Skip to content

Instantly share code, notes, and snippets.

petermarks

Block or report user

Report or block petermarks

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View JSONParse.hs
--------------------------------------------------------------------
-- |
-- Module : Text.JSON.Parsec
-- Copyright : (c) Galois, Inc. 2007-2009
--
-- Maintainer: Sigbjorn Finne <sof@galois.com>
-- 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
main=do
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
<html><head>
<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; }
@petermarks
petermarks / gist:791274
Created Jan 22, 2011
Theme Park (Optimized)
View gist:791274
-- This program solves the Theme Park Google CodeJam problem at
-- http://code.google.com/codejam/contest/dashboard?c=433101#s=p2
--
-- 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
@petermarks
petermarks / gist:782199
Created Jan 16, 2011
Theme Park (Naive)
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)
where
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
You can’t perform that action at this time.