<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6797438784639127804</id><updated>2011-12-11T14:29:10.110-05:00</updated><category term='mobile'/><category term='rdf'/><category term='Scala'/><category term='android'/><category term='geolocation'/><category term='sql'/><category term='java'/><category term='mysql'/><category term='php'/><category term='qr codes'/><category term='programming'/><category term='interview questions'/><category term='semantic web'/><category term='tutorial'/><category term='c++'/><category term='recursion'/><category term='HTML5'/><category term='Fibonacci'/><title type='text'>Reality Is Important</title><subtitle type='html'>Tutorials, articles, thoughts, programming 101 through ∞</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Garrett</name><uri>http://www.blogger.com/profile/10157693937724512283</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_x81YABKRdos/TLJ-J9pnH1I/AAAAAAAAA78/k9B6dgIskY4/S220/IMG_0040.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>36</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-1675976455454994765</id><published>2011-04-27T08:47:00.000-04:00</published><updated>2011-04-27T08:47:12.110-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mobile'/><category scheme='http://www.blogger.com/atom/ns#' term='android'/><title type='text'>Android SDK - File Not Found</title><content type='html'>Every time I tried to update the Android SDK on Windows 7 I'd receive a 'Nothing updated' error. Looking through the running log of the download there were multiple File Not Found errors. I ran into this when I tried adding in the nook color emulator URL as well.&lt;div&gt;&lt;br /&gt;&lt;table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-right: 1em; text-align: left;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-K-eD1Jah0dM/TbgPzo_WLPI/AAAAAAAABZ0/vko39yplXas/s1600/win31-1-1.png" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="211" src="http://3.bp.blogspot.com/-K-eD1Jah0dM/TbgPzo_WLPI/AAAAAAAABZ0/vko39yplXas/s320/win31-1-1.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;If your screen looks like this, you're doing it wrong.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This issue is due to the inability for the SDK to access the Program Files (x86) folder on Windows 7 from the SDK Manager.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The quick workaround:&amp;nbsp;&lt;i&gt;Right-click&lt;/i&gt; on &lt;span class="Apple-style-span" style="color: #38761d;"&gt;Android SDK Manager&lt;/span&gt; and &lt;b&gt;Run as Administrator&lt;/b&gt;.&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-1675976455454994765?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/1675976455454994765/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=1675976455454994765' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/1675976455454994765'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/1675976455454994765'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2011/04/android-sdk-file-not-found.html' title='Android SDK - File Not Found'/><author><name>Garrett</name><uri>http://www.blogger.com/profile/10157693937724512283</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_x81YABKRdos/TLJ-J9pnH1I/AAAAAAAAA78/k9B6dgIskY4/S220/IMG_0040.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-K-eD1Jah0dM/TbgPzo_WLPI/AAAAAAAABZ0/vko39yplXas/s72-c/win31-1-1.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-1806295996516331071</id><published>2011-04-26T10:10:00.001-04:00</published><updated>2011-04-28T09:35:09.566-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='interview questions'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><title type='text'>Binary Searches</title><content type='html'>So a mythological interview question supposedly asked by F______k is, "Given the numbers 1 to 1,000, what is the minimum number of guesses needed to find a specific number if you are given the hint 'higher' or 'lower' for each guess you make."&lt;br /&gt;&lt;br /&gt;I cannot provide a citation for that question and have not heard it asked myself. It has been passed all around the internet as a 'weird interview question.' This question is indeed not weird at all and you, the programmer, should be able to know how to address this straight away.&lt;br /&gt;&lt;br /&gt;A related question &lt;i&gt;I&lt;/i&gt;&amp;nbsp;was asked by M_______t was, "When does one use a binary search?" Let me tell you this, the only answer they want to hear for this question is, "When the data is already sorted." Quite obviously, data from 1 to 1000 is already sorted.&lt;br /&gt;&lt;br /&gt;So, lets return to the original question and break it down &lt;i&gt;binary style&lt;/i&gt;, yo. Lets assume our number is &lt;a href="http://flyowa.com/"&gt;815&lt;/a&gt;. Our independent calculation guesses as follows:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Guess: 500&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Response: higher&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Guess: 750&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Response: higher&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Guess: 875&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Response: lower&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Guess: 812&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Response: higher&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Guess: 843&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Response: lower&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Guess: 827&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Response: lower&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Guess: 819&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Response: higher&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Guess: 815&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Ding&lt;/li&gt;&lt;/ul&gt;&lt;/ol&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://technabob.com/blog/wp-content/uploads/2010/08/supercoder_2000_binary_keyboard.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="258" src="http://technabob.com/blog/wp-content/uploads/2010/08/supercoder_2000_binary_keyboard.jpg" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;I don't know about you, but this is how I code.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;So, we're looking at around eight or nine iterations to find our answer. Although it could be less, what if the number was 500? Obviously it would hit on the first iteration. The question was, "what is the minimum number of guesses needed to find a specific number" so in a literal interpretation of that question would answer, "one".&lt;br /&gt;&lt;br /&gt;Anyway, back to binary searches. There is no need for me to define them here as you can and should be able to find that information out yourself. So on to some code! A representation of the above in C++ would be as follows:&lt;br /&gt;&lt;code&gt;int binSearch(int needle, int low, int high) {  if (high &amp;lt; low)  return -1; // no match int middle = low + ((high - low) / 2); // added debug output for demonstration.        cout &amp;lt;&amp;lt; "middle: " &amp;lt;&amp;lt; middle &amp;lt;&amp;lt; " low: " &amp;lt;&amp;lt; low &amp;lt;&amp;lt; " high: " &amp;lt;&amp;lt; high &amp;lt;&amp;lt; endl; if (needle &amp;gt; middle)  return binSearch(needle, middle, high); else if (needle &amp;lt; middle)  return binSearch(needle, low, middle); else   return middle; // match}&lt;/code&gt;&lt;br /&gt;If called with &lt;i&gt;binSearch(815, 1, 1000)&lt;/i&gt; our result would be the following:&lt;code&gt;middle: 500 low: 1 high: 1000middle: 750 low: 500 high: 1000middle: 875 low: 750 high: 1000middle: 812 low: 750 high: 875middle: 843 low: 812 high: 875middle: 827 low: 812 high: 843middle: 819 low: 812 high: 827middle: 815 low: 812 high: 819&lt;/code&gt;&lt;br /&gt;So there you have it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-1806295996516331071?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/1806295996516331071/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=1806295996516331071' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/1806295996516331071'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/1806295996516331071'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2011/04/binary-searches.html' title='Binary Searches'/><author><name>Garrett</name><uri>http://www.blogger.com/profile/10157693937724512283</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_x81YABKRdos/TLJ-J9pnH1I/AAAAAAAAA78/k9B6dgIskY4/S220/IMG_0040.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-6702355442974638748</id><published>2011-04-19T09:12:00.011-04:00</published><updated>2011-04-28T09:37:03.526-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='interview questions'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><title type='text'>FizzBuzz Examples</title><content type='html'>I have noticed lately programmers and interviewers are all up in arms about the FizzBuzz programming task. Interviewers are making a deal of the fact that programmers cannot even write a basic FizzBuzz program, even recent graduates.&lt;br /&gt;&lt;br /&gt;&lt;table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-right: 1em; text-align: left;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://www.books4kids.co.uk/images/fizz%20buzz.jpg" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" src="http://www.books4kids.co.uk/images/fizz%20buzz.jpg" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Where does one buy a domino shirt?&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;First off, this is an absurd trend and non-news in developer interviews. While the argument exists to make developers &lt;i&gt;develop&lt;/i&gt;&amp;nbsp;in an interview, often the tasks are absurd and impractical. This is yet another example and part of the reason for my recent series on interview questions.&lt;br /&gt;&lt;br /&gt;So on to the question.&lt;br /&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="color: #333333; font-family: Verdana, Tahoma, 'lucida grande', sans-serif; font-size: 12px; line-height: 21px;"&gt;Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz.” For numbers which are multiples of both three and five print “FizzBuzz.”&lt;/span&gt;&lt;/blockquote&gt;Seems simple enough right? Don't overthink this one. Let's break it down.&lt;i&gt;"Write a program that prints the numbers from 1 to 100."&lt;/i&gt; Okay so we need a loop. What kind of loop? Well you can do lots of things here, try and wow them with a recursive loop, use a &lt;i&gt;do..while &lt;/i&gt;or a &lt;i&gt;for&lt;/i&gt;&amp;nbsp;loop. Let's use the KISS method and go with a for loop.&lt;br /&gt;&lt;code&gt;for (int i=1;i&amp;lt;=100;i++) {&lt;br /&gt;cout &amp;lt;&amp;lt; i &amp;lt;&amp;lt; endl; }&lt;/code&gt;&lt;br /&gt;Done deal. We're printing out the numbers from 1 to 100. Now onward."But for multiples of three print “Fizz”" Alright remember, how we can find out if something is a multple of three? Hmm? Divide it by 3? Is there a remainder? No? Well it's divisible by 3 then. duh. So use the dreaded &lt;i&gt;mod&lt;/i&gt; here. &lt;br /&gt;&lt;code&gt;for (int i=1;i&amp;lt;=100;i++) {if (i % 3 == 0)&amp;nbsp;&amp;nbsp;cout &amp;lt;&amp;lt; "Fizz"&amp;lt;&amp;lt; endl;&lt;br /&gt;else&lt;br /&gt;&amp;nbsp;&amp;nbsp;cout &amp;lt;&amp;lt; i &amp;lt;&amp;lt; endl;&lt;br /&gt;}&lt;/code&gt;Alright now I think you have this, continue on in this method and check if it's divisible by 5...&lt;code&gt;for (int i=1;i&amp;lt;=100;i++) {if (i % 3 == 0)&amp;nbsp;&amp;nbsp;cout &amp;lt;&amp;lt; "Fizz"&amp;lt;&amp;lt; endl;&lt;br /&gt;else if (i % 5 == 0)&amp;nbsp;&amp;nbsp;cout &amp;lt;&amp;lt; "Buzz"&amp;lt;&amp;lt; endl;&lt;br /&gt;else&lt;br /&gt;&amp;nbsp;&amp;nbsp;cout &amp;lt;&amp;lt; i &amp;lt;&amp;lt; endl;&lt;br /&gt;}&lt;/code&gt;Oops! It seems that we've backed into a corner and missed the final step of requirements. For numbers which are multiples of both three and five print “FizzBuzz.”. Just by eliminitating the else if and the line breaks we should have it then, right?&lt;code&gt;int main() { for (int i=1;i&amp;lt;=100;i++) {  if (i % 3 == 0)   cout &amp;lt;&amp;lt; "Fizz";  if (i % 5 == 0)   cout &amp;lt;&amp;lt; "Buzz";  if (i % 3 != 0 &amp;amp;&amp;amp; i % 5 != 0)   cout &amp;lt;&amp;lt; i;  cout &amp;lt;&amp;lt; endl; }}&lt;/code&gt;"But I can write this so much more elegantly!" You say. Please do. That is what will separate you from the rest of the pack.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-6702355442974638748?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/6702355442974638748/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=6702355442974638748' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/6702355442974638748'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/6702355442974638748'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2011/04/fizzbuzz-examples.html' title='FizzBuzz Examples'/><author><name>Garrett</name><uri>http://www.blogger.com/profile/10157693937724512283</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_x81YABKRdos/TLJ-J9pnH1I/AAAAAAAAA78/k9B6dgIskY4/S220/IMG_0040.JPG'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-1600323804823970659</id><published>2011-04-08T08:04:00.000-04:00</published><updated>2011-04-08T08:04:05.617-04:00</updated><title type='text'>C++ Proficiency - Palindromes</title><content type='html'>&lt;b&gt;Write a boolean in C++ to detect if a string is a palindrome.&lt;/b&gt;&lt;br /&gt;This was a question asked in a M_______t technical interview. For the life of me, I couldn't recall what a palindrome even was at that time. The example given was &lt;i&gt;level.&amp;nbsp;&lt;/i&gt;&amp;nbsp;&amp;nbsp;&lt;code&gt;1:&amp;nbsp;&amp;nbsp;bool isPalindrome(string test) {2:&amp;nbsp;&amp;nbsp;3:&amp;nbsp;&amp;nbsp; for (int i=0; i &amp;lt; test.length() - 1;i++){4:&amp;nbsp;&amp;nbsp;  if (test[i] != test[test.length() - 1 - i]) return false;5:&amp;nbsp;&amp;nbsp; }6:&amp;nbsp;&amp;nbsp;7:&amp;nbsp;&amp;nbsp; return true;8:&amp;nbsp;&amp;nbsp;}&lt;/code&gt;&lt;br /&gt;Around line 2 one would want to add some replace functions to remove non-alpha characters and spaces. Think about the common example used "dammit i'm mad". It will return false if given to this function as is but is truly a palindrome.&lt;br /&gt;&lt;br /&gt;I think a better bool function would be to detect if a string is a&amp;nbsp;&lt;a href="http://politicalhumor.about.com/od/sarahpalin/a/palinisms.htm"&gt;Palinism&lt;/a&gt;. In other words, if the coherency of the sentences are random babble, mixed with &lt;i&gt;n&lt;/i&gt;&amp;nbsp;number of keywords, add in some further nonsense, it returns true.&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-1600323804823970659?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/1600323804823970659/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=1600323804823970659' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/1600323804823970659'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/1600323804823970659'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2011/04/c-proficiency-palindromes.html' title='C++ Proficiency - Palindromes'/><author><name>Garrett</name><uri>http://www.blogger.com/profile/10157693937724512283</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_x81YABKRdos/TLJ-J9pnH1I/AAAAAAAAA78/k9B6dgIskY4/S220/IMG_0040.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-9071927644571909779</id><published>2011-04-06T10:17:00.001-04:00</published><updated>2011-04-06T10:22:29.298-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='interview questions'/><title type='text'>Java Proficiency - Access control</title><content type='html'>&lt;b&gt;How can one make a certain method in a certain class only accessible by classes that are defined within the same package as the class of the method? How do you enforce this restriction?&lt;/b&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;mark the method "public"&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Right here, you know this one is wrong. Public is accessible by all methods in all packages.&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;mark the method "package"&lt;/li&gt;&lt;ul&gt;&lt;li&gt;This isn't even a modifier that exists. So pass. One might be temted by this answer and it is meant to throw you. Know your Java access modifiers.&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;mark the method "protected"&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Well this is closer to restriction and in a sense true, however, protected is accessible by the class only and the subclasses of the class.&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;do not mark the method with a modifier&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Otherwise known as default. This is the answer we're looking for. Providing no modifier makes the method accessible throughout the same package only.&lt;/li&gt;&lt;/ul&gt;&lt;/ol&gt;For reference, see the chart &lt;a href="http://download.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html"&gt;http://download.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;As with the other technical interview articles, these are meant to be a quick reference for an answer rather than a tutorial on use.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-9071927644571909779?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/9071927644571909779/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=9071927644571909779' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/9071927644571909779'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/9071927644571909779'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2011/04/java-proficiency-access-control.html' title='Java Proficiency - Access control'/><author><name>Garrett</name><uri>http://www.blogger.com/profile/10157693937724512283</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_x81YABKRdos/TLJ-J9pnH1I/AAAAAAAAA78/k9B6dgIskY4/S220/IMG_0040.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-2743258622010125901</id><published>2011-04-06T09:46:00.000-04:00</published><updated>2011-04-06T09:46:00.793-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='interview questions'/><title type='text'>C++ Proficiency - macro function</title><content type='html'>&lt;b&gt;Define a macro function in C++ that takes parameters &lt;i&gt;a &lt;/i&gt;and &lt;i&gt;b&lt;/i&gt;&amp;nbsp;and returns which one is greater.&lt;/b&gt;&lt;br /&gt;&lt;code&gt;1:&amp;nbsp;&amp;nbsp;#define WhoIsGreater(a, b) \2:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;( a &amp;gt; b ? a : b )&lt;/code&gt;&lt;br /&gt;&lt;b&gt;How would you use the function in your program?&lt;/b&gt;&lt;br /&gt;&lt;code&gt;1:&amp;nbsp;&amp;nbsp;int main() {2:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cout &lt;&lt; "Between 3 and 5 the greater is: " &lt;&lt; WhoIsGreater(3,5) &lt;&lt; endl;3:&amp;nbsp;&amp;nbsp;}&lt;/code&gt;Again this is not a tutorial on how to make macro functions, it's a quick refresher and an actual question asked in a technical interview.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-2743258622010125901?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/2743258622010125901/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=2743258622010125901' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/2743258622010125901'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/2743258622010125901'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2011/04/c-proficiency-macro-function.html' title='C++ Proficiency - macro function'/><author><name>Garrett</name><uri>http://www.blogger.com/profile/10157693937724512283</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_x81YABKRdos/TLJ-J9pnH1I/AAAAAAAAA78/k9B6dgIskY4/S220/IMG_0040.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-4093366903138862686</id><published>2011-04-06T09:19:00.003-04:00</published><updated>2011-04-06T09:23:44.840-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='interview questions'/><title type='text'>Java Proficiency - final</title><content type='html'>&lt;b&gt;What does the keyword &lt;i&gt;final&lt;/i&gt;&amp;nbsp;do in this code block?&lt;/b&gt;&lt;br /&gt;&lt;code&gt;1:&amp;nbsp;&amp;nbsp;public class MyClass {2:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public final int doStuff() {}3:&amp;nbsp;&amp;nbsp;}&lt;/code&gt;&lt;br /&gt;Methods declared as final within a class cannot be overridden by a subclass. So if we extend MyClass we can't be messin' with doStuff(). It's final.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;What if the class is declared as final?&lt;/b&gt;&lt;br /&gt;&lt;code&gt;1:&amp;nbsp;&amp;nbsp;public final class MyClass {2:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public int doStuff() {}3:&amp;nbsp;&amp;nbsp;}&lt;/code&gt;&lt;br /&gt;Declaring a class as final means that class cannot be extended.&lt;br /&gt;&lt;br /&gt;These short answers are not meant to be a definition or a tutorial in the use of &lt;i&gt;final&lt;/i&gt;. They are meant to give the answer the technical interviewer seems to want.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-4093366903138862686?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/4093366903138862686/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=4093366903138862686' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/4093366903138862686'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/4093366903138862686'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2011/04/java-proficiency-final.html' title='Java Proficiency - final'/><author><name>Garrett</name><uri>http://www.blogger.com/profile/10157693937724512283</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_x81YABKRdos/TLJ-J9pnH1I/AAAAAAAAA78/k9B6dgIskY4/S220/IMG_0040.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-55148117617252792</id><published>2011-04-06T08:56:00.000-04:00</published><updated>2011-04-06T08:56:02.801-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sql'/><category scheme='http://www.blogger.com/atom/ns#' term='interview questions'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><title type='text'>SQL Joins Demystified</title><content type='html'>&lt;b&gt;Explain the types of joins in SQL.&lt;/b&gt;&lt;br /&gt;Yet another of those common technical interview questions that every interviewer wants to know, every candidate gets wrong and everyone looks up anyway when using them. There are four types of joins that this article focuses on &lt;i&gt;Inner&lt;/i&gt;,&lt;i&gt; Outer&lt;/i&gt;,&lt;i&gt; Right,&lt;/i&gt; and &lt;i&gt;Left&lt;/i&gt;. For perspective, the following two tables will be used.&lt;br /&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr valign="top"&gt;&lt;td&gt;&lt;table border="1"&gt;&lt;thead&gt;&lt;tr&gt;&lt;th colspan="2"&gt;tblTypes&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th&gt;ID&lt;/th&gt; &lt;th&gt;TYPE&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr align="center"&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;Animal&lt;/td&gt;&lt;/tr&gt;&lt;tr align="center"&gt; &lt;td&gt;2&lt;/td&gt; &lt;td&gt;Vegetable&lt;/td&gt;&lt;/tr&gt;&lt;tr align="center"&gt; &lt;td&gt;3&lt;/td&gt; &lt;td&gt;Mineral&lt;/td&gt;&lt;/tr&gt;&lt;tr align="center"&gt; &lt;td&gt;4&lt;/td&gt; &lt;td&gt;TBD&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/td&gt;&lt;td width="20"&gt;&lt;/td&gt;&lt;td&gt;&lt;table border="1"&gt;&lt;thead&gt;&lt;tr&gt;&lt;th colspan="3"&gt;tblItems&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th&gt;ID&lt;/th&gt; &lt;th&gt;tblTYPE_ID&lt;/th&gt; &lt;th&gt;NAME&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr align="center"&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;Ocelot&lt;/td&gt;&lt;/tr&gt;&lt;tr align="center"&gt; &lt;td&gt;2&lt;/td&gt; &lt;td&gt;2&lt;/td&gt; &lt;td&gt;Cardoon&lt;/td&gt;&lt;/tr&gt;&lt;tr align="center"&gt; &lt;td&gt;3&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;Banteng&lt;/td&gt;&lt;/tr&gt;&lt;tr align="center"&gt; &lt;td&gt;4&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;Guenon&lt;/td&gt;&lt;/tr&gt;&lt;tr align="center"&gt; &lt;td&gt;5&lt;/td&gt; &lt;td&gt;3&lt;/td&gt; &lt;td&gt;Vomicine&lt;/td&gt;&lt;/tr&gt;&lt;tr align="center"&gt; &lt;td&gt;6&lt;/td&gt; &lt;td&gt;7&lt;/td&gt; &lt;td&gt;Brobee&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;b&gt;What is the difference between an &lt;i&gt;Inner Join &lt;/i&gt;and an &lt;i&gt;Outer Join&lt;/i&gt;?&amp;nbsp;&lt;/b&gt;&lt;br /&gt;By definition an &lt;i&gt;Inner Join&lt;/i&gt;&amp;nbsp;(also just called a &lt;i&gt;Join,&amp;nbsp;&lt;/i&gt;inner is assumed) connects the rows from both tables when there is a match between the columns compared.&lt;br /&gt;&lt;code&gt;SELECT tblTypes.TYPE, tblItems.NAME FROM tblItems JOIN tblTypes ON tblItems.tblTYPE_ID = tblTypes.ID&lt;/code&gt;&lt;br /&gt;&lt;table border="1"&gt;&lt;thead&gt;&lt;tr&gt; &lt;th&gt;TYPE&lt;/th&gt; &lt;th&gt;NAME&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr align="center"&gt;  &lt;td&gt;Animal&lt;/td&gt; &lt;td&gt;Ocelot&lt;/td&gt;&lt;/tr&gt;&lt;tr align="center"&gt; &lt;td&gt;Vegetable&lt;/td&gt; &lt;td&gt;Cardoon&lt;/td&gt;&lt;/tr&gt;&lt;tr align="center"&gt; &lt;td&gt;Animal&lt;/td&gt; &lt;td&gt;Banteng&lt;/td&gt;&lt;/tr&gt;&lt;tr align="center"&gt; &lt;td&gt;Animal&lt;/td&gt; &lt;td&gt;Guenon&lt;/td&gt;&lt;/tr&gt;&lt;tr align="center"&gt; &lt;td&gt;Mineral&lt;/td&gt; &lt;td&gt;Vomicine&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;An &lt;i&gt;Inner Join&lt;/i&gt;&amp;nbsp;or simply &lt;i&gt;Join&lt;/i&gt;&amp;nbsp;matches when there is a matching condition as above between the type_id in the Items table and the id in the Types table.&amp;nbsp;Notice that we did not get the 'Brobee' record. There was no matching id to the specified type.&lt;br /&gt;What is we want to get all the records regarless if there is a match in our condition. In that case, use an &lt;i&gt;Outer Join.&amp;nbsp;&lt;/i&gt;&amp;nbsp;&lt;i&gt;Outer&lt;/i&gt;&amp;nbsp;is slightly different in that it is comprised of a&amp;nbsp;&lt;i&gt;Left&lt;/i&gt;&amp;nbsp;or &lt;i&gt;Right Join&lt;/i&gt;.&lt;br /&gt;&lt;b&gt;What is a &lt;i&gt;Right Join&lt;/i&gt;&amp;nbsp;and &lt;i&gt;Left Join?&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;&lt;code&gt;SELECT tblTypes.TYPE, tblItems.NAME FROM tblItems LEFT JOIN tblTypes ON tblItems.tblTYPE_ID = tblTypes.ID&lt;/code&gt;&lt;br /&gt;&lt;table border="1"&gt;&lt;thead&gt;&lt;tr&gt; &lt;th&gt;TYPE&lt;/th&gt; &lt;th&gt;NAME&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr align="center"&gt;  &lt;td&gt;Animal&lt;/td&gt; &lt;td&gt;Ocelot&lt;/td&gt;&lt;/tr&gt;&lt;tr align="center"&gt; &lt;td&gt;Vegetable&lt;/td&gt; &lt;td&gt;Cardoon&lt;/td&gt;&lt;/tr&gt;&lt;tr align="center"&gt; &lt;td&gt;Animal&lt;/td&gt; &lt;td&gt;Banteng&lt;/td&gt;&lt;/tr&gt;&lt;tr align="center"&gt; &lt;td&gt;Animal&lt;/td&gt; &lt;td&gt;Guenon&lt;/td&gt;&lt;/tr&gt;&lt;tr align="center"&gt; &lt;td&gt;Mineral&lt;/td&gt; &lt;td&gt;Vomicine&lt;/td&gt;&lt;/tr&gt;&lt;tr align="center"&gt; &lt;td&gt;&lt;i&gt;NULL&lt;/i&gt;&lt;/td&gt; &lt;td&gt;Brobee&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;The above left joins records regardless if there is a match for our type_id. All the records were retrieved regardless of a match on our left side table. Conversely, a &lt;i&gt;Right Join&lt;/i&gt; will match only the right side of our condition.&lt;code&gt;SELECT tblTypes.TYPE, tblItems.NAME FROM tblItems RIGHT JOIN tblTypes ON tblItems.tblTYPE_ID = tblTypes.ID&lt;/code&gt;&lt;br /&gt;&lt;table border="1"&gt;&lt;thead&gt;&lt;tr&gt; &lt;th&gt;TYPE&lt;/th&gt; &lt;th&gt;NAME&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr align="center"&gt;  &lt;td&gt;Animal&lt;/td&gt; &lt;td&gt;Ocelot&lt;/td&gt;&lt;/tr&gt;&lt;tr align="center"&gt; &lt;td&gt;Vegetable&lt;/td&gt; &lt;td&gt;Cardoon&lt;/td&gt;&lt;/tr&gt;&lt;tr align="center"&gt; &lt;td&gt;Animal&lt;/td&gt; &lt;td&gt;Banteng&lt;/td&gt;&lt;/tr&gt;&lt;tr align="center"&gt; &lt;td&gt;Animal&lt;/td&gt; &lt;td&gt;Guenon&lt;/td&gt;&lt;/tr&gt;&lt;tr align="center"&gt; &lt;td&gt;Mineral&lt;/td&gt; &lt;td&gt;Vomicine&lt;/td&gt;&lt;/tr&gt;&lt;tr align="center"&gt; &lt;td&gt;TBD&lt;/td&gt; &lt;td&gt;&lt;i&gt;NULL&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;In summation:&lt;br /&gt;There are four major types of joins: &lt;i&gt;Inner, Outer, Right&lt;/i&gt;, and &lt;i&gt;Left. Right &lt;/i&gt;and &lt;i&gt;Left &lt;/i&gt;are part of an outer join. &lt;i&gt;Inner&lt;/i&gt;&amp;nbsp;retrieves all matches from the specified join condition(s). &lt;i&gt;Right &lt;/i&gt;retrieves from the right table regardless of a match for the left and &lt;i&gt;Left, &lt;/i&gt;okay well you have it now.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-55148117617252792?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/55148117617252792/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=55148117617252792' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/55148117617252792'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/55148117617252792'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2011/04/sql-joins-demystified.html' title='SQL Joins Demystified'/><author><name>Garrett</name><uri>http://www.blogger.com/profile/10157693937724512283</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_x81YABKRdos/TLJ-J9pnH1I/AAAAAAAAA78/k9B6dgIskY4/S220/IMG_0040.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-6629429173326367777</id><published>2011-04-05T15:56:00.001-04:00</published><updated>2011-04-06T07:33:18.676-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sql'/><category scheme='http://www.blogger.com/atom/ns#' term='interview questions'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><title type='text'>SQL Having Clause</title><content type='html'>&lt;b&gt;When would one use the &lt;i&gt;HAVING&lt;/i&gt;&amp;nbsp;keyword in SQL?&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;It seems to me that the HAVING keyword in SQL is a common question asked in technical interviews. No one uses it though if you're writing code, chances are you'll pull all the data out and get what you need through the code. Looking at the HAVING keyword you may realize it can be quite useful to let SQL do all the heavy lifting and skip the WHERE.&lt;br /&gt;&lt;br /&gt;First, lets establish a basic table for our example...&lt;br /&gt;&lt;table border="1"&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;ID&lt;/th&gt; &lt;th&gt;TYPE&lt;/th&gt; &lt;th&gt;QUANTITY&lt;/th&gt; &lt;th&gt;DESCRIPTION&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr align="center"&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;Animal&lt;/td&gt; &lt;td&gt;8&lt;/td&gt; &lt;td&gt;Ocelot&lt;/td&gt;&lt;/tr&gt;&lt;tr align="center"&gt; &lt;td&gt;2&lt;/td&gt; &lt;td&gt;Vegetable&lt;/td&gt; &lt;td&gt;4&lt;/td&gt; &lt;td&gt;Cardoon&lt;/td&gt;&lt;/tr&gt;&lt;tr align="center"&gt; &lt;td&gt;3&lt;/td&gt; &lt;td&gt;Animal&lt;/td&gt; &lt;td&gt;4&lt;/td&gt; &lt;td&gt;Banteng&lt;/td&gt;&lt;/tr&gt;&lt;tr align="center"&gt; &lt;td&gt;4&lt;/td&gt; &lt;td&gt;Animal&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;Guenon&lt;/td&gt;&lt;/tr&gt;&lt;tr align="center"&gt; &lt;td&gt;5&lt;/td&gt; &lt;td&gt;Vegetable&lt;/td&gt; &lt;td&gt;8&lt;/td&gt; &lt;td&gt;Fluted Pumpkin&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;So there we have a table. First lets get the quantities of everything.&lt;code&gt;SELECT type, SUM(quantity) as total from table GROUP BY type&lt;/code&gt;We'd end up with:&lt;br /&gt;&lt;table border="1"&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;type&lt;/th&gt; &lt;th&gt;total&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt; &lt;td&gt;Animal&lt;/td&gt; &lt;td&gt;13&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt; &lt;td&gt;Vegetable&lt;/td&gt; &lt;td&gt;12&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;What can HAVING do for us? It can give a way to search the GROUP BY data easily. So, lets just look for quantities greater than 12.&lt;code&gt;SELECT type, SUM(quantity) as total from table GROUP BY type HAVING SUM(quantity) &amp;gt; 12&lt;/code&gt;&lt;br /&gt;&lt;table border="1"&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;type&lt;/th&gt; &lt;th&gt;total&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt; &lt;td&gt;Animal&lt;/td&gt; &lt;td&gt;13&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;How is &lt;i&gt;HAVING&lt;/i&gt;&amp;nbsp;different&amp;nbsp;from&amp;nbsp;&lt;i&gt;WHERE&lt;/i&gt;?&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;/b&gt;The HAVING keyword is followed by some aggregate function SUM, AVG, MIN, MAX. You cannot do the aggregate functions with the WHERE clause and this is a primary difference. &lt;i&gt;When you're doing a WHERE, you're looking at a row by row comparison versus HAVING which is working with grouped data.&lt;/i&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-6629429173326367777?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/6629429173326367777/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=6629429173326367777' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/6629429173326367777'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/6629429173326367777'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2011/04/sql-having-clause.html' title='SQL Having Clause'/><author><name>Garrett</name><uri>http://www.blogger.com/profile/10157693937724512283</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_x81YABKRdos/TLJ-J9pnH1I/AAAAAAAAA78/k9B6dgIskY4/S220/IMG_0040.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-6890858098871985353</id><published>2011-02-15T15:52:00.000-05:00</published><updated>2011-04-27T07:54:30.389-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mobile'/><category scheme='http://www.blogger.com/atom/ns#' term='android'/><title type='text'>Another Android App - FindMyRep</title><content type='html'>&lt;a href="http://2.bp.blogspot.com/-KWLoWtPojTw/TVrmcWXWZ-I/AAAAAAAABE8/pd1hTjGA-eY/s1600/fmr2.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="400" src="http://2.bp.blogspot.com/-KWLoWtPojTw/TVrmcWXWZ-I/AAAAAAAABE8/pd1hTjGA-eY/s400/fmr2.png" width="251" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Announcing the newest application for Android, &lt;a href="https://market.android.com/details?id=entro.py.findmyrep"&gt;FindMyRep&lt;/a&gt;. This application allows the user to enter in a zip code to retrieve associated Senators and Representatives.&lt;br /&gt;&lt;br /&gt;Additionally, the output is linked directly to the phone for instant calling.&lt;br /&gt;&lt;br /&gt;Future upgrades include:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;automatic location by geopositioning&lt;/li&gt;&lt;li&gt;map linking of the address&lt;/li&gt;&lt;/ul&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-6Z-b48uLdoA/TVrmYH8Uc9I/AAAAAAAABE0/X1Ho0j3561M/s1600/web_hires_512.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://3.bp.blogspot.com/-6Z-b48uLdoA/TVrmYH8Uc9I/AAAAAAAABE0/X1Ho0j3561M/s320/web_hires_512.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-6890858098871985353?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='https://market.android.com/details?id=entro.py.findmyrep' title='Another Android App - FindMyRep'/><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/6890858098871985353/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=6890858098871985353' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/6890858098871985353'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/6890858098871985353'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2011/02/another-android-app-findmyrep.html' title='Another Android App - FindMyRep'/><author><name>Garrett</name><uri>http://www.blogger.com/profile/10157693937724512283</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_x81YABKRdos/TLJ-J9pnH1I/AAAAAAAAA78/k9B6dgIskY4/S220/IMG_0040.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-KWLoWtPojTw/TVrmcWXWZ-I/AAAAAAAABE8/pd1hTjGA-eY/s72-c/fmr2.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-5115223217206301934</id><published>2011-02-10T13:54:00.000-05:00</published><updated>2011-04-27T07:54:30.390-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mobile'/><category scheme='http://www.blogger.com/atom/ns#' term='android'/><title type='text'>New Android App - Quotr</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-m0TvgmUHG3g/TVQyIpqwuII/AAAAAAAABEU/xf2CWZLVLDI/s1600/web_hires_512.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="200" src="http://2.bp.blogspot.com/-m0TvgmUHG3g/TVQyIpqwuII/AAAAAAAABEU/xf2CWZLVLDI/s200/web_hires_512.png" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;Brand new Android application released today (I really do need to get an Android phone).&lt;br /&gt;&lt;br /&gt;The application, titled Quotr is a straightforward quote display application.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/-KXCbng1XCP8/TVQyRsR6zYI/AAAAAAAABEY/2T-6EaUqZYA/s1600/quot1320480.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" height="320" src="http://1.bp.blogspot.com/-KXCbng1XCP8/TVQyRsR6zYI/AAAAAAAABEY/2T-6EaUqZYA/s320/quot1320480.png" width="213" /&gt;&lt;/a&gt;The app uses a large vertically and horizontally centered TextView. The content is retrieved using XML in Java. The application consumes a webservice and displays the result.&lt;br /&gt;&lt;br /&gt;Additionally, I put no menus or buttons in the application. To refresh the quotes I put an onClickListener for the TextView and a listener for shakes.&lt;br /&gt;&lt;code&gt;  TextView tv;  tv = (TextView) findViewById(R.id.quote);  tv.setOnClickListener(new View.OnClickListener() {   public void onClick(View v) {    retrieveQuote();   }  });&lt;/code&gt;and a listener for shake events...&lt;code&gt;private final SensorEventListener mSensorListener = new SensorEventListener() {  public void onAccuracyChanged(Sensor arg0, int arg1) {   retrieveQuote();  } };&lt;/code&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-mVqXaLpJzRk/TVQ0Mcnq2CI/AAAAAAAABEg/cZjjv2QdmlU/s1600/quot2854480.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="224" src="http://2.bp.blogspot.com/-mVqXaLpJzRk/TVQ0Mcnq2CI/AAAAAAAABEg/cZjjv2QdmlU/s400/quot2854480.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-5115223217206301934?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='https://market.android.com/details?id=entro.py.quotr' title='New Android App - Quotr'/><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/5115223217206301934/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=5115223217206301934' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/5115223217206301934'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/5115223217206301934'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2011/02/new-android-app-quotr.html' title='New Android App - Quotr'/><author><name>Garrett</name><uri>http://www.blogger.com/profile/10157693937724512283</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_x81YABKRdos/TLJ-J9pnH1I/AAAAAAAAA78/k9B6dgIskY4/S220/IMG_0040.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-m0TvgmUHG3g/TVQyIpqwuII/AAAAAAAABEU/xf2CWZLVLDI/s72-c/web_hires_512.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-597434217850724313</id><published>2011-02-07T13:11:00.000-05:00</published><updated>2011-04-27T07:54:30.390-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mobile'/><category scheme='http://www.blogger.com/atom/ns#' term='android'/><title type='text'>FXSignalizr Updates</title><content type='html'>The FX Signal Generator (&lt;a href="https://market.android.com/details?id=entro.py"&gt;FXSignalizr&lt;/a&gt;) has been updated to the Google Android Marketplace.&lt;br /&gt;&lt;br /&gt;We're running at version 1.2 now with a cleaner user interface.&lt;br /&gt;&lt;br /&gt;Some of the updates include a complete rewrite of the selection code. Conversion of spinner controls to listView.&lt;br /&gt;&lt;br /&gt;Additional update to the chart component. The chart for some reason was tiny before. It fits the screen now.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_x81YABKRdos/TVA1gXx6xdI/AAAAAAAABEE/9r8mCPJIdLk/s1600/results.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" height="320" src="http://3.bp.blogspot.com/_x81YABKRdos/TVA1gXx6xdI/AAAAAAAABEE/9r8mCPJIdLk/s320/results.png" width="192" /&gt;&lt;/a&gt;&lt;a href="http://2.bp.blogspot.com/_x81YABKRdos/TVA0qcG8u-I/AAAAAAAABEA/VL0rd3qx0kI/s1600/fx11menu.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://2.bp.blogspot.com/_x81YABKRdos/TVA0qcG8u-I/AAAAAAAABEA/VL0rd3qx0kI/s320/fx11menu.png" width="192" /&gt;&lt;/a&gt;&lt;a href="http://3.bp.blogspot.com/_x81YABKRdos/TVA0ow7PLFI/AAAAAAAABD8/y0xentaX62k/s1600/currencySelection.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://3.bp.blogspot.com/_x81YABKRdos/TVA0ow7PLFI/AAAAAAAABD8/y0xentaX62k/s320/currencySelection.png" width="192" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-597434217850724313?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='https://market.android.com/details?id=entro.py' title='FXSignalizr Updates'/><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/597434217850724313/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=597434217850724313' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/597434217850724313'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/597434217850724313'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2011/02/fxsignalizr-updates.html' title='FXSignalizr Updates'/><author><name>Garrett</name><uri>http://www.blogger.com/profile/10157693937724512283</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_x81YABKRdos/TLJ-J9pnH1I/AAAAAAAAA78/k9B6dgIskY4/S220/IMG_0040.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_x81YABKRdos/TVA1gXx6xdI/AAAAAAAABEE/9r8mCPJIdLk/s72-c/results.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-4308921276269830616</id><published>2011-02-04T14:25:00.002-05:00</published><updated>2011-04-27T07:54:30.391-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mobile'/><category scheme='http://www.blogger.com/atom/ns#' term='android'/><title type='text'>Android Application Released - FXSignalizr</title><content type='html'>&lt;a href="http://1.bp.blogspot.com/_x81YABKRdos/TUxRyUKCB6I/AAAAAAAABDs/0388lJiXy08/s1600/web_hires_512.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://1.bp.blogspot.com/_x81YABKRdos/TUxRyUKCB6I/AAAAAAAABDs/0388lJiXy08/s320/web_hires_512.png" width="320" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Just announcing my first ever published application to the Android Marketplace. I must say after a bit of development this is a fantastic platform to work with.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Using Java with Eclipse is like bread and butter (without the fat and carbs). The process is smooth and the tools are easy to work with.&lt;br /&gt;&lt;br /&gt;More fixes need to go in and I'll explain more about the way the application runs in time. It is basically lots of Python running on Google App Engine with Java Android package.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;More on this soon. For now, if you have an Android phone, go grab the &lt;a href="http://market.android.com/details?id=entro.py"&gt;FXSignalizr&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The application is:&lt;br /&gt;&lt;span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse; color: #666666; font-family: 'Droid Sans', Arial, sans-serif; font-size: 13px; line-height: 19px;"&gt;Foreign Exchange (FX) entry signal generator. This application requests a currency type, limit and stop loss. It looks at past data and attempts to calculate a basic entry signal for FX Trading. No trades are available through this application.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse; color: #666666; font-family: 'Droid Sans', Arial, sans-serif; font-size: 13px; line-height: 19px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_x81YABKRdos/TUxST5eo84I/AAAAAAAABDw/P9Ckjw99Eng/s1600/fxs1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://3.bp.blogspot.com/_x81YABKRdos/TUxST5eo84I/AAAAAAAABDw/P9Ckjw99Eng/s320/fxs1.png" width="235" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_x81YABKRdos/TUxSUiKfMhI/AAAAAAAABD0/uw3YmxMf-98/s1600/fxs2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://4.bp.blogspot.com/_x81YABKRdos/TUxSUiKfMhI/AAAAAAAABD0/uw3YmxMf-98/s320/fxs2.png" width="270" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="color: #666666; font-family: 'Droid Sans', Arial, sans-serif; font-size: x-small;"&gt;&lt;span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; border-collapse: collapse; line-height: 19px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-4308921276269830616?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://market.android.com/details?id=entro.py' title='Android Application Released - FXSignalizr'/><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/4308921276269830616/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=4308921276269830616' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/4308921276269830616'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/4308921276269830616'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2011/02/first-android-application.html' title='Android Application Released - FXSignalizr'/><author><name>Garrett</name><uri>http://www.blogger.com/profile/10157693937724512283</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_x81YABKRdos/TLJ-J9pnH1I/AAAAAAAAA78/k9B6dgIskY4/S220/IMG_0040.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_x81YABKRdos/TUxRyUKCB6I/AAAAAAAABDs/0388lJiXy08/s72-c/web_hires_512.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-8127698873248368561</id><published>2011-01-21T09:48:00.000-05:00</published><updated>2011-04-27T07:54:30.392-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mobile'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='android'/><title type='text'>App Inventor for Android - Centering</title><content type='html'>The &lt;a href="https://encrypted.google.com/url?sa=t&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CBoQFjAA&amp;amp;url=http%3A%2F%2Fappinventor.googlelabs.com%2Fabout%2F&amp;amp;ei=bZw5TdKFOYGw8gOC68CaCA&amp;amp;usg=AFQjCNFLbpnTdwBKtLKSR_0e20koi_ORbQ&amp;amp;sig2=_boiyfe9lBflfBh-VN6hAg"&gt;Google App Inventor for Android&lt;/a&gt;&amp;nbsp;is a really interesting tool. Having quite a bit of iOS experience, I decided to give some android development a shot next. Some interenet research lead me to the App Inventor, which honestly should change the entire way we think of &lt;i&gt;coding&lt;/i&gt;. Object oriented is, with this fantastic tool, literally objects that are manipulated on the screen. &lt;br /&gt;&lt;br /&gt;I am not here to extol the virtues of App Inventor, I'm here to complain about one aspect of it. Layouts. Why can't this thing have a grid positioning tool?! At any rate, here is a technique to center an item on the screen with app inventor that may not be readily visible.&lt;br /&gt;&lt;br /&gt;Select Screen Arrangement then add a horizontal&amp;nbsp;arrangement&amp;nbsp;to the screen. set the width to "fill parent."&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_x81YABKRdos/TTmYswa_9mI/AAAAAAAABC8/VEzKwrska2Q/s1600/horizontalArrangement.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="135" src="http://3.bp.blogspot.com/_x81YABKRdos/TTmYswa_9mI/AAAAAAAABC8/VEzKwrska2Q/s400/horizontalArrangement.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;Next Basic and add a label to the arrangement on the left, setting it's width to Fill Parent and delete the 'text for label&lt;i&gt;x&lt;/i&gt;. Now add your item to be centered next in the horizontal arrangement, in-line with the just placed label. Finally add another label to the right of your just placed item to be centered also setting it to fill parent and deleting the default text.&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_x81YABKRdos/TTmakqm3iiI/AAAAAAAABDA/NmzGuXxoKPo/s1600/centeredButton.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="110" src="http://3.bp.blogspot.com/_x81YABKRdos/TTmakqm3iiI/AAAAAAAABDA/NmzGuXxoKPo/s400/centeredButton.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;To now center this vertically, just follow what you've done already with labels. Add a label above the horizontal arrangement, setting its height to "fill parent". Add one below the horizontal arrangement setting it to Fill Parent as well. Also, uncheck "Scrollable" on the screen.&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_x81YABKRdos/TTmblLbbU7I/AAAAAAAABDE/6aVJ5J-dRZ8/s1600/verticalCenter.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="152" src="http://4.bp.blogspot.com/_x81YABKRdos/TTmblLbbU7I/AAAAAAAABDE/6aVJ5J-dRZ8/s400/verticalCenter.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;Anyway, that's&amp;nbsp;ridiculous. How about some decent layout tools, Google? I have more layout abilities, right in my blog post editor. Otherwise applications designed with the app inventor are going to look like a 1998 Geocities layout.&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;I want to credit the &lt;a href="http://groups.google.com/group/appinventor/msg/04521db789edb1ba"&gt;App Inventor Coffee Shop&lt;/a&gt; for the guidance. I built the tutorial here but none of this was evident.&amp;nbsp;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-8127698873248368561?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/8127698873248368561/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=8127698873248368561' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/8127698873248368561'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/8127698873248368561'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2011/01/app-inventor-for-android-centering.html' title='App Inventor for Android - Centering'/><author><name>Garrett</name><uri>http://www.blogger.com/profile/10157693937724512283</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_x81YABKRdos/TLJ-J9pnH1I/AAAAAAAAA78/k9B6dgIskY4/S220/IMG_0040.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_x81YABKRdos/TTmYswa_9mI/AAAAAAAABC8/VEzKwrska2Q/s72-c/horizontalArrangement.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-3606825988314558689</id><published>2010-10-21T08:39:00.001-04:00</published><updated>2011-04-27T07:54:30.393-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mobile'/><category scheme='http://www.blogger.com/atom/ns#' term='android'/><title type='text'>Determine and Dynamic Change a View in Stacklayout</title><content type='html'>Recently, I've been doing quite a bit of mobile development using client side code. One fantastic, but poorly documented IDE  (come-on Apple!) is &lt;a href="http://developer.apple.com/technologies/xcode.html"&gt;Dashcode&lt;/a&gt;. The tool can assist with event handling, layouts, standard UI components, etc. It is a simplistic tool and can be confusing.  Relying on it for complex tasks can be challenging, however.&lt;br /&gt;&lt;br /&gt;One often needed event in mobile web development is a way to flip views easily in a Stacklayout. There are various ways this can be accomplished through hardcoding buttons, and so forth. Making a back and forward card flip button is much more interesting.&lt;br /&gt;&lt;br /&gt;Through two JavaScript functions &amp;nbsp;the onclick events can be handled and we have a dynamic view change function. To start, attach a function name of your choosing to any object on screen.For the forward or right button view change I use&amp;nbsp;&lt;i&gt;rBtn_onclick&lt;/i&gt;&amp;nbsp;as the function name.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_x81YABKRdos/TMAzGPkCADI/AAAAAAAAA88/FOALme7yTPU/s1600/Screen+shot+2010-10-21+at+8.27.27+AM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://1.bp.blogspot.com/_x81YABKRdos/TMAzGPkCADI/AAAAAAAAA88/FOALme7yTPU/s320/Screen+shot+2010-10-21+at+8.27.27+AM.png" width="218" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;The function works by looping an array of all the views, comparing it to which current view we are on and then presenting the user with the next one in the array.&lt;br /&gt;&lt;code&gt;function rBtn_onclick(event){&amp;nbsp;&amp;nbsp; var views = document.getElementById('stackLayout');&amp;nbsp;&amp;nbsp; for (var i=0;i&amp;lt;views.object.getAllViews().length;i++)&amp;nbsp;&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (views.object.getAllViews()[i] == views.object.getCurrentView())&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var next = views.object.getAllViews()[i+1];&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp; if (views &amp;amp;&amp;amp; views.object &amp;amp;&amp;amp; next) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;views.object.setCurrentView(next);&amp;nbsp;&amp;nbsp; }}&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;The left navigation button is similiar but just displays the &lt;i&gt;.getAllViews()[i-1]&lt;/i&gt;. An interesting notation here, if you are using transitions for your view changes there is an additional parameter that can be added to &lt;i&gt;.setCurrentView()&lt;/i&gt;. &lt;code&gt;&lt;b&gt;Change this line in left navigation&lt;/b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;views.object.setCurrentView(next);&lt;b&gt;To this to reverse the transitions&lt;/b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;views.object.setCurrentView(next, 'reverse');&lt;/code&gt;Also, be sure and trap your (&lt; 0) and (&gt; length) in the code. Enjoy!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-3606825988314558689?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/3606825988314558689/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=3606825988314558689' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/3606825988314558689'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/3606825988314558689'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2010/10/determine-and-dynamic-change-view-in.html' title='Determine and Dynamic Change a View in Stacklayout'/><author><name>Garrett</name><uri>http://www.blogger.com/profile/10157693937724512283</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_x81YABKRdos/TLJ-J9pnH1I/AAAAAAAAA78/k9B6dgIskY4/S220/IMG_0040.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_x81YABKRdos/TMAzGPkCADI/AAAAAAAAA88/FOALme7yTPU/s72-c/Screen+shot+2010-10-21+at+8.27.27+AM.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-5156103955895548558</id><published>2010-10-20T07:44:00.004-04:00</published><updated>2010-10-21T08:56:00.094-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Bubblesort a Vector in C++</title><content type='html'>I have learned from looking through my logs on this site, that consistently the most viewed page is the &lt;a href="http://realityisimportant.blogspot.com/2008/11/bubblesort-multidimensional-array-in.html"&gt;Bubble sort Multidimensional Array in Java&lt;/a&gt;. This got me to wondering if people were here for Bubble sorting,&amp;nbsp;Java&amp;nbsp;or&amp;nbsp;multidimensional&amp;nbsp;arrays. The analytics show that it's mostly searches for Java and sorting that have been attracting visitors to that particular page.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://www.publicdomainpictures.net/pictures/5000/velka/87-12545660383bGu.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" height="240" src="http://www.publicdomainpictures.net/pictures/5000/velka/87-12545660383bGu.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;I thought perhaps users may find it useful for a straightforward &lt;a href="http://en.wikipedia.org/wiki/Bubble_sort"&gt;bubble sort&lt;/a&gt; in C++. The sort will take a vector of ints (strings would work or any other data type too but adjust the condition to fit your needs) and perform a basic bubble sort on it. This could easily be changed to support arrays and so forth. The algorithm is the same.&lt;br /&gt;&lt;br /&gt;Add this function into any of your programs, porting to Java, JavaScript, PHP, et al. should be no problem. The syntax is mostly&amp;nbsp;similar,&amp;nbsp;save for the variable declarations. I can, if requested write this out however. This sort returns a &lt;i&gt;vector&lt;/i&gt;&amp;nbsp;but can easily be modified.&lt;br /&gt;&lt;code&gt;vector&amp;lt;int&amp;gt; bubblesort(vector&amp;lt;int&amp;gt; w){      int temp;   bool finished = false;   while (!finished)   {      finished = true;      for (int i = 0; i &amp;lt; w.size()-1; i++)       {         if (w[i] &amp;gt; w[i+1]) {            temp = w[i];            w[i] = w[i+1];            w[i+1] = temp;            finished=false;          }       }   }   return w;}&lt;/code&gt;This is nothing new and not inventing the wheel. Porting this to any other language would take minimal effort. Let me know any thoughts in the comments.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-5156103955895548558?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/5156103955895548558/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=5156103955895548558' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/5156103955895548558'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/5156103955895548558'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2010/10/bubblesort-single-dimension-array.html' title='Bubblesort a Vector in C++'/><author><name>Garrett</name><uri>http://www.blogger.com/profile/10157693937724512283</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_x81YABKRdos/TLJ-J9pnH1I/AAAAAAAAA78/k9B6dgIskY4/S220/IMG_0040.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-2212596468087416945</id><published>2010-10-19T07:59:00.002-04:00</published><updated>2011-04-27T07:54:58.168-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mobile'/><category scheme='http://www.blogger.com/atom/ns#' term='HTML5'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='android'/><title type='text'>Geolocation: Finding Directions</title><content type='html'>&lt;a href="http://3.bp.blogspot.com/_x81YABKRdos/TL2Hxd9IizI/AAAAAAAAA84/lqqs1JmaG8I/s1600/map-directions-500.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" height="320" src="http://3.bp.blogspot.com/_x81YABKRdos/TL2Hxd9IizI/AAAAAAAAA84/lqqs1JmaG8I/s320/map-directions-500.jpg" width="261" /&gt;&lt;/a&gt;So far in this series, I've covered &lt;a href="http://realityisimportant.blogspot.com/2010/10/geolocation-through-javascript.html"&gt;retrieving your latitude and longitude with JavaScript&lt;/a&gt;, r&lt;a href="http://realityisimportant.blogspot.com/2010/10/geolocation-and-mapping-recording-track.html"&gt;ecording a track while changing locations&lt;/a&gt; and &lt;a href="http://realityisimportant.blogspot.com/2010/10/geocoding-returning-address-based-on.html"&gt;reverse geocoding&lt;/a&gt; your position. One additional key component for any mapping utility is finding directions between two points.&lt;br /&gt;&lt;br /&gt;Now that we have a position determined, we can find directions to another position. This script uses components from the &lt;a href="http://code.google.com/apis/maps/documentation/javascript/basics.html"&gt;Google Maps JavaScript API&lt;/a&gt;, please read this thing. For simplicity sake and to reduce server load I have created a static list of positions that can be routed to. Adding a text input instead should be reasonable if you've made it this far. The location finder has been modified slighty to remove the event driven button. Instead now the address is automatically updated and the user is presented with a list of positions they can route to.&lt;br /&gt;&lt;br /&gt;So the HTML portion of the script is as follows:&lt;br /&gt;&lt;code&gt;Latitude: &amp;lt;div id="lat"&amp;gt;&amp;nbsp;&amp;lt;/div&amp;gt;&amp;lt;br /&amp;gt;Longitude: &amp;lt;div id="lng"&amp;gt;&amp;nbsp;&amp;lt;/div&amp;gt;&amp;lt;br /&amp;gt;*** Get Directions *** &amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;From: &amp;lt;div id="from"&amp;gt;&amp;nbsp;&amp;lt;/div&amp;gt; &amp;lt;br /&amp;gt;To:&amp;lt;br /&amp;gt;&amp;lt;form&amp;gt;&amp;lt;select id="to"&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;option&amp;gt;&amp;lt;/option&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;option&amp;gt;Times Square, NYC&amp;lt;/option&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;option&amp;gt;Griffith Observatory, Los Angeles, CA&amp;lt;/option&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&amp;lt;/select&amp;gt;&amp;lt;/form&amp;gt;&amp;lt;div id="directions"&amp;gt;&amp;nbsp;&amp;lt;/div&amp;gt;&lt;/code&gt;Converting that select box to an entry field would require minimal effort. To handle the change event of the select box and update the current address location automatically, I added the following function which is called on each position change.&lt;code&gt;function displayMap(location) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var lat = ...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var addy = document.getElementById('from');&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; geocoder = new google.maps.Geocoder();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var latlng = new google.maps.LatLng(lat, lng);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; geocoder.geocode( { 'latLng': latlng},&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; function(results, status) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (status == "OK" &amp;amp;&amp;amp; results.length &amp;gt; 0) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; addy.innerHTML = results[0].formatted_address;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; addy.innerHTML = status;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var destination = document.getElementById("to");&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; destination.addEventListener("change",function() { getDirections(&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; addy.innerHTML, destination.value) },false);}&lt;/code&gt;If you look closely at the event listener for the "to" select box, you'll see it calls the getDirections function and pushes the innerHTML of the address div and the value of the destination selection as parameters. &lt;i&gt;This may not work in all browsers.&lt;/i&gt;the getDirections function uses the Google objects to retrieve the directions. The directions are updated using three key components.&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Create the directionsDisplay object&lt;/li&gt;&lt;li&gt;Attach a div on the page to the setPanel method. In this case we'll be using the "directions" div.&lt;/li&gt;&lt;li&gt;Use diresctionsDisplay.setDirections of our response to post Google formatted directions.&lt;/li&gt;&lt;/ol&gt;Okay, yeah the directions are returned exactly like the ones we are all familiar with from Google Maps. You are able to read the directions in as an array and post the results as you see fit here however. Perhaps a paging style with static maps, on a spinner, etc. As I said before, this is the path of least resistance. Modifying is as easy as reading the&lt;a href="http://code.google.com/apis/maps/documentation/javascript/basics.html"&gt; spec&lt;/a&gt;.&lt;br /&gt;&lt;code&gt;function getDirections(from, to){&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var dirs = document.getElementById("directions");&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; directionsService = new google.maps.DirectionsService();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var request = {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; origin: from,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; destination: to,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; travelMode: google.maps.DirectionsTravelMode.DRIVING&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; directionsDisplay = new google.maps.DirectionsRenderer();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; directionsDisplay.setPanel(dirs);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; directionsService.route(request,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; function(response, status) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (status == "OK") {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; directionsDisplay.setDirections(response);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dirs.innerHTML += status;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; );}&lt;/code&gt;And...that about sums up this episode. I have a demo of this &lt;a href="http://qrencodr.appspot.com/geolocateWithDirections.html"&gt;short web app online&lt;/a&gt;. Any questions...please post in the comments.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-2212596468087416945?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/2212596468087416945/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=2212596468087416945' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/2212596468087416945'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/2212596468087416945'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2010/10/geolocation-finding-directions.html' title='Geolocation: Finding Directions'/><author><name>Garrett</name><uri>http://www.blogger.com/profile/10157693937724512283</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_x81YABKRdos/TLJ-J9pnH1I/AAAAAAAAA78/k9B6dgIskY4/S220/IMG_0040.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_x81YABKRdos/TL2Hxd9IizI/AAAAAAAAA84/lqqs1JmaG8I/s72-c/map-directions-500.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-356801424741735287</id><published>2010-10-18T14:21:00.003-04:00</published><updated>2011-04-27T07:54:58.169-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mobile'/><category scheme='http://www.blogger.com/atom/ns#' term='geolocation'/><category scheme='http://www.blogger.com/atom/ns#' term='HTML5'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='android'/><title type='text'>Geocoding: Returning an address based on position</title><content type='html'>While building the framework for the mobile, web-based geolocation and mapping application, other various features come to mind. Some of the more more popular location based tools such as Yelp and Foursquare the user an ability to 'check-in' to a location. This not only retains the position and can socially share it with others, it provides a journal of sorts for the individual. In order to develop something like this, one would need to find the address of the current location to start and then cross reference to check-in at a nearby location.&lt;br /&gt;To get started, we're going to find the current address based on our position. So far, using only the one JavaScript navigation object and subsequent methods we have retrieved the latitude and longitude. With a some short lines of code and including the Google Maps API, we can retrive many other attributes of our current location, including elevation. We also have an option to &lt;a href="http://code.google.com/apis/maps/documentation/geocoding/#ReverseGeocoding"&gt;Reverse Geocoding&lt;/a&gt;&amp;nbsp;an address by using only the latitude and longitude.&lt;br /&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: Helvetica, Arial, sans-serif; font-size: small; line-height: 16px;"&gt;The term&amp;nbsp;&lt;i&gt;geocoding&lt;/i&gt;&amp;nbsp;generally refers to translating a human-readable address into a location on a map. The process of doing the converse, translating a location on the map into a human-readable address, is known as&amp;nbsp;&lt;i&gt;reverse geocoding&lt;/i&gt;.&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;a href="http://code.google.com/apis/maps/documentation/geocoding/#ReverseGeocoding"&gt;http://code.google.com/apis/maps/documentation/geocoding/#ReverseGeocoding&lt;/a&gt;&lt;/blockquote&gt;This article will specifically focus on the &lt;a href="http://code.google.com/apis/maps/documentation/javascript/services.html"&gt;Google Maps API JavaScript&lt;/a&gt; for our objects.&amp;nbsp;Access to this API does not require a key &lt;span class="Apple-style-span" style="color: white;"&gt;UCPKHPKAE7BC&lt;/span&gt;&amp;nbsp;or signed URL.  For this article we're going to be sticking with client-side code and letting JavaScript do the lifting.&lt;br /&gt;&lt;br /&gt;To access the Google Map objects, we need to add a simple script include into our &amp;lt;head&amp;gt; section.&amp;nbsp;&lt;code&gt;&amp;lt;script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=&lt;i&gt;[true||false]]&lt;/i&gt;"&amp;gt;&amp;lt;/script&amp;gt;&lt;/code&gt;&lt;br /&gt;There are many different objects we now have access to that can be called, all from just our beginning latitude and longitude which were&lt;a href="http://realityisimportant.blogspot.com/2010/10/geolocation-through-javascript.html"&gt; retrieved from the browser&lt;/a&gt; built in JavaScript.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_x81YABKRdos/TLyN-DrH8eI/AAAAAAAAA80/gf_WITuBgN4/s1600/iStock_000005440773XSmallEDIT.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_x81YABKRdos/TLyN-DrH8eI/AAAAAAAAA80/gf_WITuBgN4/s1600/iStock_000005440773XSmallEDIT.jpg" /&gt;&lt;/a&gt;One key parameter in that URL is &lt;i&gt;sensor. &lt;/i&gt;This is relatively straightforward to determine. Google asks (requires) one to set sensor to true if the request is coming from a device with a GPS sensor, including a mobile device. If you would are running tests from your desktop and building a static URL, set this to false.&lt;br /&gt;&lt;br /&gt;Instead of modifying the original &lt;a href="http://realityisimportant.blogspot.com/2010/10/geolocation-through-javascript.html"&gt;Geolocation&lt;/a&gt;&amp;nbsp;application, we're going to use a webpage that retrieves our latitude and longitude and outputs it to the browser. The user can press a button to request a reverse geocode on this position. Through this we'll let Google try and determine our current position.&lt;br /&gt;&lt;br /&gt;The actual body of the page contains just 5 lines to display our positioning information:&lt;br /&gt;&lt;code&gt;Latitude: &amp;lt;div id="lat"&amp;gt;&amp;nbsp;&amp;lt;/div&amp;gt;&amp;lt;br /&amp;gt;Longitude: &amp;lt;div id="lng"&amp;gt;&amp;nbsp;&amp;lt;/div&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;button id="geocode"&amp;gt;Find me!&amp;lt;/button&amp;gt;&amp;lt;div id="addresses"&amp;gt;&amp;nbsp;&amp;lt;/div&amp;gt;&lt;/code&gt;&lt;br /&gt;To make the events fire attach a dynamic event to the button in JavaScript:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;function displayMap(location){ var lat = location.coords.latitude; var lng = location.coords.longitude;        // update the current positions in the divs var latdiv = document.getElementById("lat"); latdiv.innerHTML = lat; var lngdiv = document.getElementById("lng"); lngdiv.innerHTML = lng;         // change the function params each time the above positions are updated var geoBtn = document.getElementById("geocode"); geoBtn.addEventListener("click",function() { getAddresses(lat, lng) }, false); }&lt;/code&gt;&lt;br /&gt;Now whenever displayMap is called through a position update (hint: look back at the &lt;a href="http://realityisimportant.blogspot.com/2010/10/geolocation-through-javascript.html"&gt;original article&lt;/a&gt;) the function call will be updated with the new coordinates. Nifty! There are also other ways to create this event listener. Use whatever works for you.&lt;br /&gt;Now to get our current address.&lt;code&gt;function getAddresses(lat,lng)&lt;br /&gt;{ var addy = document.getElementById('addresses');   geocoder = new google.maps.Geocoder(); var latlng = new google.maps.LatLng(lat, lng); geocoder.geocode( { 'latLng': latlng},   function(results, status) {&amp;lt;   if (status == "OK") {    for (var i=0;i&amp;lt;results.length;i++)     addy.innerHTML += results[i].formatted_address + "&amp;lt;br /&amp;gt;";   } else {    addy.innerHTML = status;   }  } );}&lt;/code&gt;&lt;br /&gt;and...our results using the coordinates of &lt;a href="http://en.wikipedia.org/wiki/Beaver_Stadium"&gt;Beaver Stadium at Penn State&lt;/a&gt; show up in the &lt;i&gt;addresses&lt;/i&gt; div.&lt;code&gt;Curtin Rd, State College, PA 16801, USACollege, PA, USAState College, PA 16801, USACentre, Pennsylvania, USAPennsylvania, USAUnited States&lt;/code&gt;&lt;br /&gt;Looping all the results is vague and gets increasingly so. We need to just return the first result. So the function is modified as follows.&lt;code&gt;geocoder.geocode( { 'latLng': latlng},   function(results, status) {   if (status == "OK" &amp;amp;&amp;amp; results.length &amp;gt; 0) {    addy.innerHTML = results[0].formatted_address;   } else {    addy.innerHTML = status;   }  } );&lt;/code&gt;So now we have the closest address to our position. This is very straight forward and done in a few lines of JavaScript. With these examples I am taking the path of least resistance for demonstration purposes. There is a &lt;a href="http://qrencodr.appspot.com/geolocateWithReverseGeocoding.html"&gt;working demo of this application&lt;/a&gt; available. Again, this &lt;i&gt;should&lt;/i&gt; work but &lt;i&gt;might&lt;/i&gt; be sketchy on the desktop but should work fine from a mobile.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-356801424741735287?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/356801424741735287/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=356801424741735287' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/356801424741735287'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/356801424741735287'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2010/10/geocoding-returning-address-based-on.html' title='Geocoding: Returning an address based on position'/><author><name>Garrett</name><uri>http://www.blogger.com/profile/10157693937724512283</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_x81YABKRdos/TLJ-J9pnH1I/AAAAAAAAA78/k9B6dgIskY4/S220/IMG_0040.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_x81YABKRdos/TLyN-DrH8eI/AAAAAAAAA80/gf_WITuBgN4/s72-c/iStock_000005440773XSmallEDIT.jpg' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-4954584504032579387</id><published>2010-10-17T20:20:00.005-04:00</published><updated>2010-12-15T07:10:29.768-05:00</updated><title type='text'>The n Days of Christmas</title><content type='html'>I love to love recursion! There, I said that I said it. It's a word that's scary to some, but fun to say. Also, as a professional programmer it's a word to drop occasionally to make yourself sound smart. "I made the function recursive thus reducing the lines of code." For your additional information this also works for &lt;i&gt;algorithm&lt;/i&gt;, &lt;i&gt;method&lt;/i&gt; and &lt;i&gt;deprecate&lt;/i&gt;. Do know the meanings, however, before using.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://blog.ginchen.de/wp-content/uploads/2010/03/recursion.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" height="256" src="http://blog.ginchen.de/wp-content/uploads/2010/03/recursion.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;While it is a bit early on this year, I got to thinking about the famous Twelve Days of Christmas algorithm. There is &lt;b&gt;&lt;i&gt;a lot&lt;/i&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&amp;nbsp;of items being gifted! It becomes a little bit involved to think though just how many.&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;Day 1: 1&amp;nbsp;&lt;/span&gt;&lt;/b&gt;partridge&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;Day 2: 2 turtle doves + 1&amp;nbsp;&lt;/span&gt;&lt;/b&gt;partridge + (Day 1)&lt;/li&gt;&lt;li&gt;...&lt;/li&gt;&lt;li&gt;Day 12: 12 pipers + 11 lords + 10 maids + .... + 1 partridge + (Day 11) + (Day 10) ... + (Day 1)&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;Each day's individual total gifts can be summed up with an equation.&lt;br /&gt;&lt;code&gt;g(n) = n + n-1 + n-2 ... + 1&lt;/code&gt;&lt;br /&gt;The fun begins when the previous days have to be added in. &lt;code&gt;H(N) = g(N) + g(N-1) .. + g(1)&lt;/code&gt;&lt;br /&gt;The beginning programmer might be temped to solve the days of Christmas through (ugh!) hardcoding the calculations. Don't fall into this trap. The daily calculation is a simple recusive function that will give us the results.&lt;br /&gt;&lt;code&gt;function howManyToday(n){ return (n==1) ? n : howManyToday(n-1) + n; }&lt;/code&gt;&lt;br /&gt;Running this function as &lt;i&gt;howManyToday(2)&lt;/i&gt; will return the 3 items for the day (2 turtle doves + 1 partridge). While good for one day, this will not return the total. On day 2 we would also have to be including day 1's total. Nearly the same exact function can be used to wrap the daily total.&lt;br /&gt;&lt;code&gt;function whichDay(d) { return (d==1) ? d : howManyToday(d-1) + whichDay(d-1) + d;}&lt;/code&gt;&lt;br /&gt;These two functions can be compressed further to make this problem even more fun to solve. The twelve days of Christmas have been a source of &lt;a href="http://research.microsoft.com/en-us/um/people/tball/papers/xmasgift/"&gt;code obfuscation fun&lt;/a&gt; for a long time. This code works the same exact way but is oh so much more interesting.&lt;code&gt;var _____ = 1;function _(__) {return (__==_____)?__:___(__-_____)+ _(__-_____)+__;}function ___(____){return (____==_____)?____:___(____-_____)+____;}&lt;/code&gt;With a call to &lt;i&gt;whichDay(d)&lt;/i&gt; or &lt;i&gt;_(__)&lt;/i&gt;&amp;nbsp;we can find out how many items would be gifted on any day. Note to anyone who found this site by looking for basic recursion for a 101 class, avoid the ternary and avoid the obfuscation.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-4954584504032579387?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/4954584504032579387/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=4954584504032579387' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/4954584504032579387'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/4954584504032579387'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2010/10/365-days-of-recursion.html' title='The &lt;i&gt;n&lt;/i&gt; Days of Christmas'/><author><name>Garrett</name><uri>http://www.blogger.com/profile/10157693937724512283</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_x81YABKRdos/TLJ-J9pnH1I/AAAAAAAAA78/k9B6dgIskY4/S220/IMG_0040.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-1427624802543941464</id><published>2010-10-15T23:02:00.012-04:00</published><updated>2010-10-16T07:34:53.821-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Blog Action Day 2010 - Water Use Calculator</title><content type='html'>In honor of &lt;a href="http://blogactionday.change.org/"&gt;Blog Action Day 2010&lt;/a&gt; recognizing water usage, I have put together a simple water use calculator. Water consumption is something most of us just take for granted around the house. When that access is limited, water needs become much more pressing. Just try jogging on a hot day without easy access to water. There are many places around the world that have little to no access to clean water and sanitation.&lt;br /&gt;We're also using techniques that can be used for any basic JavaScript calculator. I'm a huge fan of taking the work load &lt;i&gt;off&lt;/i&gt; of the server and handing it to the browser. Extremely fast JavaScript processing in modern browsers, like Chrome, make this a viable solution for simple interactive web tools.&lt;br /&gt;This HTML/JavaScript uses simple client-side form handling for the select values. The values are  calculated using multipliers from &lt;a href="http://apps.awwa.org/EbusMain/Default.aspx?TabId=55&amp;amp;ProductID=6471"&gt;Handbook of Water Use and Conservation&lt;/a&gt;. Adjust the multipliers accordingly as necessary, I am quite sure they are dated and severely underestimated &lt;b&gt;If anyone can provide a reliable reference to better water use multipliers it would be appreciated.&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;The user selects the number of each use event: showers, toilet flushes, etc and submits the form for calculation. The calculateUsage() function rewites the innerHTML of the divs with the calculated water usage. One other short function that may be of interest is writing out the select options through a loop in a function. I have not fully checked this for cross-browser compatibility. Let me know in the comments if anyone has difficulty with it. &lt;br /&gt;&lt;code&gt;&amp;lt;head&amp;gt;&amp;lt;title&amp;gt;Water Use Calculator&amp;lt;/title&amp;gt;&amp;lt;script type="text/javascript"&amp;gt;function calculateUsage(form){ document.getElementById('shower').innerHTML = form.showers.selectedIndex * 15 + " gallons taking showers."; document.getElementById('clothe').innerHTML = form.clothes.selectedIndex * 15.0 + " gallons washing clothes."; document.getElementById('dish').innerHTML = form.dishes.selectedIndex * 10 + " gallons using the dishwasher"; document.getElementById('toilet').innerHTML = form.toilets.selectedIndex * 3 + " gallons flushing toilets."; document.getElementById('bath').innerHTML = form.baths.selectedIndex * 9 + " gallons in the bathtub."; document.getElementById('other').innerHTML = form.hands.selectedIndex * 2 + " gallons for handwashing."; document.getElementById('total').innerHTML = (form.showers.selectedIndex * 15) + (form.clothes.selectedIndex * 15) + (form.dishes.selectedIndex * 10) + (form.toilets.selectedIndex * 3) + (form.baths.selectedIndex * 9) + (form.hands.selectedIndex * 2) + " Approximate Total Gallons Daily Water Usage";}function generateOptions() {  for (var i=0;i&amp;lt;11;i++) { document.write('&amp;lt;option&amp;gt;' + i + '&amp;lt;/option&amp;gt;'); }}&amp;lt;/script&amp;gt;&amp;lt;body&amp;gt;&amp;lt;fieldset&amp;gt;&amp;lt;legend&amp;gt;Water Use Calculator&amp;lt;/legend&amp;gt;&amp;lt;form id="waterCalculator"&amp;gt;&amp;lt;div id="shower"&amp;gt; &amp;lt;label for="showers"&amp;gt;Showers&amp;lt;/label&amp;gt; &amp;lt;select name="showers"&amp;gt;   &amp;lt;script&amp;gt;generateOptions();&amp;lt;/script&amp;gt; &amp;lt;/select&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div id="clothe"&amp;gt; &amp;lt;label for="clothes"&amp;gt;Clothes&amp;lt;/label&amp;gt; &amp;lt;select name="clothes"&amp;gt;  &amp;lt;script&amp;gt;generateOptions();&amp;lt;/script&amp;gt; &amp;lt;/select&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div id="dish"&amp;gt; &amp;lt;label for="dishes"&amp;gt;Dishwashers&amp;lt;/label&amp;gt; &amp;lt;select name="dishes"&amp;gt;  &amp;lt;script&amp;gt;generateOptions();&amp;lt;/script&amp;gt; &amp;lt;/select&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div id="toilet"&amp;gt; &amp;lt;label for="toilets"&amp;gt;Toilet Flushes&amp;lt;/label&amp;gt; &amp;lt;select name="toilets"&amp;gt;  &amp;lt;script&amp;gt;generateOptions();&amp;lt;/script&amp;gt; &amp;lt;/select&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div id="bath"&amp;gt; &amp;lt;label for="baths"&amp;gt;Baths&amp;lt;/label&amp;gt; &amp;lt;select name="baths"&amp;gt;  &amp;lt;script&amp;gt;generateOptions();&amp;lt;/script&amp;gt; &amp;lt;/select&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div id="other"&amp;gt; &amp;lt;label for="hands"&amp;gt;Hand Washing&amp;lt;/label&amp;gt; &amp;lt;select name="hands"&amp;gt;  &amp;lt;script&amp;gt;generateOptions();&amp;lt;/script&amp;gt; &amp;lt;/select&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div id="total"&amp;gt; &amp;lt;input type="button" name="calculate" value="submit" onclick="calculateUsage(this.form);"&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/form&amp;gt;&amp;lt;/fieldset&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&lt;/code&gt;&lt;br /&gt;Here is a working demo of the water use calculator&lt;br /&gt;&lt;script type="text/javascript"&gt;function calculateUsage(form){ document.getElementById('shower').innerHTML = form.showers.selectedIndex * 15 + " gallons taking showers."; document.getElementById('clothe').innerHTML = form.clothes.selectedIndex * 15.0 + " gallons washing clothes."; document.getElementById('dish').innerHTML = form.dishes.selectedIndex * 10 + " gallons using the dishwasher"; document.getElementById('toilet').innerHTML = form.toilets.selectedIndex * 3 + " gallons flushing toilets."; document.getElementById('bath').innerHTML = form.baths.selectedIndex * 9 + " gallons in the bathtub."; document.getElementById('other').innerHTML = form.hands.selectedIndex * 2 + " gallons for handwashing."; document.getElementById('total').innerHTML = (form.showers.selectedIndex * 15) + (form.clothes.selectedIndex * 15) + (form.dishes.selectedIndex * 10) + (form.toilets.selectedIndex * 3) + (form.baths.selectedIndex * 9) + (form.hands.selectedIndex * 2) + " Approximate Total Gallons Daily Water Usage";}function generateOptions() {for (var i=0;i&lt;11;i++) { document.write('&lt;option&gt;' + i + '&lt;/option&gt;'); }}&lt;/script&gt;&lt;br /&gt;&lt;fieldset&gt;&lt;br /&gt;&lt;legend&gt;Water Use Calculator&lt;/legend&gt;&lt;br /&gt;&lt;form id="waterCalculator"&gt;&lt;div id="shower"&gt;&lt;label for="showers"&gt;Showers&lt;/label&gt;&lt;select name="showers"&gt;&lt;script&gt;generateOptions();&lt;/script&gt;&lt;/select&gt;&lt;/div&gt;&lt;div id="clothe"&gt;&lt;label for="clothes"&gt;Clothes&lt;/label&gt;&lt;select name="clothes"&gt;&lt;script&gt;generateOptions();&lt;/script&gt;&lt;/select&gt;&lt;/div&gt;&lt;div id="dish"&gt;&lt;label for="dishes"&gt;Dishwashers&lt;/label&gt;&lt;select name="dishes"&gt;&lt;script&gt;generateOptions();&lt;/script&gt;&lt;/select&gt;&lt;/div&gt;&lt;div id="toilet"&gt;&lt;label for="toilets"&gt;Toilet Flushes&lt;/label&gt;&lt;select name="toilets"&gt;&lt;script&gt;generateOptions();&lt;/script&gt;&lt;/select&gt;&lt;/div&gt;&lt;div id="bath"&gt;&lt;label for="baths"&gt;Baths&lt;/label&gt;&lt;select name="baths"&gt;&lt;script&gt;generateOptions();&lt;/script&gt;&lt;/select&gt;&lt;/div&gt;&lt;div id="other"&gt;&lt;label for="hands"&gt;Hand Washing&lt;/label&gt;&lt;select name="hands"&gt;&lt;script&gt;generateOptions();&lt;/script&gt;&lt;/select&gt;&lt;/div&gt;&lt;div id="total"&gt;&lt;input name="calculate" onclick="calculateUsage(this.form);" type="button" value="submit" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;/fieldset&gt;&lt;br /&gt;&lt;br /&gt;&lt;script type="text/javascript" src="http://www.change.org/widgets/content/petition_scroller_js?width=600&amp;causes=all&amp;color=00B1FF&amp;partner=1654-164"&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-1427624802543941464?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/1427624802543941464/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=1427624802543941464' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/1427624802543941464'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/1427624802543941464'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2010/10/blog-action-day-2010-water-use.html' title='Blog Action Day 2010 - Water Use Calculator'/><author><name>Garrett</name><uri>http://www.blogger.com/profile/10157693937724512283</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_x81YABKRdos/TLJ-J9pnH1I/AAAAAAAAA78/k9B6dgIskY4/S220/IMG_0040.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-6619941751968174048</id><published>2010-10-15T12:58:00.006-04:00</published><updated>2011-04-27T07:54:58.170-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mobile'/><category scheme='http://www.blogger.com/atom/ns#' term='geolocation'/><category scheme='http://www.blogger.com/atom/ns#' term='HTML5'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='android'/><title type='text'>Geolocation and Mapping - Recording a Track</title><content type='html'>In this episode we're going to add on to our &lt;a href="http://realityisimportant.blogspot.com/2010/10/geolocation-through-javascript.html"&gt;web based geolocation/mapping utility&lt;/a&gt; and add in tracking. the tracking format that I am going to build is in &lt;a href="http://en.wikipedia.org/wiki/GPS_eXchange_Format"&gt;GPS eXchange Format&lt;/a&gt; or GPX. This will build an XML/ASCII file that is compatible with just about any GPS or mapping utility. The format, however, is not essential. It would just as easy to create JSON or CSV.&lt;br /&gt;&lt;br /&gt;For instructional purposes, the&amp;nbsp;JavaScript&amp;nbsp;is verbose. There is most definitely more elegant ways of coding this solution but the intent is for this to be ported and modified as you will.&lt;br /&gt;&lt;br /&gt;In order to record a track with our mapping application we have to consider the problems:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;What information is available about the positioning?&lt;/li&gt;&lt;li&gt;What information should be retained?&lt;/li&gt;&lt;li&gt;When is the data retained?&lt;/li&gt;&lt;li&gt;How is the data retained?&lt;/li&gt;&lt;li&gt;What should be done with the retained data?&lt;/li&gt;&lt;/ol&gt;In the introductory application, we are only retaining the latitude and longitude which are basically all that is needed to hold a track. A developer may find it useful to also stamp the time along with the positioning. There is also other information available such as elevation that can be recorded into the track. For our purposes, we will be working with the latitude and longitude only at this point.&lt;br /&gt;&lt;br /&gt;The information will be retained just like any other programmer stores data, in a variable or more specifically an array. Keeping things simple, I added in a small global scope array outside of any of the functions.&lt;br /&gt;&lt;code&gt;var locations = [];&lt;/code&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_x81YABKRdos/TLiBV9YnfeI/AAAAAAAAA8s/4zBXIGLIp50/s1600/mapWithTracking.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://1.bp.blogspot.com/_x81YABKRdos/TLiBV9YnfeI/AAAAAAAAA8s/4zBXIGLIp50/s320/mapWithTracking.png" width="213" /&gt;&lt;/a&gt;&lt;/div&gt;To trigger the tracking I added in some buttons to the HTML above the map iFrame. Since this is not a tutorial about event handling in JavaScript, I just added an onclick event to each button.&lt;br /&gt;&lt;code&gt;&amp;lt;button id="start" onclick="startTrack();"&amp;gt;Start Track&amp;lt;/button&amp;gt;&amp;lt;button id="stop" onclick="stopTrack()"&amp;gt;Stop Track&amp;lt;/button&amp;gt;&lt;/code&gt;To accomodate the tracking I added in one more global &lt;i&gt;(last one, I promise).&amp;nbsp;&lt;/i&gt;&lt;br /&gt;&lt;code&gt;var recording = false;&lt;/code&gt;When a &lt;i&gt;start track&lt;/i&gt;&amp;nbsp;event is triggered the recording pseudo-boolean is set to true and an alert notifies the user.&lt;br /&gt;&lt;code&gt;function startTrack() { alert("recording started ..."); recording = true;}&lt;/code&gt;&lt;br /&gt;Now back in our actual function that displays the map, we need to do something with this recording data. For simplicity sake, it's pushed into that locations array.&lt;br /&gt;&lt;code&gt;if (recording)     locations.push(lat + "," + lon);&lt;/code&gt;&lt;br /&gt;That's it then, we're tracking and retaining our data. You should be able to do anything with it at this point, since it's stored up. So now we build the GPX/XML file.&lt;br /&gt;&lt;code&gt;function stopTrack() {    &lt;b&gt;&lt;i&gt;// let the user know something happened.&lt;/i&gt;&lt;/b&gt;   alert("recording stopped ...");   recording = false;&lt;br /&gt;   &lt;b&gt;&lt;i&gt;// generate our XML headers&lt;/i&gt;&lt;/b&gt;   document.write("&amp;lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&amp;gt;\n");   document.write("&amp;lt;gpx xmlns=\"http://www.topografix.com/GPX/1/1\"&amp;gt;\n");   document.write("&amp;lt;trk&amp;gt;\n");   document.write("\t&amp;lt;name&amp;gt;Recorded Track&amp;lt;/name&amp;gt;");   &lt;b&gt;&lt;i&gt;// you're smart enough to add a time in here&lt;/i&gt;&lt;/b&gt;   document.write("\t&amp;lt;desc&amp;gt;Jul 28, 2010&amp;nbsp;&amp;nbsp;5:46 am&amp;lt;/desc&amp;gt;");   document.write("\t&amp;lt;trkseg&amp;gt;");&lt;br /&gt;   &lt;b&gt;&lt;i&gt;// loop our previously created locations array    // placing the lat and lon into the nodes&lt;/i&gt;&lt;/b&gt;   for (var i=0;i&amp;lt;locations.length;i++)   {      document.write("\t\t&amp;lt;trkpt lat=\""          + locations[i].replace(',' ,' lon=') + "\" /&amp;gt;\n");      &lt;b&gt;&lt;i&gt;// here is where you would want to add in an      //&amp;lt;ele&amp;gt;vation and definitely a &amp;lt;time&amp;gt;&lt;/i&gt;&lt;/b&gt;   }&lt;br /&gt;   &lt;b&gt;&lt;i&gt;// close out the XML&lt;/i&gt;&lt;/b&gt;   document.write("\t&amp;lt;/trkseg&amp;gt;\n");   document.write("&amp;lt;/trk&amp;gt;\n");   document.write("&amp;lt;/gpx&amp;gt;");}&lt;/code&gt;&lt;br /&gt;Here is the paradox with this application now...this works well on a mobile device but the mobile device does not to know how to handle our file in the mobile browser. Also, is that really a paradox? To address this, in the next tutorial we'll be deprecating pretty much everything here and building JSON to store our locations and push it to a Python webservice that can actually do something with the recorded data. You should at this point be able to modify this as necessary to make something useful out of the stored track.&lt;br /&gt;This application is available for demonstration at &lt;a href="http://qrencodr.appspot.com/geolocateWithTracking.html"&gt;http://qrencodr.appspot.com/geolocateWithTracking.html&lt;/a&gt;. Since this is all client-side code, the full source is available with a &lt;i&gt;view source&lt;/i&gt; at that address as well.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-6619941751968174048?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/6619941751968174048/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=6619941751968174048' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/6619941751968174048'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/6619941751968174048'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2010/10/geolocation-and-mapping-recording-track.html' title='Geolocation and Mapping - Recording a Track'/><author><name>Garrett</name><uri>http://www.blogger.com/profile/10157693937724512283</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_x81YABKRdos/TLJ-J9pnH1I/AAAAAAAAA78/k9B6dgIskY4/S220/IMG_0040.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_x81YABKRdos/TLiBV9YnfeI/AAAAAAAAA8s/4zBXIGLIp50/s72-c/mapWithTracking.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-5851171900420350722</id><published>2010-10-13T11:08:00.006-04:00</published><updated>2011-04-27T07:54:58.171-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mobile'/><category scheme='http://www.blogger.com/atom/ns#' term='HTML5'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='android'/><title type='text'>Geolocation through Javascript</title><content type='html'>Navigation, through geolocation...the one of the many key pieces that makes a mobile device indispensible.&lt;br /&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif; font-size: 13px; line-height: 19px;"&gt;&lt;b&gt;Geolocation&lt;/b&gt;&amp;nbsp;is the identification of the real-world geographic location of an object, such as a cell phone or an&amp;nbsp;&lt;a href="http://en.wikipedia.org/wiki/Internet" style="background-attachment: initial; background-clip: initial; background-color: initial; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: #0645ad; text-decoration: none;" title="Internet"&gt;Internet&lt;/a&gt;-connected computer terminal. Geolocation may refer to the practice of assessing the location, or to the actual assessed location.&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;a href="http://en.wikipedia.org/wiki/Geolocation"&gt;http://en.wikipedia.org/wiki/Geolocation&lt;/a&gt;&lt;/blockquote&gt;Developers use many techniques to retrieve this information. Navigation tools being some of the top selling and most demanded applications available. The &lt;a href="http://en.wikipedia.org/wiki/W3C_Geolocation_API"&gt;W3C Geolocation API&lt;/a&gt;&amp;nbsp;makes finding our location through the web browser as simple as a line in javascript. We no longer require a dedicated and complex application for our positioning.&lt;br /&gt;&lt;br /&gt;This article is going to focus on retrieving the latitude and longitude through Javascript. Then we'll update a web page with a map. &lt;br /&gt;&lt;br /&gt;To begin with the following navigator object has the methods to return our position. Add this to an init or window.load function in your javascript.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;navigator.geolocation.getCurrentPosition(someMapFunction, errorHandler, {timeout:x});&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;This returns a one time location. To keep the position updated, use:&lt;br /&gt;&lt;code&gt;window.onload = function() { navigator.geolocation.watchPosition(someMapFunction, errorHandler, {timeout:x});}&lt;/code&gt;&lt;br /&gt;&lt;i&gt;An aside here on the {timeout:}. The error handling seems to be worthless because the position keeps trying to happen. An error will never occur. Adding a timeout will stop the page and your error trap function will fire.&lt;/i&gt;&lt;br /&gt;&lt;code&gt;// essential error handlingfunction error(e){ alert(e.code + ": " + e.message); }function displayMap(location) { var lat = location.coords.latitude; var lon = location.coords.longitude;         // for stress free implementation, just update an iFrame var map = document.getElementById('mappy'); map.src = ... url to embedded map ...}&lt;/code&gt;When testing the positioning tools out on a desktop browser it has been a little hit-or-miss recently. There is a good deal of comments on the internets about this issue and the usual debate of "it's a bug" vs. "that's how it's supposed to work." For the purposes here then, lets assume you're building this for a mobile application. I have added in a few essential tags to a simple HTML page for rendering on mobile device (my iPhone at the moment). &lt;code&gt;&amp;lt;meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" /&amp;gt;&lt;/code&gt; was added into the html head.Then the only tag in the html body is an iFrame.&lt;code&gt;&amp;lt;iframe id="mappy" width="100%" height="100%" src=""&amp;gt;... placeholder ...&amp;lt;/iframe&amp;gt;&lt;/code&gt;The embedded map can be pretty much any of the available maps, Google, Yahoo, MapQuest, etc. I chose to be less cliche and embed &lt;a href="http://www.openstreetmap.org/"&gt;Open Street Map&lt;/a&gt;. The result is a very usable web based map application on a mobile device.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_x81YABKRdos/TLXJ2BHwM1I/AAAAAAAAA8c/O97W681G1H4/s1600/iphone-map.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://1.bp.blogspot.com/_x81YABKRdos/TLXJ2BHwM1I/AAAAAAAAA8c/O97W681G1H4/s320/iphone-map.png" width="213" /&gt;&lt;/a&gt;&lt;/div&gt;If you would like to see the application in action, visit &lt;a href="http://qrencodr.appspot.com/geolocate.html"&gt;http://qrencodr.appspot.com/geolocate.html&lt;/a&gt;&amp;nbsp;from your smartphone. &lt;b&gt;Results of using this web app in a desktop browser are dodgy at best, works mostly fine on mobile though.&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;For the full source code in this article, either view source from the above link or &lt;a href="https://sites.google.com/site/gjwprojekt/experiments/geolocate.html"&gt;download directly&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;In the next article, we'll be using the geolocation data to update and track our position.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-5851171900420350722?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/5851171900420350722/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=5851171900420350722' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/5851171900420350722'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/5851171900420350722'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2010/10/geolocation-through-javascript.html' title='Geolocation through Javascript'/><author><name>Garrett</name><uri>http://www.blogger.com/profile/10157693937724512283</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_x81YABKRdos/TLJ-J9pnH1I/AAAAAAAAA78/k9B6dgIskY4/S220/IMG_0040.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_x81YABKRdos/TLXJ2BHwM1I/AAAAAAAAA8c/O97W681G1H4/s72-c/iphone-map.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-3380002443473617392</id><published>2010-10-10T21:55:00.009-04:00</published><updated>2010-10-12T14:25:45.404-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='qr codes'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>QR Code Generation</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_x81YABKRdos/TLJwCfzDsxI/AAAAAAAAA7Y/MI1ghEJ8Hlw/s1600/qr-RII.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 230px; height: 230px;" src="http://1.bp.blogspot.com/_x81YABKRdos/TLJwCfzDsxI/AAAAAAAAA7Y/MI1ghEJ8Hlw/s320/qr-RII.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5526602880934720274" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Without getting into a major definition of &lt;span style="font-style:italic;"&gt;what&lt;/span&gt; a QR code actually is, let me simply refer you to &lt;a href="http://en.wikipedia.org/wiki/QR_Code"&gt;Wikipedia&lt;/a&gt;. These things are ultra-convenient, put them on a business card to contain all your contact information or direct someone to a URL. One can use any device with a QR scanner to read these codes. &lt;br /&gt;&lt;br /&gt;While this isn't exactly everywhere here in the US _yet_ it has an amazing potential. What can we do as a developer then? Start using this everywhere and adding it to work.&lt;br /&gt;&lt;br /&gt;Lets look then at how to build a super simple application to generate QR codes through the &lt;a href="http://code.google.com/apis/chart/docs/http://code.google.com/apis/chart/"&gt;Google Charts API&lt;/a&gt;. Through an amazingly simple querystring builder one can generate these codes in any application. So...to start, lets build a QR generator with just a generic HTML form.&lt;br /&gt;&lt;br /&gt;First off Google tells us we need to build a querystring as follows...&lt;br /&gt;&lt;br /&gt;&lt;code&gt;http://chart.apis.google.com/chart?cht=&lt;i&gt;chart_type&lt;/i&gt;&amp;amp;ampchs=&lt;i&gt;chartsize&lt;/i&gt;&amp;amp;chl=&lt;i&gt;data_to_qrEncode&lt;/i&gt;&lt;/code&gt;&lt;br /&gt;Through a simple HTML form, using GET we can build this string on this in a few seconds.&lt;br /&gt;&lt;code&gt;&amp;lt;form method="get" action="http://chart.apis.google.com/chart"&amp;gt;&lt;br /&gt;&amp;lt;!-- note value as QR --&amp;gt;&lt;br /&gt;&amp;lt;input type="hidden" name="cht" value="qr" /&amp;gt; &lt;br /&gt;&amp;lt;!-- create a 230 x 230 image --&amp;gt;&lt;br /&gt;&amp;lt;input type="hidden" name="chs" value="230x230" /&amp;gt; &lt;br /&gt;Text to Encode: &amp;lt;input type="text" name="chl" / &amp;gt;&lt;br /&gt;&amp;lt;input type="submit" /&amp;gt;&lt;br /&gt;&amp;lt;/form&amp;gt;&lt;/code&gt;&lt;br /&gt;Quick and simple right? We'll build on this further in the coming days and look at ways of integrating this into a C++ application, Java and possibly Objective-C.  In the mean time, here's a usable demo of the above form.&lt;br /&gt;&lt;fieldset&gt;&lt;legend&gt;QR Generator&lt;/legend&gt;&lt;br /&gt;&lt;form method="get" action="http://chart.apis.google.com/chart"&gt;&lt;input type="hidden" name="cht" value="qr"&gt;&lt;input type="hidden" name="chs" value="230x230"&gt;Enter Text to Encode: &lt;input type="text" name="chl"&gt;&lt;input type="submit"&gt;&lt;/form&gt;&lt;/fieldset&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-3380002443473617392?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/3380002443473617392/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=3380002443473617392' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/3380002443473617392'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/3380002443473617392'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2010/10/qr-code-generation-without-getting-into.html' title='QR Code Generation'/><author><name>Garrett</name><uri>http://www.blogger.com/profile/10157693937724512283</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_x81YABKRdos/TLJ-J9pnH1I/AAAAAAAAA78/k9B6dgIskY4/S220/IMG_0040.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_x81YABKRdos/TLJwCfzDsxI/AAAAAAAAA7Y/MI1ghEJ8Hlw/s72-c/qr-RII.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-4343555937061906912</id><published>2009-03-20T21:15:00.000-04:00</published><updated>2009-03-20T21:15:58.704-04:00</updated><title type='text'></title><content type='html'>&lt;div style="TEXT-ALIGN: center; MARGIN: 0px auto 10px"&gt;Flying lesson, practiced stalls, slow flight and landings. Flew at 8500 MSL around SW of JST for about 1.6 today. First time practicing stalls and first time above the cloud cover.&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_6uoMreCmwbU/ScQ_yz6fRhI/AAAAAAAAB6g/TTT_pCwRST0/s1600-h/Photo_032009_002.jpg"&gt;&lt;img border="0" alt="" src="http://1.bp.blogspot.com/_6uoMreCmwbU/ScQ_yz6fRhI/AAAAAAAAB6g/TTT_pCwRST0/s320/Photo_032009_002.jpg" /&gt;&lt;/a&gt; &lt;/div&gt;&lt;br /&gt;&lt;div style="TEXT-ALIGN: center; MARGIN: 0px auto 10px"&gt;&lt;a href="http://2.bp.blogspot.com/_6uoMreCmwbU/ScQ_zjxNETI/AAAAAAAAB6o/YC7FKMf3F2E/s1600-h/Photo_032009_001.jpg"&gt;&lt;img border="0" alt="" src="http://2.bp.blogspot.com/_6uoMreCmwbU/ScQ_zjxNETI/AAAAAAAAB6o/YC7FKMf3F2E/s320/Photo_032009_001.jpg" /&gt;&lt;/a&gt; &lt;/div&gt;&lt;div style='clear:both; text-align:CENTER'&gt;&lt;a href='http://picasa.google.com/blogger/' target='ext'&gt;&lt;img src='http://photos1.blogger.com/pbp.gif' alt='Posted by Picasa' style='border: 0px none ; padding: 0px; background: transparent none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;' align='middle' border='0' /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-4343555937061906912?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/4343555937061906912/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=4343555937061906912' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/4343555937061906912'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/4343555937061906912'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2009/03/flying-lesson-practiced-stalls-slow.html' title=''/><author><name>garrett wyrwas</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_6uoMreCmwbU/ScQ_yz6fRhI/AAAAAAAAB6g/TTT_pCwRST0/s72-c/Photo_032009_002.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-8799490683328174433</id><published>2008-11-10T13:05:00.009-05:00</published><updated>2010-10-15T08:52:03.983-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Bubblesort Multidimensional Array in Java</title><content type='html'>This quick work around will allow for an easy an "efficient" sort of a multidimensional array in Java. Simply pass your array in and the index you'd like to sort on.&lt;br /&gt;&lt;div&gt;Although there are other solutions to this, using java's builtin Arrays.sort method won't cut it. I put together this code to be called as a private method within your application. Enjoy!&lt;/div&gt;&lt;br /&gt;This works great when using a String[][] compare. If you are trying to sort integers, simply change your array and take out the if (...compareTo...) business and just check which is greater.&lt;br /&gt;&lt;code&gt; private String[][] bubbleSortMulti(String[][] MultiIn, int compIdx) {      String[][] temp = new String[MultiIn.length][MultiIn[0].length];      boolean finished = false;      while (!finished) {        finished = true;        for (int i = 0; i &amp;lt; MultiIn.length - 1; i++) {           if (MultiIn[i][compIdx].compareToIgnoreCase(MultiIn[i + 1][compIdx]) &amp;gt; 0) {             for (int j = 0; j &amp;lt; MultiIn[i].length; j++) {                temp[i][j] = MultiIn[i][j];                MultiIn[i][j] = MultiIn[i + 1][j];                MultiIn[i + 1][j] = temp[i][j];             }             finished = false;           }         }      }      return MultiIn;   }  &lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-8799490683328174433?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/8799490683328174433/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=8799490683328174433' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/8799490683328174433'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/8799490683328174433'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2008/11/bubblesort-multidimensional-array-in.html' title='Bubblesort Multidimensional Array in Java'/><author><name>garrett wyrwas</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-1953029095512263811</id><published>2008-08-28T14:07:00.006-04:00</published><updated>2008-08-28T14:26:36.243-04:00</updated><title type='text'>Corporate do-gooder</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_6uoMreCmwbU/SLbtFokKSLI/AAAAAAAAAzs/PGlk3Xnpvr8/s1600-h/132228195207_651409.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://1.bp.blogspot.com/_6uoMreCmwbU/SLbtFokKSLI/AAAAAAAAAzs/PGlk3Xnpvr8/s320/132228195207_651409.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5239635897536366770" /&gt;&lt;/a&gt;&lt;br /&gt;A very talented team of coworkers (&lt;a href="http://www.kevinslonka.com"&gt;Kevin&lt;/a&gt;, Diane and Adam) along with my constant meticulous badgering launched a new website for the &lt;a href="http://www.uwlaurel.org"&gt;United Way of the Laurel Highlands&lt;/a&gt;. The site was a voluntary project outside of our normal day to day. &lt;br /&gt;&lt;br /&gt;Technologically, the site is PHP with mySQL using &lt;b&gt;mod_rewrite&lt;/b&gt; to clean the URLs and &lt;b&gt;mod_cache&lt;/b&gt; for, well, caching. I'll follow with a mod_rewrite tutorial someday. For now check out &lt;a href="http://www.uwlaurel.org"&gt;uwlaurel.org&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-1953029095512263811?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/1953029095512263811/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=1953029095512263811' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/1953029095512263811'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/1953029095512263811'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2008/08/corporate-do-gooder.html' title='Corporate do-gooder'/><author><name>garrett wyrwas</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_6uoMreCmwbU/SLbtFokKSLI/AAAAAAAAAzs/PGlk3Xnpvr8/s72-c/132228195207_651409.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-3484468151871893737</id><published>2008-07-31T09:20:00.005-04:00</published><updated>2011-04-27T08:50:52.629-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><category scheme='http://www.blogger.com/atom/ns#' term='semantic web'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Building a Web Service with Java, Jena and mySQL [Part 4.1] - SPARQL Update</title><content type='html'>Now that &lt;a href="http://prdownloads.sourceforge.net/jena/Jena-2.5.6.zip?download"&gt;Jena 2.5.6&lt;/a&gt; supports updates directly through SPARQL, Part 4 of this tutorial is deprecated. We no longer need to use multiple methods to run the insert, update and delete utilities. Instead you can use some of the &lt;a href="http://jena.hpl.hp.com/~afs/SPARQL-Update.html"&gt;new SPARQL awesomeness&lt;/a&gt; to do that work. &lt;br /&gt;&lt;br /&gt;You may want to determine which route you're going to take. If you use the methods from Part 4 you have more control of what is being passed to Jena. Additionally, you're controlling the triple store and models directly instead of letting SPARQL do the work. It's your call.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;import com.hp.hpl.jena.query.QuerySolutionMap;&lt;br /&gt;import com.hp.hpl.jena.update.UpdateAction;&lt;br /&gt;...&lt;br /&gt;public static boolean sparqlUpdater(String query, String modelName) throws Exception {&lt;br /&gt;  IDBConnection dbcon = initDBStore(M_DB_URL, M_DB_USER, M_DB_PASSWD, M_DB_TYPE, &lt;br /&gt;    CLEAN_DB);&lt;br /&gt;  ModelMaker maker = initModel(dbcon);&lt;br /&gt;  Model model = maker.openModel(modelName);&lt;br /&gt;&lt;br /&gt;  // the UpdateAction obj does all the hard work now.&lt;br /&gt;  // there is a slight bug in this version of Jena that requires the new &lt;br /&gt;  //  QuerySolutionMap obj created. I believe this is fixed in the SVN.&lt;br /&gt;  UpdateAction.parseExecute(query, model, new QuerySolutionMap());&lt;br /&gt;  model.close();&lt;br /&gt;  maker.close();&lt;br /&gt;  dbcon.close();&lt;br /&gt;  return true;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Obviously, surround that in some try/catch business and remember this requires Jena 2.5.6 (newest version at the time of this writing.) So get that in your -classpath and get rid of the old stuff. This should greatly simplify &lt;a href="http://en.wikipedia.org/wiki/Create%2C_read%2C_update_and_delete"&gt;CRUD&lt;/a&gt; activities with Jena persistent store. One other thing to note, although you can use a SPARQL select through this method, I wouldn't. This only returns a boolean whereas our sparqlSelect() method returned a &lt;code&gt;String[][]&lt;/code&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-3484468151871893737?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/3484468151871893737/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=3484468151871893737' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/3484468151871893737'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/3484468151871893737'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2008/07/building-web-service-with-java-jena-and_31.html' title='Building a Web Service with Java, Jena and mySQL [Part 4.1] - SPARQL Update'/><author><name>garrett wyrwas</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-7920776478215669386</id><published>2008-07-28T08:53:00.008-04:00</published><updated>2010-10-12T13:43:15.038-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Scala'/><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Fibonacci'/><title type='text'>Scala: Fibonacci Revisited and Recursed</title><content type='html'>Building on the previous Fibonacci number function, we have some more Scala specific tools available at our disposal. In the &lt;a href="http://realityisimportant.blogspot.com/2008/07/java-to-scala-well-do-it-live.html"&gt;previous&lt;/a&gt; example, I basically did a verbatim duplication of Java to Scala. &lt;br /&gt;This post builds on the same Fibonacci function using the Scala &lt;b&gt;match&lt;/b&gt;. &lt;b&gt;match&lt;/b&gt; is a Scala implementation of the Java &lt;b&gt;switch&lt;/b&gt; statement. Additionally, &lt;b&gt;match&lt;/b&gt; is available for all objects instead of just an &lt;i&gt;int, char, byte&lt;/i&gt; and &lt;i&gt;short&lt;/i&gt;.&lt;br /&gt;&lt;b&gt;Tree Recursion&lt;/b&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;def fibonacci(num: Int): Int= {&lt;br /&gt;  num match {&lt;br /&gt;    case 0 =&gt; 0&lt;br /&gt;    case 1 =&gt; 1&lt;br /&gt;    case _ =&gt; fibonacci(num-1) + fibonacci(num-2)&lt;br /&gt;  }&lt;br /&gt;}&lt;/code&gt;&lt;br /&gt;This should be relatively straightforward right? One new token that appears in this example is the use of &lt;b&gt;_&lt;/b&gt;. The underscore in Scala is a wildcard character and in this &lt;b&gt;case&lt;/b&gt; example gives us an 'all others' or 'default' to match. The underscore can also be used in your imports.&lt;br /&gt;&lt;b&gt;Java&lt;/b&gt;&lt;div class="mycode"&gt;import java.io.*;&lt;/div&gt;&lt;br /&gt;&lt;b&gt;Scala&lt;/b&gt;&lt;div class="mycode"&gt;import java.io._&lt;/div&gt;&lt;br /&gt;Functional languages lend themselves toward recursion rather than looping. Our Fibonacci number method is a recursive function but could make better use of the Scala compiler as tail recursion. Tail recursion will optimize the threads needed for each iteration of our method. &lt;br /&gt;&lt;b&gt;Tail Recursion&lt;/b&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;def fibonacci(num: Int) = fibonacciTR(num, 1, 0)&lt;br /&gt;&lt;br /&gt;def fibonacciTR(num: Int, nxt: Int, res: Int): Int= {&lt;br /&gt;  num match {&lt;br /&gt;    case 0 =&gt; res&lt;br /&gt;    case _ =&gt; fibonacciTR(num-1, nxt+res, nxt)&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;The tail recursion is a good deal more gentle than the tree recursion method. In your journeys toward functional programming put aside what you know about iteration and looping and look at how recursion can do the work for you.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-7920776478215669386?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/7920776478215669386/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=7920776478215669386' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/7920776478215669386'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/7920776478215669386'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2008/07/scala-fibonacci-revisited-and-recursed.html' title='Scala: Fibonacci Revisited and Recursed'/><author><name>garrett wyrwas</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-2800569183887285356</id><published>2008-07-18T09:54:00.005-04:00</published><updated>2010-10-11T06:34:39.704-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Scala'/><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='recursion'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Java to Scala: We'll do it live!</title><content type='html'>Today begins a disjointed tutorial on &lt;a href="http://www.scala-lang.org"&gt;Scala&lt;/a&gt;. For those of you out there that think functional programming is just plain awful, I don't blame you. I am no advocate of &lt;a href="http://www.ruby-lang.org"&gt;Ruby&lt;/a&gt; or it's ilk but Scala feels and looks different, especially for a Java programmer. &lt;br /&gt;&lt;br /&gt;It's different because it natively inherits all of Java's classes and has interoperability without all the garbage. There are plenty of discussions about this available so it's not necessary to duplicate one here. Lets just say that inferred typed variables feels nice for a change. I thought that PHP was messy because variables did not need typed and this was one of the strict things about Java that I liked. Each day I like it less and less. Why for instance does one need to define the primitive types like &lt;b&gt;String var = " ";&lt;/b&gt; when it is quite obvious that it is a string there in those quotes? Scala can just infer this is a string without the hand-holding &lt;b&gt;var = " "&lt;/b&gt;. &lt;br /&gt;&lt;br /&gt;Oh and no trailing semi-colon; that was no typo. It is not necessary when the line ending is obvious.&lt;br /&gt;&lt;br /&gt;I'm going to go against the grain of the computer overlords and not demonstrate 'Hello, World!' application. Instead lets do something fun, that everyone loves, recursion. Well not just any recursion, Fibonacci numbers. &lt;br /&gt;&lt;b&gt;Java&lt;/b&gt;&lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;public int fibonacci(int num) {&lt;br /&gt;   return num &lt;=1 ? num : &lt;span style="font-style:italic;"&gt;fibonacci&lt;/span&gt;(num-1) + &lt;span style="font-style:italic;"&gt;fibonacci&lt;/span&gt;(num-2);&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Now we're going to do a direct conversion to Scala. If you read the &lt;a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"&gt;language ref&lt;/a&gt;, there is no ternary condition so we have to go with if-else. There is a really cool reason for this, however. In Scala we can use one expression and use the if-else to compare it. More on this if necessary.&lt;br /&gt;&lt;b&gt;Scala&lt;/b&gt;&lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;def fibonacci(num: int): int= {&lt;br /&gt;  if (num&lt;=1) return num&lt;br /&gt;  else &lt;br /&gt;     return fibonacci(num-1) + fibonacci(num-2)&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Those of us with a C background may have thrown up a little bit in your throat looking at that. Relax, it's easy to follow. &lt;b&gt;def&lt;/b&gt; defines our method, &lt;b&gt;num: int&lt;/b&gt; says we're accepting an integer param and &lt;b&gt;int= { }&lt;/b&gt; says we're returning an int type. Simple right? We'll move on in future discussions to web frameworks for Scala.&lt;br /&gt;&lt;br /&gt;This is just a !HelloWorld Scala intro example. I hope this gives a brief introduction. More will follow sporadically.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-2800569183887285356?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/2800569183887285356/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=2800569183887285356' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/2800569183887285356'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/2800569183887285356'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2008/07/java-to-scala-well-do-it-live.html' title='Java to Scala: We&apos;ll do it live!'/><author><name>garrett wyrwas</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-289838310166115766</id><published>2008-07-10T13:42:00.009-04:00</published><updated>2010-10-12T14:35:21.394-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>How to Write a Text File in Java</title><content type='html'>This is a relatively straight forward tutorial on writing text to a file in Java. This question comes up for every coder at some time. Most languages have a quick and easy way to solve this. In Java you can use the &lt;a href="http://java.sun.com/j2se/1.4.2/docs/api/java/io/BufferedWriter.html"&gt;bufferedwriter&lt;/a&gt; object to do the work for you. You can also determine if the data should be appended to the file or the file should be overwritten.In a nutshell this can be done in a very few lines.&lt;code&gt;import java.io.*;class FileWriteTest {public static void main(String[] args) throws IOException {BufferedWriter bw;bw = new BufferedWriter(new FileWriter("filepath",true));bw.write("Hello World!");bw.close();}}&lt;/code&gt;That is it. Notice in the boolean value in FileWriter? Set to &lt;b&gt;true&lt;/b&gt; data is appended to your file, set to &lt;b&gt;false&lt;/b&gt;, you're starting with clean file.Lets extend this to an activity log, I used this in the Jena Web Service to monitor usage. We can talk about other potentially more preferred log methods in Java later but this can be useful for anyone as a quick maintenance utility.&lt;code&gt;static void activityLog(String logData) {try {BufferedWriter out = new BufferedWriter(new FileWriter(filePath+ "jenaWebService.log", true)); // we're appending dataout.write(logData + "\n"); out.close();} catch (Exception e) {System.err.println(e.getMessage());}}&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-289838310166115766?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/289838310166115766/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=289838310166115766' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/289838310166115766'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/289838310166115766'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2008/07/how-to-write-text-file-in-java.html' title='How to Write a Text File in Java'/><author><name>garrett wyrwas</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-6398810551654991147</id><published>2008-07-03T08:39:00.008-04:00</published><updated>2010-10-11T06:34:39.706-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Building a Web Service with Java, Jena and mySQL [Part 4]</title><content type='html'>&lt;span style="font-style:italic;"&gt;&lt;span style="font-weight:bold;"&gt;Author's note : This has been replaced by &lt;a href="http://realityisimportant.blogspot.com/2008/07/building-web-service-with-java-jena-and_31.html"&gt;Part 4.1&lt;/a&gt; of this tutorial. It remains here for reference. It still works, it's just deprecated.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Well we've reached the end of the Jena Web Service, renamed to JAWS. This is now an official Google Code project. More on this to come.&lt;br /&gt;&lt;br /&gt;Today we're going to add an a way to insert, delete and update, yes update data back into the triple store. &lt;br /&gt;&lt;br /&gt;In order to insert data, one would need to post an entire triple. That is: subject, predicate, object.  The best way to do this is to add objects and predicates to an existing subject. This ensures everything matches up in the Jena persistent store. Additionally the way the store accepts a predicate is through a URI, formatted as a URI. &lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;@deprecated&lt;br /&gt;public static boolean &lt;del&gt;insertTriple&lt;/del&gt;(String resourceURI, String predicateURI,&lt;br /&gt; String subject, String predicate, String object) {&lt;br /&gt; ModelMaker maker = initDBStore(M_DB_URL, M_DB_USER, M_DB_PASSWD,&lt;br /&gt;          M_DB_TYPE, CLEAN_DB);&lt;br /&gt; Model model = maker.openModel(M_NAME, false);&lt;br /&gt; model.begin();&lt;br /&gt; Resource resource = model.createResource(resourceURI + "/"&lt;br /&gt;  + subject);&lt;br /&gt; Property property = model.createProperty(predicateURI, predicate);&lt;br /&gt;  resource.addProperty(property, object);&lt;br /&gt; model.commit();&lt;br /&gt; return true;&lt;br /&gt;}&lt;/div&gt;&lt;br /&gt;The next major important utility for managing the triples is a delete method. Delete is very particular, requiring fully qualified URIs for each part of the triple. Additionally, you can delete entire subjects, predicates or object by &lt;span style="font-style:italic;"&gt;&lt;span style="font-weight:bold;"&gt;null&lt;/span&gt;&lt;/span&gt;ing any of the parameters. &lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;@deprecated&lt;br /&gt;public static void &lt;del&gt;deleteTriple&lt;/del&gt;(String subject, String predicate,&lt;br /&gt; String object, String modelName) {&lt;br /&gt; ModelMaker maker = initDBStore(M_DB_URL, M_DB_USER, M_DB_PASSWD,&lt;br /&gt;  M_DB_TYPE, CLEAN_DB);&lt;br /&gt; Model model = maker.openModel(modelName);&lt;br /&gt; model.begin();&lt;br /&gt; Resource sub = (subject != null) ? model.getResource(subject)&lt;br /&gt;  : null;&lt;br /&gt; Property pred = (predicate != null) ? model.getProperty(predicate)&lt;br /&gt;  : null;&lt;br /&gt; if (sub != null &amp;&amp; pred != null) {&lt;br /&gt;  StmtIterator iter = model.listStatements(new SimpleSelector(&lt;br /&gt;   sub, pred, (RDFNode) null));&lt;br /&gt;  while (iter.hasNext()) {&lt;br /&gt;   Statement s = iter.nextStatement();&lt;br /&gt;   // The only decent way to match an object without killing&lt;br /&gt;   // resources&lt;br /&gt;   // ////////////&lt;br /&gt;   if (s.getObject().toString().equals(object))&lt;br /&gt;    iter.remove();&lt;br /&gt;   if (object == null)&lt;br /&gt;    iter.remove();&lt;br /&gt;  }&lt;br /&gt;         }&lt;br /&gt;         return true;&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;On the rare occasion that you may want to actually update a triple from the store, just use the above methods and verify the returns are &lt;span style="font-weight:bold;"&gt;&lt;span style="font-style:italic;"&gt;true&lt;/span&gt;&lt;/span&gt; along the way. Again, the :s :p :o must be fully qualified. Feel free to modify as you see fit.&lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;@deprecated&lt;br /&gt;public static boolean &lt;del&gt;updateTriple&lt;/del&gt;(String subject, String predicate,&lt;br /&gt; String object, String newObject, String modelName) {&lt;br /&gt;  if (deleteTriple(subject, predicate, object, modelName))&lt;br /&gt;   if (insertTriple(subject, predicate, newObject, modelName))&lt;br /&gt;    System.out.println("Update Completed :" + subject + " :" &lt;br /&gt;        + PREDICATE_URI + predicate + " :" + newObject + " [" + modelName + "]");&lt;br /&gt;    return true;&lt;br /&gt;   } else {&lt;br /&gt;    return false;&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Well there it is, the final method. Here is the entire Jena Web Service. Remember there is no main(), this expects to run as a web service as a &lt;span style="font-style:italic;"&gt;&lt;span style="font-weight:bold;"&gt;.jws&lt;/span&gt;&lt;/span&gt; file on Apache Axis 1. In later posts we'll talk about extending this service, overloading the methods and adding business logic. This will be done under Axis2.&lt;br /&gt;&lt;a href="http://kilsoft.googlepages.com/Jaws.java"&gt;&lt;blockquote&gt;Jaws.java&lt;/blockquote&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-6398810551654991147?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/6398810551654991147/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=6398810551654991147' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/6398810551654991147'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/6398810551654991147'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2008/07/building-web-service-with-java-jena-and.html' title='Building a Web Service with Java, Jena and mySQL [Part 4]'/><author><name>garrett wyrwas</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-451091851121638814</id><published>2008-06-16T07:56:00.006-04:00</published><updated>2011-04-27T08:51:13.478-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Detect OS in Java</title><content type='html'>I realize we're still sidetracked from the Jena tutorial, more will be forthcoming. This is a small part of the next section where we are going to be building a log utility for our Jena web service. &lt;br /&gt;&lt;br /&gt;For today here is a quick way to determine the operating system in Java. This is effective for putting a path to your file writes.&lt;br /&gt;&lt;br /&gt;First set your &lt;a href="http://lopica.sourceforge.net/os.html"&gt;os.name&lt;/a&gt; to a String. See the link for an entire list of what you can get back. We're not going to be looking for a very specific OS here, just check if it's Windows or not.&lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;String osName = system.getProperty("os.name");&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;That is pretty much it, you can write out your value now to see what you get. Here is a quick way of creating a path to a file based on your os.&lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;String filePath = osName.toUpperCase().indexOf("WINDOWS") == 0 ? "x:/"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;: "/lin/ux/Path/";&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;I used the &lt;a href="http://en.wikipedia.org/wiki/%3F:"&gt;ternary operation&lt;/a&gt; there to keep it quick. The above statement basically says "Does our osName in all caps have the string WINDOWS in it? yes? make the path x:/. no? make the path /lin/ux/Path." &lt;br /&gt;&lt;br /&gt;You can do whatever you want once you have your os depending on what you're looking for.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-451091851121638814?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/451091851121638814/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=451091851121638814' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/451091851121638814'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/451091851121638814'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2008/06/detect-os-in-java.html' title='Detect OS in Java'/><author><name>garrett wyrwas</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-184470974107631276</id><published>2008-06-11T07:29:00.007-04:00</published><updated>2011-04-27T08:50:52.630-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><category scheme='http://www.blogger.com/atom/ns#' term='semantic web'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Building a Web Service with Java, Jena and mySQL [Part 3]</title><content type='html'>Welcome to part three of the &lt;a href="http://jena.sourceforge.com/"&gt;Jena&lt;/a&gt; Web Service tutorial, aptly named JAWS.  In &lt;a href="http://realityisimportant.blogspot.com/2008/06/building-web-service-with-java-jena-and.html"&gt;part one&lt;/a&gt; and &lt;a href="http://realityisimportant.blogspot.com/2008/06/building-web-service-with-java-jena-and_06.html"&gt;part two&lt;/a&gt; of this tutorial we covered the basics with a Java web service. At this point, you should be familiar with the Jena API and already experimenting with your own ways of working with it.&lt;br /&gt;This part of the tutorial is by far the largest method. We are going to build an engine to perform &lt;a href="http://www.w3.org/TR/rdf-sparql-query/"&gt;SPARQL&lt;/a&gt; queries.&lt;br /&gt;&lt;br /&gt;You can get all (a little) of the information you may need on SPARQL with a few searches. If necessary we can discuss how it works in subtle detail post-tutorial.  We know that SPARQL is an effective, yet simplified way to query RDF. Because RDF = triples = the way Jena stores data, we can use SPARQL to pull our data.&lt;br /&gt;&lt;br /&gt;Since the data will be pulled out into a web service, a multi dimensional array seems most effective here as a return type. Also, this method is specifically written with the assumption that SPARQL is one-directional, that is read-only. In the next tutorial we will cover the insert, update, delete functions not through SPARQL but through Jena's methods.&lt;br /&gt;&lt;br /&gt;The first part of the method assigns a name sparqlSelect and looks for two passed parameters.  The first is the actual SPARQL query formatted as a string and the second is the Jena model that you created earlier and loaded data into. We also see the String[][] return type. This is means all of our returned data will be stored in this format. For details on how to parse this type of data see my earlier post &lt;a href="http://realityisimportant.blogspot.com/2008/06/how-to-read-and-write-multi-dimensional.html"&gt;How to Read Multi-dimensional Arrays in Java&lt;/a&gt;.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;public static String[][] sparqlSelect(String query, String modelName) {&lt;br /&gt;// open model here&lt;br /&gt;Query sql = QueryFactory.create(query);&lt;br /&gt;QueryExecution qexec = QueryExecutionFactory.create(sql, model);&lt;br /&gt;// next line assumes we are running a SELECT query (very intuitive).&lt;br /&gt;ResultSet results = qexec.execSelect();&lt;br /&gt;// this next little object will let us move around through the results.&lt;br /&gt;ResultSetRewindable rsw = ResultSetFactory.makeRewindable(results);&lt;br /&gt;// ... not done yet ...&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Next, we retrieve the variables we queried for into the resultVars ArrayList. This keeps the method dynamic and as a web service you don't want to have to know what is being passed to you, just how to work with it. One could parse this out of the SPARQL but you are better off reading in the results rather than making assumptions about the results. We loop through the results adding them to our ArrayList so we know how big to make our soon to be born multidimensional array.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;br /&gt;// ... continued ...&lt;br /&gt;&lt;br /&gt;// get the result variables passed from the SQL statement&lt;br /&gt;// and parse them into a list for later retrieval.&lt;br /&gt;// typically s,p,o could be more could be less&lt;br /&gt;ArrayList&amp;lt;string&amp;gt; resultVars = new ArrayList&amp;lt;string&amp;gt;();&lt;br /&gt;&lt;br /&gt;int k = 0;&lt;br /&gt;for (Iterator j = results.getResultVars().iterator(); j.hasNext();) {&lt;br /&gt;resultVars.add(k, j.next().toString());&lt;br /&gt;k++;&lt;br /&gt;}&lt;br /&gt;// ... not done yet ...&lt;/code&gt;&lt;br /&gt;In the closing parts of the method, we will be declaring our array. The first line in this part sets the array dimensions into a new variable tripleOut. This will ultimately be our returned variable. Next, we set a counter and loop through our results.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;br /&gt;String[][] tripleOut = new String[rsw.size()][resultVars.size()];&lt;br /&gt;int m = 0;&lt;br /&gt;while (rsw.hasNext()) {&lt;br /&gt;// get next statement&lt;br /&gt;QuerySolution rs = rsw.nextSolution(); &lt;br /&gt;for (int i = 0; i &amp;lt; resultVars.size(); i++) {&lt;br /&gt;tripleOut[m][i] = rs.get(resultVars.get(i)).toString();&lt;br /&gt;}&lt;br /&gt;m++;&lt;br /&gt;}&lt;/code&gt;&lt;br /&gt;If you don't like the idea of returning a multidimensional array, return something else. Keep in mind though that if you're working with this as a web service you are limited in how (not what) you can return. This part of the tutorial can be expanded on numerous ways as we will see later when we extend this and query an inferred model.&lt;br /&gt;&lt;br /&gt;Here is part three organized into a Java file. Please note if you want to run this as a Java class you will need to add a main method in. This article intends the files to be run as a web service.&lt;br /&gt;&lt;a href="http://kilsoft.googlepages.com/JawsPart3.java"&gt;&lt;blockquote&gt;JawsPart3.java&lt;/blockquote&gt;&lt;/a&gt;In the next part our the tutorial, we will put in the insert, update and delete methods for our triple store.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-184470974107631276?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/184470974107631276/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=184470974107631276' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/184470974107631276'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/184470974107631276'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2008/06/building-web-service-with-java-jena-and_11.html' title='Building a Web Service with Java, Jena and mySQL [Part 3]'/><author><name>garrett wyrwas</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-292322757973903030</id><published>2008-06-07T11:30:00.002-04:00</published><updated>2011-04-27T08:50:30.478-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><category scheme='http://www.blogger.com/atom/ns#' term='semantic web'/><category scheme='http://www.blogger.com/atom/ns#' term='rdf'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Building a Web Service with Java, Jena and mySQL [Part 2]</title><content type='html'>In &lt;a href="http://realityisimportant.blogspot.com/2008/06/building-web-service-with"&gt;part 1&lt;/a&gt; of this tutorial we looked at the basics in building a Jena web service.  With all the beginning stuff out of the way, we can move on to the more extensive and useful code.&lt;br /&gt;&lt;br /&gt;By now you should have a mysql database and have created a new model, in the database. Next, we're going to expose a small utility method to import an RDF file into your Jena persistent store.&lt;br /&gt;&lt;br /&gt;If you're consuming this web service from a remote client, using this method may take some thought. Consider that the RDF file should reside either on the same machine as the web service or perhaps as a remote URL. So, you may need to build an upload utility to post the file so this web service can find it. For this article, we can assume that the web service and the RDF file are on the same machine.&lt;div class="mycode"&gt;&lt;br /&gt;public static void loadRdf(String filename, String modelName) {&lt;br /&gt; try {&lt;br /&gt;   InputStream in = FileManager.get().open(filename);&lt;br /&gt;   if (in == null) {&lt;br /&gt;    System.err.println("File: " + filename + " not found.");&lt;br /&gt;   } else {&lt;br /&gt;    IDBConnection dbcon = initDBStore(M_DB_URL,M_DB_USER,&lt;br /&gt;     M_DB_PASSWD, M_DB_TYPE, CLEAN_DB);&lt;br /&gt;    ModelMaker maker = initModel(dbcon);&lt;br /&gt;    // create or open the default model&lt;br /&gt;    Model model = maker.openModel(modelName);&lt;br /&gt;    model.begin();&lt;br /&gt;    model.read("file:///" + filename, null);&lt;br /&gt;    model.commit();&lt;br /&gt;    model.close();&lt;br /&gt;    dbcon.close();&lt;br /&gt;    System.out.println("RDF File was loaded :" + filename + " ["&lt;br /&gt;     + modelName + "]");&lt;br /&gt;   }&lt;br /&gt; } catch (Exception e) {&lt;br /&gt;   System.out.println(e.getMessage());&lt;br /&gt; }&lt;br /&gt;}&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Now you should be able to load data into your persistent store. You can even load in OWL along with RDF. If it's valid, it should go in. This is also a good way of loading an ontology into persistent store. If you have an ontology, go ahead and load that in also.&lt;br /&gt;&lt;br /&gt;The next snippet will allow us to export an RDF from a model. Just pass in the model name as a parameter and you will have a file exported.&lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;public static boolean exportRdf(String modelName) {&lt;br /&gt; try {&lt;br /&gt;  IDBConnection dbcon = initDBStore(M_DB_URL, M_DB_USER, M_DB_PASSWD,&lt;br /&gt;   M_DB_TYPE, CLEAN_DB);&lt;br /&gt;  ModelMaker maker = initModel(dbcon);&lt;br /&gt;&lt;br /&gt;  Model m = maker.openModel(modelName);&lt;br /&gt;  OutputStream out = new FileOutputStream(modelName +".rdf");&lt;br /&gt;  &lt;br /&gt;  RDFWriter fasterWriter = m.getWriter("RDF/XML");&lt;br /&gt;   fasterWriter.write(m, out,"http://YOUR_BASE_URL");&lt;br /&gt;&lt;br /&gt;  out.close();&lt;br /&gt;  m.close();&lt;br /&gt;  maker.close();&lt;br /&gt;  dbcon.close();&lt;br /&gt;  return true;&lt;br /&gt; } catch (Exception e) {&lt;br /&gt;  System.out.println(e.getMessage());&lt;br /&gt; }&lt;br /&gt; return false;&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Now when you call the export method you should be able to output an RDF file from a model. There are numerous ways to output also. N-TRIPLES, RDF, RDF/XML-ABBREV, etc. See the &lt;a href="http://jena.sourceforge.com/"&gt;Jena&lt;/a&gt; doc for details.&lt;br /&gt;&lt;br /&gt;In part three, we will be implementing a SPARQL engine to query our data into a multi-dimensional array, something easily managed from a web service client.&lt;br /&gt;&lt;br /&gt;Here is part two organized into a Java file. Please note if you want to run this as a Java class you will need to add a main method in. This article intends the files to be run as a web service. &lt;blockquote&gt;&lt;a href="http://kilsoft.googlepages.com/JawsPart2.java"&gt;JawsPart2.java&lt;/a&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-292322757973903030?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/292322757973903030/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=292322757973903030' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/292322757973903030'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/292322757973903030'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2008/06/building-web-service-with-java-jena-and_06.html' title='Building a Web Service with Java, Jena and mySQL [Part 2]'/><author><name>garrett wyrwas</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-8495561090173115830</id><published>2008-06-06T09:23:00.009-04:00</published><updated>2011-04-27T08:50:30.479-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><category scheme='http://www.blogger.com/atom/ns#' term='semantic web'/><category scheme='http://www.blogger.com/atom/ns#' term='rdf'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Building a Web Service with Java, Jena and mySQL [Part 1]</title><content type='html'>Without getting into a huge overview of the Semantic Web world, why we need it, if we need it, etc; I am going to discuss developing for it. There can be infinite objectives with semantic data. Data mining, web crawling, tag clouds, organizational tracking, data &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_0"&gt;inference&lt;/span&gt;, wiki integration and so forth, are a few of the uses. What a developer needs to look at is how to:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;collect this data&lt;/li&gt;&lt;li&gt;make it available for whatever client may be using  the data.&lt;/li&gt;&lt;/ol&gt;Pushing step one to the back burner, one way to make semantic stores available is through a web service. A web service can provide us the interface so multiple and varying clients can use its functionality.&lt;br /&gt;&lt;br /&gt;Methods to collect the data will be in following parts as we discuss a semantic web crawler, add, update, delete methods, load from &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;RDF&lt;/span&gt; and database manipulation.&lt;br /&gt;&lt;br /&gt;For our semantic purposes we need to download &lt;a href="http://jena.sourceforge.net/"&gt;Jena&lt;/a&gt;. The Jena Semantic Web Framework is a framework &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;API&lt;/span&gt; for building semantic web applications. This framework allows us to use Jena's methods to manipulate semantic stores.  If you're developing for the semantic web, &lt;a href="http://jena.sourceforge.net/"&gt;Jena&lt;/a&gt; is the foundation.&lt;br /&gt;&lt;br /&gt;There are other components to web service development which are far beyond the scope of this article. For our purposes we're going to assume this will be running on &lt;a href="http://tomcat.apache.org/download-55.cgi"&gt;Apache Tomcat 5.5&lt;/a&gt; with &lt;a href="http://ws.apache.org/axis2/"&gt;AXIS2&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The other major, but optional, component is &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;mySQL&lt;/span&gt;. You will need to have this running and an &lt;span style="font-weight: bold;"&gt;empty database created&lt;/span&gt; to start this article, if you wish to use a persistent store. Persistent stores are database backed Jena models. Additionally, the code within these posts assume you will be using a persistent model so adjust as necessary. While you're at it, pick up a copy of the &lt;a href="http://dev.mysql.com/downloads/connector/j/3.1.html"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;mySQL&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;JDBC&lt;/span&gt;&lt;/a&gt; driver also for the database connection.&lt;br /&gt;&lt;br /&gt;You also need to have the Jena libs and the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;jdbc&lt;/span&gt; in your &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;classpath&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Whew ... prerequisites done? Lets code.&lt;br /&gt;&lt;br /&gt;First off, open a connection to the database so Jena can use it. Here is my privatized method that can be called from the various other places we will be building in the coming parts.&lt;br /&gt;&lt;div class="mycode"&gt;private static IDBConnection initDBStore() {&lt;br /&gt; String dbUrl = "jdbc:mysql://YOUR_DATABASE_SERVER_IP/YOUR_DATABASE_NAME";&lt;br /&gt; String dbUser = "MYSQL_USER"; // please, for all things good, don't use 'root'&lt;br /&gt; String dbPass = "MYSQL_PASSWORD";&lt;br /&gt; String dbType = "MySQL";&lt;br /&gt; String dbDriver = "com.mysql.jdbc.Driver";&lt;br /&gt;&lt;br /&gt; // this should almost never be set to true. Set it true if you want&lt;br /&gt; // to purge out all the models&lt;br /&gt; boolean cleanDB = false;&lt;br /&gt;&lt;br /&gt; // load JDBC&lt;br /&gt; try {&lt;br /&gt;  Class.forName(dbDriver);&lt;br /&gt;  IDBConnection dbcon = new DBConnection(dbUrl, dbUser,dbPass,dbType);&lt;br /&gt;&lt;br /&gt;  if (cleanDB)&lt;br /&gt;   dbcon.cleanDB();&lt;br /&gt;  return dbcon;&lt;br /&gt; } catch (Exception e) {&lt;br /&gt;  System.out.println(e.getMessage());&lt;br /&gt; }&lt;br /&gt; return null;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;Now that we know how to connect to a &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_31"&gt;mysql&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_32"&gt;datastore&lt;/span&gt;, we can do something with Jena. This method will create a Jena model in our database.&lt;br /&gt;&lt;pre&gt;public static &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_33"&gt;boolean&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_34"&gt;createModel&lt;/span&gt;(String &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_35"&gt;modelName&lt;/span&gt;) {&lt;br /&gt;try {&lt;br /&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_36"&gt;IDBConnection&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_37"&gt;dbcon&lt;/span&gt; = &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_38"&gt;initDBStore&lt;/span&gt;();&lt;br /&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_39"&gt;ModelMaker&lt;/span&gt; maker = &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_40"&gt;initModel&lt;/span&gt;(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_41"&gt;dbcon&lt;/span&gt;); // see attached code for this method.&lt;br /&gt;&lt;br /&gt;maker.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_42"&gt;createModel&lt;/span&gt;(&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_43"&gt;modelName&lt;/span&gt;, true);&lt;br /&gt;&lt;br /&gt;maker.close();&lt;br /&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_44"&gt;dbcon&lt;/span&gt;.close();&lt;br /&gt;return true;&lt;br /&gt;} catch (Exception e) {&lt;br /&gt;System.out.println("Model Create Failed : " + e.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_45"&gt;getMessage&lt;/span&gt;());&lt;br /&gt;}&lt;br /&gt;return false;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;Here is part one organized into a Java file. Please note if you want to run this as a Java class you will need to add a main method in. This article intends the files to be run as a web service.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;a href="http://kilsoft.googlepages.com/JawsPart1.java"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_46"&gt;JawsPart&lt;/span&gt;1.java&lt;/a&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;In the continuing parts, we will be building on this file and adding in methods to load an &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_47"&gt;RDF&lt;/span&gt; file, run &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_48"&gt;SPARQL&lt;/span&gt; queries, insert and delete triples, and manage the server models.&lt;br /&gt;&lt;div style="text-align: right;"&gt;&lt;a href="http://realityisimportant.blogspot.com/2008/06/building-web-service-with-java-jena-and_06.html"&gt;continue to part two -&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-8495561090173115830?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/8495561090173115830/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=8495561090173115830' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/8495561090173115830'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/8495561090173115830'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2008/06/building-web-service-with-java-jena-and.html' title='Building a Web Service with Java, Jena and mySQL [Part 1]'/><author><name>garrett wyrwas</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6797438784639127804.post-7782105739037029894</id><published>2008-06-04T10:43:00.016-04:00</published><updated>2010-10-12T14:36:19.409-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='php'/><title type='text'>How to Read Multi-dimensional Arrays in Java and PHP</title><content type='html'>First, lets look at what a multidimensional array is. Basically it is an array of array(s) and it can be two, three or more dimensions. For simplicity and readability we're going to work with two dimensions, representing our data as: &lt;br /&gt;&lt;pre&gt;&lt;br /&gt;multiArray = { {"item1","item2"} , {"thing1","thing2"} , etc. }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;In a pinch an item can be read out very similar to reading out one dimensional arrays.&lt;br /&gt;&lt;pre&gt;print(multiArray[1][2])&lt;/pre&gt;&lt;br /&gt;this returns&lt;br /&gt;&lt;pre&gt;thing2&lt;/pre&gt;&lt;br /&gt;If we wanted to just iterate all the items in the array, we use a series of loops.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;java version&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;for (int i=0;i&amp;lt;multiArray.length;i++) {&lt;br /&gt;     for (int j=0;j&amp;lt;multiArray[i].length;j++) {&lt;br /&gt;          System.out.println(multiArray[i][j]);&lt;br /&gt;     }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;strikingly similar PHP version&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;for ($i=0;$i&amp;lt;count($multiArray);$i++) {&lt;br /&gt;        for ($j=0;$j&amp;lt;count($multiArray[$i]);$j++) {&lt;br /&gt;                echo($multiArray[$i][$j]. "&amp;lt;br /&amp;gt;");&lt;br /&gt;        }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This is useful in multiple scenarios. Relating this to the semantic web and/or RDF, results are typically in :subject :predicate :object format. So these returns are easily read in a multidimensional array with the first dimension being the row and the second each column (subject, predicate, object). &lt;br /&gt;&lt;br /&gt;Much more on how this works in the semantic web world later.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6797438784639127804-7782105739037029894?l=realityisimportant.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://realityisimportant.blogspot.com/feeds/7782105739037029894/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6797438784639127804&amp;postID=7782105739037029894' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/7782105739037029894'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6797438784639127804/posts/default/7782105739037029894'/><link rel='alternate' type='text/html' href='http://realityisimportant.blogspot.com/2008/06/how-to-read-and-write-multi-dimensional.html' title='How to Read Multi-dimensional Arrays in Java and PHP'/><author><name>garrett wyrwas</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
