Skip to content

Instantly share code, notes, and snippets.


Soham Kamani sohamkamani

View GitHub Profile
sohamkamani / localstorage_lru_cache.html
Created Jul 21, 2020
An example of how to implement LRU cache with eviction using the HTML5 localStorage API
View localstorage_lru_cache.html
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>LocalStorage With LRU Eviction</title>
<button id="btn-set">Set</button><br />
Key: <input id="input-set-key" /><br />
sohamkamani / rsa.js
Last active Oct 6, 2021
An example of RSA Encryption implemented in Node.js
View rsa.js
const crypto = require("crypto")
// The `generateKeyPairSync` method accepts two arguments:
// 1. The type ok keys we want, which in this case is "rsa"
// 2. An object with the properties of the key
const { publicKey, privateKey } = crypto.generateKeyPairSync("rsa", {
// The standard secure default length for RSA keys is 2048 bits
modulusLength: 2048,
sohamkamani / rsa.go
Created Apr 12, 2020
Example of RSA encryption, decryption, signing, and verification in Go
View rsa.go
package main
import (
sohamkamani / statsd_send.go
Created Jun 28, 2018
sending metrics to statsd via udp in Go
View statsd_send.go
func main() {
conn, err := net.Dial("udp", "")
if err != nil {
fmt.Printf("Some error %v", err)
for i := 0; i < 10; i++ {
// This is the only line of code you need to push stats to telegraf
fmt.Fprintf(conn, "deploys.test.myservice,from=go:1|c")
sohamkamani / rabbitmq_go_sample.go
Created Mar 13, 2018
An example of a simple pub-sub workflow for rabbitmq in go
View rabbitmq_go_sample.go
package queue
import (
var conn *amqp.Connection
View heimdall_sample2.go
res, err := client.Get("", nil)
if err != nil {
View heimdall_sample1.go
// After importing ""
// Create a new hystrix configuration, and input the command name, along with other required options
hystrixConfig := heimdall.NewHystrixConfig("downstream_get_request", heimdall.HystrixCommandConfig{
ErrorPercentThreshold : 20,
MaxConcurrentRequests: 30,
Timeout: 1000,
SleepWindow: 1500
// Create a new hystrix-wrapped HTTP client
View .zshrc
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
export MONGO_URL="mongodb://localhost/baybank"
source ~/.iterm2_shell_integration.`basename $SHELL`
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
View oops-in-browser.html
<title>My first Three.js app</title>
.list-item {
font-size: 1.2em;
color: black;
.completed {
sohamkamani /
Created Mar 12, 2015
Lists all directories and stores them as a variable in a js file
import os
import os.path
dirs = [os.path.join(d,o) for o in os.listdir(d) if os.path.isdir(os.path.join(d,o))]
dir_sanitized = []
for dir in dirs:
dirmap = open('dirmap.js','w')
dirmap.write("var directories=[");