George Ornbo shapeshed

View Messages per minute
1 2 3 4 5 6 7 8 9 10
var map = function () {
if (this.event === 'user message') {
var datetime = new Date(this.timestamp);
var created_at_minute = new Date(datetime.getFullYear(),
datetime.getMonth(),
datetime.getDate(),
datetime.getHours(),
datetime.getMinutes());
emit(created_at_minute, {count: 1});
}
View gist:5780590
1 2 3 4 5 6 7 8 9 10
git rev-parse HEAD
8ae08b436531503aef7ddd82cb21641ecc55d78f
 
vagrant up
 
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'precise64'...
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
View rest.md

REST Workshop

What is REST?

  • Roy Fielding
  • HTTP
  • Distributed data
  • Web APIs (GitHub, Twitter etc)

tl;dr

View gist:5433860
1 2 3 4 5 6 7 8 9 10
#!/bin/sh
 
cd /usr/local/share
wget https://phantomjs.googlecode.com/files/phantomjs-1.9.0-linux-i686.tar.bz2
tar -xjf /usr/local/share/phantomjs-1.9.0-linux-i686.tar.bz2
sudo ln -sf /usr/local/share/phantomjs-1.9.0-linux-i686/bin/phantomjs /usr/local/bin/phantomjs
git clone git://github.com/n1k0/casperjs.git /usr/local/src/casperjs
cd /usr/local/src/casperjs
git checkout tags/1.0.2
ln -sf /usr/local/src/casperjs/bin/casperjs /usr/local/bin/casperjs
View REST convention
1 2 3 4 5 6
GET /users -> index
GET /users/new -> new
POST /users -> create
GET /users/:user -> show
PUT /users/:user -> update
DELETE /users/:user -> destroy
View homebrew.mxcl.bitlbee.plist
1 2 3 4 5 6 7 8 9 10
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>homebrew.mxcl.bitlbee</string>
<key>KeepAlive</key>
<true/>
<key>ProgramArguments</key>
<array>
View base.pp
1 2 3 4 5 6 7 8 9 10
apt::source { 'nodejs':
location => 'http://ppa.launchpad.net/chris-lea/node.js/ubuntu',
repos => 'main',
key => 'C7917B12',
key_server => 'keyserver.ubuntu.com',
notify => [Package['nodejs'], Package['npm']],
}
 
apt::source { 'redis-server':
location => 'http://ppa.launchpad.net/chris-lea/redis-server/ubuntu',
View gist:5115387
1 2 3 4 5 6 7 8 9 10
server {
listen 80;
server_name www.shapeshed.com;
rewrite ^/(.*) http://shapeshed.com/$1 permanent;
}
 
server {
if ($host != 'shapeshed.com' ) {
rewrite ^/(.*) http://shapeshed.com/$1 permanent;
}
View gist:5115385
1 2 3 4 5 6 7 8 9
 
user www-data;
worker_processes 4;
worker_priority -5;
worker_rlimit_nofile 2048;
timer_resolution 100ms;
 
error_log /var/log/nginx/error.log crit;
pid /var/run/nginx.pid;
View queue.js
1 2 3 4 5 6 7 8 9 10
var amqp = require('amqp');
 
var connection = amqp.createConnection({});
 
connection.on('ready', function () {
 
'use strict';
 
connection.exchange('chat', {type: 'topic'}, function(exchange) {
connection.queue( 'users', function (queue) {
Something went wrong with that request. Please try again.