Skip to content

Instantly share code, notes, and snippets.

View Kuranes's full-sized avatar

Tuan Kuranes Kuranes

View GitHub Profile
# Simulator for depth comparison error (i.e. z-fighting)
# Nathan Reed, June 2015
# Written for Python 3.4; requires numpy
import math
import numpy as np
import optparse
# Parse command-line options
parser = optparse.OptionParser()
@rygorous
rygorous / symdiff.py
Created April 28, 2015 15:32
Figure out actual external deps in .a (only tested for OS X/iOS)
"""This tool queries undefined symbols in a lib, then queries defined
symbols, and then diffs the two sets so we know what the actual
externals for the purpose of the lib are."""
import os
import re
import subprocess
libname = 'libbink2.a' # command line parsing? please.
def parse_def_sym(str):
@gafferongames
gafferongames / delta_compression.cpp
Last active October 19, 2025 16:17
Delta Compression
/*
Delta Compression by Glenn Fiedler.
This source code is placed in the public domain.
http://gafferongames.com/2015/03/14/the-networked-physics-data-compression-challenge/
*/
#include <stdint.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Listing 2-2, Load Shaders From DOM</title>
<meta charset="utf-8">
<script id="shader-vs" type="x-shader/x-vertex">
attribute vec3 aVertexPosition;
void main() {
gl_Position = vec4(aVertexPosition, 1.0);
@ocornut
ocornut / printf_tips.cpp
Last active March 24, 2023 11:23
C/C++ tips for using printf-style functions
// C/C++ tips for using printf-style functions
// Lots of manipulation can be expressed simply and fast with printf-style formatting
// Also helps reducing the number of temporaries, memory allocations or copies
// ( If you are looking for a simple C++ string class that is printf-friendly and not heap-abusive,
// I've been using this one: https://github.com/ocornut/Str )
// If you are interested in a FASTER implementation of sprintf functions, see stb_sprintf.h
// https://github.com/nothings/stb/blob/master/stb_sprintf.h
// How to concatenate non-zero terminated strings
@pervognsen
pervognsen / asdf.el
Last active August 29, 2015 14:10
watch expressions with dbg.el
(defun dbg-watch (expression)
(interactive "sExpression: ")
(dbg-mi-command (list 'dbg-watch-handler expression) "-var-create - @ %s" (prin1-to-string expression)))
(defun dbg-watch-handler (status result expression)
(case status
((done)
(push (cons (cons 'expression expression) result) dbg-watches)))
(dbg-render-watches))
@pervognsen
pervognsen / dbg.el
Last active May 12, 2025 14:29
dbg.el
(require 'cl)
(require 'peg)
(defcustom dbg-mi-process-name "dbg-mi" "")
(defcustom dbg-mi-buffer-name "*dbg-mi*" "")
(defvar dbg-mi-process nil)
(defvar dbg-mi-buffer nil)
@jeromeetienne
jeromeetienne / consoleLogToScreen.js
Created September 25, 2014 13:55
console.log to screen - nice to debug mobile
//////////////////////////////////////////////////////////////////////////////////
// console.log to screen
//////////////////////////////////////////////////////////////////////////////////
;(function(){
var container = document.createElement('div')
container.dataset.name = 'consoleLogOnScreen'
container.style.width = '100%';
container.style.height = '100%';
container.style.position = 'absolute';
container.style.fontSize = '100%';
@dwilliamson
dwilliamson / GenerateSHConstants.c
Last active August 29, 2015 14:05
Generating SH constants from polynomial form in C-style comments
//
// Uses pycgen: https://github.com/Celtoys/pycgen
// Generates code for C, HLSL, CUDA and OpenCL
//
void SH_Y2(float3 n, cmp_out float y[9])
{
/*$pycgen
from math import pi
from math import sqrt
console.highlight = function(text, sample) {
var escapedSample = sample.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
var reSample = new RegExp(escapedSample, 'g');
var args = [''];
var highlightedText = text.replace(reSample, function(match) {
args.push('background-color: #ffc', 'background-color: none');
return '%c' + match + '%c';
});
args[0] = highlightedText;
console.log.apply(console, args);