Skip to content

Instantly share code, notes, and snippets.

View agzam's full-sized avatar
👀
Available for hire

Ag Ibragimov agzam

👀
Available for hire
View GitHub Profile
@agzam
agzam / update_kbd.js
Created January 28, 2024 02:21
Update Kinesis 360 ZMK helper
// OMG. This all so stupidly dirty and so needlessly tangled.
// I imagined this would be a tiny, simple thing, but it came out as this crap.
// Fuck Javascript, I should rewrite the whole thing in Clojurescript (but I'm lazy)
//
// This is a helper script to update Kinesis 360 firmware.
// When you put the keyboard in the bootloader mode it becomes unavailable, and you can't type
// but the mouse remains connected.
// This thing basically loads a tiny html page where you can click things to update and unblock your keyboard.
//
// Prerequisites:
@agzam
agzam / send-browser-urls-to-emacs-eww.org
Last active October 7, 2022 15:21
Send browser URLs to Emacs EWW (Mac)

Instructions and the script for https://www.youtube.com/watch?v=05wghiNzIj0

EWW - Emacs’ built-in browser is great for many things. Simple use cases include:

  • Opening any file on GitHub/GitLab without having to download it
  • Log investigation e.g., for GitHub Actions
  • Reading PDF - link to a pdf doc opens it in pdf-tools (if installed)
  • Bypassing a paywall
(defun outline-collapsed? ()
"Returns nil if the top outline heading is collapsed (hidden)"
(save-excursion
(when (org-get-outline-path 'with-self?)
(ignore-errors (outline-up-heading 1))
(let* ((beg (point))
(end (+ 1 (line-end-position))))
(not
(seq-empty-p
(seq-filter
@agzam
agzam / log
Last active February 9, 2021 06:01
clojure-lsp GraalVM build failing
clojure-lsp on  master via ☕ v11.0.10 at 23:00:01 ❯ ./graalvm/native-unix-compile.sh
Picked up JAVA_TOOL_OPTIONS: -Dapple.awt.UIElement=true
OpenJDK 64-Bit Server VM warning: forcing TieredStopAtLevel to full optimization because JVMCI is enabled
Picked up JAVA_TOOL_OPTIONS: -Dapple.awt.UIElement=true
Compiling 1 source files to /Users/ag/sandbox/clojure-lsp/target/classes
Picked up JAVA_TOOL_OPTIONS: -Dapple.awt.UIElement=true
Compiling clojure-lsp.clojure-core
Compiling clojure-lsp.crawler
Compiling clojure-lsp.db
Compiling clojure-lsp.feature.call-hierarchy
@agzam
agzam / zathura-client.org
Last active September 8, 2024 15:37
Open pdf files with Zathura on Mac

Zathura on Mac

I want to open PDF files with Zathura on Mac. Problem is - Zathura does not have a proper App Bundle. So you cannot go in Finder to a pdf file, navigate to ‘Get Info’ and set pdf files to be opened with Zathura.

Luckily, you can create a custom App Bundle that wraps up a script that does that

But that is not as straightforward as you think it is, you can’t just execute a shell script. What if the file already opened with one of the instances of zathura process? Since Zathura is not a native OSX app, it will create a new process instance every time you open it.

The following script opens a file in Zathura, and if it was already opened, it would only activate the right window.

How to use it

@agzam
agzam / funcs.el
Created October 10, 2020 20:33
Find a message in a mailing list
(defun mu4e-action-find-in-mailing-list (msg)
"Find message in mailing-list archives"
(interactive)
(let* ((mlist (mu4e-message-field msg :mailing-list))
(msg-id (mu4e-message-field msg :message-id))
(url
(pcase mlist
;; gnu.org
((pred (lambda (x) (string-suffix-p "gnu.org" x)))
@agzam
agzam / toggle-frame-maximized-undecorated.el
Last active August 28, 2020 02:10
Emacs undecorated (title-less) frame in OSX
(defun toggle-frame-maximized-undecorated ()
(interactive)
(let* ((frame (selected-frame))
(on? (and (frame-parameter frame 'undecorated)
(eq (frame-parameter frame 'fullscreen) 'maximized)))
(geom (frame-monitor-attribute 'geometry))
(x (nth 0 geom))
(y (nth 1 geom))
(display-height (nth 3 geom))
(display-width (nth 2 geom))
@agzam
agzam / diff-last-two-kills.el
Last active July 27, 2020 15:46
Diff last couple of things in the kill ring
(defun diff-last-two-kills (&optional ediff?)
"Diff last couple of things in the kill-ring. With prefix open ediff."
(interactive "P")
(let* ((old "/tmp/old-kill")
(new "/tmp/new-kill")
(prev-ediff-quit-hook ediff-quit-hook))
(cl-flet ((kill-temps
()
(dolist (f (list old new))
(kill-buffer (find-buffer-visiting f)))
@agzam
agzam / custom-org-insert-link.org
Last active June 30, 2020 23:29
Customize org-insert-link
@agzam
agzam / ibuffer-unsaved-files.el
Last active March 27, 2020 00:10
Custom iBuffer filter for unsaved buffers
(define-ibuffer-filter unsaved-file-buffers
"Toggle current view to buffers whose file is unsaved."
(:description "file is unsaved")
(ignore qualifier)
(and (buffer-local-value 'buffer-file-name buf)
(buffer-modified-p buf)))
(define-key ibuffer-mode-map (kbd "/ u") #'ibuffer-filter-by-unsaved-file-buffers)