Skip to content

Instantly share code, notes, and snippets.

@assafmo
assafmo / Golang_Flame_Graphs.md
Last active April 18, 2020 11:50
Golang Flame Graphs
package main

import "runtime/pprof"

func main() {
	pprof.StartCPUProfile(os.Stderr)
	defer pprof.StopCPUProfile()

 // ...
@assafmo
assafmo / sysctl.conf
Created December 12, 2018 08:40
set BBR for TCP
# put in /etc/sysctl.conf
net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr
@assafmo
assafmo / rescan_hd.sh
Created December 12, 2018 11:09
Rescan hard drives without rebooting
#!/bin/bash
echo "- - -" > sudo tee /sys/class/scsi_host/*/scan
@assafmo
assafmo / fstab
Last active December 13, 2018 19:07
Mount /tmp as tmpfs
# https://blog.ubuntu.com/2016/01/20/data-driven-analysis-tmp-on-tmpfs
# In /etc/fstab:
tmpfs /tmp tmpfs rw,size=128m,noexec,nosuid 0 0
@assafmo
assafmo / bluetooth_off.sh
Created December 13, 2018 20:55
Turn Bluetooth off on Linux
#!/bin/bash
rfkill block bluetooth
@assafmo
assafmo / client.sh
Last active May 30, 2019 09:45
SSH Over TOR (Good for any service, also to expose a server behind NAT)
#!/bin/bash
sudo apt install -y tor
# get hostname from /var/lib/tor/ssh/hostname on the server
torsocks ssh [email protected]
@assafmo
assafmo / url_to_pdf.sh
Last active December 27, 2018 16:12
Use headless chrome to print a page to pdf
#!/bin/bash
google-chrome --headless --disable-gpu --print-to-pdf="$PDF_NAME" "$URL"
@assafmo
assafmo / ssh_config
Last active December 30, 2018 19:51
SSH Multiplexing
# Put in ~/.ssh/config
Host *
ControlMaster auto
ControlPath ~/.ssh/%r@%h:%p
ControlPersist yes
ServerAliveInterval 30
@assafmo
assafmo / csv
Last active February 28, 2019 11:23
Handle CSV files with awk
gawk -v FPAT=\'[^,]*|"[^"]*"\' '{print $3}' < test.csv
@assafmo
assafmo / unmount.sh
Created February 19, 2019 10:10
Safely unmount disk on ubuntu
#!/bin/bash
DEV=$(mount | grep /media/ | awk '{print $1}')
udisksctl unmount -b "$DEV"
udisksctl power-off -b "$DEV"