Skip to content

Instantly share code, notes, and snippets.

Myron Marston myronmarston

Block or report user

Report or block myronmarston

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@myronmarston
myronmarston / observer.md
Created Nov 5, 2015 — forked from pnc/observer.md
Using Erlang observer/appmon remotely
View observer.md

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 learn_sequel_model_spec.rb
require "sequel"
# Connect to the DB to make sequel happy. It expects a DB connection when you subclass Sequel::Model
DB = Sequel.sqlite
# Use the module to avoid naming collisions with other specs.
module LearnSequelModelSpec
# Where can I safely declare this class without specifying
# the database for it?!
View queues.rb
➜ 8549841 git:(master) ✗ ruby queues.rb
Popping before put
popped job:
popped job:
popped job:
popped job:
popped job:
popped job:
popped job:
popped job:
View Gemfile
# A sample Gemfile
source "http://rubygems.org"
gem 'vcr'
gem 'fakefs'
gem 'typhoeus'
gem 'fakeweb'
gem 'rspec'
gem 'rr'
@myronmarston
myronmarston / test_it.rb
Created Aug 7, 2012 — forked from jrochkind/test_it.rb
VCR, WebMock, HTTPClient weirdness
View test_it.rb
require 'httpclient'
require 'vcr'
require 'webmock'
require 'test/unit'
# To allow us to do real HTTP requests in a VCR.turned_off, we
# have to tell webmock to let us.
WebMock.allow_net_connect!
VCR.configure do |c|
View triangle.rb
TriangleError = Class.new(ArgumentError)
Triangle = Struct.new(:x, :y, :z) do
def initialize(*args)
super
validate
end
def type
TYPES.fetch(uniq_side_lengths)
@myronmarston
myronmarston / some_spec.rb
Created Apr 16, 2012 — forked from tommeier/some_spec.rb
VCR with placeholders
View some_spec.rb
use_vcr_cassette 'some/cassette', :tag => :bad_staging_api
@myronmarston
myronmarston / some_spec.rb
Created Mar 20, 2012 — forked from stevenharman/some_spec.rb
Using Rspec's "let" inside an "it" block. Crazy? Yes. Useful? Occasionally.
View some_spec.rb
describe "#mentions_story?" do
subject { described_class.new(file) }
let(:file) { "COMMIT_EDITMSG" }
def set_file_contents(text)
File.stub(:read).with(file) { example_commit_message(text) }
end
context "commit message contains the special Pivotal Tracker story syntax" do
@myronmarston
myronmarston / my_class_spec.rb
Created Mar 4, 2012 — forked from pat/gist:1947369
Using rspec-fire?
View my_class_spec.rb
# My normal approach:
require './path/to/my_class'
describe MyClass do
let(:my_class) { MyClass.new }
describe '#add_widget' do
it "makes a widget using OtherClass" do
other_class = fire_replaced_class_double("OtherClass")
other_class.should_receive(:make_widget!)
@myronmarston
myronmarston / gist:1684632
Created Jan 26, 2012 — forked from justinko/gist:1684051
Methods to aid in testing without loading the Rails environment
View gist:1684632
def stub_model(model_name)
stub_class model_name, ActiveRecord::Base
end
def stub_class(class_name, super_class = Object)
stub_module class_name, Class.new(super_class)
end
def stub_module(module_name, object = Module.new)
module_name = module_name.to_s.camelize
You can’t perform that action at this time.