I have a very complex string, such as:
<p>aaa <font style="color:red">ABCD@@@EFG^&*))*T*^[][][]</p>
<p>bbb <font style="color:red">ABCD@@@EFG^&*))*T*^[][][]</p>
<p>ccc <font style="color:red">ABCD@@@EFG^&*))*T*^[][][]</p>
....
Now I want to get the aaa,bbb,ccc parts. I don't want to use regular expression here, because it's too compli...
Iterating a block in Ruby is simple enough - it finishes cleanly and proceeds on to the rest of the code.
Iterating with an Enumerator, on the other hand, is a bit more confusing. If you call :each without a block, an Enumerator is returned instead. :next can then be called on the Enumerator to get each next iterative value.
And then...
I use ruby reading a web page, and its content is:
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=GB2312" />
</HEAD>
<BODY>
中文
</BODY>
</HTML>
From the meta, we can see it uses a GB2312 encoding.
My code is:
res = Net::HTTP.post_form(URI.parse("http://xxx/check"),
{:query=>'x...
hi,
is there a library like mongoid for rails 2.1 ?
thanks
...
I have chosen Domain Specific Language as my College Project, implementing it using Ruby.
I seek suggestions regarding the Project's Objective/Problem, from the people who have worked with DSL Projects and would ask them to post the problem on which they developed their project exclulding the solution. I am trying to seek a real time pro...
Hi,
Can anyone suggest how to fix this (Ubuntu 9.10):
/home/chris/.rvm/gems/ruby-1.9.1-p378/gems/bundler-0.9.26/lib/bundler/shared_helpers.rb:42:in `default_gemfile': Could not locate Gemfile (Bundler::GemfileNotFound)
from /home/chris/.rvm/gems/ruby-1.9.1-p378/gems/bundler-0.9.26/lib/bundler/shared_helpers.rb:51:in `env_file'
...
Suppose a column client_id is ubiquitous through out our database, and for a given session or request, we will be 'in the context' of a client the whole time.
Is there a way to simulate having each client's data stored in a separate database, while keeping them in the same table for simpler database-management ? What I want is similar ...
Hi
i get a string from a external method with a time and date like so "07/09/10 14:50" is there any way i can convert that time in ruby to 'Pacific US' time knowing its 'UTC' time? with changes accounted for in the date? i.e if the time difference results in the day being different.
thanks
...
Guys for wc, a rubygem I'm writing and that is useful for counting word occurrences in a text, I choose to put 3 parameters in class constructor.
The code is working, but I want to refactor it for niceness.
In your experience, it's easier to read/mantain/use as API a class with a constructor with no params and a lot of setters/getters m...
There are some checkboxes in a form, so the post data is:
type: flowers
color[]: red
color[]: white
color[]: blue
My code is:
Net::HTTP.post_form(URI.parse("http://xxx"), { :type=>'flowers',
'color[]'=>%w[red white blue] })
It seems there is something wrong with my code, that I can't g...
I am trying to write this :
%meta{ :name => "keywords", :content => "#{@page_city}, #{truncate_words(@page_keywords, 7) || 'Meta, Words, Are, Dope, For, SEO'}"}
Basically it sees if there is a local page that has a page city or keywords and adds those as they meta keywords. If it doesn't, it says the latter.
This works, but the onl...
The Chingu example looks something like this:
require 'rubygems'
require 'chingu'
class Game < Chingu::Window
def initialize
super
@player = Player.new
end
end
class Player < Chingu::GameObject
def initialize(options = {})
super(options.merge(:image => Gosu::Image["player.png"])
end
end
Game.new.show
If I want t...
When I use ruby 1.8.7 Net::HTTP.post_form(URI.parse(URL), params), I found it has a bug, see :
http://stackoverflow.com/questions/3214502/how-to-send-an-array-with-nethttp-post-form
My code is a regular ruby script, and I want to override that method(net/http.rb#set_form_data) like this:
require 'net/http'
require 'uri'
module Net
...
Let's say I have a FireNinja < Ninja object in my database, stored using single table inheritance. Later, I realize he's really a WaterNinja < Ninja. What's the cleanest way to change him to the different subclass? Even better, I'd love to create a new WaterNinja object and just replace the old FireNinja in the DB, preserving the ID.
Ed...
Is it possible to use multiple languages along side with ruby. For example, I have my application code in Ruby on Rails. I would like to calculate the recommendations and I would like to use python for that. So essentially, python code would get the data and calculate all the stuff and probably get the data from DB, calculate and update ...
Hello,
Quick question:
I have XML with the following code:
<Experiment>
<mzData version="1.05" accessionNumber="1635">
<description>
<admin>
<sampleName>Fas-induced and control Jurkat T-lymphocytes</sampleName>
<sampleDescription>
<cvParam cvLabel="MeSH" accession="D017209" name="apoptosis" />
<cvParam cvLabel="UNITY" accession="D21...
I checked IRC for redmine and was unable to get help.
I was conflicted on weather to stick this on Superuser, ServerFault or here, but as my problem is technically programming oriented I decided to look for help here.
We have a Mercurial repository system with a layout based on projects that addresses our needs. I wrote some shell scrip...
I have the following ruby code:
class Mp
def initialize
Test.new.mytest
Work.new.mywork
ha
address
end
def ha
puts "message from ha"
end
def address
a='see'
end
end
class Test
def mytest
m=Mp.new
puts "Message from test do you #{m.address}"
end
end
class Work
def mywork
pu...
What's the best way to manage i18n urls?
It's strange because google and facebook encode utf8
ex. search ★。SмAck%2BтнAт。★ on google
while yahoo doesn't do it.
ex. search ★。SмAck%2BтнAт。★ on yahoo
How do u manage utf8 urls and which libs do u use?
-- edit
I tried on Firefox and the behavior is the same, so the question is: Do you have ...
I'm using Ruby on Rails and the paths_of_glory gem
I need to access the types of achievements that a user accomplishes in order to display a picture along with each particular achievement. When I try to access it via @user.achievements.type, I get an error that says that it wants to return "array" (as in achievements is an array) inste...