Making use of prefrences in applescripts with the Griffin PowerMate and email
Okay, I own a PowerMate gadget that I have not used in a very very long time. So this afternoon I deiced to play with it and make a couple of scripts that help me at work.
My first task was to make the thing pulse when I have unread email in my inbox. After some simple searching I found a nice entry at macosxhints.com about the script. I also found some smart posts that contained some very effcient apple scripts. One them had a nice idea of using the "say" command to make the mac speak some text! I found this to be very entertaining and started to think how I could use this when I wanted to.
Just a little side note: I have decided to stop checking my email ever 10 seconds and move that to 10 minutes. I find that checking email or seeing that I have unread email ever 10 seconds or so is very distruptive in the moment of my thoughts and projects. So I have decided to increment my email checking to 10 minutes for now. I might even increase this to 20 minutes. Not sure yet.
Back to the script. I liked the idea of a script telling me when it was checking my email but I wanted to have the ability to toggle this on and off with a prefrences setting. After a little searching, I found a great idea and put it to good use. It was so good that I had to write it down because I know I will be trying to implement this in future scripts.
Iteration 1
I came up with this design:
set mac_speak to (do shell script "defaults read com.AaronsAppleScripts.pref 'macSpeak'")
if mac_speak is "true" then
say "Processing email"
end if
try
tell application "System Events" to if (exists process "Mail") is false then
set theCount to 0
else
tell application "Mail" to set theCount to unread count of inbox
end if
if theCount > 0 then
tell application "PowerMateDaemon" to set pulse always to true
else
tell application "PowerMateDaemon"
set pulse always to false
set brightness to 0
end tell
end if
end try
if mac_speak is "true" then
say "Finished"
end if
Explanation of the preferences
To use the preferences here are the following examples of commands to type in your terminal:
set the value to true:
defaults write com.AaronsAppleScripts.pref 'macSpeak' 'true'
set the value to false:
defaults write com.AaronsAppleScripts.pref 'macSpeak' 'false'
read the preference:
defaults read com.AaronsAppleScripts.pref 'macSpeak'
use preferences inside apple scripts:
do shell script "defaults read com.AaronsAppleScripts.pref 'macSpeak'"
Ruby and AS3
When I saw this project, I was in shock. This is fantastic!! To combine Ruby, a great programming language with the universal power of AS3/flex. I have some application ideas using this language and I can't wait to learn it!!
building passenger with macports in os x leopard
install the gem
gem install passenger
install apache
port install apache2
set variable to use apache apxs in /opt/local/
export APXS=/opt/local/apache2/bin/apxs
install and compile passenger
passenger-install-apache2-module
edit your apache conf file to add the following lines
LoadModule passenger_module /opt/local/lib/ruby/gems/1.8/gems/passenger-2.0.6/ext/apache2/mod_passenger.so PassengerRoot /opt/local/lib/ruby/gems/1.8/gems/passenger-2.0.6 PassengerRuby /opt/local/bin/ruby
host your rails app with either a virtual host or RailsBaseURI /path/to/app/dir
<VirtualHost *:80> ServerName www.yourhost.com DocumentRoot /somewhere/public </VirtualHost>
(alias with RailsBaseURI)
cd /somewhere/already ln -s /rails_app/public /new_app
<VirtualHost *:80> ServerName www.yourhost.com DocumentRoot /somewhere/already RailsBaseURI /new_app </VirtualHost>
installing mysql5 with macports in mac os x leopard
Install mysql and server with macports:
port install mysql5 +server
Generate the default database and permissions tables. This is a good command to know if you want to wipe all your settings and start from scratch.
/opt/local/lib/mysql5/bin/mysql_install_db --user=mysql
launch mysql daemon
/opt/local/bin/mysqld_safe5 &
set your admin password for security
mysqladmin5 -u root password (your password)
make links to make your life easy
ln -s /opt/local/lib/mysql5/bin/mysql /opt/local/bin/mysql
ln -s /opt/local/lib/mysql5/bin/mysqladmin /opt/local/bin/mysqladmin
ln -s /opt/local/lib/mysql5/bin/mysqldump /opt/local/bin/mysqldump
jrun startup bash script for coldfusion 8 to put in init.d
I got this from Josh Hand's Technology Blog and I have added it to my own blog for archive purposes only!
- create a file "vi jrun-myinstance"
- copy the follwing text into it
#!/bin/bash
#
# Startup script for JRun
# chkconfig: 345 90 14
# description: JRun myinstance instance service.
#
# Source function library.
. /etc/rc.d/init.d/functions
#
case "$1" in
start)
echo -n "Starting JRun myinstance: "
/opt/jrun4/bin/jrun -start myinstance &
echo
;;
stop)
echo -n "Shuting down JRun myinstance: "
/opt/jrun4/bin/jrun -stop myinstance &
echo
;;
restart)
/opt/jrun4/bin/jrun -restart myinstance &
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0
- copy the file into "cp jrun-myinstance /etc/init.d/jrun-myinstance"
- set permissions "chmod 777 /etc/init.d/jrun-myinstance"
- add it to the run levels "chkconfig --add jrun-myinstance"
- if you want it on the default run level "chkconfig jrun-myinstance on"
- now take control of your jruns!!
service jrun-myinstance start
service jrun-myinstance stop
service jrun-myinstance restart










