Skip to content

Instantly share code, notes, and snippets.

View ohmyhub's full-sized avatar
🦋
I'm going to go buy ice cream.

kevin ohmyhub

🦋
I'm going to go buy ice cream.
View GitHub Profile
@rougier
rougier / make-box.el
Last active February 6, 2025 04:05
Emacs: add borders around some part of a buffer
;;; make-box.el --- Box around part of a buffer -*- lexical-binding: t -*-
;; Copyright (C) 2024 Nicolas P. Rougier
;; Maintainer: Nicolas P. Rougier <Nicolas.Rougier@inria.fr>
;; Version: 0.1.0
;; Package-Requires: ((emacs "27.1"))
;; Keywords: convenience
;; This file is not part of GNU Emacs.
@jdtsmith
jdtsmith / org-toggle-emphasis.el
Last active November 20, 2024 15:44
org-toggle-emphasis: easily toggle emphasis markers: =~*/_+
(defun my/org-toggle-emphasis (type)
"Toggle org emphasis TYPE (a character) at point."
(cl-labels ((in-emph (re)
"See if in org emphasis given by RE."
(and (org-in-regexp re 2)
(>= (point) (match-beginning 3))
(<= (point) (match-end 4))))
(de-emphasize ()
"Remove most recently matched org emphasis markers."
(save-excursion
@sebastiancarlos
sebastiancarlos / sway-print-tree.bash
Last active February 19, 2024 15:18
sway-print-tree.bash (Pretty print Sway/i3 tree, color output, 'jq' is the only dependency)
#! /usr/bin/env bash
# ansi colors
bold='\033[1m'
red='\033[0;31m'
green='\033[0;32m'
yellow='\033[1;33m'
blue='\033[0;34m'
reset='\033[0m'
#!/usr/bin/bash
menu=" Minimize\n Floating Toggle\n Window Shot\n Move Workspace\n Close"
swspc () {
wspc=$(wofi -d -W 15% --prompt="Move To Worspace" --lines=2); swaymsg move window to workspace $wspc
}
active=$(swaymsg -t get_tree | jq -r 'recurse(.nodes[]?, .floating_nodes[]?) | select(.focused) | .rect | "\(.x),\(.y)"')
@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
@rougier
rougier / imenu-filter.org
Created May 7, 2022 18:06
Filter for imenu-list

Section 1

Section 1.1

Section 1.1.1

Section 1.1.2

Section 1.2

Section 1.2.1

Section 1.2.2

@Eanilsen
Eanilsen / roam-search.el
Created February 18, 2022 07:45
Counsel-ag search for Roam directory
(defun me/counsel-ag-roam ()
"Do counsel-ag on the org roam directory"
(interactive)
(counsel-ag nil org-roam-directory))
@jsilve24
jsilve24 / print-helper.el
Created December 2, 2021 01:03
Simple print helper, its a thin wrapper around pdf-tools' pdf-misc-print-document that lets you select a printer registered with CUPS.
;; see cups help page for lots on how to print with lpr and lp
;; the below functions assume these options are set
(setq pdf-misc-print-program-executable "/usr/bin/lpr"
pdf-misc-print-program-args (list "-o sides=two-sided-long-edge"))
;;; print-helper -- not enough to make a stand-alone package
(require 'dash)
;;;###autoload
(defun ph--get-list-of-priters ()
@roadkell
roadkell / acpi-call-kernel-oops.md
Last active November 3, 2025 13:07
Fixing acpi_call kernel oops on Thinkpads

Fixing acpi_call kernel oops on Thinkpads

Intro

TLP, a power management utility for Thinkpads and other laptops, uses tpacpi-bat script for battery calibration and setting charge thresholds (for Thinkpads xx20 and later), which in turn uses acpi_call Linux kernel module that enables calls to ACPI methods through /proc/acpi/call. acpi_call can also be used for hybrid graphics switching and other power management tasks.

What happened

As explained here and here, a kernel upstream commit made seek support for [procfs](https://en.wikipedia.org/wiki/

@dylan-slack
dylan-slack / gpt3-estimate-costs.py
Created May 30, 2021 00:31
Compute the cost of running GPT3 on a set of prompts. Store all the costs incurred so far.
"""
Estimate GPT-3 costs!
Author: Dylan
"""
import math
class GPT3CostsCalculator:
def __init__(self,
gpt3_model_version,