How do I perform vector addition in Ruby so that
[100, 100] + [2, 3]
yields
[102, 103]
(instead of joining two arrays)?
Or it can be another operator too, such as
[100, 100] @ [2, 3]
or
[100, 100] & [2, 3]
...
I'm having a strange problem where a user can enter the following text
Test '<3'
and it outputs as
Test '<3>
On the output I'm using white_list, and the value stored in the database is:
'testing ''<3'''
What could be causing the output to think it's a tag of some sort and trying to close it (which is what it looks like ...
Here are the entire contents of activeresource.rb:
require 'active_resource'
Could someone explain the logic of this?
Why not simply have activeresource.rb contain what active_resource.rb contains and forget about the additional require statement?
...
Hi,
I'm playing around with Ruby and I have written the following code:
module IdAndNameRedefine
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def use_id_and_name_from_module(use_attribute)
class_eval <<CODE
def id_and_name
"\#{id}-\#{#{use_attribute}.downcase}"
...
When I find the keyword "in" in ruby first time. I think maybe I can do that:
1 in (0..10)
But it look like I cannot use it like that way.
Then I search it in ruby-lang.org, and google it. There is no answer!
What's the meaning of keyword "in" in ruby?
...
Ruby is slow at certain things. But what parts of it are the most problematic?
How much does the garbage collector affect performance? I know I've had times when running the garbage collector alone took several seconds, especially when working with OpenGL libraries.
I've used matrix math libraries with Ruby that were particularly slo...
I have made a application and the logo appears on every page. All 3 of my layouts are copy and pasted to be identical. I have 2 partials linking to 2 pages in the same view folder and the logo works with one and doesn't with the other. It just displays the "alt" name of the <img>. Is there a way to fix this?
...
After having the unpleasant surprise that Comma Seperated Value (CSV) files are not necessarily comma-separated, I'm trying to find out if there is any way to detect what the regional settings list separator value is on the client machine from http request.
Scenario is as follows: A user can download some data in CSV format from web sit...
I have a model called Profile which is belong_to User, so there is 'user_id' for the database to keep track of. In the local admin interface I made for this model I wanted to provide the flexibility of allowing admin to enter an username to a field in the editing screen, and then resolve that to user_id for saving in controller.
However...
I wrote a program to click on an application automatically at scheduled time using Win32, using MOUSE_DOWN and MOUSE_UP. It usually works well, except I found that I need to put in a
sleep 0.1
between the MOUSE_DOWN and MOUSE_UP. (using Ruby, which allows sleeping a fraction of a second).
Without the sleep, sometimes the click doe...
I'm using the Facebooker plugin in Rails to publish a user action to their newsfeed, but the image isn't being added.
The call (via Net::HTTP.post_form) looks like this:
Posting to http://api.facebook.com/restserver.php with
{:api_key=>"4f5ed28f76142adsfasdf029c98ad", :template_bundle_id=>"107345673712",
:template_data=>"{\"project\"...
Hi guys, i have an action called individual user pdf per page, it communicates with two model, the user model which retrives information from the database, but specific information only for all users, it then takes the information and send it to the model report which, then when i inspect the attributes of each user it is displayed in wa...
I'm trying to change the directory of the shell I start the ruby script form via the ruby script itself...
My point is to build a little program to manage favorites directories and easily change among them.
Here's what I did
#!/usr/bin/ruby
Dir.chdir("/Users/luca/mydir")
and than tried executing it in many ways...
my_script (this do...
I was looking at active_support.rb to try to understand the load process it uses. It uses three loading methods: load_all!, autoload and require.
Why use three different ways of loading in the same file?
module ActiveSupport
def self.load_all!
[Dependencies, Deprecation, Gzip, MessageVerifier, Multibyte, SecureRandom, TimeWithZon...
I am working on a web project. I want to implement same in ruby. I am aware of the ruby frameworks like merb, sinatra. Just I want to know which is most suitable framework for developing web based application using ruby ?
...
In the QT4 library QFileSystemWatcher is supposed to emit a "fileChanged" signal when the watched file is changed.
However, under ruby1.8 "fileChanged" is reported as "No such signal".
The FileSystemWatcher is clearly there. I can add files to it and read back the files property; it's just that the changed signal doesn't appear to be de...
Using Ruby (newb) and Regex, I'm trying to parse the street number from the street address. I'm not having trouble with the easy ones, but I need some help on:
'6223 1/2 S FIGUEROA ST' ==> 'S FIGUEROA ST'
Thanks for the help!!
UPDATE(s):
'6223 1/2 2ND ST' ==> '2ND ST'
and from @pesto
'221B Baker Street' ==> 'Baker Street'
...
I'm starting a new job soon where I'm going to be developing in Ruby and Rails on a Windows machine. I haven't used Windows for years, and the likes of Textmate, Git and Bash, are an integral part of the workflow using a Mac.
So, does anybody have any suggestions or recommendations as to the best tools or work strategies to use? Or pitf...
How can you display the hierarchy of 'require's that take place in a Ruby app?
Some files require files which require additional files.
However, by running an application in debug mode you only trigger a subset of required files - only the ones that are used by whatever subset of functionality your application is using at any given poi...
I have a method in my ApplicationController that is part of a before_filter. How do I identify which controller is calling that method and can I pass arguments to it?
Presumably worst case, I can create a new object where I use controller names and values, then call it directly in the before_filter method with NewObject.find(:first, :c...