Skip to content

Instantly share code, notes, and snippets.


Myron Marston myronmarston

View GitHub Profile
View inverse_hook_filtering.rb
RSpec.configure do |config|
# Either put conditional logic in the hook...
config.around(:example) do |ex|
unless ex.metadata[:slow]
puts "Not tagged slow"
View rspec_output.txt
A group of examples
 is pending (PENDING: not yet passing)
 fails (FAILED - 1)
 fails with a diff (FAILED - 2)
 fails with a multiline snippet in order to show off syntax highlighting (FAILED - 3)
Pending: (Failures listed here are expected and do not affect your suite's status)
View response.txt
HTTP/1.1 400 Bad Request
connection: close
server: Cowboy
date: Tue, 24 Nov 2015 20:24:58 GMT
content-length: 0
myronmarston /
Created Nov 5, 2015 — forked from pnc/
Using Erlang observer/appmon remotely

Using OTP's observer (appmon replacement) remotely

$ ssh remote-host "epmd -names"
epmd: up and running on port 4369 with data:
name some_node at port 58769

Note the running on port for epmd itself and the port of the node you're interested in debugging. Reconnect to the remote host with these ports forwarded:

$ ssh -L 4369:localhost:4369 -L 58769:localhost:58769 remote-host
View supervisor.ex
defmodule Delorean.RankingsShardRepository.RunningShard.Supervisor do
use Supervisor
def start_link(opts) do
Supervisor.start_link(__MODULE__, opts, [])
def start_shard(supervisor, shard_opts) do
Supervisor.start_child(supervisor, shard_opts)
View snapshot_repository_test.exs
defmodule MyApp.SnapshotRepositoryTest do
use ExUnit.Case, async: true
doctest MyApp.SnapshotRepository
alias MyApp.SnapshotRepository.SnapshotOptions
test "queries S3 with a prefix and returns the matched keys" do
options = %SnapshotOptions{ campaign_id: "prod.0.1", backend: "SomeBackend", cycle_type: "week" }
prefix = SnapshotOptions.to_key_prefix(options)
key_1 = "#{prefix}0/2013-03-19T15:04:50Z/mtoken.json.gz"
key_2 = "#{prefix}1/2013-03-19T15:04:50Z/mtoken.json.gz"
View parallel.ex
defmodule Delorean.Parallel do
def map(list, fun) do
|> -> Task.async(fn -> fun.(item) end) end)
myronmarston / named_doubles.rb
Created Jul 9, 2015
How to get the name of a double.
View named_doubles.rb
# to get the name, you can use `instance_variable_get`:
tweet = double("Twitter::Tweet")
tweet.instance_variable_get(:@name) # => "Twitter::Tweet"
# that's clearly violating the public API, though. Another way is to pass it as a stub:
tweet = double("Twitter::Tweet", name: "Twitter::Tweet") # => "Twitter::Tweet"
# If you like that approach, you could create a new `named_double`
# helper method:
View sentence_spec.rb
class Sentence
def test(sen)
first = sen[0]
last = sen.split('').last
rest = sen[1..-1]
word_arr = sen.split
word_arr_len = word_arr.length
unless first == first.upcase then
puts "the first letter is not in uppercase"
myronmarston / stack_overflow_debugger.rb
Created Jun 1, 2015
Stack overflow debugger (since Ruby doesn't provide the whole stack in this case)
View stack_overflow_debugger.rb
max_stack_frames = 500
TooManyStackFrames = do |tp|
if caller.size >= max_stack_frames
raise TooManyStackFrames, "Stack has exceeded #{max_stack_frames} frames"
You can’t perform that action at this time.