Ruby: remote file access
http://viget.com/extend/make-remote-files-local-with-ruby-tempfile
MySql: Backup and Restore DB
backup: # mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql
restore:# mysql -u root -p[root_password] [database_name] < dumpfilename.sql
Ruby: Create a gem
http://rakeroutes.com/blog/lets-write-a-gem-part-one/
http://rakeroutes.com/blog/lets-write-a-gem-part-two/
MySQL: Check size of DB
SELECT table_schema 'DB Name',
round(Sum(data_length + index_length) / 1024 / 1024, 1) 'DB size in MB'
FROM information_schema.tables
GROUP BY table_schema;
Sidekiq: Start the sidekiq process
bundle exec sidekiq -e staging -d -L log/sidekiq.log
sidekiq -h
-c, –concurrency INT processor threads to use
-d, –daemon Daemonize process
-e, –environment ENV Application environment
-g, –tag TAG Process tag for procline
-i, –index INT unique process index on this machine
-p, –profile Profile all code ru...
MySQL: Create Database With User
mysql>CREATE DATABASE memcachedSample;
mysql>CREATE USER 'web20'@'localhost' IDENTIFIED BY 'web20';
mysql>GRANT ALL PRIVILEGES ON memcachedSample.* TO 'web20'@'localhost';
mysql>exit;
Ruby on Rails: Start Unicorn service
unicorn_rails -c config/unicorn.rb -D -E staging
-D flag: Start as daemon process (i.e. in background.)
-c flag: config file
-E flag: environment to run in
Linux: Find files with text
BASIC:
grep "text string to search” directory-path
EXAMPLE:
$ grep "redeem reward" /home/tom/*.txt
Linux: Compress and Archive Directory
tar -zcvf archive-name.tar.gz directory-name
The resulting .tar.gz file is actually the product of two different things, tar basically just packages a group of files into a single file bundle but doesn’t offer compression on it’s own, thus to compress the tar you’ll want to add the highly effective gzip compression. You can run these as two separate commands if you really want to, but there isn’t much need because the tar command offers the -z flag which lets you automatically gzip the tar file.