Technology news and views
RSS icon Email icon Home icon
  • Boston Hack Day Challenge this weekend

    Posted on February 24th, 2011 Sandeep 11 comments

    I will be heading to Boston this Friday for the Boston Hack Day Challenge. Getting there early enough though, is my first challenge. Sign-in starts at 5:30pm, and to be there by that time I will have to leave New York by 1:00pm — which is impossible given my deadlines at work.

    Still haven’t thought of what I will be working on — I may end up joining another team, or continue with the “audio reviews for the visually impaired” hack that I created during the Yahoo! Open Hack NYC event.

    Uncategorized
  • Apache WINK: Issue with Single-Element JSON Array

    Posted on January 14th, 2011 Sandeep No comments

    For the last few weeks, I have been building a RESTful service using the very fine Apache WINK library. When the service is called, the server sends a response in JSON. One of the response elements was an array; in the resulting response, if the array contained a single element I noticed a strange thing:

    {
      "success": true,
      "subject": "Some subject",
      "origin": {
        "email": "some@email.example.com",
        "fullname": "Full name"
      },
      "listresult": {
        "r1": "yes",
        "r2": "no",
        "r3": "cancel"
      }
    }

    The expected response, of course, was for listresult to be as follows:

    "listresult": [
        {
        "r1": "yes",
        "r2": "no",
        "r3": "cancel"
        }
      ]

    The response class used JAXB annotations to set the element names and all the other good stuff. But for some reason, a single element list resulted in an erroneous response. Now, out-of-the-box, WINK comes configured with JSON4J as the  provider for JSON serialization. This library has an unfortunate side effect where the array serialization shows unexpected behavior: for a single element array, it was simply collapsing the array!

    Which led me to this posting on the WINK user forum. The solution was to use an alternative provider. As mentioned in that post, I decided to go ahead with Jackson, available here. I chose the easier route of simply replacing the JSON4J library with Jackson, both in my build environment and in the WEB-INF/lib folder.

    This approach worked out fine for my needs. If, however, you have multiple services hosted by the same application and want each of them to have a separate provider, I refer you to this excellent post on IBM developerWorks.

    Uncategorized
  • Understanding MySQL Control Flow Functions

    Posted on May 21st, 2009 Sandeep 1 comment

    Sure, the documentation for control flow functions is available right here. But it’s not the easiest thing in the world to understand. The documentation, I mean – since the examples given there are very simple cases.

    Here’s a portion of it, explaining the CASE statement:

    CASE value WHEN [compare_value] THEN result [WHEN [compare_value] THEN result ...] [ELSE result] END

    CASE WHEN [condition] THEN result [WHEN [condition] THEN result ...] [ELSE result] END

    The first version returns the result where value=compare_value. The second version returns the result for the first condition that is true. If there was no matching result value, the result after ELSE is returned, or NULL if there is no ELSE  part.

    mysql> SELECT CASE 1 WHEN 1 THEN 'one'
        ->     WHEN 2 THEN 'two' ELSE 'more' END;
            -> 'one'
    mysql> SELECT CASE WHEN 1>0 THEN 'true' ELSE 'false' END;
            -> 'true'
    mysql> SELECT CASE BINARY 'B'
        ->     WHEN 'a' THEN 1 WHEN 'b' THEN 2 END;
            -> NULL

    Great, but how do you use it in an actual scenario where you want to, let’s say, update a column based on its current contents?

    Read the rest of this entry »

    Uncategorized
  • iPhone DevCamp NYC

    Posted on April 7th, 2008 Sandeep No comments

    There’s an iPhone DevCamp at the Polytechnic University in Brooklyn, NY on Saturday April 19, 2008. I will be attending, and if you’re interested, go sign up at http://barcamp.org/iPhoneDevCampNYC. If you’re a member of MoMo-NY, you know what the invite password is already. If not, go sign up and check out the message archive. I am still not sure if I want to dive into Objective C “just so I can develop for the iPhone”, but let’s see.

    Be sure to tag your flickr, technorati, digg, etc. posts with “iPhoneDevCampNYC”.

    Uncategorized
  • Apache JAMES Mailet: Processing Email Attachments

    Posted on November 1st, 2007 Sandeep 2 comments

     

    James Mailet

      

    The Apache JAMES project is a one-stop shop for your mail/news needs. At the core is the JAMES server, a Java SMTP/POP3 mail and NNTP news server. The project provides a Java API in form of the Apache Mailet API for “the rapid development and flexible deployment of email processing functionality.” While documentation is scarce, the Javadocs are pretty helpful, as the website says.

    One of the guys over at the JAMES server-user list posted a query on the ability to access/process a mail attachment from a mailet. I’m reproducing my response here, with a few more details. The JAMES server version assumed is 2.3.1 (latest and greatest at the time of this writing).

    Let’s assume you want to process incoming emails with pesky GIF images and modify their subject to include “[has GIF attachment]“, for whatever reason. It is assumed that the email is multipart MIME encoded. We will develop a matcher/mailet combo to do just this. The matcher is called “HasGifAttachment”, and the mailet is called “ChangeSubject”.

    Read the rest of this entry »

    Uncategorized