Skip to content

Instantly share code, notes, and snippets.

@simonw
simonw / recover_source_code.md
Last active May 21, 2024 19:04
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
@jkern
jkern / Lisa10.py
Created November 15, 2010 02:07
LISA 10 Weigher
#!/usr/bin/python
import urllib2
import json
import base64
import operator
import math
PAGE = 1
BASE_URL='http://search.twitter.com/search.json?q=%23lisa10&rpp=100&until=2010-11-12&page='