It seems like people are compiling MRI Ruby (1.8.7) for 64-bit platforms. I've been searching and reading for a while now without really getting the answers I want. What I want to know is if any of you guys actually used more than 4GB of memory in Ruby? Is Ruby truly 64-bits if you compile it that way?
I've found comments in the source ...
Using apricot, it is pretty easy to see how I can extract all elements with a given id or class using a CSS Selector. Is it possible to extract elements from a document based on whether some attribute of those elements matches against some regular expression?
...
I'm implementing an exporter for an XML data format that requires namespaces. I'm using the Nokogiri XML Builder (version 1.4.0) to do this.
However, I can't get Nokogiri to create a root node with a namespace.
This works:
Nokogiri::XML::Builder.new { |xml| xml.root('xmlns:foobar' => 'my-ns-url') }.to_xml
<?xml version="1.0"?>
<root ...
Can I have a link that would add something to the session hash? For example if I had a link, can it do this when clicked:
session[:items] << item
I'll probably have to have the link trigger a JS file for that action, so I can update the session when the user clicks the link.
...
I find myself using PHP-like loops a lot in Ruby and it feels wrong when the rest of the language is so neat. I wind up with code like this:
conditions_string = ''
zips.each_with_index do |zip, i|
conditions_string << ' OR ' if i > 0
conditions_string << "npa = ?"
end
# Now I can do something with conditions string
I feel like I...
I have this small snipped of code.
I don't know ruby and I think this is a great opportunity to apply it.
I want to print all the lines in file e which are not in file c. Each line is a number.
This is what I've got:
e = File.new('e').readlines
c = File.new('c').readlines
x = e.collect do |item|
c.include?( item ) ? "" : item...
In my RoR app, I have a query that could return anywhere 0 to 1000000 results, that I'm limiting to 16 and providing pagination for:
find(:all, :conditions => conditions, :limit => limit, :offset => offset)
I'd like to be able to tell the user how many results they're looking at vs. the total amount of results. Something like "Showing...
When I try to deploy my rails app to my shared hosting (dreamhost) I get this error:
can't activate rack (~> 1.0.1, runtime) for [], already activated rack-1.0.0 for []
So I want to freeze the rack gem in my dev environment, and add it to the project, but even though I have this in my config/environment.rb:
config.gem 'rack'
Doing ...
I've got a Sinatra app that I'm trying to run on Dreamhost that makes use of pony to send email. In order to get the application up and running at the very beginning (before adding pony), I had to gem unpack rack and gem unpack sinatra into the vendor/ directory, so this was my config.ru:
require 'vendor/rack/lib/rack'
require 'vendor/s...
Working from the railscast #160 base code I've set up a very simple site that allows me to log in, out and register an account. (Its almost identical except that I've removed the 'username' from the users migrate table and relevant views so only an email address is required)
I'm now trying to create a new log in action so that I can log...
I'm thinking in:
class X
def new()
@a = 1
end
def m( other )
@a == other.@a
end
end
x = X.new()
y = X.new()
x.m( y )
But it doesn't works.
The error message is:
syntax error, unexpected tIVAR
How can I compare two private attributes from the same class then?
...
If I have two arrays a and b, what method should the object contained have to override so the subtract method - works properly?
Is it enough with eql?
EDIT
I'm adding more detail to my question.
I have this class defined:
class Instance
attr_reader :id, :desc
def initialize( id , desc )
@id = id.strip
@d...
Hello,
Can someone provide an example of using Builder to create multiple XML files from a SQL database. I can easily create one containing the entire database as in here...
def index
respond_to do |format|
format.xml { @rides = Rides.find(:all) }
end
end
This will create a file called index.xml based on a file I created calle...
Hi,
For the criterias below, what a technology stack would fit best?
Cross-platform (Linux/Windows).
Ability to run as a service (daemon).
Powerful object-oriented data access (O/R-mapping).
Multiple databases support (MsSql, Oracle, MySQl, SqlLite, Postgress).
Web application can be tested (Unit and Integration testing).
Reasonable o...
I came across the following statement in Trapexit, an Erlang community website:
Erlang is a programming language used
to build massively scalable soft
real-time systems with requirements on
high availability.
Also I recall reading somewhere that Twitter switched from Ruby to Scala to address scalability problem.
Hence, I won...
I am using Ruby on Rails in NetBeans 6.7.1 under windows, and I'm trying to use SQLite3. I've installed the windows version of sqlite3-ruby, and I've placed sqlite3.def, sqlite3.dll and sqlite3.exe in NetBeans6.7.1>ruby2>jruby-1.2.0>bin
When I try to run the db:create rake task, I get the error and trace shown below.
Can anyone help pl...
I am using Vim for Ruby development and I have some annoying problem.
When I type Ruby hashes, I see the wrong indentation:
{
{ #Here it is.
}
}
How it is possible to resolve this?
I am using akitaonrails vimfiles.
...
I am puzzled with the following simple problem:
Given positive integers b, c, m where (b < m) is True it is to find a positive integer e such that
(b**e % m == c) is True
where ** is exponentiation (e.g. in Ruby, Python or ^ in some other languages) and % is modulo operation. What is the most effective algorithm (with the lowest big-...
I read a answer the gem fetch answer on this question is-it-possible-to-download-a-ruby-gem-without-installing-it-automatically. But windows I do not always get the windows gem.
Using gem install gosu --remote installs the windows version Successfully installed gosu-0.7.15-x86-mswin32-60.
When downloading using gem fetch gosu I get Dow...
Hi all,
I've got a problem with creating an HTTP post request in .NET. When I do this request in ruby it does work.
When doing the request in .NET I get following error:
<h1>FOXISAPI call failed</h1><p><b>Progid is:</b> carejobs.carejobs
<p><b>Method is:</b> importvacature/
<p><b>Parameters are:</b>
<p><b> parameters are:</b> vacatur...