June 24th, 2010
Probably because many people think Bash is outdated it’s that hard to find proper resources digging into this Shell. Now we’ll have a look at an associative array and use each key to rename a file defined in value one got via wget.
Beware: Take a look at the OS X issues at the end of this article if working on a Mac!
#!/bin/bash
unset array; declare -A array # the -A attributes stands for associative
array[foo]=bar
array["spaced string"]="foo bar"
for i in ${!array[@]}
do
# do something
done
This is how an iteration could look like. Have a look at bash-hackers.org to get more information. Thanks to Dennis Williamson solving this topic.
To get a file from the given URL perform the following command in the loop:
wget "${array[$i]}" -O "${i}.jpg"
The attribute -O renames the file.
Using variables outside Strings obviate the need for curly brackets so that $i would work as well.
Go on reading if you’re using a Mac:
Read the rest of this entry »
Tags: Bash, Mac OS
Posted in Gemachtes | No Comments »
March 25th, 2010
There are several situations one might want to do cross-domain (/cross-site) AJAX-requests. Probably you experience the security borders of modern browsers very fast.
JSONP is a hack for JSON that provides a great workaround. It means sending a callback with the URL (eg. ?callback=sampleFunction). Server-sided we setup our application to respond with a JSON body wrapped in a function named like our callback function. In this case
sampleFunction({
"ourData": [{
"title": "is an array"
},
"title": "..."
}]
})
What we have to do (Sample)
Frontend
JS-Frameworks like jQuery are smart enough to send such requests with ease. Lets write a simple function with jQuery:
$.ajax({
type: 'get',
url: 'file.json',
dataType: 'jsonp',
success: function(data) {
doSomethingWith(data);
}
})
Let’s see how to setup the server:
Using Ruby and Rack it becomes very simple to beautifully provide regular JSON for non-JSONP clients and JSONP for jQuery & Co.
Simply use the rack middleware rack-contrib by Ryan Tomayko
gem install rack-rack-contrib --source=http://gems.github.com/
If you’re using pure rack, put this in your config.ru
require 'rack/contrib/jsonp'
use Rack::JSONP
Using Sinatra, I’d put it somewhere with my config files.
Let’s see how a sample Sinatra application could look like:
require 'sinatra'
require 'json'
require 'rack/contrib/jsonp'
use Rack::JSONP
before do
content_type :json
end
get '/posts' do
Posts.find.to_a.to_json
end
That simple, this powerful.
Tags: AJAX, Hacks, jQuery, JSON, Rack, Ruby, Sinatra
Posted in Gemachtes | 1 Comment »
March 8th, 2010
Es gibt zwei Möglichkeiten die Sprache für das Text- und Absatzformat in InDesign zu ändern. Wenn wir allerdings nicht für jedes Textfeld die Sprache ändern wollen, müssen wir uns eines Workarounds bedienen. Schließlich gibt es kein “Sprache für Dokument ändern”. Dann wollen wir mal:
Read the rest of this entry »
Tags: Arbeit, InDesign
Posted in Gemachtes | No Comments »
February 9th, 2010
Es kann so einfach sein.. Werbung von Morgen.

Aufgenommen: Bf Hamburg Altona (neben Mc Donalds) – “Werbekasten”
Update via @MrRaffnix – so macht man’s richtig:
Read the rest of this entry »
Tags: Absurd, Hamburg, Verrückt
Posted in Gemischtes | 1 Comment »
February 8th, 2010
Um herauszufinden, was du willst, musst du bewusster leben – nicht danach suchen. Denn erst Erlebtes lässt sich reflektieren. Leben ist permanent in Bewegung zu bleiben.
Studien haben ergeben, dass sportliche Menschen, denen man mehrere Wochen lang Faulenzen verordnet hat, schon nach kürzester Zeit schwere physische Mängelerscheinungen aufwiesen. Ich bin mir trotz fehlenden Studien sicher, dass genau dies auch mit deiner Psyche passiert wenn du deinen Geist zu Bette trägst. Am leichtesten passiert dies, wenn du dich auf erreichtem ausruhst. Was dein Körper dir mit schwammigen Polstern verbucht, endet für dein Wesen in einer erträglichen, unbewussten Einfalt. Die Seligkeit scheint omnipräsent – ist aber zerbrechlich wie Porzellan. Es ist einfacher.
Reflektierst du diese Hypothese auf deine Beziehungen, wirst du ganz ähnliche Zusammenhänge erkennen. Insbesondere partnerschaftliche Beziehungen können unter der enormen Last der Unbedarftheit bersten. Die Schlichtheit einer Beziehung ist bester Nährboden für Glückseligkeit. Wenn sich Lebensbedingungen und Beziehungen ändern kann es aber sein, dass dieser Boden nicht mehr trägt. Was man also bis hierher aufgebaut hat, kann sich geradewegs entrüsten. Du bist entmutigt und enttäuscht von dir selbst. An dieser Stelle bist du gerade. Du musst nun beantworten ob du dir zutraust mit den gleichen Steinen, mit der Annahme die Architektur besser zu verstehen, das Fundament neu zu verlegen. Wenn, denke daran, dass du entweder die Ruinen des alten Baus – so weit möglich – wegräumst oder ein, in seiner Stabilität gefährdetes, Neues darauf setzt. Oder du sogar neue Gründe erforscht und auf neuem Raum mit neuem Material baust.
In jedem Fall ist es maßgebend, dass du die ständige Anpassung und Auseinandersetzung wahrst. Lass dies dein oberster Grundsatz sein.
Vielleicht konnte ich dir ein wenig helfen. Viel Erfolg und Glück!
Tags: Freunde, Menschen
Posted in Gedachtes | No Comments »
January 20th, 2010
This article is about moving a running web-environment along with it’s MySQL database from one server to another via SSH.
Compress files
Let’s compress the directory we’re going to move using gzip:
tar cfvz backup.tar.gz /path/
Dump MySQL database content
mysqldump -uUser -p -hlocalhost database_name > dump.sql
You can also dump several databases with mysqldump by addind the --databases or --all-databases parameter.
Moving files
Now we use SCP to move files to our new machine. The following example copies from the old machine:
scp user@host:/path/backup.tar.gz .
The other way round, copying the file to the new machine from the old one would look like this:
scp backup.tar.gz user@host:/path/backup.tar.gz
Do the same with your database dump.
Uncompress files
Simply type:
Now we should have the same directory structure we had on our old machine.
Import MySQL database
mysql -uUser --default-character-set=utf8 -hlocalhost -p database_name < dump.sql
If you have international content and an utf-8 environment running don’t forget to pass the charset-parameter!
Tags: Arbeit, Server, Web
Posted in Gemachtes | 1 Comment »
January 12th, 2010
Passend zum Schneechaos in Norddeutschland ein paar Eindrücke aus dem Hamburger Hafen im Winter. Ich habe noch nichts nachbearbeitet – also seht ihr Rohmaterial aus der Kamera.

Read the rest of this entry »
Tags: Hafen, Hamburg
Posted in Gemachtes | No Comments »
November 19th, 2009
The following script jQuery extension selects any text from a given jQuery selector. Tested with Firefox and Safari – should work in IE6+ as well.
jQuery.fn.extend({
selectText: function() {
var text = $(this)[0];
if ($.browser.msie) {
var range = document.body.createTextRange();
range.moveToElementText(text);
range.select();
} else if ($.browser.mozilla || $.browser.opera) {
var selection = window.getSelection();
var range = document.createRange();
range.selectNodeContents(text);
selection.removeAllRanges();
selection.addRange(range);
} else if ($.browser.safari) {
var selection = window.getSelection();
selection.setBaseAndExtent(text, 0, text, 1);
}
return $(this);
}
})
To use it simly do:
var shortSelector = $('#name').selectText();
var longSelector = $('ul#names li:contains("Hampel")').selectText();
written on top of Source and Source
Tags: Arbeit, jQuery, Web 2.0
Posted in Gemachtes | No Comments »
August 13th, 2009
Wer einen Complete Tarif mit iPhone hat, hat “eigentlich” auch eine HotSpot Flat für die über 8000 Hotspots vom rosa Riesen. Da aber die komplette Benutzerverwaltung auf mein.t-mobile.de absoluter Schrott ist und von Integrität nicht die Rede sein kann, muss man erraten wie man nun an seine Zugangsdaten kommt. Wenn man es weiss, ist es einfach: Read the rest of this entry »
Tags: iPhone, T-Mobile
Posted in Gemischtes | 9 Comments »
July 8th, 2009
As I had to build a simple html to pdf converting for a client using php, I found a beautiful library called DOMPDF written by Benj Carson.
It seemed to be very lightweight and uncomplicated, which turned out to be true. In a standard case it really is as simple as
I am going to talk about the basic usage and problems I had to solve, specially with umlauts / non latin characters.
Read the rest of this entry »
Tags: Arbeit, PDF, PHP, Web
Posted in Gemachtes | 1 Comment »