Archive for the ‘Code’ Category
Thursday, February 11th, 2010
This is an example from a class that deals with user accounts.
function save() {
if(!$this->id) {
### DUPE PREVENTION
$sql = "SELECT id FROM users WHERE username = '" . $this->username . "' LIMIT 1";
$db2 ...
Posted in Code | No Comments »
Tuesday, February 17th, 2009
The brilliance of programming...
Last year I needed to tail a file in PHP. I whipped this out.
Today I needed to do it and came up with this:
$output = `tail -n 150 /var/log/messages`;
$tail_str = "<pre>$output</pre>";
Weee... don't know what the hell I was thinking last time.
Posted in Code | No Comments »
Saturday, February 7th, 2009
I had the need to convert a PDF to a JPG today. I searched around on Google and everything was pay to play. This is pure exploitation since this sort of conversion is a one liner for most Linux systems.
I wrote my own.
File:
Depending on your connection ...
Posted in Code | 2 Comments »
Tuesday, December 2nd, 2008
The PDF toolkit is command line app for manipulating PDFs. I use it to split faxes received in Hylafax into one file per page. I recently upgraded a server to x86 64 Fedora Core 9 and found that all of the precompiled versions of pdftk wouldn't work. I tried to ...
Posted in Code | 5 Comments »
Wednesday, November 12th, 2008
I've decided to learn flash. I don't know why, I don't know what I am planning on using it for, but I am going to do it.
Here is some example code I wrote up to play around with, it can read in XML outputted from a PHP script and display ...
Posted in Code | No Comments »
Monday, October 27th, 2008
This function will dynamically create a jpeg from the string you provide. It even handles multi-line strings.
function str_to_jpg($str, $file) {
$lines = explode("\n", $str);
$number_lines = count($lines);
$image = imagecreate(1000, ($number_lines * 16));
$background = imagecolorallocate($image, 0, 0, 0);
$text = imagecolorallocate($image, 255, 255, 255);
...
Posted in Code | No Comments »