Skip to content

Instantly share code, notes, and snippets.

View rdammkoehler's full-sized avatar

Rich Dammkoehler rdammkoehler

View GitHub Profile
find . -type f -exec stat --format '%Y :%y %n' "{}" \; | sort -nr | cut -d: -f2- > /root/latest_files.txt
@rdammkoehler
rdammkoehler / foo.py
Last active May 15, 2017 14:59
Moise Foo.py
from unittest import TestCase
import nose.tools as nt
def foo(x,y):
return (x+y), (x*y)
class FooTests_2(TestCase):
def __execute_foo(self, x, y):
@rdammkoehler
rdammkoehler / foo.py
Last active May 15, 2017 14:58
Super DRY Foo Test
from unittest import TestCase
import nose.tools as nt
def foo(x,y):
return (x+y), (x*y)
class FooTests_1(TestCase):
def setUp(self):
@rdammkoehler
rdammkoehler / foo.py
Created May 15, 2017 14:43
Undry Impl of Foo.py
from unittest import TestCase
import nose.tools as nt
def foo(x,y):
return (x+y), (x*y)
class FooTests_0(TestCase):
def test_foo_does_add(self):
@rdammkoehler
rdammkoehler / trunc_file.sh
Created February 3, 2017 02:24
Truncation a file without restarting a service
: > app.log && ls -halt app.log
@rdammkoehler
rdammkoehler / x.rb
Created December 13, 2016 19:55
return chain with gimme in ruby
require 'gimme'
class C
def f
return 1
end
end
l = [ 2, 3, 4, 5 ]
c = gimme(C)
#!/bin/bash
rm -f x.dat
for id in $( diff new.care_logs.ids old.care_logs.ids | grep ">" | awk '{print $2}' | grep -e "^[0-9]" ); do
jq ".[] | select(.id == $id)" old/care_logs.jsonl | jq .updated | cut -c1-12 >> y.dat
done
cat y.dat | sort | uniq
#!/bin/bash
rm -f x.dat
for id in $( diff new.shifts.ids old.shifts.ids | awk '{print $2}' | grep -e "^[0-9]" ); do
jq ".[] | select(.id == $id)" old/shifts.jsonl | jq .updated | cut -c1-12 >> x.dat
done
cat x.dat | sort | uniq
@rdammkoehler
rdammkoehler / FasterOfPuppet.lyrics
Created November 18, 2016 21:43
Lyrics of Master of Puppets rewritten to Faster of Puppet
End of development play, crumbling away
I’m your source of code-destruction
Veins that pump with fear, sucking darkest clear
Leading on your death’s construction
Taste me you will see
More is all you need
You’re dedicated to
This build is killing you
Come crawling faster
#!/bin/sh
email_to=${1:-default@yourdomain.com}
limit=${2:-90}
df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output;
do
usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $2 }' )
if [ $usep -ge $limit ]; then
echo "Running out of space \"$partition ($usep%/$limit%)\" on $(hostname) as on $(date)\n\nThe machine needs more disk or it will eventually crash!\n\nSend someone in to clean up log files and/or other files that are gobbling up the space.\n\nDetails:\n$output" |
mail -s "Alert: Almost out of disk space $usep%/$limit%" $email_to