Skip to content

Instantly share code, notes, and snippets.

View stefanooldeman's full-sized avatar

Stefano Oldeman stefanooldeman

  • bol.com
  • Netherlands, Utrecht
View GitHub Profile
@stefanooldeman
stefanooldeman / ghci_hellman.markdown
Created December 14, 2011 08:44
Diffie-Hellman with real world numbers in Haskell..

Here we start in the terminal with ghci (interactive Haskell interperter / ghc) First we create P a nice prime number, and 3 a prime root and two input secrets (8bit) Then start doing the Diffie-Hellman key exchange

Because the lazy evaluation in Haskell defining a variable p is only calculated when needed. And as shown when defining keyA everything is OK. but when called the calculations take too long and are terminated..

Prelude> let p = 2^56 - 46

Prelude> let v = 3

@stefanooldeman
stefanooldeman / .gitconfig
Created August 8, 2011 15:34
My git config (color part)
# colour output for diffs
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
@stefanooldeman
stefanooldeman / gpush.sh
Created July 15, 2011 11:25
push a branch and open the pull request screen
#!/bin/sh
gpush() {
branch=`git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
git push origin $branch
_url='https://github.com'
# add username
username=`git config -l | grep user.name | cut -d"=" -f2`
_url="$_url/$username"
@stefanooldeman
stefanooldeman / vim__xsdp_keys_1.markdown
Created May 11, 2011 10:58
#1 out a series of VIM tips on copy/cut and paste buffers

Action: Copy Earl Grey before pickwick and remove the comma after it.

  • Used Keys:
    1. Press v
    2. Move the cursor to end position
    3. Press d
    4. Move to cursor on the comma
    5. Press x
    6. Move cursor to the p from pickwick
    7. Press P
  • hiccups: With x in step 5 the comma is placed in the buffer.
@stefanooldeman
stefanooldeman / ServiceContainer.php
Created April 5, 2011 21:14
Dependency Injection With default configuration demo
<?php
class ServiceContainer implements ArrayAccess {
static protected $instance;
public $parameters = array();
public function __construct(array $parameters = array()) {
$this->parameters = $parameters;