Skip to content

Instantly share code, notes, and snippets.

View paton's full-sized avatar
🆘
We're Hiring! Email me: brandon@localizejs.com

Brandon Paton paton

🆘
We're Hiring! Email me: brandon@localizejs.com
View GitHub Profile

Keybase proof

I hereby claim:

  • I am paton on github.
  • I am bpaton (https://keybase.io/bpaton) on keybase.
  • I have a public key whose fingerprint is AB1A 0C11 5183 4E5A 6162 6365 C46E E841 8228 83FA

To claim this, I am signing this object:

@paton
paton / ko.js
Last active May 24, 2016 22:02
window.document.normalize() breaks Knockout 3.3.0
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.3.0/knockout-min.js"></script>
<script>
// Problem occurs on IE 11 on Windows 10 (and earlier versions)
// Problem does NOT occur in Chrome
// window.document.normalize(); breaks knockoutjs bindings
@paton
paton / simple.js
Last active October 7, 2019 16:14
Super simple implementation of define() and require() used in Localize.js (https://localizejs.com)
var define, require;
(function() {
var modules = {};
require = function(name) {
return modules[name]();
};
define = function(name, fn) {
@paton
paton / gist:1a573fd7c178bfb9156f
Created October 31, 2014 17:51
Zombie / SEO middleware
var app = requireBase('libs/app'),
Zombie = require('zombie');
var botRegex = /bot|crawler|baiduspider|80legs|mediapartners-google|adsbot-google/i;
module.exports = function(req, res, next) {
// Zombie not necessary for homepage since it's boostrapped
// Exclude non-get calls and API calls
if (req.url === '/' || req.method !== 'GET' || /^\/api\//.test(req.url)) return next();
var $ = require('jquery');
var _ = require('underscore');
var Backbone = require('backbone');
var log = require('../libs/logging');
var pubnub = require('pubnub');
require('cookie');
function Socket() {
_.extend(this, Backbone.Events);
@paton
paton / handlebars-backbone-subviews.js
Last active December 22, 2015 08:18
How to include subviews in a Backbone template using handlebars
/*
How it works:
1) Pass in the parent view when rendering subviews in templates
{{v 'subview' parent=this}}
2) the 'v' handlebars helper:
- creates the child view and calls its render method
- set data-cid="CID" on the subview