Skip to content

Instantly share code, notes, and snippets.

Johan Sundström johan

Block or report user

Report or block johan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
johan / JSXTransformer.min.js
Last active Jan 16, 2020
Week Calendar of Life
View JSXTransformer.min.js
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.JSXTransformer=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(_dereq_,module,exports){"use strict";var ReactTools=_dereq_("../main");var inlineSourceMap=_dereq_("./inline-source-map");var headEl;var dummyAnchor;var inlineScriptCount=0;var supportsAccessors=Obj
johan /
Last active Jan 16, 2020 — forked from benelsen/
Earth, night and day sides.
johan /
Last active Jan 16, 2020
Solar Analemmas Anywhere

Hourly solar analemmas (ignoring daylight savings time) as seen from anywhere in the world in 2014.

johan / index.html
Last active Jan 16, 2020
Vacation Day Planner
View index.html
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<base href=";m1=05&amp;y1=2018&amp;d2=9&amp;m2=7&amp;y2=2018&amp;">
<title>Vacation Day Planner</title>
const sumUp = (td) => { const t = td.parentNode.parentNode, r = t.rows[t.rows.length-1], c = r.cells[r.cells.length-1]; c.textContent = Array.from(t.querySelectorAll('td')).filter(c => c.classList.contains('hl-b') || c.classList.contains('hl')).length; = '#000'; }
document.onclick = (e) => { if ( === 'TD') { const t =, cl = t.classList; cl.contains('hl-b') || cl.contains('hl') ? cl.remove('hl-b', 'hl') : cl.add('hl'); sumUp(t); } };
const pad = (n) => (n < 10 ? '0' : '') + n;
const date = (t) => t.getFullYear() + '-' + pad(t.getMonth() + 1) + '-' + pad(t.getDate());
const ONE_DAY = 864e5;
const ghostThePast = () => {
johan /
Last active Jan 11, 2020
osx + java 7 = painfully easy

Step 1

Does your osx terminal speak java 7? Start and try: java -version:

> java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
johan /
Last active Jan 10, 2020 — forked from johan/autofork.js
(Re)fork any gist, including your own

Want to fork your own gists? No fork button? No problem! Install this user script by clicking refork.user.js' "raw" link down below: ⇓

johan /
Last active Dec 6, 2019
A micro-library (4k minified) for DRY:ing up the boring boilerplate of user scripts.


The fun part of user scripting is deciding what happens. The boring part is scavenging the DOM for bits of templated data, or elements you want to mod.

Have on.js do it for you!

johan / laughing-man.svg
Created Jul 6, 2011
The Laughing Man (Ghost in the Shell), 1000 byte SVG :-)
View laughing-man.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
johan /
Last active Sep 26, 2019
LocalStorage Cross-window notifications

Take a website with some kind of notifications system showing the user a count of their unread notifications or similar. (Facebook, Google+, GMail et c.)

Now perform an action in one browser tab, that changes or clears the count. Does this immediately propagate to all other tabs you have open on the site?

If not – this example is for you!

As it happens, this is really easy to do in

johan / d3.v2.min.js
Last active Aug 23, 2019
National Conventions Word Usage
View d3.v2.min.js
(function(){function e(e,t){try{for(var n in t)Object.defineProperty(e.prototype,n,{value:t[n],enumerable:!1})}catch(r){e.prototype=t}}function t(e){var t=-1,n=e.length,r=[];while(++t<n)r.push(e[t]);return r}function n(e){return}function r(){}function i(e){return e}function s(){return this}function o(){return!0}function u(e){return typeof e=="function"?e:function(){return e}}function a(e,t,n){return function(){var r=n.apply(t,arguments);return arguments.length?e:r}}function f(e){return e!=null&&!isNaN(e)}function l(e){return e.length}function c(e){return e==null}function h(e){return e.trim().replace(/\s+/g," ")}function p(e){var t=1;while(e*t%1)t*=10;return t}function d(){}function v(e){function t(){var t=n,r=-1,i=t.length,s;while(++r<i)(s=t[r].on)&&s.apply(this,arguments);return e}var n=[],i=new r;return t.on=function(t,r){var s=i.get(t),o;return arguments.length<2?s&&s.on:(s&&(s.on=null,n=n.slice(0,o=n.indexOf(s)).concat(n.slice(o+1)),i.remove(t)),r&&n.push(i.set(t,{on:r})),e)}
You can’t perform that action at this time.