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 | |
grep -r --include='*.py' "$1" ${2:-.} |
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 | |
"""Exports a GitHub repository's issues to CSV format.""" | |
from __future__ import print_function | |
import argparse | |
import csv | |
import getpass | |
import requests |
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 bash | |
tags="$(git tag --list)" | |
for tag in $tags; do | |
hash="$(git rev-list $tag | head -n 1)" | |
echo "${hash} ${tag}" | |
done |
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 subprocess import Popen, PIPE | |
def cmd(*args): | |
"""Runs a shell command and returns the output as a string.""" | |
out, err = Popen(args, stdout=PIPE, stderr=PIPE).communicate() | |
# Convert output from byte array to string. | |
out = out.decode('utf-8') | |
err = err.decode('utf-8') |
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 | |
"""Parses and encodes the result of `docker ps` in JSON format.""" | |
import json | |
import sys | |
from collections import namedtuple | |
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
git log --graph --all --oneline --decorate |
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
""" | |
Connection adapter for Requests that allows it to talk with raw UNIX sockets. | |
Adapted from requests-unixsocket, which itself was adapted from docker-py. | |
https://github.com/msabramo/requests-unixsocket | |
https://github.com/docker/docker-py/blob/master/docker/unixconn/unixconn.py | |
""" | |
import socket | |
from urllib.parse import unquote, urlparse |
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
"""An example of a cache decorator.""" | |
import json | |
from functools import wraps | |
from redis import StrictRedis | |
redis = StrictRedis() | |
def cached(func): |
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
// NSNotificationCenter isn't thread-safe, so this ensures that notifications are posted on the main thread. | |
func postMainThreadNotification(notification: Notification) { | |
DispatchQueue.main.async { NotificationCenter.default.post(notification) } | |
} |
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 AppKit | |
class PreferencesViewController: NSTabViewController { | |
private lazy var tabViewSizes: [NSTabViewItem: NSSize] = [:] | |
override func tabView(_ tabView: NSTabView, didSelect tabViewItem: NSTabViewItem?) { | |
super.tabView(tabView, didSelect: tabViewItem) | |
if let tabViewItem = tabViewItem { |