This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function resize($new_w, $new_h, $preserve=false){ | |
$name = $this->image; | |
$e = $this->getExtension(); | |
$filename = dirname($this->image) .'/'. $e['file'] .'_'. $new_w .'x'. $new_h . $e['extension']; | |
// this function only works if the imagecreatefromjpeg function exists | |
if(!function_exists('imagecreatefromjpeg')){ return false; } | |
// adapted from http://icant.co.uk/articles/phpthumbnails/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class A { | |
public $id; | |
public function __construct($id){ | |
$this->id = $id; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find . -name ._* -not -path *.svn* -exec svn rm {} \; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
params = { | |
:font_size => 10 | |
} | |
# 1 | |
defaults = { | |
:font => "Times-Roman", | |
:font_size => 11, | |
:stroke => false | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Create a new function based on the current line | |
Examples: | |
Line: myFunction | |
Output: a function with the name myFunction |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf import settings | |
from django.utils.http import urlquote | |
from django import http | |
class EnforceHostnameMiddleware(object): | |
""" | |
Enforce the hostname per the ENFORCE_HOSTNAME setting in the project's settings | |
The ENFORCE_HOSTNAME can either be a single host or a list of acceptable hosts | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// jQuery plugin | |
// make "blank" options non-selectable | |
(function($){ | |
$(document).ready(function(){ | |
jQuery('select').change(function(){ | |
var select = jQuery(this) | |
var blankValues = ['', '-', '#', ' '] | |
if(jQuery.inArray(select.val(), blankValues) != -1){ | |
jQuery('option:selected', select).attr('selected', '') | |
jQuery('option:first', select).attr('selected', 'selected') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// convert the error reporting value to an array of constant values | |
// from: http://php.net/manual/en/function.error-reporting.php | |
$bit = ini_get('error_reporting'); | |
$res = array(); | |
while ($bit > 0) { | |
for($i = 0, $n = 0; $i <= $bit; $i = 1 * pow(2, $n), $n++) { | |
$end = $i; | |
} | |
$res[] = $end; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datettime | |
import rotatelib | |
import MySQLdb | |
db = MySQLdb.connect('localhost', 'user', 'password', 'my_database') | |
# find any backup tables (tables with a date in the name) that are older than 5 days | |
items = rotatelib.list_backup_tables(db=db, before=datetime.timedelta(5)) | |
for item in items: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# | |
# Textmate item to increment all numbers in a selection | |
# | |
# If you have: | |
# | |
# line1 | |
# line1 | |
# line1 |
OlderNewer