labria’s ruby blog

random ruby/rails stuff

New TLD

one comment

Seeing how new Top Level Domains get introduced all the time, and how .com is misused, I had a idea:

.app TLD

Lets face it, we need it. lighthouseapp.com, kaleidoscopeapp.com, and I'm sure you can name a few more each.

Wouldn't it be nice to have a domain for your application? Be it a web-app or a desktop one, it needs a website, right? And wouldn't cheesegrinder.app domain be more descriptive than cheesegrinder.com (which is occupied, so you would end up with cheesegrinder.info or cheesegrinderapp.com)?

I'm not sure it's feasible, but I still think it would be nice.

Written by labria

April 19th, 2011 at 4:59 pm

Posted in Uncategorized

Mac OS X Lion and Ruby (or, NoRuby)

6 comments

I've installed the Lion DP twice. Once (DP1) as an upgrade to Snow Leopard, and the second time on a clean partition.

You can surely find all about Lion in the interwebs (it rocks, except some quirks), so I'll just rant about one thing that is interesting to me: Lion and Ruby.

First, about DP1 over SL. Everything was fine, all the installed rubies continued working smoothly, no trouble whatsoever. Too bad I had to reformat and give that MBP away.

Then came the clean DP2 install. In short: it was a mess. Sadly, I didn't keep logs of my attempts to make it right, but I guess anyone can relive it and publish the logs and errors, if they want to. I went through about 5 to 10 attempts to install ruby and some gems, all failed, until reality caught on with me and I had to reboot back to SL to get my work for the day done.

First, about Lion and gcc. By default you don't get one. XCode4.0 doesn't install, only XCode4.1DP. Somehow, XCode3.2.3 is also installable (not that it helped a lot). So you end up with gcc-4.2 with LLVM (and Clang for whatever reason), not being able to compile much.

System ruby: 1.8.7 p200something. Well, I don't recall anyone working with the system ruby installation seriously, but this got worse, because they forgot to include ruby dev headers and so no binary gems for you. (I guess this should be fixable, I just didn't try).

RVM REE: The installer failed, telling me it kinda missed zlib and openssl. That was quite strange, I was used to the system providing it (and homebrew doesn't even have a formula for zlib). Manual compilation failed with something printing out the ree version and segfaulting.

RVM 1.9.2: Compilation failed with a stack too deep error.

Hombrew 1.9.2: Compilation failed with some _mach_something_ not found somewhere.

MacRuby did a good job. It installed fine, compiled all the gems and just after that failed with some incompatibility between it and the JSON gem (a bit on that later).

JRuby was the best: it installed, compiled the gems, and even gave me a result for "knife node list". A bit later it failed on "knife cookbook upload" and I gave up.

As a conclusion, a few small pieces of advice: don't try Lion on you work box, and if you wanna try it, install it as a upgrade. While I'm sure there's a way to make everything work, expect it to take some time. And don't believe people saying 20Gb is enough for Lion. 30 was barely enough for Lion+Xcode + some minor stuff.

A sidenote on json. As you may know, there are two json libraries: json, and json_pure (a pure-ruby implementation, as the name suggests). While it's perfectly OK to depend on the 'json' gem, please, do not require it using "gem 'json'", use "include 'json'" instead. Because the first form is unable to use the json_pure replacement, which can be quite useful if you can't use the binary one. Be kind to the less fortunate ones (and Solaris people, IIRC).

Written by labria

April 3rd, 2011 at 8:38 pm

Posted in Ruby

Google won (in a small way)

2 comments

I work in a web-company. The browser is our one and only platform. We should know exactly which one we use, right? Well, seems we do not.

Out of 60 people who took a internal survey, 36 said their browser was "Chrome". Almost all the rest uses Firefox, some Safari and one or two IE. Quite a normal distribution for a high-tech company.

But here comes the odd part: none (as in 0) Chrome users indicated a version. Almost all Firefox users wrote something like "Firefox 4" or "Firefox 3.6". Anyone with IE was sure to indicate the version. But even the ones to have both Chrome and Firefox indicated the version only for the latter.

I have Crome installed myself (while Fireox 4 recently became my main browser, mainly due to Vimperator/Pentadactyl). And I have no clue what version it is.

I think it's a small victory for Google, and somehow a sign of the browser's quality. If no one (even quite tech-savvy users) cares about the version of the browser, it kinda shows that it simply works. Isn't it what we want from any piece of software?

 

Written by labria

April 2nd, 2011 at 7:54 pm

Posted in Uncategorized

I’m going v6

leave a comment

After a few hours of testing ipv6 from home yesterday, I decided that who else except us, IT pros, will move the technology forward.

So, I set up a tunnel to my server today, and http://ipv6.blog.startika.com/ is now live. (You do need to have ipv6 connectivity to view it)

This way, when the day comes, I'll be ready =)

Yes, I know all the links from there still go to the v4 version. This can be fixed by simply making a AAAA record for blog.startika.com, but I'll refrain from doing it right now.

Written by labria

January 23rd, 2011 at 1:39 pm

Posted in Editorial

Opscode

4 comments

Today I got the best snail-mail letter in years.

Background: I recently joined the Wix.com team as a Systems And Deployment engineer, and started working with the chef server management system. After a few days I wrote a tiny patch, and requester developer access to the Opscode JIRA to submit it. (I'm currently working on a much bigger and useful patch)

And today, I received a envelope with my name on it to the corporate address from Opscode. I expected it to be some legal stuff (we signed a CCLA), but instead I found this:

(sorry for the photo quality, it's from a cameraphone)

I was really touched, you know. These guys really seem to care about open source contributors. Keep up the good job guys, and we'll try contributing more!

Thanks, Adam and Jesse, you made my day!

Written by labria

October 5th, 2010 at 1:55 pm

Posted in Editorial

erlgen deprecated.

leave a comment

I created my erlgen tool because I lacked something to do the job. Now i'm deprecating it, because such a tool was written.

Welcome Rebar! It's not simpy a generator, but a swiss knife for the complete erlang application lifecycle. Generation, dependencies, building, dialyzer, eunit, release, you name it — Rebar does it.

And to complete the beauty of it: it's written in erlang and has no dependencies itself except erlang. (for all of you ruby haters out there =))

Written by labria

June 20th, 2010 at 12:08 pm

Posted in Erlang

Erlang application generator

leave a comment

In the ruby world, we're used to code generators. Take rails, or the jeweler gem. When we start a project, we rarely start it from scratch, usually we have a skeleton to start with.

In the hardcore Erlang world, it's different. I found only one erlang project generator, the one bundled with mochiweb. It's nice, but its only purpose is to generate a mochiweb application. What I wanted was a generic project skeleton.

So, to help myself and other erlang users out there, I started the erlgen project. Erlgen is a ruby gem that install the erlgen binary. Erlgen has two functions

  • Generate a skeleton project
  • Generate skeleton gen_server/gen_fsm/gen_event modules

Installation

Erlgen requires you to have ruby and rubygems on your machine. I know it sounds like a strange requirement for a Erlang tool, but it was easier for me to write the tool that way, and ruby is very common nowadays (MacOS has it installed by default)

gem install erlgen 

Usage

To generate a new project simply run

erlgen project_name

To create a gen_server (or fsm, or event):

erlgen --gen_server module_name

Note: if you run it from your project root, it will create the file in the 'src' directory.

That's about all it can do for now, but I'm always open to suggestions.

Written by labria

April 1st, 2010 at 12:49 am

Posted in Erlang

Naglfar release

leave a comment

I finally found time in my schedule to release the Naglfar project. I've been thinking for a long time of a project to use the beautiful name, and I suddenly realized that the name itself is quite enough for me =)

To install, just do the usual:

gem install naglfar

The gem does almost nothing, actually. It declares the Naglfar singleton class with one useless method, and prints a message to stdout after you require it.

From now on, i'll require it in every ruby project I'll be doing. I do think that having a Naglfar in your project will bring it good luck, so don't hesitate to require it too!

PS: I plan to release something much more useful soon, so watch this space.

Written by labria

February 21st, 2010 at 10:54 pm

Posted in Ruby

Tagged with

My first working Erlang code.

one comment

I wrote my first working bit of Erlang code. Wasn't much code, actually. Here it is:

<erl>
out(A) ->
    {ok, Challenge} = queryvar(A,"hub.challenge"),
    {html,io_lib:format('~s', [Challenge])}.
</erl>

Wow... my highlighter doesn't even support Erlang! now it does

This a complete and finished piece of code, yes. If you heard of PubSubHubbub — that's the code to confirm all subscriptions in async mode.

The funny thing about it is the amount of code I would user to do the same in Rails/Sinatra/Whatever + erb:

<%= params["hub.challenge"]%>

Written by labria

September 15th, 2009 at 1:13 am

Posted in Erlang

A wonderful way to list your project files

9 comments

This article is published as a reply to the last few articles on the thoughtbot blog.

Some time or another during the project development you may wonder: «What files does my project include?» or «Why am I a Star Wars fan anyway?». This article will focus on the first question, leaving the second to your own reflection.

Any shell you might be using comes with a lot of useful tools. The one of interest today is ls

Here's the most simple example of its usage in a Rails project

sample_project $ ls
README		app		db		lib		public		test		vendor
Rakefile	config		doc		log		script		tmp

As a little more complex example, you might want to get the list of your model files:

sample_project $ ls app/models/
comment.rb	post.rb

Or, it even can do crazy stuff, like list all your model files AND controller files AND helper files! Now thats some useful magic, isn't it?

sample_project $ ls app/*
app/controllers:
application_controller.rb	comments_controller.rb		posts_controller.rb
 
app/helpers:
application_helper.rb	comments_helper.rb	posts_helper.rb
 
app/models:
comment.rb	post.rb
 
app/views:
comments	layouts		posts

ls can do much. much more. Go check out the manual page here, you'll be amazed.

Note to Windows users: you also have a similar command, named dir.

Written by labria

September 10th, 2009 at 12:17 pm

Posted in Rails