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
test
test
test
(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>)
# 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]
@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
@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: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)
;; read a key sequence and echo it in kbd-friendly format
(message (edmacro-format-keys (read-key-sequence "key: ") nil))
@legumbre
legumbre / *scratch*
Created August 22, 2011 21:26
usb blaster setup CentOS 5
# USB Blaster setup for Centos5
# create /etc/udev/rules.d/51-usbblaster.rules
BUS=="usb", SYSFS{idVendor}=="09fb", SYSFS{idProduct}=="6001",MODE="0666", PROGRAM="/bin/sh -c 'K=%k; K=$${K#usbdev}; printf /proc/bus/usb/%%03i/%%03i $${K%%%%.*} $${K#*.}'", RUN+="/bin/chmod 0666 %c"
touch ~/.jtag.conf
@legumbre
legumbre / gist:1148156
Created August 15, 2011 23:40
longest common suffix of two strings
;; awful hack, get the common suffix from two strings using regexp-quote
(let* ((a "foo/bar")
(b "baz/bar")
(ro (regexp-opt (list a b))))
(string-match "\\\\)\\(.*?\\)\\\\)$" ro)
(match-string 1 ro))
;; "/bar"
;; what trickery be this?!
@legumbre
legumbre / gist:1140686
Created August 11, 2011 20:34
old calc-eval usage example
;; 1) te bajas una lista de 15 primos impares de aca
;; http://www.research.att.com/~njas/sequences/table?a=65091&fmt=4
;; 2) abris el emacs, (que de todas maneras deberias tenerlo abierto) y pones
(setq list-of-odd-primes '( 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277))
(setq numerito
(let ((first-fifteen (subseq (coerce list-of-odd-primes 'vector) 0 15)))
(reduce 'math-mul first-fifteen)))