Return to 10to1.be

Under the Hat


Create UML diagrams from the command line

13 Oct 2009

Maybe you know it, maybe you don’t but yUML is awesome!

Create and share simple UML diagrams in your blogs, wikis, forums, bug-trackers and emails.

Yesterday I was creating a new class diagram using yUML and besides it’s a great product it was a bit cumbersome working in a small textarea and pressing ‘Generate!’ (all the time). I fired up textmate and created a diagram using the yUML syntax. A couple of minutes later I had ruby script which generated the diagram using yUML by taking a text file as input.

Thanks to Jeweler it’s dead easy to create gems and release them to Gemcutter so a yumlcmd gem was born.

Installation

sudo gem install yumlcmd

Usage

yumlme -f your-diagram.txt

Example your-diagram.txt

[Customer]+1->*[Order]
[Order]++1-items >*[LineItem]
[Order]-0..1>[PaymentMethod]

Syntax overview: http://yuml.me/diagram/scruffy/class/draw

Output

yuml-output.png

I hope you like it as much as I do :)

Railscasts Xcode theme

25 Sep 2009

I use textmate for all things ruby, rails, txt, blog, xml, … and while doing so I enjoy using the railscasts textmate theme from Ryan Bates. Nice, clean and easy on the eyes.

Since I was never really happy with the standard Xcode themes I decided to port the textmate theme to an Xcode theme.

After days of work, or was it weeks, I got it right. I think.

No really, it just took about 5 minutes clicking around in the Xcode theme editor. You can find it here.

Enjoy!

Find or create with hash attributes

04 Sep 2009

Dynamic finders in Rails, represent some the ‘magic’ we’ve all gotten used to. One can use these dynamic finders to create or initialize a new object when it doesn’t already exist.

# Find a user by screen_name_
user = User.find_by_screen_name("atog")  

# So instead of ...
user = User.find_by_screen_name("atog")  
unless user  
  user = User.create(:name => "atog")  
end

# ... you can  
user = User.find_or_create_by_screen_name("atog")  

It gets even better. By passing a hash to the finder you can initialize or create a new object with all the values while only the attribute named in the finder will be used to find the object.

user = User.find_or_create_by_screen_name(
		:screen_name => "atog", 
		:name => "Koen Van der Auwera")

Working with multiple ruby versions - the sequel

28 Aug 2009

Remember when we talked about how to use multiple versions of Ruby on your Mac?

Well, apparently that post is already outdated. Now all you have to do is to install the rvm gem

I’ve just tried it, and it works without a hickup. I’ve noticed one little thing: the installation of the gem creates a file ~/.bash_profile. This, apparently, overrides ~/.bashrc on my Mac. I lost all of my neatly-crafted terminal environment. Deleting ~/.bash_profile fixed this. Happy camper!

Present

14 Aug 2009

If this isn’t a discovery! I couldn’t have said it better myself.

twitter tweet

Just like Nick Quaranto, I prefer positive conditions. For example, you’ll find more unless object.blank? in my code than if !object.blank?. So I’m very happy that I learned about present? today.

present?, the inverse of blank?. Heaven.


About this blog

You’re reading Under the Hat, a weblog written by 10to1.

Who’s got the mic?