On my Mac Pro I have two internal hard drives I rarely use. Some times they “sleep” and while doing so, every file opening dialog, search in Spotlight or search in Dictionary might wake them up and that takes some time. I could, of course, disable sleeping in power settings, but then the drives would be unreasonably wasting power all the time, so I decided to write an AppleScript to mount or unmount a drive depending on it’s state.
Read the rest of this entry »
Archive for the “Programming” category
AppleScript to mount/unmount a drive
Friday, March 5th, 2010Permission error of AppleScript in iTunes
Sunday, January 31st, 2010I was getting a permission error (code -54) when trying to set an id3 tag of a track using AppleScript. The solution was to add a delay between each operation: delay 1
Note that the track will remain “locked” until you restart iTunes.
Launch character palette using AppleScript in Snow Leopard
Sunday, December 6th, 2009tell application "CharacterPalette" to activate
There is an issue though: the new character palette doesn’t get “bound” to any of the applications, therefore double-clicking a symbol doesn’t paste it automatically to the text field. You’d have to drag-and-drop.
I’m posting this because most results from Google were telling me to launch a “.component”, and that “.component” doesn’t exist on my Snow Leopard system.
Restrict page access to authorized MODx managers only
Sunday, December 6th, 2009A while ago I needed to create a private zone with documentation, accessible only by the MODx managers. In order to restrict access I wrote a simple snippet, which you can now use as well.
Read the rest of this entry »
Add an <option> to a <select> using Mootools
Sunday, December 6th, 2009
var newoption = new Option("option html", "option value");
try
{
$('myselect').add(newoption, null);
}
catch (err)
{
$('myselect').add(newoption);
}
To select the newly created option:
newoption.setProperty('selected', 'selected');