Recent Blog Posts
Is your argument list too long? :)
Juli 21st, 2016 Read more ...
Good reference!
Sometimes it is nice to inject the output of a shell command into the current text, like the current and time.
PCRE Regex to match IP Version 4 Address in Decimal ASCII Representation
Juni 12th, 2014 Read more ...
During search for a regex that matches an IP address accurately I found [this article][1] which is the first result on google. The article shows a regular expression for accurate matching but it is not correct. This article show a correct implementation for the PCRE engine.
PHP implementation of common distribution functions
April 30th, 2014 Read more ...
Today I stumpled upon a great old answer on stackoverflow. @MarkBaker showed an implementation of the common distribution functions in PHP.
http://stackoverflow.com/a/3109793/171318
Don’t miss to upvote him
Create CSV file in memory PHP
Februar 9th, 2014 Read more ...
I've often seen solutions which are creating a temporary file using `tempnam()`. However, this solution still needs all contents written to a file first and then, in a second step, reading again using `file_get_contents()`. Also it needs to be sure that the file will be removed after operations, ... I mean *ensured*! ;)
Here I will show an alternative ...
Science of Sound
Januar 25th, 2014 Read more ...
sl – The opposite of ls :)
Januar 24th, 2014 Read more ...
Today I accidently made a typo when issuing the `ls` command on an Ubuntu server. The shell returned:
The application >>sl<< is currently not installed. You can install it using ...
Oh cool! What's that? A tool named `sl` ?
1982 Awards for Achievement
Oktober 14th, 2013 Read more ...
When automating mysqldump it is necessary to pass authentication information along with the command. While you can pass the credentials on the command line this is considered unsafe as the password would be visible to all users using the ps afx command (for example).
A workaround for this is using expect a program that is meant to automate user interaction for terminal programs. IT simulates a tty and passes input to the controlled program depending on its output.
Disable autoloading and enable it again later
Juli 17th, 2013 Read more ...
For some reasons it might be useful to disable autoloading, do some stuff and enable it again later. When using some frameworks or libraries this should be done in an anonymous way. For that pupose PHP provides the following functions:
Iterative algorithm to remove a directory tree
Juli 11th, 2013 Read more ...
When it comes to deleting a directory tree most solutions that have been posted around are recursive functions, like the following: ... While this is easy to implement it has some disadvantages when it comes to large trees ...
Windows XP, PXE Boot
Juni 14th, 2013 Read more ...
Windows XP is pretty old, but however, you may know those friends which are using quiet ooooold laptops, having a system crash but don't want to purchase a new one. When those laptops don't have a working CD-ROM drive anymore and ...
What’s the best (most efficient) way to search for content in a file and change it with PHP?
Juni 4th, 2013 Read more ...
Interesting question that is about to deleted on stackoverflow.
PHP IPC Signal Example
Mai 24th, 2013 Read more ...
There are several pitfalls when using POSIX signal handling with php. The following example should help to get around them.
The example forks a child process and afterwards sends the `SIGTERM` signal to the child. I'll guide you through the important sections:
Dump Source Code of Closure in PHP
Mai 22nd, 2013 Read more ...
Recently I was required to dump the source code of a closure in php, for debugging purposes. Here comes my first working approach:
Maximum URL Length
April 20th, 2013 Read more ...
I found an interesting article about the maximum length of an URL: http://www.boutell.com/newfaq/misc/urllength.html
Great answer on floating point precision on stackoverflow
Februar 12th, 2013 Read more ...
I recently found a GREAT point on floating point precision on stackoverflow. Here comes the link:
Simple download / upload speed measurement with PHP
Januar 29th, 2013 Read more ...
I was requested on stackoverflow to give a little download measurement script in PHP. Below the displayed page an info about download size and download speed should be displayed. I found the question really interesting. Here comes a short example how I would do this ...
metashock PEAR channel
November 23rd, 2012 Read more ...
Using the PEAR channel server you can install / upgrade my php packages using the PEAR installer. The url is http://www.metashock.de/pear/
Booting your usb stick using Virtual Box on a Linux host
November 16th, 2012 Read more ...
During the development of my Linux From Scratch I were searching for a way to test the boot process using Virtual Box instead of rebooting my development computer again and again. I found some articles on how to achive this using Windows, but I use Linux on my computer. Finally I did it :) using
VBoxManage internalcommands
. As I found no articles on this, here comes a short howto: Export a linux binary with its lib dependencies to a chroot or initramfs, …
November 9th, 2012 Read more ...
Sometimes it is nessesary to copy a Linux binary with its lib dependencies to a folder or archive. For example when creating an chroot emvironment, create an initramfs or copy a binary from one machine to another with the same architecture and kernel interface (this is hacky, yes)
Because I frequently needed to do this, I wrote a small shellscript for that purpose. Here comes the shellscript, explanation will follow ...
Wikileaks @ xkcd
Oktober 10th, 2011 Read more ...
PHP script for validating a XML file against a XSD Schema
Oktober 10th, 2011 Read more ...
A simple script that shows how to validate xml against in xsd schemas using PHP.
printf like log function for PHP
Oktober 9th, 2011 Read more ...
The following functions are good friends for logging. You can use format strings parsed by printf and several log levels.
Hexdump function for PHP
April 30th, 2011 Read more ...
When devoloping PHP applications that handle binary data it is useful to to be able to hexdump that data for debugging or logging. This is a hexdump() implementation for PHP.