Skip to content

Instantly share code, notes, and snippets.

View ethagnawl's full-sized avatar
🐢

Pete Doherty ethagnawl

🐢
View GitHub Profile
@ethagnawl
ethagnawl / recover_source_code.md
Created May 17, 2024 16:36 — forked from simonw/recover_source_code.md
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
@ethagnawl
ethagnawl / i3autolock.md
Created June 24, 2023 16:56 — forked from rometsch/i3autolock.md
Configure lockscreen for i3 window manager.

The i3-wm does not come with a keybinding to lock the screen or a preconfigured auto lockscreen. This gist describes how to setup both using i3lock and xautolock. i3lock is a minimalistic lockscreen and xautolock monitors mouse and keyboard activities to automatically lock the screen after a certain time of beiing inactive.

First get the tools if neccessary. E.g. sudo apt install i3lock xautolock.

To setup the keybinding Ctrl+Alt+l (last one is a lowercase L) to lock the screen append the following lines to the i3 configuration file located at ~/.config/i3/config.

# keybinding to lock screen
@ethagnawl
ethagnawl / Install NVIDIA Driver and CUDA.md
Created February 12, 2022 19:56 — forked from wangruohui/Install NVIDIA Driver and CUDA.md
Install NVIDIA Driver and CUDA on Ubuntu / CentOS / Fedora Linux OS
@ethagnawl
ethagnawl / .tmux.conf
Created June 7, 2020 13:29
tmux pane titles
# tmux config file
# the rest of your config file ...
# This example creates a variable named `custom_pane_title` which will be
# displayed if and only if it has been set -- in this case by by your
# tmuxinator pane commands.
# This feature doesn't seem to be documented, otherwise I'd provide a link.
# I _believe_ this feature requires tmux >= 3.0
set -g pane-border-format "#{pane_index}#{?@custom_pane_title,:#{@custom_pane_title},}:#{pane_title}"
@ethagnawl
ethagnawl / gist:78c1d0945400987b29d8a0b281ecea0a
Created April 14, 2020 17:10
Find Raspberry Pi IP using arp-scan
sudo arp-scan --localnet 2> /dev/null | grep Pi | awk '{print $1}'
# https://www.postgresqltutorial.com/postgresql-indexes/postgresql-list-indexes/
SELECT
tablename,
indexname,
indexdef
FROM
pg_indexes
WHERE
schemaname = 'public'
ORDER BY
@ethagnawl
ethagnawl / pg_stat_activity.sql
Created January 18, 2020 03:13
view postgres clients
select pid as process_id,
usename as username,
datname as database_name,
client_addr as client_address,
application_name,
backend_start,
state,
state_change
from pg_stat_activity;
@ethagnawl
ethagnawl / break.py
Created September 6, 2019 20:08 — forked from obfusk/break.py
python equivalent of ruby's binding.pry
import code; code.interact(local=dict(globals(), **locals()))
@ethagnawl
ethagnawl / reverse-tunnel.service
Created August 5, 2019 16:25
auto reverse tunneling
[Unit]
Description=Reverse SSH Tunnel
After=network.target
[Service]
ExecStart=/usr/bin/ssh -N -R 27276:localhost:22 -o "ExitOnForwardFailure yes" server
KillMode=process
Restart=always
[Install]
@ethagnawl
ethagnawl / sort-dir-size-recursive.sh
Created June 14, 2019 16:22
list/sor directories by content size
du -s * | sort -k 1,1 -V