Skip to content

Instantly share code, notes, and snippets.

@banker
banker / Rails MongoMapper Template.rb
Created October 27, 2009 01:41 — forked from bscofield/gist:181842
A Rails Template for using MongoMapper
# mongo_template.rb
# fork of Ben Scofield's Rails MongoMapper Template (http://gist.github.com/181842)
#
# To use:
# rails project_name -m http://gist.github.com/gists/219223.txt
# remove unneeded defaults
run "rm public/index.html"
run "rm public/images/rails.png"
run "rm public/javascripts/controls.js"
@n1k0
n1k0 / jquery.truncatable.js
Created March 9, 2010 08:35
jQuery lightweight text truncation plugin
/**
* truncatable - jQuery lightweight text truncation plugin
*
* Adapted from Philip Beel's code http://theodin.co.uk/blog/development/truncatable-jquery-plugin.html
*
* Copyright (c) 2010 Nicolas Perriault (http://prendreuncafe.com/blog/)
* Copyright (c) 2009 Philip Beel (http://www.theodin.co.uk/)
*
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@TooTallNate
TooTallNate / webfont-manual.js
Created July 29, 2010 18:20
Adds a "manual" module to the WebFontLoader JS library, to dynamically create @font-face nodes.
webfont.DomHelper.prototype.setCssStyle = function(styleNode, body) {
if (styleNode.styleSheet) {
styleNode.styleSheet.cssText = body;
} else {
styleNode.appendChild(this.document_.createTextNode(body));
}
return styleNode;
}
/**
@octplane
octplane / mongo_pubsub.rb
Created November 9, 2010 16:17
Simple Pub/Sub system using MongoDB, capped collections and tailable cursors in ruby
require 'rubygems'
require 'mongo'
module MongoPubSub
QUEUES_COLLECTION = 'queues'
class EndSubscriptionException < Exception; end
class Publisher
def initialize(queue_name, mongo_connection)
# Initialize queue collection as a capped collection
if not mongo_connection[QUEUES_COLLECTION].collection_names.include?(queue_name)
@jrburke
jrburke / apiexamples.js
Created April 7, 2011 05:50
Description of browser-friendly module APIs: AMD and Loader Plugins
//*******************************************
// Level 1, basic API, minimum support
//*******************************************
/*
Modules IDs are strings that follow CommonJS
module names.
*/
//To load code at the top level JS file,
//or inside a module to dynamically fetch
@oisin
oisin / gist:987247
Created May 23, 2011 18:34 — forked from leereilly/gist:987094
API version checking using Sinatra's before filter; supports nested resources
require 'sinatra'
# Set the version of the API being run here
#
MAJOR_VERSION = 1
MINOR_VERSION = 0
VERSION_REGEX = %r{/api/v(\d)\.(\d)}
helpers do
def version_compatible?(nums)
@WizardOfOgz
WizardOfOgz / gist:1012107
Created June 7, 2011 12:13
Save Base64-encoded images with Paperclip
class Avatar < ActiveRecord::Base
attr_accessor :content_type, :original_filename, :image_data
before_save :decode_base64_image
has_attached_file :image,
PAPERCLIP_CONFIG.merge(
:styles => {
:thumb => '32x32#',
:medium => '64x64#',
@cspickert
cspickert / subclass.js
Created February 14, 2012 14:32
How to subclass in JS
// Source: http://www.golimojo.com/etc/js-subclass.html
function subclass(constructor, superConstructor)
{
function surrogateConstructor()
{
}
surrogateConstructor.prototype = superConstructor.prototype;

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: