Skip to content

Instantly share code, notes, and snippets.

View mrgenixus's full-sized avatar

Ben West mrgenixus

View GitHub Profile
/*
* This decorates Handlebars.js with the ability to load
* templates from an external source, with light caching.
*
* To render a template, pass a closure that will receive the
* template as a function parameter, eg,
* T.render('templateName', function(t) {
* $('#somediv').html( t() );
* });
* Source: https://github.com/wycats/handlebars.js/issues/82
function resolve(cb, res){
$.when(res).then(cb)
}
//usage:
function definePurpleEventually(cb){
setTimeout(function(){
cb({
purple: "color"
})
@mrgenixus
mrgenixus / Gemfile
Last active January 3, 2016 07:39
Single Table Inheritance Prototype
source 'https://rubygems.org'
gem 'activerecord'
gem 'pg'
gem 'binding_of_caller'
gem 'pry'
@mrgenixus
mrgenixus / object.js
Last active December 31, 2015 20:59
ObjectWatch "I like to watch"
var watch = require('watch');
module.exports = function MyObject (){
}
MyObject.prototype.printMe = function(){
console.log(JSON.stringify(this));
}
watch(MyObject.prototype, function(name, args){

Menu

Thursday

  • Sketti N' Salad al Bryan, sous/dishes: Marshall

Friday

  • Gnocchi (Sweet Potato/reg) a la Sam, sous/dish (Rebekah/Ben)

Saturday (out)

  • Pho/Teryaki planet/etc
  • Bfast. Burrito Prep for:
hammerEvents: {
'tap .share': 'handleShareClick',
'tap img, .dismiss': 'close'
},
#!/bin/env python
class ExpirationInterface():
def setExpiration(self,value):
setattr(self,self.expiration_property,value)
def getExpiration(self):
getattr(self,self.expiration_property)
class Principal( BaseClass, ExpirationInterface ):
@mrgenixus
mrgenixus / badge_listener.js
Created September 19, 2013 23:40
Handling Badge delivery declaratively is a pain; this might help .. a little
var types = {
'winner': {
trigger: 'quiz-end'
conditions: {
place: 'first only'
},
img_file: 'winner.png'
},
'first_loser':{
trigger: 'quiz-end'
@mrgenixus
mrgenixus / add_items.js
Last active December 21, 2015 09:49
adding some items to a list, jQuery
module.exports = function(item){
var $list = $('<ul>').attr('style', 'disc').append($.map(items, function(v,i){
return $("<li>").attr('id', 'demo_' + v.id).addClass('demo-remove-item').append($('<a>')
.add_class(v.link_class).append(
$('<span>').addClass('glyphicon') //...
));
}));
}
@mrgenixus
mrgenixus / em-ftpd-start.rb
Created May 14, 2013 19:27
This is an example of an implementation that USES the em-ftp gem
#!/usr/bin/env ruby
# Boot an FTP server
#
# Usage:
#
# em-ftpd config.rb
require 'em-ftpd'