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
""" | |
In https://github.com/pygfx/wgpu-py/issues/114 we tried to find a way | |
to invalidate numpy/memoryview views when the base memory was released. | |
This file lists some attempts (and related cases) that demonstrates how | |
thet do not work. | |
In the end, we've not found a way to do it. | |
""" | |
import ctypes |
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
from wgpu.gui.auto import WgpuCanvas, run | |
import pygfx as gfx | |
import pylinalg as la | |
import numpy as np | |
def set_position(ob, pos): | |
# compat between old and new api | |
if hasattr(ob, "local"): | |
ob.local.position = pos |
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
from datetime import datetime | |
import numpy as np | |
import time | |
n = 100000 | |
mark1 = datetime.now() |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>three.js sandbox</title> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"> | |
</head> | |
<body> | |
<div id='infodiv' style=""></div> | |
<script src='https://cdn.jsdelivr.net/gh/mrdoob/three.js@dev/build/three.js'></script> |
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
<html> | |
<script src='dist/plotly.js'></script> | |
<body> | |
<div id='myDiv'></div> | |
<script> | |
var source = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAlCAYAAAAA7LqSAAADmklEQVR4nO2XUWhTVxjHfyfdmKMN1oelK9QSLUVY2RWHrEKtLw66KQX30Ifpg0qxz31wb8O0UNjL1I3h09iDAy000D0Z0DJhEdslBXN7SwZBJmmbErKwNuU2UXDes4d4r700bib33KflD+Ge8+We78sv3/fdcy401VRTTTXVVFMIvxwnEhG5c97fP+lbLPARZHz8qBwY+AAA0zTp69MA/4B8cTo+flRq2n4MY42dMMFgEICRkZ+Uxw2odgigafudq2majn3nWLV8ATGMNdf44cPfd9lVyxeQwcF3MIw1gsEgY2OLzM9fYmDgPebnLzlQquVLj1y//pFcWan+R1eujLm+KxYTHDr0o/K4b6l2GI2efPnY3eTUqSMUiwmgBQDD+ANNC6sOCSgurUxmVAKUSpfp6tpHLJYiFksBL4AXaFr45Vy9lGUkkxmVhpEll9ukra1q6+raB+D68d3d76oK6ZKSjGQyozIWS5HLbVIujwCQyz0jHL4LVIHsT3f3r0xNfS3/zV8jUlpaNsT6eoS2tq/Q9TnSaZOZmRAzMyFKpcvo+hz5fEE5jGcQOxt2GeXzBQC2t6fY3p5y3bu+HnFsqmE8gdh9AThlZGtr67kzDoU6CIU6nPnGxioXLnzD0NCXLC7+rQTGE4jd3MePJ9H1OQBu3PjW2SO2tp6TTvfQ2dnhWjc9PSvs++2rVyl7aun6XTY2Vl22dLqHw4erp97Ozg6WlnqIRqfFqzVqIMADiL3x7cyGrb1733bGds8ArvK6f/+HRkPXVMNHhWj0pMzlNkkmw46tvT1NofAUTXtfPnnyrKbvgwf3yImJpPIznufSOns2C8Dt22EKhafMzq6Kf |
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
""" | |
Implementation of an iterator that yields the lines in a file in reverse order. | |
Copyright (C) 2018, Almar Klein | |
BSD licensed. | |
""" | |
## ===== The code ===== | |
def readlines_reversed(f): |
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
import os | |
def trim_py_files(*directories): | |
"""Remove trailing whitespace on all .py files in the given directories. | |
""" | |
nchanged = 0 | |
for directory in directories: | |
for root, dirs, files in os.walk(directory): | |
for fname in files: |
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
"use strict"; | |
function base64encode(b, last_two) { | |
"use strict"; | |
console.assert(b.BYTES_PER_ELEMENT == 1); | |
// Most Base64 encoders use +/ for the last two characters, but not all | |
if (last_two === undefined) last_two = '+/'; | |
// Init charcodes array | |
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" + last_two; | |
var charcodes = new Uint8Array(64); |
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
## Option 1 - strings for verbatim html, dicts for elements with attributes | |
class MyReactlikeWidget(ReactLike): | |
name = event.StringProp('john', settable=True) | |
def render(self): | |
return ['greet: ', | |
dict(type='b', | |
onclick=lambda:print('clicked!'), | |
innerHTML='hi ' + self.name), |
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
# Copyright 2016 (C) Almar Klein. Consider this 2-clause BSD licensed. | |
""" | |
I initially wrote this to be included in flexx for multiple processes | |
on the same machine to communicate, more specifically, to allow a Flexx | |
CLI to get info on and terminate running server processes. I tested it | |
to work on Windows and Linux. I eventuially discarded this approach | |
because I don't fully get how UDP multicast works. It's important for | |
this to only work for localhost, and I am not sure if it does, or how | |
hard it is to compromise this. I went with a simpler approach based on | |
http requests using Tornado. |
NewerOlder