What I’m Reading This Week.

“Maybe” monad through async/await in C# (No Tasks!)

https://habr.com/en/post/458692/

Dmitry Tikhonov outlines how to create `Maybe` object in C# that carries 2 states (think about success and failure object) in a monad way. The implementation includes code sample and usage in async / await.

 

Functional Programming In Object-Oriented Programming In C#

https://www.codeproject.com/Articles/5162828/Functional-Programming-in-Object-Oriented-Programm

Emulate functional programming in an object oriented programming world. Yes it is possible. I do feel a basic understanding of functional programming is needed.

 

2019 State of Testing Report

https://www.infoq.com/articles/2019-state-testing-report/

Worth your time to read if you are involved a lot in testing. At least, read the “Key Takeaways”. This report covers what’s going on around global testing community as it surveys 1000 participants from around 80 countries.

 

Clancey’s HotUI

https://github.com/Clancey/HotUI

A MVU (Model View Update) way of building UI. Platform supported includes: iOS, Android, UWP, WPF, Mac OS, Xamarin.Forms, Blazor. And it support hot reload! It’s still proof of concept though, definitely don’t use it in production.

 

Jason Livesay’s NoScriptWeb

https://github.com/runvnc/noscriptweb

I thought this is a very cool concept. The idea is to build all pages in a website from markdown. 100% JavaScript free. That means, no ads, secure, fast browsing. Still work in progress, but promising.

Advertisements

Fair Distribution Algorithm

Given 5 boxes with different weight [24, 27, 17, 15, 17], distribute the weight as even as possible among 3 trucks of the same size. The trucks can fit unlimited number of boxes. The weight of the boxes can’t be transferred, for example moveĀ 4 from box 1 (originally weight 24) and transfer to box 2.

What if we have more boxes with different weight, let’s say 6 boxes with weight of [1, 2, 17, 21, 7, 6].

What if the number of truck change to 5 trucks?

What’s the most effective algorithm to distribute the boxes evenly (in weight) within all the trucks?

Parse JSON in SQL Server

I have following rows in database.

2019-07-17 17_33_37-SQLQuery45.sql - (local)_.Infinity (ENERGY_sutet (53))_ - Microsoft SQL Server M

Here is the full json:

{
    "FirstName": "Paul",
    "LastName": "Goodman",
    "Occupations": [
        {
            "Title": "Senior Manager",
            "Company": "Purple Ocean",
            "YearOfService": 9
        },
        {
            "Title": "Manager",
            "Company": "Blue Ocean",
            "YearOfService": 4
        }
    ]
}
{
    "FirstName": "Tom",
    "LastName": "Badman",
    "Occupations": [
        {
            "Title": "Supervisor",
            "Company": "Red Sky",
            "YearOfService": 1
        },
        {
            "Title": "Janitor",
            "Company": "Yellow Sky",
            "YearOfService": 7
        }
    ]
}

Here is how I can use JSON_VALUE to parse `Data` column.

2019-07-17 17_34_04-SQLQuery45.sql - (local)_.Infinity (ENERGY_sutet (53))_ - Microsoft SQL Server M

I can also use JSON_VALUE in WHERE clause.

2019-07-17 17_34_38-SQLQuery45.sql - (local)_.Infinity (ENERGY_sutet (53))_ - Microsoft SQL Server M