Skip to content

Instantly share code, notes, and snippets.

View BoeingX's full-sized avatar

boeingx BoeingX

  • Paris, France
View GitHub Profile
@BoeingX
BoeingX / peano.hs
Created May 30, 2019 13:45
Peano numbers
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleInstances #-}
data Z
data S n
data Natural :: * -> * where
NumZ :: Natural Z
NumS :: Natural n -> Natural (S n)
@BoeingX
BoeingX / BenchmarkReadIntsFromFile.hs
Created November 4, 2018 15:16
Compare different ways from reading integers from standard input or a file
import Criterion.Main
import System.Environment
import qualified Data.ByteString.Char8 as C
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
readBaseline :: FilePath -> IO [Int]
readBaseline filename = map parse . words <$> readFile filename
where parse :: String -> Int
@BoeingX
BoeingX / flatten.py
Created April 8, 2018 10:11
Recursively flatten a nested iterable
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import collections
def flatten(lst):
"""Flatten a iterable.
>>> from __future__ import print_function
>>> lst = [[1, 2], [], [1, [[2, 3], 3]], 4, 5]
>>> print(flatten(lst))
[1, 2, 1, 2, 3, 3, 4, 5]
@BoeingX
BoeingX / cleaner.py
Created April 4, 2018 19:08
Example of pipeline
from pipeline import pipeline
class Cleaner(object):
def __init__(self):
self.pipeline = pipeline
def add_pipeline(self, p):
self.pipeline.append(p)
def __call__(self, s):
@BoeingX
BoeingX / vimrc
Last active October 14, 2017 08:11
Minimalist vim configuration file. Copied from wikia.
" URL: http://vim.wikia.com/wiki/Example_vimrc
" Authors: http://vim.wikia.com/wiki/Vim_on_Freenode
" Description: A minimal, but feature rich, example .vimrc. If you are a
" newbie, basing your first .vimrc on this file is a good choice.
" If you're a more advanced user, building your own .vimrc based
" on this file is still a good idea.
"------------------------------------------------------------
" Features {{{1
"
@BoeingX
BoeingX / tmux_local_install.sh
Last active June 22, 2016 02:29 — forked from ryin/tmux_local_install.sh
bash script for installing tmux without root access
#!/bin/bash
# Script for installing tmux on systems where you don't have root access.
# tmux will be installed in $HOME/local/bin.
# It's assumed that wget and a C/C++ compiler are installed.
# exit on error
set -e
TMUX_VERSION=2.2
@BoeingX
BoeingX / ovpn-writer.sh
Last active April 30, 2017 20:32 — forked from renatolfc/ovpn-writer.sh
Script to generate an OpenVPN client configuration file in the unified format
#!/bin/bash
#
if [ "$#" -lt 6 ]; then
echo "./ovpn-writer.sh <server address> <protocol> "
echo " <port> <ca certificate> "
echo " <client certificate> <client key>"
echo " [tls key] "
exit 1
fi