- Download this application skeleton.
- Convert the app to use AJAX.
- Add any files you changed to your gist and submit your code.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//The Jasmine test. | |
describe("A suite", function() { | |
var addFriendButton; | |
var removeFriendButton; | |
var contacts; | |
beforeEach(function() { | |
addFriendButton = document.createElement("button"); | |
document.body.appendChild(addFriendButton); | |
addFriendButton.setAttribute("id", "addFriendButton"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GuessingGame | |
def initialize(answer) | |
@answer = answer | |
end | |
def guess(guess) | |
@guess = guess | |
if guess > @answer | |
puts "high" | |
return :high |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def numerals_subtraction(int) | |
values = %w(M D C L X V I) | |
roman_num = "" | |
values = {"M" => 1000, "D" => 500, "C" => 100, "L" => 50, "X" => 10, "V" => 5, "I" => 1} | |
values.keys.each do |i| | |
if (int % values[i]) then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
menu_1 = [1, 2.50, 3.50] | |
target_1 = 450 | |
menu_2 = [0.31] | |
target_2 = 450 | |
menu_3 = [2.15, 2.75, 3.35, 3.55, 4.20, 5.80, 6.55] | |
target_3 = 15.05 | |
def knapsack(menu, target, current_price) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def knapsack2(menu, target, steps, next_step) | |
size = menu.size | |
current_price = (0...size).inject(0) {|r, i| r + menu[i]*steps[i]} | |
# File.open("knapsack.txt", 'w') {|f| f.write("menu = #{menu}, target = #{target}, current_price = #{current_price}" + "steps = #{steps}") } | |
if current_price == target | |
return steps | |
elsif current_price > target | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# require 'Math' | |
def is_prime?(num) | |
(2..Math.sqrt(num)).each { |factor| return false if num % factor == 0 } | |
true | |
end | |
def prime_factors(num) | |
primes_hash = {} | |
primes = [] |
- Download this application skeleton.
- Convert the app to use AJAX.
- Add any files you changed to your gist and submit your code.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function () { | |
$('form').submit(function (e) { | |
e.preventDefault(); | |
$.post('/', function(response) { | |
source = response + '.png'; | |
$('#die_pic').attr('src', source); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
OlderNewer