Skip to content

Instantly share code, notes, and snippets.

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

Arnab Mukherjee mukherjeearnab

🏠
Working from home
View GitHub Profile
@mukherjeearnab
mukherjeearnab / fall.ino
Created May 15, 2023 06:57
Node MCU Fall Detection Code
#include <ESP8266WiFi.h>
#include <Wire.h>
const int MPU_addr = 0x68; // I2C address of the MPU-6050
int16_t AcX, AcY, AcZ, Tmp, GyX, GyY, GyZ;
float ax = 0, ay = 0, az = 0, gx = 0, gy = 0, gz = 0;
boolean fall = false; // stores if a fall has occurred
boolean trigger1 = false; // stores if first trigger (lower threshold) has occurred
boolean trigger2 = false; // stores if second trigger (upper threshold) has occurred
boolean trigger3 = false; // stores if third trigger (orientation change) has occurred
byte trigger1count = 0; // stores the counts past since trigger 1 was set true
@mukherjeearnab
mukherjeearnab / ping.js
Created January 30, 2022 06:14
JS script to ping a series of IP addresses
var ping = require("ping");
for (let i = 1; i < 256; i++) {
let host = `172.23.156.${i}`;
ping.sys.probe(host, function (isAlive) {
isAlive ? console.log(`host ${host} is alive`) : "";
});
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.8.0;
/**
* @title Storage
* @dev Store & retrieve value in a variable
*/
contract Storage {
@mukherjeearnab
mukherjeearnab / Mythril Bytecode to OPCODE.py
Last active April 1, 2024 21:20
Convert Solidity Bytecode to OPCODE
bytecode2opcode(bytecode):
# Decompile bytecode
opl = mythril.disassembler.asm.disassemble(bytearray.fromhex(bytes))
# Append opcodes
opcode = ''
for op in opl:
opcode += op['opcode'] + ' '
# Remove useless whitespace
@mukherjeearnab
mukherjeearnab / SMOTETomek
Last active October 1, 2020 05:11
Performance Metrics
Performance Metrics for SMOTETomek LSTM models.
************************************************************
Error Label 1
************************************************************
Total Positive Samples: 335
Total Negative Samples: 5883
Accuracy: 0.983757
Precision: 0.875000
Recall: 0.814925
F1 score: 0.843895
@mukherjeearnab
mukherjeearnab / split_label_array.py
Last active September 5, 2020 13:43
Code Snippets used for Blockchain_ML
def split_label_binarizer(data_frame):
# Change 'label' to whatever naming used in the original DataFrame.
cl = []
for index in data_frame.index:
temp = data_frame['label'][index]
temp = [int(i) for i in temp]
cl.append(temp)
data_frame['lca'] = cl
return data_frame
@mukherjeearnab
mukherjeearnab / Cert.json
Created July 21, 2020 16:13
A Hyperledger Fabric x509 Certificate
{
"Raw": "MIIClDCCAjugAwIBAgIUBYm/l7U+6lmN5Ej47oGc7L1w/9UwCgYIKoZIzj0EAwIweTELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBGcmFuY2lzY28xHDAaBgNVBAoTE2NpdGl6ZW4udmVoaWNsZS5jb20xHzAdBgNVBAMTFmNhLmNpdGl6ZW4udmVoaWNsZS5jb20wHhcNMjAwNzIxMTYwNTAwWhcNMjEwNzIxMTYxMDAwWjBCMTAwDQYDVQQLEwZjbGllbnQwCwYDVQQLEwRvcmcxMBIGA1UECxMLZGVwYXJ0bWVudDExDjAMBgNVBAMTBXVzZXIxMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEqczToVyMOxcJw0fgZ2vL0j+2XzXCHMHhCLg70Lgllm5+QYoQCnZnLacN0cXE4+AuJG0kbbYgdsij+CkYd28BSqOB1zCB1DAOBgNVHQ8BAf8EBAMCB4AwDAYDVR0TAQH/BAIwADAdBgNVHQ4EFgQUgKl6P1KVEl3yJzgPVl5nfXDZL4IwKwYDVR0jBCQwIoAg+thpkSvHPfKxRWqcDpkR8m800rA7DLHgHDVjN8Wuu+YwaAYIKgMEBQYHCAEEXHsiYXR0cnMiOnsiaGYuQWZmaWxpYXRpb24iOiJvcmcxLmRlcGFydG1lbnQxIiwiaGYuRW5yb2xsbWVudElEIjoidXNlcjEiLCJoZi5UeXBlIjoiY2xpZW50In19MAoGCCqGSM49BAMCA0cAMEQCICOL0Fx3jTB8Sl9+lBCfL16eWpavKVsyptMEpG4IQ51lAiBltV6WVhR3xhWsEDTqq+UP/Fs9ERwx7QZS6LiMv6lTOg==",
"RawTBSCertificate": "MIICO6ADAgECAhQFib+XtT7qWY3kSPjugZzsvXD/1TAKBggqhkjOPQQDAjB5MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ
@mukherjeearnab
mukherjeearnab / blockexplorer.html
Last active February 16, 2020 13:52
A simple Block Explorer using Web3.js for Rinkeby network.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Blockchain Explorer</title>
<!-- Bootstrap -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<!-- Styles -->
public static void Main(string[] args)
{
Double CPUtprt = 0;
System.Management.ManagementObjectSearcher mos = new System.Management.ManagementObjectSearcher(@"root\WMI", "Select * From MSAcpi_ThermalZoneTemperature");
foreach (System.Management.ManagementObject mo in mos.Get())
{
CPUtprt = Convert.ToDouble(Convert.ToDouble(mo.GetPropertyValue("CurrentTemperature").ToString()) - 2732) / 10;
Console.WriteLine("CPU temp : " + CPUtprt.ToString() + " °C");
}
Console.ReadKey();