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 / repair.py
Created October 15, 2024 12:38
repair tokenizer
import json
# Define the input and output file paths
input_file = 'fused_model/tokenizer.json'
output_file = 'fused_model/repaired_tokenizer.json'
# Read the JSON file containing the entire structure
with open(input_file, 'r', encoding='utf-8') as f:
data = json.load(f)
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
#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;
* 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 / gist:63cc56bb4fbc9847e3779fec0db75c31
Created April 25, 2020 00:02
Vulkan Validation on macOS
(1) cd ~/github/glslang/build
git pull
cmake ..
sudo chown -R $(whoami) /usr/local/bin /usr/local/etc /usr/local/sbin /usr/local/share /usr/local/share/doc
make install
(2) cd ~/github/Vulkan-Headers
git pull
rm -rf build ; mkdir -p build && cd build
@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())
@prideout
prideout / MainActivity.kt
Created April 3, 2020 02:45
getting-started-names
val asset = modelViewer.asset!!
val rm = modelViewer.engine.renderableManager
for (entity in asset.entities) {
val renderable = rm.getInstance(entity)
if (renderable == 0) {
continue
}
if (asset.getName(entity) == "Scheibe_Boden_0") {
rm.setLayerMask(renderable, 0xff, 0x00)
}