Matthew Hinton

nerdy stuff is discussed here

Rails Client Side Validation Position the Error Message

I needed to postion the error message the client_side_validations gem adds today and it turned out to be pretty easy. I copied the html that displayed the error out of the browser and moved it where I wanted it and the javascript was smart enough to find it and use it.

So this is the html that was generated by default.

“Original HTML”
1
2
3
4
5
  <div>
    <label for="add_organization">Organization</label>
    <input type="text" id="add_organization" name="add_organization" class="required"/>
    <label for="add_organization" generated="true" class="error" style="display: inline">This field is required.</label>
  </div>

This is what I wanted. I was able to get this output by adding the generated error label to my html. The validation javascript sees that the error label markup is already there and just changes the display style from none to inline making it visible.

“Correct HTML”
1
2
3
4
5
6
7
  <div class="item">
    <label for="add_organization">Organization</label>
    <input type="text" id="add_organization" name="add_organization" class="required"/>
  </div>
  <div class="item">
    <label for="add_organization" generated="true" class="error" style="display: none;">This field is required.</label>
  </div>

Chrome Dev Tools Tip

I am putting this here so the next time I need to work with javascript in a lightbox or other model dialog I won’t bang my head my desk trying to figure out how to access its elements with jquery.

I the Chrome open the dialog you want to work with then open the development tools. In the console tab at the bottom of the window is a menu that defaults to <top frame> click on it and select the name of the dialog you are working with and jquery selectors and javascript operations will work.

Chrome Dev Tools Context Selector

Google Reader Shutting Down

Well Google finally let loose the news that they are Spring cleaning the Google Reader product and shutting it down July 1. I am to happy about this because I have been a heavy user of RSS for at least twelve years.

I used a web service called bloglines first then when I bought a Mac I used NetNewsWire for years. NetNewsWire didn’t really have a syncing solution so and bloglines was going to shutdown so I moved my feed reading to Google Reader and I used it via the web for years. When Google released the free Reader service they basically killed all other RSS services and most of the desktop clients.

I have always preferred desktop applications for feed reading. Google has no design sense outside of search and email, their other products have no design sense. NetNewsWire added the ability to sync with Google Reader and for a while everything was good. Then NetNewsWire started having problems syncing with the Google Reader service and those problems just kept getting worse.

I went looking for alternatives and eventually I found a wonderful Mac app called Reeder that was designed to be a desktop front end to Google Reader. Reeder also has a nice iOS app that I use. I have been using Reeder on multiple machines and I have been very happy with it. I don’t think I have been to the Google Reader site other than to add new subscriptions more than a couple of times in the last two years.

Google hasn’t been showing any love for the Reader product for years other than stripping out features in an effort to force users to move to Google+ a product that is a completely different tool than Reader. Which is like replacing someone’s hammer with a saw and trying to tell them it’s a much better tool for driving nails. The death of Google Reader has been a long time coming it’s still frustrating for those of us who used it in one form or another.

The question now is what can replace Google Reader. The developer of the my favorite RSS reading applications tweeted that his users don’t have to worry so my hope is he had the forsight to see that Google Reader wasn’t long for this world and he has been working on enabling a substitute of some kind.

What I would like to see is for someone to develop an RSS syncing solution and charge a reasonable fee to users and application developers and fill that data store role Google Reader has been doing. Then allow anyone with an account to use any front end they want. I believe that would be a solid business. Whoever did that could quickly become the Twitter of RSS except they would have a viable business model.

So I am hoping for an RSS syncing solution that will allow me to continue to use my preferred RSS reading applications. A solution that will grow and develop RSS tools. I want the end of Google Reader to spur the growth and development of RSS as it is a wonderful part of the open web.

A Great Ruby Book

I recently finished reading a great book Practical Object-Oriented Design in Ruby by Sandi Metz also referred to as POODR. This is one of the best software design books I have read. I usually skim a technical book because they are usually so dry or basic that I find myself not getting much out of them and I will drop them half way through. POODR however uses a great iterative method of illustrating it’s points. This kept me engaged and thinking about what I was reading.

Sandi starts with a naive implementation of a solution to a design problem and then shows the issues that arise from that solution. She then iterates the solution several more times until she has arrived at an elegant solution that will deal with change well. Sandi stresses that a good design is one that deals with change well.

POODR taught me how to approach design problems in a more Ruby way. I really enjoyed POODR and I feel like I got a lot out of it. I have already used the lessons I learned from it several times. I have also been able to illustrate to the other developers on my team why doing the things I have learned are a better way to approach a problem than what had been done previously. I personally and through me my team have benefited from Sandy’s excellent work. I highly recommend Practical Object-Oriented Design in Ruby for anyone interested in working with Ruby. I think it would be a great second Ruby book for anyone after reading a book on the Ruby language like Programming Ruby.

Tear Down and Rebuild

I am going to be upgrading my work MacBook Pro to Mountain Lion over the Christmas break and I have decided to tear down and rebuild my Vim setup.

Currently I use pathogen and git submodules to manage my Vim plugins. I have accumulated quite a few plugins over the last two years and my Vim install has developed some quirky behavior and I am going to take the os upgrade as an opportunity to do a reset in Vim.

My plan is to try the Vundle plugin manager for Vim and then start adding back in the really nice Vim plugins from Tim Pope. Once I have the basic git/ruby/rails plugins setup then I will move on to testing plugins I trust less.

Apple Gets My Money Again

I have been a bit ambivalent so far about the iPhone 5 since I was pretty happy with my iPhone 4. However my iPhone 4 had started to get a little flaky recently. The larger screen on the iPhone 5 as well as being able to use Siri is very enticing. I have been waiting patiently for the AT&T store to get some stock in.

I prefer to actually go to the AT&T store to make sure they don’t mess up my contract when I upgrade our phones. I called the store on Saturday and asked if they had any of the iPhone 5 in and they said they had just received a shipment.

I asked my wife if she would like to upgrade her phone and she said yes so I drove into town and there were only two people waiting in line ahead of me. AT&T now takes your name and puts you on a waiting list to be helped which is much better than having to stand in line.

I got to go around the store and play with the other phones that were on display while I waited. AT&T seems to carry at least twenty Android phones, a handful of Windows Phone 7/8, and the iPhone 4S and 5. I saw a couple of people getting the iPhone 5 but it seemed like most of the customers in the store were getting Android phones.

The Android devices have some interesting features and they do have the best maps app right now. However I can’t get past the fact that they look like Linux machines. I ran Linux at work and home for several years and then I ran Windows XP/7 and now I use a Mac. I like having a device that looks nice is well made, and works well without having to manage it. I see the Android devices as a suboptimal solution for the average smartphone user.

Another interesting thing I noticed was that no one else looked at the Windows Phone 7/8 devices in the entire time I was in the store. I have a lot more respect for the Windows Phone 8 devices because Microsoft didn’t try and copy Apple they came up with their own mobile computing experience. I just think it took them to long to respond to the iPhone.

I was able to pick up a white iPhone 5 for me and a black one for my wife. I setup the phones as new phones and synced with iCloud to get contacts, notes, photos setup. I then had to setup a bunch of applications I use manually which was a bit of a pain. It would be nice if all of that could go through iCloud.

So far I am really enjoying the iPhone 5. I really like the larger screen and better performance. The iPhone 5 is super slim and light which doesn’t sound like a huge benefit until you actually hold it in your hand or put it in your pocket and barely notice that it’s there. I am going to try and get by without putting a case on my phone which would make it thicker and heavier. I am going to have to be careful and not lose it in the couch because the stainless steel back is pretty slippery.

I have a grandfathered in unlimited data plan with AT&T so I am looking forward to the availability of LTE. I read that AT&T is supposed to roll out LTE service nationwide by the end of 2014 so I am hoping that living in one of the more populous parts of the state outside of the Chicago area will put us higher on the list of areas to roll out.

Retina MacBook Pro and Windows 8

I was out running some errands this morning and I had a little time so I ducked into Best Buy to check out Apple’s new toys (the nearest Apple store is 3 hours away). I got to hold and iPad mini and it was a lot better than I expected it to be. I was quite impressed. I still wish it had a retina screen for it’s price though.

I also got to play with the new 13” Retina MacBook Pro and it was really great. I was kind of blown away how much nicer it was than the Air. I read a review of the new Pro on The Verge yesterday that was kind of wishy washy on it but I have to say it was the best looking screen I have ever seen on a laptop.

I have been thinking of picking up a new laptop and I was kind of leaning toward the Air but now that I have seen the 13” Retina MacBook Pro it’s a much harder decision. I will probably wait for the next minor revision of the Air/Retina to make a decision though. 

After drooling over the new Apple gear I went to checkout the Windows 8 machines for the first time. I was primarily looking at the notebooks in the middle of the hardware range, machines with i5 or low end i7 processors. I must say I was not impressed.

Scrolling and navigating inside Win 8 isn’t intuitive at all and didn’t work very well on any of the machines I tried it on. I would hate to spring Win 8 on my family I think it would be very frustrating for them. It will be interesting to see how much push back Microsoft receives in the coming months as to the new interface. Will people choose a new Windows 8 machine or a tablet computer, whether it be an iPad or another tablet. 

Some of the laptops running Windows 8 had touch screens and although it was interesting to scroll and select a tile the actual screens looked awful even in comparison to the other Windows laptops. It is easy to tell that those manufacturers picked the cheapest crappy screens they could find. I wonder what Windows 8 would be like on some really good hardware that was designed to really run it well.

Is It Time for a New Twitter

I love Twitter. Twitter is a great service. Ever since I discovered Twitter and started following people and it really clicked for me what Twitter was I have loved it. I have communicated with new people all across the country and made connections I wouldn’t have without Twitter. Twitter has also become an important news channel. I have seen many news stories mentioned first on Twitter. Twitter is both enjoyable and useful to me.

However in Twitter’s attempts to monetize ad revenue it has been making some changes that will make the service worse. If in Twitter’s attempts to control the presentation of tweets they lock out third party client developers many of twitters most engaged users will not be happy.

Twitter’s own desktop and mobile clients are pretty bad and they haven’t gotten better, and in the case of the iOS app it’s gotten much worse. Twitter has hundreds of people working for the company but it’s pretty obvious they aren’t working on making the desktop and mobile clients better only more uniform.

I have been following the development of the App.net project to create a user supported twitter competitor and while it seems like a good idea I really doubt they can get enough people willing to pay $50 a year to make it worth it. At $10 a year they might have a business, however I would be surprised if they could get enough people to sign up to be profitable. Without users a social network can’t survive.

So the current options aren’t great. Twitter seems intent on locking down their platform and I am skeptical about any viable alternative appearing. I will continue to use TweetBot and hope that Twitter doesn’t lock them out anytime soon.

Product Deployment

This has been kind of a crazy week at work as we have been getting our product MVP out the door. I have learned all kinds of things this week about product design and deployment.

Our product is divided up into applications and services and we are running on jruby inside the GlassFish Java application server. Since I come from a .Net background I haven’t dealt with the need to run inside a separate application server before, unless you consider IIS an application server. We have a developer on our team who comes from a Java background and he has been a great help setting up profilers and drilling down to find some problematic caching code we had in our service client. We have reduced the number of calls to our services and been able to get some decent page load times once the application server has fully warmed up. Something we have been dealing with is the JVM warm up time. The JVM used the JIT compiler while collecting statistics about the code and eventually compiles to native code. The warm up time of the JVM is fairly lengthy so we are trading some initial speed for throughput.

Update 7/1/2012 It took me a while to get around to finishing this post and in the meantime we have had some issues crop up that have made think some hasty decisions were made. Right now we are experiencing an issue where an error occurs and then GlassFish starts returning the wrong response to incoming requests. This error is rare and difficult to reproduce, we are having problems tracking it down. We have found some references to what looks to be this issue online and seems to be a problem in the JRuby stack. I have been working on web applications for ten years and I have never seen this before on any of the other platforms (PERL/PHP/.Net) I have worked on.

Update 7/3/2012 It looks like the issue with User A making a request and getting the response for User B is a problem with AJP and other people have seen it. We are in the process of switching to the HTTP connector between Apache and GlassFish as we haven’t been able to reproduce the error using this configuration.

I now believe we have over optimized our deployment stack prematurely. I think we should have put the effort in to moving to Ruby 1.9.x rather than JRuby. If we had just used Passenger and Apache, which is a much more common deployment scenario, we would have much more predictable performance. Deployment would be much faster and I don’t believe we would be seeing these obscure issues we are dealing with now. If we actually started to run into performance issues it would be much easier to scale by adding more memory to the servers or adding AWS EC2 instances as needed.

Tofu Tacos

Last night my son’s extra music lessons started back up with a new teacher. The new music teacher is the husband of the old music teacher who had to stop giving lessons as a result of a some medical issue she had. My wife took our son to his lesson and I watched our daughter. She was feeling a little beat last night because of to much playing out in the sun so I made her breakfast for dinner which she enjoyed.

Next I decided to try making something a little different for for the rest of us. I have recently discovered that I am not averse to eating tofu so when I saw some extra firm tofu at the grocery store I bought it. I had originally been thinking of using it in a stir fry but I decided to wing it. I cut it up and fried it and then seasoned it with taco seasoning. I made some black beans and corn and whipped up quick guacamole and served tofu tacos. I didn’t tell my son what it was before hand. He started eating it and said it was good chicken. However about two-thirds of the way through his taco he said it tasted funny so I told him it was tofu and not chicken and then he was like “oh, OK” and then he didn’t complain about it anymore.