Skip to content

Instantly share code, notes, and snippets.

View brianleroux's full-sized avatar
💚
You are now aware that you are breathing

Brian LeRoux brianleroux

💚
You are now aware that you are breathing
View GitHub Profile
(true + 1) === 2;​ ​// true
(true + true) === 2; // true
true === 2; // false
true === 1; // false
typeof null // object
null instanceof Object // false
<script src="./lib/Lawnchair.js"></script>
<script src="./lib/LawnchairAdaptorHelper.js"></script>
<script src="./lib/adaptors/DOMStorageAdaptor.js"></script>
give this a try it in Firebug:
>>> var people = new Lawnchair({adaptor:'dom'});
@brianleroux
brianleroux / irb
Created April 24, 2009 19:03 — forked from quirkey/irb
[08:48 AM:gist-99771(master)] $ irb -rubygems -r myapp.rb -r rack/test
>> app = Rack::Test::Session.new(Sinatra::Application)
=> #<Rack::Test::Session:0x17e8820 @headers={}, @app=Sinatra::Application>
>> app.get '/'
=> #<Rack::Response:0x17ad4dc @block=nil, @writer=#<Proc:0x0189f7b4@/opt/local/lib/ruby/gems/1.8/gems/rack-0.9.1/lib/rack/response.rb:24>, header{"Content-Type"=>"text/html", "Content-Length"=>"7"}, body["testing"], length7, status200
>> app.body
NoMethodError: undefined method `body' for #<Rack::Test::Session:0x17e8820>
from (irb):3
@brianleroux
brianleroux / irb
Created April 20, 2009 17:08 — forked from bmizerany/irb
blake:carealot$ irb -rubygems -r myapp.rb -r sinatra/test
irb(main):001:0> app = Sinatra::TestHarness.new(Sinatra::Application)
=> #<Sinatra::TestHarness:0x10c3d74 @app=Sinatra::Application>
irb(main):002:0> app.get '/'
=> #<Rack::MockResponse:0x10ae780 @original_headers={"Content-Type"=>"text/html", "Content-Length"=>"7"}, @status=200, @errors="", @headers={"Content-Type"=>"text/html", "Content-Length"=>"7"}, @body="testing">
irb(main):003:0> app.body
=> "testing"
# NAME: authinabox
# VERSION: 1.01 (Dec 27, 2008)
# AUTHOR: Peter Cooper [ http://www.rubyinside.com/ github:peterc twitter:peterc ]
# DESCRIPTION: An "all in one" Sinatra library containing a User model and authentication
# system for both session-based logins OR HTTP Basic auth (for APIs, etc).
# This is an "all in one" system so you will probably need to heavily tailor
# it to your own ideas, but it will work "out of the box" as-is.
# COMPATIBILITY: - Tested on 0.3.2 AND the latest rtomayko Hoboken build! (recommended for the latter though)
# - NEEDS DataMapper!
# - Less work needed if you use initializer library -- http://gist.github.com/40238
<html>
<head>
<title>XUI Flickr Example</title>
<script type="text/javascript" src="xui.js" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
x$(window).load(function(e){
// unobtrusive add behavior to thte
x$('a.fetch-image').touchstart(function(e){
var url = "http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=json&jsoncallback=?";
x$("#imagebox").xhr( url, { callback:function(){
Experiments in revision control: Curry recipe.
My personal recipe for Japanese curry, which has mutated over the years and is
now open-source thanks to github, hot damn. Some of the ingredients are not
very Japanese, but curry came to Japan from England which got it from India to
begin with, so whatever.
1.5 - 2 lbs. of meat, prefer thin-sliced beef (komagire), pork works, too.
Thin-sliced stuff is always best, but in a pinch stewing beef works. Bacon
works surprisingly well. Chicken will work, technically, but if you must,
# This method is heavily adapted from the Rails method of determining the subdomain.
require 'rubygems'
require 'sinatra'
require 'rack/request'
# We re-open the request class to add the subdomains method
module Rack
class Request
def subdomains(tld_len=1) # we set tld_len to 1, use 2 for co.uk or similar
class InvalidateCachedUnreadPostsCountsAndGenerateAllToSpeedUpLoad < ActiveRecord::Migration
def self.up
DiscussionGroupUnreadPostsCount.delete_all
all_users = User.find(:all)
all_users.in_groups_of(100) do |users|
fork do
# reconnect because forking rapes the connection pool