Skip to content

Instantly share code, notes, and snippets.


Mark Sonnabaum msonnabaum

View GitHub Profile

Keybase proof

I hereby claim:

  • I am msonnabaum on github.
  • I am msonnabaum ( on keybase.
  • I have a public key ASAglXeQJzr-CGEUgFL8hJIrd_NFs5TFViA2uHH9i5s7wQo

To claim this, I am signing this object:

View stackfilter-perf.rb
#!/usr/bin/env ruby
require "optparse"
options = {} do |opts|
opts.banner = "Usage: #{File.basename __FILE__} [options]"
opts.on "-p", "--process-names [process names]", "Process names to filter" do |v|
options[:process_names] = v.split(",")
View who_posts_the_most.kts
// Download the twitter4j jar:
// wget
// Fill out the key/token/secrets
// Run the script
// kotlinc -script -classpath ./twitter4j-core-4.0.4.jar who_posts_the_most.kts|sort -n
import twitter4j.Status
import twitter4j.Twitter
import twitter4j.TwitterException
import twitter4j.TwitterFactory
View heap_dump.rb
require "objspace"
trap "USR2" do |signo| {
ObjectSpace.dump_all output:"/tmp/heap-#{}.json", "w")
View reduce_wtf.js
[1,2,3].reduce(function(memo, current) {
}, {});
// > {}
// > undefined
// > undefined
View test.php
$application['kernel'] = $application->share(
$application->extend('kernel', function ($kernel, $app) {
return new YourNewHttpKernelInterfaceObject($kernel);
View wait_until.go
func WaitUntil(f func() bool, seconds int) {
done := make(chan bool)
go func() {
time.Sleep(time.Duration(seconds) * time.Second)
done <- true
go func() {
for {
if f() {
done <- true
View fix-dstat-csv
#!/usr/bin/env ruby
require "csv"
def fix_dstat_csv(file)
dstat_csv = file
# Shift off useless metadata rows
dstat_csv.shift 5
# dstat spreads the headers out over two rows, which R does not like, so
View lm.thrift
namespace go thriftgen
namespace rb LatencyMetricsThrift
struct LatencyMetric {
1: string timestamp,
2: required string product,
3: required string host,
4: required string metric,
5: string environment,
6: required double value,
View flatten_json
#!/usr/bin/env ruby
require "json"
def flatten_hash(hash, parent_key = "")
result_hash = {}
hash.each do |key, value|
if value.is_a? Hash
result_hash.merge! flatten_hash(value, key)
result_key = if parent_key.empty? then key else "#{parent_key}.#{key}" end