Posts

macOS unrar file using terminal

Image
Hello Guys, Whenever you download some .rar file on your mac & you want to unzip/unrar it, macOS doesn't have a default unrar, so let's check how to do this. macOS unrar file using terminal Prerequisite: Homebrew installed on your macOS. Now we are ready to install the required software on our macOS, just run following command to install unrar tool. brew install unrar You can check whether its installed or not by running following command: $ unrar so it will print all available commands with it. now let's take an example you want to unrar file names MyApp.rar so following command will help you to unrar it. $ unrar x MyApp.rar It will create a new folder with MyApp name & also with all files & folders inside it. so this way it will unrar the file using the terminal.  I hope now can you can install & run above commands to unr...

JavaScript find max value in an array | find max value in array object

Image
Find the max or min value from an array or an object As JavaScript Developer we usually need to work on arrays & array objects and sometimes we need to do some operations on arrays like searching, sorting, find min/max etc. So today's post we will see how to find max or min value from an array. So let's take an example of the following array. let arr = [21,32,43,34,42,5,6,2,43,23]; If we want to find the maximum value from the array, so code will be as follows: Math.max(…arr); If we print it then the output will be as follows: So this will provide the maximum value from the array element. ProTip: If you are not aware of ... the operator then just inline explanation is that this is Destructuring mechanism for an array so it provides values in the destructed format. If we want to find the minimum value from the array, so code will be as follows: Math.min(…arr); So this will provide the minimum value from the array element. If we print it then the output will be as follows: ...

Install Python 3 on Mac

Image
Install Python 3 on Mac In this tutorial, we are going to install python3 in Mac OS. There are multiple ways to install like downloading from the official site  or homebrew . Check whether python2 installed or not Initially, MacOS came preinstalled with Python 2, however, starting with Mac 10.15 this is no longer the case. And since Python 2 will no longer be officially supported as of January 1, 2020, you  should really use Python 3 instead . Check whether python3 already installed or not: Before we start, make sure Python 3 isn’t already installed on your computer. Open up the command line via the Terminal application which is located at Applications -> Utilities -> Terminal. $ python --version Python version Xcode Installation: The first step for Python 3 is to put in Apple’s Xcode program which is important for iOS improvement as nicely as most programming tasks. We will use XCode to put in Homebrew. In your Terminal app,...

JavaScript check string contains in string or not using search() method

Image
JS find string contains in string If you want to check whether substring present or not in javascript then following are methods you can use: JavaScript Search() method to check whether the string contains substring is there or not const str = "this is main string to check" ; const subStr = "main string" ; if (str.search(subStr)) { console.log( ` ${ subStr } string is present in ${ str } ` ); } else { console.log( ` ${ subStr } string is not present in ${ str } ` ); } The Output will be as follows: Definition of Search() method The search() method searches a string for a specified value and returns the position of the match . Search()  method returns -1 if no match is found . We can search on a string or on a regular expression. It will return the first occurrence of the specified value. I will post more method in upcoming posts which I will link over there so you can check it. Thanks.

tilde (~) and a caret (^) in a npm package.json file

Image
What is tilde (~) and a caret (^) in an npm package.json file? If you are using npm to manage your app, then you know that we will use package.json for managing dependencies. sample package.json file So as we can see in the above sample package.json file we have some dependencies & dev dependencies as well, now let's go close to dependencies and try to understand the meaning of tilde & caret symbols. { "devDependencies": { "@angular/common": "5.0.0", "cordova-plugin-splashscreen": "^5.0.3", }, "devDependencies": { "@ionic/app-scripts": "3.2.4", "@types/chart.js": "^2.7.37", "typescript": "~2.6.2" } } As we can see above JSON from the package.json file,  key is the name of the package and the value is the version of the package to be used. The version number is in semver syntax which designates each s...

Javascript detect connection speed

Image
JavaScript detect connection speed Ever feel like your internet is running slow? Webpages seem sluggish while uploads and downloads take forever! It's very frustrating, especially when you pay for high-speed internet. As a developer, we need to find the current speed and load the pages accordingly. So if you want to get the connection speed in JS you can use the  Navigator.connection  object. Let's take an example: navigator.connection.addEventListener( 'change' , () => { let currRtt = navigator.connection.rtt; let effType = navigator.connection.effectiveType; console.log( 'current connections' , currRtt, effType) }) so the above example will trigger an event whenever there will be some changes in the network. So let's test it by changing the network connections. As you can see in logs whenever I changed the network type from network tab events gets fired and it printed the current connections types. Javascript detect...

Remove property from Javascript Object

Image
How to remove property from a JavaScript object If you want to remove property from a JavaScript object then you can do by following ways. Remove JavaScript Object Property lets create one object so we can run and test it. var user = { "id": "1001", "name": "Vikas", "email": "test@test.com", "password": "TesTP2ss", "createdAt": "20-08-2019" }; The  will be as follows: Now we can remove the object property from the following ways: Using delete operator: as we have seen the user's object now before sending to frontend we will delete the password property and then we will send it. delete user.password; >>true Or alternatively, you can do the following way as well. delete user['password']; >>true If delete won't work then you can use the following: user . password = undefined ; Please le...