Skip to content

Instantly share code, notes, and snippets.

@ToJans
ToJans / after.c
Last active January 4, 2016 11:09
static ERL_NIF_TERM nif_fdb_future_get_keyvalue_array(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
enif_future_t *f;
const FDBKeyValue * out_kv=NULL;
int out_count = 0;
fdb_bool_t out_more = 0;
if (argc!=1) return enif_make_badarg(env);
if (get_future(env, argv[0], &f) == 0 )
return enif_make_badarg(env);
@ToJans
ToJans / currenthaskell.log
Created January 9, 2014 10:40
Haskell wai performance comparision on different haskell compiler versions Source code for benching: http://www.techempower.com/benchmarks/#section=data-r4
[root@ghcwebcurrent bench]# ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.4.2
[root@ghcwebcurrent bench]# bench 5 aaa &
[1] 537
[root@ghcwebcurrent bench]# weighttp -t 2 -n 100000 -c 100 127.0.0.1:8000/
weighttp - a lightweight and simple webserver benchmarking tool
starting benchmark...
spawning thread #1: 50 concurrent requests, 50000 total requests
spawning thread #2: 50 concurrent requests, 50000 total requests
# FoundationDB Python API
# Copyright (c) 2012 FoundationDB, LLC
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@ToJans
ToJans / environment.py
Created December 27, 2013 21:45
Example (we used python combined with the `behave` testing fw)
from selenium import webdriver
import os
import subprocess
def before_all(context):
get_browser(context)
get_sut_url(context)
def after_all(context):
@ToJans
ToJans / fizzbuzz.clj
Last active December 31, 2015 22:09
My implementation of fizzbuzz in Haskell; I tried to find a functional fit for the problem...
; taken from http://elegantcode.com/2013/12/19/clojure-kata-1-fizz-buzz/
(defn fizz-buzz [number]
(let [fizz? (zero? (rem number 3))
buzz? (zero? (rem number 5))
fizz-buzz? (and fizz? buzz?)]
(cond
fizz-buzz? "fizzbuzz"
fizz? "fizz"
buzz? "buzz"
:else number)))
@ToJans
ToJans / CH03.hs
Last active December 31, 2015 20:19
You don't want to know how long the `mean`function took, just because I added the spec `myLength :: [a] -> Int`
myLength :: (Num a) => [t] -> a
myLength [] = 0
myLength (_:xs) = 1 + myLength xs
mySum :: (Num a) => [a] -> a
mySum [] = 0
mySum (x:xs) = x + (mySum xs)
mean :: Fractional a => [a] -> Maybe a
@ToJans
ToJans / seqable.ex
Last active December 31, 2015 06:29
An attempt for proper Enumerators in Elixir
defmodule Seqable do
defprotocol ChuckNorris do
def value?(continuation)
def value(continuation)
def next(continuation)
end
defimpl ChuckNorris, for: List do
def value?([]), do: false
@ToJans
ToJans / example.ex
Last active December 31, 2015 05:39
Enumerable elixir continuations
// José's proposition
{ :suspended, n_, cont } = Enumerable.reduce(1..5, { :cont, 0 }, fn x, n ->
if x == 3 do
{ :suspend, n }
else
{ :cont, n + x }
end
end)
@ToJans
ToJans / no_if.erl
Last active December 25, 2015 17:09
What I love about Erlang: no "if" statements
%% @doc Register a new identity.
-spec register_identity(identifier()) -> succeeded().
%% @end
register_identity(Id) ->
F = fun () ->
Identity = get_identity(Id),
{_, true} = {already_registered, Identity =/= not_found},
identity_registered(Id)
end,
transact(F).
@ToJans
ToJans / gist:6755089
Created September 29, 2013 18:18
Just a test for @ptomasroos
Did you get the msg?