typescript 2.8 - Conditional Type

Conditional Type

Which basically trying to say if  type A kinda like B type, then we can just use C type.

interface Car {
drive():void; } interfaceFerarriextendsCar { drivefaster():void; } // Foo becomes numbertypeFoo=Ferarri extendsCar ? number : string;

Learning flutter quick and dirty guide

I find it easier to go through :-

1. Widget catalog - to check out what are the widget available in flutter. Basically their capabilities.

2. Cook book - All the code you need to quickly spin out a UI element. Pretty limited but you get an idea.

3. Code labs - is so much better compare to "Writing your first app" write up.

Hope this helps.

flutter : no connected devices available / configure.

Please make sure you have clone flutter sdk from here

and run

flutter doctor --android-licenses

Check to ensure you have install the following :-

Android SDK, Android SDK Platform-Tools, and Android SDK Build-Tools, Images are installed

Then from the toolbar make sure you set to a "device", in my case Nexus 6 API P emulator. This will fire it up and once it is up and running, click on the play button.

It is a bit weird but .......that's how it works. 

Flutter package repository

Flutter package repository can be found here.

Flutter : unable to locate development device

Face this issue trying to run Flutter using Android studio. This simple means you need to configure your platform tools.  Go to File->Project Structure->Configure your Platform Sdk as shown below :- Try to set to Android 27 (or as recent version of Android SDK as you could).

Then fire away. Once you have it configure, your application bar - Flutter Hot Reload -> Should be enabled.

That's a big

EF Core 2.0.1 - Entity framework migration specific update - minus out initial database update

Wow, this title is pretty long.

Let's say you already have an existing database and right now you wanted to use EF Core to help migrate specific DML updates to your target database - which could be creating a new View or creating additional table minus out the initial database structure.

Note : Sometimes when you do an upgrade, you might get error message saying "your database has already been updated".

All rite, to be honest, you ca't do specific migration, example you can say "apply ABC Migration".

It is all based on the migration class that you've setup in your project,  meaning you get to type "Update-Database" without any parameter.

Anyways, please setup your project and all in the required EF nugets.

Next create the following class.

Then you specific what needs to be done. In this case, we are creating a view called "AppTesrtView".

Goto "package manager console" and then run "Update-Database". Please note y…

EF core hosting database migration on a separate project.

Project is available on Github.

Create a NEW project and then ensure you have installed all the nuget packages. The next important task that you need to do is to add a reference to your DbContext entities, if you have it separately from the main project

In your Startup.cs please ensure you have the following codes (which links directly to "Alphacert.Acc.Ods.Entities.Migrations".

services.AddDbContextPool(o => o.UseSqlServer(connectionString, x => x.MigrationsAssembly("Alphacert.Acc.Ods.Entities.Migrations")))

Using MsgPack in your core webapi

MsgPack (here) is reportedly faster then msgpack-cli in terms of performance. To get your excited, check out the diagram below :-

Yes, it is ridiculously fast and beat protobuf in many ways. I was gonna put on my hardworking cap and write up some formatters but this way is easier to do :-

Client code 

Client side code to de-serialized it.


Install it through nuget using the following command :-

Install-Package WebApiContrib.Core.Formatter.MessagePack -Version 2.0.0

Next, you gotta decorate your objects with the correct attributes.

And then somewhere in your controller, you can serialize your object as bytes and push it through using code below :-

Anaconda3 - Getting the environment installation of your library packages

How do you get the path where all your "pip install" packages are stored?

Fire up your python shell and run the following command :-

import os; print(os.path.dirname(os.__file__) + '/site-packages')

For me, i get the following output :-


Where CNTK is my current active environment and all the goodies that comes with it.

EF core using views

To access database view using DbContext, you just need to :

1. POCO - Create your POCO using code shown below. Please note that you need to match exactly the POCO to your views but not necessary all the fields. Let's say you have 10 fields but you can just defined 3 that is of interest to you :

2. Add your DbSet - You need to open up your DBContext and add in your DbSet Manually.

  public virtual DbSet VwValuations { get; set; }

3.OnModelCreating - in your DbContext, add your valuations data as shown below :

The data type used depends on your view.

That should be all the changes you need to make.

Cannot access a disposed object in ASP.NET Core working with DbContext

Bump into this error and found out the reason you cannot spin up a task to run a injected DbContext which normally injected by WebAPI dependency injection of a DbContext.


Create your dbcontext manually using code below (instead of using DbContext passed in the controller)

WebAPI support for File based Partial Content 206

Image core support for partial content is far out easier than i imagine. For example, if your application delivering a huge file, 100 Megabytes for example. then you might want to request these data as chunks

Some notes : this only works for File result and not with JSON which might fetch some data from the table. For example, you have a huge json (about 2M) and defining range 30-1000 will not change returned data.

Sample controller to handle partial content :- Yeap this is all you need.

Next, fire up your post and and you can see some of the results that i'm getting. Oh before anything else, please ensure you place a large txt file a folder.

As you can see from Postman. i create a request with Range : 30 - 1000 and the response is shown here too.

A couple of things to notice :-

Return result is 206. (Http Partial Content) 

Content-Length is 2500 ( which is the total file size we have) 

EF Net Core does not support nvarchar

I got this problem earlier today and i could swore it only happens for .net core 2.0. The message looks something like this :-

Data type 'nvarchar' is not supported in this form" after scaffolding from database 

After my model is binded or built, it throws this exception. I change

entity.Property(e => e.Comments).HasColumnName("Comments").HasColumnType("nvarchar");// No size specifier to


What is CNTK dynamic axis?

CNTK has static and dynamic axis. Static axis remains the same throughout the whole life cycle of the model. Dynamic axis has the following characteristics :-

a) varies from instance to instance
b) typically unknown
c) maybe ordered.

Sounds like a minibatch

Taken directly from Microsoft website :-

To make this more concrete, let’s consider two examples. First, let’s see how a minibatch of short video clips is represented in CNTK. Suppose that the video clips are all 640x480 in resolution and they are shot in color which is typically encoded with three channels. This means that our minibatch has three static axes of length 640, 480, and 3 respectively. It also has two dynamic axes: the length of the video and the minibatch axis. So a minibatch of 16 videos each of which is 240 frames long would be represented as a 16 x 240 x 3 x 640 x 480 tensor.

Dynamic axis in this case are video length (240 frames) and a total of 16 videos.

kubernetes dashbboard

Kubernetes dashboard is a UI driven approach to view and get us working with Kubernetes fasters.

Accessing the dashboard run :-

kubectl proxy

And you might get : Starting to serve on

So browse to : localhost:8001/ui

The nice dashboard of Kubernetes appears.

That's it.

kubernetes working with deployments : quick and easy

Do your deployment 

kubectl run connectcd --image=kepung/dotnetapp-prod --port=5050

Check your deployment is deployed 

kubectl get deployments

Get the pods spin up by your deployments and look for the labels :-

kubectl describe deployment/connectcd

kubectl get pods -l run=connectcd

NAME                         READY     STATUS    RESTARTS   AGE
connectcd-545c87f8d8-j4fsv   1/1       Running   0          27s

connectcd-545c87f8d8-j4fsv is our pods

Get all the pods in all namespace

kubectl get pods --all-namespaces

elastic search docker image that works

It has been challenging to find the images that works for ELK stack. Finally settle with the following images from elastic co version 6.2.2

Elastic Search

run the following image to get elastic search

docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node"

Then browse to the following site :-