File Uploads With AngularJS and Ratpack: Part 1

Before I start this blog post, I just want to give a shout out to the Ratpack forum and especially the users that contribute to the forum. When I finished my code for this post, I posted it to the forum in hopes of receiving some criticism so that I could tweak it before writing an article about. At most, I expected a comment or two along the lines of, “Yah, XYZ is OK but you could maybe try it this way instead.” In other words, helpful but not too helpful.

The next day, Luke Daley had forked my project (his fork is here) and made some major improvements. He was also available to answer a few questions I had about his changes. I already thanked him profusely on the forum, but I just wanted to offer my thanks again – it’s communities like this that make me really enjoy working with new (to me) technology. So, without further ado, let’s get into it..

Migrating Octopress to a New Computer

Yesterday, I decided to pull the trigger on updating to Windows 8.1. It went smoothly, but I couldn’t seem to get Octopress working for me. Luckily, Daniel Auger posted a quick snippet (originally posted by @dlobckdotorg) on how to get back up and running. If you’re moving Octopress to a new computer, make sure you save that post! Just in case either of their sites go away, I’ve reproduced it as a Gist here: https://gist.github.com/s992/23d35ebad8e8988c02c5

Ratpack: First Impressions

I first heard about Ratpack about a month ago at Gr8Conf US. I didn’t make room in my schedule to go to any of the sessions, but I did add it to my (long) list of stuff to check out. Most things that end up on that list have a 50/50 chance of ever making it into my editor.

Luckily, I found an excuse to check it out – and I’m glad I did. My current project at work requires me to interface with a third party web based API, but that API doesn’t actually exist just yet. Using Ratpack, I was able to quickly mock up the API and then code against my mock. Unfortunately (or maybe fortunately!), the application is for work and I can’t share it. What I can share, however, is my first impression of Ratpack.

Running the Groovy Console From Gradle

I tend to write stuff iteratively. I’ll write a little chunk, then poke at it a bit, then write some more, and so on. The Groovy Console is a great tool for doing so, but one thing that just hasn’t “clicked” with me yet is the concept of dependencies, classpaths, and all the dependency management stuff in between (Maven, Gradle, Ivy, etc.).

I quickly found myself frustrated with my lack of understanding, so I got in to the bad habit of just pasting all my classes right into the Groovy Console window and playing around with them right there. As my toy projects grew larger (and especially once they started relying on external dependencies), this became unworkable.

I did some poking around and found three ways to run the Groovy Console from Gradle, which (as far as I can tell) populates the Groovy Console classpath with everything I need for my project.

Quick Tip: Angular Debugging

Occasionally I’ll run into someone who is having trouble debugging their Angular application and their first complaint is almost always the incomprehensible error messages. You know the type, they look like this:

You’ll see ugly error messages like that when you are using the minified version of Angular. But, don’t lose hope! You can find a full error message with a (sometimes) helpful explanation by just hitting the link immediately following Error: [$injector:unpr]. I find that a lot of people tend to gloss over that URL when confronted with the ugly error. For an example of where that link takes you, you can try this one from the screenshot: https://docs.angularjs.org/error/$injector/unpr?p0=iDontExistProvider%20%3C-%20iDontExist. It’s obviously a contrived error for the sake of this post, but it will give you an idea of what to expect.

Now, if you’re working in a development environment and battling ugly error messages, you can swap out your minified Angular for the unminified version and get a nicer error:

Now we can see what’s going on at a glance (in this case, Angular’s dependency injection can’t find iDontExist), but we still have access to the URL in case we need more information.

Groovy Browser Automation With Geb

As I was going over my tentative itinerary for GR8Conf (my first Groovy conference!), I spotted a session titled, “Functional testing your Grails app with GEB.” The session, given by Colin Harrington, will be covering “…what it takes to test your grails application with Geb.” According to the Geb website, Geb (pronounced “jeb”) is a browser automation solution for Groovy. I’ve always been curious about browser automation, and Geb’s easy-to-read syntax really piqued my interest. I decided to dive in to the documentation – The Book of Geb – and see if I could take some of their examples and translate them over to my site.

Changes!

Well, this site has been sitting around unattended since my last post over a year ago. I figured it was about time to make some changes, so I took the opportunity to look into Octopress and here I am. I transferred a couple of posts over and plan to move some more this weekend. Unfortunately, I’m going to lose all of the comments from my previous blog due to changing the commenting platform to Disqus.

I’m hoping that a new platform will encourage me to start posting more often, so stay tuned!

Chrome Logger API for ColdFusion

About two weeks ago, I spotted a link on either Reddit or Hacker News to a Google Chrome extension called Chrome Logger. I immediately saw the potential, because I frequently want to cfdump something but have to either abort immediately after or worry about my dump disappearing into a thread, screwing up my layout, etc., etc. There were libraries available for PHP, Python, and Ruby at the time (Node was added recently as well), so I figured I may as well jump on board and put one together for CF.

I finished my preliminary work on the component last weekend and used it at work all week, fixing bugs as I came across them. I’m now reasonably confident that it can be put into the wild, so I’m pleased to announce version 0.1 of chromelogger-cf, hosted at http://www.github.com/s992/chromelogger-cf

In addition to logging simple values, structs, arrays, and queries, I’ve also added a method to convert objects (primarily ORM entities) into a struct representation, including relationships.

Programmatically Creating New Datasource in Coldfusion

I got a new laptop at work. Awesome, right? This thing is blazing fast and a huge upgrade. Unfortunately, I needed to set up my entire local development environment all over again. I managed it with some quick and dirty batch scripts, but I was still left with the tedious task of creating datasources for each of the 40ish MySQL databases that I had imported. Each datasource entry is identical except for the database name, so I figured there must be a better way of doing it than manually creating each entry. Sure enough, there is…