Skip to content

Instantly share code, notes, and snippets.

@vuongngo
vuongngo / .cc
Last active August 3, 2017 23:39
Arduino Temperature Light
#include <OneWire.h>
int Temp_Pin = 2;
int outputPins[] = {10, 11, 12};
OneWire ds(Temp_Pin);
void setup() {
Serial.begin(9600);
for (int i = 0; i < 3; i++) {
#include <OneWire.h>
/**
* Get temperature
* And communicate through zbee S1
* On Arduino Leonardo
*/
int Temp_Pin = 2;
int outputPins[] = {10, 11, 12};
var SerialPort = require('serialport');
const Readline = SerialPort.parsers.Readline;
try {
var port = new SerialPort('/dev/ttyUSB0'); // default port for Zbee Explorer
// As I sent line separation message
const parser = new Readline();
port.pipe(parser);
var awsIot = require('aws-iot-device-sdk');
var device = awsIot.device({
keyPath: "./private.key",
certPath: "./cert.pem",
caPath: "./root-CA.crt",
clientId: "name-of-thing",
host: "https-endpoint",
});
'use strict';
const v4 = require('aws-signature-v4');
const crypto = require('crypto');
exports.handler = (event, context, callback) => {
const url = v4.createPresignedURL(
'GET',
process.env.IOT_ENDPOINT_HOST.toLowerCase(),
'/mqtt',
import mqtt from 'mqtt';
export function mqclient(options) {
return new Promise((resolve, reject) => {
fetch('https://your-lambda-endpoint', {
method: 'get'
}).then((response) => {
const client = mqtt.connect(response.body.url, options);
resolve(client);
}).catch(err => reject(err));
function (user, context, callback) {
var namespace = 'your_domain';
context.idToken[namespace + 'app_metadata'] = user.app_metadata;
context.idToken[namespace + 'user_metadata'] = user.user_metadata;
callback(null, user, context);
}
import React, { Component } from 'react';
import HighCharts from 'highcharts';
export default class Chart extends Component {
componentDidMount() {
if (this.props.modules) {
this.props.modules.forEach(module => {
module(HighCharts);
});
}
package model
import (
"net/http"
"time"
"github.com/mholt/binding"
"gopkg.in/mgo.v2/bson"
)
package db
import (
"errors"
"gopkg.in/mgo.v2"
)
/*
Mongo construction