Skip to content

Instantly share code, notes, and snippets.

View kevinswiber's full-sized avatar
🍄
lizard person

Kevin Swiber kevinswiber

🍄
lizard person
View GitHub Profile
@kevinswiber
kevinswiber / rpc_vs_rest.md
Last active April 11, 2021 16:50
A brief moment of RPC vs. REST.
@kevinswiber
kevinswiber / server-to-server-2.md
Last active September 28, 2015 20:46
Zetta Server-to-Server Protocol DRAFT

Zetta Server-to-Server Protocol (DRAFT)

Table of Contents

1. Overview
2. Establishing a Peer Connection
  2.1 Handshake Request
    2.1.1 Request
 2.1.2 Successful Response
@kevinswiber
kevinswiber / describe-zetta.json
Created April 20, 2015 14:02
Toying around with a Siren description language.
{
"type": "api",
"identifier": "zetta",
"description": "The Zetta IoT API",
"descriptors": [
{
"type": "class",
"identifier": "root",
"description": "The root resource of a Zetta API.",
"descriptors": [
@kevinswiber
kevinswiber / metadata_app.js
Last active August 29, 2015 14:19
Capture metadata from Zetta devices.
var MetadataResource = require('./metadata_resource');
module.exports = function(server) {
var argo = server.httpServer.cloud;
argo.add(MetadataResource, server);
};
@kevinswiber
kevinswiber / zetta-dos.js
Last active August 29, 2015 14:18
Subscribing to all Zetta streams.
var Rx = require('rx');
var zrx = require('zrx');
var siren = require('siren');
var MAX = 10;
var CLOUD = 'http://testing.iot.apigee.net';
var count = 0;
var started = false;
@kevinswiber
kevinswiber / zrx-app.js
Created April 1, 2015 19:22
Interactions with ZRX, Zetta style.
var Rx = require('rx');
var zrx = require('./zrx');
var subject = new Rx.ReplaySubject();
var detroit = zrx()
.load('http://zetta-cloud-2.herokuapp.com')
.server('Detroit')
.subscribe(subject);
@kevinswiber
kevinswiber / zrx-example.js
Created March 24, 2015 23:48
Subscribe to all devices.
var zrx = require('zrx');
zrx()
.load('http://zetta-cloud-2.herokuapp.com')
.servers()
.devices()
.toDevice()
.subscribe(console.log)
@kevinswiber
kevinswiber / download.js
Created January 27, 2015 14:50
Downloading a file with request.
var fs = require('fs');
var request = require('request');
var url = 'https://github.com/joyent/node/archive/v0.10.36.tar.gz';
request(url)
.on('error', function(err) {
console.error('error:', err);
})
.on('response', function(response) {
@kevinswiber
kevinswiber / delegates.rs
Last active August 29, 2015 14:13
Method encapsulation for Rust.
#![allow(unstable)]
#![feature(unboxed_closures)]
fn main() {
let action = Action { f: || { println!("action"); } };
action.call();
let a1 = Action1 { f: |n| { println!("action1: {:?}", n); } };
a1.call(42i32);
@kevinswiber
kevinswiber / node_hello_world.json
Last active August 29, 2015 14:11
Node Marathon Hello World
{
"id": "node-hello-world",
"container": {
"type": "DOCKER",
"docker": {
"image": "kevinswiber/docker-ubuntu-nodejs-hello",
"network": "BRIDGE",
"portMappings": [
{
"containerPort": 3000,