Skip to content

Instantly share code, notes, and snippets.

View AndreiCalazans's full-sized avatar
🏠
Working from home

Andrei Xavier de Oliveira Calazans AndreiCalazans

🏠
Working from home
View GitHub Profile
@AndreiCalazans
AndreiCalazans / try-catch.ts
Created May 6, 2021 11:32 — forked from karlhorky/try-catch.ts
Try-catch helper for promises and async/await
export default async function tryCatch<Data>(
promise: Promise<Data>,
): Promise<{ error: Error } | { data: Data }> {
try {
return { data: await promise };
} catch (error) {
return { error };
}
}
@AndreiCalazans
AndreiCalazans / http_streaming.md
Created March 2, 2021 16:03 — forked from CMCDragonkai/http_streaming.md
HTTP Streaming (or Chunked vs Store & Forward)

HTTP Streaming (or Chunked vs Store & Forward)

The standard way of understanding the HTTP protocol is via the request reply pattern. Each HTTP transaction consists of a finitely bounded HTTP request and a finitely bounded HTTP response.

However it's also possible for both parts of an HTTP 1.1 transaction to stream their possibly infinitely bounded data. The advantages is that the sender can send data that is beyond the sender's memory limit, and the receiver can act on

@AndreiCalazans
AndreiCalazans / Description.md
Created August 5, 2020 10:55 — forked from TejasQ/Description.md
⬢ G2i NodeJS Test

⬢ G2i NodeJS Test

Messaging acronyms are everywhere now. Do you know all of them?

Build a REST API for the World Texting Foundation, also known as WTF.

A sample JSON data file will be provided with a base set of acronym definitions. We expect you to create a NodeJS server using modern best practices for API development. Please consider the recommendations attached as this will list the items we are looking for above.

@AndreiCalazans
AndreiCalazans / ddd.md
Created May 27, 2020 11:57 — forked from zsup/ddd.md
Documentation-Driven Development (DDD)

Documentation-Driven Development

The philosophy behind Documentation-Driven Development is a simple: from the perspective of a user, if a feature is not documented, then it doesn't exist, and if a feature is documented incorrectly, then it's broken.

  • Document the feature first. Figure out how you're going to describe the feature to users; if it's not documented, it doesn't exist. Documentation is the best way to define a feature in a user's eyes.
  • Whenever possible, documentation should be reviewed by users (community or Spark Elite) before any development begins.
  • Once documentation has been written, development should commence, and test-driven development is preferred.
  • Unit tests should be written that test the features as described by the documentation. If the functionality ever comes out of alignment with the documentation, tests should fail.
  • When a feature is being modified, it should be modified documentation-first.
  • When documentation is modified, so should be the tests.
@AndreiCalazans
AndreiCalazans / babel.config.js
Last active April 27, 2020 11:26 — forked from jgcmarins/babel.config.js
Webpack configs for Node.js backends to run both locally and on AWS Lambda
module.exports = {
presets: [
'@babel/preset-react',
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
@AndreiCalazans
AndreiCalazans / The Rules.md
Created August 17, 2019 12:11 — forked from sebmarkbage/The Rules.md
The Rules of React

The Rules of React

All libraries have subtle rules that you have to follow for them to work well. Often these are implied and undocumented rules that you have to learn as you go. This is an attempt to document the rules of React renders. Ideally a type system could enforce it.

What Functions Are "Pure"?

A number of methods in React are assumed to be "pure".

On classes that's the constructor, getDerivedStateFromProps, shouldComponentUpdate and render.

@AndreiCalazans
AndreiCalazans / react-native-update.md
Created July 20, 2019 11:03 — forked from jgcmarins/react-native-upgrade.md
Steps to upgrade a React Native App

React Native Upgrade path

  • Change React and React Native version on package.json
  • run yarn install to upgrade dependencies
  • run yarn outdated or yarn upgrade-interactive libraries that are outdated (make sure that there's no breaking changes, check release notes (one by one))
  • check the diff or use the upgrade-helper and update the native code
  • open Xcode and link the binaries
  • run on iOS
  • test iOS
  • run on Android
  • test Android
@AndreiCalazans
AndreiCalazans / useEventEmitter.tsx
Created June 6, 2019 20:17 — forked from sibelius/useEventEmitter.tsx
UseEventEmitter hook to work with react navigation navigationOptions buttons
import { useEffect, useRef } from 'react';
export const useEventEmitter = (eventEmitter, eventName: string, fn: () => void) => {
const subscription = useRef(null);
useEffect(() => {
subscription.current = eventEmitter.addListener(eventName, fn);
return () => {
if (subscription.current) {