Skip to content

Instantly share code, notes, and snippets.

View alphapapa's full-sized avatar

Adam Porter alphapapa

  • USA
View GitHub Profile
@alphapapa
alphapapa / emacs-raise-or-run
Last active February 11, 2020 18:06
emacs-raise-or-run and org-git-add-commit
#!/bin/bash
# ** Vars
# *** Emacs version
if type emacs26 &>/dev/null
then
emacs="emacs26"
emacsclient="emacsclient26"
emacsWindowClass="Emacs"
@alphapapa
alphapapa / intersection-benchmarks.org
Last active January 30, 2020 06:24
Benchmarking list intersections

Note that the update to the macros which provide the :setup argument is not published yet…

(bench-multi-lexical ;; :ensure-equal t
  :times 100
  :setup (progn
           (setq lst1 (make-random-list 1000)
                 lst2 (make-random-list 1000))
           (defun make-random-list (n)
             (let ((l nil))
(defun ap/overlay-isearch-test ()
(interactive)
(with-current-buffer (get-buffer-create "*overlay-isearch-test*")
(pop-to-buffer (current-buffer))
(erase-buffer)
(dolist (ov (overlays-in (point-min) (point-max)))
(delete-region (overlay-start ov) (overlay-end ov))
(delete-overlay ov))
(insert "foo\n")
(ap/insert-overlaid "bar\n" :transcluded-content t)
@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
@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 / org-tree-view.el
Last active October 1, 2019 13:02
Show Org outline tree in a side buffer
;; NOTE: This has been superseded by `org-sidebar-tree': https://github.com/alphapapa/org-sidebar#org-sidebar-tree-command
(defun ap/open-tree-view ()
"Open a clone of the current buffer to the left, resize it to
30 columns, and bind <mouse-1> to jump to the same position in
the base buffer."
;; http://emacs.stackexchange.com/questions/9530/how-can-i-get-an-org-mode-outline-in-a-2nd-buffer-as-a-dynamic-table-of-contents
;; TODO: Make this use navi-mode, which handles most of this already
(interactive)
(let ((new-buffer-name (concat "<tree>" (buffer-name))))
@alphapapa
alphapapa / ap-helm-find-files.el
Created May 31, 2018 04:03
Custom Helm find-files command
(defun ap/helm-find-files ()
(interactive)
(helm :sources '(ap/helm-source-ivy-views
ap/helm-source-current-file-other-buffers
helm-source-buffers-list
ap/helm-source-files-in-current-dir
helm-source-org-recent-headings
helm-source-bookmarks
ap/helm-source-recentf
ap/helm-source-bindir
@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 / 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