text:
Q: Setting application_name on Postgres/SQLAlchemy Looking at the output of select * from pg_stat_activity;, I see a column called application_name, described here.
I see psql sets this value correctly (to psql...), but my application code (psycopg2/SQLAlchemy) leaves it blank.
I'd like to set this to something useful, like web.1, web.2, etc, so I could later on correlate what I see in pg_stat_activity with what I see in my application logs.
I couldn't find how to set this field using SQLAlchemy (and if push comes to shove - even with raw sql; I'm using PostgresSQL 9.1.7 on Heroku, if that matters).
Am I missing something obvious?

A: the answer to this is a combination of:
http://initd.org/psycopg/docs/module.html#psycopg2.connect

Any other connection parameter supported by the client library/server can be passed either in the connection string or as keywords. The PostgreSQL documentation contains the complete list of the supported parameters. Also note that the same parameters can be passed to the client library using environment variables.

where the variable we need is:
http://www.postgresql.org/docs/current/static/runtime-config-logging.html#GUC-APPLICATION-NAME

The application_name can be any string of less than NAMEDATALEN characters (64 characters in a standard build). It is typically set by an application upon connection to the server. The name will be displayed in the pg_stat_activity view and included in CSV log entries. It can also be included in regular log entries via the log_line_prefix parameter. Only printable ASCII characters may be used in the application_name value. Other characters will be replaced with question marks (?).

combined with :
http://docs.sqlalchemy.org/en/rel_0_8/core/engines.html#custom-dbapi-args

String-based arguments can be passed directly from the URL string as query arguments: (example...)  create_engine() also takes an argument connect_args which is an additional dictionary that will be passed to connect(). This can be used when arguments of a type other than string are required, and SQLAlchemy's database connector has no type conversion logic present for that parameter

from that we get:
e = create_engine("postgresql://scott:tiger@localhost/test?application_name=myapp")

or:
e = create_engine("postgresql://scott:tiger@localhost/test",
              connect_args={"application_name":"myapp"})

A: If you're using asyncpg driver, you should use
conn = await asyncpg.connect(server_settings={'application_name': 'foo'})

src - https://github.com/MagicStack/asyncpg/issues/204#issuecomment-333917251


text:
Q: How to check for functionalty with multiple threads working without synchronization Consider this code:
public class test2 {
public static void main(String[] args) throws Exception{

    Thread t1 = new Thread(new Runnable() {
        public void run() {
            for(int i = 0; i<1000000; i++) {

            }
        }
    });

    Thread t2 = new Thread(new Runnable() {
        public void run() {
            Out.println("Counter" +" "+ i);
        }
    });

    t1.start();
    t2.start();

}

}
This code is susposed to complete this task:
Implement a program in which a thread increments a counter (static field) 1000000 times. Another thread should immediately output the same counter without waiting for the end of the first thread.
Is my code right? The reason why I am asking is because the output is always 0,and I am not sure if that is right.I'm confused as how to check for functionalty of a code when there is no synchronization in play.

A: The problem is that your code is missing the required static field (e.g. i in the code given below).
class Main {
    // Counter
    static int i = 0;

    public static void main(String[] args) throws Exception {
        Thread t1 = new Thread(new Runnable() {
            public void run() {
                for (i = 0; i < 1000000; i++) {

                }
            }
        });

        Thread t2 = new Thread(new Runnable() {
            public void run() {
                System.out.println("Counter" + " " + i);
            }
        });

        t1.start();
        t2.start();
    }
}

Output:
Counter 8588

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to use Suggester component with Solr.Net I am able to configure the Suggester component with Solr but how do I query it with Solr.Net? Is it supported?

A: The suggester component is not currently implemented in SolrNet. It is listed as an open issue within the SolrNet project - Issue 141 - Suggester Component Support


text:
Q: Application crashes at [[NSBundle mainBundle] pathForResource My Application is crashes in the device at this point,
[[NSBundle mainBundle] pathForResource

I am giving the path for the pdf here . but at the execution time it is showing that it is not getting path there . and that may be the reason for crashing.
however it is running perfectly on simulator .
i am not able to figure out why is this happening
here is that code
NSString *path = [[NSBundle mainBundle] pathForResource:[myArray objectAtIndex:0] ofType:[myArray objectAtIndex:1]];
NSLog(@"array elemt :%@", [myArray objectAtIndex:0]);
NSLog(@"array elemt 1 :%@", [myArray objectAtIndex:1]);
NSLog(@"path is :%@",path);
NSLog(@"responds to selector mainBundle=%@",[NSBundle respondsToSelector:@selector(mainBundle)]?@"YES""NO");
NSURL *targetURL = [NSURL fileURLWithPath:path];

in this log of the path - when i use device it is showing me nil and when i use simulator it is showing me the path . and it is showing me that is is crashing on NSURL line

A: I've found that when something like this works on the simulator, but not on the device, it's likely a problem with the case of the string. Your device is case sensitive but not your computer. Check your string of the file name or the type.


text:
Q: content displayed out of expandable div image When I tried to add content dynamically,div image is expanding,but the content is displaying outside the image.

        if the content is long,going out og image

.sentcontainer
{
     background-image: url("../images/sent.png");
        background-size: 100% 100%;
        margin-right: -8%;
        overflow:auto;
}

please me to get through.

A: Use padding instead of strange -/+ % margins and add the missing
 tag:
jsBin demo


text:
Q: Swapping using two variables not three?
Possible Duplicate:
Swapping two variable value without using 3rd variable

we have
int a=4;
int b=7;

can i swap these no.s without using third variable?

A: a=a+b;
b=a-b;
a=a-b;

A: The precise implementation of course depends on the programming language you're using, but check out XOR swap.
An example in C could be
#include <stdio.h>

/* Swaps the content pointed to by a and b. The memory pointed to is
   assumed non-overlapping! */

void swap(int* a, int* b)
{
  *a = (*a)^(*b);
  *b = (*a)^(*b);
  *a = (*a)^(*b);
}

int main(int argc, char** argv)
{
  int a = 4;
  int b = 7;
  printf("a=%d, b=%d\n", a, b);
  swap(&a, &b);
  printf("a=%d, b=%d\n", a, b);
  return 0;
}

Important: As Prasoon Saurav commented on the question itself, this answer to another question is more correct than mine, seeing as it is important that the two variables reside at non-overlapping locations in memory. My example does not check for this.

A: a=a+b;  //a=11,b=7
b=a-b;  //a=11,b4
a=a-b;  //a=7,b=4
or
a=a*b;
b=a/b;
a=b/a;
but careful with this method, overflow or underflow is possible for some combinations.

A: Sure: a,b = b,a works in various programming languages.
In others you can use the xor trick.


text:
Q: How to calculate the number of parameters of convolutional neural networks? I can't give the correct number of parameters of AlexNet or VGG Net.
For example, to calculate the number of parameters of a conv3-256 layer of VGG Net, the answer is 0.59M = (3*3)*(256*256), that is (kernel size) * (product of both number of channels in the joint layers), however in that way, I can't get the 138M parameters.
So could you please show me where is wrong with my calculation, or show me the right calculation procedure?

A: If you refer to VGG Net with 16-layer (table 1, column D) then 138M refers to the total number of parameters of this network, i.e including all convolutional layers, but also the fully connected ones.
Looking at the 3rd convolutional stage composed of 3 x conv3-256 layers:

*

*the first one has N=128 input planes and F=256 output planes,

*the two other ones have N=256 input planes and F=256 output planes.

The convolution kernel is 3x3 for each of these layers. In terms of parameters this gives:

*

*128x3x3x256 (weights) + 256 (biases) = 295,168 parameters for the 1st one,

*256x3x3x256 (weights) + 256 (biases) = 590,080 parameters for the two other ones.

As explained above you have to do that for all layers, but also the fully-connected ones, and sum these values to obtain the final 138M number.
-
UPDATE: the breakdown among layers give:
conv3-64  x 2       : 38,720
conv3-128 x 2       : 221,440
conv3-256 x 3       : 1,475,328
conv3-512 x 3       : 5,899,776
conv3-512 x 3       : 7,079,424
fc1                 : 102,764,544
fc2                 : 16,781,312
fc3                 : 4,097,000
TOTAL               : 138,357,544

In particular for the fully-connected layers (fc):
 fc1 (x): (512x7x7)x4,096 (weights) + 4,096 (biases)
 fc2    : 4,096x4,096     (weights) + 4,096 (biases)
 fc3    : 4,096x1,000     (weights) + 1,000 (biases)

(x) see section 3.2 of the article: the fully-connected layers are first converted to convolutional layers (the first FC layer to a 7 × 7 conv. layer, the last two FC layers to 1 × 1 conv. layers).
Details about fc1
As precised above the spatial resolution right before feeding the fully-connected layers is 7x7 pixels. This is because this VGG Net uses spatial padding before convolutions, as detailed within section 2.1 of the paper:
[...] the spatial padding of conv. layer input is such that the spatial resolution is preserved after convolution, i.e. the padding is 1 pixel for 3×3 conv. layers.
With such a padding, and working with a 224x224 pixels input image, the resolution decreases as follow along the layers: 112x112, 56x56, 28x28, 14x14 and 7x7 after the last convolution/pooling stage which has 512 feature maps.
This gives a feature vector passed to fc1 with dimension: 512x7x7.

A: The below VGG-16 architechture is in the original paper as highlighted by @deltheil in  (table 1, column D)  , and I quote from there

2.1 ARCHITECTURE
During training, the input to our ConvNets is a fixed-size 224 × 224
  RGB images. The only preprocessing we do is subtracting the mean RGB
  value, computed on the training set, from each pixel.
The image is passed through a stack of convolutional (conv.) layers,
  where we use filters with a very small receptive field: 3 × 3 (which
  is the smallest size to capture the notion of left/right, up/down,
  center). The convolution stride is fixed to 1 pixel; the spatial
  padding of conv. layer input is such that the spatial resolution is
  preserved after convolution, i.e. the padding is 1 pixel for 3 × 3
  conv. layers.  Spatial pooling is carried out by five max-pooling
  layers, which follow some of the conv. layers (not all the conv.
  layers are followed by max-pooling). Max-pooling is performed over a 2
  × 2 pixel window, with stride 2.
A stack of convolutional layers (which has a different depth in
  different architectures) is followed by three Fully-Connected (FC)
  layers: the first two have 4096 channels each, the third performs
  1000-way ILSVRC classification and thus contains 1000 channels (one
  for each class).
The final layer is the soft-max layer.

Using the above, and

*

*A formula to find activation shape of a layer!

*

*A formula to calculate the weights corresponding to every layer:

Note:

*

*you can simply multiply respective activation shape column to get the activation size

*CONV3: means a filter of 3*3 will convolve on the input!

*MAXPOOL3-2: means, 3rd pooling layer, with 2*2 filter, stride=2, padding=0(pretty standard in pooling layers)

*Stage-3 : means it has multiple CONV layer stacked! with same padding=1, , stride=1, and filter 3*3

*Cin : means the depth a.k.a channel coming from the input layer!

*Cout: means the depth a.k.a channel outgoing (you configure it differently- to learn more complex features!),
Cin and Cout are the number of filters that you stack together to learn multiple features at different scales such as in the first layer you might want to learn vertical edges, and horizontal edges and edges at say 45degree, blah blah!, 64 possible different filters each of different kind of edges!!

*

*n: input dimension without depth such n=224 in case of INPUT-image!

*p: padding for each layer

*s: stride used for each layer

*f: filter size i.e 3*3 for CONV and 2*2 for MAXPOOL layers!

*After MAXPOOL5-2, you simply flatten the volume and interface it with the first FC layer.!
We get the table:

Finally, if you add all the weights calculated in the last column, you end up with 138,357,544(138 million) parameters to train for VGG-15!

A: A great breakdown of the calculation for VGG-16 network is also given in CS231n lecture notes.
INPUT:     [224x224x3]    memory:  224*224*3=150K   weights: 0
CONV3-64:  [224x224x64]   memory:  224*224*64=3.2M  weights: (3*3*3)*64 = 1,728
CONV3-64:  [224x224x64]   memory:  224*224*64=3.2M  weights: (3*3*64)*64 = 36,864
POOL2:     [112x112x64]   memory:  112*112*64=800K  weights: 0
CONV3-128: [112x112x128]  memory:  112*112*128=1.6M weights: (3*3*64)*128 = 73,728
CONV3-128: [112x112x128]  memory:  112*112*128=1.6M weights: (3*3*128)*128 = 147,456
POOL2:     [56x56x128]    memory:  56*56*128=400K   weights: 0
CONV3-256: [56x56x256]    memory:  56*56*256=800K   weights: (3*3*128)*256 = 294,912
CONV3-256: [56x56x256]    memory:  56*56*256=800K   weights: (3*3*256)*256 = 589,824
CONV3-256: [56x56x256]    memory:  56*56*256=800K   weights: (3*3*256)*256 = 589,824
POOL2:     [28x28x256]    memory:  28*28*256=200K   weights: 0
CONV3-512: [28x28x512]    memory:  28*28*512=400K   weights: (3*3*256)*512 = 1,179,648
CONV3-512: [28x28x512]    memory:  28*28*512=400K   weights: (3*3*512)*512 = 2,359,296
CONV3-512: [28x28x512]    memory:  28*28*512=400K   weights: (3*3*512)*512 = 2,359,296
POOL2:     [14x14x512]    memory:  14*14*512=100K   weights: 0
CONV3-512: [14x14x512]    memory:  14*14*512=100K   weights: (3*3*512)*512 = 2,359,296
CONV3-512: [14x14x512]    memory:  14*14*512=100K   weights: (3*3*512)*512 = 2,359,296
CONV3-512: [14x14x512]    memory:  14*14*512=100K   weights: (3*3*512)*512 = 2,359,296
POOL2:     [7x7x512]      memory:  7*7*512=25K      weights: 0
FC:        [1x1x4096]     memory:  4096             weights: 7*7*512*4096 = 102,760,448
FC:        [1x1x4096]     memory:  4096             weights: 4096*4096 = 16,777,216
FC:        [1x1x1000]     memory:  1000             weights: 4096*1000 = 4,096,000

TOTAL memory: 24M * 4 bytes ~= 93MB / image (only forward! ~*2 for bwd)
TOTAL params: 138M parameters

A: Here is how to compute the number of parameters in each cnn layer:
  some definitions
  n--width of filter
  m--height of filter
  k--number of input feature maps
  L--number of output feature maps
  Then number of paramters  #= (n*m *k+1)*L in which the first contribution is from
  weights and the second is from bias.

A: I know this is a old post nevertheless, I think the accepted answer by @deltheil contains a mistake. If not, I would be happy to be corrected. The convolution layer should not have bias.
i.e.
    128x3x3x256 (weights) + 256 (biases) = 295,168
should be
    128x3x3x256 (weights)  = 294,9112
Thanks


text:
Q: React call a function from another class ES6

class F1 extends React.Component{
  hot(){
    alert("Hot function running");
  }
  lot(){
    let t = this;

      ReactDOM.render(<F2 yF={() => {
      t.hot();
    }} />,document.getElementById("b"));
  }
  render(){
     return (
      <button onClick={this.lot}>F1 click</button>
    );
  }
}
class F2 extends React.Component{
  constructor(props){
    super(props);
  }
  render(){
    return (
      <button onClick={this.props.yF}>F2 click</button>
    );
  }
}

 ReactDOM.render(<F1 />,document.getElementById("a"));

<!DOCTYPE html>

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>

https://jsbin.com/poqofohiqa/edit?html,js,console,output
I want to call a function that is inside class F1 when i click Button F2 the function inside F1 should be executed.
Currently im trying to pass the function from F1 to F2 but its not working
UPDATE 1
To make it simple ...
Im trying to call hot function inside F1 by clicking the button on F2

A: You need to bind lot method to this in constructor method. Then only it will get the context

class F1 extends React.Component{
  constructor() {
    super();
    this.lot = this.lot.bind(this);
  }
  hot(){
    alert("Hot function running");
  }
  lot(){
      ReactDOM.render(<F2 yF={() => {
       this.hot();
      }} />,document.getElementById("b"));
  }
  render(){
     return (
      <button onClick={this.lot}>F1 click</button>
    );
  }
}
class F2 extends React.Component{
  constructor(props){
    super(props);
  }
  render(){
    return (
      <button onClick={this.props.yF}>F2 click</button>
    );
  }
}

 ReactDOM.render(<F1 />,document.getElementById("a"));

<!DOCTYPE html>

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>


text:
Q: WrappingText in stackpanel I have a stackpanel with 2 textblocks. The problem is that my textblocks doesn't wrap a text.
What is weird, even if I have only one textblock wrapping also doesn't work.
        <StackPanel Orientation="Horizontal" VerticalAlignment="Top" Grid.Row="1" Grid.ColumnSpan="2" Margin="0">
            <!--<ContentControl Width="800">-->
                <TextBlock x:Name="textBlock" TextWrapping="Wrap" Text="{Binding Path=StaticTextLibrary.ApplicationSubtitle, Source={StaticResource ResourcesManager}}"
                        FontSize="14" HorizontalAlignment="Left" Foreground="{StaticResource text}" Opacity="0"  RenderTransformOrigin="0.5,0.5"
                        VerticalAlignment="Bottom" Padding="5" Height="30">
                    <TextBlock.RenderTransform>
                        <CompositeTransform TranslateX="30"/>
                    </TextBlock.RenderTransform>
                </TextBlock>
            <!--</ContentControl>-->
            <TextBlock x:Name="subTitlePostfix" TextWrapping="Wrap" Text="by Credit Suisse©" Margin="6,0,0,0" Opacity="0" RenderTransformOrigin="0.5,0.5" VerticalAlignment="Top" HorizontalAlignment="Left" Foreground="{StaticResource text}" Padding="0,4,0,0" >
                    <TextBlock.RenderTransform>
                        <CompositeTransform TranslateX="30"/>
                    </TextBlock.RenderTransform>
            </TextBlock>
        </StackPanel>

Where have I done a mistake?

A: Why don't you use a WrapPanel from the Silverlight ToolKit?

A: I copied to code and punched it until it would wrap.
Here are a few notes and a solution:
Your first TextBlock specifies a Height, but 30 is not enough for a second line ==> can't wrap because can't create a second line. Remove Height="30".
Instead of StackPanel, don't you mean WrapPanel? unless you have something special in mind.
I used TranslateTransform x="30" instead of CompositeTransform TranslateX="30", it shouldn't be an issue though.
HTH,
bab.


text:
Q: How to get md select value in angular js i want to to get value from md select but i don't know how to do that
<md-option ng-value="{"region":"United Arab Emirates","country_code":"ae","url":"google.ae"}">Test
</md-option>

I want to get value from select option and create a link
Like This

A: You need to store the data into the "model" attribute of the parent "md-select".
<md-select ng-model="someModel">
   <md-option ng-value="{"region":"United Arab Emirates","country_code":"ae","url":"google.ae"}">Test
   </md-option>
<md-select>

The value is then set to the variable "someModel" in your Controller and you typically access it via $scope.someModel


text:
Q: How to compare each cell in one column with a specific value in pandas? I have a dataframe like this, I want to achieve this:
if the sign of A is the same with the sign of B, get a new column C = min(3, |A|);
if the sign of A is is different from the sign of B, C = min(3, B);
if the values for A & B are zero, C=A
Type subType  A       B     C
 X    a       -1      4     3
 X    a       5       9     3
 X    a       5       9     3
 X    b       1       4     1
 X    b       3       5    ...
 X    b       5       0
 Y    a       -1      1
 Y    a       3       2
 Y    a       -5      3
 Y    b       1       4
 Y    b       3       5
 Y    b       5      -2

I tried :
if df["A"] * df["B"] > 0:
    df["C"] = (3, abs(df["A"]).min(axis=1)

It gave me error, seems like I can't compare a value '3' with a column directly, any suggestions?
Follow-up: what if the formula is more complex like C = A + min(3, |A|) *B?

A: Because if the values for A & B are zero it means use minimum between (3, abs(0)) what is always 0 solution should be simplify with numpy.where and numpy.minimum:
#compare signs
m = np.sign(df["A"]) == np.sign(df["B"])
#alternative
#m = (df["A"] * df["B"]) >= 0
df['C'] = np.where(m, np.minimum(3, df.A.abs()), np.minimum(3, df.B))
print (df)
   Type subType  A  B  C
0     X       a -1  4  3
1     X       a  5  9  3
2     X       a  5  9  3
3     X       b  1  4  1
4     X       b  3  5  3
5     X       b  5  0  0
6     Y       a -1  1  1
7     Y       a  3  2  3
8     Y       a -5  3  3
9     Y       b  1  4  1
10    Y       b  3  5  3
11    Y       b  5 -2 -2

EDIT: If need more condition in pandas/numpy is possible use instead multiple np.where function numpy.select:
m1 = np.sign(df.A) == np.sign(df.B)
m2 = np.sign(df.A) == np.sign(df.C)

s1 = df.A + np.minimum(3, df.A.abs()) * df.B
s2 = df.C + np.minimum(3, df.A.abs()) * df.B

df['D'] = np.select([m1, m2], [s1, s2], default=df.A)
print (df)
   Type subType  A  B  C   D
0     X       a -1  4  3  -1
1     X       a  5  9  3  32
2     X       a  5  9  3  32
3     X       b  1  4  1   5
4     X       b  3  5  3  18
5     X       b  5  0  0   5
6     Y       a -1  1  1  -1
7     Y       a  3  2  3   9
8     Y       a -5  3  3  -5
9     Y       b  1  4  1   5
10    Y       b  3  5  3  18
11    Y       b  5 -2 -2   5

A: df['C'] = [min(abs(a), 3) if a*b > 0 else min(b, 3) if a*b < 0 else a for a,b in zip(df.A, df.B)]

A: df['C'] = np.where(df.A.mul(df.B).gt(0), df.A.abs().clip(upper=3),
                   np.where(df.A.mul(df.B).lt(0), df.B.clip(upper=3), df.A)
                  )

    Type    subType A   B   C
0   X       a       -1  4   3
1   X       a       5   9   3
2   X       a       5   9   3
3   X       b       1   4   1
4   X       b       3   5   3
5   X       b       5   0   5
6   Y       a      -1   1   1
7   Y       a       3   2   3
8   Y       a      -5   3   3
9   Y       b       1   4   1
10  Y       b       3   5   3
11  Y       b       5  -2  -2

A: You can try this as you would:
df["C"] = np.where(df["A"]*df["B"]>0, min(3,abs(df["A"]).min()),
                   np.where(df["A"]*df["B"]<0, min(3,df["B"].min()),
                            df["A"]))

df
   Type subType  A  B  C
0     X       a -1  4 -2
1     X       a  5  9  1
2     X       a  5  9  1
3     X       b  1  4  1
4     X       b  3  5  1
5     X       b  5  0  5
6     Y       a -1  1 -2
7     Y       a  3  2  1
8     Y       a -5  3 -2
9     Y       b  1  4  1
10    Y       b  3  5  1
11    Y       b  5 -2 -2


text:
Q: How to configure vm login with Azure AD credentials (Windows Server 2019) I have been trying to configure login with Azure Credentials for a Windows Server , I followed up this :
https://learn.microsoft.com/en-us/azure/active-directory/devices/howto-vm-sign-in-azure-ad-windows
I can see that extension is installed , however once I tried to login in received this error :
Logon Faile
I see some advices about this but still having the issue :https://learn.microsoft.com/en-us/azure/active-directory/devices/howto-vm-sign-in-azure-ad-windows#unauthorized-client
Alreday tried using AzureAD/UPN but did not work.
Do I need to do Azure AD Join to this server for being able to use this extension for AzureADLogin ? Or I need to do Azure AD Join to my personal computer that is trying to connect to this vm via RPD ?
Thanks for the help !

A: You need to do either Azure AD registered (starting Windows 10 20H1), Azure AD joined or hybrid Azure AD joined to your personal computer that is trying to connect to this Azure VM. See the Supported Azure regions and Windows distributions.

Remote connection to VMs joined to Azure AD is only allowed from
Windows 10 PCs that are either Azure AD registered (starting Windows
10 20H1), Azure AD joined or hybrid Azure AD joined to the same
directory as the VM.

For more reference, you may want to know find the Azure AD Join Type with the command dsregcmd /status.


text:
Q: Does Puzzle Quest on PlayStation 4 include the "Revenge of the Plague Lord" expansion? I really loved playing Puzzle Quest back when it was released, and noticed that the PlayStation 4 version was on sale this week so was considering re-buying it.
There was an expansion made for the game called "Revenge of the Plague Lord" that was released as DLC for some platforms, and bundled with the main game on others.
I couldn't see any reference to the expansion in the description on the store, and it isn't listed as DLC either.  So is it being sold as part of the base game, or is it simply not available?

A: Having played through the entirety of Puzzle Quest on the DS (sans expansion) as well as the PS4 version, I did not see any differences. Having looked up what the expansion includes, I can say for certain that the Revenge of the Plague Lord expansion is not included in the item you linked to (the same version I have on my PS4). The additional character classes were definitely not available.
That said, I cannot find a link to the expansion in the PSN store, nor can I find any articles mentioning it being ported to the PS4, so I do not think it is available.


text:
Q: Множественный выбор с пунктом "другое" Как сделать поле формы, где пользователь может выбрать несколько значений и/или вписать свое? Т.е. должно получиться что-то вроде этого.

<html>
<head>
  <meta charset="UTF-8">
  <title>Множественный выбор</title>
</head>
<body>
  <label>
  <input type="checkbox">Яблоки
  </label>
  <label>
  <input type="checkbox">Груши
  </label>
  <label>
  <input type="checkbox">Бананы
  </label>
  <input type="text" placeholder="Другое">
</body>
</html>


text:
Q: Subclipse error "svn: SQLite compiled for 3.8.6, but running with 3.8.5" I am trying out the Mac OS X Yosemite beta [edit: same issue in full release], which seems to have broken my Eclipse/Subversion.  When I attempt to perform any svn action, I get:
svn: Couldn't perform atomic initialization
SQLite error
svn: SQLite compiled for 3.8.6, but running with 3.8.5

I have installed subversion-javahlbindings +nobdb+universal using macports, which includes the most recent SQLite3 (3.8.6), so I have no idea where the 3.8.5 is coming from on my system.
Svn works fine on the commandline, but not Eclipse.  I have looked at this similar problem and googled the relevant E200029 error code without success.
Since it works on the command line, I'm thinking there's something in my Eclipse setup which is somehow pointing to the wrong/old svn but I can't find anywhere I can change any settings that would apply.
Any advice?  (other than the obvious switching my OS back to Mavericks)
Edit:  I've got svnkit working to get the Eclipse svn functionality but still would like to figure out what's going on with the subversion-javahl for future reference.

A: I have solved this problem.
replace version to 3.8.5.0, it's ok.
1, # brew uninstall sqlite
2, # brew uninstall subversion
3, # brew edit sqlite
modify following content:
  3 class Sqlite < Formula
  4   homepage "http://sqlite.org/"
  5   url "https://www.sqlite.org/2014/sqlite-autoconf-3080500.tar.gz"
  6   version "3.8.5.0"
  7   sha1 "7f667e10ccebc26ab2086b8a30cb0a600ca0acae"

 34   resource "docs" do
 35     url "https://www.sqlite.org/2014/sqlite-doc-3080500.zip"
 36     version "3.8.5.0"
 37     sha1 "c5655a4004095c50dc8403661e0ed02fd4191d57"
 38   end

like vim , :wq to save changes and quit.
4, # brew install --universal --java subversion
5, # rm -f /Library/Java/Extensions/libsvnjavahl-1.dylib
    delete symbolic link file;
6, # sudo mkdir -p /Library/Java/Extensions
    # sudo ln -s /usr/local/lib/libsvnjavahl-1.dylib /Library/Java/Extensions/libsvnjavahl-1.dylib
7, reboot Eclipse, it's OK.

A: This problem is caused by the fact that Yosemite appears to include a version of sqlite that is earlier than the one delivered by MacPorts.  I have found a work-around to this problem by downgrading the version that MacPorts installs.  MacPorts does not have 3.8.5 version of the port, so the following steps will manually do this.  Also, the next time you do a port selfupdate you will wipe out these changes, so you may have to repeat these steps.
Type sudo port edit sqlite3
Edit the version and checksums lines to the following:
version             3.8.5
checksums           rmd160  b8da5ec594ac808da85469349c7506bd343946bf \
                sha256 98c33abe4106e508e73fda648b2657ac9e969fe24695f543dcde68cc71f3091b

Type sudo port install sqlite3
Type sudo port upgrade --force subversion-javahlbindings +no_bdb+universal
This will cause subversion to recompile against the 3.8.5 version of sqlite3.

A: See if you can run this command from command line:
$ svn --version --verbose
This will show all the libraries that are loaded which should show you where SQLite is coming from.  I'd also see if MacPorts has any updates or pending patches to the port file.  Maybe there are different build/link options needed now.  I'd file a bug in their tracker if you cannot find anything.
I recall seeing errors like this in the past, but I have been using Homebrew for a while and the build process is different.
I have not tried on Yosemite.

A: I am on latest public Yosemite + MacPorts everything updated, Eclipse Luna 4.4 (STS 3.6.1), subclipse 1.10.5.
$ /usr/bin/sqlite3 --version
3.8.5 2014-08-15 22:37:57 c8ade949d4a2eb3bba4702a4a0e17b405e9b6ace

$ /opt/local/bin/sqlite3 --version
3.8.6 2014-08-15 11:46:33 9491ba7d738528f168657adb43a198238abde19e

I have a feeling macports' javahlbindings had some references to the 3.8.5 version. Didn't spend too much time to check.
My workaround is to use SVNKit (Pure Java) SVNKit v1.8.5.10237.
Eclipse->Preference->Team->SVN->SVN Interface->change from javahl to SVNKit
SVNKit is one of the Subclipse's feature. (SVNKit Client Adapter (Not Required))

A: I've been relying on Macports for the java HL for Eclipse Luna, and after I updated to Yosemite I, too, ran into the same problem.  I use subversive instead of subclipse, but the error was the same.  I decided to give Homebrew a try and to my surprise the SQLite error went away.
$ brew install --java subversion
$ brew options subversion # shows your options
$ brew install --universal --java subversion # Got Warning: subversion-1.8.10_1 already installed
$ sudo mkdir /Library/Java/Extensions
$ cd /Library/Java/Extensions
$ sudo ln -sf /usr/local/lib/libsvnjavahl-1.dylib
$ sudo ln -sf /usr/local/lib/libsvnjavahl-1.jnilib
$ nano ~/.profile # add export PATH=/usr/local/bin:$PATH

A: I see the same thing here. Fresh macports, rebuilt sqlite3 and subversion*. Everything works in command line, but eclipse / subclipse fails with
SQLite compiled for 3.8.7, but running with 3.8.5

Looks fishy that svn links with both versions. I tried adding --with-sqlite3=${prefix} to the Portfile for subversion and subversion-javahlbindings, but that did not help.
$ svn --version  --verbose|grep sql
- /opt/local/lib/libsqlite3.0.dylib   (64-bitars Intel)
- /usr/lib/libsqlite3.dylib   (64-bitars Intel)

Any ideas how to resolve this, apart from using the somewhat more insecure native binding?

A: I encounter the same problem, saying:
svn: E200029: Couldn't perform atomic initialization
svn: E200030: SQLite compiled for 3.8.9, but running with 3.8.8.3

and my svn version is downgrade from 1.8 to 1.7.14 by following this post: Install a Specific Version of a Tool on OS X With Homebrew。
But after downgrade svn, I got this sqlite error. I fixed the problem by this:
$ brew update
...omit a lot of output...
$ brew upgrade sqlite
==> Upgrading 1 outdated package, with result:
sqlite 3.8.10.2
==> Upgrading sqlite
==> Downloading https://homebrew.bintray.com/bottles/sqlite-3.8.10.2.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring sqlite-3.8.10.2.yosemite.bottle.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local.

Mac OS X already provides this software and installing another version in
parallel can cause all kinds of trouble.

OS X provides an older sqlite3.

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/sqlite/lib
    CPPFLAGS: -I/usr/local/opt/sqlite/include

==> Summary
  /usr/local/Cellar/sqlite/3.8.10.2: 9 files, 2.8M

after this, it works just fine!


text:
Q: Using TransactionScope class I've a .Net based thick client winforms application deployed to the clients.
I need to use TransactionScope class [System.Transactions] in the code for handling transactions on the oracle database.
Looks like this class requires oramts.dll on the client machine.
See here:
Using transaction scope and querying
Given this, is it a good idea to use this class in a thick client application?
Because, then all the client machines would need to have this dll and other dependancies present on their machine.
Plus, if these dlls are COM based, then  they would need to be registered in the registry too.
Is oramts.dll a COM dll?And can anyone please let me know what are its dependancies?
Please advise.
Thanks.

A: TransactionScope is a very elegant and errorsafe way to handle transactions in the code. It's definitely worth having to add another dll.
By the way - are you sure that the dll wouldn't be needed if you created the transactions by hand?


text:
Q: I'm trying to Normalise a vector but my code returns a fail? Below is my code sample, trying to normalize my 3 point vector {5, 5, 5}
however it is printing "Normalise - Failed" when running, may someone explain why it isn't succeeding this to me so i may attempt to fix it?
#include <iostream>
#include "Geometry.h"
#include <math.h>

void Normalise()
{
    TVector3 _krA;//vector / mag vector = answer x y z
    {
        _krA.m_fX = 5;
        _krA.m_fY = 5;
        _krA.m_fZ = 5;
    }
    TVector3 _rResultant;
    {
        _rResultant.m_fX = (_krA.m_fX * _krA.m_fX);
        _rResultant.m_fY = (_krA.m_fY * _krA.m_fY);
        _rResultant.m_fZ = (_krA.m_fZ * _krA.m_fZ);
    }
    float _fResultFinalMag = sqrt(_rResultant.m_fX + _rResultant.m_fY + _rResultant.m_fZ);

    float _fresultXMag = (_krA.m_fX / _fResultFinalMag);
    float _fresultYMag = (_krA.m_fY / _fResultFinalMag);
    float _fresultZMag = (_krA.m_fZ / _fResultFinalMag);

    float _fNormliseTestX = 0.577350;
    float _fNormliseTestY = 0.577350;
    float _fNormliseTestZ = 0.577350;

    if (_fNormliseTestX == _fresultXMag && _fNormliseTestY == _fresultYMag && _fNormliseTestZ == _fresultZMag)
    {
        std::cout << "Normalise - Success" << std::endl;
    }
    else
    {
        std::cout << "Normalise - Failed" << std::endl;
        std::cout << _fresultXMag << std::endl;
        std::cout << _fresultYMag << std::endl;
        std::cout << _fresultZMag << std::endl;
        std::cout << _fResultFinalMag << std::endl;
    }
}

A: The reason your code prints "Failed", is because you're comparing float values exactly using ==. Floating point data types don't generally store values exactly, but instead store them with a certain precision. Furthermore, they're subject to rounding errors, further compounded the more calculations you perform with the values.
Have a read through this C++ FAQ entry about "Why doesn't my floating-point comparison work?" for a good explanation.
One option you have, is to compare using an epsilon :
float epsilon = 0.0001; // or whatever accuracy you require
if (fabs(_fNormliseTestX - _fresultXMag) < epsilon) {
    // _fNormliseTestX and _fresultXMag are considered equal
}


text:
Q: How to call shiny module based on reactive input? I would like to call a nested module server based on a reactive input and display the return output on the main panel. The function callModule doesn't seem to work here when it is depending on a reactive input.
I assume this to be a common scenario when you're building a complex app but I've been struggling to find a solution.
Below is my code or you can run the app by entering the following command in R:
shiny::runGist("23abbb50a1df6a91af990a7401919044")
Thank you in advance.
library(shiny)

# innerModule 1
csvFile_Input <- function(id, label = ".csv file") {
  # Create a namespace function using the provided id
  ns <- NS(id)
  tagList(
    fileInput(ns("file"), label),
    checkboxInput(ns("heading"), "Has heading")
  )
}

# server
csvFile <- function(input, output, session){

  userFile <- reactive({
    req(input$file)
  })

  dataframe <- reactive({

    read.csv(userFile()$datapath,
             header = input$heading)
  })

  observe({
    msg <- sprintf("File %s was uploaded", userFile()$name)
    cat(msg, "\n")
  })

  return(dataframe)

}

# innerModule 2
othersource_Input <- function(id) {
  ns <- NS(id)
  textInput("text", label = h3("From the web"), value = "http://www.stats.ox.ac.uk/pub/datasets/csb/ch11b.dat")
}

othersource <- function(input, output, session){
  library(data.table)

  dataframe <- reactive({
    req(input$text)
    fread(input$text)
  })

   return(dataframe)
}

loadDataInput <- function(id){
  ns <- NS(id)
  wellPanel(
    tagList(
      uiOutput(ns("selectSource")),
      uiOutput(ns("text"))
    )
  )

}

loadData <- function(input, output, session){

  ns <- session$ns

  # Select source from user or from wibi
  output$selectSource<-renderUI(
    radioButtons(
      ns("dt"), "Data source",
      c(csvFile = "fromCSV", web = "fromWeb"),
      inline = TRUE
    )
  )

  dtype <- reactive({
    req(input$dt)
  })

  output$text <- renderUI({
    req(dtype())
    if(dtype() == "fromCSV"){
      csvFile_Input(ns("user"))
    } else if (dtype() == "fromWeb"){
      othersource_Input(ns("web"))
    }
  })

 data <- reactive({
    req(dtype())
    if(dtype() == "fromCSV"){
      callModule(csvFile, "user")
    } else if (dtype() == "fromWeb"){
      callModule(othersource, "web")
    }
  })

  output$viewinput <- renderPrint({
    print(data())
  })

  return(data)

}

loadDataOutput <- function(id){
  ns <- NS(id)
  verbatimTextOutput(ns("viewinput"))
}

ui <- fluidPage(
  titlePanel(paste("Calling module based on reactive input")),
  sidebarLayout(
    sidebarPanel(
      loadDataInput("test")
    ),
    mainPanel(
      loadDataOutput("test")
    )
  )
)

server <- function(input, output) {
  callModule(loadData, "test")
}

shiny::shinyApp(ui = ui, server = server)

A: You shouldn't invoke callModule inside renderXXX or reactive functions. The following changes worked for me.
csvinput <- callModule(csvFile, "user")
otherinput <- callModule(othersource, "web")

data <- reactive({
  req(dtype())
  if(dtype() == "fromCSV"){
    csvinput()
  } else if (dtype() == "fromWeb"){
    otherinput()
  }
})

Also, you should use ns("text") in othersource_Input. If you want further explanations, please provide a minimal example.


text:
Q: Troubleshoot failing NUnit Selenium tests in Azure DevOps I am trying to build an NUnit Selenium test suite, that I can run from within Azure DevOps, to perform functional testing on my companies web app.
I've built and testing a demo project locally, which creates a browser instance and authenticates the session with the web app in the OneTimeSetUp - the browser instance is then used to run a demo test. Where I encounter my primary issue is that when I run this test in DevOps, it fails during the OneTimeSetUp, and as such, it fails the test also.
I'm unsure how to resolve this, because as mentioned, locally, the test runs as desired. I'm running the tests against the same web app.
A secondary issue I've encountered with this is that I've tried taking screenshots using the ((ITakesScreenshot)driver).GetScreenshot() method, so that I might be able to see where the test is having trouble, but no screenshots appear in the test results (where I understand they should appear (based off this video))
Without being able to see what the tests are doing in DevOps, I'm at a loss as to how to troubleshoot this issue. Any tips, pointers, or resources on how to achieve this are greatly appreciated.

A:
Troubleshoot failing NUnit Selenium tests in Azure DevOps

Based on your description, you are creates a browser instance and authenticates the session with the web app in the OneTimeSetUp - the browser instance is then used to run a demo test, it shows you are running UI tests.
So, you should make sure run your self-hosted agent as an interactive mode and a special configuration of the agents is required.
Please check the detailed info from the documents UI testing considerations.


text:
Q: Scala Iterator next method caching result? I'm having problems with this code:
case class MyIterator(myVal: Int) extends Iterator[MyIterator] {
    override def hasNext:Boolean = true
    override def next(): MyIterator = MyIterator(myVal+1)
    override def toString:String = s"MyIterator : $myVal"
}

object Main extends App {
    val mi = new MyIterator(0)
    mi.take(5).foreach(println(_))
}

What I'd like to see is:
MyIterator : 0
MyIterator : 1
MyIterator : 2
MyIterator : 3
MyIterator : 4

but instead I'm getting:
MyIterator : 1
MyIterator : 1
MyIterator : 1
MyIterator : 1
MyIterator : 1

and I really can't see why. Does anybody know what's going on?

A: If you look at the source for take you see that it calls a method slice,  which looks like this:
def slice(from: Int, until: Int): Iterator[A] = {
  val lo = from max 0
  var toDrop = lo
  while (toDrop > 0 && self.hasNext) {
    self.next()
    toDrop -= 1
  }

  new AbstractIterator[A] {
    private var remaining = until - lo
    def hasNext = remaining > 0 && self.hasNext
    def next(): A =
      if (remaining > 0) {
        remaining -= 1
        self.next()
      }
      else empty.next()
  }
}

In the while loop next on your iterator is called repeatedly, i.e. the next iteration it doesn't call next on the iterator you return, instead it continues to call next on the same instance. What you've created is essentially an iterator that will always return a new MyIterator, but with the same value each time.
Is there a specific reason you want to implement it recursively? Iterators sort of inherently need to have some kind of state to keep track of which value to return, from the way the trait is written. It seems very hard to implement them immutably in the way that other classes expect them to work. If that's what you're after, take a look at Stream instead.


text:
Q: make $user is undefined Make the variable optional in the blade template. Replace {{ $user }} with {{ $user ?? '' }} I have one-page sidebar.blade.php and I have to import this page in another page as a sidebar
I have variable here that is coming from the controller when I import sidebar to other page using @extends it shows me error undefined variable with solution
" make $user is undefined Make the variable optional in the blade template. Replace {{ $user }} with {{ $user ?? '' }}"
how I can solve this
sidebar code here
@if($user->role  =="handlers" )

                 kontaktuppgifter{{--  --}}

            @endif

A: Since Your probably not passing the variable $user in to each of your views, but you are extending the sidebar view, try using Laravel auth() helper instead to get the user model. You can do something like this:
@if(auth()->user()->role  == "handlers")

            kontaktuppgifter

@endif

You can also share a $user variable with all your views, this way you won't have to query the database each time you want to retrieve the user data.
You can do this in your BaseController class __construct() function:
//App\Http\Controller.php

public function __construct()
{
    $user = auth()->user();

    view()->share('user', $user);
}

Then you can use a user variable in your view, just like you are doing right now:
@if($user->role  == "handlers")

            kontaktuppgifter

@endif

A: If $user is current user, then You should use Auth for that:
@if(auth()->user()->role  =="handlers" )

                 kontaktuppgifter{{--  --}}

@endif


text:
Q: Verifying university membership/attendance via email address My client's web app allows members to sign up (Rails using AuthLogic) and those signups are limited in that they must be under the auspices of a university. To wit: A university organizer can sign up to be the representative of a university, and students can sign up as "attendees" of that university.
I've been tasked with finding if there is a programmatic way to verify university membership/attendance. The only way I can see doing this is having a database of universities and a database of associated emails, and verifying that the student's email address is part of this database. That doesn't help if using Facebooker and AuthLogic's "sign up with Facebook credentials" ability, however.
I suspect the answer to this is "via human intervention," and that this is something we can't solve programmatically. Either we, or the university, will have to bite the bullet and check records. However, I'd thought I'd ask if anyone else has run into the issue of verification of university membership before.

A: I've researched this in many places and the only thing I've come up with are hacks centered around an email suffix database. I think the best (and safest) solution (for us) is to have more of a person to person communication with the university admin for this verification, rather than have it fully automated.


text:
Q: Telerik ASP.NET MVC Grid on Editing in Popup mode gives weird jscript error I have a Grid, which I am trying to Edit in Pop Up mode. The pop up opens fine. I have placed two more grids within the pop up window. I load them through javascript ajax calls. These 2 grids on pop up also get populated just fine. Once I click on the submit for the pop up window (which is the default checkmark icon), I get this Jscript error
"data.CancelledAMA.AgreementID is null or not an object"
Where CancelledAMA is a custom object in my model (ReplacementCombo) that I bind to the original grid (not the 2 grids within the pop up window). And AgreementId is an int within the CancelledAMA object
I have tried the .DefaultDataItem(new ReplacementCombo()) in the original grid so that the model object gets populated with default values and created a constructor object too in the ReplacementCombo model class. But nothing works.

A: People,
I feel proud saying that after hours of pain, I have found the issue and resolved it!
Lesson learnt, on the Telerik MVC Grid you cannot have the DataKey from a nested object of the grid model. My original grid had the datakey as CancelledAMA.AgreementID and CancelledAMA is a nested object within the Model (ReplacementCombo) bound to the original Grid. You can only have a datakey to a property on the top level of the model object not properties of nested objects.
Thanks.


text:
Q: How to change language Google Map V2 android I am using google-play-service-lib. How can I change language of google map i.e. show locations in korian language or Hindi Language.

A: We only need to change the location in the application to get the Map´s descriptions with different language. We have to add validations to avoid the use of deprecated methods:
 @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        String language= "hi"; //Hindi language!.
        Locale locale = new Locale(language);
        Locale.setDefault(locale);
        Configuration config = new Configuration();

        if(Build.VERSION.SDK_INT>Build.VERSION_CODES.JELLY_BEAN){
           config.setLocale(locale);
           getContext().createConfigurationContext(config);
        }else { //deprecated
           config.locale = locale;
           getResources().updateConfiguration(config, getResources().getDisplayMetrics());
        }

...
...

...
Very important to say that all the languages are not supported, this is an example in Russian language:

We can get the code languages from:
https://www.transifex.com/explore/languages/

A: You can change location for Google Maps that use the Google Map API V2 by using a Locale Object.  The language needs to be supported on the device being used though.
Here is the full list of supported languages.
With this code below I was able to change the language on the map to Chinese:
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    String languageToLoad = "zh_CN";
    Locale locale = new Locale(languageToLoad);
    Locale.setDefault(locale);
    Configuration config = new Configuration();
    config.locale = locale;
    getBaseContext().getResources().updateConfiguration(config,
            getBaseContext().getResources().getDisplayMetrics());

    setContentView(R.layout.activity_maps);

    setUpMapIfNeeded();

}

Result, language set to Chinese in the code (no manual changes) on a U.S. based phone:

I was also able to get it to show Korean, use this Locale code:
 String languageToLoad = "ko_KR";

Result:

NOTE
It looks like the supported languages for Google Maps are listed here:
https://developers.google.com/maps/faq#languagesupport

A: Just change the locale on the device.  If translations are available, they will be shown automatically.
A screenshot of my US phone with the locale switched to Korean:

A: hope this easy solution for changing map language helps someone:
simply add call setUpMapLocale() in your activity onCreate():
 private fun setUpMapLocale() {
        val languageToLoad = "iw_IL" // your desired language locale
        val locale = Locale(languageToLoad)
        Locale.setDefault(locale)
        baseContext.resources.configuration.setLocale(locale)
    }

so i just had to call setLocale() on the existing configuration attached to baseContext resources


text:
Q: How to forward https requests to another hosts based on hostname My situation:
I have three ubuntu servers, one NAT router and three domain names and three apache websites. The two domains Ipadress are the WAN ip for the NAT router. All https traffic from internet is forwarded to server one. Every server has his own certificate for his own website.
Someone try to connect:
If the requested hostname is the hostname for website 1. Server 1 shows website 1.
If the requested hostname is for website 2 or 3. Then server 1 forwards the connection to server 2 or 3. The server 2 or 3 shows website 2 or 3.
Remember server 1 does not have the keys for server 2 or 3.
I have two questions.

*

*Is this possible without getting errors like man in the middle.

*How to edit the apache configuration that this works.

Research:
I searched on google howto forward https requests to another https hosts. Most answers is that server 1 has all the public certificates and keys. and that you need to make an another certificate and key for server 2 or 3. (In my case a self signed certificate). But I don't want that server 1 has the private key for server 2 or 3. Because the public ip for server 1, 2 or 3 is the same it is possible that server 1 does not have the private keys.
I also found how you can have mutiple https virtualhosts on one server with different certificates. No because every server has his own website.
Can someone help me?

A: This can be achieved using Apache's Reverse Proxy feature.  In Server 1's Apache configuration, you would create VirtualHost definitions using the hostname's and SSL configs for the sites on Servers 2 and 3, with ProxyPass being used to proxy the connections back to those servers via Server 1.
An alternate method would be to run something like NGINX in front of all three servers, have your HTTP/HTTPS traffic NAT'd to NGINX, and configure it to do SSL termination and reverse proxy for all three servers.


text:
Q: Area between two curves with respect to y
Let $x_1$ be the red curve and $x_2$ be the blue curve. I've tried integrating $x_1-x_2$ as well as $x_2-x_1$ from $y=0$ to $y=9/2$ and both answers were marked wrong.
What do I do here? I'm thinking it might be better to integrate with respect to $x$ and break it down into intervals, but I'm not sure how to go about doing this.

A: In that region, the smallest $y$-coordinate of a point is $0$ (occuring at the point $(0,0)$) and the greatest $x$-coordinate is $\frac92$ (occuring at the point $\left(-\frac{27}4,\frac92\right)$).
So, you should consider the integral$$\int_0^{9/2}(3y-y^2)-(y^2-6y)\,\mathrm dy=\int_0^{9/2}9y-2y^2\,\mathrm dy=\frac{243}8.$$


text:
Q: Positivity of a convolution integral Let $f\in\mathcal{S}(\mathbb{R}^3)$ a real function. Consider the following integral
$$I_f:=\int_{\mathbb{R}^3}\int_{\mathbb{R}^3}\frac{f(x)f(y)}{|x-y|^2}dydx$$
Observe that,  either if $f$ is positive or negative, the integral becomes positive.
Is it true that $I_f\geq 0$ for a generic $f$?

A: In the following, we will construct a suitable real-valued Schwartz
function $f\in\mathcal{S}\left(\mathbb{R}^{3}\right)$ satisfying
$$
A_{f}:=\int_{\mathbb{R}^{3}}\int_{\mathbb{R}^{3}}\frac{f\left(x\right)\cdot f\left(y\right)}{\left|x-y\right|^{2}}dy\,dx<0.
$$
For the idea, note that (as we will see below) $A_{f}$ is given by
a certain convolution, i.e., $A_{f}=\left\langle \phi\ast f,\,f\right\rangle _{\mathcal{S}',\mathcal{S}}$.
Using the Fourier transform, we see that $A_{f}=\left\langle \widehat{f}\cdot\widehat{\phi},\,\widehat{f}\right\rangle _{\mathcal{S}',\mathcal{S}}$.
We will show below that $\widehat{\phi}$ is given by integration
against a locally integrable function; in fact by integration against
$\widehat{\phi}\left(\xi\right)=\frac{\pi}{\left|\xi\right|}$.
Now, note for $U:=B_{1}\left(\left(\begin{smallmatrix}10\\
0\\0
\end{smallmatrix}\right)\right)$ (the open ball with radius $1$ around $(10,0,0)$) that $U\cap\left(-U\right)=\emptyset$. Indeed, for $\xi\in U\cap\left(-U\right)$
we would have
$$
18=2\left[\left|\left(\begin{matrix}10\\
0\\0
\end{matrix}\right)\right|-1\right]\leq2\left|\xi\right|=\left|\xi-\left(-\xi\right)\right|\leq\left|\xi-\left(\begin{matrix}10\\
0\\0
\end{matrix}\right)\right|+\left|-\left(\begin{matrix}10\\
0\\0
\end{matrix}\right)-\left(-\xi\right)\right|<2,
$$
a contradiction. Now, choose an arbitrary nonnegative function $h\in C_{c}^{\infty}\left(U\right)$
and define
$$
g\left(\xi\right):=i\cdot h\left(\xi\right)-i\cdot h\left(-\xi\right)\qquad\forall x\in\mathbb{R}^{3}.
$$
Note $\overline{g\left(-\xi\right)}=-i\cdot h\left(-\xi\right)+i\cdot h\left(\xi\right)=g\left(\xi\right)$,
so that $f:=\mathcal{F}^{-1}g\in\mathcal{S}\left(\mathbb{R}^{3}\right)$
is real-valued.
But (assuming $\widehat{\phi}\left(\xi\right)=\frac{\pi}{\left|\xi\right|}$,
which we will show below),
\begin{align*}
A_{f} & =\left\langle \widehat{f}\cdot\widehat{\phi},\,\widehat{f}\right\rangle _{\mathcal{S}',\mathcal{S}}\\
 & =\int_{\mathbb{R}^{3}}\frac{\pi}{\left|\xi\right|}\cdot\left[\widehat{f}\left(\xi\right)\right]^{2}\,d\xi\\
 & =\int_{\mathbb{R}^{3}}\frac{\pi}{\left|\xi\right|}\cdot\left[i\cdot h\left(\xi\right)-i\cdot h\left(-\xi\right)\right]^{2}\,d\xi\\
\left({\scriptstyle \text{support of }h\text{ and }h\left(-\bullet\right)\text{ is disjoint}}\right) & =-2\cdot\int_{\mathbb{R}^{3}}\frac{\pi}{\left|\xi\right|}\cdot\left[h\left(\xi\right)\right]^{2}\,d\xi\\
\left({\scriptstyle \text{integrand }\geq0\text{ and does not vanish a.e.}}\right) & <0.
\end{align*}
All that remains to show is that indeed $A_{f}=\left\langle \phi\ast f,\,f\right\rangle _{\mathcal{S}',\mathcal{S}}$
with $\widehat{\phi}\left(\xi\right)=\frac{\pi}{\left|\xi\right|}$.
To this end, define
$$
\phi:\mathbb{R}^{3}\to\left[0,\infty\right),x\mapsto\begin{cases}
\left|x\right|^{-2}, & \text{if }x\neq0,\\
0, & \text{if }x=0
\end{cases}
$$
and note $\phi\in L_{{\rm loc}}^{1}\left(\mathbb{R}^{3}\right)$;
in fact, we have (using polar coordinates):
\begin{align*}
\int_{\left|x\right|<1}\left|\phi\left(x\right)\right|\,dx & =\int_{0}^{1}r^{3-1}\int_{S^{2}}\left|\phi\left(r\xi\right)\right|\,d\mathcal{H}^{2}\left(\xi\right)\,dr\\
 & =\mathcal{H}^{2}\left(S^{2}\right)\cdot\int_{0}^{1}\,dr<\infty,
\end{align*}
where $\mathcal{H}^{2}$ denotes the $2$-dimensional Hausdorff measure
and $S^{2}\subset\mathbb{R}^{3}$ is the unit sphere. Likewise, a
similar calculation shows
\begin{align*}
\int_{\left|x\right|>1}\left|\phi\left(x\right)\right|^{2}\,dx & =\mathcal{H}^{2}\left(S^{2}\right)\cdot\int_{1}^{\infty}r^{3-1}\cdot r^{-4}\,dr\\
 & =\mathcal{H}^{2}\left(S^{2}\right)\cdot\int_{1}^{\infty}r^{-2}\,dr\\
 & =\mathcal{H}^{2}\left(S^{2}\right)\cdot\left(-r^{-1}\right)\bigg|_{1}^{\infty}=\mathcal{H}^{2}\left(S^{2}\right)<\infty.
\end{align*}
Hence, we have shown $\phi\in L^{1}\left(\mathbb{R}^{3}\right)+L^{2}\left(\mathbb{R}^{3}\right)\subset\mathcal{S}'\left(\mathbb{R}^{3}\right)$.
Now, with this notation, it is not hard to see
\begin{align*}
\left\langle \phi\ast\overline{f},\,f\right\rangle _{\mathcal{S}',\mathcal{S}} & =\int_{\mathbb{R}^{3}}\left(\phi\ast\overline{f}\right)\left(x\right)\cdot f\left(x\right)\,dx\\
 & =\int_{\mathbb{R}^{3}}\int_{\mathbb{R}^{3}}\frac{\overline{f\left(x\right)}}{\left|x-y\right|^{2}}\,dy\,f\left(x\right)\,dx=A_{f}.
\end{align*}
Here, we take the pairing $\left\langle \cdot,\cdot\right\rangle _{\mathcal{S}',\mathcal{S}}$
to be bilinear (not sesquilinear). Furthermore, I use the normalization
$\widehat{f}\left(\xi\right)=\int f\left(x\right)\cdot e^{-2\pi i\left\langle x,\xi\right\rangle }\,dx$
of the Fourier transform. Now, the left-hand side of the above equation
can be rewritten as
$$
A_{f}=\left\langle \phi\ast\overline{f},\,f\right\rangle _{\mathcal{S}',\mathcal{S}}=\left\langle \widehat{\phi\ast\overline{f}},\,\widehat{f}\right\rangle _{\mathcal{S}',\mathcal{S}}=\left\langle \widehat{\overline{f}}\cdot\widehat{\phi},\,\widehat{f}\right\rangle _{\mathcal{S}',\mathcal{S}}=\left\langle \widehat{\overline{f}}\cdot\widehat{\phi},\,\widehat{f}\right\rangle _{\mathcal{S}',\mathcal{S}}=\left\langle \widehat{f}\cdot\widehat{\phi},\,\widehat{f}\right\rangle _{\mathcal{S}',\mathcal{S}},
$$
where the last step is only valid if $f$ is \emph{real-valued}. This
identity shows that the Fourier transform
$$
\psi:=\widehat{\phi}\in\mathcal{F}\left(L^{1}+L^{2}\right)\subset C_{0}\left(\mathbb{R}^{3}\right)+L^{2}\left(\mathbb{R}^{3}\right)
$$
is important. In fact, if we can show that $\psi\geq0$ almost everywhere,
we are in business.
Now, recall that taking the Laplacian in Fourier domain corresponds
(up to a constant) to multiplication with $\left|x\right|^{2}$ in
space domain, which is nice for us since this will cancel out $\phi$.
More precisely, we have
$$
\mathcal{F}^{-1}\left(\Delta\psi\right)=\sum_{j=1}^{3}\mathcal{F}^{-1}\left(\partial_{j}^{2}\psi\right)=\sum_{j}\left(-2\pi i\cdot x_{j}\right)^{2}\cdot\mathcal{F}^{-1}\psi=-4\pi^{2}\cdot\left|x\right|^{2}\cdot\mathcal{F}^{-1}\psi=-4\pi^{2}.
$$
Taking the Fourier transform of this identity yields
$$
\Delta\left(\frac{-\psi}{4\pi^{2}}\right)=\delta_{0},
$$
with $\left\langle \delta_{0},g\right\rangle _{\mathcal{S}',\mathcal{S}}=g\left(0\right)$
for $g\in\mathcal{S}\left(\mathbb{R}^{3}\right)$. But another solution
to this equation is given by the fundamental solution (cf. https://en.wikipedia.org/wiki/Fundamental_solution#Laplace_equation
and also https://en.wikipedia.org/wiki/Green\%27s_function_for_the_three-variable_Laplace_equation)
of the Laplace equation,
$$
\Gamma:\mathbb{R}^{3}\to\mathbb{R},x\mapsto\begin{cases}
\frac{-1}{4\pi\cdot\left|x\right|}, & \text{if }x\neq0,\\
0, & \text{if }x=0.
\end{cases}
$$
Hence, $\Delta\left(\Gamma-\frac{\psi}{4\pi^{2}}\right)=0$. Taking
again the Fourier transform of this identity, we arrive at
$$
-4\pi^{2}\cdot\left|\xi\right|^{2}\cdot\left[\widehat{\Gamma}+\frac{\widehat{\psi}}{4\pi^{2}}\right]=0.
$$
Since $\left|\xi\right|^{2}$ only vanishes at $0$, it is not too
hard to see that this implies
$$
\mathrm{supp}\left[\widehat{\Gamma}+\frac{\widehat{\psi}}{4\pi^{2}}\right]\subset\left\{ 0\right\} ,
$$
which has to be understood in the sense of tempered distributions.
But the only distributions with this support condition are (finite(!))
linear combinations of $\partial^{\alpha}\delta_{0}$ with $\alpha\in\mathbb{N}_{0}^{3}$.
Hence, $\mathcal{F}\left[\Gamma+\frac{\psi}{4\pi^{2}}\right]\in\left\langle \partial^{\alpha}\delta_{0}\,:\,\alpha\in\mathbb{N}_{0}^{3}\right\rangle $.
By again taking the inverse Fourier transform, we conclude
$$
\Gamma+\frac{\psi}{4\pi^{2}}\in\left\langle X^{\alpha}\,:\,\alpha\in\mathbb{N}_{0}^{3}\right\rangle \qquad\text{ i.e., }\qquad\Gamma+\frac{\psi}{4\pi^{2}}=p
$$
for some polynomial $p$. We want to show $p\equiv0$. To this end,
recall $\psi\in C_{0}\left(\mathbb{R}^{3}\right)+L^{2}\left(\mathbb{R}^{3}\right)$.
Furthermore, $\Gamma\left(x\right)\to0$ as $\left|x\right|\to\infty$.
But for $g\in L^{2}\left(\mathbb{R}^{3}\right)$, it is well-known
that $g\left(nx\right)\xrightarrow[n\to\infty]{}0$ for almost all
$x\in\mathbb{R}^{3}$. Hence, we get $p\left(nx\right)\xrightarrow[n\to\infty]{}0$
for almost all $x\in\mathbb{R}^{3}$. This implies that $p\equiv0$
(I am quite sure that this is true, but at the moment I am lacking
a convincing proof. I will post one if I find one). Hence, we have
shown (up to this last slight problem) that
$$
\psi=-4\pi^{2}\Gamma=\left(x\mapsto\frac{\pi}{\left|x\right|}\right).
$$
Remark: There is probably some easier way of computing the
Fourier transform of $\psi=\mathcal{F}\phi$.


text:
Q: How to print a object's value while debugging python in vscode? What function (if any) should I implement so that VScode (or really python) can pick up the value of a user defined object in the VScode variable pane whilst debugging?
In this image you can see that arr shows up as [1, 2, 3, 4]. How can I get the variable node to show its value (1) instead of <__main__.ListNode object at 0x7f4a19eafb20>

A: Since node is an object, its corresponding __repr__ method is returning that value by default. If you want to see the actual node value instead, then you can add a __repr__ method to ListNode class.
VScode uses the __repr__ method when showing the variable values. Here's a sample ListNode class with __repr__ method added -
class ListNode(object):
    def __init__(self, x):
        self.val = x
        self.next = None

    def __repr__(self):
        return str(self.val)

node = ListNode(1)
print(node)

If you run this in VScode debug mode you would see the expected node value instead of <__main__.ListNode object at 0x101bed2b0>
Without __repr__ method -

With __repr__ method -


text:
Q: Unit test interceptor logic in Axios I have an interceptor set up in Axios that will refresh tokens and then retry the call if the initial HTTP response is a 401.
I'm trying to unit test this logic by mocking Axios request to return a 401 and then a valid response (see a simplified version below) and asserting that it gets called twice.
My problem is that because I'm mocking request the interceptor doesn't seem to run. Rather than retry the request, I get the stubAuthError returned.
Is there any way of achieving what I'm after, or is there a better way to test this?
index.js
const axios = require('axios');

axios.interceptors.response.use(
  response => response,
  error => {
    const status = error.response ? error.response.status : null;

    if (status === 401) {
      return makeRequest();
    } else {
      return Promise.reject(error);
    }
  }
);

async function makeRequest() {
  return axios.request('url');
}

module.exports = {
  makeRequest
};

index.spec.js
const axios = require('axios');

const { makeRequest } = require('./index');

const stubAuthError = { response: { status: 401 } };
const stubResponse = { data: { foo: 'bar' } };

it('should make the request twice', async () => {
  expect.assertions(1);

  axios.request = jest.fn();
  axios.request
    .mockRejectedValueOnce(stubAuthError)
    .mockResolvedValueOnce(stubResponse);

  try {
    await makeRequest();
  } catch (error) {}

  expect(axios.request).toHaveBeenCalledTimes(2);
});

A: interceptors are registered sequentially, similar to express middleware,
you can access axios.interceptors.request and axios.interceptors.response to unit test functions registered on the interceptor manager
for example:
on my main.js:
let axios = require('axios');

axios.interceptors.response.use(
  response => response,
  error => {
    const status = error.response ? error.response.status : null;

    if (status === 401) {
      return makeRequest();
    } else {
      return Promise.reject(error);
    }
  }
);

async function makeRequest() {
  return axios.request('https://randomuser.me/api/');
}

module.exports = {
  makeRequest
};

on my main.test.js:
let axios = require('axios');

//
// based on your question, we don't want to test "makeRequest"
// so, I'm loading the file only to register the interceptors
//
require('./main');

let stubAuthError = { response: { status: 401 } };
let stubExceptionError = { response: { status: 500 } };
let stubResponse = { data: { foo: 'bar' } };

test("interceptor fulfilled", () => {
  let res = axios.interceptors.response.handlers[0].fulfilled(stubResponse);
  expect(res).toEqual(stubResponse);
});

test("interceptor rejected => makeRequest", () => {
  let originalAxiosRequest = axios.request;

  // this fn will be called by "makeRequest"
  axios.request = jest.fn();

  axios.interceptors.response.handlers[0].rejected(stubAuthError);

  expect(axios.request).toHaveBeenCalledTimes(1);

  axios.request = originalAxiosRequest;
});

test("interceptor rejected => exception", async () => {
  await expect(axios.interceptors.response.handlers[0].rejected(stubExceptionError)).rejects.toEqual(stubExceptionError)
});


text:
Q: Sinon spy doesn't work I have a test case like this:
    it("test",function(){

        var spy = sinon.spy(test,"method");
        decider = 1
        test.nextServiceTab();

        assert(spy.calledOnce);

    });

When the method test.nextServiceTab is called, it calls method based on the value decider, which is supposed to be 1. In fact the control goes to the the method.
But why does the control goes to the method? Since I'm spying it should't be right?
My goal was to just check that method is called. Where I'm making mistake?
Is the way I have used sinon is correct?

A: If you want to avoid control entering the function, you should use sinon.stub instead of sinon.spy. With a stub you can still see if it is called because stub implements the same interface as spy, but additionally it prevents the original function from receiving control and allows you to override the behavior.
For example, if you want the function to always return true:
it("test",function(){

    var stub = sinon.stub(test, "method");
    stub.returns(true);

    decider = 1;
    test.nextServiceTab();

    assert(stub.calledOnce);

    stub.restore();

});


text:
Q: How to use AdSense on an AJAX based site the right way? I am currently finishing my web application which will be a soccer/sports data related dashboard. The URL won't change whenever a user clicks on a different team in the sidebar to fetch the according data from an API via AJAX.
I would like to implement a Google AdSense skyscraper which refreshes on a user click within the sidebar (so basically the same dashboard and URL, but new data, each click on a team in the sidebar = new AJAX data = new impression?). So the event to refresh the AdSense banner  would be the user interaction and not an autorefresh.
Would that be in the terms of AdSense and a proper way to implement it into my web application?
Thank you.

A: Yes, that is the prescribed way.  The AdSense API has a refresh method you can call.
I would also recommend setting some sort of throttle on this so that if the user is constantly clicking around on different content, that you're not refreshing that ad too quickly.


text:
Q: How to send a constrained double value over a network efficiently I'm quite new to network programing.
I need to send a latitude longitude pair composed of doubles over a network. I am coding both ends so I can use whatever method I like.
At present. I'm converting both directly to bytes and sending the whole 16 bytes.
What I was wondering was, if it might be better to divide each by the maximum possible value (90 and 180 respectively) then multiply by Int32.MaxValue then convert to an int before sending.
Obviously this would halve the data sent but I can't work out how much precision I would loose.
Does anyone know how to calculate this?

A: You drop from 53 (type double/binary64 significand Wikipedia IEEE_754) to 32 (type integer) bits - a loss of 21 bits or roughly 6 decimal digits (2^21 ~= 2,000,000) of the 15-16 decimal digits that doubles represent.
What precision is required in your application?  Are your latitude and longitude coordinates in degrees?  At the equator 1 degree (of latitude or longitude) is roughly 110km so 3 significant digits gets you to a resolution of ~100km, 5 digits  ~1km, 8 digits ~1m, 10 digits (the best you can hope for with your transform) ~10cm.
This is just rule-of-thumbing by orders of magnitude to give you an idea.  If your coordinates must resolve to less than 10m you should proceed with caution.


text:
Q: Search Gtk# TreeModel using Foreach function Could anyone provide a TreeModel.Foreach function example?.  I am having difficulty figuring out the syntax in c#.
Given an object I would like to search the tree to see if any of the TreeIters contain that object (I know which column to use).  The object may be one of three different types.

A: I know this question has been asked a while ago but since I was looking for a solution to this very question I figured other people might as well.
So here's the correct syntax for the ListStore.Foreach (I assume the syntax will be the same for TreeModel.Foreach):
listStore.Foreach(new TreeModelForeachFunc(delegate(TreeModel model, TreePath path, TreeIter iter) {
    // Do whatever you want to do here...
}));

I hope this helps somebody.


text:
Q: hitTest check of a movie clip without checking its parent What I am trying to do is check for collision of a movie clip instance named enemy with an instance of a movie clip called laser (which is inside a movie clip called ship).
When enemy collides with ship I want the main timeline to go to frame 2.
When enemy collides with laser I want the main timeline to go to frame 3.
The problem is that when ship.laser collides with enemy, it also counts as if ship was colliding with enemy.
Is there a way to check for the collision of ship.laser and enemy without checking for ship and enemy at the same time?
addEventListener(Event.ENTER_FRAME, collide);
function collide(event:Event)
{
    if (enemy.hitTestObject(ship) )
    {
        gotoAndStop(2);
        trace("hit Ship");

    }

    if (enemy.hitTestObject(ship.laser))
    {
        trace("hit laser");
        gotoAndStop(3);

    }
}

A: It's normal that if the enemy collides with laser it also collides with ship, because laser is part of the ship.
What you can do is just to check if enemy collided with laser:
if (enemy.hitTestObject(ship) )
{
    if (enemy.hitTestObject(ship.laser))
    {
        // collides with ship AND laser
    } else {
        // collides with ship only, but not with the laser
    }
}


text:
Q: Untracked file causes failure in git push I originally added a really big file - after failing to push, I untracked the file using git rm subposts.xml --cached.
git ls-tree -r master --name-only does not show the too big post.
I then created a new commit.
However, when I do git push origin master, I still a failure and it cites the untracked file as being too large.
This is not a copy of another post (the git rm --cached command) because the answer in that post did not resolve my issue.
Results of git log (the first commit introduces the large file):
commit db81c3895a00ba2298e77a5daccb5c7f95c27544 (HEAD -> master)
Author:
Date:   Mon Apr 8 17:50:32 2019 -0400

    untrack subposts.xml

commit 1de84132e1171b43d3bc0b9f491619a555933144
Author:
Date:   Mon Apr 8 17:49:07 2019 -0400

    TF program

commit 2193588f8606d8f20743e4f4d423a7db882ec7a4
Author:
Date:   Mon Apr 8 17:45:44 2019 -0400

    first commit


text:
Q: Can I make two requests to the clicky API using just one File() call or similar? I am making a call to the clicky API as follows:
$href = urlencode( $_SERVER['SCRIPT_NAME'] );
$title = urlencode( $_SERVER['SCRIPT_NAME'] );
$ref = urlencode( $_SERVER['HTTP_REFERER'] );
$ua = urlencode( $_SERVER['HTTP_USER_AGENT'] );

file("necessary clicky API call to clicky id );

But we need to make a call from one page to two different clicky accounts:
$href = urlencode( $_SERVER['SCRIPT_NAME'] );
$title = urlencode( $_SERVER['SCRIPT_NAME'] );
$ref = urlencode( $_SERVER['HTTP_REFERER'] );
$ua = urlencode( $_SERVER['HTTP_USER_AGENT'] );

file("necessary clicky API call to clicky id X );

file("necessary clicky API call to clicky id Y );

Is there anyway in PHP to do that without making use of the file() function twice? It seems like it would be optimal to log both in one connection if that is an option, but I am not sure if it is possible?
Is the lag time of two connections perhaps not a worry? That's a loaded question I suppose as we want this page to perform as quickly as possible.

A: Not familiar with that API but if the API urls differ then yes your need to make 2 requests, if speed is important to you then you could use curl_multi, which will make both requests at the same time. Which could speed up the return speed, but your still need to explode() each line into an array like file() does if you require that. So it might not make a huge difference, but heres an example:
<?php
function curl_multi($urls = array()) {
    $curl = array();
    $result = array();

    $mh = curl_multi_init();
    foreach ($urls as $id=>$url) {
        $curl[$id] = curl_init();
        curl_setopt($curl[$id], CURLOPT_URL, $url);
        curl_setopt($curl[$id], CURLOPT_HEADER, 0);
        curl_setopt($curl[$id], CURLOPT_TIMEOUT, 30);
        curl_setopt($curl[$id], CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; curl)');
        curl_setopt($curl[$id], CURLOPT_RETURNTRANSFER, true);
        curl_multi_add_handle($mh, $curl[$id]);
    }

    $running = null;
    do {
        curl_multi_exec($mh, $running);
    } while($running > 0);
    foreach($curl as $id=>$c) {
        $result[$id] = curl_multi_getcontent($c);
        curl_multi_remove_handle($mh, $c);
    }
    curl_multi_close($mh);
    return $result;
}

$urls['X'] = 'clicky API URL call to clicky id X';
$urls['Y'] = 'clicky API URL call to clicky id Y';

foreach(curl_multi($urls) as $id=>$result){
    $urls[$id] = explode(PHP_EOL, $result);
}
?>


text:
Q: SymPy : Using Results of sympy.solve function I will try to use the result of solve function in sympy
from sympy import solve,  expand,

SolutionForPi = (alpha*mu*(-gamma*l*rho + gamma*l - gamma*pi*rho + gamma*pi - l*rho - pi*rho)/(-rho/(rho - 1) + 1) + f*mu)-pi
SolutionForPi = solve(SolutionForPi, pi)

The Result is
[mu*(-alpha*gamma*l*rho**2 + 2*alpha*gamma*l*rho - alpha*gamma*l - alpha*l*rho**2 + alpha*l*rho - f)/(alpha*gamma*mu*rho**2 - 2*alpha*gamma*mu*rho + alpha*gamma*mu + alpha*mu*rho**2 - alpha*mu*rho - 1)]

Then I use sympy.expend function
ExpandSolution = expand(SolutionForPi)

But I get this error :
AttributeError: 'list' object has no attribute 'expand'

What I understand is this is a list not an equation so what should I do ?

A: If your solution is encapsulated in a list, access the (single) list member
ExpandSolution = expand(SolutionForPi[0])


text:
Q: Which wavelength of light can reflect easiest on any material? What I know is, when wave has long wavelength it tend to penetrate matter. While a short wavelength tend to be absorbed
So what is the medium value of wavelength has most probability to reflect? And what situation is causing it? Is it because the average size of atom? Or it is a constant value across universe?


text:
Q: How do I align the text below a little better? I almost always use
\begin{equation}
\begin{split}
your equation here // equation in next line
\end{split}
\end{equation}

and I get a really bad aligning in which the text is going outside the border on the right. How can I fix it?

A: if i correctly understood your question you looking for alignment showed in the second equation:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{equation}
\begin{split}
\text{your equation here} \\
\text{equation in the next line}
\end{split}
\end{equation}

\begin{equation}
\begin{gathered}
\text{your equation here} \\
\text{equation in the next line}
\end{gathered}
\end{equation}
\end{document}

if i understood you correctly than your use of split is wrong. it is intended for use in cases similar to the following:
\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{equation}
\begin{split}
y & = \text{your equation here} \\      % observe ampersands
  & = \text{equation in the next line}  % <---
\end{split}
\end{equation}
\end{document}


text:
Q: 'ClassName' does not name a type I have seen similar answers, but I don't seem to be able to solve mine just by looking at these for example ( this or that one for example).
So, I am having that .
A.h
#ifndef INCLUDE_CLASS_NAME
#define INCLUDE_CLASS_NAME

#include <B.h>

using namespace C;

D::DPtr myvariable;  <-- Error in here

#endif

In the include B.h I have this :
namespace C{
namespace E{

class D
{
  public:
      typedef shared_ptr<D> DPtr;
}

} //end of namespace E
} // end of namespace C

Why am I getting this error in the mentioned line :
'D'  does not name a type

I am including the .h file, which defines the class. What am I missing?

A: The symbol D is inside namespace E, which is inside namespace C, so the fully qualified name is C::E::D.
So either:

*

*Add E:: to refer to D correctly:
mutable E::D::DPtr myvariable;

*Declare E in the using directive as well:
using namespace C::E;

A: You missed namespace E...
mutable E::D::DPtr myvariable; // should work

A: You're trying to call a function that does not exist yet according to the preprocessor. You need to define functions before you call them:
int mainFunction(){
    int foo(int bar){ //define function FIRST...
        return bar;
    }
foo(42) //call it later.
}

This should get rid of the error.
This does not:
int mainFunction(){
    foo(42) //trying to call a function before it's declared does not work.
        int foo(int bar){
        return bar;
    }
}


text:
Q: Automatically selecting a checkbox in datagridview when another checkbox is selected A little help would be much appreciated, I am designing a bike hire/booking program as an extension to a current project in VB using a MS Sql DB.
I have a datagridview that is showing several rows of data which is pulled in from my DB, and I am manually adding two more columns in order to have a couple of check box columns.
The idea is that if someone selects a bike using the first check box column, then the second check box column (for selecting a helmet) will automatically be selected.  If the person doesn't want a helmet, then the user can deselect that option.  This is so that the user will automatically be given a helmet unless they make the decision not to have one, instead of having to opt in for a helmet.
How do I make the selection of the first check box enable the second check box?  I have an event handler for when the user clicks on the cell:
 Private Sub dgvBikeAvailability_CellContentClick(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvBikeAvailability.CellContentClick
    drBikeAvailability = dvBikeAvailability(e.RowIndex).Row

    'MsgBox to test data pass through
    MsgBox(drBikeAvailability("bikeName"))

End Sub

I have been trying to access the extra columns I have added to the datagridview, but because they are not present in the datatable, I am unable to do so in the even handler.
Any ideas and suggestions are greatly appreciated!

A: Let's say the fist checkbox is at column index 0 and the second is at index 2
(I think you can replace the indexes with the names of the columns).
You need to handle the value of the checkbox yourself, as the event seems to disable to normal behavior of the click.
Private Sub dgvBikeAvailability_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgvBikeAvailability.CellContentClick
    If e.ColumnIndex = 0 Then
        dgvBikeAvailability.Rows(e.RowIndex).Cells(0).Value = Not dgvBikeAvailability.Rows(e.RowIndex).Cells(0).Value
        dgvBikeAvailability.Rows(e.RowIndex).Cells(2).Value = dgvBikeAvailability.Rows(e.RowIndex).Cells(0).Value
    End If
End Sub

Let me know if it worked.


text:
Q: "this declaration has no storage class or type specifier" I have a link.h file and a link.cpp file. When I set up the constructor definition in link.cpp for class Link, I get two errors:

*

*When hovering the cursor over Link in link.cpp, I get this declaration has no storage class or type specifier.

*When hovering the cursor over the :: after Link in link.cpp, I get expected a ; .

This is a pretty bare bones implementation -- I've double checked the syntax and so far have spotted no structural inconsistencies or syntactical errors. What could this error mean?
link.h
#ifndef LINK_H
#define LINK_H

#pragma once

class Link
{
public:
    Link();
};

#endif

link.cpp
#include "link.h"

Link::Link()
{

}

I have other files with different filenames and class names with the exact same structure and syntax as above, but they aren't giving the errors this one is giving me.


text:
Q: Can a Windows process start a WSL-2 sub-process? Currently we are passing XML to a web service written in C# and running on IIS.  The XML is written to a file.
We then run a series of  Ruby and C++ command line applications as processes started by the web service which read input files and write output files.
The web service then gathers the output files and returns them as an XML response.  The applications can be run as Windows applications, but the developers prefer using WSL because it is more Ruby friendly.
The problem is that the Windows gems are slightly different than the Linux gems.  I would like to run the applications in a WSL process created by the web service.  All the WSL documentation I have found assumes you are typing commands at a WSL bash prompt and does not address the possibility of starting a WSL process from a Windows process.


text:
Q: Is potential energy always defined by a position in a field? Most potential energies appear to have their basis in a field, but do all?  I know gravitational energy has the form $mgh$, which has a position term $h$ but no velocity.  More "internal" energies like elastic energies in a spring can find their root in atomic forces, such as electrostatic forces.  Indeed, when we look at Lagrangian mechanics, we find that the Lagrangian form of Netwonian physics neatly splits the Lagrangian into $L=T-V$, where $T$ is the kinetic energy in the system (depending on velocity), and $V$ is the potential energy (depending only on position).
Is this always true?  Based on current theories, do we always find potential energy takes a form based on a position in spatial coordinates, and nothing more?  Or do we find exotic concepts of energy that show up in the extremes (such as the subatomic world) that are not captured in this field-centric way?

A: I think the potential energy $V$ is always defined as a scalar potential field $\phi(x)$ for every point $x$ in space, associated with a conservative force that is the gradient of the field $F=\nabla\phi(x)$.
So, not only does the potential $V=-\phi$ have to be continuous, it also has to be differentiable at least once. In Euclidean space, this is always true for a conservative force.
Maybe things are different in other spaces though.

A: It is meaningful to speak of potential energy as that measured at a point relative to some other point or inside a region represented by a coordinate system (a field basically). We measure potential energy between two points, so it is hard to imagine a form of potential energy not dependent on position.
In considering non-mechanical situations, there are other examples like chemical potential energy. Here, energy is released (or absorbed) during certain chemical reactions and so there is no apparent position dependence. But this may be not what you had in mind.
The concept of potential energy is not properly defined in special and general relativity because it would depend on your local coordinate system and relativity likes to define its principles so that they are coordinate system independent. For example, you may be measuring the potential energy of mass at a certain height $h$, and it makes no sense to ask "what is the potential energy according to another frame?" Such measurements are only valid in your system and where you locally define $h=0$ or some other value.


text:
Q: Forcefully enable fq_pie I am very interested in setting up fq_pie queue discipline for TCP congestion control. If I write  net.core.default_qdisc = fq_pie to /etc/sysctl.d/90-override.conf, it should enable fq_pie on latest kernels.
It does work on my desktop though. But on my laptop:
$ tc qdisc show
qdisc noqueue 0: dev lo root refcnt 2
qdisc noqueue 0: dev wlp1s0 root refcnt 2
qdisc mq 0: dev wlp0s20f0u3 root
qdisc fq_pie 0: dev wlp0s20f0u3 parent :4 limit 10240p flows 1024 target 15ms tupdate 16ms alpha 2 beta 20 quantum 1514b memory_limit 32Mb ecn_prob 10
qdisc fq_pie 0: dev wlp0s20f0u3 parent :3 limit 10240p flows 1024 target 15ms tupdate 16ms alpha 2 beta 20 quantum 1514b memory_limit 32Mb ecn_prob 10
qdisc fq_pie 0: dev wlp0s20f0u3 parent :2 limit 10240p flows 1024 target 15ms tupdate 16ms alpha 2 beta 20 quantum 1514b memory_limit 32Mb ecn_prob 10
qdisc fq_pie 0: dev wlp0s20f0u3 parent :1 limit 10240p flows 1024 target 15ms tupdate 16ms alpha 2 beta 20 quantum 1514b memory_limit 32Mb ecn_prob 10

As it can be seen that I have 2 wifi adapters. One comes inbuilt to my laptop, which is Qualcomm Atheros (ath10k), fq_pie can't be activated on this.
The fq_pie however, can be activated on TP Link (RTL8188EUS) adapter.
I have also tried 2 more laptops (Dell and HP), the integrated wifi adapter is not actually running fq_pie.
Is there a way to forcefully activate fq_pie to the Qualcomm Atheros and other wifi adapters?
System Details:
$ cat /proc/version
Linux version 5.8.12-xanmod1-1 (makepkg@archlinux) (gcc (GCC) 10.2.0, GNU ld (GNU Binutils) 2.35) #1 SMP PREEMPT Wed, 30 Sep 2020 14:19:49 +0000

$ ip -V
ip utility, iproute2-v5.7.0-77-gb687d1067169

$ tc -V
tc utility, iproute2-v5.7.0-77-gb687d1067169

A: It appears net.core.default_qdisc affects an interface driver when it's loaded. If the kernel module was loaded before net.core.default_qdisc was changed, then it won't affect it afterward. Some interfaces have altered behaviour: multiqueue interfaces will keep mq but their leaves inherit this default instead. lo or veth won't get any default queue.
If you want to ensure the sysctl is changed before the driver, you could:

*

*have it changed in initramfs scripts (some tweaking is probably needed),

*have it loaded from kernel cmdline. This Q/A tells it's possible for any arbitrary sysctl only since kernel 5.8, which you are using. So in theory you could add something this in the boot parameters (probably in GRUB's GRUB_CMDLINE_LINUX) and forget about it:
sysctl.net.core.default_qdisc=fq_pie

but actually this is possible only for built-in drivers. It's very unlikely that sch_fq_pie was compiled built-in.

*delay the loading of the driver for wlp1s0 (I wouldn't know where to do this)

*rmmod ath10k and modprobe ath10k so the new default applies.
Anyway to immediately change an interface's qdisc, just define its qdisc, which will override the default kernel qdisc, which has the reserved handle 0:. For example:
tc qdisc add dev wlp1s0 handle 1: root fq_pie


text:
Q: Can we get only value of _source field using ElasticSearch query Consider the below mapping:
PUT imagetest
{
   "mappings": {
      "imageMap": {
         "properties": {
            "image": {
               "type": "string",
               "index": "no"
            }
         }
      }
   }
}

Using below query
GET imagetest/imageMap/11601_100_44/_source

I am getting this
{
   "image": "/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkS...."
}

I want to write a query that will give me below result
"/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkS...."


text:
Q: TIMESTAMP para data/hora em PT-BR no MYSQL Como faço para retornar a data brasileira em coluna do banco de dados para que ela ficar assim 29-04-2020 17:02:02, porque ele tá retornando assim 2020-04-29 17:02:02.
create database teste;
use teste;

CREATE TABLE cliente (
  cd_cliente INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
  nome VARCHAR(30),
  cpf VARCHAR(14),
  telefone VARCHAR(15),
  email VARCHAR(50),
  cidade VARCHAR(30),
  bairro VARCHAR(30),
  rua VARCHAR(30),
  numero INT,
  data_cadastro TIMESTAMP(0)
);

insert into cliente (nome,cpf,telefone,email,cidade,bairro,rua,numero,data_cadastro)
values
('João','111.111.111-01','(77) 12345-1234','joao@gmail.com','Guanambi','Santo Carlos','Alguma',123,CURRENT_TIMESTAMP);
select * from cliente;

A: Sugiro você incluir no modo default a data e somente na hora da query transformar para o formato desejado.
Tipo:
SELECT DATE_FORMAT('2020-04-29', '%d de %M de %Y');

Você pode setar o banco para pt-br também, o que não recomendo porque pode afetar outros usuários/aplicações.
SET GLOBAL lc_time_names=pt_BR;


text:
Q: Rasing events and handling them I am trying to get this event to fire on my main from but at present it is not firing and updating the progress bar in my class it is called as following
   Private Sub _onTransferStart(ByVal source As String, ByVal destination As String,   ByVal transferredBytes As Integer, ByVal totalBytes As Integer, ByVal message As String) Handles transfer.OnTransferStart
    RaiseEvent onTransferStart(source, destination, transferredBytes, totalBytes, message)
End Sub

then I handled it in my form as follows but its not updating my progress bar for some reas but yet when i set brake point on the ontransferstart it does indead show bytes are downloaded

This is how im calling my on trafnerstart
 Private Sub onTransferStart(ByVal source As String, ByVal destination As String, ByVal transferredBytes As Integer, ByVal totalBytes As Integer, ByVal message As String) Handles transfer.onTransferStart
    Me.ProgressBar1.Minimum = 0
    Me.ProgressBar1.Maximum = totalBytes
    Me.tbStatus.Text = "Transfer started.."
End Sub

I should have stated that I am calling it via a background worker already
  Private Sub bgroundDownload_DoWork(sender As System.Object, e As
  System.ComponentModel.DoWorkEventArgs) Handles bgroundDownload.DoWork

  Dim wcEDIimport As New wcEDIimport
 e.Result = wcEDIimport.DownloadPricat()
 End Sub

 Private Sub bgroundDownload_RunWorkerCompleted(sender As System.Object, e As
System.ComponentModel.RunWorkerCompletedEventArgs) Handles
bgroundDownload.RunWorkerCompleted
Dim results As Boolean = CBool(e.Result)
If results = True Then
    MessageBox.Show("The download is completed: " & results.ToString)
End If
end sub

A: http://msdn.microsoft.com/en-us/library/9aackb16%28v=vs.110%29.aspx
This gives an example of raising and consuming events. I think your issue is, the class raising the event should be different from where the addhandler is used.
You should not use raiseevent and addhandler in the same class.
Sample code:
Class A
    sub raiser()
        RaiseEvent anevent
    end sub
end class
Class B
     dim A1 as A
     sub New()
         AddHandler A1.anevent, AddressOf catchEvent
     End sub
     sub catachEvent()
          'do something here
     end sub
end class


text:
Q: Touchpad multitouch gestures not working My friend asked me to take a look at their laptop as the touchpad was no longer allowing them to scroll with two fingers, or any of the other multitouch gestures. The left and right click and ability to move the cursor still worked. I thought it would be an easy fix, that they'd likely just turned off the function by accident, but it has been a nightmare.
I immediately went to the mouse as a device from the control panel to change its settings and there was no tab for Synaptics. After much trouble, I finally got the Synaptics tab to appear, and although I can access the tab, the button for "settings" is greyed out so I can't access them. I tried updating the mouse's driver and when it returned that the device was "up to date", I uninstalled it, restarted the laptop, downloaded the driver straight from the manufacturer's website, but it still won't do multitouch gestures. I performed a clean boot and still nothing. My friend said this wasn't a problem before the weekend so I did a system restore to a point in very early July. Still nothing!
Does anyone know what has happened to stop the multitouch gestures of the touchpad from working, and how to bring them back again?
The laptop is a Dell 2-in-1, model Inspiron 5482, Windows 10 Home, version 10.0.17134. The device name for the touchpad is PS/2 Compatible Mouse. Touching the screen to scroll and click still works.

A: Happened to me too many times, here is what I did:
Disconnect any external devices(mouse), bluetooth etc.
Uninstall the synaptics driver and restart
Run windows update and check if it is working if not then download the drivers.. make sure you download the correct driver because this is most likely just a driver issue.
Then once synaptics is installed go to mouse settings and configure multi finger scrolling

A: For me, the solution was really simple. I just installed the driver from Dell's website.
This was the procedure:

*

*I rebooted my "Dell 2-in-1, model Inspiron 5482";

*Donwload the file "Intel-HID-Event-Filter-Driver_9FT4R_WIN_2.2.1.375_A10_01.EXE" from Dell Support Center (https://www.dell.com/support/home/pt-br/product-support/product/inspiron-14-5482-2-in-1-laptop/drivers    ==>   https://www.dell.com/support/home/pt-br/drivers/driversdetails?driverid=9ft4r&oscode=wt64a&productcode=inspiron-14-5482-2-in-1-laptop);

*Run the file "Intel-HID-Event-Filter-Driver_9FT4R_WIN_2.2.1.375_A10_01.EXE" and reboot the laptop again.

After this procedure, the touchpad multitouch gestures started working again.


text:
Q: Debugging IBM Application Center Issues Can anyone suggest how to resolve issues on IBM Application center, I am not able to login and download the apps, I am getting a alert message "server error - contact the server administrator", is there a way to debug things and see what is happening, Please suggest.
Thanks
djrecker

A: If you get the message "server error", most likely you will see something in the webserver logs. The webserver logs are in

*

*<Tomcat>/logs

*<Liberty>/usr/servers/<yourserver>/logs

*<WAS>/profiles/<yourprofile>/logs  (and its subdirectories)

If you use firewalls, IHS, load balancers etc., you should also check their logs, as the error can be there.
Device logs can be obtained from the device:
For iOS:

*

*Download iPhone Configuration Utility from Apple to your computer.

*Exit iTunes and Xcode before using.

*Open iPhone Configuration Utility

*Connect Device

For Android:

*

*See here
For BlackBerry until version 6:

*

*The log file can be downloaded from a USB-connected device with the JavaLoader.exe.  (Command: JavaLoader.exe eventlog).

For Windows Phone 8, the situation is not optimal:

*

*See here
In those logs, you should see all REST communication (URLs) that is happening between the device and the webserver. I think a server error is most likely a REST Response 500 "Internal server error", which means there was an exception in the server that you should see in the server logs (or firewall logs etc).


text:
Q: How to get the princeton WN sense id given a sense offset? Python-NLTK I can get the sense offset from a princeton WN sense as marked in the NTLK corpus library:
[in]:'dog.n.01'
>>> from nltk.corpus import wordnet as wn
>>> ss = wn.synset('dog.n.01')
>>> offset = str(ss.offset).zfill(8)+"-"+ss.pos
>>> print offset
[out]:'02084071-n'

That offset is similar to the convention used in http://casta-net.jp/~kuribayashi/cgi-bin/wn-multi.cgi?synset=02084071-n&lang=eng
How can i do the reverse without looping through the whole wordnet corpus? where:
[in]: '02084071-n'
[out]: 'dog.n.01' or Synset('dog.n.01')

I could do this but it's just way way too long and too many redundant cycles:
[in]: '02084071-n'
in_offset, in_pos = "02084071-n".split("-")
from nltk.corpus import wordnet as wn
nltk_ss = [i for i in wn.all_synsets() if i.offset == int(in_offset) and i.pos == in_pos][0]
print nltk_ss
[out]: Synset('dog.n.01')

A: Unfortunately, you cannot reverse lookup without iterating over the corpus at least once (like you have shown). The only thing I can suggest would be to keep it in a dictionary if you are going to be looking up synsets based on offsets multiple times.
>>> senseIdToSynset = {s.offset:s for s in wn.all_synsets()}
>>> senseIdToSynset[2084071]
Synset('dog.n.01')