Sunday, 7 December 2014

Feel free to block ads

It's 2014, and I'm browsing a review website owned by the internet giant Amazon.

Important Message: A required driver is missing

There's no option to report the ad. I assume the close button is supposed to mean "I'm not interested in this ad, please show me different ones instead." (I wouldn't recommend you click anywhere on such an ad, by the way). AdChoices, the button next to Close... technically gives you an option to report this ad, but basically only if you're a lawyer.  (You need to either own a trademark being misused - as Windows is here - or read the T&Cs for Google's ad service and find a violation.

I chose "ad takes over the screen" from the close button menu instead, which allegedly flagged the ad for human review. However I saw an identical ad minutes later (on the same site), so the close button doesn't seem to do anything.

So I'm sorry, Ars Technica. I'm not going to feel guilty about disabling Flash (which this ad happens to use) just because you get more money for Flash ads. I'm not going to feel guilty about setting Flash to "click to play", and using a technical mechanism that assumes you were actually doing something important with Flash, that you'd prefer I see "click to play" instead of a fallback image advert. I'm not going to feel guilty about disabling Javascript (which almost all ads use). Or EFF's PrivacyBadger which effectively blocks you until you promise to implement Do-Not-Track. Or Firefox's new project to block third-party trackers (like ads, or at least the targeting that makes them cost-effective).

Nor will I feel guilty about providing AdBlock on people's computers to protect them from fraudulent adverts like this one.

If I use your site regularly I'll start to trust it, and if I don't remember seeing abusive ads on it, I'll make a good-faith effort to unblock you. Personally I will not tolerate attention-grabbing animations, but I can't speak for others and I have cognitive differences.

Sunday, 7 October 2012

Known Linux issues re: Lifetime of low-power USB hard drives

[I originally posted this on the Raspberry PI forum].

This could affect anyone with an ARM computer running *nix and a low-power USB hard drive.  Here's what my drive looked like when I realized I needed to check it. It's been spun up for about half a year:

$ MY_DRIVE_OPTS="-d sat /dev/sda"
$ sudo smartctl -a $MY_DRIVE_OPTS | grep Load_Cycle_Count
193 Load_Cycle_Count        0x0032   109   109   000    Old_age   Always       -       273664


For those not familiar with smartctl, some explanation may be needed.

Monday, 9 July 2012

How to block annoying cookie popups without accepting a cookie

Problem: website cookie notices


I. Some of us don't particularly want random websites to remember us.

I don't particularly care if that means e.g. not remembering my preferred language.  (If I need to, I can always bookmark the English home page). I don't particularly appreciate the modern creeping intrusions on privacy either... But mainly - probably for technical reasons - I just prefer browsing an un-personalized Web.

II. Some of us reject cookies.

Or set them to expire after a short time. Or configure the browser to forget them all when it's closed. 

Friday, 13 January 2012

viewport meta tag: An alternative to "width=device-width"

Update: the viewport guru ppk discovered at least one substantial difference in practice, between the popular "width=device-width" and my ideological preference for "initial-scale=1".  It is described concisely in presentation slides, or you can read the original blog posts.

The viewport meta tag is used in modern "mobile" browsers. (iOS/Safari, Android/Chrome, Mobile Firefox, Opera). It lets developers say "this is a properly-designed website, not desktop-specific crud". Without it, the mobile browsers assume your website is designed with an unspecified min-width, somewhere around 960 pixels.

Many articles about mobile viewports recommend the following approach:
<meta name="viewport" content="width=device-width">
But I have a philosophical objection. I don't like device-width. Hypothetically, if I connect a N900 running Mobile Firefox to a big screen, I won't be using full-screen windows.

Looking at the original Apple documentation, the W3C draft (based on the initial iOS implementation), and the Android and Opera documentation, there's another way:
<!--DISCLAIMER: I HAVE NOT ACTUALLY TESTED THIS.-->
<meta name="viewport" content="initial-scale=1">
This avoids mentioning device-width. The documentation for the mobile browsers say that this is effectively the same as the first approach. But the W3 draft says it's equivalent to this CSS version:
@viewport {
    zoom: 1.0;
    width: auto;
}
And "width: auto" is not defined in terms of device-width. If you can resize the browser window, the content should respond as you'd expect.

In practice, if it's a major problem I'm sure browsers will invent another hack. The current answer is "desktop browsers don't implement @viewport". In the future it might be changed, e.g. to "browsers only apply @viewport if their window is maximized, filling the screen". But it's interesting to anticipate such problems :).

Saturday, 3 December 2011

Moar paranoia: using lower CD speeds for more reliable ripping

paranoia: "Use your CDROM drive to read audio tracks.... and have it actually work right!"

cdparanoia is fine. It's smart enough to work around my (and probably your) imperfect CD drives. But if, like me, you're still curious...

"readom" (nee readcd) has this interesting feature:
-c2scan

              Scans  the  whole  CD  or  the  range specified by the sectors=range for C2
              errors. C2 errors are errors that are uncorrectable after the second  stage
              of  the  24/28  + 28/32 Reed Solomon correction system at audio level (2352
              bytes sector size). If an audio CD has C2 errors, interpolation  is  needed
              to  hide  the  errors. If a data CD has C2 errors, these errors are in most
              cases corrected by the ECC/EDC code that makes 2352 bytes out of 2048  data
              bytes.  The ECC/EDC code should be able to correct about 100 C2 error bytes
              per sector.

              If you find C2 errors you may want to reduce the  speed  using  the  speed=
              option as C2 errors may be a result of dynamic unbalance on the medium.
Very educational, but "speed=" isn't quite reliable.
$ sudo eject; sudo eject -t; sudo readom dev=/dev/cdrom -c2scan speed=4
Read  speed:     0 kB/s (CD   0x, DVD  0x).
Write speed:  9173 kB/s (CD  52x, DVD  6x).
In this case, it looks like readom has set the speed before the drive is ready. It claims this nonsensical "Read speed: 0 kb/s", and then goes ahead to read at full speed. On my drive, using the full 52x with -c2scan causes hard errors (which can cause a very noticeable delay). So let's baby-sit readom and insert a small delay.
$ sudo eject; sudo eject -t; sleep 2; sudo readom dev=/dev/cdrom -c2scan speed=4
Read  speed:  1764 kB/s (CD  10x, DVD  1x).
Write speed:  9173 kB/s (CD  52x, DVD  6x).
And again, the drive spins up to full washing-machine-imitation speed, producing the same errors.

What's happening here is a race condition. When I put a CD in the drive, it automatically spins up, flashing the activity light on the front of the drive. This start-up procedure is racing with readom. In the second case above, readom fails to limit the speed, and reads back the speed used during the start-up procedure. This is either a hardware- or kernel-triggered process. It happens even when udev isn't running.

What we need to do is watch the drive after putting the disk in, and only start readom when the light has stopped flashing. So if you still want to use a script, you can replace the "sleep 2" delay with "read", and hit enter when you think the drive is ready.

In my test, the highest reliable speed seemed to be 24x.
$ sudo eject; sudo eject -t; read; sudo readom dev=/dev/cdrom -c2scan speed=24
Read  speed:  4234 kB/s (CD  24x, DVD  3x).
Write speed:  4234 kB/s (CD  24x, DVD  3x).
Capacity: 256032 Blocks = 512064 kBytes = 500 MBytes = 524 prMB
Sectorsize: 2048 Bytes
Copy from SCSI (0,1,0) disk to file '/dev/null'
end:    256032
addr:   256032 cnt: 18
Time total: 231.759sec
Read 661582.69 kB at 2854.6 kB/sec.
Total of 0 hard read errors.
C2 errors total: 0 bytes in 0 sectors on disk
C2 errors rate: 0.000000% 
C2 errors on worst sector: 0, sectors with 100+ C2 errors: 0

That still doesn't make cdda2wav reliable on my system. However, it does seem that "cdparanoia -S 24" is less noisy in terms of error markers, strange delays, and the worrying washing-machine sound you get when the drive gets up to full speed.

Sunday, 6 November 2011

Fixing up XML well-formedness

You have a lot of text marked up as XML (most likely XHTML). You've edited it by hand, and as a result it's chock-full of errors. Mainly, it's missing closing-tags (or, when you meant to type a closing-tag, you actually typed an opening-tag).

It's easy to find the errors using xmllint. But if you want to fix them, that's a bit cumbersome.

I found emacs worked very nicely. You don't have to use emacs-specific keyboard shortcuts (much :); the current version has friendly menus and standard Gtk dialogues. Just remember not to try and use normal keyboard shortcuts like ctrl-s to save. (Or Alt to bring up menus. If you're addicted to standard keyboard shortcuts, you can use F10 and the arrow keys - this is a less well known standard in GNOME and other CDE/CUA-compatibles).

If you don't see an XML menu, you need to switch to XML mode manually.

M-x xml-mode

(M for "meta", which by default will be the Alt key. So Alt-x, then type "xml-mode" and hit Enter).


Then look in the XML menu. Note the "Next error" command - exactly what we want. Conveniently, if you look to the right, you'll see it's keyboard shortcut: C-c C-n. I.e. Ctrl-c, followed by Ctrl-n. You can keep Ctrl pressed down for both, or not, as you wish.


I used XML->Set Schema->Any Well-formed XML, for a first-pass checking for mismatched tags etc, without bothering about validity against the specific DTD.


You can quickly add missing close-tags, by typing "<", and then C-Enter for auto-completion. (I was obscurely amused to see M-Tab listed as an alternative shortcut. If you don't get the joke, try it yourself in any popular desktop environment; it doesn't do any harm. I didn't realize it myself until I tried it). You may also want Options->Line Wrapping for this buffer->Word Wrap.


I originally tried xmlcopyeditor. In order to change an open-tag to a close-tag, you have to delete the open-tag and then create a fresh close tag. It's not that this takes too long - backspace/delete kills the whole tag at once, and then "

Enabling the Orca Screen Reader manually

If you log into GNOME, you can use Control Center / System Settings to enable Orca. I've played with Orca in the past, and found it very impressive.

Yesterday, I used it to read out a plain text ebook in gedit. But my netbook didn't have room for a GNOME environment as well as my default KDE.

Here's how I enabled Orca for GNOME programs, despite not using a GNOME desktop.


0. Install orca. (ubuntu package gnome-orca). You may also need to make sure you have a speech synthesizer installed, eg. espeak


1. Enable accessibility.

If you don't have the GNOME control center installed, it's still possible to do this manually.

I used gconf-editor to enable the setting /desktop/gnome/interface/accessibility. I suspect that's a bit out of date though. I've also seen this suggested:

gsettings set org.gnome.desktop.interface toolkit-accessibility true


2. export GTK_MODULES=libgail

You need to run this command from a terminal, and then run your GNOME applications from the same terminal.

If you're logged into GNOME, this part is taken care of automatically.