Skip to content

Instantly share code, notes, and snippets.

Avatar

Corey Schram cschram

View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am cschram on github.
  • I am cschram (https://keybase.io/cschram) on keybase.
  • I have a public key whose fingerprint is 9969 0145 5893 7D7E 0195 8333 EAC3 D073 40BA 0B84

To claim this, I am signing this object:

@cschram
cschram / typelist.d
Created Aug 28, 2015
Generic list that allows only one of any sub-type.
View typelist.d
module typelist;
import std.stdio;
import std.conv;
class TypeList(T)
{
T[string] objects;
void addObject(S)(S obj)
@cschram
cschram / collision.d
Last active Aug 29, 2015
late night attempt at separating axis theorem
View collision.d
module collision;
import collision.shape;
import collision.vector;
import collision.quadtree;
QuadTree collisionTree(Shape[] shapes)
{
auto tree = new QuadTree(0, Vector(800, 600));
foreach (shape; shapes) {
@cschram
cschram / orm-mockup.js
Last active Aug 29, 2015
Mockup for an ES7 ORM
View orm-mockup.js
let adapter = new RESTAdapter({
url: 'api.mysite.com/v1'
});
@registerModel('user', adapter)
class User extends Model {
@field(is => is.primaryKey().type(String).len(3, 20).alphaNumeric())
username = ''
@field(is => is.required().type(String).email())
@cschram
cschram / disableentity.d
Last active Aug 29, 2015
Removing/disabling entity causes access violation in system
View disableentity.d
import core.thread;
import std.stdio;
import artemisd.all;
class TestComponent : Component
{
mixin TypeDecl;
int foo = 42;
@cschram
cschram / bad.d
Last active Aug 29, 2015
You can get around method privacy by passing the method as a delegate.
View bad.d
module bad;
import std.stdio;
class Foo {
private void bad()
{
writeln("This shouldn't work ಠ_ಠ");
}
}
View split-with-matches.js
function splitWithMatches(str, pattern) {
var s = str.split(pattern),
pieces = [],
matches = [];
for (var i = 0, len = s.length; i < len; i++) {
if (s[i].match(pattern)) {
matches.push(s[i]);
} else {
pieces.push(s[i]);
@cschram
cschram / stacktrace.log
Created May 28, 2013
PhantomJS stack trace
View stacktrace.log
Operating system: Linux
0.0.0 Linux 2.6.38.8-32.fc14.x86_64 #1 SMP Wed Jun 29 12:42:10 CDT 2011 x86_64
CPU: amd64
family 6 model 45 stepping 7
2 CPUs
Crash reason: SIGSEGV
Crash address: 0x200000002
Thread 0 (crashed)
You can’t perform that action at this time.