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 / 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 / interpolate.js
Created March 8, 2011 19:04
javascript string interpolation
String.prototype.interpolate = function(object) {
return this.replace(/#{([\w0-9]+)}/g, function(val, match) {
return object[match];
})
}
String.prototype.evilInterpolate = function() {
return this.replace(/#{([\w0-9]+)}/g, function(val, match) {
return eval(match);
});
@nakajima
nakajima / hp
Created January 18, 2011 18:38
heroku production command wrapper thing
#!/usr/bin/env ruby
require 'readline'
loop do
command = Readline.readline('> ')
command == "exit" && exit
puts "heroku #{command} --remote production"
system("heroku #{command} --remote production")
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}")
@nakajima
nakajima / slogan
Created November 18, 2010 18:33
Prints advertising slogans to the command line. Awesome
#!/usr/bin/env ruby
# USAGE
#
# Install the nokogiri gem by running (it might need sudo):
#
# $ gem install nokogiri
#
# Get a random slogan:
#
# $ slogan
>> 15.minutes.class
=> Fixnum
>> Object.instance_method(:class).bind(15.minutes).call
=> ActiveSupport::Duration
@nakajima
nakajima / remote.rake
Created November 8, 2010 16:38
bad idea
require 'open-uri'
desc "Run a remote script from ENV['REMOTE_URL']"
task :remote => :environment do
instance_eval(open(ENV['REMOTE_URL']).read)
end