Subversion on Dreamhost

This post is a log of how I personally got Subversion running on Dreamhost using this post.

  1. Obtained the Subversion source from http://subversion.tigris.org/project_packages.html#source-release, compiled it, and put the binaries in my ~/bin directory.
  2. Added the Subversion binaries to my path by adding these lines to my ~/.bash_profile file.
    # Set PATH so it includes user's private bin if it exists
    if [ -d ~/bin ] ; then
      PATH="~/bin:${PATH}"
    fi

    For this change to take effect you either have to relogin or:

    $ . ~/.bash_profile

  3. Initialized new subversion repositories. For example:
    $ svnadmin create ~/svn/mk 
    $ svn mkdir \
        file:///home/fkim/svn/mk/trunk \ 
        file:///home/fkim/svn/mk/branches \
        file:///home/fkim/svn/mk/tags

    I am following the suggested way of organizing a Subversion repository.

  4. Imported the files into the subversion repository. For example:
    svn import ~/meetingkoreans.com file:///home/fkim/svn/mk/trunk/
    svn import ~/meetingkoreans.com svn+ssh://fkim@meetingkoreans.com/home/fkim/svn/mk/trunk/

    Note: I was having a strange problem when I tried to do an import and kept getting an already exists error.  It turned out the problem was because what I was trying to import was a link instead of the actual directory.  This might only be an issue on Cygwin.

  5. Checked the files out. To do this locally:
    svn co file:///home/fkim/svn/mk/trunk meetingkoreans.com

    To do this remotely:

    svn co svn+ssh://fkim@meetingkoreans.com/home/fkim/svn/mk/trunk mkrb

Ruby Development Tools (RDT) plug-in for Eclipse

Excellent introductory article, Using the Ruby Development Tools plug-in for Eclipse.

This article introduces using the Ruby Development Tools (RDT) plug-in for Eclipse, which allows Eclipse to become a first-rate Ruby development environment. Ruby developers who want to learn how to use the rich infrastructure of the Eclipse community to support their language will benefit, as will Javaâ„¢ developers who are interested in using Ruby.

WordPress and Gallery2

I installed Gallery2 for one of my clients. I then integrated Gallery2 with WordPress using this plugin.

Everything seemed to go fine except I could not get Gallery2’s URL rewrite to play nicely with the WordPress installation which resulted in thumbnail images not showing up in the sidebar. After much experimentation I finally decided just to turn off Gallery2’s URL rewrite to resolve the problem. I tried using this help page but it didn’t work for me.

I am also unsure how to make the Gallery2 pages look more integrated with the WordPress pages. Right now it’s glaringly obvious that the Gallery2 pages are not part of the rest of the site.

Gallery2 is pretty cool. It is quite improved from the original Gallery. I like how you can set the permissions for individual photos so that certain photos only registered users can see. It was annoying though that I had to type in the group name “Registered Users” instead of being given a choice in a drop down list of which group I want to assign a new permission.

WordPress fun

Plugins

  • WPG2 – embeds Gallery2 within WordPress to share photos, videos and any other Gallery2 content seamlessly into the WordPress Sidebar and Blog entries
  • Croissanga – re-posts your published-status posts to your Xanga site
  • WeatherIcon 2.0 – displays the weather for any place in the world
  • Theme Switcher – allows your readers to switch between your installed themes

Themes

To see different WordPress themes try the WordPress Theme Viewer.

Java allocation is no longer expensive

Beginning in JDK 1.4.2, allocation of new objects is no longer expensive according to this article, Java theory and practice: Urban performance legends, revisited. According to this article.

… allocation in modern JVMs is far faster than the best performing malloc implementations…

The malloc/free approach deals with blocks of memory one at a time, whereas the garbage collection approach tends to deal with memory management in large batches, yielding more opportunities for optimization (at the cost of some loss in predictability).

This “plausibility argument” — that it is easier to clean up a mess in one big batch than to pick up individual pieces of dust throughout the day — is borne out by the data.

So allocate away, never object pool, don’t do strange, non-intuitive things to avoid allocating objects on the heap. Life is good.

Updating/Reading Dates

I always forget how to do this.

UPDATE foo SET bar_date = TO_DATE( '2005-09-29', 'YYYY-MM-DD') WHERE foo_id=51

SELECT TO_CHAR(bar_date, 'yyyy-mm-dd hh24:mi:ss') FROM foo;

SELECT * FROM foo WHERE bar_date > TO_DATE('08/16/2006', 'MM/DD/YYYY')

When you need a date in a pinch for inserting test data use sysdate.

INSERT INTO foo (bar_date) VALUE (sysdate)

A good article about this is Oracle, SQL, Dates and Timestamps.

How to schedule tasks or perform tasks repeatedly

There is an excellent tutorial at The Java Tutorial called
Using the Timer and TimerTask Classes.

It explains how to use a timer to schedule tasks or to perform tasks repeatedly. With the Timer and TimerTask classes you don’t have to create your own threads, it’s all done for you. Thank you Joshua Bloch for writing these classes.

On a side note, Joshua Bloch is one of the premier Java engineers. Recently he left Sun for Google. Gosh, that must have hurt Sun.

Sequences on Oracle

Here is an example of how to create a sequence which you can use for creating sequential numbers, typically for ID’s.

CREATE SEQUENCE person_seq
    INCREMENT BY 1
    START WITH 1
    NOMAXVALUE
    NOCYCLE
    CACHE 10;

This is how you would then use the sequence.

INSERT INTO persons (id, name) VALUES (person_seq.NEXTVAL, 'Dylan')
INSERT INTO persons (id, name) VALUES (person_seq.NEXTVAL, 'Isaac')

If you want to select the next ID you would do it like this.

SELECT person_seq.NEXTVAL FROM Dual

To learn more, Managing Sequences and the Oracle DUAL table.

java.io.FileNotFoundException for valid URL

In one of our ATG servlet’s we were making a normal HTTP call to a page located on our ATG Dynamo server.

url = new URL(urlString);
connection = (HttpURLConnection)url.openConnection();
reader = new InputStreamReader(connection.getInputStream());

Free Daddy and His Little Shadow Girls at The Skate Park Creative Commons on FlickrHowever when trying to get the input stream we got a FileNotFoundException yet we were able to go to the same URL using a browser. Googling around we found this lovely thread about the same problem.

To summarize the thread, the problem was in our proxy settings which are set on Windows in localconfig/environment.bat and on UNIX in localconfig/environment.sh. An example of proxy settings on Windows is set PROXY_ARGS=-Dhttp.proxyHost=192.168.1.134 -Dhttp.proxyPort=8080.

The proxy server did not recognize our machines as valid clients so it rejected our requests. Once we changed the proxyHost argument to point to a valid server then this problem was fixed.