Skip to content

Instantly share code, notes, and snippets.

View haji-ali's full-sized avatar

Abdul-Lateef Haji-Ali haji-ali

View GitHub Profile
@haji-ali
haji-ali / karabiner-emacs.yaml
Created August 21, 2023 10:41
A Karabiner YAML config for Emacs keybindings
---
global:
ask_for_confirmation_before_quitting: true
check_for_updates_on_startup: true
show_in_menu_bar: false
show_profile_name_in_menu_bar: false
unsafe_ui: false
profiles:
- complex_modifications:
parameters:
@haji-ali
haji-ali / karabiner-yaml.py
Created August 21, 2023 10:40
A script to convert a short karabiner YAML config to JSON one
#!/usr/bin/env python3
import yaml
import json
import re
import sys
def transform_key(key, is_from=True):
mod_map = {"M":"option", "C":"control", "S":"command", "F":"fn"}
m = re.match(r"^((?:(?:C|F|S|M)-)*)(.*)", key)
@haji-ali
haji-ali / org-minical.el
Last active July 22, 2023 22:30
Org Date picker in minibuffer
;;; org-minical.el --- Org Date picker in minibuffer -*- lexical-binding: t; -*-
;; Copyright (C) 2023, Al Haji-Ali
;; Author: Al Haji-Ali <abdo.haji.ali at gmail.com>
;; Created: Author
;; Version: 0.0.1
;; Package-Requires: ((emacs "28.1"))
;; Keywords: calendar
@haji-ali
haji-ali / emacs29-crash.log
Created November 9, 2022 22:43
Emacs crash log
-------------------------------------
Translated Report (Full Report Below)
-------------------------------------
Process: Emacs [18026]
Path: /opt/homebrew/*/Emacs.app/Contents/MacOS/Emacs
Identifier: org.gnu.Emacs
Version: Version 29.0.50 (9.0)
Code Type: ARM-64 (Native)
Parent Process: launchd [1]
@haji-ali
haji-ali / echo-line.el
Last active August 30, 2022 08:48
Echo messages in minibuffer
;;; echo-line.el --- Echo messages in minibuffer -*- lexical-binding:t -*-
;;
;; Author: Al Haji-Ali <abdo.haji.ali@gmail.com>
;; Version: 0.1.0
;; Package-Requires: ((emacs "26.1"))
;; Keywords: message, echo, gui
;;
;; This file is not part of GNU Emacs.
;;
;; This program is free software; you can redistribute it and/or modify
@haji-ali
haji-ali / break-string.el
Last active July 15, 2022 23:11
Break long string with backslashes
(defun break-string (do-not-break column-width)
"Break string to a fit within a fill-column.
If DO-NOT-BREAK is non-nil (set with `C-u') then join a broken
string. COLUMN-WIDTH defaults to `fill-column'"
(interactive (list current-prefix-arg
fill-column))
(save-excursion
(let* ((initial (point))
(string-start (search-backward-regexp "\\([^\\]\\|^\\)\"" nil t))
(start-col (current-column))
@haji-ali
haji-ali / copy-file.sh
Last active February 15, 2021 17:38
Copy file, backing up the destination file if its different form the source.
#!/bin/bash
#!/bin/bash
function copy-file {
SRC=$1
DEST=$2
# Make sure DEST is a file
if [ ! -f "$SRC" ]; then
echo "Source file does not exist"
@haji-ali
haji-ali / concat-pdf.sh
Last active October 29, 2019 13:35
Concatenates a list of pdfs ensuring that blank pages are added when the number of pages are odd.
#!/bin/sh
# USAGE: ./concat-pdf.sh *.pdf output-file.pdf
ALL_FILES=""
BLANK_FILE="/tmp/blank.pdf"
for OUTPUT_FILE; do true; done
if test -f "$OUTPUT_FILE"; then
echo "$OUTPUT_FILE already exists"
exit 1