Tag Archives: Programming

Write HTTP request to web server with PHP.

I’ve recently built a proxy server that manually handles a lot of HTTP exchanges. I summarized the proxy’s read/writing to the server here. It actually is very simple: format a request in the form of an HTTP header, send the request to the server, and then read the server’s response. // OPEN SOCKET TO SERVER [...]
Posted in Programming | Also tagged , , | Leave a comment

Using reduce in Python.

Python has a built in operator called reduce. This is just another name for what a functional programmer would called a fold. They’re really useful, but you don’t know so until you actually need one. The easiest example to understand is listed below and is the same example provided on Python’s documentation. lon = [1, [...]
Posted in Programming | Also tagged , | Leave a comment

Calculate file age in Python.

I use a file’s age for many things, especially when it comes to monitoring servers with nagios. Every language has their own modules to do these things, so here is my quick example to calculate a file’s age with Python. import os from datetime import datetime stat = os.stat('/etc/php.ini') fileage = datetime.fromtimestamp(stat.st_mtime) now = datetime.now() [...]
Posted in Programming | Also tagged , | Leave a comment