Skip to content

Instantly share code, notes, and snippets.

View HirbodBehnam's full-sized avatar

Hirbod Behnam HirbodBehnam

View GitHub Profile
@qhwa
qhwa / go_port_forwarding.go
Last active September 8, 2024 19:01
network port forwarding in go lang
package main
import (
"fmt"
"io"
"net"
)
func main() {
ln, err := net.Listen("tcp", ":8080")
@arsham
arsham / go_cpu_memory_profiling_benchmarks.sh
Last active October 16, 2024 11:38
Go cpu and memory profiling benchmarks. #golang #benchmark
go test -run=. -bench=. -benchtime=5s -count 5 -benchmem -cpuprofile=cpu.out -memprofile=mem.out -trace=trace.out ./package | tee bench.txt
go tool pprof -http :8080 cpu.out
go tool pprof -http :8081 mem.out
go tool trace trace.out
go tool pprof $FILENAME.test cpu.out
# (pprof) list <func name>
# go get -u golang.org/x/perf/cmd/benchstat
benchstat bench.txt
@madeye
madeye / iperf.sh
Created February 3, 2017 01:29
Bandwidth test for shadowsocks
#!/bin/bash
method=$1
ss-tunnel -k test -m $method -l 8387 -L 127.0.0.1:8388 -s 127.0.0.1 -p 8389 &
ss_tunnel_pid=$!
ss-server -k test -m $method -s 127.0.0.1 -p 8389 &
ss_server_pid=$!
iperf -s -p 8388 &
@chrisdone
chrisdone / gist:02e165a0004be33734ac2334f215380e
Last active October 4, 2024 00:07
Build and run minimal Linux / Busybox systems in Qemu

Common

export OPT=/opt
export BUILDS=/some/where/mini_linux
mkdir -p $BUILDS

Linux kernel

@miguelmota
miguelmota / rsa_util.go
Last active September 27, 2024 02:42
Golang RSA encrypt and decrypt example
package ciphers
import (
"crypto/rand"
"crypto/rsa"
"crypto/sha512"
"crypto/x509"
"encoding/pem"
"log"
)
@seriyps
seriyps / mtp_install.sh
Last active September 7, 2024 06:44
Interactive MTProto proxy installer
#!/bin/bash
# Automatic interactive installer for mtproto proxy https://github.com/seriyps/mtproto_proxy
# Supported OS:
# - Ubuntu 18.xx
# - Ubuntu 19.xx
# - Ubuntu 20.xx
# - Ubuntu 21.xx
# - Ubuntu 22.xx
# - Debian 11 bullseye
# - Debian 10 buster
@lellis1936
lellis1936 / AESGCM.cs
Created November 2, 2019 15:56
GCM Encryption / Decryption on Windows .Net Full Framework
//Requires PInvoke.BCrypt
//Note that AES GCM encryption is included on .Net Core 3.0, but not in the full .Net framework.
//This implementation requires PInvoke.BCrypt, and reulies on the Windows CNG Bcrypt library which
//is available on Windows Vista or later. Note also the requirement for unsafe code.
//As coded requires VS 2015 / C#6 or above.
using System;
using PInvoke;
using static PInvoke.BCrypt;
using System.Security.Cryptography;