Skip to content

Instantly share code, notes, and snippets.

View kaustavha's full-sized avatar
:octocat:
:electron: :atom: :shipit: 🚀 🌟 🇮🇳 🇺🇸 🇨🇦 Ethereum fanboi

Kaustav Haldar kaustavha

:octocat:
:electron: :atom: :shipit: 🚀 🌟 🇮🇳 🇺🇸 🇨🇦 Ethereum fanboi
View GitHub Profile
@kaustavha
kaustavha / jsHijinks.md
Created November 5, 2019 17:25
javascript hijinks to remembers

Javascript language hijinks and quirks to watch out for

  • Copy by reference vs copy by value Strings and numbers are passed by value. Arrays and objects are passed by reference. -- Example
// Nums
> a = 0
0
@kaustavha
kaustavha / mailDeliver.md
Created November 4, 2019 17:33
Various smtp mail server cross connection performances

I checked mail delivery from 3 servers to google. All mail is from hi@kaustav.me

gmail with outbound server set as zoho delivered in 0 seconds. gmail to gmail with from set to zoho

Message ID	<CABaOn_z82JMJsDX62fTQ0vG76HPVTn60iVEDxD1GCzEQVy0foA@mail.gmail.com>
Created at:	Mon, Nov 4, 2019 at 12:17 PM (Delivered after 0 seconds)
From:	Kaustav Haldar <hi@kaustav.me>
To:	Kaustav haldar <kausthal@gmail.com>
@kaustavha
kaustavha / objToArr.js
Created October 8, 2019 02:05
Javascript - turn array with negative indices to normal array
/**
* Returns a normal iterable array from an array with -ve numbers, padding any missing elements with the provided filler
* Use case - algo problems where we move in 2d space to -ve numbered places in an arr or matrix
* @param {Array} obj An array containing -ve numbers as indices, behaves like an object at times
* @param {*} filler Filler material to populate missing members e.g. array or string
* @param {Number} maxPos maximum positive value of a key in array
* @param {Number} maxNeg max -ve value of a key in the incoming array
* @returns {Array} Sorted array
*/
function _objToArr(obj, filler, maxPos, maxNeg) {
@kaustavha
kaustavha / deleteDupFilesInDirectory.js
Last active February 24, 2019 19:27
Delete all duplicate files in mac
// cd to the dir// or open a iterm window - rclick , new console/iterm2
// > node
let arr = fs.readdirSync('.'), dupcheck = [], outarr = [],
add = a => a[0] + a[1];
arr.forEach(i => {
if (i.split(' ').length > 1) {
if (dupcheck.indexOf(add(i.split(' '))) !== -1) {
outarr.push(i.split(' '));
}
@kaustavha
kaustavha / github.js
Created June 28, 2018 20:31
Github browser helper
// Get a list of all the names of all the projects on a github org page
s = [];
document.querySelectorAll('.col-12').forEach(e => {x = e.firstChild.nextSibling.firstChild.nextSibling.innerText; s.push(x.replace(' Private', ''))});
// Break the list into lines to easily copy paste into a spreadsheet
s.forEach(e => console.log(e));
@kaustavha
kaustavha / speedup.md
Last active January 30, 2024 22:29
Increase playback speed on any video
document.querySelector('video').playbackRate = 1.5
  • Videos on any page using a video tag. Youtube, vimeo etc

  • (Right click/2 finger click on mac -> inspect element); on the video to reveal the <video></video> tag, otherwise you might get a var v = document.querySelector('video'); var t = prompt('Set the playback rate'); v.playbackRate = parseFloat(t) err.

  • Paste this into the console (go to console from the window that pops up from inspect element or cmd + option + i):

@kaustavha
kaustavha / a.txt
Last active September 28, 2017 23:28
0xB64762d24e24a27468ab09aA0D19244a2832e893
@kaustavha
kaustavha / README.md
Last active September 28, 2017 15:48
Ethereum waterloo meetup 2 F17 - setup instructions

Pre-setup:

  • Install nodejs, npm, git

Setup:

  • Install the meta-mask chrome extension: https://metamask.io/
  • For part1: git clone https://github.com/kaustavha/learn_eth.git && cd learn_eth && npm install
  • For part2: npm install -g truffle ethereumjs-testrpc && mkdir pet-shop-tutorial && cd pet-shop-tutorial && truffle unbox pet-shop

Links:

@kaustavha
kaustavha / ethere.txt
Created June 29, 2017 23:13
0xB64762d24e24a27468ab09aA0D19244a2832e893
0xB64762d24e24a27468ab09aA0D19244a2832e893
@kaustavha
kaustavha / README.md
Created February 20, 2016 00:27
Kafka Go benchmarks

You'll need a version of Go >1.3 since Sarama will fail to compile on anything below that. also remember to install sarama using go get github.com/Shopify/sarama and finally build the binary.

Usage:

./warehouser -zookeeper "localhost:2181"

Results: