Printing books and such in color can be expensive. So here is how to count the color pages using a recent version of GhostScript and a UNIX shell:
gs -o - -sDEVICE=inkcov input.pdf | grep -v "^ 0.00000 0.00000 0.00000" | grep "^ " | wc -l
A collection of coding snippets, tips, hints and random thoughts.
Printing books and such in color can be expensive. So here is how to count the color pages using a recent version of GhostScript and a UNIX shell:
gs -o - -sDEVICE=inkcov input.pdf | grep -v "^ 0.00000 0.00000 0.00000" | grep "^ " | wc -l
Earlier this year I detailed how to run gtags of GNU Global when Emacs is idle. However, this collides with some special Emacs modes, like ediff. That mode makes its own Emacs frame layout, which can be destroyed by the xgtags incremental update buffer. So I conceived a way to disable gtags temporarily as long as ediff is active:
;; This stuff is only needed, if you haven't got xgtags loaded yet
(autoload 'gtags-mode "gtags" "" t)
(require 'xgtags)
(add-hook 'c-mode-common-hook (lambda () (xgtags-mode 1)))
(defun global-update-incrementally () (shell-command "global -u -q" "*Messages*" "*Messages*") )
;; Call gtags update when idle for some time
(defcustom my-gtags-update-idle-time 60
"Number of idle seconds before an incremental gtags update is launched"
:group 'my-group
:type 'integer
)
;; initially allow gtags updates
(setq my-gtags-update-active t)
(run-with-idle-timer my-gtags-update-idle-time t
(lambda ()
(if (and my-gtags-update-active
(not (minibufferp) )
)
(progn
(message "Running gtags...")
(global-update-incrementally)
)
)
)
)
(add-hook 'ediff-quit-hook
(lambda ()
(message "Activating gtags update.")
(setq my-gtags-update-active t)
)
)
(add-hook 'ediff-before-setup-hook
(lambda ()
(message "Deactivating gtags update.")
(setq my-gtags-update-active nil)
)
)
Today something very simple: use ffmpeg to encode an image sequence as a MPEG4 video:
ffmpeg -f image2 -i filename-%04d.png -vcodec mpeg4 -b 6000k output.mp4
I often use blender or custom software to render out a bunch of images. Blender usually names output files filename-0000.png, where 0000 is the frame number. So ffmpeg can generate those filenames with the usual printf style format. You can of course tweak ffmpeg’s output via a myriad of options. But this here will simply generate a 25fps mpeg4 file, which is easily embedded for example into your Keynote presentation. On OS X you can get ffmpeg for example via MacPorts: sudo port install ffmpeg, and Linux distros usually have a package for ffmpeg as well.