w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
PHP objects inside arrays (HOW TO: If array key is 0, return 0. Else if array key is 2, return 2. BASIC LOGIC)
I think the problem is here: foreach($array as $single) { $array = $single->name . ','; } $array is only an array the first time the loop is executed as inside the loop your assigning it a new value. Try this instead: $names = array(); foreach ($array as $single) { $names[] = $single->name; } echo implode(', ', $names);

Categories : PHP

Using navigator.platform to detect os in browser
Reliably checking the platform information isn't an easy problem. You can parse out navigator.userAgent, but I'd recommend using a library that can do this for you. Platform.js looks to be the most featured of these libraries.

Categories : Javascript

Find where array of objects does not contain objects with param with specific value
Use the $ne operator and dot notation to do this: UserModel.find({'registrations.fieldA': {$ne: 'specific value'}}, cb); When used with an array field like this, $ne will only match docs where no array element contains the specific value.

Categories : Javascript

Find nested object by value and return the found objects key
You can extend Array object with new functionality by adding a function to the Array.prototype, and you can use this to refer the the owner which calls the function. Inside the find() method, you can utilize filter() function to filter the collection. var data = [{ _id: 123, name: "Test"}, { _id: 124, name: "Test2" }] Array.prototype.find = function(obj){ return this.filter(function(item){ return (item._id === obj._id); }); } var result = data.find({_id: 123});

Categories : Javascript

Maven: Report plugin org.apache.maven.plugins:maven-project-info-reports-plugin has an empty version
Oh, I resolved my issue. I include info for maven-project-info-reports-plugin in plugin section where maven-resources-plugin is described <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>2.6</version> <executions> <execution> <phase>test</phase> <goals> <goal>resources</goal> <goal>testResources</goal> </goals> </execution> </executions> </plugin> <plugin> &

Categories : Maven

Best way to return the key of an array about the value of one of its containing objects
Array.map() passes the index as the second parameter to the callback. However, it won't help you find a single item. Javascript arrays do not have a function that does this. Using LoDash, you can do this very easily: _.findIndex(Players, { id: 4 })

Categories : Javascript

Find and search for a double in an array and return its indices? Is this an array element swap method?)
A few things to fix in your first example: Right now, j < circles[0].length means that only one column is being searched: column 0. You'll want j < circles[i].length to search every column by row. if (temp == r) means you're comparing a Circle and a double. I'm not familiar with the circle class, but I believe you'll want to replace instead of Circle temp = circles[i][j] with double temp = circles[i][j].getRadius();. You want to return as soon as you find the matching Circle, so you have some things a little backwards. With my new revisions, if (temp == r) will now activate the code if you have found the correct radius. That means below that if statement, you'll want return {i, j};. That will return the current circle's (which has the correct radius) indicies. The last statement wi

Categories : Java

how to populate an array with return value objects
To access one of the CCPhysicsSprite objects at a particular index of ballArray, do this: int index; // Set this to which index of the array you wish to view. CCPhysicsSprite *sprite = [ballArray objectAtIndex: index]); If you want to access all the CCPhysicsSprite objects of ballArray, do this: int count = [myColors count]; for (i = 0; i < count; i++) { CCPhysicsSprite *sprite = [myColors objectAtIndex: count]; } Hope this answers your question.

Categories : Objective C

How to return all objects in javascript array
If what you are asking is how you iterate over the contents of an array, you can do so in plain javascript like this: var arr = [1,2,3]; for (var i = 0; i < arr.length; i++) { // arr[i] is each item of the array console.log(arr[i]); } Just because something is of type Object does not necessarily mean that it's an array. It could also just be a plain object with various properties on it. If you look at the info argument in either the debugger or with console.log(info), you should be able to see what it is.

Categories : Javascript

How to create and return a pointer to an array of objects in C++?
typedef std::vector<Entity> entities; void foo1( entities& myEntities ) {} void foo2( entities& myEntities ) {} have a master vector of entities, pass it by reference to the functions avoids the copying of the vector.

Categories : C++

Need to return a date/time string from phonegap's navigator.globalization.dateToString
Yes it's an asynchronous call so you need to continue your process in the callback function : var myTime = new Date(parseInt(myData.StartTime.substr(6))); // get a date object var myTimeString = ''; console.log("before"); navigator.globalization.dateToString(myTime, function(date) { console.log("doing"); myTimeString = date.value; callback(myTimeString); }, function() { alert('Error getting dateString '); }, { formatLength : 'short', selector : 'date and time' }); function callback(myTime) { console.log("done"); console.log(myTime); }

Categories : Javascript

Using extensions/plugins/addons with a headless browser
So, apparently, shoehorning plugins into server side browsers is near impossible, or not recommended. I've overcome my problem by using client-side unit tests (using QUnit), but I believe the original issue can be solved by adding firewall/iptable rules that block specific urls that serve ads, on the machine used for testing. The list of blocked urls can be taken from the ad-blocker plugins themselves, and updated regularly.

Categories : Testing

Joomla: Plugins for a plugin - how to 'advertise' capabilities?
If you import your plugins trough the plugin helper JPluginHelper::importPlugin('mycmdplugins'); then you can get all available commands which are supported by your sub plugins like $cmds = JDispatcher::getInstance()->trigger('onMyAwesomeCmds'); With the $cmds variable you know now which commands are supported by the sub plugins and you can parse the article for them. Then you can do foreach ($cmds as $cmd) { preg_match_all("{".$cmd."*}", $article->text, $matches, PREG_SET_ORDER); if (!empty($matches)) { JDispatcher::getInstance()->trigger('onMyAwesome'.ucfirst($cmd), array($article, $params)); } } To eliminate more repeating tasks I suggest that the additional plugins will extend a base class from your plugins folder.

Categories : Joomla

Which Grails Plugins do not work with Hibernate 4 Plugin?
Pretty much any plugin that depends on Hibernate 3 won't, since there were significant changes between Hibernate 3 and 4, including package changes. EDIT - I looked through the available plugins and these all seem to require Hibernate 3: app-info-hibernate db-reverse-engineer db-helper-rest envers hibernate-filter hibernate-hijacker hibernate-search hibernate-spatial hibernate-spatial-hdb hibernate-spatial-mysql hibernate-spatial-oracle hibernate-spatial-postgresql hibernate-spatial-sqlserver hibernate-stats infinispan lazylob memcached multi-tenant multi-tenant-acegi multi-tenant-core multi-tenant-ehcache multi-tenant-proxy multi-tenant-single-db multi-tenant-spring-security quartz searchable There are probably others, but either they're old or obscure and I didn't bother to check.

Categories : Hibernate

TableSorter Plugin and other Sorting Plugins not Working
Change: $("myTable").tablesorter(); For $("#myTable").tablesorter(); The reason being is that you are selecting the element by its Id, which requires the # in front of it. If you want to apply the tableSorter plugin to all your tables with the class tablesorter then you would do this: $(".tablesorter").tablesorter(); //now you are selecting by class and not by Id Demo here.

Categories : Jquery

Foreach through an array with objects and return the values and keys
Instead of foreach($results2->name as $item) use foreach($results2 as $item). $results2->name is not an array thus causing the error. You can read about object iteration in PHP here foreach($result as $results2) { echo $results2->name.' '.$results2->set_id; }

Categories : PHP

Find index in array of objects
I don't think you need underscore for that just regular ole js - hope this is what you are looking for var data = [ { "text":"one","siteid":"1","chid":"default","userid":"8","time":1374156747 }, { "text":"two","siteid":"1","chid":"default","userid":"7","time":1374156735 } ]; var userid = "userid" var filterparams = {userid:'7', chid: 'default'}; var index; for (i=0; i < data.length; i++) { for (prop in data[i]) { if ((prop === userid) && (data[i]['userid'] === filterparams.userid)) { index = i } } } alert(index);

Categories : Javascript

Find all objects with same property in array PHP
Try this: $persons_region = 'Cheshire'; $found_jobs = array(); foreach ($jobs as $job) { if ($job['region'] == $persons_region) { $found_jobs[] = $job; } }

Categories : PHP

NPAPI plugin not getting loaded upon installing and browser plugin method call failing
I don't see where this refreshs the page. What should work though is re-instantiating the plugin (e.g. by switching it to display:none and back). This also looks like you could be accessing the plugin too soon - the plugin might not have finished instantiating yet. After finding it listed in navigator.plugins and (re-)instantiating you could: periodically try accessing it until it works or (better) have your plugin call into the page when it finished loading In both cases you'll want to time out after a "reasonable" time and conclude that either it failed to load or the plugin is being blocked (plugin being set to click-to-play or some extension blocked it) ... there is a best-practices article for this on MDN.

Categories : Javascript

Unit testing plugins in an application with plugin architecture
Seems like putting generic tests into a base class and deriving from it for each plugin is a viable way: public interface IPluginComponent { } [TestClass] public abstract class BaseTests { protected abstract IPluginComponent CreateComponent(); [TestMethod] public void SomeTest() { IPluginComponent component = this.CreateComponent(); // execute test } } public class MyPluginComponent : IPluginComponent { } [TestClass] public class MyPluginTests : BaseTests { protected IPluginComponent CreateComponent() { return new MyPluginComponent(); } [TestMethod] public void CustomTest() { // custom test } } Tests using MSTest should however be aware of a bug, where it is not possible to run tests in base class, if

Categories : C#

Phonegap and making use of Plugins (specifically the Facebook Plugin)
Should you ever have any plugin problems ie there is complainant about the Plugin Class as above, then at least for Facebook this problem has been solved here

Categories : Android

Dependency between plugins? Calling a method before plugin is created
I makes plugins load this way. May it will useful for someone. In global section define array var plugins = []; Load all my plugins (*.js) as usual, <script type="text/javascript" src="pluginX.js"></script> Each pluginX.js add his init() function to plugins array. And onload document body event handler loop thru plugins array and call each added function. So, we wait till document was load all scripts, and then continue. Code in global section: var plugins = []; function startOnLoad() { // Start init() of every 'registered; plugin for (var i = 0; plugins.length - 1; i++) { plugins[i](); } // Ok, all plugins initialized, can access each other. // Ex: plugin1Instance.settings.variable and etc. } In each pluginX.js an the end: plugins.push(Plugin1

Categories : Javascript

Need some plugin to use in selenium for browser compatable( for cross browser UI testing )
Selenium is a browser automation tool. It can only drive the browser by interacting with an HTML page loaded in the browser. There are currently no plugins (and as far as I'm aware nobody has any plans to make any) that you can add to Selenium to enable it to automate the OS level GUI.

Categories : Testing

Find out Button position in array of objects
evt.target will contain a reference to the clicked display object, which actually is myBtn inside the myObj class (it's the only visible graphics you can click on). There are two ways to solve this. Set this.mouseChildren = false inside the myObj() constructor. This way a click on a child display object in myObj will be "counted" as a click on myObj, and evt.target will be a reference to an instance of myObj. Instead of evt.target use evt.currentTarget. It's the instance you attached the event listener to, not the instance you clicked on (That is actually what you want in most cases).

Categories : Arrays

How to find min/max value in Array of complex objects in Javascript?
You could use Array.prototype.map() to pluck the values you require, and then pass as arguments to Math.max() or Math.min(). Math.max.apply(Math, values);

Categories : Javascript

Adding stylesheet from plugins folder to front end, inside of plugin
try removing array from wp_enqeue_script function input_admin_enqueue_scripts() { // register scripts wp_register_script('input-icon_field', $this->settings['dir'] . 'js/input.js', array('input'), $this->settings['version']); wp_register_style('input-icon_field', $this->settings['dir'] . 'css/input.css', array('input'), $this->settings['version']); // scripts wp_enqueue_script('input-icon_field'); // styles wp_enqueue_style('input-icon_field'); } and add an action to this function like so add_action('wp_enqueue_scripts', 'input_admin_enqueue_scripts');

Categories : PHP

find all objects that belong to a relationship from an Array of NSManagedObjects
Is this what you are looking for? NSArray *items = ...; // your array of Item objects NSArray *groups = [items valueForKeyPath:@"@distinctUnionOfObjects.group"]; Using "Key-Value Coding", it returns a unique list of groups that are related to the given items.

Categories : Iphone

Google Glass ADB devices doesn't find. OMAP4430 driver not installed (can't find it!)
Poking around I found a blog entry that seems to have a fix. Here's a copy and paste of Michal's tutorial: ...[F]or half of the day the ADB didn’t want to hear about the new tablet that it supposed to cooperate with. Here is how you can force it to listen: Downloading Android SDK is necessary. Also, we will need additional android USB drivers that can be installed through the SDK manager. After installing the Android SDK, go to ../sdk/extras/google/usb_driver. We will modify the android_winusb.ini file a little bit. Edit the file and find [Google.NTx86] or [Google.NTamd64] lines. Paste provided code right below those two lines. Don’t modify anything else. ; OMAP-3/4 %SingleAdbInterface% = USB_Install, USBVID_0930&PID_D101 %CompositeAdbInterface% = USB_Install, USBVID_0930&am

Categories : Android

Apple review objection Invalid directory name for Plugins folder (Child Browser Cordova)
There are few steps required to fix in XCode. Right Click on the plugins folder and select Show in Finder. Change the directory name plugins with CBPlugin. Now back to XCode and click to change name Plugins directory with CBPlugin. if these plugins files are referenced or copied elsewhere in project then delete the file from XCode (Not from CBPlugin folder) and reference it again. and finally add these .h and .m files again into Compile Sources to make this plugin available for app in XCode. Integrate ChildBrowser into Worklight App (IOS Version) hope it helps.

Categories : Cordova

plugin for com_modules is getting installed but no execution
Joomla plugins are executed depending on a particular event. If your plugin does not work it might be due to the reason that you plugin does not bind the event correctly. 1st make sure that the event is hit by the plugin.

Categories : PHP

Dynamic execution is not working when the plugin was installed
I would assume that the context classloader is different when running as a plugin. Look at the classloader hierarchy obtained in your line: ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); See if it differs in the two runtime contexts. If you can step-debug the plugin, you should be able to explore around the available objects and find a classloader among them that works for your dynamic class. If you want to use a URLClassLoader (which appears to have been abandoned in your code), you need to give it a parent, like: new URLClassLoader(urls, this.getClass().getClassLoader())

Categories : Java

Detecting if the silverlight plugin is installed but disabled
You can do this with two steps: 1st step: Detect whether Silverlight is working, e.g. host a test plugin and let it invoke a javascript method like this Silverlight HtmlPage.Window.Invoke("setSilverlightWorks", new bool[] { true }); Javascript var silverlightWorks = false; setSilverlightWorks(value) { globalSilverlightWorks = value;} 2nd step: If Silverlight does not work, you can do your IsInstalled-test. If it has been installed, it must be disabled.

Categories : Javascript

Vaadin - Altought plugin is installed I can't install add-ons
Putting a jar to WEB-INF/lib just includes this jar in the war file. You will not get a compile information. Since you do not use any build scripts: how do you build and deploy the war file? Did you add the jar to your classpath?

Categories : Java

I've installed the Admob plugin into my Phonegap project... now what?
The plugin project you linked to is using the Android AdMob SDK which is a Android native component and doesn't require you to add anything to your Phonegap/Cordova HTML/Javascript code in any way. What is happening is that you are modifying your DroidGap Activity and adding a AdMob AdView component along side the WebView which contains your HTML/Javascript. The code gets the linear layout which your WebView is held and adds in the AdView. adView = new AdView(this, AdSize.BANNER, AdMob_Ad_Unit); LinearLayout layout = super.root; layout.addView(adView); After that it is just initializing the Ad.

Categories : Javascript

Can we get list of Search Engines installed in a browser using javascript
Simple answer: No. The definition of "a plugin" is reasonably well understood, as a component that provides additional functionality to the page via its actions. It is reasonable to expose availability of individual plugins to the user interface, to enable it to make informed decisions as to the types of content being displayed. An "installed search engine" isn't well defined and differs across different browsers, and also makes no difference to the functionality of an individual page or site; it's a user option that you'd not expect a page to need to know about, in the same way as (for example) you can't get a list of the current printers. You should be able to write a plugin that JavaScript would be able to use to access this information (which would probably require access to the reg

Categories : Javascript

WebIntent plugin for Phonegap: Cannot find import org.apache.cordova.api.Plugin
I ran into exactly the same problem. The issue here is that org.apache.cordova.api.plugin is completely removed as of phonegap-2.7.0 and should be replaced with org.apache.cordova.api.CordovaPlugin. For more info on how to do this, look at http://simonmacdonald.blogspot.fr/2013/06/why-dont-my-plugins-work-in-phonegap.html. I followed these instructions and you can find the relevant part of my replacement code for WebIntent.java at https://github.com/phonegap/phonegap-plugins/issues/1047.

Categories : Android

Using JQuery/JavaScript how would I group values in an array of objects and create a new array of objects from the groups
If you're willing to use Underscore.js, this becomes pretty trivial. Assuming data is your original list of json objects, this will achieve what you're after: var groups = []; var by_grade = _.groupBy(data, function(obj) { return obj['grade'] }); _.each(by_grade, function(objs, grade) { var group = {}; group['grade'] = grade; group['ids'] = _.pluck(objs, 'id'); group['versions'] = _.pluck(objs, 'version'); // Use the following if the value is known to be // the same for all grouped objects group['platform'] = objs[0]['platform']; // And the rest... groups.push(group); }); _.groupBy() will group your objects by grade, resulting in two objects with the keys X and A, whose values are lists of objects with the corresponding grades. You can then loop ove

Categories : Javascript

Navigator.app.exitApp()/navigator.device.exitApp() crashing with error on 3.0.0 only
Without the full code it is hard to tell where the problem is :( Check if you are making some alerts or calls inside getObj("btnBack"). Did you change something iside your activity?

Categories : Cordova

Firefox & Fortinet SSL VPN Client plugin is not installed on your computer or it is not up-to-date
This a known bug related to Firefox issue. SSl vpn client plugin's would not work if you are running Firefox version higher then 20 Reference to bug id (0211153).The purposed workaround at this time would be to download stand alone sll vpn client.Please see the link given below for downloading stand alone ssl vpn or go back on a previous version (like 21) Download SslvpnClient.msi from http://dekiwiki.ties2.net/Fortinet/Fortinet_SSL_VPN_Client_Installers

Categories : Firefox

Grails 2.2.1 does not recognize the "release" plugin is installed from BuildConfig.groovy
After adding the entry in BuildConfig.groovy for release plugin, do a grails compile or just grails run-app. I normally prefer grails clean && grails compile. Once cleaned and compiled, you can check the installed plugin list grails list-plugins --installed It has been working for me. :-)

Categories : Grails



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