Skip to content

Instantly share code, notes, and snippets.

View johnfn's full-sized avatar

Grant Mathews johnfn

View GitHub Profile
@johnfn
johnfn / gist:2434a822f64d0bda2e47
Created June 28, 2015 23:27
Floodfill with LINQ
public List<List<Cell>> World; // 100x100 2d list of Struct
private void FloodFill()
{
var edge = new List<Cell> { World[0][0] };
var seen = new HashSet<Cell> { };
//while (edge.Count > 0)
for (var i = 0; i < 50; i++) // Just run 50 iterations
{
// this is what the data looks like
interface Battle {
entries: number[];
host: string;
id: number;
major: boolean;
timestamp: string;
title: string;
}
DEBUG:TS:Body sequence#: 610
DEBUG:TS:Read body of length: 83
DEBUG:TS:Body sequence#: 611
DEBUG:TS:Read body of length: 83
DEBUG:TS:Body sequence#: 612
DEBUG:TS:Read body of length: 83
DEBUG:TS:Body sequence#: 613
DEBUG:TS:Read body of length: 83
DEBUG:TS:Body sequence#: 614
@johnfn
johnfn / gist:0d8d1bf7e4de78d0e4bc
Created June 21, 2015 03:14
TypeScript plugin freeze
DEBUG:TS:Body sequence#: 358
DEBUG:TS:Read body of length: 83
DEBUG:TS:Body sequence#: 359
DEBUG:TS:Read body of length: 83
DEBUG:TS:Body sequence#: 360
DEBUG:TS:Read body of length: 83
DEBUG:TS:Body sequence#: 361
DEBUG:TS:Read body of length: 83
DEBUG:TS:Body sequence#: 362
DEBUG:TS:Read body of length: 83
class DbPerson.cs {
var id: int
var email: string
var snippet: string
var bio: string
var created: DateTime
var firstname: string
var lastname: string
var birthdate: DateTime?
var gender: string
@johnfn
johnfn / gist:d4b4f25e7caef6bd70b6
Last active August 29, 2015 14:16
c# to swift (written in python for obvious reasons)
# TODO
# * Parse out name of class
# * Parse nested objects
# * Since they are explicitly marked with ForeignKey("nameOfProperty"), this should be a single regex
# * test against different files
import re
filename = "DbPerson.cs"
test = "".join([line for line in open(filename)])
@johnfn
johnfn / gist:b9afbaae3d05c63f3f6b
Last active August 29, 2015 14:16
JSON to Swift Mk. I
// JSON String -> Object
// Still TODO:
// 1. Nested JSON object parsing
// 2. String -> JSON data type
// Data structures to hold JSON
// Probably not necessary but they make the code nice and I wanted to learn about them
enum JSONItem {
case StringEntry(String, String)
@johnfn
johnfn / gist:d7907fd100261beda045
Created January 4, 2015 08:03
Parsing javascript for docs and inserting them into Typescript definition files.
import re
CLASS_RE = r'(export )?class ([^\s]+)'
MODULE_RE = r'(declare )?module ([^\s]+)'
INTERFACE_RE = r'interface ([^\s]+)'
FUNCTION_RE = r'^\s*(static)?\s*([^\(]+)\('
PARAM_RE = r'^\s*(static)?\s*([^:^\(]+):'
DOCS_START = r'^\s*/\*\*\s*$'
DOCS_END = r'^\s*\*/\s*$'
CLOSE_BRACKET_RE = r'^\s*\};?\s*$'
@johnfn
johnfn / gist:5233925
Last active December 15, 2015 08:49
discrepancy between Popen and shell
haxe -cp /Users/grantm/code/punktest/src/ -cp /Users/grantm/code/punktest/fp/src/ -lib nmedev --remap flash:nme -cpp /Users/grantm/code/punktest/Main -D st_display --display /Users/grantm/code/punktest/src/Main.hx@262 --no-output
VS
Popen(['haxe', '-cp', '/Users/grantm/code/punktest/src/', '-cp', '/Users/grantm/code/punktest/fp/src/', '-lib', 'nmedev', '--remap', 'flash:nme', '-cpp', '/Users/grantm/code/punktest/Main', '-D', 'st_display', '--display', '/Users/grantm/code/punktest/src/Main.hx@262', '--no-output', ''], stdout=PIPE, stderr=PIPE).communicate()
// Go ahead, try and guess what this will do.
for (var i:int = 0; i < 10; i++) {
var k:int;
k++;
trace(k);
}