Wednesday, 1 November 2017

Hubble Telescope made with Unity 3d

Hubble telescope finished and ready to be downloaded from

Most of the textures are in 4096x4096 px format and all materials are PBR.
Screenshots below were not modified, it is direct screen from Unity 3d game engine.

Tuesday, 12 September 2017

Simple extension class in ASP.NET C# application

We are going to write simple extension class to automatically add tax and give us gross price for net price. Very common feature in most of applications that are dealing with accounting, finance, trading, e commerce etc.

Seing code like this in lots of different places in application is not uncommon.

decimal grossPrice = (etPrice * 0.20) + netPrice;

It is not the end of the world if you are using that only in one place of the application, but in most case this code might appear in many places. As a developer I hate magic number (0.20 in this case) and not using DRY (do not repeat yourself) approach.

There is very simple approach to this problem I like to use - using extension.

Let's get straight to the code.

Constant class
public static class TaxConstants
    public static decimal TAX_VALUE = (decimal)0.20;

Extension class

namespace AbDeveloper.Extensions

public static class PriceExtension
    public static decimal AddTaxToNetValue(this decimal price)
      return price + price * Constants.TaxConstants.TAX_VALUE;

We can now easily test the functionality in test project.

using namespace AbDeveloper.Extensions;

  public class PriceExtensionTest
    public void TestAddTaxToNetValue()
      decimal netPrice = 20;
      decimal grossPrice = netPrice.AddTaxToNetValue();

      Assert.AreEqual(24, grossPrice, "Expected gross price is incorrect. Check AddTaxToNetValue method in PriceExtension class.");

At this stage test will pass and grossPrice will be equal 24 with an input of 20. If however tax rate will change to 0.25 (25%) test will fail.

In order to use extension in class make sure you will add "using namespace" expression.

Wednesday, 30 August 2017

The Richest Man in Babylon - 5 rules of gold

The Richest Man in Babylon - Book written in 1920s by George S.Clason still holds wisdom in terms of investing, business, money -

One of the chapters explains 5 rules of gold that wise man should follow. Below is my short explanation of how to apply those rules in modern world.

1. Gold cometh gladly and in increasing quantity to any man who will put by not less than one-tenth of his earnings to create an estate for his future and that of his family.

Make sure to save at least 10% of your net earnings..

2. Gold laboreth diligently and contentedly for the wise owner who finds for it profitable employment, multiplying even as the flocks of the field.

You can invest in bonds, stocks, low cost index funds(my personal preference), investment funds, ISA stock(UK only as I am aware), gold silver, crypto currencies such as bitcoin, ethereum. By buying stocks, investment funds and indexes you can also benefit from dividends. Avoid investing in stocks that do not pay dividends.

3. Gold clingeth to the protection of the cautious owner who invests it under the advice of men wise in its handling.

Invest your money wisely, avoid high leverage, get rich quick schemes, if something is too good to be true it's probably scam. When you are investing make sure to diversify your portfolio by investing in different types of markets.

4. Gold slippeth away from the man who invests it in businesses or purposes with which he is not familiar or which are not approved by those who are skilled in its keep.

Avoid investing in business you do not understand. This is very simple rule that greatest investor Warren Buffet follow.

5. Gold flees the man who would force it to impossible earnings or who followeth the alluring advice of tricksters and schemers or who trusts it to his own inexperience and romantic desires in investment.

Well connected with 3rd rule but it is very important to follow. Again I will quote Warren Buffet -"The first rule is not to lose. The second rule is not to forget the first rule".