Skip to content

Instantly share code, notes, and snippets.

#Array#map calls the passed block once for each element of the array it was called on.
#It creates and return a new array containing the new values.
#Array#inject combines each element of an enumerator by applying the operation specified in the attached block or
#represented by an operator/method symbol (like +, -, /). If a block is specified, the block is passed an accumulator value
#and the individual element. It then returns the value of memo.
#Array#select returns a new array containing all the elements of the passed array for which the passed block is true.
class Array
@ayoformayo
ayoformayo / reflect_on_learning.rb
Created June 9, 2013 19:51
REFLECT ON LEARNING FOR THE WINNNNNNNNN
#List 10 topics
#1. Recursion
#2. Pairing effectively
#3. Benchmarking
#4. Using Regex
#5. Using the zip method.
#6. When to use destructive methods effectively
#7. Loops- each, while, unless
#8. Using yield
#9. Writing in pseudocode.
# row coordinate logic
ROW_1 = MY_BOARD[0]
ROW_2 = MY_BOARD[1]
ROW_3 = MY_BOARD[2]
ROW_4 = MY_BOARD[3]
ROW_5 = MY_BOARD[4]
ROW_6 = MY_BOARD[5]
ROW_7 = MY_BOARD[6]
ROW_8 = MY_BOARD[7]
@ayoformayo
ayoformayo / racer_utils.rb
Created June 10, 2013 03:48
This is the revamped edition of ruby Racer.
class Die
def initialize(sides = 6)
@sides = sides
end
# Remember: rand(N) randomly returns one of N consecutive integers, starting at 0
# So rand(N) returns a random integer in (0..N-1)
# And 1 + rand(N) returns a random integer in (1..N)
# See: http://www.ruby-doc.org/core-1.9.3/Kernel.html#method-i-rand
def roll
class TreeGrove
def initialize(array)
end
def age!
p "Hello!"
end
def trees
end
@ayoformayo
ayoformayo / flashcards.rb
Created June 14, 2013 21:41
Flashcard App V1 and V2.
require 'csv'
module Flashcard
class Deck
def initialize options = {}
@file = options[:deck] || 'default.csv'
@deck = load_deck
end
def list
#@deck.inject("") {|memo, card| memo + card.front + "\n" }

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.
.container {
/*
If you have a block-level element of a certain width, margin: 0 auto;
will how you center it inside its parent container.
See: http://bluerobot.com/web/css/center1.html
Don't change the container width.
*/
margin: 0 auto;
@ayoformayo
ayoformayo / index.html
Last active December 19, 2015 07:29 — forked from dbc-challenges/index.html
DBC Phase 2 Practice Assessment Part 3
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="http://cdn.jsdelivr.net/normalize/2.1.0/normalize.css">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:100,900">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.0.2/css/font-awesome.min.css">
</head>
@ayoformayo
ayoformayo / zoo.js
Last active December 19, 2015 07:29 — forked from dbc-challenges/zoo.js
var Zoo = {
animals : [],
bipeds : function(){
result = [];
for(i=0; i < this.animals.length; i++){
if(this.animals[i].legs == 2){result.push(this.animals[i]);}
}
return result;
},