Thursday, December 29, 2016

Cyclomatic Complexity and C Code

Cyclomatic Complexity refers to the code complexity and the relevent threat level of code having bugs. It's measured as counts and the range is generally 1-10 good - very less possible bugs, 10-20 average - few bugs possible, 20-30 High threat - high number of bugs possible due to high complexity, >30 is very dangerous with very high number of complex bugs possible.

Generally a program counting the Cyclomatic complexity goes through the code and
counts the various conditions, branches, go to's etc. Then by counting the edges of code flow graph w r t nodes, the CC count is calculated.

What I have to do with all this? Basically in my current organization we have CBA - continuous build automation facility which produces nightly builds of all projects. It also performs linting, static code analysis and produces various red/yellow etc flags for code quality issues. Recently a red flag was seen in a feature I halped integrate.
This is a third party component, but since we integrate it in source form, the CBA issues become our responsibility.

Going through the code I found the flagged c - functions to be complex code with about 25+ if else conditions and couple of switch cases each.

So now to make this code CBA clear, I'm going to have to refactor it into cleaner code.

To do this I am using "cccc" tool. Following link proved very handy
http://baptiste-wicht.com/posts/2011/08/compute-metrics-of-c-project-using-cccc.html
cccc lets me check in detail what's wrong with cyclomatic complexity of functions and where. Then when we have cleaned them up we can check the result with cccc again to validate the changes.

Similar too is an eclipse plugin  by name of metriculator. So if you are using eclipse as IDE for your C/C++/Java code then you can use this.

Wednesday, December 28, 2016

Thinking about getting a Raspberry Pi 3 to use as Living Room Computer

Well, I have a laptop for home use. But it's got kind of cramped feeling when using it for media consumption - because mainly that's what we use it for. Basically I have an external HDD to which I dump whatever media I get my hands on. This is then used on the laptop. So I'm looking at a setup which is cost effective and at the same time let us do the TV thing with external HDD and also lets us do bit of browsing for news etc. 
Recently I purchased a Logitech MK215 wireless Keyboard Mouse combo and it's made this setup much better. So now I'm thinking of shifting to bigger display - at least a 18.5 - 24" monitor. The problem is connecting laptop to this will just make the laptop work as desktop and it's not good for battery. Also it gives us a tangle of cables plus the space used. Then there's the screen switching between external and internal display. So it's not just the ideal setup. What I want is a low power one box solution that will let me play all the media I have and also let me do basic computing tasks. 
Now the Raspberry Pi 3 fits the bill. The board with a case and power adapter costs about INR 3500/-. To this I connect the HDMI monitor and I get the display, my existing 2.1 speakers, and voila I have a media center of my choosing with minimum cost. I'm assuming the monitor to go for about INR 8000/-. That's INR 11.5K but I get a good and big monitor plus a separate system from my laptop which is self contained. So that my wife could use this or the laptop while I'm using the other. The main reason for this being that my other laptop went kaput. And getting a D-SUB monitor is waste of time. Of course if I could get a D-SUB to HDMI converter box then that might work too. In that case I'll have to shell out INR 8000/- for monitor and the box for approx INR 800/- which is INR 8800/-. But in this case I'll be dependent upon a 5Yr old hardware which might fail at any time. 
Hmm. The RPi route looks better. But the cost if of course more. Maybe if I experimented with the Pi Zero the cost would come down. On the other hand my existing kaput laptop is sitting there in the closet gathering dust, it might get some usage with the second route, also better since four months back I spent about INR 700/- on a power brick for that thing. Grrr!
Well lets see. Mostly I would just postpone this due to my temporary living arrangements. Maybe next year when I move to a bigger and permanent place I'll get the things. 

Sunday, December 25, 2016

My views regarding smart phone purchase

Many of us are routinely looking at buying yet another smart phone and there are so many options out there, so many features, combinations and different hardwares, it becomes challenging. Looking at the available choices it can be frustrating at times - especially for people looking to buy an Android phone.
There are some people who want an iPhone. New buy is simple for them. If you have the budget go for the latest and greatest from Apple. Otherwise settle for one or two gen older iPhone. You know what you are getting. You want it so you take it with all the shortcomings or the lack of features there-of. They spend considerable amount on phone and get something that can be very fulfilling for them.
Next are people who are looking for just calling and light games-entertainment. They usually have budgets from INR 5000 to 10000. And from options front they have Androids only. The entry level androids are quite limiting in hardware/features and overall performance. But they can be good value for money if people are looking for limited functionality.
When you cross INR 10000, you start getting some very good androids with mid range hardware with good enough specs and features like Snapdragon 600 series processors/ 2GB RAM/ 16-32GB ROM etc. There are many good options in 10000-15000 range and most people buy phones from this range itself.
Beyond 15000 till 25000 there are capable devices with latest chipsets and high-end features. People who have budgets and are looking for even better features covet these. There are usually one or two defining features like flagship grade cameras, thin and light construction, great design etc. They are coveted for these differentiating features.
Beyond 25000 there are true flagships. These are handful devices with high end specs costing similarly. People who don't want iPhone but want flagship devices in Android go for these devices.
In Indian smartphone market, people are usually looking for phones to use for 3-4Years. The phones come unlocked and carrier subsidies are not available. So people pay upfront and that's one of the reasons that Indian smartphone market is very price sensitive and is very competitive. Also this is the major reason that even unknown chinese brands sell well, if they are giving good value for money and quality.
So that's about the market. Lets look at a case of buying a phone in the most popular price bracket. Lets say I'm buying a phone from Amazon. So I open Amazon and enter the price bracket. There is so much choice. 197 Androids, 3 WP's and 1 Blackberry even!!! Lets drop the WP and blackberry. Lets say I'm looking at only 32-64GB ROM devices. There are 44 left now. I'm looking for a 5" device. So that narrows down to 13. There are same models with different colors. These are Nubia Z11 mini, Lenovo Vibe X2-AP, Asus Zenphone 3Max, Gionee Elife E6, HTC Desire 628, Gionee Marathon M5. All these are capable and we can choose further. In case we are looking for particular brand we can differentiate accordingly. E.g. Moto G4 is available in similar brackets but has only 16GB ROM, still many people prefer a Moto and go for it.
That's it!

Thursday, December 22, 2016

Android Games I Like

I occasionally use my Android phone for playing games. Most of the android games are not comparable to PC Games where you get lots of content, slick graphics and great game play too. There are some games on Android which strive to be equivalent and also manage to be so. Lets take a look at them: 

1. Modern Combat 5: Blackout - Excellent Game, pity can't be played offline. Bugs out once in a while due to god knows what issues. But overall awesome when it works. 

2. Brothers in Arms: WWEII era game that manages to look and play the part. Really awesome game - felt like I'm almost back to Call of Duty. The missions and games are totally worth.

3. Modern Warplanes: Relatively new game but is very engaging. Excellent graphics and great controls. Overall awesome experience. 

4. Hill Climb Racing and Hill Climb Racing 2: Total timepass. 

5. Asphalt 8 and Asphalt Extreme: Great racing games. The graphics are top notch and the races even more so.

6. Overkill 3: This is the game I have played longest. Very engaging with great weapons. The only thing which made me turn away after almost five months of playing it, it's feels like a tight FPS with not much funny aspect. You shoot enemies, but you can't play with the enemies, like lodge a grenade and watch them go kaboom. 

7. Sniper Fury: Great sniper game. 

8. Plants Vs Zombies 2: Great game but if you have played the first then this might get repetitive. 

8. Trials Frontier: Another great game of adventure bike genre but the game can get windy at times and get boring when you have to keep playing existing games to get through.

9. NOVA 3: This is the game everybody talks about like its the de facto FPS on Android. And it is with great weapons and great gameplay. 

So these are few of my favorite games. There are thousands more out there and I'm yet to try them but these few are maybe the cream.


A Recap of Year 2016

It's about the end of this year and I felt like I should put together a recap post for this year. The thing is I'm not posting as much sine I have been busy elsewhere. (New home it is ;) )
But a lot of things happened. I started the year with a switch to Linux Mint, but after using it for 3-4 months got bored, and instead switched to KDE Neon distro which showcases latest plasma developments and certainly is cutting edge and exciting. But because of stability related issues - yeah it's cutting edge ;C - I had to abandon it. So couple of months back I'm back on Ubuntu. Actually my old Acer laptop which boasted of 1GB of RAM and was proving to be bane of all Linux distros I was trying, died second time. It turns on and everything seems to be working except no display. Maybe the LCD panel is gone or maybe the connector is damaged, I don't know. I don't have a spare monitor to connect to the D-SUB port so I can't check if it's really working or just making stupid noises. Maybe I'll get a monitor in near future and put this to work, maybe. 
So now I'm left with the blue Lenovo - blue because there's another Lenovo which my Sister uses which is black and had AMD A4 5000K APU inside, so that makes mine the Intel Lenovo which doesn't sound as good as Blue Lenovo. It's Pentium D + 2 GB+500GB machine which is working fine since last year I replaced it's battery and keyboard. Having 2GB RAM it's lot forgiving and manages to run everything fine. So that meant I'm sticking to Ubuntu since it just works now. (Previously it was bit of struggle on 1GB Acer J.) 
On Windows front, I'm sticking to tried and trusted Windows 7 - no surprises here. 
Mid year was quiet with me busy with things and work at office with assignment to a new project. 
In Sept, I got an Intex Aqua Fish to try out Jolla and it has been a good experience overall. They have good amount of work to do, there are many things missing, but there are updates and things are looking at least ok for Jolla. Lets see how far they make. I posted my experience of various things about Aqua Fish and Sailfish in many posts. I have not yet tried to use Aqua Fish as my daily driver. Will try soon.
Last but not least my Nubia Z9 Mini completed one year in Oct and to celebrate I replaced the factory applied screen protector with a tampered glass screen protector purchased for all of INR 169/-. Hahaha. But the original had acquired a number of scratches and was looking really scruffy. So the new one makes the phone look newer right away and better on eyes.
Meanwhile I started on a Sailfish App but after spending a some time on it I realized that I am not able to give it enough time to make it work. So I scrapped it. 
Ubuntu translations have continued and it's my pleasure to state that Marathi Language support have passed Tamil Language and is right behind Punjabi - got to keep kicking. This was possible because I got hold of butt-load of upstream translations for Inkscape. Still merging them with the po file from Launchpad was no mean feat and took me about a week. 
So that's all for Yr 2016. A lot has happened here in India with Demonetization, Black Money Issues, New Corruption scandals, Terrorist attacks and still we keep kicking. 
What's for new year? Well I'm thinking about getting a Raspberry Pi or some similar board and doing a TV Connected home computer with it, I'm just not sure if it'll serve the purpose that well. Lets see, I'm going through the available hardware and actual requirements. Might come true. The Dead Acer might see the light of day too. And The Blue Lenovo should keep going. That's all 2016! 

Adios!!!

Thursday, December 8, 2016

Git Proxy Settings

Command to use:

git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080

    change proxyuser to your proxy user
    change proxypwd to your proxy password
    change proxy.server.com to the URL of your proxy server
    change 8080 to the proxy port configured on your proxy server

If you decide at any time to reset this proxy and work without proxy:

Command to use:

git config --global --unset http.proxy

Finally, to check the currently set proxy:

git config --global --get http.proxy


A test of merging two big files in Linux

Update: "Beyond Compare" it is. Certainly for big files weighing in MBs it's the clear winner since meld just craaaaaawls. Unfortunately you get only 30 days of eval period with Beyond Compare and it's paid after that. But for anybody doing serious amount of compare and merge "Beyond Compare" may prove to e good investment. Otherwise for all us fellows who just occasionally merge things "Meld" it is!

I contribute to Ubuntu Translations. Recently a curious thing happened. While going through some translations I noticed that there are some projects where upstream translations are available. But those are not yet imported in Ubuntu packages available on Launchpad.

One such package was inkscape. When I checked the upstream website for inkscape I found that in trunk there's a translation available and there is a lot of work done.

So I downloaded the po file from there and tried to upload it to Launchpad. Rosetta(Launchpad Translations Management System) declined with note that Launchpad po files contain custom tags, which the upstream translation did not have.

So I decided to go at it the hard way - manually merge the files and upload the updated Launchpad copy. This I found out to be tough task since the files are 1.4MB and all linux merge softwares fairly suck at big file merging.

Meld was creeping and took about couple of minutes (:D) to load the files. Merging was slow with every change taking upto 10secs to refresh the UI.
Kompare also failed where similar behaviour was observed. I didn't try any other tool since these two are the mainline tools.

Finally I cleaned up the upstream po file removing unwanted text like fuzzy markers and easing the load a bit. After this cleanup I'm now able to merge the files using meld. But it's still creepy crawly. But at least not as bad as before.

Incidently I came to know about Linux version of Beyond Compare. It's a paid software. But I downloaded it anyway. Funnily enough it works great. I could move around with no delay and the merging is very fast. Lets see how it works out. Certainly beats meld though!!!