This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl https://api.binance.com/api/v3/exchangeInfo --header 'Accept-Encoding: gzip, deflate' | gunzip - |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The fundamental theorem of calculus, in discrete version! | |
import numpy as np | |
np.set_printoptions(linewidth=200, precision=2) | |
print('This Python snippet shows how the sum of many differences is one difference of endpoinds!') | |
print('You can consider this the "discrete fundamental theorem of calculus"!') | |
# ---------------------------------------------------------------------- | |
N_VALUES = 16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Compile and run with: | |
// nvcc add1.cu -o add1 && ./add1 | |
// This minimal CUDA program performs vector addition, component-wise! | |
#include <stdio.h> | |
#define N_ELEMENTS 8 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def load_ndarray(filename): | |
"""Load a NumPy array from disk into memory, with extension .npy or .7z. If no extension is | |
included in the argument, first assume it's .npy, then .7z. | |
Args: | |
filename (str): Name of the NumPy array (in disk). | |
Returns: | |
ndarray | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def save_ndarray(ndarray, filename, compress=False): | |
"""Store a single NumPy array on an .npy binary file. Tries to keep allow_pickle at False. | |
Optional multithreaded compression using 7-zip (needs to be in the PATH). | |
Args: | |
ndarray (ndarray): Array to be stored on disk. | |
filename (str): The file's name on disk. No need for .npy extension | |
compress (bool, optional): Set to True to save array as .npy and then compress it to .7z | |
Returns: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Vispy is based on OpenGL ES 2.0. | |
Vispy offers a Pythonic object-oriented interface to OpenGL, useful to those | |
who know OpenGL. | |
It is critical to use as few OpenGL draw calls as possible. Every draw incurs | |
a significant overhead. High performance is achieved by rendering all similar | |
primitive types at once (batch rendering). | |
The vertex shader is executed for EACH vertex that is given to the rendering |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@contextlib.contextmanager # Create factory function for *with* context managers | |
def timeit(): | |
"""Time execution of code, based on time.clock(). Call using a *with* statement! | |
Examples: | |
with timeit(): | |
a @ a | |
""" | |
start = time.clock() | |
yield # The decorated func must return a generator-iterator |