Categories
Server Configuration

Rclone: Google Drive configuration

One of my client ask to configure server backup on his google drive account. The setup documentation for rclone is very good in this regard. However, there is one little problem, that Google drive ask for Web browser based consent and since I am doing remote server work with CLI, there is no way I can run the web url from server directly. Now, there maybe different ways available like I can try to run user from public IP of server, but then I have to open port on server etc. For just one URL or install a text browser which doesn’t very well for google URL.

So, I use ngork, I just download it’s Linux addition bind it to Port that rclone suggest. And now I can use their temporary URL to run the port outside on my desktop machine. It took 2-3 minute to get it up and running and then removal from server [for security reasons].

Just making this note for future reference. Then to access any URL we can use ngork subdomain capabilities to proxy and use it outside server.

Categories
.NET Continous Integration Docker MS SQL Server Programming Project Management

Automate Testing: Gitlab, Dotnet

I always want to test my .NET based application on my personal Gitlab based repo. But since, my old project is too much a mess to do the effort for. So, when we got to rewrite the whole project, I was happy to get my experience on Unit Testing with automation of CI. I still don’t do much of CD as my development environment is still limited to development only.

So, I read about it and using Gitlab’s YML configuration, I was able to run the xUnit based Unit Test easily. It was simple too, call a MS/dotnet docker as base image, then dotnet build and later dotnet test .

But the problem arise when I have to connect to database and then I cannot get SQLCMD command to work, though I get the MS SQL Server based service to started, but until that command runs which is not present in ms dotnet docker, I cannot reload my database easily. For that I have to write code to bootstrap and create database. So, I try to search for it, and after lot of fail attempt and surprisingly no example of how to use database with YML configuration other than basic example for Mysql or Microsoft’s own docker file example. I found no info on this.

So, I decide to create a new docker image, I want to do it my way. So, I use a Ubuntu Docker image, install dotnet 2.2 on that image with mssql-cmd tools. I didn’t install MS SQL Server as I can use that as service. So using this docker image, I get my Unit testing working. This help me automate my project workflow and help me get best out of me, without need to worry about hidden errors.

My this docker image is available for anyone need it at Docker hub:

https://hub.docker.com/r/archergod/dotnetcoredb

Categories
Case Study

Case Study: When to realise mismanagement?

From last month or maybe two months, I am helping one of my client’s company. They are sort of done with outsourced developer because (well they didn’t meet me before) and get bad experience. They are using my client, who is a hosting provider, for providing server services. They hire an in house apprentice to maintain their 10-12 yr old system which use Classic ASP to early version of .NET Framework based console app for automation.

So, now they need some help as their in house programmer is not very good and they reach me indirectly. All, is good so far as I am not charging them much and it is really just help. But I feel bad for them, because they are so mismanaged that they don’t even realize that they are missing a proper management. They get in this frame where they think developer is done in this bad environment like that. They have simple process, Client purchase their hardware, there Point of Sale machine generate a TEXT DAT file that they use to print “pre printed” invoice, so their old system only has to write text where it is required. Since the print invoice system is old and they don’t want to change, so our only option is to read those “DAT” file and read it into database to create PDF or do some reporting.

For this they initially have a website which does some online selling and reporting for their admin. It was in classic ASP. So, when a need of PDF arise they get a developer to write PDF, but since ASP is not handy and ASP.NET was in market this developer write that PDF using single page script in ASP.NET for PDF. It works fine. But now they need to bulk email to different vendors and customer at end of day their invoice, so they get couple of Console EXE that they run in background and get things done. It looks good maybe at that time. And it keep working if they get a proper team to handle it.

But here comes the mismanagement part. First they do not have the source code of EXE, until they need to change the pre-printed Invoice design, that result in change in PDF. They realise they never took the source code from old developer, or they don’t bother to keep it safe. Old developer who was now fired don’t bother to keep source code, because he is not responsible to keep it. He send a copy to client and is done when he was fired.

So, my first job to help them was to either recreate a small PDF code as their in-house developer cannot do that. (I still wonder why they call him developer). But I give them option to recreate or try to de-compile code, which works and give full source code back in shorter time. So they become happy to get old code back as it is easier. I however suggest them to not invest much on old system and get new system. They can elimiate to many moving parts from new system and get much stable version. But they are not ready, as for them it is always “one last small change, and we are done”. But are they really smart? I mean it is almost 2 months and their PDF changes are not yet done. They pay 2 month salary to their in house developer. Not to mention if they have to pay me for all help? They are so mismanaged in their approach, that they don’t realise they are missing a good management in IT department. They are lucky to have stable business that is paying for unstable IT needs. But what business they are losing for it, and wasting their resource they have no idea.

You can be busy, have a working solution. But that doesn’t mean it is always the best. Yes they are constraints, money, time, resources. But you have to make decision until when you can drag it. If they were using a simple Github/bitbucket account they can avoid losing files, source code in emails. If they serialise process they can avoid 5-6 console EXE to make similar yet different PDF, they can combine them in one EXE to reduce cost, and save time. Wish I can help them more than I am doing now. Hope their in-house developer learn fast, but he is not. They don’t realise it yet. Hope one day they will.

Categories
Blog: My thoughts

Quit, Quite, Quiet : A Year has gone

It is interesting how these three word summarize my last year. I quit lot of things that were stopping me. I quit to go down. However it is not entirely true that I succeed in my quest. Though, I am certainly at better perspective of life.

I have quite interesting events happen all around me, and most recently I start my own company which looks to expand all around and always. I was surprise that how small change in motivation leads to totally different perspective. My client feels more closure to me, and are getting happy with improved service of mine. My client always like my work, but somewhere with time, I lose the touch where I deliver to the desire. My biggest issue was time period. Though it is surprise me that when I start to reduce my work hour, I start to get more done and client are more happy as the delays are going away. Now, to get more done, my company is expanding its work base, and it means I have lot more to focus on. I am quite prepared for it and doing things as they come.

I remain quiet for long time on blog, as I wasn’t sure what I should write. I was not learning much of new tech and there is little that I do differently which is not already explain in other blogs. Though I still had few topics to write, technical or personal. But, they do not inspire me to write a post. Today, with this post I try to break that barrier so I can be more focused on things that make me, what I am. Sharing knowledge and learning from other is one of my biggest strength. I will try to write more and learn more. I start enjoying programming again, this new generation of programming was going over my head before, but now I found myself in the zone. I can learn and overcome them. Hope to post some technical articles soon.

Categories
.NET C#.NET Programming

Extensions Method in .NET

Recently I use extension method in C# project. I knew those for years, but really never get a chance to use them where they are most effect. I have couple of extension method in my project, such as ToInteger(), for a string to convert a String to Integer, which I used more frequently in my project. But that doesn’t seems a good use of technology to me.

But I now found a perfect use for extension method. i.e. I was upgrade my code from old ASP.NET project to MVC and for this I am making a class library of all objects. Now, this scenario need me to make a conversion from old enum to new enum  which are now part of namespace of my class library, rather than sitting around in App_Code folder. Here I make a extension method that convert a OLD enum to new name space base. This ease lot of my works.

Method goes like:


public static NewType GetSaleType(this OldType s)
{
	NewType r = NewType.Regular;
	switch (s)
	{
		case OldType.BK: r = NewType.BK; break;
		case OldType.IL: r = NewType.IL; break;
		case OldType.MM: r = NewType.MM; break;
		case OldType.PC: r = NewType.PC;break;
		case OldType.Regular: r = NewType.Regular; break;
		case OldType.Trigger:r = NewType.Trigger; break;
	}
	return r;
}
Categories
Continous Integration MySQL PHP Programming Project Management

Experience with BitBucket CI

I have been using bitbucket for quite sometime, and really like their service. Recently, I come to know that they have Beta of CI through pipeline, that can run any docker from Docker hub. I thought to give it a try though I have my own build setup on my local machine and really don’t need it. But why not test something new.

So, my project is regular website, which is coded in Custom PHP (no framework) and using MySQL database. I wrote some Unit Test using PHPUnit test, so all I need is to run those test when I commit to Bitbucket. It seems pretty straight forward as Bitbucket configuration example shows the configuration file for PHPUnit test. I pick it up, change path and run. My test failed, as they never get the MySQL extension for PHP. What? PHPunit test docker doesn’t have database extension installed? So, how we are suppose to test it?

Well, there are few ways, one is you use multiple docker (multi-docker environment) which I recently studied is available and I didn’t yet test it. And other is you create your own docker and use it. Install whatever you need to make it happen. Also, I realize that installing MySQL will not make any good unless I install database on it before test and change it’s certain values for testing. So, I create a new docker that has everything I need for my project, all PHP extension and database server. (You can use it from https://hub.docker.com/r/archergod/phpall/). Then I update configuration file to do following:

  1. Run MySQL service (yes by default docker do not initiate run.d etc, not sure why) and hence no service auto start.
  2. Then run `mysql` to import a Script (SQL) file to create and install database, and users needed. I put everything in that one SQL file and run it as root MySQL user. It is only a docker doing testing.
  3. then Navigate to Directory in respect to my Git folder as my default bitbucket leave your prompt at git folder.
  4. Run your test.

It does a great work, though every time you push to git, it create a CI request and download docker image, set it up based on BitBucket’s script and then run your script. So it take 2 minute extra to set the machine. If you are in habbit to push every 2 hr of work, then you end up running your test every 2 hr on every push.

But basically it is all good and is free too, which I like most. Though I have GitLab at my local machine and it works exceptionally great, but BitBucket’s CI is good and different. And in some cases is better than Gitlab’s CI.

Categories
Blog: My thoughts Operating System PHP Server Configuration

Linux Upgrade from 12.04 to 14.04: Save the day

So, this fine sunday, I think I wake with “lets spoil the day” mood. I start by checking my server to see how it is doing. A regular log view and updates I perform on my VPS. all was good, until I realise an update is available for my billing software. I decide to purchase an update for it. Before buying I forgot to check system requirement. Well it is just an update, and we install it every here and there for other things. So, I have updated copy of my billing software, which I follow the steps of upgrade and upload to my live server. All went well until I reach for software to suggest install PHP 5.6 instead of version I had. Well no problem how hard it is to update PHP in ubuntu 12.04, just matter of running apt-get.

Soon, I realise PHP 5.6 was never release for OS, and I need to use PPA. Found an old tutorial teaching me how to use PPA as it is my first time for it, the blog explain everything good, found couple more article but they are nearly the same. So, I went on and install the PPA and update the PHP 5.6. I run a command line to see what version of PHP is there and it correctly shows 5.6. So far so good, but suddenly “If anything goes wrong will go wrong” statement hit me. It only update CLI PHP not apache version. Damn, what is wrong with it.

PPA on Ubuntu 12.04 LTS need Apache 2.4 and Apache 2.4 never makes to Ubuntu 12.04. So, again there is PPA for apache but that doesn’t work for me well. I mean it does update few things, but cannot make PHP’s Lib for Apache to get installed. At this very moment, I have two options. Either I rollback all updates to my Backup Copy, or I move ahead to upgrade OS to 14.04 LTS. I choose later one.

Simply run “do-release-upgrade” and follow the course of stream. but it stuck as VestaCP’s APT repo didn’t work with upgrade. Not sure why, I just remove them from APT repo’ List and all goes well. All updated nothing is broken but Apache. It is broken because my previous attempt of PPA apache upgrade leave it broken and in conflicting state.

I remove and try reinstall apache without PPA, but that cause more conflict. After hit and trial with PPA and non PPA apache, I end up getting it upgrade and everything running.

There is no technical details shared in this post, as this post is not for Step on how to do it, but what not to do it. And that is only one thing, never miss reading about what upgrades you are going to do, never miss system requirement before paying someone. It only took me 4 hrs to get it all going, and frankly it turns out to be Positive for me, as it get my pending upgrade of OS done. But, I would have save my day if I read the simple requirement before buying the upgrade for billing software. I would have avoided unnecessary upgrade path, and reduce the down time to say 1 hr at most instead of 4 hrs. Good thing my blog is not a business, but never try that at client server.