<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Saffron Developer Blog</title>
	<atom:link href="http://saffrontech.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://saffrontech.wordpress.com</link>
	<description>Associative Memory Technology Discussions</description>
	<lastBuildDate>Thu, 12 Nov 2009 17:22:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='saffrontech.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Saffron Developer Blog</title>
		<link>http://saffrontech.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://saffrontech.wordpress.com/osd.xml" title="Saffron Developer Blog" />
	<atom:link rel='hub' href='http://saffrontech.wordpress.com/?pushpress=hub'/>
		<item>
		<title>It&#8217;s All Just Counts</title>
		<link>http://saffrontech.wordpress.com/2009/11/12/its-all-just-counts/</link>
		<comments>http://saffrontech.wordpress.com/2009/11/12/its-all-just-counts/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 17:22:40 +0000</pubDate>
		<dc:creator>Manny Aparicio</dc:creator>
				<category><![CDATA[Natural Intelligence]]></category>
		<category><![CDATA[analogies]]></category>
		<category><![CDATA[classifications]]></category>
		<category><![CDATA[counts]]></category>
		<category><![CDATA[entropy]]></category>

		<guid isPermaLink="false">http://saffrontech.wordpress.com/?p=71</guid>
		<description><![CDATA[The idea of a memory base is simple.  We define a memory as a matrix, keeping counts in the matrix cells between the names of things on the rows and columns.  Let’s say we had a memory of me, called “Person: Manny”.  If I query the row called “City: London” and ask for associated columns [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saffrontech.wordpress.com&amp;blog=8618537&amp;post=71&amp;subd=saffrontech&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The idea of a memory base is simple.  We define a memory as a matrix, keeping counts in the matrix cells between the names of things on the rows and columns.  Let’s say we had a memory of me, called “Person: Manny”.  If I query the row called “City: London” and ask for associated columns for “Carrier: ?”, I’d see “AA” and “BA” for American and British Airlines.  Moreover, AA would be returned with a count of 6 and BA with a count of 1.  More than just the existence of my travel relationships, we can also see the strength of my travel habits – in the context of going to London at least.</p>
<p>The idea is simple but fundamental.  When we started Saffron and began working with one of the big intelligent agencies, one true believer in what we were doing would provoke others by saying, “It’s all just counts.  What else is there?”  What did he mean?  When dealing with the analysis of massive data, so much of what is computed needs to be computed over counts.   More deeply, information and knowledge is based on the frequencies of what we see in the world.  Counts are fundamental to knowing what we know.</p>
<p>Let’s use even the most basic definition of a statistical mean or “average”, computed as the sum of counts divided by the number of counts.  An average count is useful as a measure of expected value (although other measures are also possible from counts).  Knowing nothing else, you can have an expectation about how tall a person is or often a business person travels.  Meeting someone who is 7 feet tall is rare.   A million mile traveler is unusual.   In general, these deviations from expectation are surprising, unusual, and potentially interesting.  This simple measure, based on count frequencies, is fundamental to many forms of analysis.</p>
<p>Now let’s look at a more advanced but still fundamental measure, such as entropy, a measure of disorder &#8212; or information &#8212; contained in a frequency distribution.    If we define information formally, as in Information Theory, then counts are critical to this definition and its application.  Think of the “analogies” query in the SaffronMemoryBase REST API.  How do we find entities that are similar to a given entity?  The entire method starts with getting a signature of the most informative attributes for the given entity.  What is most informative?  If the analysis were over a “bad guy” database and in fact all the persons are described as “gender: male”, then being male doesn’t tell us much.  In fact, it holds zero information as defined by an entropy measure.  But suppose the given entity was born in Timbuktu and only one other person was born in Timbuktu?  This is maximally informative when reasoning by similarity.</p>
<p>This example describes a method for entity resolution, determining who might actually be whom such as to resolve name variants and aliases.  Or you might want to find similar bad guys with a similar signature.  If you are a manufacturer, we might need to find similar parts, such as for part replacement strategies.  Also for predictive analytics, the “classifications” method in the REST API is a form of nearest neighbor classification, also reasoning by similarity.    As with “analogies”, the memory base supports a larger process of easily and quickly computing over connections and counts, but computing entropy is part of the process.   If the classifications are for buying and selling, sniffing whether transactions are suspicious or not, or deciding whether a product is desirable or not, the differentiating power of each attribute can be weighted by the distribution of frequencies.  If the counts of the attribute are distributed over the classifications according to chance, then it doesn’t seem to matter.  To the degree an attribute is more associated with one class, then it is informative to helping us make the classification.</p>
<p>The information in counts comes from data but is stored in a memory “above” the data.  I recently heard someone in the intelligence community say, “Everything we want to compute begins with collecting the counts.  We spend too much query time just to get these counts” (using map-reduce to compute of massive data at query time).   So why not start with a count-based representation? Why waste time searching and scanning for counts when they can be always at the ready for more advanced analysis?   The requirements for massive data analysis, whether for entity analysis or predictive analysis, are growing.   SaffronMemoryBase is a massive connection engine as well as a massive correlation engine, both of which are fundamental to analysis.  Connections and counts.  What else is there?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/saffrontech.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/saffrontech.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/saffrontech.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/saffrontech.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/saffrontech.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/saffrontech.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/saffrontech.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/saffrontech.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/saffrontech.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/saffrontech.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/saffrontech.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/saffrontech.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/saffrontech.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/saffrontech.wordpress.com/71/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saffrontech.wordpress.com&amp;blog=8618537&amp;post=71&amp;subd=saffrontech&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://saffrontech.wordpress.com/2009/11/12/its-all-just-counts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dbb5d45029353296a8b6cb42b4b5771a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Mad Dog</media:title>
		</media:content>
	</item>
		<item>
		<title>Bootstrapping, An Environmentalist&#8217;s Perspective</title>
		<link>http://saffrontech.wordpress.com/2009/09/28/bootstrapping-an-environmentalists-perspective/</link>
		<comments>http://saffrontech.wordpress.com/2009/09/28/bootstrapping-an-environmentalists-perspective/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 15:19:59 +0000</pubDate>
		<dc:creator>Jared Peterson</dc:creator>
				<category><![CDATA[Sierra]]></category>
		<category><![CDATA[grails]]></category>

		<guid isPermaLink="false">http://saffrontech.wordpress.com/?p=57</guid>
		<description><![CDATA[Grails gives you a handy little class called Bootstrap.groovy.  As it&#8217;s name implies this class allows you to &#8220;bootstrap&#8221; your application at startup (and shutdown).  This is pretty handy in development when you want your application to start with some sample data loaded.  For example, you might use Bootstrap.groovy to create a bunch of test [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saffrontech.wordpress.com&amp;blog=8618537&amp;post=57&amp;subd=saffrontech&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://grails.org" target="_blank">Grails</a> gives you a handy little class called Bootstrap.groovy.  As it&#8217;s name implies this class allows you to &#8220;bootstrap&#8221; your application at startup (and shutdown).  This is pretty handy in development when you want your application to start with some sample data loaded.  For example, you might use Bootstrap.groovy to create a bunch of test user accounts (that&#8217;s what we do for <a href="http://saffronsierra.com" target="_blank">Sierra</a>).  As you start to move your application into production you might find yourself commenting out lines of code (I did) in Bootstrap.groovy so that the production version of your application does not launch with all of your sample data loaded.</p>
<p>This week as I was working on some administrative functions for Sierra I found myself thinking there had to be a better way, and it turns out there is.  As I&#8217;ve discussed <a href="http://saffrontech.wordpress.com/2009/09/21/grails-the-good-and-the-bad/" target="_blank">before</a> when Grails launches it knows what mode/environment it&#8217;s running in.  The default environments are &#8220;development&#8221;, &#8220;test&#8221;, and &#8220;production&#8221;.  The Grails configuration scripts Config.groovy, DataSource.groovy, etc&#8230; give you handy &#8220;<a href="http://grails.org/doc/latest/guide/3.%20Configuration.html#3.2%20Environments" target="_blank">environments</a>&#8221; blocks, but what about classes such as Bootstrap.groovy.  What should we do there?  The answer is the <a href="http://grails.org/doc/1.1.1/api/grails/util/Environment.html" target="_blank">grails.util.Environment</a> class.  This class knows what the current running environment is.  If we use this in Bootstrap.groovy we now have a way to only load our sample data if we are in &#8220;development&#8221; mode.  This is how it looks:</p>
<p><pre class="brush: plain;">
if (Environment.getCurrent() == Environment.DEVELOPMENT) {

// Insert sample data here

}
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/saffrontech.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/saffrontech.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/saffrontech.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/saffrontech.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/saffrontech.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/saffrontech.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/saffrontech.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/saffrontech.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/saffrontech.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/saffrontech.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/saffrontech.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/saffrontech.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/saffrontech.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/saffrontech.wordpress.com/57/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saffrontech.wordpress.com&amp;blog=8618537&amp;post=57&amp;subd=saffrontech&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://saffrontech.wordpress.com/2009/09/28/bootstrapping-an-environmentalists-perspective/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3041b947632770a91a74b926d2b19755?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jaredatsaffron</media:title>
		</media:content>
	</item>
		<item>
		<title>Grails, The Good and The Bad</title>
		<link>http://saffrontech.wordpress.com/2009/09/21/grails-the-good-and-the-bad/</link>
		<comments>http://saffrontech.wordpress.com/2009/09/21/grails-the-good-and-the-bad/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 13:36:04 +0000</pubDate>
		<dc:creator>Jared Peterson</dc:creator>
				<category><![CDATA[Sierra]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[REST]]></category>

		<guid isPermaLink="false">http://saffrontech.wordpress.com/?p=34</guid>
		<description><![CDATA[As I&#8217;ve mentioned here before we&#8217;ve been using Grails to build the web front-end for Sierra as well as the Sierra REST API.  This week has provided a couple of great examples of the joys, and pains, of using open source software.  Let me start by saying that using Grails is mostly all joy, and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saffrontech.wordpress.com&amp;blog=8618537&amp;post=34&amp;subd=saffrontech&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As I&#8217;ve mentioned <a href="http://saffrontech.wordpress.com/2009/09/14/rest-jquery-jsonp-grails/" target="_blank">here</a> <a href="http://saffrontech.wordpress.com/2009/09/04/using-grails-for-saas-deployment/" target="_blank">before</a> we&#8217;ve been using <a href="http://grails.org/" target="_blank">Grails</a> to build the web front-end for <a href="http://saffronsierra.com" target="_blank">Sierra</a> as well as the Sierra <a href="http://docs.saffronsierra.com/REST-API" target="_blank">REST API</a>.  This week has provided a couple of great examples of the joys, and pains, of using open source software.  Let me start by saying that using Grails is mostly all joy, and not much pain.</p>
<p>While working on the administration console for Sierra this week I ran into a case where I needed to paginate a set of results.  Having built web applications for years now I have some pretty tried and true methods for doing this.  However, in the past while using other frameworks these methods have involved me writing a decent chunk of code.  With Grails that chunk of code is no longer needed.  Or, a least I don&#8217;t have to write it.  Let me show you a simple example.  Let&#8217;s say we have a &#8220;show&#8221; method on a UsersController that either fetches a single user (if we pass in an id), or returns a list of all users.  It might look something like this:<br />
<pre class="brush: java;">
def show = {

if (params.id &amp;amp;&amp;amp; User.exists(params.id.toLong())) {

def user = User.get(params.id)

[user: user]

} else {

// default max num for the page to 10 if not specified

if (!params.max) {

params.max = 10

}

render view: &quot;list&quot;, model: [userList: User.list(params)]

}

}
</pre><br />
Notice the call to &#8220;User.list(params)&#8221;.  This is passing in the URL parameter coming from the client into call to fetch the users.  If those parameters contain paging information then the list() method will fetch the proper subset of users.  I didn&#8217;t have to code the list() method.  Grails just gives it to me.</p>
<p>The last piece needed to get this working is a simple one line addition to your list.gsp file so that those URL parameters actually get passed in and the pagination controls get rendered.  That line looks like this:<br />
<pre class="brush: xml;">
&amp;lt;g:paginate controller=&quot;users&quot; action=&quot;show&quot; total=&quot;${User.count()}&quot; /&amp;gt;
</pre><br />
That&#8217;s it! Done! We have pagination and it only took about 15 minutes (mostly spent reading documentation) where as it would have taken at least an hour had I coded it all myself (sorry, I&#8217;m slow).</p>
<p>Now for the &#8220;Bad&#8221;, or at least the not so pleasant.  I spent some time this week implementing a load balancing solution for the Sierra REST APIs.  While doing this I decided that I needed to externalize some of the Grails configuration.  When you create a Grails application your configuration normally lives in Config.groovy.  This is great to get started, but as your app matures you don&#8217;t want to have to recompile just to point at a new database, etc&#8230; Config.groovy gives you the ability to easily load external configuration files using a command like this:</p>
<p><pre class="brush: java;">

grails.config.locations = [&quot;classpath:${appName}-config.properties&quot;]

</pre></p>
<p>If you do just this things work great, but I started thinking that I probably wanted things to work differently in my development environment than in my production environment in regards to loading external configuration.  Grails has thought about this desire and gives you the ability to define <a href="http://grails.org/doc/latest/guide/3.%20Configuration.html#3.2%20Environments" target="_blank">&#8220;environments&#8221;</a> blocks within your Config.groovy.  I thought that using this along with loading external configuration would be the perfect combination.  Not so fast Jared.  It turns out that these two features don&#8217;t play nicely together.  I think this is a bug, or simple stupidity on my part.  I&#8217;m open to either option.  Using Grails 1.1.1 if you put a &#8220;grails.config.locations&#8221; definition inside of an &#8220;environments&#8221; block the external configuration will not be loaded.  I&#8217;ve logged the bug with the Grails folks <a href="http://jira.codehaus.org/browse/GRAILS-5108" target="_blank">here</a>.</p>
<p>I wonder fun next week will hold?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/saffrontech.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/saffrontech.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/saffrontech.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/saffrontech.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/saffrontech.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/saffrontech.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/saffrontech.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/saffrontech.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/saffrontech.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/saffrontech.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/saffrontech.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/saffrontech.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/saffrontech.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/saffrontech.wordpress.com/34/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saffrontech.wordpress.com&amp;blog=8618537&amp;post=34&amp;subd=saffrontech&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://saffrontech.wordpress.com/2009/09/21/grails-the-good-and-the-bad/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3041b947632770a91a74b926d2b19755?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jaredatsaffron</media:title>
		</media:content>
	</item>
		<item>
		<title>REST, jQuery, JSONP, &amp; Grails</title>
		<link>http://saffrontech.wordpress.com/2009/09/14/rest-jquery-jsonp-grails/</link>
		<comments>http://saffrontech.wordpress.com/2009/09/14/rest-jquery-jsonp-grails/#comments</comments>
		<pubDate>Mon, 14 Sep 2009 12:45:03 +0000</pubDate>
		<dc:creator>Jared Peterson</dc:creator>
				<category><![CDATA[Sierra]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[prototype]]></category>
		<category><![CDATA[REST]]></category>

		<guid isPermaLink="false">http://saffrontech.wordpress.com/?p=31</guid>
		<description><![CDATA[As we started building the REST API for Saffron Sierra we wanted an easy way to test it from within a web browser.  REST APIs run on top of HTTP so this makes pretty good sense.  At first we used the REST Client plugin for Firefox, which was great, but as we added authentication and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saffrontech.wordpress.com&amp;blog=8618537&amp;post=31&amp;subd=saffrontech&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As we started building the REST API for <a href="http://saffronsierra.com" target="_blank">Saffron Sierra</a> we wanted an easy way to test it from within a web browser.  REST APIs run on top of HTTP so this makes pretty good sense.  At first we used the <a href="https://addons.mozilla.org/en-US/firefox/addon/9780" target="_blank">REST Client</a> plugin for Firefox, which was great, but as we added <a href="http://docs.saffronsierra.com/Authentication" target="_blank">authentication</a> and other things to the API using the REST Client plugin began to be a little cumbersome.  I started toying with the idea of putting together a very basic test harness using HTML and Javascript.  The hope was that it would provide a good testing tool, but also give future users of Sierra a basic tool to use and learn from.</p>
<p>I had been wanting to use and learn <a href="http://jquery.com/" target="_blank">jQuery</a> for quite some time.  We (<a href="http://www.saffrontech.com" target="_blank">Saffron Technology</a>) had used <a href="http://prototypejs.org/" target="_blank">Prototype</a> in the past for a lot of our applications.  I noticed a while back that there seemed to be a lot of buzz surrounding jQuery and wanted to see what it was all about.  The hope was that jQuery would provide a quick an easy way to consume the <a href="http://www.json.org/" target="_blank">JSON</a> responses from the Sierra REST APIS.  It well exceeded my expectations in this department.</p>
<p>The development of the first few pages and API calls went very smoothly and things looked great while testing on my local development workstation.  However, as I tried to use the test harness to access remote Sierra instances I noticed I wasn&#8217;t getting the responses I would expect, in fact, I wasn&#8217;t getting responses at all.  It turns out this was due to web browsers enforcing tight security when it comes to calling other domains/sites from the domain on which you&#8217;re currently running.  This issue is well documented in <a href="http://en.wikipedia.org/wiki/Cross-site_scripting" target="_blank">this wikipedia article</a>.</p>
<p>It turns out that the Javascript powers that be have a pretty handy hack that gets around this issue for well meaning developers like myself.  The solution has the somewhat unfortunate name <a href="http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/" target="_blank">JSONP</a> (also explained <a href="http://remysharp.com/2007/10/08/what-is-jsonp/" target="_blank">here</a>).  Using JSONP involves altering the way you make your REST calls on the client side and changing how JSON responses are formed on the server side.  On the client side you need to add a request parameter called &#8220;callback&#8221;.  In Javascript that&#8217;s as simple as the following line of code:</p>
<p>url += &#8216;&amp;callback=?&#8217;;</p>
<p>On the server side you have to detect the existence of the &#8220;callback&#8221; parameter and make sure the JSON response is properly wrapped with the value of the &#8220;callback&#8221; parameter (in the above code using the value of &#8220;?&#8221; tells jQuery to generate a value).  The grails code in our controllers that handles this logic looks like this:</p>
<p>// if we have a JSONP callback we need to wrap the response with the callback</p>
<p>if (params.callback) {</p>
<p>render &#8220;${params.callback}(${json as JSON})&#8221;</p>
<p>} else {</p>
<p>render json as JSON</p>
<p>}</p>
<p>The rest of the &#8220;magic&#8221; is handled by jQuery.  It just works.  Calling remote Sierra instances now return responses just as my local development workstation.  If you&#8217;re interested in taking a look at the test harness code you can grab it using the instructions <a href="http://docs.saffronsierra.com/Sample-Code" target="_blank">here</a>.</p>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:102px;width:1px;height:1px;">// if we have a JSONP callback we need to wrap the response with the callback</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:102px;width:1px;height:1px;">if (params.callback) {</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:102px;width:1px;height:1px;">log.debug &#8220;Wrapping JSON response with JSONP callback.&#8221;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:102px;width:1px;height:1px;">render &#8220;${params.callback}(${json as JSON})&#8221;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:102px;width:1px;height:1px;">} else {</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:102px;width:1px;height:1px;">render json</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/saffrontech.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/saffrontech.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/saffrontech.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/saffrontech.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/saffrontech.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/saffrontech.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/saffrontech.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/saffrontech.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/saffrontech.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/saffrontech.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/saffrontech.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/saffrontech.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/saffrontech.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/saffrontech.wordpress.com/31/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saffrontech.wordpress.com&amp;blog=8618537&amp;post=31&amp;subd=saffrontech&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://saffrontech.wordpress.com/2009/09/14/rest-jquery-jsonp-grails/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3041b947632770a91a74b926d2b19755?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jaredatsaffron</media:title>
		</media:content>
	</item>
		<item>
		<title>Using Grails for SaaS Deployment</title>
		<link>http://saffrontech.wordpress.com/2009/09/04/using-grails-for-saas-deployment/</link>
		<comments>http://saffrontech.wordpress.com/2009/09/04/using-grails-for-saas-deployment/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 20:22:36 +0000</pubDate>
		<dc:creator>Jared Peterson</dc:creator>
				<category><![CDATA[Sierra]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[Saas]]></category>
		<category><![CDATA[Slicehost]]></category>

		<guid isPermaLink="false">http://saffrontech.wordpress.com/?p=23</guid>
		<description><![CDATA[Grails is a great framework for deploying SaaS, but there are some challenges to overcome.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saffrontech.wordpress.com&amp;blog=8618537&amp;post=23&amp;subd=saffrontech&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>First, a little history&#8230;</p>
<p>About 6 months ago we began using <a href="http://grails.org/" target="_blank">Grails</a> for our new and ever growing set of <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer" target="_blank">REST</a> apis.  Overall our experience has been great.  Grails has really allowed us to accelerate development and focus on the things that are important to us.  Naturally, when we started talking about <a href="http://saffronsierra.com" target="_blank">Sierra</a> and knew that we&#8217;d need to build a user dashboard, admin console, etc&#8230; we turned to Grails.</p>
<p>Grails is implemented using <a href="http://groovy.codehaus.org/" target="_blank">Groovy</a>, which is a scripting language that runs in the Java JVM.  Seeing as the rest of the <a href="http://www.saffrontech.com" target="_blank">Saffron</a> stack uses Java this was another strong selling point for us, but it also means that in order to stand up Sierra we&#8217;d have to jump through all of the same hoops that come along with running a Java stack.</p>
<p>In the past all of our software and applications were installed and run in LAN environments.  This allowed us to ignore some of the issues that come along with deploying a Java application on the Internet.  Not so with Sierra, which is SaaS.  I hope to cover some of those challenges here which may, or may not be of some use to others.</p>
<ol>
<li>Hosting &#8211; We needed some place to run the web front-end for Sierra.  While our new office does have sweet server closet we didn&#8217;t want to host it here.  We needed a place with more reliable power, bandwidth, etc&#8230;  We also needed an environment that would be relatively easy for us to manage.  We chose <a href="http://www.slicehost.com/" target="_blank">Slicehost</a>.  With Slicehost we were able to get a server slice up and running in minutes.  It really is a great service.</li>
<li>Port 80 &#8211; Whenever you use a web browser to hit a web server your traffic typically travels over port 80 (unless your using https).  The port number is usually assumed and you don&#8217;t even see it in your URL.  Unfortunately Java web containers (<a href="http://tomcat.apache.org/" target="_blank">Tomcat</a>, <a href="http://www.mortbay.org/jetty/" target="_blank">Jetty</a>, etc&#8230;) don&#8217;t easily run on port 80.  They typically run on port 8080.  The reason for this is one of security.  Most Unix OS&#8217;s don&#8217;t allow a non-root user to start a process that listens on a port below 1024.  You don&#8217;t want to run as root because that could be bad.  So, your left trying to figure out how to let people hit &#8220;http://saffronsierra.com&#8221; and not &#8220;http://saffronsierra.com:8080&#8243;.  There are number of potential solutions to this problem.  Using <a href="http://www.groovygrails.de/blog/groovygrails/entry/non_root_tomcat_on_port" target="_blank">iptables</a> seems to be the most commonly used/recommended approach and is the one we chose.</li>
<li>Too Many Redirects &#8211; Some Grails <a href="http://grails.org/plugin/acegi" target="_blank">plugins</a> give you to ability to state what URL endpoints needs to travel over http vs https.  This gives you the flexibility of not having the explicitly state http vs https in your markup.  They do this by issuing http redirects.  This works great in a development environment, but can cause problems in production.  As we moved over to our slice we kept getting the browser error  &#8221;Too many redirects&#8221;.  Browsers have a threshold as to the number of times a particular request can be redirected.  I&#8217;m guessing, but I think the solution to the port 80 problem threw us over the redirect limit.  In order to get around this we had to explicitly define &#8220;http://&#8221; or &#8220;https://&#8221; in our markup.  While this doesn&#8217;t give us the flexibility of being able to separately define things on the fly in configuration, not markup, it will work for now.</li>
<li>Spam &#8211; Sierra needs to send out emails to user for certain events (registration, service start, etc&#8230;).  We setup <a href="http://www.postfix.org/" target="_blank">Postfix</a> to send mail on localhost.  However, I noticed that whenever I would send a test email to my Gmail account it would get flagged as spam.  After reading and tinkering a bit I figured out that by simply modifying some of the defaults in the &#8220;main.cf&#8221; configuration file for Postfix Gmail no longer thinks Sierra email is spam.  The steps I followed to edit main.cf are nicely listed in this <a href="http://articles.slicehost.com/2008/7/31/postfix-basic-settings-in-main-cf" target="_blank">Slicehost article</a>.</li>
</ol>
<p>I&#8217;m sure there were other challenges, but those are the &#8220;big&#8221; ones that come to mind.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/saffrontech.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/saffrontech.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/saffrontech.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/saffrontech.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/saffrontech.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/saffrontech.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/saffrontech.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/saffrontech.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/saffrontech.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/saffrontech.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/saffrontech.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/saffrontech.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/saffrontech.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/saffrontech.wordpress.com/23/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saffrontech.wordpress.com&amp;blog=8618537&amp;post=23&amp;subd=saffrontech&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://saffrontech.wordpress.com/2009/09/04/using-grails-for-saas-deployment/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3041b947632770a91a74b926d2b19755?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jaredatsaffron</media:title>
		</media:content>
	</item>
		<item>
		<title>Sierra Applications</title>
		<link>http://saffrontech.wordpress.com/2009/08/28/sierra-applications/</link>
		<comments>http://saffrontech.wordpress.com/2009/08/28/sierra-applications/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 18:34:32 +0000</pubDate>
		<dc:creator>Dave Sohigian</dc:creator>
				<category><![CDATA[Sierra]]></category>

		<guid isPermaLink="false">http://saffrontech.wordpress.com/?p=10</guid>
		<description><![CDATA[As Saffron Technology prepares to launch our new SaaS version of the Associative Memory Base (AMB), we are thinking about some example uses for the application. Because the AMB is so flexible, there are lots of possibilities, but we want to be sure to pick one that has both wide-spread appeal AND shows off the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saffrontech.wordpress.com&amp;blog=8618537&amp;post=10&amp;subd=saffrontech&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As <a href="http://www.saffrontech.com">Saffron Technology</a> prepares to launch our new SaaS version of the Associative Memory Base (AMB), we are thinking about some example uses for the application. Because the AMB is so flexible, there are lots of possibilities, but we want to be sure to pick one that has both wide-spread appeal AND shows off the unique capabilities of the AMB.</p>
<p>Here are some example applications we are considering:</p>
<ul>
<li>Tracking exercise activity sites (<a href="http://www.mapmyrun.com/" target="_blank">http://www.mapmyrun.com/</a>)</li>
<p>Online tracking of exercise activity is booming, but it&#8217;s not clear exactly what we could analyze here (it would depend a lot on what is available). But looking for patterns (grouping by age, diet, activity, etc..) and determining outcomes based on those observations is one possibility. Maybe an application that can suggest the best exercise routine based on real data of people like you (not just statistical averages).</p>
<li>Build upon data set from <a href="http://www.data.gov" target="_blank">http://www.data.gov</a></li>
<p>Data.gov has a ton of data available, but it arguably of little value unless we can see associations and patterns in the data. But finding a clean use case may be difficult.</p>
<li>Swine Flu/H1N1 research using CDC data</li>
<p>This, or other, CDC data could be very powerful. Imagine being able to identify where an issue originated based on the pattern of previous disease profiles.</p>
<li>Cell phone call log analysis</li>
<p>Although this data is private, it might be useful for either individual users, businesses or phone companies to be able to identify patterns in usage.</p>
<li>Twitter/Social Media analysis</li>
<p>This is a hot topic right now and we have thought of several apps that might be a good fit. One example is an application that you feed all your social media contacts (twitter, facebook, myspace, delicious, etc&#8230;) and point out a few &#8220;important&#8221; contacts in the data set. These could be people that you know personally, or people that matter to you (or your org) because they have been influential in the past. Then Sierra could look for people like them based on any qualities (things they tweet, location, connections, etc&#8230;) and tell you who else might be influential.</p>
<li>Website widget (what people are saying about…)</li>
<p>Similar to the previous example, but you would feed it blogs, twitter accounts, comment feeds and other conversational information and it could pick out the stuff important to your organization. Then it could be displayed as a widget on your site showing &#8220;what people are saying about us&#8221;. Would need some serious filters on this one though&#8230;</p>
<li>Analyzing Gordon Bell’s MyLifeBits data (<a href="http://research.microsoft.com/en-us/projects/mylifebits/" target="_blank">http://research.microsoft.com/en-us/projects/mylifebits/</a>)</li>
<p>Gordon Bell has been collecting data for quite some time and has several search and indexing applications to find his stuff. But Sierra would be so much more effective and finding things because it works much like the human brain: looking for patterns of associations. Now we just need to figure out how to get all that data from Gordon&#8230;.</ul>
<p>What we are looking for is complex data sets (and unstructured data) where finding a &#8220;needle in a haystack&#8221; would be of value.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/saffrontech.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/saffrontech.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/saffrontech.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/saffrontech.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/saffrontech.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/saffrontech.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/saffrontech.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/saffrontech.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/saffrontech.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/saffrontech.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/saffrontech.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/saffrontech.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/saffrontech.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/saffrontech.wordpress.com/10/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saffrontech.wordpress.com&amp;blog=8618537&amp;post=10&amp;subd=saffrontech&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://saffrontech.wordpress.com/2009/08/28/sierra-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d396d70487acd08d012533d20ff574a6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Dave Sohigian</media:title>
		</media:content>
	</item>
	</channel>
</rss>
