Let's close the ultra-small library cycle with some awesome array-based templating. 323 bytes minified.
Just download the minified version here or include it into your code:
''' | |
matplotlib must be developer release for voxel support | |
install instructions: | |
https://matplotlib.org/devdocs/users/installing.html | |
''' | |
import matplotlib.pyplot as plt | |
import numpy as np | |
from mpl_toolkits.mplot3d import Axes3D | |
import matplotlib.animation as manimation |
#Evolution Strategies with Keras | |
#Based off of: https://blog.openai.com/evolution-strategies/ | |
#Implementation by: Nicholas Samoray | |
#README | |
#Meant to be run on a single machine | |
#APPLY_BIAS is currently not working, keep to False | |
#Solves Cartpole as-is in about 50 episodes | |
#Solves BipedalWalker-v2 in about 1000 |
#!/usr/bin/env python | |
from __future__ import print_function | |
from keras.models import Sequential | |
from keras.layers import TimeDistributed | |
from keras.layers.core import Dense, Activation, Dropout, RepeatVector, TimeDistributedDense | |
from keras.layers.recurrent import LSTM | |
from keras.utils.data_utils import get_file | |
import numpy as np | |
import random,string | |
import sys |
#!/usr/bin/env bash | |
# set -x | |
if [[ $EUID -ne 0 ]]; then | |
echo "You must be root to run this script" | |
exit 1 | |
fi | |
# Returns all available interfaces, except "lo" and "veth*". |
Let's close the ultra-small library cycle with some awesome array-based templating. 323 bytes minified.
Just download the minified version here or include it into your code:
Orthodox C++ (sometimes referred as C+) is minimal subset of C++ that improves C, but avoids all unnecessary things from so called Modern C++. It's exactly opposite of what Modern C++ suppose to be.
//////////////////////////////////////////////////////////////// | |
// | |
// Defer statement | |
// - Akin to D's SCOPE_EXIT or similar to Go's defer but scope-based | |
// | |
//////////////////////////////////////////////////////////////// | |
#if defined(__cplusplus) | |
extern "C++" { | |
// NOTE(bill): Stupid fucking templates | |
template <typename T> struct gbRemove_Reference { typedef T Type; }; |
The following gist is an extract of the article Flask-SQLAlchemy Caching. It allows automated simple cache query and invalidation of cache relations through event among other features.
# pulling one User object
user = User.query.get(1)
As of version 3.3, python includes the very promising concurrent.futures
module, with elegant context managers for running tasks concurrently. Thanks to the simple and consistent interface you can use both threads and processes with minimal effort.
For most CPU bound tasks - anything that is heavy number crunching - you want your program to use all the CPUs in your PC. The simplest way to get a CPU bound task to run in parallel is to use the ProcessPoolExecutor, which will create enough sub-processes to keep all your CPUs busy.
We use the context manager thusly:
with concurrent.futures.ProcessPoolExecutor() as executor: