Skip to content

Instantly share code, notes, and snippets.

View danvk's full-sized avatar

Dan Vanderkam danvk

View GitHub Profile
@danvk
danvk / parser.test.ts
Created December 6, 2023 03:13
Lisp Parser
import { assertEquals } from "https://deno.land/std@0.208.0/assert/mod.ts";
import { parseLisp, tokenize } from "./parser.ts";
Deno.test("tokenizer", () => {
const input = "(first (list 1 (+ 2 3) 9))";
assertEquals(
[...tokenize(input)],
["(", "first", "(", "list", 1, "(", "+", 2, 3, ")", 9, ")", ")"],
);
@danvk
danvk / tsp.geojson
Created June 1, 2023 00:17
An optimal route through the Catskills 3500 High Peaks
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@danvk
danvk / slide.gpx
Created February 19, 2023 15:55
Winter Hike on Slide (Does GitHub support GPX?)
<?xml version="1.0"?>
<gpx xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.1" creator="AllTrails.com" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
<metadata>
<name><![CDATA[Slide Mountain Winter Hike]]></name>
<desc><![CDATA[Sunny day for a winter hike. The trail was quite icy on the way up and we were happy to have our spikes. By the time we came down enough ice had melted that we took them off.]]></desc>
<link href="http://www.alltrails.com">
<text>AllTrails, LLC</text>
</link>
<bounds minlat="41.99887" minlon="-74.42762" maxlat="42.00864" maxlon="-74.38516"/>
</metadata>
@danvk
danvk / README.md
Created June 20, 2022 23:03
Pruning a transitive type dependency for TypeScript

Pruning a transitive type dependency for TypeScript

See [Stack Overflow: How can I completely hide an irrelevant directory of type declarations from TypeScript?][1].

This is mostly interesting as a template for using paths to prune the set of files considered by tsc when building a project.

Solution tsconfig.json:

{
@danvk
danvk / README.md
Created February 23, 2021 14:47
type-coverage repro

Type Coverage Repro

See plantain-00/type-coverage#83

$ yarn type-coverage --detail --ignore-catch --ignore-unread -p tsconfig.json
yarn run v1.22.4
$ /Users/danvk/code/type-coverage-toy/node_modules/.bin/type-coverage --detail --ignore-catch --ignore-unread -p tsconfig.json
6 / 6 100.00%
type-coverage success.

✨ Done in 0.94s.

@danvk
danvk / index.d.ts
Created February 20, 2021 20:38
Reviving the old @types/dygraphs tests
// Type definitions for dygraphs 2.1
// Project: http://dygraphs.com
// Definitions by: Dan Vanderkam <https://github.com/danvk>
// Martin Badin <https://github.com/martin-badin>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="google.visualization" />
declare namespace dygraphs {
type DataArray = Array<Array<number | Date | null>>;
@danvk
danvk / index.md
Last active November 15, 2020 19:16
JS Poland Talk

What is TypeScript?

TypeScript does two things:

  1. Compiles TypeScript to JavaScript ("transpiling").
  2. Performs static type analysis on your code.
async function f() { const funFact = await fetch('http://numbersapi.com/42');
@danvk
danvk / index.html
Created February 25, 2020 23:27
Flailing around with raycasting
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>Raycasting with Mapbox</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v1.4.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v1.4.0/mapbox-gl.css' rel='stylesheet' />
<style>
@danvk
danvk / h-index-top.csv
Created February 10, 2020 03:24
Top h-index orgs/users on GitHub
h-index organization
347 google
314 microsoft
216 apache
206 fossasia
203 sindresorhus
142 googlearchive
137 mozilla
133 alibaba
132 spatie
@danvk
danvk / h-index-top-50.csv
Created February 10, 2020 03:12
Comparison of the top 50 users/orgs by h-index and total stars
h-index org/user type Rank (h-index) Rank (stars)
347 google Organization 1 1
314 microsoft Organization 2 2
216 apache Organization 3 4
206 fossasia Organization 4 13
203 sindresorhus User 5 5
142 googlearchive Organization 6 ???
137 mozilla Organization 7 19
133 alibaba Organization 8 6
132 spatie Organization 9 65