A Test for the Iron Law

If you’ve been around Irreal for a while, you know about the Iron Law of Data Collection. Briefly, the law says that anytime data is collected

  1. No matter the rationale and promises about the data collection and the purposes to which it will be put, it will invariably find new uses as interested parties demand access to it.
  2. Eventually, the data will be abused.

Usually when I write about the Iron Law it’s after the fact: the data has been collected and the mission creep and abuse have already begun. This time, the London Metropolitan Police has provided us with an opportunity to test the law ab initio. The Met has announced plans to implement facial recognition cameras on London’s streets as part of a plan to catch serious criminals.

Civil libertarians are not amused but despite their vigorous objections the Met is going ahead with its plans. They claim the system is 70% accurate so, apparently, there’s no reason for alarm. Independent studies of the system, however, found it to be about 19% accurate.

That’s one data point. Here’s another:

The Met has made promises to the mayor of London, Sadiq Khan, after an
independent ethics review raised concerns over its earlier trials of
facial recognition software. The system will not be linked to other
official databases.

That very specific. We will not make this data available to be used with other databases. The Iron Law predicts that of course it will be made available to those other databases eventually and that it will be abused by, say, being used to identify law abiding citizens legally protesting government actions. Time will tell, of course, but I know which way I’m betting.

Posted in General | Tagged | Leave a comment

Finding The Intersection of Two Lists

I recently saw an Emacs Stack Exchange Question on how to find the intersection of two lists. The questioner asked if there was a better way than the obvious solution of looping over both lists looking for matches, a \(O(mn)\) solution for lists of size \(m\) and \(n\). The “best” solution was to use the Elisp function seq-intersection, which accomplishes the task in one function call but that under the covers loops over both loops giving it \(O(nm)\) performance

My first thought when I saw the question was to use a hash table to capture the items in the first list and then check the second list against the hash. That would be a \(O(n+m)\) solution but, of course, the multiplicative constants would be much bigger for \(O(n+m)\) than for \(O(nm)\). My gut feeling was that the hash table solution would be a bit faster but as my experiments with palindrome predicates showed, my gut is not particularly reliable.

The only answer was to run some benchmarks. I wrote a bit a Elisp to generate a couple of random lists and a function to find their intersection using the hash table method. The hash-intersection function is pretty simple. It adds each entry of the first list to a hash table with a value of t. Then it checks each entry in the second list to see if it’s in the hash table.

(defun make-random-list (n)
  (let ((l nil))
    (dotimes (i n l)
      (push (random 1500) l))))

(defconst lst1 (make-random-list 1000))
(defconst lst2 (make-random-list 1000))

(defun hash-intersection (l1 l2)
  (let ((ht (make-hash-table :test #'equal))
        (acc nil))
    (mapc (lambda (x) (puthash x t ht)) l1)
    (mapc (lambda (x) (if (gethash x ht nil)
                          (push x acc)))
          l2)
    acc))

Then I ran benchmarks that called hash-intersection and seq-intersection 100 times on the two lists. The benchmark-run macro reports total running time, the number of garbage collections, and the time taken by garbage collection.

(benchmark-run 100 (hash-intersection lst1 lst2))
0.081114 0 0.0
(benchmark-run 100 (seq-intersection lst1 lst2))
8.2707 0 0.0

As you can see, there was no garbage collection. Surprisingly, the hash-intersection function was about 100 times faster, which is much faster than I expected. I thought there might be garbage collection with the hash table method but there wasn’t—perhaps there would be with larger lists.

Regardless of the garbage collection results, the hash table method certainly takes more memory. Even so, the speed results suggest that for most reasonable inputs, the hash table method is a good choice. With shorts lists of 8 elements, both methods took about a microsecond for a single run so there doesn’t appear to be a penalty for short lists either.

Posted in General | Tagged , | Leave a comment

Org Mode 9.3.2

Bastien writes that Org Mode 9.3.2 has been released. It’s a bug release so no new features but if you are experiencing problems with Org, you should consider upgrading. Even if you aren’t seeing problems, it’s probably a good idea to update.

Correction

In Sunday’s post on Undo Region, I said that selective undo did not appear to work with undo-tree. One of Irreal’s intrepid readers, hjmr, discovered that it did work in older versions of undo-tree and that in the latest version it still works but you have to enable it. I’ve added an update to the Undo Region post that gives the spell for making it work but because there appears to be a lot of interest in selective undo, I wanted to make sure all of Irrealdom knows that you can use it with undo-tree.

Posted in General | Tagged , | Leave a comment

Another Great Example of Recursion

Remember how I told you that Joe Marshall was really good at coming up with elegant examples of recursion? He’s back with another. This time it’s not one he thought up but it’s too good not to share.

Here’s the problem: You have a server that you can query for time-stamped records by specifying a begin and end date. The problem is that the server will return (only) an error if the number of records you request is too large. There’s no way to tell, a priori, how many records exist between any two dates. How do you write the client?

Marshall offers a beautiful recursive solution that solves the problem in 10 lines of—I guess—Java (I’m not a Java maven so I’m not sure). It’s very much worthwhile reading and understanding the example so you can add the trick to your toolkit.

Marshall’s larger point is that often people are afraid of and resist recursive algorithms but they shouldn’t be. It’s not always the right solution but it is for many problems and usually results in a simple and easy-to-understand solution. As Marshall says, one can imagine solving the above problem without recursion but that solution would be more complicated and probably harder to maintain.

I learned to use and appreciate recursion from reading Paul Graham and it’s amazing how often I’ve been able to amaze my colleagues with a nice recursive solution to some problem. If you’re not comfortable with recursion, you should try to fix that.

Posted in General | Tagged | Leave a comment

Undo Region

Here’s an Emacs feature that I—and, apparently, many others—didn’t know about:

That’s a fantastic time and effort saver when you want to undo a change that’s not at the tip of your undo tree.

Sadly, as far as I can tell, it doesn’t work with undo-tree, a package that I’m not willing to give up. For those of you not using undo-tree, you should try this out. It’s built into the Emacs undo system so there’s nothing to install.

According to the Emacs Manual, if you aren’t in Transient Mark mode you will need a prefix argument to undo. If, like most people these days, you are using Transient Mark mode, you won’t need the prefix argument.

Update [2020-01-27 Mon 12:03]: Hjmr reports that it will work with undo-tree if you set undo-tree-enable-undo-in-region to t. I’ve verified that this works so we can have the best of both worlds: undo-tree and selective undo.

Posted in General | Tagged | Leave a comment

Surprise! Online Advertisers Are Breaking The Law

According to a report by Forbrukerradet—which I think is the Norwegian Consumer Council—online advertisers are ignoring the GDPR and continuing to track consumers and build profiles of them. The report, linked above, and the technical addendum are both quite long (193 and 93 pages respectively) and detail how Android apps are continuing to send Advertiser IDs and other personal data—including precise GPS coordinates—to third parties.

One particularly disturbing revelation is that the Grindr app, a dating app for gay, bi, and trans, people was collecting personal and sensitive information from its users and sending it to numerous third parties. The report devotes 39 pages to Grindr and its data sharing.

The report includes a legal analysis that concludes the advertisers are in breach of the GDPR in significant ways. As I’ve said before, the problem is that there’s so much money in adtech and its abuse that rouge companies are making the calculation that it’s worth the risk of cheating and that they’ll just pay the fine if they get caught. And, of course, go right on violating the law. There needs to be harsh individual penalties for people involved not just their companies. Until that happens, expect more of the same.

Posted in General | Tagged , | Leave a comment

Makefiles for Elisp

Chris Wellons has another great post over at Null Program. This post discusses how he uses makefiles to build his Emacs packages. If you’re like most Elisp programmers, you probably write only small bits of Elisp to add to your init.el and, of course, that doesn’t require a makefile.

Wellons, on the other hand, is writing Emacs packages for others to use. The majority of those consist of a single file but there’s still a good reason to use a makefile. In the first place, Wellons has tests for his packages and he has rules to run those tests in the package’s makefile. That makes it easy to run the tests after every update. The other issue is subtler but still important. As Wellons says, the Elisp compiler may be dumb but it does do static analysis and it’s a useful way of finding problems before they manifest themselves at run time. Therefore, the default rule in his makefiles is to compile the Elisp files.

Most of the post documents the conventions that he uses in his makefiles. He shows the Makefile for each of his projects so you can see real examples of what he does. The other important point is that Wellons makes a point of writing portable makefiles. That means they will work with any make adhering to the POSIX make standard, not just GNU make. If you’re writing software that will be used in a variety of Unix/Linux systems, this can make your life a lot easier because you can use the system make rather than installing GNU make.

Besides serving as a good example of using makefiles for Elisp projects, Wellons’ post is also a nice tutorial on makefiles. If you don’t know anything about make, it won’t help you much but if you’re an occasional user, it’s an excellent reminder of the important points. If you’re a beginner, you should check out his make tutorial.

If you’re writing Emacs packages or you’re just in need of a booster shot for your make-foo, this post is definitely worth your time. As usual, Wellons presents useful information in an interesting way.

Update [2020-01-24 Fri 14:26]: find → finding

Posted in General | Tagged , | Leave a comment

Another Victory in the Walletless Crusade

As you regular readers know, I’m always in search of ways to minimize the things I have to carry around and, in particular, to avoid carrying a wallet with the cash and credit cards that goes with it. My main strategy has been to move as much of my wallet as I can into my iPhone. Other than my driver’s license, which Florida is still dragging its feet on, I’ve pretty much completed that process.

It turns out, though, that’s there’s another possibility. Sirius and Visa are collaborating to let your car pay for gas, tolls, and food. The idea is that your in-car digital interface would act like, say, Apple Pay to let you pay digitally for your gas or food.

My first thought was why would I want this when I already have my smartphone but then I realized it could be useful in certain use cases. It’s hard to use your smartphone in a fast food drive-through but this system promises to make that easy. Look at it as another arrow in your quiver. It enables another way of paying with a minimum of mess and fuss. You don’t even have to get out of your car. Or pull your smartphone out of your pocket. As the article says, this could be the end of our fumbling for our credit cards when we want to gas up or grab a burger at our local fast food drive-through.

Posted in General | Tagged | Leave a comment

Karl Voit on Starting to Use Org-mode

Karl Voit has a nice post in his Using Org Mode Features series. It’s advice on how to start using Org-mode. Org-mode is large and complicated and can seem intimidating. That leads many people to start with someone else’s configuration. I did that and can testify that it’s a big mistake.

I was completely awed by Bernt Hansen’s Org Mode – Organize Your Life In Plain Text!. I thought it was brilliant and wanted to recreate his wonderful workflow for myself. It didn’t work out well. I had all these capabilities enabled and didn’t understand how to use any but the simplest.

That brings us to to Voit’s first point: start simple. I always advise people to start out with just headers, lists, and tables and to add other features as you find you need them. Whatever you need is almost certainly there but there’s no point in enabling it and adding the extra complexity until you really need it. Voit agrees with that and his own list of things to start with is similar to mine. The point, though, is to start with a minimal set of features.

Voit also suggests starting out with a single file. That’s really good advice. It’s easy to add new files later if you need them but it’s really hard to combine several files into one if you discover that’s your best strategy. This is in keeping with Voit’s advice to not overthink your file structure. It’s certainly going to change as your workflow does so your best strategy is to hone it as you go along rather than trying to get it perfect from the beginning.

Voit also discusses learning Org, discovery, and the Org-mode community. It’s a good post and definitely worth reading if you’re thinking about starting to use Org or are just beginning your journey.

Posted in General | Tagged , | Leave a comment

Digital Inheritance

I know all you readers think you’re going to live forever—and if you’re young enough that might even be (approximately) true—or you at least think it’s way too early to be thinking about wills and other such unpleasant matters. Nonetheless, things happen: you could contract a deadly disease, get hit by a bus, or have your life cut short by any number of other things.

If you’re reading Irreal, the chances are you have a rich digital life and that much of your data having monetary or sentimental value is stored online. If something did happen to you, would your family be able to access that data? What about your online accounts? Your investment and insurance data? Your blog or social media accounts? A recent issue of Sans’ Ouch! Newsletter addresses the issue of Digital Inheritance and the steps you should take to ensure that your family and loved ones will have access to your digital life after you’re gone.

It’s a useful exercise to spend 10 minutes listing your digital assets and taking note of which ones you would like to be available to your family if something happened to you. You’ll probably be surprised at how many there are. I know I was.

The Ouch! article is short and definitely worth taking a minute or two to read even if you’re sure you are going to live forever.

Posted in General | Tagged | Leave a comment