Skip to content
accelerando

Category Archives: Shortcuts

SVN: Revert to previous version

09-Sep-09

Just a quick reminder:

To revert a complete working copy or a single file use:

svn merge -rHEAD:PREV .
# or
svn merge -rHEAD:PREV path/to/file
svn commit -m "reverted"

Batchconvert ascii to utf8

12-May-09

Next time i see umlauts in source, I’ll scream. Loud.

In the mean time I try this:

find . -iname "*.java" -exec sh -c 'iconv -f cp1252 -t utf-8 {} > {}.utf8' \;
for i in `(find . -name "*.utf8")`; do mv $i ${i/.utf8/}; done

Before you try this, make a backup of your files. It worked for me but i don’t guaranty that your files won’t vanish.

XML / XSD Schema validation on Mac OS X

16-Jan-09

I found no fancy graphical xml validator on OS X, but this isn’t a problem.

OS X includes libxml which comes with xmllint.

To validate a xml file against a schema:

xmllint --noout --schema sitemap.xsd sitemap.xml

Recursively md5sum all files in a directory tree

25-Oct-08

After a server crash a wanted to compare all actual files with the backuped data. An easy way is to compare the md5 hashes like that:

First create recursively md5 hashes from all files in that directory:

find ./backup -type f -print0 | xargs -0 md5sum > /checksums_backup.md5

Then check the actual data:

md5sum -c checksums_backup.md5

I was lucky, no files where damaged.

Sony Ericsson C702: Show received and send traffic

28-Jul-08

Once again, a quick reminder for myself: Howto display the internet traffic on your Sony Ericsson C702:

Menü, #, 4th Tab, 5

(On a german phone: “Einstellungen / Anrufe / Zeit und Kosten”)

I guess that works with other SEs like K800i and K850i.

I remember an old SE that i had which always displayed the traffic after ending an internet session, i wonder why they changed it.

Firefox 3 Mouse Wheel Zoom

08-Jul-08

Zooming with the CTRL+Mouse Wheel Up/Down has been in inversed in Firefox 3. In version 2 you zoomed in (enlarged the text) with CTRL+Mouse Wheel Down and zoomed out with CTRL+Mouse Wheel Up, its now in Firefox 3 the other way round.

The revert back to the old behaviour, change

mousewheel.withcontrolkey.numlines = 1

to

mousewheel.withcontrolkey.numlines = -1

in about config.

To me “pulling” the page towards myself always felt much more natural to me than the other way round, but that’s just me.

Oracle XE environment variables on Linux

04-Jun-08

Just a quick reminder for myself:

With the default installation of an Oracle Express (Oracle XE) comes two shell script with all the necessary environment variables to use sql*plus, exp, imp and the like on the command line:

source /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle_env.sh

respectively

source /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle_env.csh

Hibernate and Inheritance Mapping

27-May-08

Hibernate supports multiple types of inheritance mapping, some of them (Table per class, Table per subclass) using a discriminator column to decide the class.

The type of the discriminator can be one of

string, character, integer, byte, short, boolean, yes_no, true_false

In case you need to use any other than string or character, i.e. integer, you have to give the base class a default discriminator-value like 0 or -1 or whatever fits, otherwise you’ll end up with a an exception like:

org.hibernate.MappingException: Could not format discriminator value to SQL string

as Hibernate uses the class name of the base class to derive a default value.

Division by zero

26-May-08

Just a quick reminder for myself:

int a = 0/0; // Throws ArithmeticException
double d1 = 0/0.0; // d1 is NaN
double d2 = 1/0.0; // d2 is Infinity
double d3 = -1/0.0; // d3 is -Infinity

Can cause some headache if things fall apart in the JDBC driver and not before. Grmpf.

Ampersands and XHTML

25-May-08

A regular expression to replace all ampersands (&) in a text that are not part of an entity:

t = t.gsub(/&(?!#?\w+;)/, '&')

Language is ruby. The regexp feature used is called a negative lookahead.

Close
E-mail It