Skip to content

Instantly share code, notes, and snippets.

View OliverJAsh's full-sized avatar

Oliver Joseph Ash OliverJAsh

View GitHub Profile
@davemo
davemo / backbone.sessionStorage.js
Last active April 15, 2016 22:53
Backbone sessionStorage Adapter
/**
* Backbone sessionStorage Adapter
* Based on https://github.com/jeromegn/Backbone.localStorage
*/
(function() {
// A simple module to replace `Backbone.sync` with *sessionStorage*-based
// persistence. Models are given GUIDS, and saved into a JSON object. Simple
// as that.
@Integralist
Integralist / retina.scss
Created October 18, 2012 14:12
Example of passing a code block to a Mixin to make it more flexible (especially for displaying retina content)
@mixin retina {
/* Target any and all high-density screens on any browser currently known (October 2012) */
@media (min--moz-device-pixel-ratio: 1.5),
(-o-min-device-pixel-ratio: 3/2),
(-webkit-min-device-pixel-ratio: 1.5),
(min-resolution: 1.5dppx) {
@content;
}
}
@davemo
davemo / api.proxy.server.js
Created November 6, 2012 21:56
A simple express.js server with a proxy that intercepts all requests with /api/ and proxies them to localhost:3000
var express = require('express'),
httpProxy = require('http-proxy'),
app = express();
var proxy = new httpProxy.RoutingProxy();
function apiProxy(host, port) {
return function(req, res, next) {
if(req.url.match(new RegExp('^\/api\/'))) {
proxy.proxyRequest(req, res, {host: host, port: port});
@defunctzombie
defunctzombie / browser.md
Last active July 15, 2024 04:13
browser field spec for package.json
@termi
termi / crossBrowser_initKeyboardEvent.js
Last active June 13, 2023 02:01
Cross-browser initKeyboardEvent
void function() {//closure
var global = this
, _initKeyboardEvent_type = (function( e ) {
try {
e.initKeyboardEvent(
"keyup" // in DOMString typeArg
, false // in boolean canBubbleArg
, false // in boolean cancelableArg
, global // in views::AbstractView viewArg
@adamyeats-zz
adamyeats-zz / script.js
Last active April 7, 2017 21:18
Typekit Hack
/*
This small hack loads fonts from the Typekit webfontloader (https://github.com/typekit/webfontloader)
contextually, effectively "patching" in a new font if a media query is fired.
You need to have 2 seperate kits on Typekit, one for your main fonts, and another for the fonts you want
when the media query is fired.
Improvements or suggestions welcome!
@spion
spion / browserify-v2.jade.js
Last active December 15, 2015 04:18
browserify-jade-v2
// Example browserify transform which precompiles Jade
// templates including them in the bundle, allowing you
// to use:
// var tmpl = require('./templates/template.jade');
//
// Supports layouts and blocks
//
// requirements:
// npm install jade through
//
@elliotf
elliotf / gist:5277447
Last active December 15, 2015 14:49
What I ended up using after smacking my face against backbone relational and backbone associations
//= require ../collections/children.js
(function($){
demo.models.Parent = Backbone.Model.extend({
initialize: function(options) {
this.children = new demo.collections.Children();
this.attributes = this.parse(this.attributes);
}
, exampleJSON: {
someAttr: 'some value'