Skip to content

Instantly share code, notes, and snippets.

View atbradley's full-sized avatar

Adam Bradley atbradley

View GitHub Profile
@atbradley
atbradley / import_links_from_delicious.php
Created June 17, 2011 21:07
Sample event to demonstrate importing outside data (Delicious links from RSS) into the Symphony CMS
@atbradley
atbradley / gist:1006998
Created June 3, 2011 19:30
CodeIgniter configuration to allow both GET variables and segment-based addressing
$config['uri_protocol'] = "PATH_INFO";
$config['enable_query_strings'] = TRUE;
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_-?=+&;';
@atbradley
atbradley / stripTags.groovy
Created April 28, 2011 14:22
Very simplistically remove HTML tags from strings.
public static String stripTags(String input) {
return input.replaceAll("\\<.*?>","");
}
@atbradley
atbradley / gist:946439
Created April 28, 2011 14:20
Generate a random-enough string. Maybe useful for passwords or for the encryption seed required in some frameworks' configuration file.
function randstr($len = 8) {
$src = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
$src = $src.$src.$src.$src.$src;
return substr(str_shuffle($src), 0, $len);
}
@atbradley
atbradley / gist:946438
Created April 28, 2011 14:19
Python equivalent of php's md5()
def md5(str):
import md5
hasher = md5.new()
hasher.update(str)
return hasher.hexdigest()
@atbradley
atbradley / gist:946435
Created April 28, 2011 14:18
Basic scaffold for a Python decorator
def SomeDecorator(next):
def getFunction(fn):
def doStuff(req, *args):
return fn(req, *args)
return doStuff
return getFunction