Zoomable/rotatable world globe that uses orthographic projection. Drag behavior is enhanced as described here: https://www.jasondavies.com/maps/rotate/
Performance is not good due to redrawing whole world upon zoom/drag.
// ts 3.6x | |
function debounce<T extends Function>(cb: T, wait = 20) { | |
let h = 0; | |
let callable = (...args: any) => { | |
clearTimeout(h); | |
h = setTimeout(() => cb(...args), wait); | |
}; | |
return <T>(<any>callable); | |
} |
{ | |
"presets": ["es2015"], | |
"plugins": ["transform-async-to-generator"] | |
} |
import decamelize from 'decamelize'; | |
import { fromGlobalId } from 'graphql-relay'; | |
import pluralize from 'pluralize'; | |
import getItem from '../api/getItem'; | |
const types = {}; | |
const endpoints = {}; | |
const getItemOverrides = {}; |
// Run this from the commandline: | |
// phantomjs runner.js | ffmpeg -y -c:v png -f image2pipe -r 24 -t 10 -i - -c:v libx264 -pix_fmt yuv420p -movflags +faststart output.mp4 | |
var page = require('webpage').create(), | |
address = 'http://s.codepen.io/phanan/fullembedgrid/YPLewm?type=embed&safe=true&_t=1424767252279', | |
duration = 3, // duration of the video, in seconds | |
framerate = 24, // number of frames per second. 24 is a good value. | |
counter = 0, | |
width = 500, | |
height = 500; |
; a hand-made GIF containing valid JavaScript code | |
; abusing header to start a JavaScript comment | |
; inspired by Saumil Shah's Deadly Pixels presentation | |
; Ange Albertini, BSD Licence 2013 | |
; yamal gifjs.asm -o img.gif | |
WIDTH equ 10799 ; equivalent to 2f2a, which is '/*' in ASCII, thus starting an opening comment |
function download(fileUrl, apiPath, callback) { | |
var url = require('url'), | |
http = require('http'), | |
p = url.parse(fileUrl), | |
timeout = 10000; | |
var file = fs.createWriteStream(apiPath); | |
var timeout_wrapper = function( req ) { | |
return function() { |
Zoomable/rotatable world globe that uses orthographic projection. Drag behavior is enhanced as described here: https://www.jasondavies.com/maps/rotate/
Performance is not good due to redrawing whole world upon zoom/drag.
A quick overview of the node.js streams interface with basic examples.
This is based on @brycebaril's presentation, Node.js Streams2 Demystified
Streams are a first-class construct in Node.js for handling data.
Think of them as as lazy evaluation applied to data.
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>d3 geo map</title> | |
<meta charset="utf-8"> | |
<style> | |
svg { | |
border: 1px solid #ccc; | |
} |
Example illustrating zoom and pan with a "rolling" Mercator projection. Drag left-right to rotate projection cylinder, and up-down to translate, clamped by max absolute latitude. Ensures projection always fits properly in viewbox.