Skip to content

Instantly share code, notes, and snippets.

View joostkremers's full-sized avatar

Joost Kremers joostkremers

  • CE-CON
  • Osterholz-Scharmbeck, Germany
View GitHub Profile
@joostkremers
joostkremers / count-char-in-string.el
Last active October 13, 2015 22:39
Emacs: timing count-char-in-string.el implementations
;; http://emacs.1067599.n5.nabble.com/How-to-count-the-number-of-occurrences-of-a-character-in-a-string-td371732.html
(defvar num-repeats 100000)
(defun count-char-in-string-cl-count (char str)
(cl-count char str))
(defun count-char-in-string-mapcar (char str)
(apply '+ (mapcar (lambda (x) (if (= x char) 1 0))
str)))
@joostkremers
joostkremers / ebib-filter-n-days.el
Created January 7, 2015 08:26
Ebib: filter recently added entries (updated for Ebib 2.1)
(defun ebib-filter-n-days (n)
"Filter entries added in the last n days"
(let* ((field "timestamp")
(day-of-year (string-to-number (format-time-string "%j")))
(n-days-ago (- day-of-year (- n 1)))
(days-between (number-sequence n-days-ago day-of-year))
(regexp-days-between (mapconcat (lambda (x)
(concat "\\(" (number-to-string x) "d\\)"))
days-between "\\|")))
@joostkremers
joostkremers / gist:5561773
Created May 11, 2013 23:18
Emacs lisp code to run pandoc on each buffer where pandoc-mode is activated.
(defun pandoc-process-all-buffers (prefix)
"Run pandoc on all buffers with pandoc-mode enabled."
(interactive "P")
(let ((buffers (buffer-list)))
(mapc #'(lambda (buffer)
(set-buffer buffer)
(when pandoc-mode
(when (or (and prefix (y-or-n-p (format "Process buffer `%s' with pandoc? (y/n)" (buffer-name buffer))))
(not prefix))
(pandoc-run-pandoc nil))))
@joostkremers
joostkremers / gist:3782203
Created September 25, 2012 14:18
Homebrew: installing mu --with-emacs --HEAD does not install mu4e
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by mu configure 0.9.9-dev4, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ ./configure --disable-dependency-tracking --prefix=/usr/local/Cellar/mu/HEAD --with-gui=none
## --------- ##
## Platform. ##
@joostkremers
joostkremers / gist:3776197
Created September 24, 2012 14:24
Homebrew: error installing mu --HEAD
joost@pc201:~ $ HOMEBREW_MAKE_JOBS=1 VERBOSE=1 brew install mu --with-emacs --HEAD
==> Cloning https://github.com/djcb/mu.git
Updating /Users/joost/Library/Caches/Homebrew/mu--git
git config remote.origin.url https://github.com/djcb/mu.git
git config remote.origin.fetch +refs/heads/master:refs/remotes/origin/master
git fetch origin
git reset --hard origin/HEAD
HEAD is now at 18ccc3c * man: update mu-server doc
git checkout-index -a -f --prefix=/private/tmp/brew-mu-HEAD-1IPM/
==> autoreconf -ivf