- Create
UNLOGGED
table. This reduces the amount of data written to persistent storage by up to 2x. - Set
WITH (autovacuum_enabled=false)
on the table. This saves CPU time and IO bandwidth on useless vacuuming of the table (since we neverDELETE
orUPDATE
the table). - Insert rows with
COPY FROM STDIN
. This is the fastest possible approach to insert rows into table. - Minimize the number of indexes in the table, since they slow down inserts. Usually an index
on
time timestamp with time zone
is enough. - Add
synchronous_commit = off
topostgresql.conf
. - Use table inheritance for fast removal of old data:
This file contains 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
/** | |
* Theory: | |
-Classes use prototype-based inheritance | |
*/ | |
/** | |
* Relevant Examples | |
*/ |
This file contains 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
/** | |
* Theory: | |
-Arrays in JavaScript are an ordered collection of values | |
-Its elements are untyped, an array can contain different types of data | |
-Arrays are 32-bit indexed so its index can be from 0-4294967294 (2^32 - 2) | |
and its elements can go from 0 to 4.294.967.295 | |
*/ | |
/** | |
* Relevant Examples |
This file contains 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
const handsomeArray = [ | |
"Option1", | |
"Option2", | |
"Option3", | |
"Option4", | |
"Option5", | |
"Option6" | |
] | |
function * generatorFunction(array) { // Line 1 |
This file contains 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
/** | |
* When we do a freeze to an object, we only can read their items. | |
*/ | |
const obj = { | |
prop: 42 | |
}; | |
Object.freeze(obj); | |
obj.prop = 55; |
This file contains 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
/** | |
* Explanation with an interview example from real life | |
* Call invokes the function and allows you to pass in arguments one by one. | |
* Apply invokes the function and allows you to pass in arguments as an array. | |
* Bind returns a new function, allowing you to pass in a this array and any number of arguments. | |
**/ | |
// Call - Example | |
const callSomeone = (name, callback) => { | |
const innerMessage= { |
This file contains 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
// This validation is correct, because is not undefined neither zero | |
if(42){ | |
// Here we have a comparison without types (===) so, JS sees both as equals | |
if(42 == "42"){ | |
// Correct | |
if(true){ | |
// This have no sense, because the callstack see the first item that is an integer, and can't compare | |
// the boolean as a number | |
if(42 == true){ | |
console.log("continue") |
This file contains 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
FROM php:5.6-apache | |
RUN apt-get update | |
RUN apt-get install -y apt-utils | |
RUN apt-get install -y libpq-dev | |
RUN apt-get install -y mcrypt libmcrypt-dev | |
RUN apt-get install -y zlib1g-dev | |
RUN docker-php-ext-install pdo_pgsql pgsql mcrypt zip | |
RUN apt-get install nano |
This file contains 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
FROM nginx:alpine | |
RUN apk add --update npm | |
COPY nginx.conf /etc/nginx/conf.d/default.conf | |
COPY . /usr/local/app/ | |
WORKDIR /usr/local/app/ | |
RUN npm install |
This file contains 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
/* Method to exclude items in a json, filtering by key index */ | |
const excludeItemsInJson = | |
(jsonObject: any, filterParams: ReadonlyArray<string>) = | |
Object.keys(jsonObject) | |
.filter((key: string) => filterParams.includes(key) ? false : true) | |
.reduce((obj, item) => ({...obj, [item]: test[item]}) ,{}) | |
/* Method to allow items in a json, filtering by key index. | |
Then a json will be returned with all the allowed items | |
*/ |
NewerOlder