Skip to content

Instantly share code, notes, and snippets.

@azhao1981
azhao1981 / ruby_tips.rb
Created February 22, 2012 05:57
ruby tips
require_relative '../../spec_helper'
require (File.expand_path('./../../../spec_helper', __FILE__))
env_value = ENV[env_name]
env_value = env_value.split(";")
require pathname realpath
name = %w{ zhangsan lisi wangwu zhaoliu galeki lyanry liulanger xiaosl tom nick bara}
name.find_all{|n| n.length == 4} #过滤
@azhao1981
azhao1981 / zsh.md
Created March 23, 2012 03:22 — forked from tsabat/zsh.md
Getting oh-my-zsh to work in Ubuntu

Getting zsh to work in ubuntu is weird, since sh does not understand the source command. So, you do this to install zsh

wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh

and then you change your shell to zsh

chsh -s `which zsh`

and then restart

@azhao1981
azhao1981 / gist:2183029
Created March 24, 2012 13:45
rails tips
render "form",:locals => { :ad => ad }
@azhao1981
azhao1981 / gist:2192638
Created March 25, 2012 09:58
ruby and rails recources
The Bastards Book of Ruby http://ruby.bastardsbook.com/
Clever Algorithms http://www.cleveralgorithms.com
DS and Algos with OO Design Patterns in Ruby http://www.brpreiss.com/books/opus8/
MacRuby: The Definitive Guide http://macruby.labs.oreilly.com/
Humble Little Ruby Book http://humblelittlerubybook.com/
Programming Ruby http://ruby-doc.org/docs/ProgrammingRuby/
Read Ruby 1.9 http://ruby.runpaint.org/
Ruby Best Practices http://rubybestpractices.com/
Ruby on Rails Tutorial Book http://railstutorial.org/book
#To install ruby-debug on Ubuntu ruby-1.9.3 you need to download from http://rubyforge.org/frs/?group_id=8883
gem install ruby_core_source
gem install archive-tar-minitar
gem install linecache19
gem install ruby-debug-base19
gem install ruby-debug19
不能用现在
@azhao1981
azhao1981 / Rakefile
Created April 28, 2012 01:15 — forked from daichirata/Rakefile
Use Pry as IRB replacement in rails 2.3.5 console
namespace :pry do
def pry_setting(args)
libs ||= []
libs << %( -r "#{RAILS_ROOT}/config/environment")
libs << " -r console_app"
libs << " -r console_with_helpers"
if args.sandbox
libs << " -r console_sandbox" if args.sandbox
puts "Loading #{ENV['RAILS_ENV']} environment in sandbox (Rails #{Rails.version})"
puts "Any modifications you make will be rolled back on exit"
data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>

kvz: "I'm recommending these Mac apps to a colleague who's losing his OSX virginity: https://gist.github.com/1372883. Anything you think I should add?"

Don't forget to look at the suggestions at the bottom, there's some cool stuff in there.

Essential

  • 1Password - password manager. intergrates with Dropbox & all main webbrowsers so you'll never lose a password again
  • Dropbox - a free 2GB folder in your homedir that stays in sync with all the devices you also install it on (linux/windows/mac/ipad/iphone/etc). Useful for backup, collaboration (share 1 folder with others), and keeping important documents with you.
  • Chrome - browsing
  • Colloquy - IRC
@azhao1981
azhao1981 / rails_rspec.md
Created March 31, 2013 03:05
rails with rspec

rails new MYAPP -T # The -T option tells rails not to include Test::Unit in Gemfile:

gem 'rspec-rails' in config/initializers/generator.rb

Rails.application.config.generators do |g| g.test_framework = :rspec end at command line:

Why!!!!!!!!!!