Skip to content

Instantly share code, notes, and snippets.

Avatar

Nicolas Trangez NicolasT

View GitHub Profile
@NicolasT
NicolasT / .gitignore
Last active March 23, 2023 15:05
Non-failing test with DejaFu
View .gitignore
dist-newstyle/
@NicolasT
NicolasT / Raadsel.hs
Created January 26, 2023 20:58
Raadsel oplossen met een SMT solver via SBV
View Raadsel.hs
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
View get_addr.py
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
View calico-cni-plugin.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
View README.md

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?
View test.hs
-- 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)
View abstract.hs
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ViewPatterns #-}
module Main where
import Data.Monoid
import Control.Lens
View testepoll.c
/*
* $ make testepoll CFLAGS="-Wall -Werror -ggdb3"
*
* One console:
*
* $ nc -l 8000
*
* Other console:
*
* $ ./testepoll
@NicolasT
NicolasT / slice_xor.c
Created January 23, 2017 11:24
Slicing XOR hashing
View slice_xor.c
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <x86intrin.h>
#include <avx2intrin.h>
#ifdef __cplusplus
extern "C" {
void slice_xor(const unsigned char *data, size_t len, uint64_t *p1, uint64_t *p2);
@NicolasT
NicolasT / cryptosplice.c
Created May 10, 2016 17:52
Demonstration of splice, tee and AF_ALG hashing for zero-copy storage and data hash calculation
View cryptosplice.c
/* Usage:
*
* $ make cryptosplice
* cc cryptosplice.c -o cryptosplice
*
* $ rm -f cryptosplice.out
* $ ./cryptosplice
*
* Now, in another terminal:
*