Skip to content

Instantly share code, notes, and snippets.

View su-tiko's full-sized avatar
🤜
Working at 127.0.0.1

Tiko JG su-tiko

🤜
Working at 127.0.0.1
View GitHub Profile
@su-tiko
su-tiko / linux-commands-snippets.md
Last active November 11, 2019 16:22
Useful linux commands

ctrl+x+e Open an editor for writing a large command

mount -t tmpfs tmpfs <folder> -o size=8192M Mounts a temporary RAM disk to folder. Useful for temp files with very high speed.

tee -a <file> Captures stdout and writes it to <file>

disown -a && exit Closes the terminal without stopping running commands

sudo du -a / 2>/dev/null | sort -n -r | head -n 20 Find the 20 largest files in linux

@su-tiko
su-tiko / greplines.sh
Created March 27, 2019 09:39
Grep all lines from the first to the last occurrence of a pattern in a file
# !/bin/bash
#
# greplines.sh
# Grep all lines from first to last occurrence of <pattern> in <file>
#
if [ "$#" -lt 2 ]; then
echo "usage: $0 <pattern> <file> [-v]"
exit
fi
sudo lsblk
sudo growpart /dev/[DEVICE_ID] [PARTITION_NUMBER]
sudo resize2fs /dev/[DEVICE_ID][PARTITION_NUMBER]
@su-tiko
su-tiko / Upgrade shell to full TTY.md
Last active April 25, 2024 02:00
Pass from a no-interactive shell to fully TTY

Python

python -c 'import pty; pty.spawn("/bin/bash")'

Socat

Listener

socat file:`tty`,raw,echo=0 tcp-listen:4444
@su-tiko
su-tiko / .tmux.conf
Created September 27, 2019 11:55
Custom tmux conf
set -g history-limit 1000000
set -g allow-rename off
# Join windows
bind-key j command-prompt -p "join pane from:" "join-pane -s '%%'"
bind-key s command-prompt -p "send pane to:" "join-pane -t '%%'"
# split panes using | and -
bind | split-window -h
bind - split-window -v
@su-tiko
su-tiko / trace_decorate.py
Last active February 14, 2020 11:49
Decorator for profiling a function
import cProfile
import pstats
from io import StringIO
def print_profile(f):
"""
Wrap a function with this decorator to obtain profiling information;
the output of cProfile is sent to a logger called 'profile'.