I've got a few DOM elements, say text-field input A, B, C, and all of them have the property of 'onclick'. How do I find to which object a particular 'onclick' belongs?
I need to return two values at a time, so I have:
class IterableObject(object):
def __iter__(self):
for item in self.__dict__:
return self.__dict__[item + 1], self.__dict__[item]
So I can have:
myObj1, myObj2 = IterableObject()
value = myObj1.balance - myObj2.balance
Of course it did not work. What am I doing wrong? I think I can not add value on item like that.
I have a string in my db I want to pull into my page and convert to a json object.
[
{id: 1,title: "Long Event",
start: new Date(2009, 5, 6, 14, 0),end: new Date(2009, 5, 11)},
{id: 2,title: "Repeating Event",
start: new Date(2009, 5, 2)},
{id: 3,title: "Meeting",
start: new Date(2009, 5, 20, 9, 0)},
{id: 4,title: "Click for Facebook",
start: new Date(2009, 5, 27, 16),end: new Date(2009, 5, 29),
url: "http://facebook.com/"}
]
How can I do this using JQuery?
See title. To be more specific, I am trying to return the mutableCopy of an object, however it's returned with a retainCount of 1 and I am worrying that it will leak.
program runs fine. When I put a breakpoint a segmentation fault is generated. Is it me or GDB? At run time this never happens and if I instantiate only one object then no problems.
Im using QtCreator on ubuntu x86_64 karmic koala.
Is there a possibility to create any python object that will be not sortable? So that will be an exception when trying to sort a list of that objects?
I created a very simple class, didn't define any comparison methods, but still instances of this class are comparable and thus sortable. Maybe, my class inherits comparison methods from somewhere. But I don't want this behaviour.
Let say I have a object. I'm assigning that to an integer.
MyClass obj1 = 100;//Not valid
Let's say, I have a parameterized constructor which accepts an integer.
MyClass(int Num)
{
// .. do whatever..
}
MyClass obj1 = 100;//Now, its valid
Likewise on any circumstance, does the vice-versa becomes valid?!.
eg) int Number = obj1;//Is it VALID or can be made valid by some tweeks
When you call remove(object o) on an arraylist in java, how does it compare the objects to find the correct one to remove? does it use the pointer? or does it compare the objects using the interface Comparable?
In Python 2.x, using backticks to get decimal string from int object is Horrible?
Because backticks are repr(), not str()? I have noticed that when I answering this question.
In Python source, they have same function in Python source, intobject.c
(reprfunc)int_to_decimal_string, /* tp_repr */
....
(reprfunc)int_to_decimal_string, /* tp_str */
What do you think?
I'm trying to create a table using google spreadsheet API as described here
http://code.google.com/apis/spreadsheets/data/3.0/developers_guide_protocol.html#TableRecordFeeds
But I'm not sure how to construct the Atom object in Javascript and POST it to an URL.
Hi,
While replacing or inserting into an nsmutable array, I am getting exception as
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '* -[NSCFArray replaceObjectAtIndex:withObject:]: mutating method sent to immutable object'
[list replaceObjectAtIndex:indexRow withObject:editcontacts];
//or
[list insertObject:editcontacts atIndex:indexRow];
please help me.
Madan,
Thank You.
So for example we have real life photo. how to get (relativly to image dimentions for example) the distance from wall to girls, from girls to trees if all we know ts this picture?
Any papers with algorithms or Open Source programs doing this would be appreciated.
So How to detect how far the object on photo is from another objects on that photo?
Is there a way to have an XDocument object save its content and keeps the hexadecimal references as they are without parsing them?
Thank you for any help.
I've performed the "Replace Method with Method Object" refactoring described by Beck.
Now, I have a class with a "run()" method and a bunch of member functions that decompose the computation into smaller units. How do I test those member functions?
My first idea is that my unit tests be basically copies of the "run()" method (with different initializations), but with assertions between each call to the member functions to check the state of the computation.
(I'm using Python and the unittest module.)
Further to my previous question, which did not get a useful answer despite a bounty, I will try rephrasing the question.
Basically, when the user clicks the ellipsis in the object inspector, Delphi opens a file/open dialog. I want to replace this handling with my own, so that I can save the image's path.
I would have expected that all I need to do is to derive a class from TImage and override the Assign() function, as in the following code. However, when I do the assign function is never called. So, it looks like I need to override something else, but what?
unit my_Image;
interface
uses
Classes, ExtCtrls, Jpeg, Graphics;
type
Tmy_Image = class(Timage)
private
FPicture : TPicture;
protected
procedure OnChange(Sender: TObject);
public { Public declarations }
Constructor Create(AOwner: TComponent); override;
procedure SetPicture(picture : TPicture);
procedure Assign(Source: TPersistent); override;
published { Published declarations - available in the Object Inspector at design-time }
property Picture : TPicture read FPicture write SetPicture;
end; // of class Tmy_Image()
procedure Register;
implementation
uses Controls, Dialogs;
procedure Register;
begin
RegisterComponents('Standard', [Tmy_Image]);
end;
Constructor Tmy_Image.Create(AOwner: TComponent);
begin
inherited; // Call the parent Create method
Hint := 'Add an image from a file|Add an image from a file'; // Tooltip | status bar text
AutoSize := True; // Control resizes when contents change (new image is loaded)
Height := 104;
Width := 104;
FPicture := TPicture.Create();
self.Picture.Bitmap.LoadFromResourceName(hInstance, 'picture_poperty_bmp');
end;
procedure Tmy_Image.OnChange(Sender: TObject);
begin
Constraints.MaxHeight := Picture.Height;
Constraints.MaxWidth := Picture.Width;
Self.Height := Picture.Height;
Self.Width := Picture.Width;
end;
procedure Tmy_Image.SetPicture(picture : TPicture);
begin
MessageDlg('Tmy_Image.SetPicture', mtWarning, [mbOK], 0); // never called
end;
procedure Tmy_Image.Assign(Source: TPersistent);
begin
MessageDlg('Tmy_Image.Assign', mtWarning, [mbOK], 0); // never called
end;
end.
I have an on object like so
var obj = {};
function set()
{
obj.x1 = 20;
obj.y1 = 35;
obj.x2 = 60;
obj.y2 = 55;
...
}
Whats the quickest way to delete/reset all of the properties of obj?
Basically i want to do this. ee causes a bad cast exception.
NOTE: o can be ANYTHING. It may not be B, it can be C, D, E, F etc.
var b = (B)"sz";
var e = (A)b;
object o = b;
var ee = (A)o;
I'm writing a PropertiesMustMatch validation attribute that can take a string property name as a parameter. I'd like it to find the corresponding property by name on that object and do a basic equality comparison. What's the best way to access this through reflection?
Also, I checked out the Validation application block in the Enterprise Library and decided its PropertyComparisonValidator was way too intense for what we need.
How does the garbage collector determine whether an object is garbage? Does it refer to the stack to check the references to the space allocated in the heap?
In c# I can declare object o; then I can assign o=(float)5.0; or o="a string." Is there an equivalent for Objective-C? I tried to use id but it does not take primitive type like float or integer. Thanks for helping.
Given the following object graph:
{
"children": [
{
"child": {
"pets": [
{
"pet": {
"name": "fido"
}
},
{
"pet": {
"name": "fluffy"
}
}
]
}
},
{
"child": {
"pets": [
{
"pet": {
"name": "spike"
}
}
]
}
}
]
}
What would be a nice one-liner (or two) to collect the names of my grandchildren's pets? The result should be ["fido", "fluffy", "spike"]
I don't want to write custom methods for this... I'm looking for something like the way jQuery works in selecting dom nodes, where you can just give it a CSS-like path and it collects them up for you.
I would expect the expression path to look something like "children child pets pet name"