Skip to content

Instantly share code, notes, and snippets.

@torbiak
torbiak / tag-created
Last active November 8, 2017 06:57
Tag ogg, flac, and mp3 files with their Windows creation time.
#!/usr/bin/python
# Tag mp3, ogg, and flac files with a 'created' tag in the format 'YYYYMMDD',
# based on the file's birthtime, as stored by Windows. Unix doesn't store
# birthtimes, so this won't work there.
import os
import sys
from time import strftime, localtime
import mutagen # v1.21 works. Others probably do, too.
@torbiak
torbiak / gist:d46dcaf472c1bc1ecde4
Created May 12, 2014 05:52
cherry-pick args when using xargs
# Reverse order and control placement of the incoming args.
echo hi there bud | xargs -n 3 sh -c 'echo $2 $1 $0;'
@torbiak
torbiak / .Xresources
Last active September 1, 2016 20:13
xresources
*background: #101f2f
*foreground: #80aad5
*color0: #323b44
*color8: #464f58
*color1: #8c4b4b
*color9: #8c4b4b
*color2: #4b8c4b
*color10: #4b8c4b
*color3: #8c8c4b
*color11: #8c8c4b
@torbiak
torbiak / map_win_keycodes.reg
Created November 7, 2014 08:10
Windows kernel keycode mappings
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,07,00,00,00,36,00,3a,00,2e,e0,5c,e0,\
30,e0,5d,e0,10,e0,44,00,22,e0,57,00,19,e0,58,00,00,00,00,00
@torbiak
torbiak / birthed.py
Created November 8, 2014 22:57
find files based on their Windows "birthtime"
#!/usr/bin/python
# Recursively print files created before/at/after (-//+) some number of days
# ago. This only works on Windows, which stores file "birthtime" in the
# filesystem
import sys
import os
from datetime import date, timedelta
@torbiak
torbiak / spec_vim_formatter.rb
Created March 3, 2015 06:00
rspec formatter for vim :make
class VimFormatter
RSpec::Core::Formatters.register self, :example_failed, :example_passed, :dump_summary
def initialize(output)
@output = output
end
def example_passed(n)
@output << "PASSED: " << n.example.description << "\n\n"
end
@torbiak
torbiak / diffmon
Created October 9, 2015 19:05
Periodically monitor a command's output for changes.
#!/usr/bin/env bash
# Monitor a command's output for changes.
set -eu
usage="diffmon [-D] [-t INTERVAL] CMD ARGS...
-t INTERVAL Interval to sleep between command executions
-b Print a blank line between changes instead of the date"
interval=1
show_date=yes
while getopts "hbt:" o; do
case "$o" in
@torbiak
torbiak / .Xmodmap
Created March 27, 2016 05:56
13" macbook air xmodmap
keycode 232 = XF86MonBrightnessDown
keycode 233 = XF86MonBrightnessUp
keycode 121 = XF86AudioMute
keycode 122 = XF86AudioRaiseVolume
keycode 123 = XF86AudioLowerVolume
keycode 173 = XF86AudioPrev
keycode 172 = XF86AudioPlay
keycode 171 = XF86AudioNext
@torbiak
torbiak / gtff.py
Last active April 17, 2016 19:01
Guess Tag From Filename
#!/usr/bin/env python
# Guess Tags From Filename, using python and mutagen.
import mutagen
from mutagen.easyid3 import EasyID3
import re
import os.path
import sys
@torbiak
torbiak / format-srt.rb
Created April 4, 2016 12:21
Clean and format subrip subtitles that have been converted from ASS format by ffmpeg.
#!/usr/bin/env ruby
require 'text/format'
class Entry
attr_accessor :flighting, :body
def initialize
@body = []
end