Skip to content

Instantly share code, notes, and snippets.

View tregusti's full-sized avatar

Glenn Jorde tregusti

View GitHub Profile
@tregusti
tregusti / currentElement.js
Last active December 21, 2015 08:22
Output currently selected element in the browser console
(function() {
var a
setInterval(function() {
var a1 = document.activeElement
if (a !== a1) {
a = a1
var s = a.nodeName.toLowerCase()
if (a.id) s += '#' + a.id
if (a.className.trim()) s += '.' + a.className.trim().split(/\s/g).join('.')
console.log('focused: %s %o', s, a)
@tregusti
tregusti / except.js
Created August 22, 2013 15:07
Allow easy modification to key/value objects.
function With( key, value ) {
this[key] = value;
return this;
};
function Except( key ) {
delete this[key];
return this;
};
exports.augment = function() {
(function() {
// Run this script in the console to add the foo cae event to the calendar.
'use strict';
let url = document.location.href;
let title = document.querySelector('h1').textContent;
let timestamp = document.querySelector('.eventtime p').textContent.trim();
let datematch = timestamp.match(/, (\w+) (\d+)/);
let from = new Date();
from.setMonth('January Februari March April May June July August September October November December'.split(' ').indexOf(datematch[1]));

Såpbubblor

När Miliam fyllde ett år, så lektes det med stora såpbubblor, och det var många som ville veta hur man gjorde en riktig såpbubblemix. Så här kommer receptet.

Ingredienser

  • ½ tsk guarkärnmjöl
  • 2 tsk glycerin
  • 1 liter vatten
  • 2½ msk handdiskmedel
function NotImplementedError(message) {
this.message = message || "";
}
NotImplementedError.prototype = Object.create(Error.prototype, {
constructor: { value: NotImplementedError },
name: { value: 'NotImplementedError' },
stack: { get: function() {
return new Error().stack;
}},
});