понедельник, 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 г.

пятница, 21 декабря 2012 г.

rails 3 rvm console: cannot load such file -- readline

After installing rvm on Ubuntu sometime I have error when I try to go app console:


current$ bundle exec rails c staging
/home/ubuntu/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/irb/completion.rb:9:in `require': cannot load such file -- readline (LoadError)
from /home/ubuntu/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/irb/completion.rb:9:in `'
from /var/www/apps/staging/newage/shared/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/commands/console.rb:3:in `require'
from /var/www/apps/staging/newage/shared/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/commands/console.rb:3:in `'
from /var/www/apps/staging/newage/shared/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/commands.rb:38:in `require'
from /var/www/apps/staging/newage/shared/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/commands.rb:38:in `'
from script/rails:6:in `require'
from script/rails:6:in `
'


Solution:

1. rvm requirements

Requirements for Linux "Ubuntu 12.10"

NOTE: 'ruby' represents Matz's Ruby Interpreter (MRI) (1.8.X, 1.9.X)
             This is the *original* / standard Ruby Language Interpreter
      'ree'  represents Ruby Enterprise Edition
      'rbx'  represents Rubinius

bash >= 4.1 required
curl is required
git is required (>= 1.7 for ruby-head)
patch is required (for 1.8 rubies and some ruby-head's).

To install rbx and/or Ruby 1.9 head (MRI) (eg. 1.9.2-head),
then you must install and use rvm 1.8.7 first.

Additional Dependencies:
# For Ruby / Ruby HEAD (MRI, Rubinius, & REE), install the following:
  ruby: /usr/bin/apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config

# For JRuby, install the following:
  jruby: /usr/bin/apt-get install curl g++ openjdk-6-jre-headless
  jruby-head: /usr/bin/apt-get install ant openjdk-6-jdk

# For IronRuby, install the following:
  ironruby: /usr/bin/apt-get install curl mono-2.0-devel

# For Opal, install the following:
  opal: /usr/bin/apt-get install nodejs npm


2.  sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config

3.  Install readline:

cd  .rvm/src/ruby-1.9.3-p327/ext/readline

ruby extconf.rb
make
sudo make install


The solution from there: http://stackoverflow.com/questions/4922700/ruby-1-9-2-and-rails-3-cannot-open-rails-console

Good luck!

пятница, 13 июля 2012 г.

Moving Mysql database folder to mounted disk

Use the instructions bellow: http://article.my-addr.com/?show=how_to_move_the_mysql_data_directory-ubuntu_change_datadir_issue


How to move the mysql data directory in ubuntu

  • Open the terminal
  • Stop MySQL with the command
    /etc/init.d/mysql stop
  • Copy the existing data directory (which is located in /var/lib/mysql) using the command
    cp -R -p /var/lib/mysql /usr/new_datadir
  • All you need are the data files. Delete the others with the command
    rm /usr/new_datadir

    (You will get a message about not being able to delete some directories, but do not care about them)
  • Edit the MySQL configuration file with the command
    vim /etc/mysql/my.cnf
  • Find the entry for datadir, change the path to the new data directory.
  • But there is a trick involved here. Ubuntu uses some security software called AppArmor that specifies the areas of your filesystem applications are allowed to access. Unless you modify the AppArmor profile for MySQL, you'll never be able to restart MySQL with the new datadir location.
  • In the terminal, enter the command
    vim /etc/apparmor.d/usr.sbin.mysqld
  • Copy the lines beginning with /var/lib/mysql
  • Comment out the originals with hash marks (#),(in my way I just added new lines NOT COMMENT) and paste the lines below the originals.
  • Now change /var/lib/mysql in the two new lines with /usr/new_datadir. Save and close the file.
  • Restart the AppArmor profiles with the command
    /etc/init.d/apparmor restart
  • Restart MySQL with the command
    /etc/init.d/mysql restart
  • MySQL should now start without any errors and your data will be stored in the new location. See also article Linux Ubuntu move mysql database to other path in 5 minutes


четверг, 12 июля 2012 г.

Install Jungledisk on the ubuntu

1. Download server and management files from https://www.jungledisk.com/downloads/business/server/linux/.


To check bit version of your system:


uname -a
Result for 32-bit Ubuntu:
Linux discworld 2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11 03:31:50 UTC 2011 i686 i686i386 GNU/Linux
whereas the 64-bit Ubuntu will show:
Linux discworld 2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11 03:31:50 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux



I prefer .deb for my 64-bit Ubuntu


wget https://downloads.jungledisk.com/jungledisk/junglediskserver_316-0_amd64.deb
wget https://downloads.jungledisk.com/jungledisk/junglediskservermanagement_316-0_amd64.deb


2. Install management first and then server deb:
sudo dpkg -i package_file.deb
or to delete
sudo dpkg -r package_file.deb
to see the list of deb packages:
dpkg --get-selections 


So I done:
sudo dpkg -i junglediskservermanagement_316-0_amd64.deb
sudo dpkg -i junglediskserver_316-0_amd64.deb


3. Then you need to set up licence key:
cp /usr/local/share/junglediskserver/junglediskserver-license-EXAMPLE.xml  /etc/jungledisk/junglediskserver-license.xml
And set up license key in the junglediskserver-license.xml file.


4. Restart the service:
sudo service junglediskserver restart


!!!