Skip to content

Instantly share code, notes, and snippets.

View sente's full-sized avatar

Stuart Powers sente

View GitHub Profile
#!/bin/sh
dir=$1
find $dir -type f -name "*.zip" -printf "%TY-%Tm-%Td\t%h/%f\n" | sort | while read line; do
echo "unzip -jod $line"; done
#!/bin/sh
# stuart powers
# list the files installed from a specific package or all
# packages which match /pattern/ # one line of output per file:
# [exe|dir|pipe|etc] $PACKAGE $FILE
#to see all the executable files from libwww-perl:
#stu@sente ~ $ pkginfo.sh libwww-perl | grep ^x | cut -f3
# /usr/bin/lwp-download
@sente
sente / id_rsa.pub
Created December 22, 2010 07:44
id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIBJNXmgPkbvgLx+ntGD55ON6fPwXKWIy+ah475VHip6Pdr3QWQSo0VdB8cheRwrDys0wVotWxd4ZufeNCJEGNUR2NWFYXfWYpC8hbtga/RlH/GhfcvJW4wlg4vBXBbwBl5kLRRQo6FfgqJlXeVq6gQINEogm4EnXQ+Wo8RxXOIzRQ== rsa-key-20060627
import codecs
def unicode_safe_127(ss, debug=False):
"""safely handle strings with have ordinal values greater than 127
by escaping each value as appropriate.
if debug=True, log each conversion to stderr
"""
mys = ss
tos=[]
for i,s in enumerate(mys):
@sente
sente / gist_commandline.py
Created February 1, 2011 20:57
gist from the commandline
#!/usr/bin/env python
import getpass, mechanize, optparse, os.path, sys
parser = optparse.OptionParser()
parser.add_option('--login')
parser.add_option('--password')
parser.add_option('--filename')
parser.add_option('--description')
parser.add_option('--private', action='store_true', default=False)
@sente
sente / python_snippets.py
Created February 1, 2011 21:02
various snippets I've written or copied (and hopefully attributed)
#!/usr/bin/python
# from reddit --------------------------------------------
def traceit(fn):
import sys
def new_fn(*a,**kw):
ret = fn(*a,**kw)
sys.stderr.write("Fn: %s; a=%s; kw=%s\nRet: %s\n"
% (fn,a,kw,ret))
return ret
@sente
sente / imaplib_connection.py
Created February 2, 2011 16:37
imaplib_connection class
#taken from Doug Hellman's PyMOTW
import imaplib
import ConfigParser
import os
def open_connection(verbose=False):
# Read the config file
config = ConfigParser.ConfigParser()
config.read([os.path.expanduser('~/.pymotw')])
@sente
sente / twisted_portscan.py
Created February 3, 2011 10:59
scan for open ports
from twisted.internet import reactor, defer
from connectiontester import testConnect
def handleAllResults(allResults, ports):
for port, results in zip(ports, allResults):
success, result = results
if success:
print "Connected to port %i" % port
reactor.stop()
@sente
sente / portscan.py
Created February 3, 2011 11:16
scan for open ports
#!/usr/bin/python
import sys
import socket
try:
server = sys.argv[1]
except:
server = "localhost"
for x in range(10000):
@sente
sente / home-snapshot.sh
Created March 30, 2011 08:44
script used for localized snapshots
PATH=$PATH:bin/
set -x
cd $HOME || exit 1
DIR=.hide/proc/snapshots
if [ ! -d ${DIR}/daily.0 ]; then exit 1; fi
cp -al ${DIR}/daily.0 ${DIR}/daily.`date +%F`