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 / gist:1d660d7bdf3aae1f76aa40fb1d51a9e3
Last active April 7, 2023 10:38
setup tengine with lua
sudo apt-get install build-essential libpcre3 libpcre3-dev libssl-dev libjemalloc-dev libatomic-ops-dev
sudo apt-get install zlib1g-dev libxslt-dev libgd-dev libgeoip-dev
# build lua
git clone https://github.com/openresty/luajit2
make && make install
export LUAJIT_LIB=/usr/lib64;
export LUAJIT_INC=/usr/include/luajit-2.1;
@kakopappa
kakopappa / build_nginx_with_lua.sh
Created April 7, 2023 06:07 — forked from riskiwah/build_nginx_with_lua.sh
A simple script to build nginx with lua support
#!/bin/sh
# Script to build nginx with lua support.
NGINX_VERSION='1.18.0'
NGX_DEVEL_KIT_VERSION='0.3.1'
LUA_NGINX_MODULE_VERSION='0.10.16rc5'
STREAM_LUA_NGINX_MODULE_VERSION='0.0.8rc3'
# we use openresty's version of luajit here.
@kakopappa
kakopappa / build_nginx_with_lua.sh
Last active April 8, 2023 09:39 — forked from kanna5/build_nginx_with_lua.sh
A simple script to build nginx with lua support
#!/bin/sh
# Script to build nginx with lua support.
# XXX: The result might work, but it was not thoroughly tested. Use it at your
# own risk. If you really need nginx with LUA in production, you should use
# OpenResty instead.
NGINX_VERSION='1.20.2'
NGX_DEVEL_KIT_VERSION='0.3.1'
@kakopappa
kakopappa / esp8266-wifi-connect.ino
Created May 15, 2023 15:58
Example for Arduino ESP8266, ESP32 WiFi connect with max tries
#include <ESP8266WiFi.h>
#define WIFI_SSID "MY SSID"
#define WIFI_PASSWORD "MY PASS"
bool isConnected() {
return (WiFi.status() == WL_CONNECTED);
}
void connectToWiFi(int max_tries = 20, int pause = 500) {
int ret, len;
mbedtls_net_context listen_fd, client_fd;
unsigned char buf[1024];
const char *pers = "ssl_server";
int port = 443
mbedtls_entropy_context entropy;
mbedtls_ctr_drbg_context ctr_drbg;
mbedtls_ssl_context ssl;
@kakopappa
kakopappa / name-cheap-dynamic-dns.sh
Created June 3, 2023 04:24 — forked from Goddard/name-cheap-dynamic-dns.sh
auto update ip script for dynamic dns
curl -i -H "Accept: application/xml" -H "Content-Type: application/xml" -X GET https://dynamicdns.park-your-domain.com/update?host=@&domain=[domain]&password=[update-password]&ip=[local-ip]
@kakopappa
kakopappa / install_go_pi.sh
Created June 6, 2023 10:50 — forked from pcgeek86/install_go_pi.sh
Install Go Lang on Raspberry Pi
cd $HOME
FileName='go1.13.4.linux-armv6l.tar.gz'
wget https://dl.google.com/go/$FileName
sudo tar -C /usr/local -xvf $FileName
cat >> ~/.bashrc << 'EOF'
export GOPATH=$HOME/go
export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin
EOF
source ~/.bashrc
@kakopappa
kakopappa / rate-limiting-queue.js
Created August 23, 2023 02:32 — forked from samsonjs/rate-limiting-queue.js
Basic rate limiting queue for node
//// Usage
var queue = createMessageQueue({ messagesPerMinute: 60 })
queue.on('message', function(msg) {
console.log('message: ' + JSON.stringify(msg, null, 2))
})
queue.enqueue({ to: 'avian', from: 'sjs', body: 'cool story bro' })
@kakopappa
kakopappa / LM335.ino
Created September 21, 2023 07:52
LM335
#if defined(ESP8266)
#define LM_PIN A0
#elif defined(ESP32)
#define LM_PIN 36
#endif
#define ADC_VREF_mV 5000.0 // 5000 is the voltage provided by MCU. If you connect to 3V change to 3000
#define ADC_RESOLUTION 4096.0
void setup() {
#ifdef ENABLE_DEBUG
#define DEBUG_ESP_PORT Serial
#define NODEBUG_WEBSOCKETS
#define NDEBUG
#endif
#include <Arduino.h>
#if defined(ESP8266)
#include <ESP8266WiFi.h>
#elif defined(ESP32)