Counting Working Days

Here’s a small problem to think about: how many working days are there in this month or, more generally, between any two dates? “Working days” means Monday through Friday minus holidays. It’s not a hard problem but think how you would solve it. There’s certainly no formula like that for calculating the day of the week on a given date but even consigning yourself to brute forcing the calculation there’s no obvious trivial solution.

Marcin Borkowski (mbork) has an interesting post that details his solution. His solution is for the number of working days in a given month but wouldn’t be too hard to generalize to the number of working days between two arbitrary dates. His method is truly brute force. He pushes the weekend days onto a list, adds any other days off such as holidays occurring during the month, counts the size of the list, and subtracts the result from the number of days in the month. The extra days off are specified manually so that he can add personal days off and account for differences in holidays between countries.

As Mbork says, the real lesson from all this is how flexible Emacs is and what a nice environment it provides for writing little helper functions. Take a look at his post and see if you don’t agree.

Posted in General | Tagged | Leave a comment

An Update On The Copilot Suit

A couple of weeks ago, I wrote about developers threatening a suit against Microsoft/GitHub/Copilot for copyright violations. The issue was that the AI assistant Copilot was “suggesting” code that was an exact copy of copyrighted code without attribution. That post talked about Matthew Butterick, a lawyer and programmer, who was collecting information from developers who felt their rights had been violated by the application.

At that time, a lawsuit was still a tentative outcome but Butterick and his law firm have moved forward and filed a lawsuit against GitHub, Microsoft, and OpenAI for allegedly violating open source licenses. The defendants, of course, are claiming fair use while the plaintiffs are claiming clear violations of their licenses.

Whatever your feelings about this, it’s almost certainly a harbinger of things to come. The issue is that AI systems are being trained on copyrighted material so of course they output results that are arguably copyright violations. If you think Copilot is definitely producing copyright violations, consider things like Dall-E where you describe what you want a picture to be about and it produces something very much like an existing work. Is that a copyright violation? If you’re not a lawyer, it’s a hard question. One thing for sure, the legal system is not (yet) prepared to deal with the question.

Posted in General | Tagged | Leave a comment

Mini Introduction to Elisp

For those of you who are afraid of Lisp—and in particular Elisp—Suraj Kushwah has a short video on Elisp that posits the way to love Emacs is to learn Elisp. I can relate, sort of. I first learned Lisp and then decided to move to Emacs so that I could leverage my Lisp knowledge. It’s worked out well. Kushwah takes the opposite view: if you started with Emacs, you should learn Elisp to learn to love it more.

The video will by no means make you an Elisp master. Its virtue is to show how easy Elisp really is. Like all Lisps, the syntax is trivial. Sure, there’s a couple of corner cases but mostly the difficulty is learning the functions. In that respect, it’s like learning a library—which is what you’re really doing. It’s not syntax, it’s finding out what commands are available.

Kushwah’s video shows how to do just a few things in Elisp and takes the mystery out of it. Mostly, it’s getting used to putting the operator before the operands. Basically, that’s 90% of the syntax. The often despised parentheses become natural once you grok the basic syntax. Paul Graham once described Lisp as forcing the coder to write the syntax graph directly instead of relying on the compiler. That may seem restrictive but once you try it, it turns out to be liberating. Instead of worrying about complex syntax and precedence rules, you simply write what you mean. I’ve reached the point where writing in other languages is chore.

If you’re new to Emacs or Elisp take a look at Kushwah’s video. It won’t make you a master but will give you confidence that Elisp is well within your command.

Posted in General | Tagged , | Leave a comment

Google and Twitter Compared

Manu Cornet worked at Google for 14 years and recently moved to Twitter (he’s since been caught up in the great Twitter purge) and has an interesting discussion of the differences in the companies’ cultures as seen from a staff engineer’s perspective.

The differences aren’t particularly profound and probably reflect Google’s larger size and older age. I’m not sure Cornet would agree but to me it seems as if Twitter is less bureaucratic. Again, that probably reflects smaller size and younger age.

His discussion covers such things as outsourcing, use of open source software, remote friendliness, gender diversity, managerial technical ability, documentation, code ownership, code reviews, and a few other items.

My career was spent mostly with comparatively smaller companies so I always find these sorts of discussion interesting: a peek into another dimension. If you’re interested in different work cultures, Cornet’s discussion is a worthwhile read. It’s not too long so it’s easy to find time for it.

Posted in General | Tagged | Leave a comment

Extracting and Displaying EXIF Information

Álvaro Ramírez continues to roll out new examples of applications for his dwim-shell-command framework. His latest offering is three functions that, given a photo:

  1. Display the EXIF information
  2. Displays the location of where the photo was taken in the minibuffer
  3. Displays the location of where the photo was taken on a map

All the heavy lift is done by ExifTool. As usual with dwim-shell-command functions, the actual functions are just a little glue code that calls ExifTool and displays the results. In the case of displaying the location on a map, the lat/lon is first extracted from the photo by ExifTool and then used in a call to OpenStreetMap in the browser. It works with both macOS and X-based display systems.

The three functions, along with all the others are available in Ramírez’s dwim-shell-commands.el file. They’re all simple and easy to adjust to your particular workflow. Take a look at Ramírez’s latest post for a nice example of the power of this framework.

Posted in General | Tagged | Leave a comment

FSM Diagrams in LaTeX

I’ve written several times about my use and affection for finite state automata in programming. It’s amazing how often it can reduce a complex problem to a triviality. The first stage in taking advantage of this method is to draw a state transition diagram. Once you’ve got the diagram, it’s easy to write the code.

After writing the code, you’ll want to document the program and that will include the state diagram. Traditionally, I’ve used the Graphviz dot program to produce these diagrams but it can also be done directly from LaTeX.

Alexander Hayes has a short post that shows how to use LaTeX to generate FSM diagrams. It’s not a comprehensive tutorial, although he does give a link to one, but it’s still useful for getting an idea of how to produce such diagrams.

Documentation is always a pain, of course, so it’s nice to discover tools that make it easier. Even if you usually write in, say, Org mode, you can still include the requisite LaTeX for the diagrams or you can generate them separately and include the generated diagram in your text.

The nice thing about this solution is that it uses easily available, open source tools that most developers are going to have installed anyway. If you use state diagrams and have to document them, take a look at Hayes’ post.

Posted in General | Tagged | Leave a comment

A Discussion of Markup Languages

Alex Kladov has a post that discusses various markup languages and what makes a great one. He considers

  • Markdown
  • AsciiDoctor
  • LaTeX
  • reStructuredText
  • HTML

He finds them all lacking in various ways. He believes that any markup that’s tied to a particular target language—he puts Markdown is this category, unfairly I think—is already losing. He believes that the parsing (and syntax) of the input language should be decoupled from the target language and the driver that produces it.

If you look at the above list, you’ll notice a glaring omission: Org mode is missing. That’s too bad because Org meets most of the criteria that Kladov calls out. It’s got a simple, lightweight syntax; it’s tree structured; and has a simple format for links, lists, and tables. Perhaps most importantly for Kladov, Org mode markup syntax is not tied to any particular target language. Indeed, there are several targets and new ones are being added all the time. Even with a given target language, Org mode is flexible and extensible. You can mark some text as belonging to a particular environment with the name of your choice and define the semantic meaning of the environment with CSS or a LaTeX environment who definition you can include in a couple of ways. See this post for details.

Of course, ports notwithstanding, Org is mostly tied to Emacs. Much of the simplicity of writing in Org is because of shortcuts built into Emacs. Regardless, if you want the best and most flexible markup language, you should be using Org. Karl Voit makes a strong case that Org is the superior markup language and I certainly agree. It would have been interesting to see Kladov’s take.

Posted in General | Tagged , | Leave a comment

EmacsConf 2022 is Coming

Leo Vivier announces on the Emacs subreddit that the 2022 EmacsConf is scheduled for December 3rd and 4th. The conference will be live streamed so you needn’t travel to participate. Most of us won’t be able to watch the whole thing live but here’s a schedule in case you’re particularly interested in a particular talk.

The conference guide doesn’t say (that I can find) whether or not the recordings of the talks will be available for later viewing but they almost certainly will be. The organizers are promising more information as the conference itself approaches.

UPDATE [2022-11-07 Mon 11:32]: Sacha notes in the comments that they will be posting the videos.

Posted in General | Tagged | Leave a comment

Emacs Modifier Keys in X-Windows

Most Irreal readers know that Emacs offers the Hyper and Super modifier keys for use in keybindings. Less well known is that there is also an Alt key. It’s not the Alt key that appears on most modern keyboards that Emacs usually maps to Meta but a separate modifier. Sadly, we no longer have the Space-cadet keyboard so special effort is required to map them to existing keys. Usually, this means giving special meanings to the right modifier keys and perhaps the Window key if you have one.

This isn’t too hard on macOS but can be tricky under X. Over at Emacs Notes there’s a very nice post that shows you how to use the xkb file to set up all these keys. It’s very fussy but only needs to be done once. After that, you can enjoy the full set of Emacs modifier keys.

In the Emacs Next Step branch there are variables to set up the modifiers so you can simply add them to your init.el, possibly conditionally evaluated, to make your configuration portable to other OS environments.

The utility of doing all this may not be clear but I use Hyper as a modifier for many operations—either existing or homegrown—that aren’t already mapped. Once you have these keys, you’ll find all sorts of uses for them.

Posted in General | Tagged | Leave a comment

The Coverup Begins to Unravel

Irreal has long been suspicious about the back story of COVID-19. As I’ve written before, if you put on your scientific hat, the only possible conclusion is that there’s not yet any definite resolution to covid-19’s genesis. But if you think about it as an intelligent, knowledgeable citizen, the story being flogged by the press and the various governments involved just doesn’t pass the smell test. The unremitting insistence that any explanation other than the zoonotic one was a conspiracy theory and that there was nothing to see, please move on, left even the least cynical of folks wondering what was going on.

Now the coverup is beginning to unravel. Two recent revelations herald the unraveling. The first is a paper by Buttel, Washburne, and VanDongen claiming that an endonuclease fingerprint of the virus indicates that it was synthetic. That means, of course, that the lab leak hypothesis that many felt was the best explanation of COVID-19 is correct. If you know a little biology or chemistry, this article by Anandamide steps you through the analysis and even points you at the SnapGene Viewer tool that helps you with the analysis.

The second is a joint ProPublica/Vanity Fair article that reports on an extensive Senate investigation of documents obtained from Wuhan laboratory that strongly suggests that there was a serious biosecurity breach at the Wuhan labs just prior to the emergence of COVID-19. The story is very complex and involves plumbing the mind numbing depths of Chinese Communist “Party Speak”. Read the article for details. It’s long and complex but worth your attention.

That (even) the U.S. officials responsible for enabling and covering up this debacle will be brought to justice is probably too much to hope for but we can at least hope for an end to the dangerous and probably useless gain-of-function research before it manages to kill us all.

Posted in General | Tagged | Leave a comment