Skip to content

Instantly share code, notes, and snippets.

Avatar
⛱️
Working from home

Tiago Celestino tcelestino

⛱️
Working from home
View GitHub Profile
@tcelestino
tcelestino / reading-file.yml
Last active Oct 29, 2020
using .nvmrc in node-version on gh action workflow
View reading-file.yml
# https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-output-parameter
# https://github.com/actions/setup-node/issues/32
- name: Read .nvmrc
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
id: nvm
- name: Setup node
uses: actions/setup-node@v1
with:
View center.html
<div class="parent">
<div class="child">
1 line center
</div>
</div>
View debounce.js
let timeout;
const debounce = (func, wait) => {
clearTimeout(timeout);
timeout = setTimeout(func, wait);
};
const handleInput = () => {
debounce(() => {
format();
@tcelestino
tcelestino / isEmptyArray.php
Created Sep 1, 2020
verify has array's children are empty
View isEmptyArray.php
<?php
function isntEmpty($x)
{
$key = array_keys($x)[0];
if(!empty($x[$key])) {
return $x;
}
}
View qr-code-gsheets.txt
=IMAGE(“https://chart.googleapis.com/chart?chs=200×200&cht=qr&chl=”&A2&””)
View cloudflare-dns.md

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
View reducer-without-switch.js
function reducers(state = initState, action) {
const mapping = {
[ACTION_ONE]: { ...state, token: action.payload },
[ACTION_TWO]: { ...state, error: action.payload }
};
return mapping[action.type] || state;
}
View randomString.js
const secret = `${Math.random().toString(36).slice(2)}`;
View duplicating-repo.md

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 Jul 17, 2019
solutions to code interviews
View anagram.js
// 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