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
@brianleroux
brianleroux / BeforeExitListener.js
Created September 12, 2019 22:04
Lambda NodeJS 10.x Default Runtime JavaScript
/** Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */
"use strict";
/**
* The runtime has a single beforeExit function which is stored in the global
* object with a symbol key.
* The symbol is not exported.
* The process.beforeExit listener is setup in index.js along with all other
* top-level process event listeners.
*/
@axemclion
axemclion / MainApplication.java
Created August 12, 2019 18:30
Adding Flipper to ReactNative
// Call this in MainApplication.onCreate(), just after Soloader line.
private static void initialize(Context context) {
if (BuildConfig.DEBUG) {
try {
/*
We use reflection here to pick up the class that initializes Flipper,
since Flipper library is not available in release mode
*/
Class<?> aClass = Class.forName("com.facebook.flipper.ReactNativeFlipper");
aClass.getMethod("initializeFlipper", Context.class).invoke(null, context);
@jgcmarins
jgcmarins / react-native-upgrade.md
Last active February 17, 2021 14:19 — forked from julioxavierr/react-native-update.md
Steps to Upgrade a React Native App

React Native Upgrade Path

  1. Change React and React Native versions in package.json
  2. Run yarn install to upgrade dependencies
  3. Run yarn outdated or yarn upgrade-interactive to upgrade outdated libraries. Make sure that there's no breaking changes, check release notes (one by one).
  4. Compare your changes with the diff or use the upgrade-helper and update the native code.
  5. Open Xcode and link the binaries
  6. Run iOS
  7. Test iOS
  8. Run on Android
  9. Test Android
@lucianomlima
lucianomlima / adb_connect.sh
Created June 5, 2019 17:57
Connect to Android devices with ADB through wi-fi
function adb_connect {
# PORT used to connect. Default: 5555
PORT=${1:-5555}
# IP address from current device connected
IP_ADDRESS=`adb shell ip route | awk '{print $9}'`
echo "ADB connect to $IP_ADDRESS on port $PORT"
# Change connection from usb to tcpip using $PORT
@ericlewis
ericlewis / RCTNativeTestModuleSpec.h
Last active November 19, 2019 07:27
Codegen experiment
/**
* RCTNativeTestModuleSpec.h
*
* NOTE: This file is codegenerated.
*/
#import <vector>
#import <Foundation/Foundation.h>
@fakenickels
fakenickels / metro.config.js
Last active December 22, 2019 04:54 — forked from sibelius/metro.config.js
metro config to work with yarn workspaces
const path = require('path');
const getWorkspaces = require('get-yarn-workspaces');
const blacklist = require('metro-config/src/defaults/blacklist');
const workspaces = getWorkspaces(__dirname);
// Blacklists any react-native that doesn't come from packages/app
const blacklistRE = blacklist([ /(?<!packages\/app\/)node_modules\/react-native\/.*/g])
@dabit3
dabit3 / Authexample.js
Created May 14, 2019 19:45
Example of manual sign out using React Native & AWS Amplify
import React from 'react'
import { View, Text } from 'react-native'
import { withAuthenticator } from 'aws-amplify-react-native'
function App(props) {
function signOut() {
Auth.signOut()
.then(() => {
props.onStateChange('signedOut', null);
})
@dslounge
dslounge / lint changes.sh
Created May 13, 2019 18:31
eslint the javascript files changed on your branch
git diff master... --name-only | grep -E '.js$' | xargs ./node_modules/eslint/bin/eslint.js
const {useCallback, useEffect, useReducer, useRef} = require('react');
let effectCapture = null;
exports.useReducerWithEmitEffect = function(reducer, initialArg, init) {
let updateCounter = useRef(0);
let wrappedReducer = useCallback(function(oldWrappedState, action) {
effectCapture = [];
try {
let newState = reducer(oldWrappedState.state, action.action);
@stolinski
stolinski / providerCompose.js
Created April 23, 2019 17:40
ProviderComposer
function ProviderComposer({ contexts, children }) {
return contexts.reduceRight(
(kids, parent) =>
React.cloneElement(parent, {
children: kids,
}),
children
);
}