Skip to content

Instantly share code, notes, and snippets.

View bradhe's full-sized avatar
👋
looking for friendship

Brad Heller bradhe

👋
looking for friendship
  • Berlin
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am bradhe on github.
  • I am bradhe (https://keybase.io/bradhe) on keybase.
  • I have a public key ASCEphB5acVdQ7wzmY47GaB1SgrOkh9rBzpenr74qe2bOwo

To claim this, I am signing this object:

@bradhe
bradhe / example-integration.rb
Last active November 30, 2015 20:03
An example integration for (hypothetical) social media data in a MySQL database with Reflect.
View example-integration.rb
require 'mysql'
# gem install reflect
require 'reflect'
sql = <<-SQL
(
SELECT
'twitter' AS `Network`,
DATE(scrape_time) AS `Scrape Date`,
View falsy.php
<?php
echo "Empty array false-y? " . (array() ? "No" : "Yes");
echo "\n";
echo "Array false-y? " . (array("hi") ? "No" : "Yes");
echo "\n";
echo "Associative array false-y? " . (array("hi" => "there") ? "No" : "Yes");
echo "\n";
View gist:768d90770d4b75ce00c1
Nov 20 14:02:38 production-web-007 unicorn: E, [2014-11-20T22:02:32.901848 #13636] ERROR -- : worker=2 PID:20950 timeout (61s > 60s), killing
Nov 20 14:02:38 production-web-007 unicorn: E, [2014-11-20T22:02:32.956764 #13636] ERROR -- : reaped #<Process::Status: pid 20950 SIGKILL (signal 9)> worker=2
Nov 20 14:02:38 production-web-007 unicorn: I, [2014-11-20T22:02:34.138374 #22844] INFO -- : worker=2 ready
...
Nov 20 14:03:38 production-web-007 unicorn: E, [2014-11-20T22:03:35.392466 #13636] ERROR -- : worker=2 PID:22844 timeout (61s > 60s), killing
Nov 20 14:03:38 production-web-007 unicorn: E, [2014-11-20T22:03:35.413304 #13636] ERROR -- : reaped #<Process::Status: pid 22844 SIGKILL (signal 9)> worker=2
Nov 20 14:03:38 production-web-007 unicorn: I, [2014-11-20T22:03:36.601522 #22983] INFO -- : worker=2 ready
@bradhe
bradhe / shark-server.conf
Created April 21, 2014 22:46
Shark upstart script.
View shark-server.conf
>> cat config/shark-server.conf
description "shark server"
start on runlevel [23]
stop on shutdown
exec /root/shark/bin/shark --service sharkserver 12022
View facts.hql
CREATE TABLE facts (
dimension1 STRING,
dimension3 STRING,
dimension4 STRING,
timestamp2 TIMESTAMP,
measure1 DECIMAL,
measure2 DECIMAL,
measure3 DECIMAL
) PARTITIONED BY(dimension2 STRING, timestamp1 TIMESTAMP)
CLUSTERED BY(dimension1) INTO 32 BUCKETS;
View external_table.hql
CREATE EXTERNAL TABLE raw_facts (
dimension1 STRING,
dimension2 STRING,
dimension3 STRING,
dimension4 STRING,
timestamp1 TIMESTAMP,
timestamp2 TIMESTAMP,
measure1 DECIMAL,
measure2 DECIMAL,
measure3 DECIMAL
@bradhe
bradhe / bukkit.sh
Last active August 29, 2015 14:00
How big is mah bukkit?
View bukkit.sh
aws s3 ls s3://my-bucket/my-prefix/ | awk '{print $3}' | ruby -e 'puts ARGF.read.split("\n").map(&:to_i).reduce(&:+)'
@bradhe
bradhe / output.md
Last active August 29, 2015 13:57
EBS performance with 4k PIOPS vs no PIOPS...not impressed.
View output.md

No PIOPS

$ dd if=/dev/urandom of=/mnt/data/my_file bs=1k count=5000000
5000000+0 records in
5000000+0 records out
5120000000 bytes (5.1 GB) copied, 460.399 s, 11.1 MB/s

PIOPS

@bradhe
bradhe / monitor.rb
Created March 12, 2014 22:45
Calculate number of transactions/second being ran against your MySQL DB.
View monitor.rb
require 'mysql2'
$mysql = Mysql2::Client.new(
host: 'localhost',
username: 'root'
)
SLEEP_TIMEOUT=1.0
last_trx = 0