This file contains hidden or 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 PackageImports #-} | |
| module Main where | |
| import qualified Data.Char as C | |
| import qualified Data.Word as W | |
| -- must qualify this (requiring the ghc pragma above) to disambiguate | |
| -- from the Data.UUID also in system-uuid | |
| import qualified "uuid" Data.UUID as U | |
| import qualified Data.UUID.V5 as U5 |
This file contains hidden or 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 Main where | |
| import Control.Monad.Random | |
| import Data.Char | |
| rnd :: (RandomGen g) => Rand g Int | |
| rnd = getRandomR (65,90) | |
| main = do | |
| values <- evalRandIO (sequence (replicate 10 rnd)) |
This file contains hidden or 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
| {"S":"a string"} | |
| {"N":"123456"} | |
| {"SS":["a string","another string"]} | |
| {"NS":["123","456"]} |
This file contains hidden or 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
| #!/usr/bin/env gorun | |
| package main | |
| import ( | |
| "encoding/json" | |
| "fmt" | |
| ) | |
| type MyJSONType struct { |
This file contains hidden or 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
| // take an interface{} string and turn it into a real string | |
| func To_S(i interface{}) (string,error) { | |
| i_str,ok := i.(string) | |
| if !ok { | |
| e := fmt.Sprintf("cannot convert %v to string\n",i) | |
| return "", errors.New(e) | |
| } | |
| return i_str,nil | |
| } |
This file contains hidden or 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 Network.Wai | |
| import Network.Wai.Handler.Warp | |
| import Network.HTTP.Types | |
| import qualified Data.Text as T | |
| import Data.Time.Clock | |
| import Data.Time.Format |
This file contains hidden or 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 Main where | |
| import Data.List | |
| import Data.List.Split | |
| -- performs the transformation of adjacent strings | |
| tr :: String -> String | |
| tr s = case s of | |
| "ab" -> "c" | |
| "ba" -> "c" | |
| "ac" -> "b" |
This file contains hidden or 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 TupleSections #-} | |
| module Main where | |
| -- see https://plus.google.com/u/0/105746006385940131491/posts/9Uev6KVRUgK for | |
| -- context | |
| -- what we essentially have is a non-associative operation (represented by | |
| -- concatenation): | |
| -- | |
| -- ab = ba = c | |
| -- bc = cb = a |
This file contains hidden or 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
| <?php | |
| $u = 4/0; | |
| if ($u == $t) { | |
| print "do stuff with *your* credit card number here\n"; | |
| } | |
| ?> |
This file contains hidden or 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 Main where | |
| import qualified Data.DateTime as DATE | |
| import qualified Control.Monad as C | |
| import qualified Control.Monad.Trans as CT | |
| import qualified Database.Redis as R | |
| import qualified System.Random as SR | |
| import qualified Data.ByteString.UTF8 as U | |
| -- a nice find from the web - picking an elt at random |