Skip to content

Instantly share code, notes, and snippets.

View cvan's full-sized avatar
🚌
🌊

Christopher Van Wiemeersch cvan

🚌
🌊
View GitHub Profile
{
"log": {
"version": "1.2",
"creator": {
"name": "PhantomJS",
"version": "1.9.0"
},
"pages": [
{
"startedDateTime": "2014-01-21T22:51:06.795Z",
function parseQueryString(qs) {
if (!qs) {
return {};
}
var chunks;
var result = [];
qs.split('&').forEach(function(val) {
chunks = val.split('=');
result.push({
name: chunks[0],
@cvan
cvan / sentry2bz.js
Last active January 4, 2016 21:19
script for one-click filing of sentry tracebacks in bugzilla
/*
1. Install dotjs (https://addons.mozilla.org/en-US/firefox/addon/dotjs/ for Firefox or https://github.com/defunkt/dotjs for Chrome)
2. Put the contents of this file at ~/.js/sentry.dmz.phx1.mozilla.com.js
*/
(function() {
function serialize(obj) {
@cvan
cvan / snoopy.js
Created January 29, 2014 21:30
record user's history
/*
1. Install dotjs (https://addons.mozilla.org/en-US/firefox/addon/dotjs/ for Firefox or https://github.com/defunkt/dotjs for Chrome)
2. Put the contents of this file at ~/.js/default.js
*/
const API_URL = 'http://localhost:7000/';
function getData(e, comment) {
.throbber {
animation(unquote('.9s spin infinite steps(30)'));
border: 4px solid cyan;
border-left-color: transparent;
border-radius: 150px;
border-top-color: transparent;
bottom: 0;
display: block;
height: 33px;
left: 0;
@cvan
cvan / throbber.css
Created January 30, 2014 23:52
CSS throbber
/*
Usage:
<div class="throbber"><b></b><b></b><b></b></div>
*/
.throbber {
position: absolute;
@cvan
cvan / delegate.js
Created February 4, 2014 05:33
simple querySelectorAll wrapper + event delegation
function $(sel) {
if (!sel) {
return document.body;
}
var r = document.querySelectorAll(sel);
return r.length == 1 ? r[0] : Array.prototype.slice.call(r);
}
$.matches = function(el, sel) {
var matchesSelector = el.webkitMatchesSelector || el.mozMatchesSelector ||
@cvan
cvan / post.js
Created February 5, 2014 00:33
promise-based, jQuery-like $.post XHR wrapper
function reqResponse(xhr) {
var data = xhr.responseText;
if ((xhr.getResponseHeader('Content-Type') || '').split(';', 1)[0].indexOf('json') !== -1) {
try {
return JSON.parse(data);
} catch(e) {
// Oh well.
return {};
}
}
/**
* Copyright (c) 2011-2013 Fabien Cazenave, Mozilla.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
@cvan
cvan / trigger.js
Created February 7, 2014 18:02
trigger custom events in JS
if (!('CustomEvent' in window)) {
// For IE 9/10 lol.
function CustomEvent(eventName, params) {
params = params || {bubbles: false, cancelable: false, detail: undefined};
var e = document.createEvent('CustomEvent');
e.initCustomEvent(eventName, params.bubbles, params.cancelable, params.detail);
return e;
}
CustomEvent.prototype = window.CustomEvent.prototype;
window.CustomEvent = CustomEvent;