Skip to content

Instantly share code, notes, and snippets.

@julianlconnor
julianlconnor / sleepdeprived.js
Last active October 4, 2015 02:07
Sleep Deprived JS
_this.raw_exchange.to_users = JSON.stringify(function() {
var obj = [];
_.each(targets, function(item) {
if ( item.get('active') ) {
if ( item.get('email') ) {
obj.push({email: item.get('email')});
} else {
obj.push({phone: item.get('phone')});
}
}
@julianlconnor
julianlconnor / @2xappend.sh
Created May 15, 2012 18:08
Small script that runs through all images in the current directory that do not have the '@2x' identifier and promptly adds it.. lol
for i in `ls | grep -v "@2x"`;
do mv $i `echo $i|sed s/\.png/@2x\.png/`;
done;
@julianlconnor
julianlconnor / gravy.js
Created July 10, 2012 04:25
First Go at Gravy
/*
*
* Gravy is a small form validation library.
*
* Used specifically for Venmo's Backbone Env.
*
* By Julian Connor
*
*/
Backbone.Gravy = Backbone.View;
it 'should handle fs.stat errors', (done) ->
list = new m.List patterns('/some/*.js'), [], emitter, preprocessMock
sinon.stub(fs, "stat").yields([new Error(), null])
expect ->
refreshListAndThen()
done()
.to.not.throw
@julianlconnor
julianlconnor / gist:6241532
Last active December 21, 2015 03:19
Passing multiple models and collections to a view via Rendr
// controller
module.exports = {
index: function(params, callback) {
var spec = {
posts: { collection: 'Posts', params: params },
feed: { collection: 'Feed', params: params },
user: { model: 'User', params: params, ensureKeys: ['name'] },
session: { model: 'Session', params: params }
};
this.app.fetch(spec, function(err, result) {
@julianlconnor
julianlconnor / .vimrc
Created September 25, 2013 17:42
.vimrc
" Pathogen
set nocompatible
set laststatus=2 " Always show the statusline
set encoding=utf-8 " Necessary to show Unicode glyphs
set t_Co=256 " Explicitly tell Vim that the terminal supports 256 colors
filetype off " Pathogen needs to run before plugin indent on
call pathogen#runtime_append_all_bundles()
call pathogen#helptags() " generate helptags for everything in 'runtimepath'
call pathogen#infect()
filetype plugin indent on
@julianlconnor
julianlconnor / index.js
Last active December 24, 2015 16:29
How we mock and stub modules in stitched files. We ran into a roadblock when trying to mock and stub dependencies on the client. The stitched file wouldn't allow us to inject any of our own stuff. We had to write a wrapper around require inside of stitch to allow us to insert tests. I've made my own modifications to stitch and rendr_stitch in or…
var BaseView = require('../base'),
FeedView = require('../feed');
module.exports = BaseView.extend({
className: 'home_index_view',
postRender: function() {
this.feed = new FeedView({ collection: this.options.feed,
app: this.app});
this.$('.feed-wrapper').html(this.feed.render().el);
@julianlconnor
julianlconnor / pre-commit.js
Last active August 29, 2015 13:58
pre-commit madness
#!/usr/bin/env node
var q = require('q');
var exec = require('child_process').exec;
var exit = process.exit;
var fs = require('fs');
var readline = require('readline');
var grep = function(pattern) {
var dfd = q.defer();
q.all([only(), debug()])
.then(flatten)
.then(function(lines) {
var dfd = q.defer();
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question(lines[0] + ' -- is this cool? (n)o , (y)es >', function(answer) {
#!/usr/bin/env node
var q = require('q');
var exec = require('child_process').exec;
var exit = process.exit;
var fs = require('fs');
var readline = require('readline');
var grep = function(pattern) {
var dfd = q.defer();