Skip to content

Instantly share code, notes, and snippets.

View NicolasT's full-sized avatar

Nicolas Trangez NicolasT

View GitHub Profile
/* Build using
*
* gcc -shared -o libcrc32.so -O2 crc32.c
*
* Then run using
*
* LD_PRELOAD=./libcrc32.so myprog
*/
unsigned long crc32(unsigned long crc, const unsigned char *buf, unsigned int len) {
@NicolasT
NicolasT / .gitconfig
Created February 11, 2015 17:58
My (redacted) .gitconfig
[user]
[color]
ui = auto
diff = auto
status = auto
branch = auto
[alias]
ci = commit -s
pick = cherry-pick -s -x
graph = log --graph --pretty=oneline --abbrev-commit --all --decorate
@NicolasT
NicolasT / Makefile
Last active August 29, 2015 14:14
Demo of custom userspace probe points
DTRACE := dtrace
default: demo
sofs_probes.h: sofs_probes.d
$(DTRACE) -h -o $@ -s $<
sofs_probes.o: sofs_probes.d
$(DTRACE) -G -o $@ -s $<
@NicolasT
NicolasT / Conc.lhs
Last active May 25, 2017 03:15
Deriving Typeclass Instances using Typed Holes
# Deriving Typeclass Instances using Typed Holes
> module Conc where
> import Control.Applicative
We're presented with the following structure:
> data Concurrent a = Concurrent ((a -> Action) -> Action)
> data Action = Atom (IO Action)
> | Fork Action Action
@NicolasT
NicolasT / cdmi.lua
Last active August 29, 2015 14:12
Script to benchmark a CDMI service using wrk
-- JSON = (loadfile "JSON.lua")()
-- Utilities
function randomString(len)
local tab = {}
for i = 1, len do
tab[i] = string.char(math.random(0, 255))
end
return table.concat(tab)
end
diff --git a/stack.sh b/stack.sh
index ec13338..612cf73 100755
--- a/stack.sh
+++ b/stack.sh
@@ -388,6 +388,7 @@ if [[ -n "$LOGFILE" ]]; then
# Set fd 3 to a copy of stdout. So we can set fd 1 without losing
# stdout later.
exec 3>&1
+ exec 4>&2
if [[ "$VERBOSE" == "True" ]]; then
@NicolasT
NicolasT / gist:19a6e3d6482091115ff3
Created December 10, 2014 23:07
Recursive `mkdir` with `fsync` of created directory parents
def mkdir_nicolast2(path, fsync=False):
'''Recursively create a directory
If `fsync` is `True`, parent directories of created directories are
`fsync`ed.
'''
abspath = os.path.abspath(path)
# Step 1: Calculate which directories need to be created (in reverse order)
@NicolasT
NicolasT / module-symbols.sh
Last active August 29, 2015 14:10
Utility script to load debug symbols for Linux kernel modules into GDB
#!/bin/bash -ue
MODULE=$1
SYMBOL_PATH_BASE=usr/lib/debug
SYS_MODULES_BASE=/sys/module
MODULES_BASE=/lib/modules/`uname -r`/
function go() {
MODULE_NAME=$1
SECTIONS_PATH=$SYS_MODULES_BASE/`echo $MODULE_NAME | sed s/-/_/g`/sections
@NicolasT
NicolasT / safesql.hs
Created November 18, 2014 00:05
Type-safe SQL select queries
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ConstraintKinds #-}
module Main where
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Main where