Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
#
# 4633c8a2a16a8e0428d253baafb76bbc18f29562390c84d1c85ba98865531a2b
CRYPTER="base64 -b 78"
HEADER="----BEGIN PGP MESSAGE----"
FOOTER="-----END PGP MESSAGE-----"
do_encryption() {
local plain="$1"
@simonw
simonw / recover_source_code.md
Last active January 16, 2024 08:13
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
// Go to https://twitter.com/messages and when the DM's modal is loaded,
// open the console and run this CSS overwrite rules :)
$('.DMInbox')[0].style.maxWidth = '100%'
$('.DMInbox')[0].style.width = '100%'
$('.DMInbox')[0].style.height = '100%'
$('.DMConversation')[0].style.maxWidth = '100%'
$('.DMConversation')[0].style.width = '100%'
$('.DMConversation')[0].style.height = '100%'
$('.DMDock')[0].style.height = '100%'
@arikfr
arikfr / export_lists.py
Created August 19, 2014 04:57
Simple script to export Twitter lists to CSV
import twitter # python-twitter
import csv
import cStringIO
import codecs
from requests_oauthlib import OAuth1Session
REQUEST_TOKEN_URL = 'https://api.twitter.com/oauth/request_token'
ACCESS_TOKEN_URL = 'https://api.twitter.com/oauth/access_token'
AUTHORIZATION_URL = 'https://api.twitter.com/oauth/authorize'
SIGNIN_URL = 'https://api.twitter.com/oauth/authenticate'
# Sort a list of dictionary objects by a key - case sensitive
from operator import itemgetter
mylist = sorted(mylist, key=itemgetter('name'))
# Sort a list of dictionary objects by a key - case insensitive
mylist = sorted(mylist, key=lambda k: k['name'].lower())