Skip to content

Instantly share code, notes, and snippets.

View Zireael07's full-sized avatar

Zireael07

View GitHub Profile
function chainfunc(...)
local chain={...}
return function(...)
local first = true
local a,b,c,d,e,f
for i,v in ipairs(chain) do
if first then
result = {v(...)}
first = false
else
@banksean
banksean / perlin-noise-classical.js
Created February 15, 2010 10:00
two Perlin noise generators in javascript. The simplex version is about 10% faster (in Chrome at least, haven't tried other browsers)
// Ported from Stefan Gustavson's java implementation
// http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
// Read Stefan's excellent paper for details on how this code works.
//
// Sean McCullough banksean@gmail.com
/**
* You can pass in a random number generator object if you like.
* It is assumed to have a random() method.
*/
@stuartpb
stuartpb / redirect.md
Created January 31, 2011 14:20
A page of combined documentation for SDL_ScanCode and SDLKey.
@nowl
nowl / perlin.c
Created February 15, 2011 19:04
Perlin Noise in C
#include <stdio.h>
static int SEED = 0;
static int hash[] = {208,34,231,213,32,248,233,56,161,78,24,140,71,48,140,254,245,255,247,247,40,
185,248,251,245,28,124,204,204,76,36,1,107,28,234,163,202,224,245,128,167,204,
9,92,217,54,239,174,173,102,193,189,190,121,100,108,167,44,43,77,180,204,8,81,
70,223,11,38,24,254,210,210,177,32,81,195,243,125,8,169,112,32,97,53,195,13,
203,9,47,104,125,117,114,124,165,203,181,235,193,206,70,180,174,0,167,181,41,
164,30,116,127,198,245,146,87,224,149,206,57,4,192,210,65,210,129,240,178,105,
@nowl
nowl / perlin.lisp
Created February 16, 2011 01:55
Perlin Noise in Common Lisp (slightly optimized)
(defpackage #:perlin
(:use #:cl)
(:export #:perlin2d
#:*seed*))
(in-package #:perlin)
(declaim (optimize (speed 3) (safety 0) (debug 0)))
(defparameter *seed* 0)
@randrews
randrews / dice.lua
Created March 9, 2011 04:01
Lua library for dice games
Die = {
roll = function(self)
self.value = math.random(self.sides)
end
}
Die["__index"] = Die
function D(sides, value)
local die = {sides = sides, value = value}
setmetatable(die, Die)
@nyuichi
nyuichi / 90-min-scc.scm
Created July 31, 2011 10:36
The 90 Minute Scheme to C Compiler
#!/usr/local/Gambit-C/bin/gsi
; Copyright (C) 2004 by Marc Feeley, All Rights Reserved.
; This is the "90 minute Scheme to C compiler" presented at the
; Montreal Scheme/Lisp User Group on October 20, 2004.
; Usage with Gambit-C 4.0:
;
; % ./90-min-scc.scm test.scm
@randrews
randrews / hello.lua
Created August 8, 2011 05:04
Embedding Lua in C
-- Pack this into an object file with ld: ld -r -b binary -o hello.o hello.lua
print "Hello, World!"
@WizKid
WizKid / gist:1170297
Created August 25, 2011 09:16
Remove comments in a JSON file
def removecomments(s):
inCommentSingle = False
inCommentMulti = False
inString = False
t = []
l = len(s)
i = 0
fromIndex = 0
@cmaes
cmaes / find_elem_circuits.m
Created October 3, 2011 20:31
Find all the elementary circuits of a directed graph
function [numcycles,cycles] = find_elem_circuits(A)
if ~issparse(A)
A = sparse(A);
end
n = size(A,1);
Blist = cell(n,1);