Search This Blog

August 3, 2020

Unable to checkout Git repo on Windows?

This post is about looking into the order in which you debug the reason for your inability to checkout Git repo on Windows operating system. It could be because of the following reasons and you should debug in that order:
  1. Existence and validity of your SSH Keys
  2. Presence of files in your git repository whose names are reserved words in Windows OS
The next section of the post delves into these two pointers in detail.

Existence and validity of your SSH Keys


  • You should have SSH keys (typically id_rsa and id_rsa.pub) in your operating system path $HOME/.ssh/. If not generate it with ssh-keygen.
  • You should have the contents of the public key (id_rsa.pub) added to your list of SSH Keys in your Git remote repository. In the case of Github, it will be in your personal settings page

Windows OS incompatible file names in your git repository


This is a little crazy Windows OS weirdo. After making sure that I indeed have the SSH Keys setup right both in my local windows-os and in the remote Git repository (Github in my case). But how do you do that? 

After hours of hair-splitting to think that SSH keys isn't setup right and I was only left frustrated and hopeless. A little insight into why I was misled to thinking so and you too could be trapped by this very step. I tried what others prescribed to validate this, which is to run the below commands:
ssh -T git@github.com
ssh -T your-github-id@github.com
While the first command turned out successful, the second one failed with an exception stating, "... Permission denied (publickey)" leading me into the rabbit hole to be lost in darkness.

The best thing to do when your lost is to take a break from the problem. You would still be thinking about it at the back of your mind, which is a good sign ;)

So after my break and back at my desk, the next thing that I tried was do exploratory testing to validate my assumption. And so I tried to checkout a couple of other repositories to see if that works. And it did. Damn, my SSH Keys setup was indeed right and that I was wrong to assume that I missed something right there. 

Side-note: Best test case for this kind of use-case is to create a simple repository with only a Readme.md file in it and see if you can checkout that repository. If that works good, the problem is likely with your operating system and the repository contents. In my case the remote repository had a file named aux.js
 
So now the problem is with my current repository which worked in my other laptop having Ubuntu OS? That leads me to wondering if there is something in my repository that my Windows OS isn't liking? I slap myself and get back to basics of reading that error I get when I checkout this troubling git repository. The error message that I got mid-way through checking out read something like below:
error: invalid path 'src/hoc/aux.js'.
fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'
I now have zoomed in into the file aux.js as the possible cause, because windows is unable to create that file. When I tried to manually create a file by that name, I was shocked to learn that windows doesn't allow me to create one by that name, because aux is a reserved name in windows that refers to some device. And boy Windows has quite a few such reserved names and if you got files created by those names in your non-windows operating systems that make it to remote Git repository, your other developers using windows operating systems will be at a loss. 

There are other such reserved names in windows os. Do not use the following reserved names for the name of a file: CON, PRN, AUX, NUL, COM1, COM2, COM3,..., LPT1, LPT2, LPT3, ... Also avoid these names followed immediately by an extension; for example, NUL.txt is not recommended.

Below are two possible ways to solve this problem: 
  • The quick and easy route is to change your git config by running: git config core.protectNTFS false
  • The other is the hard route that I recommend for portability reasons, if it is doable in your project. And that is to rename the file to something that windows developers can consume without any issue.
It is important to know the other windows operating limitations as well for project portability on windows platforms:
  • In Windows, filenames are case-insensitive.
  • In Windows, certain characters are not permitted as part of file names.
For this reason, it is important to consider the following links to see if you have broken any of windows conventions in your file naming:

August 2, 2020

Know Your Windows 10


I was looking into all these details to decide on my options in purchasing the kind of laptop that I want. I ended up purchasing a customized Lenovo laptop, only for it to be cancelled from their end after 6-7 weeks failing their promised delivery in 4 weeks time. Lenovo laptop delivery timelines seem to historically bad and their support is just terrible. I suffered great loss because of their slack. Subsequently, I grew really impatient and wanted to get one ASAP with Windows 10 Pro operating system pre-installed. This narrowed my choice to very few models that didn't impress me much for their hardware specs and price. I opted to prioritize on hardware specs and experiment on the software side of things. And that helped. For the curious I got myself an Acer Predator Triton 300 laptop and have post my experience with it thus far in another post.

This blog post has those little things I wish I knew about Windows 10, when it was most important for me but discovered/learned later. I practically battled my time with Ubuntu OS and Mac OS prior to that. I never cared to think about these details when I was using Windows 10 during my gig at corporate houses in the mean time; understandably there were other things to focus.

  1. If you are using Windows 10 Home, you can use Remote Desktop Connection (RDP) to connect to other systems but not share your desktop with others using it. To share your desktop with others using native RDP app, you must upgrade to Windows 10 pro.
  2. Hyper-V is disabled in Windows 10 Home edition. So if you are purchasing a new laptop, you are better off getting one with Windows 10 Pro OS installed instead of Windows 10 Home. Cost saving tip!
  3. If you are in a country like India where you have plethora of options to buy Windows 10 Home laptop with very limited options for pre-installed Windows 10 Pro or customised laptops, you can always upgrade to Windows 10 Pro via Windows Store at half the price (INR 8000 incl. taxes), instead of buying a new one from windows website at full price (INR 18000 incl. taxes). Microsoft managed to lend its ears to the market and respond positively to its consumers.
  4. In your Control Panel > Turn Windows Features On/Off, you should enable Windows Defender Application Guard that offers a secure container from internet browsing to protect your host OS from malicious attacks. To take advantage of this though, you need to use Microsoft Edge browser only. 
  5. Windows Office Home/Student pack works well on Windows 10 Pro OS. So if you are a developer wanting both Windows 10 Pro and MS Office for your personal needs, you have have them both together without any incompatibility issue.
  6. You can get your pre-installed windows 10 license key from your terminal aka command prompt by running it as administrator and executing the command: wmic path softwarelicensingservice get OA3xOriginalProductKey. Note down this license key for future reference.
  7. Do you know that when you upgrade from Windows 10 from Home to Pro, your license key actually changes. I got this confirmed from Windows Support Team!
  8. Do you know that when you upgrade from Windows 10 from Home to Pro, you end up getting a Single User License (aka Retail license) instead of the OEM license. At least, I think I had only the OEM license prior to windows upgrade. You can check the type of your license by opening your terminal or powershell in administrator mode and executing the command: slmgr /dli
  9. With WSL (Windows Subsystem for Linux) support introduced by Microsoft in 2019, you don't miss your Linux distros. I have Ubuntu installed, for instance.
  10. If you are on Windows 10 Home, you can use WSL-1. If you are on Windows 10 Pro, you should use WSL-2 to leverage windows native virtualization, for better performance. 
  11. Do you know that you can download and use Windows 10 Home for free, legally for personal use. The only downside is that you can't have any customization done to it and you will see a watermark on the screen to activate your version of installed operating system. Cheers to Microsoft for that smart strategy of allowing the masses to experience its work.
Should you think there is more that I should know as a developer, do drop your comments.

August 1, 2020

My Reviews Of Acer Predator Triton 300 Laptop

My Context

  • I am no gamer.
  • I got this for my personal projects using Kubernates (requiring better CPU) and resume my journey of learning Deep Learning (requiring better GPU).
Note: Your mileage may vary depending on your context.

Pros

  1. Better looks with minimalist design that you can take it to office/school without it distracting others during your work.
  2. Better pricing than its competitors for its specs. It's closest competitor IMHO would be Dell G-series laptop.
  3. Build quality is sturdy with metal body.
  4. The keys on the keyboard are top-notch in that I like the touch-and-feel.
  5. The touch-pad is too good that you would start to hate other laptops for this purpose. 
  6. This is a gaming laptop with brilliant honeycomb venting for quicker heat dissipation. And it works! 
  7. Acer's Aeroblade technology promises better heat dissipation and so far it has been cool enough. 
  8. It supports Dual SSD plus One HDD. I have my Windows OS in SSD and data on HDD. My OS loads in about 5 seconds today with not many softwares installed and added to startup list thus slowing it down. 
  9. Default backlit keyboard with blue light (that can be customized) is pretty comforting to my hands that does a poor job in typing. 
  10. Higher screen refresh rate of 144 hz. This is not of any use to me though, given that I am not a gamer. 
  11. Full HD screen does come to your favor, for it reduces your eye-strain with its crystal clear clarity of smaller fonts instead of tearing it down. 
  12. It has got a killer wifi router supporting superior bandwidth performance. Should come to your rescue when you do screen sharing for your development work.
  13. The monitor lid is sturdier in comparison to its competitors where the lid might be a bit flimsy shaking. I think it's because of thicker bezels around the screen in this laptop that gives it the desired sturdiness that I wish it has to suit my handling.

Cons

  1. Built-in speaker sound quality is relatively feable and poor. 
  2. Keyboard layout is discomforting when coming from traditional layout experience. 
  3. Power button is positioned as one of the keys in the top right corner, increasing the chances of accidental selection. 
  4. Sharp edges of the metal body, that can tear your skin. You can use it as a weapon of self-defense, when you need it :P 
  5. The Laptop should work on improving the battery span as well. For normal developmental usage like mine it lasts for 3 hours only. This is perhaps a known downside with any gaming laptop :(
  6. Acer India support could do better. Registering the product for warranty is bit of a hassle in India, at least.

July 31, 2020

Microservices Architecture Versus SOA


This is my take on differences between Microservices Architecture (MSA) and Services Oriented Architecture (SOA) based on my experience of working with these architectural styles thus far. I do understand that there are companies that doesn't distinguish between these two architecture lingos and use them interchangeable. And then there are also companies that have their own definitions of how each of these architectural styles are modeled. There is no right or wrong definition here (Ouch!, the world became chaotic even before we realized). What truly matters is that knowing our audience as we speak to them. It is unwarranted chaos when our mental models are different.

So, at the very outset let me state clearly that I see these models differently by virtue of my experience. So this post is my perspective on the difference between these two architectural patterns as I had experienced it. 


  • SOA is monolithic solution like a big lion in the jungle; how it works would be pretty evident for a pair of eyes.
    MSA is distributed system constituting a set of services working together as one, like a pack of wild dogs working together to attack its target; how it works together would seem like a magic for a pair of eyes.

  • SOA is layered. The app is broken into independent functional modules owned by respective teams. In the Java EE world, each team owning the module builds and publishes its artifacts as libraries for consumption by the core app. The application thus remains monolithic, so any changes to a module meant building and deploying the entire application. This also means that the release of functional modules needs to be coordinated with that of the main application. At least that is how the teams I had been in had build the big monolithic enterprise application, the SOA way.
    MSA is about breaking the large monolithic app into independently deploy-able application where the teams owning it can have its own release cadence; although the larger release of the application still requires some bit of coordinated efforts.

  • SOA standardizes on shared release cadence requiring larger project planning to keep teams occupied and syncing efforts across teams.
    MSA liberates teams to have its own release cadence to meet the needs of the larger release cycle of the application.

  • SOA is externally focussed. It was intended to solving communication gaps with 3rd-party heterogeneous systems in a safe, secure and vendor neutral way. More often than not, the communication was outside of the trusted networks.
    MSA is internally focussed. It lays emphasis on building small and independently deployable applications that work together, for faster development and deployment of business needs. The inter-app communication challenge was a consequence of this decision. Typically, the coordinating apps are within the trusted network of the company.

  • Refactoring across bounded context is relatively simpler with SOA.
    Refactoring across bounded context is harder with MSA. This is one of the key reasons I don't recommend Microservices First Architecture, but yeah, you can always hit a middle ground that is there somewhere. 

  • SOA embraced SOAP as the de-facto communication protocol and later went on to support REST protocol too.
    MSA embraced REST as the de-facto communication protocol, but is pretty open to embracing other newer protocols for good. Inherently though, there is a dislike for SOAP/XML within the MSA community :)

  • SOA solved the integration challenges for businesses primarily in the B2B space.
    MSA solved the delivery challenges for businesses that wanted to be nimble with faster release cycles; historically, to respond to its B2C customers. 

July 29, 2020

Switch Between Java Versions In Windows 10


There are 2 Options to manage multiple java versions in your windows: 
  • jEnv : I have used this for long in my Ubuntu/Mac laptops. This doesn't support Windows platform though!
  • SDKMan : This one has a workaround for Windows 10 platform (see https://sdkman.io/install) and that leaves me no choice but try this one out.

The SDKMan Way To Switch Between Java Versions in Windows 10


Some good things about SDKMan:
  • It supports all platforms Linux/Mac/Windows.
  • It is more popular tool over jEnv today, per libhunt.
  • It supports great deal of JDKs and SDKs for quick install and use.

Installing SDKMan in Windows has the following pre-requisites:
  1. Install ConEmu which is  an advanced console window (also known as local terminal emulator). This is only an emulator and hence shares the same environment as Windows. Alternatively, you can install CygWin, which is a more popular and pioneer tool in this Linux Terminal on Windows.
  2. If you have installed Git in Windows it is likely that you have installed Git Bash. If not, please do install Git Bash (that comes bundled with Git installer for windows) with all the default recommended options as the installer suggests.
  3. The SDKMan makes use of zip command for its installation. So you may need to install GnuWin Zip
  4. It may also use the following commands in its installation script, viz., zip, unzip, tar, gzip, curl. According to the SDKMan installation page, MinGW can be used to provide this tooling. But because, I use ConEmu out of personal preference, I had to check for the validity of the following commands in my ConEmu terminal like below:

When all the above commands showed the installation path of the softwares, we can be confident that the commands would work well to install SDKMan from within ConEmu.

Now from within ConEmu terminal, we can go ahead and run installation script for SDKMan like below:
    $ curl -s "https://get.sdkman.io" | bash

Next, open a new terminal or enter:
    $ source "$HOME/.sdkman/bin/sdkman-init.sh"

Lastly, run the following code snippet to ensure that installation succeeded:
$ sdk version

Bingo, you can now go ahead and install your favourite versions of java sdk, Ant, Maven, Groovy, Gradle, etc using your now favorite SDKMan :)

Quick Cheatsheet for SDKMan



References