Skip to content

Instantly share code, notes, and snippets.

View alphapapa's full-sized avatar

Adam Porter alphapapa

  • USA
View GitHub Profile
#!/usr/bin/env hy3
(import [requests [get :as fetch]])
(require [hy.extra.anaphoric [ap-each :as aeach
ap-map :as amap]]
[hy.contrib.walk [let]])
(defmacro try* [&rest body]
`(try ~@body
@alphapapa
alphapapa / test-data.org
Created January 16, 2019 13:20
org-ql all-dates testing

Plain inactive

[2019-02-01 Fri]

Deadline

Scheduled

Closed

Plain active

@alphapapa
alphapapa / dll-fifo.el
Created January 1, 2019 01:39 — forked from jordonbiondo/dll-fifo.el
A fifo queue in emacs lisp using a cyclic doubly linked list.
;; FIFO queue implementation using cyclic doubly linked lists
;;
;; This data structure is a bit overkill for a queue,
;; but it has many other uses
;; a doubly linked list cell look like (val . (prev-cell next-cell))
;;
;; a FIFO queue object looks like ('fifo . cyclic-doubly-linked-list)
;;
;; An empty FIFO queue would be: ('fifo . nil)
@alphapapa
alphapapa / let-it-snow.el
Last active January 3, 2020 17:15
Let it snow in Emacs! Moved to dedicated repo: https://github.com/alphapapa/snow.el
;; Moved to dedicated repo: https://github.com/alphapapa/snow.el
(cl-defmacro bench-lexical-binding (&key (times 1) forms ensure-equal)
"FIXME docstring"
(declare (indent defun))
`(let ((dynamic (bench-multi :times ,times :ensure-equal ,ensure-equal :raw t
:forms ,forms))
(lexical (bench-multi-lexical :times ,times :ensure-equal ,ensure-equal :raw t
:forms ,forms))
(header '("Form" "x faster than next" "Total runtime" "# of GCs" "Total GC runtime"))
combined-results)
(cl-loop for result in-ref dynamic

--filter

(bench-multi :times 1000 :ensure-equal t
  :forms (("buffer-local-value" (--filter (equal 'magit-status-mode (buffer-local-value 'major-mode it))
                                          (buffer-list)))
          ("with-current-buffer" (--filter (equal 'magit-status-mode (with-current-buffer it
                                                                       major-mode))
                                           (buffer-list)))))
(test-it)
Formx faster than nextTotal runtime# of GCsTotal GC runtime
buffer-local-value82.160.01520145899999999900.0
with-current-bufferslowest1.249006865000000100.0
@alphapapa
alphapapa / org-kbd.el
Created December 16, 2018 10:24
Org mode: Add syntax to export HTML KBD elements
;;; org-kbd
;; (setq org-emphasis-alist '(("%" org-kbd verbatim)
;; ("*" bold)
;; ("/" italic)
;; ("_" underline)
;; ("=" org-verbatim verbatim)
;; ("~" org-code verbatim)
;; ("+"
;; (:strike-through t))))
@alphapapa
alphapapa / fitness.org
Last active April 6, 2024 04:33
An Emacs food/weight/workout tracker self-contained in a single Org file

Plots

/home/me/org/double-plot.png

Tasks

@alphapapa
alphapapa / wget-page.sh
Created November 23, 2018 09:07
Archive web pages with wget, optionally compressing with tar
#!/bin/bash
# * Defaults
compression=xz
subdir="web"
# * Functions
function debug {