Tuesday, September 17, 2024

Spotlight not finding apps

 On my mac running Monterey 12.7.6, Spotlight forgot all about the "printers and scanner" app and others.

Fixed it by issuing the following command:

sudo mdutil -ai on mdutil -Ea

Saturday, July 27, 2024

Tips on Downsizing or How to Throw Stuff Away

 I went to a seminar on how to get rid of all your extra stuff, kinda like Maria Kondo.

Here's the tips I learned:

1. Whenever you buy something, throw something else away.

2. Distribute legacy items now. Don't wait until later to give your kids your grandparents heirlooms and jewelry.

3. But, don't give family heirlooms to people who don't want them.

4. Donate, Donate, Donate - just get rid of all that stuff in your house.

5. Go thru your pantry and throw away expired food. Food started having expiration dates in 1984, so if an item has not expiration date, throw it away.

6. NOK - stands for Next of Kin. Have a folder with all the information for the people you leave behind with all the info they need - names of lawyers, accountants, brokers. And be sure to tell multiple people where that folder is. And where your will is.

7. You can donate art supplies to places like the Austin Creative Reuse organization.

8. Label all your keys.

9. List of friends to invite to your funeral.

10. Nobody wants your stuff - like this trophy from Toastmasters from 1983. Just take a picture of it, tell your family about it, and donate it so it can be disassembled and reused now.



Thursday, October 19, 2023

CostPlusDrugs.com is a winner

 I just picked up a tube of Mometasone Furoate from CVS. Cost me $44.21. I came home and checked on CostPlusDrugs.com. It's on $14.15 for the same amount and strength. Next time I'll wait and check CostPlusDrugs.com and GoodRx.com before having my doctor phone it in to CVS.


Wednesday, September 21, 2022

Best Wordle Words Mathematically

Best Wordle Words Mathematically


TLDR: Best Wordle Words
AROSE
UNTIL
DUCHY
BLIMP
GAWKY



How to select the best words to guess in Wordle?

Here's my strategy:

1.  Find the frequency of letters in words for five letter words:
AESORILTNUDCYMPHBGKFWVQJXQ

2. Now going left to right find words that contain the most frequently used letters.

AESOR ILTNU DCYMPHBGKFWVQJXQ

How to find what words contain AESOR?


We can use the tool "grep" on unix with something like this which finds all five letters words with AESOR.

[Trigger warning: actual unix tools code😱:]

grep "^[a-z]\{5\}$" /usr/share/dict/words | grep a | grep e | grep s | grep o | grep r


One word pops out: “AROSE”.


2. Now look at the letters that are next:

ILTNU DCYMPHBGKFWVQJXQ

Fortunately one word fits the bill, "UNTIL"

3. Looking at the next letters, we don't have a word that contains "DCYMP", so we get as many as we can and then get the next most frequently used letters:

DCYMPHBGKFWVQJXQ


Which produces "DUCHY".

Then the next word is "GAWKY".

Enjoy.

---------------------------------------------------------------------------------------------
PS: A bonus graphic showing probability of letter distribution within a word.
So when you get a "w", it's usually in the first two letters, and a "y" is near the end.

Image



Saturday, September 10, 2022

How to Programmatically Add Tags to Files in OS X on a Mac Using C# Without Libraries

While working on photos, I wanted to programmatically add tags to photos. The tags would be read from a file. I formally used Finder to do this, but it can be tedious for a large universe of tags and there's no record of the association. Here's my solution which is really awkward and brittle. Surely there is a better way. Please add your comments on that way. Until then, I'll use this code.
using System;
using System.Diagnostics;

namespace ImageDescriptions
{
    public class Utilities
    {
        public static string? executeShellCommand(string scriptFile, string arguments)
        {
            var processInfo = new ProcessStartInfo()
            {
                FileName = scriptFile,
                Arguments = arguments,
                UseShellExecute = false,
                RedirectStandardOutput = true,
                CreateNoWindow = true
            };
            string? result = string.Empty;
            Process process = Process.Start(processInfo);   // Start that process.
            while (!process.StandardOutput.EndOfStream)
            {
                result = process.StandardOutput.ReadLine();
                System.Console.WriteLine("result: " + result);
            }
            process.WaitForExit();
            return result;
        }
        /// 
        /// Sets tags on a file in OS X.
        /// This is really awkward and brittle.
        /// 
        /// Comma separated list, e.g., "red,black,green"
        /// file to which we add tags
        public static void SetTags(string? tagCsv, string filename)
        {
            System.Console.WriteLine($"SetTags: '{tagCsv}', '{filename}'");
            var tagXmlString = string.Empty;
            if (tagCsv == null || String.IsNullOrWhiteSpace(tagCsv)) { return; }
            var tags = tagCsv.Split(',');
            foreach (var tag in tags)
            {
                tagXmlString += "" + tag.Trim() + "";
            }
            var scriptFile = "/usr/bin/xattr";
            var arguments = " -w"
               + " com.apple.metadata:_kMDItemUserTags"
               + @" """
               + @" "
               + tagXmlString
               + @" """
               + " " + filename;
            System.Console.WriteLine($"executeShellCommand: {scriptFile}, {arguments}");

            Utilities.executeShellCommand(scriptFile, arguments);
        }
    }
}

Here's a program that reads a data file and then calls "SetTags()":
using ImageDescriptions;

public class ImageDescription
{
    public static void Main(string[] args)
    {
        if(args.Length < 1)
        {
            Console.WriteLine("usage: ImageDescription ");
            Environment.Exit(1);
        }
        string filename = args[0];
        FileStream file = File.OpenRead(filename);

        var lines = File.ReadLines(filename);
        foreach (var line in lines)
        {
            Description description = new Description(line);
            Console.WriteLine(line);
            Console.WriteLine(description);
            Utilities.SetTags(description.tags, description.name);
        }
    }
}

A line from the data file looks like this:
2013-01-23-0702-IMG_8252.jpg "Dessert pie with fruit -tags:dessert,fruit,healthy,pie"

Monday, June 06, 2022

How to find Mac OS tags from the command line

 I'm playing with tags for labeling photos and found this MacOs command to search for all files with a tag, like "awana":

mdfind 'kMDItemUserTags == "Awana"'


By the way macos tags are stored in the binary file '.DS_Store' in the same directory as your files, and as an Extended Attribute (EA) of the file.



Saturday, May 21, 2022

Fixing EXIF Errors in JPEG files like "Error: Bad format (0) for IFD1 entry 0"

I've been working on my greatgrandmother's photos and find jewels from 1910 like this one:

Unfortunately, many of the photos from 110 years ago do not have any names written on the back.

As I think about how to preserve my family's story for the next 110 or 300 years, I'd like to write the description on the back of my digital pictures by injecting EXIF image descriptions into the photos themselves.

To do this I downloaded the free command line tool "exiftool" for my mac.

Then, I added photo captions into jpeg files with this command:

exiftool -imageDescription="My image description" mypic.jpg

but got errors like this:

"Error: Bad format (0) for IFD1 entry 0"

I purchased the tool "metaImage" from the Mac store to add descriptions into the jpeg, but it wouldn't inject the caption into my files. I contacted their tech support and got a quick solution.

Jérémy Vizzini from neededapps.com (creator of "metaImage") solved the problem for me. The issue was my jpeg files were corrupt. (Some of the photos were from 2003, so the EXIF standards may have changed, or not have been rigoriously followed decades ago). Jérémy gave me this snippet of exiftool code to fix the jpeg:

  exiftool -all= -tagsfromfile @ -all:all -unsafe -icc_profile mypic.jpg

This fixed the problem. Thanks Jérémy! Now my jpegs will be ready for the next 300 years.

How do you archive your photos to preserve them for 300 years?