Skip to content

Instantly share code, notes, and snippets.

View sstur's full-sized avatar

Simon Sturmer sstur

View GitHub Profile
@sstur
sstur / keybase.md
Last active August 29, 2015 14:01
keybase.md

Keybase proof

I hereby claim:

  • I am sstur on github.
  • I am sstur (https://keybase.io/sstur) on keybase.
  • I have a public key whose fingerprint is 71E5 0A75 B701 F9DC F7F2 55C0 F227 C435 01EE 9CAE

To claim this, I am signing this object:

This file has been truncated, but you can view the full file.
(function() {
if (window.document.querySelector && window.document.body) {
if (!window.console) {
window.console = {};
}
if (!("log" in console)) {
/**
* @return {undefined}
*/
console["log"] = function() {
var f = function() {
if (a) {
this.add('x' + a + ':function()');
} else {
this.part.is.not.correctly.syntax.highlighted();
}
};
(function() {
var rows = Array.prototype.filter.call(document.querySelectorAll('.player-list-table tr'), function(row) {
return !row.classList.contains('positionFilterApplied');
});
var results = rows.map(function(row) {
return [
row.querySelector('.player-position').firstChild.nodeValue,
row.querySelector('.player-name').firstChild.firstChild.nodeValue,
row.querySelector('.player-salary').firstChild.nodeValue
].join('\t')
@sstur
sstur / UTCDate.js
Created June 17, 2015 05:16
UTCDate as a subclass of Date
function UTCDate(a) {
var x;
switch (arguments.length) {
case 0:
x = new Date();
break;
case 1:
x = (typeof a === 'number') ? new Date(a) : new Date(Date.parse(a));
break;
default:
@sstur
sstur / MyDate.js
Last active August 29, 2015 14:23
Extend (subclass) native Date
function MyDate(a, b, c, d, e, f, g) {
var date;
switch (arguments.length) {
case 0:
date = new Date();
break;
case 1:
date = new Date(a);
break;
case 2:
@sstur
sstur / MyArray.js
Created July 7, 2015 17:44
Extend (subclass) native Array
function MyArray() {
var array = [];
if (arguments.length) {
array.push.apply(array, arguments);
}
// note: use `Object.setPrototypeOf` instead of __proto__ to be truly standards-compliant
array.__proto__ = MyArray.prototype;
return array;
}
@sstur
sstur / typeof.js
Last active October 3, 2015 17:48
A better typeof for JavaScript
function typeOf(o) {
var type = (o === null) ? 'null' : typeof o;
return (type == 'object') ? Object.prototype.toString.call(o).slice(8, -1).toLowerCase() : type;
}
//Example: typeOf(new Date()) => 'date'
@sstur
sstur / regexp-escape.js
Last active October 11, 2015 05:37
RegExp Escape
RegExp.escape = function(str) {
return str.replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&");
}
//Example: string.replace(new RegExp(RegExp.escape('a&b'), 'g'), 'c&d')
//Credit: http://simonwillison.net/2006/Jan/20/escape/#p-6
@sstur
sstur / format-number.js
Last active October 11, 2015 05:37
Format Number with Commas
function formatNumber(val) {
return String(val).replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}
//formatNumber('1000000') => '1,000,000'