Skip to content

Instantly share code, notes, and snippets.

#original example from Dave Copeland (@davetron5000) sourced from https://twitter.com/davetron5000/status/1598696425675788290
# I deviate from Dave's example by adding a refund method below that I think typifies the Condition Crazy Developer Pattern
class PaymentWithConditions
def charge(price, customer)
if customer.payment_method == :credit_card
charge_credit_card(price, customer.credit_card)
elsif customer.payment_method == :venmo
charge_venmo(price, customer.venmo)
else

A block of stone possess certain characteristics, blemishes, and fissures. It is the sculptors job to address these as they arise. The sculptor must engage the stone in a dialectical conversation. As developers we must have the same conversation with our code. Let's channel our inner Michelangelo and head down this path together.

We've been asked to create a way for a user to enter orders into the system.

class Order < ApplicationRecord
end

class OrdersController < ApplicationController
def create
@noahc
noahc / words.rb
Created September 16, 2015 20:46
download to a directory and run via `ruby ./words.rb`
words = []
word = ""
while word != "\n"
if words.length == 0
print "Enter your first word: "
else
print "Enter another word: "
end
word = gets
words << word.chomp unless word.chomp.empty?
http://www.nwnet.co.uk/
http://www.nwnet.co.uk/BFG/
http://www.nwnet.co.uk/a-gardner/
http://www.nwnet.co.uk/beam-me-up/
http://www.nwnet.co.uk/beam-me-up/xword.htm
http://www.nwnet.co.uk/bramwell/4ply.htm
http://www.nwnet.co.uk/bramwell/4plycard.htm
http://www.nwnet.co.uk/bramwell/artistic.htm
http://www.nwnet.co.uk/bramwell/books.htm
http://www.nwnet.co.uk/bramwell/books2.htm
@noahc
noahc / gist:4741989
Last active December 12, 2015 08:08
Does one of these run faster than the other?
git reset --hard 5a9c02f342f5d729a2d6aefbd805ac83c5458034 #enable PRR 1min53sec
rake db:reset db:migrate db:reset db:test:prepare
rspec spec
git reset --hard cbd4d4c7ec9d9ad20e148685b6d7008bfef4814f #appointed agency merge 2min52sec
rake db:reset db:migrate db:reset db:test:prepare
rspec spec
@noahc
noahc / gist:4709359
Last active December 12, 2015 03:48
agency_or_agent_autocomplete (Tries to Differentiate between prospect and non-prospect agencies for labeling purposes. uses find_by_name on AgencyorAgent displays both)
/Users/noah/Work/mbc/app/views/agency_or_agents/index.html.haml -- ALL
agency_name_autocomplete (uses find_by_name_or_code_for_autocomplete on agency model. shows all agencies)
/Users/noah/Work/mbc/app/views/fidelity_bond_orders/new.html.haml -- Active Only
/Users/noah/Work/mbc/app/views/fidelity_bond_renewals/index.html.haml -- Active Only
/Users/noah/Work/mbc/app/views/fidelity_bonds/edit_agency.html.haml -- Active Only
/Users/noah/Work/mbc/app/views/fidelity_bonds/search.html.haml -- Active Only
@noahc
noahc / gist:3047356
Created July 4, 2012 13:34
Jquery Rails
########index.html.erb########
<div class="row">
<div class="span6">
<% if @holders.empty?%>
<h3>Time to Create your First Set</h3>
<p>A set is a container for questions you'd like to group together. They might "American Presidents of the 20th century" or "Fun Facts About Mammals".
Don't worry too much about getting this part right. You can always edit it later.</p>
require 'sinatra'
require 'date'
class Doer
def makeDate(date)
return Date.strptime(date, "%m/%d/%Y")
end
def buildArray(dateObj)