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 'active_support/concern' | |
module Foo | |
extend ActiveSupport::Concern | |
included do | |
class_eval do | |
def self.method_injected_by_foo | |
# ... | |
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
# Don't hide branches in your logic, like this: | |
def foo | |
return bar if thing | |
stuff | |
end | |
# Do this instead: | |
def foo | |
if thing | |
bar |
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
javascript:(function()%7Bdocument.getElementById('content').style.display='block';document.getElementById('mw-sopaOverlay').style.display='none'%7D)() |
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
[selection sortedArrayUsingComparator:^(MKShape *a, MKShape *b) { | |
float leftEdgeA = NSMinX([a frame]); | |
float leftEdgeB = NSMinX([b frame]); | |
if (leftEdgeA < leftEdgeB) { | |
return (NSComparisonResult)NSOrderedAscending; | |
} else if (leftEdgeA > leftEdgeB) { | |
return (NSComparisonResult)NSOrderedDescending; | |
} else { | |
return (NSComparisonResult)NSOrderedSame; |
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
#!/bin/bash | |
kill $* |
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 'benchmark' | |
class App | |
def call(env) | |
[200, {'Content-Type' => 'text/html'}, ['ohai']] | |
end | |
end | |
@object = App.new | |
@lambda = lambda do |env| |
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
# Time loading files | |
if ENV["TIMING"] == "1" | |
require 'benchmark' | |
module Kernel | |
class << self | |
def require_with_timing(file) | |
puts Benchmark.measure("require #{file}") { | |
require_without_timing(file) | |
}.format("%n: %t %r") | |
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
git for-each-ref --format="%(refname)" refs/heads | while read f; do echo -n $f " "; git log -n 1 --pretty=tformat:%cd; done |
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 User < ActiveRecord::Base | |
end | |
# doesn't work: | |
class Item < ActiveRecord::Base | |
belongs_to :user | |
accepts_nested_attributes_for :user | |
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
# rubygems | |
require 'rubygems' | |
# active_support from rails | |
require 'active_support' unless ENV['RAILS_ENV'] | |
# wirble -- colors + more | |
require 'wirble' | |
module Wirble::Colorize::Color | |
class << self |