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:1180095
Created August 30, 2011 03:21
(load "foo.el")
;; (load "foo.el")
stat64("/usr/share/emacs/23.2/site-lisp/foo.el.elc", 0xbf87b5d0) = -1 ENOENT (No such file or directory)
stat64("/usr/share/emacs/23.2/site-lisp/foo.el.elc.gz", 0xbf87b5d0) = -1 ENOENT (No such file or directory)
stat64("/usr/share/emacs/23.2/site-lisp/foo.el.el", 0xbf87b5d0) = -1 ENOENT (No such file or directory)
stat64("/usr/share/emacs/23.2/site-lisp/foo.el.el.gz", 0xbf87b5d0) = -1 ENOENT (No such file or directory)
stat64("/usr/share/emacs/23.2/site-lisp/foo.el", 0xbf87b5d0) = -1 ENOENT (No such file or directory)
stat64("/usr/share/emacs/23.2/site-lisp/foo.el.gz", 0xbf87b5d0) = -1 ENOENT (No such file or directory)
@legumbre
legumbre / gist:1182280
Created August 30, 2011 22:29
unpaper | postprocessing scanned book example
# convert multipage pdf to single page tiff
gs -q -dNOPAUSE -dBATCH -sDEVICE=tiffg4 -sOutputFile=%04d.tif source.pdf -c qui
# or use -sDEVICE=pgmraw to convert to pgm
# unpaper, rotate the logical page 90 degrees, each logical page contained two scanned physical pages, so we use --layout double (for input) and --output-pages 2 since we want to split these two pages.
unpaper -v --deskew-scan-deviation 3.0 --border-align top --deskew-scan-range 15 --no-grayfilter --no-blurfilter --no-noisefilter --overwrite --pre-rotate 90 --border-scan-step 4 --layout double --output-pages 2 %04d.pgm.pbm unpaper%04d.pbm
# trim the pages and convert the to single-page pdfs
find . -name 'unpaper*' | xargs -i -n1 -P6 convert -trim +repage {} {}.pdf
@legumbre
legumbre / gist:1202418
Created September 8, 2011 01:55
flet and byte-compiled primitives
;; discussed this with jlf and turbofail in #emacs
;; say we want a function face-at-pos, and we attempt to do
;; it by fletting `point' and using `face-at-point'
(defun face-at-pos (pos)
"return the face at position p using face-at-point"
(flet ((point () pos))
(face-at-point))) ;; face-at-point uses `point' internally
# DE0 board pin & Location Assignments
# ==========================
set_location_assignment PIN_B1 -to LEDG[9]
set_location_assignment PIN_B2 -to LEDG[8]
set_location_assignment PIN_C2 -to LEDG[7]
set_location_assignment PIN_C1 -to LEDG[6]
set_location_assignment PIN_E1 -to LEDG[5]
set_location_assignment PIN_F2 -to LEDG[4]
set_location_assignment PIN_H1 -to LEDG[3]
set_location_assignment PIN_J3 -to LEDG[2]
(progn
(shell "mysh")
(insert "cd /tmp")
(comint-send-input)
(insert "ls -alG")
(comint-send-input))
Debugger entered--Lisp error: (error "Marker does not point anywhere")
ansi-color-apply-on-region(#<marker in no buffer> #<marker at 9 in mysh>)
test
test
test
test2
test3
test4
;; for fhrodes, advice jump-to-register so erc always scrolls to
;; bottom after a window config restore
(defadvice jump-to-register (after jump-to-register-and-scroll (register &optional del) activate)
"Scroll all erc buffers to bottom after jumping to a window configuration"
(when (window-configuration-p (car (get-register register)))
(mapcar (lambda (b) (with-current-buffer b
(when (eq major-mode 'erc-mode)
(goto-char (erc-end-of-input-line))
(erc-scroll-to-bottom (get-buffer-window b t) t))))
(buffer-list))))
;; for fhrodes, advice jump-to-register so erc always scrolls to
;; bottom after a window config restore
(defadvice jump-to-register (after jump-to-register-and-scroll (register &optional del) activate)
"Scroll all erc buffers to bottom after jumping to a window configuration"
(when (window-configuration-p (car (get-register register)))
(mapcar (lambda (b) (with-current-buffer b
(when (eq major-mode 'erc-mode)
(goto-char (erc-end-of-input-line))
(erc-scroll-to-bottom (get-buffer-window b t) t))))
(buffer-list))))
@legumbre
legumbre / gist:1260490
Created October 3, 2011 22:59
VirtualBox port forwarding example
# VirtualBox port forwarding example (localhost:2222 -> vm:22)
VBoxManage setextradata $VMNAME "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol" TCP
VBoxManage setextradata $VMNAME "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort" 22
VBoxManage setextradata $VMNAME "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" 2222
# or e1000 if that's the virtual nic we're using
VBoxManage setextradata $VMNAME "VBoxInternal/Devices/e1000/0/LUN#0/Config/guestssh/Protocol" TCP
VBoxManage setextradata $VMNAME "VBoxInternal/Devices/e1000/0/LUN#0/Config/guestssh/HostPort" 2222
VBoxManage setextradata $VMNAME "VBoxInternal/Devices/e1000/0/LUN#0/Config/guestssh/GuestPort" 22