Skip to content

Instantly share code, notes, and snippets.

View sstur's full-sized avatar

Simon Sturmer sstur

View GitHub Profile
@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 / 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:
(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')
var f = function() {
if (a) {
this.add('x' + a + ':function()');
} else {
this.part.is.not.correctly.syntax.highlighted();
}
};
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() {
@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:

@sstur
sstur / console-normalize.js
Created January 23, 2014 00:11
Normalize console.log/warn/error
(function(console) {
var _apply = Function.prototype.apply;
if (!console) {
window.console = {
log: function() {},
warn: function() {},
error: function() {}
};
} else
if (console.log && typeof console.log.apply == 'unknown') {
@sstur
sstur / stackTrace.js
Last active January 4, 2016 01:19
Get a stack trace the hard way..
var stackTrace = (function() {
var _toString = Object.prototype.toString;
var _slice = Array.prototype.slice;
function inArray(array, el) {
for (var i = 0, len = array.length; i < len; i++) {
if (array[i] === el) return true;
}
return false;
}
@sstur
sstur / gist:8545473
Created January 21, 2014 18:30
JavaScript Reserved Words
abstract, boolean, break, byte, case, catch, char, class, const, continue, debugger,
default, delete, do, double, else, enum, export, extends, false, final, finally,
float, for, function, goto, if, implements, import, in, instanceof, int, interface,
long, native, new, null, package, private, protected, public, return, short, static,
super, switch, synchronized, this, throw, throws, transient, true, try, typeof, var,
volatile, void, while, with
@sstur
sstur / string-splice.js
Created December 12, 2013 19:32
String splice similar to array.splice: stringSplice('abcdef', 2, 2, '_') //=> ab_ef
function stringSplice(source, index, deleteChars, insert) {
insert = insert || '';
return source.slice(0, index) + insert + source.slice(index + Math.abs(deleteChars));
}