Skip to content

Instantly share code, notes, and snippets.

magnars / .profile
Created May 6, 2011
Show time since last commit and branch name in prompt
View .profile
source ~/bin/git-completion.bash # or where your git-completion.bash is installed
function minutes_since_last_commit {
now=`date +%s`
magnars / buster-output.txt
Created Jun 1, 2011
Reporting too few assertions?
View buster-output.txt
watchForChanges: ....
1 test case, 4 tests, 1 assertion, 0 failures, 0 errors, 0 timeouts
magnars /
Created Dec 21, 2011
Using PeepOpen with Cocoa Emacs
on open these_items
set this_item to item 1 of these_items
set file_path to (the POSIX path of this_item)
tell application "Terminal"
do shell script "/Applications/ -n " & file_path & ""
end tell
end open
View gist:1671918
(defadvice yank-pop (around yank-pop-unsupported-advice)
"yank-pop isn't supported with multiple cursors"
(message "yank-pop-advice ho!")
(if multiple-cursors-mode
(error "yank-pop isn't supported with multiple cursors")
magnars / gist:1705973
Created Jan 30, 2012
push-mark not behaving as expected
View gist:1705973
(defun mark-five-next ()
"Marks the next five chars as expected"
(push-mark (+ 5 (point)) t t))
(defun delete-region-then-mark-five-next (start end)
"Does not mark the next five chars"
(interactive "r")
(delete-region start end)
(push-mark (+ 5 (point)) t t))
magnars / gist:1892749
Created Feb 23, 2012
Hvis bare utviklerne
View gist:1892749

Hvis bare utviklerne

  • Hvis bare utviklerne hadde vært med i salgsmøtene,
  • Hvis bare utviklerne hadde estimert sakene bedre,
  • Hvis bare utviklerne hadde planlagt sprinten nøye,
  • Hvis bare utviklerne hadde blitt enige på forhånd,
  • Hvis bare utviklerne hadde satt seg ned sammen med interaksjonsdesigneren,
  • Hvis bare utviklerne hadde satt seg ned sammen med produkteieren,
  • Hvis bare utviklerne hadde satt seg ned sammen med arkitekten,
  • Hvis bare utviklerne hadde satt seg ned sammen med kunden,
magnars / gist:2350388
Created Apr 10, 2012
Push mark when using ido-imenu
View gist:2350388
;; Push mark when using ido-imenu
(defvar push-mark-before-goto-char nil)
(defadvice goto-char (before push-mark-first activate)
(when push-mark-before-goto-char
(defun ido-imenu-push-mark ()
magnars / gist:2360578
Created Apr 11, 2012
ido-imenu as used in Emacs Rocks #10
View gist:2360578
(defun ido-imenu ()
"Update the imenu index and then use ido to select a symbol to navigate to.
Symbols matching the text at point are put first in the completion list."
(let ((name-and-pos '())
(symbol-names '()))
(flet ((addsymbols (symbol-list)
(when (listp symbol-list)
(dolist (symbol symbol-list)
magnars /
Created Apr 20, 2012
Keep session alive
public void sessionKeepalive(Model json) {
json.addAttribute("result", "ok");
magnars / gist:2868250
Created Jun 4, 2012
View gist:2868250
(defn accumulate-forces [o os]
(assoc o :force
(reduce vector/add (map (partial force-between o)
(filter #(not (identical? o %)) os)))))