PHP: List of common pitfalls

I have seen a lot of PHP code, good and bad ones. Even some exploits for pretty common things that were just careless implemented.
In this post i want to share some of these pitfalls so you dont have to make them on your own.

|Den ganzen Beitrag lesen...

PHP: Benchmark Inkrement und Dekrement

Wir haben alle in der Schule das kleine EinMalEins gelernt, doch selbst bei den simpelsten Anweisungen in Programmiersprachen gibt es noch Wissenlücken über Verwendung und Laufzeitunterschiede.
Im nachfolgenden Post wird mittels Benchmark ermittelt welche Art die schnellste ist eine Variable in PHP5 um 1 zu erhöhen (inkerment) oder zu verringern (decrement).

|Den ganzen Beitrag lesen...

PHP: Everything you need to know about secure password hashing

On each site you need to register, your password has to be saved. This is typically done in a database. There are several ways to do this and some of them are good practice, other a very bad idea.

|Den ganzen Beitrag lesen...

Bash: Rename all files inside current directory

Renaming all files inside a directory can be done with the following code.

find * -type f | while read FILE; do mv "$FILE" old_"$FILE"; done;

The code will take all filenames in the current directory, and append "old_" to the name.

find * -type f
- Will make a list of all files in the current directory.
while read FILE; do ...; done
- Will read from a list each line into the variable FILE.
mv "$FILE" old_"$FILE";
- Will rename the filename in the variable $FILE to old_$FILE. Check out the double quotes - they are important, otherwise filenames with spaces will break the move command.

Ubuntu: Booting with "quiet" and "splash" ist faster.

I like to see what is going on when my ubuntu boots, so i disabled "splash" and "quiet" in mit "/etc/default/grub" and updated grub via "update-grub" afterwards as root.
Today i checked how this might slow down the boot process, because of the much output by the kernel. This is my result:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" --> 28 Seconds
GRUB_CMDLINE_LINUX_DEFAULT="quiet" --> 32 Seconds
GRUB_CMDLINE_LINUX_DEFAULT="splash" --> 30 Seconds
GRUB_CMDLINE_LINUX_DEFAULT=" " --> 33 Seconds

On my system, "quiet" speeds up booting by 1 or 2 seconds, and "splash" by 2 or 3 seconds.

I might leave both on for faster booting, but i will miss my informative kernel output :(

Auto: Opel Corsa Scheibenwischer reparieren oder Batterie austauschen

Es war mitten im Winter, in Deutschland lag überall Schnee. Inzwischen sogar so viel dass ich keine Lust mehr hatte den Schnee von der Windschutzscheibe zu entfernen, das hab ich dann den Scheibenwischer machen lassen. Es ging so lange gut, bist der Schreibenwischermotor irgendwann unter ächzen den Geist aufgegeben hat, und meine Wischer schief und krum mitten auf der Windschutzscheibe meines Opel Corsa C standen.
Im folgenden Artikel beschreibe ich, wie man den Scheibenwischermotor demontiert, austauscht / repariert, und wieder einbaut.

|Den ganzen Beitrag lesen...

Mirror: GIMP Brushes and Scrips from gimphelp.org

Today is used some arrow brushes from GIMPhelp.org. They had some nice brushes from "Paul Sherman", thanks buddy!

I mirrored their download folder, in case the site disappears.

http://juliusbeckmann.de/mirror/www.gimphelp.org/

HTC Dream (G1) zurück auf Android 1.6 flashen

Wer sein HTC Dream alias T-Mobile G1 zurück auf ein (deutsches) Android 1.6 flashen will, der halte sich an diese Anleitung von steff.
Für den Fall dass sein Seite inkl. der Download offline geht, hier der Link zu meinem Mirror.

PHP: Deprecated session_is_registered and session_unregister

Today i found in a older website i administrate some messages in the Apache error logfiles.

They looked like this:

PHP Deprecated: Function session_is_registered() is deprecated
PHP Deprecated: Function session_unregister() is deprecated

I searched the web and found this replacement code:

//session_is_registered($var);
array_key_exists($variable, $_SESSION);

and

//session_unregister($var)
unset($_SESSION[$var]);

I hope this might help someone.

Hint:
Do not use isset() here, because it might be wrong!
PHP - Benchmark isset() or array_key_exists() ?

Bash: Rename all files in current directory to lowercase

Just some code i used to rename my holiday pictures to lowercase.

find ./* -type f -maxdepth 0 | while read upName; do loName=`echo "${upName}" | tr '[:upper:]' '[:lower:]'`; mv "$upName" "$loName"; done

find lists all files in current directory. -type f lists only files, not directorys.

The while loop iterates over the file list.

echo | tr makes the filename variable lowercase.

mv finally moves the file.

Thanks to Veikko for the maxdepth hint.