Skip to content

Instantly share code, notes, and snippets.

View vireshas's full-sized avatar
:octocat:

Viresh Sanagoudar vireshas

:octocat:
View GitHub Profile
@vireshas
vireshas / main.go
Created December 31, 2019 07:49 — forked from superbrothers/main.go
http request with context in Go
package main
import (
"context"
"fmt"
"log"
"net/http"
"time"
)
@vireshas
vireshas / main.go
Created June 3, 2019 09:45 — forked from enricofoltran/main.go
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
@vireshas
vireshas / go-ssh-reverse-tunnel.go
Created May 20, 2019 04:35 — forked from codref/go-ssh-reverse-tunnel.go
Go SSH reverse tunnel implementation (SSH -R)
/*
Go-Language implementation of an SSH Reverse Tunnel, the equivalent of below SSH command:
ssh -R 8080:127.0.0.1:8080 operatore@146.148.22.123
which opens a tunnel between the two endpoints and permit to exchange information on this direction:
server:8080 -----> client:8080
@vireshas
vireshas / ssh
Created May 20, 2019 04:35 — forked from zxvdr/ssh
SSH proxy
package main
import (
"bytes"
"code.google.com/p/go.crypto/ssh"
"fmt"
"log"
"net"
"os"
)
@vireshas
vireshas / raft.go
Created May 6, 2019 05:30 — forked from F21/raft.go
Sample hashicorp/raft + hashicorp/serf app
package main
import (
"crypto/md5"
"flag"
"fmt"
"io"
"log"
"os"
"path/filepath"

FWIW: I didn't produce the content presented here (the outline from Edmond Lau's book). I've just copy-pasted it from somewhere over the Internet, but I cannot remember what exactly the original source is. I was also not able to find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

What's an Effective Engineer?

@vireshas
vireshas / consist_hash.java
Last active October 2, 2018 15:13 — forked from bcambel/consist_hash.java
Consistent Hash Java implementation
import java.util.Collection;
import java.util.SortedMap;
import java.util.TreeMap;
public class ConsistentHash<T> {
private final HashFunction hashFunction;
private final int numberOfReplicas;
private final SortedMap<Integer, T> circle = new TreeMap<Integer, T>();
@vireshas
vireshas / runWatch.sh
Created August 7, 2018 07:39 — forked from osrec/runWatch.sh
Watch a particular directory for changes and kill and restart a process on change
# In the example below, the command we want to run is `php -f "$DIR/../run.php"` - change this on lines 30 and 46
# $DIR is just the directory containing this script file (computed automatically, but you can hardcode it if you want).
# Use $DIR to specify paths relative to the script's path.
# The PROCESS_NAME variable is the name of the process to kill and restart
# You must ensure your process has the same name each time it runs (we use a file at $DIR/../servername to store the name)
# Alternatively, you can hard code the PROCESS_NAME on line 15 if you like
#!/bin/bash
@vireshas
vireshas / bad_code.clj
Created July 5, 2018 08:51
bad_code.clj
(def path ["abc" "def" "xyz" "ref" "fed"])
(defn a []
(->> path
(interpose "/")
(into ["/"])
(apply str)))
(defn b []
(str "/" (clojure.string/join #"/" path)))
module B
def print
puts C::A
end
end
class C
A = 10
include B
end