Skip to content

Instantly share code, notes, and snippets.

View saravanabalagi's full-sized avatar

Saravanabalagi Ramachandran saravanabalagi

  • Ireland
View GitHub Profile
@saravanabalagi
saravanabalagi / README.md
Created August 27, 2025 18:49
MacOS Swap ` (tilde) and § (section) keys in UK Keyboard
  1. Copy to ~/Library/LaunchAgents/com.hidutilKeyMapping.plist
  2. Open System Settings > Privacy & Security > Input Monitoring and add /usr/bin/hidutil (Hint: Cmd Up will open parent folder and Cmd Shift . will reveal hidden files)
  3. Verify hdutil present in System Settings > General > Login Items & Extensions
@saravanabalagi
saravanabalagi / pull_ollama_models.py
Created August 27, 2025 18:43
Pull multiple ollama models
import os
models = {
"all-minilm": ["l6-v2"],
"deepseek-r1": ["1.5b", "7b", "8b", "14b", "32b", "70b"],
"devstral": ["24b"],
"gemma3": ["1b-it-qat", "4b-it-qat", "12b-it-qat", "27b-it-qat", "1b", "4b", "12b", "27b"],
"llama3.2": ["1b", "3b"],
"llama3.3": ["70b"],
@saravanabalagi
saravanabalagi / latex_multiple_consecutive_cites.md
Created May 18, 2025 15:53
Regex to find consecutive \cite commands
  1. Avoid multiple consecutive \cite commands in succession, e.g. \cite{my_citation_1}\cite{my_citation_2}
  2. Combine into a \cite{} with citations separated by comma, e.g. \cite{my_citation_1,my_citation_2}

Regex

Use the following regex to find such patterns

\\cite\{([\w,]+)\}([ ~,;]*\\cite\{([\w,]+)\})
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Battery_state</key>
<false/>
<key>CPU_barChart_position</key>
<integer>0</integer>
<key>CPU_bar_chart_box</key>
<true/>
@saravanabalagi
saravanabalagi / us_to_uk_check.md
Created December 2, 2024 17:23
Regex for US to UK english to replace "iz" with "is"

Regex for US to UK english

To replace "iz" with "is" in LATEX documents:

  • find
(?<!\\(?:cite|href|url)\{[^}]*)(\b(?!size\b|sizes\b|sized\b|downsize\b|footnotesize\b|BSize\b|resized\b|quantize\b|quantization\b|horizontally\b|itemize\b|scriptsize\b|resize\b|horizontal\b|Webviz\b|OdoViz\b)\w*)iz(\w*\b)
  • replace
@saravanabalagi
saravanabalagi / find_duplicates_in_bib.py
Created December 2, 2024 17:15
Find duplicates in bibtex file based on publication title
import bibtexparser
from collections import defaultdict
# Replace 'yourfile.bib' with the path to your BibTeX file
bibtex_filename = 'root.bib'
# Load the BibTeX file
with open(bibtex_filename, encoding='utf-8') as bibtex_file:
bib_database = bibtexparser.load(bibtex_file)
@saravanabalagi
saravanabalagi / arrow_keys_shortcuts.ahk
Created August 5, 2024 08:18
AutoHotkey Config for Arrow keys
SC110::Send, {Home}
SC119::Send, {End}
SC124::Send, {PgUp}
SC122::Send, {PgDn}
+SC110::Send, +{Home}
+SC119::Send, +{End}
+SC124::Send, +{PgUp}
+SC122::Send, +{PgDn}
@saravanabalagi
saravanabalagi / Add_GLU_torch_pruning.md
Last active April 10, 2024 22:29
Add GLU to Torch Pruning lib WIP

In dependency.py, add a new update fn in DependencyGraph

    def _update_glu_index_mapping(self, glu_node: Node):
        if glu_node.type != ops.OPTYPE.GLU:
            return

        # GLU halves the number of channels by applying sigmoid
        input_node = glu_node.inputs[0]
        in_channels = self.get_out_channels(input_node)
@saravanabalagi
saravanabalagi / .pre-commit-config.yaml
Last active March 6, 2024 16:45
Ruff all rules with description
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.2
hooks:
- id: ruff
args: [ --fix ]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
@saravanabalagi
saravanabalagi / img_combine_h.py
Created December 11, 2023 13:55
Combines images horizontally using imagemagick in the specified directory based on filename suffixes: img_01.jpg, img_02.jpg, img_03.jpg will be combined into img.jpg
from pathlib import Path
import subprocess
import argparse
def find_and_append_images_with_pathlib(directory):
"""
Adjusted script using pathlib to find images in the specified directory with a given pattern
and append them horizontally using the 'convert' command from ImageMagick.
It supports both .jpg and .png files and handles different suffix patterns.