flak rss random

strict structs

Contrary to popular belief, C does have types. It even has type qualifiers. Unfortunately, the selection is somewhat limited and there are several implicit conversions that may lead to less than robust code. The good news is that with a little effort we can define our own types and enforce our own rules. I’ve forgotten where I first saw this, and don’t really have a good name for it.

more...

Posted 14 Nov 2018 15:45 by tedu Updated: 14 Nov 2018 15:45
Tagged: c programming

tell your kids about css overflow-wrap

You have a blog. You write stuff. This is all good.

But it’s a technical blog. And so you write articles that include code or URLs or auth tokens or hex coded hashes or other horrors like AbstractImplementationOfBorrowCheckerFactoryPatternMatcher which results in words of unusual size. And this being important technical content, it’s styled as whitespace preserving per the fashion of our times.

This is problematic on narrower screens because those great big long words completely blow out your page width, with the resulting effect that the main content is a tiny sliver running down the side of the screen. You’ve gone to the trouble of picking a responsive layout because you want to be mobile friendly, but your selected styles respond to such content rather poorly.

There is an easy fix. Or two.

The CSS white-space property has a value called pre-wrap which in many cases is probably better than plain pre. Long code lines will wrap, so it doesn’t really look like code anymore, but hey, I’m reading this on a phone, not compiling it.

The CSS overflow-wrap property (previously word-wrap) has a value called break-word which will split up not just lines, but long words too.

There are other possible values as well, to suit your preference, but I’d be willing to bet most people (or their readers) would be happier with values other than the ones they are using (probably the defaults). Sacrificing a small amount of technical fidelity can greatly improve the readability of the prose, and with no negative effect on desktop viewers.

Posted 08 Nov 2018 19:28 by tedu Updated: 08 Nov 2018 19:28
Tagged: web

zeno scrolling

Zeno scrolling requires javascript.

Everybody loves infinite scrolling.

Which is to say everybody hates it, but we love to use it anyway.

There’s just one problem. Infinite scrolling requires infinite data.

What if we don’t have that much content? Or what if we are old school enough to still care about bandwidth?

I have just the thing. Zeno scrolling. Infinite scrolling with finite data.

You read half the content. You’re going to read the second half of the content next.

But now the content is bigger. You scroll some more. The content gets bigger again.

In order to get to the second half you have to get past the first half.

It may be a little annoying to the user never reaching the end. But that’s no different than before, right?

On the plus side, as a site operator, I can make more economical use of my limited content.

Progress is an illusion.

There is no Zuul, only Zeno.

(Script is no longer inlined.)

var scroller = document.scrollingElement
var el = document.getElementsByClassName("post")[0]
var lh = 1
var fs = 2
var scrollit
function fixer() {
        var h = scroller.scrollHeight
        scroller.scrollTop = h * 0.4
        setTimeout(scrollit, 1000)
}
scrollit =  function() {
        var h = scroller.scrollHeight
        var t = scroller.scrollTop
        var p = t / h
        var r = scroller.scrollHeight / scroller.clientHeight
        var adjust = p > 0.5 || r < 2
        var withfix = p > 0.5
        if (adjust) {
                console.log("adjusting")
                fs *= 1.5
                el.style.fontSize = fs + "em"
                lh *= 1.5
                el.style.lineHeight = lh + "em"
        }
        if (withfix) {
                setTimeout(fixer, 1)
        } else {
                setTimeout(scrollit, 1000)
        }
}
el.style.fontSize = fs + "em"
el.style.lineHeight = lh + "em"
setTimeout(scrollit, 1)

Posted 01 Nov 2018 18:52 by tedu Updated: 01 May 2022 06:16
Tagged: javascript web

commands without magic

Is a magic command without magic still a command? And if a feature was a bug, can a new bug be a feature?

more...

Posted 29 Oct 2018 19:27 by tedu Updated: 29 Oct 2018 19:27
Tagged: openbsd programming

hard state soft state confusion

A few thoughts after reading The History of a Security Hole about a series of bugs in the OpenBSD kernel. It’s a good explanation of an instance of a problem I’ll call hard state soft state confusion, which can lead to some serious bugs, occurs with some regularity, but doesn’t seem to be often discussed.

more...

Posted 02 Sep 2018 22:51 by tedu Updated: 02 Sep 2018 22:55
Tagged: openbsd programming

deconstruct conf 2018

I was at Deconstruct, a little conference. It has no sponsors, a single track, no lunch, no public schedule, and no particular focus except computering. It was quite nice. Some notes from the talks.

more...

Posted 23 May 2018 18:22 by tedu Updated: 23 May 2018 18:22
Tagged: event software

comparative truthiness

When comparing two things, it’s easy to make a claim relating them. This one is longer. This one is stronger. This one is older. This one is bolder. (This one sounds like Dr. Seuss.)

But are we correct? Do people believe us? Would you believe me if I told you William Shatner is older than John McCain? Maybe that’s just a thing I heard. What happens if you ask me how old they are? If I don’t know, that’s a bad sign. If I know that Shatner was born in 1931 and McCain in 1936, that’s a good sign.

If a claim can be quantified, it should be. It’s very easy to do. If it’s not easy, consider why.

The first thing one can do is to ask how much when reading. Any unquantified comparisons stand out as starting points for fact checking.

The second thing one can do is to ask how much when writing. I try to fact check most claims before clicking the big red send it to the internet button, but it can be difficult to know exactly what needs checking. I don’t need to check the things I’m sure about. Alas, my certainty is also sometimes mistaken.

Which is bigger, Central Park in New York or Golden Gate Park in San Francisco? No spoilers, but I’ve heard both answers stated confidently. However, if I followup by asking how many acres is this park and how many acres is that park, confidence drops precipitously. Somehow these high level derived facts become lodged in our heads long after we’ve forgotten the underlying facts, if we ever knew them. We don’t realize this happens until somebody asks what’s underneath.

Unfortunately these high level facts don’t have a lot of error correction builtin. It’s only a single bit, and if it flops, you’ll never know. A numeric fact is more likely (how much more likely?) to degrade to uncertainty than some other value. A builtin parity check of sorts.

Everybody loves numbers. Include them when you write something. Your readers might learn something. You might learn something, too.

Posted 19 Dec 2017 18:09 by tedu Updated: 21 Apr 2022 08:35
Tagged: thoughts

easy gopher-lua bridge

I have some go code that I’d like to be a little more flexible at runtime. Like a config file, but maybe with some conditional logic based on string matching. If this sounds like a proxy deciding which filtering functions to apply based on URL, that’s a good guess.

more...

Posted 04 Dec 2017 23:02 by tedu Updated: 04 Dec 2017 23:02
Tagged: go lua programming

OtherLife review

Memories are nothing but chemicals. At that level, there’s no difference between a real and a fake memory, so if we have the appropriate nanotech, we can write some code to create memories, virtual experiences indistinguishable from those taking place in reality. Such is the concept of OtherLife. The movie’s titular company plans to sell vacation memories, allowing users to experience a day’s worth of snowboarding in less than a minute of real time. Why not take a vacation every day before going to work, arriving fresh and relaxed?

So far we’re in Total Recall territory, but the twist here isn’t secret double agents on Mars. Just a tech startup that needs funding. One founder, our heroine, created the company to further develop the tech and perhaps revive her brother from a coma. The other founder, in order to secure some necessary bridge funding days before launch, is in some shady talks with the prison bureau to develop a line of virtual imprisonment. Very near term, contemporary science fiction. It’s actually set in 2017. Just some stealth mode startup you haven’t heard about yet.

From here we explore the nature and ethics of memories. Is subjecting someone to a year of virtual solitary confinement that elapses in one real minute more or less ethical than taking away a year of their actual life? How do we know what’s real? Shades of Inception here, but with much less boom boom gusto. Very Black Mirror, with a bit of a twist, but a touch less pessimism. We’ve seen this concept before, but this might be the most grounded, without trying too hard to impress.

Posted 17 Nov 2017 23:18 by tedu Updated: 17 Nov 2017 23:18
Tagged: moviereview

books chapter sixteen

Finally.

more...

Posted 10 Nov 2017 17:13 by tedu Updated: 10 Nov 2017 17:13
Tagged: bookreview