View build_clang.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# use the current date | |
curr_date=`date +%Y-%m-%d` | |
clang_home=~/github/llvm_${curr_date} | |
# exit on any error | |
set -e | |
mkdir ${clang_home} |
View mock_stack.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mock_stack(func): | |
@mock.patch.object(FooObject, 'method') | |
@mock.patch('some.module') | |
@functools.wraps(func) | |
def wrapped_func(*args, **kwargs): | |
return func(*args, **kwargs) | |
return wrapped_func |
View gist:1250106
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
View syslog_with_year
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# added year to SYSLOGTIMESTAMP | |
SYSLOGTIMESTAMPYEAR %{MONTH} %{MONTHDAY} %{YEAR} %{TIME} | |
SYSLOGBACKFILLYEAR %{SYSLOGTIMESTAMPYEAR:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{PROG:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message} |
View right_split.pl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl -w | |
use strict; | |
use Data::Dumper qw(Dumper); | |
sub _right_split { | |
my ( $strstr, $delim, $ary ) = @_; | |
$ary ||= []; | |
return $ary unless $strstr; | |
my $rindex = rindex( $strstr, $delim ) or return $ary; |
View class_from_hash.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.initialize(opts) | |
opts.each do |k,v| | |
instance_variable_set("@#{k}",v) | |
eigenclass = class<<self; self; end | |
eigenclass.class_eval do | |
attr_accessor k | |
end | |
end | |
end |
View which.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
# | |
# taken from perl | |
# my bad perl habits aren't so easy to stomp out...tsk, tsk... | |
# | |
module File::Which | |
# | |
# Returns the full path to the executable |
View ruby_idioms.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# make a list into hash keys | |
list = %w{foo bar baz} | |
s ||= {} | |
list.each {|key| s[key.to_sym] = 1} | |
# |
View perl_idioms.pl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# size of array | |
sub foo { return qw(foo bar baz);} | |
$size = () = foo(); | |
# or just use int. scalar works as well, but int is more "intuitive" than scalar to me | |
$size = int (@array); | |
# interleave array | |
sub interleave { | |
my %interleaved; | |
@interleaved{ @{$_[0]} } = @{$_[1]}; |
View find_unused_subs.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
dir=$1 | |
if [ -z "$dir" -a "${dir+oinothir}" = "oinothir" ]; then | |
dir=$PWD | |
fi | |
ack -h --output='$1' '^\s*sub\s+(\w+)\b' $dir \ | |
| sort -u \ |
NewerOlder