Skip to content

Instantly share code, notes, and snippets.

Avatar

Fernando Daciuk fdaciuk

View GitHub Profile
View Configuração do ReScript.md

Configuração do ReScript

bsconfig.json:

{
  "name": "my-rescript-app",
  "reason": { "react-jsx": 3 },
  "sources": [
    {
@fdaciuk
fdaciuk / How to use async await without try-catch block.md
Last active Apr 14, 2021
How to use async/await without try/catch block
View How to use async await without try-catch block.md

How to use async/await without try/catch block

We can use something like this:

async function resolveToNumber () {
  const promise = Promise.resolve(1)
  const [error, result] = await to(promise)
  console.log(error, result) // [null, 1] -> Here we have the result, and error will be null
}
@fdaciuk
fdaciuk / MongoDB provider para AdonisJS (v4).md
Last active Dec 27, 2020
MongoDB provider para AdonisJS (v4)
View MongoDB provider para AdonisJS (v4).md

MongoDB provider para AdonisJS (v4)

Os exemplos abaixo utilizam o Yarn para instalação das dependências, mas se você preferir, pode usar o NPM sem problemas :)

  • Instale o driver do mongo no seu projeto:
yarn add --exact mongodb
@fdaciuk
fdaciuk / sorteio-github.js
Last active Dec 20, 2020
Sorteio GitHub (Discussions)
View sorteio-github.js
/*
Enquanto o GitHub não libera a API da nova feature de Discussions, vamos fazer o sorteio pelo console mesmo!
Para fazer o sorteio é bem simples:
1. abra a Discussão que você quer fazer o sorteio;
2. cole o código abaixo no seu console;
3. Digite no console `sortear()`.
Obs.: Somente comentários únicos serão contabilizados. Respostas à comentários serão ignoradas.
*/
@fdaciuk
fdaciuk / gnome-terminal-profiles.md
Last active Jul 25, 2020 — forked from reavon/gnome-terminal-profiles.adoc
Export / Import Gnome Terminal Profiles
View gnome-terminal-profiles.md

Export Gnome Terminal Profile

List profiles

dconf dump /org/gnome/terminal/legacy/profiles:/

Determine the terminal profile string for the profile you will need. This is the terminal profile that I will export:

@fdaciuk
fdaciuk / app.js
Created Oct 10, 2018
React: setState onBlur
View app.js
import React from 'react'
class App extends React.Component {
state = { cep: '' }
handleBlur = (e) => {
this.setState({ cep: e.target.value })
}
render () {
@fdaciuk
fdaciuk / Create Reducer.md
Created Sep 17, 2017
Less boilerplate when create a new reducer on Redux
View Create Reducer.md

Create Reducer

Less boilerplate when create a new reducer on Redux

Method:

'use strict'

const createReducer = (initialState, actionHandlers) => {
View load-async.js
'use strict'
import React, { PureComponent } from 'react'
import t from 'prop-types'
const loadAsync = (promise) => {
class Async extends PureComponent {
constructor () {
super()
this.state = {