Skip to content

Instantly share code, notes, and snippets.

@karlwestin
karlwestin / gist:8462872
Last active January 3, 2016 12:29
Stuff thats needed for initializing db
sudo pip install simplejson==2.1.6 --no-use-wheel
sudo pip install psycopg2==2.4.2 --no-use-wheel
sudo pip install South==0.7.3 --no-use-wheel
sudo pip install lxml==2.2.8 --no-use-wheel
sudo pip install pycurl==7.19.0 --no-use-wheel
/*
* Billpay review
*
* Controls effects / agree to fee subviews
* Stops user from saving accelerations w/o
* agreeing to the acc. fee + showing/hiding error for that
*/
define([
"widgets/simulation/model",
"widgets/bplib/bplib",
@karlwestin
karlwestin / .vimrc
Created January 8, 2014 18:38
.vimrc
let mapleader=","
noremap _ :ls<CR>:b
noremap <F4> :close<CR>
set autoindent
set ts=2 shiftwidth=4
set showmode
set showcmd
set expandtab
set ruler
@karlwestin
karlwestin / test.js
Created December 12, 2013 11:05
Nice javascript unit testing (jasmine) trick: which spec takes the most time?
describe("test suite that you wanna perf", function() {
beforeEach(function() {
this.start = performance.now();
});
afterEach(function() {
console.log(jasmine.getEnv().currentSpec.description, performance.now() - this.start);
});
});
var tests = [];
for (var file in window.__karma__.files) {
if (window.__karma__.files.hasOwnProperty(file)) {
if (/\/base\/spec\/js\/v2\/.*\.js$/.test(file)) {
tests.push(file);
}
}
}
console.log("Running tests for");
@karlwestin
karlwestin / example.hbs
Created November 19, 2013 16:00
nightmare nested handlebars example
{{#when-eq frequency "bi-weekly"}}
every other {{formatDate ../deliverBy "dddd"}}, starting on {{formatDate ../deliverBy "MMM d, yyyy"}}.
{{/when-eq}}
{{#when-eq frequency "monthly"}}
on the {{englishDay ../day }} every month, starting on {{formatDate ../deliverBy "MMM d, yyyy"}}.
{{/when-eq}}
{{#when-eq frequency "one-time"}}
on {{formatDate ../deliverBy "MMM d, yyyy"}}.
@karlwestin
karlwestin / readme.md
Last active December 28, 2015 02:39
Issues with errors from JS files loaded from CDN in Chrome

I've tried to make the window.onerror handler work for cdn-loaded scripts like described here: https://code.google.com/p/chromium/issues/detail?id=159566 but we're still not getting any error messages and stacks.

The page in question is https://www.readyforzero.com/auth#login and we try to load two files: lib__V{hash}.js and auth__V{hash}.js from CDN, and make them report errors via window.onerror.

The script tags has the attribute crossdomain anonymous, and the CDN is instructed to send Access-Control-Allow-Origin: https://www.readyforzero.com (which is also verified).

However we don't see the stacks and error messages in the window.onerror handler

Two questions:

define([
"hbs!templates/tmpl",
"Handlebars"
], function(
tmpl,
Handlebars
) {
var products = [{id:1},{id:2}];
var rendered = tmpl({
@karlwestin
karlwestin / cors.fake.js
Created October 4, 2013 09:38
cors.fake.js Stripping out the 'sync' layer of a backbone app and use a bunch of objects as responses instead
define([
"jquery",
"config",
"tools/filters",
"lib/json2"
], function(
$,
config,
Filters
@karlwestin
karlwestin / morhpeus.js
Created October 2, 2013 14:22
iOS7 fix for morpheus.js
var matchingTimestamps;
frame(function(timestamp) {
// if we're using a high res timer, make sure timestamp is not the old epoch-based value.
// http://updates.html5rocks.com/2012/05/requestAnimationFrame-API-now-with-sub-millisecond-precision
// patch for https://github.com/ded/morpheus/issues/53
// check if timestamps are on the same scale and cache result
var argument = timestamp > 1e12,
getTime = now() > 1e12;
matchingTimestamps = argument === getTime;
});