<?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>blog.elsdoerfer.name &#187; Other</title>
	<atom:link href="http://blog.elsdoerfer.name/category/other/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.elsdoerfer.name</link>
	<description>Contributing back to the Google Index.</description>
	<lastBuildDate>Sat, 10 Dec 2011 00:04:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Multiline items in an Ext JS combobox</title>
		<link>http://blog.elsdoerfer.name/2008/05/20/multiline-items-in-an-ext-js-combobox/</link>
		<comments>http://blog.elsdoerfer.name/2008/05/20/multiline-items-in-an-ext-js-combobox/#comments</comments>
		<pubDate>Tue, 20 May 2008 22:26:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Other]]></category>

		<guid isPermaLink="false">http://blog.elsdoerfer.name/2008/05/20/multiline-items-in-an-ext-js-combobox/</guid>
		<description><![CDATA[This is spectacularly simple: .x-combo-list-item { white-space: normal; }]]></description>
			<content:encoded><![CDATA[<p>This is spectacularly simple:</p>
<pre name="code" class="css">
.x-combo-list-item { white-space: normal; }</pre>
<p><img src="http://blog.elsdoerfer.name/wp-content/uploads/2008/05/extjs-combo-multiline.png" alt="Multiline items in ExtJs combos" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.elsdoerfer.name/2008/05/20/multiline-items-in-an-ext-js-combobox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hijacking a meme for the sole glorification of PowerShell</title>
		<link>http://blog.elsdoerfer.name/2008/04/30/hijacking-a-meme-for-the-sole-glorification-of-powershell/</link>
		<comments>http://blog.elsdoerfer.name/2008/04/30/hijacking-a-meme-for-the-sole-glorification-of-powershell/#comments</comments>
		<pubDate>Wed, 30 Apr 2008 16:43:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Other]]></category>

		<guid isPermaLink="false">http://blog.elsdoerfer.name/2008/04/30/hijacking-a-meme-for-the-sole-glorification-of-powershell/</guid>
		<description><![CDATA[Yesterday I saw this post on James Bennet&#8217;s blog -basically, people are posting the top 10 or so commands from their shell history. Now, using Windows on the desktop myself, I have nothing much to contribute there (I do manage a couple debian servers, but the data is probably too distributed to be useful in [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I saw <a href="http://www.b-list.org/weblog/2008/apr/10/meme/">this post</a> on James Bennet&#8217;s blog -basically, people are posting the top 10 or so commands from their shell history. Now, using Windows on the desktop myself, I have nothing much to contribute there (I do manage a couple debian servers, but the data is probably too distributed to be useful in this context).</p>
<p>However, I recently decided that I would renew my interest in PowerShell (I was in the beta program early on &#8211; the <em>pillars of Longhorn</em> timeframe &#8211; but never did much with it). And porting this seemed like a nice opportunity to get started.</p>
<p>First of all, it might be worth noting that PowerShell, at least the default host, only provides a session-based history feature &#8211; close and it&#8217;s gone. Apparently it is easily possible to add persistence yourself, using a combination of the <em>add-history</em> cmdlet, a startup script, and aliasing <em>exit</em>, but I haven&#8217;t tried that (yet).</p>
<p>I know the suspense must be killing you, so here&#8217;s what I came up with:</p>
<p><code>PS&gt; history | group commandline | sort count -desc | select -f 10</code></p>
<p>Or the more verbose version:</p>
<p><code>PS&gt; get-history | group-object -property commandline | sort -property count -descending | select -first 10</code></p>
<p>That was actually pretty simple, and should be quite easy to read. Compare it to the original:</p>
<p><code>$ history | awk '{print $2}' | sort | uniq -c | sort -rn | head</code></p>
<p>Now, I like the object-based approach a lot, but you have to admit: The *nix version isn&#8217;t half bad, considering it&#8217;s text-based.</p>
<p>Let&#8217;s take it one step further. PowerShell conveniently stores the start and end timestamps for each history item, so instead of by count, wouldn&#8217;t it be cool to sort the list by total runtime? Unfortunately, this is considerably more difficult. The following took me about an hour (but note that I am basically new to PowerShell, and needed to figure out a lot about commands, syntax etc. along the way):</p>
<p><code>PS&gt; history | select commandline,@{name="duration";expression={($_.endExecutionTime - $_.startExecutionTime).totalMilliseconds}} | group commandline | foreach { $_ | add-member NoteProperty Time (($_.group | measure-object -p duration -sum).sum/1000); $_ } | sort time --desc | select name,time -f 10</code></p>
<p>It&#8217;s a bit long, but &#8211; in retrospect, considering the time I spent creating it &#8211; should be moderately simple to follow as well: Calculate the runtime duration for each item, then group by the commandline string. For each group (of instances of the same command) sum up the total duration. Finally sort, and return the top 10.</p>
<p>There might very well be a better way. Particularly, I had trouble with the following:</p>
<ul>
<li>After calculating the sum execution time for a group with <em>measure-item</em>, I wasn&#8217;t sure how to continue so that the next step in the pipeline has access to both the measurement result and the commandline string. I tried a hash, but failed to get <em>sort</em> working with it. I suppose one could use <em>new-object</em>, but I wasn&#8217;t keen on bothering with it&#8217;s syntax and long .NET dotted namespace hierarchies.
<p>As you can see, the version above simply adds the <em>measure-item</em> output to each group object itself, using <em>add-member</em> (which by itself doesn&#8217;t seem to output/return anything btw, which is why the foreach block ends with a single <em>$_</em>). Stuff like <em>add-member </em>feels slightly strange to me anyway &#8211; why is it even necessary? Why not allow adding new properties on the fly? It kind of feels like Powershell has to work around .NETs static nature. I wonder if the DLR might change some of this.</li>
<li>I&#8217;m also not sure as to how you would use <em>measure-object</em> to sum up <em>timespan</em> objects, which is why the above disposes of them early on and continues to work with milliseconds.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.elsdoerfer.name/2008/04/30/hijacking-a-meme-for-the-sole-glorification-of-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Openfire, MD5-Digest, Psi, Pidgin</title>
		<link>http://blog.elsdoerfer.name/2008/04/28/openfire-md5-digest-psi-pidgin/</link>
		<comments>http://blog.elsdoerfer.name/2008/04/28/openfire-md5-digest-psi-pidgin/#comments</comments>
		<pubDate>Mon, 28 Apr 2008 21:49:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Other]]></category>

		<guid isPermaLink="false">http://blog.elsdoerfer.name/2008/04/28/openfire-md5-digest-psi-pidgin/</guid>
		<description><![CDATA[I&#8217;m running my own personal Jabber server, using Openfire, which I recently switched to a setup using SRV records. So while the JID-Domain would be @foo.com, the server is actually running on jabber.foo.com (I also used that opportunity to upgrade to the latest version of Openfire, 3.5.1). Connecting with Psi, which I use myself, works [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m running my own personal Jabber server, using <a href="http://www.igniterealtime.org/projects/openfire/">Openfire</a>, which I recently switched to a setup using SRV records. So while the JID-Domain would be <em>@foo.com</em>, the server is actually running on <em>jabber.foo.com</em> (I also used that opportunity to upgrade to the latest version of Openfire, 3.5.1).</p>
<p>Connecting with Psi, which I use myself, works fine. Unfortunately, it soon turns out that Pidgin (which, as luck has it, one of my users insists on) isn&#8217;t quite has happy with the new status quo and fails on login with &#8220;Not Authorized&#8221;. Some googling suggests setting <em>xmpp.fqdn</em> in Openfire to the actual server host name, <em>jabber</em><em>.foo.com</em>). And indeed, that looked like the solution &#8211; but not for long, because now Psi tells me &#8220;Not Authorized&#8221;. Comical, in a way.</p>
<p>So here&#8217;s what appears to be happening:</p>
<ul>
<li>Openfire offers DIGEST-MD5 auth, which both Pidgin and Psi pick up.</li>
<li>Decoding the  challenge response  from both clients reveals:
<ul>
<li>Pidgin sets the <em>digest-uri</em> field to <em>xmpp/</em><em>jabber</em><em>.foo.com</em> (i.e. it uses the hostname resolved via the SRV records)</li>
<li>Psi sets <em>digest-uri </em>to xmpp/foo.com (i.e. it uses the JID domain)</li>
</ul>
</li>
<li>Openfire expects <em>xmpp.fqdn (jabber.foo.com) </em>if set, or <em>xmpp.domain (foo.com) </em>otherwise. If there is a mismatch, it sends <em>non-authorized</em>.</li>
</ul>
<p>Apparently neither shall work while the other &#8230; &#8211; or something like that. Note that I also tried meebo and Spark, both of which work with either configuration.</p>
<p>Now there are tickets about this in the  Pidgin tracker (<a href="http://developer.pidgin.im/ticket/5008">5008</a>, <a href="http://developer.pidgin.im/ticket/5149">5149</a>, <a href="http://developer.pidgin.im/ticket/5161">5161</a>, all closed as invalid), and a thread in the <a href="http://www.igniterealtime.org/community/message/166228#166228">Openfire forums</a> (with no resolution). I wasn&#8217;t able to find much on the Psi side, shy of possibly a few mentions in older IRC logs. Nothing conclusive.</p>
<p>I am a bit confused that there appears to be no solution, since this shouldn&#8217;t be such and exotic situation I have here. For now, I configured Openfire to only allow PLAIN auth (over SSL though), which you can do by inserting this in your <em>./conf/openfire.xml</em>:</p>
<pre name="code" class="xml">&lt;sasl&gt;&lt;mechs&gt;PLAIN&lt;/mechs&gt;&lt;/sasl&gt;</pre>
<p>Note that the tag is named &lt;<em>mechs</em>&gt;, not <em>&lt;mechanisms&gt;</em>. The latter seems to be suggested at times in the forums, but won&#8217;t work (not for me anyway).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.elsdoerfer.name/2008/04/28/openfire-md5-digest-psi-pidgin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Merge Trac tickets</title>
		<link>http://blog.elsdoerfer.name/2007/12/14/merge-trac-tickets/</link>
		<comments>http://blog.elsdoerfer.name/2007/12/14/merge-trac-tickets/#comments</comments>
		<pubDate>Fri, 14 Dec 2007 17:15:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://blog.elsdoerfer.info/2007/12/14/merge-trac-tickets/</guid>
		<description><![CDATA[Below (open post to see) is a quickly hacked together script to copy tickets from one Trac database to another. It&#8217;s sets a new component on each ticket and removes a milestone, if set, so if you don&#8217;t want that, you&#8217;ll have to change that part (it&#8217;s pretty easy). Public domain, use at your own [...]]]></description>
			<content:encoded><![CDATA[<p>Below (open post to see) is a quickly hacked together script to copy tickets from one <a href="http://trac.edgewall.org/">Trac</a> database to another. It&#8217;s sets a new component on each ticket and removes a milestone, if set, so if you don&#8217;t want that, you&#8217;ll have to change that part (it&#8217;s pretty easy).</p>
<p>Public domain, use at your own risk.</p>
<p><span id="more-13"></span></p>
<pre name="code" class="python">
"""
    Usage: %s source.db target.db new_component

    Copies all tickets, ticket changes and ticket attachments from the source database
    to the target database, and updates the 'component' field on each ticket.

    * 'component' is replaced and 'milestone' removed from tickets. Customize the
      script if you don't / need this behaviour.
    * Make backups yourself!
    * No attempt is made to preserve ticket IDs from the source.
    * Ignores the ticket_custom table - not sure what it's for, it always
      seems to be empty.
    * Tries to be as generic, but makes some assumptions about the
      database schema when accessing columns via indices.
    * Expects both databases to be based on the same trac-version, i.e.
      have the same schema.
"""

import sys, os
from pysqlite2 import dbapi2 as sqlite

def main(argv):
    try:
        source_file, dest_file, new_component = argv
    except ValueError:
        print "Usage: %s source.db target.db new_component" % os.path.basename(sys.argv[0])
        return 1

    # connect to databases
    source_conn = sqlite.connect(source_file)
    source_cur = source_conn.cursor()
    dest_conn = sqlite.connect(dest_file)
    dest_cur = dest_conn.cursor()

    qmarks = lambda seq: ','.join(['?' for r in seq])
    try:
        # go through tickets in source
        tickets = source_cur.execute('SELECT * FROM ticket;')
        for ticket in tickets:
            # delete the id column - will get a new id
            old_id = ticket[0]
            ticket = list(ticket[1:])
            # reset values of component and milestone rows
            ticket[4-1] = new_component     # component
            ticket[11-1] = None               # milestone
            # insert ticket into target db
            print "copying ticket #%s" % old_id
            dest_cur.execute('INSERT INTO ticket '+
                                '('+(','.join([f[0] for f in source_cur.description[1:]]))+') '+
                                'VALUES('+qmarks(ticket)+')',
                            ticket)
            new_id = dest_cur.lastrowid

            # parameters: table name, where clause, query params, id column index, table repr, row repr index
            def copy_table(table, whereq, params, id_idx, trepr, rrepr_idx):
                cur = source_conn.cursor()
                try:
                    cur.execute('SELECT * FROM %s WHERE %s'%(table, whereq), params)
                    for row in cur:
                        row = list(row)
                        row [id_idx] = new_id
                        print "\tcopying %s #%s"%(trepr, row [rrepr_idx])
                        dest_cur.execute('INSERT INTO %s VALUES(%s)'%(table,qmarks(row)), row)
                finally:
                    cur.close()

            # copy ticket changes
            copy_table('ticket_change',
                       'ticket=?', (old_id,),
                       0, 'ticket change', 1)
            # copy attachments
            copy_table('attachment',
                       'type="ticket" AND id=?', (old_id,),
                       1, 'attachment', 2)

        # commit changes
        dest_conn.commit()
    finally:
        dest_conn.close()

if __name__ == '__main__':
    sys.exit(main(sys.argv[1:]))</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.elsdoerfer.name/2007/12/14/merge-trac-tickets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I am really liking the new version of Psi</title>
		<link>http://blog.elsdoerfer.name/2007/12/05/i-am-really-liking-the-new-version-of-psi/</link>
		<comments>http://blog.elsdoerfer.name/2007/12/05/i-am-really-liking-the-new-version-of-psi/#comments</comments>
		<pubDate>Tue, 04 Dec 2007 23:12:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[jabber]]></category>
		<category><![CDATA[psi]]></category>
		<category><![CDATA[xmpp]]></category>

		<guid isPermaLink="false">http://blog.elsdoerfer.info/2007/12/05/i-am-really-liking-the-new-version-of-psi/</guid>
		<description><![CDATA[I&#8217;ve been searching for a decent IM client for ages, but I think I&#8217;ll finally settle on Psi. I previously used an older version for some time, but had various issues. Since then, I tried my luck with Pandion, Spark and Pidgin, but wasn&#8217;t too happy with any one of them. So, I might not [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been searching for a decent IM client for ages, but I think I&#8217;ll finally settle on <a href="http://psi-im.org/">Psi</a>. I previously used an older version for some time, but had various issues. Since then, I tried my luck with <a href="http://www.pandion.be/">Pandion</a>, <a href="http://www.igniterealtime.org/projects/spark/index.jsp">Spark</a> and <a href="http://www.pidgin.im/">Pidgin</a>, but wasn&#8217;t too happy with any one of them.</p>
<p>So, I might not have to write one myself after all.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.elsdoerfer.name/2007/12/05/i-am-really-liking-the-new-version-of-psi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

