Skip to content

Instantly share code, notes, and snippets.

View kha-dinh's full-sized avatar

khadinh kha-dinh

View GitHub Profile
@kha-dinh
kha-dinh / push.sh
Created August 23, 2025 08:32
Push very large repo with millions of commits (e.g., Linux) to github in steps. This overcome Github's 2GB limit.
#!/bin/bash ╭───────────  Line Numbers ────────────╮
BR=main
mapfile -t COMMITS < <(git rev-list --reverse --first-parent "$BR")
STEP=10000
for ((i = $STEP - 1; i < ${#COMMITS[@]}; i += STEP)); do
│ git push origin "${COMMITS[$i]}:refs/heads/main"
done
# Final push to bring remote to tip
git push origin "$BR:refs/heads/main"
@kha-dinh
kha-dinh / pdf_zotero.sh
Last active December 9, 2024 07:43 — forked from Pangoraw/pdf_zotero.sh
Open zotero files from a selector like rofi, dmenu, fzf. Now with support for previewing, citation keys, authors, and builtin Zotero reader.
set -o errexit
set -o pipefail
set -o nounset
ZOTERO_DIR="$HOME/Zotero"
ZOTERO_DB="${ZOTERO_DIR}/zotero.sqlite"
OPENER="xdg-open"
# All-in-one previewer copied from https://github.com/MarrekNozka/fzf--previewer
@kha-dinh
kha-dinh / macOS-compiledb.md
Created September 30, 2023 03:36
Generate compilation database on MacOS for non-CMake projects without bear

Somehow bear did not work on my setup. Here is an alternative that collects the build log and use compiledb to generate compile_commands.json

First generate the build log by tracing executed commands

gmake SHELL='sh -x' 2>&1 | tee make.txt

Now we parse the build log:

@kha-dinh
kha-dinh / SioyekNeovim.md
Last active September 14, 2025 16:40
Lunarvim/Neovim+Sioyek+Synctex

This took me some time to figure out. Works like a charm, VimtexInverseSearch as well as texlab did not work for me. I use Lunarvim so I haven't try it on vanilla Neovim.

You first need to install the package neovim-remote on your platform.

Then, use the following configuration in your Packer declaration where vimtex is declared:

 {
        'lervag/vimtex',
        ft = { 'tex', 'bib' }, -- for lazy loading
@kha-dinh
kha-dinh / MyGrid.grid
Created September 11, 2020 06:07
My GridMove template
[Groups]
NumberOfGroups = 9
[1]
TriggerTop = [MonitorReal1Top]
TriggerLeft = [MonitorReal1Left] + [MonitorReal1Width] / 2 - 50
TriggerBottom= [MonitorReal1Top] + 35
TriggerRight = [MonitorReal1Left] + [MonitorReal1Width] / 2 + 50
GridTop = Restore
GridLeft = Restore