Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
class PoppinBottles
def self.run
loop do
print "\nNumber of dollars to invest: $"
input = gets.chomp
begin
dollars = Float(input)
@davidvandusen
davidvandusen / betting-game.js
Last active August 29, 2015 14:16
Betting Game
$(function () {
var MAX_BET = 10;
var MIN_BET = 5;
var MIN_GUESS = 1;
var MAX_GUESS = 10;
var playerMoney = 100;
var randomNumber;
@davidvandusen
davidvandusen / gist:11bbb17c3cbfdcfe4d67
Created March 14, 2015 21:45
JavaScript prototype behaviour
function Thing() {}
//undefined
var t = new Thing();
//undefined
t instanceof Thing
//true
t instanceof Object
//true
Thing.prototype.__proto__
//Object {}
@davidvandusen
davidvandusen / Gemfile
Last active August 29, 2015 14:17
ORM Lecture
gem 'pg'
h1 { color: red; }
p { background: #cdf; border: 5px dashed gold; color: green; margin: 2em; padding: 1em; }
p span { font-style: italic; }
span { background: darkslategray; }
strong { background: yellow; font-weight: normal; }
ul span { text-decoration: underline; }
.subpar { background: hotpink; text-decoration: line-through; }
@davidvandusen
davidvandusen / README.md
Last active August 29, 2015 14:17
W8D1 - Lecture Notes - February 2015

Auth and WebSec

Today we looked at 3rd party authentication and web security.

We built a simple Express.js web app that uses Passport to allow users to sign in with Google.

After that we used Wireshark to snoop on network trafic to that web app to get an authenticated user's session id to make HTTP requests to the app as them.

@davidvandusen
davidvandusen / closures.js
Created March 23, 2015 23:55
JS Closures and Prototypal Inheritance Breakout
var something = 'outer';
var outerSecret = (function () {
for (var i = 10; i--;) {
var mysecretthing = 'shhhhh';
console.log(i + ' ' + something);
}
return mysecretthing;
});
@davidvandusen
davidvandusen / forms.html
Created March 24, 2015 02:06
PT-W2D1 Web forms
<!doctype html>
<html>
<head>
<title>Forms Demo!</title>
</head>
<body>
<h1>Forms Demo!</h1>
<h2>Login</h2>
<form action="/login" method="post">
<p>
@davidvandusen
davidvandusen / w2d2.css
Created March 26, 2015 02:14
W2D2 Mock Book Pro
header {
padding-top: 75px;
}
img {
max-width: 100%;
}
#front-view-img {
margin-top: 30px;
}
# REST Resources
## Articles Resrouce
GET http://example.com/articles
- Gets all the articles (probably HTML)
POST http://example.com/articles
- Creates a new article (the article that was created, e.g. articles/100)
GET http://example.com/articles/99
- Gets article 99 (probably HTML)