Instantly share code, notes, and snippets.

View JSONParse.hs
-- |
-- Module : Text.JSON.Parsec
-- Copyright : (c) Galois, Inc. 2007-2009
-- Maintainer: Sigbjorn Finne <>
-- Stability : provisional
-- Portability: portable
-- Parse JSON values using the Parsec combinators.
View EnumLogfile.hs
module Automata where
import Control.Applicative
import Control.Monad.Trans
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as C
import qualified Data.Map as M
import Data.List
import Data.Word
import System.Environment
View Automata.hs
module Automata where
import Prelude hiding (id, (.))
import Control.Category
import Control.Arrow
import qualified Data.Map as M
import Data.List (sort)
data Automaton b c = Automaton (b -> (c, Automaton b c))
View Visualizer.hs
module Visualiser where
import Numeric.FFT
import Data.Complex
test :: [Complex Double]
test = concat $ replicate 16 (replicate 8 1.0 ++ replicate 8 (-1.0))
freqs :: [Complex Double] -> [Double]
freqs samples = take (n `div` 2) . map (/ fromIntegral n) . map magnitude $ fft samples
View gist:974782
module Main where
import Sound.Pulse.Simple
s<-simpleNew Nothing "example" Play Nothing "this is an example application"
(SampleSpec (F32 LittleEndian) 44100 1) Nothing Nothing
simpleWrite s (take 44100 (test 440) ++ take 44100 (test 330) )
simpleDrain s
simpleFree s
View gist:868042
import Text.JSON
import Data.Maybe
data JSZipper = JSZipper {
parent :: Maybe JSZipper,
lefts :: [JSValue],
hole :: JSValue,
rights :: [JSValue]
View chat.html
<title>WebSocket Chat</title>
<script type='text/javascript'>
if (!window.WebSocket)
alert("WebSocket not supported by this browser");
function $() { return document.getElementById(arguments[0]); }
function $F() { return document.getElementById(arguments[0]).value; }
View gist:791274
-- This program solves the Theme Park Google CodeJam problem at
-- I've tried to make the code clear whilst employing a selection of Haskell library
-- functions and idioms. I've also gone for efficiency, probably over optimizing in
-- places in order to demonstrate some techniques.
module Main where
import Data.List
View gist:782199
module Main where
import Text.Printf
profit :: Integer -> Integer -> [Integer] -> Integer
profit cap rides groups
| sum groups <= cap = rides * sum groups
| otherwise = profit' cap rides (cycle groups)
View gist:736615
module Main where
import Control.Arrow
import Data.Array
import Data.Char
import Data.Bits
import Data.Function
import Data.List
import Data.Maybe
type Bark = Array (Int, Int) Bool