Skip to content

Instantly share code, notes, and snippets.

View suru-dissanaike's full-sized avatar

Suru Dissanaike suru-dissanaike

View GitHub Profile
server {
listen 443 ssl;
listen [::]:443 ssl;
root /home/sudi/code/himinds-boosting-innovation-web-secure-cra/hn-app/build;
index index.html index.htm;
server_name MY_DOMAIN;
ssl_certificate /home/sudi/certbot/etc/live/MY_DOMAIN/fullchain.pem;
ssl_certificate_key /home/sudi/certbot/etc/live/MY_DOMAIN/privkey.pem;
location ~* \.(?:manifest|appcache|html?|xml|json)$ {
ESP32 IO PIN Function Direction BME280 BQ27441-G1 Comment
13 Application Push button 1 IN N/A N/A Pull down push button
15 LED Green OUT N/A N/A LED
16 LED RED OUT N/A N/A LED
26 SCL OUT PAD 4 PIN 2 I2C
27 SDA OUT PAD 3 PIN 1 I2C
21 GPOUT IN N/A PIN 12 This open-drain output can be configured to indicate BAT_LOW
// Imports the Google Cloud client library
const {BigQuery} = require('@google-cloud/bigquery');
// Your Google Cloud Platform project ID
const projectId = 'bigquery-242619';
const datasetId = "test_data";
const tableId = "raw_data";
const bqTimestamp = BigQuery.timestamp(new Date());
config_schema:
- ["i2c.enable", true]
- ["i2c.scl_gpio", 26]
- ["i2c.sda_gpio", 27]
- ["wifi.ap.enable", false]
- ["wifi.sta.enable", true]
- ["wifi.sta.ssid", "YOUR-SSID"]
- ["wifi.sta.pass", "YOUR-PASSKEY"]
- ["mqtt.server", "YOUR-BROKER-IP:8883"]
- ["mqtt.enable", true]
@suru-dissanaike
suru-dissanaike / mosquitto.conf
Created May 1, 2019 11:30
mosquitto.conf used in Medium article
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
listener 8883
cafile /etc/mosquitto/certs/ca.crt
certfile /etc/mosquitto/certs/server.crt
@suru-dissanaike
suru-dissanaike / make-keys.sh
Last active August 12, 2025 14:52
Create self-signed certificates for Eclipse Mosquitto MQTT broker
#!/bin/bash
IP="192.168.1.22"
SUBJECT_CA="/C=SE/ST=Stockholm/L=Stockholm/O=himinds/OU=CA/CN=$IP"
SUBJECT_SERVER="/C=SE/ST=Stockholm/L=Stockholm/O=himinds/OU=Server/CN=$IP"
SUBJECT_CLIENT="/C=SE/ST=Stockholm/L=Stockholm/O=himinds/OU=Client/CN=$IP"
function generate_CA () {
echo "$SUBJECT_CA"
openssl req -x509 -nodes -sha256 -newkey rsa:2048 -subj "$SUBJECT_CA" -days 365 -keyout ca.key -out ca.crt
@suru-dissanaike
suru-dissanaike / VehicleEmulator.cpp
Last active April 13, 2019 19:03
VehicleEmulator.cpp
std::unique_ptr < CommBase > CommFactory::create() {
bool isEmulator = android::base::GetBoolProperty("ro.kernel.qemu", false);
if (isEmulator) {
// return std::make_unique<PipeComm>();
return std::make_unique < SocketComm > ();
} else {
// return std::make_unique<SocketComm>();
return std::make_unique < PipeComm > ();
}
}
@suru-dissanaike
suru-dissanaike / Makefile
Last active November 25, 2023 16:04
MQTT demo using mosquitto lib
CC=gcc # gcc || clang
CCOPTIONS = -g -Wall
LIBS = -lmosquitto#-ljson-c
all: mosquitto-demo.o
$(CC) -o mosquitto-demo mosquitto-demo.o $(LIBS) $(CCOPTIONS)
import obd
connection = obd.OBD("/dev/rfcomm0")
cmd = obd.commands.RPM
response = connection.query(cmd)
print(response.value)
print(connection.protocol_name())
[Feb 13 20:51:19.925] mgos_app_init        c-code dual core ver 0.1
[Feb 13 20:51:19.925] mgos_app_init        CPU Speed: 240 
[Feb 13 20:51:19.925] mgos_app_init        Interrupt attached
[Feb 13 20:51:21.942] task_toggle_led      core: 1task_other_core      
[Feb 13 20:51:21.942] mgos_app_init        core: 0app_init done
[Feb 13 20:51:21.942] 
[Feb 13 20:51:21.942] mgos_init            Init done, RAM: 307692 total, 267056 free, 267056 min free
[Feb 13 20:51:22.934] mongoose_poll        New heap free LWM: 267016
[Feb 13 20:51:26.005] interupt_handler_gpi core: 0