Skip to content

Instantly share code, notes, and snippets.

View mrgenixus's full-sized avatar

Ben West mrgenixus

View GitHub Profile
var newModel = (function(){
var attributes = {}
var state = {
set: function(stateChange){
attributes = $.extend({}, attributes, stateChange);
},
get: function(key) {
return $.extend({}, attributes);
(function (n) { // function has no name, is therefore "anonymous"
var i=n*2;
if (i > 4) {
return undefinedFunc(); // causes a "ReferenceError: undefinedFunc is not defined at Object.<anonymous>"
} else {
arguments.callee(i); // recurses, adding the anonymous function to the call stack
}
})(1);
@mrgenixus
mrgenixus / polyreview.rb
Created March 17, 2014 04:30
RESTful Polymorphic review creation methods for associated models
class ProductsController < ApplicationController
# [...] Product Crud
def create_review
@product = Product.find params[:id]
review = @product.reviews.new
review.user_id = current_user.id
review.subject = params[:subject].nil? ? "Untitled" : params[:subject];
review.body = params[:body]
/*
* 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 ):