Search Results

Search found 6328 results on 254 pages for 'anonymous person'.

Page 15/254 | < Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >

  • Linq to DataTable without enumerating fields

    - by Luciano
    Hi, i´m trying to query a DataTable object without specifying the fields, like this : var linqdata = from ItemA in ItemData.AsEnumerable() select ItemA but the returning type is System.Data.EnumerableRowCollection<System.Data.DataRow> and I need the following returning type System.Data.EnumerableRowCollection<<object,object>> (like the standard anonymous type) Any idea? Thanks

    Read the article

  • Can someone here explain constructors and destructors in python - simple explanation required - new

    - by rgolwalkar
    i will try to see if it makes sense :- class Person: '''Represnts a person ''' population = 0 def __init__(self,name): //some statements and population += 1 def __del__(self): //some statements and population -= 1 def sayHi(self): '''grettings from person''' print 'Hi My name is %s' % self.name def howMany(self): '''Prints the current population''' if Person.population == 1: print 'i am the only one here' else: print 'There are still %d guyz left ' % Person.population rohan = Person('Rohan') rohan.sayHi() rohan.howMany() sanju = Person('Sanjivi') sanju.howMany() del rohan # am i doing this correctly --- ? i need to get an explanation for this del - destructor O/P:- Initializing person data ****************************************** Initializing Rohan ****************************************** Population now is: 1 Hi My name is Rohan i am the only one here Initializing person data ****************************************** Initializing Sanjivi ****************************************** Population now is: 2 In case Person dies: ****************************************** Sanjivi Bye Bye world there are still 1 people left i am the only one here In case Person dies: ****************************************** Rohan Bye Bye world i am the last person on earth Population now is: 0 If required i can paste the whole lesson as well --- learning from :- http://www.ibiblio.org/swaroopch/byteofpython/read/

    Read the article

  • python __getattr__ help

    - by Stefanos Tux Zacharakis
    Reading a Book, i came across this code... # module person.py class Person: def __init__(self, name, job=None, pay=0): self.name = name self.job = job self.pay = pay def lastName(self): return self.name.split()[-1] def giveRaise(self, percent): self.pay = int(self.pay *(1 + percent)) def __str__(self): return "[Person: %s, %s]" % (self.name,self.pay) class Manager(): def __init__(self, name, pay): self.person = Person(name, "mgr", pay) def giveRaise(self, percent, bonus=.10): self.person.giveRaise(percent + bonus) def __getattr__(self, attr): return getattr(self.person, attr) def __str__(self): return str(self.person) It does what I want it to do, but i do not understand the __getattr__ function in the Manager class. I know that it Delegates all other attributes from Person class. but I do not understand the way it works. for example why from Person class? as I do not explicitly tell it to. person(module is different than Person(class) Any help is highly appreciated :)

    Read the article

  • Static variables in Java for a test oObject creator

    - by stevebot
    Hey, I have something like the following TestObjectCreator{ private static Person person; private static Company company; static { person = new Person() person.setName("Joe"); company = new Company(); company.setName("Apple"); } public Person createTestPerson(){ return person; } public Person createTestCompany(){ return company; } } By applying static{} what am I gaining? I assume the objects are singletons as a result. However, if I did the following: Person person = TestObjectCreator.createTestPerson(); person.setName("Jill"); Person person2 = TestObjectCreator.createTestPerson(); would person2 be named Jill or Joe?

    Read the article

  • How to optimise MySQL query containing a subquery?

    - by aidan
    I have two tables, House and Person. For any row in House, there can be 0, 1 or many corresponding rows in Person. But, of those people, a maximum of one will have a status of "ACTIVE", the others will all have a status of "CANCELLED". e.g. SELECT * FROM House LEFT JOIN Person ON House.ID = Person.HouseID House.ID | Person.ID | Person.Status 1 | 1 | CANCELLED 1 | 2 | CANCELLED 1 | 3 | ACTIVE 2 | 1 | ACTIVE 3 | NULL | NULL 4 | 4 | CANCELLED I want to filter out the cancelled rows, and get something like this: House.ID | Person.ID | Person.Status 1 | 3 | ACTIVE 2 | 1 | ACTIVE 3 | NULL | NULL 4 | NULL | NULL I've achieved this with the following sub select: SELECT * FROM House LEFT JOIN ( SELECT * FROM Person WHERE Person.Status != "CANCELLED" ) Person ON House.ID = Person.HouseID ...which works, but breaks all the indexes. Is there a better solution that doesn't? I'm using MySQL and all relevant columns are indexed. EXPLAIN lists nothing in possible_keys. Thanks.

    Read the article

  • Pass a function as parameter in jQuery?

    - by thedp
    Hello, I would like to pass to a jQuery function a regular function, instead of the usual anonymous function, but I'm not sure how such a thing could be done. Instead of this: function setVersion(feature) { $.post("some.php", { abc:"abc" }, function(data){ // do something here }, "json"); } I would like to do this: function foo(data){ // do something here } function setVersion(feature) { $.post("some.php", { abc:"abc" }, foo, "json"); } Thank you.

    Read the article

  • How to write two-dimensional array to xml in Scala 2.8.0

    - by Shadowlands
    The following code (copied from a question from about a year ago) works fine under Scala 2.7.7, but does not behave correctly under Scala 2.8.0 (Beta 1, RC8). import scala.xml class Person(name : String, age : Int) { def toXml(): xml.Elem = <person><name>{ name }</name><age>{ age }</age></person> } def peopleToXml(people: Array[Person]): xml.Elem = { <people>{ for {person <- people} yield person.toXml }</people> } val data = Array(new Person("joe",40), new Person("mary", 35)) println(peopleToXml(data)) The output (according to 2.7.7) should be: <people><person><name>joe</name><age>40</age></person><person><name>mary</name><age>35</age></person></people> but instead comes out as: <people>\[Lscala.xml.Elem;@17821782</people> How do I get this to behave as it did in 2.7.x?

    Read the article

  • inheritance problem OOP extend

    - by hsmit
    If a Father is a Parent and a Parent is a Person and a Person has a Father I create the following: class Person{ Father father; } class Parent extends Person{} class Father extends Parent{} Instances: Person p1 = new Person(); Person p2 = new Person(); p1.father = p2; //father is of the type Father This doesn't work... Now try casting:: Person p1 = new Person(); Person p2 = new Person(); p1.father = (Father)p2; This doesn't work either. What does work for this case?

    Read the article

  • Saving data in custom class via AppDelegate

    - by redspike
    I can't seem to save data to a custom instance object in my AppDelegate. My custom class is very simple and is as follows: Person.h ... @interface Person : NSObject { int _age; } - (void) setAge: (int) age; - (int) age; @end Person.m #import "Person.h" @implementation Person - (void) setAge:(int) age { _age = age; } - (int) age { return _age; } @end I then create an instance of Person in the AppDelegate class: AppDelegate.h @class Person; @interface AccuTaxAppDelegate : NSObject <UIApplicationDelegate> { ... Person *person; } ... @property (nonatomic, retain) Person *person; @end AppDelegate.m ... #import "Person.h" @implementation AccuTaxAppDelegate ... @synthesize person; - (void)applicationDidFinishLaunching:(UIApplication *)application { // Override point for customization after app launch [window addSubview:[navigationController view]]; [window makeKeyAndVisible]; } - (void)applicationWillTerminate:(UIApplication *)application { // Save data if appropriate } #pragma mark - #pragma mark Memory management - (void)dealloc { [navigationController release]; [window release]; [person release]; [super dealloc]; } @end Finally, in my ViewController code I grab a handle on AppDelegate and then grab the person instance, but when I try to save the age it doesn't seem to work: MyViewController ... - (void)textFieldDidEndEditing:(UITextField *)textField { NSString *textAge = [textField text]; int age = [textAge intValue]; NSLog(@"Age from text field::%i", age); AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate; Person *myPerson = (Person *)[appDelegate person]; NSLog(@"Age before setting: %i", [myPerson age]); [myPerson setAge:age]; NSLog(@"Age after setting: %i", [myPerson age]); [textAge release]; } ... The output of the above NSLogs are: [Session started at 2010-05-04 18:29:22 +0100.] 2010-05-04 18:29:28.260 AccuTax[16235:207] Age in text field:25 2010-05-04 18:29:28.262 AccuTax[16235:207] Age before setting: 0 2010-05-04 18:29:28.263 AccuTax[16235:207] Age after setting: 0 Any ideas why 'age' isn't being stored? I'm relatively new to Obj-C so please forgive me if I'm missing something very simple!

    Read the article

  • Lambda recursive PHP functions.

    - by Kendall Hopkins
    Is it possible to have a PHP function that is both recursive and anonymous (lambda). This is my attempt to get it to work, but it doesn't pass in the function name. $factorial = function( $n ) use ( $factorial ) { if( $n == 1 ) return 1; return $factorial( $n - 1 ) * $n; }; print $factorial( 5 ); I'm also aware that this is a bad way to implement factorial, it's just an example.

    Read the article

  • How do I make money from my FOSS while staying anonymous?

    - by user21007
    Let's say that: You have created a FOSS project that other people find useful, perhaps useful enough to donate to or pay for modifications to be done. It is a perfectly legitimate and innocuous software project. It has nothing to do with cryptography as munitions, p2p music, or anything likely to lead to a search warrant or being sued. You want your involvement to stay anonymous or pseudonymous. You would like to receive some money for your efforts, if people are willing. Is that possible, and if so, how could it be done? When I talk about anonymity, I realize that it is necessary to define the extent. I am not talking about Wikileaks style 20 layers of proxies worth of anonymity. I would expect a 3 letter agency to be able to identify the person easily. What is wanted is shielding from commercial competitors or random people, who would not be expected to be able to get the financial intermediary to divulge your details just by asking for them. Why would you want to stay anonymous? I can think of several valid reasons, maybe you operate a stealth mode startup and don't want to give your competitors clues as to the technology you are using. Maybe it is a project that has nothing to do with your daily job, is not developed there, but the company you work for has an unfair (and possibly unenforceable) policy stating that any coding you do is owned by them. Maybe you just value your privacy. For what it's worth, you intend to pay the relevant taxes in your country on any donations.

    Read the article

  • How to perform Linq select new with datetime in SQL 2008

    - by kd7iwp
    In our C# code I recently changed a line from inside a linq-to-sql select new query as follows: OrderDate = (p.OrderDate.HasValue ? p.OrderDate.Value.Year.ToString() + "-" + p.OrderDate.Value.Month.ToString() + "-" + p.OrderDate.Value.Day.ToString() : "") To: OrderDate = (p.OrderDate.HasValue ? p.OrderDate.Value.ToString("yyyy-mm-dd") : "") The change makes the line smaller and cleaner. It also works fine with our SQL 2008 database in our development environment. However, when the code deployed to our production environment which uses SQL 2005 I received an exception stating: Nullable Type must have a value. For further analysis I copied (p.OrderDate.HasValue ? p.OrderDate.Value.ToString("yyyy-mm-dd") : "") into a string (outside of a Linq statement) and had no problems at all, so it only causes an in issue inside my Linq. Is this problem just something to do with SQL 2005 using different date formats than from SQL 2008? Here's more of the Linq: dt = FilteredOrders.Where(x => x != null).Select(p => new { Order = p.OrderId, link = "/order/" + p.OrderId.ToString(), StudentId = (p.PersonId.HasValue ? p.PersonId.Value : 0), FirstName = p.IdentifierAccount.Person.FirstName, LastName = p.IdentifierAccount.Person.LastName, DeliverBy = p.DeliverBy, OrderDate = p.OrderDate.HasValue ? p.OrderDate.Value.Date.ToString("yyyy-mm-dd") : ""}).ToDataTable(); This is selecting from a List of Order objects. The FilteredOrders list is from another linq-to-sql query and I call .AsEnumerable on it before giving it to this particular select new query. Doing this in regular code works fine: if (o.OrderDate.HasValue) tempString += " " + o.OrderDate.Value.Date.ToString("yyyy-mm-dd");

    Read the article

  • C# delegate or Func for 'all methods'?

    - by Michel
    Hi, i've read something about Func's and delegates and that they can help you to pass a method as a parameter. Now i have a cachingservice, and it has this declaration: public static void AddToCache<T>(T model, double millisecs, string cacheId) where T : class public static T GetFromCache<T>(string cacheId) where T : class So in a place where i want to cache some data, i check if it exists in the cache (with GetFromCache) and if not, get the data from somewhere, and the add it to the cache (with AddToCache) Now i want to extend the AddToCache method with a parameter, which is the class+method to call to get the data Then the declaration would be like this public static void AddToCache<T>(T model, double millisecs, string cacheId, Func/Delegate methode) where T : class Then this method could check wether the cache has data or not, and if not, get the data itself via the method it got provided. Then in the calling code i could say: AddToCache<Person>(p, 10000, "Person", new PersonService().GetPersonById(1)); AddToCache<Advert>(a, 100000, "Advert", new AdvertService().GetAdverts(3)); What i want to achieve is that the 'if cache is empty get data and add to cache' logic is placed on only one place. I hope this makes sense :) Oh, by the way, the question is: is this possible?

    Read the article

  • How do you explain refactoring to a non-technical person?

    - by Benjol
    (This question was inspired by the most-voted answer here) How do you go about explaining refactoring (and technical debt) to a non-technical person (typically a PHB or customer)? ("What, it's going to cost me a month of your work with no visible difference?!") UPDATE Thanks for all the answers so far, I think this list will provide several useful analogies to which we can point the appropriate people (though editing out references to PHBs may be wise!)

    Read the article

  • How do you explain refactoring to a non-technical person?

    - by Benjol
    (This question was inspired by the most-voted answer here) How do you go about explaining refactoring (and technical debt) to a non-technical person (typically a PHB or customer)? ("What, it's going to cost me a month of your work with no visible difference?!") UPDATE Thanks for all the answers so far, I think this list will provide several useful analogies to which we can point the appropriate people (though editing out references to PHBs may be wise!)

    Read the article

  • How to do this in VB 2010 (C# to VB conversion)

    - by user203687
    I would like to have the following to be translated to VB 2010 (with advanced syntaxes) _domainContext.SubmitChanges( submitOperation => { _domainContext.Load<Customer>( _domainContext.GetCustomersQuery(), LoadBehavior.RefreshCurrent, loadOperation => { var results = _domainContext.Customers.Where( entity => !loadOperation.Entities.Contains(entity)).ToList(); results.ForEach( enitity => _domainContext.Customers.Detach(entity)); }, null); }, null); I managed to get the above with other ways (but not using anonymous methods). I would like to see all the advanced syntaxes available in VB 2010 to be applied to the above. Can anyone help me on this? thanks

    Read the article

  • detachEvent not working with named inline functions

    - by Polshgiant
    I ran into a problem in IE8 today (Note that I only need to support IE) that I can't seem to explain: detachEvent wouldn't work when using a named anonymous function handler. document.getElementById('iframeid').attachEvent("onreadystatechange", function onIframeReadyStateChange() { if (event.srcElement.readyState != "complete") { return; } event.srcElement.detachEvent("onreadystatechange", onIframeReadyStateChange); // code here was running every time my iframe's readyState // changed to "complete" instead of only the first time }); I eventually figured out that changing onIframeReadyStateChange to use arguments.callee (which I normally avoid) instead solved the issue: document.getElementById('iframeid').attachEvent("onreadystatechange", function () { if (event.srcElement.readyState != "complete") { return; } event.srcElement.detachEvent("onreadystatechange", arguments.callee); // code here now runs only once no matter how many times the // iframe's readyState changes to "complete" }); What gives?! Shouldn't the first snippet work fine?

    Read the article

  • adhoc struct/class in C#?

    - by acidzombie24
    Currently i am using reflection with sql. I find if i want to make a specialize query it is easiest to get the results by creating a new class inheriting from another and adding the 2 members/columns for my specialized query. Then due to reflections in the lib in my c# code i can write foreach(var v in list) { v.AnyMember and v.MyExtraMember) Now instead of having the class scattered around or modifying my main DB.cs file can i define a class inside a function? I know i can create an anonymous object by writing new {name=val, name2=...}; but i need a to pass this class in a generic function func(query, args);

    Read the article

  • Predicate<INT> match question

    - by Petr
    Hi, I do not understand how following code works. Specifically, I do not understand using of "return i<3". I would expect return i IF its < than 3. I always though that return just returns value. I could not even find what syntax is it. Second question, it seems to me like using anonymous method (delegate(int i)) but could be possible to write it with normal delegate pointing to method elsewere? Thanks List<int> listOfInts = new List<int> { 1, 2, 3, 4, 5 }; List<int> result = listOfInts.FindAll(delegate(int i) { return i < 3; });

    Read the article

  • Slight confusion of `this` in a JavaScript call back function

    - by thecoshman
    $.ajax({url: path_to_file, cache: false, success: function(html_result){ $("#window_" + this.id + "_cont_buffer").html(html_result);}) Now then. This function call is with in a function of a class. this.id is a property of said class. will this pass the function value of this.id into the string the anonymous function, or will it try to evaluate it when the function actually gets called, thus making no sense. If this is not going to work how I want it to, can you recommend how I achieve this.

    Read the article

  • Rewriting usort function because of fatal error (PHP bug)

    - by Lionel
    The two following usort functions throw fatal error Base lambda function for closure not found in our productive environment (PHP 5.4). This seems to be a known PHP bug that should be fixed by now (https://bugs.php.net/bug.php?id=52144), but it still occurs for us. Anyway, we unfortunately don't have time to figure out what's wrong with our PHP configurations etc. We would like to rewrite these two functions without the use of anonymous functions, so that the error doesn't occur anymore. Ordering of a multidimensional array ($array) by value of key "position": usort($array, function($a, $b) { return $a['position'] - $b['position']; }); Ordering of a multidimensional array ($array) according to the order of a second array ($position_order): usort($array, function($a, $b) use($position_order) { return (isset($position_order[$a['ftid']]) ? ($position_order[$a['ftid']] - $position_order[$b['ftid']]) : 1); }); Especially the latter causes some headache, as we don't know how to pass the "outside" array $position_order.

    Read the article

  • Writing lambda functions in Scala

    - by user2433237
    I'm aware that you can write anonymous functions in Scala but I'm having trouble trying to convert a piece of code from Scheme. Could anyone help me convert this to Scala? (define apply-env (lambda (env search-sym) (cases environment env (empty-env () (eopl:error 'apply-env "No binding for ~s" search-sym)) (extend-env (var val saved-env) (if (eqv? search-sym var) val (apply-env saved-env search-sym))) (extend-env-rec (p-name b-var p-body saved-env) (if (eqv? search-sym p-name) (proc-val (procedure b-var p-body env)) (apply-env saved-env search-sym)))))) Thanks in advance

    Read the article

  • Is it possible to access ASP.NET anonymous profile for a logged in user?

    - by Simon_Weaver
    The ASP.NET membership supports anonymous users and logged in users. If you call FormsAuthentication.SetAuthCookie(userName, createPersistentCookie); with a true for createPersistentCookie then the user will be logged in automatically when they revisit your site - even after closing the browser. If you don't enable this 'remember me' feature, then the anonymous cookie will still be around when the user visits your site again. I'd like to do be able to store information in the user's anonymous profile when they are logged in. i.e. I don't want them to remain authenticated on the site if they go away and come back, but I'd still like be able to track certain things - like perhaps a visitCount property in the anonymous profile. Is there any way to access a user's anonymous profile when they are authenticated. The two cookies exist so it should be possible. I don't want to reinvent half the wheel! ps. I realize that tracking is skewed if multiple users use the system but thats fine.

    Read the article

  • getting record from CoreData ?

    - by Meko
    Hi. I am trying to add value to CoreData from .plist and get from coreData and show them on UITable. I made take from .plist and send them to CoreData .But I cant take them from CoreData entity and set to some NSMutable array.. Here my codes Edit : SOLVED NSString *path = [[NSBundle mainBundle] pathForResource:@"FakeData" ofType:@"plist"]; NSArray *myArray=[[NSArray alloc] initWithContentsOfFile:path]; FlickrFetcher *flickrfetcher =[FlickrFetcher sharedInstance]; managedObjectContext =[flickrfetcher managedObjectContext]; for(NSDictionary *dict in myArray){ Photo *newPhoto = (Photo *)[NSEntityDescription insertNewObjectForEntityForName:@"Photo" inManagedObjectContext:managedObjectContext]; // set the attributes for the photo NSLog(@"Creating Photo: %@", [dict objectForKey:@"name"]); [newPhoto setName:[dict objectForKey:@"name"]]; [newPhoto setPath:[dict objectForKey:@"path"]]; NSLog(@"Person is: %@", [dict objectForKey:@"user"]); NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name ==%@",[dict objectForKey:@"user"]]; NSMutableArray *peopleArray = (NSMutableArray *)[flickrfetcher fetchManagedObjectsForEntity:@"Person" withPredicate:predicate]; NSEnumerator *enumerator = [peopleArray objectEnumerator]; Person *person; BOOL exists = FALSE; while (person = [enumerator nextObject]) { NSLog(@" Person is: %@ ", person.name); if([person.name isEqualToString:[dict objectForKey:@"user"]]) { exists = TRUE; NSLog(@"-- Person Exists : %@--", person.name); [newPhoto setPerson:person]; } } // if person does not already exist then add the person if (!exists) { Person *newPerson = (Person *)[NSEntityDescription insertNewObjectForEntityForName:@"Person" inManagedObjectContext:managedObjectContext]; // create the person [newPerson setName:[dict objectForKey:@"user"]]; NSLog(@"-- Person Created : %@--", newPerson.name); // associate the person with the photo [newPhoto setPerson:newPerson]; } //THis IS myArray that I want to save value in it and them show them in UITABLE personList=[[NSMutableArray alloc]init]; NSLog(@"lllll %@",[personList objectAtIndex:0]); // save the data NSError *error; if (![managedObjectContext save:&error]) { // Handle the error. NSLog(@"Unresolved error %@, %@", error, [error userInfo]); exit(-1); } } //To access core data objects you can try the following: // setup our fetchedResultsController fetchedResultsController = [flickrfetcher fetchedResultsControllerForEntity:@"Person" withPredicate:nil]; // execute the fetch NSError *error; BOOL success = [fetchedResultsController performFetch:&error]; if (!success) { // Handle the error. NSLog(@"Unresolved error %@, %@", error, [error userInfo]); exit(-1); } // save our data //HERE PROBLEM THAT I DONW KNOW WHERE IT IS SAVING //[personList addObject:(NSMutableArray *)[fetchedResultsController fetchedObjects]]; [self setPersonList:(NSMutableArray *)[fetchedResultsController fetchedObjects]]; } Here my tableview function - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"ss %d",[personList count]); static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } cell.textLabel.text=[personList objectAtIndex:indexPath.row]; // Set up the cell... return cell; }

    Read the article

  • Before and After the Programmer Life [closed]

    - by Gio Borje
    How were people before and after becoming programmers through a black box? In a black box, the implementation is irrelevant; therefore, we focus on the input and output: High School Nerd -> becomeProgrammer() -> Manager (Person Before) -> (Person as Programmer) -> (New Person) (Person Before) -> (Person as Programmer) How are the typical lives of people before they became programmers? Why do people pursue life as a programmer? (Person as Programmer) -> (New Person) How has becoming a programmer changed people afterwards? Why quit being a programmer? Anecdotes would be nice. If many programmers have similar backgrounds and fates, do you think that there is some sort of stereotypical person that are destined to become programmers?

    Read the article

< Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >