Skip to content

Instantly share code, notes, and snippets.

View toolness's full-sized avatar

Atul Varma toolness

View GitHub Profile
@toolness
toolness / download_gmail_metadata.py
Created April 4, 2022 00:17
Script to download metadata about your Gmail account into a sqlite database.
"""
This script can be used to create a sqlite database
that contains metadata about all your Gmail messages.
You will want to modify IMAP_PASSWORD and IMAP_USERNAME below.
See CREATE_TABLE_SQL for the schema of the database.
"""
import sys
@toolness
toolness / download_quake_map_source.py
Last active October 9, 2021 16:31
A script to download id's original Quake maps and make them easy to load in TrenchBroom.
# This Python script downloads the map sources for the
# original id Quake levels and does a few things to make
# them easier to load in TrenchBroom:
#
# * It adds comments to the top of each map to let
# TrenchBroom know that the map is a Quake map, and
# that it uses the Standard map format. (Without
# these comments, TrenchBroom will ask the user, and
# choosing the default response will raise a very
# confusing error.)
@toolness
toolness / rewrite_ken_burns_jazz_mp3_metadata.py
Created May 7, 2021 15:57
Script to rewrite the MP3 metadata in Ken Burns' Jazz album to be based on the length of the whole album
# The Ken Burns Jazz album MP3s from Amazon have separate track and disc
# number metadata, but many MP3 players don't look at the disc number,
# which makes it hard to play the album's tracks in order.
#
# This script goes through all the MP3's of the album and removes the
# disc number and rewrites the track number to be based on all the
# tracks in the album, rather than all the tracks on a particular disc.
#
# This script could theoretically be used on any other multi-disc MP3
# album, but I've only tried it on the Ken Burns Jazz MP3 album in
@toolness
toolness / nycdb-analyze-hpd-corps-vs-head-officers.sql
Created October 29, 2020 18:27
NYCDB query to help compare HPD-registered corporation addresses vs. head officer addresses
CREATE FUNCTION pg_temp.address(hpd_contacts) RETURNS TEXT AS
$$
SELECT
CASE WHEN $1.businessstreetname IS NULL THEN
''::text
ELSE
COALESCE($1.businesshousenumber, '') || ' ' ||
$1.businessstreetname ||
CASE WHEN $1.businessapartment IS NULL THEN
''
@toolness
toolness / babel-cra-fun.js
Created November 19, 2019 13:30
Script to load a CRA app's babel config and run it w/ an additional example plugin.
//@ts-check
// 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
toolness / install_sdl2_rust_msvc.py
Last active May 12, 2019 14:50
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
toolness / create_dataset.py
Created April 10, 2019 01:13
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 create_dataset.py 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
toolness / Cargo.toml
Last active February 17, 2019 12:25
A simple "hello world" using Rust wasm-bindgen that doesn't require webpack.
[package]
name = "wasm_hello"
version = "0.1.0"
authors = ["Atul Varma <varmaa@gmail.com>"]
edition = "2018"
[lib]
crate-type = ["cdylib"]
[dependencies]
@toolness
toolness / bzr-to-git.md
Last active January 19, 2019 15:38
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 &amp;&amp; apt-get --assume-yes install bzr-fastimport
@toolness
toolness / nycdb-schema.md
Last active January 31, 2019 15:22
NYC-DB schema