3 ms·
I use AppleScript frequently, and one of the reasons I can't bring myself to move to Linux is because of the excellent API into every app. Somehow "hey" just d
by peterburkimsher 9y ago
I use AppleScript frequently, and one of the reasons I can't bring myself to move to Linux is because of the excellent API into every app.
Somehow "hey" just doesn't seem to offer the ecosystem that AppleScript does. Even though I really don't like the latest versions of macOS and iOS, I still prefer the old Apple ecosystem to the fragmented platforms of Windows and Linux (or Haiku).
- adamnemecek 9y agowhat exactly do you script with it if i may ask?
- peterburkimsher 9y agoMostly text processors. Bash scripting doesn't always handle Unicode nicely. For Pingtype ( https://pingtype.github.io https://pingtype.github.io ) I need data in Chinese. I get that from websites. Sometimes I can download it with curl, other times I need to tell Safari to get the source for me. Language syntax like "every paragraph" and "set applescript's text item delimiters to" are much easier to handle than str.split() and IFS. File reading and writing are easy. Getting and setting track data in iTunes is easy. Finding selected items in the Finder is easy. I've been using more "do shell script" recently as my knowledge of command-line tools increases. It's slower to run than other languages, but when I just want a quick one-off script to generate some data, it's faster for me to code it in AppleScript instead of spending hours debugging it in another language. All my processing for PlinyPedia ( http://peterburk.github.com/pliny http://peterburk.github.com/pliny ) was in AppleScript - splitting the XML into separate files grouped into folders, naming those folders, moving the footnotes to the bottom and adding links to quickly move up and down, and finally generating a basic iUI interface. I also wrote scripts to transpose chord progressions to Roman Numerals by looking up the values in a table, select cells diagonally in Excel, and turn my Facebook friends list into an iTunes database. (The iTunes database is URL tracks that trigger a PHP script running locally that opens Safari with the URL - it's basically a bookmarks manager with Smart Playlists. If you can recommend a better database, please do.)
- petre 9y agoSounds like a good usage case for Perl rather than bash. The former has good Unicode support and you can use the standard lib + Mojolicious to fetch data from the web and serve other data to Safari. No need for bash + command line tools + PHP + web server.
- peterburkimsher 9y agoI'm not trying to serve data to Safari (usually), I'm trying to read data from Safari. I often need to get the source of a webpage that's already loaded after a login screen, or with some user interaction. For example, scrolling down to load all my Facebook messages into the left-hand bar. Or segmenting text into 5000-character blocks, copy-pasting into Google Translate, and getting the output. With any command-line tools, it would be a hassle, if it's possible at all. With AppleScript, it's easy.
- jcelerier 9y ago> For example, scrolling down to load all my Facebook messages into the left-hand bar. sounds like an X-Y problem. Why wouldn't you just use the facebook API ?
- peterburkimsher 9y agoI don't think there's an API to export all my messages.
- waddlesplash 9y agoYou realize that "hey" is just the command-line interface to Haiku's view scripting system, right? We don't have a JS/Python interface (yet), but the C++ interface is well documented (see this: https://www.haiku-os.org/legacy-docs/bebook/TheApplicationKit_Scripting.html https://www.haiku-os.org/legacy-docs/bebook/TheApplicationKi... for an introduction, and also hey's source code: https://github.com/haiku/haiku/blob/master/src/bin/hey.cpp https://github.com/haiku/haiku/blob/master/src/bin/hey.cpp).