Skip to content

Instantly share code, notes, and snippets.

View wavded's full-sized avatar
🐢
Turtles all the way

Marc Harter wavded

🐢
Turtles all the way
View GitHub Profile
@wavded
wavded / gen.js
Created April 23, 2014 21:55
TCO in Generators
function* fibGen (current, next) {
yield current
yield* fibGen(next, current + next)
}
for (var num of fibGen(0,1));
// function* fibGen (current, next) {
// ^
// RangeError: Maximum call stack size exceeded
@wavded
wavded / image format test results
Created January 20, 2014 20:44
Map tile format r&d, based on resolutions
JPEG / No Imagery / Fresh Cache
250000 - 196.5k
150000 - 212.8k
100000 - 1.2m
80000 - 1.2m
50000 - 1m
35000 - 831.1k
32000 - 735.1k
25000 - 772.8k
@wavded
wavded / commands.sh
Last active January 3, 2016 10:19
Misc Commands
# A makeshift SMTP server that logs all messages to the console
python -m smtpd -n -c DebuggingServer localhost:25
# Spotlight search results in terminal
mdfind
@wavded
wavded / test-single.geojson
Last active December 27, 2015 19:19
ogr2ogr.test
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
// works
var fs = require('fs'),
spawn = require('child_process').spawn,
out = fs.openSync('./out.log', 'a'),
err = fs.openSync('./out.log', 'a');
var child = spawn('prg', [], {
detached: true,
stdio: [ 'ignore', out, err ]
});
@wavded
wavded / setup.sh
Created July 31, 2013 15:56
Ubuntu PhantomJS Setup
wget https://phantomjs.googlecode.com/files/phantomjs-1.9.1-linux-x86_64.tar.bz2
tar xvf phantomjs-1.9.1-linux-x86_64.tar.bz2
sudo mv phantomjs-1.9.1-linux-x86_64 /usr/local/lib/phantomjs
sudo ln -s /usr/local/lib/phantomjs/bin/phantomjs /usr/local/bin/phantomjs
function map (arr, func) {
return Promise.resolve().then(function () {
return arr.map(function (el) { return func(el) })
}).all()
}
function mapSeries (arr, func) {
let currentPromise = Promise.resolve()
let promises = arr.map(function (el) {
return currentPromise = currentPromise.then(function () {
@wavded
wavded / series.js
Last active December 20, 2015 05:09
var fs = require('fs')
var Q = require('q')
var fs_stat = Q.denodeify(fs.stat)
var files = ['./fixtures/file1', './fixtures/file2', './fixtures/file3']
function getStatsSeries (files) {
var d = Q.defer()
var results = []
files.reduce(function (last, file) {
@wavded
wavded / promise.js
Last active May 6, 2021 13:25
Promise A+ Implementation
"use strict"
var Promise = function () {
this.state = 'pending'
this.thenables = []
}
Promise.prototype.resolve = function (value) {
if (this.state != 'pending') return
this.state = 'fulfilled'
{"baseURL":"http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/$%7Bz%7D/$%7By%7D/$%7Bx%7D","opacity":1,"singleTile":false,"type":"XYZ","maxExtent":[-20037508,-20037508,20037508,20037508.34],"tileSize":[256,256],"extension":"%7D","resolutions":[156543.0339,78271.51695,39135.758475,19567.8792375,9783.93961875,4891.969809375,2445.9849046875,1222.99245234375,611.496226171875,305.7481130859375,152.87405654296876,76.43702827148438,38.21851413574219,19.109257067871095,9.554628533935547,4.777314266967774,2.388657133483887,1.1943285667419434,0.5971642833709717,0.29858214168548586,0.14929107084274293,0.07464553542137146]}