text:
Q: Vorticity Stretching in an Axisymmetric Flow Without Swirl For an axisymmetric flow with zero swirl the velocity field is $$u=u_r \hat e_r+u_z\hat e_z$$ which results in the following vorticity field $$\omega=\omega_\theta\hat e_\theta$$
Here, $\omega_\theta=\partial_zu_r-\partial_ru_z$ from taking the curl.
When I look at the incompressible inviscid vorticity equation $$D_t\omega=u\cdot\nabla\omega=\omega\cdot\nabla u$$ I run into the following problem.
Normally in 2D flows the vortex stretching term is zero, that is $\omega\cdot\nabla u=0$. This is because $\omega\cdot\nabla u=\omega_\theta\frac{1}{r}\partial_\theta u$ and since $u=u(r,z)$ only. However, $\hat e_r=\begin{pmatrix}\cos(\theta)\\\sin(\theta)\\0\end{pmatrix}$ so $\partial_\theta\hat e_r=\begin{pmatrix}-\sin(\theta)\\\cos(\theta)\\0\end{pmatrix}=\hat e_\theta$, expanding $\omega\cdot\nabla u$ with product rule gives (in it's fully simplified form) $\omega_\theta \frac{u_r}{r}\hat e_\theta$ not zero.
How can $u\cdot\nabla\omega=0$ and $\omega_\theta \frac{u_r}{r}\hat e_\theta$? I'm not sure if because the flow is axisymmetric if that means the $\frac{1}{r}\partial_\theta$ in $\nabla$ vanishes or not. If it does, then obviously the only remaining derivatives render the vortex stretching term zero.

A: Two-dimensional flow is defined with reference to a Cartesian coordinate system as a velocity field that (1) depends on only two spatial coordinates (say $x$ and $y$) and (2) has a zero component in the third direction ($u_z$ = 0 in this case).  Even without swirl, axisymmetric flow is not two-dimensional.  There are non-zero velocity components along all three Cartesian directions.
In two-dimensional flow the vorticity must be perpendicular to the plane of the flow and there is no vortex-line stretching. For a velocity field $(u_x(x,y), u_y(x,y)$) the vorticity is aligned in the $z-$direction and the vortex stretching term is
$$\mathbb{\omega} \cdot \nabla\mathbb{u}= \omega_z \frac{\partial u_x}{\partial z}\hat e_x + \omega_z\frac{\partial u_y}{\partial z}\hat e_y = 0.$$
However, the vortex stretching term need not be zero in axisymmetric flow.   In the case of axisymmetric flow without swirl, we have
$$\mathbb{\omega} \cdot \nabla\mathbb{u}= \frac{u_r \omega_\theta}{r} \hat e_\theta.$$
There must be some non-zero radial velocity component for the vortex-line stretching to be present. In fully-developed laminar flow in a pipe, there is only a non-zero axial velocity component and the stretching is absent.


text:
Q: grep -f file search I have two files. the first (file1.txt) has about 15,000 lines and the second file (file2.txt) has about 180,000 lines. I am trying to find all of the matching lines from file1.txt and remove them from file2.txt. What I am currently trying is this:
grep -v -f file1.txt file2.txt > out.txt

This does work, but takes an extremely long time. I am trying to find a way to speed this up, but am having trouble figuring it out. Does anyone have a suggestions?
Thank for your help

A: if the definition of "match" here is "identical":
try this:
awk 'NR==FNR{a[$0];next;}!($0 in a)' file1 file2 >out.txt

redpajama_set_name: RedPajamaStackExchange


text:
Q: Covert a column of integers and interger + strings into all integers using multiplication based on what is in the string How do I convert this column of values, mostly integers, and some strings to all integers.
The column looks like this,
x1
___
128455551
92571902
123125
985166
np.NaN
2241
1.50000MMM
2.5255MMM
1.2255MMMM
np.NaN
...

And I want it to look like this, where the rows with MMM, the characters are dropped and the number is multiplied by a billion (10**9) and converted to integers.
The rows where there are MMMM, the characters are dropped and the number is multiplied by a trillion (10**12) and converted to integers.
Basically each M means 1,000. There are other columns so I cannot drop the np.NaN.
x1
___
128455551
92571902
123125
985166
np.NaN
2241
1500000000
2525500000
1225500000000
np.NaN
...

I tried this,
df['x1'] =np.where(df.x1.astype(str).str.contains('MMM'), (df.x1.str.replace('MMM', '').astype(float) * 10**9).astype(int), df.x1)

When I do it with just the 2 rows it works fine, but when I do it with the whole dataframe I get this error, IntCastingNaNError: Cannot convert non-finite values (NA or inf) to integer.
How do i fix it?

A: A possible solution:
def f(x):
    if isinstance(x, str):
        ms = x.count('M')
        return float(x.replace('M' * ms, '')) * 10**(3 * ms)
    else:
        return x

df['x1'] = df['x1'].map(f).astype('Int64')

Output:
              x1
0      128455551
1       92571902
2         123125
3         985166
4           <NA>
5           2241
6     1500000000
7     2525500000
8  1225500000000
9           <NA>

A: You can also try the following solution:
import numpy as np

(df.x1.str.extract('([^M]+)(M+)?').replace({np.NaN : None})
 .assign(power = lambda x: 10 ** (3 * x.loc[:, 1].str.count('M').fillna(0)))
 .pipe(lambda d: d.loc[:, 0].replace({'np.NaN' : None}).astype(float).mul(d.power)))

0    1.284556e+08
1    9.257190e+07
2    1.231250e+05
3    9.851660e+05
4             NaN
5    2.241000e+03
6    1.500000e+09
7    2.525500e+09
8    1.225500e+12
9             NaN
dtype: float64

A: When considering  string values containing M, sanitized value can be multiplied on 1000 as much as M occurrences (according to your condition "Basically each M means 1,000"):
df['x1'] = np.where(df.x1.str.contains('M'),
                    (df.x1.str.replace('M', '').astype(float) \
                     * pow(1000, df.x1.str.count('M'))).astype('Int64'), df.x1)

print(df)

              x1
0      128455551
1       92571902
2         123125
3         985166
4            NaN
5           2241
6     1500000000
7     2525500000
8  1225500000000
9            NaN


text:
Q: Display diagonal line when only one point is selected I have a graph like this:

This is my dimension tab:

This is my expression tab:

The third dimension is there to create the diagonal line (see the linear reference at the bottom left in my expression tab). I got the idea from here!
When I select only one point in the graph the line disappears (see below). But I want it to remain there. Other solutions to display a diagonal line are welcome too. Thanks for the help!!

This is my csv file:
SA,PLAN,IST
tyre,0.3,0.2
steering wheel,0.7,0.9
seat heater,0.9,0.1

A: My workaround is to create a second scatter chart which will only show up when only one entity is selected. Then make the background of that scatter chart transparent and add a diagonal line object. You need also to fix the axis both to 100%.


text:
Q: On the $L^2$-norm of symmetrized functions. A question concerning the book on Malliavin calculus from Nualart In the page 10 of the book "The Malliavin Calculus and Related Topics" from Nualart one reads:

Letting $f=g$ in property $\rm (iii)$ obtains $$E(I_m(f)^2)=m!\|\tilde{f}\|^2_{L^2(T^m)}\leq m!\|f\|^2_{L^2(T^m)}.$$

The last inequality suggests that $\|\tilde f\|_{L^2(T^m)}\leq\| f\|_{L^2(T^m)}$ does not hold with equality,
otherwise one would write $$ \|\tilde f\|_{L^2(T^m)}=\| f\|_{L^2(T^m)}$$
Herre $\tilde f$ is the symmetrization of $f$.
The definition can be read in page 9

$\rm(ii)$ $I_m(f)=I_m(\tilde{f})$, where $\tilde f$ denotes the symmetrization of $f$, which means $$\tilde{f}(t_1,\ldots,t_m)=\frac1{m!}\sum_\sigma f(t_{\sigma(1)},\ldots,t_{\sigma(m)}),$$ $\sigma$ running over all permutations of $\{1,\ldots,m\}$,

Is there an example of when the inequality holds strictly?

A: Yes, take $f = 1_{[a,b]\times [c,d]}$. with $a > d$ so that the function does not intersect the diagonal.
The symmetrization of $f = \frac{1}{2}1_{[a,b]\times [c,d]} +  \frac{1}{2}1_{[c,d]\times [a,b]}$
When we compute the $L^2$-norm, we find
$$\|\tilde f\|^2 = \frac{1}{4} \mu([a,b])\mu(c,d) + \frac{1}{4} \mu([c,d])\mu(a,b) < \mu([a,b])\mu(c,d) = \| f\|^2 $$


text:
Q: PHP Login Form In Bootstrap 3 Modal I've started created a login form within a Bootstrap modal, I already have the code for the modal (simple bootstrap modal), and I have the PHP code to complete the login on a separate page (login.php), but I would like to have the login validate and return the errors inside the modal, possibly without refreshing the page. Here are examples: http://demo.flarum.org/#/ and https://phpacademy.org/, both have a login modal, and return errors as well as displaying a loading icon.
Here is my modal code with the form:

Sign In

        <form method="POST" class="form-signin">

                <input type="text" class="form-control" name="username" placeholder="Username" autocomplete="off" autofocus="on">

                <input type="password" class="form-control" name="password" placeholder="Password">

                <button type="submit" class="btn btn-primary btn-block" name="submit">Sign In</button>

        </form>

Don't have an account yet? Sign Up

And here is the simple php code in login.php, (I know this code can be improved, but just as an example) that I would like to somehow attach to the modal.
 if (!empty($_POST)) {

    $username = $_POST['username'];
    $password = $_POST['password'];

    if (empty($username) && empty($password)) {
        $errors[] = 'Please enter a username and password!';
    }

    else if (empty($username)) {
        $errors[] = 'Please enter a username!';
    }

    else if (empty($password)) {
        $errors[] = 'Please enter a password!';
    }

    else {

        $login = login($username, $password);

        if (!$login) {
            $errors[] = 'Couldn\'t sign you in with those details!';
            echo outputErrors($errors);
        } else {
            $_SESSION['user'] = $login;
            redirect('index.php');
        }

    }

}

I might be doing a lot wrong, but if someone could point me in the right direction or show me some example code that would be great.
Thanks in advance! :)

A: As peterKA said, You need to use ajax, maybe through jquery to ease things out a bit. Do you have any knowledge in jquery? You can check out http://malsup.com/jquery/form/
a plugin that sends forms via ajax to the server with almost no modification of your code.


text:
Q: docker: Error response from daemon: driver failed programming external connectivity on endpoint redis I'm trying to practice the example provided in the link https://docs.docker.com/engine/userguide/networking/work-with-networks/#connect-containers.
docker network create -o "com.docker.network.bridge.host_binding_ipv4"="172.23.0.1" my-network

$ docker network inspect my-network
  [
{
    "Name": "my-network",
    "Id": "90158e0c6f03a62f4852fcaa429f8a4d0df0e3c27f908500337e69b42d78c3a5",
    "Created": "2017-09-15T20:14:50.778210676Z",
    "Scope": "local",
    "Driver": "bridge",
    "EnableIPv6": false,
    "IPAM": {
        "Driver": "default",
        "Options": {},
        "Config": [
            {
                "Subnet": "172.23.0.0/16",
                "Gateway": "172.23.0.1"
            }
        ]
    },
    "Internal": false,
    "Attachable": false,
    "Ingress": false,
    "ConfigFrom": {
        "Network": ""
    },
    "ConfigOnly": false,
    "Containers": {},
    "Options": {
        "com.docker.network.bridge.host_binding_ipv4": "172.23.0.1"
    },
    "Labels": {}
}
 ]

Then the next docker command to run the redis on this network is giving me the error.
$docker run -d -P --name redis --network my-network redis

8a91f4a6e6a688173060ac20d71b461e13a7c7b7d6cbf1318d66114922e47357
docker: Error response from daemon: driver failed programming external connectivity on endpoint redis (4e8fad58239e5785f31c0c4e18a276f334410bcec3f9ecb6ec850d75e6120250): Error starting userland proxy: listen tcp 172.23.0.1:32787: bind: cannot assign requested address.
How this error can be resolved?

A: Just to avoid headache , restart docker once and test it again


text:
Q: Prove by induction $\sum_{i=1}^{n} \frac{1}{\sqrt{i}}$ $< 2\sqrt{n}$ for $n \geq 1$ So far I have this. I have a feeling I'm getting off track with the last two steps.
We want to prove  $\sum_{i=1}^{n} \frac{1}{\sqrt{i}}$ $< 2\sqrt{n}$ for $n \geq 1$
Base Case
Prove P(1): $\sum_{i=1}^{1} \frac{1}{\sqrt{1}}$ $< 2\sqrt{1}$. We get $1 < 2$.
Induction Hypothesis
$\sum_{i=1}^{n} \frac{1}{\sqrt{n}}$ $< 2\sqrt{n}$ is true for $n \geq 1$
Induction Step
Prove P(k + 1): $\sum_{i=1}^{k + 1} \frac{1}{\sqrt{k + 1}} < 2\sqrt{k + 1} $
LHS = $\sum_{i=1}^{k + 1} \frac{1}{\sqrt{k + 1}}$
= $\sum_{i=1}^{k} \frac{1}{\sqrt{k}}$ - 1 + $\frac{1}{\sqrt{k + 1}}$ + $\frac{1}{\sqrt{k + 2}}$
$< 2\sqrt{k}$ - 1 + $\frac{1}{\sqrt{k + 1}}$ + $\frac{1}{\sqrt{k + 2}}$

A: Hint: $$2(\sqrt{n+1}-\sqrt n)=\frac2{\sqrt{n+1}+\sqrt n} $$

A: You should only be doing induction on $n$, not changing the index $i$ as well. We only want to show that this holds if we add the first $n$ terms of the series. For example, your induction hypothesis should read
$$\sum_{i=1}^n \frac{1}{\sqrt{i}}=\frac{1}{\sqrt{1}} + \frac{1}{\sqrt{2}} + \cdots + \frac{1}{\sqrt{n}}$$
instead of
$$\sum_{i=1}^n \frac{1}{\sqrt{n}} = \frac{1}{\sqrt{n}} + \frac{1}{\sqrt{n}} + \cdots + \frac{1}{\sqrt{n}}$$
Similar story for when you do the induction step, which has the additional complication of switching from $n$ to $k$. Your induction step should read:
$$\sum_{i=1}^{n+1} \frac{1}{\sqrt{i}} = \frac{1}{\sqrt{1}} + \frac{1}{\sqrt{2}} + \cdots + \frac{1}{\sqrt{n}} + \frac{1}{\sqrt{n+1}}$$
How can we use our induction hypothesis to bound this?


text:
Q: JavaFX Canvas draw always in the same location I'm trying to draw an airplane on a canvas and move it(Don't know if it matters - a second Canvas placed in the same location in a GridPane as the first Canvas which is drawned last, like in the picture) . I used GraphicContext appendSVGPath , and positined the airplane succesfully :

I've added a button to test the movement by increasing x and y by 2 each click, triggering the redraw. the redraw indeed was triggered, and with the correct parameters, but the drawing stays the same. I tried testing what happens if in the second time clicked, I only run the clearRect command, and indeed the airplane was cleaned so I assume it just redraw it in the same location every time..
What am I missing?
public class AirplaneDrawer extends Canvas{
    public double x,y,rotate,lastX,lastY;
    public boolean isFirst = true;

    public void setCords(double x,double y,double rotate) {
        if(x != this.x || y != this.y || rotate != this.rotate) {
            lastX=this.x;
            lastY=this.y;
            this.x = x;
            this.y = y;
            this.rotate = rotate;
            redraw();
        }
    }

    public void redraw() {
        GraphicsContext gc = getGraphicsContext2D();
        String path = new String("M 323.193 226.645 c 39.244 24.41 75.644 47.053 115.706 71.978 c 7.687 -5.443 20.518 -14.485 33.308 -23.596 c 16.733 -11.923 36.27 -11.452 49.046 3.779 c 3.513 4.191 2.568 15.766 -0.705 21.426 c -23.705 40.994 -48.427 81.404 -73.095 121.833 c -4.729 7.745 -9.06 19.278 -21.177 13.509 c -12.203 -5.8 -28.746 -9.521 -27.842 -28.026 c 0.891 -18.185 3.495 -36.292 4.924 -50.249 c -40.704 -19.793 -79.74 -38.778 -119.825 -58.269 c -16.168 17.561 -22.275 40.532 -27.606 64.119 c -8.975 39.719 -18.474 79.324 -28.171 118.881 c -5.593 22.809 -12.452 26.109 -34.167 17.908 c -28.122 -10.606 -31.047 -14.689 -31.318 -45.384 c -0.605 -68.198 -1.514 -136.4 -1.325 -204.593 c 0.045 -15.865 -4.177 -25.531 -19.237 -32.95 c -30.238 -14.884 -60.119 -30.866 -88.548 -48.915 c -13.988 -8.884 -26.951 -21.77 -35.867 -35.727 C 3.526 110.834 15.381 90.43 40.637 91.746 c 17.786 0.931 36.644 4.67 52.618 12.229 c 32.58 15.413 63.735 33.905 95.022 51.921 c 8.735 5.028 15.083 4.992 23.944 0.068 c 64.671 -35.921 129.717 -71.172 194.611 -106.705 c 25.712 -14.075 46.608 -10.335 65.331 12.008 c 10.309 12.302 2.247 20.797 -6.506 28.579 c -35.89 31.91 -72.438 63.093 -107.682 95.687 C 344.877 197.641 334.677 212.878 323.193 226.645 Z");
        double wid = getWidth()/247;
        double hei = getHeight()/152;
        if(!isFirst) {
            gc.rotate(360-rotate);
            gc.scale(50, 50);
            gc.translate(-lastX*wid, -lastY*hei);
        }
        gc.clearRect(0, 0, getWidth(), getHeight());
        gc.translate(wid*x,hei*y);
        gc.scale(0.02,0.02);
        gc.rotate(rotate);
        gc.appendSVGPath(path);
        gc.setFill(Color.BLACK);
        gc.fill();
        gc.stroke();
        isFirst = false;
    }
}

And the button handler in the controller :
public void btnClickHandler(MouseEvent event) {
    airplaneDrawer.setCords(airplaneDrawer.x+2, airplaneDrawer.y+2, 145);
}

Here is a part of the FXML file :
  <MapDrawer fx:id="mapDrawer" height="237.0" width="256.0" GridPane.columnIndex="1" GridPane.rowIndex="1" >
    <GridPane.margin>
      <Insets left="18.0" top="-5" />
    </GridPane.margin>
  </MapDrawer>
  <AirplaneDrawer fx:id="airplaneDrawer" height="237.0" width="256.0" GridPane.columnIndex="1" GridPane.rowIndex="1" >
    <GridPane.margin>
      <Insets left="18.0" top="-5" />
    </GridPane.margin>
  </AirplaneDrawer>

A:   This is the best I could get to make the plane move, You have to change some parameters to suit your application. What I am moving here is the canvas.
I would suggest you create another canvas for the map. (Not sure if this will work).
I still don't get why it's drawing on the same space but If you try to append another svg path after the translate (for example adding a path2 to the canvas in the if condition) you will see your second plane on another position.
public void redraw() {
            GraphicsContext gc = getGraphicsContext2D();
    String path = new String("M 323.193 226.645 c 39.244 24.41 75.644 47.053 115.706 71.978 c 7.687 -5.443 20.518 -14.485 33.308 -23.596 c 16.733 -11.923 36.27 -11.452 49.046 3.779 c 3.513 4.191 2.568 15.766 -0.705 21.426 c -23.705 40.994 -48.427 81.404 -73.095 121.833 c -4.729 7.745 -9.06 19.278 -21.177 13.509 c -12.203 -5.8 -28.746 -9.521 -27.842 -28.026 c 0.891 -18.185 3.495 -36.292 4.924 -50.249 c -40.704 -19.793 -79.74 -38.778 -119.825 -58.269 c -16.168 17.561 -22.275 40.532 -27.606 64.119 c -8.975 39.719 -18.474 79.324 -28.171 118.881 c -5.593 22.809 -12.452 26.109 -34.167 17.908 c -28.122 -10.606 -31.047 -14.689 -31.318 -45.384 c -0.605 -68.198 -1.514 -136.4 -1.325 -204.593 c 0.045 -15.865 -4.177 -25.531 -19.237 -32.95 c -30.238 -14.884 -60.119 -30.866 -88.548 -48.915 c -13.988 -8.884 -26.951 -21.77 -35.867 -35.727 C 3.526 110.834 15.381 90.43 40.637 91.746 c 17.786 0.931 36.644 4.67 52.618 12.229 c 32.58 15.413 63.735 33.905 95.022 51.921 c 8.735 5.028 15.083 4.992 23.944 0.068 c 64.671 -35.921 129.717 -71.172 194.611 -106.705 c 25.712 -14.075 46.608 -10.335 65.331 12.008 c 10.309 12.302 2.247 20.797 -6.506 28.579 c -35.89 31.91 -72.438 63.093 -107.682 95.687 C 344.877 197.641 334.677 212.878 323.193 226.645 Z");

    double wid = getWidth()/247;
    double hei = getHeight()/152;

    if(!isFirst) {
        gc.rotate(360-rotate);
        gc.scale(50, 50);
        setTranslateX(-lastX*wid);
        setTranslateY(-lastY*hei);
        gc.setStroke(Color.BLUE);
        gc.stroke();

    }
    gc.clearRect(0, 0, getWidth(), getHeight());
    System.out.println("x="+x+" y="+y);
    setTranslateX(y*wid);
    setTranslateY(y*hei);
    gc.scale(0.02,0.02);
    gc.rotate(rotate);
    gc.appendSVGPath(path);
    gc.setFill(Color.BLACK);
    gc.fill();
    gc.stroke();

    isFirst = false;

        }
    }


text:
Q: ASP.NET MVC tries to load older version of Owin assembly As a bit of context, I'm developing an ASP.NET MVC 5 application that uses OAuth-based authentication via Microsoft's OWIN implementation, for Facebook and Google only at this stage. Currently (as of v3.0.0, git-commit 4932c2f), the FacebookAuthenticationOptions and GoogleOAuth2AuthenticationOptions don't provide any property to force Facebook nor Google respectively to reauthenticate users (via appending the appropriate query string parameters) when signing in.
Initially, I set out to override the following classes:

*

*FacebookAuthenticationOptions

*GoogleOAuth2AuthenticationOptions

*FacebookAuthenticationHandler (specifically AuthenticateCoreAsync())

*GoogleOAuth2AuthenticationHandler (specifically AuthenticateCoreAsync())

yet discovered that the ~AuthenticationHandler classes are marked as internal.
So I pulled a copy of the source for the Katana project (http://katanaproject.codeplex.com/) and modified the source accordingly.
After compiling, I found that there are several dependencies that needed updating in order to use these updated assemblies (Microsoft.Owin.Security.Facebook and Microsoft.Owin.Security.Google) in the MVC project:

*

*Microsoft.Owin

*Microsoft.Owin.Security

*Microsoft.Owin.Security.Cookies

*Microsoft.Owin.Security.OAuth

*Microsoft.Owin.Host.SystemWeb

This was done by replacing the existing project references to the 3.0.0 versions and updating those in web.config. Good news: the project compiles successfully.
In debugging, I received an exception on startup:

An exception of type 'System.IO.FileLoadException' occurred in [MVC web assembly].dll but was not handled in user code
Additional information: Could not load file or assembly 'Microsoft.Owin.Security, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

The underlying exception indicated that Microsoft.AspNet.Identity.Owin was trying to load v2.1.0 of Microsoft.Owin.Security when calling app.UseExternalSignInCookie() from Startup.ConfigureAuth(IAppBuilder app) in Startup.Auth.cs.
Unfortunately that assembly (and its other dependency, Microsoft.AspNet.Identity.Owin) aren't part of the Project Katana solution, and I can't find any accessible repository for these assemblies online.

Are the Microsoft.AspNet.Identity assemblies open source, like the Katana project?
  Is there a way to fool those assemblies to use the referenced v3.0.0 assemblies instead of v2.1.0? The /bin folder contains the 3.0.0 versions of the Owin assemblies.

I've upgraded the NuGet packages for Microsoft.AspNet.Identity.Owin, and this is still an issue.
Any ideas on how to resolve this issue?

A: I updated to OWin 3.0.1 and that fixed the problem:
Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution
I searched for the references in the list (under NuGet.org) and installed new references for Microsoft.Owin as well as Microsoft.Owin.Security, Microsoft.Owin.Security.Google, Microsoft.Owin.Security.Facebook etc.
I then checked the version number in my packages.config and Web.Config file and found that this had updated correctly:
Packages.config example:
<package id="Microsoft.Owin.Security.Google" version="3.0.1" TargetFramework="net45" />

Web.Config example:
<assemblyIdentity name="Microsoft.Owin.Security" culture="neutral" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />

A: I've found that while FacebookAuthenticationHandler is marked as internal, its abstract base class AuthenticationHandler<TOptions> is fortunately public. In the end, I took the modified version of FacebookAuthenticationHandler from the Katana project source, renamed it and included it in my own solution, so that it still uses the 2.1 libraries and doesn't cause problems with the other NuGet dependencies.
Likewise for GoogleOAuth2AuthenticationHandler.
So, using the Facebook example, I have the following class definitions in my MVC project:
// Overridden to add additional property 'ForceReauthentication'
public class FacebookOAuth2ExtendedOptions : FacebookAuthenticationOptions
...

// Reimplemented v2.1 source with modified method 'ApplyResponseChallengeAsync'
public class FacebookOAuth2CustomHandler : AuthenticationHandler<FacebookOAuth2ExtendedOptions>
...

// Reimplemented v2.1 source, modified to use 'FacebookOAuth2CustomHandler '
public class FacebookOAuth2CustomMiddleware : AuthenticationMiddleware<FacebookOAuth2ExtendedOptions>
...

Finally in the Startup class (App_Start/Startup.Auth.cs), I register the authentication using my custom middleware classes:
public void ConfigureAuth(IAppBuilder app)
{
    ...

    var fbOptions = new FacebookOAuth2ExtendedOptions()
    {
        AppId = facebookAppKey,
        AppSecret = facebookAppSecret,
        ForceReauthentication = true
    };
    app.Use(typeof(FacebookOAuth2CustomMiddleware), app, fbOptions);

    ...
}

Hope this helps others with similar issues.


text:
Q: How to use tel: with * (star, asterisk) or # (hash, pound) on iOS? I'm trying to initiate a call on the iPhone with the tel url that has a * in it. It properly brings up the call dialog but drops back to safari when you click call.
Test

A: The approved answer is not correct, at least anymore. I've tested both as a web page and in app being able to dial using the special character # and *. What you do have to do if you wish to use those characters in either instance though is to encode them.
In HTML, # becomes %23 and * does not need to be escaped
If using Swift, you can encode your link and press it from an app using this function:
//number format example (commas are pauses): 123-456-7890,,555#,1234
fileprivate func callNumber(_ number: String) {
    let dialString = "telprompt://" + number
    if let escapedDialString = dialString.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed) {
      if let dialURL = URL(string: escapedDialString) {
        UIApplication.shared.openURL(dialURL)
      }
    }
  }

A: This documentation from Apple should be helpful:

To prevent users from maliciously redirecting phone calls or changing the behavior of a phone or account, the Phone application
  supports most, but not all, of the special characters in the tel
  scheme. Specifically, if a URL contains the * or # characters, the
  Phone application does not attempt to dial the corresponding phone
  number.

UPDATE (Jan 2, 2018): The information mentioned here may be outdated. Please refer to new documentation if Apple has relaxed these rules in their newer SDKs. Refer to Husam's answer.

A: iOS11 now allows us to call number with * or #

Swift Example code
    let number = "*111*12345#"
    let app = UIApplication.shared
    if let encoded = number.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed) {
        let u = "tel://\(encoded)"
        if let url = URL(string:u) {
            if app.canOpenURL(url) {
                app.open(url, options: [:], completionHandler: { (finished) in

                })
                return
            }
        }
    }

A: If you want to add * to href typed as "tel" you need to use the utf-8 encoded version - %2A
Reference :  W3
For example

 Phone me


text:
Q: Scroll Bar is not moving but not the contents Problem description:
I am totally new to the GUI development on Tkinter. Moving to the problem, i have main window and it is divided into two different frames top and bottom frame. I want to move the top frame alone when I am moving the  horizontal scroll bar. the scroll bar is moving but contents are not moving with it.
What i have tried:
the procedure followed: main window --> top frame (on main window) --> canvas (on top frame) -->  scrollable frame (on canvas) --> 10 different frames
scroll bar is connected to top frame (set to canvas xview).
though scroll bar set, again i have add the following code ( code is given at the end)
sizes:
top frame - width = 5000, height = 550,
canvas  -w = 50000 , h = 5500 ,  (scroll region - (0,0,50000,5500)),
scrollable frame - not defined,
10 diff frame - w = 500 , h = 400 ( single frame size),
bottom frame size - w = 400, height = 400
somebody please help. I am breaking my head with this for 1 week.
Code:
from tkinter import *
from tkinter.ttk import *

top1 = tk.Tk()
top1.title("Output window")

fram1 =tk.Frame(top1,width=5000,height=550,bg = 'khaki1',relief=SUNKEN)
canvas = Canvas (fram1,width=50000,height=5500,bg = 'sky blue',scrollregion(0,0,50000,5500))

fram2 =ttk.Frame(top1,width=400,height=400,relief=SUNKEN)

scroll_bar_v = tk.Scrollbar(top1,orient='vertical')
scroll_bar_v.pack( side = RIGHT, fill = Y )

scroll_bar_h = Scrollbar(fram1,orient='horizontal')
scroll_bar_h.config(command = canvas.xview)
scroll_bar_h.pack( side = BOTTOM, fill = X )

left1= ttk.Frame(fram2, borderwidth=2, height = 400,width = 500,relief="sunken")
left2= ttk.Frame(fram2, borderwidth=2, height = 400,width = 500,relief="sunken")
left3= ttk.Frame(fram2, borderwidth=2, height = 400,width = 500,relief="sunken")

left1.pack(side = 'left',padx=10, pady=10)
left2.pack(side = 'left',padx=10, pady=10)
left3.pack(side = 'left',padx=10, pady=10)

scrollable_frame = tk.Frame(canvas, bg = 'khaki1')
scrollable_frame.pack(side = 'top',padx = 10,pady = 10)

for i in range(10):

    left = tk.Frame(scrollable_frame, borderwidth=2, height = 400,width = 500,relief="sunken") # fram1 to canvas
    left. pack(side = 'left',padx=10, pady=10)
    l1 = tk.Label (left,text = i,font = ('Arial',20,'bold')).place(x = 50, y =30)

canvas.configure(xscrollcommand= scroll_bar_h.set,scrollregion=canvas.bbox("all"))
canvas.pack(fill = 'both')

fram1.pack(side = 'top')
fram2.pack(side = 'bottom')

top1.mainloop()


text:
Q: commandLink do not pass request parameters Good morning in my timezone,
I am adding some features in a JSF application,
i add the following code
 <h:link outcome="nameOut1.innerName" >
        <f:param name="idX" value="#{xbean.idElement}"/>
        <f:param name="idY" value="#{xBean.param1.param2.id}"/>
</h:link>

And i change it by this one
 <h:commandLink  action="#{xBean.validateBeforeClose}" >
        <f:param name="idX" value="#{xbean.idElement}"/>
        <f:param name="idY" value="#{xBean.param1.param2.id}"/>
</h:commandLink>

And in the bean
 public String validateBeforeClose(){
        if (isValidToRemove()) {
            setValidationToRemove(true);
            return "";
        }else{
            return "nameOut1.innerName";
        }
    }

if the first condition is true then it come back to the same View, and displays a popupWindow, if this condition is not met , then return the same outcome that the old link tag was setting.
The problem is : True the link the h:link tag the parameters are sent, i see that in the URL, but through the action the parameters are not sent.
in the faces-config i have the following configuration
<navigation-case>
      <from-outcome>nameOut1.innerName</from-outcome>
      <to-view-id>/folder1/folder2/view2.xhtml</to-view-id>
      <redirect include-view-params="true">
      </redirect>
    </navigation-case>

Why is this happening ?
Thanks in advance
Best regards


text:
Q: xslt is not calling JavaScript function I'm using xslt to transform xml to html.
Here is .xml file.
 <ImportOrganizationUtility-logging>
  <log-session module-name="ImportOrganizationUtility" end="17:54:06" start="17:52:19">
    <ou ou-name="Exchange" status="Success">
      <Steps>
        <step1 name="Add User" Username="hcimportuser3" PlanId="2" end="17:52:29" start="17:52:26" status="Success" > <log-description><![CDATA[
          User added successfully.
]]></log-description> </step1>
        <step2 name="ImportOrganization" end="17:53:35" start="17:52:29" status="Success" >  <log-description><![CDATA[
          Imported successfully.
]]></log-description></step2>
        <step3 name="Segregation Utility Operations" MailDomain="exchange.com" end="17:53:58" start="17:53:36" status="Success">
          <log-description><![CDATA[
          Operation performed successfully.
]]></log-description>
        </step3>
      </Steps>
      <log-description><![CDATA[Organization 'Exchange' imported successfully]]></log-description>
    </ou>
    <ou ou-name="APICall2" status="Failed">
      <Steps>
        <step1 name="Add User and Sell Plan" Username="hcimportuser3" PlanId="2" end="17:54:02" start="17:54:01" status="Success" />
        <step2 name="ImportOrganization" end="17:54:06" start="17:54:02" status="Failed">
          <log-description><![CDATA[Detailed error message.]]></log-description>
        </step2>
      </Steps>
      <log-description><![CDATA[Detailed error message.]]></log-description>
    </ou>
  </log-session>
</ImportOrganizationUtility-logging>

I'm creating two tables one is sub table inside tr>td and its style="display:none" applied on it. Bot tables are creating fine.
The problem I'm facing is that I have created a JavaScript function and calling it on parent table row click to toggle sub table but its not working. I added alert but not receiving any alert on row click which show that toggleRow() is not calling.
Anyone who can let me know what is wrong here. I tried but couldn't get it.
Here is .xsl file.
<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="/">

            <link rel="stylesheet" type="text/css" href="bootstrap.min.css"/>
            <link rel="stylesheet" type="text/css" href="styles.css"/>

                Organization Name

                Owner Name
                Status
                Description

              <xsl:for-each select="ImportOrganizationUtility-logging/log-session/ou">
                <xsl:sort select="@status" order="descending"/>
                <xsl:variable name="i" select="position()"/>

                    <xsl:attribute name="onclick">javascript:toggleRow(<xsl:value-of select="$i"/>)</xsl:attribute>
                    <xsl:value-of select="@ou-name"/>

                  <xsl:value-of select="Steps/step1/@Username"/>

                  <xsl:choose>
                     <xsl:when test="@status='Failed'">
                      <xsl:value-of select="@status"/>
                      </xsl:when>
                       <xsl:otherwise >
                          <xsl:value-of select="@status"/>
                      </xsl:otherwise>
                   </xsl:choose>
                  <xsl:value-of select="log-description"/>

                            Step
                            Status
                            Description

                              1

                              <xsl:choose>
                                 <xsl:when test="@status='Failed'">
                                  <xsl:value-of select="Steps/step1/@status"/>
                                  </xsl:when>
                                   <xsl:otherwise >
                                      <xsl:value-of select="Steps/step1/@status"/>
                                  </xsl:otherwise>
                               </xsl:choose>

                              <xsl:value-of select="Steps/step1/log-description"/>

                             <xsl:if test="Steps/step2/@status!=''">

                                  2

                                  <xsl:choose>
                                     <xsl:when test="@status='Failed'">
                                      <xsl:value-of select="Steps/step2/@status"/>
                                      </xsl:when>
                                       <xsl:otherwise >
                                          <xsl:value-of select="Steps/step2/@status"/>
                                      </xsl:otherwise>
                                   </xsl:choose>

                                  <xsl:value-of select="Steps/step2/log-description"/>

                              </xsl:if>
                             <xsl:if test="Steps/step3/@status!=''">

                                  3

                                  <xsl:choose>
                                     <xsl:when test="@status='Failed'">
                                      <xsl:value-of select="Steps/step3/@status"/>
                                      </xsl:when>
                                       <xsl:otherwise >
                                          <xsl:value-of select="Steps/step3/@status"/>
                                      </xsl:otherwise>
                                   </xsl:choose>

                                  <xsl:value-of select="Steps/step3/log-description"/>

                              </xsl:if>

              </xsl:for-each>

  </xsl:template>
</xsl:stylesheet>

Here is the image of parent table
And want to show sub table on row click as in this image
Any help will be highly appreciated.
Thanks.

A: The JavaScript code
function toggleRow(itemID){
                alert(itemID);
                  if ((document.getElementById("tr" + itemID).style.display == 'none'))
                  {
                    document.getElementById("tr" + itemID).style.display = 'inline';
                  } else {
                    document.getElementById("tr" + itemID).style.display = 'none';
                  }

lacks the closing curly brace } to close the function body, i.e. you want at least
function toggleRow(itemID){
                alert(itemID);
                  if ((document.getElementById("tr" + itemID).style.display == 'none'))
                  {
                    document.getElementById("tr" + itemID).style.display = 'inline';
                  } else {
                    document.getElementById("tr" + itemID).style.display = 'none';
                  }
}

As I said in a comment, I would suggest to shorten that to
function toggleRow(id) {
  document.getElementById('tr' + id).style.display = document.getElementById('tr' + id).style.display === 'none' ? '' : 'none';
}

as it is usually better to just remove the inline style with style.display = 'none' to have the default setting kick in instead of trying to set an inline display on a table row.


text:
Q: Apache Axis 1.4 problem with generics or composite datatypes I have a class XMLDataCarrier which has a map attribute
Map (Integer, XMLDataListWrapper)catPriorityXMLDataMap.
The class XMLDataListWrapper has just a list of strings private List (String) xmlString;
All classes i.e. XMLDataCarrier,XMLDataListWrapper implement serializable and have serializable id
This data is exposed via a webservice developed using Axis 1.4
The problem is that when the map catPriorityXMLDataMap is populated with instance of XMLDataListWrapper
it cannot be retieved by the webservice client.
A close look at the stubs generated for client shows absence of reference to XMLDataListWrapper
I am at a loss to explain why. Does axis 1.4 support generics? Is that an issue?
Thank you in advance
Sameer
Note: I have not used angle brackets for generics as it causes problems here on display

A: I think i found the issue. Need to generated JAX-WS  stubs which support generics instead of RPC stubs.
http://users.skynet.be/pascalbotte/rcx-ws-doc/seiclient.htm#SEIDOCLITCOMPLEX


text:
Q: invalid value for key attachdbfilename mvc 4 I'm doing a very basic MVC 4 project. I have a simple model and a dbcontext. I am trying to take input from a form and save it using the dbcontext.
Here's my codes,
In the controller
    public ActionResult FormShow(Models.bullseye sampbe)
    {
        if (ModelState.IsValid)
        {
            var db = new bullseyeDataContext();
            db.bullseyes.Add(sampbe);
            db.SaveChanges();

            return RedirectToAction("FormShow");
        }

        return FormShow();
    }

In the dbcontext
public class bullseyeDataContext : DbContext
{
    public DbSet<bullseye> bullseyes { get; set; }

    static bullseyeDataContext()
    {
        Database.SetInitializer(new DropCreateDatabaseAlways<bullseyeDataContext>());
    }
}

And the connectionstring is
<add name="MvcFourFirstTouch.Models.bullseyeDataContext"
connectionString="Data Source=(LocalDb)\v11.0;
Integrated        Security=SSPI;AttachDBFilename=|DataDirectory|\MvcFourFirstTouch.Models.bullseyeDataContext.mdf" providerName="System.Data.SqlClient" />

And when i submit the form i'm getting invalid value for key attachdbfilename. Where's the problem??

A: Updated
The problem is with your connection string. AttachDBFileName does not like the value you've specified to it. Could be an issue with the db name, or an issue with LocalDB, or the lack/presence of an extra \ in the paths.
However, if you have no explicit reason for using AttachDBFileName, then I would suggest replacing AttachDbFileName=[...].mdf with Initial Catalog=yourDBName. You avoid a lot if issues this way :)


text:
Q: Google Places API missing ID and Referance in response I am using the Google Places API with the following search string
https://maps.googleapis.com/maps/api/place/queryautocomplete/json?key=AIzaSyDryrzCJoKA-XeN-f3Q2KDPdJHd27Nl7CoM&sensor=true&input=bri

The result back look like this:
{
   "predictions" : [
      {
         "description" : "Bristol, United Kingdom",
         "matched_substrings" : [
            {
               "length" : 3,
               "offset" : 0
            }
         ],
         "terms" : [
            {
               "offset" : 0,
               "value" : "Bristol"
            },
            {
               "offset" : 9,
               "value" : "United Kingdom"
            }
         ]
      }
   ... etc etc
   ],
   "status" : "OK"
}

I can't see an 'id' or 'reference' property on any of the returned predictions results which is needed in order to then request the full details from the Google Places Details API.
Their documentation says I should see both these items.   https://developers.google.com/places/documentation/autocomplete
Any one know what i am doing wrong?

A: You're using the wrong method.  You have to use autocomplete:  https://developers.google.com/places/documentation/autocomplete

A: You're using the "queryautocomplete" service.
Query Autocomplete not returns the place id field.
Try use autocomplete service with this url:

https://maps.googleapis.com/maps/api/place/autocomplete/json?key=AIzaSyDryrzCJoKA-XeN-f3Q2KDPdJHd27Nl7CoM&sensor=true&input=bri


text:
Q: Dropdown Selection for a table I am trying to create a dropdown selector for a table.  It is not selecting and I am still rather new to javascript.
Here is the snippet I was working on.

$('#vehicleSelect').change( function(){
  var selection = $(this).val();
  var dataset = $('#vehicleTable tbody').find('tr');

  dataset.each(function(index) {
    item = $(this);
    item.hide();

    var firstTd = item.find('td:first-child');
    var text = firstTd.text();
    if text == selection {
        item.show();
    }
  });
});

<select id='vehicleSelect'>
   <option value="">Please Select</option>
   <option value='SPARC'>SPARC</option>
   <option value='CIO_SP3_SB'>CIO_SP3_SB</option>
   <option value='CIO_SP3'>CIO_SP3</option>
   <option value='T4NG'>T4NG</option>
</select>

         Contract Type
         Contract Number
         Contract Holder

         SPARC
          Conract1
          Company1

         CIO_SP3_SB
         Conract2
         Company2

         T4NG
         Conract3
         Company3

          CIO_SP3
          Conract4
          Company4

A: There seems to be nothing wrong in the code except no () in the if-condition.
if (text == selection)
{
    item.show();
}

A: As @Varun's answer says the main problem comes from the parentheses (), but you could also shorten this action, so you don't need to loop like the sample below shows using contains() selector :
$('#vehicleSelect').change(function() {
  $('#vehicleTable tbody tr')
    .hide()
    .find('td:first-child:contains("' + $(this).val() + '")')
    .parent()
    .show();
});

$('#vehicleSelect').change(function() {
  $('#vehicleTable tbody tr')
    .hide()
    .find('td:first-child:contains("' + $(this).val() + '")')
    .parent()
    .show();
});

<select id='vehicleSelect'>
   <option value="">Please Select</option>
   <option value='SPARC'>SPARC</option>
   <option value='CIO_SP3_SB'>CIO_SP3_SB</option>
   <option value='CIO_SP3'>CIO_SP3</option>
   <option value='T4NG'>T4NG</option>
</select>

      Contract Type
      Contract Number
      Contract Holder

      SPARC
      Conract1
      Company1

      CIO_SP3_SB
      Conract2
      Company2

      T4NG
      Conract3
      Company3

      CIO_SP3
      Conract4
      Company4

Or also using filter() :
$('#vehicleSelect').change(function() {
  var selected = $(this).val();

  $('#vehicleTable tbody tr')
    .hide()
    .find('td:first-child')
    .filter(function(index) { return $(this).text() === selected; })
    .parent()
    .show();
});

$('#vehicleSelect').change(function() {
  var selected = $(this).val();

  $('#vehicleTable tbody tr')
    .hide()
    .find('td:first-child')
    .filter(function(index) { return $(this).text() === selected; })
    .parent()
    .show();
}).change();

<select id='vehicleSelect'>
   <option value="" selected>Please Select</option>
   <option value='SPARC'>SPARC</option>
   <option value='CIO_SP3_SB'>CIO_SP3_SB</option>
   <option value='CIO_SP3'>CIO_SP3</option>
   <option value='T4NG'>T4NG</option>
</select>

      Contract Type
      Contract Number
      Contract Holder

      SPARC
      Conract1
      Company1

      CIO_SP3_SB
      Conract2
      Company2

      T4NG
      Conract3
      Company3

      CIO_SP3
      Conract4
      Company4

Hope this helps.


text:
Q: in vim press k after open a file behaves strange In vim, after a open a file, if I press k, somehow it was mapped to ^[[>1;2802;0ck which will remove the current and above line and get into insert mode.
I get the map from the vim myfile -W a.log command and look into a.log file.
How to correct this?

A: Vim custom mappings are usually written in a "vimrc" file, at ~/.vimrc (or ~/_vimrc on Windows). This file automatically runs when Vim is opened, and people often put commands there to customize Vim's settings and mappings. Check if that file exists. If so, check whether it contains a command like map k ^[[>1;2802;0ck. map may be a different but related command such as nmap or nnoremap.
If you have a vimrc but it doesn't contain any mapping command, perhaps the vimrc loads a buggy plugin. Rename your vimrc file so Vim can't see it, then run Vim again. If the problem is now gone, you know the problem is in your vimrc. Delete lines in the file until you find the line that is causing the problem.


text:
Q: what is the 'SEL' rule in SQL creating table and selections such as SEL(1/0)? I had a problem with how to use SEL in Teradata. The problem is asking what does SEL(1/0) do ?
Also, I had a piece of code like this:
CREATE  VOLATILE TABLE   VT_ADDRESSES
, NO FALLBACK, NO BEFORE JOURNAL, NO AFTER JOURNAL AS
( SEL
     1234  MEMBER_KEY
    ,'1234 MAIN STREET'  STREET
    ,'DALLAS'  CITY  )
WITH DATA
PRIMARY INDEX (  MEMBER_KEY     )
ON COMMIT PRESERVE ROWS;

INSERT INTO VT_ADDRESSES  SEL 1237  MEMBER_KEY,'3413 CABRIOLET CT', 'RICHARDSON' CITY;

in this case, I guess the table format is set according to
'( SEL
     1234  MEMBER_KEY
    ,'1234 MAIN STREET'  STREET
    ,'DALLAS'  CITY  )'

But I am not sure if this could cause truncation of later inserted information
'INSERT INTO VT_ADDRESSES  SEL 1237  MEMBER_KEY,'3413 CABRIOLET CT', 'RICHARDSON' CITY; '

the string 'RICHARDSON' is longer than the previous 'DALLAS' in SEL part.
Really need help with this.


text:
Q: Cannot plot correctly with geom_flags I am trying to plot some data (mainly character data, unfortunately) and I wanted to use geom_flag to create little flag images to put under the labels on the x axis (x = Country) to make it more clear since I cannot write the full country name (it would be a mess with long names such as Argentina)
But what I am getting is the image below... Only a few flags appear and they are not even properly showed as the image seems not be "not tall enough" to contain them.
How can I modify my code to show all the flags and also make sure the image is fully showed in the graph?
I know it's complicated, thank you so much for your help!
Here's my code:
data$iso2 <- countrycode(data$Country, "country.name", "iso2")

heatmap_trial3 <- y_Rec1 %>%
  select(iso2, Place, `Contentious?`,`Comments number`, Country) %>%
  ggplot(aes(x=iso2,
             y=Place,
             group=iso2)) +
  geom_point(aes(shape=`Contentious?`,
                 size=`Comments number`,
                 color=Country)) +
  theme(plot.background = element_rect(fill = NA),
        panel.background = element_rect(fill = "white")) +
  guides(size=FALSE, color=FALSE) +
  geom_flag(y =-0.75, aes(image = iso2)) +
  xlab(NULL) + expand_limits(y=-0.75)

dput() of my data:
structure(list(iso2 = c("CA", "DE", "DE", "CA", "CA", "AU", "RU",
"BE", "BE", "BE", "BE", "TR", "DE", "DE", "DE", "DE", "DE", "DE",
"DE", "DE", "DE", "DE", "DE", "DE", "DE", "DE", "DE", "DE", "DE",
"DE", "DE", "DE", "DE", "DE", "DE", "DE", "DE", "DE", "DE", "DE",
"DE", "DE", "DE", "DE", "DE", "DE", "DE", "DE", "DE", "DE", "DE",
"DE", "FR", "FR", "FR", "CN", "CN", "CN", "CN", "CN", "CN", "CN",
"CN", "CN", "FR", "FR", "FR", "JP", "JP", "JP", "JP", "JP", "SA",
"SA", "BR", "BR", "BR", "BR", "BR", "BR", "BR", "BR", "BR", "BR",
"BR", "RU", "RU", "BE", "IT", "IT", "IT", "IT", "IT", "IT", "IT",
"IT", "AR", "IT", "IT", "CH", "AR", "IT", "US", "US", "AR", "AR",
"AR", "AR", "AR", "JP", "JP", "US", "US", "US"), Place = structure(c(4L,
3L, 3L, 3L, 4L, 4L, 3L, 5L, 5L, 5L, 5L, 4L, 2L, 2L, 2L, 2L, 2L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 3L, 3L, 4L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 4L,
4L, 5L, 4L, 5L, 5L, 5L, 5L, 3L, 4L, 2L, 4L, 4L, 4L, 5L, 5L, 5L,
5L, 5L, 5L, 2L, 3L, 5L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 4L, 4L, 5L,
5L, 5L, 3L, 5L, 3L, 3L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 3L, 4L,
5L), .Label = c("Context Intro", "Context Rec 1", "Protectionism",
"WTO Reform", "Multilateralism", "Context Rec 2", "Crisis Response",
"Customs", "Gloval Value Chains", "Context Rec 3", "Micro-Small-Med-Entrepr.",
"Trade Finance", "Export Credit Agencies", "Context Rec 4", "Green Trade",
"Foreing Investments"), class = "factor"), Contentious? = c("Not contentious",
"Contentious", "Not contentious", "Not contentious", "Not contentious",
"Not contentious", "Contentious", "Not contentious", "Contentious",
"Not contentious", "Not contentious", "Not contentious", "Not contentious",
"Not contentious", "Not contentious", "Not contentious", "Not contentious",
"Not contentious", "Not contentious", "Not contentious", "Not contentious",
"Not contentious", "Not contentious", "Not contentious", "Contentious",
"Contentious", "Not contentious", "Not contentious", "Not contentious",
"Not contentious", "Not contentious", "Not contentious", "Not contentious",
"Contentious", "Not contentious", "Not contentious", "Not contentious",
"Contentious", "Contentious", "Not contentious", "Not contentious",
"Not contentious", "Not contentious", "Not contentious", "Not contentious",
"Not contentious", "Contentious", "Contentious", "Contentious",
"Contentious", "Not contentious", "Not contentious", "Not contentious",
"Not contentious", "Not contentious", "Not contentious", "Contentious",
"Contentious", "Contentious", "Not contentious", "Not contentious",
"Contentious", "Not contentious", "Not contentious", "Not contentious",
"Contentious", "Contentious", "Contentious", "Not contentious",
"Contentious", "Contentious", "Contentious", "Contentious", "Not contentious",
"Not contentious", "Not contentious", "Contentious", "Not contentious",
"Not contentious", "Not contentious", "Not contentious", "Not contentious",
"Not contentious", "Not contentious", "Contentious", "Not contentious",
"Contentious", "Not contentious", "Contentious", "Not contentious",
"Not contentious", "Not contentious", "Not contentious", "Not contentious",
"Not contentious", "Contentious", "Not contentious", "Contentious",
"Contentious", "Not contentious", "Not contentious", "Contentious",
"Not contentious", "Not contentious", "Not contentious", "Not contentious",
"Not contentious", "Not contentious", "Contentious", "Not contentious",
"Contentious", "Not contentious", "Contentious", "Not contentious"
), Comments number = c(2L, 9L, 9L, 1L, 2L, 1L, 2L, 4L, 4L,
4L, 4L, 1L, 5L, 5L, 5L, 5L, 5L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 13L,
13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 15L,
15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 2L, 2L, 3L, 1L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 3L, 3L,
1L, 1L, 6L, 6L, 6L, 6L, 1L, 1L, 2L, 3L, 3L, 3L, 6L, 6L, 6L, 6L,
6L, 6L, 2L, 2L, 1L, 1L, 4L, 3L, 3L, 3L, 4L, 4L, 2L, 2L, 7L, 2L,
2L, 1L, 7L, 4L, 2L, 2L, 7L, 7L, 7L, 7L, 7L, 6L, 6L, 2L, 1L, 2L
), Country = c("Canada", "Germany", "Germany", "Canada", "Canada",
"Australia", "Russia", "Belgium", "Belgium", "Belgium", "Belgium",
"Turkey", "Germany", "Germany", "Germany", "Germany", "Germany",
"Germany", "Germany", "Germany", "Germany", "Germany", "Germany",
"Germany", "Germany", "Germany", "Germany", "Germany", "Germany",
"Germany", "Germany", "Germany", "Germany", "Germany", "Germany",
"Germany", "Germany", "Germany", "Germany", "Germany", "Germany",
"Germany", "Germany", "Germany", "Germany", "Germany", "Germany",
"Germany", "Germany", "Germany", "Germany", "Germany", "France",
"France", "France", "China", "China", "China", "China", "China",
"China", "China", "China", "China", "France", "France", "France",
"Japan", "Japan", "Japan", "Japan", "Japan", "Saudi Arabia",
"Saudi Arabia", "Brazil", "Brazil", "Brazil", "Brazil", "Brazil",
"Brazil", "Brazil", "Brazil", "Brazil", "Brazil", "Brazil", "Russia",
"Russia", "Belgium", "Italy", "Italy", "Italy", "Italy", "Italy",
"Italy", "Italy", "Italy", "Argentina", "Italy", "Italy", "Switzerland",
"Argentina", "Italy", "United States of America", "United States of America",
"Argentina", "Argentina", "Argentina", "Argentina", "Argentina",
"Japan", "Japan", "United States of America", "United States of America",
"United States of America")), row.names = c(NA, -114L), class = c("tbl_df",
"tbl", "data.frame"))

A: Try adding + expand_limits(y=-1) to your ggplot statement.
See this for another example from the author of that function.
After reading your data into a data object, this code:
library(dplyr)
library(ggplot2)
library(ggimage)

data %>%
  select(iso2, Place, `Contentious?`,`Comments number`, Country) %>%
  ggplot(aes(x=iso2,
             y=Place,
             group=iso2)) +
  geom_point(aes(shape=`Contentious?`,
                 size=`Comments number`,
                 color=Country)) +
  theme(plot.background = element_rect(fill = NA),
        panel.background = element_rect(fill = "white")) +
  guides(size=FALSE, color=FALSE) +
  geom_flag(y =-0.75, aes(image = iso2)) +
  xlab(NULL) + expand_limits(y=-1)

... produces for me this graph with flags that aren't cut off:

You can experiment with different y values for geom_flag and expand_limits. Just make sure your y value for expand_limits expands the graph far enough to make the flags visible.


text:
Q: Google App Engine request being executed multiple times I have an issue with our Python 2.7 Google App Engine project where after a lot of research it appears as though App Engine is repeatedly sending through the same request to our servers. Is anyone else experiencing this issue?
EDIT:
It's a standard request with all the same parameters as it was first sent with (some of which are 15 days old now). I'm wandering if it's a similar situation to this https://groups.google.com/forum/#!topic/google-appengine-downtime-notify/9fAYP7UyppQ

A: Typically App Engine doesn't send requests, it's the framework you use to handle requests.
If you're getting duplicate requests coming in, you should look to see where it's coming from. If it's coming from an app engine server to your own external server, then somebody is running some sort of process on their app engine account that's accessing data from your server during its execution.
The details, including what you would do about it, are all situation-dependent. There's no catch-all response. Just be aware that, yes, any computer on the Internet can make web requests to any other. And that includes app engine (in both directions).


text:
Q: Data not being Binded to recycler view I have a recycler View which is populated with an array list using data from a cursor.
Cursor cursor = getCursor(getContext().getContentResolver(), messageUri);
    mAdapter = new MessageAdapter(getContext(), Message_list);
    while(cursor.moveToNext()){
        // The Cursor is now set to the right position
        Message_list.add(Message.getMessage(getContext(), cursor));
    }

    new Thread(new Runnable() {
        @Override
        public void run() {

            getActivity().runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    mRecyclerView.setAdapter(mAdapter);
                    Log.d(TAG, "Size Before" + Message_list.size());
                }
            });
        }
    }).start();

This works correctly with the data being inserted properly. However when i insert a new entry into the adapter, the adapter adds the row, but loads values from a random previous row i.e the text displayed in that row is text from another row present in the array list of items. Here is the insertion method:
sendButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String message = messageText.getText().toString();
            SmsManager smsManager = SmsManager.getDefault();
            smsManager.sendTextMessage(number, null, message, null, null);
            Message messageSMS = new Message();
            messageSMS.setBody(message);
            messageSMS.setAddress(number);
            messageSMS.setDate(System.currentTimeMillis());
            Log.d(TAG, "" + messageSMS.getBody());
            Log.d(TAG, "Size After" + Message_list.size());
            mAdapter.add(messageSMS);
          mRecyclerView.smoothScrollToPosition(Message_list.size()-1);

        }
    });

And here is the add method inside the adapter:
public void add(Message item) {
    Message_list.add(Message_list.size()-1, item);
    notifyItemInserted(Message_list.size() - 1);
}

Thanks in advance for help!

A: Instead of notifyItemInserted just use notifyDataSetChanged() after adding your item into Message_list.
Please refer Document Here


text:
Q: NPM Audit Fix wants to downgrade a package We received an NPM Audit warning about jsonwebtoken <= 8.5.1. The suggested fix was to upgrade mssql to 7.2.0. Instead, we removed mssql with npm remove mssql and re-installed it to get the latest version npm i -D mssql => 9.0.1.
However, NPM Audit still complains and wants to install mssql@7.2.0.
Why is NPM Audit requiring a downgrade?
$ npm audit --registry=https://registry.npmjs.org/

# npm audit report

jsonwebtoken  <=8.5.1
Severity: high
jsonwebtoken unrestricted key type could lead to legacy keys usage  - https://github.com/advisories/GHSA-8cf7-32gw-wr33
jsonwebtoken has insecure input validation in jwt.verify function - https://github.com/advisories/GHSA-27h2-hvpr-p74q
jsonwebtoken's insecure implementation of key retrieval function could lead to Forgeable Public/Private Tokens from RSA to HMAC - https://github.com/advisories/GHSA-hjrf-2m68-5959
jsonwebtoken vulnerable to signature validation bypass due to insecure default algorithm in jwt.verify() - https://github.com/advisories/GHSA-qwph-4952-7xr6
fix available via `npm audit fix --force`
Will install mssql@7.2.0, which is a breaking change
node_modules/jsonwebtoken
  @azure/msal-node  *
  Depends on vulnerable versions of jsonwebtoken
  node_modules/@azure/msal-node
    @azure/identity  >=1.2.0-alpha.20200903.1
    Depends on vulnerable versions of @azure/msal-node
    node_modules/@azure/identity
      tedious  >=11.0.9
      Depends on vulnerable versions of @azure/identity
      node_modules/tedious
        mssql  >=7.2.1
        Depends on vulnerable versions of tedious
        node_modules/mssql

5 vulnerabilities (4 moderate, 1 high)

To address all issues (including breaking changes), run:
  npm audit fix --force

Here is the dependency graph:

*

*"mssql": "9.0.1"

*

*"tedious": "^15.0.1" (15.1.2)

*

*"@azure/identity": "^2.0.4"

*

*"@azure/msal-node": "^1.10.0"

*

*"jsonwebtoken": "^8.5.1"

We have no other libraries which depend on jsonwebtoken.
package.json
{
  "dependencies": {
    "express": "^4.18.1",
    "flatted": "^3.1.1",
    "http-proxy-middleware": "^2.0.6",
    "log-timestamp": "^0.3.0",
    "node-fetch": "^2.6.1",
    "nodemon": "^2.0.20",
    "sha1-hex": "^1.0.0"
  },
  "devDependencies": {
    "@types/jest": "^26.0.3",
    "eslint": "^7.7.0",
    "eslint-config-strongloop": "^2.1.0",
    "jest": "^28.1.3",
    "jest-junit": "^8.0.0",
    "mssql": "^9.0.1"
  }
}

A: The issue is that all versions of @azure/msal-node depends on jsonwebtoken@8.5.1. However this dependency seems to have been added in mssql >7.2.0. So downgrading to mssql@7.2.0 removes the dependence on @azure/msal-node and subsequently the vulnerable version of jsonwebtoken.


text:
Q: Polymer 2.0 getting paper-input file I am using Polymer 2.0.  I have a
<paper-input type="file" id"myFile"></paper-input>

Once I selected a file I want to use Polymer (javascript) to get the reference and details of the file.  Previously I had used
this.$.myFile.inputElement.files[0];

But that doesn't seem to work now, it says undefined.  Please help me access the file.  Here is a jsbin:
https://jsbin.com/luledugege/edit?html,console,output

A: Try this:
this.$.myFile.inputElement.inputElement.files[0]

paper-input has attribute inputElement to get its iron-input. And this element has, in turn, the native input in its shadow root with files attribute.
Your input could be:
<link rel="import" href="../bower_components/polymer/polymer-element.html">
<link rel="import" href="../bower_components/paper-input/paper-input.html">

<dom-module id="my-paper-input-file">
  <template>
    <style>
      :host {
        display: block;
        padding: 10px;
      }
    </style>

    <paper-input type="file" id="myFile" on-change="_handleFiles"></paper-input>

  </template>

  <script>
    class MyPaperInputFile extends Polymer.Element {

      static get is() { return 'my-paper-input-file'; }

      static properties() {

        files: Object

      }

      _handleFiles(e) {
        this.files = this.$.myFile.inputElement.inputElement.files;
        //SAME: this.files = e.target.inputElement.inputElement.files;
      }

    }

    window.customElements.define(MyPaperInputFile.is, MyPaperInputFile);
  </script>
</dom-module>


text:
Q: Why are stress components on opposite faces identical? The stress tensor stores information about the stress on each of the faces of an infinitesimal volume of material. But I am confused as to why the stress components on opposite faces should be equal. The textbook I am reading (Fluid Mechanics by Kundu and Cohen) gives the following explanation:

On the opposite face EFGH the stress components have the same value as on ABCD, but their directions are reversed. This is because Figure 2.4 shows the stress at a point. The cube shown is supposed to be of "zero" size, so that the faces ABCD and EFGH are just opposite faces of a plane perpendicular to the x2-axis. That is why the stresses on the opposite faces are equal and opposite.

I am not sure why the cube being infinitesimal size implies that the stress components on opposite faces should be the same. Could someone please explain?

A: The argument in your text is a bit muddled.
The usual  argument is the following: If the sides of the cube have length $L$ the the net  force $F_x$ in the $x$ direction, say, is equal to $L^2\Delta \tau_{xx}$ where $\Delta \tau_{xx}$ is the difference in the stress components  on the opposite faces. Meanwhile the mass of the cube is $m=\rho L^3$ where $\rho$ is the density. Thus, from $F=ma$ the acceleration is
$$
a =\frac 1{\rho}  \Delta \tau_{xx}L^{-1}.
$$
If $a$ is to stay finite as $L\to 0$, then $\Delta \tau_{xx}$ must go to zero $\propto L$. Or, to put it another way, if $\Delta \tau_{xx}$ were not zero in the limit, the material would move infinitely fast so as make the two stresses equal. A similar argument applied to torque and moments of intertia shows that $\tau_{ij}=\tau_{ji}$.
This argument is similar to the one that says that the tension in a massless string has to be the constant  along the length of the string.


text:
Q: How To Subtract Two Dates In Javascript and Add Days To A Specific Date var date1 = 13/10/2016 04:35;
var date2 = 27/03/2017 08:00;
var diff = date2 - date1
How do i subtract the two javascript dates that are in the above format and know the number of days between them and return the result in DD/Month/Year format. Also i will like to add 180days to date1 and also output the result in DD/Month/Year format? Thanks for your help.

A: If you take a look at the Date Object and its methods and properties in JavaScript, you'll notice that JavaScript bases its time on milliseconds since 1970.
Knowing that you can easily modify dates by adding or subtracting milliseconds.
/**
 * subtractDateFromDate
 * Use the millisecond value insert both elements to calculate a new date.
 * @param d1 {Date}
 * @param d2 {Date}
 */
function subtractDateFromDate(d1, d2) {
    return new Date(d1.getTime() - d2.getTime());
}
/**
 * addDaysToDate
 * Create a new Date based on the milliseconds of the first date,
 * adding the milliseconds for the extra days specified.
 * Notice that days can be a negative number.
 * @param d {Date}
 * @param days {number}
 */
function addDaysToDate(d, days) {
    var oneDayInMilliseconds = 86400000;
    return new Date(d.getTime() + (oneDayInMilliseconds * days));
}

And to format the date without moment.js:

/**
 * formatDate
 * returns a string with date parameters replaced with the date objects corresponding values
 * @param d {Date}
 * @param format {string}
 */
function formatDate(d, format) {
    if (format === void 0) { format = "!d!/!m!/!y!"; }
    return format
        .replace(/!y!/ig, d.getFullYear().toString())
        .replace(/!m!/ig, (d.getMonth() + 1).toString())
        .replace(/!d!/ig, d.getDate().toString());
}
//Testing
var d = new Date();
console.log("d/m/y:", formatDate(d, "!d!/!m!/!y!"));
console.log("m/d/y:", formatDate(d, "!m!/!d!/!y!"));
console.log("It was the d of m, y:", formatDate(d, "It was the !d! of !m!, !y!"));


text:
Q: Calculating T-statistics for different sub segments using Pandas I am trying to calculate p-value and t-value for different sub segments within a data frame.
The data frame has two columns, here are the top 5 values in my data frame:
df[["Engagement_score", "Performance"]].head()
   Engagement_score  Performance
0    6                 0.0
1    5                 0.0
2    7                 66.3
3    3                 0.0
4    11                0.0

I am grouping my dataframe by engagement score and then I calculate these three statistics for those groups:
1) Average performance score(sub_average) and number of values within that group(sub_bookings)
2) Average performance score for rest of the groups(rest_average) and number of values in rest of the groups(rest_bookings)
Overall performance score and overall bookings are calculated for the overall data frame.
Here's my code to do that.
def stats_comparison(i):
    df.groupby(i)['Performance'].agg({
    'average': 'mean',
    'bookings': 'count'
    }).reset_index()
    cat = df.groupby(i)['Performance']\
        .agg({
            'sub_average': 'mean',
            'sub_bookings': 'count'
       }).reset_index()
    cat['overall_average'] = df['Performance'].mean()
    cat['overall_bookings'] = df['Performance'].count()
    cat['rest_bookings'] = cat['overall_bookings'] - cat['sub_bookings']
    cat['rest_average'] = (cat['overall_bookings']*cat['overall_average'] \
                     - cat['sub_bookings']*cat['sub_average'])/cat['rest_bookings']
    cat['t_value'] = stats.ttest_ind(cat['sub_average'], cat['rest_average'])[0]

    cat['prob'] = stats.ttest_ind(cat['sub_average'], cat['rest_average'])[1] # this is the p value
    cat['significant'] = [(lambda x: 1 if x > 0.9 else -1 if x < 0.1 else 0)(i) for i in cat['prob']]
    # if the p value is less than 0.1 then I can confidently say that the 2 samples are different.

    print(cat)

stats_comparison('Engagement_score')

I got the following output, but I am getting the same P-value and T-value for my sub-segments, how do I come up with different pvalues and t-values for these sub-segments without writing a loop:
    Engagement_score  sub_average  sub_bookings  overall_average  \
0                 3    68.493120          1032         69.18413
1                 4    71.018214           571         69.18413
2                 5    70.265373           670         69.18413
3                 6    68.986506           704         69.18413
4                 7    69.587893           636         69.18413
5                 8    70.215244           656         69.18413
6                 9    63.495813           812         69.18413
7                10    71.235994           664         69.18413
8                11    69.302559           508         69.18413
9                12    81.980952           105         69.18413

   overall_bookings  rest_bookings  rest_average   t_value      prob  \
0              6358           5326     69.318025  0.870172  0.395663
1              6358           5787     69.003162  0.870172  0.395663
2              6358           5688     69.056769  0.870172  0.395663
3              6358           5654     69.208737  0.870172  0.395663
4              6358           5722     69.139252  0.870172  0.395663
5              6358           5702     69.065503  0.870172  0.395663
6              6358           5546     70.016967  0.870172  0.395663
7              6358           5694     68.944854  0.870172  0.395663
8              6358           5850     69.173846  0.870172  0.395663
9              6358           6253     68.969247  0.870172  0.395663

A: I think you can do a simple loop over the Engagement groups.
Sample Data
import numpy as np
import pandas as pd
from scipy import stats

np.random.seed(123)
df = pd.DataFrame({'Engagement Score': np.random.choice(list('abcde'), 1000),
                   'Performance': np.random.normal(0,1,1000)})

Code
# Get all of the subgroup averages and counts
d = {'mean': 'sub_average', 'size': 'sub_bookings'}
df_res = df.groupby('Engagement Score').Performance.agg(['mean', 'size']).rename(columns=d)

# Add overall values
df_res['overall_avg'] = df.Performance.mean()
df_res['overall_bookings'] = len(df)

# T-test of each subgroup against everything not in that subgroup.
for grp in df['Engagement Score'].unique():
    # mask to separate the groups
    m = df['Engagement Score'] == grp
    # Decide whether you want to assume equal variances. equal_var=True by default.
    t,p = stats.ttest_ind(df.loc[m, 'Performance'], df.loc[~m, 'Performance'])
    df_res.loc[grp, 't-stat'] = t
    df_res.loc[grp, 'p-value'] = p

Output df_res:
                  sub_average  sub_bookings  overall_avg  overall_bookings    t_stat   p-value
Engagement Score
a                   -0.024469           203     -0.03042              1000  0.094585  0.924663
b                   -0.053663           206     -0.03042              1000 -0.372866  0.709328
c                    0.080888           179     -0.03042              1000  1.638958  0.101537
d                   -0.127941           224     -0.03042              1000 -1.652303  0.098787
e                   -0.001161           188     -0.03042              1000  0.443412  0.657564

As expected, nothing is significant since it all came from the same normal distribution.


text:
Q: Efficient Searching in jQuery I want to be able to pass an array (even an array of jQuery objects) and do a simple search based on a single data member.
It'd take an array to search, a string for the data member, and the value to search for.
This is obviously easy to write myself, but I was curious if jQuery had anything built in to do this already?
Thanks SO!

A: var arr = [
    {key1 : 'value 1-1', key2    : 'value 2-1'},
    {key1 : 'value 1-2', key2NOT : 'value 2-2'},
    {key1 : 'value 1-3', key2    : 'value 2-3'},
    {key1 : 'value 1-4', key2NOT : 'value 2-4'}
],
    data_member = 'key2',
    output      = {};

$.each(arr, function (index, obj) {
    if (data_member in obj) {
        output[index] = obj[data_member];
    }
});

Here is a jsfiddle: http://jsfiddle.net/jasper/PupuZ/


text:
Q: .NET Core - The JSON property name for collides with another property I'm migrating an old API to .net core web api and one of the responses includes the same value twice, so I'm using the native Json library of .NET 5 and I'm trying to get the same value twice in the JSON response, 'Id' and 'id'
{
...

"Id": "10",

"id": "10"

...
}

In my Startup, ConfigurationServices I configured the Json Option like this:
services.AddControllers().AddJsonOptions(options =>
    { options.JsonSerializerOptions.PropertyNameCaseInsensitive = true; });

My action method
[HttpGet]
public async Task<ActionResult<IEnumerable<object>>> GetContacts(string projectID)
{
    Project project = _context.Projects.Where(a => a.Name == projectID)
        .FirstOrDefault();
    var contacts = await _context.Contacts.Where(a => a.ProjectId == project.Id)
        .Select(o => new { id = o.Id, ID = o.Id}).ToListAsync();
    return contacts;
}

While serializing, I am getting the "The JSON property name for collides with another property."
I think I'm missing something, and I'm stuck in this.

A: According to docs for PropertyNameCaseInsensitive:

Gets or sets a value that determines whether a property's name uses a case-insensitive comparison during deserialization.

So this flag is not about serialization and API output formatting. In the example code it is set to true. Hence, during deserialization a JSON property name should be matched with a single property of a target class in a case-insensitive manner. However, there is a clash - there are two candidate properties - Id and id. So it does not make sense.
Internally it's implemented as a case-insensitive dictionary for property lookup (decompiled .Net 5 by Rider):
public JsonClassInfo(Type type, JsonSerializerOptions options)
{
    // ...
    Dictionary<string, JsonPropertyInfo> cache = new Dictionary<string, JsonPropertyInfo>(
        Options.PropertyNameCaseInsensitive
            ? StringComparer.OrdinalIgnoreCase
            : StringComparer.Ordinal);
    // ...
}

So the solution is to set PropertyNameCaseInsensitive to false and use PropertyNamingPolicy = JsonNamingPolicy.CamelCase (which is the default value and is omitted below):
public class SomeObject
{
    [JsonPropertyName("Id")]
    public int Id { get; set; }

    public int id { get; set; }

    public string SomeString { get; set; }
}

Startup:
public void ConfigureServices(IServiceCollection services)
{
    services.AddControllers().AddJsonOptions(options =>
        options.JsonSerializerOptions.PropertyNameCaseInsensitive = false);
    // ...
}

This should give:
{
    "Id": 2,
    "id": 3,
    "someString": "..."
}


text:
Q: C, convert an char argv[] argument to char[] makes gibberish I am trying a C program and a part of it is taking file names as arguments, but when I try to convert them from the argument char *argv[] to char fPath[1000] to come out to gibberish.
int main(int argc, char *argv[]) {
    char fPath[1000];
    char uinp[1000];

    // Check for arguments
    if( argc == 2 ) {
        printf("The argument supplied is %s\n", argv[1]);
    } else if ( argc > 1 ) {
        printf("Too many arguments supplied.\n");
        exit(1);
    }

    // Set argv as the file for editing if it is set
    if (argv[1] != NULL) {

        printf("argv set = %s", argv[1]);
        char fPath = *argv[1]; <-- This appears to be where the Issues is.

    } else {

        printf("File: ");
        scanf("%s", fPath);

    }

After that it makes a file that is supposed to be the name of the argument given but instead it makes one named like "M'$'\026''b'$'\374\177" but in the program the you can only see the b.

A: char fPath = *argv[1]; <-- This appears to be where the Issues is.

You declare another variable fPath having type char and assigning the first letter of the second element of the argv. This fPath ends its life when the if completes.
Basically the whole if makes no sense and the code in else invokes undefined behaviour as fPath is not initialized.
You need to copy the string.
int main(int argc, char *argv[]) {
    char fPath[1000];
    char uinp[1000];

    // Check for arguments
    if( argc == 2 )
    {
        // Set argv as the file for editing if it is set
        if (argv[1] != NULL)
        {
            printf("argv set = %s\n", argv[1]);
            strcpy(fPath, argv[1]);

            printf("File: ");
            scanf("%s\n", fPath);
        }
    }
}


text:
Q: Finding minimum value of a table I need to find the value and position of the lowest entry in the table. Problem is, I don't know how to specify it. I can't put any numeric in the int value for minimum because the user can always specify a higher value. It works for the highest value but it doesn't for the smallest.
        Console.WriteLine("Podaj wymiar tablicy.");
        int dlugosc = Convert.ToInt32(Console.ReadLine());
        int[] tablica = new int[dlugosc];
        int max = 0;
        int min = tablica[0];
        for (int i = 0; i < tablica.Length; i++)
        {
            Console.WriteLine("Podaj wartosc {0} elementu.", i + 1);
            tablica[i] = Convert.ToInt32(Console.ReadLine());
        }

        for (int i = 0; i < tablica.Length; i++)
        {
            while (tablica[i] > max)
            {
                max = tablica[i];
            }
        }
        for (int x = 0; x < tablica.Length; x++)
        {
            while (tablica[x] < min)
            {
                min = tablica[x];
            }
        }
        int najmniejsze_miejsce = Array.IndexOf(tablica, min);
        int najwieksze_miejsce = Array.IndexOf(tablica, max);
        Console.WriteLine("Najwyzsza wartosc tablicy to {0}.", max);
        Console.WriteLine("Najwieksza wartosc wystepuje na miejscu {0}.", najwieksze_miejsce);
        Console.WriteLine("Najniższa wartość tablicy to {0}.", min);
        Console.WriteLine("Najnizsza wartosc wystepuje na miejscu {0}", najmniejsze_miejsce);
        Console.ReadKey();

A: you can just use:
Console.WriteLine(tablica.Min());

since your using an integer array

A: The current code is below:
int min = tablica[0];
for (int i = 0; i < tablica.Length; i++)
{
    Console.WriteLine("Podaj wartosc {0} elementu.", i + 1);
    tablica[i] = Convert.ToInt32(Console.ReadLine());
}

The min value being declared before the array is initialized means it will simply be zero. No value from your array can ever be less unless it's a negative number.
To fix, the min should be declared after the array is initialized:
for (int i = 0; i < tablica.Length; i++)
{
    Console.WriteLine("Podaj wartosc {0} elementu.", i + 1);
    tablica[i] = Convert.ToInt32(Console.ReadLine());
}
int min = tablica[0];`

A: You can find the first occurence of the min value in your table
int minIndex = Array.IndexOf(tablica, tablica.Min());

or simple:
Console.WriteLine(Convert.ToString(Array.IndexOf(tablica, tablica.Min())));

A: When you do need to do a scan you typically set the min value to Int.MaxValue and the max value to Int.MinValue before the loop and then you are guaranteed to set it on the first element and any element that improves either value.
You can then do it all in one loop (and you don't need to use while when you mean if). You can also track the index as you go:
int max = Int.MinValue;
int min = Int.MaxValue;
int maxindex = -1;
int minindex = -1;

for (int i = 0; i < tablica.Length; i++)
{
   if (tablica[i] > max) { max = tablica[i]; maxindex = i; }
   if (tablica[i] < min) { min = tablica[i]; minindex = i; }
}


text:
Q: VisualForce page embedded on custom object's page layout I am working on a visualforce page which is embedded on (its) custom object's page layout. The problem I am running into is as follows:
The visualforce page contains custom input fields with text describing each input box, which means we are unable to use the drag and drop functionality on the page layout. I added a save button to the visualforce page, which worked fine, but the producers are not satisfied with having to save one individual section, as well as saving the entire page at the end. Simply clicking the standard save button on the page layout will not save the fields in the visualforce page. Hence, I need a way to override the save button, to save the visualforce page's fields and then proceed as usual, by calling the save method on the object. Any ideas would be appreciated.

A: I don't see a possible way to achieve this. You have to either create the whole VF page with all the required fields and of course you will loose the drag and drop functionality or move those fields to the standard layout.
Another possible option is to automatically save in your embedded VF page when you loose the focus of a field but this depend on the logic of your page and how many fields you need to show on that VF page, I don't like this option, but again is possible with this approach.


text:
Q: Issue of getting more items in List(Actions on google) I am developing a shopping bot in that user will ask for the product and then i will be fetching the results from the database and the results will be more than 10 items. I know that the default items for the list is 10 items. My question here is how to add a more button at the end of the list so that i can load more of the items into the list.
for(var p=0;p<=countforchunk;p++)
{
  items[p] = {
    optionInfo: {
      key: (p + 1).toString(),
      synonyms: temparray[p],
    },
    title: temparray[p],
    url: "https://www.google.com/imgres?imgurl=https%3A%2F%2Fcdn.pixabay.com%2Fphoto%2F2015%2F04%2F23%2F22%2F00%2Ftree-736885__340.jpg&imgrefurl=https%3A%2F%2Fpixabay.com%2Fimages%2Fsearch%2Fnature%2F&tbnid=_2JirDBiGzi3lM&vet=12ahUKEwi71YPNxdrnAhVJGbcAHVi_BdEQMygAegUIARCFAg..i&docid=Ba_eiczVaD9-zM&w=546&h=340&q=images&ved=2ahUKEwi71YPNxdrnAhVJGbcAHVi_BdEQMygAegUIARCFAg",
    image: new Image({
      url: imgarray1[p],
      alt: imgarray1[p]
    }),
  }
  conv.ask(new List({
    title: 'Search Results',
    items: items
  }));
  resolve();
}

Please help me out,
Thanks.

A: You have to keep track of loaded item. There is limitation of loading 30 items at a time.
When user wants more item, you have handle that voice intent and can store current page index in context and based on that you can add another 30 items by replacing existing one.
1-30 items = page 1
30-60 items = page 2 and so on.
Call an api accordingly.

A: As far as I can tell - there is no technical limit of 10 items. If you put 12 items in a list, for example, it will show 12 items.
This is not, however, a very good idea. (Even 10 items is a lot, and you should be thinking about voice interaction, where you might not want to read back more than 2 or 3). So at some point you will want to think about paging anyway.
If you do, you need to implement this as another Intent and Intent Handler. You can do this by offering a suggestion chip that says "Show me more" and accepting training phrases such as "more", "what else", and "show me more" in the Intent. You can use a Context to keep track of where you are in the result list.


text:
Q: Why are my overlays on a mapview not shown? I followed the instructions from the google hellomapview tutorial. I get a working mapview etc. But the two items that are added to the map are not shown. It seems they are there somewhere because tapping at the specified location shows the message that was added to the items.
Edit
Here is my source code. It should be very close to the google tutorial source code.
public class MapOverlay extends ItemizedOverlay<OverlayItem> {

private List<OverlayItem> overlays = new ArrayList<OverlayItem>();
private Context context;

public MapOverlay(Drawable defaultMarker, Context context) {
    super(defaultMarker);
    overlays = new ArrayList<OverlayItem>();
    this.context = context;
}

@Override
protected OverlayItem createItem(int i) {
    return overlays.get(i);
}

@Override
public int size() {
     return overlays.size();
}

public void addOverlay(OverlayItem overlay) {
    overlays.add(overlay);
    this.populate();
}

@Override
protected boolean onTap(int index) {
  OverlayItem item = overlays.get(index);
  AlertDialog.Builder dialog = new AlertDialog.Builder(this.context);
  dialog.setTitle(item.getTitle());
  dialog.setMessage(item.getSnippet());
  dialog.show();
  return true;
}

}

public class MapsActivity extends MapActivity {

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    MapView mapView = (MapView) findViewById(R.id.mapview);
    mapView.setBuiltInZoomControls(true);

    MapOverlay overlay = new MapOverlay(this.getResources().getDrawable(
            R.drawable.androidmarker), this);

    overlay.addOverlay(new OverlayItem(new GeoPoint(19240000,-99120000), "Blubb", "See?"));
    mapView.getOverlays().add(overlay);
}

@Override
protected boolean isRouteDisplayed() {
    return false;
}
}

Is the source code from the google tutorial available somewhere?

A: The problem is that I forgot to set the bounds of the drawable. It seems that if the mapview doesn't know how to align the image it won't show it at all.
I changed the first line in my constructor from:
super(defaultMarker);

to
super(boundCenterBottom(defaultMarker));

and know its working perfect.

A: At the same time, I have no idea how to help you directly.
Here are links to various editions of a project that definitely work with overlays, perhaps they will help.


text:
Q: Cannot access props from inside navigationOptions I am using the StackNavigator library but cannot figure out how to access the props from within navigationOptions.
In my calling class I have:
navigate("TestView", { mdata: mdataObject })

In my TestView class I have the following:
static navigationOptions = {
    title: this.props.navigation.state.params.mdata.title
}

However, I get the following error:

Cannot find property 'navigation' of undefined

I have confirmed that I can access this.props.navigation.state.params.mdata.title from the componentDidMount() function so there is data there.
Why am I getting this error from within the navigationOptions function and what can I do to fix it?
Also, I called navigateOptions a function, but not sure that is correct. What should I be calling it?

A: Access navigation props at navigationOptions:
static navigationOptions = ({ navigation }) => ({
  title: navigation.state.params.mdata.title // your case
})


text:
Q: How to use the GraalVM Native Image Agent with Quarkus? I'm trying to figure out how to use the GraalVM native image agent with a Quarkus app running via mvn quarkus:dev.
I tried running:
mvn quarkus:dev -Djvm.args="-agentlib:native-image-agent=config-output-dir=native-image-config"

However I get the error:
ERROR: JDWP unable to get necessary JVMTI capabilities.

Any tips?
My version of Java:
openjdk version "11.0.8" 2020-07-14
OpenJDK Runtime Environment GraalVM CE 20.2.0 (build 11.0.8+10-jvmci-20.2-b03)
OpenJDK 64-Bit Server VM GraalVM CE 20.2.0 (build 11.0.8+10-jvmci-20.2-b03, mixed mode, sharing)

A: By default mvn quarkus:dev enables debug with -Xrunjdwp, something like -Xrunjdwp:transport=dt_socket,address=0.0.0.0:5005,server=y,suspend=n
Then you stumble upon an issue described in this answer -- in short JDWP and JVMTI don't seem to work together well.
You can disable debug with passing -Ddebug=false and then it works. Something like this:
mvn quarkus:dev -Ddebug=false -Djvm.args="-agentlib:native-image-agent=config-output-dir=native-image-config"


text:
Q: Does it make sense to provide different dpi versions of a background image in an ImageView with centerCrop that cover the whole screen? I have a layout with an ImageView that covers the complete width and 3/4 of the height of the screen used for a background image. The ImageView is set to android:scaleType="centerCrop", so it scales the image up/down until either the width or height matches the image view bounds and the other dimensions matches or exceeds it.
As the display size of the image is fixed via the image view's layout (which also does not depend on the image's actual dimensions, only on the aspect ratio) I don't need different dpi-version to ensure the image is displayed in the same size across different screen densities.
Also, the ImageView scales the image down appropriately (I assume), and I don't have versions with different resolutions that show a different amount of detail. I could of course create my own versions of the image in different resolutions. But the scaling used should be the same the Android system uses.
Given that, is there any advantage to provide different versions for different resolutions or is it enough to just provide the highest resolution version?
Is there a measurable performance benefit in providing the different resolutions and save the system from doing the scaling?
EDIT: Of course I can provide different sizes of the background image (e.g. 500x500 and 1000x1000) but almost none of the screens will match it exactly. So it has to be scaled anyway. Is there any advantage in providing different sizes if the scaling has to happen anyway?
In addition, afaik, there are no pixel-based resource specifiers. I could provide a 2160x2160px version for xxhdpi, but that would be much to large for smartphones (only needed for tablets). I could combine that with the size specifiers, e.g. large-xxhdpi, normal-xxhdpi, large-xhdpi, etc. But that would lead to a lot of combinations and a lot of different images sizes, making the .apk-file a lot large than it needs to be (and a lot of effort to maintain it).
And even than I wouldn't be able to hit the exact pixel resolution for a device, so it seems to be a lot of effort for only very little to no gain (similar to the argument in this questions).
Is that correct?

A: It is recommended to have multiple densities for images.
Lets consider that you have image 1000x1000 px and your screen is 1024-512 px. System scales the image up a bit and then centers it.
But what if the screen is like 500x250 px. The system needs to scale the 1000x1000 image a lot down, but if you would have 500x500 there as well, it could use that and do the scale computing a lot faster, saving performance and memory.
The process needs to load the original bitmap into memory and then work with that. So with low density phones the highest density image takes very much of memory before the original can be released.


text:
Q: Defining a member function of an object I declare the following object :
var Node = {
  nodeID: '',
  parentID: '',
  nodeName: '',
  children: []
}

and I'd like to write a Contains() function to check if the children array contains a specific Node object, used like Node.Contains(otherNode).
Where and how should I declare it to be able to use this syntax ?

A: Just declare this function next to the other properties:
var Node = {
  nodeID: '',
  parentID: '',
  nodeName: '',
  children: [],
  Contains: function(otherNode) {
    return this.children.indexOf(otherNode) > -1;
  }
}


text:
Q: downloading multiple images into a list with j2me I am trying to create a list of images and text. The problem is that the images are being downloaded from the web.
How do I use threads in j2me to download images from the web without freezing the application?

A: Study tutorial, like this one: Networking, User Experience, and Threads

This article explains how your MIDlet can make network connections without compromising your user interface. It includes six iterative examples that illustrate multithreaded networking and the use of a wait screen...


text:
Q: Closing the main window in cocoa? How can i close a main window programatically in cocoa?
I want to close my main window in a timer function(NSTimer) when a boolean value is set?
How can I do that, I don't want to terminate my application, But would like to just close my window.

A: Something as simple as:
[NSTimer scheduledTimerWithTimeInterval:delay target:[NSApp mainWindow] selector:@selector(performClose:) userInfo:nil repeats:NO];
should work (where delay is an NSTimeInterval with your desired wait time).


text:
Q: Hadoop Hangs on Job Kill Command I am running Hive 0.12 on a Hadoop 1.0.3 cluster and a Job got stuck at 2.5% in the mapping phase with many of the tasks showing a 'Lost task tracker' error.
When I attempt to run the hadoop job -kill job_id command, the command simply hangs and the job is not killed.
In addition, running any of the other hadoop job commands hang as well (such as hadoop job -list). The hadoop fs commands seem to work just fine.
I checked the log files, and I could not find anything out of the ordinary other than the notifications of the lost tasks.
Currently the cluster is stuck on this job and I need to run other MapReduce jobs. What is the best way to kill this job if the hadoop job -kill command is not working?

A: You have no error messages when executing the command ?
To stop the job, you can try to restart hive or restart your mapreduce service on hadoop.


text:
Q: Top 5 records by group in MS Access The code below returns all records :-
SELECT b.BROKERAGE_NAME, q.VAL_DATE
FROM TBLQUOTESNEW q LEFT JOIN TBLBROKERAGESNEW b ON q.BROKERAGE_ID = b.ID
WHERE q.VAL_DATE Is Not Null

Is it possible to have the top 5 records for each BROKERAGE_NAME returned, where VAL_DATE is descending?
Included
    Brokerage A    02/10/2017
    Brokerage A    02/10/2017
    Brokerage A    02/10/2017
    Brokerage A    02/10/2017
    Brokerage A    01/10/2017
    Brokerage B    06/06/2016

Excluded (as not in top 5)
    Brokerage A    30/09/2017

A: SELECT TOP 5
      b.BROKERAGE_NAME,
      q.VAL_DATE
FROM
      TBLQUOTESNEW q
LEFT JOIN
      TBLBROKERAGESNEW b
      ON q.BROKERAGE_ID = b.ID
WHERE
      q.VAL_DATE Is Not Null
GROUP BY
      BROKERAGE_NAME
ORDER BY
      VAL_DATE DESC`


text:
Q: Custom Sorting in Meteor MongoDB I have a Meteor Publication which returns a set of products from a collection. Each document contains a field called 'grade' for which we have assigned a string value of 'S', 'A', 'B', 'C', or 'D'. Each Grade tier represents a more broad condition of an item where 'S' is the best possible condition, 'A' is the next best, then 'B', and so on...
When I return the collection, I want to sort by the grade. Obviously it would not make any sense for MongoDB to have S-Grade products appear first on the list by default, because A, B, C, and D all come before S in standard alphabetical sorting.
Is there a way to set up custom sorting so that I can allow Grade-S items to appear at the top of the list of results during a sort, but also allowing A, B, C, and D to appear following in their proper order?

A: I don't think that mongodb offers a custom comparator for sorting, and I expect the performance of such operation would be poor anyway.
The best option is to use a numeric field for sorting purposes and, if needed, add the string for display purposes (and keep them in sync during document updates etc.).
You can avoid storing the string if you don't strictly need it in the database, and map the numeric value to the string whenever it needs to be displayed. Meteor lets you specify a transform in a query to a collection, and the platform will do the rest for you.


text:
Q: Can't send variable in http request to php I have a problem with my http request.
I send a http request to server(using firefox):
the
requestheader
Host: localhost
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0
Accept: text/html, */*; q=0.01
Accept-Language: vi-VN,vi;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Content-Type: text/plain; charset=UTF-8
Pragma: no-cache
Cache-Control: no-cache
Referer: http://localhost/home1/
Content-Length: 15
Cookie: _ga=GA1.1.868084363.1437301524
Connection: keep-alive

**request body**:

 `ip=192.168.1.13`

**This is my code on server:**

if(isset($_POST['ip'])){
        $ip = $_POST["ip"];
        echo getLightStatusById($ip).'&'.getSuccess($ip)."eos";
    }else{
        echo 'error';
    }

I received message:
error

if i don't have if condition, i received:
undefined index...

What am i wrong?
Thank you!