2012

AppleScript JSON Project

Good afternoon,

Been thinking a lot today about trying to get a new open source project started to build a fully functional JSON library entirely in AppleScript. This project would be similar to the ASObject or ASTwitterLibrary projects that I have worked on in the past and would add a much needed feature to AppleScript on OS X.

If you are interested, or know someone who would be interested in helping code this project, please let me know!

Random Shootings

A friend of mine posted this on Facebook after the most recent shooting in Connecticut. It is a statement from Morgan Freeman:

"You want to know why. This may sound cynical, but here's why.

It's because of the way the media reports it. Flip on the news and watch how we treat the Batman theater shooter and the Oregon mall shooter like celebrities. Dylan Klebold and Eric Harris are household names, but do you know the name of a single victim of Columbine? Disturbed people who would otherwise just off themselves in their basements see the news and want to top it by doing something worse, and going out in a memorable way. Why a grade school? Why children? Because he'll be remembered as a horrible monster, instead of a sad nobody.

CNN's article says that if the body count "holds up", this will rank as the second deadliest shooting behind Virginia Tech, as if statistics somehow make one shooting worse than another. Then they post a video interview of third-graders for all the details of what they saw and heard while the shootings were happening. Fox News has plastered the killer's face on all their reports for hours. Any articles or news stories yet that focus on the victims and ignore the killer's identity? None that I've seen yet. Because they don't sell. So congratulations, sensationalist media, you've just lit the fire for someone to top this and knock off a day care center or a maternity ward next.

You can help by forgetting you ever read this man's name, and remembering the name of at least one victim. You can help by donating to mental health research instead of pointing to gun control as the problem."

Giving Bash A Try Statement

I figured I would put up another little post today on yet another little bash gem that I came across recently. The try statement is staple to a lot of programming languages, AppleScript included, but the most important one I have seen yet is Python. Python’s motto for using the try statement is: “It is better to ask forgiveness than permission.” I would agree this statement often works in the developer’s favor but what if a language doesn’t have a “try” statement, what then?

Enter Bash… It does a wonderful job of a lot of things when working strictly in the shell. However, it doesn’t have a try statement. You can attempt to ask permission or simply go ahead and run your command (hoping that it doesn’t’ error) but what if you want to keep track of whether or not a command did in fact error and do something about it?

The following is two examples of how to trap an error for a command in bash:

someCommand 2> /dev/null; 
# Do the command but don’t show an error to the user if one occurs
if [ “$?” -ne 0 ]; then
echo “An Error Occurred”;

fi

OR

someCommand; 
# Show the error to the user, if any, and then do something about it
if [ “$?” -ne 0 ]; then
echo “An Error Occurred”;
do_something_about_it
fi

And that is it… now you can have a “try” statement in bash.

Processing Pseudo Arrays In Bash

I had an epiphany last night regarding the processing of an array as full lines of text in bash. Normally in bash an array is delimited by any whitespace character(space, newline, tab, etc.) however, I specifically wanted to process an array with the delimiters only being newline characters.

My first attempt at doing this lead me down the path of setting the internal field separators (IFS) in bash to the newline character, then creating my array, and finally resetting the IFS back to its default. This worked but made the script rather hard to read and, to be honest, I just didn't like doing it that way.

Then, last night, I realized that there is another way to process individual lines in bash that I could use on a “pseudo array". Thus, I have arrived at the following code conclusion:

pseudoArray=`cat `;

# Use echo to turn the string variable into a pseudo array
echo "$pseudoArray” | while read line; do
echo "$line”;
echo "----"; # To show I am processing each line in turn
done

And that, my friends, is how to take data that is delimited by a newline character and process it as an array in bash!

ASObject 0.8.1 Released

Just wanted to drop a quick note and let everyone know that ASObject 0.8.1 has been released. This is a small update but fixes some bugs that have been around for a while. However, this update makes the way for some of the other updates I have been working on.

Version 0.8.1 of ASObject contains the following updates:
  • Workaround - Bug with keychain scripting in 10.7 and later! Please download Scripting Additions Package
  • Fixed - Bug with Previous_Application method!
  • Added - Write_To_Log method now logs to system log file as well as specified file!
And… ASObject 0.9 is now under active development!

Coding Underway

I just thought I would stop by and let you all know that I have begun coding again on a bunch of the projects here at JA Computing. Some of you know that I have been staying busy while others I am sure simply thought that I had abandoned the projects. The latter of these is not the case. I hope to have some exciting updates to some of the most loved scripts here on JA Computing coming in the next few weeks. The scripts I am actively working on include:
  • Lyricatcher
  • ASObject
  • ASTwitterLibrary
  • LittleBirdOSX
If you have any other scripts you would like me to update or add features to, please let me know! Sometimes it takes you asking for something for it to get done!

See you around the web!

ASTwitterLibrary 2.2

Good evening everyone! I have a small update for you all this evening. ASTwitterLibrary 2.2. This update fixes the methods for getting statistics on twitter users, number of followers, friends, tweets, url, location, bio… etc. These calls used to parse HTML directly from Twitter but are now using API calls that are much faster and more reliable. Please let me know if you find any bugs and I will be certain to get right on them!

A Stop By My Blog

I know it has been a while, once again, since I last posted. My apologies but I have been keeping rather busy now that I am in the big city of Denver. I am loving my new job over at TW Telecom and learning a TON about RedHat. I am very glad that I chose to go in this direction.

I know many of you are wondering when I will begin working on all my scripting projects again and believe me when I tell you that they have not fallen by the wayside. I still work on them as often as I can, even if it is only an hour or two a week. I do hope to be releasing some updates to all of the scripts soon that will fix many of the bugs that I have had to simply bandaid in the recent months. Keep watching and refreshing your pages, the updates are on their way.

Also, as a side note, my wife has started a blog of her own at BrokenPencil.me! She is going to be sharing a bunch of yummy food recipes and anything else she can from our new lives in Denver! Check it out… you will like it!

Loving Colorado

Well, I am all moved into my new place and getting used to my new day job with TW Telecom. It is a definite change of pace bing in the city but one that I am enjoying immensely. Hopefully I will be getting back into my winter development cycle soon. That is all for now… TTYL!