.NET Internals Cookbook Part 7 — Word tearing, locking and others

This is the seventh part of the .NET Internals Cookbook series. For your convenience you can find other parts in the table of contents in Part 0 – Table of contents 45. Should we always avoid boxing? Boxing is expensive, it wraps value…

.NET Internals Cookbook Part 6 — Object internals

This is the sixth part of the .NET Internals Cookbook series. For your convenience you can find other parts in the table of contents in Part 0 – Table of contents 36. What is a shim? .NET applications are started directly, the same…

.NET Internals Cookbook Part 5 — Methods, parameters, modifiers

This is the fifth part of the .NET Internals Cookbook series. For your convenience you can find other parts in the table of contents in Part 0 – Table of contents 27. Can two methods differ in return type only? Not in C#,…

.NET Internals Cookbook Part 4 — Type members

This is the fourth part of the .NET Internals Cookbook series. For your convenience you can find other parts in the table of contents in Part 0 – Table of contents 18. Can you add type constructor to the interface? In C# no.…

.NET Internals Cookbook Part 3 — Initialization tricks

This is the third part of the .NET Internals Cookbook series. For your convenience you can find other parts in the table of contents in Part 0 – Table of contents 13. Can a variable be true and false at the same time?…

.NET Internals Cookbook Part 2 — GC-related things

This is the second part of the .NET Internals Cookbook series. For your convenience you can find other parts in the table of contents in Part 0 – Table of contents 7. How to compact the LOH? You need to set GCSettings.LargeObjectHeapCompactionMode property…

.NET Internals Cookbook Part 1 — Exceptions, filters and corrupted processes

This is the first part of the .NET Internals Cookbook series. For your convenience you can find other parts in the table of contents in Part 0 – Table of contents 1. What happens when you throw something which does not inherit from…

.NET Internals Cookbook Part 0 — Table of contents

This is the table of contents of the .NET Internals Cookbook. Look below for links to all answers. In this series I answer various .NET questions. Some of them are asked during interviews, some of them I see on the internet, some of…

Turing Machine Part 5 — Twice as many ones as zeroes

This is the fifth part of the Turing Machine series. For your convenience you can find other parts in the table of contents in Part 1 – Addition Today we check whether a string has exactly twice as many ones as zeroes. States:…

Turing Machine Part 4 — Subtraction

This is the fourth part of the Turing Machine series. For your convenience you can find other parts in the table of contents in Part 1 – Addition Today we subtract two numbers. This is very similar to addition so should be pretty…

Turing Machine Part 3 — Checking palindromes

This is the third part of the Turing Machine series. For your convenience you can find other parts in the table of contents in Part 1 – Addition Today we check if given word w is a palindrome. First, we add delimiters at…

Phantom types to encode state in C#

You cannot add or remove method from generic interface based on the type. Also, CLR doesn’t support higher kinded types (as of now). Let’s say that we want to encode state of an object in its type and disallow some operations depending on…

Source compatibility issue with Google Guava library

Recently I was debugging a case of NoSuchMethodError when using the Google Guava library. Conceptually my code was doing the following:

In runtime I was using library in version 19 and I was getting the following error:

I decompiled the code…

Turing Machine Part 2 — Checking if a word is a repetition

This is the second part of the Turing Machine series. For your convenience you can find other parts in the table of contents in Part 1 – Addition Today we check if given word w is of a form w = xx. Idea…

Turing Machine Part 1 — Addition

This is the first part of the Turing Machine series. For your convenience you can find other parts using the links below: Part 1 — Addition Part 2 — Checking if a word is a repetition Part 3 – Checking palindromes Part 4…

ILP Part 55 — Shortest path

This is the fifty fifth part of the ILP series. For your convenience you can find other parts in the table of contents in Part 1 – Boolean algebra We have already seen Max flow and last time we used it to ensure…

ILP Part 54 — Graph connectivity

This is the fifty fourth part of the ILP series. For your convenience you can find other parts in the table of contents in Part 1 – Boolean algebra Last time we saw how to implement max flow in ILP. Today we are…

ILP Part 53 — Max flow

This is the fifty third part of the ILP series. For your convenience you can find other parts in the table of contents in Part 1 – Boolean algebra Today we are going to implement Maximum flow in ILP. We use the following…

Heat map in Excel

If you ever wondered how to create heat maps in excel, here are two simple solutions. Data preparation Create two columns with data, as presented below. Next, select values in column C and choose conditional formatting in Home ribbon (see screenshot). This way…

ILP Part 52 — Unsigned magnitude decomposition for real variables

This is the fifty second part of the ILP series. For your convenience you can find other parts in the table of contents in Part 1 – Boolean algebra In part 2 we saw how to calculate unsigned magnitude decomposition for non-negative integer…