Skip to content

Instantly share code, notes, and snippets.


Stephen Bussey sb8244

View GitHub Profile
sb8244 / gist:8126020
Created December 25, 2013 19:11
Doctrine sample mapper to provide common operations
View gist:8126020
//FILE GenericMapperInterface.php
interface GenericMapperInterface
public function find($id);
public function findAll();
public function save($entity);
public function remove($entity);
View leak.rb
# Minimal example that demonstrates a memory leak in Celluloid.
# Adapted from @debrasetton example:
# Adapted from @grosser example:
# Run with LEAK=0 for no memory leak or LEAK=1 for memory leak, like so:
# LEAK=1 ruby ./leak.rb > /dev/null
require 'celluloid/autostart'
Celluloid.logger = nil
$counter = 0
$jobs = 5_000
sb8244 / gist:a44cfa7463c65e89612e
Created March 13, 2015 20:54
Ernie, play nice with Rails!
View gist:a44cfa7463c65e89612e
# Rails will cause the encoding to slip to ASCII-8BIT for some reason.
# This works fine when all rails libraries aren't loaded onto the ernie process
class Ernie
def self.write_berp(output, ruby)
data = BERT.encode(ruby)
sb8244 / gist:351d6561b9617546fbb5
Created March 29, 2015 02:40
Grocer in action
View gist:351d6561b9617546fbb5
DeviceNotifier =, :count) do
def call
notifications.each do |notif|
def pusher
View gist:a11c1fb5234a3e89d191
module AgentDispatch
class Loader
def run!
future = # It's a celluloid example here
while read_trap_io
View Noisy Dog Log

This privacy policy governs your use of the software application Noisy Dog Log (“Application”) for mobile devices that was created by Stephen Bussey. The Application is a way to monitor loud noises around your device, namely dog barking.

What information does the Application obtain and how is it used?

User Provided Information

The Application obtains the information you provide when you download and register the Application. Registration with us is optional. However, please keep in mind that you may not be able to use some of the features offered by the Application unless you register with us.

When you register with us and use the Application, you generally provide (a) your name, email address, user name, password and other registration information; (b) transaction-related information, such as when you make purchases, respond to any offers, or download or use applications from us; (c) information you provide us when you contact us for help, and; (d) information you enter into our system when using th

View traverse.rb
def solution(t)
traverse_height(t, 0)
def traverse_height(t, current_height)
return current_height - 1 if t.nil?
left_height = traverse_height(t.l, current_height+1)
right_height = traverse_height(t.r, current_height+1)
[left_height, right_height].max
View array_inversion_count.rb
# First sort the input using an nlogn method
# Then iterate over the array, finding the index of each value in the sorted array
# The index of the value in the sorted array is the inversion count, because all items to the left are less
# Sum those up
# Be sure to use the most efficient searching and not build in. (nlogn sort and logn search)
def solution(a)
return 0 if a.empty?
sorted = a.sort
inversions = do |val, index|
sb8244 / gist:78ba4e736f72aecc2717f6ac5b2c2d2d
Created February 2, 2018 19:18
Distillery migrations
View gist:78ba4e736f72aecc2717f6ac5b2c2d2d

Distillery migrations

  1. Add migration command in rel/config.exs [1]
  2. Create rel/commands/ script [2]
  3. Create lib/release/tasks.ex with contents of [3]
  4. Add priv/repo/migrations to your docker context [4]
  5. Now you can run the migrate command as a custom command from your Distillery output, this is just like running console or foreground. It will appear in help of your release
sb8244 / exometer.exs
Created February 7, 2018 22:26
My exometer.exs standard installation
View exometer.exs
# mix.exs deps
# start exometer; force "correct" modules due to elixometer not compiling properly
{:elixometer, "~> 1.2"},
{:lager, ">= 3.2.1", override: true},
{:exometer, github: "Feuerlabs/exometer"},
{:exometer_core, "~>1.4.0", override: true},
{:amqp_client, git: "", branch: "erlang_otp_19", override: true},
# end exometer