Monday, May 12, 2014

My First Chortle



I worked with my daddy today to make this. This is a start of an app we are making called chortle. I hope this app will be a very motivating way to do chores!

Tuesday, May 6, 2014

Reverse domain name qualifiers

When do you specify a "reverse domain name" qualifier in Grails?

Is it only when creating domain classes? Or controllers? Both?
# Which one is correct?
grails create-domain-class Thing1
grails create-domain-class com.mycompany.myapp.Thing1

# Which one is correct?
grails create-controller Thing1
grails create-controller com.mycompany.myapp.Thing1

Sunday, April 27, 2014

Let's play did you know I'll go first

Let's play "Did You Know?"

I'll go first.

Did you know that we, the Chortlers, have our own Git repo on Bitbucket (a free, web-based Git repo hosting service)? And that said repo has its own wiki? And that I, for my part, am not crystal-clear on the dividing line between "stuff that goes in the blog" and "stuff that goes in the wiki"? Yep!

Check it out: https://bitbucket.org/chortlers/chortle/wiki/Home

(An acronym to help you remember that URL is: HBOCCWH.)

Sunday, April 20, 2014

Default Login Screen with Spring Security

The spring security plugin enables some amount of default application security without any substantial coding. Here was my 30 minute experiment tonight:

> grails create-app sectest

>cd sectest

In grails-app/conf/BuildConfig.groovy I added the following under the "repositories" section:

mavenRepo "http://repo.spring.io/milestone/"

and under the "plugins" section added:

compile ':spring-security-core:2.0-RC2'

Then:

> grails run-app

I did this to import the plugin. I probably could have just build it. Anyway with the plugin installed I did:

> grails stop-app

> grails s2-quickstart com.homesteadgaming User Role

> grails run-app

Then browsing to localhost:8080/sectest, I saw the login controller listed. Clicking on the login controller gave me this default screen:

My login attempts failed with a sensible error, which is expected since there are no users in my default database.

So next I populated a default user which I hear you can do by editing BootStrap.groovy. That looks like this:

class BootStrap {

    def init = { servletContext ->

    def adminUser = new com.homesteadgaming.User(
                username: 'admin',
                password: 'admin',
                enabled: true).save(failOnError: true)
    }
    def destroy = {
    }
}

And now after restarting the app again, I can login with admin/admin. That's nice.


Saturday, April 19, 2014

Grails Twitter Clone in 90 Minutes

For those looking for the next step beyond the basic CRUD style tutorials, Jeff Brown has a great presentation about creating a Twitter clone in grails during a SF Java Users Group meeting.

Sunday, April 13, 2014

Groovy and Sublime

IDEs are wonderful and all, but sometimes a nice text editor is all you need. In preparation for some Groovy training, I've been evaluating Sublime. Sublime doesn't support Groovy out of the box, but with some syntax highlighting from here, and a build setup from here, Groovy is all ready to go. With the mac's easy <cmd>+ for increasing font size, you can get a nice, clean REPL loop, perfect for demonstration purposes.

Here's a screenshot.


Wednesday, April 9, 2014

Wednesday Night Groovy Lesson

I'm going to do this from memory, so there may be errors in this. Also, my information may be dated, and possibly just plain wrong. Or...it might be the most correct -- the essence of correctness.

In groovy you can do something like this:

4.times {  println 'hi' }

Which will, not surprisingly print 'hi' four times.

In Java you would have to do the much more cumbersome:

for (int i = 0; i < 4; i++) { System.out.println("hi"); }

So how does Groovy way even work? '4' is just a java integer. A primitive. You can't call methods on primitives. Just Objects.

Part of the answer is that Java has "autoboxing", which means that primitives will be converted to their Object equivalents at runtime. So that will solve the problem of '4' not being an Object. At runtime it's a 'java.lang.Integer', not an 'int'.

But now there's another problem. There is no "times" method on java.lang.Integer. In fact, java.lang.Integer is final, so you're not even allow to subclass it. What sort of devilry is this?

Groovy being a dynamic language, doesn't care at compile time if you try and execute a method on an object that doesn't exist. In fact, at compile time Integer.times() doesn't exist. When Groovy starts up, at runtime, it will graft on the "times" method to the Integer class.

So what's that argument? It doesn't look like a normal Java parameter. It might look more clear if you saw the entire form:

4.times ( {...})

But we leave out the parenthesis because they are unnecessary. Now it should be clear that "times" is a method that takes a single parameter: a closure. A closure is essentially an anonymous method: a code block without a name.

At the end of it all then you have a way to concisely execute the body of a loop (what would be a "for" loop in Java) a given number of times hijacking the Integer class to make it readable.

Short intro & step-by-step demo

I'm not a developer by trade.  Either by force or by chance, my job has introduced me to programming and software development in ways I stubbornly fought against for far too long.

My main reasons for resistance were simply a lack of understanding.  I had this misled understanding of any programming (scripting included) as a headache I just didn't want.  Who wants a program to not work because they didn't close a quote or forgot a curly bracket?  I was content in hardware and operations all the while reading stories of the Bastard Operator from Hell and plotting my revenge on your typical end-user.

Enter now:  Confidently developing in python and shell scripts growing daily to make my job easier.  All with the intention of automating myself out of a job!  Lets not forget that I'm now a part of a project with people I consider more friend than co-worker that will take all of us down a road filled with Groovy and Grails, most of us for the first time!

I work professionally on both a Mac and Windows.  The Windows machine simply because I'm in a multiple OS environment but I certainly fought (begged) for a Mac from day 1.  Prior to my current position, I haven't touched a windows machine in almost 10 years.  Personally, I run Ubuntu.  I adore the simplicity as well as the very extensive parental controls when it comes to internet browsing.  My kids are now at the age where they know what YouTube is and want to see the Frozen Let It Go video (...again...) but I don't want them to inadvertently go to an inappropriate-for-an-8-and-10-year-old video instead.

I could create an entire blog post on things that make Ubuntu even more awesome than Mac for development.  Sadly though, I'd be partially lying as well.  As awesome as Ubuntu is, it is an open sourced project and some applications that just make life easier or more fun are only supported on one of the 2 mainstream operating systems.  C'est la vie!

What Ubuntu is phenomenally great for is software development in general!  Installation and setup is a piece of cake for any language you could possibly want.  I could offer you the video series that actually helped to walk me through my own setup for Grails but who watches videos anyways?  Especially when I'm actually willing to walk you through step by step.

For a word of warning:  I'm a HUGE fan of the command line!  GUI's and IDE's come and go and I don't feel like re-learning how to use the latest tool when the command line is constant.  It's not to say that I don't use Eclipse (because I do), I just don't depend on it.  With that said, these steps will also take you through installing everything from a terminal and NOT the application installer (software center).

From here out, I'll simply include typed out text I used for ease of copy/pasting.  Basically ensuring you have a java jdk installed, setting the correct path and JAVA_HOME, installation of the grails IDE, & your first fast sample project!  Or, you can skip all this and just watch the darn video reference!

First, you need to have a few pre-requisites installed.  Java being key.  All commands from the terminal:
     java -version
          should output something like:
               java version "1.7.0_51"
               OpenJDK Runtime Environment (IcedTea 2.4.4) (7u51-2.4.4-0ubuntu0.13.10.1)
               OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)
If you do *NOT* have java installed, the installer should give you a few options in which you CAN install with the command:  sudo apt-get install <package_name>  
java-version again once the install is complete should return the above output.

Now that THAT is done, let's install the GVM!  ACK!  More pre-req's!  We need curl before grails.
     sudo apt-get install curl

Ok, now lets get some grails!
     curl -s get.gvmtool.net | bash

In case you didn't notice the obvious message in your terminal after installation saying 'please shutdown & open a new terminal', here is my PSA for tonight:  Close your terminal out and open a new one before continuing!

After re-opening:  gvm help  <-- should return a fairly basic help screen but helps to ensure you gvm IS in fact installed.
    gvm install grails <version number if you want.  Nothing if you want latest>

Time to set some variables!
     Later versions of Ubuntu will automatically append your $PATH as you add languages.  Simple to check!  One being your java -version.  If that returns, your path is already set.  Same with grails -version.  If you get a return, your path has already been set.  For reference, I'm running Ubuntu 13.10 and had no problems and did not have to fix my path.

From a command line perspective, your good to go!  Lets set up a demo!  Just for ease, it is usually best to create a 'grails' directory in your home,
     mkdir ~/grails
     cd grails
     grails create-app demo  <--this will download a bunch of files & move them in!
     cd demo     <--grails created this directory when you told it to create the demo above
     grails run-app     <--more downloading, will start web server, tomcat, etc...  This will take a little bit of time - if my memory is correct, this took around 15-20 minutes.  How do you know its done?  At the end you will see 'Server Running.  Browse to http://localhost:8080

Now, lets set up the Groovy/Grails Tool Suite!

You will need to download the GGTS here.  And here is where I break my command line love.  I went into the file manager once it was complete (took about 10 mins or so), downloads, extracted the tar.gz I just downloaded, and double clicked on the GGTS icon.  That really is about all there is to explain.  If you want more details or perhaps more into why your typing in what I told you to type, seriously, WATCH THE VIDEO!

Doing this allowed me enough to see a demo of staring up my own webapp, as well as installing the IDE to further allow me to play with containers and views and customization.  I hope this helps for getting Grails started in an Ubuntu environment!



Fumbling and Stumbling with Grails

Motivated by display_name's inspiring fumbling and stumbling spiel, I started perusing the contents of the website display_name and his anonymous colleague recommended. I stumbled upon a good course to get folks started in Grails (http://www.grailsexample.net/course-outline/). The course walks you through creating a sample application while exposing the learner to the nuances and niceties of grails framework for web development. It is very easy to follow even for someone like me who has not programmed professionally and only dabbles in some small scripting here and there. So, if you are like me, would highly recommend the course. I have made it through the first part of the course and cannot wait to take the second half.

Tuesday, April 8, 2014

Chortle Wish List

I asked Meredith to write down some ideas for Chortle, our to-be-written Chore tracking app. Here is what she came up with:

I think that chortle could have a bar so each time you did a chore you would earn how many points the chore holded.Ones the bar was full a big smily face would pop up on the screen. Also what if the there were locked boxes that you could open each time you filled up the bar. The box would reveal a character like a fairy, elf, wizard. I think chortle will be a fun and encouraging game.

Are there any human beings out there?

Hello hello hello.

I am blogging!

There's no way I'm actually going to post this.

What if it were "OK" and "acceptable" and even "encouraged" to just try something new, to stumble and fumble, to do it wrong and try again, to say to yourself, "I don't belong here," but to keep at it anyway, however tentatively and hesitantly; so that that eventually, maybe, you found yourself actually having something of a clue, being moderately competent, and even being able to help out others who were struggling along in the same direction? Ha! Dream on.

I work with a small, dedicated group of technologists. Ants, actually. I have a little ant farm on my desk. I watch them as they build their little tunnels. And carry food around. They're very good at what they do -- and if you aspire to build tunnels (and carry food around) as I do, they are excellent and inspiring teammates.

I also have human teammates. I lied to them when I set up Grails for the first time this week. Not "lied," exactly, but misled. I said (and I'm quoting from memory): "I got my first Grails app up and running in 20 minutes!" And at the time I shared that, I meant it. I was genuinely excited. But what I left out what was how I had, over preceding days, spent maybe 40 minutes trying and failing to set up Grails on my Mac. I kind of futzed around installing the Java JDK and "GVM" (Groovy Environment Manager) as best I could, but I couldn't actually get Grails itself to start. I'd type "grails" and, you know, "command not found." Then my friend Sten (who shall remain nameless to protect his privacy) shared with us a link to what turned out to be just what I needed: an excellent video tutorial for setting up Grails from scratch on a Mac, at http://www.grailsexample.net/installing-a-grails-development-environment-on-os-x -- and from there it only took me 20 minutes to get my first Grails app started.

So the moral of the story is... what? Stumble and fumble, but keep trying, and eventually things will come together. Sometimes. No guarantees. Either that, or: Lie your way to glory.

Sunday, April 6, 2014

This is the First Post

In a world where decisions about projects can't be made without committee approval, estimates are inflated beyond recognition, and any change of consequence has to be approved by a panel of architects, it's comforting to know that nimble software can still be written.

This blog is an oasis to those who believe that useful applications can be written by a small, dedicated group of technologists.