Jul 282011
 

Oracle is hosting a webinar today covering the awesome performance of their Exadata system. Sure Oracle’s OLTP tests probably do slightly more than Clean Speak does, but 1,870 transactions in 2 minutes hardly seems like something to rave about.

The Clean Speak profanity filter handles between 5,000 and 10,000 messages per second. The profanity filter doesn’t hit the database, but the Clean Speak Moderator tool does.

The latest tests of the Moderation tool put it around 1,000-2,000 messages per second.

So, if we use Oracle’s time granularity of 2 minutes, Clean Speak handles anywhere from 60,000-600,000 messages. Perhaps Oracle needs to work on optimizing their OTLP test system a bit.

Jul 182011
 

The ?js_string doesn’t work quite right for JSON since it ends up escaping single-quotes. This isn’t quite right for JSON since it only allows Strings to be specified using double-quotes. Therefore, in order to properly escape Strings in FreeMarker for JSON, you need to write a custom method and add it to the model. Here’s my code for a JSON escaper method:

public class JSONEscape implements TemplateMethodModelEx {
  @Override
  public Object exec(List arguments) throws TemplateModelException {
    if (arguments.size() != 1) {
      throw new TemplateModelException("jsonescape takes a single parameter");
    }

    return JSONBuilder.escape(arguments.get(0).toString());
  }
}

The JSONBuilder is a class that I wrote for creating JSON using the builder pattern. However, the escape method looks like this:

  public static String escape(String str) {
    StringBuilder build = new StringBuilder();
    escape(str, build);
    return build.toString();
  }

  public static void escape(String str, StringBuilder build) {
    char[] ca = str.toCharArray();
    for (char c : ca) {
      switch (c) {
        case '"':
        case '\\':
          build.append('\\');
          build.append(c);
          break;
        case '\r':
          build.append("\\r");
          break;
        case '\n':
          build.append("\\n");
          break;
        case '\t':
          build.append("\\t");
          break;
        case '\b':
          build.append("\\b");
          break;
        case '\f':
          build.append("\\f");
          break;
        case '/':
          build.append("\\/");
          break;
        default:
          if (c < = 0x1F) {
            unicodeEscape(c, build);
          } else {
            build.append(c);
          }
      }
    }
  }

  public static void unicodeEscape(int ch, StringBuilder build) {
    build.append('\\');
    build.append('u');
    build.append(HEX_CHARS[ch >>> 12]);
    build.append(HEX_CHARS[(ch >>> 8) & 0xf]);
    build.append(HEX_CHARS[(ch >>> 4) & 0xf]);
    build.append(HEX_CHARS[ch & 0xf]);
  }

Then I add this method to my model and render the template:

model.put("jsonescape", new JSONEscape());

My templates look like this:

{
  "foo": "${jsonescape(some.value.here)}"
}
Jul 012011
 

I’m surprised that Friendster is even still around, but today I got an email from their CEO and it had the entire MIME body in the message. These guys can’t even figure out how to send email.

X-Campaign-ID: 8002
X-Campaign-Type: 1
X-Message-Ref: 19lGRwmaJkSjEf8FZP7XSCijJOJhOejGu832ySW13bA*
Content-Type: multipart/alternative; boundary="----_=_FSter_001_3251309519900466"
MIME-Version: 1.0

This is a MIME email, the first part is the text message.

------_=_FSter_001_3251309519900466
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit

Friendster www.friendster.com July 2011

A Personal Message from Friendster's CEO

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Dear fellow Friendster members,
As many of you may know, Friendster announced that it is re-launching itself as a social gaming portal and launched a beta version of the new Friendster a couple of weeks ago. The beta version was well received. I am pleased to announce that the new Friendster is going live thereby enabling all our users to login to the new Friendster using your existing Friendster username and password.
Friendster has touched the lives of many. Since MOL, the company I founded acquired Friendster in early last year; many people have come up to me to tell me how Friendster has changed their lives. Many have told me that they have found their life partners over Friendster. Just last week, a successful Internet entrepreneur in Singapore told me that her success was triggered by promoting her business on Friendster. Friendster pioneered social networking and ignited the social media industry that has created billion dollar companies such as Facebook and Twitter, companies that may not have existed in their present form if not for Friendster's early innovation.
Today, Friendster is in a unique position to take advantage on the growth of social gaming. Through its relationship with MOL, which has a 10 year history in working with gaming companies, Friendster has both the experience and track record to make innovations in this space.
Today, as Friendster reinvents itself as a social gaming destination that enables its users to create multiple avatars, play games and enjoy rewards; I hope that all of you will wish us luck and continue to support us in our new reincarnation. The new Friendster is not perfect and we will continue to add new games and features such as localization and rewards over the next few months. Our team is working hard on adding these features and welcomes your suggestions and comments on how we can better serve your needs as a social gaming and entertainment destination.
I would like to take this opportunity to thank all of you for your support and hope that all of you will enjoy the new Friendster as Friendster continues to innovate to serve and entertain you better.
Yours truly,
Ganesh Kumar Bangah
Chief Executive Officer
ceo@friendster.com

****************************************************************
To manage your notification preferences go to: http://www.friendster.com/account/notifications
Copyright 2002-2011 Friendster, Inc. All rights reserved.
****************************************************************

------_=_FSter_001_3251309519900466
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: 7bit

[SNIP - I cut out the HTML so I didn't have to escape everything by hand]

------_=_FSter_001_3251309519900466--