Skip to content

Instantly share code, notes, and snippets.

View ivanperez-keera's full-sized avatar
🚀
Exploring

Ivan Perez, PhD ivanperez-keera

🚀
Exploring
View GitHub Profile
@ivanperez-keera
ivanperez-keera / ArduinoSerialArray.hs
Last active April 24, 2023 15:19
Read multiple values from arduino
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RebindableSyntax #-}
{-# LANGUAGE ScopedTypeVariables #-}
-- This module declares an orphan instance on purpose. This warning does not
-- need to be disabled if/when this code is moved into the arduino library.
{-# OPTIONS_GHC -Wno-orphans #-}
module ArduinoSerialArray where
@ivanperez-keera
ivanperez-keera / console-log
Created September 22, 2021 01:10
Console Log. GHC 8.10, cabal 3.4
~/tmp/du$ cabal install dunai
Resolving dependencies...
Build profile: -w ghc-8.10.4 -O1
In order, the following will be built (use -v for more details):
- base-orphans-0.8.4 (lib) (requires build)
- primitive-0.7.1.0 (lib) (requires build)
- simple-affine-space-0.1.1 (lib) (requires build)
- splitmix-0.1.0.3 (lib) (requires build)
- transformers-compat-0.6.6 (lib) (requires build)
- random-1.2.0 (lib) (requires build)
@ivanperez-keera
ivanperez-keera / IsoMaybe.idr
Created February 8, 2018 01:26
Isomorphism between MaybeT Identity a and Maybe a in Idris
module IsoMaybe
import Control.Isomorphism
data MaybeT : (m : Type -> Type) -> Type -> Type where
MaybeTC : { m : Type -> Type } -> m (Maybe a) -> MaybeT m a
data Identity : Type -> Type where
IdentityC : a -> Identity a
@ivanperez-keera
ivanperez-keera / Example.tex
Created October 1, 2017 10:12
Example of haskell code formatted as in "Beautiful code, compelling evidence"
\definecolor{mygreen}{rgb}{0,0.6,0}
\lstset{
commentstyle=\color{mygreen},
keywordstyle=\color{blue}, % keyword style
breaklines=true
}
\begin{minipage}{\linewidth}
\hspace*{.1\linewidth}%
\begin{minipage}{.7\linewidth}
\begin{lstlisting}[frame=l,basicstyle=\small\ttfamily,language=Haskell,
@ivanperez-keera
ivanperez-keera / Makefile
Last active February 7, 2024 10:30
Clean LaTeX Makefile
.PHONY: default
# Use texfot if available. Produces less output.
TEXFOT_ARGS=--no-interactive --ignore 'Underfull.*' --ignore 'Package polytable Warning: Redefining column' --ignore 'Package hyperref Warning: Token not allowed in a PDF string' --ignore 'LaTeX Warning: .h. float specifier changed to .ht..'
TEXFOT=$(shell which texfot >/dev/null && echo texfot "${TEXFOT_ARGS}" || echo "")
# TEXFOT=
# Use chronic if available. Removes output on zero exitcode.
CHRONIC=$(shell which chronic || echo "")
@ivanperez-keera
ivanperez-keera / vi
Created September 17, 2017 01:26
A wrapper around vim to open files in existing vim sessions using ConqueTerm
#!/bin/bash
# matryoshka-vim
# ==============
#
# A wrapper around vim to open files in existing vim sessions using ConqueTerm.
#
# AUTHOR: Ivan Perez Dominguez
# LICENCE: GPL-3
#
@ivanperez-keera
ivanperez-keera / SDL.hs
Created April 6, 2017 11:02
Yampa SDL 1.2 Back-end using monadic Signals/Sinks
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE FlexibleInstances #-}
module FRP.Yampa.Backends.SDL where
import Data.IORef
import FRP.Yampa.Signal as Yampa
@ivanperez-keera
ivanperez-keera / Test.hs
Last active December 2, 2015 16:55
Strange MultiWayIf indentation problem in Haskell
{-# LANGUAGE MultiWayIf #-}
test1 :: Maybe String -> String
test1 x =
case () of
_ | True
-> "Good morning"
test2 :: Maybe String -> String
test2 x =
if | True -> "Good morning"
@ivanperez-keera
ivanperez-keera / AAA-PlaySoundWithSDLMixer.md
Last active November 4, 2015 11:14
Play a sound in SDL-mixer

This is a trivial example that plays a sound in SDL mixer.

It includes arbitrary Template Haskell to check that everything links properly.

Do not copy this to your own project. Use these functions or check out the Haskell Game Programming wiki instead.

@ivanperez-keera
ivanperez-keera / Associate org-mode files with emacs.md
Last active August 7, 2021 10:06
Associate Org-mode files with emacs (on Linux)

On linux, files tend to be identified by type, not extension.

org-mode files are text files, but only a few editors support org-mode (emacs, vim, etc.)

This file can be used to associate org-mode files to a specific editor (like emacs), while using other editors for plain text files.

  • Save as /usr/share/mime/packages/org.xml;
  • Run