Saturday, February 15, 2020

BlogPost_306

  • What's the difference between operational and programmer errors?
    • Operation errors are not bugs, but problems with the system, like request timeout or hardware failure.
      On the other hand programmer errors are actual bugs.
  • What is ‘event-driven’ programming?
    • event-driven programming is a programming paradigm in which the flow of the program is determined by events such as user actions, sensor outputs, or messages from other programs or threads.
  • What are ‘worker processes?
    • The "Process" which is responsible for processing Asp.net application request and sending back response to the client , is known as "Worker Process". All ASP.NET functionalities runs within the scope of this process.
  • Explain global installation of dependencies?
    • The global installation of dependencies in Node. js refers to installing packages and their dependencies globally in your system. By global, it means they are not specific to a particular Node. js project, but they are available on the go throughout your system.
  • Explain RESTful Web Service?
    • Representational state transfer (REST) is a software architectural style that defines a set of constraints to be used for creating Web services. ... In a RESTful Web service, requests made to a resource's URI will elicit a response with a payload formatted in HTML, XML, JSON, or some other format.
    • REST is used to build Web services that are lightweight, maintainable, and scalable in nature. A service which is built on the REST architecture is called a RESTful service. The underlying protocol for REST is HTTP, which is the basic web protocol.

Sunday, February 9, 2020

BlogPost_305

  • How does Node.js handle child threads?
    • Nodejs, in its essence, is a single thread process. ... Technically, Nodejs does spawn child threads for certain tasks such as asynchronous I/O, but these run behind the scenes and do not execute any application JavaScript code, nor block the main event loop.
  • How can you listen on port 80 with Node?
    • redirect port 80 to port 3000 with this command: sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000 Then launch Node.js on port 3000. Requests to port 80 will get mapped to port 3000. You should also edit your /etc/rc.d/rc.local file and add that line minus the sudo. That will add the redirect when the machine boots up.
  • List out the differences between AngularJS and NodeJS?
    • Angular is written entirely in Javascript.
    • Node JS is written in C, C++, Javascript.
    • Angular is a single-page client side web application.
    • Node JS is a fast and scalable server side application.
    • Angular is suited for highly interactive and active web projects.
    • Node JS is best suited for small sized projects.
  • What are the advantages of NodeJS?
    • It's highly useful when scalable and faster application is required. More suited for application like real time collaborative drawing/edit like Google Docs.
  • What you mean by JSON?
    • JSON stands for JavaScript Object Notation. JSON is a lightweight format for storing and transporting data. JSON is often used when data is sent from a server to a web page.
  • Discuss your understanding of Agile so far.
    • It's a type of project management process where there's an organization implemented to be able to advance in software development in a faster, more efficient way.
  • How is scrum different from waterfall?
    • The waterfall model finishes one phase before another phase can begin. Which can lead to getting stuck. SCRUM flows using Sprints. And if something was not finished, you can just push it to the next Sprint. It's more flexible. 
  • What are the Three Amigos in Scrum?
    • The Three Amigos - normally consisting of BA, Developer, and Tester - is one of the key ways to change the culture of the team to be more Agile, and encourage more collaboration. ... The Three Amigos ensures a common understanding for a story in the team; a session between Product Owner (Business), Developer, Tester.
  • What is the “time Boxing” of a scrum process called? Describe, please.
    • Timeboxing is allotting a fixed, maximum unit of time for an activity. That unit of time is called a time box. ... Scrum uses timeboxing for all of the Scrum events and as a tool for concretely defining open-ended or ambiguous tasks.
    • Timeboxing is allotting a fixed, maximum unit of time for an activity. That unit of time is called a time box. The goal of timeboxing is to define and limit the amount of time dedicated to an activity.
  • What are the roles of a Scrum Master and Product owner?
    • The product owner and the scrum master, both have the same objective of adding value to project management. However, these two roles are defined very differently from each other. While product owner looks at the project from the customer’s perspective, scrum masters solely focuses on the team and its operations. 

Sunday, February 2, 2020

BlogPost_304

  • What is “callback hell” and how can it be avoided?
    • Also known as the pyramid of doom. If you make callback after callback it can get out of hand. 
    • The solution is to design around it. Use modules. Give your functions names. Declare your functions beforehand. Take some times to think about the structure of your code. 
  • What are ‘stubs’ in Node.js?
    • Test stubs are functions (spies) with pre-programmed behavior. They support the full test spy API in addition to methods which can be used to alter the stub's behavior. As spies, stubs can be either anonymous, or wrap existing functions.
  • What are “Streams” in Node.JS?
    • Streams are unix pipes that let you easily read data from a source and pipe it to a destination. Simply put, a stream is nothing but an EventEmitter and implements some specials methods. Depending on the methods implemented, a stream becomes Readable, Writable, or Duplex (both readable and writable).
  • What you mean by chaining in Node.JS?
    • If you meant Method Chaining, it is nothing but a syntactic sugar commonly seen in Object Oriented Languages. In chaining every method return the object, so that we can chain different calls in single line. See the below example for better understanding.
  • Explain “Console” in Node.JS?
    • The console module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers.
      The module exports two specific components:
      • Console class with methods such as console.log()console.error() and console.warn() that can be used to write to any Node.js stream.
      • A global console instance configured to write to process.stdout and process.stderr. The global console can be used without calling require('console').
  • Explain exit codes in Node.JS? List out some exit codes?
    • exit() takes an exit code (Integer) as a parameter. The code 0 is the default and this means it exit with a 'success'. While the code 1 means it exit with a 'failure'. You may use process.
  • What is the difference between Cluster and Non-Cluster Index?
    • Cluster index is a type of index that sorts the data rows in the table on their key values whereas the Non-clustered index stores the data at one location and indices at another location.
  • What are user defined function? What are all types of user defined functions?
    • There can be 4 different types of user-defined functions, they are: Function with no arguments and no return value. Function with no arguments and a return value. Function with arguments and no return value. Function with arguments and a return value.

Wednesday, January 22, 2020

BlogPost_303

  • If a user attempts to create a resource that already exists—for example, an email address that’s already registered—what HTTP status code would you return?
    • 409. The HTTP 409 Conflict response status code indicates a request conflict with current state of the server. ... For example, you may get a 409 response when uploading a file which is older than the one already on the server resulting in a version control conflict.
  • Consider a responsive site design that requires a full-width image in all responsive states. What would be the correct way to code this to ensure the page loads the smallest image required to fill the space?
    • Have a set of sizes available on your server (say 350px, 700px, 1000px, 1500px, 2000px, 4000px) and use srcset attribute of image tag. Your browser will automatically load the best one. 
    • If you need find grained control over what screen size loads what, you can also use media queries in CSS and put image in background of a full length placeholder div instead of using an img ray
  • When should you npm and when yarn?
    • Yarn when you want to want to lock dependencies to their specific versions. Yarn has the power to perform multiple installation steps at once, which speeds up the process. Npm goes sequencially. Yarn is normally faster to install. Yarn only installs dependencies from your yarn.lock so it's considered more secure. Since Yarn is supported by some of the world's largest tech companies, bugs are identified and taken care of fairly quickly. Using npm and yarn together can create some problems. Yarn is slowly overtaking npm. 
  • How can you make sure your dependencies are safe?
    • When writing Node.js applications, ending up with hundreds or even thousands of dependencies can easily happen. For example, if you depend on Express, you depend on 27 other modules directly, and of course on those dependencies' as well, so manually checking all of them is not an option!
      The only option is to automate the update / security audit of your dependencies. For that there are free and paid options:
      • npm outdated
      • Trace by RisingStack
      • NSP
      • GreenKeeper
      • Snyk
    • First, it's important to do our homework before installing a package.
      Read the package's page on npmjs.com and look at who published the package, the number of versions and the number of weekly downloads. If these numbers are very low, I would pass or definitely inspect the source code.
      Another thing, to pay attention is when you type the package name. Typo squatting is possible and there are published packages which have names close to popular packages.
      In terms of how secure is NPM (the registry), they do periodic penetration testing and outgoing code reviews. Also, they report vulnerabilities to package authors and handle vulnerabilities reports from other users. But, it's a continuous fight against spammers, malware, etc.
  • What are the differences between CHAR and VARCHAR data types? (MySQL)
    • A CHAR field is a fixed length, and VARCHAR is a variable length field.
      This means that the storage requirements are different - a CHAR always takes the same amount of space regardless of what you store, whereas the storage requirements for a VARCHAR vary depending on the specific string stored.
  • How else can the JavaScript code below be written using Node.Js to produce the same output?
    • console.log("first");
      setTimeout(function() {
          console.log("second");
      }, 0);
      console.log("third");
      
      // Output:
      
      // first
      // third
      // second
    • console.log("first");
      setImmediate(function(){
          console.log("second");
      });
      console.log("third");

Sunday, January 19, 2020

BlogPost_302

  • What do you find challenging about coding?
    • Keeping track, mentally, of where everything is. It starts to get a bit overwhelming when you have a few projects open and you want to keep track of where everything is. Then whenever you make a change, since something you code can be super long, its not easy to know immediately every part that's being affected by your new change. That is frustrating because if you have been making changes and saving your file... at some point you can get lost in a tangle web of bad choices that you thought were good choices to make your code better but now you can't even go back to where your code worked. So I find it challenging to keep track, mentally, of where everything is and what parts of the code are being affected by any new change made.
  • Talk about a project that disappointed you. What would you change?
    • I think this project about the databases disappointed me. The ExpressJS continuation. I wanted to finish it by Sunday and had tutoring scheduled for Saturday but my tutor cancelled me last minute because he said he was sick with the flu. I attempted to do the thing myself and was able to complete up until the beginning of part 3. 
    • I would not use part 3 of the project. I feel it is an extra layer of complication that's not necessary. Maybe I don't understand it fully but I just don't get why the functions have to be recoded in the controller files if they already work fine in the first place. I'm disappointed in seeing all those confusing rearrangements.
    • If I were an expressjs coder I would code a script to autogenerate the routes and controller files and move the code that needs to be moved and generate the code that needs to be generated. 
  • List three key things to consider when coding with SEO in mind.
    • Metatags for the search crawler to be able to find you.
    • The HTML Accessibility.
    • Links
    • Page loading speed
    • Secure SSL website
  • List five or more ways you could optimize a website to be as efficient and scalable as possible.
    • Have the website's separated from the server code.
    • Have all your files hosted in a separate server.
    • Be able to replicate or duplicate your servers and keep the connections instantaneously.
    • Reduce the number of plugins.
    • Don't use ads.
    • Minimize the number of javascript and css files.

Friday, January 10, 2020

BlogPost_301

  • How do you organize your code? What are some suggestions you find on the web?
    • I normally just organize it in so far it is in the order I have been coding it. I leave notes above each chunk of code to know what does what. I didn´t know I could have multiple javascript files until I watched the video. I´m not sure yet how I could do that on a website without npm.
  • Can you describe your workflow when you create a web page or web app?
    • I think about what I want to do for a while. I simulate a few options in my head. If they don´t work or I can´t see how to make it I keep thinking about it. At some point I understand how to divide its parts and then just start coding the parts from the ground up. I do know about different approaches to this but i´ve been lazy to use them. Something like SCRUM and Agile.
  • You can’t work out how to solve a coding problem, where do you find the answer? Why? How do you know?
    • It depends on how difficult it is. If its something I don´t know about and it´ll take me too much time to learn and implement I tend to look for another person who actually knows about it. If it´s something that will not take too long then I research it. If research goes beyond my estimated time and there´s no progress being made... I ask for help. 
  • What problems have you solved that didn’t involve you coding?
    • I´ve solved a few problems regarding databases using the help of a friend who knows how to use them. I´m not sure. This question is too vague. I can´t think of examples off the top of my head right now. What do you mean by problems? coding problems? If it´s coding problems then asking for help usually gets the job done. Another option has been looking for YouTube videos and hoping that there´s a similar problem there where I can see a path forward. I´ve been watching the Wes Bos new javascript course and it´s helped me identify a lot of stuff on code that I had no idea what it was before. 
  • Talk about your preferred development environment. (What IDE or text editor they enjoy, and why?
    • I really like VScode because I´m already used to it. I´ve tried different editors and they usually involve the user having to do a lot more steps to get somewhere and do something. I think VScode has been created with the developer who doesn´t want to waste time in the details in mind. That´s really good. 
  • How are you keeping up with the latest developments in web development?
    • Well... being informed is one thing but actually knowing how to implement everything is another. I´m aware of different things going on but I´m not capable of implementing them. I follow different people on instagram and youtube who show news about these subjects but it´s not all something i´m really interested in enough to learn it right away. I tend to wait a bit for things to settle down in order to see if they´re really going to stay or not. Most new things disappear very quickly and it´s not worth wasting time on them(in my opinion). 

Saturday, December 21, 2019

BlogPost_208

  • Talk about something you learned this week.
We have been using the Fetching for APIs and Recursion. Pure functions and immutability.
  • Explain Function.prototype.bind()
bind is a method on the prototype of all functions in JavaScript. It allows you to create a new function from an existing function, change the new function’s this context, and provide any arguments you want the new function to be called with. The arguments provided to bind will precede any arguments that are passed to the new function when it is called.
  • Describe event bubbling.
Event bubbling and capturing are two ways of event propagation in the HTML DOM API, when an event occurs in an element inside another element, and both elements have registered a handle for that event. The event propagation mode determines in which order the elements receive the event.
With bubbling, the event is first captured and handled by the innermost element and then propagated to outer elements.
With capturing, the event is first captured by the outermost element and propagated to the inner elements.
  • What's the difference between window load event and document DOMContentLoaded event?
The DOMContentLoaded event fires when parsing of the current page is complete; the load event fires when all files have finished loading from all resources, including ads and images.
  • Describe the call-stack.
In computer science, a call stack is a stack data structure that stores information about the active subroutines of a computer program. This kind of stack is also known as an execution stack, program stack, control stack, run-time stack, or machine stack, and is often shortened to just "the stack".

Saturday, December 14, 2019

BlogPost_207

  • Write about something you learned this week.
Using APIs. I used a Pokemon API to make a website where two pokemon appear and their attack stats are compared to say which one would win.
  • Why would you use something like the load event? Does this event have disadvantages? Do you know any alternatives, and why would you use those?
The load event fires at the end of the document loading process. At this point, all of the objects in the document are in the DOM, and all the images, scripts, links and sub-frames have finished loading. To execute anything post document loadwe fire these events. One disadvantage is that it won't wait for an image to load, so you have to do something else about that. An alternative would be to use a setTimeOut. Another is DOMContentLoaded.
  • What are the advantages and disadvantages of using Ajax?

Advantages of AJAX

AJAX Concept
Before you starting AJAX you'll need to have a strong knowledge of JavaScript. AJAX is not a difficult, you can easy implement AJAX in a meaningful manner. Some IDE are help us to implement AJAX.
Speed
Reduce the server traffic in both side request. Also reducing the time consuming on both side response.
Interaction
AJAX is much responsive, whole page(small amount of) data transfer at a time.
XMLHttpRequest
XMLHttpRequest has an important role in the Ajax web development technique. XMLHttpRequest is special JavaScript object that was designed by Microsoft. XMLHttpRequest object call as a asynchronous HTTP request to the Server for transferring data both side. It's used for making requests to the non-Ajax pages.
Asynchronous calls
AJAX make asynchronous calls to a web server. This means client browsers are avoid waiting for all data arrive before start the rendering.
Form Validation
This is the biggest advantage. Form are common element in web page. Validation should be instant and properly, AJAX gives you all of that, and more.
Bandwidth Usage
No require to completely reload page again. AJAX is improve the speed and performance. Fetching data from database and storing data into database perform background without reloading page.

Disadvantages of AJAX

1. AJAX application would be a mistake because search engines would not be able to index an AJAX application.

2. Open Source: View source is allowed and anyone can view the code source written for AJAX.

3. ActiveX requests are enabled only in Internet Explorer and newer latest browser.

The last disadvantage, XMLHttpRequest object itself. For a security reason you can only use to access information from the web host that serves initial pages. If you need to fetching information from another server, it's is not possible with in the AJAX.
  • Explain how JSONP works (and how it's not really Ajax).
JSONP (acronym for JavaScript Object Notation with Padding) is a common method to retrieve data from another domain and bypass CORS (Cross Origin Resource Sharing) rules.
An overview of JSONP base on personal experience
I have used JSONP as a work around to get data by wrapping the response data in JSON format with a function callback set in query string as parameter and setting the callback as an object property of ajax object.
** Note, I was using jQuery library when implementing AJAX with JSONP
I’ve also heard of CORS as a set of rules regarding retrieving and transferring data or assets from 3rd parties or different domains from a client. This strictly applies to XMLHttpRequest for security reasons. Making HTTP Requests with XMLHTTPRequest object will only let us make request to our own domain and restricts us from different domain, thus, JSONP was created as a way to bypass this rule.

How does JSONP work?
After reading further, implementation of JSONP differ from JavaScript libraries to the actual native JavaScript. In native JavaScript, JSONP requests aren’t dispatched with XMLHttpRequest object, rather, a script tag is added to the DOM, targeting its src attribute with the url. Reason is script tag does not have limitation to which domains it can retrieve its scripts from. Also, since JavaScript has a global scope, we can reference a function to handle incoming JSON data from a 3rd party api url and link that to our application. While, in JavaScript libraries such as jQuery, it automatically generate callback and clean up any inserted script tags unto the DOM.
In order for JSON data to be wrapped in a function, the 3rd party API service needs to support JSONP feature. Usually, they will specify on their documentation how to implement JSONP. Here is an example: http://forismatic.com/en/api/
If you copy & paste the url below, this will return a simple quote formatted in JSON
http://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=json
While this url will return the same result except JSON data will be wrapped with a function since we explicitly specify format as jsonp and gave it a callback function
http://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=jsonp&jsonp=processQuote
When this loads unto our application from script tag, the given callback name (function name) will get registered unto the global scope and will be available for us to use throughout our application.
JSONP limits us with just retrieving GET data. It does not let us create, update, or delete CRUD data. That’s why its just a work around but it does have its advantages. For example, retrieving simple data from a weather api, etc. If you want to take advantage of these other HTTP methods, then its best to build your own simple API Server.
  • Explain Ajax in as much detail as possible.
AJAX = Asynchronous JavaScript and XML.
AJAX is a technique for creating fast and dynamic web pages.
AJAX allows web pages to be updated asynchronously by exchanging small amounts of data with the server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page.
Classic web pages, (which do not use AJAX) must reload the entire page if the content should change.
Examples of applications using AJAX: Google Maps, Gmail, Youtube, and Facebook tabs.
It is a technique used in order to send and retrieve data in the background without refreshing the webpage.
  • What does it mean when we talk about time complexity of an algorithm?
Time complexity is a concept in computer science that deals with the quantification of the amount of time taken by a set of code or algorithm to process or run as a function of the amount of input. In other words, time complexity is essentially efficiency, or how long a program function takes to process a given input.
  • What are the three laws of recursion algorithm?
Like the robots of Asimov, all recursive algorithms must obey three important laws: A recursive algorithm must call itself, recursively. A recursive algorithm must have a base case. A recursive algorithm must change its state and move toward the base case.
  • How do you see yourself growing as a web developer?
I'm still unsure. I don't like making websites that have only aesthetic and commercial properties. I like complex applications and i still can't code them so I still need to learn a lot more.