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 | |
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 |
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
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@. |
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 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 |
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 <cinttypes> | |
#include <cstdlib> | |
#include <ctime> | |
#include <iostream> | |
int main(int argc, char** args) { | |
srand(time(NULL)); |
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
for(uint32_t m = mask, i = ~0U; m; ) { | |
auto shift = __builtin_ffs(m); | |
m >>= shift; | |
i += shift; | |
... do something with 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
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], |
NewerOlder