Skip to content

Instantly share code, notes, and snippets.

View JackStouffer's full-sized avatar
💭
I may be slow to respond. Email me.

Jack Stouffer JackStouffer

💭
I may be slow to respond. Email me.
View GitHub Profile
@JackStouffer
JackStouffer / test.d
Created January 4, 2017 20:55
std.conv.parse!double auto decoding test
import std.stdio;
import std.range;
import std.algorithm;
import std.traits;
import std.container;
import std.meta;
import std.conv;
import std.datetime;
Target parse1(Target, Source)(ref Source p)
@JackStouffer
JackStouffer / test.d
Created January 4, 2017 18:57
auto decoding test for std.conv.parse!int
import std.stdio;
import std.range;
import std.algorithm;
import std.traits;
import std.container;
import std.meta;
import std.conv;
import std.datetime;
Target parse1(Target, Source)(ref Source s)

Keybase proof

I hereby claim:

  • I am JackStouffer on github.
  • I am jackstouffer (https://keybase.io/jackstouffer) on keybase.
  • I have a public key whose fingerprint is 5F6A 81FC BB9E BEF0 CFA3 AD73 7E49 FBE6 8B88 208C

To claim this, I am signing this object:

@JackStouffer
JackStouffer / circuit_breaker.py
Last active October 14, 2016 15:18
A Circuit Breaker, basically a way to auto fail to relieve pressure on an external service after a number of failures in quick succession
import datetime
BREAKER_OPEN = 0
BREAKER_HALF_OPEN = 1
BREAKER_CLOSED = 2
class OpenException(Exception):
pass
import std.stdio;
import std.datetime;
import std.conv;
import std.traits;
import std.utf;
import std.range;
import std.algorithm;
Target parse2(Target, Source)(ref Source p)
if (isInputRange!Source && isSomeChar!(ElementType!Source) && !is(Source == enum) &&
################ Unified Information ################
Cores per CPU = 2
Threads per CPU = 4
------------------ TLB Information ------------------
Instruction TLB:
- - - - - ITLB1: - - - - - - - - - - - - - - - - - -
Page size = 4 KB
Pages count = 64
Pages count = 64
Associativity: 8-way associative
@JackStouffer
JackStouffer / dmd.conf
Created September 4, 2015 19:15
My dmd conf
[Environment]
DFLAGS=-I%@P%/../../phobos -I%@P%/../../druntime/import -w -dip25 -m64 -g -debug -L%@P%/../../phobos/generated/osx/debug/64/libphobos2.a
@JackStouffer
JackStouffer / quadtree.d
Created August 11, 2015 19:27
A Quadtree implementation in D with unit tests
import std.traits: hasMember;
/*
Quadtree implementation that allows the collision resolver
to only scan a small subset of the possible colliding objects
See Also:
http://gamedevelopment.tutsplus.com/tutorials/quick-tip-use-quadtrees-to-detect-likely-collisions-in-2d-space--gamedev-374
*/
struct Quadtree(T, uint MAX_OBJECTS = 10, uint MAX_LEVELS = 5) if (
@JackStouffer
JackStouffer / ringbuffer.d
Created August 11, 2015 19:24
A simple ring buffer implementation in D with unit tests
import std.traits : isNumeric;
struct RingBuffer (T, uint buffer_length = 4) if (isNumeric!T) {
private T[buffer_length] buffer;
private T sum;
private byte lastIndex;
@safe @nogc nothrow pure {
this(const T initial_value) {
this.lastIndex = 0;
@JackStouffer
JackStouffer / main.d
Last active August 29, 2015 14:22
example for bug report
import std.stdio;
import Dgame.Window;
import Dgame.Graphic;
import Dgame.System.StopWatch;
import Dgame.System.Font;
import Dgame.System.Keyboard;
interface Entity {