Skip to content

Instantly share code, notes, and snippets.

View NicolasT's full-sized avatar

Nicolas Trangez NicolasT

View GitHub Profile
@NicolasT
NicolasT / slice_xor.c
Created January 23, 2017 11:24
Slicing XOR hashing
#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
/* Usage:
*
* $ make cryptosplice
* cc cryptosplice.c -o cryptosplice
*
* $ rm -f cryptosplice.out
* $ ./cryptosplice
*
* Now, in another terminal:
*
@NicolasT
NicolasT / .gitignore
Last active October 15, 2015 23:10
CRC32 benchmark
*.o
*.hi
crc32_bench
@NicolasT
NicolasT / crc32_prop.hs
Created October 15, 2015 21:49
Combining intermediate CRC32 results
module Main where
import Data.Word (Word8, Word32)
import Foreign.C (CUInt(..), CULong(..))
import Foreign.Ptr (Ptr)
import System.IO.Unsafe (unsafePerformIO)
import qualified Data.ByteString as BS
import Test.QuickCheck
@NicolasT
NicolasT / .gitignore
Last active September 29, 2015 23:35
Vector XOR Benchmark Game
.stack-work/
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
module Langs where
import Data.Proxy
@NicolasT
NicolasT / active.hs
Created September 8, 2015 22:54
Haskell representation of F#-style Active Patterns
-- https://www.reddit.com/r/haskell/comments/3huexy/what_are_haskellers_critiques_of_f_and_ocaml/cuisrmj
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ViewPatterns #-}
module Main where
import Text.Read (readMaybe)
pattern Even <- ((`mod` 2) -> 0)
@NicolasT
NicolasT / .gitignore
Last active August 31, 2015 22:24
Expressive logging with meta-data in C
main
*.o
preload-statfs.so
test-preload-statfs
@NicolasT
NicolasT / defer.py
Last active December 14, 2018 12:28
Go-style 'defer' in Python
import functools
import socket
import sys
import threading
import types
import unittest
class OnException(object):
'''Wrapper for cleanup actions only to be executed upon exception'''