Archive for July, 2008

IP printing in OS X

July 30, 2008

Nearly everyone who uses OS X knows that one department where the OS is lacking is in the realm of IP printing and IP printing support. For most of us in an academic infrastructure, this is usually how we connect to our printers. But when you look at the configuration of such a printer, you are either only left with a handful of options or you have to follow a maze to find options. But luckily, the underlying printing system is managed by CUPS (Common Unix Printing System). Depending on your version of cups you can easily access all your printers, queues, and options in one convenient place… in your web browser! CUPS has a nice user interface that can be accessed in your web browser by typing the following into your web browser of choice

http://localhost:631

Check it out, it is pretty neat. It’s a nice and tidy place for all your printing needs… now if only OS X could just capture this and translate it into their Preferences pane.

Screenshot of the web interface for CUPS 1.3.x.

Screenshot of the web interface for CUPS 1.3.x.

Syncing iCal and Address Book to Google Calendar and Contacts

July 29, 2008

Here is some help in having some two-way syncing between your calendars in Google Calendar, iCal, Thunderbird, and Microsoft Outlook. Saves me from writing a whole bunch!

Sync Calendars

Unfortunately, Address Book cannot be synced with your Google Contacts unless you have an iPhone (lame)… here is the link to that anyway.

Sync Address Book

MATLAB – filling the “contour” function

July 25, 2008

This is a stupid post but I am just putting it here because I will forget how to fix this in the near future. So the problem with the contour function is that if you want to fill all the contours, it never fills the contour at the lowest limit in which you are interested in, i.e. it will leave an image with a disgusting white splotch where it should really be dark blue.

Look at that ugly white. This is because 'contour' doesn't know any better!

Look at that ugly white. This is because 'contour' doesn't know any better!

A quick fix to this is to set the background of an image as the color that the white areas are supposed to be. To do this, you should run the following lines:

[contours, h_w] = contour(x, y, w, w_level, line_color);

% Here is a nice fix to fill the last contour on a filled plot
set(gca, ‘Color’, [0 0 .5]); % Set background color of “axes”
set(h_w, ‘Fill’, ‘on’); % Set contour filling on
set(gcf, ‘InvertHardCopy’, ‘off’); % Prints background color when printing

Of course, if you change the default color scheme from jet to something else, you will need to change the ‘Color’ accordingly. You should have a resultant picture like this.

Ah, much better.

Ah, much better.

This is just really a temporary fix, someone should really dive into the code and fix this!

Using ImageMagick to convert a series of images to animated GIF

July 24, 2008

I use this a lot for research. I have a series of images in a postscript type format (e.g. EPS or PDF) and then I want to turn the time series of data into an animation. For this i use ImageMagick because it is a really nice command line tool for Unix operating systems to do batch type operations. You can even pipe it to C code! (Make sure you have it installed because it is not usually distributed with a bare Linux OS)

To do a simple conversion of images to an animated GIF we invoke the following

>convert -verbose -delay 20 -loop 0 -density 200 *.pdf output.gif

and we get a nice GIF file. This takes the files named *.pdf in the order that they are listed and makes a GIF out of them with a 20 hundreths of a second delay between each frame. The -loop 0 flag makes it loop indefinitely. You can put 3 in there to loop 3 times etc. The -density 200 flag specifies a DPI of 200 for the image. This is only really used when converting postscript images.

Animation of flow over a cylinder (vorticity) made from MATLAB + ImageMagick.

Animation of flow over a cylinder (vorticity) made from MATLAB + ImageMagick.

Compiz + MATLAB solution

July 24, 2008

MATLAB and Compiz do not mix (I am using Ubuntu 8.04). If you just installed MATLAB, in all likelihood MATLAB shows a window with nothing in it. For some reason MATLAB does not use the right JAVA toolbox or something along those lines. So we have to edit the launch file to do this. So add

export MATLAB_JAVA=/usr/lib/jvm/java-6-sun/jre/

to the /PATHTOMATLAB/bin/matlab lauch file so that it looks something like this:

#!/bin/sh

export MATLAB_JAVA=/usr/lib/jvm/java-6-sun/jre

#
# Name:
# matlab script file for invoking MATLAB
#
# …

MATLAB should run much better. In my experience, it is much better than the export AWT_TOOLKIT==MToolkit trick. MATLAB will still be fickle with Compiz in place (well, anything will be fickle with Compiz running). The best solution, if you use MATLAB a lot, is to just not use Compiz or any other eye candy.

Compiz and MATLAB 2007 running at the same time!?!

Compiz and MATLAB 2007 running at the same time!?!

Remove files from your Linux trash bin that just won’t go away!

July 23, 2008

Check the ~/.Trash/ and the ~/.local/share/Trash/files/ (Ubuntu 8.04) directories and see if the files are there. Most likely you are having a problem with permissions, but I’ve had issues where the permissions are perfectly okay but somehow the OS will still not let you empty the trash! To force an empty type

sudo rm -rf FILES

Be careful with this command because it is VERY unforgiving! Trust me. You should really alias a check to make sure that it asks you whether not you want to remove the file (e.g. in your .bashrc).

GNU Screen

July 22, 2008

Possibly the most useful tool ever if you do a lot of remote computing. Here’s a quote from Wikipedia:

GNU Screen is a free terminal multiplexer developed by the GNU Project. It allows a user to access multiple separate terminal sessions inside a single terminal window or remote terminal session. It is useful for dealing with multiple programs from the command line, and for separating programs from the shell that started the program.

I use it mostly for running command line utilities that take forever to run (e.g. academic programs that do “work” for me). This allows me to remotely log in, start screen, start a program, detach screen, and log out. When I come back to check on how the program is running, I can log back in, attach an already running screen, and check on it again. Once I am done then I detach.

Here are useful commands:

>screen, starts a screen session on the host.
>screen -r, reattaches to a previous session.
>screen -r blah.host, reattaches to a specific previous session.
>exit, destroys the current screen session.
>screen -x, attach to a non detached screen.

In addition, you can hit CTRL+a and type one of the following to send specific commands to screen:

c, create new screen.
n, next screen.
A, rename screen.
d, detach screen.
", lists screens. Interactive.
0-9, select certain screen.

VNC screen sharing across different platforms

July 21, 2008

Virtual Network Computing (VNC) is a graphical desktop sharing tool that can be used cross platform (unlike other tools such as Apple Remote Desktop or Windows Remote Desktop). The drawback is that it is generally slower than these OS specific remote desktop apps because there is no inherent operating system information on the viewing machine. You can even view your remote desktop in a Java enabled browser (with some distributions of VNC). On Unix machines, VNC is usually automatically included in the distribution (most flavors of Linux have it floating around somewhere as well as OS X). You can dive into more details if you just search for a Wikipedia page. But essentially you are sending images of your server desktop to your viewer and can be tunneled over an SSH connection. In general it is not “very” secure.

Windows – I use TightVNC because it is free and it works. This provides both a viewer and a server for your Windows machine. To setup a server on your just follow the TightVNC directions. Note that you have to have TightVNC server running at all times to connect to the machine. Another free one out there is called UltraVNC.

A screenshot of TightVNC in action and remotely viewing an OS X session.

A screenshot of TightVNC in action and remotely viewing an OS X session.

OS X – I use Chicken of the VNC as a viewer since it is also free and works well. The VNC server is automatically built in OS X 10.5 and can be found by navigating to System Preferences > Sharing > Screen Sharing. Go ahead and click on Computer Settings and check off that “VNC viewers may control screen with password” and insert an appropriate password. You may also have to check the box above as well. Now if you go back, you can read the dialog and it will let you know how to connect to your Mac via VNC.

Consolidate your music library (to write up soon)

July 17, 2008

Before I forget, I really need to consolidate my music library. Right now I have three different music libraries sitting on a desktop, my macbook, and on an external hard drive. Most of this music, I will never hear again in my life. Some of it I want to keep just in case I’m in the mood. The rest I want to listen to it all the time. I don’t want to lose my iTunes ratings and album covers! Hopefully I’ll learn how to do this soon and post it right here.

OnyX – A multi-function utility for OS X

July 12, 2008

OnyX is a program that lets you tweak and clean Mac OS X. I initially ran into this when I forgot how to change the format for the screen capture for my Macbook. This has a place where I can change various parameters without fooling around with the command line and hoping that I can find the right command in Google or in this blog. Here is the little blurb from their site:

It allows you to verify the Startup Disk and the structure of its System files, to run misc tasks of system maintenance, to configure some hidden parameters of the Finder, Dock, Dashboard, Exposé, Safari, Login window and of some of Apple’s own applications, to delete caches, to remove a certain number of files and folders that may become cumbersome and more.

Automatically check update, verify the status of startup disk and the structure of system files at launch, parameter with precision the actions, modify the appearance of OnyX, increase the window transparency, chooose its icon and the toolbar icons among those proposed in the Preferences…

So, I’ve just started using it and it looks like a good tool. It’s a little free and they also offer a disclaimer about bugs, but hopefully it’s not that serious. I’ll update more on this as I test it more (right now I am waiting for a Time Machine backup so that I don’t screw anything up).

Screenshot of the parameters page for OnyX.

Screenshot of the parameters page for OnyX.

Update: It kind of screws up some other 3rd party software occasionally. My MenuMeters stopped working after doing some kind of task in this program. I had to re-install MenuMeters.