Skip to content

Instantly share code, notes, and snippets.

View ptitfred's full-sized avatar

Frédéric Menou ptitfred

View GitHub Profile
@ptitfred
ptitfred / convert-netex-tarifs.hs
Created May 2, 2024 14:55
Pandoc script to transform NeTEx tarifs docx to a suitable markdown file
#!/usr/bin/env nix-shell
#!nix-shell --pure -i runghc -p "haskellPackages.ghcWithPackages (p: [ p.pandoc p.pretty-show ])"
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
import Control.Monad ((<=<))
import Control.Monad.IO.Class (liftIO)
@ptitfred
ptitfred / server.cpp
Created October 5, 2010 21:17
C++ HTTP server
#include "server.hpp"
#include <iostream>
#include <fstream>
#include <sstream>
using std::cout;
using std::cerr;
using std::cin;
using std::endl;
using std::fstream;
@ptitfred
ptitfred / .vimrc
Created August 20, 2012 08:37
Pretty format your XML in VIM
function! PrettyXML()
silent %!xmllint --format --encode UTF-8 --recover - 2>/dev/null
endfunction
command! Fxml call PrettyXML()
"-- format xml when trigger Ctrl-Shift-F (only if filetype=xml)
autocmd FileType xml map <C-S-F> :Fxml<CR>
@ptitfred
ptitfred / nix-tools.nix
Last active May 3, 2020 22:07
nix-tools derivation (pushd to test-ptitfred.cachix.org)
let pkgs = import nixpkgs (import archive {}).nixpkgsArgs;
src = {
url = https://github.com/input-output-hk/haskell.nix/archive/78f4e25f5c45c135d1798fca423420e8baa7589b.tar.gz;
sha256 = "1348y11ixypqwi0pcsqyx6n2097569x92mpgr7fk33sm2v6imvn3";
};
archive = builtins.fetchTarball src;
nixpkgs = fetchTarball {
name = "nixpkgs";
url = "https://github.com/NixOS/nixpkgs/archive/cac363c661817666e43d047addfaa722610d425f.tar.gz";
sha256 = "0fi8hgddy8qh2jrsa40jw7jxnr5lrhq2ji6a2xbndllivhzc31kf";
@ptitfred
ptitfred / Makefile
Created May 3, 2020 13:26
CI for hmacaroons using haskell.nix
.PHONY: build
build:
nix build -f ci.nix hmacaroons.components.library
.PHONY: test
test:
nix build -f ci.nix --out-link result-tests hmacaroons.components.tests
result-tests/bin/test
.PHONY: doc
@ptitfred
ptitfred / wait-tcp.sh
Created February 9, 2012 18:19
Wait for a TCP port to be open
#!/bin/bash
function help {
echo "Usage: wait-for port [timeout]"
echo " port is a TCP port number, or the service name (for instance http, ssh)"
echo " timeout is expressed in seconds"
echo " optional (defaulted to 30)"
echo " if <= 0, no timeout"
exit 1
}
# nix-env -i -f ./stack2nix.nix
let
inherit (import <nixpkgs> {}) fetchFromGitHub;
nixpkgs = fetchFromGitHub {
owner = "NixOS";
repo = "nixpkgs-channels";
# Last revision of haskell-packages before bump of cabal2nix to 2.11
# and satisfying hpack >=0.29.6
rev = "78e2045f6d747655062ed2ceee595b878e488488";
sha256 = "0v9i8x5kh6x09ngzbzizn9cbf939vbsbw3wsa81ba57y3c1z3zj7";
@ptitfred
ptitfred / README.md
Last active June 18, 2018 00:52
Patch nodegit prebuilt x86_64 library

What's that

This is an attempt to install clever-tools in a Nix environment.

How to use it

nix-env -i -f default.nix
@ptitfred
ptitfred / Servant.MessagePack.hs
Created February 6, 2018 00:19
Support MessagePack in your Servant APIs
-- msgpack-aeson for msgpack instance derived from aeson instances
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
module Servant.MessagePack
( MessagePack
) where
import Data.Aeson (FromJSON, ToJSON)

Keybase proof

I hereby claim:

  • I am ptitfred on github.
  • I am ptitfred (https://keybase.io/ptitfred) on keybase.
  • I have a public key ASBaeSUUdQZUcqJhNE2refT-wv0w2_eDU2zAtdeJUpoylwo

To claim this, I am signing this object: