This file contains 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
# nanoshorten - a very tiny URL shortener Web application written in Bottle and sqlite | |
# copyright (c) 2012 darkf | |
# licensed under the WTFPL (WTF Public License) | |
# see http://sam.zoy.org/wtfpl/ for details | |
from bottle import get, request, run | |
import sqlite3, random, string | |
con = sqlite3.connect('short.db') | |
c = con.cursor() |
This file contains 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
import sys, os, glob, re, pickle | |
if len(sys.argv) != 2: | |
print "USAGE: %s DIR" % sys.argv[0] | |
sys.exit(1) | |
INDEX = {} | |
FILES = [] | |
for path,_,dirs in os.walk(sys.argv[1]): |
This file contains 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
PC: | |
- 1024x768 VGA device; stored in memory from 0x00000000 to 0x00300000 (3,145,728 i.e. 1024x768 @ 32 bpp) | |
- BIOS using interrupt 0; has text rendering capabilities, among other things | |
RAM: | |
- Dynamically sized - default is 32mb | |
- Smallest addressable unit is the byte (8 bits) | |
- Address from VRAM's end to the next 16mb is stack space | |
- Memory from stack's end to the next 4096 bytes is reserved for the ROM (e.g. bootloader) | |
- Rest of address space is contiguous |
This file contains 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
module Prog | |
type Node = Call of string * Node * Node | |
| Str of string | |
| Int of int | |
| Binop of string * Node * Node | |
type Type = FunType of Type * Type | |
| StrType | |
| IntType |
This file contains 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
merchant Tom | |
inventory: 3x Pistol Rounds @ $5, 1x SMG Rounds @ $10 | |
on talk { | |
say "Hello! Welcome to Tom's Ammunition Supply!" | |
} | |
end | |
enemy Boar | |
inventory: 1x Boar Meat |
This file contains 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
# Objects are values with at least the methods {init, update, draw}. | |
# state describes properties shared by all game states. | |
# game states can transition into others, or call methods by others. | |
# there is a global event system that can emit (dispatch) events (by string), and catch (observe) them. | |
state { | |
player : player | |
objects : [Object] | |
} |
This file contains 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
import random | |
def say(msg): | |
print ":", msg | |
def rnd(min, max): | |
return random.randint(min, max) | |
class Player: | |
def __init__(self): |
This file contains 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
type actor = {mutable hp : int; name : string} | |
type battle = {enemy : actor; mutable turn : int} | |
type attack = Slash of int | |
let player = {hp=100; name="Player"} | |
let runAttack by who atk = | |
match atk with | |
| Slash dmg -> printfn "%s slashes %s for %d" by.name who.name dmg; who.hp <- who.hp - dmg |
This file contains 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
struct vec2 (x, y); | |
def vec2_add(a, b) { | |
vec2(a.x + b.x, a.y + b.y); | |
} | |
def main() { | |
x = [1, 2, 3]; | |
print("hi! length of x is #{len(x)}"); |
This file contains 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
#include <stdio.h> | |
#include <stdbool.h> | |
#include <math.h> | |
#include <string.h> | |
#define n 100 | |
static bool A[n]; | |
int main() { | |
int i, j; |