I have a regular expression that returns multiple variables within a match. I am interested in the first non-null variable in a subset of indices within the match, so I am using
result = a[1] || a[3] || a[6] || ...
I would like to store the relevant indices in a configuration file along with the regular expression itself. What is the ...
require 'net/http'
require 'uri'
Net::HTTP.get_print URI.parse('http://www.example.com/index.html')
when i tried to run this programm i getting error like this why??
c:/ruby/lib/ruby/1.8/net/http.rb:560:in `initialize': getaddrinfo: no address associated with hostname. (SocketError)
from c:/ruby/lib/ruby/1.8/net/http.rb:560:in `o...
Hello there :)
I am looking for a quite specific tool for generating charts, within Ruby on Rails application. I have done a research and couldn't find a solution that suits me.
Maybe you've bumped upon it and could just point me to it with a link? :)
My requirements for a solution are:
it has to feature basic chart types
like Pie, ...
Running Ubuntu Server 10.04 with Rails 2.3.4 and Webrick 1.3.1; our rails app runs fine when called via script/server -e production, but trying to test it as a daemon by calling it with the -d flag produces the following output:
=> Booting WEBrick
=> Rails 2.3.4 application starting on http://0.0.0.0:3000
Nothing is produced in the lo...
I'm trying to represent a relationship between users in my application where a user can have many followers and can follow other users.
I would like to have something like user.followers() and user.followed_by()
Could you please tell me in details how to represent this using ActiveRecord?
Thanks.
...
For example, I have 4800 and I would like to see all the divisors of this number.
# num = the number you want factors of
def divisors_of(num)
(1..num).collect { |n| [n, num/n] if ((num/n) * n) == num}.compact
end
divisors_of(4800)
=> [[1, 4800], [2, 2400], [3, 1600], [4, 1200], [5, 960], [6, 800], [8, 600], [10, 480], [1...
I have two Const with the same name; One is a global const, and the other is defined under the namespace Admin. But I need to distinguish them;The global one has already defined, and the scoped one need to auto defined if it has not been defined yet:
A = 'A Global Const'
module Admin
A = 'A Const within the Admin namespace' if...
I've configured my Rails 2.3.8 logger in the environment.rb to rotate daily:
config.logger = Logger.new("#{RAILS_ROOT}/logs/#{RAILS_ENV}.log", 'daily')
and every day in the morning I get the usual:
Error during failsafe response: Shifting failed.
Is there a decent/elegant/better solution to this?
What I've done in the past is just...
we are currently trying to package sqlite3 and sqlite3-ruby with an application that will be released as open source (ruby/rails based)
i am evaluating if it is possible to package sqlite3-ruby for windows/linux and mac.
my thoughts were, to download sqlite3-amalgamation, sqlite3-ruby on all the platforms and then compile on each.
here ...
Using Ruby on Rails 3.0, I would like to have pages where posts have side-by-side translations. For example, a page would look like this
+---------------+---------------+-----------------+
| Hello | Hola | Bonjour |
+---------------+---------------+-----------------+ ... (there could be many more languages)
| He...
I'm wondering what is the best pattern to allow large files to be uploaded to a server using Ruby.
I've found Rails and Large, Large file Uploads: Looking at the alternative but it doesn't give any concrete solutions.
I don't want to use Rails since I'm working on a simple upload server that'll run in standalone mode. I'm guessing tha...
How can a class method (inside a module) update an instance variable? Consider the code bellow:
module Test
def self.included(klass)
klass.extend ClassMethods
end
module ClassMethods
def update_instance_variable
@temp = "It won't work, bc we are calling this on the class, not on the instance."
puts "How can I ...
Im trying to add objects to an array by using push. I have a program where u can register guests. When I choose the checkin option from my menu Im unable to add the new guest to the guest history.
This dont work:
def self.check_in
puts "Welcome to the checkin"
puts "Please state your first name: "
firstName = gets.chomp
...
Say we have a list of rooms with their capacities and a list of meetings with the number of attendees. We want to match each meeting with one room in the following way:
A meeting can only be scheduled in a room with capacity equal to or greater than its attendance.
If surplus rooms are present, meetings should be scheduled so that the ...
How do I render a view within another view... in rails... is it possible?
...
Is there any web language that allows the client itself to create HTTP posts to external sites.
I know that JavaScript does this with XMLHttpRequest, but it does not allow cross-domain posting, unless the recipient domain wants to allow the sending domain.
I want to post data to an external site (that I don't control) and have the requ...
Hi, I am trying to get a facebook fql query to work using the browser, I have a valid oauth token (I can make graph api calls with it).
Here is the url I tried:
https://api.facebook.com/method/fql.query?query=SELECT metric, value FROM insights WHERE object_id=89192912655 AND end_time=1280430050 AND period=86400 AND metric='page_fans'&a...
Does anyone know of any Ruby libraries/gems that allow you to traverse a DOM quickly?
I need something which is fast, and doesn't have a lot of dependencies. I've been trying to use Nokogiri, but I'm concerned with the number of 'bug segmentation faults' I've been getting.
...
I can run a single rspec example with
spec -e 'should be awesome' spec/models/stuff_spec.rb
but how do I run an entire group ?
describe 'GoodStuff' do
it 'should be awesome' do
true.should be_true
end
it 'want to run this too' do
true.should be_true
end
end
I've heard there's a spec -g option, but a) its not docume...
I am inserting data from CSV to database.
While i am trying to insert this row
2 créditos,,,,R,75,,
into my database i am getting this error Mysql::Error: Incorrect string value: '\xE9ditos...' for column 'message' at row 1: .
...