text:
Q: Simplify Swift data struct Any suggestion on how to simplify this data struct? The data will be saved as a dictionary on the user's drive and when I read the data from the drive I have to convert them back to Member for easy accessing the properties.
I would like to have it typesafe.
struct Member {
    var id: Int
    var firstname: String
    var lastname: String
    var address: String?
    var zipCode: Int?
    var city: String?

    enum Value: String {
        case id = "id"
        case firstname = "firstname"
        case lastname = "lastname"
        case address = "address"
        case zipCode = "zipCode"
        case city = "city"
    }

    var member: [String:Any] {
        return [
            Value.id.rawValue:Int(),
            Value.firstname.rawValue:firstname,
            Value.lastname.rawValue:lastname,
            Value.address.rawValue:address ?? String(),
            Value.zipCode.rawValue:zipCode ?? Int(),
            Value.city.rawValue:city ?? String()
        ]
    }
}

func memberToDic(member: Member) -> [String:Any] {
    return [
        Member.Value.firstname.rawValue:member.firstname,
        Member.Value.lastname.rawValue:member.lastname,
        Member.Value.address.rawValue:member.address ?? String(),
        Member.Value.zipCode.rawValue:member.zipCode ?? Int(),
        Member.Value.city.rawValue:member.city ?? String()
    ]
}

func dicToMember(dic: [String:Any]) -> Member {
    return Member(
        id: dic[Member.Value.id.rawValue] as! Int,
        firstname: dic[Member.Value.firstname.rawValue] as! String,
        lastname: dic[Member.Value.lastname.rawValue] as! String,
        address: dic[Member.Value.address.rawValue] as? String,
        zipCode: dic[Member.Value.zipCode.rawValue] as? Int,
        city: dic[Member.Value.city.rawValue] as? String
    )
}

A: Almost certainly, this is the correct implementation:
struct Member: Codable {
    var id: Int
    var firstName: String // "first name" is two words, so capitalize "name"
    var lastName: String
    var address: String   // "No address" should be empty, not nil
    var zipCode: String   // ZIP codes are not integers
    var city: String      // "No city" should be empty, not nil
}

In order to save this as a plist, use PropertyListEncoder:
let data = try PropertyListEncoder().encode(member)

To read it, use PropertyListDecoder.
Codable automatically creates key mappings for your properties, so there's no need for Value.
You should strongly avoid creating or consuming [String: Any] dictionaries. These exist mostly due to Objective-C interfaces that could not generate strong types.
If address, zipCode, and city all should be set together, or not set together, then you should collect them into a single struct:
struct Address: Codable {
    var streetAddress: String
    var zipCode: String
    var city: String
}

struct Member: Codable {
    var id: Int
    var firstName: String // "first name" is two words, so capitalize "name"
    var lastName: String
    var address: Address?
}

In this case, and Optional makes sense because "empty" is not the same thing as "missing."


text:
Q: What is the difference between tint and solid in a shape? I saw this item in xml layout:
    <shape
        android:shape="rectangle"
        android:tint="#ffff00">
        <corners android:radius="8dp" />
        <size android:height="4dp" />
        <solid android:color="#ffff00" />
    </shape>

So tint and solid are setting the same color. When I change solid to another color, it doesn't have any visible effect, so solid seems to be overridden by tint anyway.
In my understanding, solid defines the fill color of the shape. While tint colorizes the whole item in the given color, including for example the stroke color.
What could be the purpose of defining the same color in both items?

A: You are right about that tint will overwrite solid.
Usually I would use solid when define a shape or drawable and use tint to customise it when necessary.
For example, you define your logo in its usual color. In certain screen, you want the logo to fit into the theme of that screen, you can make use of tint.
Note that, tint works not only with solid, you can even tint your image drawable.

A: of course tint will overwrite solid.
when you use a drawable that contains transparent parts, tint just colorizes parts that have color not transparent and solid colorize all the drawable whether its has color or not

A: Its depend on the usage, that how you are using it. I want to share one example for you.
Let suppose you have one shape or drawable file and you want to use that in 10 different place in different color. so you don't need to add 10 different drawable files in folder, just you can use the same drawable file with android:tint="your_desired_color" properties.
In this place tint will be useful, its just like a filter to change the color of that shape or drawables.
Don't be confuse with this.

redpajama_set_name: RedPajamaStackExchange


text:
Q: When is it possible to set each term in a matrix equation equal to the zero vector simultaneously? Let $A,B,C \in M_{3 \times 3}(\mathbb{R})$ be fixed and let $x,y,z \in M_{3 \times 1}(\mathbb{R})$ be any three column vectors. Consider the matrix equation given by
$Ax + By + Cz = 0_{3 \times 1}$
All multiplication of matrices is the usual row-column definition. I am interested in when the following three relations simultaneously hold:
$Ax = 0_{3 \times 1}$
$By = 0_{3 \times 1}$
$Cz = 0_{3 \times 1}$
That is, what property or properties must $A$,$B$, and $C$ possess in order to make this so? I thought about this for a while, but haven't really come to a very good conclusion yet. Any ideas?


text:
Q: Strategy to structure a search index in a relational database I am interested in suggestions for building an efficient and robust structure for indexing products in a new database I am building (i'm using MySql)
When a product is entered through the form there are three parts I am interested in indexing for searching purposes.

*

*The product title

*The product description

*Tags

The most important is title, followed by tags, followed by the description.
I was thinking of using the following structure
CREATE TABLE `searchindex` (
`id` INT NOT NULL ,
`word` VARCHAR( 255 ) NOT NULL ,
`weighting` INT NOT NULL ,
`product_id` INT NOT NULL ,
PRIMARY KEY (  `id` )
)

Then each time a product is created I would split apart the title, description and tags (removing common words) and award them a weighting.
Then it is trivial to select out the words and corresponding products and order them by weighting.
Is there a better way to do this? I would be worried that this strategy would slow down over time and as the database filled up.

A: For title you might just index the first couple of characters to get a smaller subset when matching, but for the description you should really consider a fulltext index. This can automatically weight and find the best matches


text:
Q: Which version of WiredTiger is being used by MongoDB? Is it possible to find out which version of WiredTiger I am using with MongoDB?
I tried using:-
db.serverStatus().wiredTiger

but I can't find any version info in there.
I installed MongoDB (v3.0.4) out of the box, so I'm trying to figure out what version of WiredTiger it ships with, and whether or not I can use a newer version of WiredTiger instead.

A: The source for 3.0.4 suggests that you are using WiredTiger 2.5.3:
https://github.com/mongodb/mongo/tree/r3.0.4/src/third_party/wiredtiger

WiredTiger 2.5.3: (March 26, 2015)
This is version 2.5.3 of WiredTiger.

You can, of course, recompile and attempt to use another version, but you may find it easier to take a look at a dev branch instead and try out newer versions that way, for example:
https://github.com/mongodb/mongo/tree/r3.1.6/src/third_party/wiredtiger
MongoDB 3.1.6 seems to be using WiredTiger 2.6.2:

WiredTiger 2.6.2: (June  4, 2015)
This is version 2.6.2 of WiredTiger.


text:
Q: Explanation of pysftp.Connection.walktree() parameters I have just started using Python's pysftp and I am confused as how to call it's walktree function.
I found some code (found at http://pydoc.net/Python/pysftp/0.2.8/pysftp/) that helped me better understand what form my parameters should take
def walktree(self, remotepath, fcallback, dcallback, ucallback, recurse=True):
    '''recursively descend, depth first, the directory tree rooted at
    remotepath, calling discreet callback functions for each regular file,
    directory and unknown file type.

    :param str remotepath:
        root of remote directory to descend, use '.' to start at
        :attr:`.pwd`
    :param callable fcallback:
        callback function to invoke for a regular file.
        (form: ``func(str)``)
    :param callable dcallback:
        callback function to invoke for a directory. (form: ``func(str)``)
    :param callable ucallback:
        callback function to invoke for an unknown file type.
        (form: ``func(str)``)
    :param bool recurse: *Default: True* - should it recurse

    :returns: None

But I am still confused on what exactly is meant by "callback function to invoke for a regular file, for a directory, and for an unknown file type.
I have also looked through the official documentation:      https://media.readthedocs.org/pdf/pysftp/latest/pysftp.pdf
but all it tells me about the walktree() function is that:

Is a powerful method that can recursively (default) walk a remote
  directory structure  and calls a user-supplied callback functions for
  each file, directory or unknown entity it encounters.   It is used in
  the get_x methods of pysftp and can be used with great effect to do
  your own bidding.   Each callback is supplied the pathname of the
  entity. (form: func(str))

which I felt did not give me much information on how to call it properly.
If someone could provide an example of calling this function correctly and an explanation of why you are passing your chosen arguments, it would be greatly appreciated!

A: Here is the sample code you are looking for.
import pysftp

file_names = []
dir_names = []
un_name = []

def store_files_name(fname):
    file_names.append(fname)

def store_dir_name(dirname):
    dir_names.append(dirname)

def store_other_file_types(name):
    un_name.append(name)

cnopts = pysftp.CnOpts()
cnopts.hostkeys = None
sftp = pysftp.Connection(host="Your_ftp_server_name", username="ftp_username", private_key="location_of_privatekey", cnopts=cnopts)
sftp.walktree("/location_name/",store_files_name,store_dir_name,store_other_file_types,recurse=True)
print file_names,dir_names,un_name

file names, directory names and unknown file types are stored in lists file_names, dir_names and un_name respectively.

A: Learn what is the callback, if that's the actual problem.
To all three arguments of walktree, you need to pass a reference to a function that takes a single string argument. As walktree recurses the directory structure, it "calls back" one of those functions for every file-system object it finds, passing path to the object as the (string) argument.
Typically, you will need some state (context) for the function implementation. I.e. a reference to a container to store the paths found. To avoid using global variables, the pysftp sample, you referred to in your question, passes in methods of helper class instead of plain functions, keeping the state (the flist, dlist and ulist containers) in the object instance.


text:
Q: How to make a rounded corner image in Java I want to make a image with rounded corners. A image will come from input and I will make it rounded corner then save it. I use pure java. How can I do that? I need a function like
public void makeRoundedCorner(Image image, File outputFile){
.....
}

Edit : Added an image for information.

A: I suggest this method that takes an image and produces an image and keeps the image IO outside:
Edit: I finally managed to make Java2D soft-clip the graphics with the help of Java 2D Trickery: Soft Clipping by Chris Campbell. Sadly, this isn't something Java2D supports out of the box with some RenderhingHint.
public static BufferedImage makeRoundedCorner(BufferedImage image, int cornerRadius) {
    int w = image.getWidth();
    int h = image.getHeight();
    BufferedImage output = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);

    Graphics2D g2 = output.createGraphics();

    // This is what we want, but it only does hard-clipping, i.e. aliasing
    // g2.setClip(new RoundRectangle2D ...)

    // so instead fake soft-clipping by first drawing the desired clip shape
    // in fully opaque white with antialiasing enabled...
    g2.setComposite(AlphaComposite.Src);
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setColor(Color.WHITE);
    g2.fill(new RoundRectangle2D.Float(0, 0, w, h, cornerRadius, cornerRadius));

    // ... then compositing the image on top,
    // using the white shape from above as alpha source
    g2.setComposite(AlphaComposite.SrcAtop);
    g2.drawImage(image, 0, 0, null);

    g2.dispose();

    return output;
}

Here's a test driver:
public static void main(String[] args) throws IOException {
    BufferedImage icon = ImageIO.read(new File("icon.png"));
    BufferedImage rounded = makeRoundedCorner(icon, 20);
    ImageIO.write(rounded, "png", new File("icon.rounded.png"));
}

This it what the input/output of the above method looks like:
Input:

Ugly, jagged output with setClip():

Nice, smooth output with composite trick:

Close up of the corners on gray background (setClip() obviously left, composite right):

A: I am writing a follow up to Philipp Reichart's answer.
the answer of  as an answer.
To remove the white background (seems to be black in the pictures), change g2.setComposite(AlphaComposite.SrcAtop);
to g2.setComposite(AlphaComposite.SrcIn);
This was a big problem for me because I have different images with transparency that I don't want to lose.
My original image:

If I use g2.setComposite(AlphaComposite.SrcAtop);:

When I use g2.setComposite(AlphaComposite.SrcIn); the background is transparent.

A: I found another way using TexturePaint:
                ImageObserver obs = ...;
                int w = img.getWidth(obs);
                int h = img.getHeight(obs);

                // any shape can be used
                Shape clipShape = new RoundRectangle2D.Double(0, 0, w, h, 20, 20);

                // create a BufferedImage with transparency
                BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
                Graphics2D bg = bi.createGraphics();

                // make BufferedImage fully transparent
                bg.setComposite(AlphaComposite.Clear);
                bg.fillRect(0, 0, w, h);
                bg.setComposite(AlphaComposite.SrcOver);

                // copy/paint the actual image into the BufferedImage
                bg.drawImage(img, 0, 0, w, h, obs);

                // set the image to be used as TexturePaint on the target Graphics
                g.setPaint(new TexturePaint(bi, new Rectangle2D.Float(0, 0, w, h)));

                // activate AntiAliasing
                g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

                // translate the origin to where you want to paint the image
                g.translate(x, y);

                // draw the Image
                g.fill(clipShape);

                // reset paint
                g.setPaint(null);

This code can be simplified if you have a non-animated image, by creating the BufferedImage only once and keeping it for each paint.
If your image is animated though you have to recreate the BufferedImage on each paint. (Or at least i have not found a better solution for this yet.)


text:
Q: Move file from one folder to another in sharepoint using Python I am trying to move the file from one folder to another in SharePoint using library office365.
below is the code that I have written -
from office365.runtime.auth.client_credential import ClientCredential
from office365.runtime.client_request_exception import ClientRequestException
from office365.sharepoint.client_context import ClientContext
from office365.runtime.auth.authentication_context import AuthenticationContext
from office365.sharepoint.files.file import File

ctx_auth = AuthenticationContext(url_shrpt)
if ctx_auth.acquire_token_for_user(username_shrpt,password_shrpt):
  ctx = ClientContext(url_shrpt, ctx_auth)
  file = ctx.web.get_file_by_server_relative_url(old_url)
  ctx.load(file)
  ctx.execute_query()
  File.moveto(ctx, new_relative_url=new_url, flag=1)

I am getting the error -
"'ClientContext' object has no attribute 'context'"
AttributeError                            Traceback (most recent call last)
<command-527297> in <module>
      6   ctx.load(file)
      7   ctx.execute_query()
----> 8   File.copyto(ctx, new_relative_url=new_url, overwrite=True)

/databricks/python/lib/python3.8/site-packages/office365/sharepoint/files/file.py in copyto(self, new_relative_url, overwrite)
    124         :type overwrite: bool
    125         """
--> 126         qry = ServiceOperationQuery(self,
    127                                     "CopyTo",
    128                                     {

/databricks/python/lib/python3.8/site-packages/office365/runtime/queries/service_operation_query.py in __init__(self, binding_type, method_name, method_params, parameter_type, parameter_name, return_type, is_static)
     16         :type method_name: str or None
     17         """
---> 18         super(ServiceOperationQuery, self).__init__(binding_type.context,
     19                                                     binding_type,
     20                                                     parameter_type,

AttributeError: 'ClientContext' object has no attribute 'context'

Can anyone help me with this error

A: Maybe you can try this:
from office365.runtime.auth.client_credential import ClientCredential
from office365.runtime.client_request_exception import ClientRequestException
from office365.sharepoint.client_context import ClientContext
from office365.runtime.auth.authentication_context import AuthenticationContext
from office365.sharepoint.files.file import File

ctx_auth = AuthenticationContext(url_shrpt)
if ctx_auth.acquire_token_for_user(username_shrpt,password_shrpt):
  ctx = ClientContext(url_shrpt, ctx_auth)
  source_file = ctx.web.get_file_by_server_relative_url(old_url)
  source_file.moveto(new_relative_url=new_url, flag=1)
  ctx.execute_query()

Thanks.
Reference: https://github.com/vgrem/Office365-REST-Python-Client/issues/157


text:
Q: set and group by in the same query Can I combine a 'set' with a 'group by'?
Column1  Column2  Column3  Column4
30       15        3 Sep
20       2         2 Sep

After updating:
Column1   Column2   Column3    Column4
30        15        3 Sep      30/50+15/17
20        2         2 Sep      20/50+2/17

I'm grouping the data by the entire September to calculate the sums: 50 and 17
And use this to update Column4 in the same query.
Thanks!

A: As a select, you can do this in SQL Server using the window functions:
select column1, column2, column3,
       (column1/(sum(1.0*column1) over ()) +
        column2/(sum(1.0*column2) over ()))
from t

I included the "1.0*", because SQL Server does integer division.  You probably want floating point division for this.


text:
Q: Multiple Backgrounds on Body Not sure if this is possible but can i put one transparent image over the standard background image on the website.
    body {
  font-family: Arial, Helvetica, sans-serif;
  text-align: center;
  background: #133e6f url({{ site_img_dir }}/body-bg.gif) repeat-x;
}

This is the normal background image. I want to add another transparent .png over this one which is a non-repeat image. How can this be done ?
Thanks

A: To have Multiple Backgrounds on a Single Element:
.myclass {
  background: background1, background2, ..., backgroundN;
}

More complex example:
3 backgrounds with other background properties:
Note1: You can define background-repeat and background-position (and others like background-size) properties for each of the 3 backgrounds individually.
.multi_bg_example {
  /* Background 1, an image   */ background: url(img1),
  /* Background 2, a gradient */ linear-gradient(to right, rgba(255, 255, 255, 0),  rgba(255, 255, 255, 1)),
  /* Background 3, an image   */ url(img3);
  background-repeat: no-repeat, no-repeat, repeat;
  background-position: bottom right, left, right;
}

Note2: The first one appears on top, second one below it, etc...
Source: Mozilla Developer Network, CSS multiple backgrounds:

http://developer.mozilla.org/en-US/docs/CSS/Tutorials/Using_CSS_multiple_backgrounds

A: Just add another url after a coma and it should work.
background: url('/images/body-bg.gif'), url('/images/anotherImage.png');
background-repeat: repeat-x;

You can find more info here.
UPDATE
You can find working example here, on jsfiddle. Sorry for the images, random gif and png from google.


text:
Q: Why does my Azure Function App, which generates PDF files from data, time out? I've created an Azure Function App in Visual Studio 2019 on .NET Core 2.1.  My Function takes a set of data (less than 1 MB) and generates a PDF report of the data based on an HTML template (using the NuGet package OpenHtmlToPdf).
The function is triggered by an Azure Service Bus Queue.
It works perfectly when I run the function app locally, with my local.settings.json pointing to the queue on Azure.  I send a message to the queue and everything works/completes as expected within a matter of seconds.  But when I deploy it to Azure and when it is triggered, it times out during the PDF generation process after working for several minutes.  Everything else works up until it reaches this block of code (after the LogInformation() call):
                _log.LogInformation("Converting template and content into PDF file...");
                pdf = Pdf
                    .From(content)
                    .OfSize(PaperSize.A4)
                    .WithoutOutline()
                    .WithMargins(1.25.Centimeters())
                    .Portrait()
                    .Comressed()
                    .Content();
                _log.LogInformation("Finished converting template and content into PDF file");

It never reaches the second LogInformation("Finished....") call, timing out before that point while executing the Pdf calls.
Here is a sample of the App Insights log (first my logged message, then the timeout exception):
12/4/2019, 2:30:18.351 PM   Converting template and content into PDF file...    1   trace   {"prop__{OriginalFormat}":"Converting template and content into PDF file...","HostInstanceId":"fe52d18f-9830-40bc-a92b-f0a90cf37dc9","Category":"Function.PDFProcessorFunction.User","LogLevel":"Information","ProcessId":"4456","InvocationId":"cab3b347-95d3-45ff-b24d-c7c5048e6a6b"}     PDFProcessorFunction    3f325922eef58b46b2f635d283deeebe    |3f325922eef58b46b2f635d283deeebe.60bad8bb00011f46.     PC  0.0.0.0 df-eo-pdf-queue-function-dev    c8ddc12737b5c414811dd541ac7507946788a5bbd653984da9e4a88632659933    9f5886c8-fb23-4ef3-a0af-5cb7333f460e    df-eo-pdf-queue-function-dev    7a528756-2a38-4511-8b8d-04365870a91c    azurefunctions: 2.0.12888.0 87ec212c-16cc-11ea-888f-5f9ca4eaab67    1

timestamp [UTC]
2019-12-04T19:30:18.351427Z

message
Converting template and content into PDF file...

severityLevel
1

itemType
trace
customDimensions
{"prop__{OriginalFormat}":"Converting template and content into PDF file...","HostInstanceId":"fe52d18f-9830-40bc-a92b-f0a90cf37dc9","Category":"Function.PDFProcessorFunction.User","LogLevel":"Information","ProcessId":"4456","InvocationId":"cab3b347-95d3-45ff-b24d-c7c5048e6a6b"}

operation_Name
PDFProcessorFunction

12/4/2019, 2:35:14.307 PM   Timeout value of 00:05:00 exceeded by function 'PDFProcessorFunction' (Id: 'cab3b347-95d3-45ff-b24d-c7c5048e6a6b'). Initiating cancellation.    3   trace   {"prop__{OriginalFormat}":"Timeout value of 00:05:00 exceeded by function 'PDFProcessorFunction' (Id: 'cab3b347-95d3-45ff-b24d-c7c5048e6a6b'). Initiating cancellation.","HostInstanceId":"fe52d18f-9830-40bc-a92b-f0a90cf37dc9","LogLevel":"Error","Category":"Function.PDFProcessorFunction","ProcessId":"4456","InvocationId":"cab3b347-95d3-45ff-b24d-c7c5048e6a6b"}        PDFProcessorFunction    3f325922eef58b46b2f635d283deeebe    |3f325922eef58b46b2f635d283deeebe.60bad8bb00011f46.     PC  0.0.0.0 df-eo-pdf-queue-function-dev    c8ddc12737b5c414811dd541ac7507946788a5bbd653984da9e4a88632659933    9f5886c8-fb23-4ef3-a0af-5cb7333f460e    df-eo-pdf-queue-function-dev    7a528756-2a38-4511-8b8d-04365870a91c    azurefunctions: 2.0.12888.0 32061e7c-16cd-11ea-ae75-6364d66f68e2    1

timestamp [UTC]
2019-12-04T19:35:14.307144Z

message
Timeout value of 00:05:00 exceeded by function 'PDFProcessorFunction' (Id: 'cab3b347-95d3-45ff-b24d-c7c5048e6a6b'). Initiating cancellation.

severityLevel
3

itemType
trace
customDimensions
{"prop__{OriginalFormat}":"Timeout value of 00:05:00 exceeded by function 'PDFProcessorFunction' (Id: 'cab3b347-95d3-45ff-b24d-c7c5048e6a6b'). Initiating cancellation.","HostInstanceId":"fe52d18f-9830-40bc-a92b-f0a90cf37dc9","LogLevel":"Error","Category":"Function.PDFProcessorFunction","ProcessId":"4456","InvocationId":"cab3b347-95d3-45ff-b24d-c7c5048e6a6b"}

operation_Name
PDFProcessorFunction

operation_Id
3f325922eef58b46b2f635d283deeebe

operation_ParentId
|3f325922eef58b46b2f635d283deeebe.60bad8bb00011f46.

client_Type
PC

client_IP
0.0.0.0

cloud_RoleName
df-eo-pdf-queue-function-dev

cloud_RoleInstance
c8ddc12737b5c414811dd541ac7507946788a5bbd653984da9e4a88632659933

appId
9f5886c8-fb23-4ef3-a0af-5cb7333f460e

appName
df-eo-pdf-queue-function-dev

iKey
7a528756-2a38-4511-8b8d-04365870a91c

sdkVersion
azurefunctions: 2.0.12888.0

itemId
32061e7c-16cd-11ea-ae75-6364d66f68e2

itemCount
1

And here are the actual timeout exception details:
12/4/2019, 2:09:01.106 PM   Microsoft.Azure.WebJobs.Host.FunctionTimeoutException at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<TryHandleTimeoutAsync>d__29.MoveNext  Microsoft.Azure.WebJobs.Host.FunctionTimeoutException   Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35    Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<TryHandleTimeoutAsync>d__29.MoveNext   Microsoft.Azure.WebJobs.Host.FunctionTimeoutException   Timeout value of 00:05:00 was exceeded by function: PDFProcessorFunction    Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35    Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<TryHandleTimeoutAsync>d__29.MoveNext   3   [{"severityLevel":"Error","outerId":"0","message":"Timeout value of 00:05:00 was exceeded by function: PDFProcessorFunction","parsedStack":[{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<TryHandleTimeoutAsync>d__29.MoveNext","level":0,"line":660,"fileName":"C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs"},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw","level":1,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess","level":2,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification","level":3,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter`1.GetResult","level":4,"line":0},{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<InvokeAsync>d__27.MoveNext","level":5,"line":576,"fileName":"C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs"},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw","level":6,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess","level":7,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification","level":8,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.GetResult","level":9,"line":0},{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<ExecuteWithWatchersAsync>d__26.MoveNext","level":10,"line":532,"fileName":"C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs"},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw","level":11,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess","level":12,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification","level":13,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.GetResult","level":14,"line":0},{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<ExecuteWithLoggingAsync>d__25.MoveNext","level":15,"line":468,"fileName":"C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs"},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw","level":16,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess","level":17,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification","level":18,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.GetResult","level":19,"line":0},{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<ExecuteWithLoggingAsync>d__19.MoveNext","level":20,"line":278,"fileName":"C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs"},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw","level":21,"line":0},{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<ExecuteWithLoggingAsync>d__19.MoveNext","level":22,"line":322,"fileName":"C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs"},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw","level":23,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess","level":24,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification","level":25,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter`1.GetResult","level":26,"line":0},{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<TryExecuteAsyncCore>d__16.MoveNext","level":27,"line":117,"fileName":"C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs"}],"type":"Microsoft.Azure.WebJobs.Host.FunctionTimeoutException","id":"15999211"}]  exception   {"FormattedMessage":"Executed 'PDFProcessorFunction' (Failed, Id=6b0cebaa-0876-428d-a324-03265563651b)","HostInstanceId":"d7abe331-beea-4165-86b4-0323f307939a","InvocationId":"6b0cebaa-0876-428d-a324-03265563651b","ProcessId":"5856","LogLevel":"Error","Category":"Function.PDFProcessorFunction"} PDFProcessorFunction    3f325922eef58b46b2f635d283deeebe    |3f325922eef58b46b2f635d283deeebe.30b1b04f0e993f4a. PC  0.0.0.0 df-eo-pdf-queue-function-dev    34c90aa5d115bbf81d1cb11cf8ef01321f11d527a73c6ae5f86ec717cb94c776

timestamp [UTC]
2019-12-04T19:09:01.1061419Z

problemId
Microsoft.Azure.WebJobs.Host.FunctionTimeoutException at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<TryHandleTimeoutAsync>d__29.MoveNext

type
Microsoft.Azure.WebJobs.Host.FunctionTimeoutException

assembly
Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

method
Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<TryHandleTimeoutAsync>d__29.MoveNext

outerType
Microsoft.Azure.WebJobs.Host.FunctionTimeoutException

outerMessage
Timeout value of 00:05:00 was exceeded by function: PDFProcessorFunction

outerAssembly
Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

outerMethod
Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<TryHandleTimeoutAsync>d__29.MoveNext

severityLevel
3
details
[{"severityLevel":"Error","outerId":"0","message":"Timeout value of 00:05:00 was exceeded by function: PDFProcessorFunction","parsedStack":[{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<TryHandleTimeoutAsync>d__29.MoveNext","level":0,"line":660,"fileName":"C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs"},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw","level":1,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess","level":2,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification","level":3,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter`1.GetResult","level":4,"line":0},{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<InvokeAsync>d__27.MoveNext","level":5,"line":576,"fileName":"C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs"},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw","level":6,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess","level":7,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification","level":8,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.GetResult","level":9,"line":0},{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<ExecuteWithWatchersAsync>d__26.MoveNext","level":10,"line":532,"fileName":"C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs"},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw","level":11,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess","level":12,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification","level":13,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.GetResult","level":14,"line":0},{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<ExecuteWithLoggingAsync>d__25.MoveNext","level":15,"line":468,"fileName":"C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs"},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw","level":16,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess","level":17,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification","level":18,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.GetResult","level":19,"line":0},{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<ExecuteWithLoggingAsync>d__19.MoveNext","level":20,"line":278,"fileName":"C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs"},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw","level":21,"line":0},{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<ExecuteWithLoggingAsync>d__19.MoveNext","level":22,"line":322,"fileName":"C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs"},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw","level":23,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess","level":24,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification","level":25,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter`1.GetResult","level":26,"line":0},{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<TryExecuteAsyncCore>d__16.MoveNext","level":27,"line":117,"fileName":"C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs"}],"type":"Microsoft.Azure.WebJobs.Host.FunctionTimeoutException","id":"15999211"}]

itemType
exception
customDimensions
{"FormattedMessage":"Executed 'PDFProcessorFunction' (Failed, Id=6b0cebaa-0876-428d-a324-03265563651b)","HostInstanceId":"d7abe331-beea-4165-86b4-0323f307939a","InvocationId":"6b0cebaa-0876-428d-a324-03265563651b","ProcessId":"5856","LogLevel":"Error","Category":"Function.PDFProcessorFunction"}

operation_Name
PDFProcessorFunction

operation_Id
3f325922eef58b46b2f635d283deeebe

operation_ParentId
|3f325922eef58b46b2f635d283deeebe.30b1b04f0e993f4a.

client_Type
PC

client_IP
0.0.0.0

cloud_RoleName
df-eo-pdf-queue-function-dev

cloud_RoleInstance
34c90aa5d115bbf81d1cb11cf8ef01321f11d527a73c6ae5f86ec717cb94c776

appId
9f5886c8-fb23-4ef3-a0af-5cb7333f460e

appName
df-eo-pdf-queue-function-dev

iKey
7a528756-2a38-4511-8b8d-04365870a91c

sdkVersion
azurefunctions: 2.0.12888.0

itemId
88417461-16c9-11ea-9da1-1b43f8d3fcf0

itemCount
1

And yes, I have tried increasing the timeout value (up to our service plan's maximum of 10 minutes) - but it still times out.  Even though it only takes a few seconds to execute on my local machine.
In addition, I have checked, double-checked, triple-checked all the Function App configuration settings.  (I should mention that my company has several other Azure Function Apps written in .NET Core 2.1 that work fine).
What am I doing wrong?  Is is simply that Azure Functions are not meant to handle resource-intensive operations such as generating PDFs?

A: I am facing a similar problem which also demands intensive CPU. Seems to me that the problem is something in the Azure Functions side. What you can do is use a Durable Functions and pass this PDF generation to an activity. I am not sure if it will solve for you or not, but worths a try.


text:
Q: Como diminuir o tamanho do input? Alguém poderia me ajudar a diminuir o tamanho dos campos dos inputs? não manjo quase nada, provavelmente esta cheio de redundâncias, agradeço se alguém puder me mostrar o que estou fazendo de errado

#reservas {
    text-align: center;
}

form{
    display: flex;
    flex-direction: column;
    justify-content: center;

}
input{
    text-align: center;
    margin-bottom: 5px;
}

label, input[type="submit"] {
    margin-top: 10px;
    margin-bottom: 3px;
}

input, select {
    padding: 10px;
    border: none;
    outline: none;
    border-bottom: 2px solid #f4f4f4;
}

input[type="submit"] {
    background-color: rgb(43, 119, 103);
    color: #fff;
    font-weight: bold;
    border-radius: 10px 2px;
}

input[type="submit"]:hover {
    background-color: rgb(92, 170, 153);
    color: rgb(49, 49, 49);
    cursor: pointer;
    transition-duration: 380ms;
}

input:focus, select:focus {
    border-bottom-color: rgb(92, 170, 153);
}

        <form>
            Nome completo:
            <input type="text" id="nome" placeholder="Digite seu nome completo" required target="blank_">

            Telefone para contato:
            <input type="number" id="tel" placeholder="Digite seu telefone" required target="blank_">

            E-mail para contato:
            <input type="email" id="email" placeholder="Digite seu E-mail" required target="blank_">

            Reserva para o dia:
            <input type="date" id="dia" required target="blank_">

            <input type="submit" value="Confirmar agendamento">
        </form>

A: Eai blz, um modo facil de corrigir isso é colocando todo o form dentro de uma div

        <form>
            Nome completo:
            <input type="text" id="nome" placeholder="Digite seu nome completo" required target="blank_">
            Telefone para contato:
            <input type="number" id="tel" placeholder="Digite seu telefone" required target="blank_">
            E-mail para contato:
            <input type="email" id="email" placeholder="Digite seu E-mail" required target="blank_">
            Reserva para o dia:
            <input type="date" id="dia" required target="blank_">
            <input type="submit" value="Confirmar agendamento">
        </form>

e no css declarar a div assim
    .inputs {
    display: flex;
    justify-content: center;
}

A: Basta adicionar margin: 0 auto; no código CSS do seu input. Dessa forma:
input{
    text-align: center;
    margin-bottom: 5px;
    margin: 0 auto; /* adição de margem automática */
}

Caso queira controlar o tamanho dos inputs, utilize min-width: valor %:
input{
    text-align: center;
    margin-bottom: 5px;
    margin: 0 auto; /* adição de margem automática */
    min-width: 50%; /* valor de exemplo */
}


text:
Q: Hibernate seems not to resolve alias correctly since some days I'm facing the following problem:
I am using Hibernate to do the following Restriction on a criteria:
...
criteria.add(Restrictions.sqlRestriction("1=1 CONNECT BY PRIOR {ProcessEntityworkflowProject}.ID = {ProcessEntityworkflowProject}.PARENT_ID"))

Where "ProcessEntityworkflowProject" is the alias which should be resolved by hibernate.
This alias is set in code properly. I also debugged the code and inspected criteria:
There I could see that a subcriteria in subcriterialist of criteria has this correct alias bound to the association path.
But in SQL logs I see that it is not resolved:
... and this_.EXTERNAL_KEY is not null and 1=1 CONNECT BY PRIOR {ProcessEntityworkflowProject}.ID = {ProcessEntityworkflowProject}.PARENT_ID and processent4_.TYPE_ID=? ...

... or is this output correct and it is resolved later internally?
And in tomcat.log I see that there is a NPE:
java.lang.NullPointerException
at oracle.jdbc.driver.T4C8Oall.getNumRows(T4C8Oall.java:876)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:831)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1039)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:850)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1134)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3339)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3384)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:92)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1533)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:295)

I already found out that this NPE is cause because Oracle JDBC driver can not parse the brackets "{" "}". So I guess that the alias was not resolved properly.
Does anyone of you have an idea what could be wrong or how I could investigate deeper?
Some additional info:
I am using Hibernate 3.2.0 (CR1 afaik), tomcat 5.5, ojdbc14.jar.
Running on RHEL 6.4 and Oracle 11g
Many thx in advance if some of you have an idea ;)
Cheers
Sascha


text:
Q: sudo and apt-get not found I'm handling server as RA which was passed down to me by another graduated RA but I'm new and fresh to this environment facing a few issues right now. The server is setup by the graduate RA from scratch.
First of all, I'm accessing the server via PuTTY and logging in the server with username:root and its password. Then I'm trying to run some command but it shows sudo: not found.
NOTE:username is ROOT. NOT THE ROOT PRIVILLEGE.
I tried surfing for solution which asked me to install sudo with apt-get install sudo but apt-get: not found popped out.
Since I'm accessing via PuTTY, I'm not able to get into grub menu for root shell prompt. I did a reboot but it didn't help.
Please help me on this issue, I highly appreciate all solutions.

A: The whole purpose of sudo is to temporarily allow you to do what root can do.
If another person has been putting it together from scratch, it is highly probable that person got rid of sudo. As long as you can use root account, you can do everything you need.

A: Like @terdon I'm suspecting your server is not Ubuntu. (Also, please consider that people reading your questions are not in your context. What's a RA? A research assistant?)
Is the server a physical machine nearby that you happen to access through Putty, some remote machine in a remote datacenter, something else ? Also please run cat /etc/lsb-release to get hints.
Regarding root user, some hosting services provide an account that is named root and has somehow more rights that regular account yet is not actually a full superuser. In that case it's somehow logical that sudo is not available.
Regarding apt-get, presumably you wanted to use it to install some software. It generally does not exist on non-Debian based platforms.
Chances are, you don't actually need sudo or apt-get in your context. Those are tools to satisfy needs, what need makes you believe you have to use those tools ?


text:
Q: How to set environment variable in the rule of a makefile for Linux? entrypoint-job-prod:
    AWS_PROFILE_NAME=amx-prod
    export AWS_PROFILE_NAME
    ENV=PROD
    export ENV
    python ./entry_point/entry_point.py

I am trying to set the environment variables so that the code works in the production environment. However, this does not update the environment variable. One has to manually create the environment variable in the CLI for the code to work.

A: You can simply add the variables to the command when executing:
entrypoint-job-prod:
    ENV=PROD AWS_PROFILE_NAME=amx-prod python ./entry_point/entry_point.py

Here's a toy example demonstrating it in action:
$ cat /home/terdon/scripts/foo.py
#!/usr/bin/env python3

import os

print("AA:",os.environ['foo'])

And a Makefile that calls the script:
all: run

run: tests/main
    foo='baba' python /home/terdon/scripts/foo.py

If I now run make:
$ make
foo='baba' python /home/terdon/scripts/foo.py
AA: baba


text:
Q: IN operator to use AND operator I am working on a report in SSRS which passes the result of one parameter to another parameter.
The first Parameter @survey is a list of surveys
The second parameter @question is a list of questions
When the survey is select from @survey it populates @question with the list of questions on said survey using the following SQL:
SELECT DISTINCT dimSurveyQuestion.QuestionID, dimSurveyQuestion.QuestionCaption,
                factSurveyResponseAnswer.SectionID, factSurveyResponseAnswer.DisplayOrder
FROM dimSurveyQuestion
INNER JOIN factSurveyResponseAnswer
    ON dimSurveyQuestion.QuestionID = factSurveyResponseAnswer.QuestionCaptionID
WHERE (factSurveyResponseAnswer.SurveyID IN (@Survey))
ORDER BY factSurveyResponseAnswer.SectionID,
         factSurveyResponseAnswer.DisplayOrder

The customer wishes to have the ability to select multiple surveys from the @survey parameter and then the @question parameter is populated with all of the questions which can be found in ALL of the surveys selected.
I understand that by using the IN Operator on my WHERE clause this will utilise the OR operator
So if the values Survey1 and Survey2 were selected in the @survey parameter the WHERE clause of the SQL is effectively saying:
WHERE (factSurveyResponseAnswer.SurveyID = Survey1 OR
       factSurveyResponseAnswer.SurveyID = Survey2)

Is there anyway in which I can pass multiple values through from the @survey Parameter and my WHERE clause to dynamically say:
 WHERE (factSurveyResponseAnswer.SurveyID = Survey1 AND
        factSurveyResponseAnswer.SurveyID = Survey2)

This would then bring back the questions which are present in both surveys.
Apologies if this has been asked before. I have searched the forum but was unable to find the answer.
Many Thanks


text:
Q: kafka AdminClient get kafka version Is there a way to get the version of kafka cluster programmatically? Such as, using
AdminClient API.
I want to identify the version of kafka cluster in a consumer/producer app.

A: At the moment there is no way to retrieve the Kafka version brokers are running.
There is a KIP in progress to add that feature to the AdminClient: KIP-483: Add Broker Version API in Admin Client so that may be availabble in a future version.
In the meantime, there are a few workarounds you can try:

*

*Use describeConfigs() to find the inter.broker.protocol.version config of the brokers. If that returns 2.2-IV1, it means the broker is running at least 2.2.

*Check the ApiVersions response. Upon starting clients send an ApiVersions request and the response is written in the logs (at the INFO level). Or manually send an ApiVersions, it's pretty easy to craft such a request as it's an empty body. Then you can identify the broker version using https://cwiki.apache.org/confluence/display/KAFKA/Kafka+APIs

A: You can use AppInfoParser.getVersion(); in your consumer/producer code.


text:
Q: How to make the webserver within Visual Studio serve content that's viewable by other machines on the network? How do I make the webserver within Visual Studio serve content that's viewable by other machines on the network?
For example: When I press F5 and I give the other person the ip + port he/she can see the content.
Thanks!

A: Sounds like it's not possible.
From MS Site:

If you cannot or do not want to use IIS as your Web server, you can still test your ASP.NET pages by using the ASP.NET Development Server. The ASP.NET Development Server, which is included with Visual Web Developer, is a Web server that runs locally on Windows operating systems, including Windows XP Home Edition. It is specifically built to serve, or run, ASP.NET Web pages under the local host scenario (browsing from the same computer as the Web server). In other words, the ASP.NET Development Server will serve pages to browser requests on the local computer. It will not serve pages to another computer. Additionally, it will not serve files that are outside of the application scope. The ASP.NET Development Server provides an efficient way to test pages locally before you publish the pages to a production server running IIS.

A: You could installl IIS or IIS express and publish to them, otherwise as Franky says its not possible with Cassini (the VS inbuilt one)

A: You can setup Visual studio in order to use IIS to debug. Its in the properties.
If you do that then people can visit your debug.
http://learn.iis.net/page.aspx/387/using-visual-studio-2008-with-iis-7/


text:
Q: Angularjs Karma suddenly not executing tests anymore I am looking after a legacy Angularjs project and part of this project is Karma and Jasmin. Everything worked well so far, but without any (obvious) reason karma itself still starts up but does not execute any tests anymore. Instead of that it times out after 10000ms.
I would not have a clue how to debug that. Can anyone help?  Here is the Karma conf
"use strict";
module.exports = function (config) {
    config.set({
        basePath: './',
        files: [
            {pattern: 'app/bower_components/angular/angular.js', included: false},
            {pattern: 'app/bower_components/jquery/dist/jquery.js', included: false},
            {pattern: 'app/bower_components/angular/angular.js', included: false},
            {pattern: 'app/bower_components/bootstrap/dist/js/bootstrap.js', included: false},
            {pattern: 'app/bower_components/angular-route/angular-route.js', included: false},
            {pattern: 'app/bower_components/angular-mocks/angular-mocks.js', included: false},
            {pattern: 'app/bower_components/angularjs-datepicker/dist/angular-datepicker.min.js*', included: false},
            {pattern: 'app/app.js', included: false},
            {pattern: 'app/**/*.js', included: false},
            {pattern: 'app/**/*spec.js', included: false},

            // needs to be last http://karma-runner.github.io/0.12/plus/requirejs.html
            'app/require-config.js'
        ],
        ngHtml2JsPreprocessor: {
            stripPrefix: 'public/',
            stripSuffix: '.ext',
            // prepend this to the
            prependPrefix: 'served/',
            moduleName: 'templates'
        },
        autoWatch: true,
        frameworks: ['jasmine', 'requirejs'],
        plugins: [
            'karma-chrome-launcher',
            'karma-firefox-launcher',
            'karma-ie-launcher',
            'karma-safari-launcher',
            'karma-jasmine',
            'karma-requirejs',
            'karma-junit-reporter',
            'karma-coverage',
            'karma-ng-html2js-preprocessor',
            'karma-phantomjs-launcher'
        ],
        preprocessors: {
            'app/home/**/!(*spec)*.js': 'coverage',
            'app/navigation/**/!(*spec)*.js': 'coverage',
            'app/content/**/!(*spec)*.js': 'coverage',
            'app/alerts/**/!(*spec)*.js': 'coverage',
            'app/eco_login/**/!(*spec)*.js': 'coverage',
            'app/coms/**/!(*spec)*.js': 'coverage',
            'app/current_observations/**/!(*spec)*.js': 'coverage',
            'app/filters/**/!(*spec)*.js': 'coverage',
            'app/observation_records/**/!(*spec)*.js': 'coverage',
            'app/script_writer/**/!(*spec)*.js': 'coverage',
            'app/script_guidance/**/!(*spec)*.js': 'coverage',
            'app/databrowser/**/!(*spec)*.js': 'coverage',
            'app/eco/**/!(*spec)*.js': 'coverage',
            'app/extremes/**/!(*spec)*.js': 'coverage',
            'app/services/**/!(*spec)*.js': 'coverage',
            'app/location_data/**/!(*spec)*.js': 'coverage',
            'app/location_picker/**/!(*spec)*.js': 'coverage',
            'app/location_map/**/!(*spec)*.js': 'coverage',
            'app/text_forecast/**/!(*spec)*.js': 'coverage',
            'app/**/*.html': ["ng-html2js"]
        },
        coverageReporter: {
            reporters: [
                {
                    type: 'cobertura',
                    dir: 'coverage/',
                    subdir: function (browser) {
                        // normalization process to keep a consistent browser name across different
                        // OS
                        return browser.replace(/ /g, '_');
                    }
                },
                {
                    type: 'lcovonly',
                    dir: 'coverage/',
                    subdir: function (browser) {
                        // normalization process to keep a consistent browser name across different
                        // OS
                        return browser.replace(/ /g, '_');
                    }
                },
                {
                    type: 'html',
                    dir: 'coverage/',
                    subdir: function (browser) {
                        // normalization process to keep a consistent browser name across different
                        // OS
                        return browser.replace(/ /g, '_');
                    }
                }
            ]
        },
        browserConsoleLogOptions: {
            terminal: true,
            level: ""
        },
        // test results reporter to use
        // possible values: 'dots', 'progress'
        // available reporters: https://npmjs.org/browse/keyword/karma-reporter
        reporters: ['progress', 'coverage', 'junit'],
        junitReporter: {
            outputDir: 'coverage/',
            outputFile: 'unit.xml',
            suite: 'unit'
        },
        noColors: true,
        captureConsole: true,
        logLevelDebug: true,
        singleRun: true,
        logLevel: 'debug',
        browsers: ['Firefox']
    });
};

I set the logLevelDebug to true, this is part of the output
18 04 2017 08:10:07.695:INFO [karma]: Karma v1.6.0 server started at http://0.0.0.0:9876/
    18 04 2017 08:10:07.696:INFO [launcher]: Launching browser Firefox with unlimited concurrency
18 04 2017 08:10:07.707:INFO [launcher]: Starting browser Firefox
18 04 2017 08:10:07.708:DEBUG [temp-dir]: Creating temp dir at /tmp/karma-17509431
18 04 2017 08:10:07.709:DEBUG [launcher]: firefox http://localhost:9876/?id=17509431 -profile /tmp/karma-17509431 -no-remote
    18 04 2017 08:10:09.620:DEBUG [web-server]: serving: /home/uwe/ws/ForecasterPortal/node_modules/karma/static/client.html
18 04 2017 08:10:09.950:DEBUG [web-server]: serving: /home/uwe/ws/ForecasterPortal/node_modules/karma/static/karma.js
18 04 2017 08:10:10.174:DEBUG [karma]: A browser has connected on socket NeEdoBJw1Olt5Vk5AAAA
18 04 2017 08:10:10.183:DEBUG [web-server]: serving: /home/uwe/ws/ForecasterPortal/node_modules/karma/static/favicon.ico
18 04 2017 08:10:10.276:INFO [Firefox 52.0.0 (Ubuntu 0.0.0)]: Connected on socket NeEdoBJw1Olt5Vk5AAAA with id 17509431
18 04 2017 08:10:10.277:DEBUG [launcher]: Firefox (id 17509431) captured in 2.581 secs
18 04 2017 08:10:10.278:DEBUG [web-server]: upgrade /socket.io/?EIO=3&transport=websocket&sid=NeEdoBJw1Olt5Vk5AAAA
    18 04 2017 08:10:10.320:DEBUG [middleware:karma]: custom files null null null
18 04 2017 08:10:10.322:DEBUG [middleware:karma]: Serving static request /context.html
18 04 2017 08:10:10.337:DEBUG [web-server]: serving: /home/uwe/ws/ForecasterPortal/node_modules/karma/static/context.html
18 04 2017 08:10:10.394:DEBUG [web-server]: serving: /home/uwe/ws/ForecasterPortal/node_modules/karma/static/context.js
18 04 2017 08:10:10.396:DEBUG [middleware:source-files]: Requesting /base/node_modules/requirejs/require.js?b1010092f15879164973aaba0cc26c7298118d76 /
    18 04 2017 08:10:10.396:DEBUG [middleware:source-files]: Fetching /home/uwe/ws/ForecasterPortal/node_modules/requirejs/require.js
18 04 2017 08:10:10.397:DEBUG [web-server]: serving (cached): /home/uwe/ws/ForecasterPortal/node_modules/requirejs/require.js
18 04 2017 08:10:10.399:DEBUG [middleware:source-files]: Requesting /base/node_modules/karma-requirejs/lib/adapter.js?a0765fc3eacb39184893303c3bc2e821cb041787 /
    18 04 2017 08:10:10.403:DEBUG [middleware:source-files]: Fetching /home/uwe/ws/ForecasterPortal/node_modules/karma-requirejs/lib/adapter.js
18 04 2017 08:10:10.404:DEBUG [web-server]: serving (cached): /home/uwe/ws/ForecasterPortal/node_modules/karma-requirejs/lib/adapter.js
18 04 2017 08:10:10.430:DEBUG [middleware:source-files]: Requesting /base/node_modules/jasmine-core/lib/jasmine-core/jasmine.js?916005cc407925f4764668d61d04888d59258f5d /
    18 04 2017 08:10:10.430:DEBUG [middleware:source-files]: Fetching /home/uwe/ws/ForecasterPortal/node_modules/jasmine-core/lib/jasmine-core/jasmine.js
18 04 2017 08:10:10.431:DEBUG [middleware:source-files]: Requesting /base/node_modules/karma-jasmine/lib/boot.js?945a38bf4e45ad2770eb94868231905a04a0bd3e /
    18 04 2017 08:10:10.431:DEBUG [middleware:source-files]: Fetching /home/uwe/ws/ForecasterPortal/node_modules/karma-jasmine/lib/boot.js
18 04 2017 08:10:10.431:DEBUG [middleware:source-files]: Requesting /base/node_modules/karma-jasmine/lib/adapter.js?7a813cc290d592e664331c573a1a796192cdd1ad /
    18 04 2017 08:10:10.432:DEBUG [middleware:source-files]: Fetching /home/uwe/ws/ForecasterPortal/node_modules/karma-jasmine/lib/adapter.js
18 04 2017 08:10:10.432:DEBUG [web-server]: serving (cached): /home/uwe/ws/ForecasterPortal/node_modules/jasmine-core/lib/jasmine-core/jasmine.js
18 04 2017 08:10:10.436:DEBUG [web-server]: serving (cached): /home/uwe/ws/ForecasterPortal/node_modules/karma-jasmine/lib/boot.js
18 04 2017 08:10:10.437:DEBUG [web-server]: serving (cached): /home/uwe/ws/ForecasterPortal/node_modules/karma-jasmine/lib/adapter.js
18 04 2017 08:10:20.283:WARN [Firefox 52.0.0 (Ubuntu 0.0.0)]: Disconnected (1 times), because no message in 10000 ms.
    Firefox 52.0.0 (Ubuntu 0.0.0) ERROR
Disconnected, because no message in 10000 ms.


text:
Q: iOS Facebook Login Without Opening Browser or native Facebook App I am using the Facebook Login for my iOS app. However the login flow is not using the native iOS Facebook  integration.
I am using Facebook iOS SDK 3.17 (via pod) and I have followed the setup instructions. The login is working, it is simply not showing the native login dialog. Instead it opens the Facebook iOS app to authenticate...
Any ideas?

A: Facebook changed their login behavior. You can get this to work again by setting the property "loginBehavior" on your FBLoginView to "FBSessionLoginBehaviorUseSystemAccountIfPresent" in your viewDidLoad method.
self.loginView.loginBehavior = FBSessionLoginBehaviorUseSystemAccountIfPresent;


text:
Q: QuartzScheduler Trigger Issue Am facing a Problem with QuartzScheduler  trigger defination.
Thu Feb 28 16:27:30 IST 2019   : Start time
0/20 0 0 ? * * *   Cron Expression
Thu Feb 28 16:29:30 IST 2019  End Time
Trigger schedulerAdderTrigger = TriggerBuilder.newTrigger()
                .withIdentity(triggerkey)               .startAt(schedulerdata.getScheduleStartDate())             .withSchedule(CronScheduleBuilder.cronSchedule(schedulerdata.getChroneExpression())).endAt(schedulerdata.getScheduleEndDate())    .usingJobData(jobDataMap).build();
Am getting the Below Error,What might be the reason.
Error :
org.quartz.SchedulerException: Based on configured schedule, the given trigger 'DEFAULT.1010001_50' will never fire.
    at org.quartz.core.QuartzScheduler.scheduleJob(QuartzScheduler.java:882)
    at org.quartz.impl.StdScheduler.scheduleJob(StdScheduler.java:249)
    at com.naresh.sample.job.ReportDashboardDataLoader.addJobToScheduler(ReportDashboardDataLoader.java:128)
    at com.naresh.sample.job.ReportDashboardDataLoader.addToScheduler(ReportDashboardDataLoader.java:81)
    at com.naresh.sample.job.ReportDashboardDataLoader.execute(ReportDashboardDataLoader.java:47)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Also I tried to change the granularity to minute level( 0 0/1 0 ? * * *) in that case nothings running.
Please help me in understanding the problem.
regards,
Naresh

A: Sorry, Problem is my side.Cron Expression which I used is wrong. I just over looked it.
Thanks,
Naresh


text:
Q: How to verify multiple method calls with different params I have the following method that I wish to verify behaviour on.
public void methodToTest(Exception e, ActionErrors errors) {
    ...

    errors.add("exception.message",
            ActionMessageFactory.createErrorMessage(e.toString()));

    errors.add("exception.detail",
            ActionMessageFactory.createErrorMessage(e.getStackTrace()[0].toString()));

    ...
}

In my @Test class I was hoping to do something like this to verify that errors.add() is called with "exception.message" and again with "exception.detail"
verify(errors).add(eq("exception.message"), any(ActionError.class));
verify(errors).add(eq("exception.detail"), any(ActionError.class));

however Mockito complains as follows
Argument(s) are different! Wanted:
actionErrors.add(
    "exception.message",
    <any>
);

Actual invocation has different arguments:
actionErrors.add(
    "exception.detail",
    org.apache.struts.action.ActionError@38063806
);

How can I tell Mockito to check for both values?

A: OP code is correct (check your Total)
=1= Tell Mokito the total call expectation.
=2= Tell Mokito how many times each parameter combination was expected. (Mokito assumes times(1), if times is omitted).
verify(errors, times(2)).add(any(), any(ActionMessage.class));

verify(errors).add(eq("exception.message"), any());
verify(errors).add(eq("exception.detail"), any());

The OP code is correct; it checks what you need.
Your problem was in your Prod code, which (seems) never called the first arg combination with ActionError arg type. So Mokito correctly complained. However (I agree) the complaint message is confusing for the multiple calls.
SOLUTION: Ensure (first of all) you really called the method precisely 2 times (with any args).

A: If the order of both add() calls is relevant, you can use InOrder:
InOrder inOrder = inOrder(errors);
inOrder.verify(errors).add(eq("exception.message"), any(ActionError.class));
inOrder.verify(errors).add(eq("exception.detail"), any(ActionError.class));

A: In a similar way to @sendon1928 we can use:
Mockito.times(wantedInvocationCount)

to make sure method was called exact number of times (preferable solution in my opinion). Afterwards, we can call
Mockito.verifyNoMoreInteractions(mock)

To make sure that mock was not used further in any context. Full example:
Mockito.verify(mockObject, Mockito.times(wantedInvocationCount)).testMethod(Mockito.eq(1));

Mockito.verify(mockObject, Mockito.times(wantedInvocationCount)).testMethod(Mockito.eq(2));

Mockito.verifyNoMoreInteractions(mockObject)

A: Try something like this:
verify(errors, times(2))
     .add(AdditionalMatchers.or(eq("exception.message"), eq("exception.detail")),
          any(ActionError.class));

A: You can use Mockito.atLeastOnce() which allows Mockito to pass the test even if that mockObject will be called many times.
Mockito.verify(mockObject, Mockito.atLeastOnce()).testMethod(Mockito.eq(1));

Mockito.verify(mockObject, Mockito.atLeastOnce()).testMethod(Mockito.eq(2));

A: you probably have a problem in your code. Because as a matter of fact you actually write this code:
Map<Character, String> map = mock(Map.class);

map.put('a', "a");
map.put('b', "b");
map.put('c', "c");

verify(map).put(eq('c'), anyString());
verify(map).put(eq('a'), anyString());
verify(map).put(eq('b'), anyString());

Note the first verify is not even in order in regard of the actual invocations.
Also, I would recommand you to actually don't mock types you don't own, eg the struts type.
[EDIT @Brad]
After running Brice's code (above) in my IDE I can see that I have used ActionError instead of ActionMessage, so that is why my verify() was not matching. The error message I initially posted was misleading me into thinking it was the first argument that was not matching. It turns out it was the second argument.
So the answer to my question is
/**
 * note that ActionMessageFactory.createErrorMessage() returns ActionMessage
 * and ActionError extends ActionMessage
 */
verify(errors).add(eq("exception.message"), any(ActionMessage.class));
verify(errors).add(eq("exception.detail"), any(ActionMessage.class));

A: Further reading has led me to try using ArgumentCaptors and the following works, although much more verbose than I would like.
ArgumentCaptor<String> argument = ArgumentCaptor.forClass(String.class);

verify(errors, atLeastOnce()).add(argument.capture(), any(ActionMessage.class));

List<String> values = argument.getAllValues();

assertTrue(values.contains("exception.message"));
assertTrue(values.contains("exception.detail"));


text:
Q: Building ImageMagick on OSX Lion and can't link libpng I am trying to build ImageMagick 6.8.0-5 on OSX Lion with support for libpng. I am just using the standard ./configure make make install procedure.
I succeed in compiling when I do not reference libpng.
./configure --with-png=no
make

However, I get an error in make when I try to add libpng support. (libpng-1.5.13)
./configure --with-png=yes
make

The error seems to be a linker error.
/usr/bin/nm: no name list
ld: warning: cannot export hidden symbol _SyncImagePixelCache from magick/.libs/magick_libMagickCore_la-cache.o
ld: warning: cannot export hidden symbol _ResetQuantumState from magick/.libs/magick_libMagickCore_la-quantum.o
Undefined symbols for architecture x86_64:
  "_png_set_check_for_invalid_index", referenced from:
      _WriteOnePNGImage in magick_libMagickCore_la-png.o
      _ReadOnePNGImage in magick_libMagickCore_la-png.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make[1]: *** [magick/libMagickCore.la] Error 1
make: *** [all] Error 2

I have not changed any other options to configure.
How can I fix this to add libpng support?

A: You'll need to tell ImageMagick where to locate libpng. Luckily, libpng ships with a configuration script entitled "libpng-config".
You can get the link-library option form your local libpng install with the --L_opts flag.
libpng-config --L_opts

This will return something like -L/usr/local/lib. Set ImageMagick's LDFLAGS configuration  to match your libpng library.
# Use the returned value for the LDFLAGS
./configure LDFLAGS='-L/usr/local/lib'

If libpng-config returns with a message 'command not found', you'll need to ensure your libpng is installed correctly, and can be located in your shell environment. Often, this can be as simple as adding a custom path to your PATH variable.
export PATH="$PATH:/usr/local/bin"

A: Had trouble getting ImageMagick to build correctly with png support on 10.10 myself, so I just used the installer from http://cactuslab.com/imagemagick/ which includes png support. (installs in /opt)

A: Newer ImageMagick versions seems to rely on "pkg-config" to find your own libpng build. I just installed pkg-config and set PKG_CONFIG_LIBRARY=/path/to/my/libpng-version for it to work.
HTH, Axel.


text:
Q: Calculate percentage in mysql from the same column How do i calculate the percentage from the same column, between two dates?
I have column latest.
For example: 2015-11-16 the value was 159,4 and today the value is 160,1.
And between these dates there is other values, that i´m not interested in at the moment. How to i calculate the percentage difference from that specific date, compared to "todays" date.
EDIT
SELECT curr.latest * 100 / NULLIF(prev.latest, 0) as percentage
FROM myTable AS curr, myTable AS prev
WHERE date(prev.timestamp) = '2015-11-16'
AND date(curr.timestamp) = CURDATE()
AND curr.the_row_namn = 'apple'

Percentage of column latest of a specific date ex. 2015-11-16, with the the_row_namn of apple from the table myTable.
What is the percentage difference of column latest for apple of the day 2015-11-16 to today.
+--------------+--------+------------+
| the_row_namn | latest | timestamp  |
+--------------+--------+------------+
| apple        | 159,40 | 2015-11-16 |
| apple        | 164,1  | 2015-11-17 |
+--------------+--------+------------+

Expected output: (rounded) percentage: 0,2864 or even better if that is possible 2,8%
Hope this will clarify things.

A: This is the general form such a query can take:
SELECT a.value / b.value AS abPerc
FROM the_table AS a
INNER JOIN the_table AS b ON [pairing criteria]
;

A: You could do this with the following SELECT statement:
SELECT     curr.name,
           curr.value * 100 / NULLIF(prev.value, 0) as percentage
FROM       myTable AS curr
INNER JOIN myTable AS prev
        ON curr.name = prev.name
WHERE      prev.latest = '2015-10-26'
AND        curr.latest = CURDATE()
AND        curr.name = 'apple';

If you leave out the last condition, you'll get a result per possible value of name.
The main point of this query is that you use your table twice, once to select the current record, and once to retrieve the earlier record. You should just specify the date of your choice in the first line of the where clause.
Once you have both records, it is straightforward to calculate a percentage from the value columns of these two records.
The NULLIF is there to protect you from division by zero errors. Instead you'll get a NULL result.


text:
Q: can we build linq query over dynamically generated xml response? I have one query over linq, suppose i have an xml response ( i am getting from some x server) each time this xml response will change but root element of xml is same but some times descendant nodes (like inside it have many different nodes) may exists or not, so i need to build linq query over this xml  so that there will be no exceptions throws saying some x1 element or child node not exists..So finally it should take the xml (what come's from server response) and build the query.
Regards,
Raj.

A: I had this in the past: xml's coming in with each time totally different structures.
So I build something that first analyzed the structure and stored this structure in database tables, to be able to also know the delta's and have some history (and diff-ing) on it. Since sometimes manual intervention is needed (can't predict everything).
After the analysis phase, then a query can be done on the new structure based on the structure analysis.
So I took a two step approach, maybe this is also applicable for you.

A: First, you need to convert your XML to a dynamic structure. The first library I found (haven't tried though): https://www.nuget.org/packages/netfx-System.Xml.DynamicXml/
Then, you can add Linq on top of your dynamic XML root.
However, performance-wise this is really bad approach. I played once with dynamic XML and that was extremely slow. Maybe, instead of making it dynamic you can create extension methods to XElement (if you are loading the XML to XDocument) which will return empty node without throwing an exception, e.g. (pseudocode):
public static class XElementExtensions
{
  public static XElement SafeGetChild(this XElement node, string childName)
  {
    XElement result;
    if (!node.TryGetChildByName(childName, out result))
      result = node.Document.CreateElement(childName);
    return result;
  }
}


text:
Q: List retrieving from firebase I know how to fetch a simple list but having problems when the nodes are nested like if a user enters in a textbox that he wants the list of students of Section1 then only Jerry and Sean with his roll no should be shown.
This is my code for a simple list.
public class MainActivity extends AppCompatActivity {
ListView listView;
DatabaseReference dref;
ArrayList<String> list=new ArrayList<>();
ArrayAdapter<String> adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    listView=(ListView)findViewById(R.id.ListView);
    adapter=new ArrayAdapter<String>(MainActivity.this,android.R.layout.simple_list_item_1,list);
    listView.setAdapter(adapter);
    dref= FirebaseDatabase.getInstance().getReference();
    dref.addChildEventListener(new ChildEventListener() {
        @Override
        public void onChildAdded(DataSnapshot dataSnapshot, String s) {
            String value=dataSnapshot.getValue(String.class);
            list.add(value);
            adapter.notifyDataSetChanged();
        }

        @Override
        public void onChildChanged(DataSnapshot dataSnapshot, String s) {

        }

        @Override
        public void onChildRemoved(DataSnapshot dataSnapshot) {
            String value=dataSnapshot.getValue(String.class);
            list.remove(value);
            adapter.notifyDataSetChanged();
        }

        @Override
        public void onChildMoved(DataSnapshot dataSnapshot, String s) {

        }

        @Override
        public void onCancelled(DatabaseError databaseError) {

        }
    });
}

JSON tree:

Please suggest me how to do that.

A: Since you're attaching your ChildEventListener to the root of your database, your onChildAdded will be invoked with a snapshot for each section. So once for Section1, once for Section2, and once for Section3.
If you want to only listen on a specific section, attach your listener to that section:
dref= FirebaseDatabase.getInstance().getReference();
dref.child("Section1").addChildEventListener(new ChildEventListener() {
    @Override
    public void onChildAdded(DataSnapshot dataSnapshot, String s) {
        String key = dataSnapshot.getKey();
        int value  = dataSnapshot.getValue(Integer.class);
        list.add(key+": "+value);
        adapter.notifyDataSetChanged();
    }

In the above, since you're only listening to Section1, your onChildAdded will fire once for Jerry and once for Sean. But those are now the keys of the snapshots, so the code uses getKey().
On the other hand: if you want to show students for all sections, you
 need to keep your listener on the root and access lower level properties of the original snapshot. For this you either use getChild() to get to the property, or loop over getChildren() to access all properties.
dref= FirebaseDatabase.getInstance().getReference();
dref.addChildEventListener(new ChildEventListener() {
    @Override
    public void onChildAdded(DataSnapshot dataSnapshot, String s) {
        for (DataSnapshot student: dataSnapshot.getChildren()) {
            String value=student.getValue(String.class);
            list.add(value);
        }
        adapter.notifyDataSetChanged();
    }


text:
Q: FileSystemNotFoundException in a Dockerized Spring Boot Application I'm trying to load a file in a spring boot application that is running inside a Docker container but I'm getting the following exception:
java.nio.file.FileSystemNotFoundException
 at com.sun.nio.zipfs.ZipFileSystemProvider.getFileSystem(ZipFileSystemProvider.java:171) ~[zipfs.jar:1.8.0_191]
   at com.sun.nio.zipfs.ZipFileSystemProvider.getPath(ZipFileSystemProvider.java:157) ~[zipfs.jar:1.8.0_191]
 at java.nio.file.Paths.get(Paths.java:143) ~[?:1.8.0_191]
 at app.metrics.collector.util.FileUtils.getContentAsSingleLine(FileUtils.java:17) ~[classes!/:?]
     at app.metrics.collector.jobs.DbQueryJob.generatePreparedStatement(DbQueryJob.java:54) ~[classes!/:?]
at app.metrics.collector.jobs.DbQueryJob.execute(DbQueryJob.java:36) ~[classes!/:?]
  at org.quartz.core.JobRunShell.run(JobRunShell.java:202) [quartz-2.3.0.jar!/:?]

The error does not appears when I execute the jar outside the container.
Here is the Dockerfile:
FROM openjdk:8-jdk-alpine
ADD build/app.jar app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","app.jar"]

And here is the method that loads the file:
    public static String getContentAsSingleLine(String fileName) throws URISyntaxException, IOException {
    String data;
    Path path = Paths.get(FileUtils.class.getClassLoader().getResource(fileName).toURI());
    Stream<String> lines = Files.lines(path);
    data = lines.collect(Collectors.joining(StringUtils.SPACE));
    lines.close();
    return data;
}

The file is located in the resource folder:
/src/main/resources/database/file.sql

and the argument passed to the method is:
"database/file.sql"

*

*Does anyone have an idea of the cause of the issue and its possible solution ?

A: I think by execute the jar outside the container you mean running the project in your IDE. Then database/file.sql is actually available as a file.
In the jar, the file is not available for Paths.get() to actually handle.
When trying to access the resource you should use
InputStream in = getClass().getResourceAsStream(fileName);

you can then use java.util.Scanner to collect the lines:
String data = new Scanner(in)
 .useDelimiter('\n')
 .tokens()
 .collect(Collectors.joining(StringUtils.SPACE));

A: The exception looks to be dealing with zip / archive file, please ensure once that whether it is while loading sql or any other file?


text:
Q: SQL Server Compact 4.0 SP1 Runtime installs fine via GUI, fails via command line I am trying to install the SQL Server Compact 4.0 SP1 64-bit Runtime onto Windows 10 (20H2) devices in a corporate environment and I just cannot get it to install.
The situation:

*

*When I try and install it via a script (I've tried Powershell and CMD) the installation fails. However, performing the installation manually by double-clicking the installer and following the GUI prompts, the installation succeeds (!). My install commands are nothing fancy: msiexec /i file.msi /qn /l <log path> and for the .exe: file.exe /qn

*The error occurs at the installation of Visual C++ 2008. From the SQL CE install log:

*The following is logged in C:\Windows\Logs\CBS\cbs.log at the same time:

*For comparison, this is the exact same section of the CBS.log when I perform the installation using the GUI (noting the start is exactly the same):

*These devices already have a newer version of the Visual C++ 2008 redistributable installed (4148 vs 6161):

*If I install using the GUI method, and then uninstall SQL CE, the scripted method will then work. So whatever the issue is, it has been fixed via the GUI method running through successfully.
The troubleshooting I've done:

*

*I have created dozens of virtual machines with our standard build/image and the issue is reproducible every single time. The successful GUI install is reproducible every time, too.

*I have tried installing using the .exe as provided in the download link, the .msi you can create using that .exe (with the /a parameter), and also the .msi that is temporarily created when you launch the .exe via the GUI (took a copy of the .msi before the .exe did its cleanup). The results are the same for all files.

*Set the MSI to run in Compatibility Mode (right-click the file > compatibility > auto detect)

*Confirmed anti virus is not getting in the way

*Redownloaded the file more times than I can remember

*Tried resetting .NET as described here

*Run the installation from a location where the user account definitely has full rights

*Opened the MSI in Orca to try and spot some hidden issue. Nothing obvious stood out to me.

*Researched the definition of "STATUS_TRANSACTIONAL_CONFLICT": "The function attempted to use a name that is reserved for use by another transaction."

*Researched the error Error 1935. An error occurred during the installation of assembly 'Microsoft.VC90.CRT so. damn. bloody. much.

*Run the .NET Framework repair tool (which by default always recommends reinstalling the Windows Module Installer service, which I allowed to happen). No change.
The biggest thing throwing me off is that it installs fine if I use the GUI. If there was some configuration issue with my devices, or missing prerequisite, surely it should fail to install via the GUI too?


text:
Q: How do I extract only certain email addresses from a body of text has many? There are a number of email addresses, sent along with their roles, in an url encoded json. Like so:
hl=en_US&token=AFNOsBbXXvng6zJmmPyIlya1dT48RKqmaQ%3A1441100947178&foreignService=explorer&shareService=explorer&authuser=0&locale=en_US&requestType=aclChange&itemIds=0B-i4kCZeNb05Y3FrVXFLYU41N0U&confirmed=false&modelChanges=%7B%22aclEntries%22%3A%5B%7B%22scope%22%3A%7B%22scopeType%22%3A%22user%22%2C%22name%22%3A%22babar.memon%40gmail.com%22%2C%22id%22%3A%22112542596153041291285%22%2C%22me%22%3Afalse%2C%22requiresKey%22%3Afalse%2C%22email%22%3A%22babar.memon%40gmail.co%22%7D%2C%22role%22%3A30%7D%2C%7B%22scope%22%3A%7B%22iconUrl%22%3A%22%2Fc%2Fu%2F0%2Fphotos%2Fpublic%2FAIbEiAIAAABDCL_k77OCsqvJPSILdmNhcmRfcGhvdG8qKGM0MmEwMjBkZWQ0MDAzMzMwYjI2MjczZmNlZWVlMDA3NDUxMGI2N2MwAdau5OHbez_zFcRyTELkBcRF-Lv9%22%2C%22scopeType%22%3A%22user%22%2C%22name%22%3A%22Saad%20Rehman%22%2C%22id%22%3A%22104436799417545912895%22%2C%22me%22%3Afalse%2C%22requiresKey%22%3Afalse%2C%22email%22%3A%22this.saad%40gmail.com%22%7D%2C%22role%22%3A20%7D%2C%7B%22scope%22%3A%7B%22iconUrl%22%3A%22%2Fc%2Fu%2F0%2Fphotos%2Fpublic%2FAIbEiAIAAABDCL_k77OCsqvJPSILdmNhcmRfcGhvdG8qKGM0MmEwMjBkZWQ0MDAzMzMwYjI2MjczZmNlZWVlMDA3NDUxMGI2N2MwAdau5OHbez_zFcRyTELkBcRF-Lv9%22%2C%22scopeType%22%3A%22user%22%2C%22name%22%3A%22Saad%20Rehman%22%2C%22id%22%3A%22104436799417545912895%22%2C%22me%22%3Afalse%2C%22requiresKey%22%3Afalse%2C%22email%22%3A%22this.saad%40gmail.com%22%7D%2C%22role%22%3A60%7D%2C%7B%22scope%22%3A%7B%22scopeType%22%3A%22user%22%2C%22name%22%3A%22Asim%20Kazmi%22%2C%22id%22%3A%22118161687853857289891%22%2C%22me%22%3Afalse%2C%22requiresKey%22%3Afalse%2C%22email%22%3A%22asim.kazmi%40elasticaqa.info%22%7D%2C%22role%22%3A20%7D%2C%7B%22scope%22%3A%7B%22scopeType%22%3A%22user%22%2C%22name%22%3A%22Asim%20Kazmi%22%2C%22id%22%3A%22118161687853857289891%22%2C%22me%22%3Afalse%2C%22requiresKey%22%3Afalse%2C%22email%22%3A%22asim.kazmi%40elasticaqa.info%22%7D%2C%22role%22%3A60%7D%5D%7D

What if I only want the email addresses that have role 30 next to them, or in another rule, all the email addresses that have role 20 next to them.
This is what I have done so far:
`
.*?email.22.3A.22([a-zA-Z0-9_.+%-]+?%40[a-zA-Z0-9_%-]+?[.][a-zA-Z0-9_.%-]+?).22[^r]+role.22.3A30.7D

This is supposed to give me all the email addresses that have role 30 next to them i.e. babar.memon%40elastica.com. If I put .0 in place of 30, then I get all the email addresses, just like how I want them, except that I want them separately, first all the ones that have role 30, then role 20 etc.
This regex can be found in action here https://regex101.com/r/rW0qO9/1

A: Regex can be use to extract the pattern from string, you can't extract them in specific order since each match is a sub-string of sample string. You have to collect these matches and order them in the later stage.
Also there is a possibility that you construct your regex dynamically by parameterizing the (.0) part (in your regex) with 20 and 30 and 40 by taking a variable and extract each of them one by one.

A: Try this regular expression
.*?email.22.3A.22([a-zA-Z0-9_.+-]+?%40[a-zA-Z0-9_%-]+?[.][a-zA-Z0-9_.-]+).22[^r]+role.22.3A(20).7D
, I have slightly changed the capturing group since in email address we cannot have special character like %, so it will be only appearing when '@' is encoded  as %40


text:
Q: Count number of items within lists within matrix R I have two a matrix where some of the cells within the matrices are NA and others are filled with a list of numbers. And what I need is a way to calculate the number of items within each list for each cell of the matrix.
Here is the matrix:
> matrix_1
     [,1]      [,2]
[1,] NA            c(1001, 1002)
[2,] c(1001, 1003) NA

Here is what I am looking for:
     [,1]    [,2]
[1,] NA      2
[2,] 2       NA

The actual data set is much, much larger - so I am trying to avoid loops.
Here is the dput:
Matrix 1 = structure(list(NA, c(1001, 1003), c(1001, 1002), NA), .Dim = c(2L,
2L))

A: Maybe you can try lengths + replace like below
> replace(lengths(matrix_1),which(is.na(matrix_1)),NA)
     [,1] [,2]
[1,]   NA    2
[2,]    2   NA

A: You could decide to do:
NA^is.na(matrix1) * lengths(matrix1)
     [,1] [,2]
[1,]   NA    2
[2,]    2   NA

or even:
 `is.na<-`(lengths(matrix1), is.na(matrix1))
     [,1] [,2]
[1,]   NA    2
[2,]    2   NA

A: It seems that your description of the question and the expected output are slightly different.
The number of items in a list element conaining a single NA is 1, not NA.  So the answer to this is:
 matrix1=matrix(list(NA,c(1001,1003),c(1001,1002),NA),nrow=2)
answer=array(lengths(matrix1),dim=dim(matrix1))
answer
#      [,1] [,2]
# [1,]    1    2
# [2,]    2    1

However, if you want to convert all the elements corresponding a single NA entry to be NA themselves (in agreement with your expected output), you can do the extra step:
answer[is.na(matrix1)]=NA
answer
#      [,1] [,2]
# [1,]   NA    2
# [2,]    2   NA

Note that elements of more-than-one item, of which some are NA won't be detected by this last step...  (you'd need to use answer[sapply(matrix1,function(x) any(is.na(x)))]=NA instead).


text:
Q: Сортировка по русскому алфавиту С++ В задании по С++ сказанно отсортирвать массив названий товаров продуктового магазина по алфавиту на русском. С английской сортировкой в Java мне все проще - я просто подключала библиотеку и вызывала пару методов, а тут прямо ступор.

A: Пример для строк:
auto a = std::vector<std::string>{
  "Зебра",
  "ягоды",
  "Арбуз",
  "Яблоко",
};

std::sort(a.begin(), a.end(), std::locale("ru_RU.UTF-8"));

Для объектов расширяется элементарно.


text:
Q: In Coq, `Export`, `Require`, and filtered_import do not work well In Coq, Export, Require, and filtered_import do not work well.
I made _CoqProject.
-R theories/ Library_Name

theories/A/B.v
theories/A.v
theories/C.v

I made theories/A/B.v.
Definition foo : _ := _.

I made theories/A.v.
Require Library_Name.A.B.
Export Library_Name.A.B (foo).

Definition baa : _ := _.

I made theories/C.v.
Require Library_Name.A.
Import Library_Name.A (baa).

Definition baz : _ := A.foo.

However, coqc said it could not find A.foo on theories/C.v.
What I want to hear is how to refer to A.B.foo as A.foo, which is better than redefining it in A.

A: Your desire is reasonable, but not how Export works.  What you want amounts to a "filtered Include", not a "filtered Export".
When you write Export Library_Name.A.B (foo)., this says "when the current module is Imported, also make the unqualified foo available".  It does not change the qualified name of foo, which is still Library_Name.A.B.foo.
You can do something like
Notation foo := Library_Name.A.B.foo (only parsing).

in A.v, and then you'll get A.foo.  Or, if Include gets support for filtering (consider submitting a feature request for this?), you could write Include Library_Name.A.B (foo) (except that this syntax conflicts with inclusion of module functor applications...)


text:
Q: Laravel pivot table with additional fields Hi I'm trying to sync my pivot table with some additional fields.
But the problem is I don't know how to include these additional fields in my controller. Untill now, I never needed extra fields in pivot table. So I'd just go with $model->relation->sync(array_of_ids, false) but cant figure out how to send other fields with the IDs of related model. here is my current code
Model:
public function speakers(){

    return $this->BelongsToMany('App\Models\Speaker', "speaker_session_items",
        "session_item_id", "speaker_id")->withPivot('event_id', 'edition_id')
        ->withTimestamps();
}

Controller:
public function store_speakers(Request $request){

    $speakers = $request->input('speaker_id');
    $session_item = SessionItem::findOrFail($request->input("session_item_id"));
    $related = ['event_id' => $request->input('evnet_id'),
                'edition_id' => $request->input('edition_id')];

    $status =  $session_item->speakers()->sync($speakers, $false);

   print_r($status);
}

I want to send related data (edition and event as well) how can I do that?

A: You can use save
    $status =  $session_item->speakers()->save($speakers, ['your-additional-attribute' => 'value']);

for using sync
$user->roles()->speakers( [
   1 => [ 'attribute' => value ],
   2 => [ 'attribute' => value ],

]);

For saving many you can use saveMany()
    $status =  $session_item->speakers()->saveMany($YourData);

Hope this helps


text:
Q: Yarn autorestart failed application We've a streaming application running on yarn and we would like to ensure that is up running 24/7.
Is there a way to tell yarn to automatically restart a specific application on failure?

A: Have you tried Hadoop Yarn - ResourceManger Restart
Yarn will restart the driver if this fails with the feature "yarn.resourcemanager.am.max-attempts", and by default it's 2.

A: You can specify the max attempt of a specific application using ApplicationSubmissionContext::setMaxAppAttempts
Here is the document for this function