Skip to content

Instantly share code, notes, and snippets.

View gabrieljoelc's full-sized avatar

Gabriel Chaney gabrieljoelc

View GitHub Profile
@gabrieljoelc
gabrieljoelc / gist:11386605
Last active August 29, 2015 14:00
Sneakers gem handler error and timeout pseudo code
# if message doesn't contain max retry info then
# publish to delay (dead-letter) queue with first step
# elsif message contains retry info that's not max then
# update retry step and publish to delay dead-letter queue
# else
# send to error (dead-letter) queue
@gabrieljoelc
gabrieljoelc / partial_stubbing.rb
Created May 8, 2014 00:38
From http://blog.arvidandersson.se/2012/03/28/minimalicous-testing-in-ruby-1-9: "Partial stubbing is when you want use a “real object” in your tests but want to stub some of the methods of that object, for example to avoid hitting the network or to freeze the time. These kinds of stubs are easily added in ruby thanks to it's dynamic workings. Le…
describe Book do
it "glorifies published at" do
book = Book.new
def book.published_at
Time.new(2012, 1, 2)
end
book.glorified_published_at.must_equal "The most awesome and first Monday of the glorious year of 2012"
end
@gabrieljoelc
gabrieljoelc / acts_as_owned.rb
Last active August 29, 2015 14:02
Overkill but interesting learning experience for me about metaprogramming in Ruby.
module ActsAsOwned
def acts_as_owned(options = {})
raise 'Must define owner lambda' unless options[:owner] && options[:owner].class == Proc
define_method(:owner, &options[:owner])
end
end
ActiveRecord::Base.send :extend, ActsAsOwned
@gabrieljoelc
gabrieljoelc / .bash_profile
Created July 10, 2014 04:02
My OS X .bash_profile
export PATH=/usr/local/bin:$PATH
export PATH="$HOME/.rbenv/bin:$PATH"
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
export PATH="$HOME/bin:$PATH"
export PATH="/Applications/Postgres.app/Contents/Versions/9.3/bin:$PATH"
source ~/.git-prompt.sh
@gabrieljoelc
gabrieljoelc / ruby_2_0_class_prepend.rb
Last active August 29, 2015 14:05
Ruby inheritance, inner classes, and class methods with `const_get`
module Ruby2Prepend
module GetExtensions
module ClassMethods
def get
super + 1
end
end
def self.prepended(base)
class << base
queue = Sidekiq::Queue.new("deferred")
csv CSV.new
queue.each do |job|
job.klass # => 'DeferredReady'
job.args # => [1]
csv << "#{job.id}#{job.klass},#{job.args}"
end
queue.clear
@gabrieljoelc
gabrieljoelc / gist:cb079557fc9bfc9870c5
Created December 4, 2014 00:16
### Keybase proof
### Keybase proof
I hereby claim:
* I am gabrieljoelc on github.
* I am gabrieljoelc (https://keybase.io/gabrieljoelc) on keybase.
* I have a public key whose fingerprint is 1DC6 3C05 B86E 1AF7 7987 DA18 C44E FDC4 9C79 5BF9
To claim this, I am signing this object:
@gabrieljoelc
gabrieljoelc / env.rb
Last active August 29, 2015 14:10 — forked from opsb/gist:3486581
Spinach adapter for Sauce Connect
ENV['RAILS_ENV'] = 'test'
require './config/environment'
require 'minitest/spec'
require 'spinach/capybara'
require_relative 'spinach_helper'
require_relative 'sauce'
Spinach::Scenario.send(:prepend, SpinachHelper::Scenario)
begin
@gabrieljoelc
gabrieljoelc / dollarable.rb
Created February 26, 2015 23:26
Little module for define dynamic methods that automatically convert values from methods ending in `_cents` methods to `BigDecimal` dollars.
module Dollarable
def acts_as_dollarable
attribute_names.select { |m| m.ends_with?('_cents') }.each do |m|
define_method m.gsub(/_cents/, '') do
value = send(m)
return BigDecimal(0) if value.blank? || value.zero?
BigDecimal(value) / 100
end
end
end

On a company's balance sheet, accounts receivable are the money owed to that company by entities outside of the company. Account receivables are classified as current assets assuming that they are due within one calendar year or fiscal year. To record a journal entry for a sale on account, one must debit a receivable and credit a revenue account. When the customer pays off their accounts, one debits cash and credits the receivable in the journal entry. The ending balance on the trial balance sheet for accounts receivable is usually a debit.