Skip to content

Instantly share code, notes, and snippets.

# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
<select name="state">
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="DC">District Of Columbia</option>
@kareemgrant
kareemgrant / rails_crud_operations.rb
Last active August 29, 2015 14:23
Rails CRUD Operations
## Rails CRUD Operations
### Goals
1. Implement all the basic CRUD Operations (7 actions) for a Rails resource
### Assignment
***This homework assignment requires that you build upon your existing blog app (from the prior homework assignment)***
In the last homework assignment you were tasked with implementing both an index and show action for the posts resource. During this assignment you will do the following:
class Scrabble
attr_reader :word
def initialize(word)
@word = word
end
def score
letters = word.upcase.split('')
class WordCounter
attr_reader :words, :frequency
def initialize(content)
@words = content.downcase.gsub(/[.,]/, '').split(' ')
end
def count
word_frequency = Hash.new(0)

Displaying Database Data in your Sinatra Application

Goals

  1. Understand how you can take information from your database and display it to your users

  2. Create a has_many relationship in your application

Assignment

#1) Create a Robot class
#2) add an initialize method that accepts
## one attribute "name"
#3) Add reader and writer methods (long way)
#4) Add a talk method that has the robot say its name
#5) Create 3 robots, larry, curly and moe
#6) Change curly's name to "shemp"
class Robot
attr_accessor :name
require 'benchmark'
numbers = (1..9999).to_a.shuffle << 9999
def find_duplicate_hash_store(numbers_array)
checked_numbers = {}
numbers_array.each do |number|
return number if checked_numbers[number] != nil
checked_numbers[number] = number
# Given an array of n numbers with exactly one duplicate, write a program that finds the duplicate number in an efficient manner
require 'minitest/autorun'
def find_duplicate(numbers_array)
# using an hash as a way to keep track of evaluted numbers
checked_numbers = {}
# Given an array of n numbers with exactly one duplicate, write a program that finds the duplicate number in an efficient manner
require 'minitest/autorun'
def find_duplicate(numbers_array)
# using an array as a way to keep track of evaluted numbers
checked_numbers = []