Skip to content

Instantly share code, notes, and snippets.

@rsepassi
rsepassi / gist:4446280
Last active December 10, 2015 14:18
Two array sort methods
def sort2(list)
unsorted, sorted = list.dup, []
sorted[0] = unsorted.pop
while unsorted.size > 0
val = unsorted.pop
sorted.each_with_index do |s, i|
if val <= s
sorted.insert(i, val)
break
@rsepassi
rsepassi / robot.rb
Created January 3, 2013 19:41
intro exercise
# Time to complete: 40 minutes
class Robot
attr_accessor :position, :items, :health, :equipped_weapon
def initialize
@position = [0,0]
@items = []
@health = 100
end
@rsepassi
rsepassi / Students_and_Courses.rb
Last active December 10, 2015 20:48
Ryan's comments for (Ketabchi-Oleinikov)
class Student
attr_reader :first_name, :last_name, :courses_enrolled
def initialize(first_name, last_name)
@first_name = first_name
@last_name = last_name
@courses_enrolled = []
end
def name
class KnightsPath
def initialize(start, finish)
@start = convert_chess_position(start)
@finish = convert_chess_position(finish)
@queue = [KnightNode.new(@start, nil)]
end
def find_path
past_moves = []
@rsepassi
rsepassi / template.rb
Last active December 14, 2015 10:48
Simple rails template
devise = yes?("Devise? ")
cancan = yes?("Cancan? ")
omniauth = yes?("Omniauth? ")
foundation = yes?("Foundation? ")
bootstrap = foundation ? false : yes?("Bootstrap? ")
ember = yes?("Ember? ")
handlebars = ember ? false : yes?("Handlebars? ")
underscore = yes?("Underscore? ")
homecontroller = yes?("Home Controller with index page? ")
github = yes?("GitHub create and push? ")
@rsepassi
rsepassi / JitBitSQLAnswers.sql
Created June 9, 2013 14:42
JitBit SQL Interview Questions Answered
-- JitBit SQL Interview Questions (Posted on Hacker News)
-- http://www.jitbit.com/news/181-jitbits-sql-interview-questions/?utm_source=hackernewsletter&utm_medium=email
-- Schema:
-- employees table
-- EmployeeID
-- DepartmentID
-- BossID
-- Name
-- Salary
@rsepassi
rsepassi / grading_script.rb
Last active December 23, 2015 18:38
RSpec Assessment Scorer
# Will run rake in each folder, check how
# many specs failed, and output scores
# (passed specs of total specs) into
# 'final_grades.txt' along with a note if
# 'rake' errored out.
#
#
# Expectations:
#
# Single folder that contains one folder
@rsepassi
rsepassi / rspec.md
Created September 25, 2013 18:15
RSpec Outline

RSpec

Day 1: Testing Models + API

  • RSpec

Project Requirements

  • Associations + validations
  • Scopes
https://www.dropbox.com/s/2xuy5mhoqaxagbe/Drivers%20license.jpg
@rsepassi
rsepassi / autoreload_startup.ipy
Created May 8, 2014 19:23
Setup autoreload in iPython
%load_ext autoreload
%autoreload 2
# Exclude autoimports
%aimport -np
%aimport -pd
%aimport -sp
%aimport -sklearn
%aimport -skimage
%aimport -mpl