Skip to content

Instantly share code, notes, and snippets.

View RaviTezu's full-sized avatar
🎧
Wired In

RaviTeja Pothana RaviTezu

🎧
Wired In
View GitHub Profile

Here are several different ways to test a TCP port without telnet.

$ cat < /dev/tcp/127.0.0.1/22
SSH-2.0-OpenSSH_5.3
^C

$ cat &lt; /dev/tcp/127.0.0.1/23
@RaviTezu
RaviTezu / remove_except_master.sh
Last active March 29, 2018 10:52 — forked from leoapost/gist:4318441
Delete all remote branches, except master on your fork | github.
#!/usr/bin/env bash
set -e
# The MIT License (MIT)
# Copyright (c) 2018 RaviTezu
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
@RaviTezu
RaviTezu / System Design.md
Created December 30, 2017 07:51 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@RaviTezu
RaviTezu / stages.md
Created September 29, 2017 06:56 — forked from lestrrat/stages.md
Seven Stages of Becoming a Go Programmer
  • stage 1: You believe you can make Go do object oriented programming. You want to do this by using clever struct embedding.
  • stage 2: You believe goroutines will solve all of your problems. You want to use goroutines for anything and everything that you can, who cares if the code becomes a bit more complicated
  • stage 3: You believe that instead of object oriented programming, interfaces will solve all of your problems. You want to define everything in terms of interfaces
  • stage 4: You believe channels will solve all of your problems. You want to do everything from synchronization, returning values, and flow control using channels.
  • stage 5: You now believe Go is not as powerful as people claim it to be. You feel like you're stripped of all of the nice tools and constructs that other languages provide.
  • stage 6: You realize that stages 1~5 were all just your imagination. You just didn't want to accept the Go way. Everything starts to make sense.
  • stage 7: You are now at peace

Keybase proof

I hereby claim:

  • I am RaviTezu on github.
  • I am ravitezu (https://keybase.io/ravitezu) on keybase.
  • I have a public key whose fingerprint is 4EF4 F656 788D E6E1 F6EB D20A EE92 C914 D2F8 387B

To claim this, I am signing this object:

package main
import (
"context"
"fmt"
"io/ioutil"
"strings"
"cloud.google.com/go/storage"
"github.com/golang/glog"
@RaviTezu
RaviTezu / installGO.sh
Last active May 13, 2022 16:25
Shell(bash) script to install golang on Linux and MacOS machines
#!/usr/bin/env bash
set -e
# Author: Ravi Teja Pothana (@RaviTezu)
# Date: Nov 15, 2016
# The MIT License (MIT)
# Copyright (c) 2016 RaviTezu
@RaviTezu
RaviTezu / go-get-gitlab-ssh-nginx
Created November 1, 2016 04:51 — forked from jpillora/go-get-gitlab-ssh-nginx
Go get Gitlab ssh paths with nginx
location / {
## check for goget AND /namespace/project
if ($args ~* "^go-get=1") {
set $condition goget;
}
if ($uri ~ ^/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$) {
set $condition "${condition}path";
}
if ($condition = gogetpath) {
return 200 "<!DOCTYPE html><html><head><meta content='git.axon$uri git ssh://[email protected]:2200$uri.git' name='go-import'></head></html>";
type T struct {
A int
B string
}
t := T{23, "skidoo"}
s := reflect.ValueOf(&t).Elem()
typeOfT := s.Type()
for i := 0; i < s.NumField(); i++ {
@RaviTezu
RaviTezu / ipcalc.go
Created June 16, 2016 17:38 — forked from kotakanbe/ipcalc.go
get all IP address from CIDR in golang
package main
import (
"net"
"os/exec"
"github.com/k0kubun/pp"
)
func Hosts(cidr string) ([]string, error) {