Getting ‘er done?

In the past months, I’ve dropped the amount of side-projects I do apart from my 40hr. This weekend however, I decided to put some real effort into a project I’ve been waving off for about 6+ months. So, Saturday morning I get an iced mocha from the Starbucks, and at home made a few cups of an Asian/African blend. While hopped up on some quality Java, I ‘plowed’ through some yard work — those 3 hours went by fast.

Afterwards, I sat down and set my sites on getting some real dev work done. For the next 2 days, I moved with purpose. With the Pareto principle (you may know it as the 80/20 rule) in mind, I aimed for real progress; something my biz partner could see and demo. No excuses. It was a very different feeling. In the past I’ve allowed myself to be distracted by ancillary things like line heights, table cell alignment; basically rubbish. This time around, when a minor thing would come up, I tried to fix it for a consciously set amount of time: 5 minutes. If I could not solve it, I’d put it aside, and come back to it later.

This has never been my M.O. If I see a problem, I want… No, I need to know the answer. It’s been a burden. It takes away from the main issue, which is completion of the overall task. This self-imposed time limit really helped. Also, aiming to at least reach 80% completion had a positive affect. I was able to take the project from its existing 25%, to a nice 85%. It’s a great feeling, but now I need to keep that fire going. Once I actually get the version 1.0 complete, I’ll know I’ve done something. It’s in sight and now I have to rely on my biz partner’s responsiveness. Well, so far, so good.

Posted in General | 1 Comment

Wikipedia, you’re the greatest…

So I was bored at the workplace, and decided to lookup the definition of boredom on wikipedia.org. It was pretty insightful. Then I thought to myself, Wikipedia is arguably the greatest Web 2.0 application ever invented. I’m sure some would mention YouTube, Flickr or FaceBook. Possibly, I did say arguably. Yes, Google is using YouTube’s technology to spread knowledge — but for the most part, people make funny, silly or (insert adjective here) videos, and share ‘em. Being vetted by the knowledge consumers themselves, Wikipedia, for the most part, allows you to learn things that – well, you wouldn’t otherwise.

Posted in General | 2 Comments

People are simply people…

So I finally watched the film, Blood Diamond. Outstanding performances by Djimon Hounsou and Leo Decaprio. While watching this film, I heard a variation on an idea that I’ve debated and struggled with for years. It came during a brief dialogue between Decaprio’s character and a doctor. Decaprio plays a retired mercenary turned diamond smuggler. The doctor is the leader of a hidden camp, where he is attempting to salvage and possibly reprogram (for the lack of a better word) children displaced by the conflict.

The doctor asks Decaprio if people are generally good or bad. Decaprio replies neither, instead people are simply people. Their actions actually define who they are. I’ve never heard this, at least not exactly in those terms. I believe psychology avoids the concept of good and bad. Rather, psychology sees people as beings capable of various actions, that we may deem good or bad. However, in reality hearing the words ‘holocaust’ or ‘genocide’ should evoke negative emotions.

In my discussions, there’s been the school of “people are generally flawed”. I see this as the pessimistic and moralist view. Usually, Christians who accept the concept of original sin normally subscribe to this. I’ve met atheists that hold this view. I have also met a few evangelicals that hold to original sin, and that people are generally good. I’ve never fully understood that.

The counter-view has been that “people are generally good”. I see this as the optimistic and relativist view. 90% of the people I’ve had this discussion with subscribe to this. The Buddhists I’ve spoken to agree with this. Following Freud’s structural theory, some individuals have stronger ‘ids’, while others have stronger ‘super-egos’. This should be obvious in your daily life — look at yourself and those around you.

Mother Teresa and M. Gandhi, by all accounts were righteous and selfless people, even till death. A. Hitler, a mass murder. However, in all three cases, these were simply people, who through a mixture of nature and nurture became what they became. In the end, I’ve abandoned my previous view that “people are generally rubbish”. I accept that people simply temporal beings, capable of both good and bad. Generally speaking, they themselves are neither good nor bad.

By the way, remember the doctor saving kids. Well, later on while driving Decaprio and his two others to an airfield, they are stopped by a boy soldier. The doctor tries to reason with the boy, and convince him to let them pass. The boy shoots the doctor in the chest. Mmm, taste the irony.

Posted in General | 1 Comment

Programmer Personality Test

I took Doolwind’s Programmer Personality Test, and got a DHSB. It was explained it as follows:

You’re a Doer.
You are very quick at getting tasks done. You believe the outcome is the most important part of a task and the faster you can reach that outcome the better. After all, time is money.

You like coding at a High level.
The world is made up of objects and components, you should create your programs in the same way.

You work best in a Solo situation.
The best way to program is by yourself. There’s no communication problems, you know every part of the code allowing you to write the best programs possible.

You are a liBeral programmer.
Programming is a complex task and you should use white space and comments as freely as possible to help simplify the task. We’re not writing on paper anymore so we can take up as much room as we need.

This may be true, I don’t know. I will assume it means I am awesome. He also had a link to a Jung personality test, and I was an INTJ; again, awesome. If you want to see a general description of your type, look here. If ya get a chance, take the tests and post your results.

Posted in General | Leave a comment

Getting the right manifest classpath

If you use Apache’s Ant to create archives (jars or wars), you most likely include a manifest(.mf). Well in the past when I’ve needed to note the dependencies on other jars, I’ve would have to come up with some rubbish hack. Things would look something like this:


        <jar destfile="${build.dir}/${core.jar}" basedir="${tmp.build.dir}" index="true">
            <manifest>
                <attribute name="Built-By" value="${authors}"/>
                <attribute name="Implementation-Title" value="core"/>
                <attribute name="Implementation-Version" value="${version} at ${TODAY}"/>
                <attribute name="Implementation-Vendor" value="${company}"/>
                <attribute name="Class-Path" value="foo.jar yep.jar test.jar etc…"/>
            </manifest>
        </jar>

Thanks to Ant 1.7.0, things are a bit different. With the addition of the manifestclasspath task, manifest classpath generation is a bit easier.


       <manifestclasspath property="manifest.classpath" jarfile="${jars.build.dir}/hack.jar">
            <classpath>
                <fileset dir="${jars.build.dir}">
                    <exclude name="junit-4.1.jar"/>
                </fileset>
            </classpath>
        </manifestclasspath>

        <jar destfile="${build.dir}/${core.jar}" basedir="${tmp.build.dir}" index="true">
            <manifest>
                <attribute name="Built-By" value="${authors}"/>
                <attribute name="Implementation-Title" value="core"/>
                <attribute name="Implementation-Version" value="${version} at ${TODAY}"/>
                <attribute name="Implementation-Vendor" value="${company}"/>
                <attribute name="Class-Path" value="${manifest.classpath}"/>
            </manifest>
        </jar>

Note the jarfile attribute is set to ${jars.build.dir}/hack.jar. hack.jar never comes into existence. The reason being is manifestclasspath attempts to create the classpath relative to the items in their actual location. Since this is during a build process, the location is temporal, and the incorrect parent dir is prepended. By convincing the manifestclasspath task that the jars are all in the same dir as the proposed, the jars are added without the unnecessary parent dir. For some seem trivial, but remember, it’s the small things.

Posted in Technical stuff | Leave a comment

Resin, what happened?

I’ve been a loyal Resin user for about 3 years now. For a time, it was one of the fastest servlet containers. Well, I have an web-app, made up of 3 wars. It uses a number of open-source, 3rd party libraries, such as Hibernate, Spring, Acegi, DisplayTag. The length of startup time has never really been an issue. However, after upgrading from resin-3.0.19 to resin-3.0.23, and deploying the expanded war, startup time went from 90 to 117 seconds.

Since I simply deployed the expanded war from on instance to another, I knew it had nothing to do w/ the war contents. Rather Resin was doing something different. The majority of load time seems to be during the precompiling of jsps. I wouldn’t mind the extra time, if a benefit was visible at request-time, but I didn’t see that. Although just a visual inspection, the pages returned in about the same speed.

I was initially writing to see if maybe i was imagining this — and then I saw a comparison done by Matt Raible. Guess should to take a closer look at Tomcat-5.5.

Posted in Technical stuff | 3 Comments

Re-attachment

If you use Hibernate and Spring, but no JTA or Seam, and you have to subscribe to the session-per-request-with-detached-objects model, you may have run into the following situation: having to reattaching detached objects to the current open Hibernate session. Even with an Open-Session-In-View filter or interceptor, you may have situations where you need to perform and operation on a detached object, but its parent session is closed.

Well, there are a few ways to handle this. Jason C. showed me some code that would merge pending changes, using the merge(…) method on the Session interface. In my situation, I needed a way to attach the persistent parent to the current open session, and let the natural cascading occur. So, AOP to the rescue. I added the ReattachAdvice (below) as advice to the all my DAOs, for their “save*” and “update*” methods.


public class ReattachAdvice implements MethodBeforeAdvice {
    ...
    public ReattachAdvice(String... inomingMethodNames) {
     // store incoming method name patterns
    }

    /**
     * @see org.springframework.aop.MethodBeforeAdvice#before(java.lang.reflect.Method,Object[],Object)
     */
    public void before(Method method, Object[] incomingArgs, Object target) throws Throwable {
        ...
        if (!(target instanceof AbstractHibernateDao)) return;

        final HibernateTemplate template = ((AbstractHibernateDao) target).getTemplate();
        final String methodName = method.getName();
        for (String pattern : namePatterns) {
            // Is a handled method?
            if (CommonUtil.stringMatch(pattern, methodName)) {
                for (int index = 0; index < incomingArgs.length; index++) {
                    Object tmpArg = incomingArgs[index];
                    if (tmpArg instanceof Entity) {
                        incomingArgs[index] = handleEntity(template, (Entity) tmpArg);
                    }
                }
                return;
            }
        }
    }

    private static Entity handleEntity(HibernateTemplate template, Entity entity) {
        if (entity.isPersisted()) {
            try {
                entity = (Entity) template.merge(entity);
            } catch (StaleObjectStateException e) {
                template.load(entity, entity.getId());
            }
        }
        return entity;
    }
}

Then I had to make the following addition in my Spring context files. Pre-AOP, I would have had to ensure that any method that might run into this issue, would call some re-attach method. This seems cleaner.


    <bean id="reattachAdvice" class="somepackaging.ReattachAdvice">
        <constructor-arg>
            <list>
                <value>save*</value>
                <value>update*</value>
            </list>
        </constructor>
    </bean>
    ...
    <bean id="daoTemplate" class="org.springframework.aop.framework.ProxyFactoryBean" abstract="true">
        <property name="interceptorNames">
            <list>
                <value>reattachAdvice</value>
                ... other advice
            </list>
        </property>
    </bean>

Posted in Technical stuff | 5 Comments

just like a mini-mall…

I saw this months ago, and sent it in an email to a few people. When I last checked it had 960,020 views. It’s basically the best commercial ever! Well, I saw a reference to it on SNL last night, and thought why not post it here. Enjoy.

Posted in Funny | Leave a comment

Echoes

Some guy (Jason) takes digital pictures of stuff (Rochester, NY). Vote for his work here. Note: You’ll have to sign up.

Posted in General | Leave a comment

Cash to Kermit

Johnny Cash’s last video before he and his wife passed on was to the song Hurt. It was excellent. Here’s a rendition of that video with Kermit the Frog. Enjoy.

Posted in Funny | Leave a comment