Skip to content

Instantly share code, notes, and snippets.

View HirbodBehnam's full-sized avatar

Hirbod Behnam HirbodBehnam

View GitHub Profile
@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;
@seriyps
seriyps / mtp_install.sh
Last active May 24, 2024 16:11
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
@miguelmota
miguelmota / rsa_util.go
Last active May 10, 2024 20:54
Golang RSA encrypt and decrypt example
package ciphers
import (
"crypto/rand"
"crypto/rsa"
"crypto/sha512"
"crypto/x509"
"encoding/pem"
"log"
)
@chrisdone
chrisdone / gist:02e165a0004be33734ac2334f215380e
Last active June 10, 2024 19:30
Build and run minimal Linux / Busybox systems in Qemu

Common

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

Linux kernel

@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 &
@arsham
arsham / go_cpu_memory_profiling_benchmarks.sh
Last active June 26, 2024 13:32
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
@qhwa
qhwa / go_port_forwarding.go
Last active June 25, 2024 20:36
network port forwarding in go lang
package main
import (
"fmt"
"io"
"net"
)
func main() {
ln, err := net.Listen("tcp", ":8080")