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
johan / README.md
Last active Sep 26, 2019
LocalStorage Cross-window notifications
View README.md

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 / 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 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 / index.html
Created Jul 20, 2012
HTML5 GPS tracker
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>HTML5 GPS</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="stylesheet" href="style.css">
</head>
@johan
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
johan / readme.md
Last active May 15, 2019 — forked from johan/autofork.js
(Re)fork any gist, including your own
View readme.md

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
johan / index.md
Last active May 13, 2019
osx + java 7 = painfully easy
View index.md

Step 1

Does your osx terminal speak java 7? Start Terminal.app 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
johan / jquery.nodoubletapzoom.js
Created Mar 15, 2012
A jQuery plugin to selectively disable the iOS double-tap-to-zoom action on specific page elements (and have that generate two click events instead).
View jquery.nodoubletapzoom.js
// jQuery no-double-tap-zoom plugin
// Triple-licensed: Public Domain, MIT and WTFPL license - share and enjoy!
(function($) {
var IS_IOS = /iphone|ipad/i.test(navigator.userAgent);
$.fn.nodoubletapzoom = function() {
if (IS_IOS)
$(this).bind('touchstart', function preventZoom(e) {
var t2 = e.timeStamp
@johan
johan / README.md
Created Oct 28, 2011
User script to view SVG files both as image and text at gist.github.com
View README.md

Click "raw" below to install. Requires Google Chrome, Firefox + Greasemonkey, or some other browser supporting user scripts / content scripts / user javascript.

@johan
johan / octocat.svg
Created Jun 4, 2011
Github octocat avatar, SVG format
View octocat.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@johan
johan / grep.js
Created May 9, 2013
Use grep to find direct/inherited properties of an object or function, or grep.own for direct properties only. (Great for Chrome 29's devtools' Script snippets panel.)
View grep.js
/* Examples:
Use grep with two arguments to find inherited or direct properties of an object:
> grep(document, 'get') // see all properties case insensitively matching *get*:
{ getCSSCanvasContext: function getCSSCanvasContext() { [native code] }
, getElementById: function getElementById() { [native code] }
, getElementsByClassName: function getElementsByClassName() { [native code] }
, getElementsByName: function getElementsByName() { [native code] }
, getElementsByTagName: function getElementsByTagName() { [native code] }
You can’t perform that action at this time.