Skip to content

Instantly share code, notes, and snippets.

View lgmkr's full-sized avatar
🏠
Working from home

Oleh Makarov lgmkr

🏠
Working from home
View GitHub Profile
Boot2Docker-cli version: v1.7.1
Git commit: 8fdc6f5
docker: 1.7.1, build 786b29d
boot2docker ssh
sudo curl -o /var/lib/boot2docker/profile https://gist.githubusercontent.com/garthk/d5a17007c277aa5c76de/raw/3d09c77aae38b4f2809d504784965f5a16f2de4c/profile
sudo halt
#maybe reboot macosx
#reboot(powerof) boot2docker vm manualy in VM GUI
boot2docker up

iTerm2 – Useful Shortcuts (Mac OS X)

with a hat tip to Sublime Text 2 Shortcuts

The Awesome

⌘; autocomplete
⌘⌥B instant replay
⌘⌥E search across all tabs

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create droplet of your liking (ubuntu 12.10 x32)

ssh to root in terminal with your server ip

ssh root@123.123.123.123

Add ssh fingerprint and enter password provided in email

module HashConverter
class << self
def to_underscore hash
convert hash, :underscore
end
def to_camel_case hash
convert hash, :camelize, :lower
end
def convert obj, *method
case obj
@lgmkr
lgmkr / gist:5357725
Created April 10, 2013 19:32
generate UUID in ruby
::uuid generates a v4 random UUID (Universally Unique IDentifier).
p SecureRandom.uuid #=> "2d931510-d99f-494a-8c67-87feb05e1594"
p SecureRandom.uuid #=> "bad85eb9-0713-4da7-8d36-07a8e4b00eab"
p SecureRandom.uuid #=> "62936e70-1815-439b-bf89-8492855a7e6b"
The version 4 UUID is purely random (except the version). It doesn’t contain meaningful information such as MAC address, time, etc.
@lgmkr
lgmkr / gist:5314988
Created April 4, 2013 22:38
ruby global variables
$: contains an array of paths that your script will search through when using require
>>$:
#=> [".", "/Users/path/.ruby", "/test/path"]
$0 script name
$* shorter for ARGV
$? returns the exit status of the last child process to finish
>>`pwd`
@lgmkr
lgmkr / gist:5221310
Created March 22, 2013 13:35
Test password strength--use google's own account password API from 0 to 4
https://www.google.com/accounts/RatePassword?Passwd=mypwd
@lgmkr
lgmkr / gist:5143460
Last active December 14, 2015 20:19
ctags for vim
ctags -R --exclude=.git --exclude=log * ~/.rvm/gems/<your ruby@gems>
@lgmkr
lgmkr / gist:5098799
Created March 6, 2013 11:50
Method Chaining for instance and class
class Person
def name(value)
@name = value
self
end
def age(value)
@age = value
self
end
def introduce
@lgmkr
lgmkr / gist:5098621
Created March 6, 2013 11:13
semicolon(;) in ruby
my_name = "aa"; print my_name
#==>aa