Skip to content

Instantly share code, notes, and snippets.

@joxl
joxl / mdvolumes.sh
Last active June 19, 2020 06:37
Get indexing status of all volumes known to mdutil
#!/usr/bin/env bash
vols=()
maxwidth=0
while read -r vol; do
vols+=( "$vol" )
maxwidth=$(echo -e "${maxwidth}\n${#vol}" | sort -n | tail -n1)
done < <(mdutil -a 2>&1 | awk -F: '{print $1}')
fmt="%-${maxwidth}s %s\n"
#!/usr/bin/env python3
import argparse
import json
import sys
from textwrap import indent
from subprocess import PIPE, Popen
class Grid(object):
@joxl
joxl / gradient.py
Created April 5, 2016 14:18
Python utility for generating HSB gradient color samples
#!/usr/bin/env python
import argparse
import colorsys
HTML_TEMPLATE = """<!DOCTYPE html>
<html>
<head>
<style>
body {
@joxl
joxl / ssh-curl.py
Last active August 29, 2015 14:24
Check status of private webapp listening on remote port
#!/usr/bin/env python
import json
import sys
from subprocess import Popen
from urlparse import urlunsplit
def main():
params = json.load(sys.stdin)
urlparts = []
@joxl
joxl / do-in-new-term.sh
Created March 26, 2015 21:12
do-in-new-term.sh
#!/bin/bash
TERM_APP="iTerm" # change to your prefered terminal app
here=$(printf '%q' "$(pwd)") # quote it
command="$@"
osascript -e "$(cat <<EOF
on run argv
activate application "$TERM_APP"
import time
import logging
log = logging.getLogger(__name__)
class Stopwatch(object):
def __init__(self, wallclock=True):
self.timefunc = time.time if wallclock else time.clock
@joxl
joxl / pandoractl.scpt
Last active December 9, 2018 16:53
Control Pandora Radio in Google Chrome via applescript
#!/usr/bin/osascript
(*
This code is a modified version of `chrome.applescript` found in
[googlemusic-hotkeys][1] on github.
[chrome.applescript][2] by [Steven La][3], unlicensed
[1]: https://github.com/stevenla/googlemusic-hotkeys