Skip to content

Instantly share code, notes, and snippets.

View trptcolin's full-sized avatar

Colin Jones trptcolin

View GitHub Profile
@trptcolin
trptcolin / gist:2d713df94f292c832685
Last active August 29, 2015 14:07
ceci n'est pas une joke
# a little ditty for osx
function voices() {
say -v "?" | cut -d" " -f1,2 | sed -e 's/ *$//'
}
function shuffle_for_stupid_osx_that_doesnt_have_it_built_in() {
perl -MList::Util=shuffle -e 'print shuffle(<STDIN>);'
}
@trptcolin
trptcolin / core-test.clj
Last active August 29, 2015 14:12
Sorry for all the ->>; they're too much fun not to use.
;; test/foobar/core_test.clj
(ns foobar.core-test
(:require [clojure.test :refer :all]
[foobar.core :as foobar]))
(deftest formats-intervals-properly
(is (= "1" (foobar/format-interval [1])))
(is (= "1-2" (foobar/format-interval [1 2])))
(is (= "1-3" (foobar/format-interval [1 2 3]))))

Double Barrier Confusion

Recipe

The way I'm reading the Zookeeper Double Barriers recipe, the exit condition (for Leave) is that all children of the barrier node must be deleted before any given client process can complete the Leave operation.

So it seems to me that if a client process Enters the barrier after the minimum number of processes have joined the barrier, it can hold up previously-Entered client processes. I feel like a typical implementation of barriers might have the minimum # of processes equal to the total # of processes, so maybe this is an edge case? And maybe this is all totally OK and normal; I'm just looking to confirm/disconfirm my interpretation.

  1. Am I thinking about this right? If so, is there actually a problem here? If not, why not?

Paper

[Tue Jan 13 11:59:12 2009] [notice] SELinux policy enabled; httpd running as context user_u:system_r:httpd_t:s0
[Tue Jan 13 11:59:12 2009] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[ pid=12103 file=ApplicationPoolServer.h:535 time=01/13/09 11:59:12.771 ]:
*** WARNING: Could not create FIFO '/tmp/passenger_status.12103.fifo': Permission denied (13)
Disabling Passenger ApplicationPool status reporting.
[Tue Jan 13 11:59:12 2009] [error] *** Passenger could not be initialized because of this error: Could not connect to the ApplicationPool server: Connection reset by peer (104)
[Tue Jan 13 11:59:12 2009] [notice] Digest: generating secret for digest authentication ...
[Tue Jan 13 11:59:12 2009] [notice] Digest: done
[Tue Jan 13 11:59:12 2009] [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
[ pid=12107 file=ApplicationPoolServer.h:535 time=01/13/09 11:59:12.870 ]:
#!/bin/bash
if [[ -z $1 ]]; then
echo "Usage: $0 takes one argument, the project name."
exit 0
else
project=`basename $1`
fi
action="cd /srv/websites/$project; sudo -S rake db:migrate"
echo $action
#!/bin/bash
if [[ -z $1 ]]; then
echo "Usage: $0 takes one argument, the project name."
exit 0
else
project=`basename $1`
fi
action="sudo mongrel_rails cluster::restart -C /etc/mongrel_cluster/$project.yml"
def valid_phone
[self.home_phone, self.mobile_phone, self.work_phone].each do |phone|
if !phone.blank?
return phone
end
end
return ''
end
@trptcolin
trptcolin / gist:75377
Created March 7, 2009 16:24
count the signatures on the Software Craftsmanship Manifesto
require 'rubygems'
require 'nokogiri'
require 'open-uri'
# the solution is only this simple since the last row doesn't get padded to fill out the table
doc = Nokogiri::XML(open('http://manifesto.softwarecraftsmanship.org'))
puts doc.css("#signatory_table td").length
// before:
bestScore = Math.max(bestScore, -minimax(child, depth - 1, otherPlayer);
// after:
otherPlayerScore = minimax(child, depth - 1, otherPlayer);
maxOtherPlayerScore = Math.max(otherPlayerScore, maxOtherPlayerScore);
bestScore = -maxOtherPlayerScore;
(load "/Users/colin/lib/test-manager/load.scm")
(define (factor-list index product factors)
(cond ((< product 2)
'())
((= 0 (modulo product index))
(cons (cons index factors) (factor-list index (/ product index) factors)))
(else
(factor-list (+ index 1) product factors))))