Skip to content

Instantly share code, notes, and snippets.

John Nunemaker jnunemaker

Block or report user

Report or block jnunemaker

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
jnunemaker / gist:468109
Created Jul 8, 2010 — forked from jseifer/gist:468075
rvm version and git branch/dirtyness in prompt
View gist:468109
function __git_dirty {
git diff --quiet HEAD &>/dev/null
[ $? == 1 ] && echo "!"
function __git_branch {
__git_ps1 "(%s)"
function __my_rvm_ruby_version {
jnunemaker / oauth2_example.rb
Created Apr 22, 2010 — forked from technoweenie/oauth2_example.rb
oauth2, sinatra, faraday
View oauth2_example.rb
# see
require 'rubygems'
require 'sinatra'
require 'oauth2'
require 'json'
class ConnectionLogger < Faraday::Middleware
def call(env)
env[:response].on_complete do |env|
puts "RESULT: #{env[:status]}\n#{env[:body]}"
jnunemaker / mg
Created Mar 30, 2010 — forked from defunkt/gemspec
simple gemspec generator
View mg
#!/usr/bin/env ruby
# Usage: generate a blank gemspec, for defunkt
abort "pass a name" unless name = ARGV[0]
date ='%Y-%m-%d')
puts <<spec do |s| = "#{name}"
s.version = "0.1.0"
jnunemaker / application.js
Created Mar 3, 2010 — forked from bkeepers/application.js
browser cookie timezone stuff
View application.js
jQuery(function() {
$.cookie('tz', (new Date()).getTimezoneOffset());
View gist:311068
require "rack/openid"
require "warden"
use Rack::OpenID
use Warden::Manager do |manager|
Warden::Strategies.add(:openid) do
def authenticate!
if resp = env["rack.openid.response"]
case resp.status
when :success
View url_dsl.rb
require 'open-uri'
# url dsl -- the ultimate url dsl!
# You just can't beat this:
# $ irb -r url_dsl
# >> include URLDSL
# => Object
# >>
jnunemaker / gist:217362
Created Oct 24, 2009 — forked from lukesutton/gist:107966
example of warden with sinatra
View gist:217362
Warden::Manager.serialize_into_session{|user| }
Warden::Manager.serialize_from_session{|id| User.get(id) }
Warden::Manager.before_failure do |env,opts|
# Sinatra is very sensitive to the request method
# since authentication could fail on any type of method, we need
# to set it for the failure app so it is routed to the correct block
View Tests Is Wrong
In response to all the responses to:
You should never do this in a source file included with your library,
app, or tests:
require 'rubygems'
The system I use to manage my $LOAD_PATH is not your library/app/tests
View gist:214858
# Example from Rick Olson's Sparklines middleware
module Rack
class Sparklines
def initialize(app, options = {})
@app, @options = app, options
def call(env)
if env['PATH_INFO'][@options[:prefix]] == @options[:prefix]
jnunemaker / result.txt
Created Oct 19, 2009 — forked from semanticart/result.txt
troubleshooting mongo mapper issue for someone
View result.txt
$ ruby test_custom_data.rb
Loaded suite test_custom_data
Finished in 0.018501 seconds.
1) Failure:
test_creating_a_thing_with_a_foo(MyTest) [test_custom_data.rb:58]:
<"--- !ruby/object:Foo \nfirst: 1st\nsecond: 2nd\n"> expected but was
<#<Foo:0x1023a5ce8 @first="1st", @second="2nd">>.
You can’t perform that action at this time.