Website, gopher, etc
Log | Files | Refs | Submodules

commit e4f10c5fc6c43b94b66bf4e4aa3e7b2a6dd8a6a9
parent 1743061793e4cc23e36ac329672c84545f407069
Author: hhvn <dev@hhvn.uk>
Date:   Sat, 26 Nov 2022 20:06:04 +0000

Blog generation

Mgen/generate.rc | 61++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
Mnotes/makefile_workflow.txt | 6+++---
Anotes/makefile_workflow.txt.published | 1+
Anotes/makefile_workflow.txt.uuid | 1+
Anotes/raylib.txt | 81+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Anotes/raylib.txt.published | 1+
Anotes/raylib.txt.uuid | 1+
Mwww/index.css | 5+++++
8 files changed, 149 insertions(+), 8 deletions(-)

diff --git a/gen/generate.rc b/gen/generate.rc @@ -8,12 +8,43 @@ make -C stagit make -C stagit-gopher ./stagit-gopher-create.rc +notesdir = ../notes/ + +fn atomentry { + file=$1 base=$2 atom=$3 title=$4 url=$5 { + printf '\t<entry>\n' >> $atom + printf '\t\t<title>%s</title>\n' $title >> $atom + printf '\t\t<link href="%s" />\n' $url/$base >> $atom + + if (!test -f $f.uuid) { + uuid = `{uuidgen | tee $f.uuid} + } else { + uuid = `{cat $f.uuid} + } + printf '\t\t<id>urn:uuid:%s</id>\n' $uuid >> $atom + + if (!test -f $f.published) { + published = `{date +'%Y-%m-%dT%H:%M:%S' | tee $f.published} + } else { + published = `{cat $f.published} + } + printf '\t\t<published>%s</published>\n' $published >> $atom + printf '\t\t<updated>%s</updated>\n' `{dateconv -i '%s' `{stat -c '%Y' $f} -f '%Y-%m-%dT%H:%M:%S'} >> $atom + printf '\t\t<author>\n' >> $atom + printf '\t\t\t<name>hhvn</name>\n' >> $atom + printf '\t\t\t<email>hhvn AT hhvn DOT uk</email>\n' >> $atom + printf '\t\t</author>\n' >> $atom + printf '\t</entry>\n' >> $atom + } +} + # Blog generation +webatom = ../www/blog/feed.xml blog = ../www/blog/index.html blogdir = ../www/blog rm $blogdir/* -for (f in ../notes/*) { +for (f in $notesdir/*) { cp $f $blogdir/ ^ `$nl{basename $f} } @@ -29,15 +60,29 @@ cat > $blog <<'EOF' <body> <h1>hhvn's blog</h1> <hr /> + &nbsp;<a href="/">Back to /</a> <span class="vl">&nbsp;</span><a href="./feed.xml">Atom feed</a> <span class="vl">&nbsp;</span><a href="gopher://hhvn.uk/phlog">Phlog</a> + <hr /> EOF +cat > $webatom <<'EOF' +<?xml version="1.0" encoding="utf-8"?> +<feed xmlns="http://www.w3.org/2005/Atom"> + <title>hhvn's blog</title> + <subtitle>Notes and stuff.</subtitle> + <link href="http://hhvn.uk/blog/feed.xml" rel="self" /> + <link href="gopher://hhvn.uk/phlog/feed.xml" /> + <link href="http://hhvn.uk/" /> + <link href="gopher://hhvn.uk/" /> +EOF + fn recent { test `{datediff -f '%d' $1 now} -le 5 } - -{for (f in $blogdir/*.txt) { +{for (f in $notesdir/*.txt) { + base = `$nl{basename $f} + title = `$nl{grep '^Title: ' < $f | sed 's/[^ ]* //'} date = `$nl{grep '^Date: ' < $f | sed 's/[^ ]* //'} updated = `$nl{grep '^Upated: ' < $f | sed 's/[^ ]* //;s/ .*//'} @@ -47,13 +92,19 @@ fn recent { recent = ' ' } - printf '[%s] %s<a href="./%s">%s</a><br />' \ + atomentry $f $base $webatom $title http://hhvn.uk/blog + + printf '[%s] %s<a href="./%s">%s</a><br />\n' \ $date \ $recent \ `$nl{basename $f} \ `$nl{grep '^Title: ' < $f | sed 's/[^ ]* //'} -}} | sort >> $blog +}} | sort -r >> $blog cat >> $blog <<'EOF' </body> EOF + +cat >> $webatom <<'EOF' +</feed> +EOF diff --git a/notes/makefile_workflow.txt b/notes/makefile_workflow.txt @@ -1,7 +1,7 @@ Title: Tips for workflows involving makefiles and gdb Date: 2022-11-22 Updated: 2022-11-25 (valgrind) -Tags: c make gdb ctags tags vim +Tags: c make gdb ctags tags vim valgrind vim: set tw=77 cc=77 : # Some tips for making C projects more convenient. @@ -101,10 +101,10 @@ to propagate elswhere. git add -p is your friend. from history. If you need to hand your program arguments, use --args. This can be placed in a macro for convenience: - ARGS = --args whatever you want + ARGS = whatever you want gdb: all - gdb ./(BIN) $(ARGS) + gdb --args ./(BIN) $(ARGS) And since it's a macro, you could append $(ARGS) to the 'test' target, and now you only need to change it in one place. diff --git a/notes/makefile_workflow.txt.published b/notes/makefile_workflow.txt.published @@ -0,0 +1 @@ +2022-11-12T00:00:00 diff --git a/notes/makefile_workflow.txt.uuid b/notes/makefile_workflow.txt.uuid @@ -0,0 +1 @@ +87009e68-0731-47af-ba39-60ed7e431258 diff --git a/notes/raylib.txt b/notes/raylib.txt @@ -0,0 +1,81 @@ +Title: Mini-rant on raylib +Date: 2022-11-26 +Tags: raylib rant cepheid + +This is copied from the README of git://hhvn.uk/cepheid (a new-ish project of +mine). + +--- + +I selected raylib as I was hoping it would be a good enough abstraction layer +between X11/opengl/etc and "draw a line here". My opinion so far is that it's +alright. + +I can definitely say it's easy to use when you're using it as intended, as +raylib handles most data structures itself, and doesn't require any allocation +of data. There's no raylib_ctx_init(), and passing the same struct to every +single function (when functions need to be aware of some context there is +usually a BeginSomething() function that will tell raylib to be aware of that +until the EndSomething() later on, which is a pretty sweet way of handling +things). + +raygui, however, is an absolute piece of shit, IMO. I find the whole +"modulization" thing pretty dumb: all components of raylib have the same +dependencies - you save practically nothing from splitting it up into multiple +parts. The .a/.so and .h model works fine for raylib itself, so why does raygui +have to be implemented in a header when it could all be present in raylib.so? As +far as I can tell, the only way to style the gui (that won't cause you to rip +your hair out) is to use a styling program written by the author. As of the +start of this project I couldn't find the source code anywhere, and the only +place that it could be run was online. I'm sure I could've asked somewhere, but +at that point I couldn't be bothered trying to deal with raygui and decided to +implement my own. + +Honestly, I'm kind of happy that I didn't go with raygui, as writing my own gui +has been fun. + +raylib has other issues though. I said earlier that it's good if you "use it as +intended". That's because there are plenty of small features that could be very +handy but the author decided shouldn't exist. + +One example of this is support for multiple windows, this is a feature that has +been created (https://github.com/raysan5/raylib/wiki/Use-multiple-windows) +before. I understand why this hasn't been merged with raylib itself - it +wouldn't work with the web as a target - but still, I don't care about the web, +and I don't care to maintain a fork of raylib for this project, why can't it +just be there for the targets that do support it? The only visible change to +anyone using raylib would be to BeginDrawing(), but there could instead be a +BeginDrawingWindow() function that takes a context id, and produce a warning if +both BeginDrawingWindow() and BeginDrawing() are used in the same program. + +Another issue is the handling of keyboard input. In order to get text input, the +GetCharPressed() function exists, which returns a wchar_t. Great, right? No. +Because it doesn't return backspaces. Even though they are ASCII characters. +Okay, so I can just use IsKeyPressed() right? Nope, because that won't deal with +they key being held down. So instead I have to implement a function that counts +frames and every n frames says it's pressed. So I just have to find the delay +that X11 uses between emitting key presses when a keys is held and hardcode +that, right? Nope. Nope. Nope. Because X11 has settings which allow you to +change that, and since raylib is meant to be dealing with X11 I can't query +that, so what should be a setting that applies globally to all X11 applications +doesn't apply to cepheid because I can't make it. + +raylib also isn't very good at drawing big shapes. For example, the orbits of +planets. By default raylib only draws rings with 36 segments, which really isn't +enough when less than 1° is shown on screen (ie, zoomed into a planet). Cranking +up this number indiscriminately isn't a very good idea either, as the +performance goes bye bye. So yet again, I'm having to fight with raylib to try +to get it to work somewhat well. The solution at the time of writing (701a5de) +is a function that calculates the number of segments to draw based on the +radius, and estimates at what degrees the ring should start and end at (see +ui_draw_ring). Along with that, draw_orbit() does various checks to prevent +unecessary drawing in the first place. With this I'm able to get 60fps on a +"Intel i5 M 520 (4) @ 2.400GHz"'s integrated GPU displaying all the planets in +the solar system, but turn it on for all the dwarf planets and asteroids... + +I would have hoped that raylib with deal with this for me. + +After seeing this blog post, +https://www.bit-101.com/blog/2022/11/coding-curves-03-arcs-circles-ellipses/ +I'm considering writing my own function for drawing orbits, but this will depend +on the performance of drawing a lot of lines. diff --git a/notes/raylib.txt.published b/notes/raylib.txt.published @@ -0,0 +1 @@ +2022-11-26T19:48:44 diff --git a/notes/raylib.txt.uuid b/notes/raylib.txt.uuid @@ -0,0 +1 @@ +2a2b4af0-28a4-4f7f-9cc0-328263bf37a9 diff --git a/www/index.css b/www/index.css @@ -31,6 +31,11 @@ hr { border: 1px #557766 solid; } +.vl { + border-left: 2px #557766 solid; + margin-left: 2px; +} + a { color: #0566bb; text-decoration: none;