Skip to content

Instantly share code, notes, and snippets.

@alxf
alxf / session_expire.py
Created July 16, 2013 08:52
session timeout for webpy.
class Session(web.session.Session):
def _setcookie(self, session_id, expires='', **kw):
if expires == '':
expires = self._config.timeout
super(Session, self)._setcookie(session_id, expires, **kw)
@alxf
alxf / template.mako
Created April 8, 2013 20:55
Sample def block with mako
# Sample def block with mako
<%def name="artist_summary(label, img1, img2, *klass)"
cached="True" cache_timeout="300">
<div id="${label}" class="artist-column ${' '.join(klass)}">
<img src="/static/img/${img1}"/>
</div>
<script type="text/javascript">
$$("#${label} img").invoke('observe', 'mouseover', function(ev) {
ev.element().setAttribute('src', "/static/img/${img2}");
});
@alxf
alxf / 404stats.sh
Created July 10, 2012 13:05
Script to output 404 request summary per virtualhost.
#!/bin/dash
# Parse access log from a virtual host and output 404 requests.
# Logfile is $LOGDIR/host1.domain.tld/access.log for example.
# If you want this report by mail, set a crontab:
#
# 0 22 * * * 404stats.sh | mail -s "404 report" mail@domain.tld
#
#apache log directory
@alxf
alxf / geninstall.sh
Created May 21, 2012 14:52
script to help customize ubuntu installer
#!/bin/sh
#
# Script to help customize iso ubuntu installer.
#
# script constants
#
UBUNTU_MIRROR="mirror.ovh.net/ftp.ubuntu.com/releases"
@alxf
alxf / ssh-lookup.sh
Created May 14, 2012 09:46
Read hosts in ssh client configuration.
#!/bin/sh
# - ssh-lookup -
#
# This script read configuration file for ssh client. Without argument it list
# all hosts entries in the file. With host as argument, it print the real address
# for this entry.
#
# $ ssh-lookup.sh
# host1.domain.tld
@alxf
alxf / ftpshare.conf
Created January 27, 2012 00:31
Lighttpd share ftp directory
#load auth module
server.modules += ( "mod_auth" )
#auth settings
auth.debug = 2
auth.backend = "htpasswd"
auth.backend.htpasswd.userfile = "/etc/vsftpd.passwd"
#generate auth blocks for each ftp account
include_shell "/etc/lighttpd/ftpshare.sh"
@alxf
alxf / command.sh
Created January 24, 2012 14:56
Auto generated command shell script
#
# ./command.sh help
# HELP MESSAGE
# ./command.sh first
# FIRST COMMAND
#
command_help()
{
echo "HELP MESSAGE"
@alxf
alxf / app.py
Created January 21, 2012 00:10
Render restructured text as html in pygtk webkit view
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" Render restructured text as html in a pygtk webkit view.
"""
import gobject
import gtk
import gtksourceview2 as gtksourceview
import io
@alxf
alxf / gist:1646995
Created January 20, 2012 11:45
A rewrite of render_mako class from web.contrib.template (Web.py)
#webpy with mako
class render_mako(object):
"""Rendering interface to Mako Templates.
Example:
render = render_mako(
directories=['templates'],
input_encoding='utf-8',