Category: Programming

Cascadia Code and Oh-My-Posh

Following Scott Hanselman’s Post on customizing the terminal, I have customized my windows box’s Terminal to use Cascadia Code PL font and the On-My-Posh Theme.

PS Prompt

My favorite font for programming was Monaco previously, until I discovered Cascadia Code PL. I have gotten to like it so much that now I have it as the font for SQL Editor, VS Code (both on Windows and mac), Bash Terminal, and Windows Terminal.

Among the Oh-my-Posh themes, my personal favorite is ‘Spaceship’ that you see in the screenshot above. Exploring adding Oh-my-Posh to Bash next.

You can find details about customizing at https://devblogs.microsoft.com/commandline/windows-terminal-tips-and-tricks/

VS Code and Git

As a developer finding the right editor and customizing it is one of personal preference. I had always like dark themes and was fascinated when working on Vi, Emacs, Notepad++ and TextMate. But the search for the best editor continues in my mind always.

My primary job involves working with .Net and Visual Studio IDE is the preferred platform. I am comfortable using it, but it is huge when all you need is to edit a couple of documents. When Visual Studio Code was launched, I was excited and have used it as an editor in my office machines. Recently I am exploring my hands on using my personal Mac to try development of .Net apps.

Now I have VS Code on the Mac and have setup the same exact way as in Windows. Dark Theme+ with Cascadia Code font from Microsoft. Recently, VS Code team has announced the browser editor. Use the . key to change the browser to VS Code Editor. I am fascinated by the first look and the advancement of how now the entire editor with all its features and customization can be brought over to the browser. I’m in love with it. Here is a screenshot of the browser editor and the VS code editor side by side.

GitHub.dev and VS Code Local

Trying .Net development on Mac

Since my primary work involves programming with .Net, I have not used my personal laptop for programming other than fiddling with Python and Ruby sometimes.

With .net core now supporting all platforms, want to start trying out development on Mac. Taking the first step towards that and installing Docker.

Docker Install on Mac

Will update the blog on my experience with .Net on Mac. Hello World to C# on Mac.

Google Facial Recognition

I was impressed to the extent to which facial recognition algorithms have grown. Casually as I was browsing my albums on Google Photos, noticed that they have a feature to search by People. Initially I didn’t pay much attention as I suspected that there will be lot of duplicates where the software would recognize the same person as two different person. But I was amazed. No duplicates.

No DuplicatesGoing that far, wanted to see if the photos tagged to the people were right. I wanted to pick on someone who is in pictures and in different position, front, behind etc.. There again, the results were impressive.

2 3 4 5 6

 

 

 

Above I have a sample of what I got!.  Way to go Google!

MergeConfig

Maintaining .net configurations across development, test and production regions have always been a problem that is faced. To ease this process,  I was thinking of creating a utility that makes it easy to use and help deployments. The goal was to eliminate need to save and maintain multiple files for various regions. Here it is, “MergeConfig”

The utility uses ‘MergeConfig.xml’ as XML file to hold this information. The structure of this XML file is organized as:

  • Deployment Region <deploymentRegion>
  • File Info <fileInfo>
  • Maintain Configuration <maintainConfig>

The Deployment Region specifies the name of the region, i.e. dev, test, prod.This section is to be defined one per region.

<deploymentRegion name="Development">

The File Info section specifies the file path that is to be merged. This section is defined one per region per file

<fileInfo fileName="D:\Project\App.config">

The Maintain Configuration section specifies what attribute to be replaced with what.

<maintainConfig findXPath="//root/configuration/add[@key='TestConfig']" replaceAttribute="value" replaceWith="ABC" />

Here the ‘findXPath’ attribute defines which element to look for in the configuration file. ‘replaceAttribute’ defines which attribute in the element has to replaced and ‘replaceWith’ defines the new value for that region. For example, consider the following in the App.config file

<root>
	<connections>
		<connection ID="main" connectionString="DataSource=DEV;Password=PWD;UID=UID" />
		<connection ID="log" connectionString="DataSource=DEV;Password=PWD;UID=UID" />
	</connections>
</root>

We would need to use,

<maintainConfig findXPath="//root/connections/connection[@ID='main']" replaceAttribute="connectionString" replaceWith="Data Source=localhost" />

The syntax for running this command line utility is:

MergeConfig.exe {/r | /region}: {/v | /verbose}

The switch /r specifies which region to use, and /v specifies if verbose output is required.
Examples:

MergeConfig.exe /r:Development /v
MergeConfig.exe /r:Development /verbose
MergeConfig.exe /region:Development

Click Download to get the compiled utility.

Android App – Cows and Bulls Game

When I considering the next thing that I could consider for my side projects other than just fiddling with Python, Android App Development struck a chord. In order to learn this new thing, I wanted to create something that I would like doing, and immediately, Cows and Bulls game came to mind. It is simple, yet a wonderful start to learn a new platform.

Cows and Bulls as a game was introduced to us (College Friends), by Mr. Barath (a.k.a Mr B). A simple four letter word game, where the aim is to find the four letter word. We used to play this during class in the last bench.

Today, I have it released on the Android Play Store, thanks to my wife, who was kind enough to grant me $25.00 to get myself registered as a developer in Android Play. Please do check this out and let me know if any issues and feedback.

Visual Studio Themes

I like changing the look and feel of the IDE and the TextEditor that I use everyday. Since I am into .net programming the IDE that I live on is the Visual Studio.

In this post, I share the settings files (read themes) that I use for my Visual Studio 2010 setup.

Dark Rajesh Settings

I have used this settings for more than a year now. This settings is a modification of the DesertNights Theme available widely.

Features:

  • Dark Theme
  • Light Contrast to be pleasing on the eyes
  • Uses Monaco Font

VS 2010 Settings
DarkRajesh Settings - VS 2010

Download Settings : DarkRajesh.vssettings

Dark Raasukutty Settings

This settings is a modification of the Son of Obsidian Theme.

Features:

  • Dark Theme
  • Uses Monaco Font

Dark Raasukutty
Dark Raasukutty - VS 2010 Settings

Download Settings : DarkRaasukutty.vssettings

More VS settings can be downloaded from http://studiostyl.es/ website.

Time Tracking Tool

Suddenly we felt the need to time track in our project. So I started the hunt on the best free time tracking tools available before even trying to write my own. A colleague of mine, Shubham has written his own time tracking tool and had been using it. Didn’t get a chance to try it though.

Following were the features I was looking for:

  • Must be a Desktop App and should not want me to sign-up to use it.
  • Free
  • Easy to use
  • Support for Color coding different tasks

I have settled with Klok, an Adobe AIR application for time tracking. It is really simple and lightweight install. It has all the features I wanted. Klok installs on the desktop. It allows to create Projects and Sub Projects to track time.

It has a timer that starts as you start working. It allows to export to Excel and CSV formats. Really handy to report at the end of each week, month or year.

Klok Interface
Klok Time Tracking Tool

More to work on and more to track. Happy Working!

C#: LINQ Join and order by

Recently, I had a requirement which read as this:

Allocate payments into the details by contribution type such that oldest due amounts are first allocated based on the allocation order specified.

To re-phrase it in programming terms, we had a collection that contained due amounts with contribution type and date due. We also had a rule set that defined which contribution type has to be allocated first. Overriding this rule set was the oldest due amount rule.

So the collection with the due amount and date is defined as below:

public class Detail
{
	public string contribType { get; set; }
	public decimal amount { get; set; }
	public DateTime reportingDate { get; set; }

	public Detail(string contribType, decimal amount, DateTime reportingDate)
	{
		this.contribType = contribType;
		this.amount = amount;
		this.reportingDate = reportingDate;
	}
}

The rule for allocation is defined as:

public class CodeValue
{
	public string codeValue { get; set; }
	public string allocateOrder { get; set; }

	public CodeValue(string codeValue, string allocateOrder)
	{
		this.codeValue = codeValue;
		this.allocateOrder = allocateOrder;
	}
}

We have multiples ways to implement the logic. Here is an example using LINQ.

 var sortedResult= from detail in detailCollection
                               join codeValue in codeValueCollection on detail.contribType equals codeValue.codeValue
                               into joinedDetails
                               from fullDetail in joinedDetails.DefaultIfEmpty()
                               orderby detail.reportingDate, fullDetail.allocateOrder
                               select detail;

By looping through the resulting ‘sortedResult’ collection, one can easily satisfy the requirement. Elegant code with LINQ.

Why I hate Reports?

I hate Reports. Reports as in Crystal Reports, Sql Server Reporting Services.

I was pondering over the question, why do I hate reports? this entire day. Do I simple hate them? Did it have something to do with the way I look at them? Is it because, I have always seen it in the wrong way? Was it that I hated it from the first that I am getting an aversion towards it?

My first work with reports was in 2007. I really hated the way Crystal Reports did the formatting. Even though, I had very little space between the columns, it always rendered it with more space, and I would be questioned on why there was more space? How will I know? That would be my answer. Only when I had one column laid literally over the other, did it give a small space. It all started there! And it is still continuing.

I thought only Crystal Reports was like that! Now SSRS (SQL Server Reporting Services) is even more terrible. I understand that Reports are more important requirements in any project. They are the way of letting people see, decide and plan on what has to be done. Any software solution provider will have reporting requirements that need to be done. I tried to even start reading books on Reports, but something is wrong in the way that I understand them. I write SQL, but somehow, I hate it when it comes to reports. It must be the way I perceive it, but really, Reports / Data Analysis is really not my cup of tea! I really can’t get over this feeling. I want to learn it, but simply I can’t.

I hate you Reports! But somehow, I have to do it! Get it done!