Skip to content

Instantly share code, notes, and snippets.

@dreness
dreness / btc-watcher.py
Last active December 21, 2015 04:09
Send email notifications of shares and blocks.
#!/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 / filesink.rb
Last active November 7, 2017 00:39
Blather XMPP bot that receives file transfers that are sent using XEP 0096. Not at all complete, but wanted to post something that demonstrates working file transfer, since I couldn't find any.
require 'rubygems'
require 'blather/client'
require 'awesome_print'
require 'nokogiri'
require 'pretty-xml'
require 'nokogiri-pretty'
include PrettyXML
# This is a Blather bot that receives file transfers that are sent using
# XEP 0096, using either p2p SOCKS5 (XEP 0065), or through the server
@dreness
dreness / airport.pl
Created October 6, 2013 03:35
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.
#!/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 November 3, 2013 18:50
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 …
#!/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.
#!/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 April 3, 2014 00:41
A possibly useful template for runtime patching with lldb.
#!/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 July 3, 2014 19:11
pgbench on 6c 2013 mac pro, internal SSD: 35,000+ iops, 12430 transactions per second.
# 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 January 9, 2015 19:53
Tiny shell script that prints the current iTunes track info and remaining time; does not scroll.
#!/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 August 29, 2015 14:14
The magic youtube-dl incantation to prefer high frame-rate content and mux the separate audio and video into a single file.
# 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 / plotframetimes.py
Last active June 28, 2023 01:29
Graphical and statistical analysis of frame rate in a video
#!/usr/bin/env python
# dre at mac dot com
# Graphical and statistical analysis of frame rate in a video
# Requires ffmpeg and gnuplot
# Example output:
# https://youbeill.in/scrap/Screen-Recording-2018-09-07-at-3.17.33-PM.mov.png
from sys import platform
from subprocess import check_output, DEVNULL