Skip to content

Instantly share code, notes, and snippets.

@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">
@stujo
stujo / what-is-an-api.md
Created October 20, 2014 16:12
What Is An API?

#What is an API?

#Overview

  • What is an API?
  • Consumption: Omdbapi Example
  • Providing: PetWorld
  • Challenge Prep
  • Review

#What is an API?

@stujo
stujo / movies_api_single_file.rb
Created October 20, 2014 16:13
OMBDAPI Client 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 / Rakefile
Last active August 29, 2015 14:07
Consuming a REST API with Typhoeus
desc "launch the console"
task "console" do
exec 'irb -r ./pwclient.rb'
end
@stujo
stujo / twilio_app.rb
Created October 21, 2014 21:54
dotenv Twilio .env Example
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
from_number = ENV['TWILIO_PHONE_FROM']
to_number = ENV['TWILIO_PHONE_TO']
@stujo
stujo / exception-handling.md
Created October 23, 2014 16:21
Exceptions

#Exception Handling

#Bullet Points

  • raise or fail

#Demo / Live-code Overview

  • Custom StandardError class
  • raise makes RuntimeError with argument as message
@stujo
stujo / javascript-intro.md
Last active August 29, 2015 14:08
JavaScript Intro Notes

#Javascript Intro

#What the Week Looks Like

  • Intro to JavaScript
  • DOM Manipulation
  • Object Oriented JavaScript
  • EventLoop
  • jQuery
  • AJAX
  • MVC in JavaScript
@stujo
stujo / index.html
Last active August 29, 2015 14:08
javascript-sample
<!DOCTYPE html>
<html>
<head>
<title>JSample</title>
<link rel="stylesheet" type="text/css" href="css/jsample.css">
</head>
<body>
<div class="container">