On newer versions of orgmode (i.e. anything 9.7 or newer) something upstream breaks the manner in which ox-hugo handles links for sub-tree exports1. The most robust workaround is to stop using native Org links and switch to a manual Hugo short-code via an Org macro. The process has two parts. First, we need the relref macro in the Org file with #+macro: relref @@hugo:[$1]({< relref "$2" >})@@ 2. Then every internal link needs to be refactored using the target file slug, optionally appending ...| Rohit Goswami
To initialize (with single to get a clean history in the current repository): 1➜ git remote add hzeon git@github.com:HaoZeke/eOn 2➜ git fetch hzeon doCIdimer 3 josh-filter ':prefix=subrepos/eOn' FETCH_HEAD --single 4 git merge --allow-unrelated FILTERED_HEAD Changes can be made within the sub-repo. 1echo"blah" > subrepos/eOn/blah 2git add subrepos/eOn/blah 3git commit -m "blah" When changes are to be pushed back upstream / to another branch.. 1git fetch hzeon doCIdimer 2josh-filter ':/sub...| Snippets on Rohit Goswami
mold is an easy win, with the following native file: 1[binaries] 2c_ld = 'mold' 3cpp_ld = 'mold' 4fortran_ld = 'mold' 5[built-in options] 6# mold 1.11.0 or later needed due to https://github.com/rui314/mold/issues/1017 7# --no-as-needed temporarily necessary due to the seeming return of https://github.com/rui314/mold/issues/1017 8c_link_args = ['-fuse-ld=mold', '-Wl,--no-as-needed'] 9cpp_link_args = ['-fuse-ld=mold', '-Wl,--no-as-needed'] 10fortran_link_args = ['-fuse-ld=mold', '-Wl,--no-as-n...| Rohit Goswami
pre-commit accepts exclude keys which take pythonregular expressions, typically designed with regex101. For example: 1exclude:| 2 (?x)( 3 thirdparty| # vendored 4 xtb.h| # vendored 5 ) 6- id:clang-format 7name:clang-format 8entry:clang-format 9language:system10types_or:[c, c++, cuda]11args:["-fallback-style=none","-style=file","-i"] While it is especially useful for tools which don’t have ignore flags, as a convention:| Snippets on Rohit Goswami
When specifying main manually, this will suffice: 1test_deps=_deps+dependency('Catch2') Which will pick up the pkgconfig configuration typically. However, to use the main which comes with catch2 it is easier to use cmake: 1test_deps+=dependency(2'Catch2',3method:'cmake',4modules:['Catch2::Catch2WithMain'],5) The rest of the tests can be setup via auto-discovery as discussed before.| Snippets on Rohit Goswami
Slack is unusable. Pidgin and Finch are marginally better. slack-libpurple works with a password generated from the Local Storage and Cookies of a browser session as follows 1: Get the main token ($MAIN) via devtools->Application->Storage->Local Storage (search for xoxc-) Search for xoxc then find it under localConfig_v2/teams/token Get the Cookies d token ($COOKIE) from: devtools->Application->Storage->Cookies-> d Join them together with a space so it is $MAIN $COOKIE and use that as the pa...| Snippets on Rohit Goswami
To open the first unmerged file in emacsclient 1emacsclient -n $(git diff --name-only --diff-filter=U | head -n 1)| Snippets on Rohit Goswami
Recently some of my older publications were accepted and naturally were archived on the Materials Archive. That being said, local copies are also nice to have. The best compression I know of is basically via the Lzma RZIP : 1lrzdir=gprd_sella_bench;\ 2 tar cvf $lrzdir.tar $lrzdir;\ 3 lrzip -Uvvp `nproc`\ 4 -S .lrz -L 9$lrzdir.tar;\ 5 rm -fv $lrzdir.tar;unset lrzdir Which should be decompressed with: 1lrunzip -o - gprd_sella_bench.tar.bzip2-lrz | tar xvf - Though I do hear good things about 7z...| Snippets on Rohit Goswami
Didn’t look into why too much but. 1sudo DevToolsSecurity --enable 2spctl developer-mode enable-terminal 3sudo security authorizationdb write system.privilege.taskport.debug allow does the trick.| Snippets on Rohit Goswami
I was having trouble launching ovito from a desktop file. To send commands through to a new tmux session and then close it out I ended up with. 1[Desktop Entry]2Name=OVITO3Type=Application4Exec=/usr/bin/tmux new-session -d -s ovito "bash --init-file <(echo '$HOME/.local/bin/ovito && tmux kill-session -t ovito')"5Icon=ovito6Terminal=false7StartupNotify=false8Categories=Education;Science;Mathematics;9Comment=Open Visualization Tool So basically create a named session, run a bash instance, then ...| Snippets on Rohit Goswami
As kanged from NumPy. 1set -xe 2# Kanged from NumPy: 3# https://github.com/numpy/numpy/blob/main/tools/wheels/cibw_before_build.sh 4 5# remove any cruft from a previous run 6rm -rf build 7 8# TODO: delete along with enabling build isolation by unsetting 9# CIBW_BUILD_FRONTEND when numpy is buildable under free-threaded10# python with a released version of cython11FREE_THREADED_BUILD="$(python -c"import sysconfig; print(bool(sysconfig.get_config_var('Py_GIL_DISABLED')))")"12if[[$FREE_THREADED_...| Snippets on Rohit Goswami
A quick glance at the output of lsusb yields: 1Bus 003 Device 004: ID 04f2:b751 Chicony Electronics Co., Ltd Integrated Camera Which suggests the following rule: 1cat /etc/udev/rules.d/51-android.rules 2SUBSYSTEM=="usb", ATTR{idVendor}=="04f2", MODE="0660", GROUP="adbusers", TAG+="uaccess"3SUBSYSTEM=="usb", ATTR{idVendor}=="04f2", ATTR{idProduct}=="b751", SYMLINK+="android_adb"4SUBSYSTEM=="usb", ATTR{idVendor}=="04f2", ATTR{idProduct}=="b751", SYMLINK+="android_fastboot" With these forcibly l...| Snippets on Rohit Goswami
I am not particularly fond on web based programming workflows. They feel ephemeral to my dated sensibilities. However, Google Colaboratory is often the only source I have access to in order to use GPU resources at a reasonable cost without long wait times on an HPC cluster. Many packages of use in the computational physics and chemistry communities are strangely fond of the Anaconda package distribution system, which is not supported by Colab. The snippet below has aided me several times in t...| Snippets on Rohit Goswami
From here. Often nix-shell invocations have the following issue: 1bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8) The fix is in two parts: 1# Install glibc 2nix-env -i glibc-locales Then use it in the shellHook as: 1shellHook = '' 2 # Locale 3 export LOCALE_ARCHIVE=${pkgs.glibcLocales}/lib/locale/locale-archive 4''; Or directly as export LOCALE_ARCHIVE="$(nix-env --installed --no-name --out-path --query glibc-locales)/lib/locale/locale-archive"| Rohit Goswami
For a laptop, assuming the primary screen is always the one it comes with, an easy approach to position screens relatively left and right of the monitor is: 1# Get display names, -p for plain text 2swaymsg -t get_outputs -p | grep Output 3Output eDP-1 'Chimei Innolux Corporation 0x1417 Unknown' (focused) 4Output DP-1 'Lenovo Group Limited M14 V904H2WF' 5# Center the primary display 6swaymsg 'output eDP-1 position 0 0' Now we can get the current configuration and move the other screen relative...| Rohit Goswami
Re-pairing bluetooth devices in Windows and Linux is annoying. 1 The ArchWiki article on bluetooth mouse management provides a link to a helpful gist. Combined with the bitlocker setup described earlier, and this patch: 1wget "https://gist.githubusercontent.com/5shekel/8b4998a69903438a6aac2f01a44463d3/raw/622a55c3a5bc1929369047c831a3f10e6988a195/export-ble-infos.py" 2# Comment out config['LocalSignatureKey']['Key'] = read_reg('CSRK', 'hex16') 3# If there's an error 4python export-ble-infos.p...| Snippets on Rohit Goswami
cryptsetup has partial support for bitlocker encrypted drives, but dislocker works better with dual booted machines. Crucially cryptsetup doesn’t work with partially encrypted drives. 1cryptsetup --version 2# cryptsetup 2.7.3 flags: UDEV BLKID KEYRING KERNEL_CAPI HW_OPAL 3sudo cryptsetup --type bitlk open /dev/nvme0n1p3 windows 4# Activation of partially decrypted BITLK device is not supported. Usage of dislocker is rather straightforward1. 1sudo mkdir -p /media/{bitlocker,Windows} 2# Get t...| Snippets on Rohit Goswami
Basically followed along the directions for reStream 1. Got the SSH root password and IP from Settings > Help > Copyrights and licenses > General information (scroll to the bottom) Added the IP to the pass store via pass insert REMARKABLE_IP Queried via pass REMARKABLE_IP Added an ecdsa key, ssh-keygen -t ecdsa -C "MYMAIL" -f ~/.ssh/remarkable ssh-copy-id -i ~/.ssh/remarkable root@$(pass REMARKABLE_IP) The only slight point of deviation was using chezmoi to grab the local script 2:| Snippets on Rohit Goswami
Often my notebooks are organized with respect to GITROOT, so this snippet makes for an easy way to construct relative paths. 1gitroot = Path(subprocess.run(["git", "rev-parse", "--show-toplevel"], 2 check=True, 3 capture_output=True).stdout.decode("utf-8").strip()) 4# Usage 5exdata = gitroot / "data" / "very_important_folder" For packages which demand string only paths, another helper can be used in tandem. 1def getstrform(pathobj): 2 return str(pathobj.absolute()) Along with a context manage...| rgoswami.me
Both NumPy and SciPy use spin as a frontend to call meson and this can be used to setup a shell. The good thing is that invoking exit will return to the directory from which spin was run. To toggle between directories (e.g. a folder with a bug / issue reprex) and the rebuild quickly popd is useful. 1# Generate reprex for bug 2cd ~/Git/Github/BuggyNP/gh2322/ 3vim buggy.f90 4python whatever.py 5# whatever to reproduce the bug 6cd ~/Git/Github/NumPy 7# Make changes, rebuild 8spin run $SHELL 9pop...| rgoswami.me
In general, detexify (here) and my ScanTools workflow is great. However, sometimes more can be done. 1micromamba create -n textocr 2micromamba activate textocr 3micromamba install torchvision -c pytorch 4pip install pix2tex[gui] 5pip install python-doctr 6pip install nougat-ocr The TeX tool (LaTeX OCR) works great even via the terminal. The doctr library is a bit more finicky, but can be a decent way to extract plain text when regular OCR tools fail (e.| rgoswami.me
Recently a bunch of my pre-commit CI jobs started failing due to dependency resolution issues. The easiest way to ensure reliable usage is to have locally installed tools used. Consider: 1- repo: https://github.com/pocc/pre-commit-hooks 2 rev: v1.3.5 3 hooks: 4 - id: cppcheck 5 args: ["--error-exitcode=0"] Which leaves one dependent on an external repo. This can be rewritten as: 1- repo: local 2 hooks: 3 - id: cppcheck 4 name: cppcheck 5 entry: cppcheck 6 language: system 7 types_or: [c++, c]...| rgoswami.me
One of the things I missed when I migrated from cmake to meson was the ease at which cmake discovers tests. 1# Tests 2option(PACKAGE_TESTS "Build the tests" OFF) 3if(PACKAGE_TESTS) 4 find_package(GTest REQUIRED) 5 enable_testing() 6 include(GoogleTest) 7 add_subdirectory(gtests) 8endif() Thankfully, meson can kind of emulate this behavior, even in its restricted syntax. The key concept is arrays and their iterators. 1test_array = [# 2 # ['Pretty name', 'binary_name', 'BlahTest.cpp'] 3 ['Strin...| rgoswami.me
I often need to set up quick virtual environments. Unfortunately, the standard approach to work with this in nix deals with the local nixpkgs mechanism for python dependencies: 1nix-shell -p "python38.withPackages(ps: [ ps.numpy ps.sh ])" However there is a catch for packages which are not officially present upstream. 1# Fails! 2nix-shell -p "python38.withPackages(ps: [ ps.numpy ps.sh ps.lieer ])" However, the mach-nix project can indeed be used to work around this, at the cost of a somewhat ...| rgoswami.me
Very quick set of ugly commands to grab build environments. A much better approach is to make a custom Dockerfile or even better, use nix. However it does work in a pinch. 1docker pull IMG:TAG 2sudo docker run -v LOCALDIR:DIRINDOCKER -it debian:experimental-20211115 bash 3# Don't be root for long 4apt update 5apt install sudo vim zsh 6# Use the same username --> easier to manage permissions 7useradd -m -s /bin/zsh $USER -G sudo 8passwd $USER # Some crap 9# Or just add to the sudoers file 10ec...| rgoswami.me
Whenever I need to access a server running on an HPC which does not support ngrok or localtunnel or even gsocket; the fallback approach is always to rely on SSH port forwarding. The sample problem here is running an HTTP server for viewing graphics in R via httpgd. 1# Local 2export PORT=9899 && ssh -L "${PORT}:localhost:${PORT}" "rog32@krafla.rhi.hi.is" -N -L "${PORT}:localhost:${PORT}" elja 3# New tab 4ssh krafla 5ssh elja 6radian # or R Now in R.| rgoswami.me
My personal favorite for watching files and running context sensitive commands is to use the lovely filewatcher CLI utility written in Ruby. 1gem install filewatcher 2gem install filewatcher-cli This can then be used with: 1filewatcher '**/*.js' 'node $FILENAME' However this hasn’t been updated in a while now and fails on newer versions of Ruby. So now I use watchexec. 1cargo install watchexec-cli 2watchexec -w source/f2py 'make html'| rgoswami.me
Most often it makes more sense to map the same ports on every intermediate machine. 1Host super 2 Hostname super.machine.location.is 3 IdentityFile ~/.ssh/mykey 4 User myuser 5 LocalForward 8001 localhost:8001 6 LocalForward 8002 localhost:8002 7 LocalForward 8003 localhost:8003 8 LocalForward 8004 localhost:8004 This is good for interactive sessions with multiple servers. For single servers, reverse proxy tunnels are more efficient.| rgoswami.me
1doxygen191 = pkgs.doxygen.overrideAttrs (_: rec { 2name = "doxygen-1.9.1"; 3src = pkgs.fetchurl { 4 urls = [ 5 "mirror://sourceforge/doxygen/${name}.src.tar.gz" # faster, with https, etc. 6 "http://doxygen.nl/files/${name}.src.tar.gz" 7 ]; 8 sha256 = "1lcif1qi20gf04qyjrx7x367669g17vz2ilgi4cmamp1whdsxbk7"; 9}; 10});| rgoswami.me
It so happens that only a precious few generators are recognized for parsing blog-post entries into Zotero, that is: 1 2 3 4 5 This is really rather silly to put on say, a hugo generated site, but since the embedded metadata-parsing is so much better, it kind of makes sense to do so as a stop gap solution. The code which handles these meta tags for blogPosts can be seen upstream.| rgoswami.me
nix aside1, I recently shifted to using asdf to manage different language versions. 1git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.8.1 The main reason to prefer asdf over competing language specific options like rvm or pyenv or nvm and company is simply uniformity of the interface. This can be coupled with zinit snippet OMZ::plugins/asdf for loading the completions. Note that the installation steps can take a while especially if openssl is being installed.| rgoswami.me