<?xml version="1.0" encoding="ISO-8859-1"?>

<rdf:RDF
 xmlns="http://purl.org/rss/1.0/"
 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 xmlns:dc="http://purl.org/dc/elements/1.1/"
 xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
>

<channel rdf:about="http://www.peterbe.com/rss.xml">
  <title>Peterbe.com</title>
  <link>http://www.peterbe.com</link>
  <description>Peter Bengtssons's personal homepage about little things that concern him.</description>
  <dc:language>en-uk</dc:language>
  <dc:publisher>mail@peterbe.com</dc:publisher>
<items>
  <rdf:Seq>
  <rdf:li rdf:resource="http://www.peterbe.com/plog/local-nodejs-development-environment-with-nginx" />
  <rdf:li rdf:resource="http://www.peterbe.com/plog/musings-about-django.contrib.auth.models.user" />
  <rdf:li rdf:resource="http://www.peterbe.com/plog/where-i-live" />
  <rdf:li rdf:resource="http://www.peterbe.com/plog/hosting-django-static-images-with-amazon-cloudfront-cdn" />
  <rdf:li rdf:resource="http://www.peterbe.com/plog/600-billion-challenge-reactions" />
  <rdf:li rdf:resource="http://www.peterbe.com/plog/tflcameras" />
  <rdf:li rdf:resource="http://www.peterbe.com/plog/running-django-tests-with-mongodb-is-not-slow" />
  <rdf:li rdf:resource="http://www.peterbe.com/plog/muted-conversations-in-gmail" />
  <rdf:li rdf:resource="http://www.peterbe.com/plog/using-mongodb-in-your-django-app" />
  <rdf:li rdf:resource="http://www.peterbe.com/plog/mongoengine-vs.-django-mongokit" />
 </rdf:Seq>
</items>
<image>
  <title>Peterbe.com</title>
  <url>http://www.peterbe.com/misc_/Peterbecom/peterbe_logo_white_small.gif</url>
  <link>http://www.peterbe.com</link>
  <width>140</width>
  <height>37</height>
  <description>Peterbe.com (Peter Bengtsson on Python, Django, Zope, Kung Fu, London and photos)</description>
</image>
</channel>

<item rdf:about="http://www.peterbe.com/plog/local-nodejs-development-environment-with-nginx">
  <title><![CDATA[Local NodeJS development environment with Nginx]]></title>
  <description><![CDATA[<p>I'm brand spanking new to the <a href="http://nodejs.org/">node.js</a> web application development. The framework I'm currently using is <a href="http://expressjs.com/">express</a> which seems OK. So I've got an app that consists of 1 static HTML file, a lot of Javscript/CSS/image resources and some express GET and POST views that return small snippets of HTML. All data will be loaded with AJAX to avoid having to use any HTML templating on first load. What's cool about this is that it's soo fast! Everything except the JSON data can be loaded from an Nginx server. </p>
<p>At the moment I've got a light static HTML page that loads about 240Kb of Javascript and CSS (jQuery UI is big) and a couple of bytes of JSON data pulled from Node. As a little anal perfectionism I put an Nginx server in front so that Node doesn't have to serve any of the static files. To get that you have to have a Nginx site enabled that looks like this:
<pre>
 server {
    root /home/peterbe/task-calendar/static;
    location / {
      if (-f $request_filename) {
          add_header X-Static hit;
          access_log   off;
      }
      if (!-f $request_filename) {
          proxy_pass http://127.0.0.1:8000; # where Node is running
          add_header X-Static miss;
      }
    }
 }
</pre>
</p>
<p>I think much of the fun of working with this app is that it's a delight to see it load in the browser without any sluggishness or delay. Lovely!</p>]]></description>
  <link>http://www.peterbe.com/plog/local-nodejs-development-environment-with-nginx</link>
  <dc:subject>JavaScript</dc:subject>
  <dc:date>2010-09-01T18:00:00+00:00</dc:date>
</item>

<item rdf:about="http://www.peterbe.com/plog/musings-about-django.contrib.auth.models.user">
  <title><![CDATA[Musings about django.contrib.auth.models.User]]></title>
  <description><![CDATA[<p>Dawned on me that the Django auth user model that ships with Django is like the string built-in of a high level programming language. With the string built-in it's oh so tempting to add custom functionality to it like a fancy captialization method or some other function that automatically strips whitespace or what not. Yes, I'm looking at you Prototype for example.</p>
<p>By NOT doing that, and leaving it as it is, you automatically manage to Keep It Simple Stupid and your application code makes sense to the next developer who joins your project. </p>
<p>I'm not a smart programmer but I'm a smart developer in that I'm good at keeping things pure and simple. It means I can't show off any fancy generators, monads or metaclasses but it does mean that fellow coders who follow my steps can more quickly hit the ground running. </p>
<p><a href="http://www.fry-it.com/">My colleagues</a> and I now have more than ten Django projects that rely on, without overriding, the <code>django.contrib.auth.models.User</code> class and there has been many times where I've been tempted to use it as a base class or something instead but in retrospect I'm wholeheartedly happy I didn't. The benefit isn't technical; it's a matter of teamwork and holistic  productivity. </p>]]></description>
  <link>http://www.peterbe.com/plog/musings-about-django.contrib.auth.models.user</link>
  <dc:subject>Python</dc:subject>
  <dc:date>2010-08-27T20:15:00+00:00</dc:date>
</item>

<item rdf:about="http://www.peterbe.com/plog/where-i-live">
  <title><![CDATA[Where I live]]></title>
  <description><![CDATA[<p>I currently live and work from home in Raleigh, North Carolina. <a href="http://www.bing.com/maps/">Bing maps</a> has a cool feature called "Bird's eye view".</p>
<p><a href="http://www.peterbe.com/plog/where-i-live/brier.jpg"><img src="http://www.peterbe.com/plog/where-i-live/display-thumbnail/brier.jpg" alt="Where I live"  border="1" /></a></p>]]></description>
  <link>http://www.peterbe.com/plog/where-i-live</link>
  <dc:subject></dc:subject>
  <dc:date>2010-08-16T17:00:00+00:00</dc:date>
</item>

<item rdf:about="http://www.peterbe.com/plog/hosting-django-static-images-with-amazon-cloudfront-cdn">
  <title><![CDATA[Hosting Django static images with Amazon Cloudfront (CDN) using django-static]]></title>
  <description><![CDATA[<p>About a month ago I add <a href="http://github.com/peterbe/django-static/commit/05898e99cc21918bb8eae87046db4ef38a7b4e38">a new feature</a> to <a href="http://github.com/peterbe/django-static">django-static</a> that makes it possible to define a function that all files of <code>django-static</code> goes through. </p>
<p>First of all a quick recap. <code>django-static</code> is a Django plugin that you use from your templates to reference static media. <code>django-static</code> takes care of giving the file the optimum name for static serving and if applicable compresses the file by trimming all whitespace and what not. For more info, see <a href="http://www.peterbe.com/plog/serve-your-static-stuff-in-django-with-nginx">The awesomest way possible to serve your static stuff in Django with Nginx</a></p>
<p>The new, popular, kid on the block for CDN (Content Delivery Network) is <a href="http://aws.amazon.com/cloudfront/">Amazon Cloudfront</a>. It's a service sitting on top of the already proven <a href="http://aws.amazon.com/s3/">Amazon S3</a> service which is a cloud file storage solution. What a CDN does is that it registers a domain for your resources such that with some DNS tricks, users of this resource URL download it from the geographically nearest server. So if you live in Sweden you might download <code>myholiday.jpg</code> from a server in Frankfurk and if you live in North Carolina, USA you might download the very same picture from Virgina, USA. That assures the that the distance to the resource is minimized. If you're not convinced or sure about how CDNs work check out <a href="http://developer.yahoo.com/performance/rules.html">THE best practice guide for faster webpages by Steve Sounders</a> (it's number two)</p>
<p>A disadvantage with Amazon Cloudfront is that it's unable to negotiate with the client to compress downlodable resources with GZIP. GZIPping a resource is considered a bigger optimization win than using CDN. So, I continue to serve my static CSS and Javascript files from my Nginx but put all the images on Amazon Cloudfront. How to do this with <code>django-static</code>? Easy: add this to your settings:
<br /><div class="my_code_default">&nbsp;<span class="p_36">DJANGO_STATIC</span>&nbsp;<span class="p_38">=</span>&nbsp;<span class="p_36">True</span><br />&nbsp;<span class="p_38">...</span><span class="p_36">other</span>&nbsp;<span class="p_36">DJANGO_STATIC_</span><span class="p_38">...</span>&nbsp;<span class="p_36">settings</span><span class="p_38">...</span><br />&nbsp;<span class="p_33">#&nbsp;equivalent&nbsp;of&nbsp;'from&nbsp;cloudfront&nbsp;import&nbsp;file_proxy'&nbsp;in&nbsp;this&nbsp;PYTHONPATH</span><br />&nbsp;<span class="p_36">DJANGO_STATIC_FILE_PROXY</span>&nbsp;<span class="p_38">=</span>&nbsp;<span class="p_30">'cloudfront.file_proxy'</span><br /></div>
</p>
<p>Then you need to write that function that get's a chance to do something with every static resource that <code>django-static</code> prepares. Here's a naive first version:
<br /><div class="my_code_default">&nbsp;<span class="p_33">#&nbsp;in&nbsp;cloudfront.py</span><br /><br />&nbsp;<span class="p_36">conversion_map</span>&nbsp;<span class="p_38">=</span>&nbsp;<span class="p_38">{}</span>&nbsp;<span class="p_33">#&nbsp;global&nbsp;variable</span><br />&nbsp;<span class="p_43">def</span>&nbsp;<span class="p_35">file_proxy</span><span class="p_38">(</span><span class="p_36">uri</span><span class="p_38">,</span>&nbsp;<span class="p_36">new</span><span class="p_38">=</span><span class="p_36">False</span><span class="p_38">,</span>&nbsp;<span class="p_36">filepath</span><span class="p_38">=</span><span class="p_43">None</span><span class="p_38">,</span>&nbsp;<span class="p_36">changed</span><span class="p_38">=</span><span class="p_36">False</span><span class="p_38">,</span>&nbsp;<span class="p_38">**</span><span class="p_36">kwargs</span><span class="p_38">):</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p_43">if</span>&nbsp;<span class="p_36">filepath</span>&nbsp;<span class="p_43">and</span>&nbsp;<span class="p_38">(</span><span class="p_36">new</span>&nbsp;<span class="p_43">or</span>&nbsp;<span class="p_36">changed</span><span class="p_38">):</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p_43">if</span>&nbsp;<span class="p_36">filepath</span><span class="p_38">.</span><span class="p_36">lower</span><span class="p_38">().</span><span class="p_36">split</span><span class="p_38">(</span><span class="p_30">'.'</span><span class="p_38">)[-</span><span class="p_37">1</span><span class="p_38">]</span>&nbsp;<span class="p_43">in</span>&nbsp;<span class="p_38">(</span><span class="p_30">'jpg'</span><span class="p_38">,</span><span class="p_30">'gif'</span><span class="p_38">,</span><span class="p_30">'png'</span><span class="p_38">):</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p_36">conversion_map</span><span class="p_38">[</span><span class="p_36">uri</span><span class="p_38">]</span>&nbsp;<span class="p_38">=</span>&nbsp;<span class="p_36">_upload_to_cloudfront</span><span class="p_38">(</span><span class="p_36">filepath</span><span class="p_38">)</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p_43">return</span>&nbsp;<span class="p_36">conversion_map</span><span class="p_38">.</span><span class="p_36">get</span><span class="p_38">(</span><span class="p_36">uri</span><span class="p_38">,</span>&nbsp;<span class="p_36">uri</span><span class="p_38">)</span><br /></div>
</p>
<p></p><br/>[<a href="http://www.peterbe.com/plog/hosting-django-static-images-with-amazon-cloudfront-cdn" style="font-size:80%">1013 more words</a>]]]></description>
  <link>http://www.peterbe.com/plog/hosting-django-static-images-with-amazon-cloudfront-cdn</link>
  <dc:subject>Django</dc:subject>
  <dc:date>2010-07-09T08:00:00+00:00</dc:date>
</item>

<item rdf:about="http://www.peterbe.com/plog/600-billion-challenge-reactions">
  <title><![CDATA[People's reactions to Gates and Buffet's $600 billion challenge]]></title>
  <description><![CDATA[<p>Isn't it amazingly positive news that Warren Buffet and Melinda and Bill Gates have put up the <a href="http://features.blogs.fortune.cnn.com/2010/06/16/gates-buffett-600-billion-dollar-philanthropy-challenge/">$600 billion challenge</a> which is "asking the nation's billionaires to pledge to give at least half their net worth to charity". And if you haven't already read about it, Warren Buffet <a href="http://money.cnn.com/2010/06/15/news/newsmakers/Warren_Buffett_Pledge_Letter.fortune/index.htm">pledges 99% of this company stock to charity</a>. All good news but what's really interesting is reading peoples comments on the CNN page. A handful pick:</p>
<p><em>"Interesting article. It is saddening, however, to ponder just how much of this crowd's wealth was made through unfair business practices, worker exploitation, price fixing, etc. I suppose philanthropy on the back end is a nice afterthought, though, and certainly earns more praise from the public than would lessening their profit margins at the get-go."</em></p>
<p><em>"Pay their taxes first, then contribute with after tax money."</em></p>
<p><em>"If I may be cynical. Perhaps these super rich people should have done more for the people that worked for them so that they made more money and the leaders made a little less. Buffet owns companies that make goods in second and third world countries at some of the lowest possible wages."</em></p>
<p><em>"$1000 in the hands of ONE could be investment money. $1000 distributed $1 to ONE THOUSAND could get each a Coke (no fries)."</em></p>
<p>But also, there are some more "positive" comments:</p>
<p><em>"There is sooo much negativity in this country! I don't care what anyone of you says...Bill and Melinda came from Blue Collar....and now they are giving back and I think it's awesome!"</em></p>
<p><em>"I think what they are doing is very admirable. The Gates Foundation is the reason I was able to pay for college. People need to not criticize what they do with their money, at least they are trying to make a difference."</em></p>
<p>In conclusion from skimming the comments it's pretty obvious that people in the USA are angry and bitter. What is there to complain about? Really? Poor Obama, he's doing a great job but with all this resentment sizzling around it's going to be very hard if even "extreme philanthropy" gets butchered like this.</p>]]></description>
  <link>http://www.peterbe.com/plog/600-billion-challenge-reactions</link>
  <dc:subject>Politics</dc:subject>
  <dc:date>2010-06-17T12:30:00+00:00</dc:date>
</item>

<item rdf:about="http://www.peterbe.com/plog/tflcameras">
  <title><![CDATA[TfL Traffic cameras on a Google map]]></title>
  <description><![CDATA[<p><a href="http://tflcameras.peterbe.com/"><img src="http://www.peterbe.com/plog/tflcameras/display-thumbnail/tflcameras.jpg" alt="TfL Traffic cameras on a Google map" class="floatright" border="1" /></a>
Yesterday I found out that <a href="http://www.tfl.gov.uk/">Transport for London</a>
<a href="http://data.london.gov.uk/blog/boost-londons-software-developer-community-and-smes-tfl-lifts-all-restrictions-commercial-reuse">lifted all restrictions for commercial use of its data</a> that it has made available for developers.</p>
<p>In lack of better imagination I decided to attack the <a href="http://data.london.gov.uk/datastore/package/tfl-live-traffic-cameras">Live Traffic Cameras</a> data and whipped up this little app: <a href="http://tflcameras.peterbe.com">tflcameras.peterbe.com</a></p>
<p>It basically shows a map of London and then shows all the spots where traffic cameras are installed so that you can click on them. The data is updated every 3 hours I think but I haven't checked that claim yet. Use this if you're a London commuter and want to check the traffic before you hit the road. </p>
<p>Oh, and this app uses the geo location stuff so that I know where to zoom in first. But if you're not based in London it zooms in over Trafalgar square by default. </p>]]></description>
  <link>http://www.peterbe.com/plog/tflcameras</link>
  <dc:subject>Web development</dc:subject>
  <dc:date>2010-06-15T23:30:00+00:00</dc:date>
</item>

<item rdf:about="http://www.peterbe.com/plog/running-django-tests-with-mongodb-is-not-slow">
  <title><![CDATA[Correction: running Django tests with MongoDB is NOT slow]]></title>
  <description><![CDATA[<p>At <a href="http://djangocon.eu/">Euro DjangoCon</a> I met lots of people and talked a lot about MongoDB as the backend. I even <a href="http://djangoconeu.blip.tv/file/3681039/">did a presentation on the subject</a> which led to a lot of people asking me more questions about MongoDB.</p>
<p>I did mention to some people that one of the drawbacks of using MongoDB which doesn't have transactions is that you have to create and destroy the collections (like SQL tables) each time for every single test runs. I <strong>thought</strong> this was slow. <strong>It's not</strong> </p>
<p>Today I've been doing some more profiling and testing and debugging and I can conclude that it's not a problem. Creating the database has a slight delay but it's something you only have to do once and actually it's very fast. Here's how I tear down the collections in between each test:
<br /><div class="my_code_default">&nbsp;<span class="p_43">class</span>&nbsp;<span class="p_31">BaseTest</span><span class="p_38">(</span><span class="p_36">TestCase</span><span class="p_38">):</span><br /><br />&nbsp;&nbsp;&nbsp;&nbsp;<span class="p_43">def</span>&nbsp;<span class="p_35">tearDown</span><span class="p_38">(</span><span class="p_36">self</span><span class="p_38">):</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p_43">for</span>&nbsp;<span class="p_36">name</span>&nbsp;<span class="p_43">in</span>&nbsp;<span class="p_36">self</span><span class="p_38">.</span><span class="p_36">database</span><span class="p_38">.</span><span class="p_36">collection_names</span><span class="p_38">():</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p_43">if</span>&nbsp;<span class="p_36">name</span>&nbsp;<span class="p_43">not</span>&nbsp;<span class="p_43">in</span>&nbsp;<span class="p_38">(</span><span class="p_30">'system.indexes'</span><span class="p_38">,):</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p_36">self</span><span class="p_38">.</span><span class="p_36">database</span><span class="p_38">.</span><span class="p_36">drop_collection</span><span class="p_38">(</span><span class="p_36">name</span><span class="p_38">)</span><br /></div>
</p>
<p>For example, running test of one of my apps looks like this:
<br /><div class="my_code_default">&nbsp;$&nbsp;<span class="p_38">./</span><span class="p_36">manage</span><span class="p_38">.</span><span class="p_36">py</span>&nbsp;<span class="p_36">test</span>&nbsp;<span class="p_36">myapp</span><br />&nbsp;<span class="p_38">...........</span><span class="p_36">lots</span><span class="p_38">.............</span><br />&nbsp;<span class="p_38">----------------------------------------------------------------------</span><br />&nbsp;<span class="p_36">Ran</span>&nbsp;<span class="p_37">55</span>&nbsp;<span class="p_36">tests</span>&nbsp;<span class="p_43">in</span>&nbsp;<span class="p_37">3.024s</span><br /></div>
</p>
<p>So, don't fear writing lots of individual unit tests. MongoDB will not slow you down. </p>]]></description>
  <link>http://www.peterbe.com/plog/running-django-tests-with-mongodb-is-not-slow</link>
  <dc:subject>Django</dc:subject>
  <dc:date>2010-05-30T15:00:00+00:00</dc:date>
</item>

<item rdf:about="http://www.peterbe.com/plog/muted-conversations-in-gmail">
  <title><![CDATA[Muted conversations in Gmail]]></title>
  <description><![CDATA[<p><img src="http://www.peterbe.com/plog/muted-conversations-in-gmail/screenshot.png" alt="Muted conversations in Gmail" class="floatright" border="1" />
Having lived under a rock for a while I've managed to miss this great new feature in Gmail:
<a href="http://mail.google.com/support/bin/answer.py?hl=en&answer=47787">Muting or ignoring conversions</a></p>
<p>From their help text:</p>
<p><em>"you've no doubt been subjected to the 'thread that just won't die!' If you're part of a long message conversation that isn't relevant, you can <code>mute</code> the conversation to keep all future additions out of your inbox."</em></p>
<p>That is such a smart feature. Interestingly I didn't even think there was a solution to that problem. I sure I have many times needed something like this. Now, let's hope I can remember to actually use this feature.</p>]]></description>
  <link>http://www.peterbe.com/plog/muted-conversations-in-gmail</link>
  <dc:subject>Misc. links</dc:subject>
  <dc:date>2010-05-29T11:00:00+00:00</dc:date>
</item>

<item rdf:about="http://www.peterbe.com/plog/using-mongodb-in-your-django-app">
  <title><![CDATA["Using MongoDB in your Django app - implications and benefits"]]></title>
  <description><![CDATA[<p>Straight from DjangoCon 2010 here in Berlin.
Slides from my talk on "Using MongoDB in your Django app - implications and benefits" are available as a 
<a href="http://www.peterbe.com/plog/using-mongodb-in-your-django-app/django-mongodb-html5-slides/html5.html">HTML5</a> web page so you'll need one of those fancy browsers like Chrome to be able to view it. Sorry.</p>]]></description>
  <link>http://www.peterbe.com/plog/using-mongodb-in-your-django-app</link>
  <dc:subject>Django</dc:subject>
  <dc:date>2010-05-25T16:00:00+00:00</dc:date>
</item>

<item rdf:about="http://www.peterbe.com/plog/mongoengine-vs.-django-mongokit">
  <title><![CDATA[mongoengine vs. django-mongokit]]></title>
  <description><![CDATA[<p><a href="http://github.com/peterbe/django-mongokit">django-mongokit</a> is the project you want to use if you want to connect your <a href="http://www.djangoproject.com/">Django</a> project to your <a href="http://www.mongodb.org/">MongoDB</a> database via the pymongo Python wrapper. An alternative (dare I say competing alternative) is <a href="http://hmarr.com/mongoengine/">MongoEngine</a> which is bridge between Django and straight to pymongo. The immediate difference you notice is the syntax. django-mongokit looks like MongoKit syntax and MongoEngine looks like Django ORM. They both accomplish pretty much the same thing. So, which one is fastest?</p>
<p>First of all, <a href="http://www.peterbe.com/plog/speed-test-between-django_mongokit-and-postgresql_psycopg2">remember this?</a> where I showed how django-mongokit sped past the SQL ORM like a lightning bullet. Well appears MongoEngine is even faster.</p>
<p><a href="http://www.peterbe.com/plog/mongoengine-vs.-django-mongokit/mongokit-mongoengine.png"><img src="http://www.peterbe.com/plog/mongoengine-vs.-django-mongokit/display-small/mongokit-mongoengine.png" alt="mongoengine vs. django-mongokit" border="1" /></a></p>
<p>That's an <strong>average of 23% faster</strong> for all three operations!</p>]]></description>
  <link>http://www.peterbe.com/plog/mongoengine-vs.-django-mongokit</link>
  <dc:subject>Python</dc:subject>
  <dc:date>2010-05-23T23:00:00+00:00</dc:date>
</item>

</rdf:RDF>