Skip to content

Instantly share code, notes, and snippets.

View jugglebird's full-sized avatar

Chris Hunter jugglebird

View GitHub Profile
@jugglebird
jugglebird / index.html
Created October 11, 2011 04:15 — forked from jeffpflueger/index.html
Experiment 1 with d3 and svgweb
<!DOCTYPE html>
<html>
<head>
<!-- SVG web to turn svg into flash for IE
This might not be working on bl.ocks.org for the following reasons:
1) MIME types not added to the bl.ocks.org webserver:
AddType text/x-component htc
AddType application/x-shockwave-flash swf
AddType image/svg+xml svg
# Factory girl, relaxed.
#
# Factory.define :user do |f|
# f.login 'johndoe%d' # Sequence.
# f.email '%{login}@example.com' # Interpolate.
# f.password f.password_confirmation('foobar') # Chain.
# end
#
# Factory.define :post do |f|
# f.user { Factory :user } # Blocks, if you must.
var inject = function(iterable, initial, func) {
var cur = initial
for(var i = 0;i < iterable.length;i++) {
cur = func(cur, iterable[i])
}
return cur
}
var map = function(arr, func) {
return inject(arr, [], function(memo, val) {
class Report < ActiveRecord::Base
%w[hits uniques].each { |const| const_set(const.upcase, const) }
end
>> "day_threshold".camelize.constantize
=> DayThreshold
>> "day_threshold".camelize.constantize.new
=> #<DayThreshold:0xb7a6cbd0>
@jugglebird
jugglebird / gist:1807
Created July 23, 2008 16:22
Turning a string into a class
# Turning a string into a class.
def class_from_string(class_string)
clazz = class_string.split("::").inject(Object) { |obj, const| obj.const_get(const) }
instance = clazz.new
end