Skip to content

Tag: command line

Mac: changing screenshots location

mkdir ~/Desktop/screenshots

defaults write com.apple.screencapture location ~/Desktop/screenshots

killall SystemUIServer
  1. Creates a directory in /Users/username/Desktop/screenshots.
  2. Sets the default screenshot location to that directory.
  3. Restarts the service responsible for screenshots.

New screenshots (?+Shift+3, 4 or 5) are now stored in ~/Desktop/screenshots.

printing only odd or even lines using sed

$ cat AtoF
A
B
C
D
E
F

Print only odd lines

sed -n 'p;n' AtoF
A
C
E

-n suppress automatic printing of pattern space, p print the current pattern space, n read/append the next line of input into the pattern space.

Alternatively:

$ sed -n 1~2p AtoF
A
C
E

-n suppress automatic printing of pattern space, 1~2 from the 1st line match every line every 2 steps, p print the current pattern space. sed -n 0~p has the same effect . print only the even lines.

Print only even lines

$ sed -n 'n;p' AtoF 
B
D
F

or

$ sed -n 2~2p AtoF
B
D
F

0~2p would also work. I prefer

PNG to PDF and PNG to PDF

You can use ImageMagick to convert multiple PNGs into a PDF and convert a multiple pages PDF into multiple PNGs.

PDF to PNG

$ convert document.pdf document.png

For a document with 10 pages, this will generate document-0.png, document-1.png, … document-9.png.

PNG to PDF

$ convert document*.png document.pdf

This convert the PNG pages into pages in the document.pdf document.

Getting Openpixels

Openpixels is a project of mine to create a free and open source artistic framework for game projects in any language or platform. It is going pretty well.

You can just download a zip or tar.gz of the latest version.

You may want fork it or get a git working copy of it to later make your own contributions to the project. In this case:

apt-get install git-core
cd ~
git clone git://github.com/silveira/openpixels.git

You will see something like this:

Cloning into openpixels...
remote: Counting objects: 129, done.
remote: Compressing objects: 100% (126/126), done.
remote: Total 129 (delta 17), reused 0 (delta 0)
Receiving objects: 100% (129/129), 784.52 KiB, done.
Resolving deltas: 100% (17/17), done.

And now you have a repository clone at ~/openpixels and you can start hacking.