This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Special thanks to https://stackoverflow.com/a/5201642/1212371 | |
# | |
# Installation: | |
# Download and place this file somewhere in your path typically ~/bin/git-funge or /usr/local/bin/git-funge | |
# make sure it has execute permissions with `sudo chmod +x <path-to-your>/git-funge` | |
# | |
# Usage: | |
# | |
# `git funge HEAD~3` or |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# Quick and easy way to convert from yaml to json with pretty format | |
# Usage: | |
# Example 1: | |
# | |
# # Explicitly give the output filename | |
# ./yaml_to_json.rb input_file/name.yaml outputfile/name.json | |
# | |
# Example 2: | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Banking | |
module Processing | |
class Debit | |
class << self | |
def execute(amount, payment_method) | |
# Do vital checks before doing any work | |
unless payment_method.registered? | |
raise Errors::UnregisteredPaymentMethod.new("You can't debit an unregistered payment method") | |
end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Banking | |
module PaymentMethods | |
class BankAccount < ActiveRecord::Base | |
belongs_to :user | |
has_many :transactions, class_name: 'Banking::Transaction' | |
def debit(amount) | |
Processing::Debit.execute(amount, self) | |
# Or Processing::Debit.new(amount, self).process! depending on your desired API | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app/ | |
models/ | |
user.rb # ActiveRecord | |
banking/ | |
payment_methods/ | |
bank_account.rb # ActiveRecord | |
credit_card.rb # ActiveRecord | |
registration.rb | |
processing/ | |
base.rb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rake parallel:create | |
rake parallel:prepare | |
rake parallel:spec | |
Output ------- | |
8 processes for 204 specs, ~ 25 specs per process | |
/home/tyrone/.rvm/gems/ruby-2.1.5@myproject/gems/activerecord-4.1.8/lib/active_record/connection_adapters/postgresql_adapter.rb:898:in `rescue in connect': FATAL: database "myproject_test<%= ENV['TEST_ENV_NUMBER'] %>" does not exist (ActiveRecord::NoDatabaseError) | |
Run `$ bin/rake db:create db:migrate` to create your database |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
lib = File.expand_path('../lib', __FILE__) | |
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) | |
require 'bs_helpers/version' | |
Gem::Specification.new do |spec| | |
spec.name = "bs_helpers" | |
spec.version = BsHelpers::VERSION | |
spec.authors = ["Tyrone Wilson"] | |
spec.email = ["[email protected]"] |