Skip to content

Instantly share code, notes, and snippets.

View designfrontier's full-sized avatar

Daniel Sellers designfrontier

View GitHub Profile
@designfrontier
designfrontier / gist:f1644994ae8c10c1bd74
Created November 13, 2014 21:15
interview.js solution with modern schtuff
function delegate (childIn) {
var child = childIn;
return function me(){
var that = this,
oper = Object.getOwnPropertyNames(that).filter(function (attrib) {
return(typeof that[child][attrib] === 'function' && me === that[attrib]);
})[0];
return that[child][oper].apply(this[child], arguments);
@designfrontier
designfrontier / Gulpfile.js
Last active August 29, 2015 14:17 — forked from webdesserts/Gulpfile.js
node restarter in gulp specifically for monument based web apps
// NOTE: I previously suggested doing this through Grunt, but had plenty of problems with
// my set up. Grunt did some weird things with scope, and I ended up using nodemon. This
// setup is now using Gulp. It works exactly how I expect it to and is WAY more concise.
var gulp = require('gulp'),
spawn = require('child_process').spawn,
node;
/**
* $ gulp server
* description: launch the server. If there's a server already running, kill it.
@designfrontier
designfrontier / gist:77f5d768e77bb7604065
Last active August 29, 2015 14:25
pre-bernstein promise chains
somePromiseReturningFunction.then(function(data){
data.num++;
return data;
}).then(function(data){
data.num++;
return data;
}).then(function(data){
data.num++;
return data;
}).then(function(data){
@designfrontier
designfrontier / gist:6b3c11ff4c0382f702e1
Last active August 29, 2015 14:25
bernstein in use
var funcArray = [function(data, orig, next){
data.num++;
next(data);
}
, function(data, orig, next){
data.num++;
next(data);
}
, function(data, orig, next){
data.num++;
@designfrontier
designfrontier / gist:fb95b0a212f55554a09b
Last active August 29, 2015 14:25
bernstein real world-ish with pseudo code
var userCreationStack = bernstein.create([
function (data, orig, next){
var imageProm = imageServiceWrapper.sliceAndDice(data.image);
imageProm.then(function (imageData) {
data.images = imageData;
next(data);
});
}
@designfrontier
designfrontier / jquery.pinme.0.1.js
Created November 2, 2011 21:37
Pin me... an awesome jQuery plugin
//pins elements in place with JS
(function($){
$.pinme = function(el){
var base = this;
// Access to jQuery and DOM versions of element
base.$el = $(el);
base.el = el;
// Add a reverse reference to the DOM object
@designfrontier
designfrontier / titleCase
Created February 2, 2012 16:03
Some code extending the JavaScript string prototype for working with titles and headers
String.prototype.titleCaps = function(){
var thisString = this.replace(/( )([a-z])/g, function(m, $1, $2){return $1 + $2.toUpperCase();});
//remove and, the, or of from caps if they are not the first element in the string
thisString = thisString.replace(/(and|of|to|the|or)/ig, function(m,$1){return $1.toLowerCase();});
thisString = thisString.replace(/(^[a-z])/,function(m,$1){return $1.toUpperCase();});
return thisString;
};
@designfrontier
designfrontier / spin.js
Last active October 10, 2015 02:24
node console spinner (rough)
var arr = [
'\\',
'|',
'/',
'-',
]
, position = 0;
arr = arr.concat(arr, arr, arr, arr, arr, arr);
@designfrontier
designfrontier / newPadssview.sublime-snippet
Created September 24, 2012 19:06
snippet for creating a new PadssView based view
<snippet>
<content><![CDATA[
define([
'modules/PadssView'
], function(
PadssView
) {
return PadssView.extend({
events: {
@designfrontier
designfrontier / gist:4048217
Created November 9, 2012 21:03
crazy router for matching any part an url hash to a naming convention
var window = arr.length;
for(var i = 0; < arr.length; i++){
for(var index = i; index >= 0; index--){
loopOverWindow(arr,window,index);
}
window --;
}