Skip to content

Instantly share code, notes, and snippets.

Jake Lodwick jakelodwick

Block or report user

Report or block jakelodwick

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jakelodwick
jakelodwick / integration_request.vtl
Created Mar 12, 2016
AWS API Gateway - Integration Request - Mapping Template
View integration_request.vtl
#*
Via <http://kennbrodhagen.net/2015/12/06/how-to-create-a-request-object-for-your-lambda-event-from-api-gateway/>.
This mapping template formats most information that API Gateway receives, for easy use in a Lambda function (or whatever).
Not sure why the same effect isn't achieved with the "Input passthrough" option!
*#
{
"method": "$context.httpMethod",
"body" : $input.json('$'),
"headers": {
#foreach($param in $input.params().header.keySet())
@jakelodwick
jakelodwick / loadSamples.coffee
Created Dec 21, 2015
load multiple files via XHR, then run a callback
View loadSamples.coffee
loadSamples: (urls, callback) ->
loaded = []
requests = []
decode = (_raw) =>
@audio.decodeAudioData _raw, (sample) ->
loaded.push sample
callback(loaded) if loaded.length is urls.length
@jakelodwick
jakelodwick / http-to-https.coffee
Created Oct 26, 2015
redirect from http to https
View http-to-https.coffee
if location.protocol is "http:"
window.location = window.location.toString().replace("http:", "https:")
View caffe.md

Setting up Caffe for Running Deepdream on OS X

Dependencies

Use Brew

Install brew and pip (sudo easy_install pip)

brew update
brew install homebrew/science/openblas
@jakelodwick
jakelodwick / vcenter.css
Created Dec 9, 2014
vertically center in CSS
View vcenter.css
.vcenter {
display: inline-block;
position: relative;
top: 50%;
transform: translateY(-50%);
}
@jakelodwick
jakelodwick / heroku-env.sh
Created Sep 9, 2014
Getting Heroku environment variables into local repo
View heroku-env.sh
heroku plugins:install git://github.com/ddollar/heroku-config.git
heroku config:pull --overwrite --interactive
@jakelodwick
jakelodwick / phttp
Created Aug 18, 2014
Start webserver in current directory & open browser window to it
View phttp
# run these two commands:
open http://localhost:8000/
python -m SimpleHTTPServer
# I put the following in ~/.profile (OS X) so it runs every time I open a terminal window:
alias phttp="open http://localhost:8000/; python -m SimpleHTTPServer"
@jakelodwick
jakelodwick / array-last.coffee
Created Aug 17, 2014
Get last element of array
View array-last.coffee
# last element of array,
# alternative to `my_array[my_array.length - 1]`
# via http://stackoverflow.com/questions/9050345/selecting-last-element-in-javascript-array
unless Array::last
Array::last = ->
this[@length - 1]
View ppjson.coffee
# pretty-print JSON
# http://stackoverflow.com/questions/4810841/how-can-i-pretty-print-json-using-javascript
ppjson = (obj) ->
console.log JSON.stringify obj, undefined, 2
@jakelodwick
jakelodwick / gist:4b6e1f938403a1c92cf5
Created Aug 17, 2014
CoffeeScript in Sinatra apps
View gist:4b6e1f938403a1c92cf5
#put this in your Gemfile:
gem "rack-coffee"
#(don't forget to run `bundle` on the command line)
#put this in your Sinatra app:
use Rack::Coffee,
:root => 'public',
:urls => '/coffee',
:join => 'index',
:bare => true
You can’t perform that action at this time.