Skip to content

Instantly share code, notes, and snippets.

View JAChapmanII's full-sized avatar

Jeff Chapman II JAChapmanII

View GitHub Profile
@JAChapmanII
JAChapmanII / text.py
Last active August 29, 2015 14:27
text.py
class Property:
def __init__(self):
pass
class Fragment:
def __init__(self, text, property):
this.text = text
this.property = property
class ParsedText:
def __init__(self, fragments, property):
this.fragments = fragments
import std.io;
import std.string;
import core.type;
type string = std.string;
var out = std.io.stdout;
type Cat {
func purr() -> string { return "purrr"; }
func speak() -> string { return "meow"; }
@JAChapmanII
JAChapmanII / bsp.py
Created August 12, 2015 01:20
python bsp skeleton
class Point:
def __init__(self, i, x, y):
self.i = i
self.x = x
self.y = y
def __repr__(self):
if self.i == -1:
return "[(%s, %s)]" % (self.x, self.y)
else:
@JAChapmanII
JAChapmanII / error.txt
Created February 28, 2015 19:03
assertion error
All dependencies seem to be present!
[jac@quetz prototype]$ python2 ./MapEditor.py
from OverworldParts.Cell import *
from OverworldParts.Map import *
Map.G = MapEdit.G
Map.addTempCell = MapEdit.addTempCell
Map.as_8_bit = MapEdit.as_8_bit
Map.clearTempCells = MapEdit.clearTempCells
Map.colourBytesToNumber = MapEdit.colourBytesToNumber
Map.compile = MapEdit.compile
@JAChapmanII
JAChapmanII / py.js
Created October 28, 2014 16:21
loops
while True:
print("loop")
sleep(1)
function myLoop() {
console.log("loop");
window.setTimeout(myLoop, 1000);
}
@JAChapmanII
JAChapmanII / main.cpp
Created October 24, 2014 19:58
oh god what did I do
int main(int argc, char **argv) {
Database db("sp_plus.db");
Table t("users");
t.columns.push_back({ "name", "varchar(32)", true, false });
t.columns.push_back({ "posX", "int" });
t.columns.push_back({ "posY", "int" });
typedef tuple<string, int, int> UserRow;
cerr << t.formatCreate() << endl;
@JAChapmanII
JAChapmanII / loops.py
Created May 2, 2014 17:27
loop de loop
def smooth(world, location):
val = world[location[0]][location[1]]
for yo in range(-val, val):
if (location[0] + yo < 0) or (location[0] + yo >= len(world)):
continue
for xo in range(-val, val):
if (location[1] + xo < 0) or (location[1] + xo >= len(world[0])):
continue
if world[location[0] + yo][location[1] + xo] < val - max(abs(xo), abs(yo)):
world[location[0] + yo][location[1] + xo] < val - max(abs(xo), abs(yo))
@JAChapmanII
JAChapmanII / g.py
Created April 25, 2014 22:43
generators in python
def fibonacci():
a, b = 1, 1
while True:
yield a
a, b = a + b, a
x = 0
for f in fibonacci():
print(f)
x += 1
@JAChapmanII
JAChapmanII / xdocument_linq_vb
Created January 31, 2014 14:57
Short untested example of what some XDocument/LINQ usage in C# would convert to in VB.Net with XML literals
// http://stackoverflow.com/questions/1542073/xdocument-or-xmldocument
// Customers is a List<Customer>
XElement customersElement = new XElement("customers",
customers.Select(c => new XElement("customer",
new XAttribute("name", c.Name),
new XAttribute("lastSeen", c.LastOrder)
new XElement("address",
new XAttribute("town", c.Town),
new XAttribute("firstline", c.Address1),
// etc
@JAChapmanII
JAChapmanII / stardate.cpp
Created November 8, 2013 14:31
stardate
string movie = "The last one";
if(date < 300)
movie = "The penultimate one";
if(date < 200)
movie = "The 2nd to last";
if(date < 100)
movie = "The first one";
cout << movie << endl;