Skip to content

Instantly share code, notes, and snippets.

View azdle's full-sized avatar

Patrick Barrett azdle

View GitHub Profile
@azdle
azdle / Exosite.agent
Last active August 29, 2015 13:56
A very simple example showing how to use the Electric Imp with Exosite.
// Class for Communication to Exosite - No Need to Edit
class Exosite{
cik = null;
vendor = null;
model = null;
serial = null; // Consider hardware.getimpeeid() or imp.getmacaddress()
constructor(cikp = null, vendorp = null, modelp = null, serialp = null){
if(cikp == null){
server.log("No CIK, need to provision.")
@azdle
azdle / washer_dryer_monitor.ino
Created April 3, 2014 00:43
Monitoring Power with Exosite using an Arduino Yun
//*****************************************************************************
//
// wifi_read_write_string - A Simple read/write to the Exosite Cloud API
// for the Arduino WiFi shield using the
// String library
//
// Copyright (c) 2013 Patrick Barrett - All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@azdle
azdle / coap.erl
Last active August 29, 2015 14:04
CoAP Message Parsing in Erlang
coap(<<Version:2, Type:2, TKL: 4, Code:8, MID:16, Token:TKL/bytes, Tail/bytes>>) when Version =:= 1->
{Options, Payload} = coap_parse_options(Tail),
{coap, {Type, Code, MID, Token, Options, Payload}}.
coap_parse_options(OptionBin) ->
coap_parse_options(OptionBin, 0, []).
coap_parse_options(<<>>, _LastNum, OptionList) ->
{OptionList, <<>>};
coap_parse_options(<<16#FF, Payload/bytes>>, _LastNum, OptionList) ->
@azdle
azdle / Exosite_Weather_Station.ino
Created September 3, 2014 21:19
Exosite Powered Sparkfun Arduino Weather Station
/*
** Exosite Modifcations By Patrick Barrett <patrickbarrett@exosite.com>
** Modified 03-09-2014
**
** Note: This runs on the Arduino Yun, but requires modifications to the libraries,
** provided by Sparkfun, to use software I2C (https://github.com/greiman/DigitalIO)
*/
/*
Based on the work by
@azdle
azdle / example_use.lua
Last active August 29, 2015 14:06
Basic Lua Library for Exosite's JSON RPC API
local exosite = require 'exosite'
local json = require 'dkjson'
local exo = exosite.rpc:new{cik = "9829879a04efb8f4a1b42e22245739678fd4a94e"}
local status, response = exo:create{
"dataport",
{
format = "float",
name = "Temperature",

Keybase proof

I hereby claim:

  • I am azdle on github.
  • I am psbarrett (https://keybase.io/psbarrett) on keybase.
  • I have a public key whose fingerprint is E520 BFB2 9876 288A D460 4442 58E8 B2F2 D323 B505

To claim this, I am signing this object:

@azdle
azdle / count_all.js
Created April 6, 2015 17:53
Minnebar Vanity Script
var _ = require('underscore'),
async = require('async'),
page = require('webpage').create(),
system = require('system');
if (system.args.length !== 3) {
console.log('Usage: count.js <min_id> <max_id>');
phantom.exit();
}
@azdle
azdle / b64widget.js
Last active August 29, 2015 14:20
Base64 Image in a Widget
// this is an example of using a base64 image in an exosite portals widget
function( container, portal )
{
// this is the actual image, you can generate this string on most
// mac/linux computers by using `base64 image.png` from the command line
var base64_image = "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
// helpful for debugging
console.log('widget refresh');
@azdle
azdle / Agent Code
Last active December 18, 2015 07:59
Exosite Imp Agents Tests Reads respond with error code 52 (CURLE_GOT_NOTHING)
// Class for Communication to Exosite
class Exosite{
//Set CIK Manually Here or
cik = "654a29f2f230a2810a28036f79ab2fef17c058c4";
// Set Provisioning Parameters to Automatically Generate New CIK
vendor = null;
model = null;
serial = null; // Consider hardware.getimpeeid() or imp.getmacaddress()
@azdle
azdle / euler_003.rs
Created June 14, 2013 16:38
Project Euler Problem 3 in Rust using MutList
#!/usr/local/bin/rust run
/**
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
*/
extern mod extra;