Skip to content

Instantly share code, notes, and snippets.

@davidvandusen
davidvandusen / get-user-1.txt
Last active April 8, 2018 02:21
REST Lecutre Notes
GET /users/1.json HTTP/1.1
@davidvandusen
davidvandusen / actions.rb
Created April 23, 2015 03:55
Breakout on JS, jQuery, and JSON
get '/' do
# @visitor_name = params[:name]
erb :index
end
get '/challenges' do
# go to database and get challenges
# challenges = Challenge.all.order('progress DESC').to_json
challenges = [{
id: 1,
@davidvandusen
davidvandusen / mixin.js
Created April 21, 2015 18:14
W8D2 Lecture Notes
//function example() {
// console.log(arguments);
//}
//
//example('hi', 'my', 'name', 'is');
function mixin() {
var dest = {};
//var sources = Array.prototype.slice.call(arguments, 0); // Not necessary anymore
class Bee < ActiveRecord::Base
belongs_to :hive
end
# Homepage (Root path)
get '/' do
@visitor_name = params[:name]
erb :index
end
get '/users' do
# @users = User.all
@users = [{
username: 'Big Bill',
@davidvandusen
davidvandusen / search-city.html
Created April 9, 2015 00:06
City autocomplete.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="bower_components/jquery-ui/themes/smoothness/jquery-ui.css"/>
</head>
<body>
<input id="city-input" placeholder="type yo city"/>
<script src="bower_components/jquery/dist/jquery.js"></script>
@davidvandusen
davidvandusen / designpatterns.rb
Created April 8, 2015 00:27
W2D2 Breakout Notes
class StaticClass
def self.do_thing
puts "I'm doing a thing"
end
def initialize
raise 'You cannot instantiate me!'
end
@davidvandusen
davidvandusen / console.txt
Created April 6, 2015 18:49
W6D1 Lecture Notes
david:~ david$ node
> charlie;
ReferenceError: charlie is not defined
at repl:1:1
at REPLServer.defaultEval (repl.js:132:27)
at bound (domain.js:254:14)
at REPLServer.runBound [as eval] (domain.js:267:12)
at REPLServer.<anonymous> (repl.js:279:12)
at REPLServer.emit (events.js:107:17)
at REPLServer.Interface._onLine (readline.js:214:10)
@davidvandusen
davidvandusen / seeds.rb
Created April 2, 2015 18:28
A seeds.rb file that uses Faker to generate random blog content.
if Rails.env.development?
users = []
posts = []
comments = []
500.times do |i|
users << User.create(name: Faker::Name.name)
end
# 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)