Skip to content

Instantly share code, notes, and snippets.

View clrnd's full-sized avatar
🍍
haskall

Ezequiel Alvarez clrnd

🍍
haskall
View GitHub Profile
@clrnd
clrnd / wc.hs
Created October 16, 2019 18:23
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE LambdaCase #-}
module Lib
( someFunc
) where
import Data.Char
import Data.IORef
import System.IO
@clrnd
clrnd / _.md
Created October 28, 2016 06:10
proba
@clrnd
clrnd / 2015_1er_parcial_2ndo_c_p1.hs
Created October 3, 2016 23:27
2015_1er_parcial_2ndo_c_p1.hs
module Main where
data Ball = R | B deriving (Show, Eq)
data Coin = Ca | Ce deriving (Show, Eq)
s_a = [(Ca, [a, b, c, d]) | a <- l, b <- l, c <- l, d <- l]
where l = [R, R, R, R, B, B]
s_e = [(Ce, [a, b, c, d]) | a <- l, b <- l, c <- l, d <- l]
@clrnd
clrnd / scraper.hs
Created April 1, 2016 19:17
Scalpel scraper for Dr. Who IMDB ratings.
-- stack --resolver lts-5.8 runghc --package "aeson scalpel bytestring text"
{-# LANGUAGE LambdaCase #-}
module Main where
import Control.Monad (forM)
import Text.HTML.Scalpel
import Data.Aeson
import Data.Text (Text, unpack, pack, strip)
import qualified Data.Text.IO as T
import qualified Data.ByteString.Lazy as B
@clrnd
clrnd / coder.clj
Created February 25, 2016 12:20
alphabet-cipher kata solution
(ns alphabet-cipher.coder)
; Vemos que encodear un caracter `m` con
; una letra de keyword `k` es equivalente a sumar sus indices
; en el abecedario modulo 26.
;
; Por ejemplo: con indice("m") = 12 y indice("s") = 18 tenemos
; 12 + 18 ≡ 4 (mod 26)
; y 4 = indice("e")
;
module Main where
import Control.Concurrent.Async.Pool
main :: IO ()
main = do
withTaskGroup 5 $ \g ->
mapTasks_ g $ map print [1..10]
putStrLn "Done!"
@clrnd
clrnd / clusters.py
Created July 1, 2015 13:57
Cluster/partition spatial data in equal sized convex spacially cohesive parts
# coding: utf-8
import csv
import json
import numpy as np
def r_tree(points, K):
""" STR method for building R-Tree like structure.
http://stats.stackexchange.com/a/40785
http://www.dtic.mil/dtic/tr/fulltext/u2/a324493.pdf (pag. 8)

Keybase proof

I hereby claim:

  • I am alvare on github.
  • I am alvare (https://keybase.io/alvare) on keybase.
  • I have a public key whose fingerprint is 299F A304 4E77 184C 7831 7E7D A45B 3D40 CF96 B477

To claim this, I am signing this object:

@clrnd
clrnd / testv2.hs
Last active December 30, 2015 10:39
Data.Sequence lol
import Text.Printf
import System.CPUTime
import qualified Data.Sequence as Seq
import Data.Sequence ((><), (<|), (|>))
import Data.Foldable (toList)
time :: IO t -> IO t
time a = do
start <- getCPUTime
v <- a
import Text.Printf
import Control.Exception
import System.CPUTime
time :: IO t -> IO t
time a = do
start <- getCPUTime
v <- a
end <- getCPUTime
let diff = (fromIntegral (end - start)) / (10^12)