Skip to content

Instantly share code, notes, and snippets.

View pbassut's full-sized avatar

Patrick Bassut pbassut

View GitHub Profile
function resize_image($file, $w, $h, $crop=FALSE) {
list($width, $height) = getimagesize($file);
$r = $width / $height;
if ($crop) {
if ($width > $height) {
$width = ceil($width-($width*abs($r-$w/$h)));
} else {
$height = ceil($height-($height*abs($r-$w/$h)));
}
$newwidth = $w;
from cmd import Cmd
class MyCmd(Cmd):
def onecmd(self, str):
if str == 'ls':
# here we should print the files in the cwd
print 'No files. Sorry!'
def precmd(self, line):