How to support this blog?

To support this blog, you can hire me as an OmegaT consultant/trainer, or you can send translation and project management jobs my way.

Search the site:

Passwords, and time...

AppleScript is here to save you time by automating trivial tasks, but it also can save you money by allowing you to create the small utilities that you'd otherwise not hesitate to spend a few bucks on. Mind you, I have nothing against independent software developers. I just think that if you can learn to do it yourself, you should choose to learn...

It is possible to create passwords on macOS. Open Keychain Access, select "New Password Item" and click on the key shaped icon at the bottom right. You get all sorts of options and end up with a password that you nicely crafted. But really, do we need all that icing? What we need is a robust password that the machine will remember and that you can reinitialize when needed.

Using the system I introduced in the previous post I created this trivially small utility that I can launch any time I need a new password:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

set myPassword to (do shell script "openssl rand -base64 24")
display alert " New password: " & myPassword
set the clipboard to myPassword

The display tells me what the password is, and whatever I do the password is put into the clipboard so that I can paste it right away. To be able to launch this script from Spotlight, I saved it as an application.



Also, there is no "international" clock application bundled on macOS. So here is my way to check that I am on time when I need to deliver a project in a different time zone. Time zones are a problem when you work with different clients in totally different places. I don't need to have the clock running all the time either, I just need to check the time sometimes.

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

set Vancouver_time to ((current date) - 17 * hours)
set Paris_time to ((current date) - 8 * hours)
set Takamatsu_time to (current date)

display alert ("Vancouver:" & " " & time string of (Vancouver_time) & " - " & short date string of (Vancouver_time) & "

" & "Paris:" & " " & time string of (Paris_time) & " - " & short date string of (Paris_time) & "


" & "Takamatsu:" & " " & time string of (Takamatsu_time) & " - " & short date string of (Takamatsu_time))

The format is optional, you can tweak it as you wish.



Et voilà. The AppleScript used here is trivial enough that there is no need for comments. Also I decided to use a different format for AppleScript keywords: I'm using an underline so that I know what the keyword boundaries are. The hint is given in Learn Applescript from Apress. It's very nice to have that visual hint when you read your code.

Popular, if not outdated, posts...

.docx .NET .pptx .sdf .xlsx AASync accented letters Accessibility Accessibility Inspector Alan Kay alignment Apple AppleScript ApplescriptObjC AppleTrans applications Aquamacs Arabic archive Automator backup bash BBEdit Better Call Saul bug Butler C Calculator Calendar Chinese Cocoa Command line CSV CSVConverter database defaults Devon Dictionary DITA DocBook Dock Doxygen EDICT Emacs emacs lisp ergonomics Excel external disk file formats file system File2XLIFF4j Finder Fink Font français Free software FSF Fun Get A Mac git GNU GPL Guido Van Rossum Heartsome Homebrew HTML IceCat Illustrator InDesign input system ITS iWork Japanese Java Java Properties Viewer Java Web Start json keybindings keyboard Keynote killall launchd LISA lisp locale4j localisation MacPort Mail markdown MARTIF to TBX Converter Maxprograms Mono MS Office NeoOffice Numbers OASIS Ocelot ODF Okapi OLPC OLT OmegaT OnMyCommand oo2po OOXML Open Solaris OpenDocument OpenOffice.org OpenWordFast org-mode OSX Pages PDF PDFPen PlainCalc PO Preview programming python QA Quick Look QuickSilver QuickTime Player Rainbow RAM reggy regular expressions review rsync RTFCleaner Safari Santa Claus scanner Script Debugger Script Editor scripting scripting additions sdf2txt security Services shell shortcuts Skim sleep Smultron Snow Leopard Spaces Spanish spellchecking Spotlight SRX standards StarOffice Stingray Study SubEthaEdit Swordfish System Events System Preferences TBX TBXMaker Terminal text editing TextEdit TextMate TextWrangler The Tool Kit Time Capsule Time Machine tmutil TMX TMX Editor TMXValidator transifex Translate Toolkit translation Transmug troubleshooting TS TTX TXML UI Browser UI scripting Unix VBA vi Virtaal VirtualBox VLC W3C WebKit WHATWG Windows Wine Word WordFast wordpress writing Xcode XLIFF xml XO xslt YAML ZFS Zip