Skip to content

Instantly share code, notes, and snippets.

View phuochau's full-sized avatar
👨‍💻

Hau Vo phuochau

👨‍💻
View GitHub Profile
@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 / 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 / react-native-view-measurement.js
Last active May 16, 2023 15:09
Best way to measure layout of view in React Native (works in both iOS & Android)
import {
findNodeHandle
} from 'react-native'
this.childItem.measureLayout(findNodeHandle(this.containerWrapper), (x, y, width, height) => {
console.log('got measurement', x, y, width, height)
})
@phuochau
phuochau / delete_all_photos_of_facebook_page.js
Created November 12, 2022 12:08
Delete all photos of Facebook Page
function getElementByXpath(path) {
return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
const ID = document.body.children[0].id
@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 / 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 / .zshrc
Created April 11, 2022 03:29
Show Git branch in zsh (insert it into ~/.zshrc on Mac)
# Load version control information
autoload -Uz vcs_info
precmd() { vcs_info }
COLOR_DEF=$'\e[0m'
COLOR_DIR=$'\e[38;5;197m'
COLOR_GIT=$'\e[38;5;39m'
# Format the vcs_info_msg_0_ variable
zstyle ':vcs_info:git:*' formats '| %b'

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.
@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