Sunday, May 3, 2020

Advantages of node package manager yarn over npm



npm and yarn are the most popular javaScript package managers. npm is older than yarn, introduced in Jan 2010 soon after the release of Node.js and was developed by Issaac Z. Schlueter. It still holds the position of most used package manager for JavaScript till date. Whereas, yarn was introduced in late 2016  by facebook engineers with some major security and performance improvements over npm, and was well received in the node community after that.

Through years as it has grown tremendous popularity, npm community faced major security issues by some malicious code attack on some popular packages. The malicious code was meant to copy the npm credentials of the machine running the affected package and upload them to the attacker. Such technique is called Module Highjacking. Also another frustrating issue was coming up the mismatch of sub-dependencies in a package. Say a package used in the current application is not maintained now, and the sub-dependencies have introduced some breaking fixes on new release and the package is not being updated to match those changes. This may cause really frustrating issues during the application run. 

So in order to resolve these issues Yarn was introduced in late 2016 by facebook developres. Later engineers from Exponent, Google and Tilde also helped testing and validating the yarn client outside facebook on different js frameworks for additional use cases and after that it is being released publicly. Here are couple of points of yarn over npm:
  • Lock file:A lock file called yarn.lock is introduced in yarn that keeps the versions of dependencies locked. It also keeps an identifier of every sub-dependencies with their versions locked inside the file, ensuring every installation of the application have the same version of dependencies and sub-dependencies. Although npm since version 5.0 provides the package-lock.json just like yarn.lock.
  • Selective dependency resolution:
    This let user define dependent or sub-dependent package versions or a range inside "resolutions" key of package.json to control the versions of packages used.
  • Caching:
    Yarn stores every package it installs in a global cache in user directory on the file system so that all subsequent installation can be served from the local cache, improving the installation time.
  • Parallel downloads and automatic retries:
    It uses parallel workers to download the packages in order to maximize the resource utilization and helps reducing the build time. Also network requests retried upon failure to avoid build failure caused by a temporary network issue.
  • Multiple registries:
    It installs packages from both npm registry and bower, thus ensuring the availability of packages if one of them goes down.
  • Autoclean:
    The yarn autoclean command frees up space by removing unnecessary files(e.g. *.md, *.yaml) from dependencies. Also inside .yarnclean file it can be configured to clean dependency's test and example files in order to reduce the size of node_modules folder.


Conclusion
Over the years npm resolved many security issues and till date still npm holds the position of most used node package manager. Above all npm comes with node setup as a default package manager to use.

But considering the specs of yarn over npm as discussed above, it is clearly the safest and convenient option specially for production use. And in 2020 yarn released its version 2 with various bug fixes and further performance improvements. In the yarn roadmap there are many new addition including the shift of yarn from only node-specific cli package manager to a platform and API for multiple languages, which makes it more promising for the future use.


Friday, September 14, 2018

Right direction towards building a future in the world of software development.

From technical perspective, specifically when web software lifecycle is concerned, what we can see now is present, we are physically in present now. The word phisicality in software lifecycle can be asumed as the daily consumption of technological frameworks. The convenience in our daily lives, the different solutions to our problems are what can be defined as the physicality of the software lifecycle. So what we have now from a software perspective is the present and that is all accumulated from tremendous effort from past. As time goes a system enhances more, advances more, rather it accumulates more usefullness to it.

So in order to stand out in this field we need to know the existing advancements properly in its widest possibility. Now when time comes to give our thoughts a go we should digg more deeper into a specific niche from the entire width of the present software phisicality. So we need to go with present phisicality, in particular framework as we say it. Looking back to the past solutions in that particular respect would only leave us behind. So in this case exploration of the present phisicality is more required than finding and sticking with old solutions. Using the best optimum solution from present to that direction developers should start their path to build another solution which will be the future. Unless the solution is meant for the future, in this software world, the effort towards building, will not worth it. The effort will be wasted. For giving such a profound future solution of an existing problem, the most neccessary thing is the vision and the depth of exploration to the present software phisicality towards that problem.

Wednesday, June 27, 2018

Best way to judge photos captured by yourself

Its easy to judge photos clicked by someone else than your own. Actually if you slowly adopt some habit after clicking the photo this judgement will be better slowly. One of the good habit is to see each photos in a big screen after the photography session. After filtering some of the best shots, process it and see it more vividly. You will get the feel of color, exposure and sharpness.

At the time of post processing you will filter it to a more lower number of photos. Now one best way to judge and to understand the composition mistakes, make it your desktop wallpaper. See it for at least 3-4 days before changing that with another photo. If you invest your time like this in each photo, it will not only help you judging your own taken shots, but it will improve your composition and exposure control. It's for sure you will dump some of the photos after this process :-).

Sunday, September 14, 2014

Choosing browsers for different purposes

I am a Mozilla fan and I use mozilla products firefox & thunderbird. Being a developer also I prefer firefox. For using google products chrome/chromium(a open source project) obviously a best choice.

Chrome uses webkit which renders better feel specially the new HTML5 elements and the new CSS3 features. Chrome & Safari both uses Webkit whereas Firefox uses Gecko. Though chrome has moved to a new engine Blink which is a fork from Webkit browser engine. Safari also uses Webkit. Another browser that recently have come to attention is the Maxthon cloud browser which is also on webkit, and seems a modified version of chromium. Following is a detailed information about which browser uses which engines:
  • Firefox and other Mozilla browsers use Gecko. 
  • Chrome uses its own fork from Webkit named Blink starting from 2013/04/03 (as they have annouced). 
  • Safari, Maxthon & Konqueror use Webkit. 
  • Internet Explorer uses Trident. 
  • Opera 9+ uses Presto

Now if you are browsing some websites regularly which is based on some good graphics on HTML5 extensively then you must use chrome instead of firefox as chrome renders better graphics and heavy javaScript work than firefox. Safari is good but if you are using OS other than Mac its of no use cause there is no option to use it on any linux distro and on windows they have stopped further development.


Chrome/Chromium uses more system memory to give smooth user experience where firefox uses moderate amount of system resources. Alternative to chrome you can try Maxthon which is good webkit based browser, it is stable and can render HTML5 flawlessly.


Other than these popular rich browsers sometime I prefer some light weight browsers like K-Meleon, QtWeb

Sunday, August 24, 2014

Her last USG during pregnancy - 23rd aug 2014

Today I have come with Nilu in HealthETC for her final usg during pregnancy. I'm writing this in front of the USG room when Dr. S. K. Sirohia is doing the usg.

I wanted to see the ultra sound live and asked her to request doctor for the permission to allow me see my baby for the last time inside her womb!

And finally I have seen it... 've seen its heartbeat, head, moving arms and legs...

feeling... no words to describe.

And finally got the report on the same day after waiting there for 10 minutes. Report is excellent, it is 33 weeks old now according to the report and it's weight is around 2 k.g., everything is normal.

Tuesday, November 19, 2013

Server clock on client side using JS + PHP

A small piece of code(js + PHP) which will help you to get the server clock in browser using js on a global variable. It may be helpful when your are building some activity/tracker kind of application using js.


<script type="text/javascript">
    <?php date_default_timezone_set('Asia/Calcutta'); ?>
    var i = 0;
    var servDate = '<?php echo date("Y/m/d/H/i/s", time()); ?>';
    var servDateArray = servDate.split('/');
    var serverTimestamp = '';

    function serverClock()
    {
        var now = new Date( 
            Number(servDateArray[0]), 
            Number(servDateArray[1]), 
            Number(servDateArray[2]), 
            Number(servDateArray[3]), 
            Number(servDateArray[4]), 
            Number(servDateArray[5]) + i
        );
        i++;
        
        var secs = now.getSeconds();
        var mins = now.getMinutes();
        var hr = now.getHours();
        var date = now.getDate();
        var month = now.getMonth();
        var year = now.getFullYear();
        
        var finaldate = year
                            + '-' + ((month < 10) ? "0" + month : month) 
                            + '-' + ((date < 10) ? "0" + date : date);
        var finaltime = ((hr < 10) ? "0" + hr : hr) 
                            + ':' + ((mins < 10) ? "0" + mins : mins) 
                            + ':' + ((secs < 10) ? "0" + secs : secs);
        
        serverTimestamp = finaldate + ' ' + finaltime;
        // console.log(serverTimestamp);

        setTimeout('serverClock()', 1000);
    }

    window.onload = serverClock;
</script>

Saturday, September 15, 2012

One very basic file manager for the web

This is a  very basic app to manage (upload / download and delete) files to the remote server. This needs only php and a web server to run. This is basically a single php file which does the all. To configure the store dir (which will contain the uploaded files) you need to write down the path under $config variable in the same php file(one default value is there).
May be this app seems very insecure for the WEB but I have written it just to take files using HTTP from my home system to my mobile(and the way other) using wifi, and its fast.

This piece of code may help you too may be for some other purpose, please don't forget to reply to this post about your purpose if you are using this file manager.

Download: https://github.com/pras9/fmanager