Tag Archives: Programming
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, [...]
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() [...]
Write HTTP request to web server with PHP.