Skip to content

Instantly share code, notes, and snippets.

@5outh
5outh / docgen.sh
Last active August 29, 2015 14:04
Manual hackage documentation upload
# 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"
@5outh
5outh / pahcal1
Created January 4, 2012 03:59
pashamno
puts "hello"
@5outh
5outh / gist:2289676
Created April 3, 2012 06:06
BubbleSort
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
@5outh
5outh / gist:2289678
Created April 3, 2012 06:06
BubbleSort
puts "Hello world"
@5outh
5outh / gist:2289680
Created April 3, 2012 06:07
BubbleSort
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
@5outh
5outh / gist:2289711
Created April 3, 2012 06:16
Insertion Sort
import Data.List
insertionSort :: (Ord a) => [a] -> [a]
insertionSort = foldr insert []
@5outh
5outh / gist:2289792
Created April 3, 2012 06:34
Quick Sort
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 July 11, 2012 20:38
99 Haskell Problems: Problem 13
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 July 11, 2012 23:15
Move Character
#pragma strict
var forwardSpeed = 10;
var backwardSpeed = 8;
var sideSpeed = 10;
var xDisplacement:float;
var zDisplacement:float;
var displacement:Vector3;
@5outh
5outh / gist:3094373
Created July 11, 2012 23:11
Mouse Orbit
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;