Skip to content

Instantly share code, notes, and snippets.

Avatar

Johan Sundström johan

View GitHub Profile
@johan
johan / README.md
Last active Nov 23, 2020
A micro-library (4k minified) for DRY:ing up the boring boilerplate of user scripts.
View README.md

on.js

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 / index.md
Last active Nov 20, 2020
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 / 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 / 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 / readme.md
Last active Oct 15, 2020 — 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 / JSXTransformer.min.js
Last active Sep 3, 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
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
Last active Jul 3, 2020 — forked from NV/Readme.md
JS debug breakpoint / log snippets
View README.md

stopBefore.js

2min screencast

These tools inject a breakpoint, console.log or console.count in any function you want to spy on via stopBefore('Element.prototype.removeChild') or ditto stopAfter, logBefore / logAfter / logAround / logCount.

Works in Chrome DevTools and Safari Inspector; Firefox dev tools reportedly less so.

@johan
johan / editdistance
Last active Apr 29, 2020
list edit distances between all inputs of the same length, ascending order
View editdistance
#! /usr/bin/env node
// for a JSON array of strings, or an array of lines on stdin,
// shows edit distances between all the inputs, ascending
const fs = require('fs');
const ed = require('edit-distance');
// read all strings from stdin:
let names = fs.readFileSync(0, 'utf-8');
@johan
johan / index.html
Created Nov 25, 2011 — forked from johan/dnd.js
Animated Draggable Spinny Globe
View index.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>d3.js Spinny Globe from Mike Bostock's SVG Open 2011 keynote</title>
<script src="http://mbostock.github.com/d3/d3.js"></script>
<script src="http://mbostock.github.com/d3/d3.geo.js"></script>
<link type="text/css" rel="stylesheet" href="http://mbostock.github.com/d3/talk/20111018/style.css"/>
<link type="text/css" rel="stylesheet" href="http://mbostock.github.com/d3/talk/20111018/colorbrewer/colorbrewer.css"/>
<style type="text/css">
You can’t perform that action at this time.