Skip to content

Instantly share code, notes, and snippets.

@frankel
frankel / gist:1059820
Created July 2, 2011 07:24
Dual monitor in Ubuntu, run script.
xrandr --newmode "1280x1024_60.00" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync
xrandr --addmode VGA-0 "1280x1024_60.00"
xrandr --output VGA-0 --mode 1280x1024_60.00
xrandr --output VGA-0 --left-of DVI-0
@frankel
frankel / gist:1759062
Created February 7, 2012 10:44
Install nokogiri with libxml2 version 2.7.8 in Mac
gem install nokogiri -- --with-xml2-include=/Users/frankelma/github/homebrew/Cellar/libxml2/2.7.8/include/libxml2 --with-xml2-lib=/Users/frankelma/github/homebrew/Cellar/libxml2/2.7.8/lib --with-xslt-dir=/Users/frankelma/github/homebrew/Cellar/libxslt/1.1.26
gem install nokogiri -- --with-xml2-include=/Users/frankelma/github/homebrew/Cellar/libxml2/2.7.8/include/libxml2
--with-xml2-lib=/Users/frankelma/github/homebrew/Cellar/libxml2/2.7.8/lib
--with-xslt-dir=/Users/frankelma/github/homebrew/Cellar/libxslt/1.1.26
rails g scaffold product name price:decimal --skip-stylesheets
rails g bootstrap:themed products -f
@frankel
frankel / gist:2469503
Created April 23, 2012 08:24
Mac profile
export PATH="/Users/frankelma/github/homebrew/bin:$PATH:/Users/frankelma/github/homebrew/Cellar/gems/bin"
export CC=/usr/bin/gcc-4.2
if [[ -s /Users/frankelma/.rvm/scripts/rvm ]] ; then source /Users/frankelma/.rvm/scripts/rvm ; fi
export GEM_HOME="/Users/frankelma/github/homebrew/Cellar/gems"
export GEM_PATH="/Users/frankelma/github/homebrew/Cellar/gems/gems"
alias ll='ls -al'
@frankel
frankel / gist:3950956
Created October 25, 2012 06:58
Find rows with some duplicate field
select field, count(*) from table group by field having count(*) >1
@frankel
frankel / gist:3957331
Created October 26, 2012 07:00
readline rbenv
http://blog.crowdint.com/2011/10/05/using-rbenv-for-managing-your-rubies.html
CONFIGURE_OPTS="--with-readline-dir=/usr/include/readline" rbenv install 1.9.3-preview1
@frankel
frankel / gist:3957423
Created October 26, 2012 07:28
rails console production
correct: RAILS_ENV=production rails console
not : rails console RAILS_ENV=production
@frankel
frankel / gist:4334906
Created December 19, 2012 06:47
Display the top 5 memory used process
ps aux | sort -nk +4 | tail
@frankel
frankel / gist:4378901
Last active December 10, 2015 04:08
ruby style guide
Ruby 1.9 偏好使用新的 lambda 字面语法。
# 差
lambda = lambda { |a, b​​| a + b }
lambda.call(1, 2)
# 好
lambda = ->(a, b) { a + b }
lambda.(1, 2)
gem install mysql2 -- --with-mysql-config=/usr/local/mysql-5.6.16-osx10.7-x86_64/bin/mysql_config