Skip to content

Instantly share code, notes, and snippets.

View workmad3's full-sized avatar

David Workman workmad3

View GitHub Profile
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
def hash_args(options = {})
defaults = {:a => 'b', :c => 'd'}
defaults.merge!(options)
puts defaults
end
Fixnum.send(:define_method, :mod3or5?) { self % 3 == 0 || self % 5 == 0}
print (1..1000).select(&:mod3or5?).inject(:+)
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
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"
def index
@filialen = Filiale.all
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @filialen}
end
end
class Filiale
class Module
def classes
constants.select {|c| const_get(c).is_a? Class}.map {|c| const_get(c)}
end
end
CandidatesCode.all :conditions => {:code_id => ary}, :having => ["COUNT(*) > ?", count], :group_by => "candidate_id"
module Foo
attr_accessor :bar
def baz
self.bar = "test"
end
end
class Buzz
extend(Foo)
$('.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;
});