Skip to content

Instantly share code, notes, and snippets.

View joshbuddy's full-sized avatar
🤡
meow

Joshua Hull joshbuddy

🤡
meow
View GitHub Profile
module Foo
def foo
p :before
super
p :after
end
end
class Bar
def foo
p :foo
Wakupdude.controllers :dudes do
set :haml, {:format => :html5 }
# get :index do
# render "dudes/index"
# end
get :all, "/" do
@dudes = Dude.all()
render "dudes/list"
p gems.map{|g|g[/_on_(.*)/,1]}.compact.inject({}){|h,g|(h[g]||=0);h[g]+=1;h}
p gems.map{|g|g[/_for_(.*)/,1]}.compact.inject({}){|h,g|(h[g]||=0);h[g]+=1;h}
p gems.map{|g|g[/_with_(.*)/,1]}.compact.inject({}){|h,g|(h[g]||=0);h[g]+=1;h}
p gems.map{|g|g[/_in_(.*)/,1]}.compact.inject({}){|h,g|(h[g]||=0);h[g]+=1;h}
p gems.map{|g|g[/_as_(.*)/,1]}.compact.inject({}){|h,g|(h[g]||=0);h[g]+=1;h}
var HTTPParser = process.binding('http_parser').HTTPParser;
var net = require('net');
var path = require('path');
var sys = require('sys');
var Worker = require('webworker/webworker').Worker;
var VHOSTS = ['foo.bar.com', 'baz.bizzle.com'];
var WORKERS = {};
VHOSTS.forEach(function(vh) {
crapbook-pro:http_router joshua$ ruby benchmarks/rec2.rb
Results |
-------------------------------------
2 levels, static 1.845 |
4 levels, static 2.066 |
8 levels, static 2.223 |
4 levels, 1 dynamic 2.206 |
8 levels, 3 dynamic 2.714 |
4 levels, 1 greedy 2.915 |
17044
@route_set = Usher::Interface.for(:rack)
@route_set.get("/static").serves_static_from('/public/file/root')
# serves files from /public/file/root on any request starting with /static
>> Anybase::Base73ForURL.to_native((1 << 128)-1)
=> "Se'IgbSCfu$0)cMM(odbD"
>> Anybase::Base73ForURL.to_native((1 << 128)-1).size
=> 21
>> Anybase::Hex.to_native((1 << 128)-1)
=> "ffffffffffffffffffffffffffffffff"
>> Anybase::Hex.to_native((1 << 128)-1).size
=> 32
(function () {
// exports will be set in any commonjs platform.
// because the anonymous function is being called without
// a scope being set, "this" will refer to the global scope.
// In a browser, that's the window. In other JS platforms,
// it may be some other thing.
var out = typeof exports !== "undefined" ? exports : this;
crapbook-pro:emjay joshua$ node examples/nodejs/test.js
--------------------------------- RENDERED
Doing simple output
simple output
Outputting a variable passed into the template.
test title
Doing output with mixed in method, tag.
<test attr="value">
> String.prototype.markAsAwesome = function() {
> this.awesome = true;
> return this;
> }
> var s = "this is my string";
> puts(inspect(s));
< "this is my string"