Skip to content

Instantly share code, notes, and snippets.

Frédéric Menou ptitfred

  • FretLink
  • Paris, France
Block or report user

Report or block ptitfred

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View stack2nix.nix
# 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 Jun 18, 2018
Patch nodegit prebuilt x86_64 library
View README.md

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 Feb 6, 2018
Support MessagePack in your Servant APIs
View Servant.MessagePack.hs
-- 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)
View keybase.md

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:

View nodejs-installer
#!/bin/bash -e
NODE_ARCHIVE_REPOSITORY=http://nodejs.org/dist/latest/
# Move to a temp directory
BUILD_DIR=$(mktemp -t -d "nodejs-installer.XXXXX")
cd $BUILD_DIR
archive=$(curl "${NODE_ARCHIVE_REPOSITORY}SHASUMS.txt" 2>/dev/null | egrep "node-v[0-9.]*.tar.gz" | cut -f3 -d" ")
download_archive="$NODE_ARCHIVE_REPOSITORY$archive"
@ptitfred
ptitfred / screenshots2pdf.sh
Created Oct 18, 2013
Exporter en pdf une collection de screenshot png dans le format .*_[0-9]+.png
View screenshots2pdf.sh
#!/bin/bash
i=0
IFS=$'\n'
for f in $(find . -iname "*.png" | sort -k2 --field-separator=_)
do
let "i += 1"
number=$(printf "%03d" $i)
convert "${f}" slide_${number}.pdf
@ptitfred
ptitfred / gist:5353908
Last active Dec 16, 2015
One line banner-style clock
View gist:5353908
# http://stackoverflow.com/questions/15393441/obfuscated-c-code-contest-2006-please-explain-sykes2-c
cd $(mktemp -d /tmp/clock.XXXX)
cat > clock.c <<C
main(_){_^448&&main(-~_);putchar(--_%64?32|-~7[__TIME__-_/8%8][">'txiZ^(~z?"-48]>>";;;====~$::199"[_*2&8|_/64]/(_&2?1:8)%8&1:10);}
C
gcc -o clock clock.c
@ptitfred
ptitfred / Tim.scala
Last active Dec 15, 2015
Some HTTP server in Scala
View Tim.scala
package web
import com.sun.net.httpserver._
import java.net.InetSocketAddress
import java.net.Inet4Address
case class Answer(code: Int, body: String)
class MyServer(port: Int) {
type Handler = String => Answer
@ptitfred
ptitfred / gist:5090629
Last active Dec 14, 2015
Relative time builder in Ruby - requires ActiveSupport Time extensions
View gist:5090629
require "active_support/time"
# in 3 days
Time.fluent("+3d")
# Tomorrow at 10 am
Time.fluent("+1d @10h")
class Time
def self.fluent(at)
@ptitfred
ptitfred / thread_local.rb
Created Nov 23, 2012
ThreadLocal en Ruby
View thread_local.rb
class ThreadLocal
def [](key)
Thread.current[key]
end
def []=(key, value)
Thread.current[key] = value
end
end
You can’t perform that action at this time.