Skip to content

Instantly share code, notes, and snippets.

View sharkdp's full-sized avatar

David Peter sharkdp

View GitHub Profile

Did you look at the actual changes to the file(s) in the repository?

@sharkdp
sharkdp / ratings.py
Last active September 11, 2016 08:52
Statistical evaluation of your IMDB ratings
#!/usr/bin/env python
#
# Usage: ratings.py [RATINGS CSV FILE]
import argparse
import csv
import statistics
import itertools
from collections import defaultdict
@sharkdp
sharkdp / Main.purs
Last active May 26, 2016 23:03
LambdaConf talk example
module Main where
import Prelude
import Flare
import Test.FlareCheck
sayHello :: String -> Int -> Boolean -> String
sayHello name year shout = "Hello " <> name <> " " <> show year <> suffix
where suffix = if shout then "!!!" else "."
module Main where
import Prelude
import Control.Monad.Eff.Console
import Data.Int as I
import Data.Complex as C
import Math as M
class Ring r <= Absolute r where
{-# LANGUAGE DeriveFunctor #-}
import Data.Monoid
import Control.Monad
import Control.Applicative
-- | An applicative functor `f` over a base type `b` that is "annotated" by a
-- | monoidal type `a`.
data Ann a f b = Ann a (f b)
deriving (Eq, Ord, Show, Functor)
@sharkdp
sharkdp / Main.purs
Created March 22, 2016 18:47
Rendering with additional effects
module Main where
import Prelude
import Data.Int
import Data.Array
import Data.Maybe
import Data.Foldable
import Control.Monad.Eff
@sharkdp
sharkdp / Main.purs
Created February 8, 2016 22:14
Celsius to Fahrenheit (small)
module Main where
import Prelude
import Flare
celsius = number "Celsius" 0.0
convert c = "Fahrenheit: " <> show (c * 9.0 / 5.0 + 32.0)
main = runFlare "controls" "output" (map convert celsius)
module Main where
import Prelude
import Control.Apply ((*>))
import Signal (Signal(), merge)
import Signal.Time (every, second)
import Flare (UI(), liftSF, button, foldp, runFlareShow)
tick :: Signal Int
tick = every second *> pure 1
module Main where
import Prelude
import Data.Array (reverse)
import Data.Foldable (traverse_)
import Data.Monoid
import Data.Traversable (traverse)
import Control.Applicative.Free
@sharkdp
sharkdp / paniclab.purs
Created July 26, 2015 09:39
Simulation of the game Panic Lab
module Main where
import Prelude
import Control.Monad (when)
import Control.Monad.Eff
import Control.Monad.Eff.Console
import Data.Int
import Data.Int.Bits
import Data.List