Posts

Showing posts with the label Ruby

Rails Conf 2010 Day 3

A few days late on this because I've been sick all weekend. There just has to be a way to do climate control in conference centers in such a way as to not destroy the planet and, more importantly, Jake's health. I seriously wore black jeans and 2 shirts on hot summer days and yet I was shivering and caught a cold. But let's get to last day of Rails Conf 2010 and my exciting adventures therein. (tweets are in italics ) Woke to "Relax" by Frankie Goes to Hollywood. Which is good 'cause my heart was pounding. Settled it with some bacon. #railsconf Yep, I could feel cold coming but I was in denial. I ran into Neal Ford at breakfast and we chit chatted about this and that and then he mentioned that he had read my blog post from yesterday. First thought: I published that sucker at 1am this morning and he's read it already? Second thought: Oh shit, what did I say about his keynote -- I think I called him a jerk at some point. But my brain was foggy and so...

Rails Conf 2010 Day 2

Image
Only 40 tweets today (re and otherwise). I must be slowing down in my old age. Tweets are in italics . Today's morning music was "Bulletproof" by Pop Will Eat Itself. Cram that in your head @ryanbriones Ryan was complaining yesterday that he had the theme from flash stuck in his head all day because of me. That sounds awesome! I had a Daft Punk song stuck in my head all day today and I was a better person for it. Trying to work on my Lightning Talk. Lightning talks are usually the best part of any conf so it better be good. 4:25 today #railsconf Lightning talk is finished. Title: "ActiveMQ and ActiveMessaging: I've Experienced the Pain So You Don't Have To" #railsconf Yeah, I got up, worked out, ate eggs wrapped in cheese and bacon, showered and then realized I had gotten up an hour early by mistake. Opportunity! So I worked on the lightning talk. To be honest, I was kinda pissed at myself for the boneheaded alarm mishandling but if it doesn't ...

Lone Star Ruby Conf 2009 Day Two Afternoon Sessions

More Lighting Talks! A lot of people skip the lighting talks, but I find that some of the best stuff at any given conference comes out of the these intense 7 minutes sessions. Jared Ning: "Ruby Without Borders" Matthew Todd gave a talk last year asking for people to came to Tanzania and help him code in Ruby. Jared did and he loved the experience. He mentioned a very useful TextMate short-cut: If you have a bunch of files and folders open in the project drawer and you click the chevron (the triangle thingy) to close a top level folder then when you open it back up TextMate remembers the state of what folders were open and closed underneath. But sometimes you want to close down all the folders underneath. Option clicking on the chevron will do that. Also, option clicking on a closed chevron will open up all sub folders. I've been looking for this. Check out Ruby Without Borders . Jeffrey Taylor: "Fast Multi-protocol XML Parsing" Jeffrey's project had to ...

Lone Star Ruby Conf 2009 Day One

I have to admit that this morning I was not looking forward to seeing another day of presentations after 3 days of Agile 2009 and 1 of Software Craftsmanship North America, but almost immediately upon entering the Norris Conference Center I felt welcomed. Part of this is that Jim Freeze, the LSRC head organizer, is a heck of a nice guy who recognized me in the hallway and said hello but also that when I sat down I noticed that every table had plenty of power for computers. Awesome. At Agile there was no power in any of the rooms and very limited access anywhere else. I type up my notes on the presentations as they happen (and I notice a lot of others do the same) so I spent much of my time at Agile glancing at my diminishing power and hoping I could make it through the next session. I know a lot of people hate open laptops at conferences but studies have shown that if you give some people something to do with their hands while they listen to a presentation they consume it more eff...

Hey did you know that some versions of Ruby 1.8.6 don't return the right error codes?

I didn't. The box I was setting up CruiseControl.rb on today had some crazy early version of Ruby 1.8.6 and so test failures returned a code of '0'. Which meant the build would not fail until I upgraded to a more modern 1.8.6. Patch level 114 did the trick. Why are we using 1.8.6 on a new project? Well mostly so we can run along side an older Rails app using 1.8.6, but also because 1.8.7 doesn't really offer that much more to justify the headache of running two rubys on one box, and finnaly because I have no idea when 1.9x will be acceptable on all the gems I use. Good times.

Metric Fu Now Includes Flay, Roodi, and Reek

I released metric_fu 0.9.0 last night and just look at all the super cool changes since 0.8.0: Flay task finds duplication and structural similarities in your project Reek identifies common code smells Roodi finds mistakes and troublesome code A configuration class so you can configure like the big boys Standardization of the reports look and feel Increased RSpec coverage Source control type is auto-detected for Churn task Under the hood refactoring to make adding new metrics reports easy Of course it still does all the old stuff like 2 different types of complexity reports, code churn analysis, code coverage, and good old Rails stats. Set up a Cruise Control task to generate metrics reports every day and then you pinpoint the exact moment your project went to hell (or possibly avoid that fate -- your call). Check out the project home page at: http://metric-fu.rubyforge.org/ The best part about this whole thing is that almost everything added since release 0.8 has been added by the...

Naked Hashes are Trouble

So I had this form in a Rails view that needed some changes so, amongst other things, I changed this: form_tag(:action => 'search') to this: form_tag(:action => 'show', :method => :get) I had noticed that the show and search methods essentially did the same thing (and had the same views) -- which I why I refactored. However, when I made the change I got a 500. I was using restful routes and this form needed to be a get -- which I thought I had indicated. But I had not -- what should have put in the view was this: form_tag({:action => 'show'}, {:method => :get}) There's this idiom in Ruby where we don't put curly braces around hashes if we don't need to, but I've consistently lost a bunch of time to mistakes like the one above. So I'm thinking about explicitly denoting hashes with curly braces in my future Ruby code just to improve intentionality.

Ruby Conf 2008 Second Afternoon/Evening

What Every Rubyist Should Know About Threads by Jim Weirich Concurrency is becoming bigger as computers get more cores. If you look at a graph of clock speed they flattened out in 2003. Past performance gains: clock speed (not so much anymore) execution optimize cache results So if clock speed is not going up at a rapid pace anymore, now what?: hyperthreading multicore (the new saviour) caching Applications will need to be concurrent to exploit multicore machines. 100 CPU machines are on the horizon. Race conditions are trouble: If thread one has this: shared_variable += 1 And thread two wants to do the same thing: shared_variable += 1 What if the first thread looks up the shared_variable and find that it's 25 but before it can change it the second thread reads the value (still 25 because it hasn't changed). Now the first thread will add one (shared_variable becomes 26) and write the result back to memory, then the second thread will add one to the...

Ruby Conf 2008 Second Morning

Aristotle and the art of software development by Jonathan Dahl How do you identify a good programmer? Jon says Ethics. Ethics is about how you live your entire life. He thinks the what makes a good software developer and what makes a good person have parallels in their answers. Kant -- Only act on principles that you would like to become universal law. Kant would have loved Haskel. There are principles in software, but sometimes they conflict such as DRY vs write understandable code. DRYing something up can make it hard to read. John Stuart Mill Utilitarianism -- what matters is the effect of the action. The ends justify the means. However, It's hard to know whether the effects will be good ahead of time. The Pragmatic Programmer is a good outcome of Utilitarianism. But Utilitarianism may lead to sloppy code and processes. Or the Cowboy coder. Aristotle - ethics as virtue. The person is the important part. For Aristotle: ethics == a life well lived == happiness == virt...

Ruby Conf 2008 First Afternoon

Image
I was thinking today that most people design their talk to last 50-55 minutes but I've noticed that conferences have shorter and shorter times slots. 40 minutes + 5 for questions is becoming the standard. So the end slides tend to go by pretty fast. Another thought: Print the ID badge for the conference on both sides. Exactly the same information on both sides. Fully 50% of the people at Ruby Conf have their badges turned around to the white side and when I can't remember their names (even though we were just introduced) I can't cheat because all I see is a stupid white rectangle. Somehow GLSEC managed to figure this out, why can't other conferences? JRuby: What, Why, How...Try It Now by Tom Enebo and Charlie Nutter Why JRuby? Well the JVM is awesome. 15 quadriliion man years of work or something. 15 quadriliion Sun man years can't be wrong, right? They have declared that Ruby 1.8 is "done" (again) and 1.9 mode can be triggered with a flag. Full ...

Ruby Conf 2008 First Morning

Woke up 15 seconds before my alarm went off again today. Perhaps I'm a little keyed up? Keynote - Matz "Reasons behind Ruby" Matz's presentation started out with the question: Why Ruby? He asked why even though Ruby has lots of problems, like all languages, why do we love it? Which is interesting. I've seen Matz talk a few time now and he always talks about the love of languages. The idea of loving what you do is never far from his mind. When Matz was young, his first computer was a pocket computer in 1980 -- only 1400 steps allowed. Only 150 memory places. And the Language was BASIC. Later he found Lisp and it was the opposite of everything in Basic -- total freedom to do just about anything. And he loved it. That was, however, before he started using Lisp. When he started using Lisp in practice, he wasn't having a good time. Basically Matz felt that Basic took all the power from him, but Lisp gave too much back. He wanted to have a framework to ...

Metric Fu's Churn Now Supports Git

I just released version 0.8.0 of MetricFu. New in this release: Source Control Churn now supports Git (thanks to Erik St Martin) Flog Results are sorted by highest Flog Score Fix for a bunch of 'already initialized constant' warnings that metric_fu caused The flog reporter can now handle methods with digits in their name (thanks to Andy Gregorowicz) Internal Rake task now allows metric_fu to flog/churn itself To use the Churn task to find files that change a lot with Git, put this in your Rakefile: MetricFu::CHURN_OPTIONS = {:scm => :git} MetricFu is a Ruby Gem that gives you a fist full of code metrics. Find out more at the home page .

Different Ways of Installing Metric Fu

Something I didn't mention when I announced the re-launch of metric_fu as a gem is that now, because it's a gem, you have more options when installing it in your project. First option: Vendor Everything . Lots of people are big fans of unpacking gems into the vendor directory of their Rails project (or a similar folder in a non-Rails project) so that everyone who checks out the code gets the right version of the gem. You can then require it in your Rakefile like this: require 'vendor/gems/jscruggs-metric_fu-0.7.6/lib/metric_fu' However... Second option: Conditionally require the gem. When I announced metric_fu back in April, a lot of commentors bemoaned the fact that they would have to install something into their production code that wasn't really necessary for production. I don't really mind doing this as metric_fu does not modify any classes: It's mostly just a bunch of Rake tasks (and some report building code). However, I see their point. So if...

Windy City Rails Part Two

Yesterday , I talked about the first half of the first ever Windy City Rails conference that happened on Saturday at IIT. Tonight, I'll pick up where I left off with my summary of the presentations I attended. Virtualization and Elastic Servers -- Yan Pritzker of CohesiveFT The gist of this talk is that the Rails stack is not well known so why not let CohesiveFT handle deployment for you. It's a virtualization factory, that lets you put together a custom Rails stack and they can deploy and maintain it for you for as little as 10-15 bucks a month. Also, he pointed out that virtualization is a solution for your front end guys getting a working version. Which, having tried to get many a design person's computer up and running, I think is a pretty cool idea. Ten Things I Hate About Web Apps by Micah Martin Short list of things Micah hates about Web Apps: You need to know css, html, js, and the actual programing language just to get started. Html -- only 3 fonts to chose fr...

Windy City Rails Part One

This weekend was the first ever Windy City Rails Conference and I was lucky enough to not only attend but also to speak. I thought I'd sum up the talks I attended in case anyone was interested. After Ray Hightower, lead organizer of the conference, welcomed everyone Ryan Platte gave the first talk of the day: "Outside the sweet spot" Ryan's talk was about getting Ruby and or Rails into a large organization which is committed to things like: Windows, Oracle, etc. I.E. not the typical Rails stack. In Ryan's experience, Rails makes it's way into such an organization the following way: Some guy picks up a Rails book and says "Hey, this is way better than the excel spreadsheet we've been using." Then he talks one boss into the project, and maybe they hire some consultants to help. However the rest of the organization has issues with Rails (it's slow, not compatible with their stack). Ryan's advice is: Do top quality work quickly -- get ...

Metric Fu is Now a Gem

Image
I just released version 0.7.6 of metric_fu and there's all sorts of new stuff: First, MetricFu is now a Ruby gem on GitHub at: http://github.com/jscruggs/metric_fu Also, the Flog task can now flog any set of directories you like. Just put this into your Rakefile: MetricFu::DIRECTORIES_TO_FLOG = ['cms/app', 'cms/lib'] And, the Flog reports are much nicer: The Flog report generator now looks at a MD5 hash of the files its examining to determine if they files need to be re-Flogged -- which saves time. The Saikuro report generator can also look at custom directories like so: MetricFu::SAIKURO_OPTIONS = {"--input_directory" => '"cms/app | cms/lib"'} MetricFu started its life as a Rails Plugin, but I'm trying to turn it into a flexible gem that can be used in any Ruby application (but still have defaults that enable easy use in a Rails project). Eventually I'd like to create something that could tell you about methods that have hig...

Lone Star Ruby Conf Second Day (morning edition)

While checking out at the hotel I ran into Coby from confreaks.com They are recording the conference so you'll be able to see the talks online sometime soon. They're not cheap, but their videos are very good (they capture the output of the presenters computer and display it side by side with video of the presentation -- you seriously need to check out their site), and they offer a discount if the conference is willing to CreativeCommons license the talks. Starting off the morning was "Ruby: A Year of Innovation" with Gregg Pollack & Jason Seifer. They had a lot to cover so it went pretty fast. I tried to keep up as best I could. Jason Seifer was up first: HPricot - awesome for scraping websites Juggernaut - server push with rails -- keeps a connection open Ambition - write your SQL statements in Ruby Prawn - Ruby based PDF generation Capistrano Ruby VMs roo - spreadsheets Excel, google docs Dtrace and Ruby -- memory stack live Skynet - map reduce for Ruby Data...

Lone Star Ruby Conf First Day

(or the second day if you count the tutorials) To start things off Jim Freeze got up and announced that there are 282 attendees and seats for 280 -- So make friends. The the first talk of the day was "The Next Ruby" by Bruce Williams and he (of course) discussed the difference between Ruby 1.8.6 and 1.9 Bruce recommended a good test suite if you're planning to move to 1.9 and I have to agree. Tests are good for lots of reasons (including design) but they pay for themselves 100 times over when you need to do a big tech migration. Because of changes to string, anything string heavy (such as parsers) is gonna need some love. On the plus side: "ruby"[0] => 114 in Ruby 1.8.6 "ruby"[0] => "r" in Ruby 1.9 Yep, I've been burned by that and I'm glad to see sanity carry the day. In other news: Hash.select now returns a hash Hashes will maintain order :this === "this" #true Because of Multinationalization Strings now have each...

Training Day at Lone Star Ruby Conf

First, I'd to extend a big thanks to Joe and Jim for giving me a ride to the conference today. The two tutorials I decided to attend today were: "The Advanced ActiveRecord Workshop" with Gregg Pollack & Jason Seifer (the Rails Envy Guys) and "The Ins and Outs of Ruby I/O" with James Edward Gray II and Gregory Brown. Both of which were excellent. The Advanced ActiveRecord Workshop covered: Loading large data sets (the 'ar-extensions' gem helps lots). A gentle reminder to properly index your freakin' database. How Rails optimizes multiple :includes in finds and how that goes to hell if you combine lots of :includes with :conditions The super awesome Named Scopes (which you need to look up right now, if you haven't already because it's not just about defining custom finders -- it's about defining custom finders that you can chain together and get optimized queries) Polymorphic Associations, Single Table Inheritance, Dirty Fields, Associ...

Syntax Highlighting for Ruby Made Very Easy

So I've been making do with lame-o 'pre' tags for my code snippets and my blog looks, well, lame. But the various alternatives for highlighting ruby either didn't work for Blogger or smacked of effort (and you know how I feel about effort). Well, recently I joined Obtiva and I was being all nosy looking at my new co-worker's blogs, when I found Tyler Jennings post about creating Spotlight . Take some ruby code, paste it into the text box, press a button, and you get some html which you copy and past into your blog. You'll have to include the default css in your css file the first time, but that's not too hard. Output looks like this: 1 class Echo < ActionMailer :: Base 2 def copy formatted_message, incident_id 3 users_with_echo_emails = User .find( :all , 4 :conditions => " echo_email is not NULL " ) 5 users_with_echo_emails.reject! {|user| !user.receive_echo?} 6 recipi...