Skip to content

Instantly share code, notes, and snippets.

View RichardBronosky's full-sized avatar

Bruno Bronosky RichardBronosky

View GitHub Profile
#!/usr/bin/env bash
log="/tmp/$(basename $0).log"
# Truncate existing log
echo -n > $log
echo the $0 script was called with... | tee -a $log
for a in "$@"; do
echo $((++i)) $a | tee -a $log
done
@RichardBronosky
RichardBronosky / Candygram
Created August 29, 2011 15:32
Classic SNL for IRC
/\
⎛ ⊗ ⊗ ⎞
⎜ ⋁⋁⋁⋁ ⎟
⎝ ⋀⋀⋀⋀ ⎠
@RichardBronosky
RichardBronosky / mobile.conf
Created August 30, 2011 06:14
Epic Mobile mod_rewrite RewriteRules!
# Define the MOBILE_PATTERN (for user agent detection) ONLY for pages who are NOT black listed from mobile. (TODO: Try using a whitelist instead. Would probably be shorter.)
RewriteCond %{REQUEST_URI} !^/(ads|alerts|answers|audioclips|bands|categories|categories|events|documents|drinkspecials|events|features|forums|gallery|instruments|maps|mp3|lsp|onthestreet|photo|photos|galleries|photos|places|playlists|podcasts|polls|pr|qa|questionnaires|recipes|restaurants|restaurants|specials|search|songs|special_coverage|staff|stories|traffic|tumble|videos) [NC]
RewriteRule .* - [E=MOBILE_PATTERN:iphone|ipod|android|blackberry|symbian|nokia|sonyericsson|sie-|opera\ mini|portalmmm/|windows\ ce|up.browser|up.link|802sh|alcatel-|amoi-|attws|au-mic|audiovox|avantgo|benq|cdm-|ericsson|ericy-|gs308|hitachi-p300|htc-|i-2100|inn|kwc-|lg-|lg/u|lge-|lge/u|lowestcd|mo0|mobilephone|mot-|motorola|n5-10|nec-|opwv|owg1|palm|panasonic|pg-c|philips|pls|pm-|pn-215|profile/midp|qci-|rl-|rpt-httpclient|sagem|samsung|sanyo|sch-a
@RichardBronosky
RichardBronosky / hash_tests.sh
Created September 4, 2011 19:25
test the speed of various hashing programs (and dd sources of random data)
tests=3
kilobytes=102400
commands=(md5 shasum)
count=0
test_num=0
time_file=/tmp/time.out
file_base=/tmp/rand
while [[ test_num -lt tests ]]; do
((test_num++))
#!/usr/bin/env python
"""
ignore_moves.py v0.2
Filter relocated lines from a unified diff format stream.
Offered under the terms of the MIT License at github.com
Taken from http://stackoverflow.com/questions/1380333/
"""
import sys
from optparse import OptionParser
@RichardBronosky
RichardBronosky / irc_proxy.sh
Created September 15, 2011 13:59
evil for awesome™
sudo ssh -g -L 0.0.0.0:443:localhost:6697 rbronosky@bastion2.ddtc.cmgdigital.com
# oneliner
# grep_header(){ header_pattern="$1"; search_pattern="$2"; awk "/$header_pattern/ {h=\$0; } /$search_pattern/{if(h){print h; h=\"\";}; print \$0;}"; }
@RichardBronosky
RichardBronosky / *scratch*
Created September 19, 2011 14:12 — forked from bigjust/*scratch*
Cut the BS. Get developing.
# Launch screen/tmux. Start this in the background while you try your other fixes. See which works first.
# Skip this if you want to try to fix your current venv
create_environment; sv; load_prod_db; django-admin.py loaddata local_site_list
# In case your jellydoughnut wasn't totally up to date
ensure_ro_db_user
# Migration Whack-a-Mole
django-admin.py migrate sitesettings
@RichardBronosky
RichardBronosky / gist:1237044
Created September 23, 2011 09:41
Guess that protocol...
From: http://twitter.com/#!/datagrok/status/117094906115264513
/^(?::([^ ]+) )?([^ ]+)((?: [^: ][^ ]*){0,14})(?: :?(.*))?$/
/^ $/
match the left and right boundaries of the string (The entire string must be described by the pattern)
(?::([^ ]+) )?
Optional: No Back Reference*: a colon, one or more non-space chars, a space
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>www.wokv.com facebook</title>
<link rel="self" type="application/atom+xml" href="http://www.wokv.com/breaking-news/facebook-feed/"/>
<link rel="hub" href="http://cmgdigitalhub.superfeedr.com/"/>
<updated>2011-10-04T10:08:00.609307-04:00</updated>
<id>tag:www.wokv.com,2011:/breaking-news/facebook-feed/cmg@da752b67477031ae2ef09c06213463d9bccbc6f145b41def15bcb6e0</id>
<author><name>www.wokv.com</name></author>