Skip to content

Instantly share code, notes, and snippets.

View tcelestino's full-sized avatar
⛱️
Working from home

Tiago Celestino tcelestino

⛱️
Working from home
View GitHub Profile

Cloudflare DNS

  • Serviço padrão:
    • DNS primário: 1.1.1.1
    • DNS secundário: 1.0.0.1
  • Filtro de malware:
    • DNS primário: 1.1.1.2
    • DNS secundário: 1.0.0.2
  • Filtro de malware e conteúdo adulto:
  • DNS primário: 1.1.1.3
@tcelestino
tcelestino / reducer-without-switch.js
Last active April 26, 2020 21:06
reducer without switch statement - based on https://www.valentinog.com/blog/switch/
function reducers(state = initState, action) {
const mapping = {
[ACTION_ONE]: { ...state, token: action.payload },
[ACTION_TWO]: { ...state, error: action.payload }
};
return mapping[action.type] || state;
}
@tcelestino
tcelestino / randomString.js
Created April 18, 2020 11:57
random string
const secret = `${Math.random().toString(36).slice(2)}`;

Mirroring a repository

Open Terminal.

Create a bare clone of the repository.

$ git clone --bare https://github.com/exampleuser/old-repository.git
@tcelestino
tcelestino / anagram.js
Created July 17, 2019 22:00
solutions to code interviews
// helper function that builds the
// object to store the data
const buildCharObject = str => {
const charObj = {}
for(let char of str.replace(/[^\w]/g).toLowerCase()) {
// if the object has already a key value pair
// equal to the value being looped over,
// increase the value by 1, otherwise add
// the letter being looped over as key and 1 as its value
charObj[char] = charObj[char] + 1 || 1
@tcelestino
tcelestino / essentials-docker-commands.md
Last active June 14, 2019 19:29
Essentials Docker commands -

Essentials Docker commands

List all essentials command to use Docker. Based on https://hackernoon.com/docker-commands-the-ultimate-cheat-sheet-994ac78e2888

Running Docker

  • docker start [container]: Start a particular container.
  • docker stop [container]: Stop a particular container.
  • docker exec -ti [container] [command]: Run a shell command inside a particular container.
  • docker run -ti — image [image] [container] [command]: Create and start a container at the same time, and then run a command inside it.
@tcelestino
tcelestino / delete-files-netstorage.js
Created June 3, 2019 21:31
remove files in images directory at Akamai NetStorage
const deleteImagesFolder = () => {
ns.dir('/cpCode/front-app-home/images', (error, res, body) => {
if (error) {
throw new Error(`Error, ${error.message}`);
}
if (body.stat !== undefined) {
const { file: files } = body.stat;
files.forEach(file => {
@tcelestino
tcelestino / docker-clean.sh
Created May 20, 2019 21:24
alias to docker clean out
# docker
alias dockercleand='docker rmi $(docker images -q)' #delete all images
alias dockercleanu='docker rmi $(docker images -q -f dangling=true)' # delete all untagged images
alias dockercleans='docker rm $(docker ps -a -q)' #delete all stopped images
@tcelestino
tcelestino / sanitize.js
Created May 14, 2019 14:41
remove accents, switch white-space from hifen and transform string in lowercase
const sanitize = str => str.normalize('NFD').replace(/[\u0300-\u036f]/g, '').replace(' ', '-').toLowerCase();
@tcelestino
tcelestino / dark-mode-css.css
Created May 3, 2019 12:52
dark mode website with CSS
@media (prefers-color-scheme: dark) {
body {
background: black;
color: white;
}
}