Skip to content

Instantly share code, notes, and snippets.

View agarman's full-sized avatar

Andrew Garman agarman

View GitHub Profile
@agarman
agarman / messagehub.md
Created June 27, 2017 18:04
MessageHub is Kafka

MessageHub is Kafka

Kafka/MessageHub is a distributed log. It scales writes via partitioning data. You can write a custom partitioner, though the DefaultPartitioner is often sufficient for most applications.

The DefaultPartitioner uses the message key to determine which partition to write a message. This allows control of where messages are written (important for ConsumerGroups…). This also means that Kafka is susceptible to hot partitions, where more messages are being routed to a partition than can be supported by the disk IO of the Kafka nodes hosting

@agarman
agarman / Key base.md
Created May 12, 2017 00:37
Key base.md

Keybase proof

I hereby claim:

  • I am agarman on github.
  • I am andrewgarman (https://keybase.io/andrewgarman) on keybase.
  • I have a public key ASBH0sx_Ks3r31MlPdoXUmBPdU9-2GepQcxSKoAC0qJyGgo

To claim this, I am signing this object:

(defn log2 [n] (/ (Math/log n) (Math/log 2)))
(defn entropy
"Calculate Shannon entropy for xs. Higher value is greater entropy.
Values returned between 0.0 & 8.0"
[xs]
(let [freqs (vals (frequencies xs))
cnt (reduce + freqs)
calc #(let [p (double (/ % cnt))]
(* p (log2 p)))]
@agarman
agarman / pexpect.py
Created February 17, 2017 03:39 — forked from blink1073/pexpect.py
Simple cross platform version of pexpect
'''Pexpect is a Python module for spawning child applications and controlling
them automatically. Pexpect can be used for automating interactive applications
such as ssh, ftp, passwd, telnet, etc. It can be used to a automate setup
scripts for duplicating software package installations on different servers. It
can be used for automated software testing. Pexpect is in the spirit of Don
Libes' Expect, but Pexpect is pure Python. Other Expect-like modules for Python
require TCL and Expect or require C extensions to be compiled. Pexpect does not
use C, Expect, or TCL extensions. It should work on any platform that supports
the standard Python pty module. The Pexpect interface focuses on ease of use so
that simple tasks are easy.
@agarman
agarman / Sierra-MaxFiles.md
Last active February 14, 2017 04:41
Setting max files in OS X

With thanks to http://superuser.com/a/1171026/39144

It seems like there is an entirely different method for changing the open files limit for each version of OS X! For OS X Sierra (10.12.X) you need to:

  1. In /Library/LaunchDaemons create a file named limit.maxfiles.plist and paste the following in (feel free to change the two numbers (which are the soft and hard limits, respectively):
<?xml version="1.0" encoding="UTF-8"?>  
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"  
@agarman
agarman / org-mode-cheat-sheet.org
Last active September 15, 2017 09:10
A cheat sheet for org-mode (gist incorrectly renders as markdown, view/print raw)

Headlines

Visibility cycling

TAB
Cycle subtree folded -> children -> subtree
S-TAB, C-u TAB
Cycle buffer
C-u C-u C-u TAB
Expand all
#+STARTUP: `overview`|`content`|`showall`
Startup options

Motion

C-c C-n
Next heading
@agarman
agarman / combinatorics.clj
Created April 13, 2014 01:56
Helpful combinatoric functions for Clojure
(defn powerset [[h & t]]
(if (nil? h)
[()]
(for [x (powerset t)
y [x (cons h x)]]
y)))
(defn tails [[ _ & t :as xs]]
(when xs (cons xs (tails t))))
@agarman
agarman / gnu.emacs.daemon.plist
Last active August 29, 2015 13:57
MacOSX files required to setup an emacs daemon & an alias to launch emacsclient in a tmux session.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>gnu.emacs.daemon</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/emacs</string>