Skip to content

Monthly Archives: September 2010

Create reusable MySQL schema dumps


In case you need a MySQL schema transferred from one host to another and the schema names differ, you can ran into problems with a standard MySQL dump.

Use the following statement to create a schema dump that contains all table and view definitions as well as all stored procedures without a reference to the original schema:

 mysqldump -uroot -p name_of_the_original_schema --no-data --opt --routines | sed 's/`name_of_the_original_schema`.//g' > dump.sql

The dump will only contain the schema definition and no data. Calls to routines will not be prefixed with a schema name.

iTunes terminal tipps 2010


4 years ago i had a first iTunes terminal tipp, here is a round up (all terminal tipps require Mac OS X):

Invert the iTunes Store links in the list

The littler arrows can either point to the iTunes store or to the same artist or album in your library. Invert their behavior to let them point to your files instead of the store:

defaults write invertStoreLinks -bool YES

Undo this with

defaults write invertStoreLinks -bool NO

Disable them with

defaults write show-store-arrow-links -boolean FALSE

Enable them with

defaults write show-store-arrow-links -boolean TRUE

Restore the horizontal stoplight

Again, Apple messes with it’s own UI guidelines. To restore sanity, use

defaults write full-window -boolean TRUE

Reenable the vertical layout introduced with iTunes 10 through

defaults write full-window -boolean FALSE

Enable half-star ratings

The following will let you rate your songs with half-star ratings (i.e 3.5 stars):

defaults write allow-half-stars -bool TRUE

If you don’t like the fact, that the half-star ratings will round on any i* device, turn it off again:

defaults write allow-half-stars -bool FALSE

Oracle “sleep” procedure: DBMS_LOCK.SLEEP


There’s a nice little “sleep” procedure in Oracle: A procedure that stops the execution of the current thread for n seconds.

Strangely, this method can be called in SQL*Plus like so:

EXEC dbms_lock.sleep(10);

but not in another stored procedure or function like so


To use “sleep” in your procedures or functions, login as administrator to your database (or ask you admin to to so) and create the following objects:

CREATE OR REPLACE public synonym sleep FOR sleep;
GRANT EXECUTE ON sleep TO public;

and in your procedure just use “sleep”.

Preparing for Rails 2.3.9


As much as i wish to upgrade my Rails 2.3.x application Daily Fratze to the newest tag of the Rails 2.3.x branch, i cannot.

First there was the epic fail of release 2.3.6, that broke all HTML Helpers and forced the Rails XSS protection upon us. This release was immediately followed by 2.3.7 and 2.3.8. With my tests, this version was still enforcing Rails XSS and breaking helpers like “h”.

Rails 2.3.9, released last week, puts en end to this.

I just was about to upgrade, when i read this error: Textarea input silently truncated in 2.3.8!. The input of a textarea is truncated if the text entered consists of two lines or more with one of them quoted as the Rack middleware messes with the input.

I can confirm that this behavior still applies to 2.3.9.

It’s a shame, that all the talk is about Rails 3 with bugs like this in an older branch. I understand that this is a Rack problem but as it is already fixed in newer Rack versions, i cannot understand that the Rails team doesn’t bump the required Rack version respectively has no tests for problems like these.

So i’m hoping that Rails 2.3.10 sees the light of day anytime soon.

Anyway, as Rails 2.3.9 suddenly uses a new interpolation syntax for the translation files (“Hello {{name}}” becomes ” Hello %{name}”), here is a one-liner to update i18n files to the new syntax:

find . -iname "*.yml" -exec sed 's/{{\([^\{\}]*\)}}/%{\1}/g' -i {} \;

If you like some less escapism use xargs

find . -iname "*.yml"  | xargs sed 's/{{\([^{}]*\)}}/%{\1}/g' -i;

Commands need to be executed inside your locale directory.

How to get UIDefaults in Java


If you’re loocking for Javas UIDefaults, use the UIManager class. This snippet gives you all installed UIDefaults:

UIDefaults defaults = UIManager.getDefaults();		 
for(Enumeration e = defaults.keys(); e.hasMoreElements(); ){
    String key = e.nextElement().toString();
    System.out.println(key + " = " + defaults.get(key));	         

E-mail It