Skip to content

Instantly share code, notes, and snippets.

@didip
didip / shell_output.go
Last active Jul 21, 2020 — forked from hivefans/shell_output.go
get the realtime output for a shell command in golang|-|{"files":{"shell_output.go":{"env":"plain"}},"tag":"bigdata"}
View shell_output.go
package main
import (
"bufio"
"fmt"
"io"
"os"
"os/exec"
"strings"
)
@didip
didip / gist:5df46cdcf3f41b8d67cfce66afc1427c
Created Jul 5, 2020 — forked from devinodaniel/gist:8f9b8a4f31573f428f29ec0e884e6673
Generate SSH RSA Private/Public Key pair with Golang
View gist:5df46cdcf3f41b8d67cfce66afc1427c
// 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 Jul 21, 2019 — forked from bit4bit/go_example_websocket_novnc
Example: Go Websocket binary proxy noVnc
View go_example_websocket_novnc
package main
import (
"flag"
"golang.org/x/net/websocket"
"io"
"log"
"net"
"net/http"
"os"
@didip
didip / groupcache.go
Created Oct 9, 2018 — forked from fiorix/groupcache.go
Simple groupcache example
View groupcache.go
// 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 (
View select * from hosts
select * from hosts;
id | access_token_id | cluster_id | data
View hosts.cql
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,
View gist:bd8b49f6b18fa6ee4190
==================
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 Nov 5, 2015
Redirect outbound traffic to another ip:port
View gist:533a3a76abba0b6404d9
sudo iptables -t nat -A OUTPUT -p tcp --dport 80 -j DNAT --to-destination IP:80
@didip
didip / dhcp-monitoring.sh
Created Nov 2, 2015
Monitor DHCP traffic using TCPDUMP
View dhcp-monitoring.sh
tcpdump -e -vv -i any -n port 67 and port 68
@didip
didip / .vimrc
Created Oct 21, 2015
Didip's minimal .vimrc
View .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