Skip to content

Instantly share code, notes, and snippets.

@rentalcustard
rentalcustard / repo.rb
Last active August 29, 2015 14:01 — forked from ernie/repo.rb
class PersonRepository < Norm::PostgreSQLRepository
def named(name)
select_records(select_statement.where(:name => name)
end
def named_ordered_by_created_at(name)
select_records(select_statement.
where(:name => name).
order(:created_at, :desc))
11:30 < txus> what does "cis" mean??
11:30 < jkleske> mortice: no, definitely not.
11:30 < medk> 10:37 piman_ ➤ if you are comfortable with your birth sex/gender assignment, you are cis.
11:30 < fwg_> now we need the bot
11:32 < piman_> Just, in general, I don't like comparisons of "well, X is more diverse than Y", because it always seems to ignore some axes.
11:32 < mortice> fair
11:33 < mortice> i also don't think it's relevant; saying "berlin is more diverse than X" doesn't mean we don't have to work to improve diversity
11:33 < fwg_> well it can only be said as a subjective perception
11:33 < gkarekinian> Most meetups in Berlin are just white males
11:34 < jkleske> full ack
#if I have...
A.new(B.new(C.new(D.new)))
#is there some way (some inject sorcery?) to construct this from a list of the classes?
list = [A, B, C, D]
@rentalcustard
rentalcustard / gist:6112853
Created July 30, 2013 13:23
Show the contents of all files changed in a commit at the time of the commit
git show --name-only REVISION --pretty="format:" | while read file
do
echo $file:
git show REVISION:$file
done | cat
1.9.3p448 :007 > Resource.all.sort_by(&:average_rating)
Resource Load (0.4ms) SELECT "resources".* FROM "resources"
Rating Load (0.3ms) SELECT "ratings".* FROM "ratings" WHERE "ratings"."resource_id" = $1 ORDER BY "ratings"."id" ASC LIMIT 1 [["resource_id", 1]]
Rating Load (0.2ms) SELECT "ratings".* FROM "ratings" WHERE "ratings"."resource_id" = $1 [["resource_id", 1]]
Rating Load (0.2ms) SELECT "ratings".* FROM "ratings" WHERE "ratings"."resource_id" = $1 ORDER BY "ratings"."id" ASC LIMIT 1 [["resource_id", 2]]
Rating Load (0.2ms) SELECT "ratings".* FROM "ratings" WHERE "ratings"."resource_id" = $1 [["resource_id", 2]]
=> [#<Resource id: 2, title: nil, summary: nil, link: nil, created_at: "2013-07-29 13:53:52", updated_at: "2013-07-29 13:53:52", user_id: nil>, #<Resource id: 1, title: nil, summary: nil, link: nil, created_at: "2013-07-29 13:52:36", updated_at: "2013-07-29 13:52:36", user_id: nil>]
~> irb
1.9.3-p194 :001 > 10.0 / 0.0
=> Infinity
1.9.3-p194 :002 > 0.0 / 0.0
=> NaN
1.9.3-p194 :003 > 10 / 0
ZeroDivisionError: divided by 0
from (irb):3:in `/'
from (irb):3
from /Users/thomasstuart/.rvm/rubies/ruby-1.9.3-p194/bin/irb:16:in `<main>'
1.9.3-p194 :019 > 10.0 / 0.0
=> Infinity
1.9.3-p194 :020 > 0.0 / 0.0
=> NaN
@rentalcustard
rentalcustard / gist:5975279
Last active December 19, 2015 15:19
Rails 3 commands in rails 2
#put me in your ~/.(bash|zsh|other-posix-shell)rc
rails() {
command=$1
shift
case $command in
g|generate)
script/generate $*;;
c|console)
  • what
  • the
  • fuck
1.9.3p392 :001 > method(:include)
=> #<Method: main.include>
1.9.3p392 :002 > Module.new.method(:include)
=> #<Method: Module#include>