Skip to content

Instantly share code, notes, and snippets.

View kevinmcconnell's full-sized avatar

Kevin McConnell kevinmcconnell

  • Edinburgh, Scotland
View GitHub Profile
diff --git a/tests/platform_tests/mail_tests.py b/tests/platform_tests/mail_tests.py
index f33f140..db94d83 100644
--- a/tests/platform_tests/mail_tests.py
+++ b/tests/platform_tests/mail_tests.py
@@ -660,6 +660,7 @@ class MailTests(PlatformTest):
def test_forwarding_message_does_not_record_open_in_summary(self):
mailing = self._send_message("Test open record",
['alex@myemma.com'],
+ '[% bug %] Hello [% member:email %],',
'[% bug %] Hello [% member:email %],')
@kevinmcconnell
kevinmcconnell / gist:2837655
Created May 30, 2012 17:04
hacky script to make a subset of a table's rows match those on another database
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
FROM = 'postgresql://master/master'
TO = 'postgresql://core/core'
sfrom = sessionmaker(bind=create_engine(FROM, client_encoding='utf-8'))()
sto = sessionmaker(bind=create_engine(TO, client_encoding='utf-8'))()
@kevinmcconnell
kevinmcconnell / gist:8365521
Last active January 2, 2016 21:49
Simple queued concurrency pattern
class AsyncPool
def initialize
@threads = {}
@results = {}
end
def run(id, &block)
@threads[id] = Thread.new { @results[id] = block.call }
end
PAGE_SIZE = 5
EVENTS = %w(a a b c b c a a a c b c b b b c a a c a a a c b b b c b c a a a c)
EVENTS_WITH_TIMES = EVENTS.map.with_index { |id, i| [id, i] }
PARTS_A = EVENTS_WITH_TIMES.select { |entry| entry.first == 'a' }
PARTS_B = EVENTS_WITH_TIMES.select { |entry| entry.first == 'b' }
PARTS_C = EVENTS_WITH_TIMES.select { |entry| entry.first == 'c' }
def get_page(start_at)

Keybase proof

I hereby claim:

  • I am kevinmcconnell on github.
  • I am kevinmcconnell (https://keybase.io/kevinmcconnell) on keybase.
  • I have a public key whose fingerprint is 9009 2EA5 C3C9 7E17 CC12 8C64 9B9B 2B0A B358 8FBE

To claim this, I am signing this object:

@kevinmcconnell
kevinmcconnell / threaded.py
Created March 28, 2014 02:40
Run some tasks in threads and wait until one of them returns something truthy (or until they all finish)
from threading import Thread, Semaphore
class FirstToReturn:
def __init__(self):
self._tasks = []
self._results = []
self._signal = Semaphore()
def run(self, fn, *args, **kwargs):
@kevinmcconnell
kevinmcconnell / prepare-commit-msg
Created June 16, 2014 21:26
Annotate your git commits with the song that's current playing in iTunes
#!/usr/bin/env ruby
def get_current_song
`osascript \
-e 'tell application "iTunes"' \
-e '"♪ " & (get name of current track) & " - " & (get artist of current track) & " ♪"' \
-e 'end tell' 2>/dev/null`
end
def append_current_song_if_present
@kevinmcconnell
kevinmcconnell / j
Created August 18, 2014 20:31
Quickly open today's journal file
#!/bin/bash
DIR="$HOME/Dropbox/work/journals"
NAME=`date +%Y-%m-%d.md`
mkdir -p $DIR
vim "$DIR/$NAME" +