Skip to content

Instantly share code, notes, and snippets.

View tmcw's full-sized avatar
💭
merging your prs

Tom MacWright tmcw

💭
merging your prs
View GitHub Profile
@tmcw
tmcw / team.js
Created November 8, 2013 15:52
// using reduce
var team = posts.team.reduce(function(prev, post, index, list) {
prev.push(post.metadata.title);
return prev;
}, []);
// using map
var team = posts.team.map(function(post) {
return post.metadata.title);
});

Welcome to OpenStreetMap You have just joined an international volunteer organization whose goal is nothing less than a rich, detail map of the whole world that is open-source. What does that mean? It means that this is a map whose data is available to everyone for free. OpenStreetMap is an important effort that will have impact around the globe. Millions who never have had access to geographical information now will have access to

@tmcw
tmcw / README.md
Created December 28, 2022 17:00
PMTiles to SVG

Request a single tile from PMTiles, use the vector-tiles module to read it, the d3-geo tools to turn it into a string. d3-geo is probably unnecessary.

This approach feels limited:

Requires restitching tiles if more than one. Limited attributes. Any tile-based solution is going to make compromises in favor of responsiveness and lightweight data. What this wants is completeness and non-sliced data.

@tmcw
tmcw / d3.md
Last active December 6, 2022 14:04
Accompaniment to dcjq

This is a more wordy, narrative accompaniment to my pretty bare presentation about d3 that I gave to the jQuery DC Meetup.

What is d3?

  • Not a chart library (though you can make charts with it)
  • Not a map library (though you can make maps with it)

Which is to say, d3 can be used for building things, but the 'atomic parts' are lower-level than bar graphs or projections or so on. This is a powerful fact. It also means that d3 is a good basis for simple interfaces, like Vega.js, that make its power accessible in other ways.

  • Not a compatibility layer (it doesn't work with bad browsers)
#import "stdio.h"
#import "time.h"
#import "string.h"
// make now
int main() {
time_t now;
int hour;
char ampm[2];
import { Portal } from "@radix-ui/react-portal";
import clsx from "clsx";
import { useAtom } from "jotai";
import { atomWithMachine } from "jotai/xstate";
import { useRouter } from "next/router";
import { useEffect } from "react";
import { assign, createMachine } from "xstate";
import clamp from "lodash/clamp";
@tmcw
tmcw / README.md
Created October 31, 2012 15:00
GIS with Python, Shapely, and Fiona Example 1 - CSV Files
const fs = require('fs');
const d3 = require('d3-dsv');
const path = require('path');
const yaml = require('js-yaml');
const toMarkdown = require('to-markdown');
d3.csvParse(
fs.readFileSync('./goodreads_library_export.csv', 'utf8')
).filter(row => {
return row['Exclusive Shelf'] !== 'to-read';