Skip to content

Instantly share code, notes, and snippets.

@rebx
rebx / merge_sort.py
Created June 25, 2012 00:52
python merge sort
def merge_sort(list_struct=[]):
"""
merge_sort
as if there's not enough merge sorts in python out there
"""
list_len = len(list_struct)
if list_len <= 1:
return list_struct
mid = list_len / 2
@rebx
rebx / whichpm
Created March 14, 2012 21:43
Scripts for finding module locations
#!/usr/bin/env perl -w
# rebx
use strict;
my $mod = shift(@ARGV);
my @customperl = qw(/path/to/perl);
push (@INC, @customperl);
(!defined($mod)) && exit 1;
unless ( eval "require $mod;1") {
@rebx
rebx / gist:1362873
Created November 13, 2011 22:59
rvm remove [ruby pkg] kills the $rvm_usr_path set?
$ echo $rvm_usr_path
/some/path/to/rvm/usr
$ rvm remove 1.9.3
Removing /some/path/to/rvm/src/ruby-1.9.3-p0...
Removing /some/path/to/rvm/rubies/ruby-1.9.3-p0...
Removing ruby-1.9.3-p0 aliases...
Removing ruby-1.9.3-p0 wrappers...
Removing ruby-1.9.3-p0 environments...
@rebx
rebx / gist:1276809
Created October 10, 2011 22:52
c has a size for void?
$ cat voidsize.c
#include <stdio.h>
int main(void) {
printf("void size: %d\n", sizeof(void));
return 0;
}
$ make voidsize
cc voidsize.c -o voidsize
voidsize.c: In function ‘main’:
@rebx
rebx / gist:1250106
Created September 29, 2011 06:25
tshark'ing mysql
live:
tshark -i eth0 -aduration:60 -d tcp.port==3306,mysql -T fields -e mysql.query 'port 3306'
capture:
tcpdump -i eth0 port 3306 -s 1500 -w tcpdump.out
tshark -r tcpdump.out -d tcp.port==3306,mysql -T fields -e mysql.query > query_log.out
@rebx
rebx / gist:1244197
Created September 27, 2011 02:52
rvm fail?
> rvm use 1.9.2-p290@mall --create
Database file /home/rebx/.rvm/user/db does not exist.
> __rvm_db
bash: /db: No such file or directory
> echo $rvm_path