Skip to content

Instantly share code, notes, and snippets.

View gist:9281339
app_development=# select * from things;
id | tags
1 | {blue,yellow}
1 | {blue,red}
1 | {yellow,red}
1 | {blue}
(4 rows)
app_development=# select * from things where tags <@ '{"blue"}';
jjb / gist:10000281
Last active Aug 29, 2015
how to experiment with rails fragment cache key generation in the console
View gist:10000281
# inside rails console
include ActionController::Caching::Fragments
fragment_cache_key [User.first, "hello", :monkey, false]
# => "views/users/1-20140404193333893414000/hello/monkey/false"
jjb / gist:68b0b6a949d00360aa21
Created May 2, 2014
How to find a particular user's ActiveRecord session
View gist:68b0b6a949d00360aa21
ActiveRecord::SessionStore::Session.find_each do |session|
if ( ==["warden.user.user.key"][0][0] rescue false)
print "[#{}]"
View output
def a
raise "i am in a"
def b
puts "i am in b"
def c
View gist:14b34dc5a6a651823fe5
<a href="javascript:Intercom('show')">
Contact Support

Keybase proof

I hereby claim:

  • I am jjb on github.
  • I am johnjosephbachir ( on keybase.
  • I have a public key whose fingerprint is C0BC 5EAB 0143 0A0C 1EF7 A2F8 C0A4 21F5 E525 9F60

To claim this, I am signing this object:

Match (C:Cell) <- [*1..2] – (p:Cell) return c,p
View gist:fcda61801b54cc3f13d1
print "Fat: "
fat = gets.strip
print "Protein: "
protein = gets.strip
print "Carbohydrates: "
carbs = gets.strip
fat_calories = fat.to_f*9
View gist:2e0f8fa4fc79954888b7
➔ time sudo port install phantomjs
---> Fetching archive for phantomjs
---> Attempting to fetch phantomjs-2.0.0_0.darwin_14.x86_64.tbz2 from
---> Attempting to fetch phantomjs-2.0.0_0.darwin_14.x86_64.tbz2.rmd160 from
---> Installing phantomjs @2.0.0_0
---> Activating phantomjs @2.0.0_0
---> Cleaning phantomjs
---> Updating database of binaries
---> Scanning binaries for linking errors
---> No broken files found.