- Everything as a service
- Test it!
- Problem statement: Testing a server/client HTTP API
- Good plan:
- Create API
- Build client lib that can be used in confusmer apps
- Make it easy for consumer apps to test w/ our client library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config :logger, :console, | |
format: "time=$dateT$timeZ level=$level $metadata$message\n", | |
metadata: [:request_id], | |
utc_log: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# HaveFilter matchers for RSpec | |
# save as: spec/support/have_filter.rb | |
# | |
# class HomeController < ApplicationController | |
# before_filter :require_user, :except => [:action_1, :action_2] | |
# ... | |
# end | |
# | |
# describe HomeController do | |
# it { should have_before_filter(:require_user).except(:action_1, :action_2) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$LOAD_PATH.unshift(File.dirname(__FILE__)) | |
require 'midi-winmm' | |
# tested with midi-winmm, but I assume will work with alsa-rawmidi | |
class Numeric | |
def to_hex_str | |
"%02x" % self | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Usage: | |
# | |
# ./ack.rb your-query | |
require 'rubygems' | |
require 'bundler' | |
if query = ARGV[0] | |
gem_dirs = Bundler.load.specs.map(&:full_gem_path).join(' ') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
s = "Blah \xe9 blah 헌글" | |
puts "BEFORE" | |
puts "encoding: #{s.encoding}" | |
puts "valid : #{s.valid_encoding?}" | |
puts "text : #{s}" | |
s = s. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rescue_from = {} | |
# Associate status code with an HTTP status code. First argument is the status | |
# code, second argument is a function that accepts the XHR object. For example: | |
# $.rescueFrom 404, (xhr)-> alert("Oh no, page not found!") | |
$.rescueFrom = (status, fn)-> | |
rescue_from[status] = fn | |
# Default handling for unsuccessulf HTTP status code. Finds and calls most | |
# appropriate handler based on the HTTP status code (see `$.rescueFrom`). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'psych' | |
class MyEmitter < Psych::Visitors::Emitter | |
end | |
o = "hello world" | |
visitor = Psych::Visitors::YAMLTree.new {} | |
visitor << o | |
my_emitter = MyEmitter.new $stdout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- title "#{@game.name}" | |
%h1= yield(:title) | |
#documents | |
= form_tag(assessment_game_documents_path(@game)) do | |
%ul | |
%script{ type: "text/x-handlebars" } | |
{{#collection Game.DocumentsCollectionView contentBinding="Game.documentsController"}} | |
%li {{content.name}} | |
{{/collection}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rails new foo | |
create | |
create README.rdoc | |
... | |
~$ cd foo | |
~/foo$ git init | |
Initialized empty Git repository in /Users/atmos/foo/.git/ | |
~/foo$ git add . | |
~/foo$ git commit -m "initial import" | |
[master (root-commit) c3392c9] initial import |
OlderNewer