Ideas about clean if statements

If you’re reading a lot of code you may get to the point where you’d like it to be clean, so it’s easier for you to read. There’re a lot of resources about the beauty of code around and in this post I’d like to share some ideas about writing concise if statements.

Although these ideas may apply to a lot of different programming languages I chose to give examples written in Java, PHP or Python. There should be no problem to translate this into other, similar languages.

Continue reading →

Building a simple proxy checker tool

In case you’re trying to change the configuration of your proxy server you might want to check what appears in the logs of a web server returning data to your proxy. Maybe you want to suppress certain HTTP header fields or make sure that the browser’s user agent is forged correctly.

This post discusses a PHP script which tries to display helpful information from the web server’s perspective. Although it may not be complete you can easily extend it to suit your needs.

Continue reading →

PHP: Using cURL if allow_url_fopen is not enabled

In case you’re using PHP to retrieve data from a certain server you probably came across the problem that it may work for you but a client complained about lots of errors. It’s pretty likely that you’ve relied on the fact that allow_url_fopen is set to true. This way you can put pretty much anything – local path or a URL – into function calls like include or maybe simplexml_load_file.

Continue reading →