Skip to content

Instantly share code, notes, and snippets.

View sstur's full-sized avatar

Simon Sturmer sstur

View GitHub Profile
import RichTextEditor from 'react-rte';
import React from 'react';
class StatefulRichTextEditor {
constructor() {
this.state = {
value: RichTextEditor.createEmptyValue(),
};
}
@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 / 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;
}