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 Foo | |
> def bar; 1 end | |
> alias_method :baz, :bar | |
> end | |
=> Foo | |
>> class FooTwo < Foo | |
> def bar; 2 end | |
> end | |
=> nil |
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
[user] | |
name = Brad Fults | |
email = bfults@gmail.com | |
[alias] | |
amend = commit --amend | |
co = checkout | |
st = status | |
cp = cherry-pick | |
# edit config (global, local) |
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/core_ext/hash/keys' | |
# Intended as an extension for an ActiveRecord model. It allows construction | |
# of a valid ActiveRecord object from a Hash, including proper handling of | |
# the :id attribute. | |
module ActiveRecordFromHash | |
def from_hash(hsh) | |
hsh = hsh.symbolize_keys | |
self.new.tap do |obj| |
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 Hash | |
# Intersection on hash keys (and values) that actually returns a Hash. | |
# The RHS can be an Array or a Hash. | |
# | |
# == Examples: | |
# >> hsh = {:banana => "elephant", :bar => "foo", :baz => "wuux"} | |
# >> hsh & [:bar] | |
# => {:bar=>"foo"} | |
# | |
# >> hsh & {:bar => "foo", :baz => "wuux"} |
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
08:47:28 [bfults@austin] ~$ rvm info | |
1.8: | |
system: | |
uname: "Darwin austin 10.4.0 Darwin Kernel Version 10.4.0: Fri Apr 23 18:28:53 PDT 2010; root:xnu-1504.7.4~1/RELEASE_I386 i386" | |
bash: "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)" | |
zsh: "/bin/zsh => zsh 4.3.9 (i386-apple-darwin10.0)" | |
rvm: |
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
AK | |
VT NH ME | |
WA MT ND MN NY MA | |
WI MI CT RI | |
OR ID SD IL IN OH PA NJ | |
MD DE | |
WY NE IA WV VA DC | |
CA NV UT CO KS MO KY NC | |
OK AR TN SC | |
AZ NM LA MS AL GA |
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
if (!Array.prototype.uniq) | |
{ | |
Array.prototype.uniq = function(fun) | |
{ | |
var seen = {}; | |
return this.filter(function (el) { | |
var key = typeof (fun) == "function" ? fun(el) : el; | |
var r = !seen[key]; | |
seen[key] = true; | |
return r; |
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
# The irbrc file for Brad Fults <bfults@gmail.com> | |
# | |
# Most of the code here came from http://wiki.rubygarden.org/Ruby/page/show/Irb/TipsAndTricks | |
# | |
unless self.class.const_defined? "IRB_RC_HAS_LOADED" | |
HISTFILE = "~/.irb-history" | |
MAXHISTSIZE = 100 | |
begin # ANSI codes | |
ANSI_BLACK = "\033[0;30m" |
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" | |
xmlns:fb="http://www.facebook.com/2008/fbml"> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> | |
<title>XFBML Bug</title> | |
</head> | |
<body> |
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
module Enumerable | |
def how_many_have?(method) | |
self.select {|x| x.send(method)}.count | |
end | |
alias_method :how_many_are?, :how_many_have? | |
end | |
# >> [1,2,3,4,5].how_many_are?(:even?) | |
# => 2 | |
# |