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 os | |
""" | |
return a absolute path jailed in a rootpath | |
example: | |
securejoin('/home/john/', 'path1/../../path2') | |
> /home/john/path2 | |
""" | |
def securejoin(rootpath, path): | |
path = os.path.join(path).split('/') |
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
#! /bin/sh | |
# | |
# php-5.3 installation script (ubuntu 12.04) | |
# | |
install_dir=/opt/php-5.3 | |
sudo apt-get install -y \ | |
build-essential \ | |
libxml2-dev \ |
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
_jelix_completion() | |
{ | |
local cur prev opts actions | |
COMPREPLY=() | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
prev="${COMP_WORDS[COMP_CWORD-1]}" | |
# Standalone options | |
opts="" | |
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 base64, httplib, json, xmlrpclib | |
class ApiBase(object): | |
def __init__(self, host, login, password, port=10000, https=True): | |
self.host = host | |
self.login = login | |
self.password = password | |
self.port = port | |
self.https = https |
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
from django import template | |
register = template.Library() | |
def render_include_once(self, context): | |
ctname = '_include_once_node_registry' | |
if not ctname in context: | |
context[ctname] = {} | |
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 gethostip(ip): | |
return "".join([("%0.2x" % int(i)).upper() for i in ip.split('.')]) |
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
from django.core.management import BaseCommand, LaxOptionParser, CommandError, ManagementUtility | |
from django.core.management.base import handle_default_options | |
from optparse import make_option, OptionParser | |
import sys | |
class SubManagementUtil(ManagementUtility): | |
def __init__(self, argv=None, commands={}): | |
self.commands = commands | |
super(SubManagementUtil, self).__init__(argv) |
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 tail($fh, $max_length=10) { | |
$tailed = array(); | |
fseek($fh, -2, SEEK_END); | |
$stop = ftell($fh) + 2; | |
while (ftell($fh) >= 0 && count($tailed) < $max_length) { | |
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
#! /bin/sh -e | |
DAEMON="/usr/bin/xboxdrv" | |
DEAMON_OPT="--quiet --silent" | |
DAEMONUSER="root" | |
DEAMON_NAME="xboxdrv" | |
PATH="/sbin:/bin:/usr/sbin:/usr/bin" | |
test -x $DAEMON || exit 0 |
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
class Parser(object): | |
PATTERN = r"^" \ | |
+ r"(?P<month>\w{3})\s+" \ | |
+ r'(?P<day>\d{1,2})\s+' \ | |
+ r'(?P<time>\d{2}:\d{2}:\d{2})\s+' \ | |
+ r'(?P<hostname>[^\s]+)\s+' \ | |
+ r'(?P<exec>\w+/\w+)' \ | |
+ r'\[(?P<port>\d+)\]:\s+' \ | |
+ r'(?P<message_id>\w+):\s+' \ |
OlderNewer