Skip to content

Instantly share code, notes, and snippets.

View kakopappa's full-sized avatar
🏠
Working from home

Aruna Tennakoon kakopappa

🏠
Working from home
View GitHub Profile
@kakopappa
kakopappa / perference_with_checkbox.xml
Created April 23, 2019 03:56
android layout example - Perference with checkbox
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/accept_license_block"
android:layout_below="@+id/description_tv"
android:layout_width="fill_parent"
android:layout_height="40dp"
@kakopappa
kakopappa / class import example
Created May 8, 2019 04:49
nodejs class import example
// list.js
class LinkedList {
constructor() {
} // END constructor
myMethod() {
console.log("myMethod");
}
}
@kakopappa
kakopappa / free timestamp server
Created June 24, 2019 03:46
free timestamp server
https://play.googleapis.com/play/log/timestamp
@kakopappa
kakopappa / An external switch circuit:
Created October 2, 2019 03:03
An external switch circuit:
An external switch circuit:
3.3V
--+--
|
+-+
| | 1K ~ 10K
+-+
|
+--> D2 (for ESP8266, ex: GPIO16 in case of ESP32)
|
@kakopappa
kakopappa / letsencrypt_2019.md
Created November 11, 2019 03:33 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

@kakopappa
kakopappa / javascript classes example
Created November 21, 2019 04:41
javascript classes example
book.js
class Book {
async doSomething() {
console.log("Do something!");
}
constructor() {
this.id = 'id_1';
}
set name(name) {
@kakopappa
kakopappa / proxy.js
Created December 7, 2019 19:22
nodejs proxy for IIS Express
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 / HLW8032.ino
Last active December 19, 2019 11:33
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 / nginx.conf
Created December 20, 2019 03:30 — 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
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;
@kakopappa
kakopappa / learn.ino
Created July 12, 2020 03:29
learning example
#include <Arduino.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(D5, D0); // RX, TX
void start_learning_mode();
void read_ir_signal();
void setup() {