javascript

JavaScript: Working with Array

Posted Leave a commentPosted in JavaScript, Technology

Defining an array var arr = [1, 2];var arr1 = new Array(1,2); var arr2 = new Array(length); // This will create an array of the given length, but won’t initialize the values. The values would be empty and not undefined. Looping through Array arr.forEach((item, index, array) => {     // item => the current item     // index => index of the current item     // array => the actual array passed }); Retrieving an item from array arr[2]; // This will return 3rd element in the arrayarr[2] = arr[02] = arr[‘2′] != arr[’02’]arr.indexOf(2); // Returns the index of the item, or -1  … [Read More]

html javascript

HTML Tips

Posted Leave a commentPosted in Technology

Linking script and stylesheet in HTML <script src=”main.js”></script><link href=”style.css” rel=”stylesheet”></link> ———— New in HTML5canvas | audio | svg | header | footer | aside | article | nav | section etc… ————– CSS Reset – Removes browser default stylesNormalize.css – Sets a stndard across all browsers ———– parseInt(“20″) + 20 = 40; —– Semantic HTML – Semantic tags like header, nav, section, footer, etc are used that convey infomation about the content. ————- HTML4 vs HTML5=> HTML4 DOCTYPE declaration was too length, while in HTML5, it’s just <!DOCTYPE html>=> HTML5 has more semantic tags and also has multimedia supporting attributes=>  … [Read More]

javascript

Algorithms in JavaScript

Posted Leave a commentPosted in JavaScript, Technology

SECTION 1 – Introduction Introduction to AlgorithmsAlgorithms make programs run better and faster. SECTION 2 -FizzBuzz IntroductionA function that will take a number and log all the numbers from 1 till that given number.Additionally, if the number to be logged is divisible by 3, then log ‘Fizz’, if divisible by 5, then log ‘Buzz’ and if by both 3 & 5, then log ‘FizzBuzz’ Modulus Operator – It returns the remainder of a division. Code function fizzBuzz(num) {    for (var i = 1; i<= num; i++) {        if (i % 3 === 0 && i % 5 === 0) {  … [Read More]

javascript

Data Structures in JavaScript

Posted Leave a commentPosted in JavaScript, Learning, Technology

1. What are Data Structures and why are they ImportantData Structures are way of organizing data that is stored in a computer or database. Each type of data structure represents a different way of organizing the data.There are different types of data structures because they have different strengths and weaknesses.Some are fast at storing and slow at retrieving and some vice-versa. Importance of Data Structures:– Data structures have big impact on performance, quick and efficiently a program runs. Example, when we need to store data at a faster pace, we can use linked list. Or when we need to access  … [Read More]

javascript

Understanding the Weird Parts of JavaScript

Posted Leave a commentPosted in JavaScript, Learning, Technology

SECTION 1 – Getting Started 1 – Introduction and the Goal of the CourseThe goal is to understand how JavaScript works under the hood.2 – Setup3 – Big Words and JavaScript4 – Watching this Course in High-Definition5 – Understanding Frameworks and the Weird Parts SECTION 2 – Execution Contexts and Lexical Environments 6 – Conceptual Aside: Syntax Parsers, Execution Contexts and Lexical EnvironmentsSyntax parser – A program that reads the code and determines what it does and if it’s grammar is valid – Is done character by characterLexical Environment – Where something sits physically in the code that is writen.Execution  … [Read More]

eaddrinuse

How to resolve “EADDRINUSE: address already in use” error

Posted Leave a commentPosted in NodeJS, Technology

Mostly in development machines, we tend to leave out the node server running, and close the terminal. This keeps the node server running, and when we try to restart the application, it throws the “EADDRINUSE: address already in use” error. This can be fixed by first finding out which PID the process is using and then kill it. Please note that the following commands were run on Ubuntu 18.04 LTSFor Windows or Mac, the process remains the same, while the commands might be a little different.Will add them up when time permits. To find the PID, For me, the port that  … [Read More]

docker

Installing letsencrypt for both www and non-www domains in dokku

Posted Leave a commentPosted in Dokku, Technology

1. If the domain for the app was set on the non-www domain, then add the www domain to the app, and vice-versa. In my case, I had setup the app for the non-www domain which was accessible at http://app-url.com So had to run, dokku domains:add app-name www.app-url.com // A little confused on the above command if it is :add or :set. Need to confirm To check if the domain has been added to the list, you can run dokku domains:report // for all the apps dokku domains:report app-name // for the specific app 2. Check to make sure that  … [Read More]

dokku docker

Redirecting from one website to another in dokku

Posted Leave a commentPosted in Dokku

Step 1. Install dokku-redirect pluginGit: https://github.com/dokku/dokku-redirect dokku plugin:install https://github.com/dokku/dokku-redirect.git Step 2. Set the redirect to the new url dokku redirect:set app-name app-web-url.com app-new-web-url.com The app-new-web-url can be set to www.app-new-web-url.comWasn’t able to use the http/https protocol before the url Step 3. To redirect individual subdomains, the same procedure needs to be followed for all.In my case, I also needed to redirect all www.app-web-url.com to www.app-NEW-web-url.comSo, dokku redirect:set app-name www.app-web-url.com app-new-web-url.com Step 4. For the above to work, the www.app-web-url.com needs to be set as a domain for the app-name, which can be done by using the dokku’s default domain plugin  … [Read More]

angular params queryparams fragment

Working with Params, QueryParams and Fragments in Angular

Posted Leave a commentPosted in Angular

This post has been moved as a 3 part post with each part focussing on one item. While working with routes in angular, sometimes we might need to fetch some information from the url that shows up in the browser. Params, QueryParams and Fragments are the bits of information that can be fetched from the route url. 1. Working with Params in Angular 2. Working with QueryParams in Angular 3. Working with Fragments in Angular

angular params

Working with Params in Angular

Posted Leave a commentPosted in Angular

While working with routes in angular, sometimes we might need to fetch some information from the url that shows up in the browser. Params, QueryParams and Fragments are the bits of information that can be fetched from the route url. This is one part of the 3 part series of the subject – Working with Params, QueryParams and Fragments in Angular In this part, we are going to work with Route Params in Angular.   Params Params form the dynamic part that is available as a part of the url itself. Lets consider some dynamic route that we create in  … [Read More]