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
### Password hashing | |
def hash_pwd(pwd, salt=None, rounds=2**16): | |
"""Hashes a password using 2**16 rounds of SHA512 and a 64-bit salt. | |
The salt and hash result are concatenated and returned as a hexdigest. | |
""" | |
# Note: if this turns out to be too slow, consider using the py-bcrypt package | |
if salt is None: | |
# Note: Do not use python's random module for crypto! | |
salt = os.urandom(8) |
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
import random | |
def makeDeck(): | |
ranks = 'Ace Two Three Four Five Six Seven Eight Nine Ten Jack Queen King'.split() | |
suits = 'Hearts Clubs Spades Diamonds'.split() | |
return ['%s of %s' % (r,s) for r in ranks for s in suits] | |
def draw(deck): | |
card = random.choice(deck) | |
deck.remove(card) |
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
interleave :: [a] -> [a] -> [[a]] | |
interleave [] [] = [] | |
interleave as [] = [as] | |
interleave [] bs = [bs] | |
interleave as bs = [ (head as):arest | arest <- interleave (tail as) bs ] | |
++ [ (head bs):brest | brest <- interleave as (tail bs) ] |
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
--- setnohs.sorted 2012-01-27 11:45:01.768205853 +0100 | |
+++ seths.sorted 2012-01-27 11:45:23.088143702 +0100 | |
@@ -0,0 +1,2 @@ | |
+n | |
+t | |
@@ -21,2 +23,2 @@ | |
-noballooneval | |
- balloonexpr= | |
+ ballooneval | |
+ balloonexpr=GHC_TypeBalloon() |
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
--- | |
layout: page | |
categories: | |
- title: Journal Papers | |
publications: | |
- title: Rule Formats for Determinism and Idempotency (journal version) | |
date: 31.03.2010 | |
authors: | |
- Luca Aceto | |
- Arnar Birgisson |
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
diff --git a/src/Syntax.hs b/src/Syntax.hs | |
index 1905488..475a02a 100644 | |
--- a/src/Syntax.hs | |
+++ b/src/Syntax.hs | |
@@ -2,6 +2,7 @@ | |
module Syntax where | |
import Labels | |
+import Control.Monad.State | |
import Data.Generics |
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
;; Personal prefs. | |
(setq user-mail-address "x") | |
(global-set-key "\C-w" 'backward-kill-word) | |
(global-set-key "\C-x\C-k" 'kill-region) | |
;; Packages and bundles | |
(add-to-list 'load-path "~/.emacs.d/") | |
(add-to-list 'load-path "~/.emacs.d/color-theme-6.6.0") | |
;; Viper mode |
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
# Project Euler problem 102 | |
# Which side of the line AB is the point P? | |
# (The dot product of AP and the perpendicular to AB) | |
def side((ax,ay), (bx,by), (px,py)): | |
return (bx - ax) * (py - ay) - (by - ay) * (px - ax) | |
def same_side(a, b, p, q): | |
sp = side(a, b, p) | |
sq = side(a, b, q) |
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
from bottle import route, run, debug | |
import subprocess | |
def sendkeys(*keys): | |
subprocess.call(['xdotool', 'search', '--name', 'Spotify Premium - Linux Preview', 'key'] + list(keys)) | |
return "ok\n" | |
@route('/pause') | |
@route('/play') | |
def play(): return sendkeys('space') |
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 main(void) { printf( /* | |
(format t ;*/ | |
"goodbye dmr and jmc, thanks for everything!" | |
); return 0; } /* | |
(quit) | |
;*/ |