Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

/* ==UserStyle==
@name gitlab.haskell.org logo shrink - 2019-01-06
@namespace github.com/openstyles/stylus
@version 1.0.0
@description Shrink haskell logo to make rightmost buttons appear
@author fgaz
==/UserStyle== */
@-moz-document domain("gitlab.haskell.org") {
#logo {
import Data.Maybe
import Data.List
import qualified Data.Set as S
import Data.Bifunctor
d01_read :: IO [Integer]
d01_read = fmap (read . (dropWhile (=='+'))) <$> lines <$> readFile "input"
d01_1 :: [Integer] -> Integer
d01_1 = sum
@fgaz
fgaz / node-nix-shell.sh
Created November 1, 2018 10:21
Enter a nix-shell for developing node packages
#!/usr/bin/env bash
set -e
if [ -e ./node_modules ]; then
echo "please delete node_modules to use this script"
exit 1
fi
function cleanup {
@fgaz
fgaz / risiko.hs
Created December 12, 2017 15:27
Risiko (italian risk) probability calculator
module Risiko where
import System.Random
import Data.List (sortBy)
data Player = Me | Oth
data Situation = Situation { myArmies :: Int
, othArmies :: Int }
deriving (Show)
@fgaz
fgaz / roman.hs
Created October 6, 2017 07:07
integral to roman number converter
module Roman where
values = [ (1000, "M")
, (900, "CM")
, (500, "D")
, (400, "CD")
, (100, "C")
, (50, "L")
--- tuntox/Makefile 2017-09-26 15:26:24.880458159 +0000
+++ tuntox/Makefile 2017-09-26 15:26:44.880312867 +0000
@@ -16,6 +16,2 @@ all: tuntox
-gitversion.h: .git/HEAD .git/index
- @echo " GEN $@"
- @echo "#define GITVERSION \"$(shell git rev-parse HEAD)\"" > $@
-
%.o: %.c $(INCLUDES) gitversion.h
--- /dev/null
@fgaz
fgaz / place_italy_flag.py
Last active April 2, 2017 14:56
Mantain italy's flag in /r/place
# needs python 2
import urllib
import urllib2
import time
import json
import random
# italy flag position:
xmin = 107
@fgaz
fgaz / keybase.md
Created July 23, 2016 16:28
keybase.io proof

Keybase proof

I hereby claim:

  • I am fgaz on github.
  • I am fgaz (https://keybase.io/fgaz) on keybase.
  • I have a public key ASA3kMzfvGEhYSHo-GObW6h1W5HwrDq59hIAX2QjWRtAGAo

To claim this, I am signing this object:

import Data.List (delete, permutations)
numbers = [6,6,5,2] -- ++ [2,3]
target = 17
data Tree o a = Branch o (Tree o a) (Tree o a) | Leaf a | Empty deriving (Show, Eq)
data Op = Add | Sub | Mult | Div deriving (Show, Eq)
op2f :: Fractional a => Op -> a -> a -> a
@fgaz
fgaz / Main.hs
Created January 26, 2016 14:31
Hello, GHCJS!
import GHCJS.DOM (webViewGetDomDocument, runWebGUI)
import GHCJS.DOM.Document (getBody)
import GHCJS.DOM.Element (setInnerHTML)
main :: IO ()
main = runWebGUI $ \ webView -> do
Just doc <- webViewGetDomDocument webView
Just body <- getBody doc
setInnerHTML body (Just "<h1>Hello, GHCJS!</h1>")