Skip to content

Instantly share code, notes, and snippets.

View phuochau's full-sized avatar
👨‍💻

Hau Vo phuochau

👨‍💻
View GitHub Profile
@phuochau
phuochau / migrate.sh
Created August 7, 2024 16:17 — forked from Geczy/migrate.sh
Migrate Coolify to a new server
#!/bin/bash
# This script will backup your Coolify instance and move everything to a new server. Docker volumes, Coolify database, and ssh keys
# 1. Script must run on the source server
# 2. Have all the containers running that you want to migrate
# Configuration - Modify as needed
sshKeyPath="$HOME/.ssh/your_private_key" # Key to destination server
destinationHost="server.example.com"
@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 / .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 
@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 / 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 / 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),
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 / 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"