Skip to content

Instantly share code, notes, and snippets.

View ffevotte's full-sized avatar

François Févotte ffevotte

View GitHub Profile
@ffevotte
ffevotte / generators.jl
Last active January 3, 2019 16:00
Benchmarking several ways of building iterators in Julia (see https://discourse.julialang.org/t/prefered-pattern-for-generators/18749)
# Initial tests
using BenchmarkTools
N = 1_000_000
@btime let s = 0
for i in 1:$N
s += i&1
end
(defun isend--perl (buf-name)
"Prepend 'x ' to normal perl instructions.
Leave 'print' instructions untouched."
(with-current-buffer buf-name
(goto-char (point-min))
(unless (looking-at "[[:space:]]*print")
(insert "x ")))
(insert-buffer-substring buf-name))
(defun isend-default-perl-setup ()
@ffevotte
ffevotte / gist:d7e69cf147c014381003
Last active August 24, 2017 03:15
Complement to SO answer: "How do I make the compilation window in Emacs to always be a certain size?" (http://stackoverflow.com/a/9728357/1225607)
(defun my-select-bottom-window ()
(let ((bottom-window (selected-window))
window-below)
(while (setq window-below (window-in-direction 'below bottom-window))
(setq bottom-window window-below))
(select-window bottom-window)))
(defun my-compilation-hook ()
(when (not (get-buffer-window "*compilation*"))
(save-selected-window
(defun source (filename)
"Update environment variables from a shell source file."
(interactive "fSource file: ")
(message "Sourcing environment from `%s'..." filename)
(with-temp-buffer
(shell-command (format "diff -u <(true; export) <(source %s; export)" filename) '(4))
(let ((envvar-re "declare -x \\([^=]+\\)=\\(.*\\)$"))
@ffevotte
ffevotte / foo.cxx
Created January 6, 2014 14:50
Create a precompiled header with libclang
#include "foo.hxx"
int main () {
return 0;
}
@ffevotte
ffevotte / gist:8045566
Created December 19, 2013 20:19
Additions to `desktop.el` to facilitate switching between saved sessions
;;; Desktop
(setq desktop-save 'ask)
(defvar desktop-base-dir "~/.emacs.d/desktops/"
"Base directory for desktop files")
(defun desktop--set-frame-title ()
(setq frame-title-format
(list (concat "%b - Emacs ["
(file-name-nondirectory (directory-file-name desktop-dirname))
"]"))))
@ffevotte
ffevotte / multiple-compile.el
Created August 1, 2013 12:26
Define multiple compilation commands in Emacs
;; This macro creates new compilation commands
(defmacro ff/add-compilation-command (name &optional key)
(let ((buffer-name (concat "*" name "*"))
(compile-symbol (intern name))
(recompile-symbol (intern (concat "re" name))))
(when (fboundp compile-symbol)
(warn "redefining command `%s'" name))
(when (fboundp recompile-symbol)
(warn "redefining command `re%s'" name))
`(progn
@ffevotte
ffevotte / clocktable-by-tag.el
Created July 1, 2013 07:53
Emacs org-mode dynamic block similar to clocktable, but grouped by tag See: http://stackoverflow.com/q/17353591/1225607
(defun clocktable-by-tag/shift-cell (n)
(let ((str ""))
(dotimes (i n)
(setq str (concat str "| ")))
str))
(defun clocktable-by-tag/insert-tag (params)
(let ((tag (plist-get params :tags)))
(insert "|--\n")
(insert (format "| %s | *Tag time* |\n" tag))
@ffevotte
ffevotte / gist:5322803
Created April 5, 2013 21:34
Keyboard scrolling with acceleration
(setq my-scroll-counter 0)
(setq my-scroll-limit 5)
(setq my-last-scroll 0)
(setq my-scroll-interval 0.1)
(defun up1()
(interactive)
(let ((now (float-time)))
(if (and (eq last-command this-command)
(< (- now my-last-scroll) my-scroll-interval))