This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def a | |
'a' | |
end | |
if true | |
a = 'b' | |
end | |
puts a | |
# => 'b' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def a | |
puts 'a' | |
'a' | |
end | |
def null | |
puts 'null' | |
nil | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/init.d/* scripts always have to be run as 'root'. These scripts take care of | |
# launching processes with the right user (www-data, aptproxy, nagios ...) | |
define :monit_process, :pid_file => nil, :executable => nil, :user => 'root', :group => nil do | |
execute "monit_reload" do | |
command "/usr/sbin/monit reload" | |
end | |
template "/etc/monit/conf.d/#{params[:name]}.monitrc" do | |
source "monit_process.monitrc.erb" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For https://github.com/guard/guard/blob/master/CHANGELOG.md | |
str = File.read('CHANGELOG.md') | |
people = [] | |
str.each_line do |l| | |
found = l.match(/\[@(\w+)\]\(([\w:\/.]+)\)/) | |
if found | |
user = found[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aplay () { ssh applemini "afplay Music/$1" } | |
alist () { ssh applemini "ls Music" } | |
compctl -k "(`alist`)" aplay |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActiveAdmin.register Order do | |
# Export the current collection of items with filtering and sorting | |
# List the current collection ids | |
collection_action :export_txt do | |
render :text => collection.map { |order| order.id }.join(', ') | |
end | |
# Add a button to index page to export current collection as txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SSL Session Cache + Browser Leverage Caching | |
server { | |
ssl_session_cache shared:SSL:10m; # Reuse session => less handshakes => better perfs | |
# Proxy config ============================================================== | |
location / { | |
# Cache assets (Do NOT cache html pages as they contain AuthenticityTokens) | |
if ($request_uri ~* ^.+\.(svg|css|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2)$) { | |
add_header Cache-Control public; | |
expires max; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git-set-upstream () { | |
local branch=`git branch | grep '*' | sed 's/* //'` | |
git branch --set-upstream $branch origin/$branch | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Speed up REE | |
export RUBY_HEAP_MIN_SLOTS=1000000 | |
export RUBY_HEAP_SLOTS_INCREMENT=1000000 | |
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1 | |
export RUBY_GC_MALLOC_LIMIT=1000000000 | |
export RUBY_HEAP_FREE_MIN=500000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Press F5 to delete trailing spaces | |
map <silent> <F5> :let _s=@/<Bar>:%s/\(\S\)\s\+$/\1/e<Bar>:let @/=_s<Bar>:nohl<CR> |