Skip to content

Instantly share code, notes, and snippets.

View kevinw's full-sized avatar

Kevin Watters kevinw

View GitHub Profile
@kevinw
kevinw / segfault.zig
Last active July 17, 2019 10:02
zig segfault
// search for "BUG" to see the lines causing a segfault
const ENABLE_SEGFAULT = true;
const std = @import("std");
const FnPtr = fn () f64;
const EvalError = error{
ParseFloat,
ParserOutOfMemory,
const Node = struct {
t: type = bool,
next: ?*Node = null,
};
var registry: ?*Node = null;
fn addComponent(comptime T: type) void {
registry = Node{ .t = T, .next = registry };
}
@kevinw
kevinw / registry.zig
Created July 10, 2019 13:00
comptime type registry zig
var allComponentTypes: []type = undefined;
fn addComponent(comptime T: type) void {
allComponentTypes = allComponentTypes ++ [1]type{T};
}
test "add component" {
const Mover = struct {
foo: bool,
};
const Builder = @import("std").build.Builder;
const warn = @import("std").debug.warn;
const builtin = @import("builtin");
pub fn build(b: *Builder) void {
var exe = b.addExecutable("hello", "hello.zig");
exe.setBuildMode(b.standardReleaseOptions());
exe.addIncludeDir(".");
exe.addIncludeDir("C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.16299.0\\shared");
exe.addIncludeDir("C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.16299.0\\um");
@kevinw
kevinw / vfx-graph-hack.asmdef
Created April 4, 2019 16:06
Custom Unity VFX Graph node blocks and outputs hack
{
"name": "Unity.VisualEffectGraph.EditorTests",
"references": [
"Unity.VisualEffectGraph.Editor",
"Unity.VisualEffectGraph.Runtime"
],
"optionalUnityReferences": [],
"includePlatforms": ["Editor"],
"excludePlatforms": [],
"allowUnsafeCode": false,
@kevinw
kevinw / _README for Odin Vim ALE Linting.md
Last active September 18, 2019 02:06
run `odin check -vet` as a Vim ALE linter (async code checking as you write)

Until I get odin support in ALE's tree proper, here's how you register an odin check -vet linter with ALE so your edit->compile->fix loop is shorter!

An animated gif of vim's odin ALE support

Mozilla Creative Media Awards Webinar Notes

Mozilla exists to protect a healthy and open and accessible and decentralized and inclusive internet

NetGain - parent foundation; Definitely read the "Automation and the Quantified Society" whitepaper.

We're not talking about "the terminator or skynet" -- talking about issues that we're seeing RIGHT NOW. machine bias, social justice, equity, inclusive society.

check out: Propublica's investigation into a system to predict whether defendents are likely to commit a crime again.

fn compile_exe() -> Result<(), failure::Error> {
use cretonne::prelude::Configurable;
use cretonne_native;
use cretonne_faerie::{FaerieTrapCollection, FaerieBuilder, FaerieBackend};
use cretonne_codegen::settings;
use cretonne_module::Module;
use target_lexicon::BinaryFormat;
let (mut flag_builder, isa_builder) = cretonne_native::builders().unwrap_or_else(|_| {
panic!("host machine is not a supported target");
@kevinw
kevinw / CameraRaymarch.cs
Last active May 22, 2018 19:21
Using CalculateFrustumCorners to raymarch in VR
static Matrix4x4 FrustumCornersMatrix(Camera cam, Camera.MonoOrStereoscopicEye eye)
{
var camtr = cam.transform;
cam.CalculateFrustumCorners(new Rect(0, 0, 1, 1), cam.farClipPlane, eye, frustumCorners);
Matrix4x4 frustumMatrix = Matrix4x4.identity;
frustumMatrix.SetRow(0, camtr.TransformVector(frustumCorners[0]));
frustumMatrix.SetRow(1, camtr.TransformVector(frustumCorners[3]));
frustumMatrix.SetRow(2, camtr.TransformVector(frustumCorners[1]));
frustumMatrix.SetRow(3, camtr.TransformVector(frustumCorners[2]));
@kevinw
kevinw / RaymarchTemplate.shader.diff
Last active May 14, 2018 17:02
New changes in RaymarchTemplate.shader
diff --git a/Assets/Raymarching Toolkit/Assets/Shaders/RaymarchTemplate.shader b/Assets/Raymarching Toolkit/Assets/Shaders/RaymarchTemplate.shader
index 6cd2a38f..12e3b027 100644
--- a/Assets/Raymarching Toolkit/Assets/Shaders/RaymarchTemplate.shader
+++ b/Assets/Raymarching Toolkit/Assets/Shaders/RaymarchTemplate.shader
@@ -46,17 +46,11 @@ CGPROGRAM
#pragma vertex vert
#pragma fragment frag
-#if RENDER_OBJECT
#include "UnityCG.cginc" // @noinlineinclude