This is how I use the Visual Studio Code (vs-code) as a web developer.
VS Code is a widely used and free IDE that is beloved by the open web community. If you’re a web developer and haven’t heard of or used it before, you may be living under a rock the size of Mount Everest! Just saying… As a web developer myself, I use this IDE frequently and thought I would share how I use it in case it’s useful to others.
Note: There are many articles, posts, and YouTube videos available to help you get started with VS Code and even become a pro. However, I am documenting my own experience with the IDE solely for my personal reference.
Keyboard shortcuts
There is an excellent article about the 20 VS Code shortcuts for faster coding. Any developer loving the VS Code IDE should at-least know few of these shortcuts!!.
Extensions
Below are the list of the extensions I currently use and they are awesome.
For developer working with JavaScript and Node.js, you may find it necessary to use different versions of Node.js for different projects. This is where nvm (Node Version Manager) comes in handy. nvm is a command-line tool that allows you to easily install and manage multiple versions of Node.js on your system.
In this tutorial, we’ll see how to install nvm and use it to install different versions of Node.js on a Mac.
Step 1: Install Homebrew
Homebrew is a popular package manager for macOS. It allows you to easily install, update, and manage software packages on your Mac. To install Homebrew, open Terminal and enter the following command:
**If Homebrew is already installed then you may want to update it:
// First Check the state of the tool first, because if there are any issues its best to fix them
brew doctor
// Now update
brew update
Step 2: Install nvm
With Homebrew installed and updated, you can use it to install nvm. Enter the following command in Terminal:
brew install nvm
This will install nvm on your system.
Step 3: Configure nvm
Once nvm is installed, you’ll need to configure it by adding the following lines to your shell profile (e.g. ~/.bash_profile, ~/.zshrc, or ~/.profile):
Java is a popular programming language that is used to build a wide range of applications. Maven is a build automation tool that is often used in Java projects to manage dependencies, compile and test code, and package applications. In this blog post, we will go over the steps to install both Java and Maven on a Mac.
Installing Java on Mac
Download and install the Java Development Kit (JDK): The Java Development Kit (JDK) is the core component that you need to develop Java applications. You can download the JDK from the Oracle website (https://www.oracle.com/java/technologies/javase-downloads.html). Once you have downloaded the JDK, double-click on the package file and follow the on-screen instructions to install it, or check the link.
Verify the installation: To verify that Java has been installed successfully, open the terminal and run the following command:
java -version
You should see output that shows the version of Java that is installed on your system, like below.
Installing Maven on Mac
Download Maven: You can download Maven from the Apache Maven website (https://maven.apache.org/download.cgi). Once you have downloaded Maven, unzip the archive and move the unzipped folder to the location where you want to install Maven (e.g., /usr/local/).
Set the environment variables: To use Maven from the terminal, you need to set the environment variables that point to the location of the Maven installation. You can set the environment variables by adding the following lines to your .bash_profile file:
Dygraphs is a powerful and flexible open-source charting library that allows you to create interactive and customizable graphs and charts in your Angular applications. In this tutorial, we’ll walk through the steps for integrating dygraphs into an Angular project and creating your first chart.
Prerequisites
Before getting started, make sure you have the following dependencies installed:
Angular CLI: This is used to create and manage Angular projects. If you don’t already have it installed, you can install it by running npm install -g @angular/cli.
Dygraphs library: To install the Dygraphs library, run npm install dygraphs –save. Also, install the types, npm install @types/dygraphs –save-dev.
Step 1: Create a new Angular project
To create a new Angular project, open a terminal window and run the following command:
ng new ng-dygraphs
Replace ng-dygraphs with the name of your project. This will create a new Angular project with the specified name and install all the necessary dependencies.
Step 2: Add the dygraphs library to your project
To use dygraphs in your Angular project, you’ll need to first install the dependencies.
npm install dygraphs --save
Next, add @types for dygraphs.
npm install @types/dygraphs --save-dev
Step 3: Create a component for your chart
To create a chart with dygraphs, you’ll need to create a component for it. Run the following command to generate a new component:
ng generate component dygraphs-chart
Replace dygraphs-chart with the name of your component. This will create a new component in the src/app/dygraphs-chart directory with the specified name.
Step 4: Add the dygraphs code to your component
Now that you have a component set up, you can add the code to create a chart using dygraphs. Open the src/app/dygraphs-chart/dygraphs-chart.component.ts file and add the following code:
I hope this year brings you joy, happiness, and all the things you wish for. May you have a healthy and prosperous year ahead. Let’s make the most of it and create unforgettable memories. Here’s to a wonderful 2023!
Custom structural directives in Angular allow you to define your own HTML syntax and behavior for creating dynamic templates. They are used to manipulate the DOM in a declarative manner, making it easier to read and understand the intended structure and behavior of a template.
Structural directives are recognizable by the * symbol that precedes the directive name. For example, the built-in *ngFor directive is used to loop over a list of items and render them in the template.
To create a custom structural directive, you first need to import the Directive decorator from the @angular/core module and use it to define a class for your directive. The class should implement the OnChanges lifecycle hook, which is called whenever the input bindings of the directive are updated.
import { Directive, OnChanges } from '@angular/core';
@Directive({
selector: '[appMyDirective]'
})
export class MyDirective implements OnChanges {
ngOnChanges() {
// code to handle changes to input bindings
}
}
In the ngOnChanges method, you can access the updated input bindings through the SimpleChanges object that is passed to the method. You can then use this information to manipulate the DOM as needed.
To use your custom structural directive in a template, you simply add the * symbol before the directive name in the element where you want it to be applied. For example:
<div *appMyDirective>
...
</div>
You can also pass input bindings to your directive, just like with any other Angular directive. For example:
<div *appMyDirective="someInputValue">
...
</div>
Custom structural directives are a powerful way to extend the capabilities of Angular templates and provide a clean and declarative syntax for complex DOM manipulation. They can help you make your templates more readable and maintainable, and enable you to write reusable and modular code for your Angular applications.
In this post we will learn how to use date-fns in Angular application. But first let’s understand date-fns.
date-fns is a date utility library which provides simple and extensive set of functions to manipulate JavaScript dates.
For example, say we want to present to user a particular date-time based on a time-zone instead of a date based on the system / browser time-zone (typically working with UTC is easy), this is actually difficult to do until unless you are using some library which parses dates into time-zones. date-fns provides nice set of functions to achieve this.
In this post we will try to learn how to export data (JavaScript array or data) to an excel file using the SheetJS / XLSX library.
Steps:
Create the angular app.
Add the dependencies, like, xlsx.
Create the table in UI.
Logic to export data in the table to excel file.
Create the angular app
We are going to use the angular guide to create a new angular project.
ng new ng-xlsx
Now we have our angular application ready, let’s try to add other dependencies to show table data on the app component and also add the xlsx library.
Add the dependencies
npm i bootstrap lodash xlsx --save
Here we are installing few packages, bootstrap (To display the data in a table), lodash (For performing data manipulation), xlsx (SheetJS library)
We also need @types for lodash, so let’s install that too.
npm i @types/lodash --save-dev
Create the data table
First, we need to import the bootstrap CSS framework into our Angular project so that we can see the styled components / table on the page. Open styles.scss file and add below code.
Above code will be overwhelming, so I would suggest to investigate the SheetJS tool and learn few things. But to summarise…
The function takes two parameters, first the raw data (JSON / array) and second the file name. The raw data is exported to the excel file and we name the excel file with the given file name in the function parameter.
We parse the data to construct into a format that is needed for the xlsx library.
Using few functions in the library, like,
XLSX.utils.book_new() – Creates a new work book.
XLSX.utils.aoa_to_sheet() – Create a new work sheet with the given data (JS array)
XLSX.utils.book_append_sheet(wb, ws, “Sheet 1”) – Adds a work sheet to the work book.
XLSX.writeFile(wb, fileName + “.xlsx”) – Finally create the excel file.
I guess this is it, when we click the export button below the table we should see a new .xlsx file downloaded with the data as seen in the table!!.
I call myself a Web developer but in reality there are many more frameworks and libraries out there that I need to learn so to better myself. One such library is React.
React is very popular, you can tell by looking at the trend below in comparison with Angular.
React vs Angular
So, I started learning react…It’s been few days…and I decided to create my very first react application. It’s that simple.
There are many posts on the web talking about Why react is popular?, two posts I actually like are, this one and this one.
One thing I like about react is its…
Simplicity
Checkout my first react application on Github and let me know what you think!.
I have started another react application called billing to learn more or practise. But I suppose its going to take me some time to finish this application given that I only spend like few hours in a week on side projects on Github.