Skip to content

Instantly share code, notes, and snippets.

View fiveisprime's full-sized avatar
🖤

Matt Hernandez fiveisprime

🖤
View GitHub Profile
var watch = function(obj, prop, callback) {
var oldValue = obj[prop]
, newValue = oldValue
, getter = function() { return newValue; }
, setter = function(value) {
oldValue = newValue;
newValue = value;
callback.call(obj, prop, oldValue, newValue);
};
@fiveisprime
fiveisprime / gist:4475215
Created January 7, 2013 14:04
Base meerkat widget boilerplate.
(function($) {
'Use Strict';
var kendo = window.kendo
, ui = kendo.ui
, Widget = ui.Widget;
var widgetName = Widget.extend({
init: function(element, options) {
this.el = $(element);
@fiveisprime
fiveisprime / dabblet.css
Created February 12, 2013 14:42
Text selection tests
/**
* Text selection tests
*/
p.sized {
position: absolute;
margin: 0 0 0 50px;
width: 500px;
}
p.padded {
padding: 140px 900px 0 50px;
@fiveisprime
fiveisprime / dabblet.css
Created February 13, 2013 18:23
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
a.button {
display: inline-block;
text-align: center;
text-decoration: none;
height: 44px;
@fiveisprime
fiveisprime / gist-fix.css
Created February 16, 2013 01:31
Fix gist formatting.
.gist {
font-size: 13px;
line-height: 20px;
margin-bottom: 20px;
width: 100%;
}
.gist pre {
font-family: Menlo,Monaco, 'Bitstream Vera Sans Mono', 'Courier New', monospace !important;
}
@fiveisprime
fiveisprime / gist:5237409
Last active December 15, 2015 09:19
Anonymous functions.
var anon = {
foo: function() {
return typeof foo;
}
};
console.log(anon.foo()); // Prints 'undefined'
var named = {
foo: function foo() {
@fiveisprime
fiveisprime / .jshintrc
Last active December 20, 2015 12:09
Default .jshintrc for node projects. Includes globals for Jasmine specs.
{
"maxerr" : 50,
"bitwise" : true,
"camelcase" : false,
"curly" : false,
"eqeqeq" : true,
"forin" : false,
"immed" : false,
"latedef" : true,
@fiveisprime
fiveisprime / server.js
Created August 31, 2013 18:23
Example API using Hapi.
//
// Example API using Hapi.
// http://hapijs.com
//
var Hapi = require('hapi');
var quotes = [
{
author: 'Audrey Hepburn'
@fiveisprime
fiveisprime / repl.js
Last active December 22, 2015 19:19
Easy interaction with node.js REPL.
var local = require('repl').start('> ');
local.context.set = function(name) {
return function(err, value) {
if (err) throw err;
local.context[name] = value;
};
};
//
var async = require('async')
, Q = require('q')
, fs = require('fs');
//
// Typical node style function that uses a callback (fn).
//
var piratize = function(file, fn) {
fs.readFile(file, 'utf8', function(err, data) {
if (err) return fn(err, null);