What's up!

Pyaarey Allah!

Saturday, July 14, 2018

Is node.js still immature?

0 comments

Recently I was interviewed and accessed by a technical auditor. These people claim to visit incorporations internationally and talk on technical and non-technical aspects and processes of companies. They interview the technical leaders firstly and then speak to the team. After that they send written recommendations to the management, get approval and then dispatch those recommendations to the team leaders.

By background I was doing all my R&D on how I could use AWS cloud and node.js capabilities to achieve best of pricing, development, deployment, testing, DB storage, file storage etc. I was writing a small but comprehensive boilerplate app where I was testing almost s full life cycle of development and then test and deployment.

The interesting part of our discussions was that the accessors commented on node.js as an immature platform. Of course no developer in the current world ignores the importance of node.js and knows that node.js is emerging part of software development.

So as the accessor said: "Do you know Asif, we totally appreciate your efforts and like your work and R&D but we think that node.js is an immature platform yet. I said, "What in node.js is immature sir" and he tried to argue and me as well. During such comprehensive assessment we never have time of few seconds to touch a topic. Either they will not go in detail or will give you maximum of 20 seconds to explain your point of view. Which sometime is cruel for some topics and sometimes even 20 seconds is a total waste of time; but this is what it is.

My question remains there. Is node.js an immature platform? My head kept revolving around the same topic. One day in my life I want to speak to the same accessor and explain to him one single topic which is: "is node.js an immature platofrm"

So here my friends are my arguments

What exactly in node.js is immature? By core node.js is neither a web server, not a tool to give you anything finished. Node.js just runs on V8's JS engine and some of threading handled by libuv. What exactly you want node.js to do for you? My friend: node.js is just a baseline platform of tool to allow you to use whatever you want to do with ECMA/JS. That is it. So the tools which you use such as express, koa or meteor or anything matter; node itself has no big tooling other than providing a base installation on your machine.

Once we understand that node.js itself is too small to be called a "Solution provider" We must go and check "what makes node.js a "solution provider" Here is the list of things which make node.js an ultimate solution provider.
    1. Package manager examples
      1. NPM
      2. Yarn
    2. Webserver tools/framework examples
      1. express
      2. koa
      3. meteor
    3. Language options
      1. ECMA any version is possible
    4. Databses
      1. Anyone of your choice
    5. Data access layers
      1. Knex
      2. Typeorm
      3. sequelize
    6. Development tools/Views controllers etc
      1. Angular
      2. react
    7. TDD
      1. Chai/Mocha
      2. Jasmine etc
    8. And so so much more no npm and yarn
As we can see there is a good list of tooling around node.js, almost everything, then we cherry pick tools of our own choice. Such as I can prefer Angular over React or vice versa.

Then lets start comparing these cherry picked tools with one big solution provider framework such as ASP.NET
ASP.NET solution has these components
    1. Database layer usually SQL Server
      1. Entity framework for data access
    2. C# coding layer
      1. Services or BLL
      2. Data Access layer including repository and unit of work
      3. Dependency injection
      4. Controllers
      5. Routing configuration
      6. Application startup coding
      7. Request interruption such as Authorisation attributes & Action Filters  
    3. View engine
      1. Razor
    4. Front-end coding layer i.e JS
      1. All the tooling you can use in browser using JS/ECMA
Now we take each one of these components and start comparing with what is available on github in node.js tooling. We can start comparing test cases ran on the tool and we will find out that in node.js the tooling is tested and developed by mature teams which run countless tests on their own tools, and we can also compare how comprehensively issue tracking is done on tools.

For rapid examples
    1. View engines
      1. React: 100,000 stars, 18000 forks, 1200 contributors
      2. Angular (views and more) 58000 stars, 28000 forks, 1600 contributors
    2. Scripting
      1. Typescript, 36000 stars, 5000 likes, 316 contributors   

Lets create a list of comparisons of choices and maturity, This is done a format that first I will narrate ASP.NET component and then put a :: symbol and narrate its alternate in node.js 

  1. Database layer usually SQL Server or any db :: node can also use any db
    1. Entity framework for data access : substitutes I wanna mention
      1. Sequelize 15k stars with 700 contributors, 8k commits & 374 releases
      2. Typeorm 7k stars with 200 contributors, 3k commits & 36 releases
      3. Knex 7k stars with 240 contributors, 2k commits & 118 releases
  2. C# coding layer
    1. Services or BLL :: Usually done in C#
    2. Data Access layer including repository and unit of work
      1. Mentioned above
    3. Dependency injection :: Usually not needed bec of JS's nature of require(...) still there are plenty of good tools such as 
      1. https://github.com/jaredhanson/electrolyte
      2. https://github.com/jeffijoe/awilix
      3. https://github.com/luin/express-di
    4. Controllers :: three choices we can mention
      1. express 39k stars with 200 contributors, 5k commits & 275 releases
      2. koa 22k stars with 153 contributors, 1k commits & 70 releases
      3. meteor 40k stars with 390 contributors, 21k commits & 1100 releases
    5. Routing configuration
      1. Part of controllers framework
    6. Application startup coding :: All in your control in node.js
    7. Request interruption such as Authorisation attributes & Action Filters  :: All controller framework have great startup and middleware support much more powerful than ASP.NET
  3. View engine
    1. Razor :: In node.js you have so many view engine choices over 10 good ones, so there had to be a need to consolidate and now there is consolidator for express
  4. Front-end coding layer i.e JS
    1. All the tooling you can use in browser using JS/ECMA :: Same for node.js

So we can see that there are so so many mature choices in node.js as of today. We need to cherry pick a good tool for us. The conclusion is that node.js itself is not tool to be called mature or immature. Node.js is a baseline product which allows you to start playing as you like. Then you start picking from huge range of toolchains that you like. And if you make a mistake in your selection, that is purely your mistake not node.js. Also node has substitute for every tool in all popular desktop and web frameworks. 


Further reading: https://www.toptal.com/nodejs/why-the-hell-would-i-use-node-js
In this article Tomislav Capan explains some under lying architectural details and then explain some good tools. Worth reading. 

Wednesday, April 1, 2015

Backup and Archive Sql Server Database

0 comments

-- Set the name of the archive backup directory.



DECLARE @bakdir VARCHAR(300)
SET @bakdir = 'D:\radmade_projects\src\code\_db\'

-- Set the name of the database.
DECLARE @dbname NVARCHAR(1024)
SET @dbname = 'rmMedia'

-- Set the name of the database backup directory.
DECLARE @dbbakdir VARCHAR(300)
SET @dbbakdir = @bakdir 

-- Create the name of the backup file from the database name and the current date.
DECLARE @bakname VARCHAR(300)
SET @bakname = @dbname + '_backup_' + REPLACE(CONVERT(VARCHAR(20), GETDATE(), 112) + CONVERT(VARCHAR(20), GETDATE(), 108),':','')

-- Set the name of the backup file.
DECLARE @filename VARCHAR(300)
SET @filename = @dbbakdir + '\' + @bakname+'.bak'

-- Create the directories if necessary.
EXECUTE master.dbo.xp_create_subdir @dbbakdir
EXECUTE master.dbo.xp_create_subdir @bakdir

-- Backup the database.
BACKUP DATABASE @dbname
TO  DISK = @filename
WITH NOFORMAT, NOINIT,  NAME = @bakname, SKIP, REWIND, NOUNLOAD,  STATS = 10


-- Turn on the 'xp_cmdshell' function.
EXEC sp_configure 'show advanced options', 1
RECONFIGURE
EXEC sp_configure 'xp_cmdshell', 1
RECONFIGURE

-- Build the command line string to add the file to the ZIP archive.
DECLARE @cmd VARCHAR(300)
--set @cmd = '"C:\program files\7-zip\7z.exe" a -tzip "D:\radmade_projects\src\code\_db\rmMedia\db.zip"  "D:\radmade_projects\src\code\_db\rmMedia\db.bak"'
SET @cmd = 'cd.. && "C:\program files\7-zip\7z.exe" a -tzip "' + @bakdir + @bakname + '.zip" "' + @filename + '"'

-- Execute the command.
EXEC xp_cmdshell @cmd

SET @cmd = 'del "' + @filename + '"'

-- Execute the command.
EXEC xp_cmdshell @cmd

-- Turn off the 'xp_cmdshell' function.
EXEC sp_configure 'xp_cmdshell', 0
RECONFIGURE
EXEC sp_configure 'show advanced options', 0
RECONFIGURE

GO

Thursday, March 12, 2015

Essential Concepts for a .NET Programmer

0 comments

C-Sharp(course-outline)
Basic Language features of C#
.Net Framework Introduction
T-Sql basic language features
Interface.
Classes.
Console Application.
Enumeration.
Properties.
Events.
Access modifiers.
Delegates.
Language-Features.
Generics.
Linq.
Extension Method.
Lamda Expression.
Anonymous Function & Type.
Collections.
Collection Intializers.
Collection-Dictionary.
Array List.
Parallel Programming
Threading.
Exception Handling
File Reading/Writing(SystemI/O).
System.String & String Operations.
System.Data.SqlClient(ADO.NET)
Reflection.
Send Email.
Download file from url.
Encryption/Decryption.
Entity Framework(5 or 6).
App.configg & web.Config basic & advanced techniques


MS SQL Server Installation
Create Table
Create Primary key.
Foreign key.
Index(cluster,non-cluster).
Create view.
Stored Procedure.
Cursor.
Trigger.
Normalization(3-Forms).
Data access from ado.net & Entity Framework. 

Good C# Tutorials on Pluralsite

0 comments

http://www.pluralsight.com/courses/csharp-from-scratch
 http://www.pluralsight.com/courses/csharp-from-scratch-part2
http://www.pluralsight.com/courses/csharp-fundamentals-csharp5
http://www.pluralsight.com/courses/csharp-generics
http://www.pluralsight.com/courses/csharp-interfaces
http://www.pluralsight.com/courses/csharp-collections
http://www.pluralsight.com/courses/csharp-extension-methods
http://www.pluralsight.com/courses/skeet-async
http://www.pluralsight.com/courses/csharp-events-delegates

Wednesday, March 5, 2014

SQL Server - Kill process attached to database

0 comments

If you are trying to run a command


And you can't get access to the database because database might be in use by the single user and is in the single user mode.

There is a work around.

Run This command


SP_Who will show you processes attached to your database. See DBNAME Column and find your database in it. Then note down SPID. For example 72 is the SPID of the process you want to kill.
Then run this command to kill the process.

Kill command will kill the process. And then you will be able to run Set multi user mode command again and it should work.

Saturday, February 8, 2014

Shrink database and check its progress

0 comments

Claiming space from a SQL Server database is not like deleting all rows from a table or truncate it. Please follow the instructions if you want to reclaim your disk space.

  1. Run Sql Command:
    DBCC SHRINKDATABASE (MyDBName, 10 )
    Here MyDBName is a valid database name and 10 is the percentage of reserved free space.
  2. Run following command to check percentage done:
    select percent_complete, total_elapsed_time, estimated_completion_time, * from sys.dm_exec_requests where command = 'DbccFilesCompact'

Monday, October 14, 2013

Husool ka pehla usool

0 comments

Husool ka pehla usool be-nyazi hai

Sunday, October 6, 2013

Got a new PC

0 comments

I got a new desktop PC with
Intel 4th Gen Processor Intel Core i7 4770-k 3.5GHZ
Asus Z87-Pro MotherBoard
2 x 8GB-1600 Corsair Memory sticks
2 x Samsung SSDs(540 mbps) Raid0 for Windows, 250GB Each
2 x 1TB WD Black Disks for critical data storage raid-1 SATA III
1 x 1TB WD SATA 1 for media files
CoolerMaster Casing
H100i Extreme performance Liquid Cooling unit
Ex 2 Extreme 650Watts Power Supply
Nvidia Gforce 650Ti Boost Graphics Card 2GB DDR5

Sunday, September 1, 2013

Include jqeury bookmarklet

0 comments




    (function() {
      var el=document.createElement('div'),
          b=document.getElementsByTagName('body')[0],
          otherlib=false,
          msg='';
      el.style.position='fixed';
      el.style.height='32px';
      el.style.width='220px';
      el.style.marginLeft='-110px';
      el.style.top='0';
      el.style.left='50%';
      el.style.padding='5px 10px';
      el.style.zIndex = 1001;
      el.style.fontSize='12px';
      el.style.color='#222';
      el.style.backgroundColor='#f99';
     
      if(typeof jQuery!='undefined') {
        msg='This page already using jQuery v'+jQuery.fn.jquery;
        return showMsg();
      } else if (typeof $=='function') {
        otherlib=true;
      }
     
      // more or less stolen form jquery core and adapted by paul irish
      function getScript(url,success){
        var script=document.createElement('script');
        script.src=url;
        var head=document.getElementsByTagName('head')[0],
            done=false;
        // Attach handlers for all browsers
        script.onload=script.onreadystatechange = function(){
          if ( !done && (!this.readyState
               || this.readyState == 'loaded'
               || this.readyState == 'complete') ) {
            done=true;
            success();
            script.onload = script.onreadystatechange = null;
            head.removeChild(script);
          }
        };
        head.appendChild(script);
      }
      getScript('http://code.jquery.com/jquery.min.js',function() {
        if (typeof jQuery=='undefined') {
          msg='Sorry, but jQuery wasn\'t able to load';
        } else {
          msg='This page is now jQuerified with v' + jQuery.fn.jquery;
          if (otherlib) {msg+=' and noConflict(). Use $jq(), not $().';}
        }
        return showMsg();
      });
      function showMsg() {
        el.innerHTML=msg;
        b.appendChild(el);
        window.setTimeout(function() {
          if (typeof jQuery=='undefined') {
            b.removeChild(el);
          } else {
            jQuery(el).fadeOut('slow',function() {
              jQuery(this).remove();
            });
            if (otherlib) {
              $jq=jQuery.noConflict();
            }
          }
        } ,2500);
      }
    })();



Wednesday, August 7, 2013

SQL Lookup logged in users

0 comments


exec sp_who2


select d.name, d.dbid, spid, login_time, nt_domain, nt_username, loginame
  from sysprocesses p inner join sysdatabases d on p.dbid = d.dbid
 where d.name = 'DBNAME'

SQL Free up busy database resources

0 comments

use master
ALTER DATABASE im_test_restore SET SINGLE_USER WITH ROLLBACK IMMEDIATE
  
use im_test_restore;
go
 
checkpoint;
go
 
use master;

go
  
ALTER DATABASE im_test_restore SET MULTI_USER

Friday, August 2, 2013

Rename a busy database in SQL Server

0 comments

use master
ALTER DATABASE YourDBName SET SINGLE_USER WITH ROLLBACK IMMEDIATE
 
use YourDBName;
go

checkpoint;
go

use master;
go

alter database YourDBName modify name = YourDBNameNewName;
go
 
ALTER DATABASE YourDBName SET MULTI_USER

Thursday, July 4, 2013

Topper of the class

0 comments

The most intelligent student of the class is not the topper because He scores highest only in his favorite subjects. He simply cannot give equal rights to everything like Social Studies or Anything he HATES. That's completely fair in my world. That shows too many good signs like loyalty, mastership and attitude..... Where the topper of the class doesn't have any choice any attitude and any loyalty to studies. You cannot love more than 2-3 people; You cannot serve more than few(1-2) jobs. You cannot love everyone equally. So see how stupid the topper is. The topper one day will be sitting on a job and taking highest salary and the intelligent guy will be paying him handsome enough to not let the dog switch the master.

Sunday, June 30, 2013

SQL Server force identity insert for autoseed pk

0 comments

  use InspectionManager
  GO
  set identity_insert dbo.report ON 
  go
  insert into Report(ReportID, InspectionID, Name, DateCreated) values(124842,161815, 'wa report', '2013-07-01 20:59:09.297')
  set identity_insert report OFF
  go

Tuesday, June 25, 2013

MS SQL Shrink DB Log File

1 comments


USE [master]
GO
ALTER DATABASE YourDBName SET RECOVERY SIMPLE WITH NO_WAIT

USE YourDBName;
GO
DBCC SHRINKFILE (YourDBName_Log_File_Logial_Name, 1024);
GO

USE [master]
GO
ALTER DATABASE YourDBName SET RECOVERY FULL WITH NO_WAIT
GO

Thursday, June 20, 2013

SQL Server - Release database connections

0 comments

use master
ALTER DATABASE YourDBName SET SINGLE_USER WITH ROLLBACK IMMEDIATE

--do you stuff here

ALTER DATABASE YourDBName SET MULTI_USER

Friday, June 14, 2013

Backup the important stuff before installing Windows

0 comments



This is too important for us to backup our configurations and files from C Drive before re-installing Windows. It really looks so easy to just copy your documents and start installing Windows. Well if we think it is that easy we are wrong! Here is the list of items we should backup. This post should be too helpful for developers specially. If you are not a developer you can simply ignore what you don't understand.

Backup Root
Create a folder E(or D):\Windows backups\yyyy-mm-dd-Windows version
This is backup root
Example of my backup root:
E:\Windows backups\2013-06-15-windows 7-toshiba-pc\

Copy data from following locations from all users
-Desktop
-Pictures
-Documents
-Downloads
-Videos
-Music

Credentials
Go to this location
Control Panel\All Control Panel Items\Credential Manager
Click Backup Vault
Follow the instructions to create a file such as Backup root\Credentials.crd

Create db backups
I opened all instances of SQL Server and created .bak file one by one. For every single DB. I did know that some databases were useless still I created .bak for them. This was safer way.
examples:
  1. SqlExpress
  2. Sql 2008
  3. Sql 2012


Export Visual studio settings like this
vs2012\Exported-2013-06-15.vssettings

IIS Websites
I ran this command you can modify according to your needs
C:\Windows\System32>%windir%\system32\inetsrv\appcmd.exe add backup "IIS-7-2013-06-15-Toshiba-Notebook"
I copied the folder to my backup root
C:\Windows\System32\inetsrv\backup\IIS-7-2013-06-15-Toshiba-Notebook

After installing clean windows, I will have to paste the backup folder to same location in C directory and then run this command:
%windir%\system32\inetsrv\appcmd.exe restore backup "IIS-7-2013-06-15-Toshiba-Notebook"



Flash Fxp backup by right clicking on FlashFxpSites from F4 popup window(Site manager)
save here
\FlashFxp\sites.ftp


Create Misc Folder
backup [hosts] file from here:
C:\Windows\System32\drivers\etc

And asp.net config files from two locations
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config
(If you use Version 2 then take backups from version 2 too)
Files to backup are web.config and machine.config


Create fonts folder and backup fonts


Environment variables to
\Environment variables\vars.txt
Control Panel\All Control Panel Items\System\Environment Variables
Examples:
PATH
ANDROID


Take screenshot of Favorite Folders and save on Fav\fav.png
such as


For remote desktop i use Multidesk free software. i save this here
E:\tools\multidesk_2_4_4\MultiDesk\MultiDesk64.exe
so no need to backup its connections.
If you use default Remote Desktop tool then open that and expand from Options button. Click [Save As...] And save .rdp file for every connection.


Better to take a look at your Recycle Bin and delete items you don’t want one by one, so that you don’t accidently delete data which you might need to recover.


Skype backup
Copy this folder to backup root
C:\Users\[your user]\AppData\Roaming\Skype

FireFox Profile
I copied this folder to backup root
C:\Users\[your user]\AppData\Roaming\Mozilla\Firefox
See here for how to restore this folder on new windows
http://support.mozilla.org/en-US/kb/back-and-restore-information-firefox-profiles#w_backing-up-your-profile

Other things to consider if you keep them on C drive
  • PHP folder
  • Mongo DB folder
  • Inetpub folder
Finally my folder looks like this:


Do You think this was too simple? :D 


Wednesday, October 17, 2012

Video and article on repository pattern

0 comments


http://www.asp.net/mvc/videos/mvc-1/aspnet-mvc-storefront/aspnet-mvc-storefront-part-2-the-repository-pattern

http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-the-repository-and-unit-of-work-patterns-in-an-asp-net-mvc-application

Tuesday, October 16, 2012

SQL Server Training videos

0 comments


How to Install SQL Server 2008 R2 Express
http://www.youtube.com/watch?v=CXJP4D503Tk&playnext=1&list=PLAB997187BD64BB11

Installed SQL Server?...Now What? (Getting Started)
http://www.youtube.com/watch?v=9_3qgAxplW0&feature=BFa&list=PLAB997187BD64BB11

Getting Started with T-SQL Queries using SQL Server Management Studio
http://www.youtube.com/watch?v=V4hTLja7jU8&feature=BFa&list=PLAB997187BD64BB11

SQL Server Data Types: An Overview
http://www.youtube.com/watch?v=w9P8kb0zKp8&feature=channel&list=UL

Introduction to Database Design - Primary/Foreign Key-Choosing Datatypes-Identity Seed-Quiz
http://www.youtube.com/watch?v=btF5EVx9LYY

SQL Server Stored Procedures: Returning Data to the Client
http://www.youtube.com/watch?v=-WZxGv7co-c

Creating Scalar UDFs: Syntax and Basics
http://www.youtube.com/watch?v=jOGgerTAK7U&feature=plcp

SQL 2008 Series: Views
http://www.youtube.com/watch?v=to_0_bODY2Y

And finally a full series start...
Connecting to SQL Server using SSMS - Part 1(do full series)
http://www.youtube.com/watch?v=ZNObiptSMSI&list=PL08903FB7ACA1C2FB&feature=plcp