Skip to content

Instantly share code, notes, and snippets.

@Ja7ad
Ja7ad / proto.md
Last active February 28, 2022 12:07
Protocol Buffers Principles

Protocol Buffers Structures

syntax = "proto3";
option go_package = "github.com/Ja7ad/bookstore";

service Greeter {
  rpc GetBook(GetBookRequest) returns (Book) {}
  rpc AddBook(AddBookRequest) returns (Book) {}
  rpc AddManyBook(AddManyBookRequest) returns (google.protobuf.Empty) {}
  rpc UpdateBook(UpdateBookRequest) returns (Book) {}
@Merovius
Merovius / README.md
Created July 16, 2021 22:55
MergeSlice benchmarks

The post Go is not C, so there is not an extreme fast way to merge slices alleges a performance problem with Go's model of zeroing memory on allocation, in cases where it might not be needed. The methodology is

  • Run a benchmark that merges some slices, by makeing one of the appropriate size and copying the individual slices over
  • Run a benchmark that zeros a slice of the appropriate slice
  • Subtract the two numbers and call it the "overhead of zeroing"

I have some trouble with that methodology. For one, it assumes that the zeroing

@ribice
ribice / caller.go
Last active July 7, 2023 07:07
A robust rabbitmq client for Go
go func() {
for {
err = rmq.Stream(cancelCtx)
if errors.Is(err, rabbitmq.ErrDisconnected) {
continue
}
break
}
}()
@ekiara
ekiara / using-wget-with-socks-proxy
Last active July 20, 2023 16:46
Using wget with socks proxy
# using-wget-with-socks-proxy
# This should work for everything includeing curl, pip, pipenv, etc
# TLDR: Use proxychains (https://github.com/haad/proxychains)
## INSTALL PROXY CHAINS ##
$ sudo apt update -y
$ sudo apt install proxychains
## EDIT PROXYCHAINS CONFIG ##
@nickmccurdy
nickmccurdy / env.go
Created March 13, 2014 00:22
List all environment variables in Go
package main
import (
"os"
"fmt"
)
func main() {
for _, pair := range os.Environ() {
fmt.Println(pair)