Skip to content

Instantly share code, notes, and snippets.

# Continuation - http://www.ruby-doc.org/core-2.1.3/Continuation.html
require 'continuation'
# class Continuity
# def initialize total
# @total = 5
# end
@stujo
stujo / Rakefile
Created October 2, 2014 16:03
Todo Helper Rakefile
desc 'Generate a migration timestamp'
task 'mtimestamp' do
puts Time.now.strftime("%Y%m%d%H%M%S")
end
desc 'Test Drive Code'
task "driver" do
puts "ADD #{`ruby todo.rb add Bake a delicious blueberry-glazed cheesecake`}"
puts "LIST #{`ruby todo.rb list`}"
@stujo
stujo / clicker.html
Created October 13, 2014 03:58
javascript-event-demos-clicker
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.1/normalize.min.css">
<style>
body
{
margin: 0 40px;
}
h4 { margin-top: 5px }
@stujo
stujo / clock.html
Created October 13, 2014 03:58
javascript-event-demos-clock
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.1/normalize.min.css">
<style>
body
{
margin: 0 40px;
}
h4 { margin-top: 5px }
@stujo
stujo / closure_clock.html
Created October 13, 2014 03:58
javascript-event-demos-closure-clock
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.1/normalize.min.css">
<style>
body
{
margin: 0 40px;
}
h4 { margin-top: 5px }
@stujo
stujo / event-driven-programming.md
Last active August 29, 2015 14:07
JavaScript Event Driven Programming

#Event Driven Programming

#Overview

#First-class nature of functions

@stujo
stujo / app.js
Last active August 29, 2015 14:07
JavaScript Racing Game
function App(playerCount, numSpaces) {
this._boardView = new BoardView('#board_container');
this._historyView = new HistoryView('#history_container');
this._graphView = new GraphView('#distribution_container');
this._playerCount = playerCount;
this._numSpaces = numSpaces;
this._history = [];
}
App.prototype = {
@stujo
stujo / app.rb
Last active August 29, 2015 14:07
Mini Ajax Sinatra Example - A single file demonstrating Ajax with HTML Fallback
require 'sinatra'
require "sinatra/json"
def eight_ball
[
"Definitely",
"Most likely",
"Try again",
"Cannot predict now",
"Don't count on it",
@stujo
stujo / movies_api_single_file.rb
Created October 17, 2014 22:46
OMDBAPI Single File Example
require 'sinatra'
require 'typhoeus'
require 'json'
OMDBAPI_URL = 'http://www.omdbapi.com/'
def search_movies(search_string)
body = JSON.parse(Typhoeus.get(OMDBAPI_URL, params: {s: search_string} ).body)
body['Search']
end
@stujo
stujo / index.erb
Last active August 29, 2015 14:07
Simple Sinatra REST API with Active Record - Pet World
<h1>Pet World</h1>
<div id="petworld_container"></div>
<div class="modal fade" id="modal_placeholder" tabindex="-1" role="dialog" aria-labelledby="basicModal" aria-hidden="true">
<a href="#" id="show-modal">Show Modal</a>
<script id="owner-form-modal-template" type="text/template">