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
View keybase.md

Keybase proof

I hereby claim:

  • I am dreness on github.
  • I am dreness (https://keybase.io/dreness) on keybase.
  • I have a public key ASC1Rvj8z_bm9ZwNPfYVwoRpML2fXRgFyvlCZAvCfA3cbQo

To claim this, I am signing this object:

View minecraft-mod-sync.sh
#!/bin/bash
# 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
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.
# http://babun.github.io
# Install virtualenv
pip install virtualenv
# Create and activate virtualenv
@dreness
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
dreness / powerConsumption.py
Last active May 9, 2017
Display rate of charge / discharge of an Apple laptop battery
View powerConsumption.py
#!/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:
# https://opensource.apple.com/source/PowerManagement/PowerManagement-637.20.2/pmconfigd/BatteryTimeRemaining.c.auto.html
@dreness
dreness / sa_times.py
Created Dec 3, 2016
Properly sort the sa(8) accounting records by time stamp
View sa_times.py
#!/usr/bin/python
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/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/acct.h
@dreness
dreness / kc_items.sh
Last active May 9, 2017
A hopefully stable listing of identities, keys, and certs found in keychain
View kc_items.sh
#!/bin/bash
function sep { printf -- '-%.0s' {1..80}; echo ''; }
sep ; echo "Identities" ; sep
security find-identity
echo ''
sep ; echo "Keys" ; sep
@dreness
dreness / ShoutCast-polling.md
Last active Jul 3, 2017
A tentative analysis of why Shoutcast is spinning a full CPU core
View ShoutCast-polling.md

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
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 */
dtrace:::BEGIN
{
/* double dollar sign to stringify cli arg */
View wwdc_videos.py
#!/usr/bin/python
import json
import urllib2
from pprint import pprint
# These URLs are discovered by viewing https://developer.apple.com/wwdc/live/#/
# and using the web inspector to find the wwdc-streaming javascript.
# Currently: https://developer.apple.com/wwdc/live/scripts/app/min/wwdc-streaming-0.1.0.min.js
# Search that javascript for "videos.json" and "videos_live.json"
You can’t perform that action at this time.