rss_content.xml - www.codemadness.org - www.codemadness.org saait content files
(HTM) git clone git://git.codemadness.org/www.codemadness.org
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
rss_content.xml (161623B)
---
1 <?xml version="1.0" encoding="UTF-8"?>
2 <rss version="2.0"
3 xmlns:content="http://purl.org/rss/1.0/modules/content/"
4 xmlns:dc="http://purl.org/dc/elements/1.1/">
5 <channel>
6 <title>Codemadness</title>
7 <description>blog with various projects and articles about computer-related things</description>
8 <link>https://www.codemadness.org</link>
9 <item>
10 <title>Chess puzzle book generator</title>
11 <link>https://www.codemadness.org/chess-puzzles.html</link>
12 <guid>https://www.codemadness.org/chess-puzzles.html</guid>
13 <dc:date>2024-02-02T00:00:00Z</dc:date>
14 <author>Hiltjo</author>
15 <description><![CDATA[<h1>Chess puzzle book generator</h1>
16 <p><strong>Last modification on </strong> <time>2025-05-03</time></p>
17 <p>This was a christmas hack for fun and non-profit.
18 I wanted to write a chess puzzle book generator.
19 Inspired by <a href="https://archive.org/details/1001deadlycheckm0000nunn">1001 Deadly Checkmates by John Nunn, ISBN-13: 978-1906454258</a>,
20 <a href="https://www.stappenmethode.nl/en/">Steps Method workbooks</a> and other puzzle books.</p>
21 <h1>Example output</h1>
22 <ul>
23 <li>English version: <a href="https://codemadness.org/downloads/puzzles/">https://codemadness.org/downloads/puzzles/</a></li>
24 <li>Dutch version: <a href="https://hiltjo.nl/puzzles/">https://hiltjo.nl/puzzles/</a></li>
25 </ul>
26 <p>Terminal version:</p>
27 <pre><code>curl -s 'https://codemadness.org/downloads/puzzles/index.vt' | less -R
28 </code></pre>
29 <p>I may or may not periodially update this page :)</p>
30 <p>Time flies (since Christmas), here is a valentine edition with <a href="https://lichess.org/practice/intermediate-tactics/attraction/">attraction</a>
31 puzzles (not only checkmates) using the red "love" theme.
32 It is optimized for his and her pleasure:</p>
33 <p><a href="https://codemadness.org/downloads/puzzles-valentine/">https://codemadness.org/downloads/puzzles-valentine/</a></p>
34 <h2>Clone</h2>
35 <pre><code>git clone git://git.codemadness.org/chess-puzzles
36 </code></pre>
37 <h2>Browse</h2>
38 <p>You can browse the source-code at:</p>
39 <ul>
40 <li><a href="https://git.codemadness.org/chess-puzzles/">https://git.codemadness.org/chess-puzzles/</a></li>
41 <li><a href="gopher://codemadness.org/1/git/chess-puzzles">gopher://codemadness.org/1/git/chess-puzzles</a></li>
42 </ul>
43 <h1>Quick overview of how it works</h1>
44 <p>The generate.sh shellscript generates the output and files for the puzzles.</p>
45 <p>The puzzles used are from the lichess.org puzzle database:
46 <a href="https://database.lichess.org/#puzzles">https://database.lichess.org/#puzzles</a></p>
47 <p>This database is a big CSV file containing the initial board state in the
48 Forsyth-Edwards Notation (FEN) format and the moves in Universal Chess
49 Interface (UCI) format. Each line contains the board state and the initial and
50 solution moves.</p>
51 <p>The generated index page is a HTML page, it lists the puzzles. Each puzzle on
52 this page is an SVG image. This scalable image format looks good in all
53 resolutions.</p>
54 <h1>Open puzzle data</h1>
55 <p>Lichess is an <a href="https://lichess.org/source">open-source</a> and gratis website to play on-line chess. There are
56 no paid levels to unlock features. All the software hosting Lichess is
57 open-source and anyone can register and play chess on it for free. Most of the
58 data about the games played is also open.</p>
59 <p>However, the website depends on your donations or contributions. If you can,
60 <a href="https://lichess.org/about">please do so</a>.</p>
61 <h1>generate.sh</h1>
62 <p>Reads puzzles from the database and shuffle them. Do some rough sorting and
63 categorization based on difficulty and assign score points.</p>
64 <p>The random shuffling is done using a hard-coded <a href="https://en.wikipedia.org/wiki/Random_seed">random seed</a>. This means on the
65 same machine with the same puzzle database it will regenerate the same sequence
66 of random puzzles in a deterministic manner.</p>
67 <p>It outputs HTML, with support for CSS dark mode and does not require Javascript.
68 It includes a plain-text listing of the solutions in PGN notation for the
69 puzzles.
70 It also outputs .vt files suitable for the terminal. It uses unicode symbols
71 for the chess pieces and RGB color sequence for the board theme</p>
72 <h1>fen.c</h1>
73 <p>This is a program written in C to read and parse the board state in FEN format
74 and read the UCI moves. It can output to various formats.</p>
75 <p>See the man page for detailed usage information.</p>
76 <p>fen.c supports the following output formats:</p>
77 <ul>
78 <li>ascii - very simple ASCII mode.</li>
79 <li><a href="https://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notation">fen</a> - output FEN of the board state (from FEN and optional played moves).</li>
80 <li><a href="https://en.wikipedia.org/wiki/Portable_Game_Notation">pgn</a> - Portable Game Notation.</li>
81 <li>speak - mode to output a description of the moves in words.</li>
82 <li><a href="https://en.wikipedia.org/wiki/SVG">SVG</a> - Scalable Vector Graphics image.</li>
83 <li>tty - Terminal output with some markup using escape codes.</li>
84 </ul>
85 <p>fen.c can also run in <a href="https://en.wikipedia.org/wiki/Common_Gateway_Interface">CGI</a> mode. This can be used on a HTTP server:</p>
86 <p><img src="https://codemadness.org/onlyfens?fen=6k1/ppq3bp/2n2np1/5p2/2P2P2/4rBN1/PP3K1P/RQ6%20w%20-%20-%200%2023&moves=f2e3&flip=1" alt="Position from game: Rene Letelier Martner - Robert James Fischer, 1960-10-24" /></p>
87 <ul>
88 <li><a href="https://codemadness.org/onlyfens">https://codemadness.org/onlyfens</a></li>
89 <li><a href="https://codemadness.org/onlyfens?fen=6k1/ppq3bp/2n2np1/5p2/2P2P2/4rBN1/PP3K1P/RQ6%20w%20-%20-%200%2023&moves=f2e3&flip=1">https://codemadness.org/onlyfens?fen=6k1/ppq3bp/2n2np1/5p2/2P2P2/4rBN1/PP3K1P/RQ6%20w%20-%20-%200%2023&moves=f2e3&flip=1</a></li>
90 <li><a href="https://codemadness.org/onlyfens?moves=e2e4%20e7e5&flip=1&theme=green&output=svg">https://codemadness.org/onlyfens?moves=e2e4%20e7e5&flip=1&theme=green&output=svg</a></li>
91 <li><a href="https://codemadness.org/onlyfens?moves=e2e4%20e7e5&output=pgn">https://codemadness.org/onlyfens?moves=e2e4%20e7e5&output=pgn</a></li>
92 <li><a href="https://codemadness.org/onlyfens?moves=e2e4%20e7e5&output=speak">https://codemadness.org/onlyfens?moves=e2e4%20e7e5&output=speak</a></li>
93 <li><a href="https://codemadness.org/onlyfens?moves=e2e4%20e7e5&output=ascii">https://codemadness.org/onlyfens?moves=e2e4%20e7e5&output=ascii</a></li>
94 <li><a href="https://codemadness.org/onlyfens?moves=e2e4%20e7e5&output=fen">https://codemadness.org/onlyfens?moves=e2e4%20e7e5&output=fen</a></li>
95 </ul>
96 <p>Terminal output:</p>
97 <pre><code>curl -s 'https://codemadness.org/onlyfens?moves=e2e4%20e7e5&output=tty'
98 </code></pre>
99 <h1>Support for Dutch notated PGN and output</h1>
100 <p>For pgn and "speak mode" it has an option to output Dutch notated PGN or speech
101 too.</p>
102 <p>For example:</p>
103 <ul>
104 <li>Queen = Dame (Q -> D), translated: lady.</li>
105 <li>Rook = Toren (R -> T), translated: tower.</li>
106 <li>Bishop = Loper (B -> L), translated: walker.</li>
107 <li>Knight = Paard (N -> P), translated: horse.</li>
108 </ul>
109 <h1>Example script to stream games from Lichess</h1>
110 <p>There is an included example script that can stream Lichess games to the
111 terminal. It uses the <a href="https://lichess.org/api">Lichess API</a>. It will display the board using terminal
112 escape codes. The games are automatically annotated with PGN notation and with
113 text how a human would say the notation. This can also be piped to a speech
114 synthesizer like <a href="https://github.com/espeak-ng/espeak-ng/">espeak</a> as audio.</p>
115 <p>pgn-extract is a useful tool to convert Portable Game Notation (PGN) to
116 Universal Chess Interface (UCI) moves (or do many other useful chess related
117 things!).</p>
118 <h1>Example script to generate an animated gif from PGN</h1>
119 <p>Theres also an example script included that can generate an animated gif from
120 PGN using <a href="https://ffmpeg.org/">ffmpeg</a>.</p>
121 <p>It creates an optimal color palette from the input images and generates an
122 optimized animated gif. The last move (typically some checkmate) is displayed
123 slightly longer.</p>
124 <h1>References and chess related links</h1>
125 <ul>
126 <li><p>chess-puzzles source-code:<br />
127 <a href="https://www.codemadness.org/git/chess-puzzles/file/README.html">https://www.codemadness.org/git/chess-puzzles/file/README.html</a></p>
128 </li>
129 <li><p>Lichess FEN puzzle database:<br />
130 <a href="https://database.lichess.org/#puzzles">https://database.lichess.org/#puzzles</a></p>
131 </li>
132 <li><p>lichess.org:<br />
133 <a href="https://lichess.org/">https://lichess.org/</a></p>
134 </li>
135 <li><p>SVG of the individual pieces used in fen.c:<br />
136 <a href="https://github.com/lichess-org/lila/tree/master/public/piece/cburnett">https://github.com/lichess-org/lila/tree/master/public/piece/cburnett</a></p>
137 </li>
138 <li><p>pgn-extract:<br />
139 A great multi-purpose PGN manipulation program with many options:<br />
140 <a href="https://www.cs.kent.ac.uk/people/staff/djb/pgn-extract/">https://www.cs.kent.ac.uk/people/staff/djb/pgn-extract/</a></p>
141 <p>An example to convert PGN games to UCI moves:<br />
142 <code>pgn-extract --notags -Wuc</code></p>
143 </li>
144 <li><p>Lichess API:<br />
145 <a href="https://lichess.org/api">https://lichess.org/api</a></p>
146 </li>
147 <li><p>Stockfish:<br />
148 Strong open-source chess engine and analysis tool:<br />
149 <a href="https://stockfishchess.org/">https://stockfishchess.org/</a></p>
150 </li>
151 </ul>
152 ]]></description>
153 </item>
154 <item>
155 <title>xargs: an example for parallel batch jobs</title>
156 <link>https://www.codemadness.org/xargs.html</link>
157 <guid>https://www.codemadness.org/xargs.html</guid>
158 <dc:date>2023-11-22T00:00:00Z</dc:date>
159 <author>Hiltjo</author>
160 <description><![CDATA[<h1>xargs: an example for parallel batch jobs</h1>
161 <p><strong>Last modification on </strong> <time>2023-12-17</time></p>
162 <p>This describes a simple shellscript programming pattern to process a list of
163 jobs in parallel. This script example is contained in one file.</p>
164 <h1>Simple but less optimal example</h1>
165 <pre><code>#!/bin/sh
166 maxjobs=4
167
168 # fake program for example purposes.
169 someprogram() {
170 echo "Yep yep, I'm totally a real program!"
171 sleep "$1"
172 }
173
174 # run(arg1, arg2)
175 run() {
176 echo "[$1] $2 started" >&2
177 someprogram "$1" >/dev/null
178 status="$?"
179 echo "[$1] $2 done" >&2
180 return "$status"
181 }
182
183 # process the jobs.
184 j=1
185 for f in 1 2 3 4 5 6 7 8 9 10; do
186 run "$f" "something" &
187
188 jm=$((j % maxjobs)) # shell arithmetic: modulo
189 test "$jm" = "0" && wait
190 j=$((j+1))
191 done
192 wait
193 </code></pre>
194 <h1>Why is this less optimal</h1>
195 <p>This is less optimal because it waits until all jobs in the same batch are finished
196 (each batch contain $maxjobs items).</p>
197 <p>For example with 2 items per batch and 4 total jobs it could be:</p>
198 <ul>
199 <li>Job 1 is started.</li>
200 <li>Job 2 is started.</li>
201 <li>Job 2 is done.</li>
202 <li>Job 1 is done.</li>
203 <li>Wait: wait on process status of all background processes.</li>
204 <li>Job 3 in new batch is started.</li>
205 </ul>
206 <p>This could be optimized to:</p>
207 <ul>
208 <li>Job 1 is started.</li>
209 <li>Job 2 is started.</li>
210 <li>Job 2 is done.</li>
211 <li>Job 3 in new batch is started (immediately).</li>
212 <li>Job 1 is done.</li>
213 <li>...</li>
214 </ul>
215 <p>It also does not handle signals such as SIGINT (^C). However the xargs example
216 below does:</p>
217 <h1>Example</h1>
218 <pre><code>#!/bin/sh
219 maxjobs=4
220
221 # fake program for example purposes.
222 someprogram() {
223 echo "Yep yep, I'm totally a real program!"
224 sleep "$1"
225 }
226
227 # run(arg1, arg2)
228 run() {
229 echo "[$1] $2 started" >&2
230 someprogram "$1" >/dev/null
231 status="$?"
232 echo "[$1] $2 done" >&2
233 return "$status"
234 }
235
236 # child process job.
237 if test "$CHILD_MODE" = "1"; then
238 run "$1" "$2"
239 exit "$?"
240 fi
241
242 # generate a list of jobs for processing.
243 list() {
244 for f in 1 2 3 4 5 6 7 8 9 10; do
245 printf '%s\0%s\0' "$f" "something"
246 done
247 }
248
249 # process jobs in parallel.
250 list | CHILD_MODE="1" xargs -r -0 -P "${maxjobs}" -L 2 "$(readlink -f "$0")"
251 </code></pre>
252 <h1>Run and timings</h1>
253 <p>Although the above example is kindof stupid, it already shows the queueing of
254 jobs is more efficient.</p>
255 <p>Script 1:</p>
256 <pre><code>time ./script1.sh
257 [...snip snip...]
258 real 0m22.095s
259 </code></pre>
260 <p>Script 2:</p>
261 <pre><code>time ./script2.sh
262 [...snip snip...]
263 real 0m18.120s
264 </code></pre>
265 <h1>How it works</h1>
266 <p>The parent process:</p>
267 <ul>
268 <li>The parent, using xargs, handles the queue of jobs and schedules the jobs to
269 execute as a child process.</li>
270 <li>The list function writes the parameters to stdout. These parameters are
271 separated by the NUL byte separator. The NUL byte separator is used because
272 this character cannot be used in filenames (which can contain spaces or even
273 newlines) and cannot be used in text (the NUL byte terminates the buffer for
274 a string).</li>
275 <li>The -L option must match the amount of arguments that are specified for the
276 job. It will split the specified parameters per job.</li>
277 <li>The expression "$(readlink -f "$0")" gets the absolute path to the
278 shellscript itself. This is passed as the executable to run for xargs.</li>
279 <li>xargs calls the script itself with the specified parameters it is being fed.
280 The environment variable $CHILD_MODE is set to indicate to the script itself
281 it is run as a child process of the script.</li>
282 </ul>
283 <p>The child process:</p>
284 <ul>
285 <li><p>The command-line arguments are passed by the parent using xargs.</p>
286 </li>
287 <li><p>The environment variable $CHILD_MODE is set to indicate to the script itself
288 it is run as a child process of the script.</p>
289 </li>
290 <li><p>The script itself (ran in child-mode process) only executes the task and
291 signals its status back to xargs and the parent.</p>
292 </li>
293 <li><p>The exit status of the child program is signaled to xargs. This could be
294 handled, for example to stop on the first failure (in this example it is not).
295 For example if the program is killed, stopped or the exit status is 255 then
296 xargs stops running also.</p>
297 </li>
298 </ul>
299 <h1>Description of used xargs options</h1>
300 <p>From the OpenBSD man page: <a href="https://man.openbsd.org/xargs">https://man.openbsd.org/xargs</a></p>
301 <pre><code>xargs - construct argument list(s) and execute utility
302 </code></pre>
303 <p>Options explained:</p>
304 <ul>
305 <li>-r: Do not run the command if there are no arguments. Normally the command
306 is executed at least once even if there are no arguments.</li>
307 <li>-0: Change xargs to expect NUL ('\0') characters as separators, instead of
308 spaces and newlines.</li>
309 <li>-P maxprocs: Parallel mode: run at most maxprocs invocations of utility
310 at once.</li>
311 <li>-L number: Call utility for every number of non-empty lines read. A line
312 ending in unescaped white space and the next non-empty line are considered
313 to form one single line. If EOF is reached and fewer than number lines have
314 been read then utility will be called with the available lines.</li>
315 </ul>
316 <h1>xargs options -0 and -P, portability and historic context</h1>
317 <p>Some of the options, like -P are as of writing (2023) non-POSIX:
318 <a href="https://pubs.opengroup.org/onlinepubs/9699919799/utilities/xargs.html">https://pubs.opengroup.org/onlinepubs/9699919799/utilities/xargs.html</a>.
319 However many systems support this useful extension for many years now.</p>
320 <p>The specification even mentions implementations which support parallel
321 operations:</p>
322 <p>"The version of xargs required by this volume of POSIX.1-2017 is required to
323 wait for the completion of the invoked command before invoking another command.
324 This was done because historical scripts using xargs assumed sequential
325 execution. Implementations wanting to provide parallel operation of the invoked
326 utilities are encouraged to add an option enabling parallel invocation, but
327 should still wait for termination of all of the children before xargs
328 terminates normally."</p>
329 <p>Some historic context:</p>
330 <p>The xargs -0 option was added on 1996-06-11 by Theo de Raadt, about a year
331 after the NetBSD import (over 27 years ago at the time of writing):</p>
332 <p><a href="http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/xargs/xargs.c?rev=1.2&content-type=text/x-cvsweb-markup">CVS log</a></p>
333 <p>On OpenBSD the xargs -P option was added on 2003-12-06 by syncing the FreeBSD
334 code:</p>
335 <p><a href="http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/xargs/xargs.c?rev=1.14&content-type=text/x-cvsweb-markup">CVS log</a></p>
336 <p>Looking at the imported git history log of GNU findutils (which has xargs), the
337 very first commit already had the -0 and -P option:</p>
338 <p><a href="https://savannah.gnu.org/git/?group=findutils">git log</a></p>
339 <pre><code>commit c030b5ee33bbec3c93cddc3ca9ebec14c24dbe07
340 Author: Kevin Dalley <kevin@seti.org>
341 Date: Sun Feb 4 20:35:16 1996 +0000
342
343 Initial revision
344 </code></pre>
345 <h1>xargs: some incompatibilities found</h1>
346 <ul>
347 <li>Using the -0 option empty fields are handled differently in different
348 implementations.</li>
349 <li>The -n and -L option doesn't work correctly in many of the BSD implementations.
350 Some count empty fields, some don't. In early implementations in FreeBSD and
351 OpenBSD it only processed the first line. In OpenBSD it has been improved
352 around 2017.</li>
353 </ul>
354 <p>Depending on what you want to do a workaround could be to use the -0 option
355 with a single field and use the -n flag. Then in each child program invocation
356 split the field by a separator.</p>
357 <h1>References</h1>
358 <ul>
359 <li>xargs: <a href="https://man.openbsd.org/xargs">https://man.openbsd.org/xargs</a></li>
360 <li>printf: <a href="https://man.openbsd.org/printf">https://man.openbsd.org/printf</a></li>
361 <li>ksh, wait: <a href="https://man.openbsd.org/ksh#wait">https://man.openbsd.org/ksh#wait</a></li>
362 <li>wait(2): <a href="https://man.openbsd.org/wait">https://man.openbsd.org/wait</a></li>
363 </ul>
364 ]]></description>
365 </item>
366 <item>
367 <title>Improved Youtube RSS/Atom feed</title>
368 <link>https://www.codemadness.org/youtube-feed.html</link>
369 <guid>https://www.codemadness.org/youtube-feed.html</guid>
370 <dc:date>2023-11-20T00:00:00Z</dc:date>
371 <author>Hiltjo</author>
372 <description><![CDATA[<h1>Improved Youtube RSS/Atom feed</h1>
373 <p><strong>Last modification on </strong> <time>2023-11-20</time></p>
374 <p>... improved at least for my preferences ;)</p>
375 <p>It scrapes the channel data from Youtube and combines it with the parsed Atom
376 feed from the channel on Youtube.</p>
377 <p>The Atom parser is based on sfeed, with some of the code removed because it is
378 not needed by this program. It scrapes the metadata of the videos from the
379 channel its HTML page and uses my custom JSON parser to convert the
380 Javascript/JSON structure.</p>
381 <p>This parser is also used by the <a href="json2tsv.html">json2tsv</a> tool. It has few dependencies.</p>
382 <h2>Features</h2>
383 <ul>
384 <li>Add the video duration to the title to quickly see how long the video is.</li>
385 <li>Filter away Youtube shorts and upcoming videos / announcements: only videos are shown.</li>
386 <li>Supports more output formats: Atom, <a href="https://www.jsonfeed.org/version/1.1/">JSON Feed</a> or
387 <a href="sfeed.1.txt">sfeed</a> Tab-Separated-Value format.</li>
388 <li>Easy to build and deploy: can be run as a CGI program as a static-linked
389 binary in a chroot.</li>
390 <li>Secure: additionally to running in a chroot it can use pledge(2) and unveil(2)
391 on OpenBSD to restrict system calls and access to the filesystem.</li>
392 </ul>
393 <h2>How to use</h2>
394 <p>There is an option to run directly from the command-line or in CGI-mode. When
395 the environment variable $REQUEST_URI is set then it is automatically run in
396 CGI mode.</p>
397 <p>Command-line usage:</p>
398 <pre><code>youtube_feed channelid atom
399 youtube_feed channelid gph
400 youtube_feed channelid html
401 youtube_feed channelid json
402 youtube_feed channelid tsv
403 youtube_feed channelid txt
404 </code></pre>
405 <p>CGI program usage:</p>
406 <p>The last basename part of the URL should be the channelid + the output format
407 extension. It defaults to TSV if there is no extension.
408 The CGI program can be used with a HTTPd or a Gopher daemon such as geomyidae.</p>
409 <p>For example:</p>
410 <pre><code>Atom XML: https://codemadness.org/yt-chan/UCrbvoMC0zUvPL8vjswhLOSw.xml
411 HTML: https://codemadness.org/yt-chan/UCrbvoMC0zUvPL8vjswhLOSw.html
412 JSON: https://codemadness.org/yt-chan/UCrbvoMC0zUvPL8vjswhLOSw.json
413 TSV: https://codemadness.org/yt-chan/UCrbvoMC0zUvPL8vjswhLOSw.tsv
414 twtxt: https://codemadness.org/yt-chan/UCrbvoMC0zUvPL8vjswhLOSw.txt
415 TSV, default: https://codemadness.org/yt-chan/UCrbvoMC0zUvPL8vjswhLOSw
416
417 Gopher dir: gopher://codemadness.org/1/feed.cgi/UCrbvoMC0zUvPL8vjswhLOSw.gph
418 Gopher TSV: gopher://codemadness.org/0/feed.cgi/UCrbvoMC0zUvPL8vjswhLOSw
419 </code></pre>
420 <p>An OpenBSD httpd.conf using slowcgi as an example:</p>
421 <pre><code>server "codemadness.org" {
422 location "/yt-chan/*" {
423 request strip 1
424 root "/cgi-bin/yt-chan"
425 fastcgi socket "/run/slowcgi.sock"
426 }
427 }
428 </code></pre>
429 <h2>Using it with <a href="sfeed.html">sfeed</a></h2>
430 <p>sfeedrc example of an existing Youtube RSS/Atom feed:</p>
431 <pre><code># list of feeds to fetch:
432 feeds() {
433 # feed <name> <feedurl> [basesiteurl] [encoding]
434 # normal Youtube Atom feed.
435 feed "yt IM" "https://www.youtube.com/feeds/videos.xml?channel_id=UCrbvoMC0zUvPL8vjswhLOSw"
436 }
437 </code></pre>
438 <p>Use the new Atom feed directly using the CGI-mode and Atom output format:</p>
439 <pre><code># list of feeds to fetch:
440 feeds() {
441 # feed <name> <feedurl> [basesiteurl] [encoding]
442 # new Youtube Atom feed.
443 feed "idiotbox IM" "https://codemadness.org/yt-chan/UCrbvoMC0zUvPL8vjswhLOSw.xml"
444 }
445 </code></pre>
446 <p>... or convert directly using a custom connector program on the local system via the command-line:</p>
447 <pre><code># fetch(name, url, feedfile)
448 fetch() {
449 case "$1" in
450 "connector example")
451 youtube_feed "$2";;
452 *)
453 curl -L --max-redirs 0 -H "User-Agent:" -f -s -m 15 \
454 "$2" 2>/dev/null;;
455 esac
456 }
457
458 # parse and convert input, by default XML to the sfeed(5) TSV format.
459 # parse(name, feedurl, basesiteurl)
460 parse() {
461 case "$1" in
462 "connector example")
463 cat;;
464 *)
465 sfeed "$3";;
466 esac
467 }
468
469 # list of feeds to fetch:
470 feeds() {
471 # feed <name> <feedurl> [basesiteurl] [encoding]
472 feed "connector example" "UCrbvoMC0zUvPL8vjswhLOSw"
473 }
474 </code></pre>
475 <h2>Screenshot using sfeed_curses</h2>
476 <p><a href="downloads/screenshots/sfeed_curses_youtube.png"><img src="downloads/screenshots/sfeed_curses_youtube.png" alt="Screenshot showing the improved Youtube feed" width="480" height="270" loading="lazy" /></a></p>
477 <h2>Clone</h2>
478 <pre><code>git clone git://git.codemadness.org/frontends
479 </code></pre>
480 <h2>Browse</h2>
481 <p>You can browse the source-code at:</p>
482 <ul>
483 <li><a href="https://git.codemadness.org/frontends/file/youtube/feed.c.html">https://git.codemadness.org/frontends/file/youtube/feed.c.html</a></li>
484 <li><a href="gopher://codemadness.org/1/git/frontends/file/youtube/feed.c.gph">gopher://codemadness.org/1/git/frontends/file/youtube/feed.c.gph</a></li>
485 </ul>
486 <p>The program is: youtube/feed</p>
487 <h2>Dependencies</h2>
488 <ul>
489 <li>C compiler.</li>
490 <li>LibreSSL + libtls.</li>
491 </ul>
492 <h2>Build and install</h2>
493 <pre><code>$ make
494 # make install
495 </code></pre>
496 <h2>That's all</h2>
497 <p>I hope by sharing this it is useful to someone other than me as well.</p>
498 ]]></description>
499 </item>
500 <item>
501 <title>webdump HTML to plain-text converter</title>
502 <link>https://www.codemadness.org/webdump.html</link>
503 <guid>https://www.codemadness.org/webdump.html</guid>
504 <dc:date>2023-11-20T00:00:00Z</dc:date>
505 <author>Hiltjo</author>
506 <description><![CDATA[<h1>webdump HTML to plain-text converter</h1>
507 <p><strong>Last modification on </strong> <time>2025-04-25</time></p>
508 <p>webdump is (yet another) HTML to plain-text converter tool.</p>
509 <p>It reads HTML in UTF-8 from stdin and writes plain-text to stdout.</p>
510 <h2>Goals and scope</h2>
511 <p>The main goal of this tool for me is to use it for converting HTML mails to
512 plain-text and to convert HTML content in RSS feeds to plain-text.</p>
513 <p>The tool will only convert HTML to stdout, similarly to links -dump or lynx
514 -dump but simpler and more secure.</p>
515 <ul>
516 <li>HTML and XHTML will be supported.</li>
517 <li>There will be some workarounds and quirks for broken and legacy HTML code.</li>
518 <li>It will be usable and secure for reading HTML from mails and RSS/Atom feeds.</li>
519 <li>No remote resources which are part of the HTML will be downloaded:
520 images, video, audio, etc. But these may be visible as a link reference.</li>
521 <li>Data will be written to stdout. Intended for plain-text or a text terminal.</li>
522 <li>No support for Javascript, CSS, frame rendering or form processing.</li>
523 <li>No HTTP or network protocol handling: HTML data is read from stdin.</li>
524 <li>Listings for references and some options to extract them in a list that is
525 usable for scripting. Some references are: link anchors, images, audio, video,
526 HTML (i)frames, etc.</li>
527 <li>Security: on OpenBSD it uses pledge("stdio", NULL).</li>
528 <li>Keep the code relatively small, simple and hackable.</li>
529 </ul>
530 <h2>Features</h2>
531 <ul>
532 <li>Support for word-wrapping.</li>
533 <li>A mode to enable basic markup: bold, underline, italic and blink ;)</li>
534 <li>Indentation of headers, paragraphs, pre and list items.</li>
535 <li>Basic support to query elements or hide them.</li>
536 <li>Show link references.</li>
537 <li>Show link references and resources such as img, video, audio, subtitles.</li>
538 <li>Export link references and resources to a TAB-separated format.</li>
539 </ul>
540 <h2>Usage examples</h2>
541 <pre><code>url='https://codemadness.org/sfeed.html'
542
543 curl -s "$url" | webdump -r -b "$url" | less
544
545 curl -s "$url" | webdump -8 -a -i -l -r -b "$url" | less -R
546
547 curl -s "$url" | webdump -s 'main' -8 -a -i -l -r -b "$url" | less -R
548 </code></pre>
549 <p>Yes, all these option flags look ugly, a shellscript wrapper could be used :)</p>
550 <h2>Practical examples</h2>
551 <p>To use webdump as a HTML to text filter for example in the mutt mail client,
552 change in ~/.mailcap:</p>
553 <pre><code>text/html; webdump -i -l -r < %s; needsterminal; copiousoutput
554 </code></pre>
555 <p>In mutt you should then add:</p>
556 <pre><code>auto_view text/html
557 </code></pre>
558 <p>Using webdump as a HTML to text filter for sfeed_curses (otherwise the default is lynx):</p>
559 <pre><code>SFEED_HTMLCONV="webdump -d -8 -r -i -l -a" sfeed_curses ~/.sfeed/feeds/*
560 </code></pre>
561 <h1>Query/selector examples</h1>
562 <p>The query syntax using the -s option is a bit inspired by CSS (but much more limited).</p>
563 <p>To get the title from a HTML page:</p>
564 <pre><code>url='https://codemadness.org/sfeed.html'
565
566 title=$(curl -s "$url" | webdump -s 'title')
567 printf '%s\n' "$title"
568 </code></pre>
569 <p>List audio and video-related content from a HTML page, redirect fd 3 to fd 1 (stdout):</p>
570 <pre><code>url="https://media.ccc.de/v/051_Recent_features_to_OpenBSD-ntpd_and_bgpd"
571 curl -s "$url" | webdump -x -s 'audio,video' -b "$url" 3>&1 >/dev/null | cut -f 2
572 </code></pre>
573 <h2>Clone</h2>
574 <pre><code>git clone git://git.codemadness.org/webdump
575 </code></pre>
576 <h2>Browse</h2>
577 <p>You can browse the source-code at:</p>
578 <ul>
579 <li><a href="https://git.codemadness.org/webdump/">https://git.codemadness.org/webdump/</a></li>
580 <li><a href="gopher://codemadness.org/1/git/webdump">gopher://codemadness.org/1/git/webdump</a></li>
581 </ul>
582 <h2>Download releases</h2>
583 <p>Releases are available at:</p>
584 <ul>
585 <li><a href="https://codemadness.org/releases/webdump/">https://codemadness.org/releases/webdump/</a></li>
586 <li><a href="gopher://codemadness.org/1/releases/webdump">gopher://codemadness.org/1/releases/webdump</a></li>
587 </ul>
588 <h2>Build and install</h2>
589 <pre><code>$ make
590 # make install
591 </code></pre>
592 <h2>Dependencies</h2>
593 <ul>
594 <li>C compiler.</li>
595 <li>libc + some BSDisms.</li>
596 </ul>
597 <h2>Trade-offs</h2>
598 <p>All software has trade-offs.</p>
599 <p>webdump processes HTML in a single-pass. It does not buffer the full DOM tree.
600 Although due to the nature of HTML/XML some parts like attributes need to be
601 buffered.</p>
602 <p>Rendering tables in webdump is very limited. Twibright Links has really nice
603 table rendering. However implementing a similar feature in the current design of
604 webdump would make the code much more complex. Twibright links
605 processes a full DOM tree and processes the tables in multiple passes (to
606 measure the table cells) etc. Of course tables can be nested also, or HTML tables
607 that are used for creating layouts (these are mostly older webpages).</p>
608 <p>These trade-offs and preferences are chosen for now. It may change in the
609 future. Fortunately there are the usual good suspects for HTML to plain-text
610 conversion, each with their own chosen trade-offs of course:</p>
611 <ul>
612 <li>twibright links: <a href="http://links.twibright.com/">http://links.twibright.com/</a></li>
613 <li>lynx: <a href="https://lynx.invisible-island.net/">https://lynx.invisible-island.net/</a></li>
614 <li>w3m: <a href="https://w3m.sourceforge.net/">https://w3m.sourceforge.net/</a></li>
615 <li>xmllint (part of libxml2): <a href="https://gitlab.gnome.org/GNOME/libxml2/-/wikis/home">https://gitlab.gnome.org/GNOME/libxml2/-/wikis/home</a></li>
616 <li>xmlstarlet: <a href="https://xmlstar.sourceforge.net/">https://xmlstar.sourceforge.net/</a></li>
617 </ul>
618 ]]></description>
619 </item>
620 <item>
621 <title>Setup your own mail paste service</title>
622 <link>https://www.codemadness.org/mailservice.html</link>
623 <guid>https://www.codemadness.org/mailservice.html</guid>
624 <dc:date>2023-10-25T00:00:00Z</dc:date>
625 <author>Hiltjo</author>
626 <description><![CDATA[<h1>Setup your own mail paste service</h1>
627 <p><strong>Last modification on </strong> <time>2024-02-10</time></p>
628 <h2>How it works</h2>
629 <ul>
630 <li>The user sends a mail with an attachment to a certain mail address, for
631 example: paste@somehost.org</li>
632 <li>The mail daemon configuration has an mail alias to pipe the raw mail to a
633 shellscript.</li>
634 <li>This shellscript processes the raw mail contents from stdin.</li>
635 </ul>
636 <h2>What it does</h2>
637 <ul>
638 <li>Process a mail with the attachments automatically.</li>
639 <li>The script processes the attachments in the mail and stores them.</li>
640 <li>It will mail (back) the URL where the file(s) are stored.</li>
641 </ul>
642 <p>This script is tested on OpenBSD using OpenBSD smtpd and OpenBSD httpd and the
643 gopher daemon geomyidae.</p>
644 <h2>Install dependencies</h2>
645 <p>On OpenBSD:</p>
646 <pre><code>pkg_add mblaze
647 </code></pre>
648 <h2>smtpd mail configuration</h2>
649 <p>In your mail aliases (for example /etc/mail/aliases) put:</p>
650 <pre><code>paste: |/usr/local/bin/paste-mail
651 </code></pre>
652 <p>This pipes the mail to the script paste-mail for processing, this script is
653 described below. Copy the below contents in /usr/local/bin/paste-mail</p>
654 <p>Script:</p>
655 <pre><code>#!/bin/sh
656
657 d="/home/www/domains/www.codemadness.org/htdocs/mailpaste"
658 tmpmsg=$(mktemp)
659 tmpmail=$(mktemp)
660
661 cleanup() {
662 rm -f "$tmpmail" "$tmpmsg"
663 }
664
665 # store whole mail from stdin temporarily, on exit remove temporary file.
666 trap "cleanup" EXIT
667 cat > "$tmpmail"
668
669 # mblaze: don't store mail sequence.
670 MAILSEQ=/dev/null
671 export MAILSEQ
672
673 # get from address (without display name).
674 from=$(maddr -a -h 'From' /dev/stdin < "$tmpmail")
675
676 # check if allowed or not.
677 case "$from" in
678 "hiltjo@codemadness.org")
679 ;;
680 *)
681 exit 0;;
682 esac
683
684 # prevent mail loop.
685 if printf '%s' "$from" | grep -q "paste@"; then
686 exit 0
687 fi
688
689 echo "Thank you for using the enterprise paste service." > "$tmpmsg"
690 echo "" >> "$tmpmsg"
691 echo "Your file(s) are available at:" >> "$tmpmsg"
692 echo "" >> "$tmpmsg"
693
694 # process each attachment.
695 mshow -n -q -t /dev/stdin < "$tmpmail" | sed -nE 's@.*name="(.*)".*@\1@p' | while read -r name; do
696 test "$name" = "" && continue
697
698 # extract attachment.
699 tmpfile=$(mktemp -p "$d" XXXXXXXXXXXX)
700 mshow -n -O /dev/stdin "$name" < "$tmpmail" > "$tmpfile"
701
702 # use file extension.
703 ext="${name##*/}"
704 case "$ext" in
705 *.tar.*)
706 # special case: support .tar.gz, tar.bz2, etc.
707 ext="tar.${ext##*.}";;
708 *.*)
709 ext="${ext##*.}";;
710 *)
711 ext="";;
712 esac
713 ext="${ext%%*.}"
714
715 # use file extension if it is set.
716 outputfile="$tmpfile"
717 if test "$ext" != ""; then
718 outputfile="$tmpfile.$ext"
719 fi
720 mv "$tmpfile" "$outputfile"
721 b=$(basename "$outputfile")
722
723 chmod 666 "$outputfile"
724 url="gopher://codemadness.org/9/mailpaste/$b"
725
726 echo "$name:" >> "$tmpmsg"
727 echo " Text file: gopher://codemadness.org/0/mailpaste/$b" >> "$tmpmsg"
728 echo " Image file: gopher://codemadness.org/I/mailpaste/$b" >> "$tmpmsg"
729 echo " Binary file: gopher://codemadness.org/9/mailpaste/$b" >> "$tmpmsg"
730 echo "" >> "$tmpmsg"
731 done
732
733 echo "" >> "$tmpmsg"
734 echo "Sincerely," >> "$tmpmsg"
735 echo "Your friendly paste_bot" >> "$tmpmsg"
736
737 # mail back the user.
738 mail -r "$from" -s "Your files" "$from" < "$tmpmsg"
739
740 cleanup
741 </code></pre>
742 <p>The mail daemon processing the mail needs of course to be able to have
743 permissions to write to the specified directory. The user who received the mail
744 needs to be able to read it from a location they can access and have
745 permissions for it also.</p>
746 <h2>Room for improvements</h2>
747 <p>This is just an example script. There is room for many improvements.
748 Feel free to change it in any way you like.</p>
749 <h2>References</h2>
750 <ul>
751 <li><a href="https://man.openbsd.org/aliases">https://man.openbsd.org/aliases</a></li>
752 <li><a href="https://man.openbsd.org/smtpd">https://man.openbsd.org/smtpd</a></li>
753 <li><a href="https://man.openbsd.org/httpd">https://man.openbsd.org/httpd</a></li>
754 <li><a href="https://github.com/leahneukirchen/mblaze">https://github.com/leahneukirchen/mblaze</a></li>
755 </ul>
756 <h2>Bye bye</h2>
757 <p>I hope this enterprise(tm) mail service is inspirational or something ;)</p>
758 ]]></description>
759 </item>
760 <item>
761 <title>A simple TODO application</title>
762 <link>https://www.codemadness.org/todo-application.html</link>
763 <guid>https://www.codemadness.org/todo-application.html</guid>
764 <dc:date>2022-07-01T00:00:00Z</dc:date>
765 <author>Hiltjo</author>
766 <description><![CDATA[<h1>A simple TODO application</h1>
767 <p><strong>Last modification on </strong> <time>2022-07-01</time></p>
768 <p>This article describes a TODO application or workflow.</p>
769 <h2>Workflow</h2>
770 <p>It works like this:</p>
771 <ul>
772 <li>Open any text editor.</li>
773 <li>Edit the text.</li>
774 <li>Save it in a file (probably named "TODO").</li>
775 <li>Feel happy about it.</li>
776 </ul>
777 <h2>The text format</h2>
778 <p>The text format I use is this:</p>
779 <pre><code>[indendations]<symbol><SPACE><item text><NEWLINE>
780 </code></pre>
781 <p>Most of the time an item is just one line.
782 This format is just a general guideline to keep the items somewhat structured.</p>
783 <h2>Symbols</h2>
784 <p>Items are prefixed with a symbol.</p>
785 <ul>
786 <li>- is an item which is planned to be done at some point.</li>
787 <li>x is an item which is done.</li>
788 <li>? is an item which I'm not (yet) sure about. It can also be an idea.</li>
789 </ul>
790 <p>I use an indendation with a TAB before an item to indicate item dependencies.
791 The items can be nested.</p>
792 <p>For the prioritization I put the most important items and sections from the top
793 to the bottom. These can be reshuffled as you wish of course.</p>
794 <p>To delete an item you remove the line. To archive an item you keep the line.</p>
795 <h2>Sections</h2>
796 <p>A section is a line which has no symbol. This is like a header to group items.</p>
797 <h2>Example</h2>
798 <pre><code>Checklist for releasing project 0.1:
799 - Test project with different compilers and check for warnings.
800 - Documentation:
801 - Proofread and make sure it matches all program behaviour.
802 - Run mandoc -Tlint on the man pages.
803 ? Copy useful examples from the README file to the man page?
804 - Run testsuite and check for failures before release.
805
806
807 project 0.2:
808 ? Investigate if feature mentioned by some user is worth adding.
809 </code></pre>
810 <h1>Example: secure remote cloud-encrypted edit session(tm)</h1>
811 <pre><code>ssh -t host 'ed TODO'
812 </code></pre>
813 <h1>Example: multi-user secure remote cloud-encrypted edit session(tm)</h1>
814 <pre><code>ssh host
815 tmux or tmux a
816 ed TODO
817 </code></pre>
818 <h1>Example: version-controlled multi-user secure remote cloud-encrypted edit session(tm)</h1>
819 <pre><code>ssh host
820 tmux or tmux a
821 ed TODO
822 git add TODO
823 git commit -m 'TODO: update'
824 </code></pre>
825 <h2>Pros</h2>
826 <ul>
827 <li>When you open the TODO file the most important items are at the top.</li>
828 <li>The items are easy to read and modify with any text editor.</li>
829 <li>It is easy to extend the format and use with other text tools.</li>
830 <li>The format is portable: it works on sticky-notes on your CRT monitor too!</li>
831 <li>No monthly online subscription needed and full NO-money-back guarantee.</li>
832 </ul>
833 <h2>Cons</h2>
834 <ul>
835 <li>Complex lists with interconnected dependencies might not work, maybe.</li>
836 <li>It's assumed there is one person maintaining the TODO file. Merging items
837 from multiple people at the same time in this workflow is not recommended.</li>
838 <li>It is too simple: noone will be impressed by it.</li>
839 </ul>
840 <p>I hope this is inspirational or something,</p>
841 ]]></description>
842 </item>
843 <item>
844 <title>2FA TOTP without crappy authenticator apps</title>
845 <link>https://www.codemadness.org/totp.html</link>
846 <guid>https://www.codemadness.org/totp.html</guid>
847 <dc:date>2022-03-23T00:00:00Z</dc:date>
848 <author>Hiltjo</author>
849 <description><![CDATA[<h1>2FA TOTP without crappy authenticator apps</h1>
850 <p><strong>Last modification on </strong> <time>2022-10-29</time></p>
851 <p>This describes how to use 2FA without using crappy authenticator "apps" or a
852 mobile device.</p>
853 <h2>Install</h2>
854 <p>On OpenBSD:</p>
855 <pre><code>pkg_add oath-toolkit zbar
856 </code></pre>
857 <p>On Void Linux:</p>
858 <pre><code>xbps-install oath-toolkit zbar
859 </code></pre>
860 <p>There is probably a package for your operating system.</p>
861 <ul>
862 <li>oath-toolkit is used to generate the digits based on the secret key.</li>
863 <li>zbar is used to scan the QR barcode text from the image.</li>
864 </ul>
865 <h2>Steps</h2>
866 <p>Save the QR code image from the authenticator app, website to an image file.
867 Scan the QR code text from the image:</p>
868 <pre><code>zbarimg image.png
869 </code></pre>
870 <p>An example QR code:</p>
871 <p><img src="downloads/2fa/qr.png" alt="QR code example" /></p>
872 <p>The output is typically something like:</p>
873 <pre><code>QR-Code:otpauth://totp/Example:someuser@codemadness.org?secret=SECRETKEY&issuer=Codemadness
874 </code></pre>
875 <p>You only need to scan this QR-code for the secret key once.
876 Make sure to store the secret key in a private safe place and don't show it to
877 anyone else.</p>
878 <p>Using the secret key the following command outputs a 6-digit code by default.
879 In this example we also assume the key is base32-encoded.
880 There can be other parameters and options, this is documented in the Yubico URI
881 string format reference below.</p>
882 <p>Command:</p>
883 <pre><code>oathtool --totp -b SOMEKEY
884 </code></pre>
885 <ul>
886 <li>The --totp option uses the time-variant TOTP mode, by default it uses HMAC SHA1.</li>
887 <li>The -b option uses base32 encoding of KEY instead of hex.</li>
888 </ul>
889 <p>Tip: you can create a script that automatically puts the digits in the
890 clipboard, for example:</p>
891 <pre><code>oathtool --totp -b SOMEKEY | xclip
892 </code></pre>
893 <h2>References</h2>
894 <ul>
895 <li><a href="https://linux.die.net/man/1/zbarimg">zbarimg(1) man page</a></li>
896 <li><a href="https://www.nongnu.org/oath-toolkit/man-oathtool.html">oathtool(1) man page</a></li>
897 <li><a href="https://datatracker.ietf.org/doc/html/rfc6238">RFC6238 - TOTP: Time-Based One-Time Password Algorithm</a></li>
898 <li><a href="https://docs.yubico.com/yesdk/users-manual/application-oath/uri-string-format.html">Yubico.com - otpauth URI string format</a></li>
899 </ul>
900 ]]></description>
901 </item>
902 <item>
903 <title>Setup an OpenBSD RISCV64 VM in QEMU</title>
904 <link>https://www.codemadness.org/openbsd-riscv64-vm.html</link>
905 <guid>https://www.codemadness.org/openbsd-riscv64-vm.html</guid>
906 <dc:date>2021-10-23T00:00:00Z</dc:date>
907 <author>Hiltjo</author>
908 <description><![CDATA[<h1>Setup an OpenBSD RISCV64 VM in QEMU</h1>
909 <p><strong>Last modification on </strong> <time>2021-10-26</time></p>
910 <p>This describes how to setup an OpenBSD RISCV64 VM in QEMU.</p>
911 <p>The shellscript below does the following:</p>
912 <ul>
913 <li>Set up the disk image (raw format).</li>
914 <li>Patch the disk image with the OpenBSD miniroot file for the installation.</li>
915 <li>Downloads the opensbi and u-boot firmware files for qemu.</li>
916 <li>Run the VM with the supported settings.</li>
917 </ul>
918 <p>The script is tested on the host GNU/Void Linux and OpenBSD-current.</p>
919 <p><strong>IMPORTANT!: The signature and checksum for the miniroot, u-boot and opensbi
920 files are not verified. If the host is OpenBSD make sure to instead install the
921 packages (pkg_add u-boot-riscv64 opensbi) and adjust the firmware path for the
922 qemu -bios and -kernel options. </strong></p>
923 <h2>Shellscript</h2>
924 <pre><code>#!/bin/sh
925 # mirror list: https://www.openbsd.org/ftp.html
926 mirror="https://ftp.bit.nl/pub/OpenBSD/"
927 release="7.0"
928 minirootname="miniroot70.img"
929
930 miniroot() {
931 test -f "${minirootname}" && return # download once
932
933 url="${mirror}/${release}/riscv64/${minirootname}"
934 curl -o "${minirootname}" "${url}"
935 }
936
937 createrootdisk() {
938 test -f disk.raw && return # create once
939 qemu-img create disk.raw 10G # create 10 GB disk
940 dd conv=notrunc if=${minirootname} of=disk.raw # write miniroot to disk
941 }
942
943 opensbi() {
944 f="opensbi.tgz"
945 test -f "${f}" && return # download and extract once.
946
947 url="${mirror}/${release}/packages/amd64/opensbi-0.9p0.tgz"
948 curl -o "${f}" "${url}"
949
950 tar -xzf "${f}" share/opensbi/generic/fw_jump.bin
951 }
952
953 uboot() {
954 f="uboot.tgz"
955 test -f "${f}" && return # download and extract once.
956
957 url="${mirror}/${release}/packages/amd64/u-boot-riscv64-2021.07p0.tgz"
958 curl -o "${f}" "${url}"
959
960 tar -xzf "${f}" share/u-boot/qemu-riscv64_smode/u-boot.bin
961 }
962
963 setup() {
964 miniroot
965 createrootdisk
966 opensbi
967 uboot
968 }
969
970 run() {
971 qemu-system-riscv64 \
972 -machine virt \
973 -nographic \
974 -m 2048M \
975 -smp 2 \
976 -bios share/opensbi/generic/fw_jump.bin \
977 -kernel share/u-boot/qemu-riscv64_smode/u-boot.bin \
978 -drive file=disk.raw,format=raw,id=hd0 -device virtio-blk-device,drive=hd0 \
979 -netdev user,id=net0,ipv6=off -device virtio-net-device,netdev=net0
980 }
981
982 setup
983 run
984 </code></pre>
985 ]]></description>
986 </item>
987 <item>
988 <title>Sfeed_curses: a curses UI front-end for sfeed</title>
989 <link>https://www.codemadness.org/sfeed_curses-ui.html</link>
990 <guid>https://www.codemadness.org/sfeed_curses-ui.html</guid>
991 <dc:date>2020-06-25T00:00:00Z</dc:date>
992 <author>Hiltjo</author>
993 <description><![CDATA[<h1>Sfeed_curses: a curses UI front-end for sfeed</h1>
994 <p><strong>Last modification on </strong> <time>2025-07-24</time></p>
995 <p>sfeed_curses is a curses UI front-end for <a href="sfeed.html">sfeed</a>.
996 It is now part of sfeed.</p>
997 <p>It shows the TAB-separated feed items in a graphical command-line UI. The
998 interface has a look inspired by the <a href="http://www.mutt.org/">mutt mail client</a>. It has a sidebar
999 panel for the feeds, a panel with a listing of the items and a small statusbar
1000 for the selected item/URL. Some functions like searching and scrolling are
1001 integrated in the interface itself.</p>
1002 <h2>Features</h2>
1003 <ul>
1004 <li>Relatively few LOC, about 2.5K lines of C.</li>
1005 <li>Few dependencies: a C compiler and a curses library (typically ncurses).
1006 It also requires a terminal (emulator) which supports UTF-8.
1007 <ul>
1008 <li>xterm-compatible shim <a href="https://git.codemadness.org/sfeed/file/minicurses.h.html">minicurses.h</a></li>
1009 </ul>
1010 </li>
1011 <li>Easy to customize by modifying the small source-code and shellscripts.</li>
1012 <li>Plumb support: open the URL or an enclosure URL directly with any program.</li>
1013 <li>Pipe support: pipe the selected Tab-Separated Value line to a program for
1014 scripting purposes. Like viewing the content in any way you like.</li>
1015 <li>Yank support: copy the URL or an enclosure URL to the clipboard.</li>
1016 <li>Familiar keybinds: supports both vi-like, emacs-like and arrow keys for
1017 actions.</li>
1018 <li>Mouse support: it supports xterm X10 and extended SGR encoding.</li>
1019 <li>Support two ways of managing read/unread items.
1020 By default sfeed_curses marks the feed items of the last day as new/bold.
1021 Alternatively a simple plain-text list with the read URLs can be used.</li>
1022 <li>UI layouts: supports vertical, horizontal and monocle (full-screen) layouts.
1023 Useful for different kind of screen sizes.</li>
1024 <li>Auto-execute keybind commands at startup to automate setting a preferred
1025 layout, toggle showing new items or other actions.</li>
1026 </ul>
1027 <p>Like the format programs included in sfeed you can run it by giving the feed
1028 files as arguments like this:</p>
1029 <pre><code>sfeed_curses ~/.sfeed/feeds/*
1030 </code></pre>
1031 <p>... or by reading directly from stdin:</p>
1032 <pre><code>sfeed_curses < ~/.sfeed/feeds/xkcd
1033 </code></pre>
1034 <p>It will show a sidebar if one or more files are specified as parameters. It
1035 will not show the sidebar by default when reading from stdin.</p>
1036 <p><a href="downloads/screenshots/sfeed_curses_screenshot.png"><img src="downloads/screenshots/sfeed_curses_screenshot.png" alt="Screenshot showing what the UI looks" width="480" height="270" loading="lazy" /></a></p>
1037 <p>On pressing the 'o' or ENTER keybind it will open the link URL of an item with
1038 the plumb program. On pressing the 'a', 'e' or '@' keybind it will open the
1039 enclosure URL if there is one. The default plumb program is set to <a href="https://portland.freedesktop.org/doc/xdg-open.html">xdg-open</a>,
1040 but can be modified by setting the environment variable $SFEED_PLUMBER. The
1041 plumb program receives the URL as a command-line argument.</p>
1042 <p>The TAB-Separated-Value line of the current selected item in the feed file can
1043 be piped to a program by pressing the 'c', 'p' or '|' keybind. This allows much
1044 flexibility to make a content formatter or write other custom actions or views.
1045 This line is in the exact same format as described in the sfeed(5) man page.</p>
1046 <p>The pipe program can be changed by setting the environment variable
1047 $SFEED_PIPER.</p>
1048 <p><a href="downloads/screenshots/sfeed_curses_pipe_screenshot.png"><img src="downloads/screenshots/sfeed_curses_pipe_screenshot.png" alt="Screenshot showing the output of the pipe content script" width="480" height="270" loading="lazy" /></a></p>
1049 <p>The above screenshot shows the included <a href="https://git.codemadness.org/sfeed/file/sfeed_content.html">sfeed_content</a> shellscript which uses
1050 the <a href="https://invisible-island.net/lynx/">lynx text-browser</a> to convert HTML to plain-text. It pipes the formatted
1051 plain-text to the user $PAGER (or "less").</p>
1052 <p>Of course the script can be easily changed to use a different browser or
1053 HTML-to-text converter like:</p>
1054 <ul>
1055 <li><a href="https://www.dillo.org/">dillo</a></li>
1056 <li><a href="http://www.jikos.cz/~mikulas/links/">links</a></li>
1057 <li><a href="http://w3m.sourceforge.net/">w3m</a></li>
1058 <li><a href="https://git.codemadness.org/webdump/file/README.html">webdump</a></li>
1059 </ul>
1060 <p>It's easy to modify the color-theme by changing the macros in the source-code
1061 or set a predefined theme at compile-time. The README file contains information
1062 how to set a theme. On the left a <a href="https://templeos.org/">TempleOS</a>-like color-theme on the right a
1063 <a href="https://newsboat.org/">newsboat</a>-like colorscheme.</p>
1064 <p><a href="downloads/screenshots/sfeed_curses_theme_screenshot.png"><img src="downloads/screenshots/sfeed_curses_theme_screenshot.png" alt="Screenshot showing a custom colorscheme" width="480" height="270" loading="lazy" /></a></p>
1065 <p>It supports a vertical layout, horizontal and monocle (full-screen) layout.
1066 This can be useful for different kind of screen sizes. The keybinds '1', '2'
1067 and '3' can be used to switch between these layouts.</p>
1068 <p><a href="downloads/screenshots/sfeed_curses_horizontal_screenshot.png"><img src="downloads/screenshots/sfeed_curses_horizontal_screenshot.png" alt="Screenshot showing the horizontal layout" width="480" height="270" loading="lazy" /></a></p>
1069 <h2>Clone</h2>
1070 <pre><code>git clone git://git.codemadness.org/sfeed
1071 </code></pre>
1072 <h2>Browse</h2>
1073 <p>You can browse the source-code at:</p>
1074 <ul>
1075 <li><a href="https://git.codemadness.org/sfeed/">https://git.codemadness.org/sfeed/</a></li>
1076 <li><a href="gopher://codemadness.org/1/git/sfeed">gopher://codemadness.org/1/git/sfeed</a></li>
1077 </ul>
1078 <h2>Download releases</h2>
1079 <p>Releases are available at:</p>
1080 <ul>
1081 <li><a href="https://codemadness.org/releases/sfeed/">https://codemadness.org/releases/sfeed/</a></li>
1082 <li><a href="gopher://codemadness.org/1/releases/sfeed">gopher://codemadness.org/1/releases/sfeed</a></li>
1083 </ul>
1084 <h2>Build and install</h2>
1085 <pre><code>$ make
1086 # make install
1087 </code></pre>
1088 ]]></description>
1089 </item>
1090 <item>
1091 <title>hurl: HTTP, HTTPS and Gopher file grabber</title>
1092 <link>https://www.codemadness.org/hurl.html</link>
1093 <guid>https://www.codemadness.org/hurl.html</guid>
1094 <dc:date>2019-11-10T00:00:00Z</dc:date>
1095 <author>Hiltjo</author>
1096 <description><![CDATA[<h1>hurl: HTTP, HTTPS and Gopher file grabber</h1>
1097 <p><strong>Last modification on </strong> <time>2020-07-20</time></p>
1098 <p>hurl is a relatively simple HTTP, HTTPS and Gopher client/file grabber.</p>
1099 <h2>Why?</h2>
1100 <p>Sometimes (or most of the time?) you just want to fetch a file via the HTTP,
1101 HTTPS or Gopher protocol.</p>
1102 <p>The focus of this tool is only this.</p>
1103 <h2>Features</h2>
1104 <ul>
1105 <li>Uses OpenBSD pledge(2) and unveil(2). Allow no filesystem access (writes to
1106 stdout).</li>
1107 <li>Impose time-out and maximum size limits.</li>
1108 <li>Use well-defined exitcodes for reliable scripting (curl sucks at this).</li>
1109 <li>Send as little information as possible (no User-Agent etc by default).</li>
1110 </ul>
1111 <h2>Anti-features</h2>
1112 <ul>
1113 <li>No HTTP byte range support.</li>
1114 <li>No HTTP User-Agent.</li>
1115 <li>No HTTP If-Modified-Since/If-* support.</li>
1116 <li>No HTTP auth support.</li>
1117 <li>No HTTP/2+ support.</li>
1118 <li>No HTTP keep-alive.</li>
1119 <li>No HTTP chunked-encoding support.</li>
1120 <li>No HTTP redirect support.</li>
1121 <li>No (GZIP) compression support.</li>
1122 <li>No cookie-jar or cookie parsing support.</li>
1123 <li>No Gopher text handling (".\r\n").</li>
1124 <li>... etc...</li>
1125 </ul>
1126 <h2>Dependencies</h2>
1127 <ul>
1128 <li>C compiler (C99).</li>
1129 <li>libc + some BSD functions like err() and strlcat().</li>
1130 <li>LibreSSL(-portable)</li>
1131 <li>libtls (part of LibreSSL).</li>
1132 </ul>
1133 <h2>Optional dependencies</h2>
1134 <ul>
1135 <li>POSIX make(1) (for Makefile).</li>
1136 <li>mandoc for documentation: <a href="https://mdocml.bsd.lv/">https://mdocml.bsd.lv/</a></li>
1137 </ul>
1138 <h2>Clone</h2>
1139 <pre><code>git clone git://git.codemadness.org/hurl
1140 </code></pre>
1141 <h2>Browse</h2>
1142 <p>You can browse the source-code at:</p>
1143 <ul>
1144 <li><a href="https://git.codemadness.org/hurl/">https://git.codemadness.org/hurl/</a></li>
1145 <li><a href="gopher://codemadness.org/1/git/hurl">gopher://codemadness.org/1/git/hurl</a></li>
1146 </ul>
1147 <h2>Download releases</h2>
1148 <p>Releases are available at:</p>
1149 <ul>
1150 <li><a href="https://codemadness.org/releases/hurl/">https://codemadness.org/releases/hurl/</a></li>
1151 <li><a href="gopher://codemadness.org/1/releases/hurl">gopher://codemadness.org/1/releases/hurl</a></li>
1152 </ul>
1153 <h2>Build and install</h2>
1154 <pre><code>$ make
1155 # make install
1156 </code></pre>
1157 <h2>Examples</h2>
1158 <p>Fetch the Atom feed from this site using a maximum filesize limit of 1MB and
1159 a time-out limit of 15 seconds:</p>
1160 <pre><code>hurl -m 1048576 -t 15 "https://codemadness.org/atom.xml"
1161 </code></pre>
1162 <p>There is an -H option to add custom headers. This way some of the anti-features
1163 listed above are supported. For example some CDNs like Cloudflare are known to
1164 block empty or certain User-Agents.</p>
1165 <p>User-Agent:</p>
1166 <pre><code>hurl -H 'User-Agent: some browser' 'https://codemadness.org/atom.xml'
1167 </code></pre>
1168 <p>HTTP Basic Auth (base64-encoded username:password):</p>
1169 <pre><code>hurl -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \
1170 'https://codemadness.org/atom.xml'
1171 </code></pre>
1172 <p>GZIP (this assumes the served response Content-Type is gzip):</p>
1173 <pre><code>hurl -H 'Accept-Encoding: gzip' 'https://somesite/' | gzip -d
1174 </code></pre>
1175 ]]></description>
1176 </item>
1177 <item>
1178 <title>json2tsv: a JSON to TSV converter</title>
1179 <link>https://www.codemadness.org/json2tsv.html</link>
1180 <guid>https://www.codemadness.org/json2tsv.html</guid>
1181 <dc:date>2019-10-13T00:00:00Z</dc:date>
1182 <author>Hiltjo</author>
1183 <description><![CDATA[<h1>json2tsv: a JSON to TSV converter</h1>
1184 <p><strong>Last modification on </strong> <time>2021-09-25</time></p>
1185 <p>Convert JSON to TSV or separated output.</p>
1186 <p>json2tsv reads JSON data from stdin. It outputs each JSON type to a TAB-
1187 Separated Value format per line by default.</p>
1188 <h2>TAB-Separated Value format</h2>
1189 <p>The output format per line is:</p>
1190 <pre><code>nodename<TAB>type<TAB>value<LF>
1191 </code></pre>
1192 <p>Control-characters such as a newline, TAB and backslash (\n, \t and \) are
1193 escaped in the nodename and value fields. Other control-characters are
1194 removed.</p>
1195 <p>The type field is a single byte and can be:</p>
1196 <ul>
1197 <li>a for array</li>
1198 <li>b for bool</li>
1199 <li>n for number</li>
1200 <li>o for object</li>
1201 <li>s for string</li>
1202 <li>? for null</li>
1203 </ul>
1204 <p>Filtering on the first field "nodename" is easy using awk for example.</p>
1205 <h2>Features</h2>
1206 <ul>
1207 <li>Accepts all <strong>valid</strong> JSON.</li>
1208 <li>Designed to work well with existing UNIX programs like awk and grep.</li>
1209 <li>Straightforward and not much lines of code: about 475 lines of C.</li>
1210 <li>Few dependencies: C compiler (C99), libc.</li>
1211 <li>No need to learn a new (meta-)language for processing data.</li>
1212 <li>The parser supports code point decoding and UTF-16 surrogates to UTF-8.</li>
1213 <li>It does not output control-characters to the terminal for security reasons by
1214 default (but it has a -r option if needed).</li>
1215 <li>On OpenBSD it supports <a href="https://man.openbsd.org/pledge">pledge(2)</a> for syscall restriction:
1216 pledge("stdio", NULL).</li>
1217 <li>Supports setting a different field separator and record separator with the -F
1218 and -R option.</li>
1219 </ul>
1220 <h2>Cons</h2>
1221 <ul>
1222 <li>For the tool there is additional overhead by processing and filtering data
1223 from stdin after parsing.</li>
1224 <li>The parser does not do complete validation on numbers.</li>
1225 <li>The parser accepts some bad input such as invalid UTF-8
1226 (see <a href="https://tools.ietf.org/html/rfc8259#section-8.1">RFC8259 - 8.1. Character Encoding</a>).
1227 json2tsv reads from stdin and does not do assumptions about a "closed
1228 ecosystem" as described in the RFC.</li>
1229 <li>The parser accepts some bad JSON input and "extensions"
1230 (see <a href="https://tools.ietf.org/html/rfc8259#section-9">RFC8259 - 9. Parsers</a>).</li>
1231 <li>Encoded NUL bytes (\u0000) in strings are ignored.
1232 (see <a href="https://tools.ietf.org/html/rfc8259#section-9">RFC8259 - 9. Parsers</a>).
1233 "An implementation may set limits on the length and character contents of
1234 strings."</li>
1235 <li>The parser is not the fastest possible JSON parser (but also not the
1236 slowest). For example: for ease of use, at the cost of performance all
1237 strings are decoded, even though they may be unused.</li>
1238 </ul>
1239 <h2>Why Yet Another JSON parser?</h2>
1240 <p>I wanted a tool that makes parsing JSON easier and work well from the shell,
1241 similar to <a href="https://stedolan.github.io/jq/">jq</a>.</p>
1242 <p>sed and grep often work well enough for matching some value using some regex
1243 pattern, but it is not good enough to parse JSON correctly or to extract all
1244 information: just like parsing HTML/XML using some regex is not good (enough)
1245 or a good idea :P.</p>
1246 <p>I didn't want to learn a new specific <a href="https://stedolan.github.io/jq/manual/#Builtinoperatorsandfunctions">meta-language</a> which jq has and wanted
1247 something simpler.</p>
1248 <p>While it is more efficient to embed this query language for data aggregation,
1249 it is also less simple. In my opinion it is simpler to separate this and use
1250 pattern-processing by awk or an other filtering/aggregating program.</p>
1251 <p>For the parser, there are many JSON parsers out there, like the efficient
1252 <a href="https://github.com/zserge/jsmn">jsmn parser</a>, however a few parser behaviours I want to have are:</p>
1253 <ul>
1254 <li>jsmn buffers data as tokens, which is very efficient, but also a bit
1255 annoying as an API as it requires another layer of code to interpret the
1256 tokens.</li>
1257 <li>jsmn does not handle decoding strings by default. Which is very efficient
1258 if you don't need parts of the data though.</li>
1259 <li>jsmn does not keep context of nested structures by default, so may require
1260 writing custom utility functions for nested data.</li>
1261 </ul>
1262 <p>This is why I went for a parser design that uses a single callback per "node"
1263 type and keeps track of the current nested structure in a single array and
1264 emits that.</p>
1265 <h2>Clone</h2>
1266 <pre><code>git clone git://git.codemadness.org/json2tsv
1267 </code></pre>
1268 <h2>Browse</h2>
1269 <p>You can browse the source-code at:</p>
1270 <ul>
1271 <li><a href="https://git.codemadness.org/json2tsv/">https://git.codemadness.org/json2tsv/</a></li>
1272 <li><a href="gopher://codemadness.org/1/git/json2tsv">gopher://codemadness.org/1/git/json2tsv</a></li>
1273 </ul>
1274 <h2>Download releases</h2>
1275 <p>Releases are available at:</p>
1276 <ul>
1277 <li><a href="https://codemadness.org/releases/json2tsv/">https://codemadness.org/releases/json2tsv/</a></li>
1278 <li><a href="gopher://codemadness.org/1/releases/json2tsv">gopher://codemadness.org/1/releases/json2tsv</a></li>
1279 </ul>
1280 <h2>Build and install</h2>
1281 <pre><code>$ make
1282 # make install
1283 </code></pre>
1284 <h2>Examples</h2>
1285 <p>An usage example to parse posts of the JSON API of <a href="https://www.reddit.com/">reddit.com</a> and format them
1286 to a plain-text list using awk:</p>
1287 <pre><code>#!/bin/sh
1288 curl -s -H 'User-Agent:' 'https://old.reddit.com/.json?raw_json=1&limit=100' | \
1289 json2tsv | \
1290 awk -F '\t' '
1291 function show() {
1292 if (length(o["title"]) == 0)
1293 return;
1294 print n ". " o["title"] " by " o["author"] " in r/" o["subreddit"];
1295 print o["url"];
1296 print "";
1297 }
1298 $1 == ".data.children[].data" {
1299 show();
1300 n++;
1301 delete o;
1302 }
1303 $1 ~ /^\.data\.children\[\]\.data\.[a-zA-Z0-9_]*$/ {
1304 o[substr($1, 23)] = $3;
1305 }
1306 END {
1307 show();
1308 }'
1309 </code></pre>
1310 <h2>References</h2>
1311 <ul>
1312 <li>Sites:
1313 <ul>
1314 <li><a href="http://seriot.ch/parsing_json.php">seriot.ch - Parsing JSON is a Minefield</a></li>
1315 <li><a href="https://github.com/nst/JSONTestSuite">A comprehensive test suite for RFC 8259 compliant JSON parsers</a></li>
1316 <li><a href="https://json.org/">json.org</a></li>
1317 </ul>
1318 </li>
1319 <li>Current standard:
1320 <ul>
1321 <li><a href="https://tools.ietf.org/html/rfc8259">RFC8259 - The JavaScript Object Notation (JSON) Data Interchange Format</a></li>
1322 <li><a href="https://www.ecma-international.org/publications/standards/Ecma-404.htm">Standard ECMA-404 - The JSON Data Interchange Syntax (2nd edition (December 2017)</a></li>
1323 </ul>
1324 </li>
1325 <li>Historic standards:
1326 <ul>
1327 <li><a href="https://tools.ietf.org/html/rfc7159">RFC7159 - The JavaScript Object Notation (JSON) Data Interchange Format (obsolete)</a></li>
1328 <li><a href="https://tools.ietf.org/html/rfc7158">RFC7158 - The JavaScript Object Notation (JSON) Data Interchange Format (obsolete)</a></li>
1329 <li><a href="https://tools.ietf.org/html/rfc4627">RFC4627 - The JavaScript Object Notation (JSON) Data Interchange Format (obsolete, original)</a></li>
1330 </ul>
1331 </li>
1332 </ul>
1333 ]]></description>
1334 </item>
1335 <item>
1336 <title>OpenBSD: setup a local auto-installation server</title>
1337 <link>https://www.codemadness.org/openbsd-autoinstall.html</link>
1338 <guid>https://www.codemadness.org/openbsd-autoinstall.html</guid>
1339 <dc:date>2019-04-24T00:00:00Z</dc:date>
1340 <author>Hiltjo</author>
1341 <description><![CDATA[<h1>OpenBSD: setup a local auto-installation server</h1>
1342 <p><strong>Last modification on </strong> <time>2020-04-30</time></p>
1343 <p>This guide describes how to setup a local mirror and installation/upgrade
1344 server that requires little or no input interaction.</p>
1345 <h2>Setup a local HTTP mirror</h2>
1346 <p>The HTTP mirror will be used to fetch the base sets and (optional) custom sets.
1347 In this guide we will assume <strong>192.168.0.2</strong> is the local installation server
1348 and mirror, the CPU architecture is amd64 and the OpenBSD release version is
1349 6.5. We will store the files in the directory with the structure:</p>
1350 <pre><code>http://192.168.0.2/pub/OpenBSD/6.5/amd64/
1351 </code></pre>
1352 <p>Create the www serve directory and fetch all sets and install files
1353 (if needed to save space *.iso and install65.fs can be skipped):</p>
1354 <pre><code>$ cd /var/www/htdocs
1355 $ mkdir -p pub/OpenBSD/6.5/amd64/
1356 $ cd pub/OpenBSD/6.5/amd64/
1357 $ ftp 'ftp://ftp.nluug.nl/pub/OpenBSD/6.5/amd64/*'
1358 </code></pre>
1359 <p>Verify signature and check some checksums:</p>
1360 <pre><code>$ signify -C -p /etc/signify/openbsd-65-base.pub -x SHA256.sig
1361 </code></pre>
1362 <p>Setup <a href="https://man.openbsd.org/httpd.8">httpd(8)</a> for simple file serving:</p>
1363 <pre><code># $FAVORITE_EDITOR /etc/httpd.conf
1364 </code></pre>
1365 <p>A minimal example config for <a href="https://man.openbsd.org/httpd.conf.5">httpd.conf(5)</a>:</p>
1366 <pre><code>server "*" {
1367 listen on * port 80
1368 }
1369 </code></pre>
1370 <p>The default www root directory is: /var/www/htdocs/</p>
1371 <p>Enable the httpd daemon to start by default and start it now:</p>
1372 <pre><code># rcctl enable httpd
1373 # rcctl start httpd
1374 </code></pre>
1375 <h2>Creating an installation response/answer file</h2>
1376 <p>The installer supports loading responses to the installation/upgrade questions
1377 from a simple text file. We can do a regular installation and copy the answers
1378 from the saved file to make an automated version of it.</p>
1379 <p>Do a test installation, at the end of the installation or upgrade when asked the
1380 question:</p>
1381 <pre><code>Exit to (S)hell, (H)alt or (R)eboot?
1382 </code></pre>
1383 <p>Type S to go to the shell. Find the response file for an installation and copy
1384 it to some USB stick or write down the response answers:</p>
1385 <pre><code>cp /tmp/i/install.resp /mnt/usbstick/
1386 </code></pre>
1387 <p>A response file could be for example:</p>
1388 <pre><code>System hostname = testvm
1389 Which network interface do you wish to configure = em0
1390 IPv4 address for em0 = dhcp
1391 IPv6 address for em0 = none
1392 Which network interface do you wish to configure = done
1393 Password for root account = $2b$10$IqI43aXjgD55Q3nLbRakRO/UAG6SAClL9pyk0vIUpHZSAcLx8fWk.
1394 Password for user testuser = $2b$10$IqI43aXjgD55Q3nLbRakRO/UAG6SAClL9pyk0vIUpHZSAcLx8fWk.
1395 Start sshd(8) by default = no
1396 Do you expect to run the X Window System = no
1397 Setup a user = testuser
1398 Full name for user testuser = testuser
1399 What timezone are you in = Europe/Amsterdam
1400 Which disk is the root disk = wd0
1401 Use (W)hole disk MBR, whole disk (G)PT, (O)penBSD area or (E)dit = OpenBSD
1402 Use (A)uto layout, (E)dit auto layout, or create (C)ustom layout = a
1403 Location of sets = http
1404 HTTP proxy URL = none
1405 HTTP Server = 192.168.0.2
1406 Server directory = pub/OpenBSD/6.5/amd64
1407 Unable to connect using https. Use http instead = yes
1408 Location of sets = http
1409 Set name(s) = done
1410 Location of sets = done
1411 Exit to (S)hell, (H)alt or (R)eboot = R
1412 </code></pre>
1413 <p>Get custom encrypted password for response file:</p>
1414 <pre><code>$ printf '%s' 'yourpassword' | encrypt
1415 </code></pre>
1416 <h2>Changing the RAMDISK kernel disk image</h2>
1417 <p><a href="https://man.openbsd.org/rdsetroot.8">rdsetroot(8)</a> is publicly exposed now in base since 6.5. Before 6.5 it is
1418 available in the /usr/src/ tree as elfrdsetroot, see also the <a href="https://man.openbsd.org/rd.4">rd(4)</a> man page.</p>
1419 <pre><code>$ mkdir auto
1420 $ cd auto
1421 $ cp pubdir/bsd.rd .
1422 $ rdsetroot -x bsd.rd disk.fs
1423 # vnconfig vnd0 disk.fs
1424 # mkdir mount
1425 # mount /dev/vnd0a mount
1426 </code></pre>
1427 <p>Copy the response file (install.resp) to: mount/auto_install.conf
1428 (installation) <strong>or</strong> mount/auto_upgrade.conf (upgrade), but not both. In this
1429 guide we will do an auto-installation.</p>
1430 <p>Unmount, detach and patch RAMDISK:</p>
1431 <pre><code># umount mount
1432 # vnconfig -u vnd0
1433 $ rdsetroot bsd.rd disk.fs
1434 </code></pre>
1435 <p>To test copy bsd.rd to the root of some testmachine like /bsd.test.rd then
1436 (re)boot and type:</p>
1437 <pre><code>boot /bsd.test.rd
1438 </code></pre>
1439 <p>In the future (6.5+) it will be possible to copy to a file named "/bsd.upgrade"
1440 in the root of a current system and automatically load the kernel:
1441 <a href="https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/stand/boot/boot.c?rev=1.46&content-type=text/x-cvsweb-markup">See the script bsd.upgrade in CVS.</a>
1442 Of course this is possible with PXE boot or some custom USB/ISO also.
1443 As explained in the <a href="https://man.openbsd.org/autoinstall.8">autoinstall(8)</a> man page: create either an
1444 auto_upgrade.conf <strong>or</strong> an auto_install.conf, but not both.</p>
1445 <h2>Create bootable miniroot</h2>
1446 <p>In this example the miniroot will boot the custom kernel, but fetch all the
1447 sets from the local network.</p>
1448 <p>We will base our miniroot of the official version: miniroot65.fs.</p>
1449 <p>We will create a 16MB miniroot to boot from (in this guide it is assumed the
1450 original miniroot is about 4MB and the modified kernel image fits in the new
1451 allocated space):</p>
1452 <pre><code>$ dd if=/dev/zero of=new.fs bs=512 count=32768
1453 </code></pre>
1454 <p>Copy first part of the original image to the new disk (no truncation):</p>
1455 <pre><code>$ dd conv=notrunc if=miniroot65.fs of=new.fs
1456 # vnconfig vnd0 new.fs
1457 </code></pre>
1458 <p>Expand disk OpenBSD boundaries:</p>
1459 <pre><code># disklabel -E vnd0
1460 > b
1461 Starting sector: [1024]
1462 Size ('*' for entire disk): [8576] *
1463 > r
1464 Total free sectors: 1168.
1465 > c a
1466 Partition a is currently 8576 sectors in size, and can have a maximum
1467 size of 9744 sectors.
1468 size: [8576] *
1469 > w
1470 > q
1471 </code></pre>
1472 <p>or:</p>
1473 <pre><code># printf 'b\n\n*\nc a\n*\nw\n' | disklabel -E vnd0
1474 </code></pre>
1475 <p>Grow filesystem and check it and mark as clean:</p>
1476 <pre><code># growfs -y /dev/vnd0a
1477 # fsck -y /dev/vnd0a
1478 </code></pre>
1479 <p>Mount filesystem:</p>
1480 <pre><code># mount /dev/vnd0a mount/
1481 </code></pre>
1482 <p>The kernel on the miniroot is GZIP compressed. Compress our modified bsd.rd and
1483 overwrite the original kernel:</p>
1484 <pre><code># gzip -c9n bsd.rd > mount/bsd
1485 </code></pre>
1486 <p>Or to save space (+- 500KB) by stripping debug symbols, taken from bsd.gz target
1487 <a href="https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/distrib/amd64/iso/Makefile">in this Makefile</a>.</p>
1488 <pre><code>$ cp bsd.rd bsd.strip
1489 $ strip bsd.strip
1490 $ strip -R .comment -R .SUNW_ctf bsd.strip
1491 $ gzip -c9n bsd.strip > bsd.gz
1492 $ cp bsd.gz mount/bsd
1493 </code></pre>
1494 <p>Now unmount and detach:</p>
1495 <pre><code># umount mount/
1496 # vnconfig -u vnd0
1497 </code></pre>
1498 <p>Now you can <a href="https://man.openbsd.org/dd.1">dd(1)</a> the image new.fs to your bootable (USB) medium.</p>
1499 <h2>Adding custom sets (optional)</h2>
1500 <p>For patching <a href="https://man.openbsd.org/rc.firsttime.8">/etc/rc.firsttime</a> and other system files it is useful to use a
1501 customized installation set like siteVERSION.tgz, for example: site65.tgz. The
1502 sets can even be specified per host/MAC address like
1503 siteVERSION-$(hostname -s).tgz so for example: site65-testvm.tgz</p>
1504 <p>When the installer checks the base sets of the mirror it looks for a file
1505 index.txt. To add custom sets the site entries have to be added.</p>
1506 <p>For example:</p>
1507 <pre><code>-rw-r--r-- 1 1001 0 4538975 Oct 11 13:58:26 2018 site65-testvm.tgz
1508 </code></pre>
1509 <p>The filesize, permissions etc do not matter and are not checked by the
1510 installer. Only the filename is matched by a regular expression.</p>
1511 <h2>Sign custom site* tarball sets (optional)</h2>
1512 <p>If you have custom sets without creating a signed custom release you will be
1513 prompted for the messages:</p>
1514 <pre><code>checksum test failed
1515 </code></pre>
1516 <p>and:</p>
1517 <pre><code>unverified sets: continue without verification
1518 </code></pre>
1519 <p>OpenBSD uses the program <a href="https://man.openbsd.org/signify.1">signify(1)</a> to cryptographically sign and
1520 verify filesets.</p>
1521 <p>To create a custom public/private keypair (ofcourse make sure to store the
1522 private key privately):</p>
1523 <pre><code>$ signify -G -n -c "Custom 6.5 install" -p custom-65-base.pub -s custom-65-base.sec
1524 </code></pre>
1525 <p>Create new checksum file with filelist of the current directory (except SHA256*
1526 files):</p>
1527 <pre><code>$ printf '%s\n' * | grep -v SHA256 | xargs sha256 > SHA256
1528 </code></pre>
1529 <p>Sign SHA256 and store as SHA256.sig, embed signature:</p>
1530 <pre><code>$ signify -S -e -s /privatedir/custom-65-base.sec -m SHA256 -x SHA256.sig
1531 </code></pre>
1532 <p>Verify the created signature and data is correct:</p>
1533 <pre><code>$ signify -C -p /somelocation/custom-65-base.pub -x SHA256.sig
1534 </code></pre>
1535 <p>Copy <strong>only</strong> the <strong>public</strong> key to the RAMDISK:</p>
1536 <pre><code>$ cp custom-65-base.pub mount/etc/signify/custom-65-base.pub
1537 </code></pre>
1538 <p>Now we have to patch the install.sub file to check our public key. If you know
1539 a better way without having to patch this script, please let me know.</p>
1540 <p>Change the variable PUB_KEY in the shellscript mount/install.sub from:</p>
1541 <pre><code>PUB_KEY=/etc/signify/openbsd-${VERSION}-base.pub
1542 </code></pre>
1543 <p>To:</p>
1544 <pre><code>PUB_KEY=/etc/signify/custom-${VERSION}-base.pub
1545 </code></pre>
1546 <p>And for upgrades from:</p>
1547 <pre><code>$UPGRADE_BSDRD &&
1548 PUB_KEY=/mnt/etc/signify/openbsd-$((VERSION + 1))-base.pub
1549 </code></pre>
1550 <p>To:</p>
1551 <pre><code>$UPGRADE_BSDRD &&
1552 PUB_KEY=/mnt/etc/signify/custom-$((VERSION + 1))-base.pub
1553 </code></pre>
1554 <h2>Ideas</h2>
1555 <ul>
1556 <li>Patch <a href="https://man.openbsd.org/rc.firsttime.8">rc.firsttime(8)</a>: and run syspatch, add ports, setup xenodm etc.</li>
1557 <li>Custom partitioning scheme, see <a href="https://man.openbsd.org/autoinstall.8">autoinstall(8)</a> "URL to autopartitioning
1558 template for disklabel = url".</li>
1559 <li>Setup <a href="https://man.openbsd.org/pxeboot.8">pxeboot(8)</a> to boot and install over the network using
1560 <a href="https://man.openbsd.org/dhcpd.8">dhcpd(8)</a> and
1561 <a href="https://man.openbsd.org/tftpd.8">tftpd(8)</a> then not even some USB stick is required.</li>
1562 </ul>
1563 <h2>References</h2>
1564 <ul>
1565 <li>Main OpenBSD installation and upgrade shellscript:
1566 <a href="https://cvsweb.openbsd.org/src/distrib/miniroot/install.sub">/usr/src/distrib/miniroot/install.sub</a></li>
1567 </ul>
1568 ]]></description>
1569 </item>
1570 <item>
1571 <title>Idiotbox: Youtube interface</title>
1572 <link>https://www.codemadness.org/idiotbox.html</link>
1573 <guid>https://www.codemadness.org/idiotbox.html</guid>
1574 <dc:date>2019-02-10T00:00:00Z</dc:date>
1575 <author>Hiltjo</author>
1576 <description><![CDATA[<h1>Idiotbox: Youtube interface</h1>
1577 <p><strong>Last modification on </strong> <time>2021-12-25</time></p>
1578 <p>Idiotbox is a less resource-heavy Youtube interface. For viewing videos it is
1579 recommended to use it with <a href="https://mpv.io/">mpv</a> or
1580 <a href="https://mplayerhq.hu/">mplayer</a> with
1581 <a href="https://youtube-dl.org/">youtube-dl</a> or
1582 <a href="https://github.com/yt-dlp/yt-dlp">yt-dlp</a>.</p>
1583 <p>For more (up-to-date) information see the <a href="/git/frontends/file/youtube/README.html">README</a> file.</p>
1584 <h2>Why</h2>
1585 <p>In my opinion the standard Youtube web interface is:</p>
1586 <ul>
1587 <li>Non-intuitive, too much visual crap.</li>
1588 <li>Too resource-hungry, both in CPU and bandwidth.</li>
1589 <li>Doesn't work well on simpler (text-based) browsers such as netsurf and links.</li>
1590 </ul>
1591 <h2>Features</h2>
1592 <ul>
1593 <li>Doesn't use JavaScript.</li>
1594 <li>Doesn't use (tracking) cookies.</li>
1595 <li>CSS is optional.</li>
1596 <li>Multiple interfaces available: HTTP CGI, command-line, Gopher CGI (gph),
1597 this is a work-in-progress.</li>
1598 <li>Doesn't use or require the Google API.</li>
1599 <li>CGI interface works nice in most browsers, including text-based ones.</li>
1600 <li>On OpenBSD it runs "sandboxed" and it can be compiled as a static-linked
1601 binary with <a href="https://man.openbsd.org/pledge">pledge(2)</a>,
1602 <a href="https://man.openbsd.org/unveil">unveil(2)</a> in a chroot.</li>
1603 </ul>
1604 <h2>Cons</h2>
1605 <ul>
1606 <li>Order by upload date is incorrect (same as on Youtube).</li>
1607 <li>Some Youtube features are not supported.</li>
1608 <li>Uses scraping so might break at any point.</li>
1609 </ul>
1610 <h2>Clone</h2>
1611 <pre><code>git clone git://git.codemadness.org/frontends
1612 </code></pre>
1613 <h2>Browse</h2>
1614 <p>You can browse the source-code at:</p>
1615 <ul>
1616 <li><a href="https://git.codemadness.org/frontends/">https://git.codemadness.org/frontends/</a></li>
1617 <li><a href="gopher://codemadness.org/1/git/frontends">gopher://codemadness.org/1/git/frontends</a></li>
1618 </ul>
1619 <h2>Download releases</h2>
1620 <p>Releases are available at:</p>
1621 <ul>
1622 <li><a href="https://codemadness.org/releases/frontends/">https://codemadness.org/releases/frontends/</a></li>
1623 <li><a href="gopher://codemadness.org/1/releases/frontends">gopher://codemadness.org/1/releases/frontends</a></li>
1624 </ul>
1625 <h2>View</h2>
1626 <p>You can view it here: <a href="https://codemadness.org/idiotbox/">https://codemadness.org/idiotbox/</a></p>
1627 <p>For example you can search using the query string parameter "q":
1628 <a href="https://codemadness.org/idiotbox/?q=gunther+tralala">https://codemadness.org/idiotbox/?q=gunther+tralala</a></p>
1629 <p>The gopher version is here: <a href="gopher://codemadness.org/7/idiotbox.cgi">gopher://codemadness.org/7/idiotbox.cgi</a></p>
1630 ]]></description>
1631 </item>
1632 <item>
1633 <title>Gopher HTTP proxy</title>
1634 <link>https://www.codemadness.org/gopher-proxy.html</link>
1635 <guid>https://www.codemadness.org/gopher-proxy.html</guid>
1636 <dc:date>2018-08-17T00:00:00Z</dc:date>
1637 <author>Hiltjo</author>
1638 <description><![CDATA[<h1>Gopher HTTP proxy</h1>
1639 <p><strong>Last modification on </strong> <time>2020-08-30</time></p>
1640 <p>For fun I wrote a small HTTP Gopher proxy CGI program in C. It only supports
1641 the basic Gopher types and has some restrictions to prevent some abuse.</p>
1642 <p>For your regular Gopher browsing I recommend the simple Gopher client <a href="https://git.fifth.space/sacc/">sacc</a>.</p>
1643 <p>For more information about Gopher check out <a href="http://gopherproject.org/">gopherproject.org</a>.</p>
1644 <h2>Clone</h2>
1645 <pre><code>git clone git://git.codemadness.org/gopherproxy-c
1646 </code></pre>
1647 <h2>Browse</h2>
1648 <p>You can browse the source-code at:</p>
1649 <ul>
1650 <li><a href="https://git.codemadness.org/gopherproxy-c/">https://git.codemadness.org/gopherproxy-c/</a></li>
1651 <li><a href="gopher://codemadness.org/1/git/gopherproxy-c">gopher://codemadness.org/1/git/gopherproxy-c</a></li>
1652 </ul>
1653 <h2>View</h2>
1654 <p>You can view it here:
1655 <a href="https://codemadness.org/gopherproxy/">https://codemadness.org/gopherproxy/</a></p>
1656 <p>For example you can also view my gopherhole using the proxy, the query string
1657 parameter "q" reads the URI:
1658 <a href="https://codemadness.org/gopherproxy/?q=codemadness.org">https://codemadness.org/gopherproxy/?q=codemadness.org</a></p>
1659 <p><strong>Due to abuse this service is (temporary) disabled, but of course you can self-host it</strong></p>
1660 <p><strong>For authors writing crawler bots: please respect robots.txt, HTTP status codes and test your code properly</strong></p>
1661 ]]></description>
1662 </item>
1663 <item>
1664 <title>Setup your own file paste service</title>
1665 <link>https://www.codemadness.org/paste-service.html</link>
1666 <guid>https://www.codemadness.org/paste-service.html</guid>
1667 <dc:date>2018-03-10T00:00:00Z</dc:date>
1668 <author>Hiltjo</author>
1669 <description><![CDATA[<h1>Setup your own file paste service</h1>
1670 <p><strong>Last modification on </strong> <time>2018-03-10</time></p>
1671 <h2>Setup SSH authentication</h2>
1672 <p>Make sure to setup SSH public key authentication so you don't need to enter a
1673 password each time and have a more secure authentication.</p>
1674 <p>For example in the file $HOME/.ssh/config:</p>
1675 <pre><code>Host codemadness
1676 Hostname codemadness.org
1677 Port 22
1678 IdentityFile ~/.ssh/codemadness/id_rsa
1679 </code></pre>
1680 <p>Of course also make sure to generate the private and public keys.</p>
1681 <h2>Shell alias</h2>
1682 <p>Make an alias or function in your shell config:</p>
1683 <pre><code>pastesrv() {
1684 ssh user@codemadness "cat > /your/www/publicdir/paste/$1"
1685 echo "https://codemadness.org/paste/$1"
1686 }
1687 </code></pre>
1688 <p>This function reads any data from stdin and transfers the output securely via
1689 SSH and writes it to a file at the specified path. This path can be visible via
1690 HTTP, gopher or an other protocol. Then it writes the absolute URL to stdout,
1691 this URL can be copied to the clipboard and pasted anywhere like to an e-mail,
1692 IRC etc.</p>
1693 <h2>Usage and examples</h2>
1694 <p>To use it, here are some examples:</p>
1695 <p>Create a patch of the last commit in the git repo and store it:</p>
1696 <pre><code>git format-patch --stdout HEAD^ | pastesrv 'somepatch.diff'
1697 </code></pre>
1698 <p>Create a screenshot of your current desktop and paste it:</p>
1699 <pre><code>xscreenshot | ff2png | pastesrv 'screenshot.png'
1700 </code></pre>
1701 <p>There are many other uses of course, use your imagination :)</p>
1702 ]]></description>
1703 </item>
1704 <item>
1705 <title>Setup your own git hosting service</title>
1706 <link>https://www.codemadness.org/setup-git-hosting.html</link>
1707 <guid>https://www.codemadness.org/setup-git-hosting.html</guid>
1708 <dc:date>2018-02-25T00:00:00Z</dc:date>
1709 <author>Hiltjo</author>
1710 <description><![CDATA[<h1>Setup your own git hosting service</h1>
1711 <p><strong>Last modification on </strong> <time>2022-08-07</time></p>
1712 <p><strong>This article assumes you use OpenBSD for the service files and OS-specific
1713 examples.</strong></p>
1714 <h2>Why</h2>
1715 <p>A good reason to host your own git repositories is because of having and
1716 keeping control over your own computing infrastructure.</p>
1717 <p>Some bad examples:</p>
1718 <ul>
1719 <li><a href="https://en.wikipedia.org/wiki/SourceForge#Controversies">The SourceForge ads/malware/hijack controversies. Injecting malware into projects</a>.</li>
1720 <li><a href="https://gitlab.com/gitlab-org/gitaly/issues/2113">As of 2019-10-23 Gitlab added telemetry to their software</a>.</li>
1721 <li><a href="https://about.gitlab.com/blog/2019/10/10/update-free-software-and-telemetry/">On 2019-10-24 Gitlab reverted it again because many people complained</a>.</li>
1722 <li><a href="https://github.blog/2020-11-16-standing-up-for-developers-youtube-dl-is-back/">On 2020-11-16 Github reinstated youtube-dl, to reverse a Digital Millennium Copyright Act (DMCA) takedown</a>.</li>
1723 <li><a href="https://arstechnica.com/gadgets/2021/03/critics-fume-after-github-removes-exploit-code-for-exchange-vulnerabilities/">On 2021-03-11 Github (owned by Microsoft) removes exploit code for Microsoft Exchange vulnerabilities</a>.</li>
1724 <li><a href="https://www.bleepingcomputer.com/news/security/github-suspends-accounts-of-russian-devs-at-sanctioned-companies/">On 2022-04-16 Russian software developers are reporting that their GitHub accounts are being suspended without warning if they work for or previously worked for companies under US sanctions</a>.</li>
1725 <li><a href="https://www.theregister.com/2022/08/04/gitlab_data_retention_policy/">On 2022-08-04 GitLab plans to delete dormant projects in free accounts</a>.</li>
1726 <li><a href="https://www.theregister.com/2022/08/05/gitlab_reverses_deletion_policy/">On 2022-08-05 GitLab U-turns on deleting dormant projects after backlash</a>.</li>
1727 </ul>
1728 <p>The same thing can happen with Github, Atlassian Bitbucket or other similar
1729 services. After all: they are just a company with commercial interests. These
1730 online services also have different pricing plans and various (arbitrary)
1731 restrictions. When you host it yourself the restrictions are the resource
1732 limits of the system and your connection, therefore it is a much more flexible
1733 solution.</p>
1734 <p>Always make sure you own the software (which is <a href="https://www.gnu.org/philosophy/free-sw.html">Free</a> or open-source) and you
1735 can host it yourself, so you will be in control of it.</p>
1736 <h2>Creating repositories</h2>
1737 <p>For the hosting it is recommended to use a so-called "bare" repository. A bare
1738 repository means no files are checked out in the folder itself. To create a
1739 bare repository use git init with the --bare argument:</p>
1740 <pre><code>$ git init --bare
1741 </code></pre>
1742 <p>I recommend to create a separate user and group for the source-code
1743 repositories. In the examples we will assume the user is called "src".</p>
1744 <p>Login as the src user and create the files. To create a directory for the
1745 repos, in this example /home/src/src:</p>
1746 <pre><code>$ mkdir -p /home/src/src
1747 $ cd /home/src/src
1748 $ git init --bare someproject
1749 $ $EDITOR someproject/description
1750 </code></pre>
1751 <p>Make sure the git-daemon process has access permissions to these repositories.</p>
1752 <h2>Install git-daemon (optional)</h2>
1753 <p>Using git-daemon you can clone the repositories publicly using the efficient
1754 git:// protocol. An alternative without having to use git-daemon is by using
1755 (anonymous) SSH, HTTPS or any public shared filesystem.</p>
1756 <p>When you use a private-only repository I recommend to just use SSH without
1757 git-daemon because it is secure.</p>
1758 <p>Install the git package. The package should contain "git daemon":</p>
1759 <pre><code># pkg_add git
1760 </code></pre>
1761 <p>Enable the daemon:</p>
1762 <pre><code># rcctl enable gitdaemon
1763 </code></pre>
1764 <p>Set the gitdaemon service flags to use the src directory and use all the
1765 available repositories in this directory. The command-line flags "--export-all"
1766 exports all repositories in the base path. Alternatively you can use the
1767 "git-daemon-export-ok" file (see the git-daemon man page).</p>
1768 <pre><code># rcctl set gitdaemon flags --export-all --base-path="/home/src/src"
1769 </code></pre>
1770 <p>To configure the service to run as the user _gitdaemon:</p>
1771 <pre><code># rcctl set gitdaemon user _gitdaemon
1772 </code></pre>
1773 <p>To run the daemon directly as the user _gitdaemon (without dropping privileges
1774 from root to the user) set the following flags in /etc/rc.d/gitdaemon:</p>
1775 <pre><code>daemon_flags="--user=_gitdaemon"
1776 </code></pre>
1777 <p>Which will also avoid this warning while cloning:</p>
1778 <pre><code>"can't access /root/.git/config"
1779 </code></pre>
1780 <p>Now start the daemon:</p>
1781 <pre><code># rcctl start gitdaemon
1782 </code></pre>
1783 <h2>Cloning and fetching changes</h2>
1784 <p>To test and clone the repository do:</p>
1785 <pre><code>$ git clone git://yourdomain/someproject
1786 </code></pre>
1787 <p>if you skipped the optional git-daemon installation then just clone via SSH:</p>
1788 <pre><code>$ git clone ssh://youraccount@yourdomain:/home/src/src/someproject
1789 </code></pre>
1790 <p>When cloning via SSH make sure to setup private/public key authentication for
1791 security and convenience.</p>
1792 <p>You should also make sure the firewall allows connections to the services like
1793 the git daemon, HTTPd or SSH, for example using OpenBSD pf something like this
1794 can be set in <a href="https://man.openbsd.org/pf.conf">/etc/pf.conf</a>:</p>
1795 <pre><code>tcp_services="{ ssh, gopher, http, https, git }"
1796 pass in on egress proto tcp from any to (egress) port $tcp_services
1797 </code></pre>
1798 <h2>Pushing changes</h2>
1799 <p>Add the repository as a remote:</p>
1800 <pre><code>$ git remote add myremote ssh://youraccount@yourdomain:/home/src/src/someproject
1801 </code></pre>
1802 <p>Then push the changes:</p>
1803 <pre><code>$ git push myremote master:master
1804 </code></pre>
1805 <h2>Git history web browsing (optional)</h2>
1806 <p>Sometimes it's nice to browse the git history log of the repository in a web
1807 browser or some other program without having to look at the local repository.</p>
1808 <ul>
1809 <li><a href="stagit.html">Stagit</a> is a static HTML page generator for git.</li>
1810 <li><a href="stagit-gopher.html">Stagit-gopher</a> is a static page generator for
1811 <a href="http://gopherproject.org/">gopher</a> and
1812 <a href="gopher://bitreich.org/1/scm/geomyidae">geomyidae</a>.</li>
1813 <li>cgit is a CGI-based program which shows HTML views of your repository, see
1814 also the page: <a href="openbsd-httpd-and-cgit.html">OpenBSD httpd, slowcgi and cgit</a>.</li>
1815 </ul>
1816 <p>It's also possible with these tools to generate an Atom feed and then use a
1817 RSS/Atom reader to track the git history:</p>
1818 <ul>
1819 <li>An example url from cgit: <a href="https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/atom/?h=master">Linux kernel tree</a>.</li>
1820 <li>An example url from stagit for the <a href="/git/stagit/atom.xml">commit log</a>.</li>
1821 <li>An example url from stagit for the <a href="/git/stagit/tags.xml">releases</a>.</li>
1822 </ul>
1823 <p>My <a href="sfeed.html">sfeed</a> program can be used as a RSS/Atom reader.</p>
1824 <h2>Setting up git hooks (optional)</h2>
1825 <p>Using git hooks you can setup automated triggers, for example when pushing to a
1826 repository. Some useful examples can be:</p>
1827 <ul>
1828 <li><a href="/git/stagit/file/example_post-receive.sh.html">For stagit: update the repo files (example post-receive hook).</a></li>
1829 <li>Send an e-mail with the commit subject and message.</li>
1830 <li>Log/notify commits and changes to an IRC channel using a fifo: <a href="https://tools.suckless.org/ii/">ii</a>.</li>
1831 <li>Create a release tarball and checksum file on a tag push/change.</li>
1832 <li>Checkout files for website content.</li>
1833 </ul>
1834 ]]></description>
1835 </item>
1836 <item>
1837 <title>Setup an OpenBSD SPARC64 VM in QEMU</title>
1838 <link>https://www.codemadness.org/openbsd-sparc64-vm.html</link>
1839 <guid>https://www.codemadness.org/openbsd-sparc64-vm.html</guid>
1840 <dc:date>2017-12-11T00:00:00Z</dc:date>
1841 <author>Hiltjo</author>
1842 <description><![CDATA[<h1>Setup an OpenBSD SPARC64 VM in QEMU</h1>
1843 <p><strong>Last modification on </strong> <time>2020-04-18</time></p>
1844 <p>This describes how to setup an OpenBSD SPARC64 VM in QEMU.</p>
1845 <h2>Create a disk image</h2>
1846 <p>To create a 5GB disk image:</p>
1847 <pre><code>qemu-img create -f qcow2 fs.qcow2 5G
1848 </code></pre>
1849 <h2>Install</h2>
1850 <p>In this guide we'll use the installation ISO to install OpenBSD. Make sure to
1851 download the latest (stable) OpenBSD ISO, for example install62.iso.</p>
1852 <ul>
1853 <li>Change -boot c to -boot d to boot from the CD-ROM and do a clean install.</li>
1854 <li>Change -cdrom install62.iso to the location of your ISO file.</li>
1855 <li>When the install is done type: halt -p</li>
1856 <li>Change -boot d back to -boot c.</li>
1857 </ul>
1858 <p>Start the VM:</p>
1859 <pre><code>#!/bin/sh
1860 LC_ALL=C QEMU_AUDIO_DRV=none \
1861 qemu-system-sparc64 \
1862 -machine sun4u,usb=off \
1863 -realtime mlock=off \
1864 -smp 1,sockets=1,cores=1,threads=1 \
1865 -rtc base=utc \
1866 -m 1024 \
1867 -boot c \
1868 -drive file=fs.qcow2,if=none,id=drive-ide0-0-1,format=qcow2,cache=none \
1869 -cdrom install62.iso \
1870 -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-1,id=ide0-0-1 \
1871 -msg timestamp=on \
1872 -serial pty -nographic \
1873 -net nic,model=ne2k_pci -net user
1874 </code></pre>
1875 <p>The VM has the following properties:</p>
1876 <ul>
1877 <li>No audio.</li>
1878 <li>No USB.</li>
1879 <li>No VGA graphics: serial console.</li>
1880 <li>Netdev is ne0 (Realtek 8029).</li>
1881 <li>1024MB memory.</li>
1882 </ul>
1883 <p>From your host connect to the serial device indicated by QEMU, for example:</p>
1884 <pre><code>(qemu) 2017-11-19T15:14:20.884312Z qemu-system-sparc64: -serial pty: char device redirected to /dev/ttyp0 (label serial0)
1885 </code></pre>
1886 <p>Then you can use the serial terminal emulator <strong>cu</strong> to attach:</p>
1887 <pre><code>cu -l /dev/ttyp0
1888 </code></pre>
1889 <p>Another option could be using the <a href="https://git.suckless.org/st/">simple terminal(st)</a> from suckless.</p>
1890 <pre><code>st -l /dev/ttyp0
1891 </code></pre>
1892 <p>using cu to detach the <a href="https://man.openbsd.org/cu#~^D">cu(1) man page</a> says:</p>
1893 <pre><code>Typed characters are normally transmitted directly to the remote machine (which
1894 does the echoing as well). A tilde ('~') appearing as the first character of a
1895 line is an escape signal; the following are recognized:
1896
1897 ~^D or ~. Drop the connection and exit. Only the connection is
1898 the login session is not terminated.
1899 </code></pre>
1900 <p>On boot you have to type:</p>
1901 <pre><code>root device: wd0a
1902 for swap use the default (wd0b) Press enter
1903 </code></pre>
1904 <h2>Initial settings on first boot (optional)</h2>
1905 <p>Automatic network configuration using DHCP</p>
1906 <pre><code>echo "dhcp" > /etc/hostname.ne0
1907 </code></pre>
1908 <p>To bring up the interface (will be automatic on the next boot):</p>
1909 <pre><code>sh /etc/netstart
1910 </code></pre>
1911 <p>Add a mirror to /etc/installurl for package installation. Make sure to lookup
1912 the most efficient/nearby mirror site on the OpenBSD mirror page.</p>
1913 <pre><code>echo "https://ftp.hostserver.de/pub/OpenBSD" > /etc/installurl
1914 </code></pre>
1915 ]]></description>
1916 </item>
1917 <item>
1918 <title>Tscrape: a Twitter scraper</title>
1919 <link>https://www.codemadness.org/tscrape.html</link>
1920 <guid>https://www.codemadness.org/tscrape.html</guid>
1921 <dc:date>2017-09-24T00:00:00Z</dc:date>
1922 <author>Hiltjo</author>
1923 <description><![CDATA[<h1>Tscrape: a Twitter scraper</h1>
1924 <p><strong>Last modification on </strong> <time>2020-07-20</time></p>
1925 <p>Tscrape is a Twitter web scraper and archiver.</p>
1926 <p>Twitter removed the functionality to follow users using a RSS feed without
1927 authenticating or using their API. With this program you can format tweets in
1928 any way you like relatively anonymously.</p>
1929 <p>For more (up-to-date) information see the <a href="/git/tscrape/file/README.html">README</a> file.</p>
1930 <h2>Clone</h2>
1931 <pre><code>git clone git://git.codemadness.org/tscrape
1932 </code></pre>
1933 <h2>Browse</h2>
1934 <p>You can browse the source-code at:</p>
1935 <ul>
1936 <li><a href="https://git.codemadness.org/tscrape/">https://git.codemadness.org/tscrape/</a></li>
1937 <li><a href="gopher://codemadness.org/1/git/tscrape">gopher://codemadness.org/1/git/tscrape</a></li>
1938 </ul>
1939 <h2>Download releases</h2>
1940 <p>Releases are available at:</p>
1941 <ul>
1942 <li><a href="https://codemadness.org/releases/tscrape/">https://codemadness.org/releases/tscrape/</a></li>
1943 <li><a href="gopher://codemadness.org/1/releases/tscrape">gopher://codemadness.org/1/releases/tscrape</a></li>
1944 </ul>
1945 <h2>Examples</h2>
1946 <p>Output format examples:</p>
1947 <ul>
1948 <li><a href="tscrape/tscrape_html.html">tscrape_html: HTML</a></li>
1949 <li><a href="tscrape/tscrape_plain.txt">tscrape_plain: Text</a></li>
1950 </ul>
1951 ]]></description>
1952 </item>
1953 <item>
1954 <title>jsdatatable: a small datatable Javascript</title>
1955 <link>https://www.codemadness.org/datatable.html</link>
1956 <guid>https://www.codemadness.org/datatable.html</guid>
1957 <dc:date>2017-09-24T00:00:00Z</dc:date>
1958 <author>Hiltjo</author>
1959 <description><![CDATA[<h1>jsdatatable: a small datatable Javascript</h1>
1960 <p><strong>Last modification on </strong> <time>2020-07-20</time></p>
1961 <p>This is a small datatable Javascript with no dependencies.</p>
1962 <h2>Features</h2>
1963 <ul>
1964 <li>Small:
1965 <ul>
1966 <li>Filesize: +- 9.1KB.</li>
1967 <li>Lines: +- 300, not much code, so hopefully easy to understand.</li>
1968 <li>No dependencies on other libraries like jQuery.</li>
1969 </ul>
1970 </li>
1971 <li>Sorting on columns, multi-column support with shift-click.</li>
1972 <li>Filtering values: case-insensitively, tokenized (separated by space).</li>
1973 <li>Able to add custom filtering, parsing and sorting functions.</li>
1974 <li>Helper function for delayed (150ms) filtering, so filtering feels more
1975 responsive for big datasets.</li>
1976 <li>Permissive ISC license, see LICENSE file.</li>
1977 <li>"Lazy scroll" mode:
1978 <ul>
1979 <li>fixed column headers and renders only visible rows, this allows you to
1980 "lazily" render millions of rows.</li>
1981 </ul>
1982 </li>
1983 <li>Officially supported browsers are:
1984 <ul>
1985 <li>Firefox and Firefox ESR.</li>
1986 <li>Chrome and most recent webkit-based browsers.</li>
1987 <li>IE10+.</li>
1988 </ul>
1989 </li>
1990 </ul>
1991 <h2>Why? and a comparison</h2>
1992 <p>It was created because all the other datatable scripts suck balls.</p>
1993 <p>Most Javascripts nowadays have a default dependency on jQuery, Bootstrap or
1994 other frameworks.</p>
1995 <p>jQuery adds about 97KB and Bootstrap adds about 100KB to your scripts and CSS
1996 as a dependency. This increases the CPU, memory and bandwidth consumption and
1997 latency. It also adds complexity to your scripts.</p>
1998 <p>jQuery was mostly used for backwards-compatibility in the Internet Explorer
1999 days, but is most often not needed anymore. It contains functionality to query
2000 the DOM using CSS-like selectors, but this is now supported with for example
2001 document.querySelectorAll. Functionality like a JSON parser is standard
2002 available now: JSON.parse().</p>
2003 <h3>Size comparison</h3>
2004 <p>All sizes are not "minified" or gzipped.</p>
2005 <pre><code>Name | Total | JS | CSS | Images | jQuery
2006 ---------------------------------+---------+---------+-------+--------+-------
2007 jsdatatable | 12.9KB | 9.1KB | 2.5KB | 1.3KB | -
2008 datatables.net (without plugins) | 563.4KB | 449.3KB | 16KB | 0.8KB | 97.3KB
2009 jdatatable | 154.6KB | 53KB | 1KB | 3.3KB | 97.3KB
2010 </code></pre>
2011 <ul>
2012 <li><a href="https://datatables.net/">datatables.net</a> (without plugins).</li>
2013 <li><a href="https://plugins.jquery.com/jdatatable/">jdatatable</a></li>
2014 </ul>
2015 <p>Of course jsdatatable has less features (less is more!), but it does 90% of
2016 what's needed. Because it is so small it is also much simpler to understand and
2017 extend with required features if needed.</p>
2018 <p>See also:
2019 <a href="https://idlewords.com/talks/website_obesity.htm">The website obesity crisis</a></p>
2020 <h2>Clone</h2>
2021 <pre><code>git clone git://git.codemadness.org/jscancer
2022 </code></pre>
2023 <h2>Browse</h2>
2024 <p>You can browse the source-code at:</p>
2025 <ul>
2026 <li><a href="https://git.codemadness.org/jscancer/">https://git.codemadness.org/jscancer/</a></li>
2027 <li><a href="gopher://codemadness.org/1/git/jscancer">gopher://codemadness.org/1/git/jscancer</a></li>
2028 </ul>
2029 <p>It is in the datatable directory.</p>
2030 <h2>Download releases</h2>
2031 <p>Releases are available at:</p>
2032 <ul>
2033 <li><a href="https://codemadness.org/releases/jscancer/">https://codemadness.org/releases/jscancer/</a></li>
2034 <li><a href="gopher://codemadness.org/1/releases/jscancer">gopher://codemadness.org/1/releases/jscancer</a></li>
2035 </ul>
2036 <h2>Usage</h2>
2037 <h3>Examples</h3>
2038 <p>See example.html for an example. A stylesheet file datatable.css is also
2039 included, it contains the icons as embedded images.</p>
2040 <p>A table should have the classname "datatable" set, it must contain a <thead>
2041 for the column headers (<td> or <th>) and <tbody> element for the data. The
2042 minimal code needed for a working datatable:</p>
2043 <pre><code><html>
2044 <body>
2045 <input class="filter-text" /><!-- optional -->
2046 <table class="datatable">
2047 <thead><!-- columns -->
2048 <tr><td>Click me</td></tr>
2049 </thead>
2050 <tbody><!-- data -->
2051 <tr><td>a</td></tr>
2052 <tr><td>b</td></tr>
2053 </tbody>
2054 </table>
2055 <script type="text/javascript" src="datatable.js"></script>
2056 <script type="text/javascript">var datatables = datatable_autoload();</script>
2057 </body>
2058 </html>
2059 </code></pre>
2060 <h3>Column attributes</h3>
2061 <p>The following column attributes are supported:</p>
2062 <ul>
2063 <li>data-filterable: if "1" or "true" specifies if the column can be filtered,
2064 default: "true".</li>
2065 <li>data-parse: specifies how to parse the values, default: "string", which is
2066 datatable_parse_string(). See PARSING section below.</li>
2067 <li>data-sort: specifies how to sort the values: default: "default", which is
2068 datatable_sort_default(). See SORTING section below.</li>
2069 <li>data-sortable: if "1" or "true" specifies if the column can be sorted,
2070 default: "true".</li>
2071 </ul>
2072 <h3>Parsing</h3>
2073 <p>By default only parsing for the types: date, float, int and string are
2074 supported, but other types can be easily added as a function with the name:
2075 datatable_parse_<typename>(). The parse functions parse the data-value
2076 attribute when set or else the cell content (in order). Because of this
2077 behaviour you can set the actual values as the data-value attribute and use the
2078 cell content for display. This is useful to display and properly sort
2079 locale-aware currency, datetimes etc.</p>
2080 <h3>Filtering</h3>
2081 <p>Filtering will be done case-insensitively on the cell content and when set also
2082 on the data-value attribute. The filter string is split up as tokens separated
2083 by space. Each token must match at least once per row to display it.</p>
2084 <h3>Sorting</h3>
2085 <p>Sorting is done on the parsed values by default with the function:
2086 datatable_sort_default(). To change this you can set a customname string on
2087 the data-sort attribute on the column which translates to the function:
2088 datatable_sort_<customname>().</p>
2089 <p>In some applications locale values are used, like for currency, decimal numbers
2090 datetimes. Some people also like to use icons or extended HTML elements inside
2091 the cell. Because jsdatatable sorts on the parsed value (see section PARSING)
2092 it is possible to sort on the data-value attribute values and use the cell
2093 content for display.</p>
2094 <p>For example:</p>
2095 <ul>
2096 <li>currency, decimal numbers: use data-value attribute with floating-point
2097 number, set data-parse column to "float".</li>
2098 <li>date/datetimes: use data-value attribute with UNIX timestamps (type int), set
2099 data-parse on column to "int" or set the data-parse attribute on column to
2100 "date" which is datatable_parse_date(), then make sure to use Zulu times, like:
2101 "2016-01-01T01:02:03Z" or other time strings that are parsable as the
2102 data-value attribute.</li>
2103 <li>icons: generally use data-value attribute with integer as weight value to
2104 sort on, set data-parse column to "int".</li>
2105 </ul>
2106 <h3>Dynamically update data</h3>
2107 <p>To update data dynamically see example-ajax.html for an example how to do this.</p>
2108 <h3>Caveats</h3>
2109 <ul>
2110 <li>A date, integer, float or other values must be able to parse properly, when
2111 the parse function returns NaN, null or undefined etc. the sorting behaviour is
2112 also undefined. It is recommended to always set a zero value for each type.</li>
2113 <li><tfoot> is not supported in datatables in "lazy" mode.</li>
2114 </ul>
2115 <h2>Demo / example</h2>
2116 <p><strong>For the below example to work you need to have Javascript enabled.</strong></p>
2117 <p><a href="datatable-example.html">datatable-example.html</a></p>
2118 ]]></description>
2119 </item>
2120 <item>
2121 <title>Stagit-gopher: a static git page generator for gopher</title>
2122 <link>https://www.codemadness.org/stagit-gopher.html</link>
2123 <guid>https://www.codemadness.org/stagit-gopher.html</guid>
2124 <dc:date>2017-08-04T00:00:00Z</dc:date>
2125 <author>Hiltjo</author>
2126 <description><![CDATA[<h1>Stagit-gopher: a static git page generator for gopher</h1>
2127 <p><strong>Last modification on </strong> <time>2021-04-11</time></p>
2128 <p>stagit-gopher is a static page generator for Gopher. It creates the pages as
2129 static <a href="http://git.r-36.net/geomyidae/">geomyidae</a> .gph files. stagit-gopher is a modified version from the
2130 HTML version of stagit.</p>
2131 <p><a href="/git/stagit-gopher/file/README.html">Read the README for more information about it.</a></p>
2132 <p>I also run a gopherhole and stagit-gopher, you can see how it looks here:
2133 <a href="gopher://codemadness.org/1/git/">gopher://codemadness.org/1/git/</a></p>
2134 <p><a href="https://git.fifth.space/sacc/log.html">sacc</a> is a good Gopher client to view it.</p>
2135 <h2>Features</h2>
2136 <ul>
2137 <li>Log of all commits from HEAD.</li>
2138 <li>Log and diffstat per commit.</li>
2139 <li>Show file tree with line numbers.</li>
2140 <li>Show references: local branches and tags.</li>
2141 <li>Detect README and LICENSE file from HEAD and link it as a webpage.</li>
2142 <li>Detect submodules (.gitmodules file) from HEAD and link it as a webpage.</li>
2143 <li>Atom feed of the commit log (atom.xml).</li>
2144 <li>Atom feed of the tags/refs (tags.xml).</li>
2145 <li>Make index page for multiple repositories with stagit-gopher-index.</li>
2146 <li>After generating the pages (relatively slow) serving the files is very fast,
2147 simple and requires little resources (because the content is static), a
2148 geomyidae Gopher server is required.</li>
2149 <li>Security: all pages are static. No CGI or dynamic code is run for the
2150 interface. Using it with a secure Gopher server such as geomyidae it is
2151 privilege-dropped and chroot(2)'d.</li>
2152 <li>Simple to setup: the content generation is clearly separated from serving it.
2153 This makes configuration as simple as copying a few directories and scripts.</li>
2154 <li>Usable with Gopher clients such as lynx and <a href="https://git.fifth.space/sacc/log.html">sacc</a>.</li>
2155 </ul>
2156 <h2>Cons</h2>
2157 <ul>
2158 <li>Not suitable for large repositories (2000+ commits), because diffstats are
2159 an expensive operation, the cache (-c flag) is a workaround for this in
2160 some cases.</li>
2161 <li>Not suitable for large repositories with many files, because all files are
2162 written for each execution of stagit. This is because stagit shows the lines
2163 of textfiles and there is no "cache" for file metadata (this would add more
2164 complexity to the code).</li>
2165 <li>Not suitable for repositories with many branches, a quite linear history is
2166 assumed (from HEAD).</li>
2167 <li>Relatively slow to run the first time (about 3 seconds for sbase,
2168 1500+ commits), incremental updates are faster.</li>
2169 <li>Does not support some of the dynamic features cgit has (for HTTP), like:
2170 <ul>
2171 <li>Snapshot tarballs per commit.</li>
2172 <li>File tree per commit.</li>
2173 <li>History log of branches diverged from HEAD.</li>
2174 <li>Stats (git shortlog -s).</li>
2175 </ul>
2176 </li>
2177 </ul>
2178 <p>This is by design, just use git locally.</p>
2179 <h2>Clone</h2>
2180 <pre><code>git clone git://git.codemadness.org/stagit-gopher
2181 </code></pre>
2182 <h2>Browse</h2>
2183 <p>You can browse the source-code at:</p>
2184 <ul>
2185 <li><a href="https://git.codemadness.org/stagit-gopher/">https://git.codemadness.org/stagit-gopher/</a></li>
2186 <li><a href="gopher://codemadness.org/1/git/stagit-gopher">gopher://codemadness.org/1/git/stagit-gopher</a></li>
2187 </ul>
2188 <h2>Download releases</h2>
2189 <p>Releases are available at:</p>
2190 <ul>
2191 <li><a href="https://codemadness.org/releases/stagit-gopher/">https://codemadness.org/releases/stagit-gopher/</a></li>
2192 <li><a href="gopher://codemadness.org/1/releases/stagit-gopher">gopher://codemadness.org/1/releases/stagit-gopher</a></li>
2193 </ul>
2194 ]]></description>
2195 </item>
2196 <item>
2197 <title>Saait: a boring HTML page generator</title>
2198 <link>https://www.codemadness.org/saait.html</link>
2199 <guid>https://www.codemadness.org/saait.html</guid>
2200 <dc:date>2017-06-10T00:00:00Z</dc:date>
2201 <author>Hiltjo</author>
2202 <description><![CDATA[<h1>Saait: a boring HTML page generator</h1>
2203 <p><strong>Last modification on </strong> <time>2020-07-20</time></p>
2204 <p>Saait is the most boring static HTML page generator.</p>
2205 <p>Meaning of saai (dutch): boring. Pronunciation: site</p>
2206 <p><a href="/git/saait/file/README.html">Read the README for more information about it.</a></p>
2207 <p>I used to use <a href="/git/static-site-scripts/files.html">shellscripts</a> to generate the static pages, but realised I
2208 wanted a small program that works on each platform consistently. There are
2209 many incompatibilities or unimplemented features in base tools across different
2210 platforms: Linux, UNIX, Windows.</p>
2211 <p>This site is created using saait.</p>
2212 <h2>Features</h2>
2213 <ul>
2214 <li>Single small binary that handles all the things. At run-time no dependency on
2215 other tools.</li>
2216 <li>Few lines of code (about 575 lines of C) and no dependencies except: a C
2217 compiler and libc.</li>
2218 <li>Works on most platforms: tested on Linux, *BSD, Windows.</li>
2219 <li>Simple template syntax.</li>
2220 <li>Uses HTML output by default, but can easily be modified to generate any
2221 textual content, like gopher pages, wiki pages or other kinds of documents.</li>
2222 <li>Out-of-the-box supports: creating an index page of all pages, Atom feed,
2223 twtxt.txt feed, sitemap.xml and urllist.txt.</li>
2224 </ul>
2225 <h2>Cons</h2>
2226 <ul>
2227 <li>Simple template syntax, but very basic. Requires C knowledge to extend it if
2228 needed.</li>
2229 <li>Only basic (no nested) template blocks supported.</li>
2230 </ul>
2231 <h2>Clone</h2>
2232 <pre><code>git clone git://git.codemadness.org/saait
2233 </code></pre>
2234 <h2>Browse</h2>
2235 <p>You can browse the source-code at:</p>
2236 <ul>
2237 <li><a href="https://git.codemadness.org/saait/">https://git.codemadness.org/saait/</a></li>
2238 <li><a href="gopher://codemadness.org/1/git/saait">gopher://codemadness.org/1/git/saait</a></li>
2239 </ul>
2240 <h2>Download releases</h2>
2241 <p>Releases are available at:</p>
2242 <ul>
2243 <li><a href="https://codemadness.org/releases/saait/">https://codemadness.org/releases/saait/</a></li>
2244 <li><a href="gopher://codemadness.org/1/releases/saait">gopher://codemadness.org/1/releases/saait</a></li>
2245 </ul>
2246 <h2>Documentation / man page</h2>
2247 <p>Below is the saait(1) man page, which includes usage examples.</p>
2248 <pre><code>
2249 SAAIT(1) General Commands Manual SAAIT(1)
2250
2251 NAME
2252 saait the most boring static page generator
2253
2254 SYNOPSIS
2255 saait [-c configfile] [-o outputdir] [-t templatesdir] pages...
2256
2257 DESCRIPTION
2258 saait writes HTML pages to the output directory.
2259
2260 The arguments pages are page config files, which are processed in the
2261 given order.
2262
2263 The options are as follows:
2264
2265 -c configfile
2266 The global configuration file, the default is "config.cfg". Each
2267 page configuration file inherits variables from this file. These
2268 variables can be overwritten per page.
2269
2270 -o outputdir
2271 The output directory, the default is "output".
2272
2273 -t templatesdir
2274 The templates directory, the default is "templates".
2275
2276 DIRECTORY AND FILE STRUCTURE
2277 A recommended directory structure for pages, although the names can be
2278 anything:
2279 pages/001-page.cfg
2280 pages/001-page.html
2281 pages/002-page.cfg
2282 pages/002-page.html
2283
2284 The directory and file structure for templates must be:
2285 templates/<templatename>/header.ext
2286 templates/<templatename>/item.ext
2287 templates/<templatename>/footer.ext
2288
2289 The following filename prefixes are detected for template blocks and
2290 processed in this order:
2291
2292 "header."
2293 Header block.
2294
2295 "item."
2296 Item block.
2297
2298 "footer."
2299 Footer block.
2300
2301 The files are saved as output/<templatename>, for example
2302 templates/atom.xml/* will become: output/atom.xml. If a template block
2303 file does not exist then it is treated as if it was empty.
2304
2305 Template directories starting with a dot (".") are ignored.
2306
2307 The "page" templatename is special and will be used per page.
2308
2309 CONFIG FILE
2310 A config file has a simple key=value configuration syntax, for example:
2311
2312 # this is a comment line.
2313 filename = example.html
2314 title = Example page
2315 description = This is an example page
2316 created = 2009-04-12
2317 updated = 2009-04-14
2318
2319 The following variable names are special with their respective defaults:
2320
2321 contentfile
2322 Path to the input content filename, by default this is the path
2323 of the config file with the last extension replaced to ".html".
2324
2325 filename
2326 The filename or relative file path for the output file for this
2327 page. By default the value is the basename of the contentfile.
2328 The path of the written output file is the value of filename
2329 appended to the outputdir path.
2330
2331 A line starting with # is a comment and is ignored.
2332
2333 TABs and spaces before and after a variable name are ignored. TABs and
2334 spaces before a value are ignored.
2335
2336 TEMPLATES
2337 A template (block) is text. Variables are replaced with the values set
2338 in the config files.
2339
2340 The possible operators for variables are:
2341
2342 $ Escapes a XML string, for example: < to the entity &lt;.
2343
2344 # Literal raw string value.
2345
2346 % Insert contents of file of the value of the variable.
2347
2348 For example in a HTML item template:
2349
2350 <article>
2351 <header>
2352 <h1><a href="">${title}</a></h1>
2353 <p>
2354 <strong>Last modification on </strong>
2355 <time datetime="${updated}">${updated}</time>
2356 </p>
2357 </header>
2358 %{contentfile}
2359 </article>
2360
2361 EXIT STATUS
2362 The saait utility exits 0 on success, and >0 if an error occurs.
2363
2364 EXAMPLES
2365 A basic usage example:
2366
2367 1. Create a directory for a new site:
2368
2369 mkdir newsite
2370
2371 2. Copy the example pages, templates, global config file and example
2372 stylesheets to a directory:
2373
2374 cp -r pages templates config.cfg style.css print.css newsite/
2375
2376 3. Change the current directory to the created directory.
2377
2378 cd newsite/
2379
2380 4. Change the values in the global config.cfg file.
2381
2382 5. If you want to modify parts of the header, like the navigation menu
2383 items, you can change the following two template files:
2384 templates/page/header.html
2385 templates/index.html/header.html
2386
2387 6. Create any new pages in the pages directory. For each config file
2388 there has to be a corresponding HTML file. By default this HTML
2389 file has the path of the config file, but with the last extension
2390 (".cfg" in this case) replaced to ".html".
2391
2392 7. Create an output directory:
2393
2394 mkdir -p output
2395
2396 8. After any modifications the following commands can be used to
2397 generate the output and process the pages in descending order:
2398
2399 find pages -type f -name '*.cfg' -print0 | sort -zr | xargs -0 saait
2400
2401 9. Copy the modified stylesheets to the output directory also:
2402
2403 cp style.css print.css output/
2404
2405 10. Open output/index.html locally in your webbrowser to review the
2406 changes.
2407
2408 11. To synchronize files, you can securely transfer them via SSH using
2409 rsync:
2410
2411 rsync -av output/ user@somehost:/var/www/htdocs/
2412
2413 TRIVIA
2414 The most boring static page generator.
2415
2416 Meaning of saai (dutch): boring, pronunciation of saait: site
2417
2418 SEE ALSO
2419 find(1), sort(1), xargs(1)
2420
2421 AUTHORS
2422 Hiltjo Posthuma <hiltjo@codemadness.org>
2423 </code></pre>
2424 ]]></description>
2425 </item>
2426 <item>
2427 <title>Stagit: a static git page generator</title>
2428 <link>https://www.codemadness.org/stagit.html</link>
2429 <guid>https://www.codemadness.org/stagit.html</guid>
2430 <dc:date>2017-05-10T00:00:00Z</dc:date>
2431 <author>Hiltjo</author>
2432 <description><![CDATA[<h1>Stagit: a static git page generator</h1>
2433 <p><strong>Last modification on </strong> <time>2021-04-11</time></p>
2434 <p>stagit is a static page generator for git.</p>
2435 <p><a href="/git/stagit/file/README.html">Read the README for more information about it.</a></p>
2436 <p>My git repository uses stagit, you can see how it looks here:
2437 <a href="https://codemadness.org/git/">https://codemadness.org/git/</a></p>
2438 <h2>Features</h2>
2439 <ul>
2440 <li>Log of all commits from HEAD.</li>
2441 <li>Log and diffstat per commit.</li>
2442 <li>Show file tree with linkable line numbers.</li>
2443 <li>Show references: local branches and tags.</li>
2444 <li>Detect README and LICENSE file from HEAD and link it as a webpage.</li>
2445 <li>Detect submodules (.gitmodules file) from HEAD and link it as a webpage.</li>
2446 <li>Atom feed of the commit log (atom.xml).</li>
2447 <li>Atom feed of the tags/refs (tags.xml).</li>
2448 <li>Make index page for multiple repositories with stagit-index.</li>
2449 <li>After generating the pages (relatively slow) serving the files is very fast,
2450 simple and requires little resources (because the content is static), only
2451 a HTTP file server is required.</li>
2452 <li>Security: all pages are static. No CGI or dynamic code is run for the
2453 interface. Using it with a secure httpd such as OpenBSD httpd it is
2454 privilege-separated, chroot(2)'d and pledge(2)'d.</li>
2455 <li>Simple to setup: the content generation is clearly separated from serving
2456 it. This makes configuration as simple as copying a few directories and
2457 scripts.</li>
2458 <li>Usable with text-browsers such as dillo, links, lynx and w3m.</li>
2459 </ul>
2460 <h2>Cons</h2>
2461 <ul>
2462 <li>Not suitable for large repositories (2000+ commits), because diffstats are
2463 an expensive operation, the cache (-c flag) or (-l maxlimit) is a workaround
2464 for this in some cases.</li>
2465 <li>Not suitable for large repositories with many files, because all files are
2466 written for each execution of stagit. This is because stagit shows the lines
2467 of textfiles and there is no "cache" for file metadata (this would add more
2468 complexity to the code).</li>
2469 <li>Not suitable for repositories with many branches, a quite linear history is
2470 assumed (from HEAD).</li>
2471 </ul>
2472 <p>In these cases it is better to use <a href="https://git.zx2c4.com/cgit/">cgit</a> or
2473 possibly change stagit to run as a CGI program.</p>
2474 <ul>
2475 <li>Relatively slow to run the first time (about 3 seconds for sbase,
2476 1500+ commits), incremental updates are faster.</li>
2477 <li>Does not support some of the dynamic features cgit has, like:
2478 <ul>
2479 <li>Snapshot tarballs per commit.</li>
2480 <li>File tree per commit.</li>
2481 <li>History log of branches diverged from HEAD.</li>
2482 <li>Stats (git shortlog -s).</li>
2483 </ul>
2484 </li>
2485 </ul>
2486 <p>This is by design, just use git locally.</p>
2487 <h2>Clone</h2>
2488 <pre><code>git clone git://git.codemadness.org/stagit
2489 </code></pre>
2490 <h2>Browse</h2>
2491 <p>You can browse the source-code at:</p>
2492 <ul>
2493 <li><a href="https://git.codemadness.org/stagit/">https://git.codemadness.org/stagit/</a></li>
2494 <li><a href="gopher://codemadness.org/1/git/stagit">gopher://codemadness.org/1/git/stagit</a></li>
2495 </ul>
2496 <h2>Download releases</h2>
2497 <p>Releases are available at:</p>
2498 <ul>
2499 <li><a href="https://codemadness.org/releases/stagit/">https://codemadness.org/releases/stagit/</a></li>
2500 <li><a href="gopher://codemadness.org/1/releases/stagit">gopher://codemadness.org/1/releases/stagit</a></li>
2501 </ul>
2502 ]]></description>
2503 </item>
2504 <item>
2505 <title>OpenBSD httpd, slowcgi and cgit</title>
2506 <link>https://www.codemadness.org/openbsd-httpd-and-cgit.html</link>
2507 <guid>https://www.codemadness.org/openbsd-httpd-and-cgit.html</guid>
2508 <dc:date>2015-07-05T00:00:00Z</dc:date>
2509 <author>Hiltjo</author>
2510 <description><![CDATA[<h1>OpenBSD httpd, slowcgi and cgit</h1>
2511 <p><strong>Last modification on </strong> <time>2021-04-11</time></p>
2512 <p>This is a guide to get <a href="https://git.zx2c4.com/cgit/">cgit</a> working with
2513 <a href="https://man.openbsd.org/httpd.8">OpenBSD httpd(8)</a> and
2514 <a href="https://man.openbsd.org/slowcgi.8">slowcgi(8)</a> in base. OpenBSD httpd is very simple to setup, but nevertheless
2515 this guide might help someone out there.</p>
2516 <h2>Installation</h2>
2517 <p>Install the cgit package:</p>
2518 <pre><code># pkg_add cgit
2519 </code></pre>
2520 <p>or build it from ports:</p>
2521 <pre><code># cd /usr/ports/www/cgit && make && make install
2522 </code></pre>
2523 <h2>Configuration</h2>
2524 <h3>httpd</h3>
2525 <p>An example of <a href="https://man.openbsd.org/httpd.conf.5">httpd.conf(5)</a>:
2526 <a href="downloads/openbsd-httpd/httpd.conf">httpd.conf</a>.</p>
2527 <h3>slowcgi</h3>
2528 <p>By default the slowcgi UNIX domain socket is located at:
2529 /var/www/run/slowcgi.sock. For this example we use the defaults.</p>
2530 <h3>cgit</h3>
2531 <p>The cgit binary should be located at: /var/www/cgi-bin/cgit.cgi (default).</p>
2532 <p>cgit uses the $CGIT_CONFIG environment variable to locate its config. By
2533 default on OpenBSD this is set to /conf/cgitrc (chroot), which is
2534 /var/www/conf/cgitrc. An example of the cgitrc file is here: <a href="downloads/openbsd-httpd/cgitrc">cgitrc</a>.</p>
2535 <p>In this example the cgit cache directory is set to /cgit/cache (chroot), which
2536 is /var/www/cgit/cache. Make sure to give this path read and write permissions
2537 for cgit (www:daemon).</p>
2538 <p>In the example the repository path (scan-path) is set to /htdocs/src (chroot),
2539 which is /var/www/htdocs/src.</p>
2540 <p>The footer file is set to /conf/cgit.footer. Make sure this file exists or you
2541 will get warnings:</p>
2542 <pre><code># >/var/www/conf/cgit.footer
2543 </code></pre>
2544 <p>Make sure cgit.css (stylesheet) and cgit.png (logo) are accessible, by default:
2545 /var/www/cgit/cgit.{css,png} (location can be changed in httpd.conf).</p>
2546 <p>To support .tar.gz snapshots a static gzip binary is required in the chroot
2547 /bin directory:</p>
2548 <pre><code>cd /usr/src/usr.bin/compress
2549 make clean && make LDFLAGS="-static -pie"
2550 cp obj/compress /var/www/bin/gzip
2551 </code></pre>
2552 <h2>Running the services</h2>
2553 <p>Enable the httpd and slowcgi services to automatically start them at boot:</p>
2554 <pre><code># rcctl enable httpd slowcgi
2555 </code></pre>
2556 <p>Start the services:</p>
2557 <pre><code># rcctl start httpd slowcgi
2558 </code></pre>
2559 ]]></description>
2560 </item>
2561 <item>
2562 <title>twitch: application to watch Twitch streams</title>
2563 <link>https://www.codemadness.org/twitch-interface.html</link>
2564 <guid>https://www.codemadness.org/twitch-interface.html</guid>
2565 <dc:date>2014-11-23T00:00:00Z</dc:date>
2566 <author>Hiltjo</author>
2567 <description><![CDATA[<h1>twitch: application to watch Twitch streams</h1>
2568 <p><strong>Last modification on </strong> <time>2020-12-14</time></p>
2569 <p><strong>Update: as of 2020-05-06:</strong> I stopped maintaining it.
2570 Twitch now requires OAUTH and 2-factor authentication. It requires me to expose
2571 personal information such as my phone number.</p>
2572 <p><strong>Update: as of ~2020-01-03:</strong> I rewrote this application from Golang to C.
2573 The Twitch Kraken API used by the Golang version was deprecated. It was
2574 rewritten to use the Helix API.</p>
2575 <p>This program/script allows to view streams in your own video player like so the
2576 bloated Twitch interface is not needed. It is written in C.</p>
2577 <h2>Features</h2>
2578 <ul>
2579 <li>No Javascript, cookies, CSS optional.</li>
2580 <li>Works well in all browsers, including text-based ones.</li>
2581 <li>Has a HTTP CGI and Gopher CGI version.</li>
2582 <li>Atom feed for VODs.</li>
2583 </ul>
2584 <h2>Clone</h2>
2585 <pre><code>git clone git://git.codemadness.org/frontends
2586 </code></pre>
2587 <h2>Browse</h2>
2588 <p>You can browse the source-code at:</p>
2589 <ul>
2590 <li><a href="https://git.codemadness.org/frontends/">https://git.codemadness.org/frontends/</a></li>
2591 <li><a href="gopher://codemadness.org/1/git/frontends">gopher://codemadness.org/1/git/frontends</a></li>
2592 </ul>
2593 ]]></description>
2594 </item>
2595 <item>
2596 <title>Userscript: focus input field</title>
2597 <link>https://www.codemadness.org/userscript-focus-input-field.html</link>
2598 <guid>https://www.codemadness.org/userscript-focus-input-field.html</guid>
2599 <dc:date>2014-03-02T00:00:00Z</dc:date>
2600 <author>Hiltjo</author>
2601 <description><![CDATA[<h1>Userscript: focus input field</h1>
2602 <p><strong>Last modification on </strong> <time>2014-03-02</time></p>
2603 <p>This is an userscript I wrote a while ago which allows to focus the first input
2604 field on a page with ctrl+space. This is useful if a site doesn't specify the
2605 autofocus attribute for an input field and you don't want to switch to it using
2606 the mouse.</p>
2607 <h2>Download</h2>
2608 <p><a href="downloads/input_focus.user.js">Download userscript input_focus.user.js</a></p>
2609 ]]></description>
2610 </item>
2611 <item>
2612 <title>Userscript: Youtube circumvent age verification</title>
2613 <link>https://www.codemadness.org/userscript-youtube-circumvent-age-verification.html</link>
2614 <guid>https://www.codemadness.org/userscript-youtube-circumvent-age-verification.html</guid>
2615 <dc:date>2013-02-21T00:00:00Z</dc:date>
2616 <author>Hiltjo</author>
2617 <description><![CDATA[<h1>Userscript: Youtube circumvent age verification</h1>
2618 <p><strong>Last modification on </strong> <time>2020-12-27</time></p>
2619 <p>This is an userscript I wrote a while ago which circumvents requiring to login
2620 with an account on Youtube if a video requires age verification.</p>
2621 <p><strong>Note: this is an old script and does not work anymore.</strong></p>
2622 <h2>Download</h2>
2623 <p><a href="downloads/youtube_circumvent_sign_in.user.js">Download userscript Youtube_circumvent_sign_in.user.js</a></p>
2624 ]]></description>
2625 </item>
2626 <item>
2627 <title>Userscript: block stupid fonts</title>
2628 <link>https://www.codemadness.org/userscript-block-stupid-fonts.html</link>
2629 <guid>https://www.codemadness.org/userscript-block-stupid-fonts.html</guid>
2630 <dc:date>2012-10-21T00:00:00Z</dc:date>
2631 <author>Hiltjo</author>
2632 <description><![CDATA[<h1>Userscript: block stupid fonts</h1>
2633 <p><strong>Last modification on </strong> <time>2020-03-10</time></p>
2634 <p>This is an userscript I wrote a while ago which white-lists fonts I like and
2635 blocks the rest. The reason I made this is because I don't like the
2636 inconsistency of custom fonts used on a lot of websites.</p>
2637 <h2>Download</h2>
2638 <p><a href="downloads/block_stupid_fonts_v1.2.user.js">Download userscript Block_stupid_fonts_v1.2.user.js</a></p>
2639 <p>Old version: <a href="downloads/block_stupid_fonts.user.js">Download userscript Block_stupid_fonts.user.js</a></p>
2640 ]]></description>
2641 </item>
2642 <item>
2643 <title>Sfeed: simple RSS and Atom parser</title>
2644 <link>https://www.codemadness.org/sfeed-simple-feed-parser.html</link>
2645 <guid>https://www.codemadness.org/sfeed-simple-feed-parser.html</guid>
2646 <dc:date>2011-04-01T00:00:00Z</dc:date>
2647 <author>Hiltjo</author>
2648 <description><![CDATA[<h1>Sfeed: simple RSS and Atom parser</h1>
2649 <p><strong>Last modification on </strong> <time>2022-11-05</time></p>
2650 <p>Sfeed is a RSS and Atom parser (and some format programs).</p>
2651 <p>It converts RSS or Atom feeds from XML to a TAB-separated file. There are
2652 formatting programs included to convert this TAB-separated format to various
2653 other formats. There are also some programs and scripts included to import and
2654 export OPML and to fetch, filter, merge and order feed items.</p>
2655 <p>For the most (up-to-date) information see the <a href="/git/sfeed/file/README.html">README</a>.</p>
2656 <h2>Clone</h2>
2657 <pre><code>git clone git://git.codemadness.org/sfeed
2658 </code></pre>
2659 <h2>Browse</h2>
2660 <p>You can browse the source-code at:</p>
2661 <ul>
2662 <li><a href="https://git.codemadness.org/sfeed/">https://git.codemadness.org/sfeed/</a></li>
2663 <li><a href="gopher://codemadness.org/1/git/sfeed">gopher://codemadness.org/1/git/sfeed</a></li>
2664 </ul>
2665 <h2>Download releases</h2>
2666 <p>Releases are available at:</p>
2667 <ul>
2668 <li><a href="https://codemadness.org/releases/sfeed/">https://codemadness.org/releases/sfeed/</a></li>
2669 <li><a href="gopher://codemadness.org/1/releases/sfeed">gopher://codemadness.org/1/releases/sfeed</a></li>
2670 </ul>
2671 <h2>Build and install</h2>
2672 <pre><code>$ make
2673 # make install
2674 </code></pre>
2675 <h2>Screenshot and examples</h2>
2676 <p><a href="downloads/screenshots/sfeed-screenshot.png"><img src="downloads/screenshots/sfeed-thumb.png" alt="Screenshot of sfeed piped to sfeed_plain using dmenu in vertical-list mode" width="400" height="232" loading="lazy" /></a></p>
2677 <p>The above screenshot uses the sfeed_plain format program with <a href="https://tools.suckless.org/dmenu/">dmenu</a>. This
2678 program outputs the feed items in a compact way per line as plain-text to
2679 stdout. The dmenu program reads these lines from stdin and displays them as a
2680 X11 list menu. When an item is selected in dmenu it prints this item to stdout.
2681 A simple written script can then filter for the URL in this output and do some
2682 action, like opening it in some browser or open a podcast in your music player.</p>
2683 <p>For example:</p>
2684 <pre><code>#!/bin/sh
2685 url=$(sfeed_plain "$HOME/.sfeed/feeds/"* | dmenu -l 35 -i | \
2686 sed -n 's@^.* \([a-zA-Z]*://\)\(.*\)$@\1\2@p')
2687 test -n "${url}" && $BROWSER "${url}"
2688 </code></pre>
2689 <p>However this is just one way to format and interact with feed items.
2690 See also the README for other practical examples.</p>
2691 <p>Below are some examples of output that are supported by the included format
2692 programs:</p>
2693 <ul>
2694 <li><a href="downloads/sfeed/plain/feeds.txt">plain text (UTF-8)</a></li>
2695 <li><a href="downloads/sfeed/atom/feeds.xml">atom</a></li>
2696 <li>gopher</li>
2697 <li><a href="downloads/sfeed/html/feeds.html">HTML (CSS)</a></li>
2698 <li><a href="downloads/sfeed/frames/index.html">HTML frames</a></li>
2699 <li><a href="jsonfeed_content.json">JSON Feed</a></li>
2700 <li><a href="downloads/sfeed/mbox/feeds.mbox">mbox</a></li>
2701 <li><a href="downloads/sfeed/twtxt/twtxt.txt">twtxt</a></li>
2702 </ul>
2703 <p>There is also a curses UI front-end, see the page <a href="sfeed_curses.html">sfeed_curses</a>.
2704 It is now part of sfeed.</p>
2705 <h2>Videos</h2>
2706 <p>Here are some videos of other people showcasing some of the functionalities of
2707 sfeed, sfeed_plain and sfeed_curses. To the creators: thanks for making these!</p>
2708 <ul>
2709 <li><a href="https://www.youtube.com/watch?v=RnuY32DP9jU">sfeed: RSS/Atom Feeds without the Suck (Youtube)</a><br />
2710 by <a href="https://www.youtube.com/channel/UCQQB104oMOos758GTOdx_kQ">noocsharp</a>
2711 <a href="downloads/sfeed/videos/sfeed_without_the_suck.mp4">(mirror)</a><br />
2712 Video published on March 8 2020.</li>
2713 <li><a href="https://www.youtube.com/watch?v=ok8k639GoRU">Sfeed - news in the terminal with minimalism (Youtube)</a><br />
2714 by <a href="https://www.youtube.com/channel/UCJetJ7nDNLlEzDLXv7KIo0w">Gavin Freeborn</a>
2715 <a href="downloads/sfeed/videos/sfeed_news_in_terminal.mp4">(mirror)</a><br />
2716 Video published on January 15 2021.</li>
2717 <li><a href="https://www.youtube.com/watch?v=xMkW4iJzot0">Sfeed - Peak Minimal RSS Feed Reader (Youtube)</a><br />
2718 by <a href="https://www.youtube.com/channel/UCld68syR8Wi-GY_n4CaoJGA">Brodie Robertson</a>
2719 <a href="downloads/sfeed/videos/sfeed_minimalism.mp4">(mirror)</a><br />
2720 Video published on February 23 2021.</li>
2721 <li><a href="https://www.youtube.com/watch?v=O8x0MAyqvt0">RSS with sfeed, fdm, and mblaze! (Youtube)</a><br />
2722 by <a href="https://www.youtube.com/channel/UCz_u0h4usMbnFsIHSVdjUQw">Joseph Choe</a>
2723 <a href="downloads/sfeed/videos/rss_with_sfeed_fdm_and_mblaze.mp4">(mirror)</a><br />
2724 Website: <a href="https://josephchoe.com/rss-terminal">https://josephchoe.com/rss-terminal</a><br />
2725 Video published on 4 November 2022.</li>
2726 </ul>
2727 ]]></description>
2728 </item>
2729 <item>
2730 <title>Vim theme: relaxed</title>
2731 <link>https://www.codemadness.org/vim-theme-relaxed.html</link>
2732 <guid>https://www.codemadness.org/vim-theme-relaxed.html</guid>
2733 <dc:date>2011-01-07T00:00:00Z</dc:date>
2734 <author>Hiltjo</author>
2735 <description><![CDATA[<h1>Vim theme: relaxed</h1>
2736 <p><strong>Last modification on </strong> <time>2011-01-07</time></p>
2737 <p>This is a dark theme I made for <a href="https://www.vim.org/">vim</a>. This is a theme I personally used for
2738 quite a while now and over time tweaked to my liking. It is made for gvim, but
2739 also works for 16-colour terminals (with small visual differences). The
2740 relaxed.vim file also has my .Xdefaults file colours listed at the top for
2741 16+-colour terminals on X11.</p>
2742 <p>It is inspired by the "desert" theme available at
2743 <a href="https://www.vim.org/scripts/script.php?script_id=105">https://www.vim.org/scripts/script.php?script_id=105</a>, although I removed the
2744 cursive and bold styles and changed some colours I didn't like.</p>
2745 <h2>Download</h2>
2746 <p><a href="downloads/themes/vim/relaxed.vim">relaxed.vim</a></p>
2747 <h2>Screenshot</h2>
2748 <p><a href="downloads/themes/vim/vim_relaxed_theme.png"><img src="downloads/themes/vim/vim_relaxed_theme_thumb.png" alt="Screenshot of VIM theme relaxed on the left is gvim (GUI), on the right is vim in urxvt (terminal)" width="480" height="300" loading="lazy" /></a></p>
2749 ]]></description>
2750 </item>
2751 <item>
2752 <title>Seturgent: set urgency hints for X applications</title>
2753 <link>https://www.codemadness.org/seturgent-set-urgency-hints-for-x-applications.html</link>
2754 <guid>https://www.codemadness.org/seturgent-set-urgency-hints-for-x-applications.html</guid>
2755 <dc:date>2010-10-31T00:00:00Z</dc:date>
2756 <author>Hiltjo</author>
2757 <description><![CDATA[<h1>Seturgent: set urgency hints for X applications</h1>
2758 <p><strong>Last modification on </strong> <time>2020-07-20</time></p>
2759 <p>Seturgent is a small utility to set an application its urgency hint. For most
2760 windowmanager's and panel applications this will highlight the application and
2761 will allow special actions.</p>
2762 <h2>Clone</h2>
2763 <pre><code> git clone git://git.codemadness.org/seturgent
2764 </code></pre>
2765 <h2>Browse</h2>
2766 <p>You can browse the source-code at:</p>
2767 <ul>
2768 <li><a href="https://git.codemadness.org/seturgent/">https://git.codemadness.org/seturgent/</a></li>
2769 <li><a href="gopher://codemadness.org/1/git/seturgent">gopher://codemadness.org/1/git/seturgent</a></li>
2770 </ul>
2771 <h2>Download releases</h2>
2772 <p>Releases are available at:</p>
2773 <ul>
2774 <li><a href="https://codemadness.org/releases/seturgent/">https://codemadness.org/releases/seturgent/</a></li>
2775 <li><a href="gopher://codemadness.org/1/releases/seturgent">gopher://codemadness.org/1/releases/seturgent</a></li>
2776 </ul>
2777 ]]></description>
2778 </item>
2779 <item>
2780 <title>DWM-hiltjo: my windowmanager configuration</title>
2781 <link>https://www.codemadness.org/dwm-hiltjo-my-windowmanager-configuration.html</link>
2782 <guid>https://www.codemadness.org/dwm-hiltjo-my-windowmanager-configuration.html</guid>
2783 <dc:date>2010-08-12T00:00:00Z</dc:date>
2784 <author>Hiltjo</author>
2785 <description><![CDATA[<h1>DWM-hiltjo: my windowmanager configuration</h1>
2786 <p><strong>Last modification on </strong> <time>2020-07-20</time></p>
2787 <p><a href="https://dwm.suckless.org/">DWM</a> is a very minimal windowmanager. It has the most essential features I
2788 need, everything else is "do-it-yourself" or extending it with the many
2789 available <a href="https://dwm.suckless.org/patches/">patches</a>. The vanilla version is less than 2000 SLOC. This makes it
2790 easy to understand and modify it.</p>
2791 <p>I really like my configuration at the moment and want to share my changes. Some
2792 of the features listed below are patches from suckless.org I applied, but there
2793 are also some changes I made.</p>
2794 <p>This configuration is entirely tailored for my preferences of course.</p>
2795 <h2>Features</h2>
2796 <ul>
2797 <li>Titlebar:
2798 <ul>
2799 <li>Shows all clients of the selected / active tags.</li>
2800 <li>Divide application titlebars evenly among available space.</li>
2801 <li>Colour urgent clients in the taskbar on active tags.</li>
2802 <li>Left-click focuses clicked client.</li>
2803 <li>Right-click toggles monocle layout.</li>
2804 <li>Middle-click kills the clicked client.</li>
2805 </ul>
2806 </li>
2807 <li>Tagbar:
2808 <ul>
2809 <li>Only show active tags.</li>
2810 <li>Colour inactive tags with urgent clients.</li>
2811 </ul>
2812 </li>
2813 <li>Layouts:
2814 <ul>
2815 <li>Cycle layouts with Modkey + Space (next) and Modkey + Control + Space
2816 (previous).</li>
2817 <li>Fullscreen layout (hides topbar and removes borders).</li>
2818 </ul>
2819 </li>
2820 <li>Other:
2821 <ul>
2822 <li>Move tiled clients around with the mouse (drag-move), awesomewm-like.</li>
2823 <li>Add some keybinds for multimedia keyboards (audio play / pause, mute, www,
2824 volume buttons, etc).</li>
2825 </ul>
2826 </li>
2827 <li>... and more ;) ...</li>
2828 </ul>
2829 <h2>Clone</h2>
2830 <pre><code>git clone -b hiltjo git://git.codemadness.org/dwm
2831 </code></pre>
2832 <h2>Screenshot</h2>
2833 <p><a href="downloads/screenshots/dwm-screenshot.png"><img src="downloads/screenshots/dwm-screenshot-thumb.png" alt="Screenshot showing what dwm-hiltjo looks like" width="480" height="300" loading="lazy" /></a></p>
2834 ]]></description>
2835 </item>
2836 <item>
2837 <title>Query unused CSS rules on current document state</title>
2838 <link>https://www.codemadness.org/query-unused-css-rules-on-current-document-state.html</link>
2839 <guid>https://www.codemadness.org/query-unused-css-rules-on-current-document-state.html</guid>
2840 <dc:date>2010-04-21T00:00:00Z</dc:date>
2841 <author>Hiltjo</author>
2842 <description><![CDATA[<h1>Query unused CSS rules on current document state</h1>
2843 <p><strong>Last modification on </strong> <time>2010-04-21</time></p>
2844 <p>Today I was doing some web development and wanted to see all the rules in a
2845 stylesheet (CSS) that were not used for the current document. I wrote the
2846 following Javascript code which you can paste in the Firebug console and run:</p>
2847 <pre><code>(function() {
2848 for (var i=0;i<document.styleSheets.length;i++) {
2849 var rules = document.styleSheets[i].cssRules || [];
2850 var sheethref = document.styleSheets[i].href || 'inline';
2851 for (var r=0;r<rules.length;r++)
2852 if (!document.querySelectorAll(rules[r].selectorText).length)
2853 console.log(sheethref + ': "' + rules[r].selectorText + '" not found.');
2854 }
2855 })();
2856 </code></pre>
2857 <p>This will output all the (currently) unused CSS rules per selector, the output can be for example:</p>
2858 <pre><code>http://www.codemadness.nl/blog/wp-content/themes/codemadness/style.css: "fieldset, a img" not found.
2859 http://www.codemadness.nl/blog/wp-content/themes/codemadness/style.css: "#headerimg" not found.
2860 http://www.codemadness.nl/blog/wp-content/themes/codemadness/style.css: "a:hover" not found.
2861 http://www.codemadness.nl/blog/wp-content/themes/codemadness/style.css: "h2 a:hover, h3 a:hover" not found.
2862 http://www.codemadness.nl/blog/wp-content/themes/codemadness/style.css: ".postmetadata-center" not found.
2863 http://www.codemadness.nl/blog/wp-content/themes/codemadness/style.css: ".thread-alt" not found.
2864 </code></pre>
2865 <p>Just a trick I wanted to share, I hope someone finds this useful :)</p>
2866 <p>For webkit-based browsers you can use "Developer Tools" and use "Audits" under
2867 "Web Page Performance" it says "Remove unused CSS rules". For Firefox there is
2868 also Google Page Speed: <a href="https://code.google.com/speed/page-speed/">https://code.google.com/speed/page-speed/</a> this adds
2869 an extra section under Firebug.</p>
2870 <p>Tested on Chrome and Firefox.</p>
2871 ]]></description>
2872 </item>
2873 <item>
2874 <title>Driconf: enabling S3 texture compression on Linux</title>
2875 <link>https://www.codemadness.org/driconf-enabling-s3-texture-compression-on-linux.html</link>
2876 <guid>https://www.codemadness.org/driconf-enabling-s3-texture-compression-on-linux.html</guid>
2877 <dc:date>2009-07-05T00:00:00Z</dc:date>
2878 <author>Hiltjo</author>
2879 <description><![CDATA[<h1>Driconf: enabling S3 texture compression on Linux</h1>
2880 <p><strong>Last modification on </strong> <time>2020-08-21</time></p>
2881 <p><strong>Update: the DXTC patent expired on 2018-03-16, many distros enable this by
2882 default now.</strong></p>
2883 <p>S3TC (also known as DXTn or DXTC) is a patented lossy texture compression
2884 algorithm. See: <a href="https://en.wikipedia.org/wiki/S3TC">https://en.wikipedia.org/wiki/S3TC</a> for more detailed
2885 information. Many games use S3TC and if you use Wine to play games you
2886 definitely want to enable it if your graphics card supports it.</p>
2887 <p>Because this algorithm was <a href="https://dri.freedesktop.org/wiki/S3TC/">patented it is disabled by default on many Linux
2888 distributions</a>.</p>
2889 <p>To enable it you can install the library "libtxc" if your favorite OS has not
2890 installed it already.</p>
2891 <p>For easy configuration you can install the optional utility DRIconf, which you
2892 can find at: <a href="https://dri.freedesktop.org/wiki/DriConf">https://dri.freedesktop.org/wiki/DriConf</a>. DriConf can safely be
2893 removed after configuration.</p>
2894 <h2>Steps to enable it</h2>
2895 <p>Install libtxc_dxtn:</p>
2896 <p>ArchLinux:
2897 <pre><code># pacman -S libtxc_dxtn
2898 </code></pre>
2899 <p>Debian:
2900 <pre><code># aptitude install libtxc-dxtn-s2tc0
2901 </code></pre>
2902 </p>
2903 </p>
2904 <p>Install driconf (optional):</p>
2905 <p>ArchLinux:</p>
2906 <pre><code># pacman -S driconf
2907 </code></pre>
2908 <p>Debian:</p>
2909 <pre><code># aptitude install driconf
2910 </code></pre>
2911 <p>Run driconf and enable S3TC:</p>
2912 <p><a href="downloads/screenshots/driconf.png"><img src="downloads/screenshots/driconf-thumb.png" alt="Screenshot of DRIconf window and its options" width="300" height="266" loading="lazy" /></a></p>
2913 <h2>Additional links</h2>
2914 <ul>
2915 <li>S3TC: <a href="https://dri.freedesktop.org/wiki/S3TC/">https://dri.freedesktop.org/wiki/S3TC/</a></li>
2916 <li>DriConf: <a href="https://dri.freedesktop.org/wiki/DriConf">https://dri.freedesktop.org/wiki/DriConf</a></li>
2917 </ul>
2918 ]]></description>
2919 </item>
2920 <item>
2921 <title>Getting the USB-powerline bridge to work on Linux</title>
2922 <link>https://www.codemadness.org/getting-the-usb-powerline-bridge-to-work-on-linux.html</link>
2923 <guid>https://www.codemadness.org/getting-the-usb-powerline-bridge-to-work-on-linux.html</guid>
2924 <dc:date>2009-04-13T00:00:00Z</dc:date>
2925 <author>Hiltjo</author>
2926 <description><![CDATA[<h1>Getting the USB-powerline bridge to work on Linux</h1>
2927 <p><strong>Last modification on </strong> <time>2019-12-06</time></p>
2928 <p><strong>NOTE: this guide is obsolete, a working driver is now included in the Linux
2929 kernel tree (<a href="https://lkml.org/lkml/2009/4/18/121">since Linux 2.6.31</a>)</strong></p>
2930 <h2>Introduction</h2>
2931 <p>A USB to powerline bridge is a network device that instead of using an ordinary
2932 Ethernet cable (CAT5 for example) or wireless LAN it uses the powerlines as a
2933 network to communicate with similar devices. A more comprehensive explanation
2934 of what it is and how it works you can find here:
2935 <a href="https://en.wikipedia.org/wiki/IEEE_1901">https://en.wikipedia.org/wiki/IEEE_1901</a>.</p>
2936 <p>Known products that use the Intellon 51x1 chipset:</p>
2937 <ul>
2938 <li>MicroLink dLAN USB</li>
2939 <li>"Digitus network"</li>
2940 <li>Intellon USB Ethernet powerline adapter</li>
2941 <li>Lots of other USB-powerline adapters...</li>
2942 </ul>
2943 <p>To check if your device is supported:</p>
2944 <pre><code>$ lsusb | grep -i 09e1
2945 Bus 001 Device 003: ID 09e1:5121 Intellon Corp.
2946 </code></pre>
2947 <p>If the vendor (09e1) and product (5121) ID match then it's probably supported.</p>
2948 <h2>Installation</h2>
2949 <p>Get drivers from the official site:
2950 <a href="http://www.devolo.co.uk/consumer/downloads-44-microlink-dlan-usb.html?l=en">http://www.devolo.co.uk/consumer/downloads-44-microlink-dlan-usb.html?l=en</a> or
2951 <a href="downloads/int51x1/dLAN-linux-package-v4.tar.gz">mirrored here</a>.
2952 The drivers from the official site were/are more up-to-date.</p>
2953 <p>Extract them:</p>
2954 <pre><code>$ tar -xzvf dLAN-linux-package-v4.tar.gz
2955 </code></pre>
2956 <p>Go to the extracted directory and compile them:</p>
2957 <pre><code>$ ./configure
2958 $ make
2959 </code></pre>
2960 <p>Depending on the errors you got you might need to <a href="downloads/int51x1/int51x1.patch">download</a> and apply
2961 my patch:</p>
2962 <pre><code>$ cd dLAN-linux-package-v4/ (or other path to the source code)
2963 $ patch < int51x1.patch
2964 </code></pre>
2965 <p>Try again:</p>
2966 <pre><code>$ ./configure
2967 $ make
2968 </code></pre>
2969 <p>If that failed try:</p>
2970 <pre><code>$ ./configure
2971 $ KBUILD_NOPEDANTIC=1 make
2972 </code></pre>
2973 <p>If that went OK install the drivers (as root):</p>
2974 <pre><code># make install
2975 </code></pre>
2976 <p>Check if the "devolo_usb" module is loaded:</p>
2977 <pre><code>$ lsmod | grep -i devolo_usb
2978 </code></pre>
2979 <p>If it shows up then it's loaded. Now check if the interface is added:</p>
2980 <pre><code>$ ifconfig -a | grep -i dlanusb
2981 dlanusb0 Link encap:Ethernet HWaddr 00:12:34:56:78:9A
2982 </code></pre>
2983 <h2>Configuration</h2>
2984 <p>It is assumed you use a static IP, otherwise you can just use your DHCP client
2985 to get an unused IP address from your DHCP server. Setting up the interface is
2986 done like this (change the IP address and netmask accordingly if it's
2987 different):</p>
2988 <pre><code># ifconfig dlanusb0 192.168.2.12 netmask 255.255.255.0
2989 </code></pre>
2990 <h2>Checking if the network works</h2>
2991 <p>Try to ping an IP address on your network to test for a working connection:</p>
2992 <pre><code>$ ping 192.168.2.1
2993 PING 192.168.2.1 (192.168.2.1) 56(84) bytes of data.
2994 64 bytes from 192.168.2.1: icmp_seq=1 ttl=30 time=2.49 ms
2995 64 bytes from 192.168.2.1: icmp_seq=2 ttl=30 time=3.37 ms
2996 64 bytes from 192.168.2.1: icmp_seq=3 ttl=30 time=2.80 ms
2997 --- 192.168.2.1 ping statistics ---
2998 3 packets transmitted, 3 received, 0% packet loss, time 2005ms
2999 rtt min/avg/max/mdev = 2.497/2.891/3.374/0.368 ms
3000 </code></pre>
3001 <p>You can now set up a network connection like you normally do with any Ethernet
3002 device. The route can be added like this for example:</p>
3003 <pre><code># route add -net 0.0.0.0 netmask 0.0.0.0 gw 192.168.2.1 dlanusb0
3004 </code></pre>
3005 <p>Change the IP address of your local gateway accordingly. Also make sure your
3006 nameserver is set in /etc/resolv.conf, something like:</p>
3007 <pre><code>nameserver 192.168.2.1
3008 </code></pre>
3009 <p>Test your internet connection by doing for example:</p>
3010 <pre><code>$ ping codemadness.org
3011 PING codemadness.org (64.13.232.151) 56(84) bytes of data.
3012 64 bytes from acmkoieeei.gs02.gridserver.com (64.13.232.151): icmp_seq=1 ttl=52 time=156 ms
3013 64 bytes from acmkoieeei.gs02.gridserver.com (64.13.232.151): icmp_seq=2 ttl=52 time=156 ms
3014 64 bytes from acmkoieeei.gs02.gridserver.com (64.13.232.151): icmp_seq=3 ttl=52 time=155 ms
3015 --- codemadness.org ping statistics ---
3016 3 packets transmitted, 3 received, 0% packet loss, time 1999ms
3017 rtt min/avg/max/mdev = 155.986/156.312/156.731/0.552 ms
3018 </code></pre>
3019 <p>If this command failed you probably have not setup your DNS/gateway properly.
3020 If it worked then good for you :)</p>
3021 <h2>References</h2>
3022 <ul>
3023 <li><a href="http://www.devolo.co.uk/consumer/downloads-44-microlink-dlan-usb.html?l=en">Devolo download page with drivers (USB version).</a></li>
3024 <li><a href="downloads/int51x1/dLAN-linux-package-v4.tar.gz">dLAN-linux-package-v4.tar.gz</a></li>
3025 <li><a href="downloads/int51x1/int51x1.patch">Patch for recent 2.6.x kernels</a></li>
3026 <li><a href="downloads/int51x1/INT51X1_datasheet.pdf">INT51X1 datasheet</a></li>
3027 </ul>
3028 ]]></description>
3029 </item>
3030 <item>
3031 <title>Gothic 1 game guide</title>
3032 <link>https://www.codemadness.org/gothic-1-guide.html</link>
3033 <guid>https://www.codemadness.org/gothic-1-guide.html</guid>
3034 <dc:date>2009-04-12T00:00:00Z</dc:date>
3035 <author>Hiltjo</author>
3036 <description><![CDATA[<h1>Gothic 1 game guide</h1>
3037 <p><strong>Last modification on </strong> <time>2025-01-05</time></p>
3038 <p><strong>Disclaimer:</strong>
3039 Some (including myself) may find some of these hints/exploits cheating. This
3040 guide is just for educational and fun purposes. Some of these hints/tips apply
3041 to Gothic 2 as well. I got the meat exploit from a guide somewhere on the
3042 internet I can't recall where, anyway kudos to that person. Some of the
3043 exploits I discovered myself.</p>
3044 <h2>Configuration</h2>
3045 <h3>Widescreen resolution</h3>
3046 <p>Gothic supports widescreen resolutions with a small tweak, add the following
3047 text string as a command-line argument:</p>
3048 <pre><code>-zRes:1920,1200,32
3049 </code></pre>
3050 <p>This also works for Gothic 2. Here 1920 is the width, 1200 the height and 32
3051 the bits per pixel, change this to your preferred resolution.</p>
3052 <h3>Fix crash with Steam version</h3>
3053 <p>Disable steam overlay. If that doesn't work rename GameOverlayRenderer.dll in
3054 your steam folder to _GameOverlayRenderer.dll. I strongly recommend to buy the
3055 better version from <a href="https://www.gog.com/game/gothic">GOG.com</a>. The GOG version has no DRM and allows easier
3056 modding, it also allows playing in most published languages: German, English,
3057 Polish, furthermore it has some original artwork and soundtrack included.</p>
3058 <h3>Upgrade Steam version to stand-alone version and remove Steam DRM (Gothic 1 and 2)</h3>
3059 <p>You can install the Gothic playerkit and patches to remove the Steam DRM.</p>
3060 <p><a href="https://www.worldofgothic.de/">WorldOfGothic</a> playerkit patches:</p>
3061 <ul>
3062 <li>Gothic 1 (EN): <a href="https://www.worldofgothic.com/dl/?go=dlfile&fileid=28">https://www.worldofgothic.com/dl/?go=dlfile&fileid=28</a></li>
3063 <li>Gothic 1 (DE): <a href="https://www.worldofgothic.de/dl/download_34.htm">https://www.worldofgothic.de/dl/download_34.htm</a></li>
3064 <li>Gothic 2 (EN/DE): <a href="https://www.worldofgothic.de/dl/download_168.htm">https://www.worldofgothic.de/dl/download_168.htm</a></li>
3065 </ul>
3066 <h3>Play Gothic in a different language with English subtitles</h3>
3067 <p>If you're like me and have played the English version many times, but would
3068 like to hear the (original) German voice audio or if you would like to play
3069 with different audio than you're used to, then you can copy the speech.vdf file
3070 of your preferred version to your game files. Optionally turn on subtitles.
3071 I've used this to play the English version of Gothic with the original German
3072 voice audio and English subtitles.
3073 This works best with the version from GOG as it allows easier modding.</p>
3074 <h2>Easy money/weapons/armour/other items</h2>
3075 <h3>Steal from Huno</h3>
3076 <p>At night attack Huno the smith in the Old Camp and steal all his steel. Then
3077 make some weapons and sell them with a merchant. When you ask Huno about
3078 blacksmith equipment it will respawn with 5 of each kind of steel. This is also
3079 a fairly good starting weapon (requires 20 strength). Also his chest located
3080 near the sharpening stone and fire contains some steel as well, lock-pick it.
3081 The combination is: RRLRLL. The chest contains at least 20 raw steel, forge it
3082 to get 20 crude swords which you can sell for 50 ore each to a merchant. This
3083 will generate some nice starting money (1000+ ore) :)</p>
3084 <h3>Steal weapons from the castle in the Old Camp</h3>
3085 <p>This tip is useful for getting pretty good starting weapons.</p>
3086 <p>Before entering the castle itself drop your ore (Left control + down for me)
3087 in front of it. This will ensure when you get caught (and you probably will ;))
3088 no ore will get stolen by the guards. Now use the "slip past guard" technique
3089 described below and you should be able to get into Gomez his castle. Run to the
3090 left where some weapons are stored. Now make sure you at least steal the best
3091 weapon (battle sword) and steal as much as you can until you get whacked. I
3092 usually stand in the corner since that's where the best weapons are (battle
3093 sword, judgement sword, etc). You'll now have some nice starting weapon(s) and
3094 the good thing is they require very little attributes (about 13 strength).</p>
3095 <p>Location: <a href="downloads/gothic1/old_camp_swords.png">screenshot</a></p>
3096 <h3>Free scraper armour the New Camp</h3>
3097 <p>In the New Camp go to the mine and talk to Swiney at the bottom of "The
3098 Hollow". Ask who he is and then ask to join the scrapers. He will give you a
3099 "Diggers dress" worth 250 ore. It has the following stats: + 10 against
3100 weapons. + 5 against fire. This will also give you free entrance to the bar in
3101 the New Camp.</p>
3102 <h3>Unlimited water bottles in the New Camp</h3>
3103 <p>In the quest from Lefty you will be assigned to get water bottles from the
3104 rice lord. He will give you infinite amounts of water bottles, in batches of
3105 12.</p>
3106 <h3>Armour amulet and increase HP potion</h3>
3107 <p>In the Old Camp in the main castle there are at least 3 chests with valuable
3108 items that don't require a key:</p>
3109 <ul>
3110 <li><p>Middle right side (looking from the entrance), 1 chest:
3111 <ul>
3112 <li>lock combination: LLLLRLRL</li>
3113 <li>loot:
3114 <ul>
3115 <li>+15 against weapons, +15 against arrows (amulet of stone skin)
3116 (worth: 1000 ore)</li>
3117 </ul>
3118 </li>
3119 <li>additionally there are 2 locked doors at the right side in this room. In
3120 the final room there are 3 floors with lots of chests.<br />
3121 <a href="downloads/gothic1/video/amulet.mp4">Video of the location</a></li>
3122 </ul>
3123 </p>
3124 </li>
3125 <li><p>Left side, 1 chest:
3126 <ul>
3127 <li>lock combination: RLLLLLRR</li>
3128 <li>loot:
3129 <ul>
3130 <li>+8 mana amulet (worth: 600 ore)</li>
3131 <li>2 potions (+70 hp)</li>
3132 <li>dreamcall (weed)</li>
3133 <li>120 coins (worth: nothing)</li>
3134 </ul>
3135 </li>
3136 </ul>
3137 </p>
3138 </li>
3139 <li><p>Right side, 2 chests with:
3140 <ul>
3141 <li>lock combination: RLLLRLLR</li>
3142 <li>loot:
3143 <ul>
3144 <li>armour amulets, +15 against weapons (worth: 600 ore)</li>
3145 <li>maximum life potion, +10 maximum life (worth: 1000 ore)</li>
3146 <li>speed potion (1 minute duration)</li>
3147 <li>4 potions (+70 hp)</li>
3148 </ul>
3149 </li>
3150 </ul>
3151 </p>
3152 </li>
3153 </ul>
3154 <h3>Swamp/Sect Camp harvest twice</h3>
3155 <p>In the swamp-weed harvest quest you must get swamp-weed for a guru. After this
3156 quest you can get the harvest again, but you can keep the harvest without
3157 consequences.</p>
3158 <h2>Exploits</h2>
3159 <h3>Slip past guards</h3>
3160 <p>This exploit is really simple, just draw your weapon before you're "targeted"
3161 by the guard and run past them, this bypasses the dialog sequence. When you're
3162 just out of their range holster your weapon again, so the people around won't
3163 get pissed off.</p>
3164 <p>Works really well on the guards in front of the Old camp's castle, Y'Berrion
3165 templars and New Camp mercenaries near the Water magicians, just to name a few.</p>
3166 <p><a href="downloads/gothic1/video/amulet.mp4">Video</a></p>
3167 <h3>Meat duplication</h3>
3168 <p>Go to a pan and focus / target it so it says "frying pan" or similar. Now open
3169 your inventory and select the meat. Now cook the meat (for me Left Control +
3170 Arrow up). The inventory should remain open. You'll now have twice as much meat
3171 as you had before. Do this a few times and you'll have a lot of meat, easy for
3172 trading with ore/other items as well. This exploit does not work with the
3173 community patch applied.</p>
3174 <h3>Glitch through (locked) doors and walls</h3>
3175 <p>You can glitch through walls by strafing into them. Then when the player is
3176 partially collided into a door or wall you can jump forward to glitch through
3177 it.</p>
3178 <p><a href="downloads/gothic1/video/bloodsword.mp4">Video</a></p>
3179 <h3>Fall from great heights</h3>
3180 <p>When you fall or jump from where you usually get fall damage you can do the
3181 following trick: slightly before the ground use left or right strafe. This
3182 works because it resets the falling animation. There are also other ways to
3183 achieve the same thing cancelling the falling animation, such as attacking with
3184 a weapon in the air.</p>
3185 <p><a href="downloads/gothic1/video/fall.mp4">Video</a></p>
3186 <h2>Experience / level up tips</h2>
3187 <h3>Test of faith (extra exp)</h3>
3188 <p>You get an additional 750 exp (from Lares) when you forge the letter in the new
3189 camp and then give it to Diego. You can still join both camps after this.</p>
3190 <h3>Fighting skeleton mages and their skeletons</h3>
3191 <p>An easy way to get more experience is to let the skeleton mages summon as much
3192 skeletons as they can, instead of rushing to kill the summoner immediately.
3193 After you have defeated all of them: kill the skeleton mage.</p>
3194 <h3>Permanent str/dex/mana/hp potions/items and teachers</h3>
3195 <p>When you want to get the maximum power at the end of the game you should save
3196 up the items that give you a permanent boost. Teachers of strength, dexterity
3197 and mana won't train over 100 of each skill. However using potions and quest
3198 rewards you can increase this over 100.</p>
3199 <p>You should also look out for the following:</p>
3200 <ul>
3201 <li><p>Learn to get extra force into your punch from Horatio (strength +5, this
3202 can't be done after level 100 strength). Talking to Jeremiah in the New Camp
3203 bar unlocks the dialog option to train strength at Horatio.</p>
3204 </li>
3205 <li><p>Smoke the strongest non-quest joint (+2 mana).</p>
3206 </li>
3207 </ul>
3208 <h3>Permanent potions in Sleeper temple</h3>
3209 <p>This one is really obvious, but I would like to point out the mummy's on each
3210 side where Xardas is located have lots and I mean lots of permanent potions.
3211 This will give you a nice boost before the end battle.</p>
3212 <p>Location, left and right corridor in the Sleeper temple: <a href="downloads/gothic1/sleeper_temple_potions.png">screenshot</a><br />
3213 Mummies, you can loot them: <a href="downloads/gothic1/sleeper_temple_potions_mummies.png">screenshot</a><br /> </p>
3214 <h3>Permanent potions as reward in quests</h3>
3215 <p>Always pick the permanent potion as a reward for quests when you can, for
3216 example the quest for delivering the message to the High Fire magicians (mana
3217 potion) or the one for fetching the almanac for the Sect Camp. Don't forget to
3218 pick up the potions from Riordian the water magician when you're doing the
3219 focus stones quest, it contains a strength and dexterity potion (+3).</p>
3220 <h3>Improve ancient ore armour further</h3>
3221 <p>In the last chapters the blacksmith Stone from the Old Camp is captured If you
3222 save him from the prison cell in the Old Camp the reward will have a few
3223 options. One of the options is improving the Ancient Ore armour.</p>
3224 <h2>Good early game weapons available in chapter 1</h2>
3225 <h3>Orc Hammer</h3>
3226 <p>Location: in a cave near bloodhounds near the mountain fort.<br />
3227 It can be reached from a path from the swamp camp up to the mountain.
3228 Watch out for the bloodhounds. They can instantly kill you in the early game.</p>
3229 <p>Location: <a href="downloads/gothic1/early_weapon_old_orc_hammer_location.png">screenshot</a><br />
3230 Stats: <a href="downloads/gothic1/early_weapon_old_orc_hammer_stats.png">screenshot</a><br /> </p>
3231 <p>Stats:
3232 <ul>
3233 <li>Type: one-handed</li>
3234 <li>Damage: 50</li>
3235 <li>Required strength: 22</li>
3236 <li>Worth: 1000 ore</li>
3237 </ul>
3238 </p>
3239 <p>It has very low strength stat requirement and has high damage for the early
3240 game chapters. A downside is the lower weapon swing range.
3241 It is also a decent weapon against stone golems.</p>
3242 <h3>Old Battle Axe</h3>
3243 <p>Location: near Xardas his tower.<br />
3244 Watch out for a group of Biters lurking there.</p>
3245 <p>Location: <a href="downloads/gothic1/early_weapon_old_battle_axe_location.png">screenshot</a><br />
3246 Stats: <a href="downloads/gothic1/early_weapon_old_battle_axe_stats.png">screenshot</a><br /> </p>
3247 <p>Stats:
3248 <ul>
3249 <li>Type: two-handed</li>
3250 <li>Damage: 67</li>
3251 <li>Required strength: 36</li>
3252 <li>Worth: 1800 ore</li>
3253 </ul>
3254 </p>
3255 <p>It has a relatively low strength requirements and is available in game chapter
3256 1 or could be sold for a decent amount.</p>
3257 <h3>Random/beginner tips</h3>
3258 <ul>
3259 <li><p>If you want to talk to a NPC, but some animation of them takes too long (like
3260 eating, drinking, smoking) you can sometimes force them out of it by quickly
3261 unsheathing/sheathing your weapon.</p>
3262 </li>
3263 <li><p>When in the Old Camp: Baal Parvez can take you to the Sect Camp, he can be
3264 found near the campfire near Fisk and Dexter.
3265 Mordrag can take you to the New Camp, he can be found near the south gate,
3266 slightly after the campfire near Baal Parvez.</p>
3267 <p>When you follow them and when they kill monsters then you also get the
3268 experience.</p>
3269 </li>
3270 <li><p>The NPC Wolf in the New Camp sells "The Bloodflies" book for 150 ore. When
3271 you read this book you learn how to remove bloodflies parts (without having to
3272 spend learning points). After you read the book and learned its skill then you
3273 can sell the book back for 75 ore. This investment quickly pays back: Per
3274 bloodfly: sting: 25 ore (unsold value), 2x wings (15 ore each unsold value).</p>
3275 </li>
3276 <li><p>The templar Gor Na Drak (usually near the old mine and walks around with
3277 another templar): talking to him teaches you how to learn to get secretion from
3278 minecrawlers for free.</p>
3279 </li>
3280 <li><p>The spell scroll "Transform into bloodfly" is very useful:
3281 <ul>
3282 <li>A bloodfly is very fast.</li>
3283 <li>Can also fly over water.</li>
3284 <li>The scroll costs 100 ore. Its the same price as a potion of speed, but it
3285 has no duration (just until you transform back).</li>
3286 <li>You have no fall damage.</li>
3287 <li>You can climb some steep mountains this way.</li>
3288 <li>Some monsters won't attack you, but some NPCs will attack you.</li>
3289 <li>Your attribute stats will temporary change.</li>
3290 <li>It requires 10 mana to cast (low requirement).</li>
3291 </ul>
3292 </p>
3293 </li>
3294 <li><p>Almost all mummies that are lootable in the game (Orc temple and The Sleeper
3295 temple) have really good loot: permanent and regular potions and amulets and
3296 rings.<br /> </p>
3297 </li>
3298 <li><p>Skill investments:
3299 <ul>
3300 <li>For melee skills:
3301 <ul>
3302 <li>Strength</li>
3303 <li>One-handed weapons have a bit lower weapon damage but are less clunky and
3304 faster. You can also interrupt enemy attacks.</li>
3305 <li>Two-handed weapons have the highest damage, but are slower.</li>
3306 <li>Get at least the first tier of one-handed training. It will change the
3307 combat animations and make combat less slow and clunky.</li>
3308 </ul>
3309 </li>
3310 <li>For ranged skills:
3311 <ul>
3312 <li>Dexterity</li>
3313 <li>Cross-bows have high damage and are very good.
3314 <ul>
3315 <li>Cross-bow: the path for cross-bow training is easier in the old camp.
3316 When you become the Old Camp guard Scorpio can train you. Later in the
3317 game in chapter 4 after some story progression he will train everyone.</li>
3318 </ul>
3319 </li>
3320 </ul>
3321 </li>
3322 <li>For mage characters:
3323 <ul>
3324 <li>Investing a little bit into strength, lets say 30 STR is OK.</li>
3325 <li>Magic skills are powerful but are a bit clunky and slow.</li>
3326 <li>Joining the Old Camp (fire mage) or New Camp (water mage) for the magician
3327 path is probably easier.</li>
3328 </ul>
3329 </li>
3330 <li>Harvest animals:
3331 <ul>
3332 <li>Early investments of a few skill points into getting skins, teeth and claws
3333 from animals is OK (it is easy to get a lot of ore if you loot everything
3334 though).</li>
3335 </ul>
3336 </li>
3337 <li>Lockpicking: training in lockpicking only reduces the chance to break locks
3338 when you fail the combination. Investing in it is OK but not necessary.
3339 A small cheat: the lock pick combination stays the same, you can save and
3340 reload the game to avoid losing lockpicks.</li>
3341 <li>Bad skill investments to avoid:
3342 <ul>
3343 <li>Sneak and pickpocket are nearly useless.</li>
3344 </ul>
3345 </li>
3346 </ul>
3347 </p>
3348 </li>
3349 </ul>
3350 <p>Overall recommendation: I'd recommend a hybrid of melee/magic or melee/range.
3351 Early game for melee: get max strength to 100 and get at least the first tier
3352 of one-handed training.<br />
3353 In the later game focus more on ranged combat or learning the magic circles.</p>
3354 <h1>Side-quest Chromanin / The Stranger</h1>
3355 <p>This describes an interesting side quest in the Gothic 1 game, which is not too
3356 obvious to find and may be overlooked.</p>
3357 <p>The first Chromanin book is found by defeating the skeleton mage in the Fog
3358 Tower. On its bones you can find the Chromanin book. Reading the book starts
3359 the Chromanin / The Stranger quest. The books contain some typos, being
3360 demonicly possesed could be an excuse for that :)</p>
3361 <p>Note that the Old books only spawn in a specific order after reading each found
3362 book. So they have to be done in this specific order.</p>
3363 <p><a href="downloads/gothic1/chromanin/0_mage_fog_tower.png">Fog tower mage</a><br />
3364 <a href="downloads/gothic1/chromanin/0_fog_tower.png">Location</a><br />
3365 <a href="downloads/gothic1/chromanin/0_map.png">Map</a><br /> </p>
3366 <p>Text:</p>
3367 <pre><code>"He who is willing to
3368 renounce all depravity
3369 and wanders on the path
3370 of righteousness, shall
3371 know where the source
3372 of my power lies
3373 hidden. So that he might
3374 use it to break the chains
3375 of this world and prove
3376 worthy to receive Chromanin."
3377
3378 "The Wise One sees to
3379 having a general overview before he
3380 dedicates himself to his
3381 next mission."
3382 </code></pre>
3383 <h2>Chromanin</h2>
3384 <p>The clue is in the words "general overview" on the second page.
3385 One of the highest points on the map is the tower where you find and free the orc Ur-Shak
3386 from being attacked by other orcs.</p>
3387 <p>The Wise One sees to having a general overview before he dedicates himself to
3388 his next mission".<br />
3389 Location: on top of the tower near where the orc Ur-Shak was.<br />
3390 Item: Old Book.</p>
3391 <p><a href="downloads/gothic1/chromanin/1_book.png">Item</a><br />
3392 <a href="downloads/gothic1/chromanin/1_tower.png">Location</a><br />
3393 <a href="downloads/gothic1/chromanin/1_map.png">Map</a><br /> </p>
3394 <h2>Chromanin 2</h2>
3395 <p>Text:</p>
3396 <pre><code>"Carried from the tides
3397 of time, Chromanin's
3398 visions have opened my
3399 eyes. No price could be
3400 high enough to ever
3401 renounce my faith in
3402 them, for it touched my
3403 heart too insensely."
3404
3405 "What is devided will be
3406 reunited, after being
3407 massively separated for
3408 a short time."
3409 </code></pre>
3410 <p>Clue: "What is devided (sic) will be reunited, after being massively separated for a short time".
3411 Location: small island near the (divided) river near the Old Camp.</p>
3412 <p><a href="downloads/gothic1/chromanin/2_book.png">Item</a><br />
3413 <a href="downloads/gothic1/chromanin/2_river.png">Location</a><br />
3414 <a href="downloads/gothic1/chromanin/2_map.png">Map</a><br /> </p>
3415 <h2>Chromanin 3</h2>
3416 <p>Text:</p>
3417 <pre><code>"Oh, Ancient Gods. How
3418 can it be that a man like
3419 me, simple and unworthy,
3420 may receive such great a
3421 legacy. I feel great
3422 fear to lose all of it
3423 again by a slight
3424 faltering in word or
3425 deed."
3426
3427 "The wise fisherman
3428 occasionally tries to get
3429 lucky on the other side
3430 of the lake."
3431 </code></pre>
3432 <p>Clue: a fisherman lake and (partially sunken hut) can be found close the the entrance of the New Camp.
3433 At the other side is the Old Book.</p>
3434 <p><a href="downloads/gothic1/chromanin/3_book.png">Item</a><br />
3435 <a href="downloads/gothic1/chromanin/3_lake_new_camp.png">Location</a><br />
3436 <a href="downloads/gothic1/chromanin/3_map.png">Map</a><br /> </p>
3437 <h2>Chromanin 4</h2>
3438 <p>Text:</p>
3439 <pre><code>"I dare not to be in
3440 the presence of
3441 Chromanin one day. Gone
3442 are the days of wasting
3443 and wailing. So easy it
3444 will be to acheive
3445 absolute perfection. I'm
3446 not far from it!"
3447
3448 "Long forgotten are the
3449 deeds of those who once
3450 were aboard."
3451 </code></pre>
3452 <p>Clue: "Long forgotten are the deeds of those who once were aboard."
3453 A broken ship can be found near the beach at the entrance of the Fog Tower.</p>
3454 <p><a href="downloads/gothic1/chromanin/4_book.png">Item</a><br />
3455 <a href="downloads/gothic1/chromanin/4_aboard.png">Location</a><br />
3456 <a href="downloads/gothic1/chromanin/4_map.png">Map</a><br /> </p>
3457 <h2>Chromanin 5</h2>
3458 <p>Text:</p>
3459 <pre><code>"But I shall not walk this
3460 path alone. This honor is
3461 mine. I must accept to
3462 share the power within
3463 myself with the worthy
3464 ones who are to come and
3465 find me. I hope they're
3466 coming soon..."
3467
3468 "You will find me where it all began."
3469 </code></pre>
3470 <p>Clue: "You will find me where it all began."
3471 Very obvious it is the same location as were the first book was found.</p>
3472 <p><a href="downloads/gothic1/chromanin/5_book.png">Item</a><br />
3473 <a href="downloads/gothic1/chromanin/5_begin.png">Location</a><br />
3474 <a href="downloads/gothic1/chromanin/5_map.png">Map</a><br /> </p>
3475 <h2>Chromanin 6</h2>
3476 <p>Text:</p>
3477 <pre><code>"Empty pages"
3478 </code></pre>
3479 <p><a href="downloads/gothic1/chromanin/6_book.png">Item</a></p>
3480 <p>On the corpse is the last chromanin book.
3481 When reading this last book the book is empty.
3482 Then there is evil laugh and 2 skeleton mages and skeleton minions will spawn.</p>
3483 <h2>Chromanin quest log</h2>
3484 <p>Here are the texts in the quest log:</p>
3485 <p><a href="downloads/gothic1/chromanin/quest_log_part_1.png">Quest log part 1</a><br />
3486 <a href="downloads/gothic1/chromanin/quest_log_part_2.png">Quest log part 2</a><br /> </p>
3487 <h3>The End</h3>
3488 <p>When you use the tips described above Gothic should be an easier game and you
3489 should be able to get at a high(er) level with lots of mana/strength/hp.</p>
3490 <p>Have fun!</p>
3491 ]]></description>
3492 </item>
3493 </channel>
3494 </rss>