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 colormaker.py
#!/usr/bin/python
import colorsys
def ColorSpread(count, saturation, lightness):
'''
Compute a stepped spectrum sequence of color values that are evenly
distributed around the 360 degree hue wheel. Returns an array of rgb
values in hex.
@dreness
dreness / wowfix.py
Created Apr 3, 2014
A possibly useful template for runtime patching with lldb.
View wowfix.py
#!/usr/bin/python
import lldb
def patchAVAssetWriterInput64(frame, bp_loc, dict):
'''
Replace the 'outputSettings' argument to AVAssetWriterInput, to specify
a different video output codec.
This function wants to be called from a breakpoint command.
Use my setbp() function to create the breakpoint and breakpoint command.
@dreness
dreness / iops
Created Jul 3, 2014
pgbench on 6c 2013 mac pro, internal SSD: 35,000+ iops, 12430 transactions per second.
View iops
# make a new DB, in this case at ~/tmpdb, which is on the mac pro's internal SSD (disk0)
% ./bin/initdb -D ~/tmpdb
# set checkpoint_segments to 32 in postgres.conf, then start DB.
% ./bin/postgres -D /Users/andre/tmpdb
LOG: database system was shut down at 2014-07-03 11:49:38 PDT
LOG: database system is ready to accept connections
@dreness
dreness / tunes_track_info.sh
Created Jan 9, 2015
Tiny shell script that prints the current iTunes track info and remaining time; does not scroll.
View tunes_track_info.sh
#!/bin/bash
INTERVAL=$1
while true ; do
output=$(
osascript -- - <<'EOF'
tell app "iTunes"
try
set artist_track to artist of current track ¬
@dreness
dreness / ytdl-hfr-mux.txt
Last active Aug 29, 2015
The magic youtube-dl incantation to prefer high frame-rate content and mux the separate audio and video into a single file.
View ytdl-hfr-mux.txt
# list the available formats for a youtube URL.
bash-3.2$ youtube-dl -F 'https://www.youtube.com/watch?v=NlFU2wM-f8g'
[youtube] NlFU2wM-f8g: Downloading webpage
[youtube] NlFU2wM-f8g: Extracting video information
[youtube] NlFU2wM-f8g: Downloading DASH manifest
[info] Available formats for NlFU2wM-f8g:
format code extension resolution note
140 m4a audio only DASH audio 129k , m4a_dash container, aac @128k (44100Hz), 5.35MiB (worst)
141 m4a audio only DASH audio 255k , m4a_dash container, aac @256k (44100Hz), 10.62MiB
160 mp4 230x144 DASH video 112k , 15fps, video only, 4.34MiB
@dreness
dreness / recent-attachments.sql
Last active Nov 6, 2015
Show recent file attachments from Message.app's chat DB
View recent-attachments.sql
-- sqlite3 ~/Library/Messages/chat.db < recent-attachments.sql
-- dates in the DB are NSDate. NSDate.h says: NSTimeIntervalSince1970 978328800
SELECT Datetime(created_date + 978328800, 'unixepoch', 'localtime') 'created',
mime_type,
Printf("%.2f", Cast (total_bytes AS FLOAT) / 1000 / 1000) 'megabytes',
handle.id 'buddy',
filename
FROM attachment
JOIN message_attachment_join
@dreness
dreness / btc-watcher.py
Last active Dec 21, 2015
Send email notifications of shares and blocks.
View btc-watcher.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
import time, os
import re
from email.mime.text import MIMEText
from subprocess import Popen, PIPE
from datetime import datetime, timedelta
# Watch the bitcoin log, send notifications of shares and blocks, with
@dreness
dreness / airport.pl
Created Oct 6, 2013
For informational / forensic purposes only. If you still have a working Airport Extreme base station, this might work, but I doubt it, cause even apple's link to the MIB file is dead. Newer Airport base station models don't have SNMP.
View airport.pl
#!/usr/bin/perl -w
# Fetch and display wireless stats from an Apple Airport Extreme Base Station.
# Andre LaBranche, dre at mac dot com, 4/27/07
use Switch;
use Getopt::Long qw(:config permute bundling);
# User Tuneables Start
# We need to define base stations and their SNMP community names for querying.
@dreness
dreness / wow_ramdisk.sh
Created Nov 3, 2013
My 8 drive RAID array is a little weird. Throughput is decent, but latency is kinda bad. This causes World of Warcraft for mac to not be able to keep up when recording in-game video at high data rates (200+ MB/s), which of course is the only way to get large frame size *and* high frame rate :) It took me literally years to finally think of this …
View wow_ramdisk.sh
#!/bin/bash
set -x
# 11/3/2013 - dre at mac dot com
# Create a ramdisk big enough for World of Warcraft (mac version only!) to
# store a few video capture files. Shortly after each file is written, copy it
# to rotational storage, delete it from the ramdisk, and then symlink it from
# rotational back to the ramdisk.
@dreness
dreness / dezalgo.php
Last active Feb 25, 2016
exorcise the mind of zalgo from a text file
View dezalgo.php
## install composer
# mkdir dezalgo ; cd dezalgo
## place dezalgo.php (this file) into the new directory
# composer require mdwheele/zalgo
# php dezalgo.php --infile MyBestIRCLog --outfile MySafeIRCLog
<?php
require __DIR__ . '/vendor/autoload.php';
use Zalgo\Mood;
use Zalgo\Soul;
You can’t perform that action at this time.