This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function shuffleArray(array) { | |
var m = array.length, t, i; | |
while (m) { | |
i = Math.floor(Math.random() * m--); | |
t = array[m]; | |
array[m] = array[i]; | |
array[i] = t; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// state: | |
const state = { | |
todos: [{ | |
text: 'Eat food', | |
completed: true | |
}, { | |
text: 'Exercise', | |
completed: false | |
}], | |
visibilityFilter: 'SHOW_COMPLETED' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* HELPER CLASSES */ | |
.d-flex { | |
display: flex; | |
} | |
.d-col { | |
flex-direction: column; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function asyncCall(url) { | |
return fetch(url) | |
.then(response => response.json()) | |
.then(responseJson => { | |
return responseJson; | |
}) | |
.catch(error => { | |
throw error; | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$font-h: "Raleway", sans-serif; | |
$font-p: "Open Sans", sans-serif; | |
$hue-primary: 151.9; | |
$hue-secondary: 19.4; | |
$primary: hsl($hue-primary, 86%, 36.5%); | |
$primary-light: hsl($hue-primary, 47.7%, 58%); | |
$primary-xlight: hsl($hue-primary, 51.7%, 82.9%); | |
$primary-dark: hsl($hue-primary, 97.8%, 17.5%); | |
$secondary: hsl($hue-secondary, 100%, 48%); | |
$secondary-light: hsl($hue-secondary, 100%, 69.6%); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": "01", | |
"title": "React ecommerce template", | |
"description": "3 page ecommerce site including home page, detail page and shopping cart. Shopping cart and price dynamically populated. Product data are fetched from external API (https://ghibliapi.herokuapp.com/). Project done with React and Redux.", | |
"img": "ecommerce-template-thumbnail.jpg" | |
}, | |
{ | |
"id": "02", | |
"title": "Heatmap d3 plot", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I never remember what properties define the size of element, window and page. Let this serve as a quick reference. | |
// For detailed info look at: http://javascript.info/size-and-scroll and http://javascript.info/size-and-scroll-window | |
// DOM ELEMENTS | |
// OFFSET: size of the element WITH padding, border and scrollbar | |
// CLIENT: size of the element WITHOUT padding, border or scrollbar | |
// SCROLL: equivalent to SCROLL but including also scrolled out (not visible) area | |
// TOP/LEFT propeties: the width of the space outside the sizing boundary and the next sizing boundary | |
// ELEM SIZES |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Status codes reference: https://www.restapitutorial.com/httpstatuscodes.html | |
// Use something like this when fetching from an external resource, to process the response | |
const checkStatusCode = response => { | |
if (response.status >= 200 && response.status < 400) { | |
return response; | |
} | |
if (response.status === 401) { | |
throw new Error('Unauthorized to use the api!'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Middlewares created while learning nodejs/express | |
const express = require('express'); | |
const fs = require('fs'); | |
const path = require('path'); | |
require('dotenv').config(); | |
const app = express(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge" /> | |
<title>Document</title> | |
<style> | |
.flex-container { | |
padding: 0; |
OlderNewer