Skip to content

Instantly share code, notes, and snippets.

@albertstartup
albertstartup / recover_source_code.md
Created March 12, 2017 04:39 — 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
@albertstartup
albertstartup / bash-history-to-zsh-history.py
Created October 31, 2016 07:24 — forked from dllud/bash-history-to-zsh-history.py
Import bash history (has no timestamps) to zsh history.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This is how I used it:
# $ cat ~/.bash_history | python bash-history-to-zsh-history.py >> ~/.zsh_history
import sys
import time
def main():
@albertstartup
albertstartup / tf_lstm.py
Created October 4, 2016 03:42 — forked from siemanko/tf_lstm.py
Simple implementation of LSTM in Tensorflow in 50 lines (+ 130 lines of data generation and comments)
"""Short and sweet LSTM implementation in Tensorflow.
Motivation:
When Tensorflow was released, adding RNNs was a bit of a hack - it required
building separate graphs for every number of timesteps and was a bit obscure
to use. Since then TF devs added things like `dynamic_rnn`, `scan` and `map_fn`.
Currently the APIs are decent, but all the tutorials that I am aware of are not
making the best use of the new APIs.
Advantages of this implementation:
# author: Aaditya Prakash
# usage:
# python programs_on_gpu.py
# Sample Output
#GPU_ID GPU_MEM USER PGRP PID %CPU %MEM STARTED TIME COMMAND
#----- ------- ---- ---- --- ---- ---- ------- ---- -------
#1 11738MiB ap 25640 25640 158 2.4 00:47:15 00:43:01 python train.py
#2 11843MiB ap 23806 23806 99.4 2.0 00:46:22 00:27:50 python cifar10_cnn.py
@albertstartup
albertstartup / user-data.sh
Created June 8, 2016 05:26 — forked from shanestillwell/user-data.sh
Amazon User Data script
#!/bin/bash
### BEGIN INIT INFO
# Provides: ec2-run-user-data
# Required-Start: $network $local_fs $remote_fs $syslog $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Run EC2 user-data scripts
# Description: On first boot of EC2 instance, runs user-data if it starts with #!
# basic pfctl control
# ==
# Related: http://www.OpenBSD.org
# Last update: Tue Dec 28, 2004
# ==
# Note:
# this document is only provided as a basic overview
# for some common pfctl commands and is by no means
# a replacement for the pfctl and pf manual pages.