Skip to content

Instantly share code, notes, and snippets.

Shamasis Bhattacharya shamasis

Block or report user

Report or block shamasis

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View 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 Jun 16, 2019
ESP8266 Remote DHT Sensor
View arduino.ino
#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
Fixing npm global install on Raspbian
View fix-npm-raspbian.sh
# 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 Jan 7, 2018
Benchmark Object.keys().forEach vs for..in loop
View benchmark-compare-keys-vs-loop-obj-iteration.spec.js
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 Jan 7, 2018
Benchmark ES6 Set vs Object to filter unique strings from an array
View benchmark-unique-string-set-vs-obj.benchmark.js
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 Apr 5, 2016
Creates a fake package.json for sending to NSP (adds ability to exclude packages using `exclusions: []` in .nsprc)
View fake_nsp_package.js
#!/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 Mar 28, 2016
Converts package.json dependencies to bundled dependencies
View bunde_dependencies.js
#!/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;
@shamasis
shamasis / tail-slack.sh
Last active Dec 28, 2017
Tail a file and output to slack
View tail-slack.sh
#!/bin/bash
tail -n0 -F "$1" | while read LINE; do
(echo "$LINE" | grep -e "$3") && curl -X POST --silent --data-urlencode \
"payload={\"text\": \"$(echo $LINE | sed "s/\"/'/g")\"}" "$2";
done
@shamasis
shamasis / describe-it.min.js
Last active May 4, 2018
mocha/jasmine compatible test framework for postman test scripts (in less than 1KB minified)
View describe-it.min.js
(typeof tests!=='object')&&(tests={});var
it=((it=function(k,v){it.d.push(k);it.t[it.d]=1;it.b.forEach(it.c);try{v()}catch(e){it.t[it.d]=0;setTimeout&&setTimeout(function(){throw e;})}it.a.forEach(it.c);it.d.pop()}),
it.a=[],it.b=[],it.c=function(x){x()},it.d=[],it.d.toString=function(){return this.join(' ')},
it.t=tests,it.x=function(v){this.v=v},it.xp=it.x.prototype,it.xp.toBe=function(x){(this.v!==x)&&it._()},
it.xp.toNotBe=function(x){(this.v===x)&&it._()},it.xp.toEql=function(x){(this.v!=x)&&it._()},
it.xp.toNotEql=function(x){(this.v==x)&&it._()},it.xp.toBeOk=function(){!this.v&&it._()},
it.xp.toNotBeOk=function(){this.v&&it._()},it),describe=function(k,v){it.d.push(k);v();it.d.pop()},
expect=function(v){return new it.x(v)},beforeEach=it.b.push.bind(it.b),afterEach=it.a.push.bind(it.a);
@shamasis
shamasis / describe-it.js
Last active Nov 10, 2019
mocha/jasmine compatible test framework for postman test scripts (in less than 1KB minified)
View describe-it.js
/**
* @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.
*/
/**
You can’t perform that action at this time.