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 | |
def columns(data, *, delimiter, width=None, config): | |
''' | |
config is a list of objects with a `key`, and optionally a `colorize` and `truncate` method | |
''' | |
# start by extracting out all the columns & getting the width of each |
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
# Automate installing a new version of node, re-installing global | |
# node modules, and uninstalling older node versions. | |
# | |
# Depends on nvm, semver, and python3. | |
# | |
# semver will be auto-installed if it doesn't exist yet. | |
# | |
# If a single arg is given: | |
# | |
# 1. Install the new node version given as the first arg. |
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 sys | |
from itertools import islice | |
from PIL import Image | |
PIXEL = '▄' | |
# The amount an image needs to be scaled to look good in terminal | |
TERM_RATIO = 0.8276 |
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
/** | |
* Create a sorting function that can sort objects by a calculated key. Can be passed to `Array.sort`. | |
* @param cb A function that will be passed each object and expected to return a key to sort by. | |
* The key can be either a string, number, or an array of those. | |
* @return A function that can be passed to `Array.sort`. | |
*/ | |
function sortBy(cb) { | |
const stringCompare = (a, b) => a.localeCompare(b); | |
const numberCompare = (a, b) => a - b; |
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 python | |
import sys | |
if len(sys.argv) != 2: | |
print "usage: %s <number of inputs>" % sys.argv[0] | |
sys.exit(1) | |
inputs = int(sys.argv[1]) | |
rows = 2 ** inputs |
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 node | |
/** | |
* Call macOS's `say` program with every possible voice at the same | |
* time with the given phrase. Scare your pets. | |
*/ | |
const { exec } = require('child_process'); | |
function getVoices(callback) { |
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 | |
""" | |
Reduce the size of a directory by creating new directories for each | |
unique combination of the first two letters of the existing files. | |
This is the same way that git stores object files. | |
For example, a file with this name would result in the following: | |
fff394e6-214d-4f74-8607-d6825f17c8fd |
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
// ==UserScript== | |
// @name HideIt | |
// @namespace http://tampermonkey.net/ | |
// @version 1.1.2 | |
// @description Hide any element on the page, with the ability to restore all. | |
// @author Brian Schlenker <bschlenk@umich.edu> | |
// @match *://*/* | |
// @noframes | |
// ==/UserScript== |
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 python | |
# -*- coding: utf-8 -*- | |
import json | |
import sys | |
from collections import OrderedDict | |
from ConfigParser import (ConfigParser, MissingSectionHeaderError, | |
ParsingError, DEFAULTSECT) | |