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
public final class IntrusiveList<T> { | |
/** private constructor used by makeList() */ | |
private IntrusiveList() { | |
t = null; // is null so we know this must be the head/tail | |
prev = next = this; // cyclic | |
} | |
/** returns a new head/tail pointer */ | |
public static <T> IntrusiveList<T> makeList() { |
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, threading, Queue, weakref | |
try: | |
import Tkinter | |
_has_tk = True | |
_debug_win = None | |
except ImportError: | |
# quietly disable ourselves | |
_has_tk = False |
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
# -*- coding: utf-8 -*- | |
def Ord(ch): return ord(ch) - ord('A') # convert A-Z to 0-25 | |
def Chr(ch): return chr(ch + ord('A')) # convert 0-25 to A-Z | |
def Text(s): return "".join(ch for ch in s if ch in "ABCDEFGHIJKLMNOPQRSTUVWXYZ") | |
Rotors = { # name: (wiring, notches) | |
"I": ("EKMFLGDQVZNTOWYHXUSPAIBRCJ", "Q"), # 1930 Enigma I | |
"II": ("AJDKSIRUXBLHWTMCQGZNPYFVOE", "E"), # 1930 Enigma I | |
"III": ("BDFHJLCPRTXVZNYEIWGAKMUSQO", "V"), # 1930 Enigma I |
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 urllib, re, os, urlparse, json, random, sys, getopt, gzip, math, time | |
from multiprocessing.dummy import Pool as ThreadPool | |
from cStringIO import StringIO | |
import Image | |
def download_all_thumbs(ld_num=28,dest_folder="thumbs"): | |
event_name = 'ludum-dare-%d' % ld_num | |
entries_page_url_template = "http://www.ludumdare.com/compo/%s/?action=preview&etype=&start=%%d" % event_name | |
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 java.util.Random; // for test code | |
final class BFS { | |
/* finds nearest ant to a destination in a maze. | |
You give it a (partial) map and it plots a route using naive BFS. | |
As you discover more obstacles you can call addWater() for them. | |
It makes extensive use of pre-allocated data for intermediate results, | |
so you must extract the path for each call to findNearestAnt() or you | |
lose it. */ | |
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
var mandelbulbCanvas = document.getElementById('mandelbulb'); | |
window.requestAnimFrame = (function(callback) { | |
return window.requestAnimationFrame || | |
window.webkitRequestAnimationFrame || | |
window.mozRequestAnimationFrame || | |
window.oRequestAnimationFrame || | |
window.msRequestAnimationFrame || | |
function(callback) { | |
window.setTimeout(callback, 100); |
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
class Test { | |
static void func(final String X) { | |
new Test() { | |
String X = X.toLowerCase(); <-- I want to init X to be something derived from the parameter 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
// adapting http://gamedev.stackexchange.com/a/49423/4129 | |
castRay: function(ray) { | |
var oX = ray[0][0], oY = ray[0][1], oZ = ray[0][2], | |
dX = ray[1][0]-oX, dY = ray[1][1]-oY, dZ = ray[1][2]-oZ, | |
x = Math.floor(oX), y = Math.floor(oY), z = Math.floor(oZ), | |
intbound = function(s,ds) { | |
if(ds < 0) | |
return intbound(-s,-ds); | |
return (1-((s%ds+ds)%ds))/ds; |
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 emitCube(blf,trb,array,ofs) { | |
ofs = ofs || 0; | |
var left = blf[0], right = trb[0], | |
bottom = blf[1], top = trb[1], | |
front = blf[2], back = trb[2], | |
tlb = [left,top,back], | |
trf = [right,top,front], | |
tlf = [left,top,front], | |
brb = [right,bottom,back], | |
blb = [left,bottom,back], |
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
The scene has a perspective projection. | |
I want to know if a fragment is inside the cone formed by the camera and a sphere. | |
sphereCentre is set by mvMatrix*vec3(0,0,0) and radius is 1; I am drawing a unit sphere. | |
The camera is at 0,0,0 in view space. | |
The fragment shader just passes the scene position to the fragment shader: |
NewerOlder