Skip to content

Instantly share code, notes, and snippets.

@magnars
magnars / .profile
Created May 6, 2011
Show time since last commit and branch name in prompt
View .profile
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 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
magnars / EmacsClient.app
Created Dec 21, 2011
Using PeepOpen with Cocoa Emacs
View EmacsClient.app
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
View gist:1671918
(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 Jan 30, 2012
push-mark not behaving as expected
View gist:1705973
(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 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
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
(push-mark)))
(defun ido-imenu-push-mark ()
(interactive)
@magnars
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."
(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 Apr 20, 2012
Keep session alive
View Controller.java
@RequestMapping("/session/keepAlive.json")
public void sessionKeepalive(Model json) {
json.addAttribute("result", "ok");
}
@magnars
magnars / gist:2868250
Created Jun 4, 2012
accumulate-forces
View gist:2868250
(defn accumulate-forces [o os]
(assoc o :force
(reduce vector/add (map (partial force-between o)
(filter #(not (identical? o %)) os)))))