Posts

Showing posts from 2017

How to Setup a Fable-Elmish Project (May 1 2017)

Table of ContentsHow to Setup a Fable-Elmish Project (May 1 2017)Setup .NET Core and F#IDE.NET CoreMicrosoft Build ToolsF# 4.0Setup Fable-ElmishInstall yarnSetup a new project with Fable-ElmishSetup debugging environmentChromeFirefoxOpera, IE, Safari, etc.Run the sampleNext stepsConclusionHow to Setup a Fable-Elmish Project (May 1 2017)This is a short post that details the steps needed to setup a basic project with the following tools:.NET Core and F#Fable-ElmishWorking Time Travel Debugger on Firefox and Chrome.At the end, you should have the sample Fable-Elmish project (showing navigation and counter example) running in a browser with a working time travel debugger.These instructions are working as of 1 May 2017.NOTE: If you are already familiar with Fable-Elmish, this post will probably not help you. However, I would greatly appreciate any tips or corrections to improve these instructions.Setup .NET Core and F#The first step I took was to setup .NET Core. I downloaded and installed…

AOC 2016 - Day 7

Table of ContentsAOC 2016 - Day 7BackgroundProblem - Part 1Solution - Part 1Extract supernet and hypernet sequences from an IP addressCheck for an ABBA patternCheck an entire IP addressConnect the piecesProblem - Part 2Solution - Part 2Extract supernet and hypernet sequences from an IP addressCheck if a supernet sequence has at least one ABACheck if a hypernet sequence has at least one BABCheck a single IP addressConnect the piecesLessons learnedAOC 2016 - Day 7Problem statement on the Advent of Code website.Code for this post can be found on GitHub.BackgroundOn Day 1, we located Easter Bunny headquarters.On Day 2, we broke the code to use the bathroom in Easter Bunny HQ.On Day 3, we helped the EBHQ's design department by removing invalid triangles from the list.On Day 4, we figured out which rooms in the information kiosk are valid.On Day 5, we figured out how to get past security doors by calculating the code.On Day 6, we figured out how to communicate with Santa through the Eas…

AOC 2016 - Day 6

Table of ContentsAOC 2016 - Day 6BackgroundProblem - Part 1Solution - Part 1Calculate length of the longest garbled messageFind the most frequent character in a given positionCollect the most frequent characters in each positionProblem - Part 2Solution - Part 2Find the least frequent character in a given positionCollect the least-frequent characters in each positionConsiderations for Day 6Using a F# project templateUsing a testing frameworkLessons learnedAOC 2016 - Day 6Problem Statement on Advent of Code website.Code for this post can be found on GitHub.BackgroundOn Day 1, we located Easter Bunny headquarters.On Day 2, we broke the code to use the bathroom in Easter Bunny HQ.On Day 3, we helped the EBs' design department by removing invalid triangles from the list.On Day 4, we figured out which rooms in the information kiosk are valid.On Day 5, we figured out how to get past security doors by calculating the code.On Day 6, we will figure out how to communicate with Santa through …

AOC 2016 - Day 5

Table of ContentsAOC 2016 - Day 5BackgroundProblem - Part 1Solution - Part 1Collection functionProblem - Part 2Solution - Part 2Storing the pieces of the answerCollecting the pieces of the answerProducing the answerSome side notesMutable vs. Immutable data structuresSeq vs. ParallelSeqLessons learnedPS: Solution - Part 2 (Pure functional implementation)Performance comparison with day5part2AOC 2016 - Day 5Problem statement on Advent of Code website.Code for this post can be found on GitHub.BackgroundOn Day 1, we located Easter Bunny headquarters.On Day 2, we broke the code to use the bathroom in Easter Bunny HQ.On Day 3, we helped the EBs' design department by removing invalid triangles from the list.On Day 4, we figured out which rooms in the information kiosk are valid.On Day 5, we will figure out how to get past security doors by calculating the code.Problem - Part 1For Part 1, we are given two pieces of information.The door IDAn increasing integer index, starting at 0.For each …

MD5 in F#, Functionally

Table of ContentsMD5 in F#, FunctionallyOut-of-the-box implementationPlanning the implementationConsiderationsMapping from Wikipedia to F#ImplementationStep 1: Define the shift in each of the 64 roundsStep 2: Calculate the binary integer portion of integer sinesStep 3: Define the typesStep 4: Padding the messageStep 7: The core of the main loop (Yes, I know this is out of order)Step 6: Hash a single 512-bit chunkStep 5: Process the entire message and derive a single MD5 hashTestingPerformanceLessons LearnedMD5 in F#, FunctionallyCode for this post can be found on GitHub.The Advent of Code Day 5 problem presented a very interesting challenge - it required an MD5 hash function to get the final answer.As my goal with the AOC challenges is to increase my knowledge of F#, I chose to:Implement my own version of the MD5 algorithmImplement it functionally (no mutation, if possible)Out-of-the-box implementation.NET has an out-of-the-box implementation of MD5, which can be accessed quite easily…