Archive for the ‘Programming’ Category.
I have put up a new script for those of you who are running Lighttpd. You can find it here. It is a dir-generator that is nearly identical to the default, but with the added bonus that you can sort by name, size, modification time, and file type. One downside is that it doesn’t display mime type like the original does since to do that with PHP, it is required that an extension is insalled.
When I was in high school, I always had fun finding exceptions the “I before e, except after c” rule. I found over a hundred on my own back then just by searching around the Internet. Today I decided to take a better approach and wrote up a small script in to do the work for me. All in all, it found 533 exceptions to this rule.
Click here to view the list of exceptions.
Yeah, that’s quite a few. If you’re interested in how I did it, continue reading. Don’t worry, I won’t be sad if you came here just for the list.
Continue reading ‘I Before E, Except After C – Not a rule, but a joke’ »
Recently, I needed a quick and simple solution to buffer output of a few Python scripts. When I went to look for a module, I was astonished to find that one didn’t exist. I quickly decided to change this. In this article, we’ll discuss simple ways to buffer output using StringIO and I’ll introduce my output buffering module that I constructed.
Continue reading ‘Simple Output Buffering in Python’ »
A great thing about working in Python is that it provides you with numerous methods of string formatting and interpolation. Unfortunately, it isn’t as implicit as it is in PHP, where just using double-quotes will parse the string. In Python at the very minimum string interpolation requires the use of the modulo operator (%) or a custom-built function. In this article, we’ll discuss building a string interpolation function using the string.Template object and Python 3.0′s format method.
Continue reading ‘Near-Implicit String Interpolation in Python’ »
XOR encryption is a great solution to go with when a task requires that a piece of data is encrypted with a key when one doesn’t have the means to use a more well-rounded algorithm. I’ve used it on a few occasions with great success. In this document, we’ll discuss how to code the XOR cipher in Python and we’ll cover the pros and cons of using it.
Continue reading ‘XOR Encryption With Python’ »
The ternary operator can be incredibly useful in numerous situations in Python, which is why I’m surprised that prior to Python 2.5, there was no standard way of using one. In this article, we’ll cover the ternary operator that was added in Python 2.5 along with the numerous ways that people emulated the operator before then.
Continue reading ‘Ternary Operator in Python – People got Clever’ »