Skip to content

Instantly share code, notes, and snippets.

@aaronfeng
aaronfeng / tsocks.rb
Created January 29, 2013 01:23
homebrew tsocks formula
require 'formula'
class Tsocks < Formula
# The original is http://tsocks.sourceforge.net/
# This GitHub repo is a maintained fork with OSX support
homepage 'http://github.com/pc/tsocks'
head 'https://github.com/pc/tsocks.git'
depends_on 'autoconf' => :build if MacOS.xcode_version.to_f >= 4.3

ERROR [2013-01-23 00:58:51,186] New I/O server worker #2-3 - aleph.netty - Unhandled error in Netty pipeline. java.io.IOException: Connection timed out at sun.nio.ch.FileDispatcherImpl.read0(Native Method) at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39) at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:218) at sun.nio.ch.IOUtil.read(IOUtil.java:186) at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:359) at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:315) at org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:274) at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:194)

Application specific host grouping in Riemann-dash

It is generally desirable to group all the hosts for a specific service into a single dashboard view. For example, all the web servers are in single view while all the database servers are in another view.

This is usually not an issue when you are sending custom metrics using Riemann client. However, there are cases where you are using something that you do not control how the metrics are being sent. i.e., Riemann-tools.

Since Riemann-tools scripts are application agnostic, in order for the dashboard view to group hosts, we must inject some application specific information into the tags field. Tags is a collection of arbitrary strings. In the case of Riemann-tools scripts you can pass in arbitrary strings on the command line.

riemann-health --host 127.0.0.1 --tag "prod" --tag "webserver"

(let [hosts (atom {})]
(fn [event]
(let [tag-str (keyword (clojure.string/join "-" (:tags event)))]
(swap! hosts assoc tag-str (conj (tag-str @hosts #{}) (:host event)))
(index {:service (str (name tag-str) "-count")
:time (unix-time)
:metric (count (tag-str @hosts))}))))

Intro:

http://punchcard.io

Currently a developer's professional profile is made up two components:

  • LinkedIn
  • Github

LinkedIn shows your work history, and Github shows your craft. There is a missing gap between LinkedIn and Github. Punchcard.io is designed to bridge that gap.

@aaronfeng
aaronfeng / config
Created October 29, 2012 15:12
ssh config for ec2 - no more annoying host checking by defaut
Host *.compute.amazonaws.com
IdentityFile ~/.ec2/your-key.pem
User root
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
@aaronfeng
aaronfeng / gist:3379083
Created August 17, 2012 14:23
PhillyAWS - 8/28/12

I can't decided on the title. Maybe you can help me. 3 - 7 is courtesy of @codeslinger.

title

  1. "BigData: Data Crunch on a Budget"
  2. "BI in the Cloud"
  3. "You're using Oracle for that? Big Data and you"
  4. "Better Answers from More Data: Today's Business Intelligence Architecture"
  5. "How Did They Know That? Getting Smart Answers like Google"
@aaronfeng
aaronfeng / gist:3370486
Created August 16, 2012 14:25
edit last modified file
$EDITOR `find . \( ! -regex '.*/\..*' \) -type f | xargs ls -rt | tail -n 1`
@aaronfeng
aaronfeng / gist:3236613
Created August 2, 2012 12:13
chef attributes quiz
# cookbook/attributes/default.rb
default[:foo][:bar][:size] = 42
# cookbook/recipes/default.rb
node.foo.bar.size
# what will above return?
@aaronfeng
aaronfeng / etc-nginx-nginx.conf
Created July 30, 2012 14:15
nginx json log format
# /etc/nginx/nginx.conf
log_format main '{'
'"remote_addr": "$remote_addr",'
'"remote_user": "$remote_user",'
'"time_local": "$time_local",'
'"request": "$request",'
'"status": "$status",'
'"body_bytes_sent": "$body_bytes_sent",'
'"http_referer": "$http_referer",'