Skip to content

Instantly share code, notes, and snippets.

# Download the xmarks "View Bookmarks Revision" from their webpage for all revisions, then run this to audit changes.
import glob, re
class BookmarkSeparator(object):
name = '<<SEPARATOR>>'
add_date = 0
last_modified = 0
description = '<<SEPARATOR>>'
@tsumare
tsumare / sessionstore_parse.py
Last active May 21, 2016 14:31
Parse firefox session store into a HTML page with links to tabs.
#!/usr/bin/env python
import json, sys
from pprint import pprint
def escape(html):
return html.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;').replace('"', '&quot;')
sessionstore = json.load(open(sys.argv[1],'r'))
sessionstore_windowtabs = map(lambda x: x['tabs'], sessionstore['windows'])
@tsumare
tsumare / ffmpeg_notes.sh
Last active May 19, 2020 13:43
ffmpeg notes & useful commands
# Image output:
# -r: framerate of output
ffmpeg -i inputfile.mp4 -r 1 -f image2 image-%3d.jpeg # one per second
ffmpeg -i inputfile.mp4 -frames:v 1 thumb.png # one
# crop=w:h:xoffset:yoffset
-vf "crop=610:475:835:385"
# scale to w:h. -1 is 'preserve aspect ratio in this dimension' -2 is 'preserve aspect ratio but keep the dimension a multiple of 2'
-vf 'scale=-1:min(iw\,480)'
@tsumare
tsumare / muteapp.pl
Last active August 29, 2015 14:11
Pulseaudio Application Mute Toggle Script
#!/usr/bin/perl
use warnings;
use strict;
open(PALIST, '-|', 'pacmd list-sink-inputs');
my $index = undef;
my $set_mute_to = undef;
while (<PALIST>) {
if (/^\s*index: ([0-9]+)$/) {
$index = $1;
@tsumare
tsumare / fileslice.pl
Created November 16, 2014 19:55
Slice files into sections by regex
#!/usr/bin/perl
use warnings;
use strict;
my $REGEX = shift @ARGV;
my $SourceFile = shift @ARGV;
my $OutputFormat = shift @ARGV;
my $FileI = 0;
open(SRC, '<', $SourceFile) or die "Unable to open $SourceFile: $!";
@tsumare
tsumare / fetch_song_art.sh
Last active August 29, 2015 14:01
Extract still images (artwork) from Youtube songs, or other video files.
youtube-dl --restrict-filenames --auto-number https://www.youtube.com/playlist?list=$PLAYLIST # --playlist-start 1
for I in *.mp4; do
nice -n20 \
mplayer $I -vf framestep=30,decimate=100000000:512:256:0.1 -nosound -speed 100 -vo jpeg:outdir="${I%.mp4}"
done
# Key point is 'decimate', which tosses similar frames. See manpage.
# Consider the effects of decimate combined with frameskip, for notable tuning.
# And, obviously, experiment!
#