Woshiadai Dev Notebook

June 26, 2009

Subversion and SSH setup in Netbeans 6.7 RC3 on Mac OS X

Filed under: Java, PHP, Apple, Mac

Netbeans has been making a lot of progress since version 6 and the latest 6.7 RC3 is even better. For those Eclipse fans, I strongly suggest that you check out Netbeans. It feels much faster and consumes less memory. The plugins are more organized and easy to manage (I think the plugin management in Eclipse is really messy).

The PHP plugin for Netbeans is out of beta and it is quite user friendly and versatile. So, I decided to switch from PDT to Netbeans for my PHP development.

Netbeans comes with Subversion support. However, it is not so smooth to set up Subversion over SSH on Mac OS X due to the ssh-askpass problem. This is a Mac OS X issue, not a Netbeans issue.

  1. Download and install Netbeans 6.7 RC3 (as of June 25, 2009).
  2. The subversion that comes with Mac OS X (/usr/bin/svn, 1.4.4 (r25188)) is quite outdated and it has problems working with newer versions of the SVN server, probably due to different format of the metadata. You need to use MacPorts to install a more recent subversion (if you don’t know how to install MacPorts, check out this). Just type this in your terminal: port install subversion, it might take a white. The subversion from MacPorts is installed in /opt/local/bin, so make sure you put /opt/local/bin before /usr/bin in your PATH environment variable.
  3. Add SVNROOT and SVN_SSH environment variables to your .bashrc:

    export SVNROOT=svn+ssh://your_svn_server/
    export export SVN_SSH=/usr/bin/ssh
  4. Launch Netbeans, go to preferences->Miscellaneous->Versioning->Subversion, for “path to SVN executable file”, enter /opt/local/bin
  5. Now, it seems like everything is ready. However, when you try to do update/diff and other operations, you get error: ssh_askpass: exec(/usr/libexec/ssh-askpass): No such file or directory. I did some Yahoo! search and the problem is that Netbeans wants to communicate with SVN server over ssh without asking your password using ssh-askpass, but it is not available. This is a general ssh issue on Mac OS X.

    I found two solutions: solution 1 and solution 2. I only tried solution 2 and it worked perfectly for me. Here are the simple steps:

    a) download script from here (note that I had to add .jpg since blogsome only supports image upload) and save it in /usr/libexec. Change ssh-askpass script to executable:
    wget wget http://woshiadai.blogsome.com/images/sshaskpass.jpg -O ssh-askpass
    sudo cp ssh-askpass /usr/libexec/ssh-askpass
    sudo chmod a+x /usr/libexec/ssh-askpass

    b) add two more environment variables:

    export SSH_ASKPASS=macos-askpass
    export DISPLAY=:0

  6. Finally, you can use subversion actions from inside Netbeans. You will be asked for password for the first time, then it will be remembered for future activities.

    Enjoy the Netbeans! ;-)

June 19, 2009

Screen Sharing

Filed under: Apple, Mac

I have been using Mac for quite a while, but did not have much time to explore many of its features. Today, I managed to find how to do easy VNC to my linux box using Screen Share application, a hidden treasure.

First, follow the instructions here to set up the Screen Share application. Somehow I could get the advanced toolbar working.

Second, you need to set up the VNC server on your linux box. In my case, Redhat Enterprise comes with VNC server installed already. All I need is to configure it properly. Follow this nicely written tutorial to start your VNC server. There are two ways in this tutorial: use the build-in remote desktop setup, or the DIY configuration. I chose the 2nd option since it is much flexible and the first one did not really worked for me.

Third, connect to your VNC server. In my case, I just typed in hostname:5091 and clicked connect in Screen Sharing, then it starts working, really cool!

I think you should be able to do the same with a Windows machine running VNC server, but I did not try that.

June 18, 2009

ICO image processing with Imagick

Filed under: PHP, Image Processing

Used to have an issue with Imagick when I convert ICO image into png. Somehow when I create the Imagick object from image content string, the final result is a crappy image. But when I create the Imagick object directly from a file, it works fine, with only the problem of a different size.

So, I filed a bug (http://pecl.php.net/bugs/bug.php?id=15701), but still got no resolution.

Got some time recently and did a bit research, found that the problem is with the ICO format: it may contain the same image with different sizes. So, when you convert the format directly, it will not work. It is similar in the case when you try to convert an animated GIF image into JPG or PNG, you get one of the frames instead of an animated image.

There are two solutions:

1. use foreach($ico as $im) loop to get one image and just convert that image
2. use flattenImages function before the format conversion

Note that after the format conversion, the image dimensions might be different from when you directly open the ICO image from a browser or image viewer. You probably need to resize the image manually.

The bug report has some code snippets if you want to try it out.






















Get free blog up and running in minutes with Blogsome
Theme designed by Ben de Groot