Skip to content

Instantly share code, notes, and snippets.

View paolino's full-sized avatar

Paolo Veronelli paolino

  • Cardano Foundation
  • sesimbra, portugal
View GitHub Profile
import Prelude hiding (writeFile)
import Data.ByteString.Lazy hiding (map, putStrLn, putStr)
import Data.ByteString.Internal
import Network.HTTP
import Control.Monad (when)
import Data.Time.Clock
import System.FilePath
import System.IO hiding (writeFile)
import Control.Concurrent
{-# LANGUAGE MultiParamTypeClasses, TypeSynonymInstances, FlexibleInstances #-}
import Data.Map (Map, unionWith)
class Box b a where
insert :: a -> b -> b
delete :: a -> b -> b
slide :: Box b a => a -> a -> b -> b
{-# LANGUAGE MultiParamTypeClasses, TypeSynonymInstances, FlexibleInstances #-}
import Data.Map (Map, unionWith, fromList, elems, assocs, size)
import Control.Monad ((>=>))
import Data.List (mapAccumL)
import Control.Arrow (second)
class Box b a where
insert :: a -> b -> b
delete :: a -> b -> b
@paolino
paolino / topsort.hs
Last active December 23, 2015 15:09
A topological sort algorythm based on edge defined graph. Complexity is O (n^2)
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Applicative ((<*>))
import Data.List (partition,filter, nub)
-- Una dipendenza è una coppia di valori dello stesso tipo
type Dipendenza a = (a,a)
-- il primo valore della coppia è quello dipendente
dipendente (x,y) = x
#include <String.h>
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 1, 3 }; // indirizzo IP della shield
byte gateway[] = { 192, 168, 1, 1 }; // indirizzo ip del router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
EthernetServer server(80);
{-# LANGUAGE ViewPatterns #-}
-- problem: given a list of numbers and a counter in a structure C [Int] Int
-- write a function step :: Int -> C -> C which
-- change first occurrence of a multiple of a given number in a list in its successive
-- and subtract it to the counter
-- or
-- subtract 1 to the counter and add 1 to all numbers in the list.
-- step 3 (C [1,2,3,5,6] 7) == C [1,2,4,5,6] 4
-- step 3 (C [1,2,4,5,7] 16) == C [2,3,5,6,8] 15
@paolino
paolino / Generating SVG using AngularJS.markdown
Created December 30, 2015 16:58
Generating SVG using AngularJS
@paolino
paolino / Lambda.hs
Last active April 26, 2016 21:38
Lambda calculus description with beta reduction
{-#LANGUAGE StandaloneDeriving,MultiParamTypeClasses,GeneralizedNewtypeDeriving,ViewPatterns, DeriveFunctor #-}
import Data.List (nub)
import Control.Monad.Reader (runReader, local, asks, liftM2, Reader, MonadReader)
-- Lambda expressions
data Expr a = T a -- terminal name
| a :-> Expr a -- lambda parameter abstraction
| Expr a :$ Expr a -- expression composition
@paolino
paolino / cacheEventDraft.hs
Last active May 6, 2016 14:54
caching reflex widget event creation
------------- Spider synonims
type ES = Event Spider
type DS = Dynamic Spider
-------------- Dom + spider synonyms
type MS = MonadWidget Spider
@paolino
paolino / Readme_NIX_OS.md
Created May 18, 2016 04:43 — forked from i-e-b/Readme_NIX_OS.md
/etc/nixos/configuration.nix

My experiments with an XMonad setup in NixOS. This is my work box now, so it pretty much works.

probably needs:

# useradd -m iain
# passwd iain ...
# passwd root ...