Code Retreat

Last weekend I participated in the Global Day of Code Retreat here in Austin. I was impressed at the diveristy of participants, the overall good nature of those there, and what I was able to learn even while pairing with relative beginners. When I got there, there were 3 women and 3 men in the room. By the end of the day there were about 6 women and 10 men. At least 6 of the participants grew up in foreign countries. It was, for a computer meetup on a Saturday, a fairly diverse crowd. I was impressed. ...

December 19, 2013 · 2 min · Mark Simoneau

Quick Script for TMUX pair sessions

Update 2013-06-14: Improved the script, removing the github-auth dependency, some of the OS X dependencies, and added firewall punch-through (user specific) and ssh-command with external IP auto-copy to clipboard I wanted a quick and easy way to set up a new TMUX session with a brand new pair, so I came up with this: #!/bin/sh gh-auth add $1 sudo cp ~/.ssh/authorized_keys /Users/pair/.ssh/authorized_keys sudo chown pair:staff /Users/pair/.ssh/authorized_keys gh-auth remove $1 tmux -S /tmp/pairing new -ds pairing && chgrp staff /tmp/pairing && tmux -S /tmp/pairing attach -t pairing sudo rm -f /Users/pair/.ssh/authorized_keys That will download ssh keys, create a tmux session, and attach to it. When you’re done it will cleanup so the other person has no access to your box. ...

June 6, 2013 · 2 min · Mark Simoneau

Pairing Post Mortem : @thecommongeek - Ruby Koans

I paired with @thecommongeek last night again. This time we were more prepared and I think the session went much better. In our first session I misjudged where Dennis was as a coder and struggled a bit with how to pair with him effectively. This time we had him drive through ScreenHero and decided to start from the “basics” by doing the RubyKoans. The RubyKoans are meant for Ruby 1.8.7, but 1.9.3 is commonplace now, so we struggled a bit at the beginning. For anyone going through the RubyKoans on 1.9.3 getting a value19 in nearly all your errors, I’d suggest making the following changes on neo.rb (starting on line 34): ...

May 28, 2013 · 2 min · Mark Simoneau

Tic Tac Toe TDD

I spent a little (longer than I thought… maybe 2 hours?) implementing Tic-Tac-Toe in the TDD As If You Mean It style. Ended up with a VERY different implementation than I ever would have done if I just “started coding” – everything was only in one class, including the AI to “play” against itself. Observations: It was quite different to implement things inside the test method. I ended up coding like it "does something..." do player = Player.new def player.something # do work end player.something.should be_true end It was difficult to not refactor as I went. Many times I would see the duplication and want to refactor immediately. I resisted this urge until I felt the implementation was done, then refactored out duplication, ensuring that the tests continued to pass after each change. I’m still not quite sure how you’re supposed to improve design without breaking the rules. Doing pure method move seems limiting and doesn’t allow for you to see duplication. The only thing I could think of is that there can be additional refactoring after you’re “done” All in all, a very interesting exercise. I want to do it now on something broader, and eventually on something that has a core with a wrapper so that the core is purely TDD’d and the wrapper is thin, but swappable. I think Dominion is my next big attempt.

April 25, 2013 · 2 min · Mark Simoneau

Running Rails 3.2 on a shared Dreamhost with Passenger

Update: While it’s good to understand what you’re doing, this template file will get you so that after you get your app running, cap deploy:setup and cap deploy:cold works, assuming you have the host set up properly and have your app’s main directory cleared of all files. Everybody Loves Dreamhost, but… Dreamhost is a great little hosting company, but it really lags when it comes to keeping the latest software up to date. It’s version of Ruby is 1.8.7 and the latest stable version of Rails they have running is 3.0.3. That release is technically in “security fix” mode. Ugh. ...

July 20, 2012 · 3 min · Mark Simoneau

Split Badges with Twitter Bootstrap and HAML

I recently needed to display a few contextual numbers near each other in a web app. I’ve taken to liking the twitter bootstrap ‘badges’ for little informational numbers, especially with the color coding that badge-important, badge-info, and badge-success provide. Easy ways to quickly communicate not only the number, but a hint at what it means. The problem is that when you put a bunch of badges right next to each other, you get kindof a mess. ...

July 19, 2012 · 2 min · Mark Simoneau

Easy way to limit the length of a list

I have lots of lists on my new site that we want to show ‘only the first 5’ items on, but allow people to expand to see them all if they want. It’s common enough that I’d like to have an easy way to do it. Bonus points if it’s non-obtrusive. jQuery -> $('ul.show-more').each -> if $(this).find('li').length > 5 $(this).find('li:gt(4)').hide().end().append( $('<li><a href="#">Show More...</a></li>').click -> $(this).siblings(':hidden').show().end().remove() ) Now all I have to do is drop into my favorite haml template and bang out a list ...

June 15, 2012 · 1 min · Mark Simoneau

ImageMagick, JPEGs, and Orientation, Oh My

I’ve been working on a new project and decided to use CarrierWave to handle image uploads (and minor automatic manipulation). Everything looked great, but then my new boss, who has a penchant for finding the one or two things wrong with your latest well-tested feature uploaded a JPEG that looked fine in Preview, but automatically rotated on upload. After checking through the directory, it seemed that only the processed images were getting rotated. Actually, ‘rotated’ is a misnomer, they were actually just losing their orientation. JPEGs have EXIF meta data that can contain the orientation of a picture, no matter how it’s stored. This allows cameras to store everything as a 640x480, but display some in the reverse (480x640). The only thing different when the camera writes the image is what orientation the gyroscope adds to the meta data. ...

June 13, 2012 · 2 min · Mark Simoneau

DCI Generators in Rails

Recently, in my new project, I decided to take the DCI approach that Mike Pack outlined, which has been really cool. I’ve been able to keep my tests fast, and have very distinct buckets to put data (models), specific roles of that data (rather than cluttering up the models), and an easy way to take a use case and map it out programatically (contexts). I noticed that I was generating roles and contexts regularly and copying from previously written code examples so I decided to make role and context generators. The process wasn’t bad, but it did take a couple of steps that took a little digging to understand. ...

May 22, 2012 · 3 min · Mark Simoneau

CSS3 max-width and min-width selectors

I learned recently about min-width and max-width css selectors that allow you to specify certain properties that are applied under a maximum width and above a minimum width. This can enable a flexible layout that works on many different screens without multiple distinct layouts (instead, just CSS). This also makes it relatively easy to spot-test by simply resizing your browser to get an idea of how it will look on different size devices. ...

May 16, 2012 · 1 min · Mark Simoneau