Skip to content

Instantly share code, notes, and snippets.


Atul Varma toolness

View GitHub Profile
toolness / nycdb-analyze-hpd-corps-vs-head-officers.sql
Created Oct 29, 2020
NYCDB query to help compare HPD-registered corporation addresses vs. head officer addresses
View nycdb-analyze-hpd-corps-vs-head-officers.sql
CREATE FUNCTION pg_temp.address(hpd_contacts) RETURNS TEXT AS
CASE WHEN $1.businessstreetname IS NULL THEN
COALESCE($1.businesshousenumber, '') || ' ' ||
$1.businessstreetname ||
CASE WHEN $1.businessapartment IS NULL THEN
toolness / babel-cra-fun.js
Created Nov 19, 2019
Script to load a CRA app's babel config and run it w/ an additional example plugin.
View babel-cra-fun.js
// This file can be dropped into the root of a project created
// via CRA w/ typescript support, e.g.:
// yarn create react-app cra-babel-fun --typescript
// It's just a proof-of-concept that shows how we can load
// the app's babel config and add a Babel plugin that executes
// before everything else.
toolness /
Last active May 12, 2019
Install SDL2 libraries so Rust+MSVC can find them.
from pathlib import Path
from urllib.request import urlopen
from zipfile import ZipFile
from io import BytesIO
import os
import sys
assert 'win' in sys.platform, "We must be running on Windows."
MY_DIR = Path(__file__).parent.resolve()
toolness /
Created Apr 10, 2019
Create scaffolding for a new NYC-DB dataset.
This script makes it easy to create scaffolding for a new
NYC-DB dataset based on an input CSV file. Just copy it
into the `/src` directory of your NYC-DB repository,
open a terminal and run e.g.:
python my_data.csv
This will create all the data files and Python code needed
for a new dataset called 'my_data' (or whatever you named
toolness / Cargo.toml
Last active Feb 17, 2019
A simple "hello world" using Rust wasm-bindgen that doesn't require webpack.
View Cargo.toml
name = "wasm_hello"
version = "0.1.0"
authors = ["Atul Varma <>"]
edition = "2018"
crate-type = ["cdylib"]
toolness /
Last active Jan 19, 2019
Notes on converting a Bazaar repository to git

I started with this Dockerfile:

FROM python:2.7

RUN pip install bzr

# Um, the following line might not actually do anything useful,
# possibly because we just installed bzr via pip instead of apt-get.
RUN apt-get update && apt-get --assume-yes install bzr-fastimport
toolness /
Last active Jan 31, 2019
NYC-DB schema
toolness /
Last active Oct 20, 2018
Extremely ridiculously confusing things about TypeScript

By and large, TypeScript is an incredible tool that I'm very grateful for, but sometimes it really makes me want to tear my hair out.

Narrowing functions WTF

TypeScript 3.1 introduced a breaking change involving narrowing functions that I have no idea how to work around.

Here's one attempt to make an unconstrained generic into something that's vaguely constrained: I want to define a type T in which we don't know what properties it has, but we want to make sure that any properties it does have are booleans.

type ObjWithBooleanValues = {
toolness /
Last active Aug 11, 2018
Simple Graphene wrapper that uses type annotations to generate GraphQL schemas.
import inspect
from typing import Type, Any, Callable
import graphene
from graphql import ResolveInfo
class AnnoQuery:
Base class for defining a GraphQL query schema and resolvers that relies
on type annotations rather than more verbose (and un-type-checkable)
Graphene definitions.