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
@bradhe
bradhe / monitor.rb
Created March 12, 2014 22:45
Calculate number of transactions/second being ran against your MySQL DB.
require 'mysql2'
$mysql = Mysql2::Client.new(
host: 'localhost',
username: 'root'
)
SLEEP_TIMEOUT=1.0
last_trx = 0
@bradhe
bradhe / omg.rb
Created March 7, 2014 00:26
Nope.
_ = $$ / $$ # 1
__ = _ - _ # 0
@_ = _ + _ # 2
$_ = @_ + _ # 3
$- = @_ + $_ # 5
$-_ = $- * $_ # 15
@__ = '' << $-_ * ($- + $_) + @_ # z
$___ = '' << $-_ * $- - $- << $-_ * ($- + @_) << @__ << @__ # Fizz
@___ = '' << $-_ * $- - $_ * $_ << $-_ * ($- + $_) - $_ << @__ << @__ # Buzz
@bradhe
bradhe / gist:9377665
Created March 5, 2014 22:08
Bundle install attempt
$ sudo bundle install
Fetching gem metadata from https://rubygems.org/........
Fetching additional metadata from https://rubygems.org/..
Using archive-tar-minitar (0.5.2)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
@bradhe
bradhe / gist:9377640
Created March 5, 2014 22:07
Ruby info
vagrant@vagrant-ubuntu-saucy-64:~$ ruby -v
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-linux]
vagrant@vagrant-ubuntu-saucy-64:~$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.2.2
- RUBY VERSION: 2.1.1 (2014-02-24 patchlevel 76) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.1.0
- RUBY EXECUTABLE: /usr/local/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- SPEC CACHE DIRECTORY: /home/vagrant/.gem/specs
@bradhe
bradhe / proof.md
Created February 21, 2014 18:38
Keybase Proof

Keybase proof

I hereby claim:

  • I am bradhe on github.
  • I am bradhe (https://keybase.io/bradhe) on keybase.
  • I have the public key with fingerprint D906 CCBD F539 E51E 0319  DD2C 183E BDE0 6E96 032F

To claim this, I am signing this object:

CREATE TABLE first_table (
col0 DATETIME NOT NULL,
col1 VARCHAR(255) NOT NULL,
col2 INT(11) NOT NULL,
col3 INT(11) NOT NULL,
UNIQUE KEY (col0, col1, col2)
) ENGINE=InnoDB;
INSERT INTO first_table (col0, col1, col2, col3) VALUES ("2013-01-05 12:00:00", "Hello", 1, 10), ("2013-01-05 12:00:00", "World", 2, 11);
@bradhe
bradhe / test_foreman_start_time.sh
Created December 5, 2013 23:09
Shell script for testing how long it takes for Foreman + Unicorn to come online during start up.
#!/bin/bash
# Start a new foreman. We'll need the PID for later.
foreman start redis=1,web=1 &
FOREMAN_PID=$!
while :
do
curl http://localhost:5000/login &> /dev/null
@bradhe
bradhe / bogo_sort.rb
Created November 22, 2013 08:04
A Ruby implementation of bogosort (http://en.wikipedia.org/wiki/Bogosort) and a few shitty metrics about it.
$ cat bogo_sort.rb
count = []
100.times do
start_at = Time.now
corpus = (1..10).to_a
shuffled = corpus.shuffle
$count = 0
@bradhe
bradhe / output.txt
Last active December 21, 2015 18:09
Test Enumerable#sort_by! vs. Enumerable#sort_by in Ruby. Results ran under MRI.
$ ruby -v
ruby 1.9.3p374 (2013-01-15 revision 38858) [x86_64-darwin12.2.1]
$ ruby sort_test.rb
0
1
2
3
4
5
@bradhe
bradhe / add-total-allocations.path
Created June 26, 2013 21:28
This patch adds a new function to the Ruby VM for getting the total number of allocations performed, as well as adds a method to GC to get that same number.
From 2cbc1b959af0b40b0723b3fb586ea70d0324fe59 Mon Sep 17 00:00:00 2001
From: Brad Heller <[email protected]>
Date: Wed, 26 Jun 2013 13:17:02 -0700
Subject: [PATCH] Add support for total allocations measurement.
---
gc.c | 16 ++++++++++++++++
include/ruby/intern.h | 1 +
test/ruby/test_gc.rb | 4 ++++
3 files changed, 21 insertions(+)