Posts tagged with OS X

Displaying Unicode Characters in the Scala REPL on OS X

October 25th, 2010

So simple but unforuntately I missed it until now:

scala -Dfile.encoding="UTF-8"

Now you can go to town with characters like ø and ∫! Oh, and you may want to alias this command in your ~/.profile:

alias scala='scala -Dfile.encoding="UTF-8"'

Tweaking iTunes Settings

October 12th, 2010

Over the last few iTunes revisions there have been several changes that, in my opinion, have made the iTunes user interface slightly less usable. Luckily, almost all the changes can be reversed by changing the right property values.

Here’s the Bash function I wrote today so I can toggle the settings without remembering the special commands:

# tweak iTunes
iTunes () {
    if [ $# -eq 0 ]; then
        open -a iTunes
    else
        case $1 in
            "buttons" )
                if [ $# -gt 1 ]; then
                    case $2 in
                        # the standard OS X (ie pre-iTunes 10) layout
                        "horizontal" )
                            defaults write com.apple.iTunes full-window -1;;
                        # iTunes 10 layout
                        "vertical" )
                            defaults write com.apple.iTunes full-window -0;;
                    esac
                else
                    echo "Additional parameter required.";
                fi
                ;;
            "arrows" )
                if [ $# -gt 1 ]; then
                    case $2 in
                        # arrows go to entries in the iTunes Music Store (default)
                        "store" )
                            defaults write com.apple.iTunes invertStoreLinks -bool FALSE;;
                        # arrows go to entries within the local iTunes library
                        "library" )
                            defaults write com.apple.iTunes invertStoreLinks -bool TRUE;;
                        # show arrows next to songs, artists, albums (ie pre iTunes 10.0.1)
                        "on" )
                            defaults write com.apple.iTunes show-store-link-arrows -bool TRUE;;
                        # don't show arrows (ie iTunes 10.0.1)
                        "off" )
                            defaults write com.apple.iTunes show-store-link-arrows -bool FALSE;;
                    esac
                else
                    echo "Additional parameter required.";
                fi
                ;;
            * )
                echo "Invalid option.";;
        esac
    fi
}

Just drop it into your ~/.profile, save, and reload from the Terminal (source ~/.profile) and you’re good to go!

Installing the Google App Engine SDK and Django 1.0.2

May 6th, 2009

This was quite tricky for me, so I’m writing this down to share it with others.

  1. Install the SDK

    Simply download the SDK and install it. On Mac OS X that meant that I mounted the disk image, dragged the SDK app to my applications directory, and launched it. Make sure to give the app the necessary permission to create symlinks.

  2. Get the latest version of google-app-engine-django

    Use SVN to export the latest version of google-app-engine-django: svn export http://google-app-engine-django.googlecode.com/svn/trunk/ your-app-dir

  3. Get the latest stable version of Django

    Download from http://www.djangoproject.com/download/. Decompress it.

  4. Zip up Django

    Google Apps currently uses version 0.96 of Django and they do not plan to switch in the near future. Thus, you need to put a django.zip file in your App Engine app directory, your-app-dir. You create the file by, from the Terminal, going to the directory of the new version of Django you downloaded and typing:

    1. zip -r django.zip django/__init__.py django/bin django/core django/db django/dispatch django/forms django/http django/middleware django/shortcuts django/template django/templatetags django/test django/utils django/views
    2. zip -r django.zip django/conf -x 'django/conf/locale/*'
    3. zip -r django.zip django/contrib/__init__.py django/contrib/formtools django/contrib/auth django/contrib/sessions

      Note there is an oversight in the App Engine article about zipping Django 1.0; the last two directories are necessary.

  5. Edit settings

    Open app.yaml in your App Engine app directory and change the application name on line 1 to the name of your application. Then, open settings.py and uncomment line 83 so that django.contrib.sessions.middleware.SessionMiddleware is included.

  6. Launch the default app

    From your App Engine app directory, launch the server: python manage.py runserver. If everything went correctly you should see the server mention using zipimporter and then announce that your app is running at http://localhost:8000. Open the URL and your should see a simple welcome message.

  7. Build your app!

    Now you can get started building a Django app on App Engine. Make sure to read the article on using the Django App Engine helper to see how to start building your app.