Skip to content

Instantly share code, notes, and snippets.

View smallnest's full-sized avatar

smallnest smallnest

View GitHub Profile
//
// This is just a collection of syscalls that are used by libsctp linux implementation.
// Although it supports message-oriented workflow, it can't be wrapped into a net.PacketConn.
//
package main
import (
"log"
"syscall"
@smallnest
smallnest / benchmark-commands.md
Created March 30, 2022 08:51 — forked from ueokande/benchmark-commands.md
Kafka Benchmark Commands

Benchmark commands

Producer

Setup

bin/kafka-topics.sh \
  --zookeeper zookeeper.example.com:2181 \
  --create \
@smallnest
smallnest / sql.go
Created March 21, 2022 05:48 — forked from PumpkinSeed/sql.go
Extension for sql package
func structScan(rows *sql.Rows, model interface{}) error {
v := reflect.ValueOf(model)
if v.Kind() != reflect.Ptr {
return errors.New("must pass a pointer, not a value, to StructScan destination") // @todo add new error message
}
v = reflect.Indirect(v)
t := v.Type()
cols, _ := rows.Columns()
@smallnest
smallnest / proxy.go
Created January 30, 2022 04:40 — forked from vmihailenco/proxy.go
Simple TCP proxy in Golang
package main
import (
"bytes"
"encoding/hex"
"flag"
"fmt"
"io"
"log"
"net"
@smallnest
smallnest / client.go
Created January 11, 2022 08:05 — forked from mowings/client.go
Golang Websocket JSONRPC server and client
package main
import (
"golang.org/x/net/websocket"
"log"
"net/rpc/jsonrpc"
)
// In a real project, these would be defined in a common file
type Args struct {
@smallnest
smallnest / traceroute.go
Created December 8, 2021 12:57 — forked from niedbalski/traceroute.go
A small traceroute written in go
package main
import (
//"bufio"
"fmt"
"golang.org/x/net/icmp"
"golang.org/x/net/internal/iana"
"golang.org/x/net/ipv4"
"log"
"net"
@smallnest
smallnest / clickhousedump
Created October 13, 2021 09:53 — forked from inkrement/clickhousedump
dump all clickhouse databases and tables
#!/bin/bash
OUTDIR=.
while read -r db ; do
while read -r table ; do
if [ "$db" == "system" ]; then
echo "skip system db"
continue 2;
@smallnest
smallnest / ipint.go
Created September 26, 2021 04:51 — forked from ammario/ipint.go
Golang ip <-> int conversion
func ip2int(ip net.IP) uint32 {
if len(ip) == 16 {
return binary.BigEndian.Uint32(ip[12:16])
}
return binary.BigEndian.Uint32(ip)
}
func int2ip(nn uint32) net.IP {
ip := make(net.IP, 4)
binary.BigEndian.PutUint32(ip, nn)
@smallnest
smallnest / HttpProxy.go
Created July 29, 2021 08:34 — forked from yowu/HttpProxy.go
A simple HTTP proxy by Golang
package main
import (
"flag"
"io"
"log"
"net"
"net/http"
"strings"
)
@smallnest
smallnest / sched.go
Created July 7, 2021 08:11 — forked from ipcjk/sched.go
golang syscall set real time priority for task
package main
import (
"fmt"
"syscall"
"unsafe"
)
const (
SCHED_NORMAL = iota