iPad Wedding DJ

Post by Steve Vlaminck

iPad Wedding DJ
I’m a newlywed, and my one responsibility for the wedding (short of showing up on time in my suit) was to handle the music at the reception. Which is good, because that’s really the only thing that I could possibly contribute.

I instantly decided against hiring a DJ, because paying someone a bunch of money, telling him exactly which songs to play and which songs not to play didn’t sound worth it to me. I also decided against using an iPod, mostly because I don’t have one, but also because we allowed people to request songs on our wedding website, and we got a lot of requests for songs that we didn’t already own. Not wanting to buy all of those songs (some of which I would definitely NEVER listen to again), I decided my iPad would be our DJ and I would use a music streaming app.

Which to Choose?
My first plan was to make my playlists in Rdio, syncing them to my iPad so I wouldn’t have to worry about internet connectivity. All was well until I got requests for songs that Rdio doesn’t have. Rdio can match your local files, but it only adds the songs Rdio has; the rest get ignored. This is when I realized Rdio is the worst… except for everything else.

Spotify allows you to play your local files through their player so I bought a subscription and gave up on Rdio. After re-creating my playlists in Spotify, I downloaded their app on my iPad. At the time they didn’t have an iPad compatible app. (They released that about a week after my wedding. Seriously.) Their iPhone app looked funny on the iPad, but at least it would work. The only problem I had syncing local files to the mobile app was with the song She Moves In Her Own Way by The Kooks. Spotify has an acoustic version of the album, but not the original release. The album and all the songs are named the same, but the songs are different and even the song times are different, but that wasn’t enough. When I tried to sync the original release of the song to my iPad, Spotify kept giving me the acoustic version. I ended up renaming the song to get it to sync. Pretty annoying.

And then there’s crossfading. If there’s one feature on all music players that I rarely use, it’s crossfade. I don’t really care for it, but when you need it, you REALLY need it. If there is a second of silence on the dance floor, people will sit down. Well, guess what the Spotify app couldn’t do? (And yes, to answer the question you’re no doubt asking, the version they released a week later can do it. SERIOUSLY?!) The desktop version of Spotify had the crossfade feature though. It wasn’t looking very good for the iPad.

Bummer… Except Not Really
I begrudgingly came to the conclusion that my only remaining option was to give up on the iPad and use Spotify on a computer. Having to open it to change playlists would be annoying, but for better functionality, it would be necessary. But because I was already using my computer for our photo booth, it meant I had to borrow one. Fortunately, there was no shortage of MacBook Pros among my friends.

In the end, the music worked out great. I’d definitely recommend Spotify for DJ purposes, especially now that they’ve released their iPad-friendly app. And did I mention that it came out a week after my wedding? I did? Well… that really sucked.

Posted in Music | Tagged , , , | Leave a comment

Grails Tips: Deployment Tricks

Post by Josh Reed

I’m often working with several versions of a project deployed across a variety of deployment environments. Grails makes it easy to manage all of the configuration for these environments, and also allows you to switch the environment at deployment time by setting a JVM property. However, in our lower environments we’re sharing servers between multiple projects so setting a blanket environment isn’t always possible. On more than one occasion I’ve found myself wondering which environment a particular WAR file was configured for. By default, the WAR file generated by Grails is named after the app name and the app version e.g., supercoolapp-0.5.war, but a minor tweak to your BuildConfig.groovy file will add the environment to filename:

grails.project.war.file="target/${appName}-${grails.util.Environment.current.name}-${appVersion}.war"

After getting the correct WAR file deployed, the next challenge is identifying the version of code running if/when bugs are found. Grails has a built-in mechanism for versioning which works well when I remember to actually use it. And unless you’re setting a new, unique version after each change, the version won’t tell you exactly what code is running. Fortunately, Git gives us an easy and automatic way to identify the code–commit hashes. The only trick is getting the hash into the app so it can be displayed. To accomplish this, we can hook into the Grails event model to ask Git for the current commit hash at compile time. Create a scripts/_Events.groovy file with the following contents:

eventCompileStart = { msg ->
  new File("grails-app/views/_git.gsp").text = ("git rev-parse HEAD".execute().text)
}

This will put the latest Git commit hash into a GSP template called _git.gsp which you can include on any page in your app. I’ll generally put this in the footer of the main layout, either visible or commented out, so it is on every page. You’ll want to add _git.gsp to your .gitignore file since it will change frequently.

Hopefully these two little tricks will make working with your Grails apps across different deployment environments a little bit easier.

Posted in Agile Processes, Software Development | Tagged , , | 5 Comments

Grails In-Memory Cache using Google’s Guava Library

Post by Matt Nohr

In a Grails application, there are a couple of cases where you may want to consider storing data in a in-memory cache.  For example:

  • If it is expensive to read/create the data (reading across the network)
  • If the data will be used more than once
  • If multiple users need to access the data so you need to store it outside of a single user session

Here I will give you one example of how to use an in-memory cache. This can greatly improve performance but there are a couple of things you must keep in mind.

Continue reading

Posted in Software Development | Tagged , , , | 1 Comment

Music in the Office

Post by Dane Messall

If you work in an office the likelihood that you spend a major chunk of your day plugged into music is pretty high. I know it is for me and it’s also a safe assumption to make about my coworkers.

Music is something most of us take quite seriously, but have you ever thought about the effect music has on the workplace? Think of what your day would be like without music in your office.
Continue reading

Posted in Music | Tagged , , , , , , | 5 Comments

Internet Explorer Compatibility Testing

Post by Luke Bredeson

Microsoft seems to catch a lot of flack these days for the overhead required to maintain compatibility with different versions of Internet Explorer.  To help mitigate this, they’ve made some browser testing virtual machines freely available here, for IE 6, 7, 8, and 9.

You’re free to download and run these manually yourself and install with Virtual PC, if you’re on a Windows machine. If you’re running Linux or OSX, however, you might want to instead try the following:

  1. Install VirtualBox
  2. Follow these instructions to automate the download and installation of the virtual machines.

…which gives you this (I wasn’t able to get IE6 working…maybe that’s for the best):

Regardless of how you choose to do this, the download time is pretty painful (probably several hours).  The payoff is pretty nice, however:  fast Internet Explorer testing at your fingertips.

Posted in Agile Processes | Tagged , , | 1 Comment

Using MongoMapper to run MapReduce jobs

Post by Luke Bredeson

Background

When using relational databases, we sometimes take for granted certain operations that appear to be missing in “NoSQL” databases like MongoDB, such as the ability to group data and run aggregate functions in SQL, like sum, max, etc. These things can still be accomplished in MongoDB with MapReduce, of course, it just requires a different approach than in a relational database due to design choices that favor huge, sharded datasets.

The concept of MapReduce itself was nothing new at the time to functional language aficionados, but Google took the algorithm and applied it in a distributed computing context in their popular 2004 paper on the subject. MongoDB’s approach is fairly similar.

A Simple Blog App

Let’s walk through a simple blog example using the MongoMapper gem. The source code of this example is available here.

We’ll start with 2 simple models, shown below: User and Post

class User
  include MongoMapper::Document
  safe

  many :posts
  key :username, String
  timestamps!
end
class Post
  include MongoMapper::Document
  safe

  belongs_to :user

  key :content, String
  key :tags, Array
  timestamps!
end

Now, let’s generate some sample data:

pete = User.create username: 'pete'
sally = User.create username: 'tony'
joe = User.create username: 'sally'

Post.create user: pete, content: "Blog post content", tags: ["t1", "t2", "t3"]
Post.create user: pete, content: "Blog post content", tags: ["t2", "t3", "t4"]
Post.create user: pete, content: "Blog post content", tags: ["t2", "t3", "t4", "t5"]
Post.create user: sally, content: "Blog post content", tags: ["t2", "t3", "t4", "t5", "t6"]
Post.create user: joe, content: "Blog post content", tags: ["t2", "t3"]

Enter MapReduce

Based on this simple structure and sample data, we might decide that we want to know which users have been using the most tags. With MongoMapper, we could do the following:

class UserTags
  include MongoMapper::Document

  key :value, Integer

  def self.map
    <<-MAP
      function() {
        var post = this;
        this.tags.forEach(function(tag) {
          emit(post.user_id, 1);
        });
      }
    MAP
  end

  def self.reduce
    <<-REDUCE
      function(key, values) {
        var sum = 0;
        values.forEach(function(value) {
          sum += value;
        });
        return sum;
      }
    REDUCE
  end

  def self.build
    Post.collection.map_reduce(map, reduce, { out: "user_tags" })
  end
end

# Run the MapReduce job, store the results
UserTags.build

# Get the user who used the most tags on their posts
UserTags.sort(:value.desc).first

Some explanation…

In the MapReduce operation, we first emit a user_id key with a value of 1 for every tag that exists in the system. Since the key in the emit is used for grouping, when we get to the reduce step, it will receive an array of the emitted values for each key to combine in some way (I chose to sum them). We choose an output collection (out: “user_tags”), into which the results are dumped for later retrieval (it could potentially be a time consuming operation if the dataset is very large). Then a simple sort by this sum value will give you the highest user/tag-count combo in the database.

Note that even though MongoDB lacks the transactional semantics that are usually available to relational databases, this operation is nonetheless atomic. While the MapReduce operation is running, it is being output to a temporary collection which is only renamed to “user_tags” (which backs the UserTags model) once the MapReduce is complete, meaning that running this job shouldn’t cause the collection to become unavailable.

Additionally, if you decide to shard your data, the MapReduce operation can run concurrently on every shard.

Posted in Software Development | Tagged , , , | Leave a comment

Create a Heat Map Using Google Docs

Post by Matt Nohr

Using Google Docs new Fusion Tables makes it really easy to create heat maps with just a list of longitudes and latitudes.

In this example, I will use the GPS data from my watch to create a heat map that shows where the common areas are that I run:

Heat Map
Continue reading

Posted in Agile Processes, Misc | Tagged , , , , | 4 Comments

Welcome Adam!

Post by Matt Bjornson

We’re continuing to grow at Refactr, and we’re excited to welcome Adam Lanners to the team! He’s joining us from PaR Systems where he was doing web development and before that he was with Medtronic doing mobile development.

Adam will be jumping into a Grails project leveraging several social APIs. One of his recent projects he’s proud of involved implementing a document management system, centralizing and migrating over 150,000 files that were distributed across many locations  that can be replicated globally.  One of biggest challenges was building a tool to migrate the large amounts of metadata associated with each file without losing any information. The project was a huge success!

Welcome Adam!

Posted in Agile Processes, Business | Tagged | Leave a comment

JRuby Conf Sponsorship

Post by Matt Bjornson

We’re very excited to sponsor JRubyConf this year.  We are big believers in fostering and growing the technology community and it’s great to have a conference like this held in Minneapolis. The other reason we are excited about sponsoring is that the JVM is the platform. The amount of R&D that has been invested into the JVM is staggering, and fostering language communities like this will only strengthen both Ruby and the JVM.

There are multiple language alternatives to Java on the JVM, like Groovy, Clojure, Scala, Jython, etc. But with the popularity of Ruby on Rails and JRuby, there’s another bloat free option to Java with all the scalability, tuning, and tools that come with the JVM. On top of that sweetness, you have one deployment option: the JVM.

With all the great work that the JRuby team has done to make Ruby work on the JVM, it’s a no brainer to deploy Rails-based products on the JVM.  We hope to catch up with the local Ruby developers at JRubyConf.

Posted in Agile Processes, community, Software Development | Tagged , , , , | Leave a comment

Switching to Eclipse/STS For Grails Development

Post by Matt Nohr

My preferred tool for doing Grails development is the SpringSource Tool Suite (STS), which is built on the free Eclipse IDE that you download with a number of plugins already installed. It is totally free and has a number of nice features you do not get with a simple text editor.

Why Switch?

Why should you use STS? Since STS is built on Eclipse, you get a number of nice features built in. Here are just a couple of my favorites:

Outline View:
STS outline view

Content-assist / Autocomplete:
STS Content Assist

Automatic refactoring tools (like renaming all instances of a variable):
STS refactor rename

And many more:

  • Support for groovy, gsps, java, css, javascript, and many more
  • Auto formatting of files including fixing indents and spacing
  • Highly configurable workspace (tabbed editing, split-pane editing, task lists, etc)
  • Huge Plugin community (source control, other languages, etc)

Continue reading

Posted in Software Development | Tagged , , | 3 Comments