Skip to content

Instantly share code, notes, and snippets.

@ssp
ssp / Safari.css
Created June 10, 2010 21:42
Custom Style Sheet for Safari, includes Reader fix, Spiegel Online crap removal, improved legibility and vanity stuff.
/* SPIEGEL ONLINE **************/
div.spArticleImageBox, div.spMultimediaLeiste, div.spForumBoxBig, div.spRessortTeaserBox.panorama, div.spRessortTeaserBox.sport, div.spRessortTeaserBox.einestages, div.spRessortTeaserBox.auto, div.spRessortTeaserBox.reise, div.spRessortTeaserBox.spam {
display:none;
}
/* TWITTER **************/
.tab .doing, #side #currently {
word-wrap: break-word;
}
@ssp
ssp / Handbrake conversion
Created June 10, 2010 21:59
Convert DV to mp4 and ogv using Handbrake CLI
HandBrakeCLI --input input.dv --output output.mp4 --format mp4 --encoder x264 --x264opts ref=2:bframes=2:subq=6:mixed-refs=0:weightb=0:8x8dct=0:trellis=0 --optimize --quality 0.5 --audio 1 --aencoder ca_aac --ab 128 --arate 32 --aname English
HandBrakeCLI-0.9.3 --input input.dv --output result.ogv --format ogm --encoder theora --optimize --quality 0.6 --audio 1 --aencoder vorbis --ab 128 --arate 32 --aname English
# Commands to convert DV (or any) video to MP4 and OGM using the CLI version of HandBrake.
# The MP4 result it simple-minded enough to be played by QuickTime.
# The audio bitrate is picked to match the 32kHz audio of some DV video.
# You need the 0.9.3 version for the ogg files, as that feature was removed in 0.9.4.
<?xml version="1.0" encoding="UTF-8"?>
<!--
Used on the XML coming from the SUB Göttingen Opac short XML records to extract
the PPN attribute of the contained SHORTTITLE elements as one PPN per line.
Example URL for the XML:
http://opac.sub.uni-goettingen.de/DB=1/XML=/SHRTST=10/CMD?ACT=SRCHA&IKT=1016&SRT=YOP&TRM=test&ADI_BIB=a,b,c,e,k,l,n,r,x,z,i148,i165
Stored at: https://gist.github.com/750094
<?xml version="1.0" encoding="UTF-8"?>
<!--
Used to extract the <record> elements from SRU replies and dump the rest of the records.
Example URL for input XML:
http://gso.gbv.de/sru/DB=2.1/?query=pica.ppn%3D%22309041996%22&version=1.1&operation=searchRetrieve&recordSchema=pica&recordPacking=xml
Stored at: https://gist.github.com/750153
@ssp
ssp / ExifTool commands
Created January 27, 2011 19:50
exiftool commands
# Move Description tag to Title tag
exiftool '-Description>Title' *
# Move Title tag to Headline Tag
exiftool '-Title>Headline' *
# Rename from tag, adding number if necessary for uniqueness,
# without changing file dates.
exiftool '-FileName<${description}%-c.jpeg' '-DateTimeOriginal>FileModifyDate' *
@ssp
ssp / cookiekiller.py
Created July 21, 2011 15:10
Script and LaunchAgent for deleting Safari cookies on Mac OS X
#!/usr/bin/env python
"""
COOKIE KILLER
2010 by Sven-S. Porst <ssp-web@earthlingsoft.net>
Script with simple heuristics to kill the most obviously crap cookies in WebKit.
Available at http://gist.github.com/324414
Better quit cookie users before running the script.
@ssp
ssp / git-extract-file.markdown
Created January 23, 2012 13:21
Extract a single file from a git repository

How to extract a single file with its history from a git repository

These steps show two less common interactions with git to extract a single file which is inside a subfolder from a git repository. These steps essentially reduce the repository to just the desired files and should performed on a copy of the original repository (1.).

First the repository is reduced to just the subfolder containing the files in question using git filter-branch --subdirectory-filter (2.) which is a useful step by itself if just a subfolder needs to be extracted. This step moves the desired files to the top level of the repository.

Finally all remaining files are listed using git ls, the files to keep are removed from that using grep -v and the resulting list is passed to git rm which is invoked by git filter-branch --index-filter (3.). A bit convoluted but it does the trick.

1. copy the repository to extract the file from and go to the desired branch

@ssp
ssp / pz2-log-analysis.sh
Created January 23, 2012 16:47
pazpar2 log analysis
# Try to grep rough usage information from a pazpar2 log:
# Count how often each service has been initialised and
# add a + to the service name if pz:allow is used.
# Both for current and archived logs
cat pazpar2.log | grep "command=init" | sed "s/.*search.pz2?command=init&service=\([-a-zA-Z0-9]*\)/\1/g" | sed "s/.pz:allow.*/+/g" | sort | uniq -c
zcat pazpar2.log.2.gz | grep "command=init" | sed "s/.*search.pz2?command=init&service=\([-a-zA-Z0-9]*\)/\1/g" | sed "s/.pz:allow.*/+/g" | sort | uniq -c
@ssp
ssp / pazpar2-curl.sh
Created January 24, 2012 20:22
curl commands for starting a pazpar2 session, searching and querying results
#!/usr/bin/env sh
curl "http://vlib.sub.uni-goettingen.de/pazpar2/search.pz2?command=init&service=vlib" | grep init | sed -e 's/.*<session>//' | sed -e 's/<\/session>.*//' > /tmp/sessionID ; curl "http://vlib.sub.uni-goettingen.de/pazpar2/search.pz2?command=search&query=gaga&session=`cat /tmp/sessionID`" ; curl "http://vlib.sub.uni-goettingen.de/pazpar2/search.pz2?command=show&session=`cat /tmp/sessionID`" ; curl "http://vlib.sub.uni-goettingen.de/pazpar2/search.pz2?command=show&session=`cat /tmp/sessionID`" ; curl "http://vlib.sub.uni-goettingen.de/pazpar2/search.pz2?command=show&session=`cat /tmp/sessionID`" ; curl "http://vlib.sub.uni-goettingen.de/pazpar2/search.pz2?command=show&session=`cat /tmp/sessionID`" ; curl "http://vlib.sub.uni-goettingen.de/pazpar2/search.pz2?command=show&session=`cat /tmp/sessionID`" ; curl "http://vlib.sub.uni-goettingen.de/pazpar2/search.pz2?command=show&session=`cat /tmp/sessionID`" ; curl "http://vlib.sub.uni-goettingen.de/pazpar2/search.pz2?command=show&session=`cat /tmp/se
@ssp
ssp / gist:1778585
Created February 9, 2012 08:54
Solr URLs
Delete all documents:
/solr/update/?stream.body=%3Cdelete%3E%3Cquery%3E*:*%3C/query%3E%3C/delete%3E