Code Monkey home page Code Monkey logo

dotfiles's Introduction

I am a machine learning engineer who is passionate about solving real-world problems using machine learning algorithms. I am experienced in image processing using OpenCV and PIL, and also in data visualization using Matplotlib. I have been working on various vision-related projects, ranging from image retrieval, OCR, document image analysis and reconstruction, to video fingerprinting/deduplication.

I am also a FOSS lover and a Vim/Nvim enthusiast in particular, sharing tips and tricks on using Neovim. More info about me can be found on my website: https://jdhao.github.io/.

Languages and tools

Python C++ Lua shell script LaTeX Zsh OpenCV NumPy Pandas PySpark sklearn PyTorch Matplotlib MySQL PostGres Elasticsearch Redis Flask FastAPI Databricks GitHub GitHub Pages Hugo git Azure GCP GitLab Jupyter NeoVim Vim VS Code Sublime Text PyCharm Emacs Docker Linux Ubuntu CentOS Android macOS Windows Tmux Hugo Windows Terminal Jira

Projects

  • I am maintaining nvim-config -- A modern Neovim configuration with full battery for Python, C++, Markdown, LaTeX, and more...
  • Author of better-escape.vim -- a Vim/Neovim plugin that helps the users escape insert mode without lagging.
  • Author of whitespace.nvim -- A nvim plugin to show and trim trailing white spaces.
  • minimal_vim -- A minimal Vim/Nvim configuration in just one file without external dependencies.
  • deep firearm: Using a Siamese network with double margin contrastive loss for fine-grained gun image retrieval.

Latest blog posts

Stack Overflow and GitHub stats

jdhao's Stack Overflow profile

GitHub Stats GitHub Streak

Random quotes

quotes

dotfiles's People

Contributors

jdhao avatar josemiguelmorillo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dotfiles's Issues

macOS: PATH changed after openning tmux

After open a tmux session, the PATH variable is changed and different from outside of tmux.

  • outside tmux: python3 points to Python installed by Miniconda
  • inside tmux: python3 points to Python3 installed by Apple

The reason is that when you start a tmux session, it will start a shell (in the latest macOS, it is zsh by default) in login mode. So certain zsh config files are sourced again (the culprit is /etc/zprofile), which leads to messed up PATH variable.

The content of /etc/zprofile is:

if [ -x /usr/libexec/path_helper ]; then
	eval `/usr/libexec/path_helper -s`
fi

In order to confirm this, we can do an experiment (credit here):

> PATH=BEG:$PATH:END
> echo $PATH

# output: BEG:/opt/homebrew/Caskroom/miniconda/base/bin:/opt/homebrew/Caskroom/miniconda/base/condabin:/Users/hao/.local/share/zinit/polaris/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:END

> source /etc/zprofile
> echo $PATH

# output: /usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:BEG:/opt/homebrew/Caskroom/miniconda/base/bin:/opt/homebrew/Caskroom/miniconda/base/condabin:/Users/hao/.local/share/zinit/polaris/bin:/opt/homebrew/bin:/opt/homebrew/sbin:END

so what path_helper does is to construct PATH from /etc/paths and /etc/path.d. Append the current PATH variable to the constructed PATH and remove the duplicated items:

I think it is just looping through the item in the PATH variable and remove items that have appeared before. This explains why unique item inside BEG:END constructure is kept and duplicate items are removed.

How to prevent

One thing I see people do is to change /etc/zprofile, adding one line to empty PATH:

if [ -x /usr/libexec/path_helper ]; then
    PATH=""  #empty the PATH
    eval `/usr/libexec/path_helper -s`
fi

For me, it is hacky. I do not want to change the system default settings.

Another method is to tell tmux to start a non-login shell instead via default-command option:

# default command should be path to zsh executable on your system
set -g default-command /bin/zsh

If zsh is started as a non-login shell, /etc/zprofile won't be sourced, so PATH is not changed. To check if we are running a login shell or not (zsh-only), run the following (source here):

if [[ -o login ]]; then
    print yes
else
    print no
fi

After this setup, to make sure it work, run killall tmux and exit your terminal and restart it again.

ref:

should set up ripgrep properly

  1. completion:

for zsh completion, we need to update FPATH.

export FPATH=$HOME/tools/ripgrep/complete:$FPATH
  1. man doc
mkdir -p $HOME/tools/ripgrep/doc/man/man1
mv $HOME/tools/ripgrep/doc/rg.1 $HOME/tools/ripgrep/doc/man/man1

The MANPATH variable needs to updated too:

export MANPATH=$HOME/tools/ripgrep/doc/man

wezterm move tabs left or right

diff --git i/.config/wezterm/wezterm.lua w/.config/wezterm/wezterm.lua
index 2b2ac4f..272ffca 100644
--- i/.config/wezterm/wezterm.lua
+++ w/.config/wezterm/wezterm.lua
@@ -35,10 +35,9 @@ wezterm.on(
end
)

-return {
+local wez_conf = {
font = wezterm.font_with_fallback({

  • "IBM Plex Mono",
  • "IBM Plex Mono",
    
    -- "Azeret Mono",
    -- "Iosevka Nerd Font",
    -- "Noto Sans SC",
    @@ -72,3 +71,13 @@ return {
    term = "xterm-256color",
    automatically_reload_config = false,
    }

+-- move current tab left or right, modified from https://wezfurlong.org/wezterm/config/lua/keyassignment/MoveTabRelative.html.
+-- For the key notation, check https://wezfurlong.org/wezterm/config/keys.html#configuring-key-assignments
+local action = wezterm.action
+wez_conf.keys = {

  • { key = 'LeftArrow', mods = 'SHIFT|ALT', action = action.MoveTabRelative(-1) },
  • { key = 'RightArrow', mods = 'SHIFT|ALT', action = action.MoveTabRelative(1) },
    +}

+return wez_conf

zsh autoload

  1. autoload is a zsh builtin, its doc can be found in man zhsbuiltins.
    • -U: alias expansion is suppressed when the function is loaded.
    • -z: The flags -z and -k mark the function to be autoloaded using the zsh or ksh style, as if the option KSH_AUTOLOAD were unset or were set, respectively

the meaning of KSH_AUTOLOAD is defined in man zhsoptions:

Emulate ksh function autoloading. This means that when a function is autoloaded, the corresponding file is merely executed, and must define the function itself. (By default, the function is defined to the contents of the file. However, the most common ksh-style case - of the file containing only a simple definition of the function - is always handled in the ksh-compatible manner.)

  1. autoloading functions: https://zsh.sourceforge.io/Doc/Release/Functions.html
  2. what does autoload do in Zsh? https://stackoverflow.com/q/30840651/6064933
  3. zsh autoload, what is it good for? https://stackoverflow.com/q/4493173/6064933

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.