Skip to content

Instantly share code, notes, and snippets.

kstrauser / pureenergy.json
Last active Jul 3, 2019
Drums for What's On Your Mind (Pure Energy) by Information Society
View pureenergy.json
"name": "drumbit",
"metadata": {
"author": "",
"title": "",
"remarks": ""
"options": {
"tempo": 63,
"swing": 0,
kstrauser /
Last active May 31, 2019
A toy implementation of Knuth's up-arrow notation
#!/usr/bin/env python3
import pytest
def up_n(arrows, a, b):
"""Return a ↑(arrows times) b."""
if arrows == 1:
return a ** b
kstrauser /
Created Dec 1, 2018
My solution for the December 1, 2018 Advent of Code question #2
#!/usr/bin/env python
import itertools
import pathlib
value = 0
seen = set()
for line in itertools.cycle(
int(line) for line in pathlib.Path("input/1.txt").read_text().splitlines()
#!/usr/bin/env python
from collections import Counter
spammers = [
{"domain": "", "ip": "", "asn": "AS50896", "mx": ""},
"domain": "",
"ip": "",
"asn": "AS200557",
kstrauser /
Last active Nov 23, 2020
Using the "black" Python formatter in VS Code

This is how to use the Black Python code formatter in VS Code.

Make a Python 3.6 virtualenv for running Black

Black itself requires Python 3.6 to run, but few of our projects are on that version. The VS Code plugin conveniently lets you run black from its own virtualenv.

I had to give a specific version of black this morning. I didn't yesterday. Don't specify the version unless it makes you (and if you do, give the current version, not the one from this doc).

$ cd ~/Envs
kstrauser /
Created Dec 6, 2017
Cheap hack to emulate virtualenvwrapper's workon script
function workon () {
# Find the configured virtualenvwrapper home, or use Kirk's
# clearly excellent choice.
if [[ -z $PROJECT_HOME ]]; then
# Override the paths for specific environments
kstrauser / Export to OmniFocus.scpt
Last active Apr 12, 2021
Export an OmniOutliner document as a set of OmniFocus actions
View Export to OmniFocus.scpt
set isdate to (display dialog "When are you traveling?" default answer (current date)'s date string)'s text returned
tell date isdate to set travelDate to date (((its month as integer) & "/" & day & "/" & year) as text)
set lastOf to {}
tell application "OmniOutliner"
set theDoc to front document
-- Find the When and Context column numbers
set contextColumnNum to 0
kstrauser /
Last active Aug 2, 2018 — forked from tzangms/
Migrate Ghost to Wordpress
* A Wordpress Blog
* Ghost export file (json).
* Python Packages: python-wordpress-xmlrpc
>>> pip install python-wordpress-xmlrpc
kstrauser /
Last active Mar 25, 2017
Use assert functions instead of methods to avoid insidious test problems
>>> import mock
>>> m = mock.Mock()
>>> m.assert_called_once() # Old version of Mock? This may not be what you expect.
<Mock name='mock.assert_called_once()' id='4558624144'>
>>> assert_called_once = mock.Mock.assert_called_once # Doesn't exist. Now you know!
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: type object 'Mock' has no attribute 'assert_called_once'
from itertools import count
def fizz():
for i in count(1):
yield '' if i % 3 else 'fizz'
def buzz():
for i in count(1):
yield '' if i % 5 else 'buzz'