Critical Developers

Programmers Knowledge Base

Install and Execute gulp in Visual Studio Code (vscode) on Windows

I know you are struggling with your problem, don't worry the solution is here for how to install and execute gulp in Visual Studio Code (vscode) on Windows.

Following are steps you need to follow. (Note: Please skip steps those you are done already)

Step-1: Install Git (https://git-scm.com/downloads)
Step-2: Install node.js (https://nodejs.org/en/download/)
Step-3: Restart System
Step-4: Start vscode and open your project folder in workspace
Step-5: Now its time to execute gulp at root (Refer below methods).

There are 2 ways running your project as follows:-

Method-1: Using vscode Terminal
Goto Terminal window and type commands as below:-

1. Install gulp globally:
> npm install --global gulp

2. Install gulp in your project devDependencies:
> npm install --save-dev gulp

3. Create a gulpfile.js at the root of your project: (ignore if already done)

var gulp = require('gulp');
gulp.task('default', function() {
  // place code for your default task here
});

4. Run gulp:
> gulp

5. Allow access to Windows firewall (if asked usually it asks for first time)
Your project will be opened in your default browser

6. To terminate the task goto vscode "Terminal" and press Ctrl + C
It will prompt comfirmation Y/N, type Y

Method-2: Using vscode GUI
Assuming you have gulpfile.js
1. Ctrl + Shift + P
2. Select option > Tasks: Run Task
3. Select > gulp:default
4. Select Continue without scanning the task output
5. Allow access to Windows firewall (if asked usually it asks for first time)
Your project will be opened in your default browser

6. To terminate the task goto vscode "Terminal" and press Ctrl + C
It will prompt comfirmation Y/N, type Y

Hope it helped you.

Thanks.

Shorten Number to 1K, 1Lac, 1Cr using C#

        // Shorten Number to 1K, 1Lac, 1Cr
        public static string ShortNum(decimal? val)
        {
            string unit = string.Empty;
            string str = string.Empty;
            if (val >= 10000000)
            {
                val = (val / 10000000);
                str = string.Format("{0:0.00}", val);
                unit = "Cr(s)";
            }
            else if (val >= 100000)
            {
                val = (val / 100000);
                str = string.Format("{0:0.00}", val);
                unit = "Lac(s)";
            }
            else if (val >= 1000)
            {
                val = (val / 1000);
                str = string.Format("{0:0.00}", val);
                unit = "K(s)";
            }
            else
            {
                str = string.Format("{0:0.00}", val);
            }
            //
            if (str.EndsWith("00"))
            {
                str = ((int)val).ToString();
            }
            //
            if (!string.IsNullOrEmpty(unit))
                str = str + " " + unit;
            //
            return str;
        }