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 / 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 / decode.md
Created September 7, 2018 03:27 — forked from yang-wei/decode.md
Elm Json.Decode tutorial and cheatsheet

When receiving JSON data from other resources(server API etc), we need Json.Decode to convert the JSON values into Elm values. This gist let you quickly learn how to do that.

I like to follow working example code so this is how the boilerplate will look like:

import Graphics.Element exposing (Element, show)
import Task exposing (Task, andThen)
import Json.Decode exposing (Decoder, int, string, object3, (:=))

import Http
@ethagnawl
ethagnawl / JacksonKotlinModuleExample.kt
Created August 23, 2018 04:49 — forked from hansenji/JacksonKotlinModuleExample.kt
Jackson Kotlin Module Example
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
fun main(args: Array<String>) {
// val mapper = ObjectMapper().registerModule(KotlinModule())
// val mapper = ObjectMapper().registerKotlinModule()
val mapper = jacksonObjectMapper()
val writer = mapper.writerWithDefaultPrettyPrinter()
val json1 = writer.writeValueAsString(Data1(1, "Foo", "Bar"))
@ethagnawl
ethagnawl / gpg-import-and-export-instructions.md
Created December 20, 2017 05:35 — forked from chrisroos/gpg-import-and-export-instructions.md
Instructions for exporting/importing (backup/restore) GPG keys

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...

@ethagnawl
ethagnawl / README.md
Created November 21, 2017 05:42 — forked from hofmannsven/README.md
My simply Raspberry Pi Cheatsheet
# Goal: Allow addition of instances to a collection in a factory-built object
# when those instances require references to the parent.
# Typically occurs in Rails when one model has_many instances of another
# See more at:
# http://stackoverflow.com/questions/2937326/populating-an-association-with-children-in-factory-girl
# Usage
# Foo has_many :bar
#
@ethagnawl
ethagnawl / seeyouspacecowboy.cr
Last active November 4, 2017 21:42 — forked from seanlinsley/seeyouspacecowboy.rb
A Crystal verison because ... why not? :P
# Crystal fork of "SEE YOU SPACE COWBOY by DANIEL REHN (danielrehn.com)"
# by @ethagnawl
# Displays a timeless message in your terminal with cosmic color effects
# Usage:
# - build with `crystal build -o ~/seeyouspacecowboy seeyouspacecowboy.cr`
# - add `~/seeyouspacecowboy; sleep 2` to ~/.bash_logout
# (adjust the sleep variable to display the message for more seconds)
class String