Skip to content

Instantly share code, notes, and snippets.

==> Downloading http://nmap.org/dist/nmap-5.51.tar.bz2
File already downloaded in /Users/paul/Library/Caches/Homebrew
/usr/bin/tar xf /Users/paul/Library/Caches/Homebrew/nmap-5.51.tar.bz2
==> ./configure --prefix=/usr/local/Cellar/nmap/5.51 --without-zenmap
./configure --prefix=/usr/local/Cellar/nmap/5.51 --without-zenmap
checking whether NLS is requested... yes
checking build system type... x86_64-apple-darwin11.2.0
checking host system type... x86_64-apple-darwin11.2.0
checking for gcc... /usr/bin/gcc-4.2
checking whether the C compiler works... yes
==> Downloading http://nmap.org/dist/nmap-5.51.tar.bz2
File already downloaded in /Users/paul/Library/Caches/Homebrew
/usr/bin/tar xf /Users/paul/Library/Caches/Homebrew/nmap-5.51.tar.bz2
==> ./configure --prefix=/usr/local/Cellar/nmap/5.51 --without-zenmap
./configure --prefix=/usr/local/Cellar/nmap/5.51 --without-zenmap
checking whether NLS is requested... yes
checking build system type... x86_64-apple-darwin11.2.0
checking host system type... x86_64-apple-darwin11.2.0
checking for gcc... /usr/bin/llvm-gcc
checking whether the C compiler works... yes
@thepaul
thepaul / saferscanner.py
Created October 24, 2011 19:18
safer version of python's re.Scanner
# SaferScanner is just like re.Scanner, but it neuters any grouping in the lexicon
# regular expressions and throws an error on group references, named groups, or
# regex in-pattern flags. Any of those can break correct operation of Scanner.
import re
from sre_constants import BRANCH, SUBPATTERN, GROUPREF, GROUPREF_IGNORE, GROUPREF_EXISTS
class SaferScanner(re.Scanner):
def __init__(self, lexicon, flags=0):
self.lexicon = lexicon
@thepaul
thepaul / spawn_pager.py
Created September 9, 2011 17:06
the Right Way(tm) to Popen a curses-using subprocess
# works on Mac OS X and Linux. haven't tried BSD. obviously windows is out.
import os
import subprocess
import signal
def get_tty_fg():
# make a new process group within the same session as the parent. we
# do this so that if the user hits ctrl-c, etc in the curses program
# that's about to be exec'd, the SIGINT and friends won't be sent to
@thepaul
thepaul / gist:1171296
Created August 25, 2011 17:54
"git find" command
[alias]
; "git find" should work exactly like your system find (BSD or GNU), except for
; two things: one, it will always ignore the current git directory; and two, if
; you don't supply any root paths to search, it defaults to searching from your
; git project toplevel.
;
; paul cannon <[email protected]> 2011
find = "!_() { \
declare -a preargs; \
@thepaul
thepaul / print_table.py
Created July 17, 2011 04:26
print stuff arranged in a table with silly ascii box characters
def center(text, width):
if len(text) < width:
diff = width - len(text)
pad = ' ' * (diff / 2)
text = pad + text + pad
if diff % 2:
text += ' '
return text
def print_table(fieldnames, table, outstream=None):
@thepaul
thepaul / changelog_from_deb.sh
Created June 1, 2011 17:01
extract and output the changelog from a .deb file, when possible
changelog_from_deb () {
# won't work when packages symlink their docs from another package from the same source;
# you'll get "No changelog found."
t="$(mktemp -d)"
p="$(dpkg-deb -f "$1" Package)"
fail=1
dpkg-deb --fsys-tarfile "$1" | \
tar -x --wildcards -C $t ./usr/share/doc/"$p"/changelog\* 2>/dev/null
for f in changelog.Debian.gz changelog.gz; do
@thepaul
thepaul / shell_escape.py
Created January 22, 2011 00:46
escape random strings to make them single words in shells
import re
backslash_shell_quote_re = re.compile(r'([^A-Za-z0-9_.,:/])')
def shell_escape(s, flavor='sh'):
"""
Escape a random string (s) so that it reads as a single word when
undergoing shell command-line parsing.
The default flavor should be safe for all mainstream shells I know
about, but there are some other escaping modes which may result in
@thepaul
thepaul / .gitconfig
Created January 20, 2011 18:23
i <3 my git xlog
[alias]
xlog = log --graph --pretty=format:\"%C(yellow)%h%Creset %ad %s%C(cyan)%d%Creset %C(green)[%an]%Creset\" --date=short
@thepaul
thepaul / noisyInlineTracebacks.py
Created January 14, 2011 18:38
additions to twisted.internet.defer.inlineCallbacks with lots of debugging info
# Copyright (c) 2001-2010 Twisted Matrix Laboratories.
# See LICENSE for details.
import traceback
import warnings
from sys import exc_info
# Twisted imports
from twisted.python import failure, lockfile
from twisted.python.util import mergeFunctionMetadata