Skip to content

Instantly share code, notes, and snippets.

@pacovell
pacovell / Easily set the width of inputs in twitter bootstrap
Created April 12, 2012 13:33
simple_form bootstrap 2.0.x :span component
module SimpleForm
module DoneComponents
module Span
def span
if options[:span]
input_html_classes << 'input-block-level'
options[:wrapper_html] ||= {}
options[:wrapper_html][:class] ||= ""
options[:wrapper_html][:class] <<= " #{options[:span]}"
end
@pacovell
pacovell / controllers.js
Created October 25, 2011 02:56
Red in all controllers in the base dir and add them to the returned object
/**
Done. Controllers manager
Copyright (c) 2011 Done. Corporation
*/
var fs = require('fs'),
dispatch = require('dispatch'),
logger = require(process.cwd() + '/lib/loggers').get('controller');
var Controllers = function () {
var self = this,
@pacovell
pacovell / control_chain.js
Created October 25, 2011 02:54
Controller test harness for dispatch
/**
Done. Simulated control chain for testing controllers with Vows
Copyright (c) 2011 Done. Corporation
*/
var http = require('http'),
controllers = require(process.cwd() + '/lib/controllers');
var ControlChain = module.exports = function (controllerName) {
this.router = controllers.router;
this.controller = controllers[controllerName];
@pacovell
pacovell / some-resource.js
Created August 26, 2011 20:28 — forked from indexzero/some-resource.js
An example of a possible "resource" API in node.js
var util = require('util'),
resourceLib = require('our-new-resource-lib');
var SomeResource = function (options) {
resourceLib.Resource.call(this, options);
//
// Setup any other application specific state.
//
@pacovell
pacovell / resourceful_urls.js
Created July 12, 2011 16:06
Defines dynamicViewHelpers, included as per the server.js configuration also attached
module.exports = function setup() {
var fns = {},
methodName;
function makeHelperFunction(fn) {
return function(req, res) {
return fn;
};
}
@pacovell
pacovell / javascript_unquoted.rb
Created January 9, 2011 15:22
Simplest way to generate an unquoted Javascript option (for example, for a function)
class JavascriptUnquoted
def initialize(text)
@text = text
end
def to_javascript
@text
end
end