View enigma.py
# -*- 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
View make_ld_mosaic_2.py
import urllib, re, os, urlparse, json, random, sys, getopt, gzip, math, time
from multiprocessing.dummy import Pool as ThreadPool
from cStringIO import StringIO
from PIL import Image
import numpy as np
def download_all_thumbs(ld_num,dest_folder=None):
event_name = 'ludum-dare-%d' % ld_num
entries_page_url_template = "http://www.ludumdare.com/compo/%s/?action=preview&etype=&start=%%d" % event_name
View gist:935a47a6262fc5023847
XX.XX@XXX.XXX@@.XX..XXX..X.XX....X@.X.X...XXX......X.X@.@@.X@.XX......X...@....@X.X.X.X@@..X....@.X@.........@X.X.@.@@X.@.X.@...X..X.@@X...X.X.X....@X@XX.....XX.X.@X......X..X@..@@.X...@XXX@.@@XXX.XXXXXXX.X..X@XX.X@X.@@@..X.@...XX..X@XXX@X..XX.@..@.@@X.@..X.X..XX....X@@...X.XXXX.....X@...@..@...X@X@X.XXXX.@X..@....@......X...X@.....@@..X@X@..X....@@.X..@.@@XXX.X.....XX@X.@...@XX..@X@....XX..X.@.@X@X.XX...X.@..@..@@X.XXX..@X.XX..X....@@.X@...XX@X........X.@.XX.XX.X..@X@X.......X.XX@..X..XX.X@.....X.X@.@X.@@...X.@@.XX..@X.X@X@X@@@.XXX@.@.XX....X....@...X@@@X.@.@.@..X@.X.XX@@.X.X.@.@X.X..XXX.@.X..@XX.XX@XXX....X@.XXX.X.XX@X@.X..@X...X..X@X.@XX...X....@@.XXX...XXXXX...XX..X.X.X.@X@XX.XX.@X.XXX...@.X.@XX@X@X...@X...@.XXX...@X.@XX..XX..X..@.@X....X.X@.X@X.X@.@.@X....@@..@.X.X.@.@.X@.X@...@......@@X.XX..@X.XXXX.X.X.XX@.XX..XX.XXX.@@.X...X.X..X.@@..X@....@..XX@X....@X...@X..X.X...XX..@XX@X.XX.@........X.X...X@@@X@@.@.X..X.X.X..X.@XXX@XX.X@....X.X@XX.X.@.@...@@@.@X...@@XX@..@......@X@...X.X.@..@.@X....@X....@.X@.@.X@.
View emergent_orange.py
import os, sys
from PIL import Image
size = 128, 128
w, h = size
reds = [0] * w * h
greens = [0] * w * h
blues = [0] * w * h
count = 0
View gist:482fee74d096e47e006b
#include <cinttypes>
#include <cstdlib>
#include <ctime>
#include <iostream>
int main(int argc, char** args) {
srand(time(NULL));
View gist:3fcfeb1d424f01b2fa59
for(uint32_t m = mask, i = ~0U; m; ) {
auto shift = __builtin_ffs(m);
m >>= shift;
i += shift;
... do something with i
}
View make_ld_mosaic.py
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
View gist:6807325
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
};
}
}
View gist:5934448
// 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;
View cube.js
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],