Skip to content

Instantly share code, notes, and snippets.

@decrispell
decrispell / make_vtk_camera.cpp
Last active March 1, 2024 02:47
Convert standard camera intrinsic (focal length, principal point) and extrinsic parameters (rotation and translation) into a vtkCamera for rendering. Assume square pixels and 0 skew for now.
/**
* Convert standard camera intrinsic and extrinsic parameters to a vtkCamera instance for rendering
* Assume square pixels and 0 skew (for now).
*
* focal_len : camera focal length (units pixels)
* nx,ny : image dimensions in pixels
* principal_pt: camera principal point,
* i.e. the intersection of the principal ray with the image plane (units pixels)
* camera_rot, camera_trans : rotation, translation matrix mapping world points to camera coordinates
* depth_min, depth_max : needed to set the clipping range
@baojie
baojie / scan.sh
Last active April 27, 2023 03:57
Double-sided scanning in linux and converting to pdf. Dependency: sudo apt-get install xsane imagemagick
#!/bin/bash
scanimage --batch --batch-double
read -p "Flip papers in the feeder, last page on top. Press [Enter] key to start..."
endpage=$(echo "$(ls *.pnm -1 | wc -l) * 2" | bc)
scanimage --batch --batch-increment -2 --batch-start $endpage
for file in *.pnm; do convert $file $file.jpg; done
rm *.pnm
convert $(ls *.jpg -1v | paste) -compress jpeg -page A4 output.pdf
@mislav
mislav / _readme.md
Last active June 28, 2024 15:16
tmux-vim integration to transparently switch between tmux panes and vim split windows

I use tmux splits (panes). Inside one of these panes there's a Vim process, and it has its own splits (windows).

In Vim I have key bindings C-h/j/k/l set to switch windows in the given direction. (Vim default mappings for windows switching are the same, but prefixed with C-W.) I'd like to use the same keystrokes for switching tmux panes.

An extra goal that I've solved with a dirty hack is to toggle between last active panes with C-\.

Here's how it should work:

@jaygooby
jaygooby / .screenrc
Created March 5, 2012 21:48
Good default .screenrc that remaps CTRL-a to CTRL-g and lists open screens in a menu
# None of my own work. Munged from various other .screenrc recipes
#
# Don't use CTRL-A as the trigger because its stops the bash
# cli navigation like CTRL-A for start of line to stop working
escape ^Gg
# We'd like to scroll in an xterm please
defscrollback 1024
# http://superuser.com/questions/126606/how-to-get-mac-os-x-terminal-app-and-screen-vim-scrolling-to-play-nice/316900#316900