Rails 2.3.2 + Ruby 1.8.8

  • Digg this article
  • Sphinn this article
  • Stumble this article
  • Facebook
  • del.icio.us
  • LinkedIn
  • Twit this article

Sunday, 22 March 2009

Have plans to virtualize my server so the blog and all other important parts are getting pushed over to a new temporary home while I map it all out. With that I thought it might be great time to see how things cope with Rails 2.3.2 and the latest stable snapshot of Ruby 1.8.8.

Points to note, I had to change my application.rb file to application_controller.rb for the new 2.3.2 layout, done simply with;

rake rails:update:application_controller

And when compiling Ruby 1.8.8 (1.8.7 is the official stable mind), had to edit line 5 of version.h

from...
  #define RUBY_PATCHLEVEL -1
to...
  #define RUBY_PATCHLEVEL 1

Without this, RubyGems won't install, complaining about the version (1.8.8dev). This changes it to 1.8.8p1 for which RubyGems will no longer complain at.

So far, memory & speed are churning out good, used linode for this one as they offer 32-bit builds which are perfect for the job.

Ruby vs Python

"Each have a culture that defines them. Python is built around 'There's one way to do it' unlike Ruby which takes Perl's mantra 'There's more than one way to do it.'"

Thanks TopFunky for this,

How To: Upgrade Ruby on OSX Leopard

  • Digg this article
  • Sphinn this article
  • Stumble this article
  • Facebook
  • del.icio.us
  • LinkedIn
  • Twit this article

Monday, 26 January 2009

Just tested this and works ok. Leopard comes with 1.8.6, my box has 1.8.7 so best to keep them uniform for better code reliance.

What this'll do is replace your current version of Ruby without replacing the one supplied by Apple. Their's is stored in /usr/bin/ruby, your's will be stored in /usr/local/bin/ruby then hooked up with the PATH directive.

So in Terminal

sudo port install wget

wget ftp://ftp.ruby-lang.org/pub/ruby/stable-snapshot.tar.gz
tar -xzvf stable*.tar.gz
cd ruby

Configure & Build Ruby for Leopard

./configure --prefix=/usr/local --enable-pthread
sudo make
sudo make install

Add the files to your Terminal's path

mate ~/.bash_profile

Add and Save this line

export PATH=/usr/local/bin:$PATH

Refresh Terminal,

ruby -v
=> ruby 1.8.7 (2009-01-23 revision 0) [i386-darwin9.6.0]
Gems

Because this'll effectively give you another version of Ruby taking over from the supplied one, you'll have to re-install RubyGems, sorry....

wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz
tar -xzvf rubygems*.tgz
cd rubygems*

sudo ruby setup.rb

Here's some install commands to get you started from my last setup

sudo gem install rails rake mysql mongrel mongrel_cluster thin capistrano termios sqlite3-ruby mini_magick ZenTest liquid rcov RubyInline image_science

MySQL is a pig on Leopard so this will get that gem working again

sudo env ARCHFLAGS="-arch i386" gem install mysql -- \  --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib \  --with-mysql-include=/usr/local/mysql/include

Then some of my favourites...

gem sources -a http://gems.github.com
sudo gem install ultrasphinx rdiscount RedCloth twitter4r mislav-will_paginate fastercsv

...gotta dash, still on season 2 of 24, girlfriend won't let me watch day 7 until i've seen the rest ;-)

activesupport, utf-8, iconv and safe urls

  • Digg this article
  • Sphinn this article
  • Stumble this article
  • Facebook
  • del.icio.us
  • LinkedIn
  • Twit this article

Monday, 19 January 2009

A-Team

Been playing with character sets in Ruby, thankfully like most things in this language it's pretty simple.

First off, if you need access to any of the UTF-8 handlers in ActiveSupport in your Ruby script, do:

require "rubygems"
require "active_support"

This'll give you a suite of methods including .is_utf8? and mb_chars (previously chars) at your disposal.

Next up if you're trying to convert data from different character formats have a look at Iconv.

require 'iconv'

content = "them and today\xE2\x80\x99s College"
content = Iconv.iconv('ISO-8859-1//TRANSLIT', 'UTF-8', content).to_s
puts content
=> them and today’s College

In this example I've got a utf-8 string I'm trying to convert to Latin ("//TRANSLIT", approximately make conversion).

So using the Iconv module, I tell it what I want returned and what format the data I'm giving it and it returns that as an array of characters, then using .to_s I can break it back from an array to a string.

Iconv.iconv(target, source, string)

There are a lot of character codes out there, here are a few,

8859-1 <= western latin
cp437 <= extended ascii
cp1251 <= windows code page 1251 (cyrilic)

This piece of code converts a multi-byte string to something more url safe for permalinks

class String
  def to_permalink
    (Iconv.new('US-ASCII//TRANSLIT', 'utf-8').iconv self).gsub(/[^\w\s\-\—]/,'').gsub(/[^\w]|[\_]/,' ').split.join('-').downcase
  end
end

...thanks to demimismo for this

More here

Ouch my ears!

  • Digg this article
  • Sphinn this article
  • Stumble this article
  • Facebook
  • del.icio.us
  • LinkedIn
  • Twit this article

Tuesday, 04 November 2008

When upgrading to Ubuntu Ibex 8.10 i've begun to notice that on shutdown the pc speaker beeps really loudly. Going into System / Preferences / Sound didn't stop this so i've found another way which is to add it to the modprobe blacklist file (which although in no way perfect does kill it).

sudo gedit /etc/modprobe.d/blacklist

Then add this at the end of the file,

blacklist pcspkr

Save the file, close gedit then for good measure kill it once and for all,

sudo rmmod pcspkr

Harsh but should do the trick

Ubuntu Ibex 8.10 Beta - updated

  • Digg this article
  • Sphinn this article
  • Stumble this article
  • Facebook
  • del.icio.us
  • LinkedIn
  • Twit this article

Sunday, 12 October 2008

Ubuntu Ibex 8.10

Last night I upgraded my laptop's o/s to the new Ibex 8.10 release, not yet official still in beta but so far very stable.

This can be done via,

sudo update-manager -d

...then choosing the new distribution 8.10 from the top of the update manager dialog, you'll need about 1 hour for it to download & install. Be around for some of the dialogs; one of which will ask you if you want to merge or replace your network script (i clicked merge) after which you should be ok.

It comes with a lot of new updates and a major interface overhaul.

There's now a fallback linux kernel if the main one should fail (like ArchLinux), more windows-like logout panel, better hibernation and a new theme called NewHuman (see screenshot above).

Along with this there's available from the repository,

  • VLC 0.94 (with a more graphical control panel)
  • GIMP 2.6 (much more professional)
  • Gnome 2.24 (with tabbed browsing)
  • GEdit 2.24

...and a ton of other newer packages, Mercurial is also updated along with the Kernel so any new hardware should be properly recognised.

After the install I had to reboot obviously, on rebooting my wifi no longer worked, so after another reboot that came back. Did an update & upgrade for any newer packages and so far other than the battery indicator applet crashing a couple of times nothing majorly serious.

Eclipse is still at 3.2 in the repository, along with NetBeans at 6.1 so that's a little bit of a bummer. However NetBeans does come with an easier installer so just grab the latest nightly build for that, Eclipse Ganymede and 3.2 are proving a little flakey at the moment.

Interface-wise it is a heck of a lot better than the previous release and although unofficially available I would recommend grabbing a copy, definitely worth the effort.

Update

Just done an update,

  • In the repositories is Flash Player 10.
  • On bootup instead of saying 'kernel alive.. etc..', they've replaced it with 'Starting up...'; nice.
  • The Installer is now graphical with a very osx partition manager and new logout screens and graphics.
  • On that end when you login the screen doesn't go blank then show the desktop but stay Ubuntu Brown then show the desktop.
  • Stick a dvd in first-time and like Windows it'll ask you what you want to open it with, vlc, totem, etc.
  • Plus you've got some nice new default wallpapers available.

Did have a problem with the NewHuman theme, after doing a safe-upgrade I lost the theme, although I did find a replacement;

Dust

..you need to download the Murrine debian package for the distro you're using, install it, then download + install the Dust Theme.

Other than that this release is shaping up pretty nicely!

OpenOffice 3

Found this good guide to replacing OpenOffice 2.4.1 with the latest 3.0 release, pretty simple.

Basically add this to your repository then update and upgrade & you should have the new build.

deb http://ppa.launchpad.net/openoffice-pkgs/ubuntu intrepid main
Firefox 3.1 alpha

Add this to your repository to grab Firefox 3.1

deb http://ppa.launchpad.net/fta/ubuntu intrepid main

Ubuntu Setup

  • Digg this article
  • Sphinn this article
  • Stumble this article
  • Facebook
  • del.icio.us
  • LinkedIn
  • Twit this article

Sunday, 11 May 2008

After grabbing and installing Ubuntu 8.04 I then had to put together and setup the baby, luckily I wrote down most of everything I did in case I'd have to do it again and to help out you guys.

What follows are my findings and what I did to fix them. The machine I used is an HP Pavillion dv2000 model dv2742 special edition. It's got a built-in intel graphics card, 3gb memory, sata 250gb drive, wifi, bluetooth and an intel dual core 2 processor.

I installed the o/s using the 64-bit edition of Ubuntu 8.04 Hardy Heron, all what you see below are workable settings which provided the right setup; hope they help your situation if you go down this route.

Update System

First port of call, check for any new updates post-install,

sudo aptitude update
sudo aptitude upgrade

Dependencies / Software / Setup

Next, install Ruby, FlashPlayer, GCC Compiler, MySQL, JAVA, SqlLite,

sudo aptitude install mysql-server flashplugin-nonfree ruby-full libsqlite3-dev build-essential libmysqlclient15-dev sun-java6-jdk

Volume Mixer,

sudo aptitude install gnome-alsamixer

ImageMagick,

sudo aptitude install imagemagick

Ruby Gem Handler

I could get GEM from the repositories but because with each new update it breaks away from the in-built Linux installer it's best to install it from source,

wget http://rubyforge.org/frs/download.php/34638/rubygems-1.1.0.tgz 
tar xzvf rubygems-1.1.0.tgz
cd rubygems-1.1.0
sudo ruby setup.rb
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem

Had problems updating the GEM system initally, so logged in as root to finish it off,

su root 
sudo gem update --system

Now when you type gem --version you should see GEM ready to roll,

Gem Libraries

The slow bit, ran this as root just to make sure it worked,

sudo gem install rails rake mongrel mongrel_cluster thin capistrano mysql termios sqlite3-ruby mini_magick will_paginate ZenTest liquid rcov

How to update RubyGem's later

Later on you'll want to update the gem system, which by going this way won't be possible with the usual 'sudo gem update --system', but this:

sudo gem install rubygems-update
sudo update_rubygems

VLC + GIT

Next VLC to play videos,

sudo aptitude install vlc

Transmission for torrents, most important bit,

sudo aptitude install transmission

And GIT to handle code versioning,

sudo aptitude install git-core

Firefox + MS Fonts

Next I need Firebug for Firefox 3. Ubuntu 8.04 comes with Firefox 3 beta 5, the one available thru Tools / Add-ons won't work with it; but thankfully it's in the repositories

sudo aptitude install firebug

And you'll probably need Microsoft Fonts later down the line,

sudo aptitude install msttcorefonts

Pimp GEDIT

The default Gnome Text Editor Isn't bad but let's add some extra's to really kick it in gear,

sudo aptitude install gedit-plugins

And tweak it,

wget http://robzon.kapati.net/rails/rhtml.lang && sudo mv rhtml.lang /usr/share/gtksourceview-2.0/language-specs/
wget http://robzon.kapati.net/rails/rails.xml && sudo mv rails.xml /usr/share/mime/packages
sudo update-mime-database /usr/share/mime

Follow the guide here to get the TextMate look,

Now when you open rails source files they'll actually look right, thanks Grigio.

PostGreSql + Thunderbird

Pretty easy to install the most powerful db system, and the better email handler

sudo aptitude install postgresql thunderbird

Wine for Windows

Thanks to Google for their support the Wine project is going great, to get Windows software running natively on your machine,

First add the key,

wget -q http://wine.budgetdedicated.com/apt/387EE263.gpg -O- | sudo apt-key add -

Then add the repository to your default repository list,

sudo wget http://wine.budgetdedicated.com/apt/sources.list.d/hardy.list -O /etc/apt/sources.list.d/winehq.list

And finally install it,

sudo apt-get install wine

Effects

To enable compiz effects make sure Appearance / Visual Effects is set to 'Extra', then install the Advanced Effects Manager,

sudo aptitude install compizconfig-settings-manager

This will give you access to the 3d cube, skydome effect and a host of other cool addons.

My desktop dpi is set to 100dpi, fonts set to 'Bitstream Vera Sans Roman 8pt', with 'Bitstream Vera Sans Bold 8pt' for Windows Title; and 'Liberation Mono 8pt' for fixed width font. Using subpixel smoothing for LCD.

Sound

For my laptop (hp pavillion dv2000 / dv2742se model), i had to use a different sound mixer to make sure the quickplay volume and mute buttons talked to the sound system.

So from the top menu bar, System / Preferences / Sounds, then set the Default Mixer Tracks hander device to: Conexant CX20561 (hermosa) (oss mixer).

Cleanup

To get any temp files carried on from the install, clean with,

sudo aptitude clean

Job done, however I had a problem with Hibernate & Suspend which was lucky fixed with some advice from here

Install Skype - Ubuntu 8.04

  • Digg this article
  • Sphinn this article
  • Stumble this article
  • Facebook
  • del.icio.us
  • LinkedIn
  • Twit this article

Sunday, 11 May 2008

To install Skype on an AMD-64 system, you'll need the 32-bit libraries (if you're distro is 32-bit, skip this bit),

sudo apt-get install ia32-libs

Now grab the qt4 libraries,

sudo apt-get install libqt4-gui libqt4-core

Download the appropriate Skype package from...

Firefox should download it to your desktop so...

cd Desktop
sudo dpkg --install --force-architecture --force-depends skype-debian_2.0.0.72-1_i386.deb

And you're done, with the Webcam driver installed and enabled you should now be able to make video calls too.

Update 64-bit distro available

IE 7 and password fields

  • Digg this article
  • Sphinn this article
  • Stumble this article
  • Facebook
  • del.icio.us
  • LinkedIn
  • Twit this article

Thursday, 06 March 2008

Quick Note. Unlike Firefox, Internet Explorer handles password fields a little differently, blanking out whatever value you pass it within a 'value' tag.

So...

<typo:code lang="ruby"> </typo:code>

Will have a password box in Firefox starred out, but in IE it'll appear blank.

To get around this you can use Prototype to inject a value into the password field, so the user see's it as starred out.

<typo:code lang="ruby"> $('mypass').value='********'; </typo:code>

Note, if you're generating the form dynamically with...

<typo:code lang="ruby"> var innerhtml='

Only fire your $('mypass') code after the form has been written to the page otherwise you won't be able to get a handle on it (most cases you won't ever have this problem).

Flash 9 + Quicktime on Fedora 8

  • Digg this article
  • Sphinn this article
  • Stumble this article
  • Facebook
  • del.icio.us
  • LinkedIn
  • Twit this article

Thursday, 21 February 2008

Flash 9

sudo rpm -ivh http://linuxdownload.adobe.com/adobe-release/adobe-release-i386-1.0-1.noarch.rpm
sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-adobe-linux
mkdir -p /usr/lib/mozilla/plugins
sudo yum install nspluginwrapper.{i386,x86_64} pulseaudio-lib.i386
sudo yum install flash-plugin
mozilla-plugin-config -i -g -v

After that you should have the 64-bit edition of Flash 9 running in Firefox, the 32-bit edition is much easier.

Quicktime

sudo yum install mplayer mplayer-gui mplayer-skins mplayer-fonts mplayerplug-in mencoder
sudo /usr/bin/mozilla-plugin-config -i -f

Re-open Firefox and you should get some new video plugins enabled.