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 / github-close-and-archive.sh
Created September 20, 2023 07:22
close all issues, PRs and archive a repository on github
#!/bin/sh
#
# Close all issues, PR, and archive a repository
if [ $# -ne 1 ]; then
echo "usage: $0 <github-repository>"
exit 1
fi
REPO=$1

Keybase proof

I hereby claim:

  • I am vincenthz on github.
  • I am vhz (https://keybase.io/vhz) on keybase.
  • I have a public key ASD8I4pHNuWa8DybHy-jiRnWMXcXb_xMkIz2KuYylfwXQAo

To claim this, I am signing this object:

@vincenthz
vincenthz / WarpFile.hs
Created December 19, 2017 10:21
serving with warp a index.html and test.wasm
#!/usr/bin/env stack
-- stack --resolver lts-9.17 script --package warp --package wai --package http-types
{-# LANGUAGE OverloadedStrings #-}
import Network.Wai (responseLBS, responseFile, Application, rawPathInfo)
import Network.Wai.Handler.Warp (run)
import Network.HTTP.Types (status200, status404)
import Network.HTTP.Types.Header (hContentType)
main = do
@vincenthz
vincenthz / CStructExample1.hs
Created March 15, 2017 15:18
CStruct in haskell (example 1)
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
module Main where
@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
@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 / 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 / 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).
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 / 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