Skip to content

Instantly share code, notes, and snippets.

View tarynsauer's full-sized avatar

Taryn Sauer tarynsauer

  • Madison, WI
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.
/* Here is your chance to take over Socrates!
Spend 10 minutes on each of the following hacks to the socrates website.
Enter them in the console to make sure it works and then save
your results here.
Choose a new pair for each. Add your names to the section you complete.
*/
@tarynsauer
tarynsauer / index.html
Last active December 22, 2015 09:18 — 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>
@tarynsauer
tarynsauer / zoo.js
Last active December 22, 2015 09:19 — forked from dbc-challenges/zoo.js
var Zoo = {
init: function(animals) {
this.animals = animals;
},
bipeds: function(){
return this.animals.filter(function(animal){
return animal.legs === 2;
});
},
@tarynsauer
tarynsauer / form-validator.js
Last active December 22, 2015 09:49 — forked from ksolo/form-validator.js
Form Validation
$(function(){
function isValidEmailAddress(emailAddress) {
var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);
return
@tarynsauer
tarynsauer / carousel.js
Created September 5, 2013 20:35 — forked from ksolo/carousel.js
Image Carousel
@tarynsauer
tarynsauer / carousel.js
Created September 5, 2013 20:53 — forked from ksolo/carousel.js
Image Carousel
def get_best_move
get minmax_score for all_open_positions
return ID of cell with highest score
def get_score(cell, player)
player == curent_player ? 1 : -1
def minimax_score(board, player, cell, depth)
board.add_marker(cell, player.marker)
if board.game_over?
best_score = get_score(board, player)
elsif player.turn == 1
best_score = 999
board.get_free_positions.each_key do |cell1|
board.add_marker(cell1, player.opponent.marker)
score = minimax_score(board, player.opponent, cell1, depth += 1)
score = (score/depth.to_f)
class AI
def computer_move(board, player)
test_board = board.dup
test_board.all_cells = board.all_cells.dup
get_best_move(test_board, player)
end
def get_best_move(board, player)
ranked_moves = rank_possible_moves(board, player)