Recent Blog Posts
Sometimes it is nice to inject the output of a shell command into the current text, like the current and time.
During search for a regex that matches an IP address accurately I found [this article] 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.
Today I stumpled upon a great old answer on stackoverflow. @MarkBaker showed an implementation of the common distribution functions in PHP.
Don’t miss to upvote him
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 ...
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` ?
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.
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:
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 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 ...
Interesting question that is about to deleted on stackoverflow.
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:
Recently I was required to dump the source code of a closure in php, for debugging purposes. Here comes my first working approach:
I found an interesting article about the maximum length of an URL: http://www.boutell.com/newfaq/misc/urllength.html
I recently found a GREAT point on floating point precision on stackoverflow. Here comes the link:
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 ...
Using the PEAR channel server you can install / upgrade my php packages using the PEAR installer. The url is http://www.metashock.de/pear/
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
. As I found no articles on this, here comes a short howto:
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 ...
A simple script that shows how to validate xml against in xsd schemas using PHP.
The following functions are good friends for logging. You can use format strings parsed by printf and several log levels.
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.