Skip to content

Instantly share code, notes, and snippets.

View vincenthz's full-sized avatar
👻
making things better

Vincent Hanquez vincenthz

👻
making things better
View GitHub Profile
@vincenthz
vincenthz / .xsession
Created October 17, 2011 14:57
my xmonad xsession file
#xmodmap -e "keycode 192 = XF86Launch1"
xmodmap -e "keycode 192 = XF86Launch6"
#xmodmap -e "keycode 193 = XF86Launch2"
xmodmap -e "keycode 193 = XF86Calendar"
xmodmap -e "keycode 194 = XF86Launch3"
xmodmap -e "keycode 195 = XF86Launch4"
xmodmap -e "keycode 196 = XF86Launch5"
xset b off
@vincenthz
vincenthz / cprng.c
Created October 10, 2012 07:43
CPRNG with a block cipher in CTR mode.
/*
* Copyright (C) 2012 Vincent Hanquez
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
@vincenthz
vincenthz / Gh.hs
Last active August 29, 2015 14:11
github interaction
module Main where
import Data.List
import System.Environment
import Github.Issues
import Github.Repos
import Text.Printf
handleError :: String -> [String] -> Either Error a -> IO a
handleError action args (Left err) =
@vincenthz
vincenthz / mirror-hackage.sh
Created December 21, 2014 23:24
mirror hackage (2014-12 version)
#!/bin/sh
[ ! -d package ] && mkdir package
for splitpk in `tar tf 00-index.tar.gz | cut -d/ -f 1,2`; do
pk=`echo $splitpk | sed 's|/|-|'`
name=$pk.tar.gz
if [ ! -a package/$name ]; then
wget http://hackage.haskell.org/package/$pk/$name -O package/$name
fi
@vincenthz
vincenthz / github-util.hs
Created May 28, 2015 09:25
github utility for listing issues / repos
-- github util
--
-- Expect a file called ~/.github-cred with your oauth string in first line.
-- Otherwise all commands are run without credentials
module Main where
import Control.Applicative
import Control.Exception
import Control.Monad
import Data.List
module Main where
import Control.Applicative
import Control.Monad
import System.Environment
import System.Process
import Data.Function
import Data.Word
import Data.List (sortBy)
import Numeric
@vincenthz
vincenthz / Relude.hs
Last active October 27, 2016 13:20
experiment with rebindable syntax -- Prelude Reboot (like CSS reset)
--
-- Preboot -- Prelude Reboot
--
-- A minimal prelude reboot with better base classes
--
-- * Provide a module to Work with the RebindableSyntax extension
-- * Better classes:
-- * Monad : no return or fail
-- * Enum : hiding fromEnum and toEnum
-- * Number Literal become the Integral class (e.g. Int) or Fractional class (e.g. Double).
@vincenthz
vincenthz / AnsiColorShow.hs
Last active January 8, 2017 09:45
Color Show with random deterministic color sequence
funkyShow :: Show a => a -> String
funkyShow l = "\x1b[" ++ c ++ dig ++ "\x1b[0m"
where
c = cols !! (fromEnum (head dig) `mod` lenCols)
dig = show l
lenCols = length cols
cols = ["31;1m", "32;1m", "33;1m", "34;1m", "35;1m", "36;1m"] {-"37;1m", "38;1m", "7m"] -}
@vincenthz
vincenthz / HaskellHexDump.hs
Created February 15, 2017 10:40
Debug haskell snippet
import qualified Data.ByteArray.Encoding as BD
import Debug.Trace
bytedump n f a = trace ("[HS] " ++ n ++ " " ++ toHex (f a)) a
where toHex = (show :: ByteString -> String) . BD.convertToBase BD.Base16
@vincenthz
vincenthz / CStruct.hs
Last active September 1, 2019 10:45
CStruct in haskell
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
module CStruct where