Skip to content

Instantly share code, notes, and snippets.

View sohamkamani's full-sized avatar
🐦
🐧

Soham Kamani sohamkamani

🐦
🐧
View GitHub Profile
@sohamkamani
sohamkamani / newProject.sh
Last active August 29, 2015 14:14
Shell script to create a new ruby project structure
echo "Enter the project name"
read -e NAME
echo "Enter name of dummy directory"
read -e DUMMY
mkdir $NAME
cd $NAME
mkdir lib
@sohamkamani
sohamkamani / newHTMLProject.sh
Created February 15, 2015 16:12
Creates a new html web project , with the initial linked css and js files ready
echo "Enter the project name"
read -e NAME
mkdir $NAME
cd $NAME
mkdir css
touch css/index_style.css
mkdir js
touch js/index.js
@sohamkamani
sohamkamani / dirs-to-js.py
Created March 12, 2015 14:41
Lists all directories and stores them as a variable in a js file
import os
import os.path
d='.'
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:
dir_sanitized.append(dir.split('/')[1])
dirmap = open('dirmap.js','w')
dirmap.write("var directories=[");
<html>
<head>
<title>My first Three.js app</title>
<style>
.list-item {
font-size: 1.2em;
color: black;
}
.completed {
# 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.
ZSH_THEME="robbyrussell"
// After importing "github.com/gojektech/heimdall"
// 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
res, err := client.Get("http://www.gojek.io/", nil)
if err != nil {
panic(err)
}
fmt.Println(string(res.Body()))
@sohamkamani
sohamkamani / rabbitmq_go_sample.go
Created March 13, 2018 12:59
An example of a simple pub-sub workflow for rabbitmq in go
package queue
import (
"fmt"
"log"
"github.com/streadway/amqp"
)
var conn *amqp.Connection
@sohamkamani
sohamkamani / statsd_send.go
Created June 28, 2018 06:22
sending metrics to statsd via udp in Go
func main() {
conn, err := net.Dial("udp", "127.0.0.1:8125")
if err != nil {
fmt.Printf("Some error %v", err)
return
}
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
sohamkamani / rsa.go
Created April 12, 2020 17:31
Example of RSA encryption, decryption, signing, and verification in Go
package main
import (
"crypto"
"crypto/rand"
"crypto/rsa"
"crypto/sha256"
"encoding/base64"
"fmt"
)