Skip to content

Instantly share code, notes, and snippets.

View seanreed1111's full-sized avatar

Sean Reed seanreed1111

View GitHub Profile
@seanreed1111
seanreed1111 / strike9-board.js
Last active August 29, 2015 14:01
Drawing boxes for Strike9 using Canvas
"use strict";
window.onload = function(){
for(var i = 1; i<=9; i++){
var canvas = document.getElementById(i.toString());
var context = canvas.getContext("2d");
context.fillStyle = "#111";
context.fillRect(0,0,90,90);
}
var board = document.getElementById("board");
@seanreed1111
seanreed1111 / code_of_conduct
Last active August 29, 2015 13:56
Code of Conduct
Code of Conduct
We believe our events should be open for everyone.
We are committed to providing a friendly, safe, and welcoming environment for all,
regardless of gender, sexual orientation, disability, ethnicity, religion,
preferred operating system, programming language, or text editor.
We expect all event participants to help us realize a safe and positive experience for everyone.
At all of our events, we expect everyone will:
@seanreed1111
seanreed1111 / person.rb
Last active August 29, 2015 13:56
Model validation in rails
class Person < ActiveRecord::Base
attr_accessible :username, :password, :age, :graduation_year
#must have first and last name.
#If not present, throw an error message (optional)
validates_presence_of :username
validates_presence_of :password
@seanreed1111
seanreed1111 / js_code_quiz.md
Last active January 3, 2016 22:29
intro javascript

typeof(3) 'number'

typeof(3) === typeof(4.32) true

5/0 Infinity

3/" bob"

@seanreed1111
seanreed1111 / DFS.rb
Last active December 31, 2015 19:29
DFS as a class
class DFS
attr_reader :adj_list, :parent
def initialize(adj_list={})
@adj_list = adj_list
@parent = {}
end
def dfs_run!(starting_node)
@seanreed1111
seanreed1111 / bfs.rb
Last active September 21, 2016 01:31
BFS Implementation. (Not defined as a Class)
require '../lib/Queue'
frontier = Queue.new
neighbors = {}
neighbors = {:a => [:b,:f],
:b => [:a,:c,:d],
:c => [:b,:e],
:d => [:b,:e],
:e => [:c,:d],
:f => [:a,:g,:h,:i],
:g => [:f],
@seanreed1111
seanreed1111 / fibonacci.rb
Last active December 31, 2015 17:59
Fibonacci Sequence generator
def fibo(n)
if n < 2
n
else
fibo(n-1) + fibo(n-2)
end
end
puts fibo(8)
@seanreed1111
seanreed1111 / Fibonacci_with_hash.rb
Last active December 31, 2015 17:59
Fibonacci Sequence with Memoization
@fib_hash = {}
@fib_hash = {0 => 0, 1 => 1 }
def fibo_finder(n)
if @fib_hash.has_key?(n)
return @fib_hash[n]
else
@fib_hash[n] = fibo_finder(n-1) + fibo_finder(n-2)
end
end
@seanreed1111
seanreed1111 / Queue.rb
Created December 17, 2013 02:40
Queue object implemented in Ruby
class Queue
include Enumerable
attr_reader :queue
def initialize
@queue = Array.new
end
#enqueue(item) adds item to the end of the queue
@seanreed1111
seanreed1111 / Depth_First_Search.rb
Created December 17, 2013 02:36
Depth_First_Search
#defines DFS Object.
#currently only implements dfs_visit!, which only traverses the graph from one node
#to fully implement DFS, need to loop through ALL starting nodes
class DFS
attr_reader :adj_list, :parent
def initialize(adj_list={})
@adj_list = adj_list