This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Defines 2 allocators: PooledAllocator, an allocator-allocator, and StackAllocator, | |
| // a contiguous-region-polymorphic allocator that allocates + recycles chunks from PooledAllocator. | |
| // Note: these are both stateful, custom allocators, and do NOT conform to std::allocator. | |
| // Note: not tested; will try compiling later. Should work. | |
| template <typename Traits> | |
| class MemoryChunk : public Traits::Base { | |
| MemoryChunk () : data(traits::Allocator::malloc(Traits::size)) {} | |
| ~MemoryChunk () { traits::Allocator::free(data); } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import math | |
| from math import sqrt | |
| def pi (n): | |
| x = 1 | |
| for i in range(n): | |
| x = 2 - sqrt(4 - x) | |
| return 3 * 2 ** n * sqrt(x) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace layout { | |
| class Style { | |
| // Border | |
| float bl, br, bb, bt; | |
| float minw, minh, maxw, maxh; | |
| auto bwidth () const { return bl + br; } | |
| auto bheight () const { return bb + bt; } | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Space War (Standing VR, targeting Vive, etc) | |
| Note: not really a gist thing, but will post to blog once that's working again. | |
| Builds on ideas in other game concepts (VR "omniscient grab-cam", etc – would be annoyed | |
| if someone implements that before I get around to it, but so far so good...). | |
| In a nutshell: For anyone who's read Ender's Game or watched the (pretty awesome) movie version, | |
| remember the battle simulator / control room used to control fleet actions? Basically that. | |
| – Symbolic 3d Vector graphics* | |
| – User Interface: 3d Point & click**, gestural, contextual menus linked to buttons + thumbpads*** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Sig figs (pet peeve): | |
| As a CS / sort-of math major, it seems like it would make much more sense to just record scientific | |
| measurements as ranges / intervals, ie. (4.867 ± 0.0005), and treat them as algebraic pairs / 2-tuples, | |
| with a few special rules for how the error value gets carried; a neat result would be that in exact | |
| (infinite precision) figures the error value is zero, eg (4.25 ± 0) | |
| Rules are quite simple, with the rule that numbers are represented by (a + be), where e is a symbolic | |
| placeholder like i, and defined such that e^n = e^m for all n, m ≠ 0. (ie. e propagates, but e^2 = e = e^-1, etc). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This is a snippet from https://github.com/SeijiEmery/GLSandbox/blob/master/fsevents-test/main.cpp | |
| void fsEventCallback ( | |
| ConstFSEventStreamRef streamRef, | |
| void *clientCallBackInfo, | |
| size_t numEvents, | |
| void *eventPaths, | |
| const FSEventStreamEventFlags eventFlags[], | |
| const FSEventStreamEventId eventIds[] | |
| ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Note: designed to be a lazy algorithm (but didn't get that working), | |
| # which is why primeSieve() operates on "chunks" of primes and may reuse | |
| # prev results. | |
| # | |
| # Todo: | |
| # – since only arithmetic + shifts, could use python bignums (or write | |
| # own algorithms) to hit arbitrary bounds | |
| # – key is storage: need to store primes as deltas, and implement algorithm | |
| # that operates w/ prime deltas and _one_ bignum instead of lots of big numbers. | |
| # This would solve lots of issues + make massively more efficient (I think) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| ASM Sandbox: | |
| – A graphical sandbox for x86 assembly. | |
| – Sandbox portion is implemented using glfw + some gui toolkit. (imgui?) | |
| – Assembly programs are assembled, then loaded _into_ the sandbox, as opposed | |
| to linking to + launching the sandbox themselves. Benefit is faster iteration | |
| times and hotloading. | |
| x86 API(s): | |
| – Starting function is <module_name>_main |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; | |
| ; nasm / masm comparison. | |
| ; | |
| ; First I'm going to briefly discuss how nasm does things, because it's | |
| ; simpler, and then show how this applies to masm. | |
| ; | |
| ; This should hopefully improve your understanding of masm, and | |
| ; understand what its quirks are and why + how it does things. | |
| ; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // see http://stackoverflow.com/questions/3219393/stdlib-and-colored-output-in-c | |
| // https://en.wikipedia.org/wiki/ANSI_escape_code#Colors | |
| // | |
| // This is based on the xterm 24-bit RGB format, and from my own testing, is compatible | |
| // with bash, fish, and zsh. | |
| // | |
| #include "stdio.h" |