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
# 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
introduction
- brian
- brock
- nitobi
- phonegap
the current situation (brian)
- the device / platform matrix
- we've seen this before
@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"
@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
require 'rubygems'
require 'open-uri'
require 'hpricot'
require 'dm-core'
require 'dm-timestamps'
class Page
include DataMapper::Resource
property :id, Serial
property :url, String, :nullable=>false, :lazy=>false
<script>
function getPicture() {
navigator.camera.getPicture(getPicture_Success, null, { quality: 10 });
};
function getPicture_Success(imageData) {
alert("getpic success");
document.getElementById("test_img").src = "data:image/jpeg;base64," + imageData;
}
</script>
%w(rubygems hpricot open-uri json).each { |x| require x }
doc = Hpricot.parse(open("http://www.nhl.com/schedules/20092010.html#?navid=nav-sch-sea"))
data = (doc/'div[@class=skedDataRow]')
def parse_game_date(e)
(e/'div[@class=skedDataRow date]').innerHTML.gsub('&nbsp;',' ').strip
end
def parse_game_time(e)
// node.js with cramda syntax
// --------------------------
// cramda history for your reference:
// http://alex.dojotoolkit.org/2009/05/on-js-lambdas/
// http://james.padolsey.com/javascript/custom-javascript-with-parsescripts/
var sys = require('sys');
var http = require('http');
http.createServer(#(req, res) {
@brianleroux
brianleroux / get.js
Created November 22, 2009 06:12
Lawnchair example usage
// Get that document
people.get(me.key, function(r){
console.log(r);
});
// Returns all documents as an array to a callback
people.all(function(r){
console.log(r);
});
var store = new Lawnchair('things');
store.save({name:'brian'});
store.find('r.name == "brian"', function(r){
console.log(r);
});