Skip to content

Instantly share code, notes, and snippets.

@Lanny
Lanny / irvine.py
Last active August 29, 2015 14:28
like ctrl-p but for the terminal I guess?
#!/usr/bin/env python
import os
import sys
import subprocess
from fnmatch import fnmatch
from multiprocessing import Process, Queue
from Queue import Empty as QEmpty
@Lanny
Lanny / MethodSplitView.py
Created July 29, 2017 23:06
flexible class for splitting handling of different HTTP methods being dispatched to the same view into separate class methods
class MethodSplitView(object):
"""
A flexible class for splitting handling of different HTTP methods being
dispatched to the same view into seperate class methods. Subclasses may
define a separate class method for each HTTP method the view handles (e.g.
GET(self, request, ...), POST(self, request, ...) which will be called with
the usual view signature when that sort of reqeust is made.
Subclasses may also define a `pre_method_check` method which, if it returns
a HttpResponse, will be used to response to the request instead of
@Lanny
Lanny / mr.py
Last active March 4, 2018 03:24
import urllib2
import time
from collections import defaultdict
def run_mr(mapf, reducef, data):
intr = defaultdict(list)
final = []
def emitIntr(key, value):
intr[key].append(value)
@Lanny
Lanny / state-tax.json
Last active March 3, 2021 22:34
US state income tax data
{
"_META": {
"year": 2001,
"source": "https://files.taxfoundation.org/20210217114725/State-Individual-Income-Tax-Rates-and-Brackets-for-2021.pdf",
"updates_and_fixes": "https://gist.github.com/Lanny/cfb412dba213b59c7c74d7b940e77e3f",
"description": "Extraction of taxfoundation.org's info on 2021 US state income taxes into JSON for automatic processing. Tax brackets are expressed as 2-tuples of incomeat the bottom of the bracket, and tax rate within that bracket (as apercentage)."
},
"DATA": {
"AL": {
"BRACKETS": {
@Lanny
Lanny / README.md
Created June 28, 2021 16:41
File Hierarchy Preview

Outputs a limited file tree rooted at the current directory which highlights the position of the argument within the tree. Originally intended for FZF like so:

fzf --preview 'ptf.py {}'

Screenshot:

screenshot

@Lanny
Lanny / everforest.py
Created May 8, 2023 18:53
Everforest theme for qutebrowser
def get_pallet(scheme = 'dark', intensity = 'hard'):
if scheme not in ('dark', 'light'):
raise RuntimeError('Schme must be one of "dark", "light".')
if intensity not in ('hard', 'medium', 'soft'):
raise RuntimeError('Intensity must be one of "hard", "medium", "soft".')
pallet = None
if scheme == 'dark':
pallet = {
'fg': '#d3c6aa',