Posts

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...

Ionic ios build fails, error archive not found : Error code 65 for command: xcodebuild with args

If you are working on ionic app, and you are trying to create iOS build then usually we use the following command: ionic cordova build ios OR ionic cordova build ios --device --prod --release while creating build if you get following error: ✖ cordova build ios - failed! [ ERROR ] An error occurred while running cordova build ios (exit code 1):          error: archive not found at path '/Users/work/MyApp/platforms/ios/MyAppp.xcarchive'         ** EXPORT FAILED **         CordovaError: Promise rejected with non-error: 'Error code 65 for command: xcodebuild with args:   Then You have to use the following command: ionic cordova build ios -- --buildFlag="-UseModernBuildSystem=0" if this won't work then you can update and or create a build.json file. { "ios" : { "release" : { ..., "buildFlag" : [ ...

Mastering in Javascript | How do JavaScript closures work?

Image
How do JavaScript closures work? When I started learning some advanced concepts of JavaScript that time I got to know about closures but when tried to understand it but it was like leave me alone. Then I did some research on it but still, I was getting only theoretical concepts of closures. So I thought might be I am not alone who don't understand closures so I tried to explain it with examples. What is Closure in JavaScript? A closure is a function having access to the parent scope, even after the parent function has closed.    A closure is one way of supporting first-class functions; it is an expression that can reference variables within its scope (when it was first declared), be assigned to a variable, be passed as an argument to a function, or be returned as a function result. this is the terminology used to explain the closure but I know how hard it is to understand, so let's go by examples. Example of Closures in JavaScript function ...