Skip to content

Instantly share code, notes, and snippets.

@ancap
ancap / gist:7616904
Last active December 29, 2015 04:48
Ruby on Rails: helpful commands

Watch logs:

tailf /home/luna/www/myapp/log/production.log
tailf /home/luna/www/myapp/log/development.log

Debug object:

puts variable.inspect
@ancap
ancap / gist:7616833
Last active December 29, 2015 04:39
Ruby on Rails "Hellow World" app.

Run:

rails g controller StaticPages index

In config/routes.rb add:

root "static_pages#index"

###Show variable contents from controller in view### ####Controller####

@ancap
ancap / gist:7412407
Last active April 6, 2017 00:51
Nginx debug

#Nginx debug# Use strace. First, you need to detect PID of nginx process:

# ps ax | grep nginx
25043 ?        Ss     0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
25044 ?        S      0:02 nginx: worker process

Ok, so 25044 is the worker process. Now, we trace it:

# strace -p 25044 2>&1 | grep gz
@ancap
ancap / gist:7412315
Last active December 28, 2015 00:19
stat("/home/luna/www/myapp/public/", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
stat("/home/luna/www/myapp/public/assets/application-58c7c0e35a67f189e19b8c485930e614.css", {st_mode=S_IFREG|0664, st_size=0, ...}) = 0
open("/home/luna/www/myapp/public/assets/application-58c7c0e35a67f189e19b8c485930e614.css.gz", O_RDONLY|O_NONBLOCK) = 11
stat("/home/luna/www/myapp/public/assets/application-67fb624685eb5c3c2d8351122ac368a1.js", {st_mode=S_IFREG|0664, st_size=106238, ...}) = 0
open("/home/luna/www/myapp/public/assets/application-67fb624685eb5c3c2d8351122ac368a1.js.gz", O_RDONLY|O_NONBLOCK) = 12
# /home/luna/www/myapp/public/assets/application-67fb624685eb5c3c2d8351122ac368a1.js deleted
stat("/home/luna/www/myapp/public/", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
stat("/home/luna/www/myapp/public/assets/application-58c7c0e35a67f189e19b8c485930e614.css", {st_mode=S_IFREG|0664, st_size=0, ...}) = 0
open("/home/luna/www/myapp/public/assets/application-58c7c0e35a67f189e19b8c485930e614.css.gz", O_RDONLY|O_NONB
@ancap
ancap / gist:7396147
Last active December 27, 2015 21:59

#VirtualBox tips and tricks# ##Shrink disk size## In Total Commander browse to c:\Program Files\Oracle\VirtualBox and run cmd in bottom command line. Then in cmd:

VBoxManage modifyhd "d:\VirtualBox\VMs\Ubuntu 12.04 LTS amd64\Ubuntu 12.04 LTS amd64.vdi" compact

source

% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 184 100 184 0 0 106 0 0:00:01 0:00:01 --:--:-- 147
100 19527 100 19527 0 0 7715 0 0:00:02 0:00:02 --:--:-- 35754
Turning on auto dotfiles mode.
Please read and follow further instructions.
Downloading RVM branch stable
Downloading https://github.com/wayneeseguin/rvm/archive/stable.tar.gz to rvm-stable.tgz.
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
@ancap
ancap / gist:7385992
Last active March 14, 2016 22:16
Ruby on Rails installation on Ubuntu 12.04 LTS + Nginx + Puma

#Ruby on Rails installation on Ubuntu 12.04 LTS + Nginx + Puma# ##Adding new user## Create new user:

sudo useradd -G sudo -m -s /bin/bash luna

blog.lunarlogic.io

Change password: