I am a Java/C++ programmer and Ruby is my first scripting language. I sometimes find that I am not using it as productively as I could in some areas, like this one for example:
Objective: to parse only certain lines from a file. The pattern I am going with is that there is one very large line with a size greater than 15, the rest are de...
I installed Ruby Enterprise 1.8.7 on a Ubuntu server that already has the standard Ruby 1.8.6 install. They both put the same local user gem directory /home/{username}/.gem/ruby/1.8 in their GEM PATHS. Is this safe and proper?
If not, is there a way to alter the GEM PATH of Ruby Enterprise 1.8.7 (but not Ruby 1.8.6) through an environm...
running 'sudo gem list --local' and 'gem list --local' gives me differing results, my gem path is set to my home folder and only contain the gems from 'gem list --local'.
So it's probably not good to have gems installed in different directories on my computer, should I have the gem path set differently?
and should I always use sudo when...
When I execute ri ... in a terminal on my Mac, I get, maybe, 50 blank lines, then the output I'm expecting, then a last line:
(END)
, with (END) displayed with white letters on black background. I am not returned to bash, however -- ri is still running, and I can't enter anything. Also, why all the blank lines?
What's up?
Cary
...
I want to do this in ruby:
something() if conditional else something_else()
This doesn't compile, nor anything similar from what I tried. Is it possible to have statements in this format or do I have to do this as:
if conditional
something()
else
something_else()
end
...
I'm learning how to use nokogiri and few questions came to me based on the code below
require 'rubygems'
require 'mechanize'
post_agent = WWW::Mechanize.new
post_page = post_agent.get('http://www.vbulletin.org/forum/showthread.php?t=230708')
puts "\nabsolute path with tbody gives nil"
puts post_page.parser.xpath('/html/body/div/div/d...
Assume, I have an object x of MyClass. What method is called, when I do puts x? I need to override it with my own one.
I thought it was .inspect, but somehow overridden inspect isn't being called.
For example, I have a class Sum:
class Sum
initiazlie a, b
@x = a + b
end
end
And I wanna access the result like this:
s = Sum...
Hello!
So I took a quick look at Ruby some days ago. At first I was quite astonished by some things it features which really seem to make a programmers life easier. (Use of blocks, object model,...)
But then there is this big problem: Nobody seems to be using Ruby without Rails! The #Ruby(-lang) channel is dead, people are only talking...
Let's say I have I have the following file in my lib directory of my rails application:
#lib/proxy.rb
module SomeService
class ServiceProxy
def do_something
end
end
end
If I want to use ServiceProxy in a model, I can use it like so:
#app/models/product.rb
require 'proxy'
class Product < ActiveRecord::Base
def do_someth...
STDOUT is getting some strange output:
ignored attr: {}abstract
All of my SOAP calls are working fine but this is just annyoing my cron job :)
Thanks
...
I'm not very familiar using ruby with binary data. I'm using mechanize to download a large number of csv files to my local disk. I then need to search these files for specific strings.
I use the save_as method in mechanize to save the file (which saves the file as binary). The content type of the file (according to mechanize) is:
ap...
In my ruby+mechanize(nokogiri) script I use this piece of code:
row.at_xpath('td[3]/div[1]/a/text()').to_s.strip
on a forum where the post title html looks like:
<a href="showthread.php?t=233891" ></body> on Footer ?</a>
and I receive from xpath this string </body> on Footer ?
I would like to get what I can see in ...
New to ruby, put on your newbie gloves.
Is there any difference (obscure or practical) between the following two snippets?
my_array = [:uno, :dos, :tres]
my_array.each { |item|
puts item
}
my_array = [:uno, :dos, :tres]
my_array.each do |item|
puts item
end
I realize the bracket syntax would allow you to place the block on...
I know that I can have a session after the user login. Also, I created a helper method called "current_user". I don't want to other people which are not signed in can get access to the page. Apart from making doing this, how can I do?
I can do this to not allow people the get access to the content, but I don't want the user within login...
I'm new to RoR, but familiar with MVC, REST, used a lot Symfony, Yii, CI and other smaller php frameworks. Now I want to learn Ruby on Rails.
Please help me find a complete tutorial for "dummies", which describes creating web application from scratch on RoR. This is like Symfony's Askeet and Jobeet tutorials.
Thanks for any help!
Upda...
I want to build a basic Social networking site in Rails.
Can you please suggest me some ebooks for that or any web resource.
Thanks
...
I am just trying to get my head around SSL.
I have set up a Jetty server on my localhost, and generated my own certificate using Keytool.
Now when I go to https://localhost:8443/ I get the can't trust this certificate error.
I use
keytool -export -alias pongus -keystore keystore -file certfile.cer
To create the certificate whic...
I use this code to upload photos, I find that it is not successfully upload photo, but other content can be updated.
<% semantic_remote_form_for(@product, :html => {:multipart => true}) do |f| %>
<% f.inputs do %>
<%= f.input :title, :label => "Name" %>
<%= f.input :category , :include_blank => false , :label => "Catego...
I would like to enumerate all the URLs in a text string, for example:
text = "fasòls http://george.it sdafsda"
For each URL found, I want to invoke a function method(...) that transforms the string.
Right now I'm using a method like this:
msg = ""
for i in text.split
if (i =~ URI::regexp).nil?
msg += " " + i
else
...
Is there a ruby obfuscator or "compiler"?
...