April 29, 2016

Accessing Accordance from the Command Line in Terminal

I was talking with someone today about how you might grab a text reference from Accordance without leaving the command line in Terminal. So, I thought I'd share one way to accomplish it.


You can use Applescript to retrieve the full text of verse references from a given text module, all without bringing Accordance to the front or interacting with its interface in any way. This is how my old scripts and actions have worked, as well as some the OS X Services that OakTree packages with Accordance.
A raw Applescript line to get the text of John 1:1 from the NRSVS module using the citation format (true) is:

tell app "Accordance" to get «event AccdTxRf» {"NRSVS", "John 1:1", true}
You can call that from the shell using osascript:

osascript -e 'tell app "Accordance" to get «event AccdTxRf» {"NRSVS", "John 1:1", true}'
But, no-one wants to type that out each time you want to lookup a verse, so you'll want to create a shell script that passes the verse reference as an argument to the script. Here's an example:
------------------------------------
#!/bin/bash

# This script takes a verse reference as an argument to return the full text of the reference to stdout
# chmod +x getverse.sh 
# ./getverse.sh

# set the short name of module to use
modulename="NRSVS"
# set to "true" to use citation format
usecitation="true"

# trap for a null argument passed, since Accordance crashes if it receives a null parameter
if [ -n "$*" ] #[ "$#" -gt 0 ] 
then
# retrieve all passed arguments as one string, so you can pass references with spaces and without quotes: John 1:1
verseref="$*"

# get the text of the reference from Accordance
textresult=$(osascript -e "tell app \"Accordance\" to get «event AccdTxRf» {\"$modulename\", \"$verseref\", $usecitation}")

echo "$textresult"

else
    echo "Must pass a text reference as a variable, as in:  getverse John 1:1"
fi
------------------------------------
Save that as a text file in your home folder ( ~/ ) with a name like 'getverse.sh'. You'll also need to make it executable by going to the Terminal and using:

chmod +x getverse.sh
After that, you can call the script from the command line in Terminal with:

./getverse.sh John 11:35

An additional, welcome, step is to create an alias that calls that script, to further reduce what you have to type to run it.  Open up your bash profile at ~/.bash_profile (it likely doesn't exist yet, so you'll have to create it),  and then add a line to it to create the alias:

alias gv=./getverse.sh
After that, you'll need to initiate the bash shell environment with this command in Terminal:

source ~/.bash_profile
Then, you can just type: gv John 1:1, 3
to lookup your verse references.

I glossed over some details, assuming that if you're at all interested in doing what this post suggests, you are already familiar with the subjects and functions covered.


April 01, 2016

New Tesla Design Makes It the Apple of Autos

Tesla is the high-end electric car company, headed by an eccentric and high-profile CEO, that makes the incredible electric car that so many want but so few can afford. This has earned them the moniker "the Apple of Automobiles".
Tesla made big news today for revealing the design of their Model 3, which is still in production, but will start at $35,000. In just a day, 115,000 people have reserved their car, all based on the dramatic release of this one photo. Just take a look at the design photo they released, and you can see what has so many people excited:

Tesla Model 3
I am excited about this.
The single photo offers a limited scope of what's in store for the newest electric car, but a couple things revealed here have me thrilled. Immediately most controversial I suspect would be the two discreet passenger compartments. The world of tech and social sciences both have skyrocketed into the pursuit of specialization, so the inevitable result is division between passengers and operators. Several may find this off-putting, but I have two kids, and it strikes me as genius.

You can also notice Jobsesque attention to detail, such as the step ladder and the doubled headlights. Many have already been speculating about the extra headlights. What could they be for? Extra visibility. Some are suggesting that the second pair of headlights could be designed to shift the light spectrum away from intense blue light after 10pm.
The company is not saying much more, other than the availability of a few luxury and tech-related add-on options. The most intriguing the description of a deck, that then became associated with this (leaked?) picture.

They are calling an "eight track deck". I assume it is some sort of audio (bluetooth?) interface that allows you to connect up to eight iOS devices at once. At the press release, a design engineer Max Campbell was very enthusiastic about this technology.
Here's my speculation: could this new car, along with this add-on, be some type of coordination between Tesla and Apple into the new frontier of self-driving cars? Maybe you set up the directions on your phone, and then just plug it into the deck and the car takes over from there?  One can dream.

Without much revealed, we'll have to wait for more info, though that's not preventing auto and tech pundits alike from already drawing their own conclusions.
Technology aficionado John Gruber tweeted this about the upcoming car: "I think it has a classic, almost Homeric quality."