Move Wubi installation (Ubuntu on Windows) to a native Ubuntu system

There’s a tool called LVPM which could do the move, but there are sometimes problems with it. So I recommend to use a faster and safer way to do it - with the wubi-move-to-partition script:

  1. Boot into your Wubi installation.
  2. Open a shell and do a:
    wget "https://wiki.ubuntu.com/WubiGuide?action=AttachFile&do=get&target=wubi-move-to-partition"
  3. Install and run gparted:
    sudo apt-get install gparted
    sudo gparted
  4. Now create a swap partition (1x or better 2x the size of your memory) and an ext3 partition for your new ubuntu partition.
  5. Back in the shell, find out how the new partitions are called with:
    sudo fdisk -l
  6. Now start the move:
    sudo sh wubi-move-to-partition /dev/sdx1 /dev/sdx2
    (where /dev/sdx1 is your new ubuntu partition and /dev/sdx2 is the new swap partition you’ve just created with gparted)
  7. After the successful move, simply reboot your system. You should be able to boot into your new native ubuntu system.

If there are no problems with your new system, you might want to boot into windows to uninstall your wubi installation (Start Menu/Control Panel/Add or Remove Programs). It’s not needed any longer.
Keywords: transfer wubi, upgrade wubi, change wubi, native ubuntu, native linux, proper, clean, full, real, remove wubi

Smilies in Rails using RedCloth

RedCloth doesn’t come with support for smilies, so i’ve added it for one of my projects.
You need to extend the RedCloth class. You could do this by creating a file in your /lib directory, which you have to include in your environment.rb. Here an example for three simple smilies:

class RedCloth
  def glyphs_smilies(text)
    text.gsub!(/\:\-\)|\:\)/, '<img src="/images/emoticons/smile.png" alt="smile" />')
    text.gsub!(/\;\-\)|\;\)/, '<img src="/images/emoticons/wink.png" alt="wink" />')
    text.gsub!(/\:\-\(|\:\(/, '<img src="/images/emoticons/sad.png" alt="sad" />')
  end
end

To include this new function in your views, write an helper, e.g. format_text in ApplicationHelper:

module ApplicationHelper
  def format_text(text)
    RedCloth.new(text).to_html(:textile, :glyphs_smilies)
  end
end

Now you could use it anywhere in your views, like

  <%= format_text ":)" %>

or

  <%= format_text @your_record.your_text %>

Of course, you have to put some smilies in /images/emoticons :)

Keywords: smiley, smileys, smilie, smilies, rails, textile, redcloth, ruby, emoticon, emoticons

Rails: routes and special characters like dots

Rails doesn’t seem to like dots and other special chars in its routes.
If you want to use URLs like http://www.domain.com/post/1/just_a_test.. logically the following route seems to be sensible:

map.connect '/post/:id/:title', :controller => 'forum', :action => 'show_post'

But rails won’t like the dots. Use a route like the following to allow a URL with special characters to be routed:

map.connect '/post/:id/:title', :controller => 'forum', :action => 'show_post', :requirements => { :title => /.*/ }

Keywords: dots, dot, no route matches, punkt, punkte, routes.rb, routing, route, rails, problem, won’t work

Sehnsucht nach Ruhe

Functional test for HTTP Basic Authentication in Rails 2

If you want to provide a username and password for a HTTP Basic Authentication in one of your functional tests, simply use the following:

def test_should_get_index
  @request.env["HTTP_AUTHORIZATION"] = "Basic " + Base64::encode64("username:password")
  get :index
  assert_response :success
  assert_not_nil assigns(:articles)
end

Keywords: rails test, functionals, authorization, basic http authentication, how to test

404 in rails

If you need to show a 404 error page from your controller without using an exception, this could help:

render :file => "#{RAILS_ROOT}/public/404.html",  :status => 404 and return

Rails 2: authenticate_or_request_with_http_basic and Apache

I’ve tried to use the new authenticate_or_request_with_http_basic function of Rails 2 to include a simple authentication for some special pages in an application. But Apache kept refusing authorization, even if the authenticate_or_request_with_http_basic-block was set to be always true.

To fix this, add or change this in your public/.htaccess (if using FastCGI):

RewriteRule ^(.*)$ dispatch.fcgi [E=X-HTTP_AUTHORIZATION:%{HTTP:Authorization},QSA,L]

Keywords: rails2 rails http authentication error bug refusing apache problem

Save my life

Another piece of great emo

Okkervil River

That’s what I’d call EMO.

Localization problem with Wordpress 2.3

I’ve transferred a wordpress system to another server which runs PHP 5. The language file didn’t work anymore. After one annoying hour I’ve found out that the gettext functions are buggy.

Solution:

That’s all.

Keywords: wordpress, localization, php 5, language file, problem, 64 bit, gettext, de_DE.mo


linkboost