I think I understand StringIO somewhat as being similar to java's StringBuffer class, but I don't really understand it fully. How would you define it and it's purpose/possible uses in ruby? Just hoping to clear up my confusion.
Thanks
...
I am currently developing a cms and want to reuse the functionality in other projects.
...
I am using Rightscale to launch an instance on Amazon EC2. All my boot scripts work great and do things like getting the below file names in the folders. The last boot script is the following:
#!/bin/bash
MAINDIR="/root/username/"
ruby ${MAINDIR}insertfd_control.rb stop
ruby ${MAINDIR}insertfd_control.rb start
ruby ${MAINDIR}inser...
hey!
we are currently working on a rails project that uses i18n and we have small problem with the dates:
# on my mac
"10.06.2008".to_date
# produces => Tue, 10 Jun 2008
# on a friends mac and on the production server
"10.06.2008".to_date
# produces => ..., 06 Oct 2008
As you can see the dates aren't right. We checked everything. T...
Using Ruby, how can I use a single regex to match all occurrences of 'y' in "xy y ay xy +y" that are NOT preceded by x (y, ay, +y)?
/[^x]y/ matches the preceding character too, so I need an alternative...
...
I have a collection of ActiveRecord objects. I want to be able to run all the validations for each of these objects without actually saving them to the database. I just want to know if they would be valid were I to save them to the database. In other words, I essentially want to populate the errors data structure for each of my objects...
Is there a way in Shoes to have text show up transparent?
I have:
Shoes.app{
para "Text", :stroke => rgb(1.0,0.0,0.0,0.5), :size => 100
}
But it's just showing up 100% red. I know opacity works for fill, does it also work for stroke?
(I am developing with Shoes Raisins Revision 1134 on Mac OS X 10.4.11)
Thanks in advance
...
Trivial using a for loop or each_with_index, just wondering if there was a better way of doing it using Ruby syntax.
I need to create a new array that is the derivative of the source array, eg:
for(int i = 1; i < oldArray.length; i++)
{
newArray[i] = oldArray[i] - oldArray[i-1]
}
...
We are writing an email web client in Ruby to handle (potentially international) emails. I am looking for a high-level email library that supports retrieving emails, parsing email raw, decoding MIME, and converting input into UTF-8. Is there a library that you can recommend?
...
What's the best way to set Time.now for the purpose of testing time-sensitive methods in a Unit test? Thanks!
...
I am unable to run ruby on rails application. I setup the database and loaded database schema. When I run:
ruby script/server -e production
It says:
=> Booting Mongrel
=> Rails 2.3.2 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Crtl-C to shutdown server
and it just stays there. If I go to the directory w...
I want to be able to utilize the acts_as_state_machine transition methods which are auto-generated (e.g. event!).. but I don't want it to save right away. I'm updating the state as part of another set of operations, and so I don't want to be doing double saves.
Is there any way to trigger these event methods without a save right afterwa...
I am trying to find a way to let me dynamically create a regexp object from a string (taken from the database) and then use that to filter another string. This example is to extract data from a git commit message, but in theory any valid regexp could be present in the database as a string.
What happens
>> string = "[ALERT] Project: Rev...
I tried the following code but it doesn't work
class BlogsController < ApplicationController
def index
#@entry_pages = Paginator.new(self, Entry.count, 10, params[:page])
@entries = Entry.find(:all,
#:limit => @entry_pages.items_per_page,
#:offset => @entry_pages.current.offset,
:order => 'entries.created_at DESC',...
In my Rails application, I have two models, Articles and Projects, which are both associated with a user. I want to add comments to each of these models. What's the best way to structure this?
Here's my current setup:
class Comment < ActiveRecord::Base
belongs_to :article
belongs_to :project
end
class Article < ActiveRecord::Base
...
Hey guys,
I am trying to add a browser using GtkMozEmbed into a gui I am designing using Glade. I want the browser to take up a tab in a notebook widget, but I cannot figure out how to actually do this. I am wondering what container to use to put the browser in, and the associated ruby code to actually embed the browser in this contain...
I'm using IO.popen in Ruby to run a series of command line commands in a loop. I then need to run another command outside of the loop. The command outside of the loop cannot run until all of the commands in the loop have terminated. How do I make the program wait for this to happen, because at the moment the final command is running too ...
I'm using this REST web service, which returns various templated strings as urls, for example:
"http://api.app.com/{foo}"
In Ruby, I can then use
url = Addressable::Template.new("http://api.app.com/{foo}").expand('foo' => 'bar')
to get
"http://api.app.com/bar"
Is there any way to do this in Python? I know about %() templates, b...
I seem to recall that there was a plugin or Rake snippet that would put comments in various Model classes after running a migration? It's a chore to have to look at db/migrate/X when I want to see which fields a given model has.
If not, I'll write one, of course. :)
...