Skip to content

Instantly share code, notes, and snippets.

View legumbre's full-sized avatar

Leonardo Etcheverry legumbre

  • GlamST / Ulta
  • Montevideo, Uruguay
View GitHub Profile
@legumbre
legumbre / gist:1848651
Created February 16, 2012 23:12
github friendly commit messages in magit
;; github-friendly commit messages as per:
;; https://github.com/blog/926-shiny-new-commit-styles
(add-hook 'magit-log-edit-mode-hook
(lambda ()
;; highlight too-long commit summary
(set (make-local-variable 'whitespace-line-column) 50)
(set (make-local-variable 'whitespace-style) '(face lines-tail))
(whitespace-mode 1)
;; autofill longer explanatory text
(setq fill-column 72)
@legumbre
legumbre / json-pretty-print.el
Created February 21, 2012 18:09
pretty print json
;; pretty print a json region using python
;;
;; M-| python -m json.tool
(defadvice narrow-to-region (around clone-when-narrowing-already-visible-buffer activate)
"Clone an indirect buffer when attempting to narrow the
contents of buffer visible in more than one window."
(save-excursion
(when (> (length (get-buffer-window-list (current-buffer) nil nil)) 1)
(let ((cloned-buffer (clone-indirect-buffer nil t) ))
(switch-to-buffer cloned-buffer t)))
ad-do-it))
;; Just an idea for Boscop. When (eq display-buffer-reuse-frames t)
;; display-buffer will raise the frame showing the compilation
;; buffer. This advice raises the original frame so focus is not in
;; the compilation buffer frame.
(defadvice compile (around avoid-compile-switching-frames activate)
(let ((cf (selected-frame)))
ad-do-it
(raise-frame cf)))
@legumbre
legumbre / scratch.el
Created March 11, 2012 03:44
compile advice
;; Just an idea for Boscop. When (eq display-buffer-reuse-frames t)
;; display-buffer will raise the frame showing the compilation
;; buffer. This advice raises the original frame so focus is not in
;; the compilation buffer frame.
(defadvice compile (around avoid-compile-switching-frames activate)
(let ((cf (selected-frame)))
ad-do-it
(raise-frame cf)))
-- make all unbound vars of the form rNN resolve to level.rings[NN]
mt={}
mt.__index=function (t, k)
local r, rindex = string.find(k, "r%d", 0)
rindex = rindex and tonumber(string.sub(k, rindex))
if rindex then
return level.rings[rindex]
else
return nil
@legumbre
legumbre / gist:2047402
Created March 15, 2012 22:35
cleaning macports
sudo port clean --all installed
sudo port -f uninstall inactive
@legumbre
legumbre / gist:2176240
Created March 23, 2012 23:16
magic-mode-alist and cc-other-file-list
;; load objc-mode for objective-C header files
(add-to-list 'magic-mode-alist
'((lambda ()
(and (string= (file-name-extension buffer-file-name) "h")
(re-search-forward "@\\<interface\\>" magic-mode-regexp-match-limit t)))
. objc-mode))
;;set .m <-> .h correspondence for ff-find-other-file
(add-hook 'objc-mode-hook
(lambda ()
@legumbre
legumbre / gist:2232346
Created March 29, 2012 01:45
define a new style based on bsd, override c-basic-offset
(c-add-style "bsd-jimmy"
'("bsd" (c-basic-offset . 4)))
(add-to-list 'c-default-style '(c++-mode . "bsd-jimmy"))
printf("%x xor %x = %x \n", a, b, a ^ b);
printf("%x xor %x = %x \n", a, res, a ^ res);
printf("%d - %d = %d (overflow: %d)\n", a, b, res, overflow);
printf("%x - %x = %x (overflow: %x)\n", a, b, res, overflow);