Skip to content

Instantly share code, notes, and snippets.

View SaneMethod's full-sized avatar

Christopher Keefer SaneMethod

View GitHub Profile
@SaneMethod
SaneMethod / backboneSocketSync.js
Created June 24, 2014 20:23
Socket.io Websockets for Backbone
/**
* Copyright (c) Christopher Keefer. All Rights Reserved.
*
* Overrides the default transport for Backbone syncing to use websockets via socket.io.
*/
(function(Backbone, $, _, io){
var urlError = function(){
throw new Error('A "url" property or function must be specified.');
},
eventEmit = io.EventEmitter.prototype.emit,
@SaneMethod
SaneMethod / backboneMarionetteSocketSync.js
Created June 24, 2014 20:35
Socket.io Websockets for Backbone+Marionette
/**
* Copyright (c) Christopher Keefer. All Rights Reserved.
*
* Overrides the default transport for Backbone syncing to use websockets via socket.io. Includes marionette
* convenience code, specifically for sending socket-related events along the global event aggregator.
*/
(function(app, Backbone, Marionette, $, _, io){
var urlError = function(){
throw new Error('A "url" property or function must be specified.');
},
@SaneMethod
SaneMethod / canvasToBlobShim.js
Last active April 4, 2017 16:35
Canvas toBlob Shim, adapated with thanks from https://code.google.com/u/105701149099589407503/.
/**
* Canvas toBlob shim, adapted with thanks from https://code.google.com/u/105701149099589407503/,
* from this chrome bug thread: https://code.google.com/p/chromium/issues/detail?id=67587
*/
(function(){
/**
* Convert a base64 image dataURL from a canvas element, to a blob.
* @param {function} callback
* @param {string} type
* @param {number} quality
@SaneMethod
SaneMethod / django-python-social-auth-monkey.py
Created July 21, 2015 21:03
Email validation pipeline monkey patch for python-social-auth and Django.
# Monkey patching - an occasionally necessary evil.
from social import utils
from social.exceptions import InvalidEmail
from django.core import signing
from django.core.signing import BadSignature
from django.contrib.sessions.models import Session
from django.conf import settings
@SaneMethod
SaneMethod / hup.js
Created November 24, 2015 20:09
Gist for embedding in post re: HUp plugin.
/**
* Copyright (c) 2013 Christopher Keefer. All Rights Reserved.
* See https://github.com/SaneMethod/HUp/
* jQuery plugin for reading in files or uploading them with the HTML5 file api and xhr2.
*/
"use strict";
(function($){
var filters = {},
fileTypes = [];
/**
@SaneMethod
SaneMethod / fetchCacheBlogEmbed.js
Last active September 30, 2016 19:41
Gist for embedding fetchCache source in blog post.
/**
* Copyright (c) Christopher Keefer, 2016.
* https://github.com/SaneMethod/fetchCache
*
* Override fetch in the global context to allow us to cache the response to fetch in a Storage interface
* implementing object (such as localStorage).
*/
(function (fetch) {
/* If the context doesn't support fetch, we won't attempt to patch in our
caching using fetch, for obvious reasons. */