Sunday, January 28, 2024

Two-factor Authentication

How many times a day do you find yourself trying to quickly remember yet another 6-digit code sent via SMS and quickly type it as part of logging in to various sites and services? This is one of those situations where a computer should be more helpful - after all, it KNOWS the code it just received! Why make you memorize it and then type it again?

Took me a lot of Googling to find this solution. While not perfect, it's workable, and I use it daily. Hat tip to "A Better Way to Copy Two-Factor Codes on macOS"

Add this to your .zprofile

2fa(){ sqlite3 "$HOME/Library/Messages/chat.db" "select text from message order by date desc limit 1" | grep -oE '[0-9]{2,}' | pbcopy }

Note that Terminal must be granted Full Disk Access. 

As you can see, this sequence of commands queries your Messages database for the last text message received, then grabs a sequence of numbers from it, and places it on Mac's clipboard, ready for you to paste.

To use, just issue 2fa command (you can certainly call it anything else) in Terminal after receiving that SMS, and - voila! - the code is ready to be pasted (command-V).

Alternatively, place the above command in .command file, do chmod +x, and drag it to the Dock (to the right of the separator). Then just click it once to execute.

Tuesday, September 14, 2021

VirtualBox does not survive macOS updates

Lately, macOS updates break VirtualBox with "Kernel driver not installed (rc=-1908)" error. Not only is this highly annoying and oh-so-expected, but a reasonable solution (that does not involve reboots into Recovery mode, endless uninstalls and reinstalls, etc.) to this error is not terribly easy to find. After some poking around, I came across this and it worked:

1) restart the Mac

2) % sudo /Library/Application\ Support/VirtualBox/LaunchDaemons/VirtualBoxStartup.sh restart

VirtualBox runs fine again. Whew!


P.S. Why am I still bothering with VirtualBox???

Thursday, February 20, 2020

Don't Save

I noticed that the latest version of Microsoft Office applications lost the ability to activate "Don't Save" button on Save dialog boxes with Command+D shortcut. Looks like they are complying with a rather long-term change in the MacOS to a new shortcut - Command+Delete. Well, I can't very well use that shortcut with my left hand which is really used to hitting Command+D by now, can I? Some googling revealed a solution. See https://osxdaily.com/2011/08/15/return-the-dont-save-keyboard-shortcut-to-commandd-in-mac-os-x-lion/ for details. Issue the following command in Terminal to get your Command+D back:
defaults write NSGlobalDomain NSSavePanelStandardDesktopShortcutOnly -bool YES
Voila, no need to retrain myself!

Friday, January 3, 2020

Using AppleScript for a Complicated Apple Mail Rule

My son's daycare sends us an e-mail with a link to pictures they take of kids during the day. It's adorable. I like to forward this e-mail to both sets of grandparents. One small problem - he only goes there 3 days per week, but e-mails arrive daily. Mission - avoid spamming the grandparents. The daycare used to put the day of the week in the Subject line and that made it very easy to set up rules in the Mac Mail app to handle the automatic forwarding. Lately, all Subjects are the same. So, AppleScript to the rescue - forward the message only if it arrives on specified days of the week. Disclaimer - I do not know AppleScript. Not even a little bit. So it's a lot of Googling and trial and error to get these occasional scripting attempts of mine to work. Here's what I cobbled together:


using terms from application "Mail"
on perform mail action with messages these_messages for rule theRule
repeat with eachMessage in these_messages
set theDate to the date received of eachMessage
set theWeekday to weekday of theDate
--display alert (theWeekday)
if theWeekday = Monday or theWeekdayWednesday or theWeekday = Friday then
tell application "Mail"
set addressList to {"user1@yahoo.com", "user2@gmail.com"}
set theMessage to forward eachMessage --with opening window
tell theMessage
repeat with i from 1 to count addressList
make new to recipient at end of every to recipient with properties {address:item i of addressList}
end repeat
delete bcc recipients
delete cc recipients
end tell
send theMessage
end tell
end if
end repeat
end perform mail action with messages
end using terms from

Save the script to ~/Library/Application Scripts/com.apple.mail and set up a rule in Mail app with "Run AppleScript" action pointing to this script.

Tidbits to note: the if statement checks whether the message was received on specific weekdays I am interested in; I had to use a list ("addressList") and subsequently iterate over it to accommodate multiple recipients. 



Wednesday, October 30, 2019

If macOS 10.15 Catalina (and also 10.15.1, unfortunately) broke your ability to connect to certain Wi-Fi access points because the captive portal (splash page) does not appear, manually launching /System/Library/CoreServices/Captive Network Assistant seems to help. Thanks https://poweruser.blog/macos-catalina-wifi-issue-captive-portal-broken-45610cc016b5 for the suggestion!

Wednesday, December 6, 2017

VirtualBox "Wrong SSL Certificate Format" Error

VirtualBox (v5.2.2 as of this writing) on my Mac (MacOS 10.13.1) frequently fails to check for updates, etc. with the following error message: "Wrong SSL Certificate Format." I looked around periodically but could not find a solution. Until I stumbled on this: replace ~/Library/VirtualBox/vbox-ssl-cacertificate.crt with content from https://www.virtualbox.org/attachment/ticket/12340/vbox-ssl-cacertificate.crt Problem solved. Finally!

Wednesday, January 4, 2017

Wish List for Apple in 2017

Everyone is writing about what to expect or what they would want in the world of tech and gadgets in 2017. Here are my wishes for Apple:


  • Cool new iPhone - new camera, better/bigger screen. Need a reason to upgrade from 6
  • iOS improvements - simpler lock screen (iOS 10 really bungled it up), more intelligence, more customization (preference for maps, browsers, etc.)
  • Photo management is appalling! All I want is a single place (cloud) where all of the family's photos will end up. Is that too much to ask???
  • Free storage for backups. Do not make me pay $3/month - it's not cool
  • Music in iOS automatically blares the first song in alphabetic order when I connect the phone to car's media interface. Mine happens to be "ABCs" from "Baby Loves Jazz" album. Super annoying! Can I choose some other behavior to be the default instead?
  • iOS/Apple TV - need to support multi-user login. Why is Apple TV stuck with my kid as the only user???
  • MacBook Pro 2016 is slow and expensive. TouchBar seems unnecessary. Meh... I want a better laptop to replace mine from 2014. Could it be a tablet? Perhaps...
  • Continue freeing us from wires. Bluetooth earbuds - good (but VERY expensive). Wireless charging, please!
  • Siri has a LONG way to go on accuracy of recognition for speakers with [HHHeavy Russian] accent
  • Either miniaturize key Apple Watch components (heart rate monitor, Taptic engine, etc.) and stick them into rings/bracelets/third-party watches/phone/etc., or make a MUCH better-looking watch (like, making it round might be a good start).
  • Where is Augmented (or mixed)/Virtual Reality?
  • Home AI... Learn from Mark Zuckerberg's 2016 project. Need voice pickup/speaker/camera/WiFi/other sensors in each room + a bunch of AI-based features. 


And while I am at this...


  • Google - make Maps smarter. When I open the app in the morning, take a wild guess and offer "work" as the destination automatically, please (Apple's maps do that, but the navigation is - well, you know). Also, can you please add speed limit info? 


  • Wireless service providers - give up on data caps already. You know it's going to happen eventually - just do it already! Unlimited talk + unlimited data. Let's go!


  • Amazon - make Prime Video app for Apple TV. Your app on my TiVo does nothing to enhance my enjoyment of The Grand Tour. Quite the opposite!


  • Dunkin Donuts - please make your loyalty card available for Apple Pay. You promised this over a year ago. What gives?


  • Everyone - can we ditch the passwords already? Pretty please? How about some biometrics instead? Fingerprints, iris scans, face recognition, voice recognition, whatever... 


  • Anyone - see the last bullet regarding home AI in my Apple wish list. Make a device in the shape of a light bulb that combines all these features. One for each room for easy retrofitting!