Skip to content

Instantly share code, notes, and snippets.

View jkresner's full-sized avatar

ಠ_ಠ jkresner

  • airpair, inc.
  • San Francisco
View GitHub Profile
@jkresner
jkresner / Global.asax
Created October 30, 2012 20:20
Asp .net Mvc 4 Proxy Server/Controller (For help with Cross Domain Request)
public class WebApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
RouteTable.Routes.MapRoute("HttpProxy", "proxy/{*path}", new { controller = "Proxy", action = "Http" })
}
}
@jkresner
jkresner / skills-data.coffee
Created April 13, 2013 21:55
node.js testing an express mongoose REST api with supertest
module.exports = [
{ "name": "Brunch.io", "shortName": "brunch", "soId": "brunch", "_id": "514825fa2a26ea020000000b", "__v": 0 },
{ "name": "C#", "shortName": "c#", "soId": "c#", "_id": "514825fa2a26ea020000000e", "__v": 0 } ]
@jkresner
jkresner / braintree.js
Created December 2, 2014 16:22
ES6 Braintree Wrapper
var util = require('../../../shared/util')
var braintree = require('braintree')
var {merchantId, publicKey, privateKey} = config.payments.braintree
var environment = braintree.Environment[config.payments.braintree.environment]
var gateway = braintree.connect({ environment, merchantId, publicKey, privateKey })
var logging = false
@jkresner
jkresner / Procfile
Created April 13, 2013 09:05
Deploy brunch to heroku
web: ./node_modules/.bin/coffee app.coffee
@jkresner
jkresner / test-passport.coffee
Created June 20, 2013 17:50
Passport.js user mocking version 2
users = require './../data/users'
data = users: []
data.users.anon = authenticated: false
data.users.admin = users[0]
data.users.jk = users[1]
data.users.artle = users[5]
data.users.beountain = users[4]
setSession = (userKey) ->
@jkresner
jkresner / jq.js
Last active December 21, 2015 10:18
Add jQuery to any page via the browser console once it's loaded.
var _JQ = document.createElement('script');
_JQ.src = 'http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js';
_JQ.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(_JQ);
BB = require 'badass-backbone'
M = require './models'
V = require './views'
# Inherit from BadassAppRouter to get Badass Backbone conventions
module.exports = class Router extends BB.BadassAppRouter
logging: on
pushState: off # Set off for simple example
"""
BadassRouter takes the philosophical position that only one router can be
used for one html page / single page app. It is conceptually the top most
container object other than window that contains all instances associated with the app.
"""
module.exports = class BadassRouter extends Backbone.Router
# Set logging on /off - Very dandy during dev to see flow of routes
logging: off
@jkresner
jkresner / pre-push
Last active December 17, 2015 07:29
Poor man's continuous integration to run javascript tests on every git push http://hackerpreneurialism.com/post/50386628477/poor-mans-continuous-integration-automated-node-tests
#!/bin/sh
killall node
brunch watch --server -c config-test.coffee &
mocha test/server/all.coffee
mocha-phantomjs http://localhost:3333/test/index.html
""" BadassView add 3 basic bits of functionality to a normal Backbone.View
1) Auto-logging of initialize, render & save
2) Auto setting constructor args as attributes on view instances
3) Short elm() to access an html element based on it's name attribute
"""
module.exports = class BadassView extends Backbone.View
# Set logging on /off
# Why? : During dev it's handy to see the flow your views execute in
logging: on