Skip to content

Instantly share code, notes, and snippets.

View jordanmaguire's full-sized avatar

Jordan Maguire jordanmaguire

  • Perth
View GitHub Profile
erd = ERDBuilder.new
erd.begin_system("Infoamatica")
venue = erd.add_entity("Venue")
venue.attributes = {name: :string}
user = erd.add_entity("User")
user.attributes = {email: :string, password: :string}
erd.associate(user, venue, {association: :many_to_one, name: "Association"})
@jordanmaguire
jordanmaguire / erd_builder.rb
Created September 16, 2013 02:35
ERDBuilder using mother flipping ruby-graphviz
require 'rubygems'
require 'graphviz'
class ERDBuilder
attr_reader :name
def add_entity(name)
ERDEntity.new.tap do |entity|
entity.build(graph: graph, name: name)
@jordanmaguire
jordanmaguire / original_wizard.rb
Created November 2, 2012 12:50
Original Wizard
class OnlineEnquiryWizard < EnquiryWizard
# Called within the CapacityCheckController to find which step to go to
# if 'previous' is pressed on the first step of the first CapacityCheck
def step_before_capacity_check
if @object.vehicle_selection_method == "none"
"select_vehicle"
else
"duty_of_disclosure"
end
@jordanmaguire
jordanmaguire / bad_rspec.rb
Created June 26, 2012 01:31
The issue that caused me to devise my newer RSpec pattern
let(:vehicle) { FactoryGirl.create(:vehicle, :vehicle_model => vehicle_model, :type_of_sale => type_of_sale) }
let(:vehicle_model) { nil }
let(:type_of_sale) { "New" }
@jordanmaguire
jordanmaguire / rspec_attributes.rb
Created June 26, 2012 01:29
This is a helpful RSpec pattern I've been playing with lately with great success
let(:vehicle) { FactoryGirl.create(:vehicle, vehicle_attributes) }
let(:vehicle_attributes) { {} }
describe "#to_s"
subject { vehicle.to_s }
let(:vehicle_attributes) { {name: "Carzilla"} }
it { should == "Carzilla" }
end
@jordanmaguire
jordanmaguire / rspec_generators.rb
Created January 16, 2012 14:06
rspec generators
# Use the rspec generators
config.generators do |g|
g.view_specs false
g.helper_specs false
g.test_framework :rspec
end
@jordanmaguire
jordanmaguire / marks_challenge_2.sh
Created September 29, 2011 12:58
Marks Challenge 2
#!/bin/bash
echo -e "second\nthird\nfourth" > something.txt
echo -e "something.txt\n-------------"
cat something.txt
printf '%s\n' 0a "first" . w | ed -s something.txt
echo -e "\nsomething.txt\n-------------"
cat something.txt
@jordanmaguire
jordanmaguire / marks_challenge.sh
Created September 29, 2011 12:23
Mark's bash challenge
#!/bin/bash
echo -e "second\nthird\nfourth" > something.txt
echo -e "something.txt\n-------------"
cat something.txt
echo -e "first" | cat - something.txt > tmp && mv tmp something.txt
echo -e "\nsomething.txt\n-------------"
cat something.txt
@jordanmaguire
jordanmaguire / my_rename.sh
Created September 26, 2011 03:42
Recursively rename a bunch of files
#!/bin/bash
IFS=$'\n'
for FILE in `find . -name "*.wma.MP3" -type f`
do
mv $FILE `echo $FILE | sed s/.wma.MP3/.mp3/g`
done
@jordanmaguire
jordanmaguire / cleanup.sh
Created September 26, 2011 01:04
Removes unnecessary files from music collection
#!/bin/bash
find . -name "*.nfo" -delete
find . -name "*.sfv" -delete
find . -name "*.m3u" -delete
find . -name "*.html" -delete
find . -name "*.md5" -delete
find . -name "*.pls" -delete