ruby1.9

Mongrel with Ruby 1.9.

When starting the server, I get this strange error after updating to Ruby 1.9: " [BUG] cross-thread violation on rb_gc() ruby 1.8.6 (2008-08-11) [i386-mswin32] This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. " My mongrel version is 1.1.6,...

Is autoload thread-safe in Ruby 1.9?

It seems to me that the Ruby community has been freaking out a little about autoload since this famous thread, discouraging its use for thread safety reasons. Does anyone know if this is no longer an issue in Ruby 1.9.1 or 1.9.2? I've seen a bit of talk about wrapping requires in mutexes and such, but the 1.9 changelogs (or at least as...

problems installing ruby 1.9.1-p378 on snow leopard

i've installed the latest upgrades to the dev tools, and tried re-installing, and yet i still get this error: You have to install development tools first. from /Users/jian/Downloads/ruby-1.9.1-p378/lib/mkmf.rb:427:in try_compile' from /Users/jian/Downloads/ruby-1.9.1-p378/lib/mkmf.rb:473:intry_static_assert' from /Users/jian...

Authlogic_OpenID - "uninitialized constant Rack::OpenID"

So I followed the railscast tutorial (http://railscasts.com/episodes/170-openid-with-authlogic) and used the old version of the plugin from Ryan's git file. I can now successfuly create/register a user using OpenID (Google), but I cannot log in with this user. When I submit the OpenID that has been registered, I get "uninitialized consta...

Ruby, RoR, gmail and NET::SMTP

Is there any way to use gmail as a smtp server on rails 2.3.5/ruby 1.9.1? My smtp settings for actionmailer are options = { :address => "smtp.gmail.com", :port => 587, :domain => 'REMOVED', :user_name => 'REMOVED', :password => 'REMOVED', :authentication ...

Taking out a subpart from Enumerable

I often want to take out a subpart from an Enumerable. The subpart is sometimes at the beginning and sometimes the end of the original Enumerable instance, and the length used to specify the subpart is sometimes that of the subpart and sometimes its complement. That gives four possibilities, but I only know how to do three of them. Is th...

In which versions of ruby are external iterator speeds improved?

According to this rubyquiz, external iterators used to be slow, but are now faster. Is this an improvement only available in YARV (the C-based implementation of ruby 1.9), or is this also available in the C-based implementation of ruby 1.8.7? Also, does enum_for rely on external iterators? ...

sphinx, xmlpipe2, and cassandra

Hi, I start to using cassandra and I want to index my db with sphinx. I wrote ruby script which is used as xmlpipe, and I configure sphinx to use it. source xmlsrc { type = xmlpipe2 xmlpipe_command = /usr/local/bin/ruby /home/httpd/html/app/script/sphinxpipe.rb } When ...

Detect encoding

I'm getting some string data from the web, and I suspect that it's not always what it says it is. I don't know where the problem is, and I just don't care anymore. From day one on this project I've been fighting Ruby string encoding. I really want some way to say: "Here's a string. What the hell is it?", and then use that data to get it ...

How do I load files from a specific relative path in Ruby?

I'm making a gem for internal use. In it, I load some YAML from another directory: # in <project_root>/bin/magicwand MagicWand::Configuration::Initializer.new(...) # in <project_root>/lib/magicwand/configuration/initializer.rb root_yaml = YAML.load_file( File.expand_path("../../../../data/#{RootFileName}", __FILE__)) # in <project_r...

How do I replace all the values in a hash with a new value?

Let's say I have an arbitrarily deep nested Hash h: h = { :foo => { :bar => 1 }, :baz => 10, :quux => { :swozz => {:muux => 1000}, :grimel => 200 } # ... } And let's say I have a class C defined as: class C attr_accessor :dict end How do I replace all nested values in h so that they are now C instances with the dict attri...

Functional unwrapping of nested array

Given an array containing other nested arrays, I want to create an array containing only the elements from the first array. For example [["1", "2"], "3", [["4"]]] should evaluate to ["1", "2", "3", "4"]. I've managed to make a method that works: @@unwrapped_array = [] def unwrap_nested_array(array) if array.respond_to?('each') ...

Encoding problems with hpricot

I am getting the following encoding error when trying to scrap web pages with hpricot in ruby 1.9: Encoding::CompatibilityError: incompatible character encodings: ASCII-8BIT and UTF-8 I can reproduce the error by doing the following: ska:~ sam$ rvm 1.9.2@hpricot ska:~ sam$ ruby -v ruby 1.9.2dev (2010-05-31 revision 28117) [x86_64-dar...

Write an atomic operation

Hi, I would like to execute some methods atomicity with Ruby, according to http://en.wikipedia.org/wiki/Atomicity_(database_systems) For instance, if I have: a = 30 b = 75 I would like to be able to do something like: atomic_operation do a += 10 b -= 39 end Is there a native module in Ruby 1.9 that allow such process? If pos...

Ruby 1.9, Rails 2.3.9 and unicode characters in database and erb views, still a no go?

I have a Rails application running on Rails 2.3.9. It runs fine with ruby 1.8.7. I'm testing it with ruby 1.9.2-head right now. The application loads fine until I try to load a page that relies on a unicode string. Then I get the infamous encoding error: ActionView::TemplateError (incompatible character encodings: UTF-8 and ASCII-8BIT...

Is there a way to call ruby1.9 without loading rubygems?

So ruby 1.9 is really nice in that it'll automatically require rubygems, and hence when you call require 'somegem' without first requiring rubygems it'll work, and that's generally awesome. But I have a ton of shell scripts using ruby, and they generally don't rely on rubygems. Shell tools should run instantly, and loading rubygems for ...

How to avoid putting the magic encoding comment on top of every UTF-8 file in Ruby 1.9?

I have a Rails project with lots and lots of cyrillic strings in it. It worked fine on Ruby 1.8, but Ruby 1.9 recognizes all source files as US-ASCII-encoded until you provide an # encoding: utf-8 comment on top of each and every source file in the project. Obviously the files don't parse as US-ASCII. Is there a simpler way to say, li...

How to deal with 'incompatible character encodings: ASCII-8BIT and GBK' exception ?

I am reading 'Agile Web Development with Rails.3rd'. When finishing the depot application, I input some Chinese character as user name. But I got this error, it seems this has something to do with Ruby1.9 My environment is window xp, Ruby1.9 Rails 2.3.8 and sqlite3. The following is the detail about this error: Showing app/views/lay...

How to update Ruby in Google SketchUp?

Currently Google SketchUp for Mac has Ruby version 1.8.5 which I find a bit outdated. I can update Ruby to 1.8.7 (OSX's version) by the following commands $ cd /Applications/Google\ SketchUp\ 7/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/Current $ ls Headers/ Resources/ Ruby $ ls Headers/ config.h defines.h inter...

Disabling Ruby 1.9.x's YARV compiler

There is a very noticeable difference in application initiation time between running my specs from the command line with ruby 1.9.x vs. 1.8.7. My application initiates much faster with ruby 1.8.7 than with ruby 1.9.1 or 1.9.2. The application initiation difference is approximately 18 seconds. It takes about 5 seconds for my app to ini...