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
# This prints a spiral onto the terminal. | |
# It is composed of a few list comprehensions, a few ternary expressions, and a y-combinator | |
# The only python keywords used: print, join, in, lambda, if, else, int, and, or, range | |
# No libraries are used | |
# It is 308 characters although I think it would be possible to get it under 300 | |
# with some further optimization of the spiral generator. Particularly I think | |
# it might be possible to build this without storing state recursively at the | |
# expense of some additional computation. This could be done by finding an | |
# expression that would map the element index of the spiral to the coordinates |
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 | |
# This is a better way to do git branch. This orders branches by last modified | |
# date and prints the branch notes along with the branch. | |
# Branches with '+' and '_' in front come first | |
import subprocess | |
import sys | |
from dateutil.parser import parse | |
import os |
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 | |
# Loads json into a python datastructure from a url | |
# Usage: curljson http://example.com/json_endpoint | |
# Then the datastructure is accessible via jobj | |
import json | |
import sys | |
from IPython import embed | |
from subprocess import Popen, PIPE |
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 | |
# Open a IPython REPL using the arguments as libraries to be imported via `import *`. | |
# Also imports a few stdlib libraries | |
# For example: | |
# $ i lib/lib_to_be_imported.py | |
# does | |
# from lib.lib_to_be_imported import * | |
# before the REPL starts |
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 | |
# Loads the json contents of the clipboard as a python datastructure called jobj | |
import sys | |
import json | |
from IPython import embed | |
if __name__ == "__main__": | |
f_name = sys.argv[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
#!/bin/bash | |
# Usage: memprof PID# | |
# Continuously poll the memory usage of a process | |
top -l 0 -s 1 -pid $1 -stats VSIZE | awk 'NR%13==0; fflush(stdout)' | ts |
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 | |
# Set a note on the current git branch using command line arguments | |
# Usage: note this branch is broken | |
import sys | |
import subprocess | |
import json | |
if __name__ == '__main__': |
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 | |
# Do some cursory checks before pushing the branch to `origin <branch_name>` | |
# Checks that no debuggers, TODOs, or print statements are in the branch diff before pushing | |
# Also checks that there are no saved but uncommitted files in git status | |
import subprocess | |
import sys | |
def execute(cmd): |
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 | |
# This script will pixelate most jpg and png images | |
# It will both show you the result and save it | |
import sys | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import PIL.Image as Image |
OlderNewer