Skip to content

Instantly share code, notes, and snippets.

/**
IMPORTANT: Requires this version of jquery
until 1.3.3 comes out http://gist.github.com/186325
ALSO: This is very dirty still and has not been
abstracted for use. It is just solving our immediate problems.
Use cases that must pass (and should be tested someday):
* Clicking on links updates layout
* Click around a bit and then use back/forward buttons
/**
IMPORTANT: Requires this version of jquery
until 1.3.3 comes out http://gist.github.com/186325
ALSO: This is very dirty still and has not been
abstracted for use. It is just solving our immediate problems.
Use cases that must pass (and should be tested someday):
* Clicking on links updates layout
* Click around a bit and then use back/forward buttons
/*!
* jQuery JavaScript Library v1.3.3pre
* http://jquery.com/
*
* Copyright (c) 2009 John Resig
* Dual licensed under the MIT and GPL licenses.
* http://docs.jquery.com/License
*
* Date: 2009-07-16 03:32:39 -0400 (Thu, 16 Jul 2009)
* Revision: 6447
@jnunemaker
jnunemaker / result.txt
Created October 19, 2009 02:20 — forked from semanticart/result.txt
troubleshooting mongo mapper issue for someone
$ ruby test_custom_data.rb
Loaded suite test_custom_data
Started
.F..
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">>.
# Example from Rick Olson's Sparklines middleware
# http://github.com/technoweenie/rack-sparklines/blob/master/lib/rack-sparklines.rb
module Rack
class Sparklines
def initialize(app, options = {})
@app, @options = app, options
end
def call(env)
if env['PATH_INFO'][@options[:prefix]] == @options[:prefix]
In response to all the responses to:
http://twitter.com/rtomayko/status/1155906157
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
@jnunemaker
jnunemaker / gist:217362
Created October 24, 2009 04:07 — forked from lukesutton/gist:107966
example of warden with sinatra
Warden::Manager.serialize_into_session{|user| user.id }
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
env['REQUEST_METHOD'] = "POST"
end
@jnunemaker
jnunemaker / application_controller.rb
Created November 8, 2009 01:11
simple auth using twitter gem and sign in with twitter
class ApplicationController < ActionController::Base
include TwitterAuth::Helpers
helper :all
protect_from_forgery
rescue_from Twitter::Unauthorized, :with => :force_sign_in
private
def force_sign_in(exception)
@jnunemaker
jnunemaker / db_eval.rb
Created November 10, 2009 15:09
db eval to search in array of hashes with mongo
require 'pp'
require 'rubygems'
require 'mongo_mapper'
require 'benchmark'
MongoMapper.database = 'testing'
class Foo
include MongoMapper::Document
@jnunemaker
jnunemaker / push_unique.rb
Created November 18, 2009 05:18
push unique in mongodb
require 'pp'
require 'rubygems'
require 'mongo_mapper'
MongoMapper.database = 'testing'
class Site
include MongoMapper::Document
key :domain, String
key :authorizations, Array