Skip to content

Instantly share code, notes, and snippets.

View prideout's full-sized avatar
🎯
Focusing

Philip Rideout prideout

🎯
Focusing
View GitHub Profile
@prideout
prideout / servewasm.py
Created November 8, 2018 00:44
Python WASM server
#!/usr/bin/env python3
import http.server
import socketserver
PORT = 8000
Handler = http.server.SimpleHTTPRequestHandler
Handler.extensions_map.update({
'.wasm': 'application/wasm',
template <typename T>
bool operator()(T const* const* parameters, T* residuals) const {
const T* inputs = parameters[0];
size_t i = 0;
for (size_t n = _constraints.size(); i < n; ++i) {
T residual(0.0);
const Constraint& constraint = _constraints[i];
switch (constraint.type) {
case ConstraintType::ArcLineTangent: {
const auto& info = constraint.arc_line_tangent;
@prideout
prideout / compression_experiment.md
Last active March 29, 2022 20:53
Ubershader Archive Compression

zstd is a C library that features very fast decompression (similar to snappy) and dictionary-based compression.

Asking zstd to perform best possible compression is slow, but decompressing the result is still fast.

It also has command tool:

brew install zstd
#!/usr/bin/env python3
from nfft import nfft
import matplotlib.pyplot as plt
import numpy as np
from numpy.fft import fft
def gen_values(times: np.ndarray) -> np.ndarray:
"Compose three waves."
freq = 1
@prideout
prideout / texturegen.md
Last active February 4, 2022 07:11
Papers about infinitely large textures / point sets.

Image Quilting can be used to synthesize a large texture from a tiny texture; it was coined in Efros 2001, which introduced the idea of a cutting a minimum cost path through a tile to make the seams less discernable. ("Image Transfer" is also discussed in this paper, which is less interesting to me.)

Wang Tiles were popularized in Cohen 2003. These make it possible to apply image quilting over an infinite region, by baking out a small set of orientable tiles. (They can also be used for generating maze-like structures, which is somewhat orthogonal to the image quilting stuff.)

Wang Tiles can also be used to generate aperioidic tilings of blue noise (or point samples), and they can even be applied in a recursive manner, which allows for infinite zoom; see Kopf 2006, as well as [this excelle

#version 310 es
// glslc -std=310es -fshader-stage=vertex piecewise.glsl
// spirv-opt -Os a.spv -o b.spv
// spirv-cross b.spv
layout(binding = 0) uniform FrameUniforms {
mat4 clipFromWorldMatrix;
} frameUniforms;
@prideout
prideout / console.js
Last active March 3, 2021 04:23
github display rich diff everywhere
// clock all <button> with aria-label="Display the rich diff"
buttons = [].filter.call(
document.getElementsByTagName('button'),
el => el.getAttribute('aria-label') == "Display the rich diff");
buttons.forEach(el => el.click())
* thread #3, name = 'FEngine::loop', stop reason = signal SIGSEGV: invalid address (fault address: 0x7fff00000000)
* frame #0: 0x00007ffff2b6f37e libc.so.6`__libc_malloc + 286
frame #1: 0x00007ffff32ac4b9 libvk_swiftshader.so`(anonymous namespace)::alignedMalloc(alignment=8, size=272) at memory.cpp:185:21
frame #2: 0x00007ffff32ac1f8 libvk_swiftshader.so`(anonymous namespace)::DefaultAllocator::allocate(this=0x00007ffff7e22be8, request=0x00007ffff10a7a68) at memory.cpp:210:13
frame #3: 0x00007ffff30d4763 libvk_swiftshader.so`std::shared_ptr<marl::Event::Shared> marl::Allocator::make_shared<marl::Event::Shared, marl::Allocator*&, marl::Event::Mode&, bool&>(this=0x00007ffff7e22be8, args=0x00007ffff10a7ab8, args=0x00007ffff10a7ac7, args=0x00007ffff10a7ac6) at memory.h:227:16
frame #4: 0x00007ffff30d36c7 libvk_swiftshader.so`marl::Event::Event(this=0x0000000002071440, mode=Manual, initialState=false, allocator=0x00007ffff7e22be8) at event.h:187:25
frame #5: 0x00007ffff30d35e3 libvk_swiftshad
@prideout
prideout / MainActivity.kt
Last active May 4, 2020 20:27
getting-started-animation
private val frameCallback = object : Choreographer.FrameCallback {
private val startTime = System.nanoTime()
override fun doFrame(currentTime: Long) {
val seconds = (currentTime - startTime).toDouble() / 1_000_000_000
choreographer.postFrameCallback(this)
modelViewer.animator?.apply {
if (animationCount > 0) {
applyAnimation(0, seconds.toFloat())
}
updateBoneMatrices()