{{ message }}

Instantly share code, notes, and snippets.

# Kirk Strauser kstrauser

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,
Last active May 31, 2019
A toy implementation of Knuth's up-arrow notation
View up_arrow.py
 #!/usr/bin/env python3 import pytest def up_n(arrows, a, b): """Return a ↑(arrows times) b.""" if arrows == 1: return a ** b
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()
Created Aug 5, 2018
Raw data for the blog post at https://blog.freeradical.zone/yes-russia/
View spamsource.py
 #!/usr/bin/env python from collections import Counter spammers = [ {"domain": "lewohner.top", "ip": "5.189.207.59", "asn": "AS50896", "mx": "mxsrv.mailasrvs.pw"}, { "domain": "vesigarna.site", "ip": "185.71.1.152", "asn": "AS200557",
Last active Nov 23, 2020
Using the "black" Python formatter in VS Code
View black.md

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`
Created Dec 6, 2017
Cheap hack to emulate virtualenvwrapper's workon script
View workon.sh
 function workon () { # Find the configured virtualenvwrapper home, or use Kirk's # clearly excellent choice. if [[ -z \$PROJECT_HOME ]]; then envs=\$PROJECT_HOME else envs=~/Envs fi # Override the paths for specific environments
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
Last active Aug 2, 2018 — forked from tzangms/ghost2wp.py
Migrate Ghost to Wordpress
View ghost2wp.py
 """ Requirements: * A Wordpress Blog * Ghost export file (json). * Python Packages: python-wordpress-xmlrpc >>> pip install python-wordpress-xmlrpc WARNING:
Last active Mar 25, 2017
Use assert functions instead of methods to avoid insidious test problems
View mocked.py
 >>> import mock >>> m = mock.Mock() >>> m.assert_called_once() # Old version of Mock? This may not be what you expect. >>> assert_called_once = mock.Mock.assert_called_once # Doesn't exist. Now you know! Traceback (most recent call last): File "", line 1, in AttributeError: type object 'Mock' has no attribute 'assert_called_once'
Last active Jan 19, 2017
View fizzbuzz_generator.py
 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'