SubIt 1.1

subit_icon
Latest release of SubIt – version 1.1

Finally it’s here!
After a complete rewrite in Objective-C I am happy to say that I have a working version of SubIt.

What’s new?
Most noticeably the ability to select QTTracks in your media.
Ability to select a font/style/size before exporting your work.

Download it and let me know what you think and what bugs you have found!

subit_window

Multiply – little xcode project

Yesterday afternoon I was sitting with Erin & Hugh seeing if we could do 2 digit multiplications in our head, such as 34 * 94.

It turned out I am pretty bad at this so I figured I’d make a little mac app/game to practice with and get back into coding.

Looks like it’s a 64 bit app, and i think it only runs in 10.6.

multiply

I might rebuild it for the iPhone.

multiply app (517 downloads)

xcode project:

multiply xcode project .zip (428 downloads)

Learning Obj-C

Yesterday I decided I have to give up on PyObjC for the moment and step into the world of Objective-C.

I have got to a point in developing SubIt that I can’t seem to get enough out of the PyObjC bridge to be able to get what SubIt needs.

So now I am in the process of rewriting SubIt in Obj-C.

Obj-C seems weird and complicated and I can’t see why it has to be this way when Python/Ruby seem just so much much easier to understand. Oh well, I have taken the plunge.

I spent most of yesterday reading a great and easy to follow PDF called “Become An Xcoder“, available for free download:
http://www.cocoalab.com/?q=becomeanxcoder

I have been looking at a bunch of podcasts/videos/books and to me this PDF was the quickest/easiest way to get a little up to speed.

TVShows – app for subscribing to torrents

This app is awesome!

What is TVShows ?
TVShows is a Mac OS X application that automatically downloads your favourite shows. You don’t need anymore to manually download torrent files, TVShows does it for you. Manage your subscriptions and preferences from within the TVShows application, and TVShows takes care of the rest: a background process is automatically launched at a regular interval to check for new episodes.

Cheers Mr Hussey!
tvshow app

Ruby on Rails: ActiveRecord relationships almost make sense!

rails

Yesterday I was having a lot of issues getting ActiveRecord relationships to work.

The problem, as with my relationships with women, was all to do with my lack of understanding. 🙂

I posted up on the rails forum about my dilemma, and was lucky enough to get some fantastic help from one dude in particular , Duplex, who managed to walk me through all my errors and misunderstanding. Check it out here. I look like a retard!

So for my own benefit I am going to do a walkthrough here on ‘News from Above’ (how wanky does that sound?!) of what I did yesterday just to make sure I can.

This example with be an application that has a ‘job’ model (as in a job for a tv commercial) and a ‘director’ model (a tvc director).

———————————————

Create a rails project

in a shell/terminal change into a directory where you will have your RoR’s projects. Then enter:

rails yourprojectname

my app for this will be called ‘kapow’, and I want to use mysql as the database, not the default SQLite DB that comes with osx 10.5.

rails kapow -d mysql

next change directories into the new project

cd kapow

now we should create the database. There are probably many ways to do this but the following seems to be the most simple. using the ruby make command ‘rake’.

rake db:create

If all went well all that should come back in the shell/terminal is something like:

in /pathtoyourproject/kapow)

You can use apps like CocoaMySQL to view all ur MySQL databases/tables – but I have read DON’T edit the tables – do all that with Ruby/Rails.

now we need to build a ‘scaffold’ of the job model

The Job model that is created will have a ‘name’ attribute and a ‘director_id’ attribute.

ruby script/generate scaffold job name:string director_id:integer

I originally thought this is where I would want a ‘string’ field to store the director’s name in, but we are going to create another table for ‘director’. The ‘job’ table will simply store the ‘director_id’ number (actually the ‘id’ of the entry in the ‘director’ table).

Next we need to generate a scaffold for the ‘director’ model

ruby script/generate scaffold director name:string

Cool! Models are nearly ready. Now we need to open up the ruby files for the ‘director’ and ‘job’ models, and explain how they are associated – what their ‘relationship’ is.

A ‘migration’ file has been created in the ‘db’ folder. Now it just had to be run to populate the database with the models.

rake db:migrate

*From this point on it is all pretty much text editing. I use TextMate.

For this little app, the relationships in simple BOLD english are “A DIRECTOR HAS MANY JOBS” and “A JOB BELONGS TO A DIRECTOR”.

So in RoR’s terms for the director model – (“kapow/app/model/director.rb”):

class Director < ActiveRecord::Base
  has_many :jobs
end

and for the job model – (“kapow/app/model/job.rb”):
class Job < ActiveRecord::Base
belongs_to :director
end
Even cooler! So now the model’s know where they are with each other.
For this kapow app I want the user to be able to select from a list of directors when creating a new job – a ‘dropdown’ list. To get the director’s from the database we need to setup the ‘jobs_controller‘ to retrieve a list of director names from the database.
To do this we need to add a line of code to both the ‘new‘ action and ‘edit‘ action. (*** Just a note, from what I have read, an “action” is a “controller method”). The jobs_controller.rb file lives in (“kapow/app/controllers”).
@directors = Director.find(:all, :order => :name)
So each method will now look like:
  def edit
    @job = Job.find(params[:id])
    @directors = Director.find(:all, :order => :name)
  end
  
def new
  @job = Job.new
    @directors = Director.find(:all, :order => :name)
    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @job }
    end
  end
Now a few last things. The View! What we are going to see – what will be rendered to the screen. The html.erb files for ‘job’.
Firstly, the list of all jobs – the ‘index.html.erb’ and the ‘show.html.erb’.
The scaffold will have generated:
<h1>Listing jobs</h1>
<table>
<tr>
<th>Name</th>
<th>Director</th>
</tr>
<% for job in @jobs %>
<tr>
<td><%=h job.name %></td>
<td><%=h job.director_id %></td>
<td><%= link_to ‘Show’, job %></td>
<td><%= link_to ‘Edit’, edit_job_path(job) %></td>
<td><%= link_to ‘Destroy’, job, :confirm => ‘Are you sure?’, :method => :delete %></td>
</tr>
<% end %>
</table>
<br />
<%= link_to ‘New job’, new_job_path %>
We just need to update the line:
<td><%=h job.director_id %></td>
to read:
<td><%=h job.director.name %></td>
This will get the ‘name’ of the director from the ‘director’ table – otherwise it will just show the ‘id’ number of the director. The ‘*_id’ is some built in RoR built in thing I am yet to understand. I’ll update this post once I do! [THIS PART TOOK ME THE LONGEST TO UNDERSTAND!!!]
The last last thing to do is add the ‘dropdown’ menu. In the ‘edit.html.erb’ & ‘new.html.erb’ files, add this line:
<%= f.collection_select :director_id, @directors, :id, :name %>
above the line:
<%= f.text_field :director_id %>
so now the ‘edit.html.rb’ file should now look like (the ‘new.html.erb’ should look pretty similar:
<h1>Editing job</h1>
<%= error_messages_for :job %>
<% form_for(@job) do |f| %>
<p>
<b>Name</b><br />
<%= f.text_field :name %>
</p>
<p>
<b>Director</b><br />
<%= f.collection_select :director_id, @directors, :id, :name %>
<%= f.text_field :director_id %>
</p>
<p>
<%= f.submit “Update” %>
</p>
<% end %>
<%= link_to ‘Show’, @job %> |
<%= link_to ‘Back’, jobs_path %>
So now that is all setup we should be able to startup our webserver and start adding some jobs and directors.
Open up a new shell/terminal window, change directory to your ‘kapow’ project. To start the webserver, jump pack into the shell/terminal, and run this command (from within the ‘kapow’ directory:
ruby script/server
If all went well (which to can see in the shell/terminal), you should be able to go to your web browser and punchin:
localhost:3000/jobs

distributed rendering using Apple Qmaster 3 – success!!!

qmaster3logo


Thanks to a fair amount of googling and a few days on and off of testing I seem to have a working setup for doing distributed processing using Apple Qmaster – for Shake, Maya and Compressor.

Here is my effort at explaining what I did to get it working – big apologies, it’s poorly written. I’ll revisit this post soon.

some notes on our workflow

  • Our current workflow for dealing with files/assets evolves around a directory structure that breaks each project up into shot numbers and the various departments we have etc..
  • Our xserve is the centralised area for our assets and the QMaster render manager.
  • Each artist’s local machine has a directory somewhere that mimics the xServe’s project directory structure for working locally (to keep network traffic down over gigabit ethernet).
  • I set up $JOBS_LOCAL and $JOBS_SERVER env variables on each machine and the xserve – these variables point to the relevant local project directory on the artist’s mac and the project directory on the server.
  • I created a python script that does a find and replace of the 2 variables and writes our a new shake script renamed “*_SERVER.shk”, or “*_LOCAL.shk”
  • (See further down for setting up the ENV variables.)

    Centralised $NR_INCLUDE_PATH
    I setup an env variable for $NR_INCLUDE_PATH for all Shake machines and the xserve – to look at a sharepoint (the nreal folder) on the xServe and automatically mount it – so all the Shake machines would be using the same macros/plugins and settings. I setup a new user on the xserve “shake” that can only mount the nreal directory.

    After some googling around I found a way to automount volumes:

    OS X 10.5 (fstab)
    /etc/fstab – to automount sharepoint on xServe
    LINK: http://blogs.sun.com/lowbit/entry/easy_afp_autmount_on_os

    # ————————————————————————————-
    # Mount AFP share from xServe via AFP
    # ————————————————————————————-
    ourserver.local:/nreal /Network/nreal url auto,url==afp://nreal:password@ourserver.local/nreal 0 0
    # ————————————————————————————-

    how to refresh automount(login as root/su):

    sudo automount -cv

    OS X 10.4 (netinfo manager)
    LINK: http://ask.metafilter.com/54223/Help-me-automount-my-smb-share-in-Apple-OS-X-reward-inside
    in terminal.app:

    nidump fstab . > /tmp/fstab
    echo “ourservernreal /Network/nreal url url==cifs://nreal:password@ourserver/nreal 0 0” >> /tmp/fstab
    sudo niload fstab . < /tmp/fstab sudo killall -HUP automount

    how to refresh automount(login as root/su):

    sudo killall -HUP automount

    QMASTER
    I had tried for some time to get shake scripts to render over our network using Qmaster but it just wouldn’t work. The QMaster logs were where I found all my errors. ‘frame 0021 could not be found’, ‘UNIX error 3 file could not be found’

    things to check

  • shake / maya / qmaster 3 node is installed on all render machines
  • the location of all your media can be accessed by all machines
  • What seemed strange was that if I logged into the xServe and executed a script via terminal with shake (to render just on the xserve) the render would complete successfully. Then it clicked that maybe the environment variables I was using in my scripts ($xxx) might not be getting recognised by Qmaster or the way Qmaster launches Shake??

    The big tip-off
    I googled for the errors I kept seeing and luckily enough this forum post popped up:
    http://www.highend3d.com/boards/index.php?showtopic=204342

    “I have pinned this down to at least one reason – that the shake qmaster isn’t picking up the NR_INCLUDE_PATH environment variable. Does anyone know where you need to set this up on a cluster node (I can get the qmasterd to pick it up but that doesn’t solve the problem!) “

    If you are trying to use Qmaster, and need to set environment variables, then you need to create a wrapper script that sets the variables and then calls the appropriate version of shake.

    For example, (this was from Apple)

    NR_INCLUDE_PATH=/Network_Applications/Shake Plugins/nreal/include;export NR_INCLUDE_PATH
    NR_ICON_PATH=/Network_Applications/Shake Plugins/nreal/icons;export NR_ICON_PATH

    umask 000

    /Applications/Shake3.50/shake.app/Contents/MacOS/shake $*
    status=$?
    if [ $status -ne 0 ]
    then
    exit $status
    fi

    Then when using Qmaster, you run the application using this
    script (saved for example as /usr/bin/shakeWrapper) which must be
    installed on all nodes in the cluster.

    Regards
    Nell

    Cheers Nell!

    I took Nell’s script, added a few lines to it and stuck it in /usr/bin/

    /usr/bin/shakeWrapper – create a file to launch Shake respecting ENV variables – later alias ‘shake’ to this file

    echo
    echo “Shake 4 running through a wrapper script – /usr/bin/shakeWrapper”
    echo

    umask 000

    /Applications/Shake/shake.app/Contents/MacOS/shake $*
    status=$?
    if [ $status -ne 0 ]
    then
    exit $status
    fi

    I added the first few lines there so when I later made an alias to this script the Shake user would have some idea what is going on when launching Shake via the terminal.

    Setting up the ENV (environment) variables…

    /etc/profile – to declare system-wide Environment variables / aliases
    (alias shake to use a wrapper to make it launch respecting/recognising the env variables)

    # System-wide .profile for sh(1)

    if [ -x /usr/libexec/path_helper ]; then
    eval `/usr/libexec/path_helper -s`
    fi

    if [ “${BASH-no}” != “no” ]; then
    [ -r /etc/bashrc ] && . /etc/bashrc
    fi

    JOBS_LOCAL=”/Volumes/otherdrive/jobs”;
    export JOBS_LOCAL

    JOBS_SERVER=”/Volumes/ourserversharepoint/jobs”;
    export JOBS_SERVER

    NR_INCLUDE_PATH=”$HOME/nreal/include”:”/Network/nreal/include/”;
    export NR_INCLUDE_PATH

    alias shake=”/usr/bin/shakeWrapper”

    *remember to enter into terminal:
    source /etc/profile