Skip to content

Instantly share code, notes, and snippets.

@asottile
asottile / notebook-theme.json
Created March 14, 2022 18:10
notebook-theme.json
{
"name": "Notebook",
"settings": [
{
"settings": {
"background": "#BEB69D",
"foreground": "#111"
}
},
{
@asottile
asottile / queueing.py
Created July 15, 2020 21:40
really bad queue simulating sqs backed by sqlite
import contextlib
import fcntl
import json
import sqlite3
import time
import uuid
from typing import Any
from typing import Generator
from typing import Optional
from typing import Tuple
@asottile
asottile / prioritize_shiny_raid.py
Last active May 14, 2020 20:06
figure out what shiny pokemon to do
"""figure out what shiny pokemon to do.
1. adjust SEEKING as needed
2. run this
"""
import collections
SEEKING = '''\
Meowth
@asottile
asottile / vs_dark_asottile.json
Created March 28, 2020 02:28
babi theme - vs_dark_asottile.json (vs dark + ini header highlight)
{
"$schema": "vscode://schemas/color-theme",
"name": "Dark (Visual Studio)",
"colors": {
"editor.background": "#1E1E1E",
"editor.foreground": "#D4D4D4",
"editor.inactiveSelectionBackground": "#3A3D41",
"editorIndentGuide.background": "#404040",
"editorIndentGuide.activeBackground": "#707070",
"editor.selectionHighlightBackground": "#ADD6FF26",
@asottile
asottile / backup_slack_emoji.py
Created September 6, 2019 21:40
script to export all slack emoji
import concurrent.futures
import json
import os.path
import urllib.request
token = '...'
url = f'https://slack.com/api/emoji.list?token={token}'
resp = urllib.request.urlopen(url)
@asottile
asottile / move_itl.py
Created November 2, 2018 03:53
move itunes library
import os.path
import shutil
import urllib.parse
from xml.sax import make_parser
from xml.sax.saxutils import XMLFilterBase
from xml.sax.saxutils import XMLGenerator
DEST = 'E:/music'
@asottile
asottile / ntpp.py
Last active December 22, 2018 22:23
import pprint
def ntpp(x, *, l=0):
indent = l * 4 * ' '
if hasattr(x, '_fields'):
return ''.join((
type(x).__name__ + '(\n',
*(
indent + ' ' +
@asottile
asottile / gerthurb.user.js
Last active February 15, 2017 02:59
@chriskuehl hates the dark header
// ==UserScript==
// @name gerthurb
// @namespace asottile
// @include https://*.github.com/*
// @include https://github.com/*
// @version 1
// @grant none
// ==/UserScript==
document.querySelector('.header-dark').classList.remove('header-dark');
@asottile
asottile / search_rtf_in_directory.py
Created August 19, 2016 15:36
Search rtf files in a directory. (At the time requires python2 (due to pyth))
import argparse
import os
from pyth.plugins.rtf15.reader import Rtf15Reader
from pyth.plugins.plaintext.writer import PlaintextWriter
def get_text(filename):
with open(filename) as f:
doc = Rtf15Reader.read(f)
import pipes
import subprocess
pythons = (
'Python27',
'Python27_x86',
'Python34',
'Python34_x86',
'Python35',