Skip to content

Instantly share code, notes, and snippets.

@mahees
mahees / iot-update-handler.js
Created April 11, 2020 12:29
aws lambda iot-update-handler signed s3 update file
'use strict';
var AWS = require('aws-sdk');
AWS.config.update({
accessKeyId: process.env.S3_ACCESS_KEY_ID,
secretAccessKey: process.env.S3_ACCESS_KEY_SECRET,
region: 'us-east-1'
});
@mahees
mahees / tax-calculator-breakdowns-brackets.js
Created July 18, 2019 03:49
tax-calculator-breakdowns-brackets
'use strict';
const personalAllowance = 25000;
const calculateTaxes = (taxBrackets, taxableAllowance) => {
const taxInfo = taxBrackets.reduce(
(accumulator, taxBracket) => {
if (accumulator.remainingAmountToBeTaxed <= 0) {
return accumulator;
}
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <ESP8266httpUpdate.h>
#define USE_SERIAL Serial
#define SKETCH_NAME "app222le112122"
//#define LAMBDA_URL "https://xxxx.execute-api.us-east-1.amazonaws.com/prod/iot-update-handler"
//#define SSL_SIGNATURE "xx xx xx ... xx"
@mahees
mahees / google-assistant-ifttt-maker-webhook-awslambda-mqtt.js
Created November 15, 2017 04:31
converts web calls to mqtt calls. im using this with aws lambda (as its cheap) and i dont have a dedicated server.google-assistant-ifttt-maker-webhook-awslambda-mqtt
'use strict';
//lambda endpoint - https://xxxxxxx.execute-api.us-east-1.amazonaws.com/prod/whatever-you-call-it?text={{TextField}}&time={{CreatedAt}}
//https://github.com/pmorjan/paho-node
/*
git clone https://github.com/pmorjan/paho-node.git
cd paho-node
npm install
wget https://raw.githubusercontent.com/eclipse/paho.mqtt.javascript/v1.0.2/src/mqttws31.js
@mahees
mahees / google-assistant-ifttt-maker-webhook-awslambda-mqtt.js
Created November 15, 2017 04:31
converts web calls to mqtt calls. im using this with aws lambda (as its cheap) and i dont have a dedicated server.google-assistant-ifttt-maker-webhook-awslambda-mqtt
'use strict';
//lambda endpoint - https://xxxxxxx.execute-api.us-east-1.amazonaws.com/prod/whatever-you-call-it?text={{TextField}}&time={{CreatedAt}}
//https://github.com/pmorjan/paho-node
/*
git clone https://github.com/pmorjan/paho-node.git
cd paho-node
npm install
wget https://raw.githubusercontent.com/eclipse/paho.mqtt.javascript/v1.0.2/src/mqttws31.js
@mahees
mahees / trinidad-tobago-cities.json
Created October 20, 2017 16:53
Cities in Trinidad and Tobago json
{
"cities": [
"Aquat Village",
"Arima",
"Arnos Vale",
"Aranguez",
"Arouca",
"Auzonville",
"Avocat",
"Blanchisseuse beach",
@mahees
mahees / bus-routes.json
Created October 26, 2015 03:03 — forked from jasonals/bus-routes.json
Barbados's public transportation
[
{
"busId": "1",
"routeId": "",
"name": "Princess Alice Terminal to Speightstown Terminal",
"num": "1",
"stops": []
},
{
"busId": "2",