w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
adding multiple class objects to a single list and returning the values from the objects
You can provide an overload of the ToString method for each class: class classOne:onetwo { int item1 = 10; int item2 = 11; public override string ToString() { return string.Format("item1: {0}, item2: {1}", item1, item2); } } class classTwo:onetwo { string item3 = "red"; string item4 = "blue"; public override string ToString() { return string.Format("item3: {0}, item4: {1}", item3, item4); } } Another alternative is to provide a custom method in your base class to generate a formatted string via reflection: class onetwo { public virtual string ToPrintableString() { return string.Join(", ", this.GetType() .GetFields() .Select(p => p.Name + ": " + p.G

Categories : C#

Inserting multiple nested objects with MongoDB
Your answers sub-document is kind of acting like an array. There are two possibilities you could use to store multiple answers in each question: 1) Just use an array: Questions.insert({order : 1, question : "What type of property is it?", answers : [ "House", "Flat", "Bungalow", "Maisonette" ] }); 2) The way MongoDB will sometimes internally store arrays is to simply use an ordinal as the key to each sub-document, like so: Questions.insert({order : 1, question : "What type of property is it?", answers : {"1" : "House", "2" : "Flat", "3" : "Bungalow", "4" : "Maisonette"} });

Categories : Mongodb

How to query nested objects with multiple value in MongoDB?
You can use the $elemMatch operator to do this: Post.find({ advertisers: {$elemMatch: {category: 'Tech', city: 'New York' }}})

Categories : Mongodb

How to Represent Objects with Multiple Fields in the MongoDB Java Driver
Turns out one great way to do this is the following: BasicDBObject project = new BasicDBObject("$project", new BasicDBObject("sleep", new BasicDBObject().append("date", 1).append("hours", 1))); Then you can call your aggregation command as follows: AggregationOutput output = collection.aggregate(commandOne, commandTwo, Project, CommandThree); Hope this helps :)

Categories : Java

Parsing single json entry to multiple objects with Gson
The way to make Gson understand it is to write a custom deserializer by creating a TypeAdapter for your Test class. You can find information in Gson's User Guide. It is not exactly a manual parsing, but it is not that different, since you have to tell Gson how to deal with each JSON value... It should be something like this: private class TestDeserializer implements JsonDeserializer<Test> { public Test deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject obj = json.getAsJsonObject(); int id = obj.get("id").getAsInt(); String name = obj.get("name").getAsString(); double distance = obj.get("param_distance").getAsDouble(); int sampling = obj.get("param_sampling").getAsInt(); //assumin

Categories : Java

Guice inject single instance into multiple objects without using @Singleton
You should use a provider public class StoreProvider implements Provider<Store> { @Inject private Boss boss ; public Store get() { return new Store(boss, boss.getClerk().getCustomerLine()); } } And then bind it in your module bind(Store.class).toProvider(StoreProvider.class);

Categories : Java

Multiple buffer objects vs a single large manually managed one?
The real problem is not the amount of VBOs, but how large the content is (it shouldn't be too small) and reallocating a VBO. In your particular case, where you're frequently updating data having a small number of memory pool VBOs is usually better, then putting each chunk of data into its own VBO. loaded and unloaded frequently in an unpredictable manner (depending on the movements of the camera) You shouldn't do that. By which I mean use the view to decide what's loaded and whats not. Just load everything you possibly might need at the moment in the VBO and just reference it when actually required. But don't loose yourself in micromanaging each and every piece of data at every small time step. When you know, that something definitely won't show up ever again, then unload it. And if

Categories : Opengl

Build immutable NSDictionary from array with custom objects where each key could have multiple objects
There's no built-in concept of a one-to-many dictionary so I don't think there's a neater way to achieve exactly what you write — there's certainly no single line of syntax like there is for a whole bunch of other common manipulations. That said, minor suggestions would be: Use key-value coding to read the keyed property. So replace your references to obj.key with a single call to [obj valueForKeyPath:keyPath] and take keyPath as a parameter. Then you've got to write this code only once. For safety you should check that obj.key isn't nil. If it is then you'll end up doing [tmpMutableDic setObject:... forKey:nil], which raises an exception because dictionaries can't store values against a nil key. copy will return an immutable dictionary but the values in it will still be mutable arra

Categories : IOS

How can I select linked objects from multiple parent objects in Laravel Eloquent
This should work: class Location extends Eloquent { protected $table = 'locations'; public function chefs() { return $this->belongsTo('Chef'); } public function getAllChefsByCity($city) { $this->with('chefs')->where('city', $city)->get(); } } Then in your code: $array = $location->getAllChefsByCity('Chicago');

Categories : Laravel

converting multiple json objects into scala objects
Play's type class-based JSON library provides reader and writer instances for Seq[A] for any A with the appropriate instances, so all you have to do is provide a reader instance for your user type and you get a reader for a collection of users for free. We can start with the following case class (note that I've made the fact that the email address is optional explicit with Option): case class User(firstName: String, age: Double, email: Option[String]) Next we define our reader. I'm using 2.1's combinators, but there are other (more verbose) options. import play.api.libs.json._ import play.api.libs.functional.syntax._ implicit val userReads = ( (__ 'name).read[String] and (__ 'age).read[Double] and (__ 'email).read[Option[String]] )(User.apply _) We can test it: val userJs

Categories : Json

How can I have multiple copies of an object that are identical update while instantiated as separate objects in different view controllers?
if the shopping list doesnt need to be written to disk, option 1 is fine. if it does need to be written to disk, you can use core data.. or use sqlite, or NSArchiver. there are a few ways of storing data.

Categories : IOS

Using IRepository pattern for multiple domain objects and multiple storage mechanisms
Please refer to How would I design a repository to handle multiple data access strategies? , I think this is what you want. Basically assume you already have one IRepository interface having methods of CRUD and other generic methods refer by all your other repository, then you have multi implementations to IRepository interface. After that use any IOC container (I use Windsor Castle) to resolve which implement's component should take part for this interface doing application setup.

Categories : C#

What would be the best way to go about writing this in JS/jQuery? (Multiple individual objects with multiple fields)
Honestly, with the amount of data you are talking about and the number of ways it could be modified, you should look into a framework that is more robust and was designed to make data binding much easier. There are many out there, but my personal favorite is AngularJS. http://angularjs.org/ Start looking into this as it may save you a lot of time in developing the app and then of course maintaining it down the road.

Categories : PHP

Django Populating multiple forms with multiple objects
You are looking for the formsets A formset is a layer of abstraction to work with multiple forms on the same page. It can be best compared to a data grid.

Categories : Django

Convert one set of objects to another set of objects of different class in single line. C#
You could use LINQ: List<event> listOfEvents = (from eachEvent in eventsFromArgus select new Event( ReaderName = eachEvent.DeviceName, EventCode = eachEvent.EventCode, EventReceivedTime = eachEvent.ReceiveTime.ToString(), EventOriginTime = eachEvent.OriginTime.ToString(), CardNumber = eachEvent.CredentialIdentifier)).ToList(); But that's not terribly different from what you already have. Or, you could look into something like AutoMapper.

Categories : C#

Push and slice multiple times in MongoDB
The behavior you observed can be reproduced in MongoDB version 2.2. Your example works as expected in MongoDB version 2.4 > db.things.insert({name:"test1"}) > db.things.update({name:"test1"}, {"$push":{"output": {"$each": ["test1"], "$slice": -10}}}) > db.things.find() { "_id" : ObjectId("51d489f730d17c1ffbd6ff9f"), "name" : "test1", "output" : [ "test1" ] } > db.things.update({name:"test1"}, {"$push":{"output": {"$each": ["test2"], "$slice": -10}}}) > db.things.find() { "_id" : ObjectId("51d489f730d17c1ffbd6ff9f"), "name" : "test1", "output" : [ "test1", "test2" ] } From the documentation, $each support to $push operator was added in version 2.4 http://docs.mongodb.org/manual/reference/operator/each/#op._S_each Most likely you are using an older version of MongoDB

Categories : Mongodb

Multiple push channels (WNS) for a single app?
See the only formats being supported in wns push notification us either e xml based format or the json data format. If while communicating to the wns you are sending some other format then then it is bound to exceptions. ? Go through the demo from the link Push notification sample if this does not solve the problem then please leave a comment behind

Categories : Wcf

How to pass multiple model objects from controller and how to pass all as command objects into the form:form in spring mvc?
Just add both person and address into an enveloping object called personDetails and pass that to the form. class PersonDetails { private Person person; private Address address; ... } PersonDetails personDetails = new PersonDetails(); personDetails.setPerson(new Person()); personDetails.setAddress(new Address()); model.addAttribute(“personDetails”, personDetails); <form:form action=”registration” command=”personDetails”> Once you do that, you'll have to modify the paths appropriately. <form:input path="firstName" /> becomes <form:input path="person.firstName" /> Other more elegant option is to enclose Address within the Person and just expose the Person as a command. Just as @Seabook mentioned in his answer below.

Categories : Java

Multiple Counts using single MONGODB group query
if (doc.interaction.twitter.mention_ids == $twitter_id) { prev.mentions++; } Assuming mention_ids is an array in this example, I can't imagine how this condition returns true if "the first value in array is matched". You're comparing an array to a string value (I assume that's what $twitter_id is). To search the mention_ids array in JavaScript, you could either iterate through it and compare values (ideally break-ing out of the iteration after the first match), or utilize the Array.indexOf() method. As a rule of thumb, MDN's JavaScript portal is an excellent reference. In addition to the core JavaScript API, you can find a list of other JavaScript functions at your disposal in map/reduce functions in the mapReduce command docs.

Categories : PHP

In MongoDB, is one big $or search faster than multiple single searches?
I recommend you adjust your schema so it keeps a normalized array of tags. When you insert a new document, do it like this: tags : [ "business", "Computing", "PayPal" ], lowercaseTags : [ "business", "computing", "paypal" ] Similarly when you update the tags, update both arrays. Create an index on lowercaseTags, and then when you want to query them, use a single query with the $in operator, and the normalized form of the search terms. For example, to search for business iTunes YouTube, use this query: db.collection.find( { tags : $in: [ "business", "itunes", "youtube" ] } ) This answer gives an example of this approach. It should be loads faster than what you have. An alternate approach you can take is to create a text index and use the text command. Both of these approaches are

Categories : Database

Merging multiple objects
You'll not be able to achieve this with only a query in WolfCMS. You should try: $finalArr = array(); for($i=0; $i<sizeof($result);$i++) // $result being your query result array_push($finalArr,$result[$i]->country); print_r($finalArr);

Categories : PHP

Collision between multiple objects
One possible solution that might be robust against the problem you described (totally untested): Move your object for a full time-step dt Check for collisions with other objects, this might be more than one object Calculate the 'time of impact' by interpolation, which is some real number that is smaller than the time step. Do this for each object you collided with, and choose the minimum one. This gives you the time to the first collision t_col < dt. Redo the last step, but now move the object only for t_col so that it exactly hits the object and then start flipping velocities and other collision related physics. You can now either finish the step here if you are lazy (probably ok, since dt should be small), or continue to move for another dt - t_col and see if you hit something else.

Categories : Algorithm

Collapse multiple objects with same ID
The main problem is that you are using ids in a non-unique way. Ids are meant to be unique. Use a class instead. <ul> <li> <a href=".nav1" class="nav-toggle">Example <span class="nav-plus"></span></a></li> <li class="nav1" style="display:none;"><div class="orange-bar"></div><a href="page1.php">Navigation 1</a></li> <li class="nav1" style="display:none;"><div class="orange-bar"></div><a href="page2.php">Navigation 2</a></li> </ul> Notice I changed the href to ".nav1" and I changed the ids on the subsequent li tags to classes. This will cause both items to show. See this jsfiddle for proof. Also, the first li was missing a closing tag, so I fixed that as wel

Categories : Javascript

Move multiple objects at once - iOS
I might have an idea you can try. I'm assuming here you are only using objects that are inheriting from UIView, like UIButton, UILabel, UITextField etc. You could first put all current frames in an array, and then put all the elements in an array. That way, you can loop the second array, and for each elemnt, set Y to be array2[i]-20. NSMutableArray *currentFrames = [[NSMutableArray alloc] init]; for(int i = 0; i<10; i++) //10 being the number of elements, assuming they have tags from 0 to 9 [currentFrames addObject:[NSValue valueWithCGRect:[self.view viewWithTag:i].frame]]; for(int i = 0; i<currentFrames.count; i++) { UIView *v = [self.view viewWithTag:i]; [v setFrame:CGRectMake(v.frame.origin.x, v.frame.origin.y-20, v.frame.size.width, v.frame.size.height)]; }

Categories : IOS

Multiple connected objects in QT
You could use QObject::blockSignals as described here. But you must remember that if you use QObject::blockSignals will bloack all signals until you call QObject::blockSignals with false parameter.

Categories : C++

Trying to get multiple objects with inline
If I understand you correctly, you whant associate many PurchaseOrder's to one VerndorProfile. In such a case it would be better to use ManyToManyField. Example: models.py: class PurchaseOrder(models.Model): product = models.CharField(max_length=256) dollar_amount = models.FloatField() item_number = models.AutoField(primary_key=True) def __unicode__(self): return u'{} {}'.format(self.product, self.dollar_amount) class VendorProfile(models.Model): name = models.CharField(max_length=256) address = models.CharField(max_length=512) city = models.CharField(max_length=256) purchased_orders = models.ManyToManyField('PurchaseOrder') admin.py class VendorProfileAdmin(admin.ModelAdmin): filter_horizontal = ('purchased_orders', ) admin.site.register

Categories : Python

c++ Lighting Multiple Objects
Your light source doesn't have a position, it only has a direction and is therefore unaffected by translations. Plus, the vertex processor won't compute the direction from the source to the vertex for a directional light. Set the w coordinate to 1 t have a point light: GLfloat LightPosition[] = {0.0f,0.0f,1.0f,1.0};

Categories : C++

Dapper multiple objects from one row
You were pretty close to solution with the Query method. If you don't have an Id column, then you can provide a splitOn argument: connection.Query<Person, Pet, Tuple<Person, Pet>>(sql, (person, pet) => Tuple.Create(person, pet), splitOn: "PetName");

Categories : C#

NSArray with multiple Objects
If any of the 10 objects can be nil (note - use nil for Objective-C object references) then you need to do it the hard way: NSMutableArray *array = [[NSMutableArray alloc] init]; if (ob1) [array addObject:ob1]; if (ob2) [array addObject:ob2]; if (ob3) [array addObject:ob3]; // ... if (ob10) [array addObject:ob10]; This checks if each object is nil or not. If you also want to make sure it is not nil and it has a non-zero length value, change each if condition to: if (ob1.length) ...

Categories : IOS

MongoDB multiple array element update
The only way to affect multiple array elements per-doc in an update is to use numeric indexes in your keys to specifically identity the elements to update by their array position: db.exampleCollection.update({ "_id" : "00000002522dde26c6d65aed" }, { $inc: { "array.0.priority": 10, "array.1.priority": 10 } }, false, true); I know you are trying to target elements where priority > 4 rather than by index, but that's the harsh reality.

Categories : Mongodb

Android ArrayAdapter with multiple objects?
You can use SimpleAdapter with Map for data. More:http://developer.android.com/reference/android/widget/SimpleAdapter.html

Categories : Android

Can "with" keyword in VB.Net be used with multiple class objects
No, that's not possible, you can nest them, but that's about it: With something1 .property1 = value With something2 .property2 = .property1 'something2.property2 = something1.property1 End Width End With And it is really easy to get lost using this approach, especially if there're common properties between objects, so it is not recommended.

Categories : Vb.Net

Group animation on multiple objects
OK. I think I did it.After hours of looking around Stackoverflow and other places I found that to bhave the objects animate one after the other. I had to calculate the time according to the app time. I used. group.beginTime = CACurrentMediaTime() + AnimationDelay To stop the animation momentarily appearing at its final position before continuing with the animation. I had to use group.fillMode = kCAFillModeBackwards;

Categories : IOS

Working with multiple objects in file
Are you specifically looking for a solution using Select-String? If not, maybe this can work for you? $lookingFor = "string1"; $string1Line = ""; gc $inputfile | foreach { if($_ -match $lookingFor) { if($lookingFor -eq "string1") { $string1Line = $_; $lookingFor = "string2"; } else { #assuming "string2" $string1Line + $_ #return concat of string1 and string2 lines $lookingFor = "string1"; } } } EDIT: with regard to your edits, if you only need the string2 line, remove $string1Line and its assignment, then return just $_. instead of $string1Line + $_.

Categories : Powershell

Mongoose - multiple relations between objects
No you do not need two way links. All you need are Blog->Category Blog->Editors Blog->Owners Post->Blog Because your categories and users never change object ids, then you don't have to worry about updating references inside of blogs. In addition, when you want to remove a blog, don't delete the records. Instead, add a flag that marks the blog as deleted. When you display content, just check the delete flag of the corresponding blog, or even add a condition to your query to avoid those results entirely. (This also has the benefit of preserving history) To summarize, instead of creating two way links, you can just link from the more specific and changeable content to the more static content. To delete records, you either add a delete flag and don't worry about chasing recor

Categories : Database

how to parse multiple json objects with no name
JSONObject jObject = null; mJsonString = downloadFileFromInternet(urlString); jObject = new JSONObject(mJsonString); This will get you json object. This is the way to get json array from json object: JSONArray jsonImageArray = jObject.getJSONArray("your string");

Categories : Java

Display multiple objects from server
You can install an Apache server on your MacOS, read read this: http://osxdaily.com/2012/09/02/start-apache-web-server-mac-os-x/

Categories : IOS

Print or capturing multiple objects in R
You can store the result as a list and then use the capture.output fit1<-lm(mpg~cyl,data=mtcars) fit2<-lm(mpg~cyl+disp,data=mtcars) myresult<-list(fit1,fit2) capture.output(myresult, file = "results.txt")

Categories : R

Set multiple objects to a setTimeout function
You have a syntax error, use: setTimeout(function() { $('#post_confirm').fadeOut('slow'); // lose the }, here $('#chat').height($chatHeight_user); }, 1000); setTimeout() works like this: setTimeout(callback,time) So you can replace callback with a single anonymous function that has all the other code in it.

Categories : Jquery

Qt C++ - Connect multiple objects to one signal
Read documentation carefully. QSlider has public functions void setMaximum ( int ) and void setMinimum ( int ). Probably that is what you are looking for. Good luck!

Categories : C++



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.