<?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>Johannes Buchner &#187; tool</title>
	<atom:link href="http://johannes.jakeapp.com/blog/category/tag/tool/feed" rel="self" type="application/rss+xml" />
	<link>http://johannes.jakeapp.com/blog</link>
	<description>Johannes Buchner&#039;s blog about advanced usage of your operating system</description>
	<lastBuildDate>Sun, 18 Jul 2010 08:30:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>APEMoST</title>
		<link>http://johannes.jakeapp.com/blog/category/science/200911/apemost</link>
		<comments>http://johannes.jakeapp.com/blog/category/science/200911/apemost#comments</comments>
		<pubDate>Thu, 19 Nov 2009 12:57:51 +0000</pubDate>
		<dc:creator>JohannesTheLittleScientist</dc:creator>
				<category><![CDATA[science]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://johannes.jakeapp.com/blog/?p=958</guid>
		<description><![CDATA[Recently I have been busy updating APEMoST, which is a MCMC sampler for Bayesian inference. This can be used as a statistical procedure to estimate parameters of a model. That sounds pretty generic, and indeed it is. One specific example would be to determine the orbit parameters of exoplanets. You can also specify multiple models [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I have been busy updating APEMoST, which is a MCMC sampler for Bayesian inference. This can be used as a statistical procedure to estimate parameters of a model. That sounds pretty generic, and indeed it is. One specific example would be to determine the orbit parameters of exoplanets. You can also specify multiple models (1 planet, 2 planets, no planets) and calculate (with the tool) which model is more likely.</p>
<p>Everything is at <a href="http://apemost.sourceforge.net/">http://apemost.sourceforge.net/</a>. Papers pending ;-)</p>
]]></content:encoded>
			<wfw:commentRss>http://johannes.jakeapp.com/blog/category/science/200911/apemost/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Merging and sorting sorted sources</title>
		<link>http://johannes.jakeapp.com/blog/category/happy-hacking/200908/merging-and-sorting-sorted-sources</link>
		<comments>http://johannes.jakeapp.com/blog/category/happy-hacking/200908/merging-and-sorting-sorted-sources#comments</comments>
		<pubDate>Tue, 18 Aug 2009 09:47:12 +0000</pubDate>
		<dc:creator>JohannesTheDeveloper</dc:creator>
				<category><![CDATA[Happy Hacking]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://johannes.jakeapp.com/blog/?p=655</guid>
		<description><![CDATA[This neat little algorithm takes a number of sorted files and merges them together to a sorted file. It uses fixed block sizes (predefined 16). 
It basically has a &#8220;slot&#8221; for each file, you may think a queue of the blocks in this file, and tries to work its way through to the end of [...]]]></description>
			<content:encoded><![CDATA[<p>This neat little algorithm takes a number of sorted files and merges them together to a sorted file. It uses fixed block sizes (predefined 16). </p>
<p>It basically has a &#8220;slot&#8221; for each file, you may think a queue of the blocks in this file, and tries to work its way through to the end of all queues. So it takes from the slot with the smallest block, writes it to the output file, and refills the slot with the next queue element from that file.<br />
It is a little more sophisticated, because instead of looking through all slots for the next smallest block, it actually juggles the slots (files) in a sorted manner.<br />
I will definitely reuse this.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
</pre></td><td class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;stdio.h&gt;</span>
<span style="color: #339933;">#include &lt;signal.h&gt;</span>
<span style="color: #339933;">#include &lt;stdlib.h&gt;</span>
<span style="color: #339933;">#include &lt;assert.h&gt;</span>
<span style="color: #339933;">#include &lt;string.h&gt;</span>
&nbsp;
<span style="color: #339933;">#define outputfile &quot;mergedblocks&quot;</span>
<span style="color: #339933;">#ifndef DEBUG</span>
<span style="color: #339933;">#define DEBUG 0</span>
<span style="color: #339933;">#endif</span>
&nbsp;
<span style="color: #339933;">#define ENTRYSIZE 16</span>
&nbsp;
FILE <span style="color: #339933;">*</span> f<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">int</span> comp<span style="color: #009900;">&#40;</span><span style="color: #993333;">const</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span> a<span style="color: #339933;">,</span> <span style="color: #993333;">const</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span> b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #993333;">int</span> i<span style="color: #339933;">;</span>
	<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> ENTRYSIZE<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> b<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #b1b100;">return</span> a<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span> b<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #993333;">void</span> switchentries<span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span> <span style="color: #339933;">*</span> a<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span> b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #993333;">int</span> i<span style="color: #339933;">;</span> 
	<span style="color: #993333;">char</span> t<span style="color: #339933;">;</span>
	<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>ENTRYSIZE<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		t <span style="color: #339933;">=</span> a<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		a<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> b<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		b<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> t<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> argc<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">**</span> argv<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #993333;">int</span> i<span style="color: #339933;">;</span>
	<span style="color: #993333;">int</span> j<span style="color: #339933;">;</span>
	<span style="color: #993333;">int</span> nfiles<span style="color: #339933;">;</span>
	<span style="color: #993333;">int</span> v<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #993333;">char</span> <span style="color: #339933;">**</span> filenames<span style="color: #339933;">;</span>
	FILE <span style="color: #339933;">**</span> files<span style="color: #339933;">;</span>
	FILE <span style="color: #339933;">*</span> outfile<span style="color: #339933;">;</span>
	<span style="color: #993333;">char</span> <span style="color: #339933;">**</span> data<span style="color: #339933;">;</span>
	<span style="color: #993333;">unsigned</span> <span style="color: #993333;">long</span> <span style="color: #339933;">*</span> nentries<span style="color: #339933;">;</span>
	<span style="color: #993333;">int</span> <span style="color: #339933;">*</span> slot2file<span style="color: #339933;">;</span>
&nbsp;
	assert<span style="color: #009900;">&#40;</span>argc <span style="color: #339933;">&gt;</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	filenames <span style="color: #339933;">=</span> argv <span style="color: #339933;">+</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
	nfiles <span style="color: #339933;">=</span> argc <span style="color: #339933;">-</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
&nbsp;
	files <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>FILE <span style="color: #339933;">**</span><span style="color: #009900;">&#41;</span>calloc<span style="color: #009900;">&#40;</span>nfiles<span style="color: #339933;">,</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span>FILE<span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	assert<span style="color: #009900;">&#40;</span>files <span style="color: #339933;">!=</span> NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	data <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span> <span style="color: #339933;">**</span><span style="color: #009900;">&#41;</span> calloc<span style="color: #009900;">&#40;</span>nfiles<span style="color: #339933;">,</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	assert<span style="color: #009900;">&#40;</span>data <span style="color: #339933;">!=</span> NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	nentries <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">long</span> <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> calloc<span style="color: #009900;">&#40;</span>nfiles<span style="color: #339933;">,</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">long</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	assert<span style="color: #009900;">&#40;</span>nentries <span style="color: #339933;">!=</span> NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	slot2file <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> calloc<span style="color: #009900;">&#40;</span>nfiles<span style="color: #339933;">,</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	assert<span style="color: #009900;">&#40;</span>slot2file <span style="color: #339933;">!=</span> NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> nfiles<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		files<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> fopen<span style="color: #009900;">&#40;</span>filenames<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;r&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		assert<span style="color: #009900;">&#40;</span>files<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		nentries<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
		slot2file<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> i<span style="color: #339933;">;</span>
		data<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> malloc<span style="color: #009900;">&#40;</span><span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> ENTRYSIZE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		assert<span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		memset<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>data<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> ENTRYSIZE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">/* load first entry */</span>
		<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>j <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> ENTRYSIZE<span style="color: #339933;">;</span> j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			v <span style="color: #339933;">=</span> getc<span style="color: #009900;">&#40;</span>files<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			assert<span style="color: #009900;">&#40;</span>v <span style="color: #339933;">!=</span> EOF<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			data<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> v<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		nentries<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">++;</span>
		<span style="color: #808080; font-style: italic;">/* find next fitting */</span>
		<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span>j <span style="color: #339933;">=</span> i <span style="color: #339933;">-</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&gt;=</span> <span style="color: #0000dd;">0</span> <span style="color: #339933;">&amp;&amp;</span> comp<span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> data<span style="color: #009900;">&#91;</span>j <span style="color: #339933;">+</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> j<span style="color: #339933;">--</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>DEBUG<span style="color: #009900;">&#41;</span>
			<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;switching %d &lt;-&gt; %d<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> j<span style="color: #339933;">,</span> j<span style="color: #339933;">+</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			switchentries<span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#91;</span>j<span style="color: #339933;">+</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> data<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			v <span style="color: #339933;">=</span> slot2file<span style="color: #009900;">&#91;</span>j<span style="color: #339933;">+</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			slot2file<span style="color: #009900;">&#91;</span>j<span style="color: #339933;">+</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> slot2file<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			slot2file<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> v<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
	outfile <span style="color: #339933;">=</span> fopen<span style="color: #009900;">&#40;</span>outputfile<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;w&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	assert<span style="color: #009900;">&#40;</span>outfile <span style="color: #339933;">!=</span> NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>DEBUG<span style="color: #009900;">&#41;</span>
		<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> nfiles<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;slot %3d: &quot;</span><span style="color: #339933;">,</span> i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span>j <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> ENTRYSIZE<span style="color: #339933;">;</span> j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%02x&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span><span style="color: #009900;">&#41;</span>data<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			j <span style="color: #339933;">=</span> slot2file<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>j <span style="color: #339933;">&lt;</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot; (ended)&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				j <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>j <span style="color: #339933;">+</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*-</span><span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>%d-&gt;%d: '%s'&quot;</span><span style="color: #339933;">,</span> i<span style="color: #339933;">,</span> j<span style="color: #339933;">,</span> filenames<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>slot2file<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&lt;</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #808080; font-style: italic;">/* smallest is at 0 */</span>
		<span style="color: #808080; font-style: italic;">/* write out smallest */</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>slot2file<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&gt;=</span> <span style="color: #0000dd;">0</span> <span style="color: #339933;">&amp;&amp;</span> comp<span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> data<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;duplicate found<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;file %s, item %lu<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> filenames<span style="color: #009900;">&#91;</span>slot2file<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> nentries<span style="color: #009900;">&#91;</span>slot2file<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;file %s, item %lu<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> filenames<span style="color: #009900;">&#91;</span>slot2file<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> nentries<span style="color: #009900;">&#91;</span>slot2file<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span>j <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> ENTRYSIZE<span style="color: #339933;">;</span> j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%02x&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span><span style="color: #009900;">&#41;</span>data<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>DEBUG<span style="color: #009900;">&#41;</span>
			<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;smallest writeout<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>j <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> ENTRYSIZE<span style="color: #339933;">;</span> j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				putc<span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> outfile<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>DEBUG<span style="color: #009900;">&#41;</span>
		<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;refill %s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> filenames<span style="color: #009900;">&#91;</span>slot2file<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #808080; font-style: italic;">/* refill slot if possible */</span>
		<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>j <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> ENTRYSIZE<span style="color: #339933;">;</span> j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			v <span style="color: #339933;">=</span> getc<span style="color: #009900;">&#40;</span>files<span style="color: #009900;">&#91;</span>slot2file<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>v <span style="color: #339933;">==</span> EOF<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>DEBUG<span style="color: #009900;">&#41;</span>
				<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;end of file<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				slot2file<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #339933;">-</span>slot2file<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			data<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> v<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>slot2file<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&gt;=</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			nentries<span style="color: #009900;">&#91;</span>slot2file<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">++;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span> <span style="color: #808080; font-style: italic;">/* push to the end */</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>DEBUG<span style="color: #009900;">&#41;</span>
			<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;moving to the end<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span>j <span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> nfiles <span style="color: #339933;">&amp;&amp;</span> slot2file<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">&gt;=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				i <span style="color: #339933;">=</span> j <span style="color: #339933;">-</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>DEBUG<span style="color: #009900;">&#41;</span>
				<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;switching %d &lt;-&gt; %d<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> i<span style="color: #339933;">,</span> j<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				switchentries<span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> data<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				v <span style="color: #339933;">=</span> slot2file<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
				slot2file<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> slot2file<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
				slot2file<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> v<span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span>
		<span style="color: #808080; font-style: italic;">/* put in right place (bubblesort for 1 unsorted item at 0) */</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>DEBUG<span style="color: #009900;">&#41;</span>
		<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;sorting<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span>j <span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> nfiles <span style="color: #339933;">&amp;&amp;</span> slot2file<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">&gt;=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			i <span style="color: #339933;">=</span> j <span style="color: #339933;">-</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>comp<span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> data<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>DEBUG<span style="color: #009900;">&#41;</span>
				<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;switching %d &lt;-&gt; %d<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> i<span style="color: #339933;">,</span> j<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				switchentries<span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> data<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				v <span style="color: #339933;">=</span> slot2file<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
				slot2file<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> slot2file<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
				slot2file<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> v<span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> nfiles<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		slot2file<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span>slot2file<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		fclose<span style="color: #009900;">&#40;</span>files<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>i<span style="color: #339933;">&gt;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span>
			nentries<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+=</span> nentries<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	fclose<span style="color: #009900;">&#40;</span>outfile<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;mergesorted %d files (%lu entries), wrote to %s.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> 
		nfiles<span style="color: #339933;">,</span> nentries<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> outputfile<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #808080; font-style: italic;">/*free(data);*/</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://johannes.jakeapp.com/blog/category/happy-hacking/200908/merging-and-sorting-sorted-sources/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PDF merge/join/split</title>
		<link>http://johannes.jakeapp.com/blog/category/happy-hacking/200811/pdf-mergejoinsplit</link>
		<comments>http://johannes.jakeapp.com/blog/category/happy-hacking/200811/pdf-mergejoinsplit#comments</comments>
		<pubDate>Thu, 13 Nov 2008 01:23:26 +0000</pubDate>
		<dc:creator>JohannesTheDeveloper</dc:creator>
				<category><![CDATA[Happy Hacking]]></category>
		<category><![CDATA[thisreallyworks]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://johannes.jakeapp.com/blog/?p=38</guid>
		<description><![CDATA[You always wanted it to be this simple. Now it is.
.
Download:
=&#62; 8KB	pdfjoin-nosrc.tar.bz2
14712KB	pdfjoin.tar.bz2 (with Ghostscript sources)
I programmed it in Python+Glade+GTK. It uses ghostscript as backend.
Unpack and run &#8220;python pdfjoin.py&#8221;.
I&#8217;ll make a Windows package sometime.
]]></description>
			<content:encoded><![CDATA[<p>You always wanted it to be this simple. Now it is.</p>
<p><img src="http://johannes.jakeapp.com/blog/oldblog/images/Screenshot-PDF join.png" alt="Screenshot-PDF join" width="400" height="225" />.</p>
<p>Download:<br />
<strong>=&gt; <a href="http://johannes.jakeapp.com/oldsite/projekte/pdfjoin-nosrc.tar.bz2">8KB	pdfjoin-nosrc.tar.bz2</a></strong></p>
<p><a style="font-size: x-small;" href="http://johannes.jakeapp.com/oldsite/projekte/pdfjoin.tar.bz2">14712KB	pdfjoin.tar.bz2 (with Ghostscript sources)</a></p>
<p>I programmed it in Python+Glade+GTK. It uses ghostscript as backend.<br />
Unpack and run &#8220;python pdfjoin.py&#8221;.</p>
<p>I&#8217;ll make a Windows package sometime.</p>
]]></content:encoded>
			<wfw:commentRss>http://johannes.jakeapp.com/blog/category/happy-hacking/200811/pdf-mergejoinsplit/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Moving dokuwiki pages to another namespace</title>
		<link>http://johannes.jakeapp.com/blog/category/happy-hacking/200810/moving-dokuwiki-pages-to-another-namespace</link>
		<comments>http://johannes.jakeapp.com/blog/category/happy-hacking/200810/moving-dokuwiki-pages-to-another-namespace#comments</comments>
		<pubDate>Sat, 11 Oct 2008 16:47:51 +0000</pubDate>
		<dc:creator>JohannesTheDeveloper</dc:creator>
				<category><![CDATA[Happy Hacking]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://johannes.jakeapp.com/blog/?p=40</guid>
		<description><![CDATA[I adapted the perl code here:  http://blog.doomicile.de/2008/08/11/moving-dokuwiki-pages-with-perl/
It originally moves pages according to a month/day/year scheme. 
I just wanted to move all the pages to a subnamespace. Here is my script:
#!/usr/bin/perl
use strict;
use WWW::Mechanize;
use WWW::Mechanize::FormFiller;
use URI::URL;
# list with page names
my @urls = `cat liste.txt`;
my $agent = WWW::Mechanize-&#62;new( autocheck =&#62; 1 );
my $formfiller = WWW::Mechanize::FormFiller-&#62;new();
$agent-&#62;env_proxy();
print "Logging in [...]]]></description>
			<content:encoded><![CDATA[<p>I adapted the perl code here:  <a href="http://blog.doomicile.de/2008/08/11/moving-dokuwiki-pages-with-perl/">http://blog.doomicile.de/2008/08/11/moving-dokuwiki-pages-with-perl/</a></p>
<p>It originally moves pages according to a month/day/year scheme. </p>
<p>I just wanted to move all the pages to a subnamespace. Here is my script:</p>
<pre><code>#!/usr/bin/perl
use strict;
use WWW::Mechanize;
use WWW::Mechanize::FormFiller;
use URI::URL;
# list with page names
my @urls = `cat liste.txt`;
my $agent = WWW::Mechanize-&gt;new( autocheck =&gt; 1 );
my $formfiller = WWW::Mechanize::FormFiller-&gt;new();
$agent-&gt;env_proxy();
print "Logging in ... \n";
$agent-&gt;get('http://myurl/wiki/doku.php?do=login');
$agent-&gt;form_number(7) if $agent-&gt;forms and scalar @{ $agent-&gt;forms };
$formfiller-&gt;add_filler( 'u' =&gt; Fixed =&gt; 'myadmin' );
$formfiller-&gt;add_filler( 'p' =&gt; Fixed =&gt; 'mypassword' );
$formfiller-&gt;fill_form( $agent-&gt;current_form );
$agent-&gt;submit();
print "Logging in done.\n";
my $n, my $o, my $p;
foreach (@urls) {
print $_;
( $n, $o ) = m/(.*):([^:]*)/;
$p = 'myprefix:';
if (length($n) == 0) {
$p = 'myprefix';
( $o ) = m/(.*)/;
}
print '=&gt; ' . $p . '|' . $n . '|' . $o . "\n";
$agent-&gt;get( "http://myurl/wiki/doku.php?id=" . $_ . "&amp;do=admin&amp;page=pagemove" );
$agent-&gt;form_number(6) if $agent-&gt;forms and scalar @{ $agent-&gt;forms };
$formfiller-&gt;fill_form( $agent-&gt;current_form );
$formfiller-&gt;fill_form( $agent-&gt;current_form );
if (length($n) == 0) {
$formfiller-&gt;add_filler( 'nsr' =&gt; Fixed =&gt; '' );
$formfiller-&gt;add_filler( 'newns' =&gt; Fixed =&gt; $p );
$formfiller-&gt;add_filler( 'ns' =&gt; Fixed =&gt; $p );
} else {
$formfiller-&gt;add_filler( 'nsr' =&gt; Fixed =&gt; '&lt;new&gt;' );
$formfiller-&gt;add_filler( 'newns' =&gt; Fixed =&gt; $p . $n );
$formfiller-&gt;add_filler( 'ns' =&gt; Fixed =&gt; ':' );
}
$formfiller-&gt;add_filler( 'pagename' =&gt; Fixed =&gt; $o );
$formfiller-&gt;fill_form( $agent-&gt;current_form );
$agent-&gt;save_content("/tmp/mydump.txt");
$agent-&gt;submit();
$agent-&gt;save_content("/tmp/mydump-response.txt");
}</code></pre>
<p>PS: Apparently, I can write perl. I did not know.</p>
]]></content:encoded>
			<wfw:commentRss>http://johannes.jakeapp.com/blog/category/happy-hacking/200810/moving-dokuwiki-pages-to-another-namespace/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NoScript</title>
		<link>http://johannes.jakeapp.com/blog/category/fun-with-linux/200806/noscript</link>
		<comments>http://johannes.jakeapp.com/blog/category/fun-with-linux/200806/noscript#comments</comments>
		<pubDate>Sat, 21 Jun 2008 11:03:16 +0000</pubDate>
		<dc:creator>JohannesTheDeveloper</dc:creator>
				<category><![CDATA[fun with Linux]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://johannes.jakeapp.com/blog/?p=43</guid>
		<description><![CDATA[NoScript opens its own page on every update, which I find very annoying. You can turn that off by the noscript.firstRunRedirection config option (go to about:config).
]]></description>
			<content:encoded><![CDATA[<p>NoScript opens its own page on every update, which I find very annoying. You can turn that off by the noscript.firstRunRedirection config option (go to about:config).</p>
]]></content:encoded>
			<wfw:commentRss>http://johannes.jakeapp.com/blog/category/fun-with-linux/200806/noscript/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deskbar Extension Converter with Calculator functionality</title>
		<link>http://johannes.jakeapp.com/blog/category/happy-hacking/200806/deskbar-extension-converter-with-calculator-functionality</link>
		<comments>http://johannes.jakeapp.com/blog/category/happy-hacking/200806/deskbar-extension-converter-with-calculator-functionality#comments</comments>
		<pubDate>Sun, 08 Jun 2008 11:52:40 +0000</pubDate>
		<dc:creator>JohannesTheDeveloper</dc:creator>
				<category><![CDATA[Happy Hacking]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://johannes.jakeapp.com/blog/?p=63</guid>
		<description><![CDATA[Ever wanted to get answers to questions like the following?
3 kilometers in meters
6000 gallons in litres
1E+06 au in pc
7*4 EUR in dollars
0x5621*sin(3)+16 euro in dollar
$ 0.50*100/3 in euro
-L- 0.50 in euro
15 kg/m^3 in g/cm^3
3E+09*sin(3)+pow(3,10) kg/m^3 in g/cm^3
3 1000 in 1
And that quickly, from your desktop?
There existed a Converter and a Calculator extension, I made them [...]]]></description>
			<content:encoded><![CDATA[<p>Ever wanted to get answers to questions like the following?</p>
<pre>3 kilometers in meters
6000 gallons in litres
1E+06 au in pc
7*4 EUR in dollars
0x5621*sin(3)+16 euro in dollar
$ 0.50*100/3 in euro
-L- 0.50 in euro
15 kg/m^3 in g/cm^3
3E+09*sin(3)+pow(3,10) kg/m^3 in g/cm^3
3 1000 in 1</pre>
<p>And that quickly, from your desktop?</p>
<p>There existed a Converter and a Calculator extension, I made them work together.</p>
<p><img width="487" height="224" title="" src="http://johannes.jakeapp.com/blog/oldblog/images/Converter-with-Calculator.png" alt="Converter-with-Calculator" /></p>
<p><strong>Download: <a title="" href="http://johannes.jakeapp.com/blog/oldblog/files/converterplus-1.9.tar.bz2" as="link">converterplus-1.9.tar</a> (bz2, 9 KB)  <strike><a title="" href="http://johannes.jakeapp.com/blog/oldblog/files/converterplus-1.8.tar.bz2" as="link">converterplus-1.8.tar</a> (bz2, 6 KB)</strike> </strong><br />
<strong>Howto install:</strong><br />
You have to copy both files from the archive to ~/.gnome2/deskbar-applet/modules-2.20-compatible/, then activate them in the deskbar-applet Preferences.</p>
<p><strong>Old versions of Converter and Calculator will not work together!</strong><br />
You can easily check if you got the right versions: They have my name as author in them and contain the line &#8220;This version of calculator can be used with converter&#8221; and vice versa.</p>
<p><strong>You need to have the program units installed</strong> to benefit from Calculator. It is in your distribution&#8217;s repository under the name &#8216;units&#8217;.</p>
<p><strong>Bugs:</strong> Please send bug reports by email or leave a comment here.</p>
<p><b>Technical details:</b><br />
(users don&#8217;t need to read this)</p>
<p>The question was to either copy over the code from Calculator to Converter or to reuse the Module. Code duplication (DRY) was a definite argument against that. If Calculators code gets updated, Converter benefits too. Also, you can enable each functionality seperately.</p>
<p>Problem was to access the other module when loaded in deskbar, I made a hack for loading a file in the same directory, no matter of the context (see source).</p>
]]></content:encoded>
			<wfw:commentRss>http://johannes.jakeapp.com/blog/category/happy-hacking/200806/deskbar-extension-converter-with-calculator-functionality/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Latex: Table converter</title>
		<link>http://johannes.jakeapp.com/blog/category/happy-hacking/200804/latex-table-converter</link>
		<comments>http://johannes.jakeapp.com/blog/category/happy-hacking/200804/latex-table-converter#comments</comments>
		<pubDate>Tue, 15 Apr 2008 22:18:00 +0000</pubDate>
		<dc:creator>JohannesTheDeveloper</dc:creator>
				<category><![CDATA[Happy Hacking]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://johannes.jakeapp.com/blog/?p=49</guid>
		<description><![CDATA[If you copy-paste a table out of open-office, it is usually one line per cell.
This Python script converts it into a LaTeX-table (without \begin and \end):
table2latex.py:
#!/usr/bin/env python

import sys

f = sys.stdin

if(len(sys.argv) &#60; 2):

        print "First Argument is number of columns"

        sys.exit(1)

numcolumns = [...]]]></description>
			<content:encoded><![CDATA[<p><b>If you copy-paste a table out of open-office, it is usually one line per cell.</b></p>
<p>This Python script <b>converts it into a LaTeX-table</b> (without \begin and \end):</p>
<p><b>table2latex.py:</b></p>
<pre><code>#!/usr/bin/env python

import sys

f = sys.stdin

if(len(sys.argv) &lt; 2):

        print "First Argument is number of columns"

        sys.exit(1)

numcolumns = int(sys.argv[1])

borders = False

if len(sys.argv) &gt; 2 and sys.argv[2] == "--with-borders":

        borders = True

i = 0

while True:

        for j in range(numcolumns):

                l = f.readline()

                if l == "":

                        sys.exit(0)

                if i == 0:

                        print "\\tablehdr{%s}" % l.strip(),

                else:

                        print "%s" % l.strip(),

                if j == numcolumns - 1:

                        print '\\\\'

                        if borders:

                                print '\hline'

                else:

                        print '&amp;',

        i = i + 1</code></pre>
<p>Use it like this (pipe in from stdin, first arg is column count): </p>
<pre><code>[user@thiscomputer ~]$ seq 30 | python table2latex.py 3

\tablehdr{1} &amp; \tablehdr{2} &amp; \tablehdr{3} \\

4 &amp; 5 &amp; 6 \\

7 &amp; 8 &amp; 9 \\

10 &amp; 11 &amp; 12 \\

13 &amp; 14 &amp; 15 \\

16 &amp; 17 &amp; 18 \\

19 &amp; 20 &amp; 21 \\

22 &amp; 23 &amp; 24 \\

25 &amp; 26 &amp; 27 \\

28 &amp; 29 &amp; 30 \\

[user@thiscomputer ~]$ </code></pre>
<p>The second argument can be if borders should be used, i.e. \hline after each row.</p>
]]></content:encoded>
			<wfw:commentRss>http://johannes.jakeapp.com/blog/category/happy-hacking/200804/latex-table-converter/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TU: TIL Tutors helper</title>
		<link>http://johannes.jakeapp.com/blog/category/happy-hacking/200804/tu-til-tutors-helper</link>
		<comments>http://johannes.jakeapp.com/blog/category/happy-hacking/200804/tu-til-tutors-helper#comments</comments>
		<pubDate>Fri, 11 Apr 2008 22:24:00 +0000</pubDate>
		<dc:creator>JohannesTheDeveloper</dc:creator>
				<category><![CDATA[Happy Hacking]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://johannes.jakeapp.com/blog/?p=50</guid>
		<description><![CDATA[This is a script only of interest to tutors in TIL, who use sbt.logic.at for entering students data. It sets the edited selection when one enters gradings sbt-logic-at.user (js, 2 KB).
Install Greasemonkey first, then click the link or download and add manually.
]]></description>
			<content:encoded><![CDATA[<p>This is a script only of interest to tutors in TIL, who use sbt.logic.at for entering students data. It sets the edited selection when one enters gradings <a title="" href="http://johannes.jakeapp.com/blog/oldblog/files/sbt-logic-at.user.js" as="link">sbt-logic-at.user</a> (js, 2 KB).<br />
Install <a href="https://addons.mozilla.org/en-US/firefox/addon/748">Greasemonkey</a> first, then click the link or download and add manually.</p>
]]></content:encoded>
			<wfw:commentRss>http://johannes.jakeapp.com/blog/category/happy-hacking/200804/tu-til-tutors-helper/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Python: HTML database descriptions from create statements</title>
		<link>http://johannes.jakeapp.com/blog/category/happy-hacking/200804/python-html-database-descriptions-from-create-statements</link>
		<comments>http://johannes.jakeapp.com/blog/category/happy-hacking/200804/python-html-database-descriptions-from-create-statements#comments</comments>
		<pubDate>Wed, 02 Apr 2008 00:25:13 +0000</pubDate>
		<dc:creator>JohannesTheDeveloper</dc:creator>
				<category><![CDATA[Happy Hacking]]></category>
		<category><![CDATA[thisreallyworks]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://johannes.jakeapp.com/blog/?p=53</guid>
		<description><![CDATA[This code produces HTML database descriptions from create statements.
Feed into stdin, await from stdout.
For example: python dbdesc.py &#60; DATASCHEME &#62; dbdesc.html
It isn&#8217;t perfect nor meant to be, but gives a good starting point for a documentation.
#!/usr/bin/python
import sys
import re
a = ''
for i in sys.stdin.readlines():
a = a + " " + re.sub('--.*', '', i).strip()
a = a.strip().lower()
a = [...]]]></description>
			<content:encoded><![CDATA[<p>This code produces HTML database descriptions from create statements.</p>
<p>Feed into stdin, await from stdout.<br />
For example: <b>python dbdesc.py &lt; DATASCHEME &gt; dbdesc.html</b></p>
<p>It isn&#8217;t perfect nor meant to be, but gives a good starting point for a documentation.</p>
<pre><code>#!/usr/bin/python
import sys
import re
a = ''
for i in sys.stdin.readlines():
a = a + " " + re.sub('--.*', '', i).strip()
a = a.strip().lower()
a = re.sub('\/\*[^*]*\*\/', '', a)
print """
&lt;html&gt;
&lt;head&gt;
&lt;link rel="stylesheet" href="dbdesc.css" /&gt;
&lt;/head&gt;
&lt;body&gt;
"""
for m in re.findall('create table ([^ (]*)[ (]*([^;]*)[ )]*;', a):
tablename = m[0]
content = m[1]
print "&lt;h2&gt;%s&lt;/h2&gt;"  % tablename
print """&lt;table class="dbdesc"&gt;&lt;thead&gt;&lt;tr&gt;
&lt;th class="name"&gt;Feldname&lt;/th&gt;
&lt;th class="type"&gt;Typ&lt;/th&gt;
&lt;th class="option"&gt;Option&lt;/th&gt;
&lt;th class="comment"&gt;Bemerkung&lt;/th&gt;
&lt;/tr&gt;&lt;/thead&gt;"""
atts = {}
for l in content.split(','):
l = l.strip()
if l == '':
continue
if l.startswith('constraint') or l.startswith('foreign key'):
continue
l = l.split(None, 2)
if len(l)&lt;2:
continue
name = l[0]
if name == 'constraint' or name.__contains__('(') or name.__contains__(')'):
continue
type = l[1]
if len(l)&lt;3:
l.append('')
op = ""
if 'not null' in l[2]:       op = op + '!'
if 'primary key' in l[2]:    op = op + '1+P'
elif 'unique' in l[2]:       op = op + '1'
print """ &lt;tr&gt;
&lt;td class="name"&gt;%s&lt;/td&gt;
&lt;td class="type"&gt;%s&lt;/td&gt;
&lt;td class="option"&gt;%s&lt;/td&gt;
&lt;td class="comment"&gt;&lt;!-- TODO: Bemerkungen --&gt;&lt;/td&gt;
&lt;/tr&gt;""" % (name, type, op)
print """ &lt;/table&gt; """
print """&lt;/html&gt; """
</code></pre>
<p>CSS file dbdesc.css</p>
<pre><code>table.dbdesc{	width: 40em;	border: 1px solid #080;	border-width: 1px 0;}
table.dbdesc th{	border-bottom: 1px solid #080;}
table.dbdesc td{	border: none;}
table.dbdesc td, table.dbdesc th{	width: 15em;}
table.dbdesc th{	font-style: italic;	font-weight: normal; }
table.dbdesc td.option{	text-align: center;}
table.dbdesc td.type{	text-transform: uppercase;}
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://johannes.jakeapp.com/blog/category/happy-hacking/200804/python-html-database-descriptions-from-create-statements/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Skype: Chat Messages/History log file format</title>
		<link>http://johannes.jakeapp.com/blog/category/happy-hacking/200803/skype-chat-messageshistory-log-file-format</link>
		<comments>http://johannes.jakeapp.com/blog/category/happy-hacking/200803/skype-chat-messageshistory-log-file-format#comments</comments>
		<pubDate>Sun, 02 Mar 2008 21:16:05 +0000</pubDate>
		<dc:creator>JohannesTheDeveloper</dc:creator>
				<category><![CDATA[Happy Hacking]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://johannes.jakeapp.com/blog/?p=58</guid>
		<description><![CDATA[To be able to search and use the Skype chat log, message history, and call history I reverse-engineered the Skype file format of chatmsg256.dbb, chatmsg512.dbb, callmember256.dbb, &#8230; files.
I made a script able to export the history to html, as well as Python classes able to random-access the logs.
As far as I can see, I&#8217;m the [...]]]></description>
			<content:encoded><![CDATA[<p>To be able to search and use the Skype chat log, message history, and call history I reverse-engineered the <b>Skype file format</b> of chatmsg256.dbb, chatmsg512.dbb, callmember256.dbb, &#8230; files.</p>
<p>I made a script able to <b>export the history to html</b>, as well as Python classes able to random-access the logs.</p>
<p>As far as I can see, I&#8217;m the first one on the net that did this, everyone else is sane and uses the API.</p>
<p>You can view and edit all information here: <a href="http://johbuc6.coconia.net/doku.php/skype/start">http://johbuc6.coconia.net/doku.php/skype/start</a></p>
]]></content:encoded>
			<wfw:commentRss>http://johannes.jakeapp.com/blog/category/happy-hacking/200803/skype-chat-messageshistory-log-file-format/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
