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} |
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 |
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 python | |
import sys | |
from os.path import basename, dirname | |
from re import compile as regxcomp | |
from re import match as regxmat | |
INIT_BNAME = regxcomp('__init__.py') | |
def try_import(module_name): |
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} |
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; |
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 |
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 |
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} | |
# |
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]}; |
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