Tuesday, August 26, 2008

PureMVC Gotcha

Don't send notifications that you're expecting a response to in your mediator's constructor (or during construction). Instead, override the onRegister() function and call them there. Your Mediator won't receive notifications it's interested in until after the registration process is finished. Seems pretty obvious, but you can loose track real quick of what's going on in the background when you're using a system like PureMVC that just seems to work.

Thursday, August 21, 2008

Crazy Flex DateField Insanity

So, I've been busily putting together a Flex application at work, and we ran into a curious issue where Flash would infinitely loop and crash itself/the browser. (Not tested in Air) To give a little background first, we're following the convention of keeping our data in data objects (or data models), and binding both the visual component to the data model field and the data model field back to the visual component. All of our code is dynamic, so it's written in Actionscript, not MXML.
The problem occurred when we had two DateField interface components pointing to the same data model field. The two DateFields would be hooked up to a single data model field, and we saw the following behavior:
  • If we bound the DateField.selectedDate to the model.birthday (as an example), with one DateField Instance, all would work. Underneath, it set off the bindings twice when you changed the selectedDate, but that was OK. With multiple DateField Instances, it would crash as it tried to create the second DateField. (This happened when we preinitialized the DateField and without preinitializing the DateField) Underneath, it would set off the bindings between the three items infinitely.
  • If we bound the DateField.data to the model.birthday, it would never infinitely loop, but model.birthday wouldn't get updated when DateField was changed. I think that the code for DateField.data is screwy, but according to the documentation, it seems like this is the property you should bind to.
  • If I tried binding the DateField.data to the model.birthday and the model.birthday to the DateField.selectedDate, it would also loop infinitely.
Finally, I created a ChangeWatcher on the DateField for when the selectedDate changed. On change, it would call a function that checked to see if DateField.data == DateField.selectedDate, and if not, it set DateField.data = DateField.selectedDate. At first, this didn't work quite right, but I changed it to check the DateField.data.time, which is just the number of seconds since Epoch, and that magically worked.

My theory is that Date comparisons are broken or behave oddly, and if you just compare Date.time, it works as expected. I'm assuming this is why the binding went forever, but I can't be sure.

Hope this helps someone else.. some also possibly helpful links:

Wednesday, July 23, 2008

Ant Property Trickery

I needed to change a property in my ant build task. (Backstory: Flex has poorly documented ant tasks, and they seem to require that you set FLEX_HOME as a property so that the tasks know where to find the Flex compiler. I have 2 sdk's that I want to use, one has a code coverage tool called FlexCover built in, but I can't pass in something like FLEX_COVERAGE_HOME, since the ant task silently uses FLEX_HOME anyways.) Ant properties cannot be changed once they are set.

My solution? Import the build.properties file which does not set my target property (FLEX_HOME), then in my tasks, set the target property depending on which one I need (FLEX_REGULAR_HOME or FLEX_COVERAGE_HOME).

Thursday, June 12, 2008

PureMVC Documentation

So, at work we're doing a big Flex project in PureMVC. (I don't know anything about ActionScript, nor Flex, so this should be interesting). We chose PureMVC over Cairngorm because it looks like it might support the huge code base we're going to have cleaner. Plus, I can wrap my head around the framework a little easier.. probably from my Python MVC roots. I think people just think Cairngorm is simpler because they're used to it.

Anyways. I just wanted to point out that PureMVC has some of the best documentation I've ever seen. I printed out the pdf of the Framework overview, double sided to conserve paper, and it has exactly one page of written text and one page of diagrams per section, so you get the text about the view, and on the facing page, all the UML.

The little things make me happy.

Wednesday, April 16, 2008

Regular Expressions

Does it ever strike anyone else as odd that regular expressions are like Microsoft Office? (Except much more useful and less aggravating) I mean, 95% of regular expressions use only 5% of the regular expression syntax, meaning that there's enough time between looking up a particular syntactical construct that you forget it and have to look it up again. My two favorite reg exp tools out there, though I'm sure there are more:

Monday, April 07, 2008

Internet Explorer 7, Clears and Floats?

Working on a project, I'm have a form, where labels (containing fields) are all floated. In order to force a label to a new line, I put a class on it with "clear: left", but that, for some reason, causes the words to be smushed to the left. If there's a label text with a space in it, IE7 renders it as
instead of
first second

Anyone run into this before? I'm not css problem savvy enough to know what to Google for. I ended up just putting br's with a "clear: both" class on them in between rows, but it's not as clean as it was before.

Friday, March 14, 2008

PyCon 2008: Collaborative Notes?

I'm in the keynote at PyCon 2008, and I'm wondering if there are going to be people doing the SubEthaEdit Collaborative note thing this year. The last con I went to (2005), we took quite a few of these notes, and it was really a lot of fun. If you guys are out there, drop me a note: I'm Linden Wright on Bonjour and Kusmeroglu on AIM.

Thursday, March 06, 2008

Grails Date Trick

If you have a Date field in one of your domain classes, for instance:
class Person{
String Name
Date Birthday
and you're struggling to figure out a way to get stuff into it without explicitly creating a date and converting strings or integers into it, Grails provides a handy (yet not documented?) set of properties for you. In our example, I could set birthday_year, birthday_month, birthday_day, birthday_hour, etc.. I found this by digging in the scaffolded views and figuring out how they render the tag. Now, maybe you don't have to dig.

Sunday, March 02, 2008

Font choices, anyone?

I've run into this a couple times, and I find it quite handy, so I'm sharing it for all. It's a list of common windows fonts, their mac equivalents, and the fall back font-family specifier. Plus, everything is in it's own font, so you can see what you're choosing.

Just another css developer's link. I'm on a roll here.

Saturday, March 01, 2008

Color Scheme Generator by WellStyled

Perhaps one of the best color scheme tools I've run across. Simple clean interface, great set of options. I like the rest of WellStyled's website as well, an interesting way to deal with multiple languages.

Lorem Ipsum Dolor Sit Amet

I took latin in high school and college (after a failed attempt to take Chinese.. love drawing the characters, hate trying to translate spoken Chinese), so the latin text popular to layout designers and typesetters always appealed to me. Here's a useful site that will generate as much of the text as you need, in paragraphs, lists, bytes, etc. I've used it a couple times before, just thought I'd share it with everyone. (Hint, View Source to copy/paste the useful stuff). Ah, good old Lorem Ipsum. As an aside, someone took thequickbrownfoxjumpsoveralazydog.com. Is it strange that that phrase reminds me of my childhood?

Friday, February 29, 2008

Gotcha: Grails Auto Recompile Doesn't Do GSP

Grails does the auto recompile thing, much like Turbogears etc., but it doesn't seem to work for gsp pages, in particular, main.gsp. Which can trip you up, if you're trying to make a couple simple changes to your first Grails app.

Wednesday, February 27, 2008

Gotcha: Grails Capitalization

So, apparently Grails doesn't like Controllers starting with multiple capitol letters (i.e. TLAcronym). If you create a domain class with all lowercase, it will capitalize it for you, but if you try to create TLAcronym, it happily plays along. Then if you generate-all or do scaffolding for that domain class, you won't be able to access your controller. I've raised an issue for this here: GRAILS-2541.

Thursday, February 14, 2008

Acegi on Grails Tutorial

So, neither the information on the Plugin Page for the Acegi Security Plugin, nor the info in the acegi tutorial actually work completely. Here's a real tutorial for doing this. (Step 6 is where the existing documentation fails)

Step 1. Install Grails

Step 2. Download the Acegi Security Plugin. (I downloaded version 0.2 it as a zip file, to %GRAILS_HOME%/plugins/)

Step 3. Create a new Grails Project, and cd into the new project folder:

grails create-app SecurityTutorial
cd SecurityTutorial

Step 4. Add the Acegi Security Plugin. Note that you can install plugins by name using some lookup service, but the Acegi plugin won't be found.

grails install-plugin %GRAILS_HOME%/plugins/grails-acegi-0.2.zip

Step 5. Installing the Acegi Plugin will add some new scripts to your project:

  • create-auth-domains [PersonDomainName] [AuthorityDomainName: this creates the domain model needed by the plugin, Person, Authority, and RequestMap classes, login and logout controllers, as well as the login view. You can give optional names as arguments to replace Person and Authority.
  • generate-manager: creates the scaffolding controllers to add new Person, Authority, and RequestMap object in your database
  • generate-registration: create a register and captcha controller, as well as matching views, and an emailer service.

Run each of these commands.

grails create-auth-domains
grails generate-mapper
grails generate-registration

Step 6. Setup BootStrap.groovy to contain some sample data, as follows:

// ProjectFolder/grails-app/conf/Bootstrap.groovyclass BootStrap {

def init = { servletContext ->

// get a AcegiSecurity AuthenticateService
def authenticateService = new AuthenticateService()
// use it to create an encoded password
def md5pass = authenticateService.passwordEncoder("pass")

// Create two sample users
// NB: you must specify all the Person attributes, otherwise
// Grails will fail quietly to add these to the database
def user_root = new Person(username:"root",
userRealName:"Root User",
def user_admin = new Person(username:"admin",
userRealName:"Admin User",

// Add some sample Roles, add the users to those roles
def role_superuser = new Authority(description:"Superuser",

// See AcegiConfig.groovy, at the bottom, there's a defaultrole
// setting, you must make one to allow registration to work.
def role_user = new Authority(description:"User Role",

// Create some Request Maps
new Requestmap(url:"/captcha/**",
new Requestmap(url:"/register/**",

def destroy = {

We also have to edit the RegisterController.groovy to fix a bug.

// ProjectFolder/grails-app/controllers/RegisterController.groovy                    // Line # 159-161
def parMap =['j_username':person.username,'j_password':params.passwd]
// change this line:
// redirect(controller:'login',action:'../j_acegi_security_check',params:parMap)
// to this:

Step 7. Run the application

grails run-app

Step 8. Play around. Notice that you when you try to go to the register controller, it asks for a login, then, since you're already logged in, the register controller just shows you your info with a redirect(action "show"). Go delete the RequestMap for the register url, make sure you logout, then try again. See how the captcha is broken? Go remove the captcha RequestMap, and try again.

Thankyou Markmail

So, I've been trying to dig through codehaus's mail archives for the Groovy Lists. Oh wow, what a terrible interface, and miserable search. A lucky Google search later, and I stumble on Markmail's Groovy Site. Not only do I find the mail thread I was hoping for which solved my problem, but a fantastic interface to some of the larger tech mailing lists that has a fantastic interface and great search. The date restraints and graphs are nice, but even nicer: Awesome, awesome thread display, really nice interface for checking out attachments, perma-links, and powerful search features. Good job guys, I saved enough time to write this :)

Tuesday, January 15, 2008

It's not easy being dorky

So, I was hanging out with some of my friends the other night, and we watched the 2nd ep of the new Terminator show, which they had DVR'd. I didn't see the first one, because I don't really watch TV, but it was a pretty good episode. It was odd seeing Summer Glau playing a robot, but not surprising somehow. Anyways, as John leaves the store in the mall, the address of the store is '1337', so I say "haha, leet" (obviously, what else would you say?). No-one in a room full of guys, including the one I'm dating, had any idea what the heck I was talking about, even when I tried to explain. I'm not even sure how to take that.


Wednesday, January 09, 2008

Rock Band is Awesome

So, I've been playing Rock Band like a mad fiend since late last year. I never got into the Guitar Hero thing, but I truly love drumming. Singing is also fun. My crowning achievements so far: 621 note streak on Medium with The Strokes song, and singing hard Say It Ain't So while playing the drums on hard for the first time without redlining.

Anyways, the fun stuff for you: I made a list of the music videos for the standard Rock Band songlist. (At least all of the ones I could find) Here's the html and rss feed from my del.icio.us account, and here's the list (not in any particular order):
  1. You Tube - Van Halen- Won't Get Fooled Again (Live 1993)

  2. You Tube - The Killers - When You Were Young

  3. You Tube - welcome home - coheed and cambria

  4. You Tube - Pixies - Wave Of Mutilation

  5. You Tube - Bon Jovi - Wanted Dead Or Alive

  6. You Tube - Stone Temple Pilots Vaseline, Vasoline

  7. You Tube - Aerosmith - Train Kept a Rollin'

  8. You Tube - bowie, tokyo 1978: suffragette city

  9. You Tube - The Clash - Should I stay or should I go

  10. You Tube - Weezer - Say It Ain't So

  11. You Tube - Beastie Boys- Sabotage

  12. You Tube - Iron Maiden: Run to the Hills

  13. You Tube - The Strokes - Reptilia

  14. You Tube - Black Sabbath - Paranoid

  15. You Tube - R.E.M. - Orange Crush

  16. You Tube - The Police - Next To You (Hamburg 1980)

  17. You Tube - Mountain - Mississippi Queen - 1970

  18. You Tube - The Hives - Main Offender

  19. You Tube - Foo Fighters - Learn To Fly

  20. You Tube - Nirvana - In Bloom

  21. You Tube - Garbage - I Think I'm Paranoid

  22. You Tube - Deep Purple - Highway Star

  23. You Tube - OK Go - Here It Goes Again

  24. You Tube - Nine Inch Nails - The Hand That Feeds

  25. You Tube - The Outlaws - Green Grass & High Tides - Part One

  26. You Tube - Queens Of The Stone Age - Go With The Flow

  27. You Tube - The Rolling Stones Gimme Shelter

  28. YouTube - Boston - Long Time (11/13/06 at Boston Syphony Hall)

  29. YouTube - Molly Hatchet - "Flirtin' With Disaster"

  30. YouTube - Faith No More: Epic

  31. YouTube - Metallica- Enter Sandman

  32. YouTube - Don't Fear the Reaper - Blue Oyster Cult

  33. YouTube - Kiss - Detroit Rock City

  34. YouTube - FALL OUT BOY: Dead On Arrival

  35. YouTube - Red Hot Chili Peppers - Dani California

  36. YouTube - Radiohead - Creep

  37. YouTube - Smashing Pumpkins - Cherub Rock

  38. YouTube - Hole - Celebrity Skin: Video

  39. YouTube - Ramones - Blitzkrieg Bop

  40. YouTube - Soundgarden - Black Hole Sun

  41. YouTube - The Sweet - Ballroom Blitz

  42. YouTube - Jet - Are you gonna be my girl ?

  43. YouTube - Yeah Yeah Yeahs - Maps