Skip to content

Instantly share code, notes, and snippets.

View DavideCanton's full-sized avatar

Davide Canton DavideCanton

View GitHub Profile
@DavideCanton
DavideCanton / queens_csp.py
Last active August 29, 2015 13:56
Solutor of N-queens problem using Min-conflicts
__author__ = 'davide'
import sys
import random
import itertools as it
import operator
from functools import lru_cache
from collections import Counter
@DavideCanton
DavideCanton / pyng.py
Last active August 29, 2015 13:57
Python tool for pinging hosts
__author__ = "davide"
import struct
import socket
import argparse
import sys
from datetime import datetime
import time
from collections import defaultdict
from signal import signal, SIGINT, SIG_IGN
__author__ = 'Kami'
from collections import defaultdict
import itertools as it
class MappingError(Exception):
pass
@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] }
@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 / 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 / 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 / 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
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 / 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'