Skip to content

Instantly share code, notes, and snippets.

Avatar

Nick Mitchinson nrmitchi

View GitHub Profile
View config.ru
# config.ru
gem 'rack-rewrite', '~> 1.5.1'
require 'rack/rewrite'
use Rack::Rewrite do
rewrite %r{^(.*)}, '/index.html'
end
run Rack::File.new "#{Dir.getwd}/public"
View Gemfile
source 'https://rubygems.org'
gem "rack"
gem "rack-rewrite"
View Gemfile
source 'https://rubygems.org'
gem "rack"
gem "rack-rewrite"
View minimal-example-model.js
module.exports = function(sequelize, DataTypes) {
var Model = sequelize.define('Model', {
dates : {
type : DataTypes.ARRAY(DataTypes.DATE) ,
allowNull : false ,
validate : {
isDate : true
}
}
}, {
@nrmitchi
nrmitchi / client.js
Last active Dec 30, 2015
Client-side Upload to S3
View client.js
/*
Note that this is rather specific to what I was doing due to things like endpoints and message bodies. You will have to change this to fit your purposes
*/
function uploadObject () {
//This is so that I can access the object from within the XMLHTTPRequest event functions
var that = this;
this.setCallback = function (cb) {
View README.mkd

Make a client

curl http://balanced-hangman.herokuapp.com

Hopefully you'll see something like

{
 "index": "/", 
 "me": "/me", 
@nrmitchi
nrmitchi / gist:5256118
Created Mar 27, 2013
Small proof of js passing by reference
View gist:5256118
var a = { 'a': 1, 'b':2 };
var b = a
console.log(a);
console.log(b);
//Note that they are the same
b.a = 3
console.log(a);
console.log(b);
@nrmitchi
nrmitchi / PandoraTitleScroller.js
Last active Dec 14, 2015
Scroll title/artist in tab title for Pandora
View PandoraTitleScroller.js
// Copy/paste into Console/Firebug
window.PandoraTitleScroller = {}
window.PandoraTitleScroller.index = 0;
window.PandoraTitleScroller.length = 20;
window.PandoraTitleScroller.title = $('.trackData').children().first().children().first().html() + ' by ' + $('.trackData').children().eq(1).children().eq(1).html();
//Kinda buggy but it works for what I wanted
window.setInterval(function () {