Archive for: January, 2009

Making use of prefrences in applescripts with the Griffin PowerMate and email

Jan 30 2009 Published by aaron under Apple, Programming

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'"

No responses yet

Ruby and AS3

Jan 20 2009 Published by aaron under Design, Programming

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!!

http://hotruby.yukoba.jp/test-web/Box2DFlashAS3.html

No responses yet

building passenger with macports in os x leopard and hosting with apache and create an alias with railsbaseuri

Jan 11 2009 Published by aaron under Apple, Programming, Sysadmin

Installing Passenger should be very easy. Please try following my steps below and you should get some good success. I built and used the following configuration with Mac OSX 10.6. But I am sure changes in the OS/Passenger/Ruby will change in the future. You will need to have the following for this article:

  1. MacPorts installed
  2. No fear of using the terminal

Below are the steps necessary to do everything, after that is a list of commands I used that follow the steps:

  1. Install the Passenger gem
  2. Install the Apache2 with MacPorts
  3. Set variable APXS for building passenger module
  4. Run build and install for Passenger module for Apache 2
  5. Edit Apache Conf file

Here is what I typed in (I have also attached Instructions on how to install Passenger and host Ruby on Rails with either Virtualhost or RailsBaseURI for downloading):

  1. gem install passenger
  2. port install apache2
  3. export APXS=/opt/local/apache2/bin/apxs
  4. passenger-install-apache2-module
  5. edit your apache conf file to add the following lines
    1. LoadModule passenger_module /opt/local/lib/ruby/gems/1.8/gems/passenger-2.0.6/ext/apache2/mod_passenger.so
    2. PassengerRoot /opt/local/lib/ruby/gems/1.8/gems/passenger-2.0.6
    3. PassengerRuby /opt/local/bin/ruby
  6. host your rails app with either a virtual host or RailsBaseURI /path/to/app/dir
    1. virtual host
      1. text to put in your apache conf
        1. <VirtualHost *:80>
        2. ServerName www.yourhost.com
        3. DocumentRoot /somewhere/public
        4. </VirtualHost>
    2. alias with railsbaseuri
      1. cd /somewhere/already
      2. ln -s /rails_app/public /new_app
      3. text to put in your apache conf
        1. <VirtualHost *:80>
        2. ServerName www.yourhost.com
        3. DocumentRoot /somewhere/already
        4. RailsBaseURI /new_app
        5. </VirtualHost>

No responses yet

installing mysql5 with macports in mac os x leopard

Jan 11 2009 Published by aaron under Apple, Programming, Sysadmin, Tech

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

No responses yet

jrun startup bash script for coldfusion 8 to put in init.d

Jan 06 2009 Published by aaron under Sysadmin

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

No responses yet

Older posts »