Computers and Code

A collection of posts related to Coding, Programming, Hacking and Computer Tricks.

Take a look and enjoy

Restarting Finder or Dock in macOS

It is sometimes needed to restart the Finder or Doc in macOS. Usually you can do this with the following command in the terminal:

> killall Finder

Some times you may get the following response "No matching processes belonging to you were found”. If that is the case, another command you may want to try in your terminal is the following

> launchctl stop



Get the "hello" screensaver on your mac

You may have seen the shiny new 2021 iMac with the new exciting colours, actually a bit reminiscent of the iMac G3 from 1988 or "The Macintosh that Saved Apple".

The new iMac comes with a new screensaver that also gives a shout to the iconic 1984 "hello" font used to introduce the Macintosh.

You don't have to have a new iMac to enjoy the screensaver. Here are some steps you can follow:

  1. Navigate to the following directory:

/System/Library/Screen Savers/

2. You will need to be running macOS Big Sur 11.3 or higher, and if so you will find a file called Hello.saver - Drag or copy that file to your Desktop

3. In your Desktop, please rename the file to something like Hello1.saver. This step is required because the file already exists...

4. Double click on the newly renamed file and you will be prompted to install the screensaver. Simply follow the instructions.

5. Et voilà! You can now select the screensaver from System Preferences > Desktop & Screen Saver.


white and black weekly planner on gray surface

Remove Unwanted Google Calendars

white and black weekly planner on gray surface
Photo by Bich Tran on

I have been using GSuite in the last year or so at work. In general it seem to be fine, good usage of the email capabilities provided by Gmail and the storage, together with shared drives, and things like that are fine.

Calendar is ok and it does the work, however there was a very irritating thing when being invited to see other colleague's calendars and/or subscriptions to them. On the one hand it is useful to see calendar availability, but I don’t want to see all of those calendars on my mobile device, or the Calendar app on my Macbook all the time.

A quick solution would be to “uncheck” the unwanted calendars on your device, but... The problem is, when you uncheck those calendars, they’re still there. You may not see them, but boy, you do continue getting reminders, notifications, alerts - and most (all?) of the time they are not even for me to act on!

So if you require to remove these extra calendar, bit still access then via the web and Google apps then do the following:

  1. Go to
  2. Login to your Google Account, and
  3. Uncheck the calendars you don't want to sync

Then you can select what device you may want to be able to see the delegated calendars in the Apple Calendar app. Simply

  1. Go to Calendar - Preferences
  2. Select Account Information and look for the Google Account in question
  3. Select the "Delegation" tab and check the things you may want to see (or not)

Et voilà!


Importing Organised Picture Folders to Apple Photos

I have been considering moving a considerable photo collection I have amassed for a few years now after getting my first digital camera. I used to take a lot of pictures before that with a beloved Cannon SLR that belonged to my father. Sadly that camera got stolen in a holiday in Cancun... but that is a story for another time.

Anyway, I used to use Picasa to organise my photos into albums and upload or share some with friends and family. Picasa was superseded by Google Photos and I never quite liked losing some control on where my photos went.

I have been an iOS user of Apple Photos -- I like the simplicity of taking a picture and it being part of an album that I keep in my phone until I clean the album... I did try using the Mac version, but as I said I never liked just getting a soup of pictures. I wanted to keep them in the album/folder hierarchy I curated myself. It is until now that I have found a way for Apple Photos to respect my hierarchy. Here is what you need to do:

  1. Find the place where your pictures are organised folders and drag the top folder onto the Photos App icon in the Dock. It does not matter if the App is running
    • NOTE: Do not drag it to the Photo App window. If you do, the applications behaves in a different way and you will end up with a soup of photographs.
  2. At the top of the window you will see a checkbox that reads “Keep Folder Organisation” on the top right (see the screenshot above)
  3. Click the blue button, “Import All New Items”

Et voilà! Your imported photos will show up in an organised folder in the sidebar.


Sci-Advent - Writing Reports Tailored for AI Readers

This is a reblog from an article by John Naughton in the Guardian on Dec 5th 2020. Read the original here.

My eye was caught by the title of a working paper published by the National Bureau for Economic Research (NBER): How to Talk When a Machine Is Listening: Corporate Disclosure in the Age of AI. So I clicked and downloaded, as one does. And then started to read.

The paper is an analysis of the 10-K and 10-Q filings that American public companies are obliged to file with the Securities and Exchange Commission (SEC). The 10-K is a version of a company’s annual report, but without the glossy photos and PR hype: a corporate nerd’s delight. It has, says one guide, “the-everything-and-the-kitchen-sink data you can spend hours going through – everything from the geographic source of revenue to the maturity schedule of bonds the company has issued”. Some investors and commentators (yours truly included) find the 10-K impenetrable, but for those who possess the requisite stamina (big companies can have 10-Ks that run to several hundred pages), that’s the kind of thing they like. The 10-Q filing is the 10-K’s quarterly little brother.

The observation that triggered the research reported in the paper was that “mechanical” (ie machine-generated) downloads of corporate 10-K and 10-Q filings increased from 360,861 in 2003 to about 165m in 2016, when 78% of all downloads appear to have been triggered by request from a computer. A good deal of research in AI now goes into assessing how good computers are at extracting actionable meaning from such a tsunami of data. There’s a lot riding on this, because the output of machine-read reports is the feedstock that can drive algorithmic traders, robot investment advisers, and quantitative analysts of all stripes.

The NBER researchers, however, looked at the supply side of the tsunami – how companies have adjusted their language and reporting in order to achieve maximum impact with algorithms that are reading their corporate disclosures. And what they found is instructive for anyone wondering what life in an algorithmically dominated future might be like.

The researchers found that “increasing machine and AI readership … motivates firms to prepare filings that are more friendly to machine parsing and processing”. So far, so predictable. But there’s more: “firms with high expected machine downloads manage textual sentiment and audio emotion in ways catered to machine and AI readers”.

In other words, machine readability – measured in terms of how easily the information can be parsed and processed by an algorithm – has become an important factor in composing company reports. So a table in a report might have a low readability score because its formatting makes it difficult for a machine to recognise it as a table; but the same table could receive a high readability score if it made effective use of tagging.

The researchers contend, though, that companies are now going beyond machine readability to try and adjust the sentiment and tone of their reports in ways that might induce algorithmic “readers” to draw favourable conclusions about the content. They do so by avoiding words that are listed as negative in the criteria given to text-reading algorithms. And they are also adjusting the tones of voice used in the standard quarterly conference calls with analysts, because they suspect those on the other end of the call are using voice analysis software to identify vocal patterns and emotions in their commentary.

In one sense, this kind of arms race is predictable in any human activity where a market edge may be acquired by whoever has better technology. It’s a bit like the war between Google and the so-called “optimisers” who try to figure out how to game the latest version of the search engine’s page ranking algorithm. But at another level, it’s an example of how we are being changed by digital technology – as Brett Frischmann and Evan Selinger argued in their sobering book Re-Engineering Humanity.

After I’d typed that last sentence, I went looking for publication information on the book and found myself trying to log in to a site that, before it would admit me, demanded that I solve a visual puzzle: on an image of a road junction divided into 8 x 4 squares I had to click on all squares that showed traffic lights. I did so, and was immediately presented with another, similar puzzle, which I also dutifully solved, like an obedient monkey in a lab.

And the purpose of this absurd challenge? To convince the computer hosting the site that I was not a robot. It was an inverted Turing test in other words: instead of a machine trying to fool a human into thinking that it was human, I was called upon to convince a computer that I was a human. I was being re-engineered. The road to the future has taken a funny turn.


Getting Answers for Core ML deployment from my own Book

I was working today in the deployment of a small neural network model prototype converted to Core ML to be used in an iPhone app.

I was trying to find the best way to get things to work and then it occurred to me I had solved a similar issue before... where‽ when‽ aha!

The answer was actually in my Advanced Data Science and Analytics with Python.


Computer Programming Knowledge

I came across the image above in the Slack channel of the University of Hertfordshire Centre for Astrophysics Research. It summarises some of the fundamental knowledge in computer science that was assumed necessary at some point in time: Binar, CPU execution and algorithms.

They refer to 7 algorithms, but actually rather than actual algorithms they are classes:

  1. Sort
  2. Search
  3. Hashing
  4. Dynamic Programming
  5. Binary Exponentiation
  6. String Matching and Parsing
  7. Primality Testing

I like the periodic table shown at the bottom of the graphic. Showing some old friends such as Fortran, C, Basic and Cobol. Some other that are probably not used all that much, and others that have definitely been rising: Javascript, Java, C++, Lisp. It is great to se Python, number 35, listed as Multi-Paradigm!



LibreOffice - Dialogue boxes showing blanks

I have been using LibreOffice on and off for a few years now and generally I think it is a great alternative to the MS Office offering. It does the tasks that are required and the improvements over different versions have been steady and useful

I had however a very strange experience in which dialogue boxes and other windows such as alerts and messages just showed blank text. It was obvious that there was some important information in them, but it was not possible to read them. In some cases it was ok... I mean I knew here the "OK" button was expected to appear, or where "Cancel" should be placed. However, it was an annoying (at best) and limiting (at worst) exoperience.

After digging in a bit I realised what the problem was. The fonts that were supposed to be showing were at fault. The culprits were as follows:

  • DINRegular.ttf, and
  • DINRegularAlternate.ttf

After removing these two fonts from ~/Library/Fonts/ everything went back to normal. I hope this helps in case you are having a similar issue.


MacOS - No Floating Thumbnail when taking a screenshot

Have you tried taking a screenshot in your Mac and are annoyed at having to wait for the floating thumbnail - in other words you wait for 5 seconds before the screenshot becomes a file? Well here you can find out how to get rid of that.

Follow these steps:

1) Type CMD + SHIFT + 5
2) Click OPTIONS
3) Uncheck "Show Floating Thumbnail"
4) Et voilà!

See the screenshot above!


Adding new conda environment kernel to Jupyter and nteract

I know there are a ton of posts out there covering this very topic. I am writing this post more for my out benefit, so that I have a reliable place to check the commands I need to add a new conda environment to my Jupyter and nteract IDEs.

First to create an environment that contains, say TensorFlow, Pillow, Keras and pandas we need to type the following in the command line:

$ conda create -n tensorflow_env tensorflow pillow keras pandas jupyter ipykernel nb_conda

Now, to add this to the list of available environments in either Jupyter or nteract, we type the following:

$ conda activate tensor_env

$ python -m ipykernel install --name tensorflow_env

$ conda deactivate

Et voilà, you should now see the environment in the dropdown menu!


Python - Pendulum

Working with dates and times in programming can be a painful test at times. In Python, there are some excellent libraries that help with all the pain, and recently I became aware of Pendulum. It is effectively are replacement for the standard datetime class and it has a number of improvements. Check out the documentation for further information.

Installation of the packages is straightforward with pip:

$ pip install pendulum

For example, some simple manipulations involving time zones:

import pendulum

now ='Europe/Paris')

# Changing timezone

# Default support for common datetime formats

# Shifting

Duration can be used as a replacement for the standard timedelta class:

dur = pendulum.duration(days=15)

# More properties

# Handy methods
'2 weeks 1 day'

It also supports the definition of a period, i.e. a duration that is aware of the DateTime instances that created it. For example:

dt1 =
dt2 = dt1.add(days=3)

# A period is the difference between 2 instances
period = dt2 - dt1


# A period is iterable
for dt in period:

Give it a go, and let me know what you think of it. 


File Encoding with the Command Line - Determining and Converting

With the changes that Python 3 has brought to bear in terms of dealing with character encodings, I have written before some tips that I use on my day to day work. It is sometimes useful to determine the character encoding of a files at a much earlier stage. The command line is a perfect tool to help us with these issues. 

The basic syntax you need is the following one:

$ file -I filename

Furthermore, you can even use the command line to convert the encoding of a file into another one. The syntax is as follows:

$ iconv -f encoding_source -t encoding_target filename

For instance if you needed to convert an ISO88592 file called input.txt into UTF8 you can use the following line:

$ iconv -f iso-8859-1 -t utf-8 < input.txt > output.txt

If you want to check a list of know coded characters that you can handle with this command simply type:

$ iconv --list

Et voilà!



IEEE Language Rankings 2018

Python retains its top spot in the fifth annual IEEE Spectrum top programming language rankings, and also gains a designation as an "embedded language". Data science language R remains the only domain-specific slot in the top 10 (where it as listed as an "enterprise language") and drops one place compared to its 2017 ranking to take the #7 spot.

Looking at other data-oriented languages, Matlab as at #11 (up 3 places), SQL is at #24 (down 1), Julia at #32 (down 1) and SAS at #40 (down 3). Click the screenshot below for an interactive version of the chart where you can also explore the top 50 rankings.

Language Rank

The IEEE Spectrum rankings are based on search, social media, and job listing trends, GitHub repositories, and mentions in journal articles. You can find details on the ranking methodology here, and discussion of the trends behind the 2018 rankings at the link below.

IEEE Spectrum: The 2018 Top Programming Languages


Building things with Python

Very pleased to see some of the things we are building with the Intro to Python for Data Science class this evening.


Finding iBooks Files in My Mac

I was looking for the location of iBooks files (including ePub, PDFs and others) so that I can curate the list of manually exported files. Finding iBooks in my Mac should not be a difficult task, although it took a few minutes. I thought of sharing that here in the blog for future reference and in the hope that some of yo may find it useful.

We will use the Terminal, as doing things from Finder tends to redirect us. A first place to look into is the following one:


Now, that may not be the entire list of your books. In case you have enabled iCloud, then things may be stored in your Mobile Documents folder:

cd ~/Library/Mobile Documents/iCloud~com~apple~iBooks/Documents/

For things that you have bought in the iBooks store, take a look here:

cd ~/Library/Containers/

Et voilà!



Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: