Skip to content

Instantly share code, notes, and snippets.

View nakajima's full-sized avatar
💭
you can have statuses now?

Pat Nakajima nakajima

💭
you can have statuses now?
View GitHub Profile
@nakajima
nakajima / fliptable.rb
Created January 24, 2012 00:40
¯\_(ツ)_/¯
#!/usr/bin/env ruby
flips = [
'(╯°□°)╯︵ ┻━┻',
'(ノಥ益ಥ)ノ ┻━┻',
'┬──┬ ¯\_(ツ)',
'┻━┻ ︵ヽ(`Д´)ノ︵ ┻━┻',
'┻━┻ ︵ ¯\(ツ)/¯ ︵ ┻━┻',
'┬─┬ノ( º _ ºノ)',
'(ノಠ益ಠ)ノ彡┻━┻'
coffee> if true then "OK" else "UH OH"
'OK'
coffee> if false then "OK" else "UH OH"
'UH OH'
@nakajima
nakajima / after_set.rb
Created September 29, 2011 20:06
activerecord after_set callback
require "rubygems"
require "acts_as_fu"
require "test/unit"
include ActsAsFu
class ActiveRecord::Base
def self.after_set(attribute, callback)
after_save callback, :if => "#{attribute}_set?"
class_eval <<-END
it "saves cleanly from builder" do
create_${TM_FILENAME/(\w+)_spec\.rb/$1/}.should_not be_a_new_record
end
wget http://chromium.googlecode.com/files/chromedriver_mac_14.0.836.0.zip
unzip chromedriver_mac_14.0.836.0.zip
mv chromedriver /usr/local/bin/
rm -f chromedriver_mac_14.0.836.0.zip
@nakajima
nakajima / pivotaltracker.com.js
Created July 27, 2011 15:48
dotjs script to add j/k keyboard shortcuts to pivotal tracker
/******************************************************************************
.js/pivotaltracker.com.js
Get dotjs here: http://defunkt.io/dotjs
Extracted from my dotjs files: https://github.com/nakajima/nakajima-dot-js
******************************************************************************/
##
# Downloads a bunch of Goldeneye N64 videos. You're welcome.
##
require "rubygems"
require "nokogiri"
require "open-uri"
doc = Nokogiri(open("http://www.archive.org/details/GoldenEye_SecretAgent").read)
doc.at('table.fileFormats') \
.search('a') \
@nakajima
nakajima / not working
Created May 23, 2011 21:12
bizarre syntax error in staging but not in develompent
- if user_signed_in?
Welcome, #{link_to current_user.first_name, user_path(current_user)}
= link_to "Sign out", logout_path
- else
= form_for :user, :url => login_path do |f|
= f.label :email
= f.text_field :email
%br
= f.label :password
= f.password_field :password
Poundie.before do |message|
message.body.gsub! /^poundie/, "matt"
end
@nakajima
nakajima / release-gem
Created January 6, 2011 23:35
Release whatever gem exists in whatever directory you're in
#!/usr/bin/env ruby
gemspec = Dir['*.gemspec'].first
gemspec || abort("You need to have a gem spec in this directory.")
system("gem build #{gemspec}")
gemfile = Dir['*.gem'].sort.last
system("gem push #{gemfile}") && system("rm #{gemfile}")