Skip to content

Instantly share code, notes, and snippets.

View TheRyanBurke's full-sized avatar

Ryan Burke TheRyanBurke

View GitHub Profile
var sdk = require('aws-iot-device-sdk');
var shadow = sdk.thingShadow({
keyPath: 'certs/private.pem.key',
certPath: 'certs/certificate.pem.crt',
caPath: 'certs/root-CA.crt',
clientId: 'rmb-cid',
region: 'us-east-1'
});
@TheRyanBurke
TheRyanBurke / App.java
Created March 5, 2015 03:56
Java example ThingFabric API interaction
package com.twolemetry.app.sampleapiinterface;
import java.io.IOException;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
@TheRyanBurke
TheRyanBurke / HTML
Created December 29, 2014 17:28
ThingFabric Panel sample with publishing messages
<div>
<button ng-click='publishMsg()'>Publish!</button>
</div>
<div class="stream">
<p ng-show="stream.length===0">Awaiting messages...</p>
<table ng-show="stream.length!==0" class="table table-striped table-nonfluid">
<thead>
<tr>
<th>Timestamp</th>
<th>Message</th>
@TheRyanBurke
TheRyanBurke / gist:f567981a5d7d168b3c4a
Created December 11, 2014 22:11
visualize-lambda-via-thingfabric.js
var request = require('request');
// http://2lemetry.com/2014/11/18/smarter-client-usage-pooling/
var getClientFromPool = function(poolSize, prefix) {
var pick = Math.floor((Math.random() * poolSize) + 1);
prefix = prefix || "client";
var clientId = prefix.concat(pick);
return clientId; // e.g. "client74"
@TheRyanBurke
TheRyanBurke / etl.js
Created November 26, 2014 15:33
Basics of ThingFabric and AWS Lambda
var aws = require('aws-sdk');
var http = require('http');
var s3 = new aws.S3({apiVersion: '2006-03-01'});
exports.handler = function(event, context) {
var bucket = event.Records[0].s3.bucket.name;
var key = event.Records[0].s3.object.key;
s3.getObject({Bucket:bucket, Key:key},
function(err,data) {
if (err) {
[
{
"location":"40.1234,-103.9876",
"temperature":50
},
{
"location":"41.1234,-104.9876",
"temperature":100
},
{
import org.eclipse.paho.client.mqttv3.MqttCallback;
import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.eclipse.paho.client.mqttv3.MqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.eclipse.paho.client.mqttv3.MqttTopic;
public class SimpleMqttClient implements MqttCallback {
@TheRyanBurke
TheRyanBurke / 1.html
Created February 7, 2013 16:30
`npm install socket.io`, `npm install express`, `node app.js` to run
<html>
<head>
<script src="/socket.io/socket.io.js"></script>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
</head>
<body>
<h1>1</h1>
@TheRyanBurke
TheRyanBurke / sample
Last active December 10, 2015 23:09
nested scala classes -> jerkson parse/generate -> store/retrieve in cassandra.io
class Address(street: String, street2: String, city: String, state: String, zip: String) {}
class User(email: String, shippingAddress: Address, billingAddress: Address) {}
def storeUser(user: User) = {
val userjson = jerkson.generate(user)
// put this userjson in cassandra
WS.url(URL + "/" + java.util.UUID.randomUUID()).post(userjson)
}
@TheRyanBurke
TheRyanBurke / example
Created March 6, 2012 15:59
jquery fileupload
offline_tracking.html
---------------------
<script src="@{'/public/js/libs/fileupload/jquery.ui.widget.js'}"></script>
<script src="@{'/public/js/libs/fileupload/jquery.iframe-transport.js'}"></script>
<script src="@{'/public/js/libs/fileupload/jquery.fileupload.js'}"></script>
#{form @APICallScriptController.newCallScript(viewModel.rDnaId), id:'newScriptForm', enctype:'multipart/form-data'}
Script name: <input type="text" id="scriptName" name="name" />
<br />
<input type="file" id="fileupload" name="scriptFile" />