Skip to content

Instantly share code, notes, and snippets.

@gatlin
gatlin / nn_repa.hs
Last active September 24, 2015 01:42
Simple neural network with backpropagation in Haskell, using Repa. Inspired by: http://iamtrask.github.io/2015/07/12/basic-python-network/
{-
To run:
1. Ensure you have repa and repa-algorithms installed
2. ghc --make nn_repa.hs -O2
3. ./NN +RTS -s
The `+RTS -s` part prints out a summary of runtime statistics.
-}
@jorinvo
jorinvo / challenge.md
Last active April 21, 2023 17:14
This is a little challenge to find out which tools programmers use to get their everyday tasks done quickly.

You got your hands on some data that was leaked from a social network and you want to help the poor people.

Luckily you know a government service to automatically block a list of credit cards.

The service is a little old school though and you have to upload a CSV file in the exact format. The upload fails if the CSV file contains invalid data.

The CSV files should have two columns, Name and Credit Card. Also, it must be named after the following pattern:

YYYYMMDD.csv.

@nkpart
nkpart / CrazyIO.hs
Created February 3, 2015 02:47
CrazyIO - binary deserialization using mmaped I/O and Data.Vector.Storable
{-# LANGUAGE ScopedTypeVariables #-}
module CrazyIO (module CrazyIO, mmapFileByteString) where
import qualified Data.Vector.Storable as V
import qualified Data.ByteString as BS
import qualified Data.ByteString.Internal as BS
import Foreign
import System.IO.MMap
crazyLoad :: forall a. Storable a => FilePath -> Maybe (Int64, Int) -> IO (V.Vector a)
@glguy
glguy / gist:74960a3f1531b64a201b
Last active August 29, 2015 14:05
Lens Cookbook

Optic Cookbook

The imports for building the various field-oriented optics are pretty minimal. It's not until you make a Getter or a Fold that you need to look outside of base.

This cookbook only covers the field oriented optics and not the constructor oriented ones. If you want to build a Prism or an Iso without a lens dependency, you should copy the definition of lens' prism and iso combinators and add a profunctors dependency to your project. Those two combinators are quite self-contained.