Skip to content

Instantly share code, notes, and snippets.

View rcoder's full-sized avatar

Lennon Day-Reynolds rcoder

View GitHub Profile
@rcoder
rcoder / makeviz.rb
Created July 28, 2011 22:53
(dumb) Makefile visualization with GraphViz
#!/usr/bin/env ruby
require 'tempfile'
infile = ARGV.shift || 'Makefile'
outfile = Tempfile.new(File.basename(__FILE__))
variables = {}
begin
class TermVector
attr_reader :vec
private
def initialize(vec)
@vec = vec
end
public
def self.[](*vals)
#!/usr/bin/env ruby
conflicts = `git status`.split("\n").collect do |line|
md = /both modified:\s+(.*)$/.match(line)
md ? md[1] : nil
end.compact
editor = ENV['EDITOR'] || 'vim'
conflicts.each {|path| system("#{editor} #{path}") }
class A
def foo
"okay!"
end
module B
def foo
"not " + super
end
end
@rcoder
rcoder / vcs.sh
Created January 6, 2011 00:15 — forked from dcolish/vcs.sh
GIT="`which git`"
HG="`which hg`"
function checkvcs() {
base=$1
if [[ -d "${base}/.git" ]]; then
VCS="$GIT"
elif [[ -d "${base}/.hg" ]]; then
VCS="$HG"
else
"""
TCP proxy which limits which commands may be forwarded to a MongoDB server
Use to enforce read/write/insert-only restrictions
Based on protocol docs from the MongoDB wiki:
http://www.mongodb.org/display/DOCS/Mongo+Wire+Protocol
"""
import struct
lennond-mac:~ lennond$ curl -i http://www.sun.com
HTTP/1.1 301 Moved Permanently
Server: Sun-Java-System-Web-Server/7.0
Date: Thu, 28 Jan 2010 20:21:44 GMT
P3p: policyref="http://www.sun.com/p3p/Sun_P3P_Policy.xml", CP="CAO DSP COR CUR ADMa DEVa TAIa PSAa PSDa CONi TELi OUR SAMi PUBi IND PHY ONL PUR COM NAV INT DEM CNT STA POL PRE GOV"
Location: http://www.oracle.com
Content-length: 0
--- configure.in.bak 2009-12-17 11:14:31.000000000 -0800
+++ configure.in 2009-12-17 11:14:37.000000000 -0800
@@ -378,7 +378,6 @@
netinet/in.h \
alloca.h \
arpa/inet.h \
-arpa/nameser_compat.h \
arpa/nameser.h \
assert.h \
crypt.h \
@rcoder
rcoder / evil
Created December 10, 2009 00:20
RewriteRule "^/([^\?]+)(&)([^\?]+)(\?)(.*)$" "$1?$3&$5" [R,L]
RewriteRule "^/([^\?]+)(&)([^\?]+)$" "$1?$3" [R,L]
class scripts_user_revision(object):
def __init__(self, message, user=SCRIPTS_USER):
self.user = user
self.message = message
def __call__(self, f):
@revision.create_on_success
def _decorated(*args):
revision.user = self.user
revision.comment = self.message