Skip to content

Instantly share code, notes, and snippets.

View shamasis's full-sized avatar

Shamasis Bhattacharya shamasis

View GitHub Profile
@shamasis
shamasis / say-watch.sh
Created May 5, 2021 12:48
Make your Mac remind you every 30 seconds
watch -n 30 say It is time
@shamasis
shamasis / stop-media-indexing.sh
Created October 21, 2020 08:19
Bash commands to turn off CPU aggressive services on WD MyCloud EX
/etc/init.d/wdmcserverd stop
/etc/init.d/wdphotodbmergerd stop
@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 / keybase.md
Last active July 29, 2019 22:37
keybase.md

Keybase proof

I hereby claim:

  • I am shamasis on github.
  • I am shamasis (https://keybase.io/shamasis) on keybase.
  • I have a public key ASCK9Os-xiDRUyZBtzeVqOSZxOzAp7I-00B11_Jb1Xs2xQo

To claim this, I am signing this object:

@shamasis
shamasis / arduino.ino
Created June 16, 2019 08:52
ESP8266 Remote DHT Sensor
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include "DHT.h"
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
int LED_PIN = LED_BUILTIN; // amica
const char* ssid = "Your wifi SSID"; // Enter SSID here
const char* password = "Your wifi password"; //Enter Password here
@shamasis
shamasis / fix-npm-raspbian.sh
Created May 4, 2019 17:07
Fixing npm global install on Raspbian
# run the following commands
sudo mkdir /usr/local/lib/node_modules;
sudo chown pi /usr/local/lib/node_modules;
@shamasis
shamasis / benchmark-compare-keys-vs-loop-obj-iteration.spec.js
Created January 7, 2018 10:13
Benchmark Object.keys().forEach vs for..in loop
require("microtime");
const
_ = require('lodash'),
Benchmark = require('benchmark'),
suite = new Benchmark.Suite,
result = [],
seedSize = 10000,
seedData = Array(seedSize).fill().map(() => String(Math.round(Math.random() * seedSize))).reduce((obj, val) => {
@shamasis
shamasis / benchmark-unique-string-set-vs-obj.benchmark.js
Created January 7, 2018 10:11
Benchmark ES6 Set vs Object to filter unique strings from an array
const
_ = require('lodash'),
Benchmark = require('benchmark'),
suite = new Benchmark.Suite,
result = [],
seedSize = 10000,
seedData = Array(seedSize).fill().map(() => String(Math.round(Math.random() * seedSize)));
suite
@shamasis
shamasis / fake_nsp_package.js
Last active April 5, 2016 15:54
Creates a fake package.json for sending to NSP (adds ability to exclude packages using `exclusions: []` in .nsprc)
#!/usr/bin/env node
const
resolve = require('path').resolve,
loadJSON = function (file) {
return JSON.parse(require('fs').readFileSync(file).toString());
},
dependencySources = ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies',
@shamasis
shamasis / bunde_dependencies.js
Last active March 28, 2016 18:52
Converts package.json dependencies to bundled dependencies
#!/usr/bin/env node
/**
* Read a package.json file and then replace all dependencies and
* optionally dev dependencies into bundled dependencies.
*/
var p = '',
writeFile = require('fs').writeFile,
resolve = require('path').resolve;