my favorite ps1
bash: export PS1=’\[\033[38m\]\u@\h\[\033[01;34m\] \w \[\033[31m\]$(__git_ps1 “(%s) “)\[\033[37m\]$\[\033[0m\] ‘ zsh: zstyle ‘:vcs_info:*’ enable git zstyle ‘:vcs_info:*’ formats ‘(%b) ‘ precmd() { vcs_info } setopt PROMPT_SUBST PROMPT=$’%F{white}%n@mbp %B%F{blue}%~ %b%B%F{red}${vcs_info_msg_0_}%b%f%F{white}$%f ‘
patching third_party DEPS for fast fixes
Sometimes you just need to: template(“patch_file”) { assert(defined(invoker.patch_path), “patch_path must be defined for $target_name”) assert(defined(invoker.source_file), “source_file must be defined for $target_name”) action(target_name) { forward_variables_from(invoker, [ “testonly”, “visibility”, ]) script = “patch.py” sources = [ invoker.patch_path, invoker.source_file, ] outputs = [ “$target_gen_dir/” + invoker.source_file ] args = rebase_path(sources, root_build_dir) + rebase_path(outputs, root_build_dir) } } patch_file(“patch_SomeFile_m”) { […]
Oops, I did it again
git reset HEAD^ ios_internal && git commit –amend –no-edit
i did a thing
https://nvd.nist.gov/vuln/detail/CVE-2024-27879
os_log
random snippet:
HEIC for CVS
Every time I try to do a quick print of photos for CVS I need to locally convert the ones I choose from HEIC to jpg. Brainless convert: for i in *.HEIC(:r) ; sips -s format jpeg “$i.HEIC” –out “$i.jpg”
git prompt.
# From https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh source ~/.git-prompt.sh export PS1=’\[\033[38m\]\u@mbp\[\033[01;34m\] \w \[\033[31m\]$(__git_ps1 “(%s) “)\[\033[37m\]$\[\033[0m\] ‘
Fix Apple Watch Auto Unlock
Stolen from here from LongZheng I’ve finally fixed it! I found a bunch of errors related to “AutoUnlock” in the Console that was hinting to me that there was some invalid state on my Mac with keys and plists not being reset properly. After clearing/resetting them, I can now successfully pair my watchOS 7 Series […]
flash!
UIWindow* window = [[UIApplication sharedApplication] keyWindow]; UIView* snapshotView = [[UIView alloc] init]; snapshotView.translatesAutoresizingMaskIntoConstraints = false; [window addSubview:snapshotView]; [NSLayoutConstraint activateConstraints:@[ [snapshotView.topAnchor constraintEqualToAnchor:window.topAnchor], [snapshotView.leadingAnchor constraintEqualToAnchor:window.leadingAnchor], [snapshotView.trailingAnchor constraintEqualToAnchor:window.trailingAnchor], [snapshotView.bottomAnchor constraintEqualToAnchor:window.bottomAnchor] ]]; snapshotView.backgroundColor = [UIColor blueColor]; [UIView animateWithDuration:0.2 animations:^{ snapshotView.alpha = 0; } completion:^(BOOL finished) { [snapshotView removeFromSuperview]; }];
Rebase without re-checkout
TL;DR: when using multiple branches, prefer to use “git rebase –onto origin/master origin/master ${branch}” if you want to checkout and then rebase a branch. Let’s say you have the working history: /-*-* A *-*-*-*-*-*-* origin/master \-*-*-* B and you want to push the branch A because your CL has been approved. You have to rebase […]