<?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>TKBE</title>
	<atom:link href="http://blog.tkbe.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tkbe.org</link>
	<description>...goings on in the emporium</description>
	<lastBuildDate>Sat, 26 May 2012 14:07:19 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>django :: list_display can&#8217;t sort on attribute of foreign key field&#8230;</title>
		<link>http://blog.tkbe.org/archive/django-list_display-cannot-follow-fkeys/</link>
		<comments>http://blog.tkbe.org/archive/django-list_display-cannot-follow-fkeys/#comments</comments>
		<pubDate>Wed, 21 Dec 2011 03:54:10 +0000</pubDate>
		<dc:creator>tb</dc:creator>
				<category><![CDATA[django]]></category>
		<category><![CDATA[descriptor]]></category>

		<guid isPermaLink="false">http://blog.tkbe.org/?p=192</guid>
		<description><![CDATA[I&#8217;m not the only one surprised by the fact that you can&#8217;t use the double-underscore-foreignkey-attribute-accessor syntax in list_display: There has been extensive discussions on the tracker (https://code.djangoproject.com/ticket/5863) and on the mailing list (http://groups.google.com/group/django-developers/browse_thread/thread/790484bfbe1b421f). It seems unlikely that this will be &#8230; <a href="http://blog.tkbe.org/archive/django-list_display-cannot-follow-fkeys/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;m not the only one surprised by the fact that you can&#8217;t use the double-underscore-foreignkey-attribute-accessor syntax in list_display:</p>
<pre class="brush: python; title: ; notranslate">
class MyModelOptions(admin.ModelAdmin):
    list_display = ['fk_field__fk_attribute']  # ILLEGAL
</pre>
<p>There has been extensive discussions on the tracker (https://code.djangoproject.com/ticket/5863) and on the mailing list (http://groups.google.com/group/django-developers/browse_thread/thread/790484bfbe1b421f). It seems unlikely that this will be possible to do before hell freezes over (although someone commented that it works in Django 1.2 here: http://stackoverflow.com/questions/163823/can-list-display-in-a-django-modeladmin-display-attributes-of-foreignkey-field).</p>
<p>Luke Plant has suggested a solution using callables, which I personally find ugly, but YMMW:</p>
<pre class="brush: python; title: ; notranslate">
def foreign_field(field_name):
    def accessor(obj):
        val = obj
        for part in field_name.split('__'):
            val = getattr(val, part)
        return val
    accessor.__name__ = field_name
    return accessor

ff = foreign_field

class MyAdmin(ModelAdmin):

    list_display = [ff('foreign_key__related_fieldname1'),
                    ff('foreign_key__related_fieldname2')]
</pre>
<p>The code from @lukeplant does all the work in the ModelAdmin, which keeps the Model class free of extra methods for the admin. This is generally a good idea, however I just had a use case where adding accessors made working with the model much easier.</p>
<p>The model in question looks like this:</p>
<pre class="brush: python; title: ; notranslate">
class DailyEmployeeProjectHours(models.Model):
    employee = models.ForeignKey(Employee)
    empday = models.ForeignKey(EmployeeDay)
    project = models.ForeignKey(Project)
    seconds_worked = models.IntegerField(default=0)
</pre>
<p>The code was littered with &#8220;deph.employee.user.username&#8221;, &#8220;deph.empday.date&#8221;, and &#8220;deph.project.name&#8221;&#8230;</p>
<p>We needed something that could define an accessor/property, that would automagically be sortable in Django&#8217;s admin interface&#8230; which sounds like the job for a descriptor:</p>
<pre class="brush: python; title: ; notranslate">
class FkeyLookup(object):
    def __init__(self, fkeydecl, short_description=None, admin_order_field=None):
        self.fk, fkattrs = fkeydecl.split('__', 1)
        self.fkattrs = fkattrs.split('__')

        self.short_description = short_description or self.fkattrs[-1]
        self.admin_order_field = admin_order_field or fkeydecl

    def __get__(self, obj, klass):
        if obj is None:
            return self  # hack required to make Django validate (if obj is None, then we're a class, and classes are callable &lt;wink&gt;)

        item = getattr(obj, self.fk)
        for attr in self.fkattrs:
            item = getattr(item, attr)
        return item
</pre>
<p>Usage:</p>
<pre class="brush: python; title: ; notranslate">
class DailyEmployeeProjectHours(models.Model):
    employee = models.ForeignKey(Employee)
    username = FkeyLookup(&quot;employee__user__username&quot;)

    empday = models.ForeignKey(EmployeeDay)
    date = FkeyLookup(&quot;empday__date&quot;)

    project = models.ForeignKey(Project)
    name = FkeyLookup(&quot;project__name&quot;)

    seconds_worked = models.IntegerField(default=0)
</pre>
<p>and in admin.py::</p>
<pre class="brush: python; title: ; notranslate">
class DailyEmployeeProjectHoursOptions(admin.ModelAdmin):
    list_display = &quot;username date name hours&quot;.split()

    def hours(self, obj):
        return '%.2f' % round(obj.seconds_worked / 3600.0, 2)
    hours.admin_order_field = 'seconds_worked'
</pre>
<p>The admin list for EmployeeProjectHours now has columns named &#8220;Username&#8221;, &#8220;Date&#8221;, &#8220;Name&#8221;, and &#8220;Hours&#8221; &#8212; and all of them will be sortable! (if you&#8217;re on an ancient version of Django, you&#8217;ll need to apply r9212 from Django trunk, only the changes in contrib/admin/views/main.py are needed if you&#8217;re lazy).</p>
<p>In addition the DailyEmployeeProjectHours class now has a number of new properties&#8230;</p>
<pre class="brush: python; title: ; notranslate">
deph = DailyEmployeeProjectHours.objects.get(...)
assert deph.username == deph.employee.user.username
assert deph.date == deph.empday.date
assert deph.name == deph.project.name
</pre>
<p>It&#8217;s cute and it uses descriptors&#8230; <img src='http://blog.tkbe.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tkbe.org/archive/django-list_display-cannot-follow-fkeys/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>python :: Calculating the distance between two locations&#8230;</title>
		<link>http://blog.tkbe.org/archive/python-calculating-the-distance-between-two-locations/</link>
		<comments>http://blog.tkbe.org/archive/python-calculating-the-distance-between-two-locations/#comments</comments>
		<pubDate>Tue, 06 Sep 2011 14:27:38 +0000</pubDate>
		<dc:creator>tb</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://blog.tkbe.org/?p=186</guid>
		<description><![CDATA[How far is it from point a to point b? There are complicated ways to answer this question, that e.g. takes into account whether you&#8217;re walking or driving etc. However, if you only need the approximate distance &#8220;as the crow &#8230; <a href="http://blog.tkbe.org/archive/python-calculating-the-distance-between-two-locations/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>How far is it from point a to point b?  There are complicated ways to answer this question, that e.g. takes into account whether you&#8217;re walking or driving etc.  However, if you only need the approximate distance &#8220;as the crow flies&#8221;, some simple math is sufficient.</p>
<p>I&#8217;m assuming you&#8217;ve used Google&#8217;s geo-coding, or geonames.org&#8217;s postal code search, etc., and now have locations with lat and lng attributes.</p>
<p>The Earth isn&#8217;t a perfect sphere, among many non-spherical properties, it&#8217;s actually fatter around the equator than between the poles: The algorithm doesn&#8217;t take any of this into account, and instead uses a single value for the Earth&#8217;s radius.  Assuming you&#8217;re not going very far (i.e. &#8220;halfway around the globe&#8221;, the result will probably not be too far off, YMMV of course).</p>
<p>Module haversine.py:</p>
<pre class="brush: python; title: ; notranslate">
import math

def cosrad(n):
    &quot;Return the cosine of ``n`` degrees in radians.&quot;
    return math.cos(math.radians(n))
    
def haversine((lat1, long1), (lat2, long2)):
    &quot;&quot;&quot;Calculate the distance between two points on earth.
    &quot;&quot;&quot;
    earth_radius = 6371  # km
    dLat = math.radians(lat2 - lat1)
    dLong = math.radians(long2 - long1)

    a = (math.sin(dLat / 2) ** 2 +
         cosrad(lat1) * cosrad(lat2) * math.sin(dLong / 2) ** 2)
    c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))
    d = earth_radius * c
    return d

def distance(a, b):
    &quot;Return the distance between two points that have .lat and .lng members.&quot;
    return haversine(
        (float(a.lat), float(a.lng)),
        (float(b.lat), float(b.lng)))
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.tkbe.org/archive/python-calculating-the-distance-between-two-locations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>sphinx :: adding a new theme</title>
		<link>http://blog.tkbe.org/archive/creating-sphinx-theme/</link>
		<comments>http://blog.tkbe.org/archive/creating-sphinx-theme/#comments</comments>
		<pubDate>Sun, 03 Apr 2011 18:39:31 +0000</pubDate>
		<dc:creator>tb</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[sphinx]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[webfont]]></category>

		<guid isPermaLink="false">http://blog.tkbe.org/?p=168</guid>
		<description><![CDATA[Sphinx (http://sphinx.pocoo.org/) has made our internal documentation effort go a lot smoother, and the autodoc extension has provided much needed motivation for writing useful docstrings. For those unfamiliar with autodoc, a simple declaration in your documentation file: will automatically document &#8230; <a href="http://blog.tkbe.org/archive/creating-sphinx-theme/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Sphinx (<a href="http://sphinx.pocoo.org/">http://sphinx.pocoo.org/</a>) has made our internal documentation effort go a lot smoother, and the autodoc extension has provided much needed motivation for writing useful docstrings.</p>
<p>For those unfamiliar with autodoc, a simple declaration in your documentation file:</p>
<pre class="brush: python; title: ; notranslate">
.. automodule:: test.sphinxtest
   :members:
   :undoc-members:
</pre>
<p>will automatically document your module, pulling in docstrings automatically:</p>
<p><a href="http://blog.tkbe.org/wp-content/uploads/2011/04/sphinx-default-theme.png"><img class="alignnone size-medium wp-image-171" src="http://blog.tkbe.org/wp-content/uploads/2011/04/sphinx-default-theme-300x207.png" alt="Sphinx with autodoc output (default theme)." width="300" height="207" /></a></p>
<p>At first glance that&#8217;s nice, but after having used it for a while it becomes clear that your eyes are drawn away from the content and onto the &#8220;packaging&#8221;, like the headers/TOC/etc. It is also difficult to tell which level you&#8217;re at since all headers start flush left.</p>
<p>The choice of fonts for describing classes also seems a bit unusual &#8212; at least for first time readers:</p>
<p><a href="http://blog.tkbe.org/wp-content/uploads/2011/04/sphinx-default-theme-classdef.png"><img class="alignnone size-full wp-image-173" src="http://blog.tkbe.org/wp-content/uploads/2011/04/sphinx-default-theme-classdef.png" alt="Sphinx classdef (default theme)" width="357" height="59" /></a></p>
<p>There are other themes to choose from, but if you&#8217;re going to customize you might as well create your own theme &#8212; especially since it&#8217;s really easy.</p>
<p>I&#8217;ll use our dktheme as an example, the finished product looks like this:</p>
<p><a href="http://blog.tkbe.org/wp-content/uploads/2011/04/sphinx-dktheme.png"><img class="alignnone size-full wp-image-176" src="http://blog.tkbe.org/wp-content/uploads/2011/04/sphinx-dktheme.png" alt="Sphinx with dktheme" width="794" height="566" /></a></p>
<p>To start, create a folder (dktheme) to hold your theme files. I chose to put it in the documentation folder.  Change your conf.py file to reflect the new folder:</p>
<pre class="brush: python; title: ; notranslate">
html_theme = 'dktheme'
html_theme_path = ['.']
</pre>
<p>Create a <code>theme.conf</code> file in the folder and provide a few basic configuration settings:</p>
<pre class="brush: python; title: ; notranslate">
[theme]
inherit = default
stylesheet = dktheme.css
pygments_style = sphinx
</pre>
<p><code>inherit</code> declares which theme you want to use as a base (they exist in <code>site-packages/sphinx/themes</code>). <code>pygments_style</code> defines which syntax highlighting color scheme to use.</p>
<p>Create a directory <code>dktheme/static</code>, and put a file named <code>dktheme.css_t</code> in it.  Notice the _t suffix.  This file corresponds to the <code>stylesheet</code> setting in the <code>dktheme/theme.conf</code> file.</p>
<p>Define your own css rules inside <code>dktheme.css_t</code>, but begin by importing the css file of the theme you&#8217;re inheriting from:</p>
<pre class="brush: plain; title: ; notranslate">
@import url(&quot;default.css&quot;);
</pre>
<p>Firebug/Webdeveloper/etc. are useful for finding the correct selectors to override:</p>
<pre class="brush: css; title: ; notranslate">

@import url(&quot;default.css&quot;);

html, body, h1, h2, h3, h4, h5, h6 {
  font-family: 'Ubuntu', 'Trebuchet MS', sans-serif !important;
}

html,
.bodywrapper,
.documentwrapper,
.footer,
.footer a,
.related,
.related ul,
.related ul li a  {
    background-color: #c0c0cf !important;
    color:#808080 !important;
}

.related ul {
  max-width:900px; margin-left:250px !important; font-size:smaller
}
.related ul a {  background-color: transparent !important;}

.body {
  -moz-box-shadow:0px 0px 12px #666;
  -webkit-box-shadow:0px 0px 12px #666;
  box-shadow:0px 0px 12px #666;
  margin:15px 25px 15px 0px;
  margin:0px 25px 0px 0px;
  border:9px solid white;
  -moz-border-radius:14px;
  -webkit-border-radius:14px;
  border-radius:14px;
  max-width:900px;
}

.sphinxsidebar a,
.sphinxsidebar h3,
.sphinxsidebar h4,
.sphinxsidebar h5 { color:#555 !important }

.sphinxsidebar .searchtip { color:black; }

.body h1,
.body h2,
.body h3,
.body h4,
.body h5,
.body h6 {
  margin-left: 0px !important;
  margin-right: 0px !important;
  padding-left:0 !important;
  background-color: white !important;
}

.body h1 { padding-top:17px !important; }

.section .section { margin-left:14px }

.class big { font-size:85%; }
.class em { font-size:85%; }

.class .property,
.class .descclassname,
.class .descname { font-size:100%; line-height:100%; }

.class .property {
   font-style:normal;
   font-weight:bold;
   color:#1D599F;
}

.descclassname { font-size:100% !important; font-family: Tahoma; }
.descname { color:#041F3F; font-size:100% !important; font-family: Tahoma; }

dl.method::before {
    content:&quot;def&quot;;
    float:left; margin-right:0.5ex;
    font-weight:bold; color:#222;
}

dl.attribute::before {
    content:&quot;@property&quot;;
    font-size:85%;
    float:left; margin-right:0.5ex;
    font-style:italic;
}

dd &gt; p { font-size:85%; }
</pre>
<p>I&#8217;ve used <code>::before</code> rules to e.g. insert the word <em>def</em> before method definitions.</p>
<p>At the top I&#8217;ve listed the preferred font as being <em>Ubuntu</em>, which is a very clean font that Google has made available as a webfont (<a href="http://www.google.com/webfonts">www.google.com/webfonts</a>).</p>
<p>To use the Ubuntu web font, you&#8217;ll need to add a link to its css file in the &lt;head&gt; section of your html.  To accomplish this, you&#8217;ll need to add a final file to your theme, <code>dktheme/layout.html</code>, with the following content:</p>
<pre class="brush: xml; title: ; notranslate">
{% extends &quot;default/layout.html&quot; %}

{% block extrahead %}
&lt;link href=&quot;http://fonts.googleapis.com/css?family=Ubuntu:300,300italic,regular,italic,500,500italic,bold,bolditalic&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;
{% endblock %}
</pre>
<p>What this does should be obvious to anyone familiar with Django templates (although these are Jinja templates).</p>
<p>I&#8217;m not a graphical designer, but to my development eyes the documentation is much easier to use with the new theme <img src='http://blog.tkbe.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tkbe.org/archive/creating-sphinx-theme/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>css :: simple hbox</title>
		<link>http://blog.tkbe.org/archive/css-simple-hbox/</link>
		<comments>http://blog.tkbe.org/archive/css-simple-hbox/#comments</comments>
		<pubDate>Sun, 20 Feb 2011 13:18:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tkbe.org/?p=159</guid>
		<description><![CDATA[A hbox is a horizontal box. That means a box where all sub-elements display horizontally across the page, and never wrap. If you can disregard IE6 (and perhaps IE7&#8230; at least IETester doesn&#8217;t like it), then a hbox can be &#8230; <a href="http://blog.tkbe.org/archive/css-simple-hbox/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>A hbox is a horizontal box.  That means a box where all sub-elements display horizontally across the page, and never wrap.</p>
<p>If you can disregard IE6 (and perhaps IE7&#8230; at least IETester doesn&#8217;t like it), then a hbox can be as simple as:</p>
<pre class="brush: css; title: ; notranslate">
  .hbox {
    overflow-x:auto;
  }
  .hbox &gt; * { display:table-cell; }
</pre>
<p>Then the markup:</p>
<pre class="brush: xml; title: ; notranslate">
  &lt;div class=&quot;hbox&quot;&gt;
    &lt;div&gt;A&lt;/div&gt;
    &lt;div&gt;B&lt;/div&gt;
    &lt;div&gt;C&lt;/div&gt;
  &lt;/div&gt;
</pre>
<p>Adding some debugging markup to show what&#8217;s going on:</p>
<pre class="brush: css; title: ; notranslate">
  .hbox { border:3px solid green; border-spacing:3px; }
  .hbox &gt; div { border:1px solid blue; padding:5px; }
</pre>
<p>and you get:</p>
<p><a href="http://blog.tkbe.org/wp-content/uploads/2011/02/hbox.png"><img src="http://blog.tkbe.org/wp-content/uploads/2011/02/hbox.png" alt="hbox example output" title="hbox output" width="177" height="67" class="alignnone size-full wp-image-162" /></a></p>
<p>You can use other table-css on the .hbox selector as well, e.g. border-collapse.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tkbe.org/archive/css-simple-hbox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>new photo frame: pdf to jpg conversion</title>
		<link>http://blog.tkbe.org/archive/new-photo-frame-pdf-to-jpg-conversion/</link>
		<comments>http://blog.tkbe.org/archive/new-photo-frame-pdf-to-jpg-conversion/#comments</comments>
		<pubDate>Sun, 09 Jan 2011 17:19:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tkbe.org/?p=94</guid>
		<description><![CDATA[I got a new digital photo frame for xmas, and it is big enough that I wanted to use it to display the score sheets while I play the piano.  Only problem:  music scores frequently come as pdf files, and &#8230; <a href="http://blog.tkbe.org/archive/new-photo-frame-pdf-to-jpg-conversion/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I got a new digital photo frame for xmas, and it is big enough that I wanted to use it to display the score sheets while I play the piano.  Only problem:  music scores frequently come as pdf files, and the frame only handles simple image files&#8230;</p>
<p>ImageMagick to the rescue!</p>
<p>I was doing this on windows, so I first had to download Ghostscript (http://pages.cs.wisc.edu/~ghost/doc/GPL/gpl900.htm).  For some reason I already had ImageMagick installed&#8230;. (hmm).</p>
<p>Then the magic incantation:</p>
<pre class="brush: bash; title: ; notranslate">
convert -density 200x200 minuet-g.pdf minuet-g.jpg
</pre>
<p>ImageMagick automatically splits the pdf into individually numbered .jpg files.  The -density argument was necessary to get all the lines to show up.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tkbe.org/archive/new-photo-frame-pdf-to-jpg-conversion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Welcome to bluehost</title>
		<link>http://blog.tkbe.org/archive/welcome-to-bluehost/</link>
		<comments>http://blog.tkbe.org/archive/welcome-to-bluehost/#comments</comments>
		<pubDate>Fri, 07 Jan 2011 00:13:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tkbe.org/?p=84</guid>
		<description><![CDATA[I got tired of dealing with GoDaddy after they continued to stone-wall me on the speed issue.  Earlier today I was seeing load times in excess of 40 seconds! Everything is now switched over to bluehost.com, and hopefully things will &#8230; <a href="http://blog.tkbe.org/archive/welcome-to-bluehost/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I got tired of dealing with GoDaddy after they continued to stone-wall me on the speed issue.  Earlier today I was seeing load times in excess of 40 seconds!</p>
<p>Everything is now switched over to bluehost.com, and hopefully things will converge on normality.  It took a little less than 20 minutes of downtime to do the entire switch, and it could probably have gone even faster if I knew what I was doing.  Big thanks to bluehost for their excellent documentation and for answering their phone almost immediately (no more &#8220;your expected wait time is 11 minutes&#8221;&#8230;!).  Big thanks also to the WordPress team for making it so easy to transfer an entire blog!</p>
<p>Load times are now in a sane range from 328 ms to 1830 ms (the larger numbers are all from Europe).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tkbe.org/archive/welcome-to-bluehost/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GoDaddy upgraded me to appalling response times&#8230;</title>
		<link>http://blog.tkbe.org/archive/godaddy-upgraded-me-to-appalling-response-times/</link>
		<comments>http://blog.tkbe.org/archive/godaddy-upgraded-me-to-appalling-response-times/#comments</comments>
		<pubDate>Sun, 28 Nov 2010 00:34:17 +0000</pubDate>
		<dc:creator>tb</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tkbe.org/?p=59</guid>
		<description><![CDATA[I seem to be having just piles of problems with my GoDaddy hosting lately.  I&#8217;ve been a customer since 2006, but suddenly this June (2010) the database holding my blog went *poof*. Having spent a lot of time on archive.org &#8230; <a href="http://blog.tkbe.org/archive/godaddy-upgraded-me-to-appalling-response-times/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I seem to be having just piles of problems with my GoDaddy hosting lately.  I&#8217;ve been a customer since 2006, but suddenly this June (2010) the database holding my blog went *poof*.</p>
<p>Having spent a lot of time on archive.org and in the google cache, I managed to salvage some of the old posts, but it was a tedious manual process.  To speed up some of the mundane work, I wanted to turn on ssh access.  Should have been an easy option to enable from the settings menu in hosting manager, however, it told me my account had to be transferred to &#8220;newer&#8221; servers.  To do that I had to delete my blog (after exporting it) calling support, having them put in a service order, and waiting several days.</p>
<p>At my day job, I use www.pingdom.com to monitor the uptime on our servers, and naturally I&#8217;ve added this blog to the list.  Not long after the upgrade to the ssh-enabled account, I started getting text-messages saying the blog was down.  Turns out it mostly wasn&#8217;t down, it just had response times of over 30 seconds(!)</p>
<p>Below is the pretty graph from pingdom.com, with average response times per day, for the last month for access to the http://blog.tkbe.org page:</p>
<p><a href="http://blog.tkbe.org/wp-content/uploads/2010/11/pingdom-tkbe-300x1381.png"><img class="alignnone size-full wp-image-82" title="load times from Pingdom" src="http://blog.tkbe.org/wp-content/uploads/2010/11/pingdom-tkbe-300x1381.png" alt="monthly access times" width="300" height="138" /></a></p>
<p>The only advice from GoDaddy support&#8230; turn off all the WordPress plugins (which I&#8217;ve done without seeing any improvement whatsoever).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tkbe.org/archive/godaddy-upgraded-me-to-appalling-response-times/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Syntax highlighting&#8230;</title>
		<link>http://blog.tkbe.org/archive/syntax-highlighting/</link>
		<comments>http://blog.tkbe.org/archive/syntax-highlighting/#comments</comments>
		<pubDate>Fri, 24 Sep 2010 15:49:02 +0000</pubDate>
		<dc:creator>tb</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tkbe.org/archive/syntax-highlighting/</guid>
		<description><![CDATA[Syntax hiliting is the ability to get code samples in your blog to look like they do in your editor… without having to add steps, or code, that brings you out of the “flow” of your article. Like this: which &#8230; <a href="http://blog.tkbe.org/archive/syntax-highlighting/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Syntax hiliting is the ability to get code samples in your blog to look like they do in your editor… without having to add steps, or code, that brings you out of the “flow” of your article. Like this:</p>
<pre class="brush: python; title: ; notranslate"> print &quot;hello world&quot; </pre>
<p>which was accomplished by simply writing</p>
<pre class="brush: plain; title: ; notranslate">
1print &quot;hello world&quot;
</pre>
<p>Everyone seems to be using Alex Gorbatchev’s JavaScript code (<a href="http://alexgorbatchev.com/SyntaxHighlighter/">http://alexgorbatchev.com/SyntaxHighlighter/</a>) wrapping it in various ways.  The WordPress team uses (created?) a plugin named SyntaxHighlighter Evolved, which is what I’m using here.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tkbe.org/archive/syntax-highlighting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>db :: adding &quot;missing&quot; foreign key constraints (tsql)</title>
		<link>http://blog.tkbe.org/archive/db-adding-missing-foreign-key-constraints-tsql/</link>
		<comments>http://blog.tkbe.org/archive/db-adding-missing-foreign-key-constraints-tsql/#comments</comments>
		<pubDate>Fri, 24 Sep 2010 14:49:30 +0000</pubDate>
		<dc:creator>tb</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tkbe.org/archive/db-adding-missing-foreign-key-constraints-tsql/</guid>
		<description><![CDATA[I had the following tables after various failed attempts at “alter column”, “add constraint”, etc. I finally found the correct incantation In (other) words: in the foo_orders table create a new foreign key from the customerid field to the id &#8230; <a href="http://blog.tkbe.org/archive/db-adding-missing-foreign-key-constraints-tsql/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I had the following tables</p>
<pre class="brush: sql; title: ; notranslate">
create table customer (
 id int identity primary key,
 ...
)
create table foo_orders (
 orderno int identity primary key,
 customerid int,
 ...
)
</pre>
<p>after various failed attempts at “alter column”, “add constraint”, etc. I finally found the correct incantation</p>
<pre class="brush: sql; title: ; notranslate">
alter table foo_orders with nocheck add foreign key(customerid)
references customer(id)
on delete no action
on update no action
</pre>
<p>In (other) <em>words:</em></p>
<ul>
<li>in the <em>foo_orders</em> table</li>
<li>create a new foreign key
<ul>
<li>from the <em>customerid </em>field</li>
<li>to the <em>id</em> field in the customer table</li>
</ul>
</li>
<li>don’t check existing data in the table (<em>with nocheck</em>)</li>
<li>if the customer is deleted, keep the <em>foo_orders</em> record (<em>on delete no action</em>)</li>
<li>if the <em>id </em>field in the <em>customer</em> table changes, then do nothing (<em>on update no action)</em></li>
</ul>
<p>(at least that’s what I’m pretty sure it means <img src='http://blog.tkbe.org/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Why the <em>no action </em>clauses? The foo_order table records info we send to external entities, and is part of the historical record.  Any changes should never happen automagically.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tkbe.org/archive/db-adding-missing-foreign-key-constraints-tsql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bitrot</title>
		<link>http://blog.tkbe.org/archive/bitrot/</link>
		<comments>http://blog.tkbe.org/archive/bitrot/#comments</comments>
		<pubDate>Thu, 23 Sep 2010 01:31:34 +0000</pubDate>
		<dc:creator>tb</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tkbe.org/archive/bitrot/</guid>
		<description><![CDATA[My blog had a little crash, and is being restored from “backup”…]]></description>
				<content:encoded><![CDATA[<p>My blog had a little crash, and is being restored from “backup”…</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tkbe.org/archive/bitrot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
