Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from scipy import integrate
import numpy as np
def spring_sys(t, y, m, b, k, F):
x, v = y
dx = v
dv = (F - k * x - b * v) / m
return dx, dv
def run_sim(x0, v0, m, b, k, F, tend, n):
get_svg = function(f){
let c = f.canvas.clone();
let v = new c.default_view({model:c});
f.canvas_view = v;
f.force_paint.emit();
return v._ctx.getSerializedSvg();
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import cv2
import numpy as np
import time
from collections import deque
vc = cv2.VideoCapture("rtsp://192.168.0.50:8080/h264_ulaw.sdp")
avg_buf = np.zeros((10, 600, 800, 3), float)
avg = np.zeros((600, 800, 3), float)
index = 0
digraph g {
graph [
rankdir = "LR"
];
node [
fontsize = "16"
shape = "ellipse"
];
edge [
];
@ruoyu0088
ruoyu0088 / bokeh_subprocess_test.py
Created May 12, 2018 04:23
a demo for zmq process with bokeh server
from os import path
from bokeh.models import Button, Div
from bokeh.layouts import column
from bokeh.document import without_document_lock
from bokeh.io import curdoc
from zmq_subprocess import ZmqSubProcessClient
ok_button = Button(label="ok")
div = Div()
def make_quiver(fig, x, y, u, v, scale_uv=None, arrow_size=5):
import numpy as np
from bokeh.models import ColumnDataSource, CustomJSTransform, CustomJS
from bokeh.transform import field
x, y, u, v = (np.asanyarray(arr).ravel() for arr in (x, y, u, v))
if scale_uv is None:
from scipy.spatial.distance import pdist, squareform
mean_dist = np.mean(np.sort(squareform(pdist(np.c_[x, y])), axis=1)[:, 1])
max_len = np.max(np.hypot(u, v))
from os import path
from bokeh.application.handlers import code_runner
def run(self, module, post_check):
import ast
if path.exists(self._path):
with open(self._path, 'r') as f:
source = f.read()