Skip to content

Instantly share code, notes, and snippets.

View brookr's full-sized avatar
💭
🚀

Brook Riggio brookr

💭
🚀
View GitHub Profile
@brookr
brookr / deck-o-cards.html
Last active August 27, 2015 01:19
Example shuffle algo in jQuery
<!doctype html>
<html>
<head>
<title>
Deck of Cards
</title>
<style>
body {
font-family: arial;
}
<script>
var random, result;
var findDifference = function(answer, guess) {
if (answer > guess) {
return answer - guess;
}
else {
return guess - answer;
}
}
<script>
var usa, ghana, portugal, germany, miles;
function Racer(name, speed, intelligence, luck) {
this.name = name;
this.speed = speed;
this.intelligence = intelligence;
this.luck = luck;
this.position = 0;
this.race = function() {
@brookr
brookr / cards.html
Created June 12, 2014 05:23
Example code from in-class live coding of a deck of cards
<script>
function Deck() {
this.cards = [];
this.count = function() {
return this.cards.length;
}
this.init = function() {
for (s = 1; s <= 4; s++) {
for (r = 1; r <= 13; r++) {
this.cards.push(new Card(r, s));
@brookr
brookr / deck.html
Created September 17, 2014 06:30
A deck of cards, modelled in HTML and JS
<!doctype html>
<html>
<head>
<title>
Deck of Cards
</title>
</head>
<body>
<ul id="deck" class="collection">
</ul>
@brookr
brookr / listking.html
Created September 18, 2014 06:57
Demo code from Class 5
<!DOCTYPE html>
<html>
<head>
<title>JavaScript &amp; jQuery - Chapter 7: Introducing jQuery - Looping</title>
<link rel="stylesheet" href="css/c07.css" />
</head>
<body>
<div id="page">
<h1 id="header">List</h1>
<h2>Buy groceries</h2>
@brookr
brookr / deck.html
Last active August 29, 2015 14:06
A visualization of shuffling a deck of cards
<!doctype html>
<html>
<head>
<title>
Deck of Cards
</title>
<style>
#deck {
width: 52em;
background-color: purple;
@brookr
brookr / gemstore.html
Created October 27, 2014 04:24
Sharpen up with AngularJS skeleton
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular.min.js"></script>
@brookr
brookr / serve.sh
Created October 27, 2014 04:39
serve function
function serve {
port="${1:-4000}"
ruby -r webrick -e "s = WEBrick::HTTPServer.new(:Port => $port, :DocumentRoot => Dir.pwd); trap('INT') { s.shutdown }; s.start"
}
@brookr
brookr / bst.coffee
Last active August 29, 2015 14:08 — forked from philwilt/bst
class BinarySearchTree
constructor: () ->
@val = null
@size = 0
@right = null
@left = null
insert: (val) ->
if @val == val