h1. Sublime Text 2 - Useful Shortcuts (Mac OS X)
h2. General
- ⌘T go to file
- ⌘⌃P go to project
- ⌘R go to methods
- ⌃G go to line
- ⌘KB toggle side bar
- ⌘⇧P command prompt
from fabric.api import env, run, sudo, local, put | |
def production(): | |
"""Defines production environment""" | |
env.user = "deploy" | |
env.hosts = ['example.com',] | |
env.base_dir = "/var/www" | |
env.app_name = "app" | |
env.domain_name = "app.example.com" | |
env.domain_path = "%(base_dir)s/%(domain_name)s" % { 'base_dir':env.base_dir, 'domain_name':env.domain_name } |
# Functional programming babysteps :) | |
# This Proc returns a "stringified" version of the object you passed it. | |
# Example: | |
# | |
# h = Hash[1,2,3,4,5,[8,9,{:age => 90},[[[[60,{"a" => "gho"}]]],{[:what, 0] => [4.0 => 88.7]}]]]4.0 => 88.7]}]]] | |
# => {1=>2, 3=>4, 5=>[8, 9, {:age=>90}, [[[[60, {"a"=>"gho"}]]], {[:what, 0]=>[{4.0=>88.7}]}]]} | |
# stringit[h] | |
#=> {"1"=>"2", "3"=>"4", "5"=> ["8","9",{"age"=>"90"},[[[["60", {"a"=>"gho"}]]], {["what", "0"]=>[{"4.0"=>"88.7"}]}]]} | |
stringit = Proc.new do |v| |
# ~/.bash_login | |
export PATH="/usr/local/bin:$PATH" |
h1. Sublime Text 2 - Useful Shortcuts (Mac OS X)
h2. General
How to get rid of those pesky
WARNING: Nokogiri was built against LibXML version X, but has dynamically loaded Z
warnings on Mac OS X (Mountain) Lion:
gem uninstall nokogiri libxml-ruby
brew update
brew install libxml2 --with-xml2-config
brew install libxslt
gem install nokogiri -- --with-xml2-include=/usr/local/opt/libxml2/include --with-xml2-lib=/usr/local/opt/libxml2/lib --with-xslt-dir=/usr/local/opt/libxslt
# application_helper.rb | |
# Dynamically set the current navigation item to "active". | |
# Takes query params into account by default. | |
# Passing in nil for query_params ignores query params. | |
# Based on http://stackoverflow.com/a/8552816/545017 | |
# Returns true when path is the active (current) path | |
def active_path?(path, include_query_params = true) | |
if include_query_params | |
current_params = params.keep_if { |key, value| !["action", "controller", "id"].include? key } |
# include from an initializer | |
module HstoreAccessor | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
module ClassMethods | |
def hstore_accessor(hstore_attribute, *keys) | |
Array(keys).flatten.each do |key| |
$ vi /root/.profile
PATH=/opt/bin:/opt/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/syno/sbin:/usr/syno/bin:/usr/local/sbin:/usr/local/bin
$ ln -s /opt/bin/rdiff-backup-2.6 /usr/bin/rdiff-backup
$ ln -s /opt/bin/rdiff-backup-statistics-2.6 /usr/bin/rdiff-backup-statistics