Skip to content

Instantly share code, notes, and snippets.

@kc1212
kc1212 / bench_test.go
Last active October 19, 2018 16:17
comparing collectionDB and trie
package byzcoin
import (
"math/rand"
"os"
"testing"
bolt "github.com/coreos/bbolt"
"github.com/dedis/cothority/byzcoin/trie"
"github.com/dedis/cothority/darc"
@kc1212
kc1212 / btree_test.hs
Created December 2, 2015 18:35
Testing b*tree in haskell
import Pipes
import qualified BTree as BT
import Control.Monad (unless, liftM)
import System.IO
-- probably don't need IO
listToProducer :: [BT.BLeaf String Int] -> Producer (BT.BLeaf String Int) IO ()
listToProducer [] = return ()
listToProducer a@(x:xs) =
unless (null a) $ do
@kc1212
kc1212 / statet_map_io.hs
Created November 11, 2015 14:12
Simulating key-value database using StateT
import Control.Monad.State
import qualified Data.Map as Map
type MyMap = Map.Map Int Char
runDB :: StateT MyMap IO ()
runDB = do
add 1 'a'
add 2 'b'
x <- find 1
@kc1212
kc1212 / test_ctor_dtor.cpp
Last active August 29, 2015 13:58
cpp constructor and destructor order
#include <iostream>
using namespace std;
class A {
public:
A() { cout << "A ctor" << endl; }
~A() { cout << "A dtor" << endl; }
};
class B {