Skip to content

Instantly share code, notes, and snippets.

View laknath's full-sized avatar

Buddhika Laknath laknath

View GitHub Profile
@roaldnefs
roaldnefs / mac-docker-gui.txt
Created December 22, 2019 10:27
Running GUI application in Docker on MacOS
# Install XQuartz
brew cask install xquartz
# Restart MacOS
# Open XQuartz
open -a XQuartz
# Ensure the "Allow connections from network clients" option in Preferences >> Security is turned on
@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

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
#!/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 June 13, 2024 05:36
Python pprint with color syntax highlighting for the console
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 September 26, 2024 11:54
tmux vs screen commands

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

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