Skip to content

Instantly share code, notes, and snippets.

View johan's full-sized avatar

Johan Sundström johan

View GitHub Profile
@johan
johan / jquery.nodoubletapzoom.js
Created March 15, 2012 22:59
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).
// 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
Last active April 12, 2024 11:14
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
johan / laughing-man.svg
Created July 6, 2011 04:56
The Laughing Man (Ghost in the Shell), 1000 byte 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 March 1, 2024 05:26 — forked from mbostock/.block

Hourly solar analemmas (ignoring daylight savings time) as seen from San Francisco in 2014.

@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.

@johan
johan / chrome-addBookmarkRemoveListener.js
Created August 17, 2010 02:00
Like the chrome.bookmarks.onRemoved.addListener call at http://code.google.com/chrome/extensions/bookmarks.html#event-onRemoved but guaranteed to fire even if the onremove event fired on a containing folder
// makes sure fn gets called when bm_id is removed, whether it was a direct kill
// or it got caught in collateral damage from a recursive bookmark removal spree
function addBookmarkRemoveListener(bm_id, fn) {
// as we won't get an onRemoved callback for bm_id when any of its parents got
// removed recursively, keep a list of all its parents to know when to fire fn
function indexParentsFor(bm_id, bookmarks) {
function bookmarkParents(id, bms, path) {
////console.log('bookmarkParents(', id, bms, path, ')');
for (var i = 0, bm, found; bm = bms[i]; i++) {
if (bm.id === id) return path;

2023 Mission Statement:

HAI Global (HAI) empowers individuals to be potent, loving, contributing human beings.

HAI promotes personal growth and social change by replacing ignorance , shame, and fear with awareness

@johan
johan / index.md
Last active September 26, 2023 16:35
osx + java 7 = painfully easy

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 / README.md
Last active September 15, 2023 18:32
splunk country code unicode emoji flags
… | eval flag = printf("%c%c", 127452 + tonumber(substr(countrycode,1,1), 36), 127452 + tonumber(substr(countrycode,2,1), 36)),
         country=countrycode+" ("+percent+"%) "+flag

country code pie chart in splunk

@johan
johan / autofork.js
Created October 22, 2011 16:05 — forked from mbostock/autofork.js
Autoforking
var f = document.createElement("form");
f.method = "POST";
f.action = "/fork" + location.pathname;
f.appendChild(document.querySelector("input[name=authenticity_token]"));
f.submit();