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 / tutorial.js
Last active October 11, 2018 23:28
FilamentJS prototype example
class App {
constructor() {
this.canvas = document.getElementsByTagName('canvas')[0]
this.render = this.render.bind(this);
this.resize = this.resize.bind(this);
const TRIANGLE_POSITIONS = Filament.BufferDescriptor(new Float32Array([
1, 0,
@prideout
prideout / gist:cd3a3dd2ac10171b12e8
Created March 9, 2016 21:19
break on throw in LLDB
break set -E c++
@prideout
prideout / break.py
Created January 29, 2016 01:59
Break to Python interpreter
import code; code.interact(local=locals())
@prideout
prideout / gist:c962b47e5b8e3e4790e0
Created January 19, 2016 04:09
paste-to-console flatbuffers test for Python serialization
cd tests
cat > wombat.fbs <<EOF
namespace Fauna;
struct Foo { x:short; }
table Wombat { foos:[Foo]; }
EOF
../flatc -p wombat.fbs
cat > wombat.py <<EOF
import flatbuffers, binascii
from Fauna import Wombat, Foo
@prideout
prideout / dynamic_array.c
Last active January 16, 2016 18:17
dynamic array of uint16_t in C
#define PAR_CALLOC(T, N) ((T*) calloc(N * sizeof(T), 1))
#define PAR_REALLOC(T, BUF, N) ((T*) realloc(BUF, sizeof(T) * N))
#define PAR_FREE(BUF) free(BUF)
typedef struct {
uint16_t* values;
size_t count;
size_t capacity;
} par__uint16list;
@prideout
prideout / togray.py
Created December 2, 2015 22:25
Python script that extracts red from 3 BPP image and saves as 1 BPP image.
from PIL import Image
im = Image.open("color.png")
im.split()[0].save("gray.png")
@prideout
prideout / ScopeExit.cpp
Created December 1, 2015 05:52
automatically execute code when the scope ends
template <typename F>
struct ScopeExit {
ScopeExit(F f) : f(f) {}
~ScopeExit() { f(); }
F f;
};
template <typename F>
ScopeExit<F> MakeScopeExit(F f) {
return ScopeExit<F>(f);
@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

@prideout
prideout / steal-server.el
Created February 21, 2013 18:54
Steal the emacs server from another session and relabel its frame
(defun steal-server()
(interactive)
(shell-command "emacsclient -e '(set-frame-name \"STOLEN\")'")
(server-force-delete)
(server-start)
(set-frame-name "SERVER")
)
@prideout
prideout / parse-rib-stats.py
Last active December 1, 2015 05:49
dump all files that a RIB touches
# prman -statsfile FOO.xml BAR.rib
from lxml import etree
root = etree.parse('stats.xml').getroot()
print root.xpath("//set[@name='fileLog']/member/text()")