Skip to content

Instantly share code, notes, and snippets.

@magnars
magnars / .profile
Created May 6, 2011 19:20
Show time since last commit and branch name in prompt
NORMAL="\033[0m"
BLUE="\033[1;34m"
cyan="\033[0;36m"
yellow="\033[0;33m"
RED="\033[1;31m"
source ~/bin/git-completion.bash # or where your git-completion.bash is installed
function minutes_since_last_commit {
now=`date +%s`
@magnars
magnars / buster-output.txt
Created June 1, 2011 06:24
Reporting too few assertions?
watchForChanges: ....
1 test case, 4 tests, 1 assertion, 0 failures, 0 errors, 0 timeouts
@magnars
magnars / EmacsClient.app
Created December 21, 2011 11:12
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/Emacs.app/Contents/MacOS/bin/emacsclient -n " & file_path & ""
end tell
end open
@magnars
magnars / gist:1671918
Created January 24, 2012 19:05
Advice ignored
(defadvice yank-pop (around yank-pop-unsupported-advice)
"yank-pop isn't supported with multiple cursors"
(progn
(message "yank-pop-advice ho!")
(if multiple-cursors-mode
(error "yank-pop isn't supported with multiple cursors")
ad-do-it)))
@magnars
magnars / gist:1705973
Created January 30, 2012 18:57
push-mark not behaving as expected
(defun mark-five-next ()
"Marks the next five chars as expected"
(interactive)
(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
magnars / gist:1892749
Created February 23, 2012 13:19
Hvis bare utviklerne

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
magnars / gist:2350388
Created April 10, 2012 10:50
Push mark when using ido-imenu
;; 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
(push-mark)))
(defun ido-imenu-push-mark ()
(interactive)
@magnars
magnars / gist:2360578
Created April 11, 2012 17:05
ido-imenu as used in Emacs Rocks #10
(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."
(interactive)
(imenu--make-index-alist)
(let ((name-and-pos '())
(symbol-names '()))
(flet ((addsymbols (symbol-list)
(when (listp symbol-list)
(dolist (symbol symbol-list)
@magnars
magnars / Controller.java
Created April 20, 2012 07:12
Keep session alive
@RequestMapping("/session/keepAlive.json")
public void sessionKeepalive(Model json) {
json.addAttribute("result", "ok");
}
@magnars
magnars / gist:2868250
Created June 4, 2012 13:06
accumulate-forces
(defn accumulate-forces [o os]
(assoc o :force
(reduce vector/add (map (partial force-between o)
(filter #(not (identical? o %)) os)))))