UI Design Inspiration – Dribbble Roundup 1
Graphics from the amazing dribbble.com
In most of todays web projects, you need to maintain the applications data model as a database structure. There are several challenges according to the maintenance of such a data model. I want to show you my thoughts about simple solutions to some of them in this post.
I want to have one independent definition of my data model, which does not affect my code and I want to automatically track changes and generate update scripts on model changes for release deployments. So, how can we achieve these goals in a simple, pragmatic way? There are lots of solutions out there like object relational mapping solutions, different XML formats, etc. But they are not exactly what I’m looking for.
I decided to create my own generic XML representation of the data model. I only added the attributes I need for most of my projects. This is very important, because we don’t want to blow up our applications infrastructure and build a Hibernate-style mapper or whatever. Think about everything you add, do you really need it? Is there an alternative, code based method to solve the problem? Avoid to much logic in your database like views, procedures or other complex, hard-to-maintain magic. Well, the XML representation of our dummy object “user” looks like this
This is our one and only place to define the important parts of our data model. Now, normally we want to apply this data model to our database. So, we need a converter for this step. I wrote a simple PHP script, which you can see at the of this post. It’s alpha and has limited features, but for me, it’s enough for the moment. The generated SQL script will look like this
In the XML definition there is an attribute “since”, which stands for the version since this field is available and “until”, which marks a field as removed. With this information, we are able to generate diff scripts between versions. This is important for deployment of new releases. The diff method, which generates SQL ALTER scripts is not implemented in the sample script below, but will be added soon.
Start converting your data model to a single XML definition file by using the #reverse() method of the sample script in this post. It just dumps your database tables to type definitions.
Here’s the mentioned script. Use it as a starting point for your customized Conversion Utility.
Model.php
As a day to day programmer I like to code on dark color schemes. These are provided by tools like TextMate on the Mac or gedit (Oblivion color scheme) on my Ubuntu machine. But I’m an Eclipse addict. So, I created my own dark color scheme in eclipse for use with PHP source files. My sources now end up like you see in the following screenshot. Isn’t it awesome?
I use the fantastic Droid Sans Mono at 9px as my default font for monospace text.
To get this working you need to adjust your Eclipse preferences (Window > Preferences) in different menus.
General > Editors > Text Editors
General > Editors > Text Editors > Annotations
PHP > Editor > Syntax Coloring
Web > HTML Files > Editor > Syntax Coloring
Web > JavaScript > Editor > Syntax Coloring
Web > CSS Files > Editor > Syntax Coloring
Java > Properties File Editors
You can get this easier, if you download and import my preferences (Based on Eclipse 3.5.2):
eclipse_dark_color_scheme.epf
Multilanguage websites or webapplications are state-of-the-art today. You have a lot of choices in translation technology, language, format, etc. gettext is one of the most popular libraries to use. There are some downsides using gettext. One of the bad things is that you need to compile your .po files to .mo files before deployment. So, I decided to use PHP arrays instead of .po files for my translation strings. In order to convert my existing .po files, I wrote a little 5-minute script :-), which prints out a php file with a php array, according to the .po file.
This prints out something like
Btw, a great tool to manage your translations and get them in different formats like php, po, etc. is gengo string. Check it out at http://mygengo.com/string/about
The following commands describe how you can install Sphinx in Ubuntu/Debian.
If you need support for japanese or cyrillic language search, you need to register all of the UTF-8 characters in your indexer configuration. There are three configuration settings that are important to get the thing working.
These settings are working perfect for the following languages (more not tested):
- German
- English
- French
- Italian
- Spanish
- Dutch
- Danish
- Swedish
- Portuguese
- Turkish
- Greek
- Russian
- Japanese
- Chinese
- Korean
- Arabic
All languages with characters listed in this wiki article about charset tables should work, but are not tested yet.
If you are working with high performance web applications, you maybe know memcached, an in-memory key-value store. Now, there is a linux tool called memcache-top, which allows you to get statistics over your memcache cluster like you get for your system using top.
Download the tool at http://code.google.com/p/memcache-top/
memcache-top v0.5 (default port: 11211, color: on, refresh: 3 seconds) INSTANCE USAGE HIT % CONN TIME EVICT/s READ/s WRITE/s 10.50.11.5:11211 88.8% 69.6% 1123 1.9ms 0.3 13.1K 36.2K 10.50.11.5:11212 88.7% 69.6% 1175 0.6ms 0.3 12.4K 28.1K 10.50.11.5:11213 88.8% 69.4% 1148 0.7ms 0.0 16.6K 32.1K 10.50.12.5:11211 89.3% 81.5% 1460 0.7ms 0.3 17.7K 204.0K 10.50.12.5:11212 89.4% 69.3% 1174 0.6ms 1.0 28.9K 63.5K 10.50.12.5:11213 89.3% 69.4% 1158 0.7ms 0.7 166.3K 194.4K 10.50.15.5:11211 89.3% 71.8% 1472 0.8ms 0.0 37.3K 59.2K 10.50.15.5:11212 89.4% 69.3% 1143 0.7ms 0.7 44.9K 35.4K 10.50.15.5:11213 89.3% 84.5% 1371 0.7ms 0.7 49.0K 187.2K 10.50.9.90:11211 30.2% 76.3% 259 0.7ms 0.0 243 999 10.50.9.90:11212 19.2% 60.3% 261 0.7ms 0.0 40 801 10.50.9.90:11213 17.5% 16.9% 235 0.6ms 0.0 70 600 AVERAGE: 72.4% 67.3% 998 0.8ms 0.3 32.2K 70.2K TOTAL: 23.4GB 11.7K 9.2ms 4.0 386.4K 842.3K
Bald ist es wieder soweit. Es enstehen die ersten Designs für die 4. Ausgabe des beliebten Fussballtippspiels. Ihr werdet die neue Seite wieder wie immer unter http://www.goool.ch finden. Wir hoffen wieder auf reges Interesse bei den Fans. Falls ihr Anregungen habt, schreibt mir diese doch als Kommentar oder E-Mail (zu sehen unten im Screenshot).

For a small daemon written in PHP (something like while(true) { … }), I wanted to have an init script to start, stop and restart my daemon. I found some examples after googling, but most of them have a lot of unneeded stuff in there. So i stripped down to the following. See this as a template for creating your own. There is currently no implementation for status and restart, but should be no problem to enhance the script. This script is tested in Ubuntu. Maybe you need to change some path variables to other values according to your system configuration.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #! /bin/sh # Copyright 2010 Roger Dudler ### BEGIN INIT INFO # Provides: phpworker # Required-Start: $syslog # Required-Stop: $syslog # Should-Start: $local_fs # Should-Stop: $local_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 ### END INIT INFO NAME=phpworker DESC=phpworker PIDFILE=/var/run/$NAME.pid PHP=/usr/bin/php DIR=/path/to/your/daemon/ case "$1" in start) echo -n "Starting $DESC: " start-stop-daemon -S -b -m -p $PIDFILE --exec $PHP $DIR/worker.php echo "$NAME." ;; restart) ;; stop) echo -n "Stopping $DESC: " start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE echo "$NAME." rm -f $PIDFILE ;; status) ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop|restart|force-reload|status}" >&2 ;; esac exit 0 |