środa, 15 października 2014

How to quickly get rid of all xs:annotation elements from XML schema file (XSD, that is)

xmlstarlet ed -N xs="http://www.w3.org/2001/XMLSchema" -d "//xs:annotation" schema-file.xsd > pruned-schema-file.xsd

It lends itself well to automation and I like it. It uses XmlStarlet.
Useful when you want to compare 2 schemas (or versions of the same schema) and you're interested mainly in the schema definition.

środa, 9 kwietnia 2014

Running MPlayer in the background

Well,  a standard & doesn't work. But there is a trick:

mplayer somefile.mp3 < /dev/null &

http://www.mplayerhq.hu/DOCS/HTML/en/faq.html#idp61248544

środa, 2 kwietnia 2014

Log only commit hashes in Git


The answer is --pretty=format:%H. E.g.
git log --reverse --pretty=format:%H my-branch-created-from-maintenance..my-branch-created-from-master
Useful in some ad-hoc scripts.
Suppose there are some changes on maintenance branch you do not want on master (yet?). You have created a branch from maintenance and made some local commits there. Now it turns out they should be commited on master, not maintenance. If you rebase on master, the unwanted changes will be present there. So:
for hash in $(git log --reverse --pretty=format:%H my-branch-created-from-maintenance..my-branch-created-from-master)
do
git cherry-pick $hash
done
Actually, I think there is some nicer way of doing it...