Skip to content

Instantly share code, notes, and snippets.

View toolness's full-sized avatar

Atul Varma toolness

View GitHub Profile
@toolness
toolness / adventures-in-python-core-dumping.md
Last active January 9, 2024 11:53
Adventures in Python Core Dumping

Adventures in Python Core Dumping

After watching Bryan Cantrill's presentation on [Running Aground: Debugging Docker in Production][aground] I got all excited (and strangely nostalgic) about the possibility of core-dumping server-side Python apps whenever they go awry. This would theoretically allow me to fully inspect the state of the program at the point it exploded, rather than relying solely on the information of a stack trace.

@toolness
toolness / sshify.py
Created March 14, 2017 20:31
A script to run a command within an ssh-agent session.
#! /usr/bin/env python3
"""
This utility will execute the given command (by default, your shell)
in a subshell, with an ssh-agent process running and your
private key added to it. When the subshell exits, the ssh-agent
process is killed.
"""
# This code was written by Atul Varma in February 2017. It requires
@toolness
toolness / gencert.py
Last active June 22, 2023 11:52
Python script to create server SSL certs and sign them with a custom CA.
#! /usr/bin/python
"""
This simple script makes it easy to create server certificates
that are signed by your own Certificate Authority.
Mostly, this script just automates the workflow explained
in http://www.tc.umn.edu/~brams006/selfsign.html.
Before using this script, you'll need to create a private
@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 / typescript-wtf.md
Last active July 11, 2022 14:50
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
toolness / lovebomb-tiny.html
Created December 21, 2011 17:20
lovebomb tiny
<header>A Love Bomb From Atul</header>
<section>
<img src="http://lovebomb.me/templates/atul-files/lovebomb.svg" alt="Love Bomb">
<p>This massive love bomb goes out to <a href="http://en.wikipedia.org/wiki/Tim_berners-lee">Tim Berners-Lee</a> for creating the world's largest <a href="http://en.wikipedia.org/wiki/World_Wide_Web">public resource</a> and working with others to make it as splendid as possible.</p>
<aside>
</section>
@toolness
toolness / jquery-exercises.md
Last active June 16, 2022 16:30
jQuery Exercises

Here are some mini exercises to challenge your jQuery skills a bit.

Instructions

Create a new page on jsbin.com and add the following script tag to it:

<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
@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 / https-proxy-with-sni.js
Last active January 23, 2022 12:39
HTTPS proxy server with SNI
var fs = require('fs');
var crypto = require('crypto');
var http = require('http');
var https = require('https');
var async = require('async');
var httpProxy = require('http-proxy');
var _ = require('underscore');
var UID = 1000;
var PASSPHRASE = process.env.PASSPHRASE || null;
@toolness
toolness / badgebakery.py
Created April 6, 2013 14:59
Simple Python module for baking of badges, and retrieval of assertion URLs from baked badges.
"""
This small module makes it easy to bake PNG images with links to
Open Badge assertions. It also allows for easy retrieval of the link
from baked PNGs.
For more information on badge baking, see:
https://github.com/mozilla/openbadges/wiki/Badge-Baking
Note that this module requires the PyPNG module: