They are generally better than the alternatives installed by your vendor.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sample an item from an ordered set with the proportional weights 1, 2, 3, …: | |
tri x = (x·(x+1))/2 | |
invtri x = (√(8·x+1)−1)/2 | |
r ← uniform [0,1) | |
n = number of items | |
index = floor (invtri (r · tri n)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -eu | |
umask 077 | |
for username; do | |
password="$(pwgen -n 16 1)" | |
printf '%s:%s\n' "$username" "$password" | chpasswd | |
chage -E "$(( ($(date '+%s') / 86400) + 2 ))" "$username" | |
passwd -e "$username" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE MagicHash #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE UnboxedTuples #-} | |
{-# OPTIONS_GHC -fno-warn-orphans #-} | |
-- | 'MonadState' and 'MonadReader' instances for 'ST' and 'IO' | |
module MTLSTIO (State' (..)) where |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Monoid | |
import Data.Set (Set, (\\)) | |
import qualified Data.Set as Set | |
type Square a = [Row a] | |
type Row a = [a] | |
main :: IO () | |
main = mapM_ (putStrLn . unlines) (genSquare (Set.fromList "abc")) where |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE RankNTypes #-} | |
import Control.Applicative | |
import Data.Functor.Identity | |
import Data.Monoid | |
type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t | |
type Traversal s t a b = forall f. Applicative f => (a -> f b) -> s -> f t | |
_1 :: Lens (a,b) (a',b) a a' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List | |
-- | What to do when taking the middle of a list where the number of elements | |
-- around the middle window is odd. Either return the requested number of | |
-- elements or grow the window by one (making the number of elements on either | |
-- side of the window the same). The latter is convenient for computing the | |
-- median of a list (@median = mean . takeMiddle GrowWindow 1@). | |
data WindowBehavior = KeepWindow -- ^ @splitMiddle KeepWindow 1 "abcd" = ("a", "b", "cd")@ | |
| GrowWindow -- ^ @splitMiddle GrowWindow 1 "abcd" = ("a", "bc", "d")@ | |
deriving (Eq, Ord, Bounded, Show, Read) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- If ($) was left-associative | |
foo = bar -- an expression worth its own line | |
$ baz -- ditto, as the first parameter to bar | |
$ quuz -- ditto, as the second parameter to bar |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module BoxMuller | |
( getNormal | |
, getNormal' | |
, getNormals | |
, getNormals' | |
) where | |
import Control.Monad ((<$!>)) | |
import Control.Monad.Random |