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
### 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
from wsgiref.simple_server import make_server | |
from pyramid.config import Configurator | |
from pyramid.response import Response | |
def main(request): | |
return Response(''' | |
<html> | |
<head> | |
<script src="http://requirejs.org/docs/release/2.1.0/minified/require.js"></script> |
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
exports.config = | |
# See docs at http://brunch.readthedocs.org/en/latest/config.html. | |
modules: | |
definition: false | |
wrapper: (path, data) -> | |
if data.match /^\s*define\s*\(\s*\[/ | |
data.replace(/^(\s*define\s*\()/, "$1#{path}, ") | |
else | |
""" | |
define(#{path}, ['require', 'jquery'], function(require, $) { |
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
Monitor.registerStub = function (name, fun) { | |
Monitor.prototype[name] = function () { return fun.apply(this, arguments); } | |
} |
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
arnar@air:/tmp$ cat lennartsurl.json | |
{"totalPoints":14395,"version":1,"rounds":[["round","lat","lng","gLat","gLng","cLat",[null],"cLng",[null],"points"],[1,53.774101,87.18442600000003,46.07323062540838,4.21875,0,0,1337],[2,-31.704593,137.22421099999997,-26.431228064506424,132.890625,0,0,2296],[3,46.165393,14.310496999999941,47.754097979680026,14.58984375,0,0,2845],[4,22.218447,114.211588,22.375476015564765,114.1534423828125,0,0,5210],[5,-15.780246,-47.92931199999998,-13.923403897723334,-49.21875,0,0,2707]],"isChallenge":false,"challengeScore":null} | |
arnar@air:/tmp$ for url in $(cat lennartsurl.json \ | |
| jq -r '.rounds[1:][] | @uri "http://maps.googleapis.com/maps/api/geocode/json?latlng=\(.[1]),\(.[2])&sensor=true"'); do \ | |
curl -s $url | jq '.results[0].formatted_address'; \ | |
done | |
"ulitsa Vodopadnaya, Novokuznetsk, Kemerovo Oblast, Russia, 654000" | |
"Stuart Highway, Mount Gunson SA 5710, Australia" |
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
#ifndef _SHELLCODE_H | |
#define _SHELLCODE_H | |
static char shellcode[] = | |
"\xb9\xff\xff\xff\xff" | |
"\x31\xc0" //sets real user id from effective user id. | |
"\xb0\x31" | |
"\xcd\x80" | |
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
var spawn = require('child_process').spawn; | |
var midi = require('midi'); | |
// Set up a new input. | |
var input = new midi.input(); | |
var sharpnames = ['c', 'cis', 'd', 'dis', 'e', 'f', 'fis', 'g', 'gis', 'a', 'ais', 'b']; | |
var flatnames = ['c', 'des', 'd', 'es', 'e', 'f', 'ges', 'g', 'as', 'a', 'bes', 'b']; | |
var notenames = flatnames; |
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
Things to check out: | |
Ny Carlsberg Glyptotek - a museum mostly with scupltures, but nice atmosphere | |
The round tower http://www.rundetaarn.dk/ | |
Nice tower in the center with good views. Has a spiral road fit for a horse carriage | |
to the top because the king was too lazy to walk. | |
Nyhavn, Stroget and Kobmagergade, but probably you know these already. | |
http://www.cph-bike-rental.dk/ Nice bike rental |
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
% Chapter headers and other customizations (fold) | |
\newenvironment{pabstract}{{\sc abstract}\hspace{.5em}\small}{} | |
\usepackage{titlesec} | |
\titleformat{\section}{\large\bfseries}{\protect\makebox[0pt][r]{\thesection\quad}}{0pt}{} | |
\titleformat{\subsection}{\bfseries}{\protect\makebox[0pt][r]{\thesubsection\quad}}{0pt}{} | |
\titlespacing*{\paragraph}{0pt}{.7em}{1em} | |
\setcounter{chapter}{-1} |