Entries Tagged 'Ruby' ↓

Just some stuff

Just some quick links!

This links describes how to manage multiple databases with Capistrano. That’s not why I picked it though. I liked it because it shows the “<<: *” syntax of yaml.

And a repository of Ubuntu Hardy Heron debs for mod_rails/Phusion passenger. At this time I installed mod_rails via rubygems. But if the guys at brighbox make the package so it builds/installs the Apache module automatically (without human intervention and pressing Y two times) I will install that one. Much, much nicer to use with Puppet.

Installed passenger a.k.a. mod_rails


Today I’ve installed Phusion passenger on one of our servers. I wanted Redmine for one of our projects so this seemede a nice opportunity to install it.

Installation was a breeze. For mod_rails as well Redmine.

So I was thinking: we have mod_rails installed, we could offer some rails hosting to attract new customers.

But I see three bears on the road with using mod_rails in a shared hosting environment.

1. Same user

Every mod_rails site runs on the same user :( I’ve spent hours on configuring fastcgi and suexec. But now every hosting custommer’s scripts run under their own user. Would be nice if mod_rails supported something like that.

2. Memory

I couldn’t find an option to limit the memory usage per mod_rails site. And I know how memory hungry rails can be :(

3. Aliases

Mod_rails doesn’t support host aliases. This is overcomable but feels like a hack. Wouldn’t it be nice if mod_rails supported aliases :) Pleeeeeeaaaaase?

Maybe I haven’t read the documentation to well and are my points useless :) In that case: please let me know!

Installing ruby 1.8.7 (and guessnet) on Hardy

There were some vulnerabilities in Ruby which are supposedly fixed in ruby 1.8.7. Because of that and because it's always nice to have the latest, I installed ruby from Ubuntu Intrepid on Hardy Herron.

And while I was doing that I also decided to install guessnet from Intrepid. So I don't have to compile guessnet anymore.

It involves two steps:

  1. Updating you apt sources
  2. Making sure only ruby and guessnet are going to be installed from the new sources. Not all the packages!

1. Updating your sources

Create /etc/apt/sources.list.d/intrepid.list and copy the following code into it:

CODE:
  1. deb http://nl.archive.ubuntu.com/ubuntu/ intrepid main restricted multiverse
  2. deb-src http://nl.archive.ubuntu.com/ubuntu/ intrepid main restricted
  3.  
  4. ## Major bug fix updates produced after the final release of the
  5. ## distribution.
  6. deb http://nl.archive.ubuntu.com/ubuntu/ intrepid-updates main restricted multiverse
  7. deb-src http://nl.archive.ubuntu.com/ubuntu/ intrepid-updates main restricted
  8.  
  9. ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
  10. ## team, and may not be under a free licence. Please satisfy yourself as to
  11. ## your rights to use the software. Also, please note that software in
  12. ## universe WILL NOT receive any review or updates from the Ubuntu security
  13. ## team.
  14. deb http://nl.archive.ubuntu.com/ubuntu/ intrepid universe
  15. deb-src http://nl.archive.ubuntu.com/ubuntu/ intrepid universe
  16. deb http://nl.archive.ubuntu.com/ubuntu/ intrepid-updates universe
  17. deb-src http://nl.archive.ubuntu.com/ubuntu/ intrepid-updates universe
  18.  
  19. ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
  20. ## team, and may not be under a free licence. Please satisfy yourself as to
  21. ## your rights to use the software. Also, please note that software in
  22. ## multiverse WILL NOT receive any review or updates from the Ubuntu
  23. ## security team.
  24.  
  25. ## Uncomment the following two lines to add software from the 'backports'
  26. ## repository.
  27. ## N.B. software from this repository may not have been tested as
  28. ## extensively as that contained in the main release, although it includes
  29. ## newer versions of some applications which may provide useful features.
  30. ## Also, please note that software in backports WILL NOT receive any review
  31. ## or updates from the Ubuntu security team.
  32. deb http://nl.archive.ubuntu.com/ubuntu/ intrepid-backports main restricted universe multiverse
  33. # deb-src http://nl.archive.ubuntu.com/ubuntu/ intrepid-backports main restricted universe multiverse
  34.  
  35. ## Uncomment the following two lines to add software from Canonical's
  36. ## 'partner' repository. This software is not part of Ubuntu, but is
  37. ## offered by Canonical and the respective vendors as a service to Ubuntu
  38. ## users.
  39. deb http://archive.canonical.com/ubuntu intrepid partner
  40. # deb-src http://archive.canonical.com/ubuntu intrepid partner
  41. deb http://security.ubuntu.com/ubuntu intrepid-security main restricted multiverse
  42. deb-src http://security.ubuntu.com/ubuntu intrepid-security main restricted
  43. deb http://security.ubuntu.com/ubuntu intrepid-security universe
  44. deb-src http://security.ubuntu.com/ubuntu intrepid-security universe

2. Apt preferences

If /etc/apt/preferences does not exist, touch it!

Then copy this code into it:

CODE:
  1. Package: *
  2. Pin: release v=8.10
  3. Pin-Priority: -1
  4. Package: ruby
  5. Pin: release v=8.10
  6. Pin-Priority: 500
  7.  
  8. Package: ruby1.8
  9. Pin: release v=8.10
  10. Pin-Priority: 500
  11.  
  12. Package: libruby
  13. Pin: release v=8.10
  14. Pin-Priority: 500
  15.  
  16. Package: libruby1.8
  17. Pin: release v=8.10
  18. Pin-Priority: 500
  19.  
  20. Package: rdoc
  21. Pin: release v=8.10
  22. Pin-Priority: 500
  23.  
  24. Package: rdoc1.8
  25. Pin: release v=8.10
  26. Pin-Priority: 500
  27.  
  28. Package: ri
  29. Pin: release v=8.10
  30. Pin-Priority: 500
  31.  
  32. Package: ri1.8
  33. Pin: release v=8.10
  34. Pin-Priority: 500
  35.  
  36. Package: irb
  37. Pin: release v=8.10
  38. Pin-Priority: 500
  39.  
  40. Package: irb1.8
  41. Pin: release v=8.10
  42. Pin-Priority: 500
  43.  
  44. Package: libopenssl-ruby
  45. Pin: release v=8.10
  46. Pin-Priority: 500
  47.  
  48. Package: libreadline-ruby
  49. Pin: release v=8.10
  50. Pin-Priority: 500
  51.  
  52. Package: libreadline-ruby1.8
  53. Pin: release v=8.10
  54. Pin-Priority: 500
  55.  
  56. Package: ruby-dev
  57. Pin: release v=8.10
  58. Pin-Priority: 500
  59.  
  60. Package: ruby1.8-dev
  61. Pin: release v=8.10
  62. Pin-Priority: 500
  63. Package: guessnet
  64. Pin: release v=8.10
  65. Pin-Priority: 501

That's all! "Aptitude update" & "aptitude install ruby guessnet" and you are good to go.

I tried using the "Package" keyword with wildcards, but that's a no-go :(

Puppet troubles

I've installed puppet recently and I'm know trying to understand how it works and make use of it :)

If that's not difficult enough, I encountered this weird behaviour that the --noop argument didn't do anything. After an hour of searching I realized it was my own stupid fault!

I had to puppet configuration files: /etc/puppet/puppetd.conf (old way) and /etc/puppet/puppet.conf (new way). I browsed throught the source code and it looks like puppet first checks the old file, if it is found it parses that one. If it's not found, the new file is parsed. I don't know why, but if the old file is used, the --noop argument isn't parsed by puppet. So removing /etc/puppet/puppetd.conf was all I had to do. Pffff....

But why did I create the puppetd.conf file? Because I'v read the "Pulling strings with puppet"-book. And althought it's fairly new, puppet is advancing at a very high rate. So the book is becoming out-of-date already.

Released callbacks 0.0.1

Hi all! I've released my first project on rubyforge. The sourcecode is on github though. For theĀ  simple reason that my git repository on rubyforge doesn't work (yet). I hope they will fix it soon.

I've setup the project with the wonderful bones of Tim Pease.

I've got some reasonable documentation about it, a kick-ass website (stolen from Dr. Nic's newgem) and some nice unit tests. I'm now integrating the gem in one of my own projects. If that's succesfull I'm gonna release a version 0.1. The version after 0.1 will have new features.

The website ws generated with webby. A really nice way to create static websites in ruby. Maybe I'll dedicate a post/tutorial to webby.

So please look at the website, install the gem and give me some feedback. It will be very appreciated!

Interactive/inline editor in irb

I saw the MountainWest Ruby conference video: code generation: safety scissors of metaprogramming. And the speaker (Giles Bowkett) used vi from inside irb. And I've never liked Vi, but using an editor from within irb is nice! Especially if you're testing a big chunk of code.

So I began crawling the Internet for how he did this and I found the utility_belt gem. The utility belt contains the file I needed. So I installed the gem, edited my .irbrc and now I can use nano/gedit (or any other editor) from withing IRB!

These were the steps:

CODE:
  1. gem install utility_belt

My .irbrc:

CODE:
  1. require 'utility_belt/interactive_editor'
  2. module InteractiveEditing
  3. def nano
  4. edit_interactively(:nano)
  5. end
  6. end

Now to use nano in irb, just type: nano

And the bonus: a nice screencast that shows this feature in action. I tried to edit it with pitivi. But that really sucked. After I finally found it out how I could cut pieces I tried to save it and the whole program crashed. "apt-get remove pitivi"!

Up to date on GIT

GithubI've been using GIT now some weeks (for my ultra-secret ruby project) and I must say it's nice. Nothing more than nice. Just like svn was nice to use (compared to old-school full backups). When I first saw the GIT commands I was dazzling with confusion. But after two days you get the hang of it. I haven't done anything special like branching so I can't tell you about the advanced features. But the base is solid.

Ow, and github is really nice. I read somewhere that rubyforge now has git support too. Gonna check that out. But beating github will be difficult. Well, at least for now when Github is still free of charge!

testing and Rails

Ratatouille

As a "professional" webdesigner I know how much testing sucks and how it, at the same time, is one of the most important things to do (besides coding the stuff). That's why I appreciate Rails' very complete testsuite so much. And now with Rspec user stories (a nice tutorial here and here) and webrat it's getting even better!

Installing jruby

I used this resource:

http://rorblog.techcfl.com/2008/02/19/create-and-deploy-a-jruby-app-to-the-glassfish-gem-in-10-minutes-or-less-on-mac-os-x/

How to install jruby on Ubuntu:

CODE:
  1. sudo -i
  2. mdir -p ~/src/jruby/trunk
  3. cd ~/src/jruby/trunk
  4. svn svn.codehaus.org/jruby/trunk/jruby/ .
  5. ant
  6. ~/src/jruby/trunk/bin/jruby --version

The current version doesn't work to well with rails' script/console. It is very, very, very slow. So I keep using Yarv until this is fixed. It seems really promising though. Can't wait for Rubinius to become stable!

Rdoc and Rails

With my fabulous new project: mpd_radio I'm trying to everything right: tests, documentation, the whole shebang. So I was surfing tonight for some tutorials on rdoc. But I couldn't find a lot. Some useful links:

When I learn some more about it I'll post it here!