SameShirtEveryDay.com

Personal blog of the one called Alex Gorbatchev, from Toronto, Canada.
follow me on Twitter

Missing ‘a’ character on Windows with rspec and cucumber

Posted on April 18th, 2009 by Alex Gorbatchev. Tagged with , , , . In Rails, Ruby, Testing, Web Development. 10 comments!

cucumber_a_characters_missing

Trying to get a windows rails environment going this morning I stumbled upon something interesting – all ‘a’ characters were missing from cucumber and rspec output.

This has something to do with UTF-8 encoding and there’s a ticket and wiki post on cucumber about it, but no solution that I found acceptable.

Everything comes down to having change encoding in the current cmd window. This is achieved via a simple call to chcp 1252, but nobody want’s to do this every time, right?

To get this executed automaticaly and without resorting to serious registry editing, simply add this line to your cucmber.bat and any other batch files that are exhibiting this problem. You can find cucumber.bat in your /ruby/bin folder.

Here’s what it looks like:

chcp 1252
@ECHO OFF
IF NOT "%~f0" == "~f0" GOTO :WinNT
@"ruby.exe" "c:/ruby/bin/cucumber" %1 %2 %3 %4 %5 %6 %7 %8 %9
GOTO :EOF
:WinNT
@"ruby.exe" "%~dpn0" %*

Quick 3rdRail overview in screenshots

Posted on September 17th, 2007 by Alex Gorbatchev. In Rails, Ruby. No comments yet...

Code insight for a local class?

Here’s a quick 3rdRail overview in screenshots (flickr required).

CodeGear releases 3rdRail, a Ruby and Rails IDE

Posted on September 17th, 2007 by Alex Gorbatchev. In Rails, Ruby. 3 comments!

Code insight for a local class?

CodeGear released 3rdRail this morning. A few highlights:

  • Full Rails project support.
  • Rails specific refactoring, ie renaming a method in a controller will update all references as well as link_to and rename the associated view file.
  • Console with command completion.
  • Integrated Gecko browser with request monitor, DOM source, CSS and JavaScript

You can watch a screen cast here and download a trial for Windows, Unix and OSX here.

Here’s a quick 3rdRail overview in screenshots (flickr required).

dev_mode_performance_fixes

Posted on August 29th, 2007 by Alex Gorbatchev. In Rails. No comments yet...

dev_mode_performance_fixes plugin by Josh Goebel promises to speed up your Rails development server.

THE PROBLEM

So, what is the problem? It’s the fact that classes aren’t cached in development and that Rails insists on flushing them at the end of every request resulting in large chunks of your apps code having to be loaded, parsed, and reinterpreted for EVERY SINGLE request… which is SLOW.

THE IDEA

Why don’t we only reload the files when they have actually changed? Store the file names and their last modified time and then stat all the files before every request… if any are newer, kill the objects they originally defined and let the Dependency auto-loading code reload the objects from disk.

ruby script/plugin install http://svn.techno-weenie.net/projects/plugins/dev_mode_performance_fixes/

Hello Facebook in Rails

Posted on August 17th, 2007 by Alex Gorbatchev. In Rails, Web Development. 12 comments!

I’ve signed up for Facebook today to check out how the whole application development works. Setting up a development server at home which is accessible from Facebook is pretty straight forward.

Here’s what you need:

  1. Facebook account
  2. Local box with Apache
  3. Domain name pointing to your home IP. I use No-Ip.

Here are the steps I took.

  1. Setting up development application on Facebook. Follow the guide, it’s pretty straight forward.
  2. Set up No-Ip to point *.dev.mydomain.com to my local box. This allows me to create as many Rails applications as I need to.
  3. Configured Apache to forward all calls to fbtest.dev.mydomain.com to localhost:3000 using mod_proxy like so:
    <VirtualHost *:80>
      ServerName fbtest.dev.mydomain.com
      ProxyPass / http://127.0.0.1:3000/
    </VirtualHost>
  4. gem install rfacebook
  5. cd /anywhere/fbtest
  6. rails .
  7. ruby script/plugin install svn://rubyforge.org/var/svn/rfacebook/plugins/rfacebook_on_rails
  8. rake facebook:setup
  9. Go to http://www.facebook.com/developers/apps.php
  10. Copy and paste API key and secret to config/facebook.yml. Set canvas_path to the local path on Facebook, ie /myfacebookapp/ and callback_path to local path on your server, ie /facebook/.
  11. ruby script/generate controller facebook index
  12. Edit index method in Facebook controller, like so:
    class FacebookController < ApplicationController
      def index
        @result = fbsession.friends_get.uid_list
      end
    end
  13. Edit index.rhtml like so:
    <% @result.each do |uid| %>
      <fb:name uid="<%= uid %>" />
    <% end %>
  14. Start Apache
  15. ruby script/server
  16. Now you should be able to hit your Facebook application page at http://apps.facebook.com/myfacebookapp

You should see a list of your friends. Took me about 30 minutes to figure all this out.

home
Subscribe to this blog Follow me on Twitter My bookmarks on Delicious My photography on Flickr