This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
def nums2ranges(nums): | |
""" | |
>>> list(nums2ranges([])) | |
[] | |
>>> list(nums2ranges([0, 1, 2, 3, 4])) | |
[slice(0, 5, None)] | |
>>> list(nums2ranges([0, 1, 4, 5, 6])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
import re | |
import sys | |
import shlex | |
import shutil | |
import argparse | |
import subprocess | |
import logging |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
set -o pipefail | |
fd -g -td \*.app /System/Library/CoreServices /System/Applications /Applications . \ | |
| fzf --multi --exact --query="$1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import argparse | |
import collections | |
import tempfile | |
import zipfile | |
import filecmp | |
import shutil | |
import shlex | |
ZipCmpResult = collections.namedtuple('ZipCmpResult', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import argparse | |
import os | |
import ast | |
import sys | |
import pkgutil | |
import itertools | |
import logging | |
import json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__all__ = [ | |
'cjkljust', | |
'cjkrjust', | |
'cjkcenter', | |
] | |
import unicodedata | |
#def cjklen(string): | |
# return sum(2 if unicodedata.east_asian_width(char) in 'FW' else 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import itertools | |
import shutil | |
# https://gist.github.com/kkew3/8bb9aa225a6c82ae5e1a0fa609c9a65a | |
import cjkjust | |
def calc_layout(n_strings, total_width, column_width, width_between_cols): | |
# expected_ncols * column_width + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "rbtree.h" | |
rbnode *left_rotate(rbnode *x) | |
{ | |
// assert(x && x->right); | |
rbnode *y = x->right; | |
x->right = y->left; | |
y->left = x; | |
return y; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# original command adapted from https://superuser.com/a/100290 | |
import subprocess | |
filename = ... | |
try: | |
_ = subprocess.check_call(['ffmpeg', '-v', 'error', '-i', | |
filename, '-f', 'null', '-']) | |
except subprocess.CalledProcessError: | |
# the subprocess call returns non-zero, which means filename |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
import sys | |
import argparse | |
import subprocess | |
import ast | |
HOMEDIR = os.path.normpath(os.environ['HOME']) | |
MUSICDIR = os.path.join(HOMEDIR, 'Music') | |
COVERARTDIR = os.path.join(MUSICDIR, '.cover-arts') |