Friday, 1 December 2017

c# - async in override context

I am working on an iOS Xamarin Project. I need to create a
share extension.



In a share extension, we can
override this method:



 public
override SLComposeSheetConfigurationItem[]
GetConfigurationItems()



I
want to call async methods in this method.
So i need to put an async keyword
like this:



 public override async
Task
GetConfigurationItems()


But
C# compiler gives me an error, because override initial method has not this signature.
So i do not know how to
do...



Thanks




**
EDIT **



Here is full
example



 public override
SLComposeSheetConfigurationItem[] GetConfigurationItems()
{
// To
add configuration options via table cells at the bottom of the sheet, return an array of
SLComposeSheetConfigurationItem here.


var result =
await service.make_computation());

....

}

php - Remove BOM from files









As
you can see from href="https://stackoverflow.com/questions/5565349/somehow-php-broke-doctype">here
I`m fighting with BOM in my files. Can you recommend me linux console tool to remove BOM
from all files in current/sub directory ?

debugging - How do I debug a PHP WSOD?

itemprop="text">

Very occasionally I get a mystifying
white-screen-of-death PHP error - nothing is displayed or logged, even with the
following
settings:




ini_set("error_reporting",E_ALL);
ini_set("display_errors",true);
ini_set("log_errors",true);
ini_set("display_startup_errors",true);
ini_set("html_errors",false);
ini_set("error_log","/var/log/php_error_log");


I
read somewhere that output buffering or memory limit errors can result in no error
output, but previously (for example) I have found a WSOD simply caused by __autoload()
looking for a missing class file.



Has anyone
found a way to get these errors visible? I hate commenting out blocks of
code.



Thanks



Answer




I had a similar problem recently and it
turned out that the software package I was using was overriding the logging settings so
that I was never seeing the logs in certain situations. Because your putting the
settings in the ini file, i'm guessing your using php.ini, there is a lot of opportunity
that something closer to where the code is run is changing the
settings.



My advice would be to put
error_reporting(E_ALL | E_STRICT); in the file that is causing
the problem and see if that improves things.



java - Proper use cases for Android ActivityManager.isUserAMonkey()?

I was looking at the new APIs introduced in Android 2.2.
While looking at the ActivityManager class I came across the following
method:





public static boolean
isUserAMonkey()



Used to determine
whether the user making this call is subject to teleportations.




Returns whether the user making this call is a
monkey.





How
and when should this be used?

Echoing session variables in php

itemprop="text">



I know that in
php I can put a variable name inside a quoted string when I use echo, but I apparently
can't do this with a session variable. Can anyone explain why?



Here is the code, with the "offending" php
commented
out:



session_start();

$test
= 100;
$_SESSION['test'] =
200;
?>



Test



/>");?>


/>");?>



echo($_SESSION['test']."
");?>


//echo("$_SESSION['test']"."
");?>







And
the output looks like
this:



100


100

200


But
if I uncomment the offending code
line:



 

echo("$_SESSION['test']"." />");?>





I
get no output and the following
error:



Parse error: syntax error,
unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING
in - on line 14


So I
can go on my merry way knowing how to do it correctly (just keep the session variable
outside of the double quotes), but I would really like to understand why this doesn't
work for session
variables.



Thanks!



Answer




Inside a double-quoted string you must
enclose a complex variable (array or object property) in
{}:




echo("{$_SESSION['test']}"." />");?>




This
isn't an issue with $_SESSION specifically, but any array
accessed by quoted keys. Note, that you can include a numerically
indexed array value with wrapping in {}, as in
"echo $array[2] is two";



php - How To Store Tamil Font in mysql database





$servername =
"localhost";
$username = "root";
$password = "";
$dbname =
"test";
$conn = mysqli_connect($servername, $username, $password,
$dbname);
$sql = "Insert into tbl (name) VALUES
('ஆன்லைனில்')";
$result = mysqli_query($conn,
$sql);



But
Its Store Db in
ஆனà¯à®²à¯ˆà®©à®¿à®²à¯



Answer




Change the column
format



ALTER `tbl` CHANGE
`column_name` `column_name` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci
NULL;

debugging - How to read and understand the java stack trace?






For example, I got a stack trace like
this:



java.lang.NullPointerException
abc.investxa.presentation.controllers.UnixServerJobController.handleRequest(UnixServerJobController.java:66)
org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)

javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)


So
what is the root cause of this exception?
From the stack trace, I found out
that there is a problem with doFilter function in the
OncePerRequestFilter class! However, when I put a break point
there and the program never stop at that break
point.



Could anyone give explanation about
this!?
And in general case, how should I use that stack case for debugging
(read from bottom to top or from top to bottom)!




Answer




Generally the exact reason for the
Exception is at the first line of your Stack Trace, and for
more information about the cause of that exception, you need to gradually move down, and
the root cause can often be found somewhere near the bottom of the stack
trace.



But in most cases, you can even get the
cause of the exception from the first few
lines..



So, in this case, your exception is at
handleRequest method, and when you move downwards, those are
the methods, which invoked your previous method (The one at above the current method in
stack trace)


php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print ...