Skip to content

Instantly share code, notes, and snippets.

View fanktom's full-sized avatar

Thomas Fankhauser fanktom

View GitHub Profile
@fanktom
fanktom / gist:3772800
Created September 23, 2012 19:46
Scales API Update
# HTML Update URLs
Scales.update "/", "/tracks", "/overview", :format => :html
# XML Update URLs
Scales.update "/tracks.xml", "/overview.xml", :format => :xml
# JSON Update URLs
Scales.update "/tracks.json", "/overview.json", :format => :json
@fanktom
fanktom / gist:3772781
Created September 23, 2012 19:39
Scales API Push
@html = "<html><head></head><body><p>Hello World</p></body></html>"
@xml = "<tracks><track><name>Islandary</name><artist>Thomas Fankhauser</artist></track></tracks>"
@json = '[{ name : "Islandary", artist : "Thomas Fankhauser" }]'
# Push a HTML
Scales.push :html => @html, :to => "/hello"
# Push a XML
Scales.push :xml => @xml, :to => "/hello.xml"
@fanktom
fanktom / gist:3763687
Created September 21, 2012 20:21
ScaleUp File
require 'scales/up/rails'
desc "Scale up the cache"
Scales::Up.new do |scales|
# Stylesheets
scales.push :css, :to => "/assets/application.css?body=1"
scales.push :css, :to => "/assets/scaffolds.css?body=1"
scales.push :css, :to => "/assets/tracks.css?body=1"
@fanktom
fanktom / gist:3763651
Created September 21, 2012 20:15
Scaled Rails Controller
class TracksController < ApplicationController
# GET /tracks
def index
@tracks = Track.all
Scales.push :html => render("index"), :to => "/tracks"
end
# GET /tracks/1
def show
@fanktom
fanktom / gist:3763637
Created September 21, 2012 20:13
Normal Rails Controller
class TracksController < ApplicationController
# GET /tracks
def index
@tracks = Track.all
render "index"
end
# GET /tracks/1
def show
@fanktom
fanktom / timeout.rb
Created August 7, 2012 09:03
Goliath API with_api call succeeding although it shouldn't
require 'goliath'
require 'eventmachine'
require 'em-synchrony'
require 'em-synchrony/em-hiredis'
class Server < Goliath::API
def response(env)
@redis = EM::Hiredis.connect
@redis.brpop "waiting_for_ever", 0

Keybase proof

I hereby claim:

  • I am southdesign on github.
  • I am southdesign (https://keybase.io/southdesign) on keybase.
  • I have a public key whose fingerprint is B581 C015 C0D0 1ACC 27D1 5C39 2938 CD41 F64B D505

To claim this, I am signing this object:

@fanktom
fanktom / randomize.sql
Created June 21, 2012 19:46
Social Database Simulation
/* Create Database */
DROP SCHEMA IF EXISTS `limits`;
CREATE SCHEMA `limits`;
USE `limits`;
/* Create Tables */
DROP TABLE IF EXISTS `limits`.`users`;
DROP TABLE IF EXISTS `limits`.`friends`;
DROP TABLE IF EXISTS `limits`.`statuses`;