Skip to content

Instantly share code, notes, and snippets.

View TheRyanBurke's full-sized avatar

Ryan Burke TheRyanBurke

View GitHub Profile
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 {
[
{
"location":"40.1234,-103.9876",
"temperature":50
},
{
"location":"41.1234,-104.9876",
"temperature":100
},
{
@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 / 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 / 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 / 2 controllers
Created May 22, 2011 05:10
how to send param from one method to another
class TeamsController < ApplicationController
def create
@team = Team.new(params[:team])
respond_to do |format|
if @team.save
p "team-controller: #{@team.id}" #Loren: this is showing a value
format.html { redirect_to("/memberships/create", :team_id => @team.id) }#, :notice => 'Team was successfully created.') }
format.xml { render :xml => @team, :status => :created, :location => @team }
else
@TheRyanBurke
TheRyanBurke / vaadin-ipc-liferay.java
Created August 11, 2011 14:35
Vaadin IPC with Liferay add-on
public class DevicesPortlet extends Application implements PortletListener{
LiferayIPC liferayIPC = new LiferayIPC();
@Override
public void init() {
Window mainWindow = new Window("Device Portlet");
setMainWindow(mainWindow);
@TheRyanBurke
TheRyanBurke / UserManagerController.java
Created December 15, 2011 23:38
Coffeescript and Backbone.js impl of a simple Play! Groovy template
public class UserManager extends Controller {
public static void index() {
if (getUser() == null) {
flash.error("Cannot use User Manager - Please log in");
RingDNAController.index();
} else
renderArgs.put(CURRENT_USER, getUser());
List<User> users = getUsersFromOrg();
@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" />
@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)
}