I need to scrape(using scrAPI) 400+ web pages ruby, my actual code is very sequential:
data = urls.map {|url| scraper.scrape url }
Actually the code is a bit different (exception handling and stuff).
How can I make it faster?
How can I parallelize the downloads?
...
I intend to design an induction plan or you can say a crash course syllabus for developers starting to learn Ruby and Ruby on rails. I am not sure about number of topics to be covered (And the depth of coverage) as this is a 3 day course (24 to 27 hours). Also, newbies tend to compare ruby with existing object oriented programming vetera...
I am trying to work out how to detect whether a user is running with admin rights under Windows XP. This is fairly easy to do in Vista/Win7 thanks to the whoami command. Here's a snippet in Ruby for how to do it under Vista:
Note, the following link now incorporates the solution suggested by muteW
http://gist.github.com/65931
The trou...
I'm trying to write a Rakefile that both builds my code normally when I run rake compile but puts the targets in a different directory and builds with -DTEST when I run rake test. I cannot for the life of me figure out how to do it, though. I've got something like this at the moment:
SRC = FileList['src/*.erl']
OBJ = SRC.pathmap("%{sr...
I'm having trouble removing some duplication I've introduced in a rails plugin.
The code below modifies the find and calculate methods of ActiveRecord in the same way, but I've been unable to remove the duplication.
The find and calculate methods below make use of the super keyword which is one hurdle as the super keyword can only be u...
I don't know if jssh has any security built-in. While testing web apps, I would only like to be able to connect to jssh from localhost. I added the following lines to iptables :
iptables -A INPUT -p tcp -s 0/0 --dport 9997 -j LOG
iptables -A INPUT -p tcp -s 0/0 --dport 9997 -j DROP
will they provide the security I need?
EDIT : this ...
I'm getting this warning in my Test::Unit output...
/usr/local/bin/ruby -I.:lib:test -rtest/unit -e "%w[test/functional/sessions_controller_test.rb].each { |f| require f }" | unit_diff -u
Loaded suite -e
Started
.../Users/ethan/project/mtc/contactdb/app/views/sessions/new.html.haml:30: warning: multiple values for a block parameter (0 f...
I want to convert my String object to Enumerable of its 1-sized substrings (not chars), how can I do this efficiently in Ruby?
...
Hello.
I'm struggling now to get HATBM working correctly. I have a beaten scanario: articles and tags. I presume, HABTM should be used here, since it is a many-to-many relationship.
I don't know however if I should manually create a join table (articles_tags in this case).
My code currently as follows:
class Article < ActiveRecord::Ba...
I have a string (e.g. "AABBCCDDEEFF") and want to split this into an array with each element containing two characters - ["AA", "BB", "CC", "DD", "EE", "FF"].
...
I am trying to automate the Windows Task Scheduler using Ruby.
I am using Ruby 1.8 under Windows Vista.
The RegisterTaskDefintion method of the TaskFolder object takes two VARIANT parameters for the username and password. Any attempt to pass a string into these parameters results in a 'method_missing' exception:
This does not work:
r...
I'm writing a web application to monitor a furniture factory production flow. It has thousand of data to handle. So far, I run RoR on Mongrel + MySQL and it's really really slow (2-4min for some views). When I look at RoR logs, it seems that database queries aren't slow (0-10ms).
Is RoR slow when it converts database data to object ? Is...
I am trying to install a gem like this:
C:\InstantRails\rails_apps\foodmarksthespot>ruby script/plugin install git://github.com/lazyatom/engines.git
Which returns this message:
Rails requires RubyGems >= 1.3.1 (you have 1.2.0). Please `gem update --system` and try again.
But when I try to update using:
gem update --system
it say...
If you write a test class like
class MyTest < Test::Unit::TestCase
def setup
end
def test_1
flunk
end
def test_1
assert true
end
end
the first test_1 is ignored. Although it looks like a stupid mistake, it can happen with copy and paste programming. Apart from running
grep test test_me.rb | wc
and comparin...
This is a bit of a pain because I now don't have the code in front of me, but I'll try to explain.
I have a simple C# application that kicks off a Ruby script (it does a couple of other things, so it generates a batch file and executes that).
I am using the C# process object and I set the following
redirectstandardoutput = true
redirec...
Hi,
Last May at Railsconf on Portland, I went to a presentation where it was argued that, in Rails, Ruby class member variables, like @@foo, are dangerous because they are inherently unthreadsafe.
I researched the question afterward and I never found a link that really fleshed out the question. I would appreciate a pointer to a good ...
What behavior have you had to implement in your Rails applications that you feel could exist nicely as a plugin?
What plugin functionality have you searched for in the past but couldn't find?
What existing Rails plugins could be improved or extended, and how?
...
I have an sorted array like this:
['FATAL <error title="Request timed out.">',
'FATAL <error title="Request timed out.">',
'FATAL <error title="There is insufficient system memory to run this query.">']
I would like to get something like this (does not have to be a hash):
[{:error => 'FATAL <error title="Request timed out.">', :count...
Hi,
Currently I have an application that stores metadata information written in a boo internal DSL.
I store the metadata in seperate .boo files that I load if and when I need them like this:
IConfigReader reader = factory.Create(BUILD_FILE_NAME);
I would like to take advantage of Iron Ruby's or indeed Ruby's meta programming by conve...
Looking through the rails 2.3 RC1 release note I see this:
# Equivalent of render :partial => 'articles/_article', :object => @article
render @article
So somehow the render method is finding out the that object passed int it is assigned to an instance variable with the name article. How does it do this?
...