Skip to content

Instantly share code, notes, and snippets.

@gonewest818
gonewest818 / deferred-chaining.el
Last active March 1, 2020 20:13
emacs-deferred dynamic chaining example
(require 'deferred)
(require 'request)
(setq xyzzy (deferred:$
(deferred:next
(lambda () (message "test")))
(deferred:nextc it
(lambda (x) (message "nextc: %s" x)))))

foo

bar

baz

@gonewest818
gonewest818 / generate-spinner.el
Last active February 20, 2020 22:06
elisp animated spinner generator
;; to generate an animated spinner
;;
;; starting from from this:
;; ".oO@Oo."
;;
;; and producing this:
;; ["[ ]"
;; "[. ]"
;; "[o. ]"
;; "[Oo. ]"
@gonewest818
gonewest818 / org.gnu.emacs-daemon.plist
Last active December 13, 2019 19:29
MacOS: configure launchd to run `emacs --fg-daemon` at login
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.gnu.emacs-daemon</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/emacs</string>
<string>--fg-daemon</string>
@gonewest818
gonewest818 / lein-test-ns.clj
Last active February 13, 2018 19:18
what are all the namespaces`lein test` will run?
;; from #clojurians with thanks to @noisesmith for posting
;; note: all namespaces must be loaded in repl
(->> (all-ns)
(mapcat ns-publics)
(filter (comp :test meta val)))
@gonewest818
gonewest818 / dimmer.el
Created December 3, 2017 20:27
elisp to "dim" faces except in the current window - work in progress
;; This buffer is for text that is not saved, and for Lisp evaluation.
;; To create a file, visit it with C-x C-f and enter text in its buffer.
(setq face-remapping-alist nil)
(with-selected-window (get-buffer-window "*eshell*")
(setq face-remapping-alist nil)
(redraw-display))
@gonewest818
gonewest818 / out.txt
Last active November 9, 2017 00:36
spacelpa packages that don't occur in melpa-stable
;; This list was formed by clipping the version numbers from the spacelpa
;; and melpa-stable package names and then comparing the resulting strings.
;; In other words, this comparison is blind to version differences.
;; If a name appears here, it means spacelpa provides some version of this
;; package and melpa-stable has nothing, not even an older version.
2048-game
add-node-modules-path
@gonewest818
gonewest818 / cider-pprint-eval-to-buffer-experiments.el
Last active November 9, 2017 19:21
cider-pprint-eval-last-sexp-to-buffer
(setq lexical-binding t)
(defun cider-eval-pprint-to-multiline-comment-handler (buffer location arrow-prefix comment-prefix)
"Make a handler for evaluating and printing commented results in BUFFER.
LOCATION is the location at which to insert.
COMMENT-PREFIX is the comment prefix to use."
(cl-flet ((multiline-comment-handler (buffer value)
(with-current-buffer buffer
(save-excursion
@gonewest818
gonewest818 / cider-load-buffer-and-set-ns.el
Last active October 14, 2017 18:15
cider-load-buffer-and-set-ns
(defun cider-load-buffer-and-set-ns (&optional buffer)
"Load buffer's file and set ns in nREPL"
(interactive)
(let ((buf (current-buffer))
(ns (cider-current-ns)))
(cider-load-buffer buf)
(cider-repl-set-ns ns)))
@gonewest818
gonewest818 / jmx-thread-stats.clj
Last active February 28, 2020 15:15
getting thread stats via jmx in clojure
(ns xyz.core
(:require [clojure.string :refer [lower-case]])
(:import java.lang.management.ManagementFactory))
(defn describe-thread
"describe thread based on thread-info"
[thread-mx-bean thread-info]
(let [id (.getThreadId thread-info)]
{:id id