Skip to content

Instantly share code, notes, and snippets.

@ruediger
ruediger / quiz.c++
Created April 15, 2014 19:13
C++11 Quiz
// Quick C++11 Quiz
typedef istreambuf_iterator<char> iter;
stringstream ss("a");
iter const i(ss);
iter j(i);
iter const end;
++j;
cout << boolalpha << (j == end) << " " << (i == end) << endl;
@ruediger
ruediger / hermsk.sh
Last active August 29, 2015 13:58
run hermsk
#!/bin/bash
function die() {
echo "Error: ${@}!" >&2
exit 1
}
: "${INPUT_DATA_PATH:=~/develop/hermsk/mpauli/}"
input=
@ruediger
ruediger / gist:8964387
Last active August 29, 2015 13:56
git-remote-bzr error
$ git pull
fatal: mark :399671 not declared
fast-import: dumping crash report to .git/fast_import_crash_4248
fatal: Error while running fast-import
Traceback (most recent call last):
File "/usr/bin/git-remote-bzr", line 952, in <module>
sys.exit(main(sys.argv))
File "/usr/bin/git-remote-bzr", line 936, in main
do_import(parser)
File "/usr/bin/git-remote-bzr", line 398, in do_import
@ruediger
ruediger / init-bibtex-mode.el
Last active December 17, 2015 17:58
urlify doi entries in bibtex
;; A better version of this is now upstream! See comments.
;; bibtex-mode
(add-hook 'bibtex-mode-hook
(lambda ()
(setq bibtex-generate-url-list
(cons (list '("doi" . "10\\.[0-9]+/.+")
(concat (or org-doi-server-url "http://dx.doi.org/") "%s")
'("doi" "10\\.[0-9]+/.+" 0))
bibtex-generate-url-list)
@ruediger
ruediger / attributes
Last active September 2, 2024 17:28
A collection of additional "custom hunk header" patterns for .gitattributes. This provides better context in the diff hunk header.
*.tex diff=tex
*.bib diff=bibtex
*.c diff=cpp
*.h diff=cpp
*.c++ diff=cpp
*.h++ diff=cpp
*.cpp diff=cpp
*.hpp diff=cpp
*.cc diff=cpp
*.hh diff=cpp
(defun browse-in-open-browser (&rest args)
(apply
(or (cl-dolist (process (proced-process-attributes))
(let* ((process-data (cdr process))
(comm (cdr (assq 'comm process-data))))
(when (string= (cdr (assq 'user process-data)) user-login-name)
(cond
((string= comm "firefox")
(cl-return #'browse-url-firefox))))))
#'browse-url-default-browser)
@ruediger
ruediger / holidays.el
Last active January 16, 2024 13:02
Austrian Holidays for Emacs (Diary)
;; Diary
(require 'holidays)
(setq holiday-austria-holidays '((holiday-fixed 1 1 "Neujahr")
(holiday-fixed 1 6 "Heilige Drei Könige")
(holiday-easter-etc 1 "Ostermontag")
(holiday-fixed 5 1 "Staatsfeiertage")
(holiday-easter-etc 39 "Christi Himmelfahrt")
(holiday-easter-etc 50 "Pfingstmontag")
(holiday-easter-etc 60 "Fronleichnam")
(holiday-fixed 8 15 "Mariä Himmelfahrt")
@ruediger
ruediger / gist:5345354
Last active December 16, 2015 00:09
renumber-offset
(defun renumber-offset (&optional offset regex subexp)
"Add OFFSET to any number matching REGEXP.
If OFFSET is nil then 1 is chosen.
If REGEXP is nil then only numbers at the beginning of line are replaced.
SUBEXP can be used to give the number of the subexp of REGEX."
(interactive "p")
(setq offset (or offset 1))
(setq regex (or regex "^[[:digit:]]+"))
(save-excursion
(goto-char (point-min))
@ruediger
ruediger / gist:5338669
Created April 8, 2013 17:30
compile buffer stuff
;; Compile-Buffer
(setq compilation-scroll-output 'first-error)
(defmacro my-compile-command (compiler flags)
"Create mode hook to generate `compile-command'."
`(lambda ()
(flyspell-prog-mode)
(unless (or (file-exists-p "Makefile")
(local-variable-p 'compile-command)
(not buffer-file-name))
@ruediger
ruediger / rct.bash
Created November 6, 2012 22:59
rct wrapper
${CXX:-g++} -fplugin=$(pwd)/python.so -fplugin-arg-python-script=$(pwd)/src/rct.py "${@/--rct-/--fplugin-arg-python-rct-}"