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
function upto(x) | |
local k = 0 | |
return function() | |
if k < x then | |
local ret = k | |
k = k+1 | |
return ret | |
end | |
end | |
end |
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
-- lua51 setfenv tests | |
function setenv1() | |
-- 1 is the calling function | |
setfenv(1, {foo='1', print=_G.print}) | |
print(foo) -- prints 1 | |
end | |
setenv1() |
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 <iostream> | |
#include <exception> | |
#include <algorithm> | |
#include <memory> | |
#include <sstream> | |
#include <string> | |
#include <vector> | |
using namespace std; | |
class Vector { |
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
package fake3d; | |
import fake3d.Rainbow.Segment; | |
import flash.display.Shape; | |
import flash.Vector.Vector; | |
import de.polygonal.ds.ArrayUtil; | |
/** | |
* Trailing Rainbow class, reimplemented in haxe. | |
* Source : https://github.com/grapefrukt/juicy-breakout/blob/0d907c2587b9e292d7441b40045d263e3462d878/src/com/grapefrukt/games/juicy/effects/Rainbow.as |
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
// alloca() for dynamic stack memory allocation | |
#include <stddef.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <alloca.h> | |
struct string { | |
int cnt; | |
char chars[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
#include <stdio.h> | |
#include <setjmp.h> | |
jmp_buf buf; | |
void what() { | |
puts("in what()"); | |
longjmp(buf, 1); | |
puts("won't be here"); | |
} |
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
# simple math expression pratt parser | |
def lexer(s): | |
'''token generator''' | |
ix = 0 | |
while ix < len(s): | |
if s[ix].isspace(): ix += 1 | |
elif s[ix] in "+-*/()": | |
yield s[ix]; ix += 1 | |
elif s[ix].isdigit(): |
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
char arr[] = "abcdefghijklmn"; |
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 <cstdio> | |
#include <cstdlib> | |
#include <gl/glew.h> | |
#include <gl/glfw.h> | |
#include <SOIL.h> | |
#define SMAP_X(n) ( ((n)%16)*16.0/256.0 ) | |
#define SMAP_Y(n) ( ((n)/16)*16.0/256.0 ) | |
struct SpriteCoord { | |
float s1, t1, s2, t2; |
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
#!/usr/bin/python3 | |
# pratt parser described below, reimplemented in python 3 | |
# http://journal.stuffwithstuff.com/2011/03/19/pratt-parsers-expression-parsing-made-easy/ | |
# https://github.com/munificent/bantam | |
import abc | |
from io import StringIO | |
from sys import exit, stdout | |
from pprint import pprint | |
from collections import namedtuple |