Skip to content

Instantly share code, notes, and snippets.

@plecong
plecong / Dockerfile
Last active June 26, 2019 23:13
Jenkins Docker with AWS CLI
FROM jenkins/jenkins:lts
USER root
RUN apt update -y && \
apt install -y python3-pip
RUN pip3 install awscli --upgrade
USER jenkins
COPY plugins.txt /usr/share/jenkins/ref/plugins.txt
open System
let part1 (input : string) : int =
let chars = input.ToCharArray()
chars
|> Seq.pairwise
|> Seq.append [(chars.[chars.Length - 1], chars.[0])]
|> Seq.where (fun (x, y) -> x = y)
|> Seq.sumBy (fun (x, _) -> Convert.ToInt32(Char.GetNumericValue(x)))
@plecong
plecong / data.csv
Last active September 7, 2017 22:23
name value
Katrina 150
Mike 200
Vincent 130
Life 0
MyGrade 0
@plecong
plecong / Redux Command.md
Last active June 1, 2017 17:19
Redux Command

Redux Command

A version of Flux on top of Redux with a (hopefully) simpler API. When approaching Redux, for such a simple yet powerful library, there are quite a few concepts to learn including actions, action creators, reducers, stores, middleware, thunks, etc. Furthermore, with so many parts, organizing them becomes a problem (see Ducks).

Redux Command attempts to simplify the number of concepts and also provide an obvious connection between them to promote easier use while still allowing for the full power of Redux.

#r "FSharp.Data.dll"
open FSharp.Data
open System.IO
let rec addNumbers (input : JsonValue) : int =
match input with
| JsonValue.Number n -> int n
| JsonValue.Array a ->
a |> Seq.map addNumbers |> Seq.sum
| JsonValue.Record r ->
open System
open System.Text
let getCharEx (input : int) =
Encoding.ASCII.GetString([| byte (97 + (int (input % 26))) |]).ToCharArray().[0]
let codeToChar =
seq { for i = 0 to 25 do yield (uint64 i), getCharEx i }
|> dict
open System
open System.Text
module List =
let rec skip n xs =
match (n, xs) with
| 0, _ -> xs
| _, [] -> []
| n, _::xs -> skip (n-1) xs
open System
open System.Collections.Generic
open System.IO
open System.Text.RegularExpressions
type Route = {
a : string; b : string; distance : int
}
let routesRegex = @"(\w+) to (\w+) = (\d+)"
open System
open System.IO
let (|StartsWith|_|) (check : string) (str : string) =
if str.StartsWith(check) then Some(str)
else None
let (|NotEmpty|_|) (str : string) =
if (not (String.IsNullOrEmpty(str))) then Some(str)
else None
open System
open System.Collections.Generic
open System.IO
open System.Text.RegularExpressions
type Part = {
a : string;
b : string;
operator : string;
target : string