Skip to content

Instantly share code, notes, and snippets.

@sanatgersappa
sanatgersappa / alt.go
Last active March 28, 2020 07:24
Alternative handler for multiple file uploads in Go.
package main
import (
"html/template"
"io"
"net/http"
"os"
)
//Compile templates on start
@fabrizioc1
fabrizioc1 / http-proxy.go
Last active October 27, 2020 12:32
Http proxy server in Go
package main
import (
"fmt"
"io"
"log"
"net/http"
)
type HttpConnection struct {
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active March 28, 2024 11:13
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@jboner
jboner / latency.txt
Last active March 29, 2024 01:48
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@kfox
kfox / sysctl.conf
Created February 29, 2012 17:32
Linux kernel tuning settings for large number of concurrent clients
# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and
# sysctl.conf(5) for more details.
# Controls source route verification
net.ipv4.conf.default.rp_filter = 1
# Do not accept source routing
net.ipv4.conf.default.accept_source_route = 0
@willb
willb / ptr_inspect.c
Created October 3, 2008 01:57
This is some example code showing how to use the ptrace system call under Linux to trace the system calls of a child process.
/*
ptr_inspect.c
Demonstration code; shows how to trace the system calls in a child
process with ptrace. Only works on 64-bit x86 Linux for now, I'm
afraid. (Even worse, it's only tested on Linux 2.6....)
The callname() function looks clunky and machine-generated because it
*is* clunky and machine-generated.