Skip to content

Instantly share code, notes, and snippets.

View shamasis's full-sized avatar

Shamasis Bhattacharya shamasis

View GitHub Profile
@shamasis
shamasis / install-postman-insights-agent.sh
Last active April 9, 2025 08:23
Postman Insights Agent Installation Script. (Experimental)
#!/usr/bin/env bash
# 3-Clause BSD License
#
# Copyright (c) 2009, Boxed Ice <hello@boxedice.com>
# Copyright (c) 2010-2016, Datadog <info@datadoghq.com>
# Copyright (c) 2020-present, Postman, Inc. <observability-support@postman.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@shamasis
shamasis / configuration.yaml
Last active February 23, 2025 17:26 — forked from rpanachi/command_line.yaml
Tuya api script (for home assistant) (India) (All Sensors)
command_line:
sensor:
name: Meter PC321-W-TY
unique_id: meter_PC321_W_TY
command: 'python3 /config/tuyapc321.py d7978c72b206429cedo10z'
device_class: power
state_class: measurement
unit_of_measurement: W
scan_interval: 10
json_attributes:
@shamasis
shamasis / muppy.js
Created July 9, 2024 11:43
OpenAI CLI chatbot
const OpenAI = require('openai'),
readline = require('readline');
// Initialize OpenAI with API key
const openai = new OpenAI({
apiKey: "" // your-api-key-here
// For extra safety, use the line below, comment the line above and pass the API key as an environment variable:
// apiKey: process.env['OPENAI_API_KEY']
});
@shamasis
shamasis / climate.yaml
Created June 6, 2024 14:29
ESPHome Climate Controller
substitutions:
name: climate-control-esph-1337
friendly_name: Climate Control ESPH-1337
pin_status_led: GPIO2
pin_transmitter: GPIO4
pin_receiver: GPIO12
pin_dht: GPIO14
esphome:
name: ${name}
@shamasis
shamasis / esp32.blink.ino
Created June 4, 2024 10:46
Sample sketch that blinks ESP32 built-In LED to smoke test everything works
# This is an ESPHome configuration for an Outdoor Weather Station.
# The configuration includes a raindrop coverage sensor and a rain sensor.
# The raindrop coverage sensor uses an ADC to measure water resistance,
# while the rain sensor is a digital sensor indicating whether it is raining or not.
#
# The configuration uses substitutions to define all the configurable parts,
# making it easy to adjust pins and other settings without modifying the entire file.
substitutions:
name: esph-29697f-ows-1
@shamasis
shamasis / event-layer-coordinates.js
Created June 7, 2014 20:40
Cross browser layerX and layerY in JavaScript
/**
* Get layerX and layerY of an event across all browsers without
* using the deprecated layerX of webkit.
* It stores `targetX` and `targetY` in the event, to act like `layerY`
* and `layerY` respectively.
*/
getElementPosition = (function () {
var body = window.document.body || window.document.documentElement;
return function (event) {
@shamasis
shamasis / main.cpp
Created March 22, 2020 15:52
TOTP Generator for ESP32 OLED module
#include <WiFi.h>
#include <NTPClient.h>
// dependencies
#include "TOTP++.h"
#include "SSD1306.h"
// replace with your network credentials
const char* ssid = "Redacted";
const char* password = "Redacted";
@shamasis
shamasis / describe-it.js
Last active September 5, 2023 07:12
mocha/jasmine compatible test framework for postman test scripts (in less than 1KB minified)
/**
* @module describe-it
*
* This module defines global variables to provide unit test case runner functions compatible with mocha and jasmine.
* The codebase is written for brevity and facilitate being as lightweight as possible.
*
* The code is intended to be included in Postman Test Sandbox.
*/
/**
@shamasis
shamasis / alloc-assoc-elastic-ip.sh
Created December 21, 2014 09:41
Create and allocate AWS Elastic IP at one go using AWS CLI. Replace `$1` with your Instance Id or simply execute this file as a script and pass the Instance Id as the first argument to the script.
aws ec2 associate-address --instance-id $1 --public-ip $(aws ec2 allocate-address --output text --query 'PublicIp')