$ rails g model User
belongs_to
has_one
| # Recursively diff two hashes, showing only the differing values. | |
| # By Henrik Nyh <http://henrik.nyh.se> 2009-07-14 under the MIT license. | |
| # | |
| # Example: | |
| # | |
| # a = { | |
| # "same" => "same", | |
| # "diff" => "a", | |
| # "only a" => "a", | |
| # "nest" => { |
| # First install tmux | |
| brew install tmux | |
| # For mouse support (for switching panes and windows) | |
| # Only needed if you are using Terminal.app (iTerm has mouse support) | |
| Install http://www.culater.net/software/SIMBL/SIMBL.php | |
| Then install https://bitheap.org/mouseterm/ | |
| # More on mouse support http://floriancrouzat.net/2010/07/run-tmux-with-mouse-support-in-mac-os-x-terminal-app/ |
| #config/initializers/redis.rb | |
| require 'redis' | |
| require 'redis/objects' | |
| REDIS_CONFIG = YAML.load( File.open( Rails.root.join("config/redis.yml") ) ).symbolize_keys | |
| dflt = REDIS_CONFIG[:default].symbolize_keys | |
| cnfg = dflt.merge(REDIS_CONFIG[Rails.env.to_sym].symbolize_keys) if REDIS_CONFIG[Rails.env.to_sym] | |
| $redis = Redis.new(cnfg) | |
| Redis::Objects.redis = $redis |
| var myConfObj = { | |
| iframeMouseOver : false | |
| } | |
| window.addEventListener('blur',function(){ | |
| if(myConfObj.iframeMouseOver){ | |
| console.log('Wow! Iframe Click!'); | |
| } | |
| }); | |
| document.getElementById('YOUR_CONTAINER_ID').addEventListener('mouseover',function(){ |
As configured in my dotfiles.
start new:
tmux
start new with session name:
| #!/usr/bin/env ruby | |
| require 'rubygems' | |
| require 'eventmachine' | |
| class Server | |
| attr_accessor :connections | |
| def initialize | |
| @connections = [] |
brew install git bash-completion
Configure things:
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
| # Sample implementation of quicksort and mergesort in ruby | |
| # Both algorithm sort in O(n * lg(n)) time | |
| # Quicksort works inplace, where mergesort works in a new array | |
| def quicksort(array, from=0, to=nil) | |
| if to == nil | |
| # Sort the whole array, by default | |
| to = array.count - 1 | |
| end |