Ruby gsub gotcha

Today I struggled with a string replace that didn't do what I expected it to do.

Consider the following code:

"xyz".gsub("y","a\\'b")
=> "xazbz"

Because gsub can be used with a regular expression the replace value can use regular expression backrefs.

I assumed (assumption is the mother of all fuckups) when using a plain string as search term, (which cannot result in back refs) it didn't use backrefs..
Well I was wrong..

A solution is to use the block-variant:

"xyz".gsub("y") { "a\\'b" }
=> "xa\\'bz"

I think the behavior of gsub is wrong...
When you don't have a regular expression you cannot have backrefs and you can have a dumb string replace.... What's your opinion about this?

Freebsd ports, installing Perl ./+INSTALL: Permission denied

Don't you just hate it when installing ports on a live server fail!
Well I do. Today the following happened:

===>  Installing for perl-5.16
===>  Checking if lang/perl5.16 already installed
./+INSTALL: Permission denied
pkg_add: install script returned error status
*** Error code 1

Big panic, couldn't install perl on my server.

On my server the /tmp drive is mounted with noexec. This script seems to need execute rights in the temporary directory

The work-around I used is the following:

mkdir /usr/tmp
export TMPDIR=/usr/tmp

Finally my make install works again :D

make install 

Devise – Demo Event Tool

I'm a developer and I enjoy programming.. :)
One of my play-projects is a tool called Devise. It's build for the demo group "Edge of Panic".
(We've made several releases (see bottom of this page))

I've did 3d coding for Edge of Panic a few years ago (look at the ugly recursive ball scene in the Breakpoint 2010 demo), but the the last two years I'm way to busy with my company to work on the 3d engine (which btw resulted in the development http://edbee.net/).

Though I'm very busy, I've managed to find some spare time to work on Devise.

Devise is used for creating timing events and triggers in the demo. The tool imports both midi-data of the music track and the audio data and visualizes these items. The events can be moved, resized altered etc.
Events can be as simple as on or off, or can contain spline data and in the future it should be possible to write code in the event bars.

The next image shows a screenshot of this tool (written in C++ Qt)

Screen Shot 2013-10-03 at 23.06.36

Last week we had a BBQ which was used to demonstrate the state of the engine. Watch the movie below:
Lights and other events are synced on the music. This syncing is done with the help of the devise tool.

Notice the transparency in combination with deferred lighting. Our engine is improving (great work blackstar!) :)

Some releases we've done:
- Breakpoint 2010 - http://www.youtube.com/watch?v=mkuS1COsHgQ (a quick demo hack build in a few weeks)
- Revision 2012 - http://www.youtube.com/watch?v=vkkftgkw56A (a more mature release)

We've planned to finish out next production on Revision 2014, with some great music from Mr-Z and Davizion

Bundler / Passenger strange deployment Issue

Today I tried to deploy our Ruby on Rails application. Environment: Passenger with Ruby on Rails 1.9.3 (via system-wide-rvm) on FreeBSD. Deployment via a simple capistrano script.

After a successful capistano deploy I get the following error when trying to view it in the browser:

Web application could not be started

Could not find rake-10.1.0 in any of the sources (Bundler::GemNotFound)
  /usr/local/rvm/gems/ruby-1.9.3-p392@generalrails/gems/bundler-1.3.5/lib/bundler/spec_set.rb:92:in `block in materialize'
  /usr/local/rvm/gems/ruby-1.9.3-p392@generalrails/gems/bundler-1.3.5/lib/bundler/spec_set.rb:85:in `map!'
  /usr/local/rvm/gems/ruby-1.9.3-p392@generalrails/gems/bundler-1.3.5/lib/bundler/spec_set.rb:85:in `materialize'
  /usr/local/rvm/gems/ruby-1.9.3-p392@generalrails/gems/bundler-1.3.5/lib/bundler/definition.rb:114:in `specs'
  /usr/local/rvm/gems/ruby-1.9.3-p392@generalrails/gems/bundler-1.3.5/lib/bundler/definition.rb:159:in `specs_for'
  /usr/local/rvm/gems/ruby-1.9.3-p392@generalrails/gems/bundler-1.3.5/lib/bundler/definition.rb:148:in `requested_specs'
  /usr/local/rvm/gems/ruby-1.9.3-p392@generalrails/gems/bundler-1.3.5/lib/bundler/environment.rb:18:in `requested_specs'

When I run rake --version in the selected rvm-environment it just exists.
After searching for while I found the following problem:

Passenger gave the following GEM home:

GEM_HOME = /var/usr/local/www/https_www.webpathy.eu/shared/bundle/ruby/1.9.1

When I look in the directory "shared/bundle/ruby" I see everyting is deployed in a directory named: 1.9. The 1.9.1 directory is completely empty!

That's not going to work
WTF!

My quick work-around is the following:

ln -s 1.9 1.9.1

Now it's running again...
Does anybody know why bundler first deploys it all in "bundle/ruby/1.9" and passenger tries to grab it from "bundle/ruby/1.9" ?!?!?