<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Invert Your Mind</title>
	<atom:link href="http://brian.pontarelli.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://brian.pontarelli.com</link>
	<description></description>
	<lastBuildDate>Wed, 16 May 2012 23:44:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Gradle review</title>
		<link>http://brian.pontarelli.com/2012/05/16/gradle-review/</link>
		<comments>http://brian.pontarelli.com/2012/05/16/gradle-review/#comments</comments>
		<pubDate>Wed, 16 May 2012 23:44:30 +0000</pubDate>
		<dc:creator>Brian Pontarelli</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://brian.pontarelli.com/?p=364</guid>
		<description><![CDATA[Inversoft has recently switched from Savant to Gradle until Savant 2.0 is finalized and can effectively rolled out (if this ever happens). Gradle is a decent temporary solution, but as a build tool junkie, it rubs me the wrong way. Here are some things that we encountered during the switch that Savant addresses. Maven Central <a href='http://brian.pontarelli.com/2012/05/16/gradle-review/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Inversoft has recently switched from Savant to Gradle until Savant 2.0 is finalized and can effectively rolled out (if this ever happens). Gradle is a decent temporary solution, but as a build tool junkie, it rubs me the wrong way. Here are some things that we encountered during the switch that Savant addresses.</p>
<p><strong>Maven Central</strong></p>
<p>We started by attempting to use Maven Central for our dependencies, but quickly realized that Maven Central is a complete mess. We also realized that it suffers from the &#8220;most surprise&#8221; pattern as well as &#8220;GPL&#8221; infestation. During our transition, we started to realize that using Maven Central actually caused our number of JARs to dramatically increase and for a couple of GPL JARs to sneak into our classpath. </p>
<p>In the end, we had to rever to managing our own repository and manage all of the ivy.xml dependency files by hand to ensure that everything was correct.</p>
<p><strong>Transitive Mess</strong></p>
<p>Gradle appears to suffer from the &#8220;let&#8217;s make it simple&#8221; methodology of Maven. In order to actually make life simple and avoid actual work, Maven pulls in the entire universe of your project dependencies for compiling and runtime. This means that even if you never import a class from a transitive dependency, Maven puts it in the classpath. This allows you to use classes from transitive dependencies. If you do this though, you&#8217;ll never actually know what JAR file a class comes from since it could come from some deeply nested dependency. It also tightly couples your project to your dependencies and those dependencies transitives. We prefer loose coupling rather than tight, so this is generally bad. We also like fewer dependencies at compile time rather than more. Again, bad news all around.</p>
<p><strong>Flat Structure</strong></p>
<p>Gradle plugins and domain are entirely flat. This makes it difficult to separate concerns and distinguish between Java compiling, testing and runtime. Maven actually got this right by cleaning separating concerns and separating plugins.</p>
<p><strong>Configuration vs. tasks</strong></p>
<p>Gradle build files can quickly become large and complex. It is often hard to distinguish between what is configuration and what are tasks.</p>
<p><strong>Order matters</strong></p>
<p>Order matters in Gradle build files unless you always use the String syntax for all configurations and tasks. If you have one task that depends on another task, the order of declaration matters. This is quite painful to debug and I thought we had finally grown out of single pass compiling. Apparently not.</p>
<p><strong>No Versions</strong></p>
<p>There are many pieces of Gradle that don&#8217;t like versions, e.g. plugins. These don&#8217;t have versions and just use the latest available. This is usually a bad idea because historical builds can break and you&#8217;ll never know what version you&#8217;ll be using when you execute a build.</p>
<p><strong>MD5 and SHA1?</strong></p>
<p>Why both?</p>
<p><strong>Hashes not always used</strong></p>
<p>The MD5 and SHA1 hashes aren&#8217;t always used. For example, the ivy.xml files don&#8217;t appear to use the hashes associated with that file. It really should use the hashes for everything.</p>
<p><strong>UploadArchives doesn&#8217;t run the tests</strong></p>
<p>WHAT?!?!?</p>
<p><strong>Summary</strong></p>
<p>Overall, I&#8217;m not a big fan of Gradle. It seems to be overly complex and sorta punts on dependency management. Having used Maven, Savant, Ant and Ivy, I would say that Savant 2.0 is still the best build system out there, even though it still isn&#8217;t finished.</p>
]]></content:encoded>
			<wfw:commentRss>http://brian.pontarelli.com/2012/05/16/gradle-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dependency Management Standardization</title>
		<link>http://brian.pontarelli.com/2011/10/14/dependency-management-standardization/</link>
		<comments>http://brian.pontarelli.com/2011/10/14/dependency-management-standardization/#comments</comments>
		<pubDate>Fri, 14 Oct 2011 21:43:46 +0000</pubDate>
		<dc:creator>Brian Pontarelli</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Savant]]></category>

		<guid isPermaLink="false">http://brian.pontarelli.com/?p=360</guid>
		<description><![CDATA[David Lloyd and I are working on getting some standards together for dependency management. We are hoping that this will help unify projects and provide the ability for all the different projects to use the same repositories. Please join us for the discussion if you have ideas you want to share. Here are the details: <a href='http://brian.pontarelli.com/2011/10/14/dependency-management-standardization/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://in.relation.to/Bloggers/David">David Lloyd</a> and I are working on getting some standards together for dependency management. We are hoping that this will help unify projects and provide the ability for all the different projects to use the same repositories.</p>
<p>Please join us for the discussion if you have ideas you want to share. </p>
<p>Here are the details:</p>
<p>10am PDT October 21<br />
##java-modularity on irc.freenode.net</p>
]]></content:encoded>
			<wfw:commentRss>http://brian.pontarelli.com/2011/10/14/dependency-management-standardization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IE filter gradient and positioning bug</title>
		<link>http://brian.pontarelli.com/2011/09/20/ie-filter-gradient-and-positioning-bug/</link>
		<comments>http://brian.pontarelli.com/2011/09/20/ie-filter-gradient-and-positioning-bug/#comments</comments>
		<pubDate>Wed, 21 Sep 2011 03:46:47 +0000</pubDate>
		<dc:creator>Brian Pontarelli</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://brian.pontarelli.com/?p=356</guid>
		<description><![CDATA[Today I found a bug in the IE rendering engine that revolves around IE positioning and using filter&#8217;s to handle gradients. My issue was that I had a navigation component that contained a drop-down menu. These drop down menus weren&#8217;t showing up in IE for some reason. After many hours of debugging, I traced it <a href='http://brian.pontarelli.com/2011/09/20/ie-filter-gradient-and-positioning-bug/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Today I found a bug in the IE rendering engine that revolves around IE positioning and using filter&#8217;s to handle gradients. My issue was that I had a navigation component that contained a drop-down menu. These drop down menus weren&#8217;t showing up in IE for some reason. After many hours of debugging, I traced it back to a gradient I was using on the navigation element using IE&#8217;s filter definition.</p>
<p>Here is the rough HTML:</p>
<pre class="brush: html">
&lt;div class="main-nav">
  &lt;ul>
    &lt;li class="level-1">
      &lt;a href="...">Menu 1&lt;/a>
      &lt;ul>
        &lt;li>&lt;a href="...">Sub Menu 1.1&lt;/a>&lt;/li>
        &lt;li>&lt;a href="...">Sub Menu 1.2&lt;/a>&lt;/li>
      &lt;/ul>
    &lt;/li>
    &lt;li class="level-1">
      &lt;a href="...">Menu 2&lt;/a>
      &lt;ul>
        &lt;li>&lt;a href="...">Sub Menu 2.1&lt;/a>&lt;/li>
        &lt;li>&lt;a href="...">Sub Menu 2.2&lt;/a>&lt;/li>
      &lt;/ul>
    &lt;/li>
  &lt;/ul>
</pre>
<p>The CSS that was failing looked something like this:</p>
<pre class="brush: css">
.main-nav {
  background: #e5e6ec; /* Old browsers */
  background: -moz-linear-gradient(top, #ffffff 0%, #e5e6ec 100%);  /* FF3.6+ */
  background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #fffff), color-stop(100%, #e5e6ec));  /* Chrome,Safari4+ */
  background: -webkit-linear-gradient(top, #ffffff 0%, #e5e6ec 100%);  /* Chrome10+,Safari5.1+ */
  background: -o-linear-gradient(top, #ffffff 0%, #e5e6ec 100%);  /* Opera11.10+ */
  background: -ms-linear-gradient(top, #ffffff 0%, #e5e6ec 100%); /* IE10+; */
  background: linear-gradient(top, #ffffff 0%, #e5e6ec 100%); /* W3C; */
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#ffff', endColorstr = '#e5e6ec', GradientType = 0); /* IE6-9 */
}

.main-nav ul {
  padding: 4px 35px 2px 35px;
  vertical-align: top;
}

.main-nav ul li.level-1 {
  display: inline-block;
  position: relative;
}

.main-nav ul li.level-1 a {
  display: inline-block;
  padding: 5px 20px 5px 0;
}

.main-nav ul li ul {
  background: #e5e6ec;
  display: none;
  padding: 0 15px 10px 15px;
  position: absolute;
  top: 29px;
}
</pre>
<p>The issue with IE 8 (and probably IE 9) is that the gradient definition of:</p>
<pre class="brush: css">
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#ffff', endColorstr = '#e5e6ec', GradientType = 0);
</pre>
<p>caused the drop-down menus to not show up correctly. After moving them around and using some visibility magic, I found that the drop-downs were actually getting clipped inside the outer UL element. Once I removed the filter it all worked fine.</p>
]]></content:encoded>
			<wfw:commentRss>http://brian.pontarelli.com/2011/09/20/ie-filter-gradient-and-positioning-bug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Database date/time support sucks</title>
		<link>http://brian.pontarelli.com/2011/08/17/database-datetime-support-sucks/</link>
		<comments>http://brian.pontarelli.com/2011/08/17/database-datetime-support-sucks/#comments</comments>
		<pubDate>Wed, 17 Aug 2011 21:56:25 +0000</pubDate>
		<dc:creator>Brian Pontarelli</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://brian.pontarelli.com/?p=350</guid>
		<description><![CDATA[Okay, after many hours of battling with MySQL and PostgreSQL, I&#8217;ve come to the conclusion that databases support for dates and times suck. PostgreSQL appears to do a much better job than MySQL, but overall they both leave a lot to be desired. The main The main issues with both these databases is that the <a href='http://brian.pontarelli.com/2011/08/17/database-datetime-support-sucks/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Okay, after many hours of battling with MySQL and PostgreSQL, I&#8217;ve come to the conclusion that databases support for dates and times suck. PostgreSQL appears to do a much better job than MySQL, but overall they both leave a lot to be desired. The main</p>
<p>The main issues with both these databases is that the lack the ability to store values as UTC without any timezone information. That&#8217;s right, I don&#8217;t want the database to know anything about timezones. See, once the database starts to store timezone information or worse, store dates and times without timezone information but not in UTC, you get into the situation where everything melts down if the timezone of the operating system or the database server changes. You also get into really nasty issues when you migrate data across locations, for example by exporting data from a server in San Francisco and migrating it to a server in London.</p>
<p>If you think about it, databases are primarily used for storing and retrieving data. In 99.9999% of applications, the database is NOT responsible for displaying data. For this reason, the database should not know anything about timezones because these are purely for display purposes. The correct way to store date and time data is at UTC.</p>
<p>So, what&#8217;s my solution given the horrible date and time support in databases? Don&#8217;t use them and use bigint instead. Store everything using the number of milliseconds since epoch in UTC. Never ever do any timezone math with your dates and times. Handle everything in UTC and only do timezone manipulations just before you display the data to a user.</p>
<p>I pulled this off by changing all of my datetime and timestamp columns to be bigint instead. They now look like this:</p>
<pre class="brush: sql">
create table foo (
  insert_instant bigint not null,
  update_instant bigint not null
);
</pre>
<p>Additionally, in my application code when I use JDBC I pull the data out as Longs like this:</p>
<pre class="brush: java">
// using Joda here - if you don't use Joda you should
ResultSet rs = ...;
long insertInstant = rs.getLong(1);
DateTime dt = new DateTime(insertInstant);
</pre>
<p>Lastly, I wrote a Hibernate UserType that converts from longs to Joda DateTime instances and annotate my entities like this:</p>
<pre class="brush: java">
@Entity
public class Foo {
  @Column(name = "insert_instant", updatable = false)
  @Type(type = "com.inversoft.cleanspeak.api.domain.hibernate.DateTimeType")
  public DateTime insertInstant;
}
</pre>
<p>And that&#8217;s it. It works perfectly and I never have to worry about any of my data getting screwed up if someone changes the system timezone or migrates data from one server to another. Furthermore, I finally get full support for milliseconds on MySQL and I also can add support to Clean Speak for new databases easily.</p>
]]></content:encoded>
			<wfw:commentRss>http://brian.pontarelli.com/2011/08/17/database-datetime-support-sucks/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Database handling for TimeZones</title>
		<link>http://brian.pontarelli.com/2011/08/16/database-handling-for-timezones/</link>
		<comments>http://brian.pontarelli.com/2011/08/16/database-handling-for-timezones/#comments</comments>
		<pubDate>Tue, 16 Aug 2011 22:54:14 +0000</pubDate>
		<dc:creator>Brian Pontarelli</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://brian.pontarelli.com/?p=346</guid>
		<description><![CDATA[Today I&#8217;ve been working with Postgresql and MySQL trying to figure out how they handle date-time values and timezones. This is actually quite tricky, so I wanted to write it down for later. First, both databases have two different types of columns: One that stores the date-time without any time zone information One that stores <a href='http://brian.pontarelli.com/2011/08/16/database-handling-for-timezones/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Today I&#8217;ve been working with Postgresql and MySQL trying to figure out how they handle date-time values and timezones. This is actually quite tricky, so I wanted to write it down for later. First, both databases have two different types of columns:</p>
<ul>
<li>One that stores the date-time without any time zone information</li>
<li>One that stores the date-time with time zone information</li>
</ul>
<p>For Postgresql, these are:</p>
<ul>
<li>timestamp without time zone</li>
<li>timestamp with time zone</li>
</ul>
<p>respectively. </p>
<p>For MySQL, these are:</p>
<ul>
<li>datetime</li>
<li>timestamp</li>
</ul>
<p>There are a number of things to consider when dealing with date-time values:</p>
<ul>
<li>What if the timezone of the server changes?</li>
<li>What if the server moves physical locations thereby indicating a new time zone?</li>
<li>What if the timezone of the database server changes (different than the timezone of the server)?</li>
<li>How does the JDBC driver handle timezones?</li>
<li>How does the database handle timezones?</li>
</ul>
<p>To figure all of this out, it is important to understand how the date-time value goes from the application, to the database, out of the database and back to the application (for inserts and later selects). Here is how this works for values without timezone information:</p>
<p><strong>Insert</strong></p>
<ol>
<li>Java creates a java.sql.Timestamp instance. This is stored as UTC</li>
<li>Java sends this value to the JDBC driver in UTC</li>
<li>The JDBC driver sends the value to the database in UTC</li>
<li>The database converts the date-time from UTC to its current timezone setting</li>
<li>The database inserts the value into the column in the current timezone (NOT UTC)</li>
</ol>
<p><strong>Select</strong></p>
<ol>
<li>The database selects the value from the column in the system timezone</li>
<li>The database converts the value to UTC</li>
<li>The database sends the UTC value to the JDBC driver</li>
<li>The JDBC driver creates a new java.sql.Timestamp instance with the UTC value</li>
</ol>
<p>For this scenario, you will run into major issues if the the server or database timezone changes between Insert #5 and Select #1. In this case, the value will not be correct. The only way to make things work correctly for this setup is to ensure no timezone settings ever change or to set all timezones to UTC for everything.</p>
<p>For the types that store timezone information, here is how the data is passed around:</p>
<p><strong>Insert</strong></p>
<ol>
<li>Java creates a java.sql.Timestamp instance. This is stored as UTC</li>
<li>Java sends this value to the JDBC driver in UTC</li>
<li>The JDBC driver sends the value to the database in UTC</li>
<li>The database calculates the offset between the current timezone and UTC</li>
<li>The database inserts the value as UTC into the column along with the offset it calculated</li>
</ol>
<p><strong>Select</strong></p>
<ol>
<li>The database selects the value from the column in UTC along with the offset</li>
<li>The database sends the UTC value to the JDBC driver</li>
<li>The JDBC driver creates a new java.sql.Timestamp instance with the UTC value</li>
</ol>
<p>Since the JDBC driver only handles UTC values, there is no potential for data mangling here since everything is stored in UTC inside the database. Although the database stores the timezone information along with the date-time value in UTC, it isn&#8217;t ever used because the JDBC driver doesn&#8217;t care what the original timezone was and ignores that value.</p>
]]></content:encoded>
			<wfw:commentRss>http://brian.pontarelli.com/2011/08/16/database-handling-for-timezones/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracles OLTP numbers vs. Clean Speak</title>
		<link>http://brian.pontarelli.com/2011/07/28/oracles-oltp-numbers-vs-clean-speak/</link>
		<comments>http://brian.pontarelli.com/2011/07/28/oracles-oltp-numbers-vs-clean-speak/#comments</comments>
		<pubDate>Thu, 28 Jul 2011 15:36:35 +0000</pubDate>
		<dc:creator>Brian Pontarelli</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://brian.pontarelli.com/?p=342</guid>
		<description><![CDATA[Oracle is hosting a webinar today covering the awesome performance of their Exadata system. Sure Oracle&#8217;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 <a href='http://brian.pontarelli.com/2011/07/28/oracles-oltp-numbers-vs-clean-speak/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Oracle is hosting a webinar today covering the awesome performance of their Exadata system. Sure Oracle&#8217;s OLTP tests probably do slightly more than <a href="http://www.inversoft.com">Clean Speak</a> does, but 1,870 transactions in 2 minutes hardly seems like something to rave about. </p>
<p>The <a href="http://www.inversoft.com/resources/technical-specifications">Clean Speak profanity filter</a> handles between 5,000 and 10,000 messages per second. The profanity filter doesn&#8217;t hit the database, but the Clean Speak Moderator tool does. </p>
<p>The latest tests of the <a href="http://www.inversoft.com/features">Moderation</a> tool put it around 1,000-2,000 messages per second. </p>
<p>So, if we use Oracle&#8217;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.</p>
]]></content:encoded>
			<wfw:commentRss>http://brian.pontarelli.com/2011/07/28/oracles-oltp-numbers-vs-clean-speak/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Escaping JSON in FreeMaker</title>
		<link>http://brian.pontarelli.com/2011/07/18/escaping-json-in-freemaker/</link>
		<comments>http://brian.pontarelli.com/2011/07/18/escaping-json-in-freemaker/#comments</comments>
		<pubDate>Mon, 18 Jul 2011 16:39:14 +0000</pubDate>
		<dc:creator>Brian Pontarelli</dc:creator>
				<category><![CDATA[FreeMaker]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[WebService]]></category>

		<guid isPermaLink="false">http://brian.pontarelli.com/?p=337</guid>
		<description><![CDATA[The ?js_string doesn&#8217;t work quite right for JSON since it ends up escaping single-quotes. This isn&#8217;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&#8217;s <a href='http://brian.pontarelli.com/2011/07/18/escaping-json-in-freemaker/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>The ?js_string doesn&#8217;t work quite right for JSON since it ends up escaping single-quotes. This isn&#8217;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&#8217;s my code for a JSON escaper method:</p>
<pre>
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());
  }
}
</pre>
<p>The JSONBuilder is a class that I wrote for creating JSON using the builder pattern. However, the escape method looks like this:</p>
<pre>
  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) &#038; 0xf]);
    build.append(HEX_CHARS[(ch >>> 4) &#038; 0xf]);
    build.append(HEX_CHARS[ch &#038; 0xf]);
  }
</pre>
<p>Then I add this method to my model and render the template:</p>
<pre>
model.put("jsonescape", new JSONEscape());
</pre>
<p>My templates look like this:</p>
<pre>
{
  "foo": "${jsonescape(some.value.here)}"
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://brian.pontarelli.com/2011/07/18/escaping-json-in-freemaker/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Friendster can&#8217;t even send email</title>
		<link>http://brian.pontarelli.com/2011/07/01/friendster-cant-even-send-email/</link>
		<comments>http://brian.pontarelli.com/2011/07/01/friendster-cant-even-send-email/#comments</comments>
		<pubDate>Fri, 01 Jul 2011 14:27:54 +0000</pubDate>
		<dc:creator>Brian Pontarelli</dc:creator>
				<category><![CDATA[Engineering]]></category>
		<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://brian.pontarelli.com/?p=333</guid>
		<description><![CDATA[I&#8217;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&#8217;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 <a href='http://brian.pontarelli.com/2011/07/01/friendster-cant-even-send-email/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;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&#8217;t even figure out how to send email.</p>
<p><code></p>
<p>X-Campaign-ID: 8002<br />
X-Campaign-Type: 1<br />
X-Message-Ref: 19lGRwmaJkSjEf8FZP7XSCijJOJhOejGu832ySW13bA*<br />
Content-Type: multipart/alternative; boundary="----_=_FSter_001_3251309519900466"<br />
MIME-Version: 1.0</p>
<p>This is a MIME email, the first part is the text message.</p>
<p>------_=_FSter_001_3251309519900466<br />
Content-Type: text/plain; charset="UTF-8"<br />
Content-Transfer-Encoding: 7bit</p>
<p>Friendster www.friendster.com July 2011</p>
<p>A Personal Message from Friendster's CEO</p>
<p>- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -</p>
<p>Dear fellow Friendster members,<br />
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.<br />
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.<br />
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.<br />
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.<br />
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.<br />
Yours truly,<br />
Ganesh Kumar Bangah<br />
Chief Executive Officer<br />
ceo@friendster.com</p>
<p>****************************************************************<br />
To manage your notification preferences go to: http://www.friendster.com/account/notifications<br />
Copyright 2002-2011 Friendster, Inc. All rights reserved.<br />
****************************************************************</p>
<p>------_=_FSter_001_3251309519900466<br />
Content-Type: text/html; charset="UTF-8"<br />
Content-Transfer-Encoding: 7bit</p>
<p>[SNIP - I cut out the HTML so I didn't have to escape everything by hand]</p>
<p>------_=_FSter_001_3251309519900466--<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://brian.pontarelli.com/2011/07/01/friendster-cant-even-send-email/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>JDBC Batch vs. Multi-Row Inserts</title>
		<link>http://brian.pontarelli.com/2011/06/21/jdbc-batch-vs-multi-row-inserts/</link>
		<comments>http://brian.pontarelli.com/2011/06/21/jdbc-batch-vs-multi-row-inserts/#comments</comments>
		<pubDate>Tue, 21 Jun 2011 15:55:26 +0000</pubDate>
		<dc:creator>Brian Pontarelli</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://brian.pontarelli.com/?p=330</guid>
		<description><![CDATA[I recently had a requirement to insert a few hudred rows into a relational database ever couple of seconds. Generally this could be accomplished during the request, but I didn&#8217;t want to introduce issues if there were spikes. Therefore, I figured I would cache the data and then write it out in a background thread <a href='http://brian.pontarelli.com/2011/06/21/jdbc-batch-vs-multi-row-inserts/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>I recently had a requirement to insert a few hudred rows into a relational database ever couple of seconds. Generally this could be accomplished during the request, but I didn&#8217;t want to introduce issues if there were spikes. Therefore, I figured I would cache the data and then write it out in a background thread every few seconds. This would also increase my response time during requests.</p>
<p>I wasn&#8217;t sure whether or not JDBC batch or using a single insert statement that inserted multiple rows would be faster. Therefore, I setup a little test to see which was going to work better. First some code:</p>
<p>Here is the code for a single insert statement that inserts multiple rows.</p>
<pre>
long start = System.currentTimeMillis();
StringBuilder build = new StringBuilder("insert into insert_values (foo, bar, baz) values ");
for (int i = 0; i < 1000; i++) {
  build.append("(?, ?, ?)");
  if (i < 999) {
    build.append(", ");
  } else {
    build.append(";");
  }
}

Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3306/batch_vs_insert_test", "dev", "dev");
c.setAutoCommit(false);
PreparedStatement ps = c.prepareStatement(build.toString());
for (int i = 0; i &lt; 3000; i++) {
  ps.setString(i + 1, "value" + i);
}

int result = ps.executeUpdate();
c.commit();

long end = System.currentTimeMillis();
System.out.println("Insert time was " + (end - start));

ps.close();
c.close();
</pre>
<p>Here is the code for the JDBC batch:</p>
</pre>
<pre>
long start = System.currentTimeMillis();
Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3306/batch_vs_insert_test", "dev", "dev");
c.setAutoCommit(false);
PreparedStatement ps = c.prepareStatement("insert into insert_values (foo, bar, baz) values (?, ?, ?);");
for (int i = 0; i &lt; 3000; i++) {
  ps.setString((i % 3) + 1, "value" + i);
  if ((i + 1) % 3 == 0) {
    ps.addBatch();
  }
}

int[] results = ps.executeBatch();
c.commit();

long end = System.currentTimeMillis();
System.out.println("Batch time was " + (end - start));

ps.close();
c.close();
</pre>
<p>The average time over 10 iterations where roughly as follows:</p>
<p>JDBC Batch: ~100 milliseconds<br />
Single Insert: ~10 milliseconds</p>
<p>It looks like the single insert statement wins by a large margin.</p>
]]></content:encoded>
			<wfw:commentRss>http://brian.pontarelli.com/2011/06/21/jdbc-batch-vs-multi-row-inserts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iMac vs. build-your-own</title>
		<link>http://brian.pontarelli.com/2011/05/13/imac-vs-build-your-own/</link>
		<comments>http://brian.pontarelli.com/2011/05/13/imac-vs-build-your-own/#comments</comments>
		<pubDate>Fri, 13 May 2011 15:30:34 +0000</pubDate>
		<dc:creator>Brian Pontarelli</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://brian.pontarelli.com/?p=327</guid>
		<description><![CDATA[I&#8217;ve been meaning to do this comparison for a while now, but this morning I decided to just jump in and do it. A lot of people are constantly complaining about how expensive Macs are and I&#8217;ve long held the notion that they are quite reasonably priced. Here&#8217;s my break down: CPU (i7 2600K 3.4GHz <a href='http://brian.pontarelli.com/2011/05/13/imac-vs-build-your-own/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been meaning to do this comparison for a while now, but this morning I decided to just jump in and do it. A lot of people are constantly complaining about how expensive Macs are and I&#8217;ve long held the notion that they are quite reasonably priced.</p>
<p>Here&#8217;s my break down:</p>
<ul>
<li>CPU (i7 2600K 3.4GHz Sandybridge) $320</li>
<li>Motherboard (ASUS P8P67) $185</li>
<li>RAM (8GB DDR3 1333MHz) $83</li>
<li>Hard Drive (WD 1TB 7,200 RPM SATA 6G) $85</li>
<li>Video (ATI Radeon 6970M) $300</li>
<li>Keyboard/Mouse (MS wireless) $80</li>
<li>Monitor (Dell Ultrasharp 27&#8243; 2560&#215;1440) $1000</li>
<li>Webcam (Any) $50</li>
<li>Speakers (Any) $15</li>
</ul>
<p>The main expense here is definitely the CPU and the monitor. However, for equal comparisons I wanted to add a monitor that was comparable in quality, display, depth, etc. You could obviously go with a cheaper monitor from an off-brand, but I think that&#8217;s not a fair comparison.</p>
<p>Here&#8217;s the results:</p>
<ul>
<li>Apple iMac 27&#8243; with 3.4 GHz CPU and 8GB RAM factory installed: $2,199</li>
<li>BYO with above specs: $2,118</li>
</ul>
<p>The difference is about <strong>$81</strong>.</p>
<p>I poked around a bit at some desktop solutions as well, and even an entry level desktop with the i7 2600K and the Dell ultrasharp monitor is going to start around <strong>$2,000</strong>.</p>
<p>It looks like my notion about the value of a Mac is accurate. Furthermore, with the fact that the iMac is a single piece of equipment that includes the computer and the monitor and you get what I still feel is the worlds best operating system plus a bunch of free software, it is hard to argue that an iMac isn&#8217;t a great value.</p>
]]></content:encoded>
			<wfw:commentRss>http://brian.pontarelli.com/2011/05/13/imac-vs-build-your-own/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

