Sunday, October 20, 2013

Letter Frequency in Text and Rails

The other day a coworker and I were discussing keyboard layouts and this led into whether or not the character frequency (how often various letters are used) in a Rails application would be the same as it would be in normal text (though obviously, the code will have many more and more varied special characters). I thought that it would be but, he didn't think that would be the case. Since I had a bit of free time this weekend, I thought I'd write a bit of code to figure it out. For the text, I used Project Gutenberg's copy of Moby Dick and for the code, I used a smallish Rails project of mine.

Here's the code and results ...



As you can see, the histograms are pretty similar. For this particular Rails project, I was using HAML, so I'm not sure if there'd be any differences if you used erb or not. Also, as I noted, this was a fairly small project.

The code runs against a single file that's passed in on the command line. So run it like this ...

ruby letter_freqency.rb moby10b.txt > moby_results.txt

for example. For a rails project, I cat'd all the files together and then ran the code like this ...

cat `find . -iname \*.rb -or -iname \*.haml` > rails_files.txt
ruby letter_freqency.rb rails_files.txt > rails_results.txt

Let me know if you try this on one of your projects and post the results in the comments.

Sunday, September 29, 2013

Rails and Windows

In a word ... "Don't".

I often see posts, especially on LinkedIn, with titles like "How do I learn Rails" etc. My advice is always to start with Michael Hartl's Rails Tutorial. A related question that often comes up though is about using Windows to do this. There are often comments that you can use Windows for this, cross-platform is good, etc. The truth though is that you're not going to have a lot of success developing Rails on Windows and if you're looking to move into Rails development as a profession, it will not probably help. There are a few different reasons for this, but first let's take a look a why you should develop for Windows.

If you've decided that Windows is a great platform and that you're ready to do your part to bring it to the Rails community, then by all means, go for it. Very few in the Rails community do use Windows, but if someone was willing to do the work to make everything that's commonly used work together under Windows, then I think it would be welcomed with open arms.

If you're just trying to learn some Rails though, this is probably not a good approach. While you're developing, you're going to have issues come up and those that can help you are going to be few and far between. In fact, even if it's not a problem with Windows per se, the fact that it works on Mac/Linux (or even appears to work there), is going to make it hard to get others interested in the problem. You're almost certainly going to have to come up with a failing test case (you should anyway) and show that this is the case. The problems you are, in general, going to be different than you'd see on a either a Mac or Linux and so most Rails developers won't have seen them and won't be able to help you solve them. Also, a big part of Rails development is done with the command line and while you can get bash or some other Unixy shell running, it's going to be sub-optimal.

For someone who is looking to move into Rails development, this is probably even more true. You're going to have all the issues listed above and those problems and their solutions won't be relevant to the issues your co-workers are going to be having. Additionally, whatever tools (here I'm thinking of editors and editor plugins especially) get adopted internally are unlikely to work well or even at all on Windows. A big part of the Rails development experience is collaboration and you won't really be able to benefit from or contribute to this collaborative process.

So, I recommend either breaking down and buying a Mac (a pretty expensive idea if you're just looking to experiment) or dual booting using Ubuntu (a pretty common platform where you'll be able to get some help easily if you run into issues).

Good luck and I'd be glad to hear your thoughts in the comments and in this case I wouldn't mind all that much being proven wrong.

Sunday, July 28, 2013

Interviewing Redux

In my last post I talked about interviewing and overrepresenting your knowledge. We had a similar situation with a different candidate and I'd like to talk about that a bit.

A typical interview question that I've used and had used on me goes something like "What blogs do you read regularly?". It's generally used as a conversation starter to see what you're interested in and how much you stay up on things. The candidate in question told us that he read "lots of blogs" but when pressed couldn't name a single one or even talk about a post he'd read recently. As with our other candidate, he could have probably redeemed himself but didn't.

You should be reading blogs. I'd suggest at least three or four with a mix of ruby/rails and general technology. thoughtbot is good along with Ruby News. and ruby source. Before any interview make sure that you've read one or two posts pretty in depth and be prepared to talk about it a bit.

If you have other suggestions for blogs to read or thoughts on interviewing (either side of the table), be sure to leave them in the comments.

Saturday, July 20, 2013

Interviewing Classic Mistake

We were interviewing a for a position the other day, when the interviewee made the pretty classic mistake of overrepresenting his knowledge on a particular subject. In this particular case it was puppet/chef, although I've seen it happen a number of times over the years. His resume should have been a warning, he listed a large number of technologies that he knew ... actually far more than he could have known. You should keep your list down to a handful of things that you know really well. Anyway, we've been looking at puppet recently for building our machines and using them for development also and since this was on his resume, one of my coworkers asked him about it. "Oh yeah, I love puppet and chef." was the reply. "Great, where have you used them and what did you like about them? Also, where do you think each is strongest?". "Well ... I haven't really used them in production, more just played with them." Hmmmm... at this point he's not making a very good showing. If you come out that you "love" a technology, then you probably should have done more than "play" with it. "OK, then exactly how did you play with them? Did you run the tutorial?". "Yes, I ran the tutorial". By this time, we weren't even sure that he'd run the tutorial or just read a blog post or something. He probably could have redeemed himself after this (he didn't), but it would have been difficult.

In general in interviews, you don't want to be talking about things you don't know about. You really want to be talking about things that you do know about. If you don't know something, don't put it on your resume and certainly don't say much more than you've "read about it, it seems really interesting, and you'd just love to learn more about it here at XYZ Corp when you start."