General Flashcards

1
Q

What happens when you type an URL in the browser and press enter?

A

1) enter the url/ search query

2) browser checks the cache for a DNS (domain name system) record to find a corresponding IP address for the search query
- first checks browser cache (repo of DNS records within a certain duration)
- second checks OS cache. Browser makes a system call to the OS since it also maintains a record.
- third it checks the router cache
- fourth it checks the ISP cache which has its own DNS server..
* * caches are important for regulating network traffic and improving data transfer times that is why there are so damn many.

3) If not cached, the ISP’s DNS server initiates a DNS query (ISP’s DNS server is called a “DNS recursor” in this case) to find the IP address of the server that hosts the searched URL.
- this is called a recursive search that goes from one DNS server to another until it finds the IP address for the URL. Or returns an error from timeout.
- the searched servers are called “named servers”

**For maps.google.com, first, the DNS recursor will contact the root name server. The root name server will redirect it to .com domain name server. .com name server will redirect it to google.com name server. google.com name server will find the matching IP address for maps.google.com in its’ DNS records and return it to your DNS recursor which will send it back to your browser.

  1. Browser initiates a TCP connection with the server.
    Connections are made on the internet with internet protocols. TCP (Transmission control protocol aka TCP/IP) is the most common protocol used for any type of HTTP request.
  2. Browser sends HTTP request to server
    Starting with GET request.
  3. Server handles request and returns a response.
    Server has a web server which processes the request from the browser by passing to request handler. The request handler is written in Ruby (rails) or something. It returns a response in JSON or something. (Can this be considered an API?)
  4. Server sends out an HTTP response.
    Formatted as http response with payload of specified format (usually JSON or HTML)
    **Sends with a HTML status code
  5. Browser displays HTML content
    Does this for response payload of HTML format…
    - First bare bone HTML Skeleton.
    - tags may identify additional get requests to complete information. ( such as images, CSS stylesheets, JavaScript files etc)
    - Such files are cached by the browser for future easy loading.
  6. DONE!

reference:
https://medium.com/@maneesha.wijesinghe1/what-happens-when-you-type-an-url-in-the-browser-and-press-enter-bb0aa2449c1a

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

DNS

A

DNS (Domain Name System)

It’s like a phonebook!

The URLs are for human convenience since remembering an IP would suck.

Database that maintains the name of a website (URL) and corresponding IP address for it.

The IP Address belongs to the computer that hosts the server of the website.

4 levels of domain architecture:

  • root domain: “.”
  • top-level domains: edu, org, gov, com, au
  • second-level domains: expedia.gov, google.com… etc
  • third-level: www…, download.microsoft.com, sales.website…

reference:
https://webhostinggeeks.com/guides/dns/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

TCP

A

TCP = Transmission control protocol aka TCP/IP

In order to transfer data packets between your computer(client) and the server, it is important to have a TCP connection established. This connection is established using a process called the TCP/IP three-way handshake. This is a three step process where the client and the server exchange SYN(synchronize) and ACK(acknowledge) messages to establish a connection.

  1. Client machine sends a SYN packet to the server over the internet asking if it is open for new connections.
  2. If the server has open ports that can accept and initiate new connections, it’ll respond with an ACKnowledgment of the SYN packet using a SYN/ACK packet.
  3. The client will receive the SYN/ACK packet from the server and will acknowledge it by sending an ACK packet.

Then a TCP connection is established for data transmission!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

HTTP request/response cycle

A

Request header contains request type (GET, POST, DELETE, PUT etc)

Response contains status code in header
1xx Iinformational
2xx success
3xx redirects
4xx request error/ client errors
5xx server error
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

RESTful routes

A

REST apis are a design pattern that allows for easy, standardized data manipulation.

RESTapis are a convention for the internet.

They are defined by having a standard mapping between HTTP verbs and controller (from MVC architecture) CRUD actions (Create, Read, Update, Delete).

This adds an additional classification layer for requests on top of the URL contents based on the HTTP verb.

This means an API can take specific action solely based on the request (verb) type and payload.

BROWSER CAVEAT
Browsers behave a little strange as it relates to PUT, PATCH and DELETE requests, in that they don’t know how to send those requests. Forms that delete and edit need to be submitted via POST requests.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

https vs http

A

hypertext transfer protocol (+ secure)

Allows communication between systems (like server to browser)

http is not encrypted and can be intercepted.

https uses and SSL certificate (Secure Socket Layer) that creates a secure encrypted connection between the server and browser.

to switch over you need to purchase a SSL certificate and dedicated IP address from your hosting company.
+ more steps to install…

reference:
https: //www.entrepreneur.com/article/281633

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Federated data

A

Federated data is is aggregated from disparate sources. usually for the purpose of serving some business logic calculation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Static Typing

A

Static typed variables need to be defined before use. Languages like C++ where you need to declare the variables before use. (Type of variable is known at compile time)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Dynamic Typing

A

Variables do not need to be declared. Typing is assumed based on what you equate the variable to.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Closure

A

A closure is a way of accessing a variable outside its scope.

A closure is a function that encloses its surrounding state by referencing fields external to its body. The enclosed state remains across invocations of the closure.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is bootstrapping?

A

Bootstrapping refers to loading/doing something at the start of an application or upon startup of a device.

Upon start of your app, you can check if you have a pre-loaded user. This is how you “bootstrap the user”.

ex:
(from project_name.jsx)

document.addEventListener('DOMContentLoaded', () => {
  const root = document.getElementById('root');
  let store;
  if (window.currentUser) {
    const preloadedState = { session: {currentUser: window.currentUser}};
    store = configureStore(preloadedState);
  } else {
    store = configureStore();
  }
ReactDOM.render(, root);
});

and also:
(from root.html.erb)

  <% if logged_in? %>
    window.currentUser = <%=
      render(
        "api/users/user.json.jbuilder",
        user: current_user
      ).html_safe
    %>
  <% end %>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is unit testing (in classical terms)? What is the primary technique when writing a test?

A

Unit testing, simply put, is testing methods – the smallest unit in object-oriented programming. Strong candidates will argue that it allows a developer to flesh out their API before it’s consumed by other systems in the application.

The primary way to achieve this is to “assert” that the actual result of the method matches an expected result.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Reverse Polish notation

A

aka RPN. Reads right to left.

takes last operator and next two numbers. if next two items are not numbers it will move on to the last operator of the next set of operators and so on…

example:
((15 ÷ (7 − (1 + 1))) × 3) − (2 + (1 + 1)) can be written like this in reverse Polish notation:

15 7 1 1 + − ÷ 3 × 2 1 1 + + −

source:
https: //en.wikipedia.org/wiki/Reverse_Polish_notation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a Heap and how does Heapsort work?

A

insert (like push) (heapify up) O(logn) because tree breadth doubles at each level (logn is the tree height)

Commonly called a priority queue as well.

Binary tree with the following methods:
#peek (check min/max depending on heap type) (check head) O(1)

Rules:

1) Heaps need to “complete”. Fill in order. Does not necessarily need to be “Full”.
2) Each node must be >= it’s parent. (heap property for min heap)

Heapsort pops (extracts the head) the length of the array times. (can either be popped off and stored in new result array or added on and done in place by running heapify on shrinking index size)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Find children in binary tree! Or parent

A

When a tree is stored as an array.

(2 * index ) + 1 and (2 * index ) + 2
Left and right children

Child to parent
(index - 1 ) / 2 (must floor)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do priority queues use heaps?

A

When a new item is added to the heap the object is sorted by value by means of the heapify method. This ensures proper priority in the array!

17
Q

What is 3-tier architechture

A

It is a client-server architecture that subdivides concerns into 3 “layers”.

1) A Presentation Layer that sends content to browsers in the form of HTML/JS/CSS. This might leverage frameworks like React, Angular, Ember, Aurora, etc.
2) An Application Layer that uses an application server and processes the business logic for the application. This might be written in C#, Java, C++, Python, Ruby, etc.
3) A Data Layer which is a database management system that provides access to application data. This could be MSSQL, MySQL, Oracle, or PostgreSQL, Mongo, etc.

18
Q

Polymorphism (general, non-ruby)

A

Object oriented programming (result inheritance)

ex: animal class -> cat
cat inherits animal methods, but has it’s own methods and can be interpreted separately.

Add(1, 2)); (* Prints “3” )
Add(‘Hello, ‘, ‘World!’)); (
Prints “Hello, World!” *)

19
Q

API surface

A

Number of methods in a framework/paradigm.

ex:
React has a small api surface. Not a ton of methods so it’s easy to learn!