Skip to content

Instantly share code, notes, and snippets.


Andre LaBranche dreness

Block or report user

Report or block dreness

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile

Keybase proof

I hereby claim:

  • I am dreness on github.
  • I am dreness ( on keybase.
  • I have a public key ASC1Rvj8z_bm9ZwNPfYVwoRpML2fXRgFyvlCZAvCfA3cbQo

To claim this, I am signing this object:

# extra verbose
set -x
# sync mods from local host to remote host (e.g. a minecraft server)
# optionally delete extraneous files in the remote mods directory
# Go home to allow relative paths below, but remember current dir.
pushd ~
dreness / twisted_web_windows
Last active Oct 7, 2016
simple twisted web server on windows
View twisted_web_windows
# This is needed because SimpleHTTPServer in the standard python distribution isn't good enough for my use case of
# serving large mp4 files. Pretty much every request fails with a broken pipe.
# Start with the 'babun' package to provide the cli environment, based on cygwin. Python is included.
# Install virtualenv
pip install virtualenv
# Create and activate virtualenv
dreness / hls-concat
Created Nov 14, 2016
Re-assemble HLS segments
View hls-concat
1) If applicable, list available formats for this asset.
youtube-dl -F <url>
... then get URL to m3u8 for selected format
youtube-dl -f <format name> -g <url>
2) Download all the segments in the m3u8. Now you have a bag of transport stream segments.
The file names are probably increasing but not necessarily sequentially.
You can do the download with youtube-dl (which automatically re-assembles the results),
but it doesn't support parallel operation. You might find that parallelizing this download
dreness /
Last active May 9, 2017
Display rate of charge / discharge of an Apple laptop battery
#!/usr/bin/env python
from __future__ import print_function
import objc
from Foundation import NSBundle, NSString
import datetime
import time
# ioreg -l -n AppleSmartBattery -r
# To learn about battery time remaining calculations:
dreness /
Created Dec 3, 2016
Properly sort the sa(8) accounting records by time stamp
from __future__ import print_function
from datetime import datetime
Display the account records gathered by the sa(8) facility.
from /usr/include/sys/acct.h
or on macOS, /Applications/
dreness /
Last active May 9, 2017
A hopefully stable listing of identities, keys, and certs found in keychain
function sep { printf -- '-%.0s' {1..80}; echo ''; }
sep ; echo "Identities" ; sep
security find-identity
echo ''
sep ; echo "Keys" ; sep
dreness /
Last active Jul 3, 2017
A tentative analysis of why Shoutcast is spinning a full CPU core

A Shoutcast process (called sc_serv25, with PID 10213) is using way more CPU than expected for the workload - specifically, 100% of a CPU core. Let's investigate.

$ sudo strace -p 10213 -o ~/sc_serv25_strace.txt -f -t -tt -T
(control-c after a few seconds)

Looking at sc_serv25_strace.txt for weirdness, we notice thread 10221 is very hot. Here's an excerpt:

$ grep 10221 ~/sc_serv25_strace.txt
10221 1499065013.244010 poll([{fd=14, events=POLLIN}, {fd=75, events=POLLIN}], 2, 0) = 0 (Timeout) <0.000009>
dreness / watch_file.d
Last active Aug 14, 2017
Try to find out who is opening, reading from, writing to, deleting a file
View watch_file.d
#!/usr/sbin/dtrace -s
#pragma D option quiet
#pragma D option switchrate=10hz
/* pass the filename to watch for as the only cli argument */
/* double dollar sign to stringify cli arg */
import json
import urllib2
from pprint import pprint
# These URLs are discovered by viewing
# and using the web inspector to find the wwdc-streaming javascript.
# Currently:
# Search that javascript for "videos.json" and "videos_live.json"
You can’t perform that action at this time.