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
enum Status { | |
Pending, | |
PaymentReceived, | |
Shipped | |
} | |
class EnumConverter<E> { | |
toEnum(orig : string) : E { | |
return this.enumMap()[orig]; | |
} |
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 ApplicativeDo #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
module Main where | |
------------------------------------------------------------------------------- | |
import Control.Monad | |
import Data.ByteString (ByteString) | |
import Data.List.NonEmpty | |
import Data.Semigroup |
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
{-# OPTIONS_GHC -Wall -Werror #-} | |
{-# LANGUAGE DeriveFunctor #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
module Main | |
( main | |
) where | |
------------------------------------------------------------------------------- | |
import Control.Monad (void) |
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.Lens | |
-- from Control.Error | |
hush :: Either e a -> Maybe a | |
hush (Left _) = Nothing | |
hush (Right a) = Just a | |
------------------------------------------------------------------------------- | |
data Lossy e a b = Lossy { |
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
module PerPage | |
( PerPage -- don't export the constructor, only constructable via smart constructor prism | |
, perPage | |
) where | |
import qualified Control.Lens as L | |
import qualified GHC.TypeLits as TL | |
import Data.Proxy (Proxy(..)) | |
-- Represents a per page parameter you may accept on a web server, API, etc for pagination. |
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
#!/bin/bash | |
# alias stack='~/stack.sh' | |
SUCCESS=${SUCCESS:=~/Dropbox/Music/YUH.wav} | |
FAILURE=${FAILURE:=~/Dropbox/Music/AUGH.wav} | |
stack "$@" | |
status=$? | |
if [[ $status -eq 0 ]] |
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
safeHead :: [a] -> Maybe a | |
safeHead [] = Nothing | |
safeHead (x:xs) = Just x | |
safeDiv :: Int -> Int -> Maybe Int | |
safeDiv _ 0 = Nothing | |
safeDiv x y = Just (div x y) | |
divideHeads :: [Int] -> [Int] -> Maybe Int | |
divideHeads xs ys = 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
import Data.List (sort) | |
import System.Environment (getArgs) | |
main = do (inFile:outFile:_) <- getArgs | |
writeFile outFile . unlines . sort . lines =<< readFile inFile |
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
source "http://rubygems.org" | |
gem "guard-shell" | |
gem "rake" |
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
require 'sinatra' | |
require 'pp' | |
delete '/' do | |
"you DELETED: #{request.body.string}" | |
end | |
put '/' do | |
"you PUTTED: #{request.body.string}" | |
end |
NewerOlder