Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python
import json
class AuthenticationException( Exception ):
pass
def loginrequired( fn ):
def wrapper( *args, **kwargs ):
print "args:",args
print "kwargs:",kwargs
#!/bin/bash
# --- Command line
refname="$1"
oldrev="$2"
newrev="$3"
echo "> $refname"
echo "> $oldrev"
echo "> $newrev"
@waffle2k
waffle2k / coffee.rb
Created October 28, 2011 19:18
Playing with class methods and such
#!/usr/bin/env ruby
class Milk
def self.cost
puts " with Milk"
0.2
end
end
class Sugar
@waffle2k
waffle2k / create_new_project.sh
Created October 28, 2011 05:00
Simple script for creating bare git projects.
#!/bin/bash
# This will create a new repository, with a sample README, and clone it
# to a default location
PROJNAME=$1
if [ -d /home/git/tmp/$PROJNAME ]; then
echo "Project by that name already exists"
exit 1
@waffle2k
waffle2k / becomeuser.pl
Created August 25, 2011 18:32
Perl script to become a certain user, with some verbose output to describe what's happening
#!/usr/bin/perl
use POSIX qw(setuid getuid);
my $w = scalar getpwuid( $< );
if( $w eq 'root' ){
print "Hey, you're root... let's try to become 'abuse'\n";
# become user abuse
my ($pwName, $pwCode, $pwUid, $pwGid, $pwQuota, $pwComment,
#!/usr/bin/perl
my $input = do { local $/; <>; };
# Strip out the boiler plate...
$input =~ s/(\nNOTE:\s+Please respect.*?DOESN'T APPEAR TWICE IN YOUR POST\n)//s;
print $input;
exit(0);
#!/usr/bin/python
import sys
from json_decorator import *
a = [ None,1,2,3,4,5,"foobar", { 'ya': 'right' },]
@jsonify
def something(obj):
return obj
import json
class jsonify( object ):
def __init__(self,f):
self.f = f
def __call__(self, *args, **kwargs ):
results = self.f(*args, **kwargs)
j = json.dumps( results )
@waffle2k
waffle2k / pa.pl
Created June 23, 2011 15:08
Dynamically call worker modules from a directory
#!/usr/bin/perl
use strict;
use lib( "/home/pblair/lp.beta/logparse/lib" );
use File::Glob ':glob';
use RBL::ProcessAggregate;
use RBL::Whitelist;
my @libs = bsd_glob('/home/pblair/lp.beta/logparse/lib/RBL/ProcessAggregate/*.pm');
s/.*\/(\S+?)\.pm$/$1/ for @libs;
eval "require RBL::ProcessAggregate::$_" for @libs;
@waffle2k
waffle2k / ip-cc.pl
Created June 23, 2011 13:27
Using perl to find IPs belonging to a given country code
#!/usr/bin/perl
use strict;
use IP::Country::Fast;
my $reg = IP::Country::Fast->new();
my $input = do { local $/; <>; };
my @ips = $input =~ /(.*?)(?:\/\d+)?\s/sg;
my %cc = map { $_ => $reg->inet_atocc($_) } @ips;