zxing : forFragment Cannot resolve symbol - zxing

How to fix this?
IntentIntegrator test = new IntentIntegrator.forFragment(this);
forFragment, forforSupportFragment too
Cannot resolve symbol

Your invocation is wrong. Should be
IntentIntegrator test = new IntentIntegrator().forFragment(this);
Notice the first parentheses.
or
IntentIntegrator test = IntentIntegrator.forFragment(this);
Sorry but I used the older version, so I am not sure how the invocation looks right now.

Related

How to use `dataTaskDidReceiveResponse` callback?

I'm trying to use dataTaskDidReceiveResponse of the SessionDelegateof the manager but can't find how to use it. I'm new to swift (but experienced with objective-c) and can't found the correct syntax.
I have tried something like
manager.delegate.dataTaskDidReceiveResponse = {
return NSURLSessionResponseDisposition.Allow
}((session:NSURLSession, task:NSURLSessionDataTask, response:NSURLResponse)-> NSURLSessionResponseDisposition)
and some other variants. I don't know if it's just a syntax issue or my comprehension of swift/Alamofire that is lacking.
Can anyone help me found the right path?
Thanks.
Found it:
manager.delegate.dataTaskDidReceiveResponse =
{(session:NSURLSession, dataTask:NSURLSessionDataTask, response:NSURLResponse) -> NSURLSessionResponseDisposition in
return NSURLSessionResponseDisposition.Allow
}

How to use webpack.config in karma.conf without duplication

I would like to require the webpack.config in karma.conf to reduce duplication. Somehow it is not working and some errors are being thrown.
Module not found: Error: a dependency to an entry point is not allowed
ERROR [karma]: Uncaught ReferenceError: webpackJsonp is not defined
the way webpack.config is required in karma.conf
var webpackConfig = require('./webpack.config');
webpackConfig.devtool = 'inline-source-map';
webpackConfig.plugins.push(new RewirePlugin());
The entry and output property of the webpack.config are not needed in karma.conf, that might be messing with the setup. How can I get rid of it?
I have tried: webpackConfig.entry = {}; which didn't succeed.
The problem could also be something else?
Would be very nice if you could point to an existing example or correct my mistake!

neo4jphp: Cannot instantiate abstract class Everyman\Neo4j\Transport

maybe a simple question but for me as starter with Neo4j a hurdle. I installed the neo4jphp with composer in the same directory as my application. Vendor-Subfolder has been created and the everyman/neo4j folder below is available. For a first test I used this code snippet from the examples:
spl_autoload_register(function ($className) {
$libPath = 'vendor\\';
$classFile = $className.'.php';
$classPath = $libPath.$classFile;
if (file_exists($classPath)) {
require($classPath);
}
});
require('vendor/autoload.php');
use everyman\Neo4j\Client,
everyman\Neo4j\Transport;
$client = new Client(new Transport('localhost', 7474));
print_r($client->getServerInfo());
I always stumple upon the error
Fatal error: Cannot instantiate abstract class Everyman\Neo4j\Transport
Googling brought me to a comment from Josh Adell stating
You can't instantiate Everyman\Neo4j\Transport, since it is an abstract class. You must instantiate Everyman\Neo4j\Transport\Curl or Everyman\Neo4j\Transport\Stream depending on your needs
So I thought I just need to alter the use-statements to
use everyman\Neo4j\Client,
everyman\Neo4j\Transport\Curl;
but this doesnt work, debugging shows, that the autoloader only get "Transport.php" instead of "everyman\Neo4j\Transport\Curl.php". For "Client.php" its still working ("vendor\everyman\Neo4j\Client.php") so I am guessing that the use-statement is wrong or the code is not able to handle an additional subfolder-structure.
Using
require('phar://neo4jphp.phar');
works fine but I read that this is deprecated and should be replaced by composer / autoload.
Anyone has a hint what to change or had the same problem?
Thanks for your time,
Balael
Curl is the default transport. You only need to instantiate your own Transport object if you want to use Stream instead of Curl. If you really want to instantiate your own Curl Transport, the easiest change to your existing code is to modify the use statement to be:
use everyman\Neo4j\Client,
everyman\Neo4j\Transport\Curl as Transport;
Also, you don't need to register your own autoload function if you are using the Composer package. vendor/autoload.php does that for you.
Thanks Josh, I was trying but it seems I still stuck somewhere. I am fine with using the default CURL - so I shrinked the code down to
require('vendor/autoload.php');
use everyman\Neo4j\Client;
$client = new Everyman\Neo4j\Client('localhost', 7474);
print_r($client->getServerInfo());`
The folder structure is main (here are the files and the composer.json with the content
{
"require": {
"everyman/Neo4j": "dev-master"
}
}
and in the subfolder "vendor" we have the "autoload.php" and the subfolder everyman with the related content. When I run the file I come out with
Fatal error: Class 'Everyman\Neo4j\Client' not found
which does not happen when I have the autoloadfunction. I guess I made a mistake somewehere - can you give me a hint?
Thanks a lot, B
Hmmm... I was just trying around and it seems the Transport CLASS is not needed in the use-statement and the class instantiation. This seems to work:
require('vendor/autoload.php');
use everyman\Neo4j\Client;
$client = new Client();
print_r($client->getServerInfo());
also valid for having a dedicated server/port:
$client = new Everyman\Neo4j\Client('localhost', 7474);
If you have more input I would be happy to learn more - thanks, all input & thoughts are very appreciated.
Balael

making a GET request to a webservice from the playframework 2.0

I'm trying to call a webservice from the play framework, and I think I'm doing it wrong. I have an example call to http://www.myweather2.com/developer/forecast.ashx?uac=eDKGlpcBQN&query=52.6%2C-4.4&output=xml
A snippet from what I'm trying from the playframework is the following:
val response = WS.url("http://www.myweather2.com/developer/forecast.ashx?uac=eDKGlpcBQN&query=52.6%2C-4.4&output=xml").get.get()
val body = response.getBody
When I call this, the body consists of "useraccount does not exist". When I just put this url in a browser, I get the response I'm looking for. What am I doing wrong here?
For some reason, I was getting WS from the wrong import. When I fixed the imports to import play.api.libs.ws.WS, it worked. I'm still amazed it worked halfway with the wrong import
Don't know about "useraccount does not exist" but this seems to work:
val promise = WS.url("http://www.myweather2.com/developer/forecast.ashx?uac=eDKGlpcBQN&query=52.6%2C-4.4&output=xml").get()
val body = promise.value.get.body
Edit: Removed the space.
Also make sure your editor is not inserting a \n or \r after ?
I know this is old, but I just solved this problem while trying to do the same thing - getting the same results.
GET variables must be passed with WS.url("http://...").setQueryParameter(key, value)
Example:
val promise = WS.url("http://www.myweather2.com/developer/forecast.ashx").setQueryParameter("uac", "eDKGlpcBQN").setQueryParameter("query", "52.6%2C-4.4").setQueryParameter("output", "xml").get()
Annoying, but a relatively simple fix.

Drools - ClassCastException while using RuleNameEndsWithAgendaFilter

Here is the snippet of code that I'm using :
AgendaFilter filter = (AgendaFilter) new RuleNameEndsWithAgendaFilter("Test");
// Gives a compile time error if I don't cast it.
// Run the rules
int numOfRulesFired = stateFulKnowledgeSession.fireAllRules(filter);
This spits out a runtime Exception :
java.lang.ClassCastException: org.drools.base.RuleNameEndsWithAgendaFilter cannot be cast to org.drools.runtime.rule.AgendaFilter
Please let me know If I'm missing out something here.
Thanks,
Ashwin
Looks like you have the wrong AgendaFilter. I checked the latest Drools codes and org.drools.runtime.rule.AgendaFilter no longer exists or it is renamed to something better.
Use org.drools.spi.AgendaFilter and it works.