Posts

Showing posts with the label node

Complete Reactive Form Angular

Image
  In this tutorial we going to learn how to use angular reactive form in our angular application  reactive form is really amazing and has many feature and good code maintains approach and increase development work fast. How to import angular reactive form in our application  1. In app.module.ts file import reactive module in imports array of ngModule decorator. this will me reactive module available to your project if you have modular approach then import this on module level of specific feature Let's start create and example and start using reactive form  In this example we will coverup all necessary input fields in a web form and validations - input  - checkbox Demo Import the Reactive forms Module in angular app.module.ts import   {   ReactiveFormsModule   }   from   '@angular/forms' ; @ NgModule ( {    imports :  [      ReactiveFormsModule   ] , } ) export   class   AppModule ...

Here is a guide on how to perform a multipart upload of a file to AWS S3

This tutorial will guide you through using the AWS SDK to perform multipart uploads of large files in Node.js. While the tutorial focuses on Node.js, you can apply the same principles to perform multipart uploads in JavaScript on the frontend.   Prerequisite   - AWS SDK   - Nodejs Step 1: Setup the project     Before we begin, let's make sure you have a Node.js project set up. If you don't already have a Node.js project, you can create one by running the npm init command and following the prompts. npm init Step 2: Install the package     To get started, you'll need to install the AWS SDK. You can do this by running the following command in your terminal: npm   install   aws-sdk This will install the necessary package for interacting with AWS services in your project." Before we dive into the details of performing a multipart upload, let's discuss the overall approach and the three methods we'll be using to upload the file in chunks ...

Get Time Stamp from datetime - javascript

Image
This code return a datetime stamp string, can be used to file name to make it differnet to avoid override of file. function   timeStamp () {      var   date  =  new   Date ();      var   year  =  date . getFullYear ();      var   month  =  date . getMonth () +  1 ;       var   day  =  date . getDate ();      var   hour  =  date . getHours ();      var   minutes  =  date . getMinutes ();      var   secconds  =  date . getSeconds ()      var   formatted  =  month  +  ''  +  day  +  ''  +  year  +  ''  +  hour  +  ''  +  minutes  +  ''  +  secconds ;     ...

format time 12 to 24 hours - javascript

Image
This code will return 24 hours time format form 12 hours function   format12to24 ( time ) {      var   t  =  time ;      if  (! t ) {  return   null ; }      var   arr  =  t . split ( ":" );      var   h  =  parseInt ( arr [ 0 ]);      if  ( t . includes ( "pm" )) {          var   nH  =  h  !=  12  ?  h  +  12  :  h ;          var   t  =  t . replace ( h ,  nH );     }      else  {          var   nH  =  h  !=  12  ?  h  :  h  -  12 ;          var   t ...

complex filter with some method to filter out nested object data.

Image
This is example of complex filter with some method to filter out nested object data.   let   a  = [{  name :   'hugh'  }, {  name :   'wyne'  }, {  name :   'tony'  }]; let   a1  = [{  name :   'john'  }, {  name :   'stark'  }, {  name :   'god'  }]; let   a2  = [{  name :   'tony'  }, {  name :   'stark'  }, {  name :   'wyne'  }]; let   b  = [{  bname :   'bname' ,  a :   a  }, {  bname :   'bname' ,  a :   a1  }, {  bname :   'bname' ,  a :   a2  }]; let   r2  =  b . filter ( x   =>   x . a . some ( g   =>  {      console . log ( 'some' ,  g . name  ===  'hugh' );    ...

Get extension of a file

Image
This code return extension of a file , just pass the file name with extension and then it use the array pop method to extract the extension from file name. example:  extension ( "myvideo.mp4" ) output : mp4 function   extension ( filename ) {      let   ex  = (  filename  &&  filename . split ( '.' ). pop ());      console . log ( ex );     return ex; } This one is very useful when your code requirement is to get extension of file. There's lots of approach to achieve the same result some programming language has predefined methods for the same. But this will help us to think ourselves and create the approach for our code problem. So here is an approach for this Approach 1. Create a method return extension of file. We using argument to be passed in the method that is filename which is string type. 2. There is lots methods available with string type variable to we going ...

Calculate one hour addition to start date time for end date time

Image
     Calculate 1 hour form a date , application of this code where we want to set one hour from start date for calculation of end date . for example :             we have a case where we want to set start date for an event so the start date is = 11:10 am then this code calculate one end date which will be 12:10 pm you can use  dateTimeC  or  dateTimeC2  both has same result .    function   dateTimeC ( date ) {          var   hours  =  date . getHours ();          var   hours  = ( hours  +  24 ) %  24 ;          var   mid  =  'AM' ;          if  ( hours  ==  0 ) {              hou...