Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Aruna Tennakoon kakopappa

🏠
Working from home
View GitHub Profile
@kakopappa
kakopappa / build-complete.txt
Created Sep 25, 2021 — forked from welshstew/build-complete.txt
Generating and using ssl client certificates for use in an nginx sidecar image
View build-complete.txt
[user@localhost certs]$ oc get builds
NAME TYPE FROM STATUS STARTED DURATION
nodejs-mongo-persistent-1 Source Git@e59fe75 Complete About an hour ago 2m37s
simple-nginx-ssl-reverseproxy-1 Source Git@552932f Complete 16 minutes ago 47s
@kakopappa
kakopappa / wait.ino
Last active Jun 6, 2021
wait example without delay for esp8266/esp32 from Boris. Blame him if there are bugs
View wait.ino
class Wait {
public:
Wait() : next_millis(0) {}
bool operator()(unsigned long wait_millis, bool instant=false) {
unsigned long current_millis = millis();
if (next_millis == 0 && instant==false) next_millis = current_millis + wait_millis;
if (current_millis >= next_millis) {
next_millis = current_millis + wait_millis;
return true;
}
View drape_and_curtain.ino
//#define ENABLE_DEBUG
#ifdef ENABLE_DEBUG
#define DEBUG_ESP_PORT Serial
#define NODEBUG_WEBSOCKETS
#define NDEBUG
#endif
#include <Arduino.h>
#ifdef ESP8266
@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;