пятница, 31 октября 2014 г.

301 redirect from http to https + nginx

http://serverfault.com/questions/67316/in-nginx-how-can-i-rewrite-all-http-requests-to-https-while-maintaining-sub-dom

188down voteaccepted

Correct way in new versions of nginx

Turn out my first answer to this question was correct at certain time, but is tunred into another pitfall, to stay up to date please check Taxing rewrite pitfalls
I have been corrected by many SE users, so the credit goes to them, but more important, here is the correct code:
server {
       listen         80;
       server_name    my.domain.com;
       return         301 https://$server_name$request_uri;
}

server {
       listen         443 ssl;
       server_name    my.domain.com;

       [....]
}

четверг, 30 октября 2014 г.

SSL + Comodo + Faye

I have the comodo ssl cert and couple files. To create correct cry file:
1. Create PositiveSSL.ca_bundle:

#cat COMODORSADomainValidationSecureServerCA.crt COMODORSAAddTrustCA.crt AddTrustExternalCARoot.crt > PositiveSSL.ca-bundle

2. Add the ca_bundle to your example_com.crt:

#cat PositiveSSL.ca-bundle >> example_com.crt

And next use the new example_com.crt and example_com.key(it is your private key).

It solved the faye issue:
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

Links:

:)

вторник, 28 октября 2014 г.

Install Jenkins on Ubuntu

    cd /home;
    sudo mkdir peter
    sudo chown peter:peter peter
    sudo usermod -d /home/peter peter

Nginx + jenkins config: http://programmingintraveling.blogspot.com/2014/10/nginx-jenkinx-config.html
:)

Chown how to

chown owner-user file
chown owner-user:owner-group file
chown owner-user:owner-group directory
chown options owner-user:owner-group file

Highlight syntax into Blogger

Charlock Holmes issue

After upgrading Ubuntu to 14.04 I have problem with charlock_holmes gem

/opt/extra/apps/project/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require': libicuuc.so.48: cannot open shared object file: No such file or directory - /opt/extra/apps/project/shared/bundle/ruby/1.9.1/gems/charlock_holmes-0.7.3/lib/charlock_holmes/charlock_holmes.so (LoadError)

Solution: just delete bundled gems from project dir and run bundle.



#rm -rf /opt/extra/apps/project/shared/bundle
#bundle

Start service after reboot on Ubuntu

понедельник, 27 октября 2014 г.

Nginx + jenkins config

https://wiki.jenkins-ci.org/display/JENKINS/Running+Jenkins+behind+Nginx

server {
  listen 80;
  server_name jenkins.domain.tld;

  location / {
    proxy_pass              http://localhost:8080;
    proxy_set_header        Host $host;
    proxy_set_header        X-Real-IP $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_connect_timeout   150;
    proxy_send_timeout      100;
    proxy_read_timeout      100;
    proxy_buffers           4 32k;
    client_max_body_size    8m;
    client_body_buffer_size 128k;

  }
}

Mailx - send email from Ubuntu terminal


I believe mailx is what you're looking for.
sudo apt-get install bsd-mailx 
This will also install postfix at a minimum, and will give you a few options to set postfix up. If you have an SMTP server on your LAN, choose 'satellite system', then enter the mail domain name, and lastly the IP address of your SMTP server.
To use:
echo $MESSAGE_BODY | /bin/mail -s "$SUBJECT" "$RECIPIENT_ADDRESS"
You can also use a file for the body:
/bin/mail -s "$SUBJECT" "$RECIPIENT_ADDRESS" < /tmp/message.txt
share|improve this answer
  
It says missing postfix/main.cf file , how can i download that file –  John Apr 27 '10 at 6:15
  
When you installed mailx it should have run through the install screens for postfix.  Did it ask you which type of install, and for the mail name and relay host?  And when does it give you the error, when you run /bin/mail or when you tried to install? –  nedm Apr 27 '10 at 6:21
  
it didn't ask me anything, how can uninstall it and do that again –  John Apr 27 '10 at 6:28
  
If you have postfix set up as part of another install it sounds like it may not be configured correctly.  Try      "sudo dpkg-reconfigure postfix"  and then     "sudo /etc/init.d/postfix reload"                 –                      nedm                 Apr 27 '10 at 6:28                                                                                                  
  
If postfix isn't installed, then "sudo apt-get remove mailx" and then "sudo apt-get install mailx" and it should install postfix with the mailx package. –  nedm Apr 27 '10 at 6:31


http://serverfault.com/questions/136106/what-package-to-install-for-sending-emails-from-localhost-ubuntu

Install imagemagick on Ubuntu 14.04

sudo apt-get install libmagickwand-dev imagemagick
http://superuser.com/questions/163818/how-to-install-rmagick-on-ubuntu-10-04

понедельник, 1 сентября 2014 г.

Go to sublime 3


  1.  Install sublime 3: http://www.sublimetext.com/3
  2.  Add alias to run from terminal: http://crabonature.pl/posts/20-sublime-text-3-on-os-x-terminal

Show opened file in sidebar:

Maybe this will help, simple plugin:

goto Sublime package folder, make dir "Project Side Bar", in this folder make a file "Project Side Bar.py" put code below:
CODE: SELECT ALL
import sublime
import sublime_plugin

class SideBarListener(sublime_plugin.EventListener):
    
    def on_activated(self, view):
        view.window().run_command('reveal_in_side_bar')

Save and it's done, rest will be done out of box ;)

Cucumber run

.../Sublime Text 3/Packages/User/RubyTest.sublime-settings

{
  "check_for_rvm": true,
  "save_on_run": true,
  "run_cucumber_command": "bundle exec cucumber -rfeatures {relative_path}",
  "run_single_cucumber_command": "bundle exec cucumber -rfeatures {relative_path} -l{line_number}",

  "run_rspec_command": "bundle exec rspec {relative_path}",
  "run_single_rspec_command": "bundle exec rspec {relative_path}:{line_number}"
}

Switch between code and spec

{ "keys": ["super+period"],
      "command": "switch_between_code_and_test",
      "args": {"split_view": false},
      "context": [ { "key": "selector", "operator": "equal",
                   "operand": "source.ruby, source.rspec, text.gherkin.feature"
               } ]
  }

Delete trailing spaces

{ "keys": ["ctrl+shift+t"], "command": "delete_trailing_spaces" }

Overriding default snippets
http://maximilianhoffmann.com/posts/configuring-sublime-text-3


понедельник, 11 августа 2014 г.

Save files on AWS S3 into console

Productivity Sauce

May 20, 2010 GMT
Dmitri Popov
Amazon S3 provides unlimited storage at low prices, which makes it an ideal solution for storing backups. But to make use of it, you need a piece of software that can actually interact with Amazon S3: create buckets, list the contents of a bucket, upload and download files, etc. And aws, a simple command-line utility written in Perl, is the perfect tool for the job. You might wonder why not use a GUI-based application like Jungle Disk? For two simple reasons: as a CLI-based tool, aws is light on resources and it can be easily scripted.
Before you proceed, you should install the curl utility. On Ubuntu, you can do this using the sudo apt-get install curl command. Next, grab the latest version of the aws script:
curl timkay.com/aws/aws -o aws
Make it then executable and copy it to the /usr/bin directory:
chmod +x aws
sudo cp ~/aws /usr/bin/
Create then an .awssecret file and open it in a text editor like nano:
nano .awssecret
Enter your Amazon AWS credentials (the Access Key ID and the Secret Access Key) as follows:
1B5JYHPQCXW13GWKHAG2
2GAHKWG3+1wxcqyhpj5b1Ggqc0TIxj21DKkidjfz
Save the file and change its permissions:
chmod 600 .awssecret
aws is now ready to go. To create a bucket for your backup use the aws mkdir command (replacingBUCKET with the actual name):
aws mkdir BUCKET
Next, create a tarball of the directory you want to back up using the tar tool:
tar -pvczf tmp/dir.tar.gz /path/to/dir
Finally, upload the created archive to the created bucket:
aws put BUCKET/dir.tar.gz /path/to/dir.tar.gz
The best part is that you don't have to do this manually every time you want to back up a certain directory. Here is a sample script that backs up photos stored on the local hard disk:
#!/bin/bash
cd /home/user/
tar -pvczf Photos.tar.gz Photos
aws put BUCKET/Photos.tar.gz Photos.tar.gz

Tweak the script to your liking, schedule it using cron, and your perfect Amazon S3-based backup solution is ready to go.

Взято из http://www.linux-magazine.com/Online/Blogs/Productivity-Sauce/Perfect-Backup-Solution-with-Amazon-S3-and-aws