Skip to content

Instantly share code, notes, and snippets.

@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 / emf-converter.sh
Created November 13, 2012 14:54
Convert Windows EMF to usable graphics files with a crazy chain of tools.
#! /bin/sh
# Convert Windows EMF to usable graphics files with a crazy chain of tools.
# 2012 Sven-S. Porst, SUB Göttingen <porst@sub.uni-goettingen.de>
# Configuration
BASEPATH=/Users/ssp/SUB/edfu/emf
WINE=wine
METAFILE2EPS=$BASEPATH/metafile2eps-linux/metafile2eps.exe
PS2PDF=ps2pdf
INKSCAPE=/Applications/Graphik/Inkscape.app/Contents/Resources/bin/inkscape
@ssp
ssp / Check Plist Syntax.sh
Created October 4, 2009 11:55
check syntax of .strings plist files
# check syntax of .strings plist files
find . -name "*.strings" -print0 | xargs -0 plutil | grep -v ": OK"
@ssp
ssp / gpsdownload.sh
Created December 11, 2009 12:00
download data from Bluetooth GPS device
# from strange Bluetooth GPS device that's already set up using gpsbabel
gpsbabel -t -w -i wbt -f /dev/tty.SPPslave -o kml -F ~/Desktop/route.kml
@ssp
ssp / fix keyboard equivalents.sh
Created December 11, 2009 12:10
find keyboard equivalents in application preference files
#!/bin/sh
defaults find NSUserKeyEquivalents | grep Found | sed "s/.*domain .\(.*\).:.*/'\1'/g" | tr "\n" "," | sed "s/\(.*\),/(\1)/g" | sed "s/Apple Global Domain/NSGlobalDomain/g" | xargs -t -J appnames defaults write com.apple.universalaccess com.apple.custommenu.apps appnames
# If Mac OS X's keyboard preference pane forgot your custom keyboard equivalents, this may be able to restore them
# see http://earthlingsoft.net/ssp/blog/2009/07/keyboard_equivalents
@ssp
ssp / vlc transcoding to H.264.sh
Created May 19, 2010 15:25
Use VLC to convert to H.264/MP4 and Ogg in one go.
# convert to MP4/H.264 and Ogg simultaneously
/Incoming/VLC.app/Contents/MacOS/VLC -I dummy ~/Dropbox/Public/VLC/Original.dv --sout='#duplicate{dst="transcode{vcodec=h264,venc=x264{profile=main,level=3},vb=800,scale=1,acodec=mp4a,ab=128,channels=2,samplerate=32000}:standard{access=file,mux=mp4,dst=/tmp/test.mp4}",dst="transcode{vcodec=theora,vb=800,scale=1,acodec=vorb,ab=128,channels=2,samplerate=32000}:standard{access=file,mux=ogg,dst=/tmp/test.ogg}"}' vlc://quit
<?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 / 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 / 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 / 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