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
Get the .dmg | |
There is a one-click installer available for PostgreSQL on Mac OS X. It packages the database up as a .dmg file. It is available here: http://www.enterprisedb.com/products/pgdownload.do#osx | |
Edit your PATH | |
The .dmg does the installation and setup, but it doesn't alter your PATH variable to include the PostgreSQL tools. To do this, edit | |
~/.bash_profile | |
and add the lines |
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
def hash_args(options = {}) | |
defaults = {:a => 'b', :c => 'd'} | |
defaults.merge!(options) | |
puts defaults | |
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
Fixnum.send(:define_method, :mod3or5?) { self % 3 == 0 || self % 5 == 0} | |
print (1..1000).select(&:mod3or5?).inject(:+) |
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
def load_rubygems | |
min_version = '1.3.2' | |
require 'rubygems' | |
unless rubygems_version >= min_version | |
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.) | |
exit 1 | |
end | |
rescue LoadError => e | |
$stderr.puts e |
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 String | |
def !@ | |
return "fail" if self == "win" | |
return "win" if self == "fail" | |
return !self.to_bool | |
end | |
def to_bool | |
return true if self == "true" | |
return false if self == "false" |
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
def index | |
@filialen = Filiale.all | |
respond_to do |format| | |
format.html # index.html.erb | |
format.json { render :json => @filialen} | |
end | |
end | |
class Filiale |
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 Module | |
def classes | |
constants.select {|c| const_get(c).is_a? Class}.map {|c| const_get(c)} | |
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
CandidatesCode.all :conditions => {:code_id => ary}, :having => ["COUNT(*) > ?", count], :group_by => "candidate_id" |
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 Foo | |
attr_accessor :bar | |
def baz | |
self.bar = "test" | |
end | |
end | |
class Buzz | |
extend(Foo) |
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
$('.jaxy').live('submit', function() { | |
var form = this; | |
var callback = function(data) { | |
$(form).stopLoadingSpinner(); | |
$('.errors').innerHTML = data.errors | |
}; | |
$(form).startLoadingSpinner; | |
$.post(form.action, $(form).serialize(), callback, "json"); | |
return false; | |
}); |