w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
is adding methods to a element classed as extending DOM elements
It's usually considered "bad" because it can cause conflicts. As an example, at one point in time, Ext JS & prototype JS both added a defer method to the function prototype, so you could call: foo.defer(); The problem was, each library had different arguments to defer, so when you included both libraries it caused a whole lot of things to break, since both libraries would call defer() with the arguments that library was expecting. The same may happen to you, as long as you take care about which libraries you import. If it's for a small personal project it's probably fine.

Categories : Javascript

What am I doing thats causing Unknown Provider when Adding both a service and a filter or multiple services
First of all you should be doing this angular.module('testApp', []) .factory('factory1', function () { var obj = {}; obj.text = "This is a test"; return obj; }) .factory('factory2', function () { var obj = {}; obj.text = "This is another test"; return obj; }); You shouldn't create 2 modules of the same name. And I think that this angular.module('something', ['here', 'is', 'for modules', 'only']; I think what you are trying to do is this. You have 2 modules? var helpers = angular.module('helpers', []); Then you should do var app = angular.module('app', ['helpers']); Then you will have access to all factories that are attached to helpers and app Say for example you want your filters in another file there are a few ways to do it var filters = angula

Categories : Javascript

Dual purpose of Android ContentProvider: 1. Search provider and 2. List content provider
The ContentProvider you're using is generic and can be used for a search feature. You may think at first that maybe you should write a ContentProvider that specifically works for search but: You will have to duplicate a lot of code. ContentProviders are not designed to be specific, they just abstract the access to data. Your "Search Content Provider" will be used to make queries and you already have that with the Content Provider you have. The ContentProvider doesn't need to be specific to search. On the other hand, your Adpater should be specific.

Categories : Android

No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'
I just got into the same problem and it looks like EntityFramework although installed from NuGet Package Manager was not correctly installed in the project. I managed to fix it by running the following command on Package Manager Console: PM> Install-Package EntityFramework

Categories : Entity Framework

Get ExtraData from MVC5 framework OAuth/OWin identity provider with external auth provider
So unfortunately this is not super straightforward, one way you can do this is to hook the GoogleProvider Authenticated event and add a custom claim to the Claims Identity with the avatar: public class MyGoogleProvider : GoogleAuthenticationProvider { public override Task Authenticated(GoogleAuthenticatedContext context) { context.Identity.AddClaim(new Claim("avatarClaim", "<fetch avatar url here>")); return base.Authenticated(context); } } app.UseGoogleAuthentication(new GoogleAuthenticationOptions() { Provider = new MyGoogleProvider() }); Then inside of your AccountController, when the external identity is extracted, you can take this avatar claim and store it into your user object for use later.

Categories : Asp Net Mvc

trying to get location from "network" provider fails on some devices despite the provider being enabled
Similar issues relating to the Android Network Provider have been reported before on Stack Overflow which you can find here. The consensus from those who have experienced this problem state that there are two possible workarounds, rebooting the device when the issue becomes apparent, or by utilizing the Google Play Service API for retrieving location data as there appears to be an issue with the reliability of the Location Manager with Android 4.0 or newer.

Categories : Java

Ask the user to enable GPS or network provider...illegalargumentexception provider==null
I found the solution I hope that can help the others this is the changes that I made if(locationManager==null) locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); try{ gps_enabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); }catch(Exception ex){} try{ network_enabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); }catch(Exception ex){} if(!gps_enabled && !network_enabled){ Builder dialog = new AlertDialog.Builder(this); dialog.setMessage("Activez l'un des ressources de localisation" ); dialog.setPositiveButton("Setting", new DialogInterface.OnClickListene

Categories : Android

Failed to find provider info for
Try using fully qualified path in android:authorities thereby replacing de.somename.provider with de.somename.provider.hvkContentProvider in so that it becomes as follows. <provider android:authorities="de.somename.provider.hvkContentProvider" android:enabled="true" android:multiprocess="true" android:name=".hvkContentProvider" android:exported="true" ></provider> You can refer this

Categories : Android

how to keep a part of a cookbook from executing
You don't have to put any conditionals or take any measures when your EBS has been already created, mounted, formatted, etc. The Elasticsearch Chef cookbook eg. formats the device only_if it isn't already formatted, see https://github.com/elasticsearch/cookbook-elasticsearch/blob/master/recipes/data.rb#L11 Provided you keep the EBS volume attached to your instance, Chef doesn't touch it -- or definitely shouldn't touch it. If you'd see any other behaviour, please submit an issue at Github.

Categories : Amazon

Recipe from Python Cookbook
Your issue is with indentation. You would have to move the following block one level to the left for them to be recognized as class methods. def __iter__(self): for v, k in self._rating: yield k iterkeys = __iter__ def keys(self): return list(self) #the three ratings-related methods def rating(self, key): item = self[key], key i = bisect_left(self._rating, item) if item == self._rating[i]: return i raise LookUpError, "item not found in rating" def getValueByRating(self, rating): return self._rating[rating][0] def getKeyByRating(self, rating): return self._rating[rating][1] def _test( ): ''' we use doctest to test this module, which must be named

Categories : Python

.Net 4.5 EventSource ETW provider not showing up in provider list
The EventSource implementation prevents you from specifying the channel even if you do modify the manifest. When writing an event to ETW you pass a descriptor block where in the channel id is specified. Unfortunately EventSource does not offer a way to set this through an attribute or otherwise and is always setting this to zero, meaning no channel is used. EventSource is behaving a bit differently from a normal ETW providers as it does not expose its manifest through a win32 resource but rather sends a "known" ETW event with the manifest as its payload. This is why perfmon is the only ETW enabled tool that recognizes* events send from .NET 4.5 EventSource. *You can always receive events using perfmon or other tools like it but they wont be able to decode the payload e.g. parameters pass

Categories : Dotnet

List cookbook dynamically without sub-shell
You need to look outside of knife for this one. Knife delegates to Chef::CookbookLoader (lower down the stack) and therefore you can just use the cookbook loader directly: require 'chef/config' require 'chef/cookbook_loader' Chef::Config.from_file(path) cookbooks = Chef::CookbookLoader.new(Chef::Config.cookbook_path).map(&:cookbook_name) For example, knife-spork uses this pattern to load the cookbooks. Note that you will get the actual cookbook objects, not just their names. If you want something a little more lightweight, you could just iterate over each cookbook_path and look for a metadata.rb: # https://gist.github.com/fnichol/4343327 class MetadataChopper < Hash def self.extract(metadata_file) mc = new(File.expand_path(metadata_file)) [mc[:name], mc[:version]]

Categories : Ruby

Deploy java app in Chef cookbook
Refer to the application_java cookbook. you need to add these in the metadata.rb of your saymatrix cookbook: depends 'application' depends 'application_java' And add necessary details at least including repository and deployment target like tomcat. You can find the section Usage of the example here: application_java

Categories : Ruby

Why can't chefspec find the chef_handler cookbook?
I ran into the same problem recently. Because chefspec aims to be fast and only simulate chef runs, it doesn't clone cookbooks from the chef server. It requires that the chef_handler cookbook needs to be local. By default, it looks for it at the same level as the cookbook you are testing. e.g. ./test_cookbook ./chef_handler

Categories : Unit Testing

OpsWorks - what to include in custom cookbook
OpsWorks, at the moment, does not support a single cookbook directory style. It works to build the repository like this: delayed_job recipes deploy.rb undeploy.rb s3cmd attributes default.rb recipes setup.rb configure.rb templates default s3cfg.erb whenever recipes deploy.rb undeploy.rb Then under stack settings, under custom cookbooks, one can add e.g. whenever::deploy under deploy. For default.rb recipes, once can just add e.g. sphinx instead of sphinx::default. And after changing and pushing to the repositiory, one has to run the update_custom_cookbooks command from the deployments page.

Categories : Ruby On Rails

Pyramid cookbook WSGI example out of date?
I had the hydra.wsgi script in the wrong directory. It needed to be one up from the path it was in: should be here: /home/rsadmin/modwsgi/env/hydra.wsgi The example in the cookbook is correct.

Categories : Python

Default attribute is nil for Chef Apache2 cookbook
Apparently, in Chef 11, cookbooks need a metadata.rb in which dependencies are specified. These dependencies are used to autoload cookbooks. Adding depends "apache2" to the metadata.rb file solves the above problem.

Categories : Apache

Lift Cookbook Avoiding CSS and JavaScript Caching
You need to inject the random value as a GET value not a path. Changing the path would result in not finding the file (unless you are dynamically writing the css file every time to the random location). This can be done inline with javascript. <script> document.write("<link rel="stylesheet"type="text/css" href="/cached/css/standard.css?" + Math.random() + "" />"); </script>

Categories : CSS

Chef cookbook to create MongoDB users
I don't believe there are any public cookbooks that handle that currently. You would probably want to build on the following two cookbooks: https://github.com/edelight/chef-mongodb Already has a library that connects to the Mongo server. You'd probably want to use it as an example for how to interact with mongo within a chef library https://github.com/opscode-cookbooks/database The master recipe is designed for creating databases and users from a databag (adapting for encryption would be trivial) There are good library providers for interacting with several types of databases. You would just use the connection examples from the first cookbook to reimplement those providers for mongo.

Categories : Mongodb

chef application_ruby cookbook: unicorn is not restarted
The model with the application cookbook is that it will look for a "restart_command" in each of the registered resources and trigger these between the before_restart and after_restart callbacks. In the previous releases of the application_ruby this would default to "touch tmp/restart.txt" which is the default for passenger. In the current release there is no default restart_command. I suggest adding a suitable command for unicorn: application 'railsapp' do ... restart_command "service unicorn restart" ... end Depending on the version of the application_ruby cookbook, you may need to put this under the "rails" resource. We use these cookbooks extensively at Ninefold in our rails app deployment service and generally they work very well. We find the actual callbacks very useful t

Categories : Ruby On Rails

Trouble running Contoso Cookbook Samples with no changes made
It seems there's two problems. The first one (parameter is incorrect) is preventing the application from being deployed. To fix it, remove the "%2c" from the folder name (the default folder name is "Windows Phone 8 JumpStart Contoso Cookbook Step 1%2c Initial Layout", it seems to make the deploy process bug somehow). Then delete the ContosoCookbook.suo and ContosoCookbook.v11.suo files located in the C# subfolder. The second error doesn't prevent the application from working, but crashes the designer. In the attributes of the grid (MainPage.xaml, line 38) : <Grid x:Name="LayoutRoot" Background="Transparent" d:DataContext="{d:DesignData /SampleData/RecipeDataSourceSampleData.xaml, Instance={x:Null}}"> Remove the , Instance={x:Null} part and it'll work just fine: <Grid

Categories : Windows

Got "undefined method `[]' for nil:NilClass" installing java Cookbook
I think the problem is that node['java'] is evaluating to nil. One possible solution is to define the attribute node['java']['install_flavor'] either in a cookbook or in your Node definition or a relevant Role definition. But it looks like a bug in the cookbook, because the documentation says a default should apply to the install_flavor attribute.

Categories : Java

Extending DOMNode, afterwards extending DOMDocument, that inherits extended DOMNode
Fun multiple inheritance is fun. After a bit more playing around, I have concluded it simply isn't possible to do this in a meaningful way using inheritance alone. The only practical way to do this is by decoration (i.e. wrapping the native classes in your own classes without extending, and using magic methods to access the properties of the inner object). Obviously this is not ideal, it very quickly starts to get messy and you lose obvious benefits that true inheritance provides, things like playing nice with instanceof, is_a() et al. The root of the problem is that because registerNodeClass() (see original answer below) is an instance method, it can only be called on an instance of a DOMDocument - and by the time the instance has been created, the inheritance has already been determine

Categories : PHP

Chef: mysql cookbook does not know root's password after I change it using mysqladmin
You need to update the node's attribute to reflect the new password. One way to do that would be to use Knife and the knife-set-attribute plugin. knife set_attribute node mysql.server_root_password yournewpassword Other ways to set attributes can be explored in the Chef attribute docs.

Categories : Mysql

Problems with IIS and Custom Membership Provider + Custom Role Provider
I have had the similar issue. After adding machineKey to web.config everything works all right. <system.web> <machineKey validationKey="2E417D4AC04F20FA6CE1CF1EFE23FBF1695BF6981B605B1B8628D2182C43D0B10E48C4A83FDCE0D1D6300095D9EE1B8746A37E2C3256554405983DCAA7622875" decryptionKey="FA6D35C22BF7E5E9E4438052B924CCC017521137C5EB017D07C7038B80C5F726" validation="SHA1" decryption="AES" /> </system.web>

Categories : Asp Net Mvc

How to map identity provider claim value to/from identity provider registered in Azure ACS?
I tried to do this last week and couldn't find a way to match the value in the claim to the value in IdentityProvider.js. I landed up looking for specific values. The only thing I can suggest is some resource/code that understands the mapping. I was just looking for a specific one and landed up doing something like this: return (HttpContext.User.Identity as System.Security.Claims.ClaimsIdentity).Claims .First(x => x.Type == "http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider").Value .Contains("Google") I searched high and low for the data, but couldn't find it. If you do, please submit an answer, I would also like to know

Categories : Azure

The token provider was unable to provide a security token . Token provider returned message: ACS50009: SWT token is invalid
Linesh, The above API is only applicable for use with the ACS service identity and symmetric key. Based on the error it is likely a change is needed to the following line of code: ServiceBusEnvironment.CreateServiceUri("https", <myServiceBusNameSpace>, string.Empty); Can you replace "https" with "sb" and give it a try?

Categories : Misc

Symfony Security / Custom User Provider : How to get the login password within the custom User Provider?
@Pazi is correct in that building your own custom authentication provider will work. However, it's not an easy task. An alternative approach is to override DaoAuthenticationProvider and have it pass the password to the loadUser function. security_listeners.xml: <parameter key="security.authentication.provider.dao.class"> SymfonyComponentSecurityCoreAuthenticationProviderDaoAuthenticationProvider </parameter> Bit of a hack perhaps but it saves a good deal of work.

Categories : Authentication

Wrapped service
i think what you're looking for is like a 'federated service' or a 'business delegate' pattern. that is, one WSDL showing all the methods for the other two WSDL's combined. one way of doing this is using Spring Integration. with Spring Integration you could expose your 'consolidated' WSDL and then route the various methods to the specific correct actual endpoints. have a look at this in the Spring Integration documents about exposing a webservice and then subsequently routing and invoking others.

Categories : Java

Wrapped implementation of a map
What's the point of wrapping the map with Collections.synchronizedCollection(map), if then you have to synchronize the code while iterating? To make individual operations thread-safe. (Personally I think it's a bad idea in general, but that's a different matter. It's not pointless, just limited in usefulness.) After having wrapped it, should not be thread safe? For any individual operation, yes. But iteration involves many steps - and while each of those individual steps will be synchronized, the collection can be modified between steps, invalidating the iterator. Don't forget that your loop is expanded to something like: for (Iterator<Type> iterator = c.iterator(); iterator.hasNext(); ) { Type e = iterator.next(); ... } If you need iteration to be thread-safe,

Categories : Java

C# json Webservice is wrapped in XML
The deleted answer suggested first to use ScriptMethod or ScriptService attributes (i.e. [ScriptMethod(UseHttpGet = false, ResponseFormat=ResponseFormat.Json)]). That is the correct approach to return json from a web service in .NET. See here for more info: How to let an ASMX file output JSON.

Categories : C#

XML wrapped collection not deserializing
You are defining an array, you should use the [XmlArray] attribute :) [Serializable] public class Cost { [XmlElement("Code")] public string Code { get; set; } [XmlElement("Info")] public string Info { get; set; } } [Serializable] public class PurchaseItem { [XmlElement("Name")] public string Name { get; set; } // XmlArray of Cost [XmlArray(ElementName = "Costs")] public Cost[] Costs { get; set; } } public class Tests { [Test] public void Test() { var serializer = new XmlSerializer(typeof (PurchaseItem)); var xml = @"<PurchaseItem> <Name>Item 1</Name> <Costs> <Cost> <Code>A</C

Categories : C#

Removing Wrapped Words
delete your media query and add a bit of ccs to .roombuttons like so: http://jsfiddle.net/P5DEq/5/ .roombuttons { -webkit-transition:width .2s; background:#FFF; border:none; border-radius:10px; cursor:pointer; display:block; font-family:inherit; font-weight:inherit; margin:auto; transition:width .2s; width:60%; overflow: hidden; padding:0 25px; font-size:3em; line-height: 2em; height: 2em; } Since the text's container's height is equal to the line height, and overflow is hidden, it will show the first line of text, and the text that wraps to the next line(s) will be hidden.

Categories : HTML

How do I write .next() when wrapped in an extra div?
when you wrap it you need to find the next() of the wrapper element (you can use .parent() to get the wrapper) clone.appendTo(jQuery(el).parent().next().find('.sub')); Demo: Fiddle

Categories : Jquery

How to set a background for wrapped text?
Wrap your text in <span></span>. Or add display: inline-block with<div></div> Demo: http://jsfiddle.net/uNjT6/1/

Categories : CSS

Add a div below inline-block wrapped row
Here's a different alternative: http://jsfiddle.net/SYJaj/7/ There is no need to have the "banner" be absolutely positioned. Just give it display:inline-block; like everything else, and calculate which block it needs to follow with the offset method in jQuery. The key is in this code: function placeAfter($block) { $block.after($('#content')); } $('.wrapblock').click(function() { $('#content').css('display','inline-block'); var top = $(this).offset().top; var $blocks = $(this).nextAll('.wrapblock'); if ($blocks.length == 0) { placeAfter($(this)); return false; } $blocks.each(function(i, j) { if($(this).offset().top != top) { placeAfter($(this).prev('.wrapblock')); return false; } else if ((i + 1) == $bl

Categories : Jquery

trying to only show text that is not wrapped
Add white-space: nowrap to the css .temp-image .list .list.caption { background-image:url(bar.png); font-size: 16px; font-weight: bold; height: 30px; left: 1px; line-height: 16px; overflow: hidden; text-align: center; top: 190px; width: 256px; white-space: nowrap; /* Prevents Wrapping */ }

Categories : CSS

php json_decode with data wrapped by [ ]
This is not valid json together: [{"userid":"96679","userinfor":"xxxxxxxxx","userlocation":"CA"}] [{"userid":"153795","userinfor":"xxxxxxxxx","userlocation":"CA"}] [{"userid":"131878","userinfor":"xxxxxxxxx","userlocation":"CA"}] While, this part is valid: [{"userid":"96679","userinfor":"xxxxxxxxx","userlocation":"CA"}] or any one of them separately $json = '[{"userid":"96679","userinfor":"xxxxxxxxx","userlocation":"CA"}]'; print_r(json_decode($json, true)); Output: Array ( [0] => Array ( [userid] => 96679 [userinfor] => xxxxxxxxx [userlocation] => CA ) ) The valid format for all data is like this: [ { "userid": "96679", "userinfor": "xxxxxxxxx", "userlocation": "CA" }, {

Categories : PHP

Attempted to wrap sendRequest which is already wrapped
Ok, so after spending 2 hours on this problem last Friday with no luck, I figured it out twenty min after posting this question. Adding var fn.sendRequest = function(module, fnName, args) {}; to the beforeEach function fixed all the failing tests.

Categories : Unit Testing

Making all arguments available for wrapped function in R
You can provide default values for arguments: wrapper.function = function(x, w, m, asym.bin=NULL, ord='podani') { gdis <- gowdis(x, w, asym.bin, ord) gdis2 <- gdis * m gdis2 } Alternative way of solving your problem could be (like @Jilber proposed in the comments) using ellipsis. wrapper.function = function(x, w, m, ...) { gdis <- gowdis(x, w, m, ...) gdis2 <- gdis * m gids2 }

Categories : R



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