Archive for the ‘Code’ Category
Sunday, July 6th, 2008
Holy shit, why did this take so long to figure out.
$input_filename = 'somefile.jpg';
$output_file = 'someotherfile.jpg';
$new = ImageCreateFromjpeg($input_filename);
$width = imagesx($new);
$height = imagesy($new);
$black = imagecolorallocate($new, 0, 0, 0);
$white = imagecolorallocate($new, 255, 255, 255);
$font = 4;
$leftTextPos = ($width - imagefontwidth($font)*strlen($name))/2;
imagefilledrectangle($new, 0, ($height-20) , $width, $height, $black);
imagestring($new, $font, $leftTextPos, $height-18, $name, $white);
imagejpeg($new, $output_filename);
Posted in Code | Comments Off
Tuesday, July 1st, 2008
I work with a lot of NAT routers. Every brand imaginable, D-link, Linksys, odd jobs that ISPs supply, you name it. Sometimes it can be a pain to get them to forward ports properly, it can be even more of a pain to test if it is working. I wrote ...
Posted in Code | Comments Off
Wednesday, June 18th, 2008
Very, very insecure.
$base_dir = "/var/log/sxr";
$file = (isset($_GET['file']) ? $_GET['file'] : 0);
$to_tail = 25;
$full_path = $base_dir . '/' . $file;
$lines = file($full_path);
$count = count($lines);
if($count < $to_tail) {
$to_tail = $count;
}
$start = $count - $to_tail;
print = "Last $to_tail lines of $file";
while($start < $count) {
print $lines[$start] . '';
$start++;
}
Posted in Code | Comments Off
Monday, June 16th, 2008
You would think a check all function would be pretty easy in jQuery, and it is if all of the checkboxes have the same name. If they don't things get tricky.
In this example, I have an anchor named chk_all that the user can click to check all. All of my ...
Posted in Code | Comments Off
Sunday, March 30th, 2008
#!/bin/bash
#/bin/ls April Fools replacement
LS="/bin/.ls $*"
#generate random int 0
Posted in Code | Comments Off
Saturday, March 29th, 2008
#include
int main(int argc, char** argv) {
while(1) {
sleep(1);
system("eject");
sleep(1);
system("eject -t");
}
}
Posted in Code | Comments Off