Skip to content

Instantly share code, notes, and snippets.

View chadwickdonald's full-sized avatar

Chadwick Bidwell chadwickdonald

View GitHub Profile
@chadwickdonald
chadwickdonald / index.html
Created August 10, 2012 21:13
d3 bar chart
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Per_month_graph</title>
<script src="http://d3js.org/d3.v2.js"></script>
</head>
<body>
def new_cat(string1, string2)
new_string = string1 + string2
end
new_cat("Chad", "Bidwell")
def sum(numbers)
sum = 0
class SudokuBoard
def initialize(board_str)
@example_board ="123456789578139624496872153952381467641297835387564291719623548864915372235748916"
@board = board_str.split("").map { |value| Cell.new(value.to_i) }
@groups = []
(generate_rows + generate_cols + generate_grids).each do |group_member_indices|
group_cell_members = group_member_indices.map { |index| @board[index] }
@groups << Group.new(group_cell_members)
end
require "docopt"
require "csv"
class Task
attr_accessor :description, :creation_time, :completion_time, :completed
def initialize(description)
@description = description
@creation_time = Time.new.to_s
@completion_time = ""
require "csv"
require "sunlight"
class EventManager
INVALID_ZIPCODE = "0"*5
Sunlight::Base.api_key = "e179a6973728c4dd3fb1204283aaccb5"
def initialize(filename)
puts "EventManager Initialized."
@file = CSV.open(filename, {:headers => true, :header_converters => :symbol})
@chadwickdonald
chadwickdonald / gist:2955127
Created June 19, 2012 16:31
Lightning Talk: Colorizing
Huoquitlan: https://github.com/quavmo/huoquitlan.git
Gem: http://flori.github.com/term-ansicolor/
@chadwickdonald
chadwickdonald / RSP.rb
Created June 19, 2012 05:02
rock scissors paper
def game(two_players)
two_players.inject do |player1, player2|
p1 = player1[1].upcase
p2 = player2[1].upcase
if p1 == p2
"It's a Tie!"
elsif p1 == "R" && p2 =="P"
player2
elsif p1 == "R" && p2 == "S"
class BaseballTeam
def initialize()
@line_up = { 1 => { 'Aviles' => 'SS' },
2 => { 'Pedroia' => '2B' },
3 => { 'Youkilis' => '1B' },
4 => { 'Ortiz' => 'DH' },
5 => { 'Middlebrooks' => '3B' },
6 => { 'Gonzalez' => 'OF' },
7 => { 'Saltalamacchia' => 'C' },
class Array
def new_inject(*default_value)
if default_value == []
total = self.first
new_array = self.drop(1)
else
total = default_value[0]
new_array = self
end
new_array.each do |element|
@chadwickdonald
chadwickdonald / RPNCalculator.rb
Created June 16, 2012 02:46
reverse polish notation calculator
class RPNCalculator
attr_accessor :value
def initialize()
@numbers = []
@value = 0
end
def push(num)
@numbers << num