self

What does new self(); mean in PHP?

I've never seen code like this: public static function getInstance() { if ( ! isset(self::$_instance)) { self::$_instance = new self(); } return self::$_instance; } Is it the same as new className() ? EDIT If the class is inheritant,which class does it point to? ...

passing self data into a recursive function

I'm trying to set a function to do something like this def __binaryTreeInsert(self, toInsert, currentNode=getRoot(), parentNode=None): where current node starts as root, and then we change it to a different node in the method and recursivly call it again. However, i cannot get the 'currentNode=getRoot()' to work. If i try calling ...

Self Signed Applet Can it access Local File Systems

Hi I have created a Self Signed Applet , but not able to access local files system .What have i to do ? ...

Consequences of assigning self

Hi, Found a piece of code today, that I find a little smelly... TMyObject.LoadFromFile(const filename: String); begin if fileExists(filename) then self := TSomeObjectStreamer.ReadObjectFromFile(filename); end; If this code works, it will at least leak some memory, but does it work? Is OK to assign to self in this manner? Wha...

Descendent or self selector in jQuery

I want to search for all elements with class needle in all elements returned by jQuery('.haystack') and have tried jQuery('.haystack .needle'), but this doesn't seem to pick up the case where an element has both classes. Is there a selector that will do this? ...

class, dict, self, init, args ?

class attrdict(dict): def __init__(self, *args, **kwargs): dict.__init__(self, *args, **kwargs) self.__dict__ = self a = attrdict(x=1, y=2) print a.x, a.y b = attrdict() b.x, b.y = 1, 2 print b.x, b.y Could somebody explain the first four lines in words? I read about classes and methods. But here it seems very co...

Binding to a RelativeSource Self in Silverlight

Hello, I am trying to bind a value of a slider control to a property that is in the same control: <Slider Value="{Binding Path=ValueProperty, RelativeSource={RelativeSource Self}}" Name="slider1" /> but it doesn't bind to a "ValuePropery"... What am I doing wrong? ...

(self,left outer,right outer,full outer) join - real world examples

can you tell me simple real-world examples for (self,left outer,right outer,full outer) join? ...

python 'self' explained

What is the purpose of the 'self' word in python. I understand it refers to the specific object created from that class, but i cant see why it explicitly needs to be added to very function as a parameter. To illustrate, in ruby, i could do this: class myClass def myFunc(name) @name = name end end Which i understand, qu...

How to get MYSQL to show Zero results when left joining to self? (eg: Monthly Stats)

I have a table with typical statistics on page view and emails. An email creates a row and page view creates a row... I want to chart the page views and emails on a daily basis for the past 30 days (for example) so I need to show the day and the value... even if it ZERO. I cannot have missing days from my results or the chart breaks. ...

nHibernate Self Join Mapping

Hi Guys, This is probably incredibly simple, but I just cant see the wood for the trees at the moment. For brevity, I would like to model a word object, that has related words to it (synonyms), In doing so I could have the following mappings: <class name="Word" table="bs_word"> <id name="Id" column="WordId" type="Int32" unsaved-value=...

Calling self in objective c method headers

Lets say I made a method that can tabulate the total of x and y. total = [self totalThemUp x:30 y:50]; Is self correctly used? Why so? I don't see any object in particular that is acted on. Thanks for your help! ...

PHP detect if page is reloaded with PHP_SELF

I have a form that reloads the page with the updated data: <form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> ... <input type="submit" name="Submit" value="Update data"> </form> When the page is updated I want to display a message "Data updated". There was something like this with Referer I beleve, b...

A program that print out itself n times

Is that possible to write a program that reads in a integer n and outputs the program itself n times? ...

Self host WCF (Windows Communication Foundation) Ajax services

I am having trouble to understand how to expose the WCF services through Javascript. Here are what I found after days of research: Exposing WCF services through Javascript but not self host: http://msdn.microsoft.com/en-us/library/bb472488.aspx In this example, it requires the creation of a .svc file <%@ServiceHost language="c#" Debug=...

javascript new self invoking function

Hey, I've got a question about self invoking functions in javascript. What I'm doing is something similar to the following myNamespace = {}; //namespace for holding any objects/functions //helpModule as an example myNamespace.HelpModule = new (function(){ this.abc = '123'; //lots of other code in here... })(); now I'm abl...

Django self-recursive ManyToManyField filter query

Hi, I have a model like so: class Activity(models.Model): title = models.CharField(max_length=200) summary = models.TextField(null=True, blank=True) tasks = models.ManyToManyField('self', symmetrical=False, null=True, blank=True) It works like this, an activity can be linked to itself and the parent activity is call...

referencing self within a block IPhone SDK

I'm trying to implament a callback mechanism where I pass in a block to the init of a class, and after some work that class calls me back. The block gets called and most everything works, except when I call anything on "self" within the block. I get Program received signal: “EXC_BAD_ACCESS”. unless I comment out any reference to self...

self property in javascript?

I read here that "self Refers to the current window or form". Self does not seem to refer to the current form in this case: <form><input type="text" onkeyup="alert(self.foo.value)" name="foo"></form> However in this case it works (referring to the window): <form><input type="text" onkeyup="alert(self.document.forms[0].foo.value)" ...

python and using 'self' in methods

From what I read/understand, the 'self' parameter is similiar to 'this'. Is that true? If its optional, what would you do if self wasnt' passed into the method? ...