Skip to content

Instantly share code, notes, and snippets.

View DavideCanton's full-sized avatar

Davide Canton DavideCanton

View GitHub Profile
@DavideCanton
DavideCanton / .gitconfig
Last active January 30, 2023 08:49
Git useful aliases
[alias]
cln = !git fetch --prune && git branch --verbose | grep gone | awk '{ print $1 }' | xargs -r git branch -D
fall = !for b in $(git branch -l --format "%(refname:lstrip=2)"); do git fetch origin $b:$b; done
st = status -s
cl = clone
ci = commit
co = checkout
br = branch
r = reset
cp = cherry-pick
@DavideCanton
DavideCanton / graph_diff_eq.py
Last active April 15, 2019 22:20
Graphical Differential equations
import itertools as it
import matplotlib.pyplot as plt
import numpy as np
from scipy.integrate import odeint
mu = 0.3
L = 10
g = 9.8
DELTA = 0.01
T = 1000
@DavideCanton
DavideCanton / download_gists.py
Created January 30, 2015 00:08
Gist downloader using asyncio
import asyncio
import os
import pathlib
import aiohttp
import bs4
__author__ = 'Davide Canton'
module Change where
import Control.Arrow ((&&&))
import Data.Function (on)
import Data.List (group)
-- Coin datatype
data Coin = OneCent | TwoCents | FiveCents |
TenCents | TwentyCents | FiftyCents |
@DavideCanton
DavideCanton / CF.hs
Last active August 29, 2015 14:08
Calcola il codice fiscale con Haskell! Usa lo stesso DB del progetto https://github.com/DavideCanton/PyCodiceFiscale
{-# OPTIONS_GHC -fno-warn-incomplete-patterns #-}
module CF.CF where
import Control.Arrow
import Control.Monad
import Control.Monad.Error
import Data.Char
import Data.List
@DavideCanton
DavideCanton / Clock.hs
Created October 28, 2014 15:10
Clock using Haskell and OpenGL
module ProveGL.Clock where
import Data.IORef
import Data.Time.LocalTime
import Graphics.UI.GLUT
applyTo :: (a, a) -> (a -> b) -> (b, b)
applyTo (x, y) f = (f x, f y)
@DavideCanton
DavideCanton / ProvaGL.hs
Created September 26, 2014 08:01
Prova OpenGL
module ProvaGL where
import Control.Monad
import Data.IORef (IORef, newIORef)
import Graphics.UI.GLUT
points :: Int -> [(GLfloat,GLfloat,GLfloat)]
points n = [ (sin (2*pi*k/n'), cos (2*pi*k/n'), 0) | k <- [1..n'] ]
where n' = fromIntegral n
@DavideCanton
DavideCanton / dyn_prog_seg.py
Last active August 29, 2015 14:06
Segmentation of multivariate time series
__author__ = 'davide'
import matplotlib.pyplot as plt
from collections import defaultdict
import numpy as np
from datetime import datetime, timedelta
import pandas as pd
from statsmodels.tsa.vector_ar.var_model import VAR
@DavideCanton
DavideCanton / sudoku.logic
Last active June 16, 2021 21:58
Sudoku solver with Clingo
cell_index(0..8).
cell_value(1..9).
% fill with initial values
initial_pos(0, 3, 4).
initial_pos(0, 6, 1).
initial_pos(0, 7, 5).
initial_pos(1, 1, 8).
initial_pos(1, 2, 1).
initial_pos(1, 3, 9).
@DavideCanton
DavideCanton / TM.hs
Last active August 29, 2015 14:02
Implementation of a simple Turing Machine.
module TM.TM where
import Control.Monad.State (State, evalState, get, put)
import Control.Monad.Trans (lift)
import Control.Monad.Trans.Writer (WriterT, runWriterT, tell)
import Data.List (intercalate, nub, (\\))
import qualified Data.Map as Map (Map, fromList, keys, lookup,
notMember, null, union)
newtype Tape = Tape { tapeList :: [CellContent] }