Skip to content

Instantly share code, notes, and snippets.

@karlwestin
karlwestin / errorhandler.js
Created July 31, 2014 09:22
simple window.onerror handler
function errorHandler(msg, url, line, column, err) {
// firefox bug to watch for 5 arg error handler
// https://bugzilla.mozilla.org/show_bug.cgi?id=630464
/*
* most browsers don't give column number,
* but chrome can do it sometimes
*/
if(typeof column == "object") {
err = column;
public save() {
let db = this.get_db();
let data = this.get_data();
let t = this;
console.log('Save:' + this._id);
db.get(this._id, {conflicts: false})
.catch(function (err) {
if (err.status === 404) {
return {}; // you can just return an empty map if docs not found
}
@karlwestin
karlwestin / webpack-dev-server.js
Created October 12, 2016 16:01
Make webpack dev server more quiet
var webpack = require('webpack')
var WebpackDevServer = require('webpack-dev-server')
var config = require('./webpack.dev')
new WebpackDevServer(webpack(config), {
publicPath: config.output.publicPath,
hot: true,
inline: true,
historyApiFallback: true,
// It suppress error shown in console, so it has to be set to false.
@karlwestin
karlwestin / institutet-mot-mutor.md
Created January 15, 2016 16:26
Institutet Mot Mutor

institutet - institutet för högerpolitik,
institutet - en slags dimridå
institutet - för att låtsas att man är många
institutet - när man bara är några få

@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
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: