Skip to content

Instantly share code, notes, and snippets.

View rdammkoehler's full-sized avatar

Rich Dammkoehler rdammkoehler

View GitHub Profile
server {
listen 80;
root /var/www/nginx;
index index.html;
server_name ender.noradltd.com;
rewrite ^/e/(\d+)$ /f?id=$1 last;
@rdammkoehler
rdammkoehler / muddled.rb
Last active May 13, 2016 00:49
Not what you thought you'd get
a = [ { :items => [{ 'item' => 'junk' },{ 'item' => 'junk' },{ 'item' => 'junk' }] }]
# => [{:items=>[{"item"=>"junk"}, {"item"=>"junk"}, {"item"=>"junk"}]}]
a[0][:items].count # => 3
d = [] # => []
d.push a[0][:items] # => [[{"item"=>"junk"}, {"item"=>"junk"}, {"item"=>"junk"}]]
d.count # => 1, not 3
d.push a[0][:items] # => [[{"item"=>"junk"}, {"item"=>"junk"}, {"item"=>"junk"}], [{"item"=>"junk"}, {"item"=>"junk"}, {"item"=>"junk"}]]
d.count # => 2, not 6
d.flatten.count # => 6
@rdammkoehler
rdammkoehler / do_you_want_to_test_me.rb
Created February 3, 2016 22:30
Rewriting Joan Jett's Do You Want to Touch Me?
"Do You Wanna Test Me"
We've been here too long tryin' to get green
Pretendin' that you're oh, so dry
I'm a natural ma'am doin' all I can
My coverage is runnin' high
Cry at night no one in sight
An' we got so much to share
Talking's fine if you got the time
@rdammkoehler
rdammkoehler / mash_cows.py
Created January 20, 2016 21:34
Mashed Cows
for agency_files in list(r):
for key in agency_files:
values = agency_files[key]
if isinstance(values,list):
print("processing list %s" % values)
for value in values:
file_map[key].append(value)
else:
file_map[key].append(agency_files[key])
@rdammkoehler
rdammkoehler / patch_games.py
Created January 20, 2016 20:45
Mock That Monkey
In [42]: class Foo(object):
....: def bar(self):
....: return 'x'
....:
In [43]: class Baz(object):
....: def biz(self):
....: return Foo().bar()
....:
@rdammkoehler
rdammkoehler / profile_assoc_data.sh
Created January 14, 2016 15:20
Get a profile of associatedata
~/association/bin/python3 -m cProfile -o profile.out ~/association/bin/associatedata
@rdammkoehler
rdammkoehler / view_profile.sh
Created January 14, 2016 15:19
View Profile Information from Python Job
brew install qcachegrind # install qcachegrind, you only need to do this once
scp azureuser@cgoa-dev.cloudapp.net:data/profile.out . # copy the profile.out file from the server
pip install pyprof2calltree # install the profile converter, you only need to do this once
pyprof2calltree -i profile.out # convert the profile to a file qcachegrind can read
qcachegrind profile.out.log # start qcachegrind to see the profile information
@rdammkoehler
rdammkoehler / trooper.lyrics
Created January 12, 2016 22:21
The Trooper Revisited
You'll take my life but I'll take yours too
You'll fire your Dev-Ops but I'll Hack you through
So when you're waiting for the Azure Stack
You'd better stand there's no turning back
The bugle sounds as the Upload begins
But on this Cloud no one wins
The smell of acrid smoke and Coffee breath
As you plunge into a certain death
@rdammkoehler
rdammkoehler / gimme_ex.rb
Created January 8, 2016 19:46
Sneaky Gimme Tricks
let(:factory) { gimme(ServiceLoaderFactory) }
let(:uri) { 'endpoint' }
# ...
it 'handles both failure and success appropriately' do
@idx = 0
give(factory).create {
@idx += 1
[ Proc.new { fail 'massively' }, Proc.new { } ][@idx-1].call
}
@rdammkoehler
rdammkoehler / classmethod.py
Created January 7, 2016 16:09
Don't do this
class Foo(object):
@classmethod
def bar(cls,x):
cls.x = x
def p(self):
print self.x
a = Foo()
a.bar(1)
a.p() # 1