Skip to content

Instantly share code, notes, and snippets.

View wookiehangover's full-sized avatar
💭
just setting up my gthb...

Sam Breed wookiehangover

💭
just setting up my gthb...
View GitHub Profile
@wookiehangover
wookiehangover / define-wrapper.js
Created May 18, 2013 05:59
connect middleware that wraps serves common-js modules wrapped with AMD define()
var fs = require('fs');
var path = require('path');
var url = require('url');
module.exports = function(directory, blacklist) {
if( directory === undefined ) {
throw new Error('You need to pass a location to work with');
}
blacklist = blacklist || [];
var logStream = {
write: function(msg){
// strip duplicate newlines from the end of Express log messages
msg = msg.substr(0, msg.length - 1);
winston.info(msg);
}
};
app.use(express.logger({ stream: logStream, format: 'dev' }));
16:38 Laybunz: Is there a way to get the name of a function on a Backbone view?
16:39 Laybunz: When I log out the function object itself in the console, it prints this: "function (){return n.apply(t,r.concat(o.call(arguments)))}"
16:39 Laybunz: Which is obviously a nameless anonymous function
16:55 scorchedwings: Laybunz - you're just doing a console.log(function_name) ? Can you use dev tools to look at the stack or set a breakpoint?
16:55 Laybunz: I'm hoping to have an array of filter or sort functions that a list is passed through
16:56 Laybunz: And I'd like to remove them by name programmatically, as well
16:56 Laybunz: Does that make sense?
16:57 scorchedwings: Laybunz - have you looked at the documentation for underscorejs? there are lots of methods there that are perfect for that.
16:58 Laybunz: I am using Underscore to actually execute the array of filter functions, and it works perfectly
16:59 Laybunz: Maybe there's another way to go about this, but in pseudocode I'd like to do something like this
@wookiehangover
wookiehangover / less-middleware.js
Last active December 14, 2015 21:18
Express Middleware for processing less on the fly in development mode.
/*
* Less Middleware
*
* Captures requests for your production css and serves a compiled less bundle
* in its place. Less parser is pretty quick, no noticeable load times when
* parsing bootstrap & custom less on every request. Errors are printed to the
* console.
*
* Meant to be mounted to your css directory, eg:
*
{
var hasAnyone = "ever seen someone write";
function wtf(){
return "code in blocks like this?";
}
console.log( hasAnyone + wtf() );
@wookiehangover
wookiehangover / gist:4259967
Created December 11, 2012 16:21
Backbone Change Log

New Features

  • Collection#update

  • Collection#clone

  • once

  • Event Maps

  • History.extend

  • History outside of the browser

@wookiehangover
wookiehangover / gist:4259957
Created December 11, 2012 16:21
Backbone Change Log

A Long Time Coming: Backbone 1.0

By far the biggest release, Backbone 1.0 packs in a veritable menagerie of features, bug fixes and enhancements with a few breaking changes along the way. This is a brief overview of the release with tips on what to watch out for when upgrading from 0.9.2.

New Features

  • Collection#update
#!upstart
description "node server"
start on (local-filesystems and net-device-up IFACE=eth0)
stop on shutdown
script
export HOME="/home/sam"
exec sudo -u sam -i NODE_ENV=production /home/sam/local/node/bin/node /home/sam/dev/repos/wookiehangover.com/forever.js >> /var/log/node-server.log 2>&1
end script
Model = function(){
this.events = $({});
this.attributes = {};
};
Model.prototype.set = function( key, value ){
var self = this;
var events = [];
var cached_attributes = _.extend( {}, this.attributes );
/*global module:false*/
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: '<json:package.json>',
lint: {
files: [