unexpected result when evaluating operators

I have below the code and this gives an unexpected result. To my knowledge, the result should be 6 but its 1. Can any one help me get it?

int j = 0;
int i1 = j * 5 + ++ j;
System.out.println ("j =" + j);
System.out.println ("i1 =" + i1);

replacement – Unexpected behavior of Nothing in the list inside the association

This question already has an answer here:

When evaluating the following entry:

<|a ->    {c, d, e} |> /. d -> nothing

I receive (expression 1):

<|a ->    {c, nothing, e} |>

However, I would expect to get (Expression 2):

<|a ->    {c, e} |>

However, if I put the cursor on the unexpected output (expression 1) and evaluate it by pressing Shift + Enter, I get the expected output (expression 2), which is even more surprising.

The version of Mathematica is 11.0.0.0

Should we expect this behavior or is it a bug? Why?

javascript – Unexpected end of the JSON entry when trying to display the main page on nodejs

I'm trying to make the main page in the index page of my node.js server where I'm storing the .json files in my data folder. However, when I try to run my server, it displays "SyntaxError: Unexpected end of the JSON entry" in product.js. , and following the error, here is where he accuses the error

cb (JSON.parse (contentFile));

here is my whole class on how I model my product

const fs = require (& # 39; fs & # 39;);
const path = require (& # 39; path & # 39;);

const p = path.join (
path.dirname (process.mainModule.filename),
& # 39; Data & # 39 ;,
& # 39; produits.json & # 39;
)

const getProductsFromFile = cb => {
fs.readFile (p, (err, fileContent) => {
if (err) {
cb ([])
} other {
cb (JSON.parse (contentFile));
}
});
};

module.exports = class Product {
constructor (title, imageUrl, description, price) {
this.title = title;
this.imageUrl = imageUrl;
this.description = description;
this.price = price;
}

save() {
getProductsFromFile (products => {
products.push (this);
fs.writeFile (p, JSON.stringify (products), err => {
console.log (err);
});
});
}

static fetchAll (cb) {
getProductsFromFile (cb);
}
};

Now, that's the problem, it accuses an analysis error but does not currently store anything in a file. Therefore, I do not know why he gives me this error.

design – Should we expect unexpected values ​​from external APIs?

Let's say you code a function that takes the inputs of an external API MyApi.

This external API MyApi has a contract that states that he will return a chain or one number.

Is it recommended to protect yourself against things like no, indefinite, booleanetc. even if it's not part of the API of MyApi? In particular, since you have no control over this API, you can not give the guarantee through a static type analysis, so it is best to be cautious that sorry ?

I think of the principle of robustness.

Unexpected behavior in RealDigits

Can any one explain this strange result that I get using RealDigits? The number 1.001 produces numbers {1,0,0,0} instead of {1,0,0,1}. Minimum work sample below:

enter the description of the image here

8 – unexpected URL redirection when contact_form submission

I've set the language path prefix for my site with & # 39; / in & # 39; and & # 39; /. & # 39; When I submit the contact form of the path / en / user / 13 / contact to send a message to the user, the page redirects to / us / user / 13. But I think the redirect path should be / us / user / 13 or just my home page.
I have tried to solve this problem in my custom xylogin module, but this has no effect.

function xylogin_form_alter (& $ form,  Drupal  Core  Form  FormStateInterface $ form_state, $ form_ID) {
if ($ form_id == & # 39; contact_message_personal_form & # 39;) {
$ form['#submit'][]    = & # 39; xylogin_form_submit & # 39 ;;
}
}

function xylogin_form_submit ($ form, & $ form_state) {
$ state_format-> setRedirect (& # 39;& # 39;);
}

How can I correct unexpected redirection behavior in a simple way?

pdo – PHP error: syntax error, & # 39;} & # 39; unexpected, waiting for ", & # 39; or & # 39 ;; & # 39 ;; in /var/app/current/rider.php on line 139

I can not identify the syntax error here but my web server can not handle my php.

I'm developing a web application that includes a form that allows users to enter data. This form uses PHP to write to a MySql database in AWS

setAttribute (PDO :: ATTR_ERRMODE, PDO :: ERRMODE_EXCEPTION);

$ sql = "INSERT INTO riderInfo (partyNM, numParty, numCooler, phoneNum, pickUp)
VALUES ("POST $"["partyName"]. "& # 39; & # 39;". $ _ POST["numParty"]. "& # 39; & # 39;". $ _ POST["numCooler"]. "& # 39; & # 39;". $ _ POST["phoneNum"]. "& # 39; & # 39;". $ _ POST["pickUP"]. "& # 39;)";

$ dbh-> exec ($ sql);

} catch (Exception $ e) {
echo # Captured Exception: #, $ e-> getMessage (), " n";
}
}
$ dbh = null;

?>

The form must write to the database, but this is not the case. He expires. In the AWS logs, I have the following message:

Undefined index: email in /var/app/current/index.php on line 117
[Fri Jan 11 20:58:01.737589 2019] [php7:emerg] [pid 3327] [client 73.185.231.76:50783] PHP parsing error: syntax error, & # 39;} & # 39; unexpected, wait for ", & # 39; or & # 39 ;; & # 39 ;; in /var/app/current/rider.php on line 138

I can not identify the syntax problem in my PHP.

c ++ 11 – Unexpected conversion warning – on the arithmetic addition of unsigned shorts (C ++ 11)

I have code on which I did not expect to receive a warning and I wonder if there are key type conversion agreements that I have missed or misunderstood.

Here is my code:

unsigned short totalMinutes = firstPtr-> Minutes + secondPtr-> Minutes;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I can tell you that the minutes of the first and second minutes are also defined as unsigned shorts.

However, I receive a -Wconversion error on this line of code indicating that:

error: the implicit conversion loses the precision of the integer: "int & # 39; in & quot; unsigned short & # 39; [-Werror,-Wconversion]

Is there an implicit conversion when using the unsigned entries / shorts / characters arithmetic?

Analysis error: syntax error, unexpected end of file in alguem ajuda pff

Alguem asked me to decide the end of the file

$ p_page = isset ($ _GET[‘action’])
if (isset ($ _GET[‘action’])) {
switch ($ _GET[‘action’]) {
case & # 39; emailchange & # 39 ;:
echo (& # 39;);
Pause;}}

                case "raise":
echo (& # 39;& # 39;);
Pause;

case "FC":
echo ("TEST");
Pause;

default:
print "Choose an action";
}

} other {
echo "Choose an option from the left menu.";}
?>
`

Unexpected Bright Behavior in Graphics3D

I use ChartElementData[“CylindricalSector3D”] generate graphs representing a series of concentric rings stacked (4 rings, 3 layers of height). I'm trying to highlight sections of this via varying opacities, so I've configured it as a function f[a,b,c,{d1,d2,d3,d4},{e1,e2,e3}]; a / b / c defines some basic parameters, dn are the opacities of the rings and are the opacity of the layers.

Moreover, as "CylindricalSector3D" natively draws a vertical face that has visible edges, I have generated new contours with cylinders with FaceForm.[None]. Code:

rads2[bore_] : = 0.5 * {{30.35 + 1.75 * bore, 37.1}, {18.95 + 1.75 * bore, 30.35 - 1.75 * bore}, {7.3 + 0.8 * bore, 18.95 - 1.75 * bore}, {0, 7,3 - 0,8 * annoy}};
hts2 = {5,7, 6,4, 6,2};
faceHeights[zSep_, heights_, zoffset_] : = 0.5 * height * {- 1, 1} + 0.5 * zoffset * (6.4 + height + 2 * zSep) * {1, 1};

cols2 = {darker[Purple, 0.5], Blue, darker[Green, 0.7], Darker[Orange, 0.3]};
light[color_, blending_] : = {{"Ambient", GrayLevel[0.4]}, {"Directional", Mixture[{GrayLevel[0.1]color} mix], {0, 0, 1}}};

opcts[opH_, opV_] : = Opacity[0.15 + 0.85*opH*opV];
segments[rad_, zSep_, opH_, opV_, heights_, zoffset_] : = {opcts[opH, opV], EdgeForm[None], ChartElementData["CylindricalSector3D"][{{0, 2 [Pi]}, rad, FaceHeights[zSep, heights, zoffset]}, 0]};
edges[i_, j_, bore_, zSep_, opH_, opV_, heights_, zoffset_] : = {FaceForm[None], EdgeForm[Directive[Thickness[0.003], opcts[opH, opV]]], Map[Cylinder[{{00faceHeights[Cylinder[{{00faceHeights[Cylindre[{{00faceHeights[Cylinder[{{00faceHeights[zSep, heights, zoffset][[1]]}, {0, 0, faceHeights[zSep, heights, zoffset][[2]]}}, #]&, rads2[bore][[i]]]};

The first block is the basic geometric configuration. The second defines my custom lighting: I highlight the different rings by illuminating them from the top with different colors. The third generates individual segments and edges, which will be combined with Table to form the complete image.

Segments and contours seem to work well independently:

all segments[bore_, zSep_, coloring_, opacHoriz_, opacVert_] : = Graphics3D[Table[{Lighting->light[cols2[Table[{Lighting->lght[cols2[Table[{Eclairage->lumière[cols2[Table[{Lighting->lght[cols2[[i]]to color]segments[rads2[rads2[rads2[rads2[bore][[i]], zSep, opacHoriz[[i]], opacVert[[j]], hts2[[j]], j - 2]}, {i, 1, 4}, {j, 1, 3}], Boxed -> False, Method -> {"ShrinkWrap" -> True}];
alledges[bore_, zSep_, coloring_, opacHoriz_, opacVert_] : = Graphics3D[Table[{Edges[ijborezSepopacHoriz[Table[{Edges[ijborezSepopacHoriz[Table[{bords[ijborezSepopacHoriz[Table[{edges[ijborezSepopacHoriz[[i]], opacVert[[j]], hts2[[j]], j - 2]}, {i, 1, 4}, {j, 1, 3}], Boxed -> False, Method -> {"ShrinkWrap" -> True}];

opts = Transpose @ {
{0, 0, 0, {1, 1, 1, 1}, {1, 1, 1}},
{0.5, 0.5 * 10, 0.5, {1, 1, 1, 1}, {1, 1, 1}},
{1, 10, 1, {1, 1, 1, 1}, {1, 1, 1}},
{1, 10, 1, {1, 1, 1, 1}, {1, 0, 0}},
{1, 10, 1, {1, 1, 1, 1}, {0, 1, 0}},
{1, 10, 1, {1, 1, 1, 1}, {0, 0, 1}},
{1, 10, 1, {1, 0, 0, 0}, {1, 1, 1}},
{1, 10, 1, {0, 1, 0, 0}, {1, 1, 1}},
{1, 10, 1, {0, 0, 1, 0}, {1, 1, 1}},
{1, 10, 1, {0, 0, 0, 1}, {1, 1, 1}}
};
GraphicsRow[MapThread[allsegments, opts], Image size -> 1300]GraphicsRow[MapThread[alledges, opts], Image size -> 1300]

enter the description of the image here

However, when I try to combine them into a single Graphics3D object, most of my highlights appear to be affected. This seems surprising since both are filled with identical tables in the previous example and I have just grouped the arguments together.

combined[bore_, zSep_, coloring_, opacHoriz_, opacVert_] : = Graphics3D[Table[{Lighting->light[cols2[Table[{Lighting->lght[cols2[Table[{Eclairage->lumière[cols2[Table[{Lighting->lght[cols2[[i]]to color]segments[rads2[rads2[rads2[rads2[bore][[i]], zSep, opacHoriz[[i]], opacVert[[j]], hts2[[j]], j - 2]edges[ijborezSepopacHoriz[ijborezSepopacHoriz[ijborezSepopacHoriz[ijborezSepopacHoriz[[i]], opacVert[[j]], hts2[[j]], j - 2]}, {i, 1, 4}, {j, 1, 3}], Boxed -> False, Method -> {"ShrinkWrap" -> True}];
GraphicsRow[MapThread[combinedFeats, opts], Image size -> 1300]

enter the description of the image here

It is interesting to note that the appropriate lighting is always present, but apparently applied from below:

GraphicsRow[Table[Show[combinedFeats[1, 10, 1, {1, 1, 1, 1}, {1, 1, 1}], Viewpoint -> {1.3, -2.4, vpz}], {vpz, {2, 0, -2}}], Image size -> 1000]

enter the description of the image here

In addition, even if the compiled segments and contours are generated correctly (first image), trying to combine them with Show generates similar (but different) problems:

combined images[bore_, zSep_, coloring_, opacHoriz_, opacVert_] : = Show[{allsegments[bore, zSep, coloring, opacHoriz, opacVert], alledges[bore, zSep, coloring, opacHoriz, opacVert]}, Boxed -> False];
GraphicsRow[MapThread[combinedImgs, opts], Image size -> 1300]

enter the description of the image here

Normally, I would not be surprised to have to flesh out an unwanted interaction with the lighting / camera settings when interleaving segments and edges (compared to their joint use, but this is n & # 39; 39, obviously not explain the problem that appears with show.

Note:

  • I've been able to find a refreshing simple (if not entirely
    satisfying) workaround that suited my example – add a
    second light source of the opposite site. So, it's mostly for my
    edification.
  • In addition, I was using ParametricPlot3D in a previous version
    version and do not remember these problems arising but I found myself
    go to the cylinders because they were simpler and faster
    assess.
  • Finally, there are probably more elegant ways than using
    "CylindricalSector3D" (that's a bit awkward), but others
    versions of that ended up using non-circular sectors so I was looking at
    build that

Thanks in advance!