Hi,
I've got a string like this:
<block trace="true" name="AssignResources: Append Resources">
I need to get the word (or the characters to next whitespace) after < (in this case block) and the words before = (here
trace and name).
I tried several regex patterns, but all my attempts return the word with the "delimiters" ch...
Is there any way to start the/a Ruby debugger whenever the code throws an exception, without me wrapping the code like this:
begin
#do something
rescue
debugger
end
I'd like to have it in such a way that if the do something part raises an exception, the debugger will start. It would be nice not having to modify the code to add beg...
So my Passenger spins up 5 instances of my Rails app
I connect to MongoDB using Connection.new("localhost", 3000, :pool_size => 1, :timeout => 5)
Why would I need a "pool of connections" if I only incur overhead when starting up my Rails app, not per request? Why would a single process need more than 1 connection?
And what is the ...
In this code, I create an array of strings "1" to "10000":
array_of_strings = (1..10000).collect {|i| String(i)}
Does the Ruby Core API provide a way to get an enumerable object that lets me enumerate over the same list, generating the string values on demand, rather than generating an array of the strings?
Here's a further example w...
I'm trying to write a word counter for LyX files.
Life is almost very simple as most lines that need to be ignored begin with a \ (I'm prepared to make the assumption that no textual lines begin with backslashes) - however there are some lines that look like real text that aren't, but they are enclosed by \begin_inset and \end_inset:
I...
Suppose a service written with RoR starts to use AWS S3 to store some data. What is the best library to use for working with AWS S3? Currently the main two alternatives for me are:
RightScale AWS Ruby gems
http://github.com/rightscale/right_aws
AWS::s3 http://amazon.rubyforge.org/
What are their main advantages and disadvantages? Wha...
I have a class Foo with a few member variables. When all values in two instances of the class are equal I want the objects to be 'equal'. I'd then like these objects to be keys in my hash. When I currently try this, the hash treats each instance as unequal.
h = {}
f1 = Foo.new(a,b)
f2 = Foo.new(a,b)
f1 and f2 should be equal at th...
How would I use the parameter value as the instance variable name of an object?
This is the object
Class MyClass
def initialize(ex,ey)
@myvar = ex
@myothervar = ey
end
end
I have the following method
def test(element)
instanceofMyClass.element #this obviously doesnt work
end
How can I have the test metho...
So I'm writing a Ruby client for a SOAP web service, and I've figured out how to call a simple method:
# WebServiceClient.rb
require 'soap/wsdlDriver'
wsdl_url = 'http://urlmadness?wsdl'
service = SOAP::WSDLDriverFactory.new(wsdl_url).create_rpc_driver
result = service.simpleMethod(:sayHello => 'Hello')
p result.return
Now I need t...
I'd rather not "reinvent the wheel" and I've found a Ruby project that provides functionality I need in my Java app (there is no preexisting Java project that does what I need - trust me, I've looked). So, best case scenario, I am able to run the Ruby code from my Java code (ala JSR223).
However, this Ruby project depends on having seve...
Just followed the Authlogic tutorial. I am getting "uninitialized constant Authlogic" when I try run the app. After searching, I can see that it has to do with gems/plugins but I can't find a solution.
Edit:
My UserSession model is:
class UserSession < Authlogic::Session::Base
end
...
Does anyone know how I'd run plain text passwords through the authlogic hasing algorithm without using rails? It looks like the default for authlogic is sha512.
I have a database of plain text passwords (yes, I know... bad) and need to import them into a new DB that uses the authlogic setup.
This ruby script is outside of rails so I do...
I've been working on getting my library c++ Lavish working with ruby using swig. The issue is that only some of the classes I've included in the interface file can be used and I get no errors during compilation of the bundle or loading in ruby. My swig interface file can be viewed here.
An example of what works and what doesn't.
sean$ ...
I have a select that gets populated depending on the selection in a different select
To do this, I did what is recommended in Railscast #88 on 'Dynamic Select Menus'.
But now I need to render a partial, passing in the value selected in each of those selects.
I can't figure out how to simply trigger a method call from the :onchange event...
I have a settlement,I want to judge if the return_service_date is today,how to do this?
This is my code (rails)
if settlement.return_service_date &&
settlement.return_service_date.to_s(:date)
== Time.now.to_s(:date)
Is there a better way to do this?
...
Ok so I have these 2 classes
class Interface < ActiveRecord::Base
belongs_to :hardware
end
and
class Hardware < ActiveRecord::Base
has_many :interfaces
end
I have a form for a predefined @hardware.interfaces which includes array of Interfaces which is handled like below
<%= text_field_tag "hardware[interfaces][][name]",i...
Has anyone successfully built the dnssd gem on Windows?
I get the following error when trying to build the c extension:
C:\Users\Charles>gem install dnssd -- --with-dnssd-dir=c:/progra~1/bonjou~1 --with-dnssd-lib=c:/progra~1/bonjou~1/lib/win32
Building native extensions. This could take a while...
ERROR: Error installing dnssd:
...
I would like to store very large sets of serialized Ruby objects in db (mysql).
1) What are the cons and pros?
2) Is there any alternative way?
3) What are technical difficulties if the objects are really big?
4) Will I face memory issues while serializing and de-serializing if the objects are really big ?
...
I have a datamapper model that has a unique index on a property called name. I want to create new records when a name doesn't already exist and silently ignore attempts to create records with duplicate names. What's the "right" way to do this in datamapper?
...
How can I test a helper method living in app/helpers/application_helper.rb?
I have this code in my file test/unit/helpers/application_helper_test.rb
require 'test_helper'
class ApplicationHelperTest < ActionView::TestCase
test "category" do
assert categories_collection
end
end
But I get this error "NameError: undefined lo...