Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Aruna Tennakoon kakopappa

  • Sri Lanka / Thailand
View GitHub Profile
@kakopappa
kakopappa / perference_with_checkbox.xml
Created Apr 23, 2019
android layout example - Perference with checkbox
View perference_with_checkbox.xml
<?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"
View smartconfig.ino
#include "FS.h"
#include "esp_system.h"
#include <esp_wifi.h>
#include <string.h>
#include <WiFi.h>
#include <Preferences.h> // WiFi storage
const char* rssiSSID; // NO MORE hard coded set AP, all SmartConfig
const char* password;
String PrefSSID, PrefPassword; // used by preferences storage
@kakopappa
kakopappa / app.js
Created Feb 18, 2019
Hmac sha256 url parameter signature validate using dart and nodejs
View app.js
// Dart
void _incrementCounter() {
String secret = "762c4144-1630-4fab-9161-0fef8b18d316";
List<int> key = utf8.encode(secret);
String message = "clientId=android-app&type=action&ts=1550493108338&actions=%5B%7B%22name%22%3A%22setOn%22%2C%22parameters%22%3A%7B%7D%7D%5D";
List<int> messageBytes = utf8.encode(message);
Hmac hmac = new Hmac(sha256, key);
Digest digest = hmac.convert(messageBytes);
@kakopappa
kakopappa / aes.js
Created Feb 15, 2019
AES Java nodejs examples
View aes.js
import java.security.MessageDigest;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import javax.xml.bind.DatatypeConverter;
public class AES {
private static byte[] iv = "0000000000000000".getBytes();
private static String decrypt(String encrypted, String seed)
@kakopappa
kakopappa / mongo_backup.sh
Created Feb 13, 2019 — forked from sheharyarn/mongo_backup.sh
Mongodump Shell Script for Cronjob
View mongo_backup.sh
#!/bin/bash
MONGO_DATABASE="your_db_name"
APP_NAME="your_app_name"
MONGO_HOST="127.0.0.1"
MONGO_PORT="27017"
TIMESTAMP=`date +%F-%H%M`
MONGODUMP_PATH="/usr/bin/mongodump"
BACKUPS_DIR="/home/username/backups/$APP_NAME"
@kakopappa
kakopappa / rs-connect.js
Created Feb 13, 2019 — forked from chrisckchang/rs-connect.js
replica set connection with nodejs native
View rs-connect.js
/**
* MongoDB NodeJS Driver Production Connection Example
*
* Copyright (c) 2015 ObjectLabs Corporation
* Distributed under the MIT license - http://opensource.org/licenses/MIT
*/
var MongoClient = require('mongodb').MongoClient;
/**
@kakopappa
kakopappa / nginx-node-js-and-networking-for-heavy-workloads
Created Jan 28, 2019
nginx-node-js-and-networking-for-heavy-workloads
View nginx-node-js-and-networking-for-heavy-workloads
https://engineering.gosquared.com/optimising-nginx-node-js-and-networking-for-heavy-workloads
@kakopappa
kakopappa / thermostat_example_with_dht_11.ino
Created Jan 25, 2019
setSetTemperatureSettingOnServer.ino fix
View thermostat_example_with_dht_11.ino
/*
Version 0.1 - Jan 05 2019
*/
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <WebSocketsClient.h> // https://github.com/kakopappa/sinric/wiki/How-to-add-dependency-libraries
#include <ArduinoJson.h> // https://github.com/kakopappa/sinric/wiki/How-to-add-dependency-libraries
#include <StreamString.h>
@kakopappa
kakopappa / hmac.js
Last active Jan 15, 2019
hmac nodejs esp8266
View hmac.js
//https://github.com/rcarmo/azure-iot-esp-01-minimal-cpp/blob/master/iothub.cpp
//http://bitoftech.net/2014/12/15/secure-asp-net-web-api-using-api-key-authentication-hmac-authentication/
/*
var hmac = crypto.createHmac('sha256', secret_key);
hmac.update(request.body.message);
var signature = hmac.digest('hex'));
*/
var str = payload_string;
View esp8266-smart-config.ino
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
void setup() {
int cnt = 0;
// set for STA mode
WiFi.mode(WIFI_STA);
// put your setup code here, to run once:
You can’t perform that action at this time.