With a little side of applesauce...

Thursday, February 25, 2010

Coldfusion / cfquery - quotes in strings

"Escaped single quotes mess up SQL used in the cfquery tag as described in ColdFusion single quote string screwup.

The behavior described in the page above also affects ColdFusion MX 7: When a string variable is put into a cfquery tag any single quotes are changed to TWO single quotes, ( note, not a double quote). This makes creating SQL strings difficult because they do not work inside of the cfquery tag, for example a typical SQL string with should have a single quote around a string value but inside the cfquery tag the string would become:

I prefer the built-in PreserveSingleQuotes() function.


Mac OS X 10.6 - F-keys as standard function keys

I turned this on when I first moved to OS X, but now use the F-keys for screen brightness, volume control, etc. To toggle this:


Check, "Use all F1,F2, etc. keys as standard function keys"

MacBook - page up and down

fn+[up arrow] and fn+[down arrow]

iTunes - control from Terminal

I'm a console junkie, so the following alias and shell script tips are pretty cool:

I use the shell script myself, since it is more fully-featured.

# iTunes Command Line Control v1.0
# written by David Schlosnagle
# created 2001.11.08

showHelp () {
echo "-----------------------------";
echo "iTunes Command Line Interface";
echo "-----------------------------";
echo "Usage: `basename $0` <option>";
echo "Options:";
echo " status = Shows iTunes' status, current artist and track.";
echo " play = Start playing iTunes.";
echo " pause = Pause iTunes.";
echo " next = Go to the next track.";
echo " prev = Go to the previous track.";
echo " mute = Mute iTunes' volume.";
echo " unmute = Unmute iTunes' volume.";
echo " vol up = Increase iTunes' volume by 10%";
echo " vol down = Increase iTunes' volume by 10%";
echo " vol # = Set iTunes' volume to # [0-100]";
echo " stop = Stop iTunes.";
echo " quit = Quit iTunes.";

if [ $# = 0 ]; then

while [ $# -gt 0 ]; do
case $arg in
"status" ) state=`osascript -e 'tell application "iTunes" to player state as string'`;
echo "iTunes is currently $state.";
if [ $state = "playing" ]; then
artist=`osascript -e 'tell application "iTunes" to artist of current track as string'`;
track=`osascript -e 'tell application "iTunes" to name of current track as string'`;
echo "Current track $artist: $track";
break ;;

"play" ) echo "Playing iTunes.";
osascript -e 'tell application "iTunes" to play';
break ;;

"pause" ) echo "Pausing iTunes.";
osascript -e 'tell application "iTunes" to pause';
break ;;

"next" ) echo "Going to next track." ;
osascript -e 'tell application "iTunes" to next track';
break ;;

"prev" ) echo "Going to previous track.";
osascript -e 'tell application "iTunes" to previous track';
break ;;

"mute" ) echo "Muting iTunes volume level.";
osascript -e 'tell application "iTunes" to set mute to true';
break ;;

"unmute" ) echo "Unmuting iTunes volume level.";
osascript -e 'tell application "iTunes" to set mute to false';
break ;;

"vol" ) echo "Changing iTunes volume level.";
vol=`osascript -e 'tell application "iTunes" to sound volume as integer'`;
if [ $2 = "up" ]; then
newvol=$(( vol+10 ));

if [ $2 = "down" ]; then
newvol=$(( vol-10 ));

if [ $2 -gt 0 ]; then
osascript -e "tell application \"iTunes\" to set sound volume to $newvol";
break ;;

"stop" ) echo "Stopping iTunes.";
osascript -e 'tell application "iTunes" to stop';
break ;;

"quit" ) echo "Quitting iTunes.";
osascript -e 'tell application "iTunes" to quit';
exit 1 ;;

"help" | * ) echo "help:";
break ;;

iTunes - set command F as search keyboard shortcut

You can assign a keyboard shortcut for searching in iTunes by using:
defaults write com.apple.iTunes \
NSUserKeyEquivalents -dict-add "Target Search Field" "@F"


Tuesday, February 23, 2010

Coldfusion - form fields appear through autosuggest drop-downs in IE6

One of my users pointed out that autosuggest form fields were bleeding through the drop-down list from an autosuggest field above it. Thankfully there is a fix for this here:

There appears to be a fix for SELECT form field elements which also bleed through the autosuggest drop-down, (since IE6 can't handle z-index), but I have not tested it:

Wednesday, February 3, 2010

Eclipse / Mac - EMACS+ key bindings

"Real" EMACS key bindings in Eclipse on a Mac:

"Emacs+ is designed to provide a more Emacs-like experience in the Eclipse text editors. Included are enhancements for keyboard driven command execution, Ctrl-u, keyboard text selection, Emacs style search and query/replace, a kill ring for deleted text, balanced expressions (s-expressions), keyboard driven editor window splitting, transpositions, simple text manipulation and append line-comments in the Java editor. In cases where the normal Emacs binding interferes with an Eclipse binding, the Emacs binding is preferred."

I think this will save me from throwing OS X in the toilet...