This file contains 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
def SomeDecorator(next): | |
def getFunction(fn): | |
def doStuff(req, *args): | |
return fn(req, *args) | |
return doStuff | |
return getFunction |
This file contains 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
def md5(str): | |
import md5 | |
hasher = md5.new() | |
hasher.update(str) | |
return hasher.hexdigest() |
This file contains 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
function randstr($len = 8) { | |
$src = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; | |
$src = $src.$src.$src.$src.$src; | |
return substr(str_shuffle($src), 0, $len); | |
} |
This file contains 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
public static String stripTags(String input) { | |
return input.replaceAll("\\<.*?>",""); | |
} |
This file contains 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
$config['uri_protocol'] = "PATH_INFO"; | |
$config['enable_query_strings'] = TRUE; | |
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_-?=+&;'; |
This file contains 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 | |
require_once(TOOLKIT . '/class.event.php'); | |
Class eventimport_links_from_delicious extends Event{ | |
const ROOTELEMENT = 'import-links-from-delicious'; | |
public $eParamFILTERS = array( | |
'xss-fail', |
This file contains 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
/* | |
Similar to XSLT's copy-of element. Useful if e.g. you have node containing XHTML | |
that you want to return as-is. | |
*/ | |
Node.metaClass.asString = { | |
def text = [] | |
delegate.children().each { child -> |
This file contains 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
// Return the actual location of a web page given a shortened url. | |
// Based in part on this Stack Overflow answer: | |
// http://stackoverflow.com/questions/1519392/how-to-prevent-apache-http-client-from-following-a-redirect | |
import groovyx.net.http.HTTPBuilder | |
import org.apache.http.impl.client.AbstractHttpClient | |
import org.apache.http.params.BasicHttpParams | |
import static groovyx.net.http.Method.HEAD |
This file contains 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 groovy.xml.MarkupBuilder | |
//Read a tab-delimited file. | |
def tdl = new TLD('comiclist.txt', false, 'Box No.') | |
/* | |
//Turn it into a simple xml format, one 'comic' per spreadsheet row. | |
def wrt = new StringWriter() | |
def xml = new MarkupBuilder(wrt) | |
xml.comics { |
This file contains 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
library(markdown) | |
options(rstudio.markdownToHTML = | |
function(i,o) { | |
markdownToHTML(i,o,fragment.only=TRUE) | |
} | |
) |
OlderNewer