A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
| import datetime | |
| class Timer(object): | |
| """A simple timer class""" | |
| def __init__(self): | |
| pass | |
| def start(self): | |
| """Starts the timer""" |
Some things takes much less time and stress once you know the right tool. Below, there is a community edited list of software for scientists.
in General purpose text/code editors. It may be better to have a good editor for everything, than different ones for different languages, scripts, notes.
| ffmpeg -ss <start_time> -i video.mp4 -t <duration> -q:v 2 -vf select="eq(pict_type\,PICT_TYPE_I)" -vsync 0 frame%03d.jpg |
| # images to hdf5 | |
| # https://groups.google.com/forum/#!topic/h5py/9sA18XbC_ao | |
| # https://github.com/h5py/h5py/issues/268 | |
| import h5py | |
| import numpy | |
| def create_image_dataset(group, dataset_name, image, **kwargs): | |
| """ | |
| Create a dataset respecting the HDF5 image specification |
| """ | |
| This is a batched LSTM forward and backward pass | |
| """ | |
| import numpy as np | |
| import code | |
| class LSTM: | |
| @staticmethod | |
| def init(input_size, hidden_size, fancy_forget_bias_init = 3): |
| """ | |
| Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy) | |
| BSD License | |
| """ | |
| import numpy as np | |
| # data I/O | |
| data = open('input.txt', 'r').read() # should be simple plain text file | |
| chars = list(set(data)) | |
| data_size, vocab_size = len(data), len(chars) |
| #!/usr/bin/env bash | |
| # Installation script for Deep Learning Libraries on Ubuntu 14.04, by Roelof Pieters (@graphific) | |
| # BSD License | |
| orig_executor="$(whoami)" | |
| if [ "$(whoami)" == "root" ]; then | |
| echo "running as root, please run as user you want to have stuff installed as" | |
| exit 1 | |
| fi | |
| ################################### |