Skip to content

Instantly share code, notes, and snippets.

View bacarybruno's full-sized avatar
💭
Think Simple

Bacary Bruno Bodian bacarybruno

💭
Think Simple
View GitHub Profile
@bacarybruno
bacarybruno / checkIfAffected.js
Created December 12, 2022 10:24
[NX] Check if a module if affected by a change
const { execSync } = require('child_process')
const checkIfAffected = (modules) => {
const result = execSync('yarn nx print-affected --select=projects').toString()
const changedModules = result.split('\n')[2].split(', ')
return modules.some((module) => changedModules.includes(module))
}
if (require.main === module) {
const modules = process.argv.slice(2)
@bacarybruno
bacarybruno / proptypes-to-typescript.ts
Created August 4, 2022 11:53
A React codemod that will transform proptypes to typescript type alias for component types
// Modified version of https://github.com/mskelton/ratchet
import type { NodePath } from 'ast-types/lib/node-path';
import type {
API,
Collection,
CommentBlock,
CommentLine,
FileInfo,
Identifier,
import { ref, watch, onBeforeUnmount } from 'vue';
export const useState = (initialValue) => {
const state = ref(initialValue);
const setState = (value) => {
state.value = value;
};
return [state, setState];
};
import { useEffect, useState, useContext } from 'react'
import { NavigationContext } from 'react-navigation'
export const useNavigation = () => {
const navigation = useContext(NavigationContext)
if (!navigation) {
throw new Error('navigation object not found. Please make sure your component is in a navigation tree')
}
return navigation
}
// Keep in sync with
// https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/cupertino/colors.dart
export default {
black: 'rgba(0, 0, 0, 255)',
white: 'rgba(255, 255, 255, 255)',
systemBlue: {
light: 'rgba(0, 122, 255, 255)',
dark: 'rgba(10, 132, 255, 255)',
},
Resources:
NodeSecurityGroup:
Type: "AWS::EC2::SecurityGroup"
Properties:
GroupDescription: Enable HTTP access via port 3000
SecurityGroupIngress:
-
IpProtocol: tcp
FromPort: 3000
ToPort: 3000
// Based on the amazing work on https://ethercreative.github.io/react-native-shadow-generator/
// https://github.com/ethercreative/react-native-shadow-generator
const penumbra = [
'0px 1px 1px 0px',
'0px 2px 2px 0px',
'0px 3px 4px 0px',
'0px 4px 5px 0px',
'0px 5px 8px 0px',
'0px 6px 10px 0px',
{
"name": "YourAwesomeProject",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"watch": "nodemon node_modules/react-native/local-cli/cli.js start",
"eslint-init": "eslint --init",
"flow": "flow",
"test": "yarn jest && flow && eslint .",
@bacarybruno
bacarybruno / create-rn-project.sh
Created March 11, 2019 10:41
Create React Native project with base packages (redux and icons) and code recommanded structure.
cd ..
react-native init YourAwesomeProject
cd YourAwesomeProject
react-native run-android
yarn remove react-native
yarn add react-native@0.55.4
yarn remove babel-preset-react-native
yarn add babel-preset-react-native@4.0.0
yarn add prop-types react-native-vector-icons redux redux-logger redux-persist redux-saga
yarn add -D babel-core@latest babel-loader@latest eslint eslint-config-airbnb eslint-plugin-jsx-a11y eslint-plugin-import eslint-plugin-react flow-bin flow-typed jest react-test-renderer
@bacarybruno
bacarybruno / eslintrc-react.json
Created March 11, 2019 10:41
ESLint file for react, with best practices and extending airbnb config.
{
"root": true,
"parser": "babel-eslint",
"extends": "airbnb",
"env": {
"es6": true,
"node": true,
"jest": true
},
"plugins": [