Skip to content

Instantly share code, notes, and snippets.

@lgmoneda
lgmoneda / textual-topography.el
Created January 4, 2025 15:43
Textual Topography
;; Textual topography
(defun textual-topography ()
"Prompt for domain, characteristic/anti-characteristic pair, and selected text.
Save selected text to a file and call a Python script with the arguments."
(interactive)
;; Define the domains and their associated characteristic/anti-characteristic pairs
(setq domain-characteristics
'(("Mood" . (("Happy" . "Unhappy") ("Calm" . "Agitated") ("Optimistic" . "Pessimist")))
("Style" . (("Complex" . "Simple")))
@lgmoneda
lgmoneda / publishing-jekyll.el
Last active January 21, 2025 11:11
Publishing from org-roam to jekyll blog
;; Blogging
;; The following function helps me to write in a single file in org-roam to produce my personal blog posts.
;; It avoids copying and pasting to the markdown file for jekyll.
(defun lgm/publish-org-roam-to-jekyll-html (github-repo-dir output-dir branch)
"Export current Org Roam file to Jekyll-compatible HTML5 with YAML front matter.
GITHUB-REPO-DIR: Path to your GitHub Pages repository.
OUTPUT-DIR: Directory inside the repository where the HTML file will be placed.
BRANCH: Branch to which changes should be committed (e.g., 'master')."
@lgmoneda
lgmoneda / discourse_segmentation.py
Last active February 18, 2025 08:52
Segmenting text using the proportion of overlapping documents retrieved from a knowledge base to merge sentences
import json
import urllib.parse
import spacy
import requests
import re
from http.server import BaseHTTPRequestHandler, HTTPServer
from multi_language_utils import is_en_text, translate_to_english, load_language_detection_model
from urllib.parse import parse_qs, urlparse
;;; my-smudge-lyrics.el --- Show LRCLIB lyrics for current Smudge track -*- lexical-binding: t; -*-
;; Smudge → LRCLIB (async) → read-only lyrics buffer
;;; Commentary:
;; - M-x my-smudge-lyrics-popup: fetch lyrics for current track and show them.
;; - Optional: enable `my-smudge-lyrics-auto-popup` to auto-fetch on track change.
;;
;; Requirements:
;; - Smudge (https://github.com/danielfm/smudge)
@lgmoneda
lgmoneda / org-roam-links-in-agent-shell.el
Last active February 27, 2026 18:42
Org-roam links in agent-shell
@lgmoneda
lgmoneda / copy-markdown-paste-in-slack.el
Created April 19, 2026 19:33
Rich copy Markdown for Slack
;;; copy-markdown-paste-to-slack.el --- Rich copy Markdown for Slack -*- lexical-binding: t; -*-
(defun lmoneda/slack--copy-rich-and-plain-to-clipboard (plain-text rtf-text)
"Copy PLAIN-TEXT and RTF-TEXT to macOS clipboard as plain+rich flavors."
(unless (executable-find "osascript")
(user-error "osascript not found"))
(let* ((tmp-text-file (make-temp-file "markdown-slack-plain-" nil ".txt"))
(tmp-rtf-file (make-temp-file "markdown-slack-rich-" nil ".rtf"))
(jxa-script
"ObjC.import(\"Foundation\"); ObjC.import(\"AppKit\"); function run(argv){ const plainPath=argv[0]; const rtfPath=argv[1]; const enc=$.NSUTF8StringEncoding; const plain=$.NSString.stringWithContentsOfFileEncodingError($(plainPath), enc, null); const rtfStr=$.NSString.stringWithContentsOfFileEncodingError($(rtfPath), enc, null); const pb=$.NSPasteboard.generalPasteboard; pb.clearContents; const ok1=pb.setStringForType(plain, $.NSPasteboardTypeString); const rtfData=rtfStr.dataUsingEncoding(enc); const ok2=p