Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
HOST=$(hostname)
function install_postfix() {
echo | sudo debconf-set-selections <<__EOF
postfix postfix/root_address string
postfix postfix/rfc1035_violation boolean false
postfix postfix/mydomain_warning boolean
postfix postfix/mynetworks string 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
using System;
using System.Data;
using System.Data.Odbc;
public class Test
{
public static void Main(string[] args)
{
// have an ODBC DSN setup named MYSQLDSN
// that accesses a MySQL database via
@kamawanu
kamawanu / safeweb.py
Created April 1, 2010 05:30
decorate webapp.RequestHandler each method , for trap any Exceptions
#!/usr/bin/env python
import functools, logging
from django.utils import simplejson
def safeweb(srcfunc):
def decorated(self, *vargs, **kwargs):
try:
return srcfunc(self, *vargs, **kwargs)
@kamawanu
kamawanu / safesimplejson.py
Created April 6, 2010 23:55
simlpejson modification, datetime support.
#!/usr/bin/env python
import datetime
from django.utils import simplejson
def jsondefault(self, data):
#### logging.warn( data )
if isinstance(data , datetime.date ):
data = data.strftime("%Y-%m-%d")
if isinstance(data , datetime.datetime ):
@kamawanu
kamawanu / import-svn-convert-hg.sh
Created August 7, 2010 07:31
svn & mercurial scripts
#!/bin/sh -x
#svnadmin create file:$PWD/$( basename $1 )
URL1=$( echo $1 | sed -e 's/\/trunk\///' )
NAMING=$( echo $URL1 | sed -e 's/\/\/*/\//g;s/\/$//' | rev | cut -d/ -f1-2 | rev | tr / _ )
echo $URL1
echo $NAMING
###exit
NAMING=SVFS-$NAMING
svnadmin create $NAMING
( echo "#!/bin/sh" ; echo exit 0 ) > $NAMING/hooks/pre-revprop-change
curl http://gist.github.com/gists/574260/download | tar xfz -
mv ./gist*/test.sh test.sh
chmod u+x test.sh
./test.sh
@kamawanu
kamawanu / addlogging.py
Created October 2, 2010 08:14
python detailed logging with console
if os.isatty(sys.stderr.fileno() ):
logging.getLogger().setLevel(logging.DEBUG)
logging.basicConfig( format='%(asctime)s %(levelname)s %(module)s:%(lineno)s %(message)s' )
@kamawanu
kamawanu / CentOS-5.4.cpp
Created October 9, 2010 07:18
cpp -dM /dev/null | sort
#define _LP64 1
#define __CHAR_BIT__ 8
#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
#define __DBL_DIG__ 15
#define __DBL_EPSILON__ 2.2204460492503131e-16
#define __DBL_HAS_INFINITY__ 1
#define __DBL_HAS_QUIET_NAN__ 1
#define __DBL_MANT_DIG__ 53
#define __DBL_MAX_10_EXP__ 308
#define __DBL_MAX_EXP__ 1024
@kamawanu
kamawanu / bulkinsert.py
Created October 19, 2010 21:43
bulk insert mixin, for google appengine
#!/usr/bin/env python
#https://gist.github.com/635194
import logging
from google.appengine.ext import db
__all__ = [
"bulkinsert",
]
uint32_t murmur3_32(const char *key, uint32_t len, uint32_t seed) {
static const uint32_t c1 = 0xcc9e2d51;
static const uint32_t c2 = 0x1b873593;
static const uint32_t r1 = 15;
static const uint32_t r2 = 13;
static const uint32_t m = 5;
static const uint32_t n = 0xe6546b64;
uint32_t hash = seed;