Skip to content

Instantly share code, notes, and snippets.

View phuochau's full-sized avatar
👨‍💻

Hau Vo phuochau

👨‍💻
View GitHub Profile
@phuochau
phuochau / copy_version_from_packagejson_to_info_plist.sh
Created November 29, 2019 01:53
Bash script to read version in package.json and set it for Info.plist in React Native Project
#!/bin/bash
PROJECT_DIR="ios/Invygo"
INFOPLIST_FILE="Info.plist"
INFOPLIST_DIR="${PROJECT_DIR}/${INFOPLIST_FILE}"
PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]')
# Update plist with new values
@phuochau
phuochau / create_release_gitbranch.sh
Created November 29, 2019 01:51
Bash script to auto create release_x_x_x GIT branch with x.x.x is the version in package.json
#!/bin/bash
PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]')
NEW_PACKAGE_VERSION="${PACKAGE_VERSION//./_}"
BRANCH_NAME="release_${NEW_PACKAGE_VERSION}"
if [ `git branch -ra | egrep "remotes/origin/${BRANCH_NAME}$"` ]
then
echo "Branch name $BRANCH_NAME already exists!"
git checkout $BRANCH_NAME
@phuochau
phuochau / using-react-navigation-4x-with-mobx.md
Last active October 2, 2019 16:50
Use react-navigation 4.x with mobx

NAVIGATION OPTIONS

export const StackNavigationOptions = (params = {}) => {
  let { headerStyle, headerTitleStyle, ...others } = params

  if (!headerStyle) headerStyle = {}
  if (!headerTitleStyle) headerTitleStyle = {}
@phuochau
phuochau / send-filebase-push-notification-with-curl.sh
Created May 26, 2019 07:20
Send Firebase push notification with cURL
curl -d '{
"to": "REGISTRATION_TOKEN",
"notification": {
"title" : "Hello",
"body" : "World"
}
}' \
-i -H "Application/json" \
-H "Content-type: application/json" \
-H "Authorization: key=SERVER_KEY" \
@phuochau
phuochau / generate-s3-signed-url.ex
Created May 25, 2019 02:23
Generate S3 signed URL with Elixir
defmodule Famiby.Helpers.AWS do
alias Famiby.Helpers
@bucket_name Application.get_env(:ex_aws, :bucket)
@region Application.get_env(:ex_aws, :region)
@env Application.get_env(:famiby, :env)
def s3_signed_url(filename, acl \\ "public-read") do
key = "#{@env}/#{filename}"
content_type = Helpers.File.file_type(filename)
@phuochau
phuochau / use-signed-url-nodejs-with-react-native.md
Last active October 18, 2022 11:09
Generate Signed URL by NodeJS

Configure Amazon S3, generate signed url by NodeJS and upload in React Native

1. Configure Amazon S3 (updating...)

2. Generate signed url by NodeJS

import AWS from 'aws-sdk'
import { getFileType } from './File'
@phuochau
phuochau / step-to-step-to-eject-expo-by-right-way.md
Last active November 5, 2023 11:48
Step to Step to eject Expo by right way (Expo 32.0.0)

1. Step to step to eject to ExpoKit by right way:

Step 1. Run command: expo eject in root of expo project.

Step 2. Choose 2nd option: Eject to ExpoKit and follow step to step from Expo command to eject it completely.

Step 3 (Optional) Install dependencies (normally, Expo will auto run this command)

yarn install
@phuochau
phuochau / configure-build-gradle-for-using-gms-services.gradle
Last active April 19, 2019 02:11
Always use google() in the top in build.gradle if we use gms services
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "27.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 27
supportLibVersion = "27.1.1"
}
@phuochau
phuochau / request-multipart-with-axios.js
Last active April 19, 2019 02:12
Request multipart with rn-fetch-blob (Android doesn't allow number in param)
/**
* A file must have structure as below:
* {
* name: 'file'
* content: {
* uri: 'file://abc',
* data: 'file body', only use uri or data
* name: 'avatar.jpg',
* type: 'image/jpg'
* }
@phuochau
phuochau / transparent-modal-react-navigation.js
Last active April 19, 2019 02:13
Working sample for react-navigation transparent modal in 3.3.0 & support this.props.navigation.dismiss() in screen in Modal Stack
import { createSwitchNavigator, createStackNavigator } from 'react-navigation'
import { StackNavigationOptions } from './Routes.NavigationOptions'
import { getChildComponentNavigationOptions } from './Routes.Utils'
import n from './Routes.Names'
// Stacks
import StartScreen from '../containers/Start'
import GuestStack from './routes/Routes.Guest'
import MainStack from './routes/Routes.MainStack'