Skip to content

Instantly share code, notes, and snippets.

@5outh
5outh / docgen.sh
Last active Aug 29, 2015
Manual hackage documentation upload
View docgen.sh
# Usage (from project root): ./docgen.sh <Repo Name> <Version> <Hackage Username> <Hackage Password>
# e.g. ./docgen.sh Bang 0.1.1.0 5outh F4kePa55word
#!/bin/bash
cabal configure && cabal build && cabal haddock --hyperlink-source \
--html-location='http://hackage.haskell.org/package/$pkg/docs' \
--contents-location='http://hackage.haskell.org/package/$pkg'
S=$?
if [ "${S}" -eq "0" ]; then
cd "dist/doc/html"
DDIR="${1}-${2}-docs"
View gist:2289676
bubbleSort :: (Ord a) => [a] -> [a]
bubbleSort [] = []
bubbleSort [x] = [x]
bubbleSort (x:y:xs) = if sorted thisSort then thisSort else bubbleSort thisSort
where thisSort = (min x y) : bubbleSort ((max x y):xs)
sorted :: (Ord a) => [a] -> Bool
sorted [] = True
sorted [x] = True
sorted (x:y:xs) = if x <= y then sorted (y:xs) else False
View gist:2289678
puts "Hello world"
View gist:2289680
bubbleSort :: (Ord a) => [a] -> [a]
bubbleSort [] = []
bubbleSort [x] = [x]
bubbleSort (x:y:xs) = if sorted thisSort then thisSort else bubbleSort thisSort
where thisSort = (min x y) : bubbleSort ((max x y):xs)
sorted :: (Ord a) => [a] -> Bool
sorted [] = True
sorted [x] = True
sorted (x:y:xs) = if x <= y then sorted (y:xs) else False
View gist:2289711
import Data.List
insertionSort :: (Ord a) => [a] -> [a]
insertionSort = foldr insert []
View gist:2289792
quickSort :: (Ord a) => [a] -> [a]
quickSort [] = []
quickSort (x:xs) = quickSort smaller ++ [x] ++ quickSort larger
where smaller = filter (<=x) xs
larger = filter (>x) xs
@5outh
5outh / gist:3093214
Created Jul 11, 2012
99 Haskell Problems: Problem 13
View gist:3093214
data Count = Multiple Int Char
| Single Char
deriving (Eq, Show)
encodeDirect :: [Char] -> [Count]
encodeDirect = map toCount . foldr encode []
where
toCount (x, y) = case x of
1 -> Single y
_ -> Multiple x y
@5outh
5outh / gist:3094384
Created Jul 11, 2012
Move Character
View gist:3094384
#pragma strict
var forwardSpeed = 10;
var backwardSpeed = 8;
var sideSpeed = 10;
var xDisplacement:float;
var zDisplacement:float;
var displacement:Vector3;
View gist:3094373
var target : Transform;
var distance = 10.0;
var xSpeed = 250.0;
var ySpeed = 120.0;
var zoomSpeed = 10;
var yMinLimit = -20;
var yMaxLimit = 80;
var zoomMinLimit = 10;