https://gist.github.com/victor-shepardson/5b3d3087dc2b4817b9bffdb8e87a57c4
I'm using Ubuntu 16.04 with a GTX 1060
//in your .h file if using one | |
ofShader shader; | |
ofFbo fbo; | |
int w, h; | |
//in .cpp file | |
void ofApp::setup(){ | |
w = 640; h=480; | |
ofEnableDataPath(); | |
ofSetWindowShape(w,h); |
Wolfram Alpha input to get polynomial approximation to function on an interval | |
for example to approximate exp(x) with ax^2 + bx + 1 on [0,1]: | |
solve (partial derivatives wrt a,b of (integral of (exp(x)-(ax^2 +bx+1))^2 from 0 to 1)) for a,b | |
or properly: | |
Solve[ D[ Integrate[ (exp(x)-(ax^2 +bx+1))^2, {x,0,1} ], {{a,b}} ] = 0, {a,b}] |
running test | |
running egg_info | |
writing dependency_links to protobuf.egg-info/dependency_links.txt | |
writing protobuf.egg-info/PKG-INFO | |
writing namespace_packages to protobuf.egg-info/namespace_packages.txt | |
writing requirements to protobuf.egg-info/requires.txt | |
writing top-level names to protobuf.egg-info/top_level.txt | |
reading manifest file 'protobuf.egg-info/SOURCES.txt' | |
reading manifest template 'MANIFEST.in' | |
warning: no previously-included files found matching 'google/protobuf/internal/*.proto' |
import numpy as np | |
import matplotlib.pyplot as plt | |
from scipy.stats import norm, invgamma | |
# estimate a univariate gaussian by Gibbs sampling | |
true_mu = 10 | |
true_sigma = 2 | |
true_v = true_sigma**0.5 | |
N = 50 | |
R = 5000 |
from contextlib import contextmanager | |
import numpy as np | |
import torch | |
from torch import Tensor, ByteTensor | |
import torch.nn.functional as F | |
from torch.autograd import Variable | |
import pycuda.driver | |
from pycuda.gl import graphics_map_flags | |
from glumpy import app, gloo, gl |
https://gist.github.com/victor-shepardson/5b3d3087dc2b4817b9bffdb8e87a57c4
I'm using Ubuntu 16.04 with a GTX 1060
try: | |
from bokeh.io import push_notebook, output_notebook, show | |
from bokeh.plotting import figure | |
output_notebook() | |
def dynamic_image_figure(w,h): | |
"""create an RGB image figure in current cell and return an update function for it""" | |
def im2bokeh(img): | |
img = (img*255).astype(np.uint8) | |
img = np.dstack([img, np.ones(img.shape[:2], np.uint8) * 255]) | |
img = np.squeeze(img.view(np.uint32)) |
'use strict'; | |
(new Promise((resolve, reject) => { | |
resolve('success'); | |
})).then(x => {throw 'thrown error in then, no catch'}); | |
(new Promise((resolve, reject) => { | |
resolve('success'); | |
})).then(x => {throw 'thrown error in then, with catch'}) | |
.catch(err => Promise.reject(err)); |
import asyncio | |
def wrap_coroutine(coroutine): | |
def future(*a, **kw): | |
return asyncio.ensure_future(coroutine(*a, **kw)) | |
def sync(*a, **kw): | |
return asyncio.get_event_loop().run_until_complete(coroutine(*a, **kw)) | |
coroutine.sync = sync | |
coroutine.future = future | |
return coroutine |
import heapq | |
class PQDItem: | |
def __init__(self, k, v): | |
self.v = v | |
self.k = k | |
self.dead = False | |
def __lt__(self, other): | |
return self.v < other.v |