Skip to content

Instantly share code, notes, and snippets.

View oieduardorabelo's full-sized avatar

Eduardo Rabelo oieduardorabelo

View GitHub Profile
@NigelEarle
NigelEarle / Knex-Setup.md
Last active March 15, 2025 16:49
Setup Knex with Node.js

Knex Setup Guide

Create your project directory

Create and initialize your a directory for your Express application.

$ mkdir node-knex-demo
$ cd node-knex-demo
$ npm init
@busypeoples
busypeoples / IntroductionToFlow.md
Last active June 29, 2020 08:22
Introduction To Flow

Introduction To Flow

Intended for developers interested in getting started with Flow. At the end of this introduction, you should have a solid understanding of Flow and how to apply it when building an application.

Covers all the basics needed to get started with Flow.

Covers all the basic needed to get started with Flow and ReactJS.

@acdlite
acdlite / coordinating-async-react.md
Last active June 17, 2024 11:56
Demo: Coordinating async React with non-React views

Demo: Coordinating async React with non-React views

tl;dr I built a demo illustrating what it might look like to add async rendering to Facebook's commenting interface, while ensuring it appears on the screen simultaneous to the server-rendered story.

A key benefit of async rendering is that large updates don't block the main thread; instead, the work is spread out and performed during idle periods using cooperative scheduling.

But once you make something async, you introduce the possibility that things may appear on the screen at separate times. Especially when you're dealing with multiple UI frameworks, as is often the case at Facebook.

How do we solve this with React?

@seeebiii
seeebiii / LambdaConstants.java
Last active January 22, 2025 17:01
Available default environment variables in AWS Lambda. Just copy&paste into your Node or Java project.
public class Constants {
/**
* Contains the path to your Lambda function code.
*/
public static final String LAMBDA_TASK_ROOT = System.getenv("LAMBDA_TASK_ROOT");
/**
* The environment variable is set to one of the following options, depending on the runtime of the Lambda function:
* AWS_Lambda_nodejs, AWS_Lambda_nodejs4.3, AWS_Lambda_nodejs6.10
@stipsan
stipsan / Field-test.jsx
Last active August 7, 2018 22:39
Testing with Jest: Tip #15
import renderer from 'react-test-renderer'
import Field from '../Field'
// this import is created by our mock, it is inteded to help with testing and
// don't exist in the real package
import { intl } from 'react-intl'
it('should render correctly', () => {
const component = renderer.create(<Field intl={intl} />)
expect(component.toJSON()).toMatchSnapshot()
@stipsan
stipsan / Viewport-test.jsx
Last active October 17, 2021 22:13
Testing with Jest: Tip #14
import renderer from 'react-test-renderer'
import Viewport from '../Viewport'
it('should render correctly', () => {
const target = {
innerHeight: 600,
innerWidth: 800,
addEventListener: jest.fn(),
removeEventListener: jest.fn()
}
@stipsan
stipsan / Canvas-test.jsx
Last active June 17, 2017 18:07
Testing with Jest: Tip #13
import renderer from 'react-test-renderer'
import Canvas from '../Canvas'
it('should render correctly', () => {
const component = renderer.create(<Form x={0} y={0} />)
expect(component.toJSON()).toMatchSnapshot()
const instance = component.getInstance()
const spy = jest.spyOn(instance, 'calculateGrid')
@stipsan
stipsan / Form-test.jsx
Last active June 16, 2017 09:52
Testing with Jest: Tip #12
import renderer from 'react-test-renderer'
import Form, { validate } from '../Form'
jest.mock('redux-form', () => ({
Field: 'Field',
reduxForm: options => {
// Wrap the component and return the new component, just like the real hoc does
return Form => props => {
// call the validate error to make sure errors are detected
options.validate({}, props)
@stipsan
stipsan / Notifications-test.jsx
Last active June 16, 2017 09:51
Testing with Jest: Tip #11
import renderer from 'react-test-renderer'
import NotificationsContainer from '../NotificationsContainer'
// we can just pass through the component since we pass dispatch prop directly
jest.mock('react-redux', () => component => component)
it('should render correctly', () => {
const dispatch = jest.fn()
const component = renderer.create(
<NotificationsContainer dispatch={dispatch} />
@stipsan
stipsan / Input-test.jsx
Last active June 16, 2017 09:49
Testing with Jest: Tip #10
import renderer from 'react-test-renderer'
import Input from '../Input'
it('should render correctly', () => {
const component = renderer.create(<Input />)
expect(component.toJSON()).toMatchSnapshot()
// getInstance is returning the `this` object you have in your component
// meaning anything accessible on `this` inside your component
// can be accessed on getInstance, including props!