Friday, September 21, 2018

Setting up a Dockerfile to publish a .net or .netcore application in a Windows container

Docker has been gaining significant traction lately, most of it can be credited to it's ability to create portable lightweight containers very quickly for continuous deployments and sprawling testing and staging environments. These environments would require a Dockerfile to carry a set of steps and instructions that would be needed to successfully restore, build and publish a .net or .netcore application.

Let's begin right away with the 1st step; selecting a build SDK image. For .net applications it would be microsoft/dotnet-framework:4.7.1-sdk and for .netcore applications we'll use microsoft/dotnet:2.1-sdk. Both of these are Windows images. The following would be the first step of our Dockerfile:

# Build SDK image
FROM microsoft/dotnet-framework:4.7.1-sdk AS build-env   # .net

FROM microsoft/dotnet:2.1-sdk AS build-env               # .netcore

Sunday, September 2, 2018

Notifications - using Firebase Realtime database

Building successful applications for the web or mobile devices come with few key must haves. One of these must haves is a feature we all love to rely on - notifications. This feature varies in how it can be implemented in an application, and comes with a wide array of possibilities. There was a time when the only way to find out if we have a new email was to log in to the email service form the browser and check for any new mail. Then came desktop clients that would show a dialog on the side of the screen when a new mail arrived. Slowly we started receiving notifications for other products through emails. Over time notifications could be received through SMS, a secondary option to notifications through email. Now all notifications can be received as push notifications on our mobile devices and smartwatches.

As of now, notifications can be received through emails, pushed on to our handheld devices, or  are shown to us when we log in to the application. There are many ways to implement notifications in an application but at the moment we will be talking about how to use capabilities of Firebase Realtime database to our advantage.

Sunday, June 10, 2018

Using System.Drawing to create an image thumbnail cropped at 1:1

Creating a thumbnail for an image is very easy if you are developing for .Net Framework or .Net Core, since both platforms offer the System.Drawing packages. The tricky solution is cropping the image in perfect square format without distorting or stretching the image.

The following code shows how to exactly do a center crop while generating a thumbnail, the original image needs to be scaled down to match size of the thumbnail while maintaining the aspect ratio first, then moved to an offset calculated previously such that the final drawing removes the pixels that were supposed to be cut off during the cropping. The offset represents the number of pixels of that side that require to be cropped off.

It should be kept in mind that on .Net Core the package must cover all platforms. For that case there are three nuget packages available for .Net Core for Windows, Linux, and OSX each.

Saturday, August 15, 2015

WCF Services - How to consume a Service without access to it

When working on a project that contains decentralized approach, different modules are deployed on different servers by different development teams and all that needs to be integrated with each other, there can be issues regarding accessing a web service that hasn't been published for access yet or is deployed on another domain with access restriction.

To access a contract for a service that is out of reach, Visual Studio provides a tool svcutil.exe that can generate a proxy for the service. This tool needs to be executed on the machine the service is deployed to in order for it to generate the required proxy.

Executing the svcutil.exe on command line with the following command will generate the proxy
C:\path> svcutil /t:code /language=cs http://<service address> /out:MyServiceProxy.cs /config:ServiceProxy.config
Now the generated .cs file can be added to the client application project to obtain the classes and method contracts. The endpoint configuration is generated in the .config file that can pe copied to the web.config file of the client application project.

If svcutil.exe is not available in the server machine, it is available for download in the internet as WCF Test Client package.

Tuesday, February 17, 2015

Learning SQL - Part 1 - Fetching Data

What is SQL? It is basically just a standard language for interacting with databases, and that is what we will be doing. SQL stands for Structured Query Language. Manipulating data through SQL is similar throughout all Database Management Systems (DBMS) so we should not worry much about differences in language syntax. Basic syntax and operations are exactly the same among these DBMS. We use SQL mainly for Relational Databases, but we will not discuss that here. For this article it is expected the reader knows what databases are including tables, columns, restrictions, and views.

SQL allows us to create, fetch, modify and delete all elements of a database including tables, records, stored procedures, and views. Tables, simply, represent an entities in databases, much like how classes are in a software program, while records stored in the table follow the rules and columns that are set for that table. A table consists of finite number of columns, exactly how a class in a program contains attributes, but that is not the focus of this article.

Monday, February 16, 2015

Programming 101 - Part 2 - Working with Numbers and Words

Expressions and Data Types

There are six basic atomic data types in C++;

char, int, float, double, void, bool

Any other data type that we may come across are derived from these six. The first listed data type is a single character type, you can save an 'A' or an 'h' but not a complete sentence... we will get to that later on. The second type is of an integer or a number. This can hold a large numerical value... from -32,767 to 32,767. Of-course you can change it to an unsigned form by adding the "unsigned" keyword before "int", the numerical range than gets from 0 to 65,535 - unsigned positive range only.

The third data type is a decimal type with 6 digits of precision. The fourth increases decimal to 10 digits of precision. Both are almost the same but there applications can vary based on the requirement of a program.

The fifth data type is the most distinct one, its name is quite clear, its plain void, meaning the data represented by this type is not zero, not null, just nothing. Seems pretty weird but it isn't. There are many occasions when a program is not able to produce any result, but no result can not always be a zero, sometimes it is appropriate for it to be just nothing. This will get clear once experience is attained in programming for different scenarios and methods that only do something but return nothing.

Kendo UI Grid - Server Side Paging, Filtering and Sorting

There are a number of ways a DataSource can be handled with a Kendo UI Grid. In this article we are going to talk about binding data from a remote location on to a Kendo UI Grid with server side paging, filtering and sorting to ensure server response is smallest and light as possible for quick loading and to be able to handle if the data has thousands of records (that can lead to oversized response objects or time outs). I will give example code snippets to form an understanding of the solution.

The Grid

Below is a Kendo UI Grid declaration for which we will implement the server side manipulation.

Programming 101 - Part 1 - The Very Basic in C++ and Java

Welcome to Programming 101. This topic will consist of several parts all in different posts of-course. This post will include the a Hello World for C++ and Java. More posts will follow to explain how the languages work, but don't expect to master the languages by just reading through the content or watching any videos, if and where provided. Experimenting and working out of the box and over what you have learnt leads to becoming a good programmer. I am only writing these to provide very basic understanding of how to write a program.

Lets begin; to start programming you'll need an IDE which is an Integrated Development Environment. I'd recommend an easy simple one: Bloodshed DevC++ for C++, which can be downloaded for free from the Bloodshed website (search it on Google). Or if you wish to pick up the big guns right away then you can get Microsoft Visual Studio and install it for Visual C++. As for Java, I would recommend an open source IDE known as Eclipse, but you are welcome to try Netbeans as well. This topic will feature only console based coding for now.