Skip to content

Instantly share code, notes, and snippets.

View lcsjunior's full-sized avatar

Luiz Carlos Jr lcsjunior

View GitHub Profile
const recursiveCall = (index) =>
new Promise((resolve) => {
console.log(index);
if (index < 3) {
return resolve(recursiveCall(++index));
} else {
return resolve();
}
})
recursiveCall(0).then(() => console.log('done'));
// Globals
unsigned long previousMillis = 0;
const long eventInterval = 5000;
// ...
// Blocking "like delay()"
unsigned long start = millis();
while (millis() - start <= eventInterval) {
// ...
}
@lcsjunior
lcsjunior / settings.json
Last active June 29, 2022 01:51
Git Bash with Visual Studio Code
{
"terminal.integrated.profiles.windows": {
"Git Bash": {
"path": "%AppData%\\Local\\Programs\\Git\\git-bash.exe"
}
},
"terminal.integrated.defaultProfile.windows": "Git Bash",
}
import React, { useReducer } from 'react';
const useForceUpdate = () => useReducer((s) => s + 1, 0);
export { useForceUpdate };
// const [forceUpdate, setForceUpdate] = useForceUpdate();
const makePromise = (condition) => {
return new Promise((resolve, reject) => {
condition
? resolve('I am surely going to get resolved!')
: reject('Something is not right!')
})
}
const int relayPin = D6;
const long interval = 2000;
void setup() {
Serial.begin(115200);
pinMode(relayPin, OUTPUT);
}
void loop() {
digitalWrite(relayPin, HIGH);
@lcsjunior
lcsjunior / fetcher.js
Last active September 16, 2022 19:32
import axios from 'axios';
const jsonify = (resp) => resp.data;
const fetcher = (url) => axios.get(url).then(jsonify);
export { jsonify, fetcher };
@lcsjunior
lcsjunior / fetcher.js
Last active September 16, 2022 19:33
const jsonify = (resp) => resp.json();
const fetcher = (url) => fetch(url).then(jsonify);
export { jsonify, fetcher };
import { useState } from 'react';
const useDisclose = (initiallyOpen = false) => {
const [isOpen, setIsOpen] = useState(initiallyOpen);
return {
isOpen,
onOpen: () => setIsOpen(true),
onClose: () => setIsOpen(false),
onToggle: () => setIsOpen((state) => !state),
};
{
"singleQuote": true,
"trailingComma": "es5",
"tabWidth": 2,
"useTabs": false,
}