<?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>muhuk.com</title>
	<atom:link href="http://www.muhuk.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.muhuk.com</link>
	<description>know thyself</description>
	<lastBuildDate>Thu, 29 Dec 2011 05:05:14 +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>Dune Art</title>
		<link>http://www.muhuk.com/2011/12/dune-art/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=dune-art</link>
		<comments>http://www.muhuk.com/2011/12/dune-art/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 05:05:14 +0000</pubDate>
		<dc:creator>Atamert Ölçgen</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[dune]]></category>
		<category><![CDATA[sci-fi]]></category>

		<guid isPermaLink="false">http://www.muhuk.com/?p=508</guid>
		<description><![CDATA[Why is there so little Dune art? The setting is so colorful and the stories so rich, it is unlikely that artists reading it are not inspired. I can only imagine it's not read by many.

Leto II &#38; Siona:

Duncan Idaho, one of my favorite characters:

Also, check this site out if you were also puzzled ...]]></description>
			<content:encoded><![CDATA[<p>Why is there so little Dune art? The setting is so colorful and the stories so rich, it is unlikely that artists reading it are not inspired. I can only imagine it&#8217;s not read by many.</p>

<p>Leto II &amp; Siona:</p>

<p><object width="450" height="329"><param name="movie" value="http://backend.deviantart.com/embed/view.swf?1"><param name="flashvars" value="id=209804007&#038;width=1337"><param name="allowScriptAccess" value="always"><embed src="http://backend.deviantart.com/embed/view.swf?1" type="application/x-shockwave-flash" width="450" height="329" flashvars="id=209804007&#038;width=1337" allowscriptaccess="always"></embed></object></p>

<p>Duncan Idaho, one of my favorite characters:</p>

<p><object width="450" height="354"><param name="movie" value="http://backend.deviantart.com/embed/view.swf?1"><param name="flashvars" value="id=66859009&#038;width=1337"><param name="allowScriptAccess" value="always"><embed src="http://backend.deviantart.com/embed/view.swf?1" type="application/x-shockwave-flash" width="450" height="354" flashvars="id=66859009&#038;width=1337" allowscriptaccess="always"></embed></object></p>

<p>Also, check this site out if you were also puzzled by the end of original series; <a href="http://www.iwriteiam.nl/D7M_D.html">Dune: Marty and Daniel</a></p>
<p>No related posts.</p><p class="wp-flattr-button"></p>]]></content:encoded>
			<wfw:commentRss>http://www.muhuk.com/2011/12/dune-art/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Working with files in Django &#8211; Part 3</title>
		<link>http://www.muhuk.com/2011/11/working-with-files-in-django-part-3/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=working-with-files-in-django-part-3</link>
		<comments>http://www.muhuk.com/2011/11/working-with-files-in-django-part-3/#comments</comments>
		<pubDate>Wed, 30 Nov 2011 00:02:14 +0000</pubDate>
		<dc:creator>Atamert Ölçgen</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[media]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.muhuk.com/?p=463</guid>
		<description><![CDATA[First part of this article is (http://www.muhuk.com/2011/11/working-with-files-in-django/).

<h2>How to add STATIC files</h2>

You will most likely add <code>STATIC</code> files to your source code repository. As they are likely to be hardcoded in your code and templates it is a good idea to keep those and your <code>STATIC</code> files in sync.

Your <code>STATIC</code> files are collected (found ...]]></description>
			<content:encoded><![CDATA[<p><small>First part of this article is <a href="http://www.muhuk.com/2011/11/working-with-files-in-django/">here</a>.</small></p>

<h2>How to add STATIC files</h2>

<p>You will most likely add <code>STATIC</code> files to your source code repository. As they are likely to be hardcoded in your code and templates it is a good idea to keep those and your <code>STATIC</code> files in sync.</p>

<p>Your <code>STATIC</code> files are collected (found and copied or symlinked) with the help of <a href="https://docs.djangoproject.com/en/1.3/ref/contrib/staticfiles/#staticfiles-finders">finders</a>. This <em>collection</em> process might be a little confusing for you. Basically you don&#8217;t need to worry about where your files are copied, you just need to maintain the files in the locations I mention below. Collection process consolidates all your <code>STATIC</code> files for you, and it does it automatically.</p>

<p>If you are developing a reusable app place your <code>STATIC</code> files under the <code>static</code> directory. Your app directory should look like this:</p>

<pre><code>$ ls -1
models.py
static/
templates/
views.py
</code></pre>

<p>If you are developing a project absolute filesystem paths listed in your <code>STATICFILES_DIRS</code> setting will be collected:</p>

<pre><code>&gt;&gt;&gt; from django.conf import settings
&gt;&gt;&gt; settings.STATICFILES_DIRS
('/opt/myproject/src/project/static',)
</code></pre>

<p>One important thing to note, as I mentioned in the first part, is to set your <code>STATIC_ROOT</code> outside of your project directory. This is the location where all the <code>STATIC</code> files found will be consolidated. Making this directory independent from your project installation enabled its reuse.</p>

<h2>How to upload MEDIA files</h2>

<p>MEDIA files are typically uploaded by users when the project is online and a reference is stored in a model field. While this is true most of the time, <code>MEDIA</code> files can be generated by code and/or a reference can be provided in some other way that doesn&#8217;t involve models. But these edge cases are out of the scope of this post.</p>

<p>The easiest way to allow users upload their files is to use a <a href="https://docs.djangoproject.com/en/1.3/ref/models/fields/#filefield">FileField</a> or <a href="https://docs.djangoproject.com/en/1.3/ref/models/fields/#imagefield">ImageField</a> on a model and <a href="https://docs.djangoproject.com/en/dev/topics/forms/modelforms/">derive a form</a> from it:</p>

<pre><code>from django.db import models
from django.forms.models import modelform_factory


class MediaModel(models.Model):
    media_file = models.FileField(upload_to='user_media')


MediaForm = modelform_factory(MediaModel)
</code></pre>

<p>You can then use this form to provide upload functionality:</p>

<pre><code>def media_create(request):
    if request.method == "POST":
        form = MediaForm(request.POST, request.FILES)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('media-list'))
    else:
        form = MediaForm()
    return render_to_response('usermedia/create/html', {'form': form})
</code></pre>

<p>Of course it is better to use a generic <a href="https://docs.djangoproject.com/en/1.3/ref/class-based-views/#createview">CreateView</a> now we have them with Django 1.3. I wanted to emphasize one point and avoid the complexities of a class based view; you must pass <code>request.FILES</code> to the form&#8217;s constructor. Actually this is a good practice whether or not your form has an file field.</p>

<p>As in the case with <code>STATIC</code> files, <code>MEDIA_ROOT</code> should be in a location seperate from your project files. If you delete your project directory you would also lose <code>MEDIA</code> files otherwise.</p>

<h2>Conclusion</h2>

<p>This concludes <a href="">Working with files in Django</a>. I hope these posts are helpful to you. Once you are comfortable working with files I strongly recommend you to take a look at <a href="http://django_compressor.readthedocs.org/en/latest/index.html">Django Compressor</a></p>

<p><small>If you enjoyed this post please <a href="http://www.muhuk.com/about-you/">tell me a little bit about yourself</a>.</small></p>
<p>Related posts:<ol>
<li><a href='http://www.muhuk.com/2011/11/working-with-files-in-django/' rel='bookmark' title='Working with files in Django &#8211; Part 1'>Working with files in Django &#8211; Part 1</a></li>
<li><a href='http://www.muhuk.com/2011/11/working-with-files-in-django-part-2/' rel='bookmark' title='Working with files in Django &#8211; Part 2'>Working with files in Django &#8211; Part 2</a></li>
<li><a href='http://www.muhuk.com/2011/06/pycon-apac-optimizing-media-performance-with-django_compressor/' rel='bookmark' title='My PyCon APAC 2011 Presentation: Optimizing Media Performance with django_compressor'>My PyCon APAC 2011 Presentation: Optimizing Media Performance with django_compressor</a></li>
</ol></p><p class="wp-flattr-button"></p>]]></content:encoded>
			<wfw:commentRss>http://www.muhuk.com/2011/11/working-with-files-in-django-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Working with files in Django &#8211; Part 2</title>
		<link>http://www.muhuk.com/2011/11/working-with-files-in-django-part-2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=working-with-files-in-django-part-2</link>
		<comments>http://www.muhuk.com/2011/11/working-with-files-in-django-part-2/#comments</comments>
		<pubDate>Sat, 26 Nov 2011 08:31:08 +0000</pubDate>
		<dc:creator>Atamert Ölçgen</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[media]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.muhuk.com/?p=461</guid>
		<description><![CDATA[First part of this article is (http://www.muhuk.com/2011/11/working-with-files-in-django/).

<h2>How to setup file serving for development server</h2>

As I mentioned earlier, it is best to serve files on a fast HTTP server. But this setup is overkill for development environments, you can safely let Django handle your files. The snippet below relies on the assumption, behind the ...]]></description>
			<content:encoded><![CDATA[<p><small>First part of this article is <a href="http://www.muhuk.com/2011/11/working-with-files-in-django/">here</a>.</small></p>

<h2>How to setup file serving for development server</h2>

<p>As I mentioned earlier, it is best to serve files on a fast HTTP server. But this setup is overkill for development environments, you can safely let Django handle your files. The snippet below relies on the assumption, behind the scenes, that <code>DEBUG</code> is always <code>True</code> in development environment and it is always <code>False</code> in production environment. It should be fine for the purposes of this post:</p>

<pre><code>from django.conf.urls.static import static
from django.contrib.staticfiles.urls import staticfiles_urlpatterns

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += staticfiles_urlpatterns()
</code></pre>

<p>It is quite straightforward. Nothing gets added to <code>urlpatterns</code> unless <code>DEBUG</code> is <code>True</code> <strong>and</strong> prefix (<code>MEDIA_URL</code> and <code>STATIC_URL</code>) is not a fully qualified URL.</p>

<h2>How to reference <code>STATIC</code> files in templates</h2>

<p>There are two ways to reference any file. You can use a file&#8217;s location in your file storage (your filesystem for example) for internal use. Or you can build a URL for the file so that clients can access it. This post will cover the latter, as the former is a simple matter of applying <code>os.path.join()</code> to <code>STATIC_ROOT</code> and the particular file&#8217;s path.</p>

<p>To build a URL in your templates you can simply concetenate <code>STATIC_URL</code> with the file&#8217;s relative location to it:</p>

<pre><code>&lt;img src="{{ STATIC_URL }}myapp/img/logo.png" /&gt;
</code></pre>

<p>However, to have <code>STATIC_URL</code> available within your template context you need to make sure of two things:</p>

<ul>
<li>The template needs to be rendered with a <a href="https://docs.djangoproject.com/en/1.3/ref/templates/api/#django.template.RequestContext">RequestContext</a>.</li>
<li><code>django.core.context_processors.static</code> needs to be included in <code>TEMPLATE_CONTEXT_PROCESSORS</code> setting.</li>
</ul>

<p>I can&#8217;t think of a reason why, but if for some reason you are not using <code>RequestContext</code>, you can provide <code>STATIC_URL</code> using <a href="https://docs.djangoproject.com/en/1.3/ref/contrib/staticfiles/#the-get-static-prefix-templatetag">get<em>static</em>prefix</a> tag:</p>

<pre><code>{% load static %}
{% get_static_prefix as STATIC_URL %}

&lt;img src="{{ STATIC_URL }}myapp/img/logo.png" /&gt;
</code></pre>

<h2>How to reference MEDIA files in templates</h2>

<p>Dealing with <code>MEDIA</code> files is much simpler. The <code>FieldFile</code> object returned by <code>ImageField</code> and <code>FileField</code> has <code>path</code> and <code>url</code> properties and you don&#8217;t need to do concetenation yourself:</p>

<pre><code>&lt;img src="{{ some_model.some_image_field.url }}" /&gt;
</code></pre>

<p><small><a href="http://www.muhuk.com/2011/11/working-with-files-in-django-part-3/">Next part</a> deals with adding files to your project.</small></p>

<p><small>If you enjoyed this post please <a href="http://www.muhuk.com/about-you/">tell me a little bit about yourself</a>.</small></p>
<p>Related posts:<ol>
<li><a href='http://www.muhuk.com/2011/11/working-with-files-in-django/' rel='bookmark' title='Working with files in Django &#8211; Part 1'>Working with files in Django &#8211; Part 1</a></li>
<li><a href='http://www.muhuk.com/2011/11/working-with-files-in-django-part-3/' rel='bookmark' title='Working with files in Django &#8211; Part 3'>Working with files in Django &#8211; Part 3</a></li>
<li><a href='http://www.muhuk.com/2011/06/pycon-apac-optimizing-media-performance-with-django_compressor/' rel='bookmark' title='My PyCon APAC 2011 Presentation: Optimizing Media Performance with django_compressor'>My PyCon APAC 2011 Presentation: Optimizing Media Performance with django_compressor</a></li>
</ol></p><p class="wp-flattr-button"></p>]]></content:encoded>
			<wfw:commentRss>http://www.muhuk.com/2011/11/working-with-files-in-django-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Working with files in Django &#8211; Part 1</title>
		<link>http://www.muhuk.com/2011/11/working-with-files-in-django/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=working-with-files-in-django</link>
		<comments>http://www.muhuk.com/2011/11/working-with-files-in-django/#comments</comments>
		<pubDate>Mon, 21 Nov 2011 10:47:18 +0000</pubDate>
		<dc:creator>Atamert Ölçgen</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[media]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.muhuk.com/?p=453</guid>
		<description><![CDATA[In this post what I mean by <code>file</code> is any content that is not dynamically generated. There are basically two types of files a web application deals with:

<ul>
<li>Files that are hard coded in templates or in code. We will call them <code>STATIC</code> files.</li>
<li>Files that are referenced in the code but only known ...</li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>In this post what I mean by <code>file</code> is any content that is not dynamically generated. There are basically two types of files a web application deals with:</p>

<ul>
<li>Files that are hard coded in templates or in code. We will call them <code>STATIC</code> files.</li>
<li>Files that are referenced in the code but only known in the run time. We will call them <code>MEDIA</code> files.</li>
</ul>

<p>Now of course all these files are static and most of them can be classified as media, but I chose those terms because that more or less how they are referred to in <a href="https://docs.djangoproject.com/en/1.3/">Django documentation</a>.</p>

<p>Since files are stored on disk or some other <a href="https://docs.djangoproject.com/en/1.3/ref/files/storage/">storage backend</a> it is best to <a href="https://docs.djangoproject.com/en/1.3/howto/static-files/#serving-static-files-from-a-dedicated-server">serve them on a fast HTTP server</a> and let Django handle only dynamic content.</p>

<h2>How to configure STATIC/MEDIA related settings</h2>

<p>Let&#8217;s look at some code first and we can comment on it afterwards. I use the following setup in my projects:</p>

<pre><code>import os

_PATH = os.path.abspath(os.path.dirname(__file__))

MEDIA_ROOT = os.path.join(_PATH, 'files', 'media')
MEDIA_URL = '/media/'

STATIC_ROOT = os.path.join(_PATH, 'files', 'static')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
    os.path.join(_PATH, 'static'),
)
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)

ADMIN_MEDIA_PREFIX = '/static/admin/'
</code></pre>

<p><code>_PATH</code> should be obvious. But the way I use it is a little tricky here. Basically I am using a <code>files</code> directory that contains <code>media</code>, for <code>MEDIA</code> files, and <code>static</code>, for <code>STATIC</code> files, directories. This seperation is essential. You will pull your hair if you don&#8217;t seperate those two from the beginning. This will allow you to reuse them easily if you deploy a new version to a different location.</p>

<p>But why is <code>files</code> under the project directory? Because we need to check-in <code>STATIC</code> files? NO! It is just a convenience for the development environments. I strongly suggest overriding <code>MEDIA_ROOT</code> and <code>STATIC_ROOT</code> in your deployment settings and basically move the <code>files</code> directory outside of the project path. <code>STATIC</code> files that we check-in resides in <code>&lt;_PATH&gt;/static</code>. <a href="https://docs.djangoproject.com/en/1.3/ref/contrib/staticfiles/"><code>django.contrib.staticfiles</code></a> app collects your <code>STATIC</code> files from your project specific directories and within your apps and copies everything in the right places inside <code>STATIC_ROOT</code>.</p>

<p>To sum up the points above:</p>

<ul>
<li>Check-in <code>STATIC</code> files in a folder within your project directory (see <code>STATICFILES_DIRS</code> &amp; <code>FileSystemFinder</code>). If you are <a href="http://www.muhuk.com/2010/01/developing-reusable-django-apps/">developing an app</a> <code>AppDirectoriesFinder</code> will collect static files within the <code>static</code> directory in your app directory.</li>
<li>Seperate the directories, where your <code>MEDIA</code> files are saved and where your <code>STATIC</code> files are collected (see <code>STATIC_ROOT</code> &amp; <code>MEDIA_ROOT</code>).</li>
<li>Keep your <code>STATIC_ROOT</code> and <code>MEDIA_ROOT</code> outside of your project directory in production environment.</li>
</ul>

<p>One more thing to note is <code>STATIC_URL</code> and <code>MEDIA_URL</code> should both have a trailing slash. This will save you a lot of trouble later.</p>

<p><small><a href="http://www.muhuk.com/2011/11/working-with-files-in-django-part-2/">Next part</a> deals with serving files in development environment and referencing them in code and templates.</small></p>

<p><small>If you enjoyed this post please <a href="http://www.muhuk.com/about-you/">tell me a little bit about yourself</a>.</small></p>
<p>Related posts:<ol>
<li><a href='http://www.muhuk.com/2011/11/working-with-files-in-django-part-2/' rel='bookmark' title='Working with files in Django &#8211; Part 2'>Working with files in Django &#8211; Part 2</a></li>
<li><a href='http://www.muhuk.com/2011/11/working-with-files-in-django-part-3/' rel='bookmark' title='Working with files in Django &#8211; Part 3'>Working with files in Django &#8211; Part 3</a></li>
<li><a href='http://www.muhuk.com/2011/06/pycon-apac-optimizing-media-performance-with-django_compressor/' rel='bookmark' title='My PyCon APAC 2011 Presentation: Optimizing Media Performance with django_compressor'>My PyCon APAC 2011 Presentation: Optimizing Media Performance with django_compressor</a></li>
</ol></p><p class="wp-flattr-button"></p>]]></content:encoded>
			<wfw:commentRss>http://www.muhuk.com/2011/11/working-with-files-in-django/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Was it the imperialism that made the west rich?</title>
		<link>http://www.muhuk.com/2011/11/was-it-the-imperialism-that-made-the-west-rich/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=was-it-the-imperialism-that-made-the-west-rich</link>
		<comments>http://www.muhuk.com/2011/11/was-it-the-imperialism-that-made-the-west-rich/#comments</comments>
		<pubDate>Wed, 16 Nov 2011 11:36:33 +0000</pubDate>
		<dc:creator>Atamert Ölçgen</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[competence]]></category>
		<category><![CDATA[imperialism]]></category>
		<category><![CDATA[success]]></category>
		<category><![CDATA[wealth]]></category>

		<guid isPermaLink="false">http://www.muhuk.com/?p=436</guid>
		<description><![CDATA[I had a friend who kept talking about how he cares about ideology and how he is willing to sacrifice and all... In the meantime he was in a bad financial state. It could prevent him continuing his education. He changed the topic back to politics and socialism when I asked what he was ...]]></description>
			<content:encoded><![CDATA[<p>I had a friend who kept talking about how he cares about ideology and how he is willing to sacrifice and all&#8230; In the meantime he was in a bad financial state. It could prevent him continuing his education. He changed the topic back to politics and socialism when I asked what he was going to do about his own situation. I had to end the conversation by saying &#8220;save yourself first, then you can save the world&#8221; finally. I had enough with that.</p>

<p>I remembered that conversation when I was watching the TED talk <a href="http://www.ted.com/talks/niall_ferguson_the_6_killer_apps_of_prosperity.html">The 6 killer apps of prosperity</a> by Niall Ferguson. It is not an in depth analysis of course, but underlines some of the obvious facts and also includes some surprises.</p>

<p><object width="526" height="374">
<param name="movie" value="http://video.ted.com/assets/player/swf/EmbedPlayer.swf"></param>
<param name="allowFullScreen" value="true" />
<param name="allowScriptAccess" value="always"/>
<param name="wmode" value="transparent"></param>
<param name="bgColor" value="#ffffff"></param>
<param name="flashvars" value="vu=http://video.ted.com/talk/stream/2011G/Blank/NiallFerguson_2011G-320k.mp4&#038;su=http://images.ted.com/images/ted/tedindex/embed-posters/NiallFerguson_2011G-embed.jpg&#038;vw=512&#038;vh=288&#038;ap=0&#038;ti=1226&#038;lang=&#038;introDuration=15330&#038;adDuration=4000&#038;postAdDuration=830&#038;adKeys=talk=niall_ferguson_the_6_killer_apps_of_prosperity;year=2011;theme=rethinking_poverty;theme=technology_history_and_destiny;event=TEDGlobal+2011;tag=Business;tag=Culture;tag=Global+Issues;tag=economics;&#038;preAdTag=tconf.ted/embed;tile=1;sz=512x288;" />
<embed src="http://video.ted.com/assets/player/swf/EmbedPlayer.swf" pluginspace="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" bgColor="#ffffff" width="526" height="374" allowFullScreen="true" allowScriptAccess="always" flashvars="vu=http://video.ted.com/talk/stream/2011G/Blank/NiallFerguson_2011G-320k.mp4&#038;su=http://images.ted.com/images/ted/tedindex/embed-posters/NiallFerguson_2011G-embed.jpg&#038;vw=512&#038;vh=288&#038;ap=0&#038;ti=1226&#038;lang=&#038;introDuration=15330&#038;adDuration=4000&#038;postAdDuration=830&#038;adKeys=talk=niall_ferguson_the_6_killer_apps_of_prosperity;year=2011;theme=rethinking_poverty;theme=technology_history_and_destiny;event=TEDGlobal+2011;tag=Business;tag=Culture;tag=Global+Issues;tag=economics;&#038;preAdTag=tconf.ted/embed;tile=1;sz=512x288;"></embed>
</object></p>

<p>This talk also touches how Ottoman Empire lost its power by giving in to bigotry. And the funniest thing is, according to the speaker, <a href="http://en.wikipedia.org/wiki/Ibrahim_Muteferrika">İbrahim Müteferrika</a> was the one who realized the advantages of western empires. The very own İbrahim Müteferrika of Ottoman Empire, who brought the printing technology.</p>

<p>Oh, and it ends with a surprise. If you are really observant or you have watched it till the end, you will see that the trend is reversing.</p>
<p>Related posts:<ol>
<li><a href='http://www.muhuk.com/2011/09/sign-of-a-stupid-programmer/' rel='bookmark' title='Sign of a Stupid Programmer'>Sign of a Stupid Programmer</a></li>
</ol></p><p class="wp-flattr-button"></p>]]></content:encoded>
			<wfw:commentRss>http://www.muhuk.com/2011/11/was-it-the-imperialism-that-made-the-west-rich/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sign of a Stupid Programmer</title>
		<link>http://www.muhuk.com/2011/09/sign-of-a-stupid-programmer/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=sign-of-a-stupid-programmer</link>
		<comments>http://www.muhuk.com/2011/09/sign-of-a-stupid-programmer/#comments</comments>
		<pubDate>Thu, 29 Sep 2011 14:32:26 +0000</pubDate>
		<dc:creator>Atamert Ölçgen</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[code quality]]></category>
		<category><![CDATA[competence]]></category>
		<category><![CDATA[stupidity]]></category>

		<guid isPermaLink="false">http://www.muhuk.com/?p=430</guid>
		<description><![CDATA[<pre><code>if some_boolean_expression:
    return True
else:
    return False
</code></pre>

Unlike (http://www.codinghorror.com/blog/2007/02/why-cant-programmers-program.html), stupid programmers can and do program. That is the problem.

<pre><code>joined = '%s%s%s%s%s%s' % (
 ...
</code></pre>]]></description>
			<content:encoded><![CDATA[<pre><code>if some_boolean_expression:
    return True
else:
    return False
</code></pre>

<p>Unlike <a href="http://www.codinghorror.com/blog/2007/02/why-cant-programmers-program.html">programmers who can&#8217;t program</a>, stupid programmers can and do program. That is the problem.</p>

<pre><code>joined = '%s%s%s%s%s%s' % (
    some_list[0],
    some_list[1],
    some_list[2],
    some_list[3],
    some_list[4],
    some_list[5],
    some_list[6])
</code></pre>

<p>You just wish they were unable to program. Every single time you encounter their code you question yourself. You ask <code>if this is programming, what the f#ck is it I have been doing all this time?</code></p>

<pre><code>def __unicode__(self):
    return '%s' % self.some_unicode_attribute
</code></pre>

<p>I have been reading on stupidity lately. It all started with <a href="http://twitter.com/onurozer">Onur</a> tweeting <a href="http://www.science20.com/hammock_physicist/survival_stupidest-77846">this article</a>. Then I have found the following definition of <a href="http://wwwcsif.cs.ucdavis.edu/~leeey/stupidity/basic.htm">stupidity</a>:</p>

<blockquote>
  <p>A stupid person is a person who causes losses to another person or to a group of persons while himself deriving no gain and even possibly incurring losses.</p>
</blockquote>

<p>They&#8217;re both good reads. I just wish I was introduced to these concepts earlier. I felt stupid for my ignorance on stupidity.</p>

<pre><code>def some_func(**kwargs):
    param1 = kwargs.get('param1', 'param1_default')
    param2 = kwargs.get('param2', 'param2_default')
    param3 = kwargs.get('param3', 'param3_default')
    param4 = kwargs.get('param4', 'param4_default')
    param5 = kwargs.get('param5', 'param5_default')
    param6 = kwargs.get('param6', 'param6_default')
</code></pre>

<p>Watch out for the stupid programmer. He is destructive.</p>
<p>Related posts:<ol>
<li><a href='http://www.muhuk.com/2011/11/was-it-the-imperialism-that-made-the-west-rich/' rel='bookmark' title='Was it the imperialism that made the west rich?'>Was it the imperialism that made the west rich?</a></li>
</ol></p><p class="wp-flattr-button"></p>]]></content:encoded>
			<wfw:commentRss>http://www.muhuk.com/2011/09/sign-of-a-stupid-programmer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Our Fear of Success, Reptilian Brain and Principles</title>
		<link>http://www.muhuk.com/2011/09/our-fear-of-success-reptilian-brain-and-principles/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=our-fear-of-success-reptilian-brain-and-principles</link>
		<comments>http://www.muhuk.com/2011/09/our-fear-of-success-reptilian-brain-and-principles/#comments</comments>
		<pubDate>Wed, 21 Sep 2011 02:56:52 +0000</pubDate>
		<dc:creator>Atamert Ölçgen</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[criticism]]></category>
		<category><![CDATA[mentor]]></category>
		<category><![CDATA[personal development]]></category>
		<category><![CDATA[principle]]></category>
		<category><![CDATA[reptilian brain]]></category>

		<guid isPermaLink="false">http://www.muhuk.com/?p=432</guid>
		<description><![CDATA[I have been reading whatever I can find about game theory1 for some time. I am trying to understand the fundamental rules behind how we make our decisions. One thing that fascinated me all my life is human beings' unwillingness to walk the path, that which has been demonstrated to yield better results with ...]]></description>
			<content:encoded><![CDATA[<p>I have been reading whatever I can find about game theory<sup>1</sup> for some time. I am trying to understand the fundamental rules behind how we make our decisions. One thing that fascinated me all my life is human beings&#8217; unwillingness to walk the path, that which has been demonstrated to yield better results with not significantly more requirements than the alternatives. One instance is very well described in <a href="http://www.sebastianmarshall.com/the-million-dollar-question">this article</a>. I will not go into the details and try to analyze it.</p>

<p>I have learned to recognize this behaviour and walk away. There are better ways to waste your time than trying to convince someone who doesn&#8217;t want to help himself, to do something fruitful. This education cost me a lot of time. But I think I have finally learned.</p>

<p>While I was reading <a href="http://www.bwater.com/Uploads/FileManager/Principles/Bridgewater-Associates-Ray-Dalio-Principles.pdf">Ray Dalio&#8217;s Principles</a>, I found these two paragraphs below. They simply explain the whole issue:</p>

<blockquote>
  <p>Unlike any other species, man is capable of reflecting on himself and the things around him to learn and
  adapt in order to improve.  He has this capability because, in the evolution of species man’s brain
  developed a part that no other species has—the prefrontal cortex.  It is the part of the human brain that
  gives us the ability to reflect and conduct other cognitive thinking.  Because of this, people who can
  objectively reflect on themselves and others —most importantly on their weaknesses are—can figure out
  how to get around these weaknesses, can evolve fastest and come closer to realizing their potentials
  than those who can’t.</p>
  
  <p>However, typically defensive, emotional reactions—i.e., ego barriers—stand way of this progress.  These
  reactions take place in the part of the brain called the amygdala.  As a result of them, most people don’t
  like reflecting on their weaknesses even though recognizing them is an essential step toward preventing
  them from causing them problems.  Most people especially dislike others exploring their weaknesses
  because it makes them feel attacked, which produces fight or flight reactions; however, having others
  help one find one’s weaknesses is essential because it’s very difficult to identify one’s own.  Most people
  don’t like helping others explore their weaknesses, even though they are willing to talk about behind their
  backs, For these reasons most people don’t  do a good job of understanding themselves and adapting in
  order to get what they want most out of life.  In my opinion, that is the biggest single problem of mankind
  because it, more than anything else, impedes people’s abilities to address all other problems and it is
  probably the greatest source of pain for most people.</p>
</blockquote>

<p>If we can successfully classify people into these two groups, I think we can do more meaningful things. Of course, it&#8217;s OK to become friends with the people who fall into the second category. As long as you don&#8217;t forget about their limitations and pick suitable activities.</p>

<p>Now, the second group of people are quite a different story. They would not only accept your help for their personal development, they would welcome it. But, why should we care? It&#8217;s their personal development, their problem. Shouldn&#8217;t we be worried about our own personal development? These people would have a momentum in their life that will affect your own pace. Moreover they will probably try to engage you and try to help you overcome your weaknesses. You should be worried about your own growth primarily. This is why surrounding yourself with these people is a great idea.</p>

<p>I have been very fortunate to meet people who are not afraid to review and renew themselves. I have managed to understand myself and others better, thanks to their mentoring. You don&#8217;t need to wait for a mentor to appear out of nowhere<sup>2</sup> and give you all the answers and keys though. You can start with Seth Godin&#8217;s <a href="http://vimeo.com/5895898">Quieting the Lizard Brain</a> talk (below) and hopefully begin learning and changing things. After all noone can adapt for you, you will eventually need to exert some effort. Great effort.</p>

<p><iframe src="http://player.vimeo.com/video/5895898?title=0&amp;byline=0&amp;portrait=0&amp;color=e91c6b" width="400" height="300" frameborder="0" webkitAllowFullScreen allowFullScreen></iframe><p></p>

<p><strong>1</strong>: Also I have been reading about game design but it is not really related to this post.</p>

<p><strong>2</strong>: I consider myself really, really lucky, what kind of person would I be if those fantastic people hadn&#8217;t appear out of nowhere. I don&#8217;t think I would have ever dared to challenge myself.</p>
<p>No related posts.</p><p class="wp-flattr-button"></p>]]></content:encoded>
			<wfw:commentRss>http://www.muhuk.com/2011/09/our-fear-of-success-reptilian-brain-and-principles/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>F Commits: Poor Man&#8217;s Sub-commits</title>
		<link>http://www.muhuk.com/2011/07/f-commits/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=f-commits</link>
		<comments>http://www.muhuk.com/2011/07/f-commits/#comments</comments>
		<pubDate>Sun, 24 Jul 2011 13:23:49 +0000</pubDate>
		<dc:creator>Atamert Ölçgen</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[vcs]]></category>
		<category><![CDATA[version control]]></category>

		<guid isPermaLink="false">http://www.muhuk.com/?p=427</guid>
		<description><![CDATA[Lately I find myself typing the following command almost a hundred times in a day:

<pre><code>git commit -a -m"f"
</code></pre>

Instead of forming a whole changeset carefully, I just go with it and do many small <em>f commit</em>s. If it gets hairy I can revert back to a previous step or remove one ...]]></description>
			<content:encoded><![CDATA[<p>Lately I find myself typing the following command almost a hundred times in a day:</p>

<pre><code>git commit -a -m"f"
</code></pre>

<p>Instead of forming a whole changeset carefully, I just go with it and do many small <em>f commit</em>s. If it gets hairy I can revert back to a previous step or remove one or more of them. When I am happy with the result, I rebase and mark all the <em>f commit</em>s after the initial commit as <a href="http://kernel.org/pub/software/scm/git/docs/git-rebase.html"><code>fixup</code></a>. Initial commit usually has the commit message this changeset will finally have but if I want to change it I just mark is as <code>reword</code>.</p>

<p>Note that, what I call an <em>f commit</em> is not an atomic set of modifications, they&#8217;re usually undoing or overriding the previous changes. Another way to put it; they are silly commits that I wouldn&#8217;t want anyone else to see. They are a better undo mechanism than whatever editor you are using offers, and they allow you to synchronize multiple files.</p>

<p>I am not saying this is revolutionary or anything. But this is one example of how git changed my workflow and my way of thinking, definitely in a positive way. If you are not familiar with <a href="http://book.git-scm.com/4_interactive_rebasing.html">interactive rebasing</a> please take the time to learn how it works. It is going to pay really well, trust me.</p>
<p>No related posts.</p><p class="wp-flattr-button"></p>]]></content:encoded>
			<wfw:commentRss>http://www.muhuk.com/2011/07/f-commits/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Programming is Debating</title>
		<link>http://www.muhuk.com/2011/07/programming-is-debating/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=programming-is-debating</link>
		<comments>http://www.muhuk.com/2011/07/programming-is-debating/#comments</comments>
		<pubDate>Thu, 14 Jul 2011 16:33:30 +0000</pubDate>
		<dc:creator>Atamert Ölçgen</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[agile development]]></category>
		<category><![CDATA[iterations]]></category>
		<category><![CDATA[software development]]></category>

		<guid isPermaLink="false">http://www.muhuk.com/?p=419</guid>
		<description><![CDATA[How difficult is it to start programming? By starting I mean producing real code, be it a personal project or something you will get paid for. But it is not written for the purpose of learning.

Most of the readers of this blog are professional programmers. I am sure for many of you starting ...]]></description>
			<content:encoded><![CDATA[<p><div id="attachment_423" class="wp-caption alignleft" style="width: 260px"><a href="http://www.muhuk.com/wp-content/uploads/2011/07/city_centre.jpeg"><img src="http://www.muhuk.com/wp-content/uploads/2011/07/city_centre.jpeg" alt="" title="City Center, Singapore" width="250" height="750" class="size-full wp-image-423" /></a><p class="wp-caption-text">Programming is human activity, but this image still has nothing to do with it.</p></div> How difficult is it to start programming? By starting I mean producing real code, be it a personal project or something you will get paid for. But it is not written for the purpose of learning.</p>

<p>Most of the readers of this blog are professional programmers. I am sure for many of you starting was quite easy and natural. But for a lot of people it is an extremely difficult obstacle. I know people, more than 50 people, who studied CS or CE in university but has never written any real code. They get anxious when the possibility presents itself.</p>

<p>The problem with the start is usually the false expectations about programming. There are certain myths about heroic programmers writing incredible programs in impossible conditions with little or no effort. This is of course bullshit. But I have witnessed again and again people setting their expectations about the experience of writing code by these absurd standards. The actual experience inevitably fails to deliver these expectations and the person gives up. This doesn&#8217;t have be so. Programming is supposed to be fun.</p>

<p>When we open a book and start reading, the words we see are unlikely the author&#8217;s original words. The original, raw content get <a href="http://en.wikipedia.org/wiki/Copy_editing">edited</a> before printing. It is an iterative process. I don&#8217;t want to get into the details about publishing<sup>1</sup> but beginners should study this process carefully. Because the process of programming is same, sans <a href="http://groups.csail.mit.edu/mac/classes/6.001/abelson-sussman-lectures/">the magic</a>.</p>

<p>So the act of programming is also an act of debating. You debate with your tests using your code. When all tests pass, the debate is over. When you are making design decisions, no matter how small they are, there is a debate going on between the requirements, the resources and your professional judgement. Therefore it would be unreasonable to expect programming to be a smooth, frictionless process. If you want to start you should be prepared for it.</p>

<p>I would like to share a few pointers that I hope will make the start more predictable if not easier:</p>

<ol>
<li>Try to find a real problem to work on. Forget about educational/theoretical problems. Solve a real, practical problem. There is one extremely important thing to remember here; the scope of the project must be as small as possible. A series of 2-day projects are much better than a 2 week project.</li>
<li>Start by documenting the usage of the code. Write an example script that imports your hypotetical code and uses its functionality. In other words; <a href="http://www.paulgraham.com/progbot.html">design top-down, program bottom-up.</a></li>
<li>Then flesh out the structure. Create files, classes, functions, comments. Writing code is good for warming-up to write some code.</li>
<li>Divide and conquer. Implement incrementally, accomplish one thing at a time. If a functionality is giving you hard time, try to write something that produces some results but not exactly what you expect. Then continue iterating until you get it right. Don&#8217;t wait for the programming muse to come and light the way. Sometimes you need to invent all the wrong implementations before figuring out the correct one.</li>
<li>Never hesitate to ask for help. Programming is debating, why not introduce your peers and mentors into the process. If you are asking for help make sure you have a concrete question. Input, expected output and your current code is usually enough. Even when you don&#8217;t have a problem or question, share your work with others and try to get as much feedback as possible.</li>
<li>Do your research. There is no getting around the reading. I would be lying to you if I said otherwise. If you want to win the debate you need to be well prepared. It may be a little overwhelming in the beginning. But as you build up your knowledge (and experience) you will enjoy reading more.</li>
</ol>

<p>I hope these pointers are helpful. But I think the most important thing to remember is programming is not a mechanical process but it is very human, I call it a debate, some call it <a href="http://books.google.com/books/about/The_art_of_computer_programming.html?id=5oJQAAAAMAAJ">art</a>.</p>

<p><strong>1</strong>: Nor am I an expert on the subject.</p>
<p>No related posts.</p><p class="wp-flattr-button"></p>]]></content:encoded>
			<wfw:commentRss>http://www.muhuk.com/2011/07/programming-is-debating/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>My PyCon APAC 2011 Presentation: Optimizing Media Performance with django_compressor</title>
		<link>http://www.muhuk.com/2011/06/pycon-apac-optimizing-media-performance-with-django_compressor/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=pycon-apac-optimizing-media-performance-with-django_compressor</link>
		<comments>http://www.muhuk.com/2011/06/pycon-apac-optimizing-media-performance-with-django_compressor/#comments</comments>
		<pubDate>Tue, 28 Jun 2011 09:41:45 +0000</pubDate>
		<dc:creator>Atamert Ölçgen</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[media]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.muhuk.com/?p=416</guid>
		<description><![CDATA[I have given a presentation about (http://django_compressor.readthedocs.org/) at (http://apac.pycon.org/). Slides are below for everyone to see:

Optimizing Media Performance with django_compressor   View more presentations from muhuk  ]]></description>
			<content:encoded><![CDATA[<p>I have given a presentation about <a href="http://django_compressor.readthedocs.org/">django_compressor</a> at <a href="http://apac.pycon.org/">PyCon APAC 2011</a>. Slides are below for everyone to see:</p>

<div style="width:425px" id="__ss_8387857"> <strong style="display:block;margin:12px 0 4px"><a href="http://www.slideshare.net/muhuk/optimizing-media-performance-with-djangocompressor" title="Optimizing Media Performance with django_compressor">Optimizing Media Performance with django_compressor</a></strong> <iframe src="http://www.slideshare.net/slideshow/embed_code/8387857" width="425" height="355" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe> <div style="padding:5px 0 12px"> View more <a href="http://www.slideshare.net/">presentations</a> from <a href="http://www.slideshare.net/muhuk">muhuk</a> </div> </div>
<p>Related posts:<ol>
<li><a href='http://www.muhuk.com/2011/11/working-with-files-in-django/' rel='bookmark' title='Working with files in Django &#8211; Part 1'>Working with files in Django &#8211; Part 1</a></li>
<li><a href='http://www.muhuk.com/2011/11/working-with-files-in-django-part-2/' rel='bookmark' title='Working with files in Django &#8211; Part 2'>Working with files in Django &#8211; Part 2</a></li>
<li><a href='http://www.muhuk.com/2011/11/working-with-files-in-django-part-3/' rel='bookmark' title='Working with files in Django &#8211; Part 3'>Working with files in Django &#8211; Part 3</a></li>
</ol></p><p class="wp-flattr-button"></p>]]></content:encoded>
			<wfw:commentRss>http://www.muhuk.com/2011/06/pycon-apac-optimizing-media-performance-with-django_compressor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

