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
# autoload concerns | |
module YourApp | |
class Application < Rails::Application | |
config.autoload_paths += %W( | |
#{config.root}/app/controllers/concerns | |
#{config.root}/app/models/concerns | |
) | |
end | |
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
require 'rubygems' | |
require 'mechanize' | |
agent = Mechanize.new | |
page = agent.get('http://bigbangtrans.wordpress.com/') | |
page.links.select {|l| l.text =~ /^Series/}.each do |link| | |
puts link.text | |
sub_page = link.click |
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
// Fabonacci using recursion and non-recursion | |
fib := method(k, | |
first := 0 | |
sum := 1 | |
for(i, 1, k - 1, tmp := sum;sum := sum + first;first := tmp) | |
sum | |
) | |
for(i, 1, 10, fib(i) println) | |
"" println |
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
{tony}[1.9.3] ~ ➭ HOMEBREW_MAKE_JOBS=1 VERBOSE=1 brew install macvim 2>&1 | |
==> Downloading https://github.com/b4winckler/macvim/archive/snapshot-70.tar.gz | |
Already downloaded: /Library/Caches/Homebrew/macvim-7.4-70.tar.gz | |
tar xf /Library/Caches/Homebrew/macvim-7.4-70.tar.gz | |
==> ./configure --with-features=huge --enable-multibyte --with-macarchs=x86_64 --enable-perlinterp --enable-rubyinterp --enable-tclinterp --with-ruby-command=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby --with-tlib=ncurses --with-compiledby=Homebrew --with-local-dir=/usr/local --enable-cscope --enable-pythoninterp=yes | |
./configure --with-features=huge --enable-multibyte --with-macarchs=x86_64 --enable-perlinterp --enable-rubyinterp --enable-tclinterp --with-ruby-command=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby --with-tlib=ncurses --with-compiledby=Homebrew --with-local-dir=/usr/local --enable-cscope --enable-pythoninterp=yes | |
configure: creating cache auto/config.cache | |
checking whether make set |
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
// https://developers.google.com/chrome-developer-tools/docs/shortcuts | |
// Control | |
Inspect elements: command+option+i | |
Inspect elements and open console: command+option+j | |
Select element: command+shift+c | |
Next panel: command+] | |
Previous panel: command+[ | |
// Search |
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
brew update | |
brew versions FORMULA | |
cd `brew --prefix` | |
git checkout HASH Library/Formula/FORMULA.rb # use output of "brew versions" | |
brew install FORMULA | |
brew switch FORMULA VERSION | |
git checkout -- Library/Formula/FORMULA.rb # reset formula | |
## Example: Using Subversion 1.6.17 | |
# |
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
$ rake middleware | |
use ActionDispatch::Static | |
- servers static files under "public" directory | |
use Rack::Lock | |
- locks the rest of the application to a single thread | |
use #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x007fcc36ff3c00> | |
- flushes memory based store used internally by Rails.cache |
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
# #!/usr/bin/env ruby | |
snippet #! | |
#!/usr/bin/env ruby | |
# New Block | |
snippet =b | |
=begin rdoc | |
${1} | |
=end | |
snippet y |
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
# .erb and .rhmtl files | |
# Includes html.snippets | |
# Rails ***************************** | |
snippet rc | |
<% ${1} %> | |
snippet rce | |
<%= ${1} %>${2} | |
snippet % |
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
class AddAddressToEvent < ActiveRecord::Migration | |
def up | |
add_column :events, :address, :string, :after => :lat | |
Event.reset_column_information | |
say_with_time "Update each event, which will result in all events to update their address" do | |
Event.find_each { |event| event.save! } | |
end | |
end |
OlderNewer