Skip to content

Instantly share code, notes, and snippets.

View xavierchia's full-sized avatar

Xavier Chia xavierchia

View GitHub Profile
alias dd='rm -rf /Users/xavier/Library/Developer/Xcode/DerivedData/*'
alias ccb='git branch --show-current | pbcopy | echo "current branch copied to $
alias reset='git reset head~1'
alias reuse='git commit --reuse-message=orig_head | echo "commited with last me$
alias nanoz='nano ~/.zshrc'
alias xlog='git log --format="%C(auto) %h %s" -n10'
alias dab='git branch | grep -v "main" | xargs git branch -D'
alias diff='git diff --name-only --diff-filter=U --relative'
export CLICOLOR=1
export LSCOLORS=bxFxCxDxBxegedabagaced
@xavierchia
xavierchia / gist:b7b983ca0f8f1270165d9242f21d034b
Last active March 1, 2023 01:53 — forked from kylefox/gist:4512777
If you want to use Xcode's FileMerge as your git mergetool, this is how you set it up.
# Tell system when Xcode utilities live:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
# Set "opendiff" as the default mergetool globally:
git config --global merge.tool opendiff
# Then, when git tells you that there is a conflict, you can run `git mergetool` and
# it will open XCode's mergetool (like in the question's screenshot) and you can work through the conflict.
@xavierchia
xavierchia / LightweightDataMigration
Created September 5, 2022 23:15
LightweightDataMigration
Click on a data model
Editor > Add data model
Make changes to the new data model
Inspector > Model version > current > choose latest
Type this in console after breakpoint
expr variableToChangeOnTheFly = 20
# In AppDelegate:
# This is to make sure that it only happens on the first launch
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
let defaults = UserDefaults.standard
let isPreloaded = defaults.bool(forKey: "isPreloaded")
if !isPreloaded {
Switch on emulator keyboard: Command + k
Refresh preview: option + command + p

1 April 2022: Crossed $100 in 30 days for MyTummy

1648297060792

10 August 2021: Start first iOS job

Screenshot 2022-04-14 at 7 27 32 AM

1 July 2021: Crossed $100 in paid users

Screenshot 2021-07-01 at 3 42 38 PM

24 April 2021: First paid user for third iOS app (launched)

Choosing an Open Source Project

  1. Software that you've used
  2. Software that you want to use in the future
  3. Software that solves a specific problem
  4. Software that will teach you something that you want to know
  5. Software written by companies that you're interested in
  6. Software written by people that you know

How to read source code

Why it’s important

  1. Most of your time will be spent reading, not writing.
  2. Simulates working at a company or open source project.
  3. It's the fastest way to learn and improve.
  4. Learn how to ignore large parts of a codebase and get a piece-by-piece understanding.

Before you start

  1. Read the docs (if they exist).

Fixup and autosquash

  • git add .
  • git commit --fixup 3050fc0de // Created a fixup commit for 3050fc0de
  • GIT_SEQUENCE_EDITOR=: git rebase -i main --autosquash // Now the fixup commit has been squashed

Cherry picking a range of commits

  • git cherry pick firstCommit^..lastCommit # First and last are inclusive

Working with forked repos

  • git fetch upstream # This will fetch all upstream branches & show on terminal