Skip to content

Instantly share code, notes, and snippets.

View alphapapa's full-sized avatar

Adam Porter alphapapa

  • USA
View GitHub Profile
@alphapapa
alphapapa / hide-show-layers.scm
Created October 8, 2019 20:30
GIMP: Hide/Show all layers in current image
;; When editing an image with many layers (e.g. an animated GIF with
;; hundreds of frames), it's impossibly tedious to click hundreds and
;; hundreds of times on small little boxes to hide or show all layers.
;; Since GIMP seems to lack a button to hide/show all of them, and it
;; doesn't allow selection of multiple layers, this script provides
;; menu items to hide/show all layers at once.
;; Who knows if later versions of GIMP than I have provide a way to do
;; this, but this works, and maybe it will be helpful to someone.
@alphapapa
alphapapa / juliet-0ac22.el
Created September 2, 2019 18:28
Benchmarking Emacs stuff
;;; Memoization benchmark -*- lexical-binding: t; -*-
;; Ref: https://github.com/skeeto/emacs-memoize
;; $ emacs -Q --batch -L path/to/memoize -f batch-byte-compile memoize-bench.el
;; $ emacs -Q --batch -L path/to/memoize -l memoize-bench.elc
;; Note: Benchmark requires at least 64-bit integers. Choose one of:
;; * Emacs >= 27
;; * Emacs <= 26 on 64-bit host
@alphapapa
alphapapa / magit.sh
Last active April 5, 2020 10:18
Run a standalone Magit editor!
# Please see the script's new home: https://github.com/alphapapa/magit.sh
@alphapapa
alphapapa / bench.org
Last active August 17, 2019 06:47
Emacs: Benchmarking sequence shuffling

Benchmarking sequence shuffling

See melpa/melpa#6191 (comment)

(defun key-quiz--shuffle-list (list)
  "Shuffles LIST randomly, modying it in-place."
  (dolist (i (reverse (number-sequence 1 (1- (length list)))))
    (let ((j (random (1+ i)))
	  (tmp (elt list i)))
#!/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)))))