Skip to content

Instantly share code, notes, and snippets.

Avatar

Buddhika Laknath laknath

View GitHub Profile
@CMCDragonkai
CMCDragonkai / python_subprocess_run_argparse_nargs.md
Created March 11, 2019 06:56
Python `subprocess.run` and `argparse` nargs (multi-value options) is tricky
View python_subprocess_run_argparse_nargs.md

Python subprocess.run and argparse nargs (multi-value options) is tricky

If you have a Python program that uses argparse nargs to specify multi-value options then you need to make sure that each value is its own parameter.

import subprocess

subprocess.run(
    [
 'command',
@csrutil
csrutil / ipset_generate.sh
Created May 15, 2017 06:42
IPSET - fetch certain countries ip blocks for iptables DROP
View ipset_generate.sh
#!/bin/bash
country_block=(china bangladesh cambodia hongkong india iran iraq jordan korea kuwait malysia morocco oman pakistan qatar saudi singapore sudan thailand taiwan emirates vietnam turkey)
@EdwardBetts
EdwardBetts / pprint_color.py
Last active November 4, 2022 08:45
Python pprint with color syntax highlighting for the console
View pprint_color.py
from pprint import pformat
from typing import Any
from pygments import highlight
from pygments.formatters import Terminal256Formatter
from pygments.lexers import PythonLexer
def pprint_color(obj: Any) -> None:
"""Pretty-print in color."""
@P7h
P7h / tmux_vs_screen.md
Last active June 8, 2022 04:05
tmux vs screen commands
View tmux_vs_screen.md

tmux vs. screen commands


Action tmux screen
start a new session tmux
tmux new
tmux new-session
screen
start a new session with a name tmux new -s name screen -S name
re-attach a detached session tmux attach
tmux attach-session
screen -r
re-attach a detached session with a name tmux attach -t name
tmux a -t name
screen -r name
re-attach an attached session (detaching it from elsewhere) tmux attach -dtmux attach-session -d screen -dr
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know
View latency.markdown

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs