Channels
Displaying page 4
Posted 11 days ago at The Geek Talk

Who is Toni Gemayel?

I am a slightly goofy web developer who loves clean, well optimized code, WordPress and Giraffes. I am also a 20 year old business owner working hard to make his mark on the exponentially growing web.

Do you have a personal Brand?

Sure do! Two Giraffes is my recently revamped personal brand that I own and operate full time (and then some) from sunny Florida. While it is a tiny development shop, I work hard to ensure we constantly create happy clients, clean code, and fresh interfaces.

How do you find design inspiration and colours for a new project?

Inspiration is everywhere from source code to the beautiful outdoors. As a web developer, I am constantly reading blogs, tweets and articles for inspiration. For design inspiration, I usually go over to dribbble to drool over the immensely talented crop of individuals on that site. For colors, I usually head over to kuler.adobe.com and browse some palettes.

What does your typical day look like?

My typical day is usually atypical. Assuming I have no client meetings, conference calls, or other items planned for the day, a normal day would be pretty relaxed. I usually wake up around 10 a.m. and check my emails right away and look for anything labeled urgent or with a title full of expletives. Assuming my inbox is calm, I throw together some breakfast and get through my emails. I then get to client work and work until about 8pm. At 8, Ill break for dinner, hit the gym, play some xbox or tinker with some computing parts, then wrap the day up with some programming related reading.

What do you do in your free time?

Well, I dont have a lot of free time, but most of it is spent reading, writing, tinkering, working on diy projects, playing basketball, watching college football, and traveling.

Current favorite apps?

Textmate for coding, Ballpark for invoicing, and Skype for chat.

What OS do you prefer?

Im kind of an OS nut and would love to write my own someday. I spend most sunday afternoons playing around with different GNU/Linux distros/flavors. Here are my top five:

Ubuntu, Windows 7, OS X, Puppy Linux, Jollicloud

Small picture for your Workplace?

Sure thing! Here is Two Giraffes Zoo HQ.

Font, Language, JS Framework?

Archer, whatever is best for the job, jquery

Name something that has inspired you recently?

I get inspiration from guys I work with. I don’t have a single idea without bouncing it off of the immensely talented Sean Farrell who challenges me daily to be a better developer, entrepreneur and individual. I also just recently had the chance to work with Micah Davis and Court Simas of Ovenbits, who are both just stellar guys.

What do you prefer (and why)? Freelance work or full time employment?

I have worked in both environments, and It would take alot for me to work under someone elses direction again. As a freelancer, I log around 60 hours a week, usually taking some time for personal projects and learning new languages to keep the job fun and to keep myself on the top of the industry. I don’t know if the entrepreneur in me will ever be able to walk away from that flexibility.

What are your personal projects and goals for 2010?

My personal goals for for 2010 is to continue to grow as developer, specifically with the mobile web (cocoa and java) as well as site optimization, and continuing to explore html 5 and css 3.

For personal projects, I am going to continue to develop my company, Two Giraffes, into a recognizable brand. I also have a hosting company in the works. On top of that, I have a top secret start-up I have been working on for the last six months.

back to top
Posted 11 days ago at Plataforma Tecnologia Blog

Em agosto, a Plataforma Tecnologia esteve presente de Norte ao Sul do Brasil. Nada mais, nada menos que 7.000 km foram percorridos, cinco palestras, quatro eventos e menos horas de sono de todo nosso time. Mas….. valeram cada segundo e centavo investidos!

Esse post é um agregado de todas essas palestras com os respectivos slides (os vídeos serão adicionados assim que eles tornarem disponíveis). Então vamos lá!

Oxente Rails – 05 e 06 de Agosto (Natal)

O Oxente Rails foi espetacular! Não há dúvidas de que valeu o esforço que fizemos para levar boa parte do nosso time (Carlos AntônioFabio YamateHugo Baraúna, eu (José Valim) e Vinícius Baggio) e em patrocinar o evento. Aproveitamos o espaço para agradecer o pessoal da Tink! por nos convidar para dar duas palestras e pela organização do evento, que foi impecável. Nos vemos novamente no ano que vem!

Bem, a primeira apresentação foi a minha e falei sobre algumas das ferramentas Open Source da Plataforma Tec (Devise, Simple Form e Responders):

The Plafatorma Way – Oxente Rails – 05aug2010

Logo em seguida, o Hugo Baraúna falou sobre Project Rescue (um dos nossos serviços) e contou como fazemos para salvar projetos à beira de precipícios. Veja nos slides abaixo.

Project Rescue – Oxente Rails – 05ago2010

Além de um excelente evento, a cidade de Natal também reserva diversas surpresas. Um dia após o evento, nós e um pessoal da comunidade Rails fomos visitar as dunas e nos divertimos bastante. Valeu NATAL!

WhyDay – 19 de Agosto (São Paulo)

Após retornarmos de Natal, fui convidado a falar um pouco sobre Open Source e contribuições no Rails em comemoração ao WhyDay. Seguem os slides.

CRUDing Open Source – WhyDay – 19aug2010

A palestra foi bastante descontraída e logo após nós hackeamos um pouco:

Plataforma Tec no WhyDay

Valeu @rafaelrosafu pelo convite!

RS on Rails – 21 de Agosto (Porto Alegre)

Mas enquanto nós nos divertiamos no WhyDay aqui em São Paulo, o Carlos Antônio estava terminando a sua palestra para o RS on Rails. A palestra contemplou diversas novidades do Rails 3 como o Bundler, ARel, ActiveModel, entre outras.

Na foto abaixo, parece que o Carlos é político em campanha eleitoral. Mas na verdade ele só está dizendo que o Router é 100% compatível com Rack. Confira toda apresentação nos slides.

Carlos da PlataformaTec no RS on Rails

Rails 3 – RS on Rails – 21aug2010

Valeu @felipebcabral pela organização do RS on Rails e pelo convite! Ano que vem queremos mais! =D

The Developers Conference – 21 de Agosto (São Paulo)

Enfim, após poucas horas da apresentação do Carlos Antônio em Porto Alegre, lá estava eu apresentando outra palestra sobre Rails 3 no The Developers Conference. O interessante é que as duas apresentações se complementam. No TDC, falei sobre generators e a API de notificações, enquanto que no RS on Rails o Carlos Antônio falou sobre Unobtrusive Javascript e XSS Protection. Vale a pena conferir as duas apresentações.

Rails 3 – The Developers Conference – 21aug2010

E mais uma vez, obrigado ao @rafaelrosafu e ao @felipero pelo convite.

Encerrando

Agosto foi um mês bem intenso, repleto de eventos bem organizados e com conteúdo muito interessante. Tanto é verdade que nós não conseguimos participar de todos eventos que gostaríamos. Mas posso dizer que estamos contentes em ver como a comunidade Ruby e Rails está crescendo de forma bastante saudável aqui no Brasil. Parabéns a todos que estavam presentes nestes eventos, como espectadores ou organizadores. Valeu comunidade Rails!

Nos vemos em Outubro no RubyConf! E não esqueçam de conferir outras palestras da Plataforma Tec no Slideshare.

back to top
Favorite
Posted 12 days ago at Ruby5

A nice grab bag for this episode: resque_action_mailer_backend, Swift ORM, Upload Juicer, Ruby 1.9.2 debugging problems, Rails 3 RC2, and Frivol.

Listen to this episode on Ruby5

This episode is sponsored by NewRelic RPM
Did you know that New Relic Has deployment tracking? All you do is modify your capistrano task to let new relic know when you do a deployment. Then when you view you stats on new relic after the deployment, you'll actually see a line on each of your new relic graphs so you'll be able to see how performance was affected. Check out the video over on NewRelic.com to learn more.

resque_action_mailer_backend gem
This gem makes it easy to send your Rails app's emails in the background with your Resque queue.

Swift ORM
Swift, a self-described "rational rudimentary Object Relational Mapper". As its name suggests, it's super-fast.

Upload Juicer
A cloud-based service for easy image processing from your Ruby app.

Ruby 1.9.2 debugging problems
With the release of Ruby 1.9.2 certain versions of the ruby-debug19 gem get a lazy symbol binding failure. Follow the URL to the gist to learn which specific versions fix this issue.

Rails 3.0: Release candidate 2
Rails 3.0 RC2 came out this week. It includes test tweaks, deprecations, "lib" is back on the autoload path, and more finessing with ARel and Bundler as those libraries also mature towards a release.

Frivol
Frivolously simple temporary storage backed by Redis.

back to top
Favorite
Posted 12 days ago at Ruby Quicktips

Yehuda Katz posted a question on Twitter the other night: what’s the easiest way to get [“X::Y::Z”, “X::Y”, “X”] from “X::Y::Z” in Ruby?
I was determined to accomplish this with a nice application of functional programming. In other words, how can I accomplish this without running procedural code?

The first part is to split the string on ::, which is simple enough with the split command. Next, we obviously need to iterate, but neither ‘each’ nor ‘map’ give access to the other elements. Enter ‘inject’.
By seeding inject with an empty array, we can build up the array by using the most recently added element. Behold, the finished product:

module_name = "X::Y::Z"
module_name.split('::').inject([]) { |memo,x| memo.unshift(memo.empty? ? x : "#{memo[0]}::#{x}") }
=> ["X::Y::Z", "X::Y", "X"]

See? No need to use procedural code. Easy to understand with zero side-effects.

Well, you might want to have a look at some old tips and the Ruby API docs:

This tip was submitted by Bradley Grzesiak.

back to top
Posted 12 days ago at The GitHub Blog

Mozilla Labs is now mirroring open source to GitHub: http://github.com/mozilla

Read the blog post or check out the repositories on GitHub.

Rumor has it we'll being see more from Mozilla on GitHub in the future, too!

back to top
Posted 13 days ago at The GitHub Blog

I just blogged about the new git-notes functionality over at the Pro Git blog. If you're interested in using Git notes for something, you might be interested to know that GitHub now supports them and will display them on your commit pages.

If you push notes to GitHub, you will be able to see them at the bottom of the diff when you are viewing that commit. These are separate from GitHub commit comments and are displayed differently. The will look like this:

To learn more about Git notes, read my post. on them, but the short of it is: they're cool for appending notes from automated systems (like ticket or build systems) but not really for having interactive conversations with other developers (at least not yet). Hope you find them useful.

back to top
Posted 13 days ago at Engine Yard Ruby on Rails Blog

We're excited to join forces with our friends at EdgeCase to co-host the second annual JRubyConf, taking place October 1-3 at Quest Conference Center in Columbus, Ohio. This year, we've expanded the event to include three days of JRuby-filled goodness. JRubyConf will showcase the growing use of Ruby in the enterprise while also highlighting elements of the Java language that Ruby developers can benefit from via JRuby. We've got a fantastic speaker lineup including: Tom Enebo, Chad Fowler, Jeremy Heingardner, Rich Kilmer, Keavy McKinn, Charles Nutter, Joe O’Brien, Nick Sieger, Brian Swan, Glenn Vanderburg, Jim Weirich, and more to be announced soon. If you're curious about what JRuby can do for you, or if you're someone who has been using it for years - join us! We've got something for everyone. JRubyConf will begin with Java and Ruby specific talks before progressing to more advanced sessions that demonstrate the possibilities of using both languages with JRuby – all focused on bringing the Ruby and Java communities together in a collaborative environment to share best development practices. Topics to be covered include: • Introduction to JRuby • How to use Java in Ruby applications • Best practices for introducing Ruby to Java development teams • Effectively managing large agile teams that use Ruby • Large scale testing with Ruby • How to scale Ruby on Rails Our growing sponsor list includes EdgeCase, 8th Light, ELC Technologies, Kinetic Data, O'Reilly, Terremark, and WyeWorks. Registration is now open. Take advantage of an early bird discount for registration before September 1. If you would like information on user group discounts, give us a shout! To register to attend or to participate as a sponsor, visit the JRubyConf event site. Follow @JRubyConf on Twitter to stay on top of announcements. Hope you can join us in Columbus!

back to top
Posted 13 days ago at Ruby Inside

It's time to unveil my latest project: Ruby Weekly, a once-weekly e-mail roundup of 10-20 Ruby related links with a few sentences on each. It's had a brief alpha testing period and it's now ready to roll.

Click here to subscribe to Ruby Weekly - it's a one click process. It's also ultra simple to unsubscribe if it's not eventually to your taste.

As well as featuring links and (very) brief summaries, the weekly e-mail will also occasionally include new event, book, and job announcements and, if something significant is going on in Rubyland, a few paragraphs of editorial. The aim, though, is to keep the e-mail reasonably brief, in a plain format, and, above all, useful.

There's been a renaissance in e-mail newsletters in the last year or two and it seemed, to me, to be a great way to get programming related news. E-mail is not to everyone's taste (Ruby Inside will be staying as-is!) but if you want to avoid daily distraction and get a summary just once a week, it's an alternative to reloading Twitter or Google Reader every day. The popularity of the Ruby5 podcast proves there's an appetite for Ruby news in different media (and if you prefer audio, check them out).

Ruby Weekly goes out once a week on Thursdays, so if you subscribe within the next 16 hours or so, you'll get this Thursday's edition (issue #4).

back to top
Favorite
Posted 14 days ago at Ruby Quicktips

Everybody knows that you can retrieve an ActiveRecord object like this:

user = User.find(41)
=> #

But did you know that you can pass multiple ids to the find method?

user = User.find(1, 2, 5)
=> [#, #, #]

Principle of least surprise.

back to top

High Quality MySQL driver for Node:

Now that Felix Geisendörfer launched his node powered site http://transloadit.com, he’s tacked the much needed task of writing a high quality MySQL protocol implementation in pure JavaScript.

Using the high performance networking capabilities of node, and the awesome speed of V8, it’s now feasible to implement binary network protocols without resorting to writing C++ extensions and wrapping blocking APIs in thread pools.

Felix is a great programmer, but could use some help in the form of sponsorship and/or patches. We all win when high quality drivers are written and shared with the community.

Design Goals

  • TDD: All code is written using test driven development, code coverage should approach 100%
  • Simplicity: The MySQL protocol is easy, a good parser should reflect that
  • Efficiency: Use fast algorithms, buffers and as little memory as possible.
  • Portability: Should run anywhere node runs
  • Completeness: The goal is to support the full MySQL API.
  • Compatibility: MySql >= 4.1

Check out the code and more info on his git repo.

back to top

Git Extras: Helpful tools for Git:

If you’ve ever been working heavily on a project that uses git, you’d know, that sometimes it’s good to have a few extras to help you out, and that’s what TJ Holowaychuk’s recent project git-extras provides!

Currently git-extras includes:

  • git summary
  • git changelog
  • git commits-since
  • git count
  • git delete-branch
  • git delete-tag
  • git ignore
  • git release
  • git contrib
  • git repl

Most cover tasks such as counting commit contributions, or viewing commits based on time, others include changelog generation based on commits and quickly adding items to the .git-ignore file. The extras are also quite easy to install, just clone the repository, then [sudo] make install.

[source on github]

back to top
Favorite
Posted 14 days ago at Katz Got Your Tongue?

For a few months now, the bundler team has been getting intermittent reports of segfaults in C extensions that happen when using bundler with rvm. A cursory investigation revealed that the issue was that the C extensions were compiled for the wrong version of Ruby.

For instance, we would get reports of segfaults in nokogiri when using Ruby 1.9 that resulted from the $GEM_HOME in Ruby 1.9 containing a .bundle file compiled for Ruby 1.8. We got a lot of really angry bug reports, and a lot of speculation that we were doing something wrong that could be obviously fixed.

I finally ran into the issue myself, on my own machine a couple days ago, and tracked it down, deep into the fires of Mount Doom. A word of warning: this story may shock you.

It Begins

I usually use rvm for my day-to-day work, but I tend to not use gemsets unless I want a guaranteed clean environment for debugging something. Bundler takes care of isolation, even in the face of a lot of different gems mixed together in a global gemset. Last week, I was deep in the process of debugging another issue, so I was making pretty heavy use of gemset (and rvm gemset empty).

I had switched to Ruby 1.9.2 (final, which had just come out), created a new gemset, and run bundle install on the project I was working on, which included thin in the Gemfile. I had run bundle install to install the gems in the project, and among other things, bundler installed thin “with native extensions”. I use bundler a lot, and I had run this exact command probably thousands of times.

This time, however, I got a segfault in Ruby 1.9, that pointed at the require call to the rubyeventmachine.bundle file.

Debugging

Now that I had the bug on a physical machine, I started debugging. Our working hypothesis was that bundler or Rubygems was somehow compiling gems against Ruby 1.8, even when on Ruby 1.9, but we couldn’t figure out exactly how it could be happening.

The first thing I did was run otool -L on the binary (rubyeventmachine.bundle):

$ otool -L rubyeventmachine.bundle
rubyeventmachine.bundle:
	/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/libruby.1.dylib (compatibility version 1.8.0, current version 1.8.7)
	/usr/lib/libssl.0.9.8.dylib (compatibility version 0.9.8, current version 0.9.8)
	/usr/lib/libcrypto.0.9.8.dylib (compatibility version 0.9.8, current version 0.9.8)
	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.0.1)
	/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)

So that’s weird. I had run bundle install from inside an rvm gemset, yet it was being compiled against the libruby that ships with OSX. I had always suspecting that the problem was a leak from another rvm-installed Ruby, so this was definitely a surprise.

Just out of curiosity, I ran which bundle:

$ which bundle
/usr/bin/bundle

Ok, now I knew something was rotten. I printed out the $PATH:

$ echo $PATH
/Users/wycats/.rvm/gems/ruby-1.9.2-p0/bin:/Users/wycats/.rvm/gems/ruby-1.9.2-p0@global/bin:/Users/wycats/.rvm/rubies/ruby-1.9.2-p0/bin:/Users/wycats/.rvm/bin:/Users/wycats/.bin:/usr/local/bin:/Users/wycats/Code/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin:/usr/X11/bin
$ ls /Users/wycats/.rvm/gems/ruby-1.9.2-p0/bin
asdf*             erubis*           rake2thor*        sc-build-number*  sc-manifest*      thin*
autospec*         prettify_json.rb* redcloth*         sc-docs*          sc-server*        thor*
bundle*           rackup*           ruby-prof*        sc-gen*           spec*
edit_json.rb*     rake*             sc-build*         sc-init*          sproutcore*

In other words, a big fat WTF.

I asked around, and some people had the vague idea that there was a $PATH cache in Unix shells. Someone pointed me at this post about clearing the cache.

Sure enough, running hash -r fixed the output of which. I alerted Wayne of rvm to this problem, and he threw in a fix to rvm that cleared the cache when switching rvms. Momentarily, everything seemed fine.

Digging Further

I still didn’t exactly understand how this condition could happen in the first place. When I went digging, I discovered that shells almost uniformly clear the path cache when modifying the $PATH. Since rvm pushes its bin directory onto the $PATH when you switch to a different rvm, I couldn’t understand how exactly this problem was happening.

I read through Chapter 3 of the zsh guide, and it finally clicked:

The way commands are stored has other consequences. In particular, zsh won’t look for a new command if it already knows where to find one. If I put a new ls command in /usr/local/bin in the above example, zsh would continue to use /bin/ls (assuming it had already been found). To fix this, there is the command rehash, which actually empties the command hash table, so that finding commands starts again from scratch. Users of csh may remember having to type rehash quite a lot with new commands: it’s not so bad in zsh, because if no command was already hashed, or the existing one disappeared, zsh will automatically scan the path again; furthermore, zsh performs a rehash of its own accord if $path is altered. So adding a new duplicate command somewhere towards the head of $path is the main reason for needing rehash.

By using the hash command (which prints out all the entries in this cache), I was able to confirm that the same behavior exists in bash, but it seems that the which command (which I was using for testing the problem) implicitly rehashes in bash.

During this time, I also took a look at /usr/bin/bundle, which looks like this:

$ cat /usr/bin/ruby
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
#
# This file was generated by RubyGems.
#
# The application 'bundler' is installed as part of a gem, and
# this file is here to facilitate running it.
#
 
require 'rubygems'
 
version = ">= 0"
 
if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
  version = $1
  ARGV.shift
end
 
gem 'bundler', version
load Gem.bin_path('bundler', 'bundle', version)

As you can see, executable wrappers created by Rubygems hardcode the version of Ruby that was used to install them. This is one of the reasons that rvm keeps its own directory for installed executables.

A Working Hypothesis

It took me some time to figure all this out, during which time I was speaking to a bunch of friends and the guys in #zsh. I formed a working hypothesis. I figured that people were doing something like this:

  1. Install bundler onto their system, and use it there
  2. Need to work on a new project, so switch to rvm, and create a new gemset
  3. Run bundle install, resulting in an error
  4. Run gem install bundler, to install bundler
  5. Run bundle install, which works, but has a subtle bug

Let's walk through each of these steps, and unpack exactly what happens.

Install bundler on their system

This results in an executable at /usr/bin/bundle that looks like this:

#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
#
# This file was generated by RubyGems.
#
# The application 'bundler' is installed as part of a gem, and
# this file is here to facilitate running it.
#
 
require 'rubygems'
 
version = ">= 0"
 
if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
  version = $1
  ARGV.shift
end
 
gem 'bundler', version
load Gem.bin_path('bundler', 'bundle', version)

There are two important things here. First, it hardcodes the shebang to the system Ruby location. Second, it uses Rubygems to look up the location of the executable shipped with bundler, which will respect GEM_HOME.

Switch to rvm, and create a new gemset

Switching to an rvm gemset does a few relevant things. First, it prepends ~/.rvm/gems/ruby-1.9.2-p0@gemset/bin onto the $PATH. This effectively resets the shell's built-in command cache. Second, it sets $GEM_HOME to ~/.rvm/gems/ruby-1.9.2-p0. The $GEM_HOME is where Ruby both looks for gems as well as where it installs gems.

Run bundle install, resulting in an error

Specifically,

$ bundle install
/Library/Ruby/Site/1.8/rubygems.rb:777:in `report_activate_error': Could not find RubyGem bundler (>= 0) (Gem::LoadError)
	from /Library/Ruby/Site/1.8/rubygems.rb:211:in `activate'
	from /Library/Ruby/Site/1.8/rubygems.rb:1056:in `gem'
	from /usr/bin/bundle:18

Most people don't take such a close look at this error, interpreting it as the equivalent of command not found: bundle. What's actually happening is a bit different. Since bundle is installed at /usr/bin/bundle, the shell finds it, and runs it. It uses the system Ruby (hardcoded in its shebang), and the $GEM_HOME set by rvm. Since I just created a brand new gemset, the bundler gem is not found in $GEM_HOME. As a result, the line gem 'bundler', version in the executable fails with the error I showed above.

However, because the shell found the executable, it ends up in the shell's command cache. You can see the command cache by typing hash. In both bash and zsh, the command cache will include an entry for bundle pointing at /usr/bin/bundle. zsh is a more aggressive about populating the cache, so you'll see the list of all commands in the system in the command cache (which, you'll recall, was reset when you first switched into the gemset, because $PATH was altered).

Run gem install bundler, to install bundler

This will install the bundle executable to ~/.rvm/gems/ruby-1.9.2-p0@gemset/bin, which is the first entry on the $PATH. It will also install bundler to the $GEM_HOME.

Run bundle install, which works, but has a subtle bug

Here's where the fun happens. Since we didn't modify the cache, or call hash -r, the next call to bundle still picks up the bundle in /usr/bin/bundle, which is hardcoded to use system Ruby. However, it will use the version of Bundler we just installed, since it was installed to $GEM_HOME, and Rubygems uses that to look for gems. In other words, even though we're using system Ruby, the /usr/bin/bundle executable will use the rvm gemset's Bundler gem we just installed.

Additionally, because $GEM_HOME points to the rvm gemset, bundler will install all its gems to the rvm gemset. Taken together, these factors make it almost completely irrelevant that the system Ruby was used to install gems. After all, who cares which Ruby installed the gems, as long as they end up in the right place for the rvm's Ruby.

There are actually two problems. First, as we've seen, the version of Ruby that installs a gem also hardcodes itself into the shebang of the executables for the gem.

Try this experiment:

$ rvm use 1.9.2
$ rvm gemset create experiment
$ rvm gemset use experiment
$ /usr/bin/gem install rack
$ cat ~/.rvm/gems/ruby-1.9.2-p0@experiment/bin/rackup
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
#
# This file was generated by RubyGems.
#
# The application 'rack' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'rubygems'

version = ">= 0"

if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
  version = $1
  ARGV.shift
end

gem 'rack', version
load Gem.bin_path('rack', 'rackup', version)

As a result, any gems that bundler installed will put their executables in the gemset's location, but still be hardcoded to use the system's Ruby. This is not actually the problem we're encountering here, but it could cause some weird results.

More concerningly, since our system Ruby installed the gems, it will also link any C extensions it compiles against its own copy of libruby. This shouldn't be a major issue if you're using a version of Ruby 1.8 in rvm, but it is a major issue if you're using Ruby 1.9.

Now, we have a gem stored in your rvm's Ruby that has a .bundle in it that is linked against the wrong Ruby. When running your application, Ruby 1.9 will try to load it, and kaboom: segfault.

Postscript

The crazy thing about this story is that it's a lot of factors conspiring to cause problems. The combination of the shell command cache, $GEM_HOME making it look like SYSTEM Ruby was doing the right thing, and hardcoding the version of Ruby in the shebang line of installed gems made this segfault possible.

Thankfully, now that we figured the problem out, the latest version of rvm fixes it. The solution: wrap the gem command in a shell function that calls hash -r afterward.

Amazing.

back to top
Posted 14 days ago at The GitHub Blog

I just released and deployed Jekyll 0.7.0 to GitHub Pages today. This release includes support for SmartyPants via RDiscount for Markdown files. To get all those nice curly quotation marks, em/en dashes, and elipses, simply make sure your Jekyll repo's _config.yml contains the following lines:

markdown: rdiscount
rdiscount:
  extensions: [smart]

Then, push your repo to GitHub and enjoy some automatic fancy typographical elements!

NOTE: SmartyPants will only be active on pages written with Markdown.

back to top
Favorite
Posted 15 days ago at Ruby5

Azebiki, RVM's 1.0 release, home_run, Prowly, and Wrong are all covered on this episode of Ruby5. It feels so right, how can it be wrong?

Listen to this episode on Ruby5

This episode is sponsored by Obtiva

Obtiva provides agile software development services for organizations that need to create custom web applications. Obtiva consultants strengthen customer teams on-site by providing specialized skill sets and languages such as Ruby on Rails, Eclipse RCP, Java, agile project management, agile and technical coaching, and training.

Our experienced team shares their knowledge of XP, Agile, and innovative new technologies by leading scheduled and on-site training throughout North America.

Obtiva is looking for a few great senior developers. Take your craft to the next level. Contact them now at obtiva.com.


Ruby enVironment (Version) Manager – RVM – 1.0.0
This weekend, Ruby enVironment (Version) Manager - better known as RVM - had it's 1.0 release. The two largest changes in this release are the addition of "trusted" .rvmrc files and better Set operations.

Prowly - Prowl Push Notifications in Ruby
If you enjoy receiving instantaneous notifications - especially on your mobile phone - then Prowly may be for you. Written by Rafael Magana, it's a Ruby library for interacting with the Prowl push notification application for the iPhone.

home_run - Faster Ruby Date/DateTime Classes
You may have heard complaints that Ruby's native Date and DateTime classes can be a bit slow. Well, Jeremy Evans jumped on the issue and rewrote much of the Date and DateTime interface on top of a native C-extension. With it, he's seeing a 20 to 200x speed increase in everyday use.

Azebiki - A Better Webrat DSL
Eric Allam recently released Azebiki, a better DSL for working with Webrat. In this case, he was using webrat to verify whether or not a given HTML string contained certain elements. The library provides better validation and error messages over the default.

More Concise Testing with Wrong
Steve Conover and Alex Chaffee recently released Wrong. Wrong is a Ruby test library which provides you a single "assert" call. That method will intelligently introspect on exactly what you're trying to test and generate useful failure messages for you, automatically.

back to top
Posted 15 days ago at Intridea - Company Blog

Warning: I am not an experienced Node developer and I may be doing this completely wrong. However, I am happy to publish this anyway with the hope that more learned Javascripters will correct my naive ways.

The Node Knockout is this weekend and I've been trying to teach myself Node and get ready in a variety of ways. One of the most important (and least clear) aspects of preparation was figuring out how to properly vendor the latest Node libraries for use in Heroku. I've got NPM up and running locally, but as of its latest release it has no built-in support for vendoring. Here's how I managed.

NPM's Command Options

NPM provides a few helpful command options that let you specify the directory of installation when you install a library. By using the --root and --binroot options you can use a folder inside your local project instead of the default NPM root. For example, in my project I created a vendor folder and then, to install Express, specified:

npm install express --binroot ./vendor --root ./vendor

Now while this seems like it might do exactly what we want, it's not quite perfect. Rather than install everything in vendor, it installs the important stuff in vendor/.npm/.cache. This isn't the end of the world but can make for some pretty ugly require statements.

The Require Blues

So now you've got your packages all nice and installed inside your project directory (probably a lot of support files that you don't need, as well, but the Node slugs on Heroku tend to be small anyway so no biggie). Now you need to include them in your application. To do this, I wrote a quick function, vrequire that adds the necessary load path and then requires the library all at once:

vrequire = function(lib) { 
  require.paths.unshift("vendor/.npm/" + lib + "/active/package/lib");
  return require(lib); 
}

Now if I call vrequire("express") it will load up from my vendored library. If I deploy my app to Heroku, it's able to find everything it needs and (cross your fingers) launch and work correctly!

Hopefully some people find this little guide useful, and I look forward to someone pointing me to the "real" way to do this stuff! If you want to poke around the exploratory code I've been creating to play with Node, you can find it on GitHub (but don't expect much!).

back to top