This file contains hidden or 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 animate(i): | |
return plt.plot(x[:i], y[:i], c='r') | |
x = np.linspace(0, 2*np.pi, 100) | |
y = np.sin(x) | |
fig = plt.figure(figsize=(12, 8)) | |
plt.xlim(0, 2 * np.pi) | |
plt.ylim(-1, 1) | |
anim = animation.FuncAnimation(fig, animate, frames=100) | |
display(HTML(anim.to_html5_video())) |
This file contains hidden or 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
from kafka import KafkaConsumer | |
consumer = KafkaConsumer('fast-messages', bootstrap_servers='localhost:9092') | |
for message in consumer: | |
print(message) |
This file contains hidden or 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
FROM ubuntu:latest | |
MAINTAINER Vaclav Cadek | |
RUN apt-get update | |
RUN apt-get install python-virtualenv -y | |
RUN virtualenv -p /usr/bin/python3 ~/venv | |
RUN . ~/venv/bin/activate | |
RUN ~/venv/bin/pip install numpy pandas matplotlib jupyter |
This file contains hidden or 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
from scipy import stats | |
import matplotlib.pyplot as plt | |
import numpy as np | |
def PoissonPP( rt, Dx, Dy=None ): | |
''' | |
Determines the number of events `N` for a rectangular region, | |
given the rate `rt` and the dimensions, `Dx`, `Dy`. | |
Returns a <2xN> NumPy array. | |
''' |
This file contains hidden or 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
from ortools.sat.python import cp_model | |
class SolutionPrinter(cp_model.CpSolverSolutionCallback): | |
def __init__(self, variables): | |
super().__init__() | |
self.variables = variables | |
self.solutions = [] |
This file contains hidden or 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 rgb2hex(rgb): | |
return ''.join([format(val, '02X') for val in rgb]) |
This file contains hidden or 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
51 | |
27 68 | |
30 48 | |
43 67 | |
58 48 | |
58 27 | |
37 69 | |
38 46 | |
46 10 | |
61 33 |
This file contains hidden or 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
from scipy.integrate import simpson | |
import matplotlib.pyplot as plt | |
import numpy as np | |
def almost_fourier_transform(g: np.ndarray, t: np.ndarray, f: float): | |
# approximate center of mass as a mean | |
t1 = np.min(t) | |
t2 = np.max(t) | |
scaling_factor = (1 / (t2 - t1)) |
This file contains hidden or 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
FROM python:3.8-alpine | |
# Define global args | |
ARG FUNCTION_DIR="/home/app/" | |
RUN apk add --no-cache \ | |
libstdc++ | |
# Install aws-lambda-cpp build dependencies | |
RUN apk add --no-cache \ |
This file contains hidden or 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
import json | |
import pickle | |
class Foo: | |
""" An old Foo.""" | |
def __init__(self, a, b): | |
self.a = a | |
self.b = b |