Skip to content

Instantly share code, notes, and snippets.

View jergason's full-sized avatar
🦢
theft puts a parade in my walk

Jamison Dance jergason

🦢
theft puts a parade in my walk
View GitHub Profile
@jergason
jergason / gist:795259
Created January 25, 2011 17:26
DataMapper association woes
module TruckPricer
class Engine
include DataMapper::Resource
property :id, Serial, :key => true
property :name, String, :required => true
property :vin_string, String
belongs_to :price, :required => false
end
end
@jergason
jergason / gist:1041434
Created June 22, 2011 22:34
Two has-and-belongs-to-many Properties to the same model
class Comparison
include DataMapper::Resource
property :id, Serial
has n, :msruns, :through => Resource
has n, :msruns, :through => Resource
belongs_to :metric
end
class Msrun
@jergason
jergason / app.rb
Created August 10, 2011 08:37
Checking size of each request
#in top of your app.rb file
require 'sinatra'
require 'response_size'
use Rack::ResponseSize
@jergason
jergason / response_size.rb
Created August 10, 2011 14:38 — forked from rkh/response_size.rb
Checking size of each request
require 'rack'
##
# Tries to calculate size of the complete response.
# This middleware should be chained in front of everything else.
# Middleware taking care of compression, etag handling etc could
# produce wrong results.
#
# Leaves streaming intact and does work file bodies from sockets
# and files.
@jergason
jergason / gist:1173831
Created August 26, 2011 16:44
Chat server callback stuff
var storage = {
"messages": [],
"callbacks": []
};
function await_message(func) {
storage.callbacks.push(func);
}
//inside my Connect route
class Foo
include DataMapper::Resource
#ignore all the other stuff
def graph
begin
files = OtherCode::method_that_throws_exceptions
rescue
puts "rescued an error"
end
@jergason
jergason / gist:1218534
Created September 15, 2011 04:32
Gnuplot installation error
==> Installing gnuplot
==> Downloading http://downloads.sourceforge.net/project/gnuplot/gnuplot/4.4.3/gnuplot-4.4.3.tar.gz
File already downloaded in /Users/jergason/Library/Caches/Homebrew
==> ./configure --disable-debug --prefix=/usr/local/Cellar/gnuplot/4.4.3 --with-readline=/usr/local/Cellar/readline/6.2.1 --disable-wxwidgets --with-gd=/usr/local/Cellar/g
==> make install
Making install in config
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
Making install in m4
make[2]: Nothing to be done for `install-exec-am'.
@jergason
jergason / objects_in_js.js
Created October 24, 2011 22:06
Wrong way to do objects in JS?
function Test() {
this.hurp = "HURP";
this.durp = "DURP";
}
Test.prototype.publiclyDoStuff = function(foo) {
this.privatelyDoStuff(foo);
}
Test.prototype.privatelyDoStuff(foo) {
@jergason
jergason / vows-example.js
Created January 17, 2012 18:43 — forked from coolaj86/vows-example.js
Asynchronous Vows
(function () {
"use strict";
var vows = require('vows')
, suite
, batch
, helloWorld = require('./index')
, assert = require('assert')
, request = require('ahr2')
, createJoin = require('join')
@jergason
jergason / gist:1742478
Created February 5, 2012 03:44 — forked from anonymous/gist:1742436
MrShake - pastebin.com/qSTY96AP
window.addEvent('domready', function() {
$('fullconfreg').addEvent('click', calculate);
$('fullconfspouse').addEvent('click', calculate);
$('fullconfregfirsttime').addEvent('click', calculate);
$('intspeechticket').addEvent('click', calculate);
$('evalticket').addEvent('click', calculate);
$('fridinnerham').addEvent('click', calculate);
$('fridinnerroastbeef').addEvent('click', calculate);
$('fridinnerturkey').addEvent('click', calculate);
$('satlunch').addEvent('click', calculate);