Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
;; stab at generalizing this | |
(defun line-or-region-wrapper (func) | |
(interactive) | |
(if (region-active-p) | |
(funcall func (region-beginning) (region-end)) | |
(funcall func (line-beginning-position) (line-end-position)))) | |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
(defun use-theme (theme &optional no-confirm no-enable) | |
(interactive | |
(list | |
(intern (completing-read "Load custom theme: " | |
(mapcar 'symbol-name | |
(custom-available-themes)))) | |
nil nil)) | |
(progn | |
(dolist (curtheme (custom-available-themes)) | |
(disable-theme curtheme)) |
(defun collect-regexp-results (regex) | |
;;; collects all the matches of regex in a buffer called *collect-result* | |
;;; then switches to that buffer | |
;;; TODO refactor this to take the region as a parameter | |
(interactive "Mregex to search for: ") | |
(let ((curmin (region-or-buffer-beginning)) | |
(curmax (region-or-buffer-end))) | |
(save-excursion | |
(goto-char curmin) | |
;; (goto-char (region-or-buffer-beginning)) |
(defun close-sexp () | |
;; closes the s-expression at point | |
;; by computing how many open parens and close parens | |
;; there are and inserting the appropriate number | |
;; bug: doesnt handle backquoted parens like \( \) properly | |
(interactive) | |
(let ((pt (point)) | |
(numopen 0) | |
(numclose 0)) | |
(save-excursion |
(defun multiyank (times) (interactive "p") (loop for i from 1 to times do (yank))) | |
(global-set-key (kbd "C-y") 'multiyank) |
% example code how to get dbg to run | |
% you can even run this remotely with "erl -remsh ..." | |
dbg:tracer(). | |
dbg:p(all, c). | |
dbg:tpl(mnesia, x). % x means "everything", its probably supposed to represent a * | |
mnesia:info(). |
% example code how to get dbg to run | |
% you can even run this remotely with "erl -remsh ..." | |
dbg:tracer(). | |
dbg:p(all, c). | |
dbg:tpl(mnesia, x). % x means "everything", its probably supposed to represent a * | |
mnesia:info(). |
Erlang has a powerful trace utility, similar to strace. Instead of tracing system calls, you can trace any piece of Erlang code. RabbitMQ is written in Erlang, so we can use Erlang trace to see what its doing. The extra load may flood the system, so be very careful running this in prod.
In this example we will see how Rabbit is invoking mnesia. Mnesia is the database rabbit is using.