Stop helping me python!

/media/images/snake_with_hat.jpg

I recently added a new django app to the site and took the opportunity to finally sync this code with the code that was actually running on my SBC webserver. The new code seemed to be solid but I'd made some radical changes and I wasn't confident I didn't break things. Of course this just meant the longer I delayed the more the two code bases diverged.

Of course there was an issue. It came up when I wanted to add an image to a blog entry and it crashed because I'd neglected to update the blog model to work with the new thumbnail API.

This started a frantic scramble to fix it within my development framework, a rootless podman container, but I learned that had issues too. Group permissions weren't getting propagated into the container so I didn't have write access to the database.

After some investigation I found the issue and fixed it without any way of testing it before pushing it to 'production' (by which I mean the SBC that runs this site - which no one reads). It crashed and so I was forced to temporarily turn on debug to see why.

Python was complaining that my code was trying to index a tuple with a string. This was baffling because my code wasn't working with tuples. Eventually I tracked the fault down to this block of code:

mediadict = {'type': 'image',
             'thumbfilepath': Path(thumbfilepath),
             'filepath': Path(newpath),
             'cstring': 'center-block',
             'constraint': 'width max',
             'filesize': image_filesize,
             'filelength': 'unknown'},
if self.resize:
    mediadict['constraint'] = str(self.resize)

im = thumbnail.make_thumbnail(mediadict)

Spot the issue? Here it is in an interpreter:

[ins] In [1]: t = {'a':1, 'b':2}

[ins] In [2]: t
Out[2]: {'a': 1, 'b': 2}

[ins] In [3]: t = {'a':1, 'b':2},

[ins] In [4]: t
Out[4]: ({'a': 1, 'b': 2},)

I accidentally left a trailing comma on my dictionary instantiation so python automatically enclosed it in a tuple!

This is both surprising and horrifying. It should raise an error or, if you want to be syntactically permissive, ignore the comma altogether. I cannot imagine anyone expecting a trailing comma to automatically convert your object into a different (and unmentioned) data structure.

In fact this bug is so alarming I'm beginning to think it may be time to start edging away from the language altogether. Python is convenient for making something fast but it may be too friendly.

You can see the changes I made here.

LOTS OF HORSES!

/media/images/horse045.jpg

Are your friends competitive? Athletic? Do you like shouting? Heart racing excitement? Do you and your bros watch football and UFC in splitscreen while drinking brewskies? Well I have a game for you!

In Lots of horses you and your buddies will enter the intense and immersive world of horselandia in a competition of glorious consensus!

Thrill! - at Gulliver's preference to keep napping in the barn instead of exploring a new pasture.

Quiver! - at Shilo's reluctance to hang with the rest of the herd.

Delight! - in agreeing with your buddy Spike over which horse has the 'dustiest hooves'.

Tingle! - with excitement as you determine which horse is the most courageous.

Deep Enchantment! - is what you and your fellow bros will feel as you play...


LOTS OF HORSES!

Click on this link to play lots of horses for free today!

Les Lupins

/media/images/les_lupins.jpg

lubins aren’t quite werewolves. “Sorrowful, dreamy and stupid spirits,” she writes, “they spend their lives chatting in an unknown language along the walls of cemeteries. In some places they are accused of breaking into the field of rest and gnawing on bones. In the latter case, they belong to the race of lycanthropes and werewolves, and must be called lupins. But in the case of lubins, manners soften with the name. They do no harm and escape at the slightest sound.

George Sand (source)

OK, bye!

/media/images/one_day_i_hope_to_understand_you_humans.jpg

Days of the week

Taken from A Restitution of Decayed Intelligence in Antiquities by Richard Verstegan in 1605 in which he lays out the Germanic gods from which we take the names of the days of the week.

Sunday

/media/images/dow_sunday.png

The idol of the Sun.


It was made as here appeareth, Iike halfe a naked man, set upon a Piller, his face as it were, brightened with gleames of fire, and holding with both his armes stretched out, a burning wheele upon his breast: the wheele being to signifie the course which he runneth round about the world; and the fiery gleames, and brightnes, the light, and heat wherewith he warmeth, and comforteth the things, that live, and grow.

Monday

/media/images/dow_monday.png

The idol of the Moon.


The forme of this Idoll seemeth very strange, and ridiculous, for being made for a woman shee hath a short coat like a man: but more strange it is to see her hood with such two long eares. The holding of a Moone before her breast may seeme to have beene to expresse what she is, but the reason of her chapron with long eares, as also of her short coat, and pyked shooes, I doe not finde.

Tuesday

/media/images/dow_tuesday.png

The idol of Tuysco.


The next unto the Idols of the two most apparant Planets, was the Idoll of Tuysco: the most antient, and peculiar god of all the Germans, here described in his garment of a skinne, according to the most antient manner of the Germans cloathing.

Of this Tuisco, the firsthand, and chiefest man of name among the Germans, and after whom they doe call themselves Tuytshen, that is, duytshes, or duytsh-people, I have already spoken in the first Chapter: as also shewed, how the day which yet amongst us retaineth the name of Tuisday, was especially dedicated unto the adoration, and service of this Idoll.

Apparently there was a book published in 1670 (De Anglorum gentis origine by Robert Sheringham) than vigorously refutes this interpretation.

Wednesday

/media/images/dow_wednesday.png

The idol of Woden.


The next was the Idoll Woden, who as by his Picture here set downe appeareth was made armed, and among our Saxon Ancestors esteemed, and honoured for their god of Battell, according as the Romans reputed, and honoured their god Mars.

He was while sometime he lived amongst them, a most valiant and victorious Prince, and Captaine, and his Idoll was after his death honoured, prayed, and sacrificed unto, that by his ayd, and furtherance they might obtaine victory over their enemies: which when they had obtained, they sacrificed unto him such prisoners as in battell they had taken. The name WODEN signifies fires, or furious, and in like sence we yet retaine it, saying when one is in a great rage that he is WOOD

I guess that bit of slang has been lost

Thursday

/media/images/dow_thursday.png

The idol of Thor.


The next in order as aforesayd, was the Idoll THOR, who was not onely served, and sacrificed unto of the antient Pagan-Saxons, but of all the Teutonicke people of the septentrionall Regions, yea, even of the people that dwelt beyond Thule or ISLAND, for in Greeneland was he knowne, and adored; in memory whereof a promont dryor high poynt of land lying out into the sea, as also a river which felleth into the sea at the said promontory, doth yet beare his name; and the manner how he was made, his picture here doth declare.

This great reputed God, being of more estimation than many of the rest of like sort, though of as little worth as any of the meanest of that rabble; was majestically placed in a very large, and spacious Hall, and there set, as if he had reposed himselfe upon a covered Bed. On his head he wore a Crowne of gold, and round incompasse above, and about the same, were set or fixed, twelve bright burnished golden starres. And in his right hand he held a Kingly Scepter.

Friday

/media/images/dow_friday.png

The idol of Friga.


The next following in rank and reputation, was the Goddess Friga, who was made according as this picture here doth demonstrate.

This Idoll represented both sexes, as well man as woman, and as an Hemophrodite is said to have had both the members of a man, and the members of a woman. In her right hand she held a drawne Sword, and in her left a Bow signifying thereby that women as well as men should in time of neede be ready to fight.

Some honoured her for a God and some for a Goddess, but she was ordinarily taken rather for a Goddesse than a God, and was reputed the giver of peace, and plenty, as also the causer, and maker of love, and amity, and of the day. Of her especiall adoration we yet retaine the name of Friday, and as in the order of the dayes of the weeke THURSDAY commeth betweene Wednesday and Friday, so (as Olaus magus noteth) in the septentrionall regions, where they made the Idoll THOR sitting or lying in a great Hall upon a covered bed, they also placed on the one side of him the Idoll WODEN, and on the other side the Idoll FRIGA. Some do call her frea and not friga., and say she was the wife of Woden, but she was called FRIGA, and her day our Saxon ancestors called FRIGE DEAG, from whence our name now of Friday in deed commeth, Saxo Gramaticus saith, that the people which by reason of the great famine in the time of Snio King of Denmarke (whereof I have before made mention) were constrained by lot to go seeke them new habitations, were by the Goddess FRIGA commanded to call themselves Longobards, which is an opinion by Crantziuts and others rejected as fabulous, and for no lesse I esteeme it.

Yeah, more like Crazytziuts, am I right?

Saturday

/media/images/dow_saturday.jpg

The idol of Seater


The last to make up here number of seven, was the Idoll SEATER, fondly of some supposed to be Saturnus, for he was otherwise called CRODO, this goodly god stood to be adored in such manner as here this picture doth shew him.

First on a pillar was placed a pearch, on the sharpe prickled backe whereof stood this Idoll. He was leane of visage, having long haire, and a long beard: and was bare-headed, and bare footed. In his left hand he held up a wheele, and in his right he carried a paile of water, wherein were flowers, and fruites. His long coate was girded unto him with a towel of white linnen. His standing on the sharpe finnes of this fishe was to signifie that the Saxons for their serving him, should pass stedfastly, & without harme in dangerous, and difficult places.

Everyone should aspire to be more like Seater.

GOOD DAY!

Re-entry

/media/images/reentry_2024-01-08_20-48.png

I got a bunch of video games for Christmas. They're all notable for one reason or another but the one that's been haunting me lately is called "re-entry an orbital simulator". It's a flight simulator developed by a solo developer recreating the American Mercury, Gemini, and Apollo space missions. I've always been interested in the engineering behind the space program and this game is my chance to learn what all those buttons do.

So far I've completed the Mercury training and I'm about half-way done learning the interior controls for the Gemini spacecraft.

It's interesting to see the engineering behind these spacecraft. The Mercury capsule was largely self-guided using 1960's technology, leaving the astronaut as little more than a passenger. Pilots were only responsible for monitoring and signaling the automated system and dealing with any emergencies, often by stepping through a paper checklist.

It's fun to know what each button and knob does but it's also fun to see all the redundancy built into the controls and guess the engineering reasons behind them. I suspect there was a good reason for the Mercury capsule to have 3 primary batteries, 2 backup batteries, and a third (called the isolated battery) to handle maneuvering. The electrical system was designed so you could remove or replace all the battery connections from the main bus using switches in the cockpit. Making all this work with 1960's technology and still be understandable is, in itself an interesting UI feat.

/media/images/reentry_2024-01-08_20-482.png

Most of the systems are routed through three-position fuses. Each fuse has two different ONs and one OFF. I'm not sure why they have redundancy in the shorted position but only a single open position. Is it because open circuits are less prone to failure? Are they less fatal to the mission? There isn't much feedback in some of these systems; how do you know that a fuse in position 1 has failed and should be switched to position 2?

Controls for blood pressure, suit temperature, and suit fans and fuses are found on the console along with the other cabin controls. How much was the astronaut plugged into the capsule? How easily could he get himself unplugged in an emergency? I seem to remember the first astronauts raising a fuss about having to wear rectal thermometers and diapers under their suits.

The mercury capsule has two separate fuel tanks for automatic RCS thrusters and manual thrusters. This seems to suggest the computer (the Automatic Stabilization Control System ASCS) wasn't trusted to not burn all the propellant during it's automatic attitude correction.

In both the Mercury and Gemini space capsules there's a DC and an AC electrical system. The AC is generated by inverters from the DC supply and is used to drive the fans and ASCS. This just seems crazy. Adding 250V lines to a oxygen pressurized spacecraft tempts disaster. Did they not have DC fans? Why did the digital computer require AC? Were they in a rush and had the mass allowance to just throw in another electrical system so they could re-use flight-tested hardware?

The game has an overwhelmingly positive rating on steam but I think it's because the only people who are playing it are massive space nerds like me and everyone else avoids a simulator where you're expected to sit in a cockpit among hundreds of buttons, knobs, and switches with strange acronyms. One of the reviewers said he hadn't played the game yet but was having a blast reading the manual. Each spacecraft comes with a 100+ page manual covering the various systems. You can see them here

So far I've gone through the Mercury training having launched, orbited, and landed the capsule and I'm working through the Gemini missions.

The Gemini spacecraft has an on-board computer that can be programmed (from tape!) and queried with a keypad. I don't know what happened between the two programs but the Gemini requires much more manual intervention. Each stage of orbital entry and retrograde burn is tracked by the computer which lights up a button but it's up to the astronaut to press it.

/media/images/reentry_2024-01-08_20-42.png

The flight controls are an order of magnitude more complex. I haven't gotten into changing the angle of inclination, orbital rendezvous, or orbital circulation but I suppose the extra controls let you do that.

/media/images/reentry_2024-01-08_20-44.png

I almost get the sense they were so proud of their new computer technology they included it even though it was kind of a pain. To compute your retro burn (essentially deciding when to de-orbit your spacecraft so you land in a particular spot on earth) you punch in 19 on the computer keypad and hit enter to get the time in seconds to retrograde. Then you program this number into an awkward facsimile of a digital clock, and load the re-entry program on the computer from tape - which takes 10 minutes and during which your computer is unavailable. When your digital clock runs out you know when to manually trigger the next stage of de-orbit. You can see this in action starting at 11:40 in this video

So far I'm really enjoying the game though it's still in early access and the graphics and effects are rough. I haven't blown up a spacecraft yet, it may not be possible in this early version of the simulator, but I accidentally ejected myself, didn't realize my temperatures sensors were off the scale (threatening a fire in my pure oxygen pressurized cabin), and I got trapped in space a few times when I messed up my retro burns.

I think I prefer the Mercury aesthetics over the Gemini.

/media/images/reentry_2024-01-08_20-43.png /media/images/reentry_2024-01-08_20-47.png

Games like this and kerbal space program are fun to play in the dark before bed. In the quiet dark they become a meditative exercise of tracking fuel expenditure, battery, and oxygen use and watching clocks tick down to trigger events. I've somehow got 190 hours of playtime in KSP and I suspect I'll find this game equally absorbing if not as time intensive.