Skip to content

Instantly share code, notes, and snippets.

View danvk's full-sized avatar

Dan Vanderkam danvk

View GitHub Profile
@danvk
danvk / gpt_batch_manager.py
Created September 17, 2024 13:38
Python Type Hint Autocomplete repro
#!/usr/bin/env python
"""Manage multiple batches on OpenAI"""
import json
import hashlib
import os
import sys
import time
from typing import Optional, TypedDict, get_type_hints
@danvk
danvk / unlocated-digital-ids.csv
Created August 28, 2024 14:39
Digital IDs that are missing from OldNYC
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
DIGITAL_ID
717743f
2040871
717939f
1516983
1640784
703777f
1629993
1630288
1629362
@danvk
danvk / parser.test.ts
Created December 6, 2023 03:13
Lisp Parser
import { assertEquals } from "https://deno.land/[email protected]/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
Loading
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>