Skip to content

Instantly share code, notes, and snippets.

View johan's full-sized avatar

Johan Sundström johan

View GitHub Profile
@johan
johan / us-counties.json
Created November 21, 2012 04:20 — forked from mbostock/.block
TopoJSON Examples
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@johan
johan / gist-logs.user.js
Created October 25, 2012 09:06 — forked from noromanba/gist-logs.user.js
Show commit logs on Gist for Greasemonkey
// ==UserScript==
// @name gist logs
// @namsgpace https://www.hatena.ne.jp/noromanba/
// @description Show commit logs on Gist for Greasemonkey
// @include https://gist.github.com/*
// @grant GM_xmlhttpRequest
// @version 2012.10.12.2
// @license WTFPL http://sam.zoy.org/wtfpl/ (Do What The Fuck You Want To Public License)
// @contributor satyr https://gist.github.com/107780
// @contributor saitamanodoruji https://gist.github.com/2653937
@johan
johan / intersections.js
Created October 20, 2012 06:38 — forked from mbostock/intersections.js
Circle-Circle Intersection
function intersections(a, b) {
var R = a.r,
r = b.r,
dx = b.x - a.x,
dy = b.y - a.y,
d = Math.sqrt(dx * dx + dy * dy),
x = (d * d - r * r + R * R) / (2 * d),
y = Math.sqrt(R * R - x * x);
dx /= d;
dy /= d;
@johan
johan / getBackgroundImages.js
Created October 18, 2012 22:07 — forked from donut/getBGImgURLsFromCSSs.js
Produces an array of background-image urls used in the page
/* Builds a list of background image urls from inline styles / linked stylesheets
*
* @return {array}
* Array of unique absolute image URLs from inline styles/readable style sheets
*/
function getBackgroundImages(doc) {
doc = doc || document;
var sheets = doc.styleSheets
, url_re = /\burl[(\s]+['"]?([^"')]+)["']?[\s)]+/g
, _slice = Array.prototype.slice
@johan
johan / ios-test.css
Created August 16, 2012 22:58 — forked from mattyoho/ios-test.css
iOS Media Queries
// iOS Media Queries
// Goal: capture styles for iPhone, -3G, -3GS, -4, -4S, iPad, -2 and -3
//
// Author: Tony Schneider (@tonywok)
// Please tell me where I fail. :)
// iPhone v(4,4S) portrait
// test: black text (overwritten by v* portrait) with blue background
@media all and (-webkit-min-device-pixel-ratio: 2) and (orientation: portrait) {
a {
@johan
johan / brown.svg
Created July 20, 2012 07:17 — forked from johan/index.html
HTML5 GPS plotter
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@johan
johan / github-logo.svg
Created June 25, 2012 00:20 — forked from johan/github-logo.svg
SVG font exposition
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@johan
johan / github-logo.svg
Created June 24, 2012 23:24 — forked from johan/github-logo.svg
Github social coding logo, semantic 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 June 14, 2012 19:49 — forked from mbostock/.block
SVG Path Cleaning
<!DOCTYPE html>
<meta charset="utf-8">
<script src="http://d3js.org/d3.v2.js?2.9.1"></script>
<svg viewBox="0 0 2000 1625.4" width="960" height="500">
<path fill="#52ade5" d="m2e3 192.42c-73.58 32.64-152.67 54.69-235.66 64.61 84.7-50.78 149.77-131.19 180.41-227.01-79.29 47.03-167.1 81.17-260.57 99.57-74.84-79.75-181.48-129.57-299.5-129.57-226.6 0-410.33 183.71-410.33 410.31 0 32.16 3.63 63.48 10.63 93.51-341.02-17.11-643.37-180.47-845.74-428.72-35.32 60.6-55.56 131.09-55.56 206.29 0 142.36 72.44 267.95 182.54 341.53-67.26-2.13-130.54-20.59-185.85-51.32-.04 1.71-.04 3.42-.04 5.16 0 198.8 141.44 364.64 329.15 402.34-34.43 9.38-70.68 14.4-108.1 14.4-26.44 0-52.15-2.58-77.2-7.36 52.22 163.01 203.75 281.65 383.3 284.95-140.43 110.06-317.35 175.66-509.6 175.66-33.12 0-65.79-1.95-97.88-5.74 181.59 116.42 397.27 184.36 628.99 184.36 754.73 0 1167.46-625.24 1167.46-1167.47 0-17.79-.41-35.48-1.2-53.08 80.18-57.86 149.74-130.12 204.75-212.41"/>
</svg>
<script>
var svg = d3.select("svg"),
path = svg.select("path")
@johan
johan / google-map-marker-with-shadow.js
Created May 21, 2012 17:02 — forked from simonw/google-map-marker-with-shadow.js
google-map-marker-with-shadow.js
/* Here's how to add a coloured marker to a Google Map with a shadow in the
right place.
The pin itself used to be dynamically generated via Google Charts:
//chart.apis.google.com/chart?chst=d_map_pin_letter&chld=|3491FF|000000
documented here:
https://developers.google.com/chart/image/docs/gallery/dynamic_icons
Note however that this API was marked as deprecated on April 20th 2012
although it's not clear when or if it will be turned off.