Skip to content

Instantly share code, notes, and snippets.

@didip
didip / shell_output.go
Last active July 21, 2020 05:01 — forked from hivefans/shell_output.go
get the realtime output for a shell command in golang|-|{"files":{"shell_output.go":{"env":"plain"}},"tag":"bigdata"}
package main
import (
"bufio"
"fmt"
"io"
"os"
"os/exec"
"strings"
)
@didip
didip / gist:5df46cdcf3f41b8d67cfce66afc1427c
Created July 5, 2020 04:32 — forked from devinodaniel/gist:8f9b8a4f31573f428f29ec0e884e6673
Generate SSH RSA Private/Public Key pair with Golang
// This shows an example of how to generate a SSH RSA Private/Public key pair and save it locally
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"golang.org/x/crypto/ssh"
@didip
didip / go_example_websocket_novnc
Created July 21, 2019 19:12 — forked from bit4bit/go_example_websocket_novnc
Example: Go Websocket binary proxy noVnc
package main
import (
"flag"
"golang.org/x/net/websocket"
"io"
"log"
"net"
"net/http"
"os"
@didip
didip / groupcache.go
Created October 9, 2018 20:58 — forked from fiorix/groupcache.go
Simple groupcache example
// Simple groupcache example: https://github.com/golang/groupcache
// Running 3 instances:
// go run groupcache.go -addr=:8080 -pool=http://127.0.0.1:8080,http://127.0.0.1:8081,http://127.0.0.1:8082
// go run groupcache.go -addr=:8081 -pool=http://127.0.0.1:8081,http://127.0.0.1:8080,http://127.0.0.1:8082
// go run groupcache.go -addr=:8082 -pool=http://127.0.0.1:8082,http://127.0.0.1:8080,http://127.0.0.1:8081
// Testing:
// curl localhost:8080/color?name=red
package main
import (
select * from hosts;
id | access_token_id | cluster_id | data
CREATE TABLE IF NOT EXISTS hosts (
id text,
cluster_id bigint,
access_token_id bigint,
hostname text,
updated bigint,
tags map<text, text>,
master_tags map<text, text>,
data map<text, text>,
lucene text,
@didip
didip / gist:bd8b49f6b18fa6ee4190
Created March 14, 2016 00:40
go run -race trace
==================
WARNING: DATA RACE
Read by goroutine 55:
runtime.mapaccess1_faststr()
/usr/local/Cellar/go/1.6/libexec/src/runtime/hashmap_fast.go:193 +0x0
github.com/resourced/resourced/libmap.(*TSafeMapBytes).Get()
/Users/didip/go/src/github.com/resourced/resourced/libmap/libmap.go:34 +0xe9
github.com/resourced/resourced/queryparser.(*QueryParser).dataValue()
/Users/didip/go/src/github.com/resourced/resourced/queryparser/queryparser.go:108 +0x9b
github.com/resourced/resourced/queryparser.(*QueryParser).replaceDataPathWithValue()
@didip
didip / gist:533a3a76abba0b6404d9
Created November 5, 2015 17:23
Redirect outbound traffic to another ip:port
sudo iptables -t nat -A OUTPUT -p tcp --dport 80 -j DNAT --to-destination IP:80
@didip
didip / dhcp-monitoring.sh
Created November 2, 2015 18:58
Monitor DHCP traffic using TCPDUMP
tcpdump -e -vv -i any -n port 67 and port 68
@didip
didip / .vimrc
Created October 21, 2015 06:05
Didip's minimal .vimrc
set backspace=2 " backspace in insert mode works like normal editor
syntax on " syntax highlighting
filetype indent on " activates indenting for files
set autoindent " auto indenting
set number " line numbers
colorscheme desert " colorscheme desert
set nobackup " get rid of anoying ~file
set ignorecase " Ignore case when searching
set hlsearch " Highlight search results
set smartcase " When searching try to be smart about cases