Skip to content

Instantly share code, notes, and snippets.

View johan's full-sized avatar

Johan Sundström johan

View GitHub Profile
@johan
johan / README.md
Created September 24, 2015 20:54
getXPathTo / getRootXPathTo

I was looking for two clean, tiny and elegant element-to-xpath functions producing short and complete xpaths like id("main")/ul/li[3] or /html/body/ul/li[3] for a given element, and figured I'd just craft my own.

@johan
johan / README.md
Last active September 26, 2019 14:19
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
johan / Svenska Akademien.svg
Last active September 17, 2015 18:53
Svenska Akademien + SAOB
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@johan
johan / d3.v2.min.js
Last active August 23, 2019 03:34
National Conventions Word Usage
(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 Array.prototype.slice.call(e)}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)}
@johan
johan / README.md
Last active September 24, 2015 05:23
Portal Signs

I just want the stickers. :-) (Original)

@johan
johan / google-2015.svg
Last active September 14, 2015 02:13
Google logo, September 2015
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@johan
johan / README.md
Last active August 31, 2015 08:26
Movielens guesses as to how I'd rate HBO now movies

Cross-referencing HBO movies with Movielens data

I decided to try that free month of HBO Now this weekend. It didn't have more than 377 movies when I checked, and it had no way of guessing at what I'd like. Fortunately for me, I have an old Movielens account, which has a fair idea of things I like, so I figured I'd cross-reference the HBO inventory with their guesses at what I'd like, given what I've seen and liked or disliked.

@johan
johan / README.md
Last active September 18, 2015 02:55
git rsif

git rsif

Usage

git rsif 'REPLACE-FROM' 'REPLACE-WITH'

Background

@johan
johan / index.html
Last active August 29, 2015 14:26
Sleep visualization based on massaged data excerpts from Sleep Time app
<div id="sleep"></div>
@johan
johan / README.md
Last active March 1, 2024 05:26
Solar Analemmas Anywhere

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