Skip to content

Instantly share code, notes, and snippets.

View azdle's full-sized avatar

Patrick Barrett azdle

View GitHub Profile
@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 / 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();
}

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 / 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",
@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 / 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 / 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 / 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 / appinfo.json
Created November 17, 2013 23:35
Pebble App Message Problem
{
"uuid": "14683333-c12a-451d-ad88-307d8a7e8384",
"shortName": "Test App",
"longName": "Test App",
"companyName": "Me",
"versionCode": 1,
"versionLabel": "0.0.1",
"watchapp": {
"watchface": false
},
@azdle
azdle / nPages.py
Last active December 23, 2015 00:49
PyQt Problem -- Fixed with Help From Ryan Hanson on PyQt Mailing List
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *
pages = [
"https://portals.exosite.com/views/3819798770/3579834479",
"https://portals.exosite.com/views/2562112089/4128069106",
"https://portals.exosite.com/views/2060811893/1760385000",
"https://exosite:AKYQhkDqj4@logs.exosite.com:444"