Skip to content

Instantly share code, notes, and snippets.

function Comment(author, text){
this.form = "<form id='new_comment'><textarea></textarea><input name='author' id='authorName' type='text'><input type='submit' value='submit' id='submitButton'></form>";
this.author = author;
this.text = text;
};
Comment.prototype.addToPage = function() {
$('#comment_list').append("<li>" + this.text + "<span class='author'>" + this.author + "</span></li>");
$('#new_comment').replaceWith('<button id="new_comment_button">New Comment</button>');
};
function FruitTree(){
this.height = 0;
this.age = 0;
this.fruitCollection = [];
this.dead = false;
}
function Fruit(){}
FruitTree.prototype.grow = function(){
@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;
},
@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>
.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;

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.
@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" }
class TreeGrove
def initialize(array)
end
def age!
p "Hello!"
end
def trees
end
@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
# 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]