“If you do not like it here because some humorists you don’t like are making a newspaper, may I then say you can fuck off.”

— Ahmed Aboutaleb, Mayor of Rotterdam

Fun with software testing


Before I released PDF::Cairo, I gave it a basic test suite to make sure that everything at least loaded correctly. I wanted to fully exercise the various methods, but that wouldn’t tell me if they actually worked or not. I needed to put ink on the page, and then compare it with a reference page. Automatically, using tools likely to be available (or at least easily installed) on the target platforms. I decided to generate an N-page PDF with small pages, draw a single test per page, and convert the results to a series of PNG files; if they were byte-for-byte identical to the files generated from the reference PDF, the tests passed.

ImageMagick’s convert utility was out, even though I currently use it to import non-PNG images into PDF::Cairo, because it can choose between multiple PDF backends, and I didn’t want the added test complexity. I considered Ghostscript, which I have a few decades of practice with, but then I came across Poppler’s pdftocairo utility. Not only does it have the functionality I need, but it’s built on Cairo, FreeType, and Fontconfig, the same libraries I’m generating the PDFs with in the first place.

Here’s what it looks like:

my $pdf = PDF::Cairo->new(
    width => in(2),
    height => in(2),
    file => $OUT,
);
...
push(@test_desc, "bezier curves");
$pdf->move(10, 10);
$pdf->curve(20, 120, 40, 40, 140, 60);
$pdf->rel_curve(-10, 10, -40, 40, -100, -30);
$pdf->linedash([12, 4, 8], 2);
$pdf->linewidth(4);
$pdf->stroke;
$pdf->newpage;
...
$pdf->write;
...
SKIP: {
  my $tmp = `pdftocairo -v 2>&1` || '';
  skip("need poppler's pdftocairo to compare images")
    unless $tmp =~ /pdftocairo/;
  my $PDFTOCAIRO = "pdftocairo -png -r 200 -antialias gray";
  system("$PDFTOCAIRO t/02-cairo.pdf $TMP/ref");
  system("$PDFTOCAIRO $OUT $TMP/02");
  foreach my $i (1..@test_desc) {
    $i = sprintf("%02d", $i);
    my $test = "page $i: " . shift(@test_desc);
    subtest $test => sub {
      plan tests => 3;
      ok(-s "$TMP/ref-$i.png", "reference page non-empty?");
      ok(-s "$TMP/02-$i.png", "page non-empty?");
      ok(compare("$TMP/02-$i.png", "$TMP/ref-$i.png") == 0,
        "page matches reference?");
    }
  }
}

Works quite nicely on Mac and Linux, and the small page size speeds up the PNG conversion. To test text methods, I had to add a free TTF font from Google Fonts. I can’t really test the effect of Fontconfig font substitution, which also means that I can’t really test Pango font-handling; currently, the work-in-progress Pango tests only run if you install the fonts included in the tarball.

Naturally, the act of writing the tests smoked out half a dozen bugs, so once I had decent coverage of the main module, I pushed out a new release to Github and CPAN.

Dear Souji Okita,


This is a block. Not a great block, since it’s a little low, and too close to your head, but an incoming strike will at least hit the blade before it hits your head:

This is not a block. Honestly, you’re about five seconds away from re-enacting Ben Kenobi’s final scene in Star Wars:

Dear Apple QA,


I like to think that there’s someone out there to address this message to, but all signs point to “no”.

Let’s look at the intersection of several features:

  1. Quick Look, activated by pressing spacebar.
  2. “Display as Folder” view for the Downloads folder in the Dock.
  3. Keyboard event passthrough to the active application.
  4. Spacebar as “mark item completed” in Reminders.
  5. Auto-select next item.

Now, let’s suppose that I have recently downloaded some items to which quicklook can be applied, perhaps pictures of scantily clad young ladies. While the Reminders app is active and an item is selected, I click on the Downloads icon, bringing up thumbnail images of these downloads, which I wish to view more closely.

I do this by pressing the spacebar, once to preview an image, once to make it go away again. I repeat these keystrokes several times, examining several images. When I click the Downloads folder again, I am returned to the Reminders app, which is now empty, because I’ve just marked every single item as completed.

This behavior is not consistent between applications. It never happens with Terminal, sometimes happens with Safari, where it’s a minor nuisance, and always happens with Reminders, where it is destructive.

Bootstrapping...


# tdnf install perl
# cpan App::cpanminus
# tdnf install man-db man-pages gawk tar diffutils
# tdnf install make gcc binutils glibc-devel linux-api-headers ncurses-devel
# su - build
% curl http://ftp.gnu.org/gnu/emacs/emacs-26.2.tar.gz | tar xzf -
% cd emacs-26.2
% ./configure --without-all --without-x
% make
# cd ~build/emacs-26.2
# make install
# cat <<EOF > /root/.emacs
(setq-default initial-major-mode 'fundamental-mode)
(defun set-auto-mode (&optional foo) (interactive "p") (fundamental-mode))
(when (fboundp 'electric-indent-mode) (electric-indent-mode -1))
(global-set-key (kbd "TAB") 'self-insert-command)
(setq-default tab-width 4)
(setq-default enable-local-variables nil)
(setq-default inhibit-eol-conversion t)
(setq inhibit-startup-screen t)
(setq inhibit-splash-screen t)
(setq line-move-visual nil)
(setq transient-mark-mode nil)
(setq sentence-end-double-space nil)
(setq isearch-lax-whitespace nil)
(setq search-whitespace-regexp nil)
(put 'narrow-to-region 'disabled nil)
EOF

Okay, now I can start exploring Photon.

File under baffling the fact that there’s no Emacs RPM at all. Admittedly, even my “minimal” build adds 200MB to /usr/local/, but:

“When you don’t have enough space for Emacs, you don’t have enough space.”
     — Sandy Wambold

Early Japanese drone technology


Honestly, I’m surprised Thanko doesn’t make this gadget…

(via)

OMC: Nanoka


After lengthy, careful inspection, it’s not true that there are eight different models named Nanoka (菜乃花). That would be nice, but the reality is that she’s got an unusual face, with features that are strongly affected by the perspective effect from different lens focal lengths. Where most models look more attractive when shot with the flatter perspective of a longer lens, Nanoka just turns into a different girl. That’s in addition to the effect of makeup, of course, which also acts to exaggerate or minimize different features. If it weren’t for selfies on her Twitter and Instagram accounts, I suspect fans would have trouble spotting her on the street.

Note that the intersection of “Nanoka” and “Safe For Work” is quite small. Rather similar to the intersection of “Nanoka” and “warm clothing”.

In related news, bigboobsjapan.com (backup site) is back online after being suspended by their previous hosting company, but without their archives. They’re making up for it by posting new stuff quite frequently, but a lot of quality cheesecake was lost. Remember, boys and girls, if your data only exists on Somebody Else’s Servers (sometimes called the “cloud”), it can go away at any time. Only downside is that they’ve switched to a Javascript-only template that not only dynamically loads thumbnails, but doesn’t allow you to right-click to download images; you have to click each thumbnail in turn, download, then press the back button.

more...

Safety first!


Fortunately for them, no one ever robs jewelry stores…

Forgotten SF Novels: The Alien


I’ve got floor-to-ceiling bookshelves in two rooms that are crammed with old SF novels. Every once in a while one of them catches my eye, and I give it a re-read. Some are old friends that deserve the attention, while others are basking in well-deserved obscurity.

First up is one that I read back in the late Seventies, after I’d just heard about a new movie called “Alien”. Since I wasn’t really in a position to go see it in a theater, I popped into the local library to try to find a novelization and see what it was about.

They didn’t have it. Instead, I found something called The Alien, and the cover made it pretty clear that there weren’t going to be any spaceships.

I don’t remember when or where I actually bought a copy, but it was almost certainly out of the same misplaced nostalgia that led me to hunt down a copy of Manly Banister’s Conquest Of Earth (aka The Scarlet Saint), another dusty old library classic.

The Alien was the second, and last, novel by one Victor Besaw, published in paperback by Fawcett in 1979. The Internet doesn’t seem to know a damn thing about him, but I’m inclined to say he lacked the Gift of Names:

“Outside Gelsan on the road to Malkha Voet,
on the third day of the year of Lilkhanflet
Bdengi got himself a strange new thrall…
a small Nyarlethu, scarce five mangi tall.”

That’s how it starts, and before the brief prologue is over, we’ve heard about the Vilarian sun, the Chalkhrondu, the Volsek river, a carriage pulled by delkhators, Bdengi’s wife Verla (who calls him Zhen), some sort of divinity to swear by named Khanophet, his driver Haldor (who calls him vlan), his guard Arlo, and Our Hero himself, the toddler Godranec, fed a nice piece of roasted tharg by Verla after being dropped in the middle of the road by a skaldu bird.

And that’s just the first three pages. I’ve gotten more consistent names out of a pile of Boggle dice. The world-building is just as consistent, which is to say not at all. Every few pages, something happens that introduces a half-dozen more boggle-words, another strange race, and a minor challenge for Our Hero to overcome. It makes for a rather quick read, and it isn’t a long book to begin with.

When he’s fully grown and conveniently armed with a magic spear (given to him by his master to destroy in the forge), a noble’s sword (given to him by the Halzhengim lizard-men, along with some advice from their tribe’s shogan on how to find his people), and a mighty axe (made by Our Hero in his master’s forge, which he conveniently had to himself that night), he murders the kitchen overseer Kula (as promised 40 pages earlier) and sets out for his freedom through the mysterious and deadly wierwood.

About a hundred pages later, Our Hero defeats a mighty cave bear, is reunited with his people, learns his true identity, and gains a beautiful princess as his wife, all in about ten pages. The end.

The book is stuffed with Tiny Adventures that are over almost before they start, each involving a new and different and vaguely-sketched element of this fantasy world, with no real thought to fitting them together into a coherent whole. Most disasters are averted by the convenient fact that his horns have a Spidey-sense, alerting him to plot points. It’s like reading an ADHD teen trying to imitate Edgar Rice Burroughs.

These days, it would be a 14-book indie series on Kindle, with each volume over 300 virtual pages long, but Besaw crammed it all into one, and that was that.

Worth reading? Only as a snapshot of the sort of brisk pulp fantasy that fed a hungry young SF market in that era. No sex, no gore, no character development, no world-building, just a nondescript protagonist who overcomes every obstacle in a few paragraphs and gets the girl.

On a related note, Good Show Sir collects terrible SF covers…

“Need a clue, take a clue,
 got a clue, leave a clue”