Skip to content

Instantly share code, notes, and snippets.

View cnocon's full-sized avatar
:octocat:
Professionally developing

Cristin O'Connor cnocon

:octocat:
Professionally developing
View GitHub Profile

Instructions:

  1. Download this application skeleton.
  2. Convert the app to use AJAX.
  3. Add any files you changed to your gist and submit your code.
class Car
@@WHEELS = 4
def initialize(args)
@color = args[:color]
@wheels = @@WHEELS
end
def drive
@status = :driving
end
def brake
@cnocon
cnocon / pig_latin.rb
Created January 8, 2014 22:32
pig latin
def pig_latin(word)
if !!(word =~ /\s/)
split_sentence = word.split(' ').map {|w| w.split(//)}
translate_sentence(split_sentence)
else
split_word = word.split(//)
translate_single_word(split_word)
end
end
@cnocon
cnocon / loop.js
Last active December 31, 2015 01:09
wrong!
window.onload= function(){
var styleSet = {
boxShadow: "0 1px 3px rgba(0,0,0,0.5)",
textShadow: "1px 1px #000",
backgroundColor: "lightBlue",
padding: "1em",
margin: "2em 0"
}
@cnocon
cnocon / section_elements.html
Created December 11, 2013 15:04
html for blog post
<!DOCTYPE html>
<html>
<head>
<title>Looping in Javascript</title>
<script async src="blogpost.js"></script>
</head>
<body>
<section>
<h2>Here is our 1st section element.</h2>
</section>
@cnocon
cnocon / styleset.js
Created December 11, 2013 15:04
styleSet object
var styleSet = {
boxShadow: "0 1px 3px rgba(0,0,0,0.5)",
textShadow: "1px 1px #000",
backgroundColor: "lightBlue",
padding: "1em",
margin: "2em 0"
}
@cnocon
cnocon / blogpost.html
Last active December 31, 2015 01:09
Blog post on javascript iteration
<!DOCTYPE html>
<html>
<head>
<title>Looping in Javascript</title>
<script async src="blogpost.js"></script>
</head>
<body>
<section>
<h2>Here is our 1st section element.</h2>
</section>
@cnocon
cnocon / gist:7705368
Created November 29, 2013 12:58
Another look at why it's important to understand what the method you are using is returning and how it works. There are some significant advantages and disadvantages to methods that might generate the same, correct, output for you.
require 'benchmark'
array = (1..900_000).to_a
Benchmark.bmbm do |x|
#reject returns the array without the rejected number, so it has to re-index it without the rejected number
x.report("reject 890,000") { array.reject{|num| num == 890_000}}
x.report("reject 2") { array.dup.reject{|num| num == 2}}
#select goes through whole array no matter what bc it returns all matched elements
x.report("select 890,000") { array.select{|num| num == 890_000}}
x.report("select 2") { array.select{|num| num == 2}}
#detect returns the first match for what's in the block, so the later the match, the longer it will take
@cnocon
cnocon / 0.2.1-boggle_class_from_methods.rb
Last active December 27, 2015 17:29 — forked from dbc-challenges/0.2.1-boggle_class_from_methods.rb
phase 0 unit 2 week 1 boggle class challenge
class BoggleBoard
def initialize (board)
@board=board
end
def create_word(*coords)
puts coords.map { |coord| @board[coord.first][coord.last]}.join("")
end