Skip to content

Instantly share code, notes, and snippets.

View kstrauser's full-sized avatar

Kirk Strauser kstrauser

View GitHub Profile
#!/usr/bin/env python
from functools import cache
real = True
with open("real_1.txt" if real else "test_1.txt") as infile:
data = infile.read().strip()
version: '3'
services:
[...]
sidekiq_1:
build: .
image: tootsuite/mastodon
restart: always
env_file: .env.production
command: bundle exec sidekiq -c 25
volumes:
---
:concurrency: 25
:queues:
- [default, 6]
- [push, 4]
- [mailers, 2]
- [pull]
@kstrauser
kstrauser / pureenergy.json
Last active July 3, 2019 23:56
Drums for What's On Your Mind (Pure Energy) by Information Society
{
"name": "drumbit",
"metadata": {
"author": "",
"title": "",
"remarks": ""
},
"options": {
"tempo": 63,
"swing": 0,
@kstrauser
kstrauser / up_arrow.py
Last active May 31, 2019 14:09
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
kstrauser / advent2018_2.py
Created December 1, 2018 20:07
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": "lewohner.top", "ip": "5.189.207.59", "asn": "AS50896", "mx": "mxsrv.mailasrvs.pw"},
{
"domain": "vesigarna.site",
"ip": "185.71.1.152",
"asn": "AS200557",
@kstrauser
kstrauser / black.md
Last active March 18, 2023 00:24
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
kstrauser / workon.sh
Created December 6, 2017 18:31
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
envs=$PROJECT_HOME
else
envs=~/Envs
fi
# Override the paths for specific environments
@kstrauser
kstrauser / Export to OmniFocus.scpt
Last active April 12, 2021 13:08
Export an OmniOutliner document as a set of OmniFocus actions
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