<commit_before><?xml version="1.0" encoding="utf-8" ?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Fortune</title>
<meta name="author" content="<NAME>" />
<meta name="description" content="An online programme that displays 'fortune cookies,' random epigrams, as found on pretty much all modern Unices." />
<meta name="date" content="2012-06-07T16:38:00Z" />
<meta name="mtime" content="2012-06-07T20:02:00Z" />
<meta name="category" content="Projects" />
<meta name="unix:name" content="project:fortune" />
</head>
<body>
<div class="figure">
<h1>Summary</h1>
<p>Displays random epigrams, just like the programme with the same name found on your favourite UNIX derivative's terminal.</p>
<ul>
<li><span style="text-decoration: line-through">see it in action</span></li>
</ul>
</div>
<h1>Project Goals</h1>
<p>The idea behind this programme is dead simple: a port of the terminal programme 'fortune', found on most Unices, so that it works on your favourite web browser. This isn't exactly a novel idea. You'll find this programme implemented several dozen times with a simple Google query.</p>
<p>The reason why I went and wrote this version anyway, is that I needed a simple testing environment for two things: writing web applications in C++, and using HTTP as the wire protocol between the web server and the application. Turns out both of these are rather simple. As an added bonus, I've made this version of fortune choose random epigrams from both the offensive and inoffensive ones, which is a feature I've missed in nearly all of the other implementations.</p>
<h1>Details</h1>
<p>As a daemon, upon starting, this version maps all the files in /usr/share/games/fortunes into memory, scans them for the characteristic '%' lines, maintains a list of start/stop locations of the individual epigrams and whether to decode them with ROT13, then opens a local socket for the web server to connect to. I've used the fortune-mod data files that came with debian for this particular project.</p>
<p>If you'd like to examine the source code, just download it via this site's git repository and see the file 'src/fortune.cpp' for the programme's code and 'include/ef.gy/http.h' for the http server code. If you do examine the source code, you'll find that the daemon doesn't actually produce XHTML output. Instead, it generates extremely simple XML, which is post-processed by 'xslt/xhtml-fortune.xslt' to produce plain XHTML. This makes this particular implementation a good example of how to separate logic and content from design elements.</p>
</body>
</html><commit_msg>updated the old blog post to point to the new one.<commit_after><?xml version="1.0" encoding="utf-8" ?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Fortune</title>
<meta name="author" content="<NAME>" />
<meta name="description" content="An online programme that displays 'fortune cookies,' random epigrams, as found on pretty much all modern Unices." />
<meta name="date" content="2012-06-07T16:38:00Z" />
<meta name="mtime" content="2012-06-07T20:02:00Z" />
<meta name="category" content="Projects" />
<meta name="unix:name" content="project:fortune" />
</head>
<body>
<h1>Summary</h1>
<p>Displays random epigrams, just like the programme with the same name found on your favourite UNIX derivative's terminal.</p>
<h1>Project Goals</h1>
<p>The idea behind this programme is dead simple: a port of the terminal programme 'fortune', found on most Unices, so that it works on your favourite web browser. This isn't exactly a novel idea. You'll find this programme implemented several dozen times with a simple Google query.</p>
<p>The reason why I went and wrote this version anyway, is that I needed a simple testing environment for two things: writing web applications in C++, and using HTTP as the wire protocol between the web server and the application. Turns out both of these are rather simple. As an added bonus, I've made this version of fortune choose random epigrams from both the offensive and inoffensive ones, which is a feature I've missed in nearly all of the other implementations.</p>
<h1>Details</h1>
<p>As a daemon, upon starting, this version maps all the files in /usr/share/games/fortunes into memory, scans them for the characteristic '%' lines, maintains a list of start/stop locations of the individual epigrams and whether to decode them with ROT13, then opens a local socket for the web server to connect to. I've used the fortune-mod data files that came with debian for this particular project.</p>
<p>If you'd like to examine the source code, just download it via this site's git repository and see the file 'src/fortune.cpp' for the programme's code and 'include/ef.gy/http.h' for the http server code. If you do examine the source code, you'll find that the daemon doesn't actually produce XHTML output. Instead, it generates extremely simple XML, which is post-processed by 'xslt/xhtml-fortune.xslt' to produce plain XHTML. This makes this particular implementation a good example of how to separate logic and content from design elements.</p>
<p><em>Update: this has been seriously updated, <a href="/fortuned">see the fortuned article for details</a>. There's a JSFiddle for using the server there and everything.</em></p>
</body>
</html>
{'fraction_non_alphanumeric': 0.09735849056603774, 'fraction_numerical': 0.01660377358490566, 'mean_word_length': 5.051369863013699, 'pattern_counts': {'":': 0, '<': 81, '<?xml version=': 2, '>': 81, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2603443', 'n_tokens_mistral': 1525, 'n_tokens_neox': 1428, 'n_words': 727}