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

<channel>
	<title>/kb &#187; Programming</title>
	<atom:link href="http://grx.no/kb/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://grx.no/kb</link>
	<description>personal knowledgebase</description>
	<lastBuildDate>Mon, 06 Feb 2012 17:05:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Google Data API: Unsupported browser.  Continue at your own risk.</title>
		<link>http://grx.no/kb/2011/06/13/google-data-api-unsupported-browser-continue-at-your-own-risk/</link>
		<comments>http://grx.no/kb/2011/06/13/google-data-api-unsupported-browser-continue-at-your-own-risk/#comments</comments>
		<pubDate>Mon, 13 Jun 2011 10:42:48 +0000</pubDate>
		<dc:creator>hgrimelid</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[gdata]]></category>
		<category><![CDATA[google data api]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://grx.no/kb/?p=210</guid>
		<description><![CDATA[Opera is not officially supported in the Google Data API and the following error message is thrown as an alert(!) when loading the API: Unsupported browser. Continue at your own risk. Remove the error message by sending an empty anonymous function to the init method: google.gdata.client.init(function() {}); var service = new google.gdata.calendar.CalendarService('my-calendar'); Ref. Google Data [...]]]></description>
			<content:encoded><![CDATA[<p>Opera is not officially supported in the Google Data API and the following error message is thrown as an alert(!) when loading the API: <code>Unsupported browser.  Continue at your own risk. </code></p>
<p>Remove the error message by sending an empty anonymous function to the init method:</p>
<pre>
<strong>google.gdata.client.init(function() {});</strong>
var service = new google.gdata.calendar.CalendarService('my-calendar');
</pre>
<p>Ref. <a href="http://code.google.com/apis/gdata/docs/js.html#Request_Feed_Unauthenticated">Google Data API Documentation</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://grx.no/kb/2011/06/13/google-data-api-unsupported-browser-continue-at-your-own-risk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Translation of Django Core</title>
		<link>http://grx.no/kb/2010/08/07/translation-of-django-core/</link>
		<comments>http://grx.no/kb/2010/08/07/translation-of-django-core/#comments</comments>
		<pubDate>Sat, 07 Aug 2010 19:31:27 +0000</pubDate>
		<dc:creator>hgrimelid</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[translation]]></category>

		<guid isPermaLink="false">http://grx.no/kb/?p=202</guid>
		<description><![CDATA[cd django_trunk svn update # Generate .po files: bin/django-admin.py makemessages -l nn bin/django-admin.py makemessages -d djangojs -l nn cd conf/locale/nn/LC_MESSAGES Edit .po files. Search for text string fuzzy and empty double quotes (&#8220;&#8221;) to find untranslated strings. Finally, create diffs: svn diff django.po &#62; nn-django-translation-update.diff svn diff djangojs.po &#62; nn-djangojs-translation-update.diff]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> django_trunk
<span style="color: #c20cb9; font-weight: bold;">svn</span> update
<span style="color: #666666; font-style: italic;"># Generate .po files:</span>
bin<span style="color: #000000; font-weight: bold;">/</span>django-admin.py makemessages <span style="color: #660033;">-l</span> nn 
bin<span style="color: #000000; font-weight: bold;">/</span>django-admin.py makemessages <span style="color: #660033;">-d</span> djangojs <span style="color: #660033;">-l</span> nn
<span style="color: #7a0874; font-weight: bold;">cd</span> conf<span style="color: #000000; font-weight: bold;">/</span>locale<span style="color: #000000; font-weight: bold;">/</span>nn<span style="color: #000000; font-weight: bold;">/</span>LC_MESSAGES</pre></div></div>

<p>Edit .po files. Search for text string fuzzy and empty double quotes (&#8220;&#8221;) to find untranslated strings.</p>
<p>Finally, create diffs:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">svn</span> <span style="color: #c20cb9; font-weight: bold;">diff</span> django.po <span style="color: #000000; font-weight: bold;">&gt;</span> nn-django-translation-update.diff
<span style="color: #c20cb9; font-weight: bold;">svn</span> <span style="color: #c20cb9; font-weight: bold;">diff</span> djangojs.po <span style="color: #000000; font-weight: bold;">&gt;</span> nn-djangojs-translation-update.diff</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://grx.no/kb/2010/08/07/translation-of-django-core/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compile Vim in Snow Leopard</title>
		<link>http://grx.no/kb/2010/04/28/compile-vim-in-snow-leopard/</link>
		<comments>http://grx.no/kb/2010/04/28/compile-vim-in-snow-leopard/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 09:01:58 +0000</pubDate>
		<dc:creator>hgrimelid</dc:creator>
				<category><![CDATA[Editors]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://grx.no/kb/?p=196</guid>
		<description><![CDATA[./configure &#8211;enable-pythoninterp &#8211;with-macsdk=10.6 via Chris Moyer: OSX, Vim, and Python.]]></description>
			<content:encoded><![CDATA[<p>./configure &#8211;enable-pythoninterp &#8211;with-macsdk=10.6</p>
<p>via <a href="http://blog.coredumped.org/2010/01/osx-vim-and-python.html">Chris Moyer: OSX, Vim, and Python</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://grx.no/kb/2010/04/28/compile-vim-in-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Git: Start a new branch after making changes</title>
		<link>http://grx.no/kb/2010/04/23/git-start-a-new-branch-after-making-changes/</link>
		<comments>http://grx.no/kb/2010/04/23/git-start-a-new-branch-after-making-changes/#comments</comments>
		<pubDate>Fri, 23 Apr 2010 10:39:39 +0000</pubDate>
		<dc:creator>hgrimelid</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://grx.no/kb/?p=189</guid>
		<description><![CDATA[Sometimes I realize that my latest changes actually should belong to another branch than the one I&#8217;m currently working on. The easy way to add the changes to a new branch is to use the stash command. &#91;… changes …&#93; git stash git stash branch name_of_new_branch git commit &#91;…&#93; git push origin name_of_new_branch Ref. git [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes I realize that my latest changes actually should belong to another branch than the one I&#8217;m currently working on. The easy way to add the changes to a new branch is to use the <code>stash</code> command.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>… changes …<span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #c20cb9; font-weight: bold;">git</span> stash
<span style="color: #c20cb9; font-weight: bold;">git</span> stash branch name_of_new_branch
<span style="color: #c20cb9; font-weight: bold;">git</span> commit <span style="color: #7a0874; font-weight: bold;">&#91;</span>…<span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #c20cb9; font-weight: bold;">git</span> push origin name_of_new_branch</pre></div></div>

<p>Ref. <a href="http://www.kernel.org/pub/software/scm/git/docs/git-stash.html"><code>git stash</code></a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://grx.no/kb/2010/04/23/git-start-a-new-branch-after-making-changes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Translation of Django Apps</title>
		<link>http://grx.no/kb/2010/03/04/translation-of-django-apps/</link>
		<comments>http://grx.no/kb/2010/03/04/translation-of-django-apps/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 13:50:43 +0000</pubDate>
		<dc:creator>hgrimelid</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[translation]]></category>

		<guid isPermaLink="false">http://grx.no/kb/?p=178</guid>
		<description><![CDATA[I recently created a Django app that needed translation of the Django administration. It took some googling and messing around to make it work, so this quick and dirty walkthrough will hopefully be helpful for others. Here&#8217;s how I did it: Add translations for all model fields: class Stuff&#40;models.Model&#41;: title = models.CharField&#40;_&#40;'title'&#41;, max_length=255&#41; the_other_model = [...]]]></description>
			<content:encoded><![CDATA[<p>I recently created a Django app that needed translation of the Django administration. It took some googling and messing around to make it work, so this quick and dirty walkthrough will hopefully be helpful for others. </p>
<p>Here&#8217;s how I did it:</p>
<p>Add translations for all model fields:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">class</span> Stuff<span style="color: black;">&#40;</span>models.<span style="color: black;">Model</span><span style="color: black;">&#41;</span>:
    title = models.<span style="color: black;">CharField</span><span style="color: black;">&#40;</span>_<span style="color: black;">&#40;</span><span style="color: #483d8b;">'title'</span><span style="color: black;">&#41;</span>, max_length=<span style="color: #ff4500;">255</span><span style="color: black;">&#41;</span>
    the_other_model = model.<span style="color: black;">ForeignKey</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'othermodel'</span>, verbose_name=_<span style="color: black;">&#40;</span><span style="color: #483d8b;">'the other model'</span><span style="color: black;">&#41;</span>, verbose_name_plural=_<span style="color: black;">&#40;</span><span style="color: #483d8b;">'the other models'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">class</span> Meta:
      verbose_name = _<span style="color: black;">&#40;</span><span style="color: #483d8b;">'stuff'</span><span style="color: black;">&#41;</span>
      verbose_name_plural = _<span style="color: black;">&#40;</span><span style="color: #483d8b;">'stuffs'</span><span style="color: black;">&#41;</span></pre></div></div>

<p>Then the language (.po) files must be created:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> locale
python manage.py makemessages <span style="color: #660033;">-l</span> LANG_CODE</pre></div></div>

<p>Then edit your language files in <code>locale/<strong>_LANGUAGE_</strong>/LC_MESSAGES/django.po</code>.  When you&#8217;ve finished editing the language file must be compiled:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">python manage.py compilemessages</pre></div></div>

<p>If you want to translate app names as well, you can add something like this to your project <code>__init__.py</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">utils</span>.<span style="color: black;">translation</span> <span style="color: #ff7700;font-weight:bold;">import</span> ugettext_lazy <span style="color: #ff7700;font-weight:bold;">as</span> _
&nbsp;
_<span style="color: black;">&#40;</span>u<span style="color: #483d8b;">'auth'</span><span style="color: black;">&#41;</span>
_<span style="color: black;">&#40;</span>u<span style="color: #483d8b;">'configuration'</span><span style="color: black;">&#41;</span>
_<span style="color: black;">&#40;</span>u<span style="color: #483d8b;">'sites'</span><span style="color: black;">&#41;</span>
_<span style="color: black;">&#40;</span>u<span style="color: #483d8b;">'appname'</span><span style="color: black;">&#41;</span>
_<span style="color: black;">&#40;</span>u<span style="color: #483d8b;">'Auth'</span><span style="color: black;">&#41;</span>
_<span style="color: black;">&#40;</span>u<span style="color: #483d8b;">'Configuration'</span><span style="color: black;">&#41;</span>
_<span style="color: black;">&#40;</span>u<span style="color: #483d8b;">'Sites'</span><span style="color: black;">&#41;</span>
_<span style="color: black;">&#40;</span>u<span style="color: #483d8b;">'Appname'</span><span style="color: black;">&#41;</span></pre></div></div>

<p>This feels like a dirty hack but I couldn&#8217;t find any other way to do it.</p>
<p>Source: <a href="http://docs.djangoproject.com/en/dev/topics/i18n/">Django documentation &#8211; Internationalization and localization</a>, and some Google Groups thread that I can&#8217;t find right now, for the app name translation.</p>
]]></content:encoded>
			<wfw:commentRss>http://grx.no/kb/2010/03/04/translation-of-django-apps/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Install PIL (Python Imaging Library) in Leopard</title>
		<link>http://grx.no/kb/2010/02/07/install-pil-python-imaging-library-in-leopard/</link>
		<comments>http://grx.no/kb/2010/02/07/install-pil-python-imaging-library-in-leopard/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 11:09:32 +0000</pubDate>
		<dc:creator>hgrimelid</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[mac os]]></category>
		<category><![CDATA[pil]]></category>
		<category><![CDATA[pip]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[virtualenv]]></category>

		<guid isPermaLink="false">http://grx.no/kb/?p=175</guid>
		<description><![CDATA[Installing modules when using pip, virtualenv and virtualenvwrapper is a breeze, but it took some time before I realized what was the easiest way to install PIL. I do it this way: pip -E PATH_TO_VIRTUALENV install http://dist.repoze.org/PIL-1.1.6.tar.gz This installs a slightly repackaged version of PIL. The latest PIL version is 1.1.7, but as far as [...]]]></description>
			<content:encoded><![CDATA[<p>Installing modules when using pip, virtualenv and virtualenvwrapper is a breeze, but it took some time before I realized what was the easiest way to install PIL.</p>
<p>I do it this way:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">pip <span style="color: #660033;">-E</span> PATH_TO_VIRTUALENV <span style="color: #c20cb9; font-weight: bold;">install</span> http:<span style="color: #000000; font-weight: bold;">//</span>dist.repoze.org<span style="color: #000000; font-weight: bold;">/</span>PIL-1.1.6.tar.gz</pre></div></div>

<p>This installs <a href="http://pypi.python.org/pypi/PIL/1.1.6">a slightly repackaged</a> version of PIL. The latest PIL version is 1.1.7, but as far as I know it&#8217;s not available in this form.</p>
]]></content:encoded>
			<wfw:commentRss>http://grx.no/kb/2010/02/07/install-pil-python-imaging-library-in-leopard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chapter 7 in &#8220;Python Web Development with Django&#8221; &#8211; some notes</title>
		<link>http://grx.no/kb/2009/03/08/chapter-7-in-python-web-development-with-django-some-notes/</link>
		<comments>http://grx.no/kb/2009/03/08/chapter-7-in-python-web-development-with-django-some-notes/#comments</comments>
		<pubDate>Sun, 08 Mar 2009 18:08:07 +0000</pubDate>
		<dc:creator>Morten Wergeland Hansen</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://grx.no/kb/?p=103</guid>
		<description><![CDATA[I am currently in the process of learning Django and have just finished chapter 7 in Python Web Development with Django. Here are some notes on how I got it working (except for the index page which still isn&#8217;t completely as expected) on an ubuntu hardy installation. The photo gallery example assumes an apache2 + [...]]]></description>
			<content:encoded><![CDATA[<p>I am currently in the process of learning Django and have just finished chapter 7 in <a href="http://withdjango.com">Python Web Development with Django</a>. Here are some notes on how I got it working (except for the index page which still isn&#8217;t completely as expected) on an ubuntu hardy installation.</p>
<p>The photo gallery example assumes an <em>apache2</em> + <em>mod_python</em> setup. I didn&#8217;t really find it straightforward to get this running from the description in the appendix, so here is how I got it to work (after installation of <em>apache2</em> and <em>mod_python</em>, of course):</p>
<p>In <em>/etc/apache2/sites-available/default</em>, change lines:</p>
<pre>        &lt;Directory /var/www/&gt;
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        &lt;/Directory&gt;</pre>
<p>To:</p>
<pre>        &lt;Directory /var/www/&gt;
                Options Indexes FollowSymLinks MultiViews
                AllowOverride AuthConfig
                Order allow,deny
                allow from all

                AddHandler mod_python .py
                PythonHandler mod_python.publisher
                PythonDebug On
        &lt;/Directory&gt;</pre>
<p>Then I did the changes in <em>/etc/apache2/httpd.conf</em>, but slightly different from the book by adding a <code>PythonOption django.root</code> (didn&#8217;t work for me with the setup in the book):</p>
<pre>&lt;Location "/gallery/"&gt;
      SetHandler python-program
      PythonHandler django.core.handlers.modpython
      SetEnv DJANGO_SETTINGS_MODULE gallery.settings
      PythonOption django.root /gallery
      PythonDebug On
      PythonPath "['/path/to/django/root', '/home/user/django-stuff'] + sys.path"
&lt;/Location&gt;</pre>
<p>With an additional entry for media files:</p>
<pre>&lt;Location "/gallery/media"&gt;
      SetHandler none
&lt;/Location&gt;</pre>
<p>Now, I created a directory <em>/var/www/gallery</em> and a <em>/var/www/gallery/media</em> like explained in &#8220;Preparing for File Uploads&#8221; and edited <em>settings.py</em>:</p>
<p><code>MEDIA_ROOT = '/var/www/gallery/media/'</code><br />
<code>MEDIA_URL = 'http://localhost/gallery/media/'</code><br />
<code>ADMIN_MEDIA_PREFIX = 'http://localhost/gallery/media/admin/'</code></p>
<p>Where admin is a symbolic link (<em>/var/www/gallery/media/admin</em>) to the admin media directory in the Django installation. The two last entries where not mentioned in the book, but they made it work&#8230;</p>
<p>With the settings described above and the <code>PythonOption django.root</code> in <em>httpd.conf</em>, I didn&#8217;t need the section about DRY URLs. And it worked &#8211; as opposed to the stuff in the book.</p>
<p>With all the configuration stuff in place I typed the code outlined in the chapter and to begin with I couldn&#8217;t see any photos, except for the <code>thumb_url</code> in <em>items_list.html</em> (typo: <em>items_listing.html</em> in the last paragraph page 175). I managed to get it working by changing some lines in <em>items_detail.html</em> and <em>photos_detail.html</em> though:</p>
<pre>22                 &lt;img src="{{ photo.image.thumb_url }}" /&gt;</pre>
<p>instead of</p>
<pre>22                 &lt;img src="{{ photo.get_image_thumb_url }}" /&gt;</pre>
<p>and</p>
<pre>8 &lt;img src="{{ object.image.url }}" /&gt;</pre>
<p>instead of:</p>
<pre>8 &lt;img src="{{ object.get_image_url }}" /&gt;</pre>
<p>The alternatives that worked seems more intuitive to me.</p>
<p>I also imported <code>list_detail</code> from <code>django.views.generic</code> in <em>urls.py</em>, but am not sure if this was needed. The photo gallery seems to work fine except for the thumbnails in <em>index.html</em>. I&#8217;ve noticed that the code in <em>urls.py</em> for that template is different from the others, using <code>simple.direct_to_template</code>, but I haven&#8217;t managed getting that part to work.</p>
<p>Thanks to this thread for getting mod_python up and running: <a href="http://ubuntuforums.org/showthread.php?t=91101">Python and Apache2</a></p>
]]></content:encoded>
			<wfw:commentRss>http://grx.no/kb/2009/03/08/chapter-7-in-python-web-development-with-django-some-notes/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Strings and equality in Java</title>
		<link>http://grx.no/kb/2008/06/04/strings-and-equality-in-java/</link>
		<comments>http://grx.no/kb/2008/06/04/strings-and-equality-in-java/#comments</comments>
		<pubDate>Wed, 04 Jun 2008 11:32:59 +0000</pubDate>
		<dc:creator>hgrimelid</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[strings]]></category>

		<guid isPermaLink="false">http://grx.no/kb/?p=18</guid>
		<description><![CDATA[In order to compare objects in Java we are taught to use the equals()-method, except when the goal is to check for object reference, explicitly, then the == operator must be used. However, String objects does not behave entirely as expected, as seen from the following example. String s1 = &#34;Fish&#34;; String s2 = &#34;Fish&#34;; [...]]]></description>
			<content:encoded><![CDATA[<p>In order to compare objects in Java we are taught to use the <code>equals()-</code>method, except when the goal is to check for object reference, explicitly, then the <code>==</code> operator must be used. However, String objects does not behave entirely as expected, as seen from the following example.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #003399;">String</span> s1 <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Fish&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #003399;">String</span> s2 <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Fish&quot;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #003399;">String</span> s3 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Fish&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #003399;">String</span> s4 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Fish&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>s1 <span style="color: #339933;">==</span> s2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>       <span style="color: #666666; font-style: italic;">// true</span>
  <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>s1.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>s2<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// true</span>
&nbsp;
  <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>s3 <span style="color: #339933;">==</span> s4<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>       <span style="color: #666666; font-style: italic;">// false</span>
  <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>s3.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>s4<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// true</span></pre></div></div>

<p>The reason for this behaviour is that strings <code>s3</code> and <code>s4</code> are created outside of the string pool. In the string pool, String objects with the same value are set to the same object internally in order to save space.</p>
]]></content:encoded>
			<wfw:commentRss>http://grx.no/kb/2008/06/04/strings-and-equality-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Prettify print_r output</title>
		<link>http://grx.no/kb/2008/05/07/prettify-print_r-output/</link>
		<comments>http://grx.no/kb/2008/05/07/prettify-print_r-output/#comments</comments>
		<pubDate>Wed, 07 May 2008 16:21:19 +0000</pubDate>
		<dc:creator>hgrimelid</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[print_r]]></category>

		<guid isPermaLink="false">http://k.grx.no/?p=11</guid>
		<description><![CDATA[By putting print_r() statements enclosed by html pre-tag, the output is quite a lot more readable.]]></description>
			<content:encoded><![CDATA[<p>By putting print_r() statements enclosed by html pre-tag, the output is quite a lot more readable.</p>
]]></content:encoded>
			<wfw:commentRss>http://grx.no/kb/2008/05/07/prettify-print_r-output/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

