Skip to content

Instantly share code, notes, and snippets.

View phuochau's full-sized avatar
👋
looking for interesting projects...

Hau Vo phuochau

👋
looking for interesting projects...
View GitHub Profile
@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 / 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 / strip_unwanted_architectures.sh
Created January 14, 2020 07:23
Strip unwanted architectures in iOS build. Add after "Embed Frameworks" step
APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
# This script loops through the frameworks embedded in the application and
# removes unused architectures.
find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
ACTION = build
AD_HOC_CODE_SIGNING_ALLOWED = NO
ALTERNATE_GROUP = staff
ALTERNATE_MODE = u+w,go-w,a+rX
ALTERNATE_OWNER = grantdavis
ALWAYS_SEARCH_USER_PATHS = NO
ALWAYS_USE_SEPARATE_HEADERMAPS = YES
APPLE_INTERNAL_DEVELOPER_DIR = /AppleInternal/Developer
APPLE_INTERNAL_DIR = /AppleInternal
APPLE_INTERNAL_DOCUMENTATION_DIR = /AppleInternal/Documentation
@phuochau
phuochau / fix_keyboard_avoiding_issue_expo.js
Last active May 9, 2020 02:57
Fix Keyboard Avoiding issue on Expo
import React from 'react'
import { View, ScrollView, KeyboardAvoidingView, Platform, StyleSheet } from "react-native";
import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";
import { getStatusBarHeight, getSafeBottomHeight } from "~/Utils";
const styles = StyleSheet.create({
safeContainer: {
flex: 1,
backgroundColor: Colors.background,
paddingTop: getStatusBarHeight(true),
@phuochau
phuochau / create_dynamic_func.ex
Created September 11, 2020 07:16
Create dynamic function with Elixir Macro
defmodule MyMacro do
defmacro create_some_function_by_number(name, num, do: block) do
params =
for n <- 1..num do
{"id#{n}", Macro.var(:"id#{n}", nil)}
end
# We can't call Macro.escape because it is for escaping values.
# In this case, we have a mixture of values "id#{n}" and
# expressions "Macro.var(...)", so we build the map AST by hand.
@phuochau
phuochau / testing_regular_sdk.js
Created September 30, 2020 07:15
Testing regula SDK
/* OCR Helper */
import {
NativeEventEmitter,
Platform
} from 'react-native'
import RNFetchBlob from 'rn-fetch-blob'
import Regula from '@regulaforensics/react-native-document-reader-api'
const EventManager = new NativeEventEmitter(Regula.RNRegulaDocumentReader)
const DocumentReader = Regula.DocumentReader
@phuochau
phuochau / fix_out_of_storage_macos.md
Last active February 1, 2021 08:06
Fix out of storage issue on Mac OS
  1. Remove temp folder of Android sdk
rm -rf /Users/hauvo/Library/Android/sdk/.temp
  1. Clear Derived Data of Xcode
rm -rf /Users/hauvo/Library/Developer/Xcode/DerivedData 

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.