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 Control.Monad (unless) | |
import Prelude hiding (catch) | |
import System.IO (isEOF) | |
prependLineNums :: Int -> IO () | |
prependLineNums n = isEOF >>= flip unless prependLineNum | |
where prependLineNum = getLine >>= putStrLn . (++) (padTo 5 $ show n) | |
>> prependLineNums (n+1) | |
padTo c s = case c `compare` length s of | |
GT -> s ++ replicate (c - length s) ' ' |
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.Colour.RGBSpace.HSV (RGB, hsv) | |
nextColor :: (RealFrac a) => a -> a -> a -> (RGB a,a) | |
nextColor h s v = let h' = (h + golden_ratio_conjugate) % 360 | |
in (hsv h' s v,h') | |
where golden_ratio_conjugate = 222.4922359499622 -- 0.618033988749895 * 360 | |
dividend % divisor = dividend - divisor * | |
(fromIntegral $ floor (dividend/divisor)) | |
goldenColors :: (RealFrac a) => a -> a -> a -> [RGB a] |
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
-- To build just copy this and convexhull.cabal somewhere | |
-- and then run cabal build | |
-- | |
-- Usage Example: | |
-- > ./dist/build/viewConvexHull/viewConvexHull plot.pdf 1,10 10,5 4,6 7,9 20,1 4,2 5,6 8,2 3,9 | |
-- | |
-- this creates a pdf file called plot.pdf with the plot in the current directory | |
module Main where | |
import Control.Arrow |
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 InstanceSigs #-} | |
module Data.TwoThreeTree where | |
import Control.Applicative | |
import Data.Foldable | |
import Data.Traversable | |
import Prelude hiding (foldr) | |
data Tree23 k = Leaf |
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 Control.Monad (forM_) | |
import qualified Data.DList as DL | |
import System.Environment (getArgs,getProgName) | |
import System.Exit (exitSuccess) | |
data CSVState = OutsideQuote | InsideQuote | AfterQuote | |
listFromCSV :: String | |
→ [String] | |
listFromCSV = toResult ∘ foldl parseChar (OutsideQuote,DL.empty,DL.empty) |
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 #-} | |
import Control.Applicative | |
import Control.Exception | |
import Control.Monad | |
import Data.Char | |
import Data.List | |
import Data.Maybe | |
import Data.ByteString.Char8 (ByteString) | |
import qualified Data.ByteString.Char8 as C | |
import Prelude hiding (readFile) |
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 scala.language.higherKinds | |
import scala.math.{pow} | |
import scalaz._ | |
import Scalaz._ | |
import scalaz.effect._ | |
case class Point(_x : Double, _y : Double) | |
case class GameUnit(_health : Int, _position : Point) |
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
function! IndentAsPrevLine() | |
python << EOF | |
import itertools as I | |
from vim import * | |
if current.range.start > 0: | |
def takewhile(pred,l): return ''.join(I.takewhile(pred,l)) | |
prev_line = current.buffer[current.range.start - 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
import org.scalatest.FunSuite | |
import org.apache.spark.SparkConf | |
import org.apache.spark.SparkContext | |
class MyTestSuite extends FunSuite { | |
val conf = new SparkConf() | |
.setAppName("My Spark test") |
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
{- | |
Parsing the output of the xrandr command. For example: | |
$> xrandr | |
Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 32767 x 32767 | |
eDP1 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 309mm x 173mm | |
1920x1080 60.0*+ 59.9 | |
1680x1050 60.0 59.9 | |
1600x1024 60.2 | |
1400x1050 60.0 |
OlderNewer