This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getRandomPayload() { | |
return { | |
ts: new Date().valueOf(), | |
date: { | |
epoc: new Date().valueOf(), | |
iso: new Date().toISOString(), | |
local: new Date().toString(), | |
utc: new Date().toUTCString() | |
}, | |
float: Math.random(), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
const body = document.querySelector("body"); | |
const sources = { | |
"google": "https://www.google.com/search?q=@", | |
"amazon": "https://www.amazon.co.uk/s?k=@", | |
"gutenberg": "https://www.gutenberg.org/ebooks/authors/search/?query=@", | |
"etymology": "https://www.etymonline.com/search?q=@", | |
"dictionary": "https://www.dictionary.com/browse/@", | |
"wikipedia": "https://en.wikipedia.org/wiki/@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(root, factory, NS="myfunction") { if (typeof define === "function" && define.amd) { define([], factory); } else if (typeof exports === "object") { module.exports = factory(); } else { root[NS] = factory(); } })(this, function() | |
{ | |
/* | |
myfunction | |
Tell the user what your function does. | |
And perhaps leave them a usage example | |
NOTE: don't forget to change NS="myfunction" | |
that appears in the UML decoration, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(root, factory, NS = "Base64") { if (typeof define === "function" && define.amd) { define([], factory); } else if (typeof exports === "object") { module.exports = factory(); } else { root[NS] = factory(); } })(this, function() | |
{ | |
/* | |
Base64 library | |
Lets you encode with UTF-16 or UTF-8 | |
https://gist.github.com/fliptopbox/dfbb7ce14730ba1533d48329e4d7740a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Console log index by color | |
Creates a window method that returns an Array of | |
arguments to colour code the console.log output | |
Each log has a timestamp, and time diff of the last log, | |
the log message is uniquely coloured according | |
to the 1st string in the argument list | |
Usage: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
'AF' : 'Afghanistan', | |
'AX' : 'Aland Islands', | |
'AL' : 'Albania', | |
'DZ' : 'Algeria', | |
'AS' : 'American Samoa', | |
'AD' : 'Andorra', | |
'AO' : 'Angola', | |
'AI' : 'Anguilla', | |
'AQ' : 'Antarctica', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
a bookmarklet that dumps localStorage | |
and saves the stringified JSON | |
to your downloads folder. | |
1. createa new bookmark (page) | |
2. in the address field type: | |
javascript: .... (paste below code) | |
3. Click the new button | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ms; | |
var runtime; | |
var i; | |
var total; | |
var diff; | |
var incr; | |
var prev = 0; | |
function updater (target, rtime, msec) { | |
if(target) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(e,t) { | |
console.log('%s\nKilroy was here.', t.replace(/\w/g, function(x) {return e[x];})); | |
}({a:' ',l:'▀',i:'▄',e:'█',n:'\n'}, "aaaliaaailaanaaieleeeleianaeleeeeeeelenaeaellllleaenaaaallallaaan")); | |
console.log output: | |
▀▄ ▄▀ | |
▄█▀███▀█▄ | |
█▀███████▀█ | |
█ █▀▀▀▀▀█ █ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.shuffleAndClip = function (len) { | |
var array = this; | |
if(len && array.length && len > array.length - 1) { | |
len = null; | |
} | |
for(var rnd, value, i = array.length; i; | |
rnd = Math.floor(Math.random() * i), | |
value = array[--i], | |
array[i] = array[rnd], | |
array[rnd] = value); |
NewerOlder