Skip to content

Instantly share code, notes, and snippets.

@app.cli.command('shell', short_help='Runs a shell in the app context.')
def shell_command():
"""Runs an interactive Python shell in the context of a given
Flask application. The application will populate the default
namespace of this shell according to it's configuration.
This is useful for executing small snippets of management code
without having to manually configuring the application.
"""
import code
import gym
from gym import wrappers
import numpy as np
from collections import defaultdict
def main():
env = gym.make('FrozenLake-v0')
@SandeR2012
SandeR2012 / recover_source_code.md
Created March 13, 2017 09:41 — 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
@SandeR2012
SandeR2012 / gist:b919d611c246550b8c2d
Created April 29, 2015 12:00
MultiSafepay API for Python
import uuid
import random
import hashlib
import requests
from xml.sax.saxutils import escape
from xml.etree import ElementTree