Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Peter Cooperx http://www.petercooper.co.uk/

« Newer Snippets
Older Snippets »
Showing 1-6 of 6 total  RSS 

How to create a RAM disk on OS X

32768 = size in sectors (16MB in this case, a sector is 512 bytes)

$ hdid -nomount ram://32768
/dev/disk1
$ newfs_hfs /dev/disk1
$ mkdir /tmp/ramdisk1
$ mount -t hfs /dev/disk1 /tmp/ramdisk1


To unmount:

hdiutil detach /dev/disk1

Change OS X's default screenshot image format

At the prompt, type this:

defaults write com.apple.screencapture type image_format


Replace "image_format" with a file format name, like pdf, png, tiff, etc. Then to take screenshots, Cmd+Shift+4, then drag around the area you want to capture.

Easy file encryption and decryption from the shell

Works on OS X, Linux, anywhere with OpenSSL installed:

To encrypt a file:
openssl des3 -salt -in infile.txt -out encryptedfile.txt


To decrypt the file:
openssl des3 -d -salt -in encryptedfile.txt -out normalfile.txt


Do not specify the same file as input and output on encryption.. I have noticed weird effects on OS X (it eats the file). Remove the -in * stuff if you want to pipe data into it (e.g. a tarred folder). Omit the -out * stuff if you want it to pipe data out on STDOUT.

Mount an SMB / Samba share from the OS X command line

mount_smbfs -W workgroup //user@SERVER/folder ./mntpoint

Installing libjpeg on OS X

Get http://www.ijg.org/files/jpegsrc.v6b.tar.gz, and then:

tar zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b
cp /usr/share/libtool/config.sub .
cp /usr/share/libtool/config.guess .
./configure --enable-shared --enable-static
make
sudo make install
sudo ranlib /usr/local/lib/libjpeg.a
« Newer Snippets
Older Snippets »
Showing 1-6 of 6 total  RSS