I'm just a newbie to ruby. I've seen a string method (String).hash .
For example, in irb, I've tried
>> "mgpyone".hash
returns
=> 144611910
how does this method works ?
In codeigniter Im trying to use this plugin which requires I implement a toString method in my models. My toString method simply does
return $this->name
On my local machine with php 5.3 everything works just fine but on the production server with php 5.1.6 it shows "Object id#48" where the value of the name property of that object should appear..... I found something about the problem here but I still dont understand... How can I fix this?
Hi,
I'm building a download manager in python for fun, and sometimes the connection to the server is still on but the server doesn't send me data, so read method (of HTTPResponse) block me forever. This happens, for example, when I download from a server, which located outside of my country, that limit the bandwidth to other countries.
How can I set a timeout for the read method (2 minutes for example)?
Thanks, Nir.
the extracted source is below
Showing /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/templates/rescues/diagnostics.erb where line # raised:
private method `gsub' called for #<NoMethodError: undefined method `closed?' for nil:NilClass>
Extracted source (around line #):
RAILS_ROOT: /home/sharath/Desktop/RORWorkspace/ITPLOW1
It was working before installing Sunspot: A Solr-Powered Search Engine for Ruby
i am working in ubuntu 10.4
In my view, if I have a situation where I need to use a dynamic method (such as Domain.findByName("name")) in multiple places, would it be better to define a variable with and refer to that, rather than have the dynamic method in multiple places? I know this seems like an obvious answer, but I just wanted to make sure Grails doesn't cache it or something, and indeed two DB calls are being made.
I'm very new to Ruby (and OOP as well) and I don't know why the following thing doesn't work in Ruby
I extended the String class with a new method. Easy enough. Now I want to extend the Fixnum class. A String object appears somewhere in the class, but I can't use the method that I defined earlier. Why? Is this normal?
I have a service which is defined as ConcurrencyMode.Single:
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Single,
UseSynchronizationContext = false,
InstanceContextMode = InstanceContextMode.PerSession,
IncludeExceptionDetailInFaults = true)]
public class MyService : IMyService
This service provides a method to tell the client what it's currently working on:
[OperationContract]
string GetCurrentTaskDescription();
Is there a way to make this particular method allowable while another long-running task is running where all other methods still follow the single-threaded concurrency model?
I am writing a Ruby on Rails app and I want a method to be called every time the database is modified. Is it possible to do this without inserting a method call in every location where the database is modified?
I have issue "The caller was not authenticated by the service." when calling service method from IIS7 in client side. The client and service are in different machines. But when I am giving credentials its work fine. So, is any way to call service method without credentials and without this issue?
thanks
Hello,
I have a value range from 0 to 255.
There is a method that returns an array with a min and max values within this range, i.e: 13, 15, 20, 27, 50 ... 240
where 13 is the min and 240 is the max
I need to scale these values so that 13 becomes 0 and 240 becomes 255 and scale all the other values between them proportionally.
Is there any C# method that does that?
thanks!
Hi All,
I have a asp.net page which is checking a UNC path on a listbox item change event using Directory.exist method.
This works fine in Internet explorer.
But when i use firefox and debugging this method returns false even though the directory exists.
What could be the reason for this strange problem.
Please someone answer this
Thanks
SNA
i have to create a program to login on facebook using example http://code.google.com/p/facebook-java-api/wiki/Examples but
when i run project then i get my doFilter method does not call after complete init method please give me solution
My form has several numeric up down controls. All of these controls, when changed, call the same method:
private void SetColors(object sender, EventArgs e)
How do I determine which control called the method?
I have several classes that extend C and I would need a method that accepts any argument of type C. But in this method I would like to know if I'm dealing with A or B.
*
public A extends C
public B extends C
public void goForIt(C c)()
If I cast how can I retrieve the type in a clean way (I just read using getClass or instanceof is often not the best way).
PS: Fell free to edit an explicit title.
*Sorry but I can't type closing braces
Whenever the user scrolls map or zooms in/out, this method gets called instantaneously. I want to delay the call to this method by say 2 secs. Is it possible to do that?
2 Interfaces with same method names and signatures. But implmented by a single class then how the compiler will identify the which method is for which interface.In java.
I have several classes that extend C and I would need a method that accepts any argument of type C. But in this method I would like to know if I'm dealing with A or B.
*
public A extends C
public B extends C
public void goForIt(C c)()
If I cast how can I retrieve the type in a clean way (I just read using getClass or instanceof is often not the best way).
*Sorry but I can't type closing braces
I'm trying to declare a method for my program that takes only a 5 digit integer and for each digit of the integer, reads a value from the program and prints it out. I understand this isn't very clear but im having trouble relaying what I mean. I understand it will be some sort of for loop to read each digit of the integer individually until something reaches 5. Something like the charAt() string method but works for digits.
So I just tried excluding String[] args from the main method
It compiled alright !
But JVM is showing an exception
Why did it compile when String[] args HAS to be included every time ?
What is going on here ? Why won't it show a compilation error ?
typing this made me think that may be compiler did not see it as THE main method ..is that so ?
I'm trying to learn and understand more about mapping and displaying values on a map. (GIS)
At the moment I'M looking to take some values and apply those values to a tile or bin on a map.
Ideally I'd like the tile sizes to be uniform, like 100 meters, 500 meters, etc.
Is there a standard method for creating uniform tile sizes?
Or
Are what are common accepted method to deal with this kind of data display?
(Currently I'm using geodjango and it's related toolset geos, proj4, etc)
2 Interfaces with same method names and signatures. But implmented by a single class then how the compiler will identify the which method is for which interface.
I'm trying to redefine the File.dirname method to first change %20s to spaces. But the following gives me an error
class File
old_dirname = instance_method(:dirname)
define_method(:dirname) { |s|
s = s.gsub("%20"," ")
old_dirname.bind(self).call(s)
}
end
This trhows a NameError exception: undefined method 'dirname' for class 'File'
What is the right way to do this?
I'm implementing paging on an mvc view, and I want to call a method in the controller from the view
view:
>a href=">%= Url.Action("Search", new
{ page =
NextPage(Request["exactPage"])).ToString()})
%"
controller:
public string NextPage(string
currentPage)
{
return (int.Parse(currentPage) +
1).ToString();
}
How can I call the NextPage method from the view?
thanks!
I am working with ruby 1.8.6 (2007-03-13 patchlevel 0) [x86_64-linux] and I get
undefined method `bytes' for #<String:0x2a95ec2268> (NoMethodError)
even though my code works on ruby 1.8.7. patchlevel 249
I saw somewhere that you need to add require "jcode" for a similar method not defined error with each_byte. I tried adding that but it still does not work. Any suggestions are very appreciated.