This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<title>Create or test Firebase tokens - by katowulf</title> | |
<script type="text/javascript" src="https:////cdnjs.cloudflare.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script> | |
<script type="text/javascript" src="https://static.firebase.com/v0/firebase.js"></script> | |
<script type="text/javascript" src="https://cdn.firebase.com/v0/firebase-token-generator.js"></script> | |
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.4.0/moment.min.js"></script> | |
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Base64/0.2.0/base64.min.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server.log("Agent started, URL is " + http.agenturl()); | |
//------------------------------------------------------------------------------------------------------------------------------ | |
program <- null; | |
html <- @"<HTML> | |
<BODY> | |
<form method='POST' enctype='multipart/form-data'> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ----------------------------------------------------------------------------- | |
// USB Host Shield pinouts | |
// | |
// 1- CS (not sure if it's active high/low) | |
// 2- MISO | |
// 5- SCLK | |
// 7- MOSI | |
// 8- RESET (also not sure about active high/low) | |
// 9- Interrupt (not sure if this is useful for anything) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ------------------------------------------------------------------------ | |
// Takes a string, renders it and sends it to the device for display | |
text <- null; | |
function displayText(_text) { | |
device.send("text", _text); | |
text = _text; | |
} | |
// ------------------------------------------------------------------------ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HTTPRetry.get("http://icanhazip.com").sendasync(function(res) { | |
if (res.statuscode == 200) { | |
server.log(res.body); | |
} else { | |
server.log("Error: " + res.statuscode); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ----------------------------------------------------------------------------- | |
class HTTPPlus { | |
_http = null; | |
// ......................................................................... | |
// Keep a copy of the original http object for internal use | |
constructor() { | |
_http = http; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function number_format(num, decimals=null, separator=",") { | |
// Fix the decimals | |
if (decimals == null) { | |
if (typeof num == "string") decimals = 0; | |
else if (typeof num == "integer") decimals = 0; | |
else if (typeof num == "float") decimals = 2; | |
else return num; | |
} | |
// Check we have a number or convert to one if required | |
if (typeof num == "string") { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ----------------------------------------------------------------------------- | |
const html = @" | |
<!DOCTYPE html> | |
<html lang='en'> | |
<head> | |
<meta charset='utf-8'> | |
<meta http-equiv='X-UA-Compatible' content='IE=edge'> | |
<meta name='viewport' content='width=device-width, initial-scale=1'> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//------------------------------------------------------------------------------------------------ | |
const CALENDAR_URL = "http://devious-dorris.gopagoda.com/meeting_minder"; | |
const REFRESH_TIME = 60; // Once a minute | |
SESSION_TOKEN <- "token" in server.load() ? server.load().token : ""; | |
// server.log(SESSION_TOKEN); | |
function check_calendar(reschedule = true) { | |
local headers = {}; | |
headers["X-GCal-Session-Token"] <- SESSION_TOKEN; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Environmental Sensor Tail Firmware | |
* Ambient Light Sensor: APDS-9007-020 (http://www.avagotech.com/docs/AV02-0512EN) | |
* Air Pressure Sensor: LPS25HTR (http://www.st.com/web/en/resource/technical/document/datasheet/DM00066332.pdf) | |
* Humidity/Temp Sensor: SI7020-A10-GMR (http://www.silabs.com/Support%20Documents/TechnicalDocs/Si7020.pdf) | |
*/ | |
const LPS25H_ADDR = 0xB8; // 8-bit I2C Student Address for LPS25HTR | |
const SI7020_ADDR = 0x80; // 8-bit I2C Student Address for SI7020 | |
const ALS_RLOAD = 47000.0; // load resistor value on ALS | |
const READING_INTERVAL = 3; // seconds between readings |