Skip to content

Instantly share code, notes, and snippets.

View NicolasT's full-sized avatar

Nicolas Trangez NicolasT

View GitHub Profile
@NicolasT
NicolasT / star.ml
Last active February 7, 2024 00:09
module Functor = struct
module type S = sig
type 'a t
val map : ('a -> 'b) -> 'a t -> 'b t
end
module type API = sig
include S
@NicolasT
NicolasT / .gitignore
Last active December 16, 2023 14:02
Testing Python scripts using pytest
__pycache__/
.pytest_cache/
@NicolasT
NicolasT / .gitignore
Last active March 23, 2023 15:05
Non-failing test with DejaFu
dist-newstyle/
@NicolasT
NicolasT / Raadsel.hs
Created January 26, 2023 20:58
Raadsel oplossen met een SMT solver via SBV
module Main (main) where
import Data.SBV
raadsel :: Symbolic SBool
raadsel = do
vars@[s, e, n, d, m, o, r, y] <- sIntegers ["s", "e", "n", "d", "m", "o", "r", "y"]
-- Helper, maakt bvb. (100 * a + 10 * b + c) uit [a, b, c]
let woord w = sum (zipWith (*) (reverse w) (iterate (* 10) 1))
@NicolasT
NicolasT / get_addr.py
Created April 1, 2020 14:09
Dumb Python implementation to get the IP address assigned to an interface
import sys
import fcntl
import socket
import struct
'''
#include <stdio.h>
#include <net/if.h>
#include <netinet/in.h>
#include <sys/ioctl.h>
@NicolasT
NicolasT / calico-cni-plugin.spec
Last active February 7, 2019 10:31
Calico cni-plugin RPM spec
%global provider github
%global provider_tld com
%global project projectcalico
%global repo cni-plugin
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
%ifarch x86_64
%global built_arch amd64
%global calico_sha256 5736d46dc8f3d17eafd1d7874c49457244b698d5fccf726066c60c136ac5a318
%global calico_ipam_sha256 ae32622d5c904e216cd914031e560e481c9ea9c213153172d0eacabadbb5e984
@NicolasT
NicolasT / README.md
Last active June 20, 2018 22:32
PaxosLease question

An e-mail I sent to the authors of the PaxosLease paper back in the day. One of them replied explaining how in their actual implementation of the protocol (http://github.com/scalien/keyspace/tree/master/src/Framework/PaxosLease) they added phase separation/tracking (bool preparing and bool proposing), which would indeed solve the issue with the protocol outlined in the paper as explained in the e-mail.

@NicolasT
NicolasT / test.hs
Created September 12, 2017 23:00
Enhancing type inference of indexed monads, removing type annotations?
-- See below
-- {-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE RebindableSyntax #-}
{-# LANGUAGE ScopedTypeVariables #-}
import Prelude hiding ((>>=), (>>), return)
import qualified Prelude as P
import Data.Functor.Identity (Identity, runIdentity)
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ViewPatterns #-}
module Main where
import Data.Monoid
import Control.Lens
/*
* $ make testepoll CFLAGS="-Wall -Werror -ggdb3"
*
* One console:
*
* $ nc -l 8000
*
* Other console:
*
* $ ./testepoll