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

Some links

Postgress:

1. Configuration: http://www.iakovlev.org/index.html?p=1431&m=1
2. Book: http://postgresql.leopard.in.ua/html/
3. Replication: http://eax.me/postgresql-replication/

https://habrahabr.ru/post/268631/

пятница, 29 января 2016 г.

Update ruby version on Ubuntu nginx.

> rvm install ruby-2.1.8

> rvm use 2.1.8@xan --create

and

> gem install bundler

Edit nginx.cof

> sudo vi /opt/nginx/conf/nginx.conf

server{
......
   passenger_ruby /home/ubuntu/.rvm/gems/ruby-2.1.8/wrappers/ruby;
   passenger_enabled on;
   rails_env staging;
......
}

restart nginx.

среда, 14 января 2015 г.

Forward local emails to external email

Very often when you go to server via ssh you see:

You have mail.

Which you can see into /var/mail/ubuntu. Yep yo can see it on server by mutt.
Other solution is to forward it to another email which you check daily:

1. Instal mailx. To check all is ok:

#echo 'it is test' | mailx -s 'test email' 'my@email.com'

2. https://help.ubuntu.com/community/PostfixBasicSetupHowto#Per_User_.forward_Files
Add your email to the .forward file into home folder:

Per User .forward Files

Users can control their own mail delivery by specifying destinations in a file called .forward in their home directories. The syntax of these files is the same as system aliases, except that the lookup key and colon are not present.
I will illustrate an example here:
Assume that you need to forward all the mails which come to the sysadmin account to an another account. Enter the following commands:
su - sysadmin
touch .forward
Then open the .forward file
vi .forward
Add the following code:
fossedu@example.com
Remember to use email address which exists in this exercise.


Now send a mail to sysadmin and mail should come to fossedu@example.com


пятница, 2 января 2015 г.

Creating New Admin Users into CouchDB

Creating New Admin Users

Let’s do another walk through the API using curl to see how CouchDB behaves when you add admin users.
> HOST="http://127.0.0.1:5984"
> curl -X PUT $HOST/database
{"ok":true}
When starting out fresh, we can add a database. Nothing unexpected. Now let’s create an admin user. We’ll call her anna, and her password is secret. Note the double quotes in the following code; they are needed to denote a string value for the configuration API (as we learned earlier):
curl -X PUT $HOST/_config/admins/anna -d '"secret"'
""

From: http://guide.couchdb.org/draft/security.html

пятница, 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:

:)

среда, 29 октября 2014 г.

вторник, 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

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

Server time is fast?


- Usually time is only synced once upon each boot or wakeup-from-sleep

So the problem appears to be either that Ubuntu's default time server (what is it?) has the incorrect time, or Ubuntu is not setting the time automatically from the Internet.
No, Ubuntu's time server is correct, and it is setting the time automatically from it.
The problem is that is usually occurs only once upon each bootup (or to be more precise, each time a network interface is brought up - whether from shutdown, sleep or hibernation). Based on your uptime, it's safe to say it wasn't sync'd in more than a week. And your system clock is running slightly fast for some reason.

- Set up an hourly cron job to sync if you don't reboot often, or your server/desktop never goes to sleep

Your best bet is to set up a cron-job, I'd say hourly if you want super-precise time. The easiest way to do that is:
  • sudo editor /etc/cron.hourly/ntpsync
Add the following lines:
#!/bin/bash

ntpdate ntp.ubuntu.com #or your choice of server
  • save, exit and sudo chmod +x /etc/cron.hourly/ntpsync
You can put this in /etc/cron.daily instead if you would like, for once per day.


http://askubuntu.com/questions/138916/why-is-ubuntus-clock-getting-slower-or-faster/138956#138956

https://help.ubuntu.com/10.04/serverguide/NTP.html

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