This file contains 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 random, turtle | |
def maze(w=10, h=10): | |
# This is the random spanning tree implementation | |
seen = set() | |
# Add some walls to confine the maze | |
for i in xrange(-1, w+1): | |
seen.add((i, -1)) | |
seen.add((i, h+1)) |
This file contains 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
-- NO ! | |
record :: (Show a, Show label, MonadIO m) => label -> Pipe a a m () | |
record label = do | |
x <- await | |
print (label, x) | |
yield x | |
-- yes: | |
record :: (Show a, Show label, MonadIO m) => label -> Pipe a a m () | |
record label = do |
This file contains 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 OverloadedStrings #-} | |
module Main where | |
import Control.Concurrent (forkIO) | |
import Control.Monad (forever) | |
import Network.Wai.Handler.Warp (run) | |
import Network.Wai.Handler.WebSockets as WaiWS | |
import Network.WebSockets (acceptRequest, receiveDataMessage, sendTextData, PendingConnection, defaultConnectionOptions, DataMessage(..)) | |
import Data.ByteString.Lazy (ByteString) |
This file contains 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
$ nix-shell -p "haskell.packages.ghcjs.ghcWithPackages (pkgs: [pkgs.reflex-dom])" |
This file contains 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 Reactive.Banana (compile) | |
import Reactive.Banana.Frameworks (newAddHandler, fromAddHandler, actuate, reactimate) | |
import Control.Concurrent (threadDelay, forkIO) | |
import Control.Monad (forever) | |
import Data.Char (toUpper) | |
main = do | |
-- newAddHandler returns an AddHandler (roughly a callback) and a | |
-- way to fire the callback (fire). | |
(es, fire) <- newAddHandler |
This file contains 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.ReactiveValue ((=:>), ReactiveFieldWrite(..), ReactiveFieldRead(..)) | |
import Hails.Polling (pollingReactive) | |
main :: IO () | |
main = do | |
hello <- pollingReactive (return "hello") (Just 1000000) | |
let out = ReactiveFieldWrite print | |
hello =:> out | |
getLine >> return () |
This file contains 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 dbus | |
bus = dbus.SystemBus() | |
NM = 'org.freedesktop.NetworkManager' | |
def get_manager(): | |
proxy = bus.get_object(NM, '/org/freedesktop/NetworkManager') | |
return dbus.Interface( | |
proxy, NM) |
This file contains 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 numpy | |
MODEL = """\ | |
53..7.... | |
6..195... | |
.98....6. | |
8...6...3 | |
4..8.3..1 | |
7...2...6 | |
.6....28. |
This file contains 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 System.Environment | |
import Data.Array.Repa as R | |
import Data.Array.Repa.Algorithms.Randomish as RR | |
import Criterion.Main | |
import Criterion.Config | |
ra = RR.randomishDoubleArray (ix2 1000 3) 0 1 1 | |
main = defaultMainWith defaultConfig {cfgSamples = ljust 10} (return ()) [ | |
bgroup "pairwise-random" [ |
This file contains 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
""" | |
Script to download a show from http://prairiehome.publicradio.org/ | |
Depends on rtmpdump (apt-get install rtmpdump) | |
Usage: | |
# List shows in January | |
python prar.py 2012 1 | |
# Download show with index 0 | |
python prar.py 2012 1 0 |