When i have a table;
1 0 0 1 0
0 1 0 1 0
0 0 1 0 1
1 1 1 1 0
0 0 0 0 1
Say i want to only read and keep the values along the upper diagonal of this table, how can i easily accomplish this in pure ruby?
Such that the final structure looks like
1 0 0 1 0
1 0 1 1
1 0 1
1 0
1
Thanks
I have class X that takes much time to initialize itself. I want to make that class singleton and force its creation when rails application starts.
I've made the singleton:
class X
@@instance = nil
def self.instance
if @@instance.nil?
@@instance = X.new
puts 'CREATING'
end
return @@instance
end
private_class_method :new
end
The problem is that every time I use this class I see 'CREATING' in logs. I've tried to put creation of class in initializers directory but it doesn't work either.
I have not tried yet, as I would rather not spend time setting up memcached if this is not going to work...
I am using Ruby. Is is possible to store a resource, such as an FTP connection, in memcache?
I have to stay away from my MacBook and will use Windows for a while. I missed Textmate's folder view when editing my rails projects. Is there an editor on Windows with the folder view? I know there is the E text editor. But I'll save a few bucks if there is a free (cheaper) alternative, as I won't stay in Windows for long ...
HI,
I used to have PHP websites and using url rewriting on picture to have SEO friendly urls,
On php I had links like
/image/blablablabla-1234-blablabla
rewriting to:
/image/1234.jpg
by using a url rewrite rule on apache .htaccess file.
Now I totally switched to rubyonrails and I would like to know what is the best way to do that on RoR? I am hosting websites on apache with passenger.
Thanks in advance
I have been looking at paypal for a online transaction, but I wanted to know if there are other 3rd party vendor that offer a good service at a good price ( transaction fee) and ease of use of API for rubyonrails application.
I am not able to validate passord with ()-=_+ , i.e it should accept these special characters but its not working when i use the regular expression as
`validates_format_of :password, :with => /^[A-Za-z0-9. ! @ # $ % ^ & * ( ) _ - + = ]*\z/`
its only excepting till * but not accepting ()-=_+ in rubyonrails.
We have server on Python and client + web service onRuby. That works only if file from URL is less than 800 k. It seems like "socket.puts data" in a client works, but "output = socket.gets" - not. I think problem is in a Python part. For big files tests run "Connection reset by peer". Is it buffer size variable by default somewhere in a Python?
I am currently learning RubyonRails. I currently do all my development on my laptop. However, I know in all "real world" situations, I will be connecting to a dedicated server that will hold the site.
So here is my question: what are the pros and cons of developing on the machine I use vs running the website on a separate server?
Hello,
I need to make a collection with a lot of movies, but I was wandering if there is something like API or other method to make that database automatically? I will be using RubyonRails, but if there is a useful and fast tool, I will use it.
Thank you.
while installing any Gem or doing any listing of gem gzip related error comes as shown below:-
C:\Documents and Settings\gangunragem install rhosync -v 2.0.0.beta7 --pre
ERROR: While executing gem ... (Zlib::GzipFile::Error)
not in gzip format
C:\Documents and Settings\gangunragem list rails -r
* REMOTE GEMS *
ERROR: While executing gem ... (Zlib::GzipFile::Error)
not in gzip format
Please help me out how to reslove this
I want to share a method amongst all Ruby's data object classes. That is to say the following classes:
Hash
String
Number
Array
Firstly, any classes I've missed out?
Secondly, how can I share my_method amongst all classes at once?
class Hash
def my_method
"hi"
end
end
class String
def my_method
"hi"
end
end
class Number
def my_method
"hi"
end
end
class Array
def my_method
"hi"
end
end
Hi there,
This might be a stupid questions but I wanted to know what happens if two users edit some data at once and then both click submit at the same time, I assumed Rails handled requests one after the other and so someone would get an error message but is this correct?
Thanks
(Once one person has edited data I dont want it to be accessible or editable anymore)
Dear friends,
I'm trying to set up a small full functional website for a small community on a shared hosting. Scientific computing is quite heavy. Scalability is not important. The only criterion is performance. Which framework would you suggest among the following:(or more) from your list)
1)Ruby onRails
2) Grails
3) asp.net
4) zend
I'm really new to this area, only starting reading some books and googling different blogs...so your expertise is really appreciated!
thanks!
Hello,
I have some difficulties for using Ruby block, passing in a method.
As in the following case, I would like to display each element of @array, from Box instance (using .each method):
class Box
def initialize
@array = [:foo, :bar]
end
def each(&block)
# well, hm..
end
end
a = Box.new
a.each { |element| puts element }
Thanks for any help.
Hi all,
Using the perennial example of a Blog webapp (and all resources are currently automatically mapped in routes.rb):
I have a simple index page that lists all my Post titles. I would like to add a form at the bottom of this page to quickly create new Posts.
I'm new to Rails and can't seem to figure this out! Please help!
HI all!
I would like to insert a hash at the beginning of a selected block of text in VIM (ruby comment). I selected the lines in Visual Mode, but how do I perform the same operation to all lines?
Thank you in advance!
I'm working with Rubyonrails 2.3.4 and I'd like to pass some parameters from one page to another ones the first one is submitted.
For example:
On the first page, I have a form that when it's filled a Preview button can be clicked to check all the info entered before submitting the form. That button redirects to another page with the info entered before, but I don't know how to get it in the second page.
I'd like to restrict access to my Rails app (running on Apache/Passenger) to just two IPs, but if the visitor doesn't fall into those two IPs, I would like for him/her to be prompted to enter a password that would allow any user with the proper credentials to access the site from anywhere.
I am new to configuring Apache and would appreciate any hints. Thanks!
Possible Duplicate:
Can I add custom methods/attributes to built-in Python types?
In Ruby you can override any built-in object class with custom method, like this:
class String
def sayHello
return self+" is saying hello!"
end
end
puts 'JOHN'.downcase.sayHello # >>> 'john is saying hello!'
How can i do that in python? Is there a normally way or just hacks?
I have a multi-dimensional array:
a=[[2,3,4],[1,3,4],[1,2],[1,2,3,4]]
i've to compare all the 4 sub-arrays and get common elements.Next,take 3 subarrays at a time and get common elements.then take 2 sub arrays at a time and get common elements, in RUBY.
what is the best way to implement real time updates in rubyonrails using Node.JS? It would be great to hear either real examples or your thoughts on alternative solutions
I'm using the Ruby SVN bindings built with SWIG. Here's a little tutorial.
When I do this
@repository = Svn::Repos.open('/path/to/repository')
I can access the repository fine. But when I do this
@repository = Svn::Repos.open('svn://localhost/some/path')
It fails with
/SourceCache/subversion/subversion-35/subversion/subversion/libsvn_subr/io.c:2710: 2: Can't open file 'svn://localhost/format': No such file or directory
When I do this from the command line, I do get output
svn ls svn://localhost/some/path
Any ideas why I can't use the svn:// protocol?