Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Aruna Tennakoon kakopappa

🏠
Working from home
View GitHub Profile
@kakopappa
kakopappa / onoff.ino
Created May 7, 2021
relay on off example
View onoff.ino
const int RELAY_PIN = 3;
void setup() {
pinMode(RELAY_PIN, OUTPUT);
}
void loop() {
digitalWrite(RELAY_PIN, HIGH);
delay(500);
digitalWrite(RELAY_PIN, LOW);
@kakopappa
kakopappa / ChangeReport.json
Created Mar 29, 2021 — forked from sivar2311/ChangeReport.json
ContactSensor-AlexaJSON
View ChangeReport.json
{
"context": {},
"event": {
"header": {
"messageId": "cedd4af3-a6ce-4e13-9c72-6bed87261eb6",
"namespace": "Alexa",
"name": "ChangeReport",
"payloadVersion": "3"
},
"endpoint": {
@kakopappa
kakopappa / gist:f2a97c449199217e20cc7af688611d80
Last active Oct 3, 2020
How to Encrypt in Flutter and Decrypt in ESP8266
View gist:f2a97c449199217e20cc7af688611d80
Encrypt in Flutter
String encryptDecrypt(String input) {
var key = ['KCQ']; //Can be any chars, and any size array
var output = [];
for(var i = 0; i < input.length; i++) {
var charCode = input.codeUnitAt(i) ^ key[i % key.length].codeUnitAt(0);
output.add(new String.fromCharCode(charCode));
}
View SinricProAirQualitySensor.h
/*
* Copyright (c) 2019 Sinric. All rights reserved.
* Licensed under Creative Commons Attribution-Share Alike (CC BY-SA)
*
* This file is part of the Sinric Pro (https://github.com/sinricpro/)
*/
#ifndef _SINRICAIRQUALITYSENSOR_H_
#define _SINRICAIRQUALITYSENSOR_H_
@kakopappa
kakopappa / app.js
Last active Jul 16, 2020
nodejs sinricpro example
View app.js
const { SinricPro, SinricProActions, raiseEvent, eventNames, SinricProUdp } = require('sinricpro'); // Use require('sinricpro'); if you are using NPM
const appKey = ''; // d89f1***-****-****-****-************
const secretKey = ''; // f44d1d31-1c19-****-****-9bc96c34b5bb-d19f42dd-****-****-****-************
const device1 = ''; // 5d7e7d96069e275ea9******
const device2 = ''; // 5d80ac5713fa175e99******
const deviceId = [device1]
function setPowerState(deviceid, data) {
  console.log(deviceid, data);
@kakopappa
kakopappa / learn.ino
Created Jul 12, 2020
learning example
View learn.ino
#include <Arduino.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(D5, D0); // RX, TX
void start_learning_mode();
void read_ir_signal();
void setup() {
@kakopappa
kakopappa / nginx.conf
Created Dec 20, 2019 — forked from kmjones1979/nginx.conf
This is an example NGINX configuration for the blog: Performing A/B Testing with NGINX - This demonstrates split_clients based routing on an argument named token
View nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;
events { worker_connections 1024; }
http {
default_type text/html;
log_format main '$remote_addr -> $request $status $body_bytes_sent bytes -> $upstream_addr';
access_log /var/log/nginx/access.log main;
View HLW8032.ino
static float Vk=1.88;//分压电阻算出的值
static float Ik=0.25;//根据采样电阻(4mR)算出的值
static uint32_t VParam=0;
static uint32_t VReg=0;
static float V=0;
static uint32_t IParam=0;
static uint32_t IReg=0;
static float I=0;
static uint32_t PParam=0;
@kakopappa
kakopappa / proxy.js
Created Dec 7, 2019
nodejs proxy for IIS Express
View proxy.js
var http = require('http'),
httpProxy = require('http-proxy');
//
// Create a proxy server with custom application logic
//
var proxy = httpProxy.createProxyServer({});
// To modify the proxy connection before data is sent, you can listen
// for the 'proxyReq' event. When the event is fired, you will receive
@kakopappa
kakopappa / javascript classes example
Created Nov 21, 2019
javascript classes example
View javascript classes example
book.js
class Book {
async doSomething() {
console.log("Do something!");
}
constructor() {
this.id = 'id_1';
}
set name(name) {