UI Design Inspiration – Dribbble Roundup 1

Graphics from the amazing dribbble.com

Dashboard Stats

Gowalla Startscreen

ID Card

Rating Slider

Green UI Progress Bar

Colorful Login Screen

Just a UI

Slideout

Stats

Blue UI

Calendar

Background Pattern

Avatar Design

Dashboard / Progress

Heading

Pragmatic data model maintenance in a web project

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

Dark color scheme for Eclipse, especially for use with PHP scripts

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

Background color: #2e3436
Current line hightlight: #555753
Selection foreground color: #FFFFFF
Selection background color: #757575
Line number foreground: #D0D0D0

General > Editors > Text Editors > Annotations

PHP elements ‘write’ occurrences: #000000
PHP elements ‘read’ occurrences: #000000

PHP > Editor > Syntax Coloring

Normal: #D8D8D8
Comment: #C7DD0C (Italic)
Keyword: #FFFFFF (Bold)
String: #FFC600
Number: #7FB347
PHPDoc: #CCDF32
Variable: #79ABFF
PHPTags: #FF6A6A

Web > HTML Files > Editor > Syntax Coloring

Attribute Equal Signs: #6D8710
Attribute Names: #9FC90C
Attribute Values: #FFC600
Comment Content: #C7DD0C
Comment Delimiters: #C7DD0C
Content: #D8D8D8
Tag Delimiters: #79ABFF
Tag Names: #79ABFF

Web > JavaScript > Editor > Syntax Coloring

Local variable declarations: #79ABFF
Local variable references: #79ABFF
Parameter variables: #A6BADD
Others: #D8D8D8
Operators: #D8D8D8
Strings: #FFC600
Keyword ‘return’: #FFFFFF
Keywords excluding ‘return’: #FFFFFF
Comments>Single-line comment: #C7DD0C
Comments>Multi-line comment: #C7DD0C
Comments>Task Tags: #CCDF32 (Bold)
JSDoc>Others: #C7DD0C
JSDoc>Tags: #CCDF32 (Bold)
JSDoc>Links: #939E3D
JSDoc>HTML Markup: #798805

Web > CSS Files > Editor > Syntax Coloring

Comments: #C7DD0C
Arguments: #FF3100
Property Value: #FFC600
Property Name: #79ABFF
Selector: #D8D8D8
Curly Brace: #B5B5B5
Property Delimiter: #B5B5B5
SemiColon: #B5B5B5

Java > Properties File Editors

Assignments: #D8D8D8
Comments: #C7DD0C
Keys: #79ABFF
Values: #FFC600

You can get this easier, if you download and import my preferences (Based on Eclipse 3.5.2):
eclipse_dark_color_scheme.epf

Quicktip – Convert .po files to .php (PHP array)

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

goool.tv ist online – Das WM-Tippspiel 2010

How to install Sphinx search engine with MySQL support on Linux

The following commands describe how you can install Sphinx in Ubuntu/Debian.

cd /opt
sudo wget http://www.sphinxsearch.com/downloads/sphinx-0.9.9.tar.gz
sudo tar xvfz sphinx-0.9.9.tar.gz
sudo ln -s /opt/sphinx-0.9.9 sphinx
sudo apt-get install build-essential libmysqlclient15-dev
cd /opt/sphinx
sudo ./configure
sudo make
sudo make install
sudo cp /usr/local/etc/sphinx.conf.dist /usr/local/etc/sphinx.conf

Full UTF-8 Language Support (Japanese, Cyrillic, etc.)

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.

charset_type = utf-8
ngram_len = 1
ngram_chars = click to get the list
charset_table = click to get the list

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.

MySQL / Sphinx – Optimizing application performance using Sphinx

http://www.mysqlperformanceblog.com/wp-content/uploads/2010/04/Sphinx_new.pdf

Monitoring memcache daemons using top-like tool

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

goool.ch – Das ultimative Tippspiel zur WM 2010 in Südafrika

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).

Create a simple shell init script for your PHP daemon

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