Skip to content

Instantly share code, notes, and snippets.

@zross
zross / index.html
Last active April 11, 2024 08:33
Animate path on Leaflet map using D3 (Gimme!, Proletariat)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7/leaflet.css" />
<script src="http://d3js.org/d3.v3.min.js" type="text/javascript"></script>
<script src="http://cdn.leafletjs.com/leaflet-0.7/leaflet.js"></script>
<script src='https://api.tiles.mapbox.com/mapbox.js/v1.6.4/mapbox.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox.js/v1.6.4/mapbox.css' rel='stylesheet' />
Feature: NPM notifies me when my dependencies are out of date
In order to avoid accidentally running the tests against out of
date dependencies, npm should notify me when I try to do so.
Scenario:
Given I have a package.json that declares a dependency on [email protected]
And I have run `npm install` and installed [email protected]
And my coworker updates package.json to depend on [email protected]
When I pull that change and run `npm test`
Then I should get an error
@Noitidart
Noitidart / about.md
Last active April 13, 2022 17:52 — forked from antichris/about.md
Adds a fully functional "Fork" button to your own Gist.

Fork your own Gist

This is a script that adds a fully functional Fork button to your own Gist.

If a Fork button is already present in the page, this bookmarklet will set focus to it instead of adding another one.

The change is temporary and the button will disappear as soon as you navigate away from that Gist (clicking the Fork button does this for you as well). Meaning you will have to run the script every new page load.

Firefox

Copy the contents from bookmarklet.js, open Scracthpad (Ctrl+F4), paste it there. Back in browser, swwitch to tab with your Gist you want to fork. Back in Scratchpad, "Run" it. Save and/or bookmark the Scratchpad file for future use.

@tyrasd
tyrasd / index.html
Last active August 29, 2015 13:55
2014 Sochi Olympics ski venues in the Krasnaya Polyana mountain cluster
<!DOCTYPE html>
<html>
<head>
<title>2014 Sochi Olympics ski venues in the Krasnaya Polyana mountain cluster</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!--leaflet-->
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.js"></script>
</head>
anonymous
anonymous / index.js
Created November 22, 2013 10:29
Gist from mistakes.io
// You can include libraries in mistakes
// with a magic function called require(),
// which simply loads javascript in a script tag.
require('https://raw.github.com/lodash/lodash/2.3.0/dist/lodash.js');
require('https://raw.github.com/tyrasd/osmtogeojson/gh-pages/osmtogeojson.js');
osmtogeojson(
{elements:[{type:"node",id:"-1",lat:1.23,lon:3.21}]},
{flatProperties:true}
@tmcw
tmcw / hexer.md
Last active December 28, 2015 03:38
Hexer is Cool

hexer is cool. It's a new project by Howard Butler that makes hexagon binned files out of point files.

Building hexer

This worked on my system (OSX 10.9, git via homebrew)

git clone https://github.com/hobu/hexer.git
@javisantana
javisantana / parse_osm.js
Last active December 27, 2015 08:59
quick'n'dirty conversor from OSM xml to GeoJSON using d3
// you should use https://github.com/tyrasd/osmtogeojson if you are gonna build something real
function osm2geojson(xml) {
var parser = new DOMParser();
var doc = parser.parseFromString(xml, 'text/xml');
var points = {}
d3.select(doc).selectAll('node').each(function() {
var n = d3.select(this)
@tmcw
tmcw / json.md
Created August 15, 2013 20:27
Why JSONP is a terrible idea and I will never use it again

Moral Concerns

JSONP is not actually JSON with padding, it's Javascript code that's executed. JSON is not a real subset of Javascript and the way it is not is important to us: via UTFGrid, we are all UTF-8 masters.

JSONP is not safe: it's Javascript that's executed. It's trivial to XSS with JSONP, because JSONP is XSS. Just have a call like mapbox.load('foo.tilejson', …) and if foo.tilejson gets replaced with destroyYoursite(), it gets run. Compare to JSON.parse, which is, on purpose, not eval.

Practical Concerns

JSONP is questionable in terms of performance. To be fast, you want to have the same callback all the time so that you can cache the response. But this leads to a page like

@tyrasd
tyrasd / index.html
Last active January 9, 2016 21:56 — forked from tmcw/index.html
compares OSM-Carto with the older "Mapnik" style. http://bl.ocks.org/tyrasd/raw/6164696
<!DOCTYPE html>
<html>
<head>
<script src='http://api.tiles.mapbox.com/mapbox.js/v0.6.7/mapbox.js'></script>
<link href='http://api.tiles.mapbox.com/mapbox.js/v0.6.7/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>