Skip to content

Instantly share code, notes, and snippets.

View msonnabaum's full-sized avatar

Mark Sonnabaum msonnabaum

  • Lithic
  • San Diego, CA
View GitHub Profile

Keybase proof

I hereby claim:

  • I am msonnabaum on github.
  • I am msonnabaum (https://keybase.io/msonnabaum) on keybase.
  • I have a public key ASAglXeQJzr-CGEUgFL8hJIrd_NFs5TFViA2uHH9i5s7wQo

To claim this, I am signing this object:

#!/usr/bin/env ruby
require "optparse"
options = {}
OptionParser.new 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(",")
end
end.parse!
// Download the twitter4j jar:
// wget http://twitter4j.org/maven2/org/twitter4j/twitter4j-core/4.0.4/twitter4j-core-4.0.4.jar
// 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
require "objspace"
trap "USR2" do |signo|
Thread.new {
ObjectSpace.trace_object_allocations_start
GC.start
ObjectSpace.dump_all output: File.open("/tmp/heap-#{Time.now.to_i}.json", "w")
}.join
end
[1,2,3].reduce(function(memo, current) {
console.log(memo);
}, {});
// > {}
// > undefined
// > undefined
@msonnabaum
msonnabaum / test.php
Last active October 26, 2015 19:01 — forked from damiankloip/test.php
<?php
$application['kernel'] = $application->share(
$application->extend('kernel', function ($kernel, $app) {
return new YourNewHttpKernelInterfaceObject($kernel);
})
);
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
#!/usr/bin/env ruby
require "csv"
def fix_dstat_csv(file)
dstat_csv = CSV.read file
# Shift off useless metadata rows
dstat_csv.shift 5
# dstat spreads the headers out over two rows, which R does not like, so
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,
#!/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)
else
result_key = if parent_key.empty? then key else "#{parent_key}.#{key}" end