Skip to content

Instantly share code, notes, and snippets.

View rdammkoehler's full-sized avatar

Rich Dammkoehler rdammkoehler

View GitHub Profile
private void NotifyThreadPoolOfPendingWork() {
ThreadPool.UnsafeQueueUserWorkItem(_ => {
/* lots of code here that distributes work to Threads */
}, null);
}
import sys
import sqlalchemy
from hisc.common.config import Config
script = sys.argv[1]
sql_url = Config().read()['sql_url']
with open(script, "r") as schema:
create_statement = schema.read().replace('\n', '')
@rdammkoehler
rdammkoehler / partial.rb
Created May 29, 2014 15:50
There must be a better way to do this. The cards(...) method is kinda ugly as is lists_in(...) But for the life of me I cannot see a way to make it prettier
#where the json content is a trello board that has been sucked into jsoncontent
def lists_in(jsoncontent)
lists = jsoncontent['lists']
[Hash[ lists.collect { |list| [ list['id'], list['name'] ] } ], lists.map { |list| list['id'] if list['closed'] }.to_set]
end
def id_for(card)
card['idList']
end
@rdammkoehler
rdammkoehler / ArrayLookupRules.java
Last active December 27, 2015 00:48
No If's Game of Life Rules
package com.noradltd.golagain;
import static com.noradltd.golagain.CellState.ALIVE;
import static com.noradltd.golagain.CellState.DEAD;
public class ArrayLookupRules implements GameOfLifeRules {
private static final CellState[][] RULES = new CellState[2][9];
static {
RULES[ALIVE.ordinal()][0] = DEAD;
RULES[ALIVE.ordinal()][1] = DEAD;
@rdammkoehler
rdammkoehler / .swearing.bash
Created April 22, 2013 19:39
If you source this from your .bashrc file you will be able to swear on the command line.
alias shit="echo Sorry about that"
alias fuck="echo Terribly sorry about that"
alias fucker="echo Please, why would you blame me?"
alias fucking="echo Well, thats not very polite."
alias piss="echo Is it really that bad?"
alias damn="echo Thats the way the ball bounces"
alias hell="echo Yup, thats where you are"
@rdammkoehler
rdammkoehler / a_test_file.txt
Created March 18, 2013 19:54
What I'd like this to do is substitute any given shell variable for it's matching value in the input file; e.g. when I run this, $USER in a_test_file.txt should become rich. I haven't even tried to get the output to $2 yet.
blah $FOO
foo $BAR
smack $HEAD
for $USER
#!/bin/bash
if [ -f "$1" ]
then
cat << END_OF_RESULTS
<testsuite>
$(
cat $1 | grep -Ee "^ *(IGNORE_)?TEST" | while read line; do
command=$(echo $line | \
@rdammkoehler
rdammkoehler / mkchroot.sh
Last active December 14, 2015 09:59
Chroot in one sweep still a few tweaks to make, most importantly the 'build environment load'
#get your system ready to chroot
#sudo apt-get install dchroot debootstrap
#lsb_release -cs << default your UBUNTU_BASE_CODE_NAME with this
if [ $# -ne 4 ]
then
echo "Wrong Arg Count! 4 are required"
echo "$0 <chroot_name> <chroot_folder> <chroot_ubuntu_base_code_name> <target_user>"
exit
@rdammkoehler
rdammkoehler / update_dot_files.sh
Created January 29, 2013 20:47
Copy my gist of my .gitconfig into my home directory and substitute in my settings
#!/bin/sh
#update .gitconfig from github gist
mv ~/.gitconfig ~/.gitconfig.`date +%Y%m%d%H%M%S` && \
wget --quiet https://gist.github.com/raw/1886998/a197c56ab30d8ae7716583dd3177f6a85001b36e/.gitconfig -O ~/.gitconfig && \
cat ~/.gitconfig | perl -p -i -e 's/Your Name Here/Rich Dammkoehler/g'| perl -p -i -e 's/your\@email.net/mah@email.org/g' | perl -p -i -e 's/home\/you/home\/rich/g' > /tmp/.gitconfig && \
mv /tmp/.gitconfig ~/.gitconfig
@rdammkoehler
rdammkoehler / monkey_patch_nil.rb
Created December 5, 2012 17:23
I have wrought evil, by monkey patching nil. I should be shot.
def nil::strip
raise "I am not a string!"
end
nil.strip
#RuntimeError: I am not a string!
# from (irb):6:in `strip'
# from (irb):8
# from /Users/rich/.rvm/rubies/ruby-1.9.3-p194/bin/irb:16:in `<main>'