This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var QueryStringParser; | |
QueryStringParser = (function() { | |
function QueryStringParser(url) { | |
var parser, _that; | |
this.query_params = {}; | |
if (!document || !document.createElement) { | |
throw 'This needs to be run in an HTML context with a document.'; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class String | |
def chunk(ct) | |
result = [] | |
dup = self.dup | |
val = dup.slice!(0..(ct-1)) | |
until val.empty? || !val do | |
result << val | |
val = dup.slice!(0..(ct-1)) | |
end | |
result |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in app/helpers/admin_form_builder.rb | |
class AdminFormBuilder < ActionView::Helpers::FormBuilder | |
#### | |
# To control classes on fields, pass in the following in your options hash | |
# :row_class => 'whatever' : this will add a class 'whatever' to the field wrapper (which is a row) | |
# :input_html => {:class => 'whatever'} : this will add all these elements to the input/textarea tag as attributes | |
# Note: if you use the field_row method, this will be ignored | |
# | |
def file_input_row(field, hint, opts = {}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
add ability to load json fixtures into jasmine | |
**/ | |
var readJsonFixtures = function() { | |
return jasmine.getJsonFixtures().proxyCallTo_('read', arguments); | |
}; | |
var preloadJsonFixtures = function() { | |
jasmine.getJsonFixtures().proxyCallTo_('preload', arguments); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.myPluginDefaults = | |
param1: 'default param1' | |
param2: [] | |
$.fn.myPlugin = (method) -> | |
inArgs = arguments | |
methods = | |
init: (options) -> | |
localSettings = $.extend({},$.myPluginDefaults, options); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def upto(arr,v); arr[0..arr.select{|x| x < v}.count] end | |
# usage | |
arr = 5.times.map{|x| 12 * (2**x)} | |
maxval = 26 | |
upto(arr,maxval) | |
# => [12,24,48] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class QueryStringParser | |
constructor: (url) -> | |
@query_params = {} | |
if !document || !document.createElement | |
throw 'This needs to be run in an HTML context with a document.' | |
parser = document.createElement('a') | |
parser.href = url | |
@url = url | |
if (parser.origin) | |
@origin = parser.origin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var jasmine = jasmine || {} | |
jasmine.getEvents = function(sel, event_name) { | |
var events = []; | |
try { | |
var evs = $$(sel)[0].getStorage().get('prototype_event_registry'); | |
events = evs.get(event_name); | |
} | |
catch(e) {} | |
return events; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'data_mapper' | |
require 'sinatra' | |
require 'sinatra/config_file' | |
disable :run | |
root = File.expand_path(File.join(File.dirname(__FILE__), '..')) | |
Dir[File.join(root,"{lib,models}/**/*.rb")].each do |file| | |
require file | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var PrototypeExtensions = { | |
data: function(elem, key, val) { | |
var DATA_REGEX = /data-(\w+)/; | |
var ii = 0; | |
var nattr = elem.attributes.length; | |
if (key && val) { | |
elem.setAttribute('data-' + key, val); | |
} | |
else { | |
for (; ii < nattr; ++ii ) { |