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
class PitTree[T](val children : Map[String, PitTree[T]], val value : Option[T]) extends Map[String, T] { | |
def this() = this(Map(), None) | |
def this(value : T) = this(Map(), Some(value)) | |
def update(path : String, upVal : T) : PitTree[T] = update(splitPath(path), upVal) | |
def update(path : List[String], upVal : T) : PitTree[T] = path match { | |
case Nil => | |
new PitTree[T](upVal) | |
case h :: t => | |
val child = children.getOrElse(h, new PitTree[T]()).update(t, upVal) | |
new PitTree[T](children + (h -> child), value) |

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
; haskell mode | |
(load "~/elisp/haskell-mode-2.8.0/haskell-site-file") | |
(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode) | |
;These tree indentation modes are mutually exclusive | |
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation) | |
;;(add-hook 'haskell-mode-hook 'turn-on-haskell-indent) | |
;;(add-hook 'haskell-mode-hook 'turn-on-haskell-simple-indent) |
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
<html> | |
<head><title>Kombinationer</title></head> | |
<body> | |
<script> | |
// shorthand function | |
function $(id) { | |
return document.getElementById(id); | |
} |
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
// ==UserScript== | |
// @match http://duego.com/preregister* | |
// @require http://code.jquery.com/jquery-1.4.2.min.js | |
// ==/UserScript== | |
var load,execute,loadAndExecute;load=function(a,b,c){var d;d=document.createElement("script"),d.setAttribute("src",a),b!=null&&d.addEventListener("load",b),c!=null&&d.addEventListener("error",c),document.body.appendChild(d);return d},execute=function(a){var b,c;typeof a=="function"?b="("+a+")();":b=a,c=document.createElement("script"),c.textContent=b,document.body.appendChild(c);return c},loadAndExecute=function(a,b){return load(a,function(){return execute(b)})}; | |
loadAndExecute("//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js", function() { | |
function Notifier() {}; |
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/python | |
############################################################################### | |
# | |
# Script for generating a truly random password, using atmospheric noise. The | |
# generator uses the web service at random.org | |
# | |
# Usage: | |
# password.py [password length] [alphabet] | |
# For example: password.py 5 abcdefgh |
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 that checks if a swedish personnummer is valid. | |
* Author: André Laszlo <[email protected]> | |
*/ | |
function check_personnummer(pnr) { | |
// Do formatting and sanity control | |
pnr = pnr.replace(/[^0-9]/g, ''); // only keep digits | |
if (12 == pnr.length) // year format 1985 → 85 | |
pnr = pnr.substr(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 run_interactive(parser): | |
"""Inspect the argument parser and let the user decide on values for | |
all parameters interactively. | |
""" | |
args = [] | |
print "You are running this script in interactive mode. " + \ | |
"Press C-d to abort. Run with --help to see more options." | |
try: |
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
### Implement some commands from dc | |
registers = {'r': None} | |
stack = [] | |
def add(): | |
stack.append(stack.pop() + stack.pop()) | |
def z(): | |
stack.append(len(stack)) | |
def less(reg): | |
if stack.pop() < stack.pop(): | |
registers[reg]() |
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 drop_shell(global_vars, local_vars): | |
""" Call with drop_shell(global_vars().copy(), locals()) """ | |
import readline # optional, will allow Up/Down/History in the console | |
import code | |
global_vars.update(local_vars) | |
shell = code.InteractiveConsole(global_vars) | |
shell.interact() |
OlderNewer