This file contains hidden or 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/env python | |
import random, itertools | |
def generate( symbols ): | |
out = "" | |
for s in symbols: | |
out += s | |
done = False |
This file contains hidden or 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/env python | |
import shlex, pprint | |
text = """ | |
(define mauri (lambda (x y) | |
(+ x y) | |
) | |
) | |
(display (mauri 1 2) ) | |
""" |
This file contains hidden or 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
def generic_create_form(name, modelclass): | |
model_fields = [field.name for field in modelclass._meta.fields] | |
class Meta: | |
pass | |
setattr(Meta,"model", modelclass) | |
setattr(Meta,"fields", model_fields) | |
attrs = {'__module__': '', 'Meta': Meta} |
This file contains hidden or 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/env python | |
# input as dependency graph | |
# { | |
# "node1": ["dep1", "dep2"...], | |
# "node2": [...], | |
# ... | |
# } | |
def solve( graph ): |
This file contains hidden or 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
int fast_compare( const char *ptr0, const char *ptr1, int len ){ | |
int fast = len/sizeof(size_t) + 1; | |
int offset = (fast-1)*sizeof(size_t); | |
int current_block = 0; | |
if( len <= sizeof(size_t)){ fast = 0; } | |
size_t *lptr0 = (size_t*)ptr0; | |
size_t *lptr1 = (size_t*)ptr1; |
This file contains hidden or 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/env python | |
def generate_test_cases(N): | |
M = 2**N | |
out = [] | |
for i in range( M ): | |
case = [ (i >> j & 0x01) == 1 for j in range( N ) ] | |
out.append( tuple( case ) ) | |
return out | |
This file contains hidden or 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 fetchMultiple( datasets, predicate, finished ){ | |
var functions = []; | |
var results = []; | |
for( var i = 0 ; i < datasets.length ; ++i ){ | |
functions.push( (function(i){ return function(){ | |
$.getJSON( datasets[i], function( response ){ | |
results.push( predicate( response ) ); | |
functions[i+1](); | |
}); | |
This file contains hidden or 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 class Vektori { | |
public double x, y, z; | |
public static Vektori fromPolar( double r, double phi ){ | |
return new Vektori( r * Math.cos( phi ), r * Math.sin( phi ), 0 ); | |
} |
This file contains hidden or 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/env python | |
import sys, os | |
basedir = "." | |
if len( sys.argv ) > 2: | |
basedir = sys.argv[1] | |
string = sys.argv[-1] |
This file contains hidden or 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/env python | |
import xml.dom.minidom as dom | |
import xml | |
import sys | |
def read_xml_file( fn ): | |
return dom.parse( fn ).documentElement |