Skip to content

Instantly share code, notes, and snippets.

View marcogbarcellos's full-sized avatar

Marco Barcellos marcogbarcellos

  • Toronto
View GitHub Profile
  • browser looks for the DNS cache
  • browser ask the OS to find the ip
  • OS makes a DNS lookup to find the ip and gives to the browser * Looks for the closest DNS Server to find the IP, if it's not there the DNS Server looks for another DNS Server until finds it
  • OS caches the IP
  • browser opens a tcp connection( If it's HTTPS this step is waay more complicated)
  • browser sends an http request
  • browser receives an http response and may close the connection or reuse for more requests.
  • browser checks what kind of response se he receives: 3xx redirect or conditional, 401 authorization required, 4xx and 5xx errors or 2xx "good" responses
  • If cacheable, browser caches response
@marcogbarcellos
marcogbarcellos / LinkedList.js
Created February 8, 2017 03:52
Linked List Operations on javascript
function Node(value){
this.value = value;
this.next = null;
}
function LinkedList() {
this.start = null;
this.length = 0;
}
LinkedList.prototype.push = function (val) {
@marcogbarcellos
marcogbarcellos / fibonnacci.js
Created February 7, 2017 17:03
Returns the value of the Nth value of the fibonnacci sequence.
function fibonnacci(n) {
if (n === 0) {
return 0;
}
else if (n === 1) {
return 1;
}
else {
return fibonnacci(n-1)+fibonnacci(n-2);
}
@marcogbarcellos
marcogbarcellos / nextSmallestButLargerPalindrome.js
Last active February 11, 2017 03:47
Given a number, find the next palindrome on which this next palindrome is larger than the given number.
//We can check that the Recursive Version of Palindrome is way faster...
function palindromeRecursive(n) {
var nArr = n.split('');
if(nArr.length <= 1) {
return true;
}
else {
if(nArr[0] === nArr[nArr.length-1]){
return palindromeRecursive(n.slice(1, nArr.length-1));
} else {
@marcogbarcellos
marcogbarcellos / BinarySearchTree.js
Last active February 14, 2021 19:55
Creating, manipulating and calculating distance between nodes inside a Binary Search Tree
function Node(value){
this.value = value;
this.left = null;
this.right = null;
}
function BinarySearchTree() {
this.root = null;
}
BinarySearchTree.prototype.push = function (val) {