simple templating engine
function parseTemplate(content, data) { content=String(content); re = /\[\[(\w*)\]\]/gi; return ( content.replace( re, function ($1,$2,$3) { return data[$2]; } ) ); }
12381 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Eric Vitiello http://www.leapfroginteractive.com
function parseTemplate(content, data) { content=String(content); re = /\[\[(\w*)\]\]/gi; return ( content.replace( re, function ($1,$2,$3) { return data[$2]; } ) ); }
function resize_jpg($inputFilename, $new_side){
$imagedata = getimagesize($inputFilename);
$w = $imagedata[0];
$h = $imagedata[1];
if ($h > $w) {
$new_w = ($new_side / $h) * $w;
$new_h = $new_side;
} else {
$new_h = ($new_side / $w) * $h;
$new_w = $new_side;
}
$im2 = ImageCreateTrueColor($new_w, $new_h);
$image = ImageCreateFromJpeg($inputFilename);
imagecopyResampled ($im2, $image, 0, 0, 0, 0, $new_w, $new_h, $imagedata[0], $imagedata[1]);
return $im2;
}