Skip to content

Instantly share code, notes, and snippets.

View TheRyanBurke's full-sized avatar

Ryan Burke TheRyanBurke

View GitHub Profile
public class ByteUtil {
/* ========================= */
/* "primitive type --> byte[] data" Methods */
/* ========================= */
public static byte[] toByta(byte data) {
return new byte[]{data};
}
@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) {
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 / 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" />
@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 / 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 / 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 / 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;