Random Musings

about me

Married 12 years to a loving and patient woman.

Father to 3 very energetic boys.

Addicted to cycling.

I do geeky stuff with machines, electronics, and computers.

recent public projects

Status updating…

found on

contact at

me@ryangeyer.com

Hidden Danger of Grails Plugins

- - posted in Grails/Groovy | Comments

As a new developer to Grails you’re probably in awe over the vast number of very powerful plugins which are available to you. Without writing a single line of your own code you can do all sorts of cool things like interact with Twitter, Facebook, Amazon’s S3 storage system, Apple Push notifications, Spring Security, and the list goes on and on. As of this writing there are 447 plugins available in the official Grails plugin repository.

It is understandably tempting to leverage all of this code to simply bolt together an integrated solution which solves the problem you’re facing. But there is a downside to consuming someone else’s code, particularly when you’re doing test driven development. Here are some things to consider before you pull the trigger and grails install-plugin.

I Made Velveeta

- - posted in Parenting, Personal Expressions | Comments

I attended a city college culinary program, which means I know a little about food. I learned the basics of the culinary world, things like mother sauces, cuts of meat, basics of pastries, ect. I’m a foodie. I love food, like it and love to play with it and experiment. Thankfully my husband enjoys my experiments, eating and helping me cook and inspiring me.

RightScriptDiff - Maintain Your RightScripts Locally

- - posted in Cloud computing, Linux | Comments

If you’re running servers in the cloud, particularly on Amazon’s AWS and haven’t heard about RightScale you owe it to yourself to check them out. I’ve been using their tools for launching and managing linux servers on AWS. They allow you to automate all of the tasks to launch a new box, and even run regular operational tasks, all with the use of RightScripts.

RightScripts are just glorified shell scripts which get downloaded from RightScale to your linux server running in any of the clouds they support, and executed with the parameters that you specify in the RightScale dashboard for that RightScript. Of course, as you start to get into more complex scenarios you’re likely to start writing and testing your scripts locally before saving them in the RightScale dashboard. That’s where RightScriptDiff comes in.

Sleep, Sweet Sweet Sleep

- - posted in Parenting, Personal Expressions | Comments

I remember being young and fighting every single nap time in preschool, daycare, and kindergarten. I remember whimpering when my parents held true to my 8:30pm bedtime. I just wanted to stay up and play with the adults, I didn’t get why I had to go to bed. I imagined that my parents were having candy and ice cream parties. I could hear soft jazz playing in the living room and muffled conversations that had a healthy sprinkling of laughter, singing and silly noises. I felt like I was missing out on so much. It wasn’t until Jr. High that I started to stay up late for school work and honestly I thought I was a grown up for not complaining. Then high school I stayed up for cram sessions, reports, homework and started to get that sleep was a valuable commodity. Still I would stay up Friday and Saturday in attempts to spend time with my mom and grandmother or with my friends. I had a strict curfew, one that my mom would tell my friends and their parents so that they knew she meant business.

Grails Domain Mocking Limitations

- - posted in Grails/Groovy | Comments

So, I just threw out most of this morning trying to figure out why something which clearly should work was blowing up my unit test on a grails app. To spare you the same pain I’m documenting it here.

The scenario is that I have Roles and Privileges as domain classes. A role has many privileges, and any privilege may belong to one or more roles. This is represented in domain classes pretty succinctly as;

/grails-app/domain/com/nslms/mockdomainlimtations/Role.groovy
1
2
3
4
5
6
7
8
9
package com.nslms.mockdomainlimitations

class Role {
  static hasMany = [privileges: Privilege]

  static constraints = {
  }
  String name
}
/grails-app/domain/com/nslms/mockdomainlimtations/Privilege.groovy
1
2
3
4
5
6
7
8
9
package com.nslms.mockdomainlimitations

class Privilege {

  static constraints = {
  }

  String name
}

So I can access all the privileges which belong to a role pretty easily, but what if I want to know all roles which a particular privilege belongs to? Easy enough, we can look that up in a variety of ways. Below I show adding a new closure to the privilege domain class which uses the withCriteria functionality of GORM to return all roles which have this privilege in the privileges map. The new closure is in the highlighted lines.

/grails-app/domain/com/nslms/mockdomainlimtations/Privilege.groovy (with new closure) mark:10,11,12,13,14,15,16
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package com.nslms.mockdomainlimitations

class Privilege {

  static constraints = {
  }

  String name

  def getRolesWithThisPrivilege = {
    Role.withCriteria() {
      privileges {
        eq('id', this.id)
      }
    }
  }
}

Now, if you’re doing proper test driven development (you are doing TDD, right?!), you’d probably already have a test written for this new closure that would look something like the highlighted lines of the test fixture below. Notice lines 8 and 9 which are also highlighted to show that we’re asking the framework to mock out the GORM methods on the role and privilege classes.

/test/unit/com/nslms/mockdomainlimitaions/PrivilegeTests.groovy mark:8,9,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package com.nslms.mockdomainlimitations

import grails.test.*

class PrivilegeTests extends GrailsUnitTestCase {
  protected void setUp() {
    super.setUp()
    MockUtils.mockDomain(Role.class)
    MockUtils.mockDomain(Privilege.class)
  }

  protected void tearDown() {
    super.tearDown()
  }

  void testAbilityToGetAListOfRolesAPrivilegeBelongsTo() {
    def role1 = new Role(name: 'Administrator')
    def role2 = new Role(name: 'User')

    def priv1 = new Privilege(name: 'ReadAll').save(flush: true)

    role1.addToPrivileges(priv1)
    role2.addToPrivileges(priv1)

    role1.save(flush: true)
    role2.save(flush: true)

    def roleList = priv1.getRolesWithThisPrivilege()

    assert roleList.size() == 2
    assert roleList == [role1, role2]
  }
}

Even after you’ve implemented getRolesWithThisPrivilege on the Privileges domain class though, you’ll find your test still fails with an error that looks like the following.

No signature of method: com.nslms.mockdomainlimitations.Role.withCriteria() is applicable for argument types: (com.nslms.mockdomainlimitations.Privilege$_closure1_closure3) values: [com.nslms.mockdomainlimitations.Privilege$_closure1_closure3@8327473]

In short, it’s telling us that the withCriteria method of GORM isn’t implemented in the context of our test. Of course if you put the exact same code in an integration test you’re golden.

/test/integration/com/nslms/mockdomainlimitations/PrivilegeTest.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package com.nslms.mockdomainlimitations

class PrivilegeTest extends GroovyTestCase {
  void testAbilityToGetAListOfRolesAPrivilegeBelongsTo() {
    def role1 = new Role(name: 'Administrator')
    def role2 = new Role(name: 'User')

    def priv1 = new Privilege(name: 'ReadAll').save(flush: true)

    role1.addToPrivileges(priv1)
    role2.addToPrivileges(priv1)

    role1.save(flush: true)
    role2.save(flush: true)

    def roleList = priv1.getRolesWithThisPrivilege()

    assert roleList.size() == 2
    assert roleList == [role1, role2]
  }
}

With this in place, you can run a “grails test-app -integration” and the exact same test which failed during unit testing will succeed. This is of course because the entire grails bootstrapping occurs, and all of the artifacts (like domain classes) are wired up fully by the framework.

So the moral of the story? If you’re planning to test anything more than simple saves with GORM in your testing phase, consider putting the more complex stuff into an integration test. Either that, or keep your eyes peeled for problems like this and be prepared to refactor.

Feel free to grab a copy of the test grails app I created for this example.

svn export https://linode.nslms.com/svn_ro/MockDomainLimitations

* UPDATE: This example app has a new home..

Grab the project

1
git clone git://ec2.nslms.com/grails/blog_example_mock_limitations

My Torrid Confession…

- - | Comments

I LOVE the Gilmore Girls. I love the cheesy storyline, I love the silly romances, the silly friendships. I love all the dysfunctional relationships that somehow come to a nearly peaceful resting place within an hour. I loved the relation ship between Lorlei and Rori. I felt a kinship with their relationship as it was reminiscent of the relationship between my mother, my sister, and I. We have comical relationships, we play off each other and crack each other up daily, though we had more of a George Lopez, Chris Rock playful antics than what they had.

I looked forward to watching it Monday-Friday on a network I rarely admit watching.

I have even developed a soft spot in my heart for Scott Patterson (actor that plays Luke). In some ways that character has an air that is reminiscent of my husband, protective and hardworking and sweet. I even think he is cute, almost as cute as my husband. I totally blame my husband being one of those spectacular men that I compare all to and that is why I have a crush on him. :-P

On many of my days suffering from my extreme morning sickness when pregnant with my second son, I would lay on the couch watching the Gilmore Girls twice a day. I would squeal when it would start and happily watch it or if I was too ill that day (i.e. running to the bathroom to kneel before the porcelain throne too often) I would record the shows to watch later. I have even been known to set up the DVR to record both episodes being shown that day even though I knew that the morning episode was a rerun played the evening before. I feel shame, I told you it was a torrid confession.

Renewed Passion

- - posted in Personal Expressions | Comments

I attempted a day of rest yesterday as it was one of my last days when my husband was easily available while I recovered from my c-section. I ended up watching a lot of the new food channel (Anyone else feel like this is a more cooking focused fine living network? Anyone?) and found my self getting a bit excited at the thought of getting back in the kitchen.

Don’t get me wrong, I do cook but everything has become routine and needs to be easily taken over by my husband as one or both boys may suddenly need something only their mom can provide. My husband can hold his own in the kitchen but I can’t expect him to get where I was going with two or three pots on the stove and read my mind as to what my goal was. I like recipes but love to get inspired, use basic technique I have learned years ago and run with it.

I found myself considering staying home full time with my boys and making bread. Yep, I’m thinking about getting a sourdough starter again and making bread regularly. I watched Giada make a rather small pan of focosia and wondered why she didn’t poke her fingers through the dough and then pour her olive oil all over and debated if I liked the idea of adding grapes as a topping. Then I remembered the challenge of braiding challah and how yummy it was for french toast for breakfast. I had flash backs of making danish dough and how much work was involved and wondered if that is even possible with two boys in tow. I mean having a homemade danish is delightful and you can make some of the flakiest decadent cinnamon rolls ever with it. Can you tell I was never an advocate of the Atkin’s diet?

I suddenly remember my Asian food obsession, how I was attempting to make an array of foods from different countries. Thankfully my husband told me everything was yummy and would clean his plate. I wonder if I can attempt to add sushi to my menu. Oh and I have to try to make Pho again, collect my beef bones and make my own stocks from scratch again.

I’m definitely feeling renewed in my passion, my choice of career so many years ago, mama is feeling inspired to get cooking again. We shall see if I’m successful. I’m sure you will hear from both myself and the husband about said attempts…I guarantee you will have a couple laughs.

My First Five Days…

- - posted in Parenting, Personal Expressions | Comments

My first five days home with both my boys and my husband were a bit of a whirl wind. Slowly my mom has shortened her visits here to help, trying to give our newly extended family more space. When writing these posts I heard Captain Kirk from the original Star Trek with beeps and all. I feel as if I have entered a strange and exciting new world. Each day offering new ideas and new lessons of an alien land.

Men and Women Are Different

- - posted in Parenting, Personal Expressions | Comments

Yes, I know the obvious differences, body parts, hair growth, DNA. My husband and I are different, he is a good foot taller than me, has straight hair, is fair and has dreamy blue green eyes. I’m short, olive, with dark brown eyes, you get the point. I have been reminded time and time again how different my husband and I are. We are a happy fit, we have a good rhythm and work nicely together.

I have had the joy of working with him in some large catering events and at home in the kitchen. We have had some small kitchens during our marriage and yet seem to be able to work together well, it has become a lovely graceful dance. Often he and I do a dance when it comes to taking care of our toddler and taking care of our home and each other. That being said, we are still so different.

We are both type A personalities, in our own special ways. Our son has picked up on it, he likes certain things to be a certain way. Example: He has to have his train put away with the wheels all pointing in the same direction in their cubbies. He can handle some messes but food spills drive him nutty.

Back to my husband and I, we are different in how we do chores. Both of us have had to learn neither of us are doing anything wrong, we just do things differently to work towards the same end result. Example: I cook a meal and love for the dishwasher to be loaded by the time I am plating a meal. Oil, seasonings and food is put away. I wipe down counters as I go and if possible have the dishwasher running by the time we sit down to eat.

My husband, on the other hand, will make a lovely meal and have most of the dishes piled up in the sink, food put away and have a few seasonings and oil out. Pans cooling on the range. He is much more concerned in getting the family at the table and enjoying our meal than making sure the kitchen is clean before sitting down. He will clean the kitchen later and I know that. There is nothing wrong with this, but it still makes me a bit twitchy.

We do laundry differently. I do small chores or have small projects going that are easily stopped and started. I am constantly keeping an eye on where the loads are at in their cycle and as soon as the dryer dings I have the load out and the load from the washer in and I’m folding the laundry. As soon as the laundry is folded I put it away. I hate having laundry hanging out in out small laundry room or folded in a basket in our room.

My husband on the other hand is busy multitasking. He usually needs to finish his thought or where ever he is in his process, then he checks on the laundry. He has no problem leaving a basket of folded clothes at the foot of our bed for a few hours, sometimes even overnight. This isn’t a crime yet again, I’m usually left twitchy and he just looks at me like I have lost a bit of my mind. He doesn’t get it.

I don’t get why he has to watch a movie from beginning to end even if he isn’t enjoying it. Why his keys have to be on the key hook before he takes off his shoes when he gets home. We both have our quirks.

We approach diaper changes differently, we dress our toddler differently (ironically my husband is pickier than I am about what our son wears), we play with our son differently. This doesn’t bother me. I know my husband adores our children and he is only doing what is in our son’s best interest, I also know that my husband’s part in our sons lives is HUGE. He also doesn’t seem to mind how I do these things either, he likes that we have a different approach to these mundane things. It makes life interesting.

Men and women are different, and the differences can be fun and amazing or annoying and frustrating. I am still finding new differences and it blows my mind and gives me a new lesson to learn. I’m still having fun discovering our differences.