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
#By Robin Wellner (gvx) | |
#I hereby waive copyright and related or neighboring rights to this work | |
#See the Creative Commons Zero Waiver at <http://creativecommons.org/publicdomain/zero/1.0/> | |
def switch(expression, cases, default=None): | |
try: | |
ret = cases[expression] | |
except KeyError: | |
ret = default | |
if callable(ret): ret = ret() |
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
#By Robin Wellner (gvx) | |
#I hereby waive copyright and related or neighboring rights to this work | |
#See the Creative Commons Zero Waiver at <http://creativecommons.org/publicdomain/zero/1.0/> | |
class mutable(object): | |
def __init__(self, obj): | |
self._obj = obj | |
def __repr__(self): | |
return 'mutable('+repr(self._obj)+')' | |
def __call__(self, obj=None): |
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
#By Robin Wellner (gvx) | |
#I hereby waive copyright and related or neighboring rights to this work | |
#See the Creative Commons Zero Waiver at <http://creativecommons.org/publicdomain/zero/1.0/> | |
def rotn(intext, n): | |
outtext = [] | |
for char in intext: | |
if 65 <= ord(char) < (65+26): | |
char = chr(((ord(char) - 65) +n) % 26 + 65) | |
elif 97 <= ord(char) < (97+26): |
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
PROGRAM:RNDABC | |
:Input D:randInt | |
(1,D)→A:randInt( | |
1,D)→B:randInt(1 | |
,D)→C:Disp "AB", | |
AB,"AC",AC,"BC", | |
BC:Pause :Disp " | |
{A,B,C}",{A,B,C |
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
#ROTurn | |
#Decode a ROT13'ed block of text. | |
#Python version of Perl script by Jay Kominek | |
#By Robin Wellner (gvx) | |
#I hereby waive copyright and related or neighboring rights to this work | |
#See the Creative Commons Zero Waiver at <http://creativecommons.org/publicdomain/zero/1.0/> | |
""" | |
"I recently wrote a Perl script, which, using letter frequency, attempts | |
to guess whether a given block of text has been ROT13ed or not. I've found |
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
#By Robin Wellner (gvx) | |
#I hereby waive copyright and related or neighboring rights to this work | |
#See the Creative Commons Zero Waiver at <http://creativecommons.org/publicdomain/zero/1.0/> | |
def rename(oldname, newname, scope): | |
scope[newname] = scope[oldname] | |
if hasattr(scope[newname], '__name__'): scope[newname].__name__ = newname | |
del scope[oldname] |
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
#namespace | |
#By Robin Wellner (gvx) | |
#I hereby waive copyright and related or neighboring rights to this work | |
#See the Creative Commons Zero Waiver at <http://creativecommons.org/publicdomain/zero/1.0/> | |
#Simulation of modules containing one or more function/class/object. | |
#Warning: modules are named differently than what you would expect. | |
def namespace(name): | |
class namespace: |
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
#Listtools 0.1 | |
#By Robin Wellner (gvx) | |
#Functions for lists | |
#I hereby waive copyright and related or neighboring rights to this work | |
#See the Creative Commons Zero Waiver at <http://creativecommons.org/publicdomain/zero/1.0/> | |
def append(lst, object): | |
"listtools.append(lst, object) -- append object to end" | |
lst.append(object) |
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
-- defdef.lua | |
-- default definitions for lua | |
-- By Robin Wellner (gvx) | |
-- I hereby waive copyright and related or neighboring rights to this work | |
-- See the Creative Commons Zero Waiver at <http://creativecommons.org/publicdomain/zero/1.0/> | |
-- Evaluate truth like in Python | |
function is_true (arg) | |
if arg == '' or arg == 0 then |
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
#By Robin Wellner (gvx) | |
#I hereby waive copyright and related or neighboring rights to this work | |
#See the Creative Commons Zero Waiver at <http://creativecommons.org/publicdomain/zero/1.0/> | |
import sys | |
diff_file = sys.stdin.read().split('\n') | |
if len(sys.argv) > 1: | |
filename = sys.argv[1] | |
else: |
OlderNewer