Skip to content

Instantly share code, notes, and snippets.

@trg1984
trg1984 / addPointer.js
Created January 18, 2017 13:15
Adds a red corner pointer to the given pixel coordinates. Useful for quickly determining where exactly the given coordinates are on the screen.
function addPointer(x, y) {
$('body').append('<div style="position:absolute; left: ' +
x +
'px; top: ' +
y +
'px; border-left: 3px solid red; border-top: 3px solid red; box-sizing: border-box; width: 10px; height: 10px; z-index:1000000000;"></div>');
}
@trg1984
trg1984 / announceTime.js
Created January 7, 2017 23:18
Converts a Date object to its relative verbal description.
var timeIntervals = [
{start: 0, caption: 'Just now.'},
{start: 60 * 1000, caption: 'A minute ago.'},
{start: 2 * 60 * 1000, caption: '@1 minutes ago.'},
{start: 60 * 60 * 1000, caption: 'An hour ago.'},
{start: 2 * 60 * 60 * 1000, caption: '@2 hours ago.'},
{start: 24 * 60 * 60 * 1000, caption: 'Yesterday.'},
{start: 2 * 24 * 60 * 60 * 1000, caption: '@3 days ago.'},
{start: 7 * 24 * 60 * 60 * 1000, caption: 'A week ago.'},
{start: 14 * 24 * 60 * 60 * 1000, caption: '@4 weeks ago.'},