Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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
==> 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
==> 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
diff --git a/Library/Formula/nmap.rb b/Library/Formula/nmap.rb
index 8bd1df1..7e06901 100644
--- a/Library/Formula/nmap.rb
+++ b/Library/Formula/nmap.rb
@@ -14,7 +14,7 @@ class Nmap < Formula
def install
ENV.deparallelize
- args = ["--prefix=#{prefix}", "--without-zenmap"]
+ args = ["--prefix=#{prefix}", "--without-zenmap", "--without-liblua", "CFLAGS=-DNOLUA"]
import collections
import Queue
class MaxSizeDict(collections.MutableMapping):
def __init__(self, maxsize):
self.maxsize = maxsize
self.valdict = {}
self.keyqueue = Queue.Queue()
def __setitem__(self, key, value):
@thepaul
thepaul / knapsack.py
Created July 5, 2012 23:49
dynamic programming generic 0-1 knapsack problem solver
def solve_knapsack(items, maxcost, cost=lambda n:n, value=None):
"""
Generic dynamic-programming knapsack problem solver. Takes time
O(len(items) * maxcost), so it can be helpful to reduce the costs
and maxcost by the greatest common divisor if possible. Costs for
all items must be nonnegative integers.
Returns the set of items the sum of whose costs does not exceed
maxcost, and the sum of whose values is otherwise maximal.
"""
@thepaul
thepaul / config.log
Created July 27, 2012 21:48
brew install quvi configure output
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by quvi configure 0.2.19, which was
generated by GNU Autoconf 2.68. Invocation command line was
$ ./configure --disable-dependency-tracking --prefix=/usr/local/Cellar/quvi/0.2.19 --enable-nsfw --enable-todo --enable-nlfy
## --------- ##
## Platform. ##
@thepaul
thepaul / git-pbuilder-fix.diff
Created November 9, 2012 04:22
git-pbuilder argument splitting fix
--- /usr/bin/git-pbuilder 2012-09-28 12:18:15.000000000 -0600
+++ /usr/bin/fixed-git-pbuilder 2012-11-08 21:07:37.123999784 -0700
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
# $Id: git-pbuilder,v 1.27 2012/01/13 04:12:35 eagle Exp $
#
# git-pbuilder -- Wrapper around pbuilder for git-buildpackage
@@ -75,7 +75,8 @@
fi