Skip to content

Instantly share code, notes, and snippets.

View trptcolin's full-sized avatar

Colin Jones trptcolin

View GitHub Profile

Keybase proof

I hereby claim:

  • I am trptcolin on github.
  • I am trptcolin (https://keybase.io/trptcolin) on keybase.
  • I have a public key whose fingerprint is 67E5 7A31 E9E0 2368 EEAC 5CCF BB1D BD36 16F1 DDB9

To claim this, I am signing this object:

@trptcolin
trptcolin / runq.d
Last active August 21, 2019 01:52
A DTrace script to print the average, min, and max run queue count by CPU
#!/usr/sbin/dtrace -s
/*
* runq.d - run queue sizes by CPU.
*
* This prints the average, min, and max run queue count by CPU each second. A
* consistently large run queue count is a sign of CPU saturation.
*
* USAGE: runq.d
*
* FIELDS:
@trptcolin
trptcolin / dispqlen.d
Last active August 21, 2019 01:53
OSX DTrace scripts that didn't work as shipped (run queue related)
#!/usr/sbin/dtrace -s
/*
* dispqlen.d - dispatcher queue length by CPU.
* Written using DTrace (Solaris 10 3/05).
*
* 14-Feb-2006, ver 0.90
*
* USAGE: dispqlen.d # hit Ctrl-C to end sample
*
* NOTES: The dispatcher queue length is an indication of CPU saturation.

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

@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]))))
@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>);'
}

Found way fewer than I expected with bibliographies. But also way fewer 2009-present books. The select few w/ nice beefy bibliographies:

  • The Joy of Clojure (Fogus/Houser)
  • The Linux Programming Interface (Kerrisk)
  • Systems Performance (Gregg)
  • The Art of Multiprocessor Programming (Herlihy/Shavit)
  • Machine Learning (Flach)

I counted 8/18 tech books on my shelf since 2009 with bibliographies - way fewer than I'd have guessed. This is even w/ some selection bias towards the type of book that would have a bibliography, I suspect.

# Hackery idea
- Github API (get/use an api key - otherwise really limited)
$ curl -u 'USERNAME_HERE' -d '{"scopes":["repo"],"note":"help example"}' https://api.github.com/authorizations
- find all your organizations (paginated)
- find all usernames (grouped by org name) who are in that group
with you
/orgs
user=> (sequence (comp (map inc) (map #(* % %))) (range 10))
(1 4 9 16 25 36 49 64 81 100)
user=> (map (comp inc #(* % %)) (range 10))
(1 2 5 10 17 26 37 50 65 82)
@trptcolin
trptcolin / spec_output.txt
Created June 23, 2014 03:47
speclj test output
(ns clj16.core-spec
(:require [speclj.core :refer :all]
[clj16.core :refer :all]))
(describe "tests"
(it "compares strings"
(should= "space" "spice"))
(it "compares maps 1"
(should== {:sheep 1} {:cheese 1 :sheep 1}))