Skip to content

Instantly share code, notes, and snippets.

const modhash = window.reddit.modhash;
const width = 33;
const height = 9;
var sec = 0, index = Math.floor(Math.random() * (width * height));
setInterval(() => console.log("Drawing in " + (sec--) + " seconds"), 1e3);
const draw = seconds => {
index++
index = index % (width * height);
sec = seconds = Math.ceil(seconds)
setTimeout(() => {
const modhash = window.reddit.modhash;
const width = 60;
const height = 10;
var sec = 0, index = Math.floor(Math.random() * (width * height));
setInterval(() => console.log("Drawing in " + (sec--) + " seconds"), 1e3);
const draw = seconds => {
index++
index = index % (width * height);
sec = seconds = Math.ceil(seconds)
setTimeout(() => {
@tomsterritt
tomsterritt / gist:811e1d5f33a22e70569e
Created August 21, 2014 19:51
Custom URI scheme redirect with http alternative
var redirect = function (location) {
var iframe = document.createElement('iframe');
iframe.setAttribute('src', location);
iframe.setAttribute('width', '1px');
iframe.setAttribute('height', '1px');
document.documentElement.appendChild(iframe);
iframe.parentNode.removeChild(iframe);
iframe = null;
};
@tomsterritt
tomsterritt / gist:8985677
Created February 13, 2014 22:57
Track copy & paste on Google Analytics
// Track copied content adapted from Onderweg & Tim Down by Robert Kingston - http://www.optimisationbeacon.com/
// Get Selection Text function by Tim Down - http://stackoverflow.com/a/5379408/458627
function getSelectionText() {
var e = "";
if (window.getSelection) {
e = window.getSelection().toString()
} else if (document.selection && document.selection.type != "Control") {
e = document.selection.createRange().text
}
return e