Skip to content

Instantly share code, notes, and snippets.

-module(stopwatch_client).
-export([start_timer/0, stop_timer/0, read_timer/0]).
start_timer() ->
stopwatch_server ! {self(), start_timer}.
stop_timer() ->
stopwatch_server ! {self(), stop_timer}.
-module(stopwatch).
-behaviour(gen_server).
%% Server API
-export([start_link/0, stop/0]).
%% Client API
-export([start_timer/0, stop_timer/0, read_timer/0]).
%% gen_server callbacks
-module(echo_server).
-behaviour(gen_server).
%% Server API
-export([start_link/3, stop/1]).
%% Client API
-export([echo/1, assassinate/1]).
%% gen_server callbacks
-module(echo_supervisor).
-behaviour(supervisor).
%% API
-export([start_link/0]).
%% Supervisor callbacks
-export([init/1]).
-define(SERVER, ?MODULE).
@kenpratt
kenpratt / simple_dropbox_operation.rb
Created December 7, 2012 01:23
Testing a very simple Dropbox API scenario and timing the results
ROOT_PATH = File.expand_path(File.join(File.dirname(__FILE__), ".."))
$:.unshift File.join(ROOT_PATH, "vendor", "dropbox-ruby-sdk", "lib")
require "dropbox_sdk"
require "fileutils"
app_key = ENV["DROPBOX_APP_KEY"]
app_secret = ENV["DROPBOX_APP_SECRET"]
auth_key = ENV["DROPBOX_AUTH_KEY"]
auth_secret = ENV["DROPBOX_AUTH_SECRET"]
$ ruby simple_operation.rb
Creating /tmp/hello840: (data)
Fetching metadata for /tmp/hello840: (data)
Uploading /tmp/hello840/tmp.rb: (data)
Fetching metadata for /tmp/hello840/tmp.rb: (data)
Uploading /tmp/hello840/tmp.rb: (data)
Fetching metadata for /tmp/hello840/tmp.rb: (data)
Uploading /tmp/hello840/tmp.rb: (data)
Fetching metadata for /tmp/hello840/tmp.rb: (data)
Fetching metadata for /tmp/hello840: (data)
@kenpratt
kenpratt / gist:4237341
Created December 7, 2012 23:05
Timing simple operations against personal account
$ ruby simple_operation.rb
Creating /tmp/hello446: (data) (404ms)
Fetching metadata for /tmp/hello446: (data) (230ms)
Uploading /tmp/hello446/tmp.rb: (data) (914ms)
Fetching metadata for /tmp/hello446/tmp.rb: (data) (298ms)
Uploading /tmp/hello446/tmp.rb: (data) (860ms)
Fetching metadata for /tmp/hello446/tmp.rb: (data) (259ms)
Uploading /tmp/hello446/tmp.rb: (data) (922ms)
Fetching metadata for /tmp/hello446/tmp.rb: (data) (234ms)
Fetching metadata for /tmp/hello446: (data) (250ms)
@kenpratt
kenpratt / gist:4237342
Created December 7, 2012 23:05
Timing simple operations against production account
$ ruby simple_operation.rb
Creating /tmp/hello185: (data) (2622ms)
Fetching metadata for /tmp/hello185: (data) (1229ms)
Uploading /tmp/hello185/tmp.rb: (data) (4120ms)
Fetching metadata for /tmp/hello185/tmp.rb: (data) (1308ms)
Uploading /tmp/hello185/tmp.rb: (data) (3409ms)
Fetching metadata for /tmp/hello185/tmp.rb: (data) (1254ms)
Uploading /tmp/hello185/tmp.rb: (data) (5276ms)
Fetching metadata for /tmp/hello185/tmp.rb: (data) (1028ms)
Fetching metadata for /tmp/hello185: (data) (1386ms)
@kenpratt
kenpratt / simple_dropbox_operation.rb
Created December 7, 2012 23:07
Script timing simple Dropbox operations
ROOT_PATH = File.expand_path(File.join(File.dirname(__FILE__), ".."))
$:.unshift File.join(ROOT_PATH, "vendor", "dropbox-ruby-sdk", "lib")
require "dropbox_sdk"
require "fileutils"
app_key = ENV["DROPBOX_APP_KEY"]
app_secret = ENV["DROPBOX_APP_SECRET"]
auth_key = ENV["DROPBOX_AUTH_KEY"]
auth_secret = ENV["DROPBOX_AUTH_SECRET"]
var WebSocketServer = require('ws').Server
, wss = new WebSocketServer({port: 8088})
, _ = require("underscore");
var connections = [];
wss.on('connection', function(ws) {
connections.push(ws);
ws.on('message', function(message) {
console.log('received: %s', message);