Skip to content

Instantly share code, notes, and snippets.

View sharkdp's full-sized avatar

David Peter sharkdp

View GitHub Profile
@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 "."
@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

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

Data.NaturalTransformation
Type.Proxy
Data.Boolean
Unsafe.Coerce
Data.Int.Bits
Data.Show
Data.String.Unsafe
Global.Unsafe
Data.ArrayBuffer.Types
Data.Char
@sharkdp
sharkdp / Main.purs
Last active September 10, 2017 08:44
Try Flare main example
module Main where
import Prelude
import Text.Smolder.HTML as H
import Text.Smolder.Markup ((!), text)
import Text.Smolder.HTML.Attributes as A
import Color (black, toHexString)
import Flare.Smolder (runFlareHTML)
@sharkdp
sharkdp / Main.purs
Last active February 12, 2017 16:31
Color matrix
module Main where
import Prelude
import Data.List.Lazy
import Data.Maybe
import Data.Tuple
import Data.Int (pow, toNumber)
import Flare
import Flare.Drawing
@sharkdp
sharkdp / watch.py
Created February 16, 2017 19:37
Randomly choose a movie from your IMDb watchlist
import csv
import random
with open("WATCHLIST.csv") as f:
rows = csv.DictReader(f, delimiter=",", quotechar='"')
movies = [row for row in rows if row["Title type"] == "Feature Film"]
movie = random.choice(movies)
@sharkdp
sharkdp / insect-type-safety.md
Last active August 24, 2017 19:59
Type-safety in physics calculations

Type-safety in physics calculations

This article describes a (loose?) analogy between physical units and data types in programming languages that I thought about while working on Insect, a scientific calculator that supports physical units.

In addition to typical mathematical operators like +, *, ^, %, etc., Insect has a special conversion operator (written as an arrow ->/ or as the word to). It can be used to convert an expression to a particular unit:

≫ 2 ft + 2 in ➞ cm

  = 66.04 cm
 
#pragma once
extern double pi;
@sharkdp
sharkdp / cold-cache.sh
Last active October 7, 2017 20:13
fd benchmark scripts
echo "This script will now ask for your password in order to gain root/sudo"
echo "permissions. These are required to reset the harddisk caches."
echo ""
sudo echo "Okay, acquired superpowers :-)" || exit
base_path="/mnt/daten"
pattern='.*[0-9]\.jpg$'
for _ in $(seq 1 3); do