text:
Q: Listing role members in one single message - discord.py rewrite I made a command that lists the members of a role(it's called gangs on our server).
@bot.command(pass_context=True)
async def gangmembers(ctx,*args):
    server = ctx.message.guild
    role_name = (' '.join(args))
    role_id = server.roles[0]
    for role in server.roles:
        if role_name == role.name:
            role_id = role
            break
    else:
        await ctx.send("Not an existing gang, sorry about that.")
        return
    for member in server.members:
        if role_id in member.roles:
            await ctx.send(f"{member.display_name} - {member.id}")

It does it's job correctly, but I wanna make it that it lists the role members on the same message, not 1 message for each role member. Is that possible to do? If so, what is the solution? Thanks.

A: You can add them to a list, keep in mind that there is a character limit of 2000 in messages. you will get an error if you exceed it.
@bot.command(pass_context=True)
async def gangmembers(ctx, *args):
    server = ctx.message.guild
    role_name = (' '.join(args))
    role_id = server.roles[0]
    for role in server.roles:
        if role_name == role.name:
            role_id = role
            break
    else:
        await ctx.send("Not an existing gang, sorry about that.")
        return
    data = []
    for member in server.members:
        if role_id in member.roles:
            data.append(f"{member.display_name} - {member.id}")

    await ctx.send('\n'.join(data))


text:
Q: Passing a variable from one class to paintComponent class my first time here and total newbie. I have two classes in my program, the first class SwingPaintDemo2 and the second class MyPanel. MyPanel contains my paintComponent(Graphics g) method. I have a boolean variable in my first class called isTrue. I want to make it so that if isTrue = true; then paintComponent executes g.fillRect(l, w, 50, 50). Believe me, I have googled and googled and googled......
import java.awt.*;
import javax.swing.*;

public class SwingPaintDemo2 extends JComponent {

public static boolean isTrue = true;

public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            createAndShowGUI();
        }
    });
}

private static void createAndShowGUI() {

    JFrame f = new JFrame("Swing Paint Demo");
    JPanel MyPanel = new JPanel();
     MyPanel.setBorder(BorderFactory.createEmptyBorder(1000, 1000, 1000, 1000));
     MyPanel.setPreferredSize(new Dimension(250, 200));
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.add(new MyPanel());
    f.pack();
    f.setVisible(true);

}

}

class MyPanel extends JComponent {

public MyPanel() {
    setBorder(BorderFactory.createLineBorder(Color.black));
}

public Dimension getPreferredSize() {
    return new Dimension(250,200);
}

public void paintComponent(Graphics g) {
    super.paintComponent(g);
    int l = 30;
    int w = 30;

    if (SwingPaintDemo2.isTrue){g.setColor(Color.black);
  g.fillRect(l, w, 50, 50);}

}
}

how do I get my isTrue variable to my paintComponent class (getting variable not found error in paintComponent class)? Thanks in advance for any help.
Update: I have just posted my most recent code above after making the changes suggested earlier. Now I am getting "cannot find symbol - variable isTrue", any help would be appreciated, thanks

A: If you want to access a public static variable, always refer to it using the name of the enclosing class (and not by recreating a new instance of your SwingPaintDemo2 class):
SwingPaintDemo2.isTrue

You should try to avoid static variables.
Now, maybe you meant to declare a constant, then you need to declare it final
public static final boolean isTrue = true;

Finally, I see also a suspicious line:
if (isTrue=true)

which should rather be
if (isTrue)

NB: variables should start with a lower-case letter.

A: Since isTrue is a static member of SwingPaintDemo2 class, you can access this without instantiating a new object i.e. SwingPaintDemo2.isTrue
So your code will look like:
public void paintComponent(Graphics g) {
    super.paintComponent(g);
    int l = 30;
    int w = 30;
   SwingPaintDemo2 PaintDemo = new SwingPaintDemo2();

    if (SwingPaintDemo2.isTrue == true){
        g.setColor(Color.black);
        g.fillRect(l, w, 50, 50);
    }

}

redpajama_set_name: RedPajamaStackExchange


text:
Q: Query with TAKE and check if it is null I am trying to get information from a Cosmos DB, and I want to get an amount of rows or all rows. User can type 100, for example, and he will get only 100 rows and if he doesn't type anything he will get all rows.
Before I got the information with .Take()
For example: .Take(amount), but if amount is null I have a fail.
With:
.Take(amount)

I would like to have something like this:
.TakeIf(amount != null, amount);

I know the lines above are wrong but this is the idea.
And the lines below are the complete query.
var resultDTO = this.client.CreateDocumentQuery<DTO>(
     UriFactory.CreateDocumentCollectionUri(idDatabase, idCollection), queryOptions)
     .WhereIf(sourceId != null, x => x.sourceId == sourceId)
     .Take(amount)
     .AsEnumerable()
     .ToList();

How can I check if amount is null or not?

A: This one is deeper thank just configuring the expression. CosmosDB only returns paginated results by default. If you use the synchronized AsEnumerable().ToList() approach your code will go through all the pages in a synchronous fashion. This will lead to terrible performance. What you wanna do is iterate and collect. Sadly there is no fancy way to go about this.
Sadly, you cannot encapsulate all the necessary code in a TakeIf call because there is more that needs to happen during querying.
Here is a code example.
var amount = 100;

var queryOptions = new RequestOptions {
    MaxItemCount = 100
};

var queryable = this.client.CreateDocumentQuery<DTO>(
     UriFactory.CreateDocumentCollectionUri(idDatabase, idCollection), queryOptions)
     .WhereIf(sourceId != null, x => x.sourceId == sourceId);

if(amount != null && amount > 0){
    queryable.Take(amount);
}

var documentQuery = queryable.AsDocumentQuery();

var results = new List<DTO>();
while (query.HasMoreResults)
{
    if (amount != null && amount > 0 && results.Count == amount)
        break;

    var items = await query.ExecuteNextAsync<DTO>(cancellationToken);

    foreach (var item in items)
    {
        results.Add(item);

        if (amount != null && amount > 0 && results.Count == amount)
            break;
    }
}
return results;

In this example I am assuming that you only wanna add the Take call when the amount is not null and it is more than 0. If that's not the case then remove the > 0 checks.
For a more detailed example on this check Cosmonaut's source code here.

A: I'd suggest:
var bob = this.client.CreateDocumentQuery<DTO>( UriFactory.CreateDocumentCollectionUri(idDatabase, idCollection), queryOptions)
    .WhereIf(SourceId != null, x => x.SourceId == SourceId);

var resultDTO = Amount == null ? bob.ToList() : bob.Take(Amount.Value).ToList();

This will apply the Take only if Amount is not null.
If that doesn't work, try using .AsEnumerable() before .ToList().


text:
Q: OpenCart 1.5: how to disable caching for SVG? I think to use svg for images of brands - svg is responsive and good for displays with high DPI. But I have problem with caching mechanism of Opencart 1.5 than can't correct cache vector images and in browser I not see image.
I not found (in search) any solution for this or any extension for Opencart - svg can be minified too, but this is not raster.
I am not expert for Opencart and php and I ask you about better sulution in this situation.

A: As a possible purpose for uploading SVG seems to not be planned into the 2.0.x serie of OpenCart, I suppose there's no solution at this time for the former 1.5.x serie.

A: You can tell the image resize function to skip images that have the svg file extension with a slight mod.  Check in catalog/model/tool/image.php for the line:
if ($width_orig != $width || $height_orig != $height) {

and include some logic to skip files with "svg" extension:
if (strtolower($extension) != 'svg' && ($width_orig != $width || $height_orig != $height)) {

The result will be that an unmodified copy of the original is placed in the image/cache directory and used instead of processing with GD library.


text:
Q: Fisher information of product model Consider the following regular statistical model: $(\mathbb{R}^n, \mathcal{B}(\mathbb{R}^n), \mathbb{P}_{\theta}: \theta \in \mathbb{R}_+ )$. Assume $\mathbb{P}_{\theta}$ has the density $$\rho(\theta,.) = \frac{1}{\theta} f\left(\frac{x}{\theta}\right)$$, where $f(x)>0$ and $f'(x)$ exists.
I want to show that the fisher- information is given by:
$$I(\theta) = \int_{\mathbb{R}}\frac{n}{\theta^2} \frac{(xf'(x)+f(x))^2}{f(x)} dx $$
Therefore I have to compute $$E[U_{\theta}^2]$$
$U_{\theta}$ is the score, which is given by:
$$U_{\theta} = \partial_{\theta} ln(\rho(\theta,x))$$ for $x \in \mathbb{R}^n$
Then we have: $$\partial_{\theta}  ln(\prod_{i=1}^n \rho(\theta,x_i)) = \sum_{i=1}^n\partial_{\theta}  \frac{1}{\theta} f\left(\frac{x_i}{\theta}\right) =
 \sum_{i=1}^n  \frac{\frac{-1}{\theta^2}f\left(\frac{x_i}{\theta}\right)+ \frac{1}{\theta}f'\left(\frac{x_i}{\theta}\right)\frac{-x_i}{\theta^2}}{\frac{1}{\theta}f\left(\frac{x_i}{\theta}\right)}$$
How can I go on from there. How can I make it independent from $i$ as the solution suggests to compute $$E[U_{\theta}^2]$$

A: You are on the good track. I will start from where you left, i.e.:
$$\partial_{\theta} \ln \left(\prod_{i=1}^{n} \rho\left(\theta, x_{i}\right)\right)=\sum_{i=1}^{n} \partial_{\theta} \log{\frac{1}{\theta} f\left(\frac{x_{i}}{\theta}\right)}=\sum_{i=1}^{n} \frac{\frac{-1}{\theta^{2}} f\left(\frac{x_{i}}{\theta}\right)+\frac{1}{\theta} f^{\prime}\left(\frac{x_{i}}{\theta}\right) \frac{-x_{i}}{\theta^{2}}}{\frac{1}{\theta} f\left(\frac{x_{i}}{\theta}\right)} $$
Therefore what is requested to compute is the following:
$$
\mathbb{E} \left[U_{\theta}^{2}\right]
$$
$U_{\theta}$ is the score, which is given by:
$$
U_{\theta}=\partial_{\theta} \ln (\rho(\theta, x))
$$
for $x \in \mathbb{R}^{n}$, this exactly means:
$$ \mathbb{E} \left[U_{\theta}^{2}\right] = \mathbb{E} \left[ \sum_{i=1}^{n} \left(\partial_{\theta} \log{\frac{1}{\theta} f\left(\frac{x_{i}}{\theta}\right)} \right)^2 + \sum_{i\neq j} \partial_{\theta}  \log{\frac{1}{\theta} f\left(\frac{x_{i}}{\theta}\right)} \partial_{\theta} \log{\frac{1}{\theta} f\left(\frac{x_{j}}{\theta}\right)} \right] $$
Now recall that the samples are considered to be i.i.d.,  then means that all the crossed terms for $i\neq j$ are zero because we can split the expectations by independence and it is a well known fact that the expectation of the log score is zero:
$$\sum_{i\neq j}  \mathbb{E} \left[\partial_{\theta} \log{\frac{1}{\theta} f\left(\frac{x_{i}}{\theta}\right)} \partial_{\theta} \log{\frac{1}{\theta} f\left(\frac{x_{j}}{\theta}\right)} \right] \stackrel{i.i.d.}{=} \sum_{i\neq j} \underbrace{\mathbb{E} \left[\partial_{\theta} \log{\frac{1}{\theta} f\left(\frac{x_{i}}{\theta}\right)} \right]}_{=0} \underbrace{\mathbb{E} \left[ \partial_{\theta} \log{\frac{1}{\theta} f\left(\frac{x_{j}}{\theta}\right)} \right]}_{=0} =0$$
Thus we are left only with the first summation of the squared terms, but again since the samples are i.i.d. and we are taking expectation results into:
$$  \mathbb{E} \left[U_{\theta}^{2}\right] = \mathbb{E} \left[ \sum_{i=1}^{n} \left( \partial_{\theta} \log{\frac{1}{\theta} f\left(\frac{x_{i}}{\theta}\right)} \right)^2 \right]  = n \mathbb{E} \left[ \left( \partial_{\theta} \log{\frac{1}{\theta} f\left(\frac{x}{\theta}\right)} \right)^2 \right]  = \int n \left( \frac{\frac{-1}{\theta^{2}} f\left(\frac{x}{\theta}\right)+\frac{1}{\theta} f^{\prime}\left(\frac{x}{\theta}\right) \frac{-x}{\theta^{2}}}{\frac{1}{\theta} f\left(\frac{x}{\theta}\right) }\right)^2 \frac{1}{\theta} f\left(\frac{x}{\theta}\right) dx =$$
Now we can make a change of variable and set $y = \frac{x}{\theta}$, thus $dy = \frac{1}{\theta} dx$ and obtain:
$$= \int n \left( \frac{\frac{-1}{\theta} f\left(y\right)+f^{\prime}\left(y\right) \frac{-y}{\theta}}{ f\left(y\right) }\right)^2 f\left(y\right)  dy$$
Now note that the minuses inside the square are not of any use, and we pull outside $\frac{1}{\theta}$ and obtain:
$$= \int \frac{n}{\theta^2} \left( \frac{f\left(y\right)+f^{\prime}\left(y\right) y}{ f\left(y\right) }\right)^2 f\left(y\right) dy= \int \frac{n}{\theta^2}  \frac{\left(f\left(y\right)+f^{\prime}\left(y\right) y\right)^2 }{ f\left(y\right) } dy$$
Now just call my $y$, $x$ and you get the answer.
(Please if this answer was useful leave positive feedback and/or accept the answer, as it took me quite some time :) ).


text:
Q: What does |5E| mean in Common Lisp? I got following error message in Common Lisp.
What does || mean in CL?
CL-USER> (write-to-string 5e)
The variable |5E| is unbound.
   [Condition of type UNBOUND-VARIABLE]

A: It's using those characters as quotes. It is trying to interpret 5e as a name of a variable. My guess is that you really want it to interpret it as a hex number, so it should probably be #x5e.

A: |foo| is just a printed representation for symbols. 5e does not read as a number by default, so it is a symbol and may be printed as |5E|. One can use it also to have all kinds of characters in symbols, including whitespace. |this is a symbol, isn't it?| - it is!
CL-USER > (describe '|this is a symbol, isn't it?|)

|this is a symbol, isn't it?| is a SYMBOL
NAME          "this is a symbol, isn't it?"
VALUE         #<unbound value>
FUNCTION      #<unbound function>
PLIST         NIL
PACKAGE       #<The COMMON-LISP-USER package, 798/1024 internal, 0/4 external>

Note also that Common Lisp uses uppercase symbols by default. Symbols read will be uppercased. So the symbol foo is read and then has a symbol name "FOO". To denote a symbol with lowercase or mixed case letters, one can use |foo|. If you create a lowercase symbol with something like (intern "foo"), then it also will be printed as |foo|. If you create an uppcase named symbol with something like (intern "FOO"), then it will be printed as foo. That's the reason why 5e prints as |5E| with an uppercase E.
If you have a symbol, you can get its name as a string with the function SYMBOL-NAME.
You can read an integer from a string with he function PARSE-INTEGER. It has a keyword parameter :RADIX, where you can provide the radix for reading.
CL-USER > (parse-integer (symbol-name '5e) :radix 16)
94

Otherwise use hex numbers like #x5e or change the read base.
Frank Shearar points out the documentation in the Common Lisp HyperSpec: 2.3.4 Symbols as Tokens.


text:
Q: MXNet using NDArray Scatter_nd on multi GPU When I use multi gpu to train on MXNet(CUDA8.0+cudnn7), I firstly initialize parameters on different context, then I perform scatter_nd on different contexts, the first time scatter nd would work perfectly, but when compute for the second gpu card, I got
F1217 23:53:01.012707  2619 stream_gpu-inl.h:62] Check failed: e == cudaSuccess CUDA: an illegal memory access was encountered

A: This will happen if you haven't copied your data over to all contexts. As per github.com/apache/incubator-mxnet/issues/10240, this may be fixed by github.com/apache/incubator-mxnet/pull/10833. Try with 1.3.1 if you're using 1.3.0


text:
Q: What does it mean to not be able to take the derivative of a function multiple times? I'm taking a intro to mathematical analysis course and I'm having trouble understanding this definition.
They are talking about how it can be interesting to see what happens if you take the derivative of a function multiple times (this is discussed in the intro to Taylor polynomials). They throw this definition at us, which they call $C^kfunctions$:
A function $f: I \rightarrow \mathbb{R} $ belongs to $C^k(I)$ if it is possible to take the derivative of the function k times on $I$ and if $f^{(k)}(x)$ is continuous on $I$
I'm a little confused by this. Aren't all functions $C^\infty$ then? Can't you just keep taking the derivative of a function even if it becomes $0$? Specifically I'm on a chapter now where they are discussing curve integrals and they keep mentioning that it is a $C^2$ function. What does this mean? Can you only take the derivative 2 times?
I'm confused and can't wrap my mind around it. I would love if anyone was able to explain it in such a way that I could understand and apply it. Thanks in advance.

A: Some functions have a derivative that cannot be further differentiated.
For example, consider the function $f(x) = |x|$. It is not differentiable but it can be integrated. Any antiderivative $F(x)$ of $f(x)$ will be differentiable and we have $F'(x) = f(x)$. Since $f$ is continuous, $F \in C^1$ but since $f$ is not differentiable, $F \notin C^2$.

A: I think a picture can help explain what's going on here. Below is a graph of a function (red) and its derivative (blue). The original function is differentiable, which we can see by its lack of "sudden turns". However, the derivative is not, as evidenced by the "pointy turn" at $(0,0)$.
\begin{align}
\text{(red)} \qquad f(x) &= x \cdot |x| \qquad\qquad \qquad \\
\text{(blue)} \quad\,\,\, f'(x) &= 2 \cdot |x| \qquad\qquad \qquad
\end{align}

Part of the reason why this idea can be confusing is that the original (red) function looks smooth, but it's not smooth by the math definition since its first derivative isn't differentiable. While $f(x)$ has no pointy bits, it has the spirit of one inside, just waiting to be released.
(By the way, if you're wondering how we derive $f'(x)$ you can see that here.)

A: As an example:

*

*$f(x)=6|x|$ does not have a derivative at $x=0$

*$g(x)=3x|x|$ does have a first derivative everywhere of $f(x)$ but not a second derivative at $x=0$

*$h(x)=x^2|x|= |x^3|$ has a first derivative everywhere of $g(x)$ and a second derivative of $f(x)$ but not a third derivative at $x=0$

A: I'll address your points one by one. If you have further questions, please ask away:
Aren't all functions $C^\infty$ then?
No. Examples of functions whose $k$-th order derivative is not continuous abound for every $k$. It is true that $C^1$ functions are very similar to $C^\infty$ functions, but for the time being it is better to focus on the ones we will encounter.
There are even functions that are continuous but not derivable at any point. One of them is the Weierstrass function, and I'm pretty sure you'll encounter it further down the road in this course. If you find this read difficult to follow, don't worry, I'm sure your lecturer will give you great explanations (and you are of course welcome to ask).
Can't you just keep taking the derivative of a function even if it becomes $0$?
$0$ is just another value a derivative can take. There are some functions that lack a derivative. Some do have a derivative. Of these, some are zero; some are not.
Specifically I'm on a chapter now where they are discussing curve integrals and they keep mentioning that it is a $C^2$ function. What does this mean? Can you only take the derivative 2 times?
Not exactly. It means that the second derivative is continuous, but it says nothing about the third one, because it doesn't really matter. $C^3$ functions are also $C^2$: note that if you can do something like taking derivatives three times you can also do it twice, but being able to do it twice is no guarantee you can go on and do it a third time.


text:
Q: Where can I find an NVIDIA GeForce 9800GT driver for Windows Vista/7? I obtained a new NVIDIA GeForce 9800GT today and inserted it into my computer.  I found its driver CD had no driver for Windows Vista and 7.
I downloaded the 9800GT driver for Windows 7 64-bit, but the setup gave the following error:

The NVIDIA Setup program could not locate any drivers that are compatible with your current hardware.

Where can I find an older driver for this video card? Could there be a problem with the graphics card itself?

A: Here is the 32 bit driver.


text:
Q: Converting a string into a date within a for loop I am trying to compare a date in a CSV file to days date - If todays date is bigger then the output will be no.
I am trying to figure out if the expiry date of a card is past todays date:
#input number you want to search
number = input('Enter the card number\n')
#read csv, and split on "," the line
   csv_file = csv.reader(open('carddetails.csv', "r"), delimiter=",")
#loop through the csv list
   for row in csv_file:
    #if current rows 2nd value is equal to input, print that row
      if number == row[1]:
         valid_to_date = row[3]
         if valid_to_date>todays_Date:

            print("nop")
         else:
            print("yep")

I have declared todays_Date as a global variable else where.
It works in regards to giving me the date but it tells me that I cannot compare str and date.time.
I haven't done much with datetime so looking how to convert valid_to_date to a date.time to be able to compare them.

A: You're need to convert your string date to a datetime object with datetime.strptime
https://docs.python.org/3/library/datetime.html#datetime.datetime.strptime
https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior
# if your date in your csv is in format YYYYmmddTHHMMSS (year-month-day:hour-min-sec then
from datetime import datetime
valid_datetime = datetime.strptime(valid_to_date, "%Y%m%dT%H%M%S")

# now you can compare the datetimes
if valid_datetime > todays_date:
    valid = "NO"


text:
Q: What is wrong with my Laplace Transform? I need to find the Laplace transform of sine(t), and it is proving rather difficult.  I integrate by parts, then integrate by parts again so that the original integral is on both sides of the equation, then I get it wrong.
$ f\left(x\right) = \left\{
     \begin{array}{lr}
       \sin t & : 0 \leq t \le \pi\\
       0 & : t > 1
     \end{array}
   \right.\\$
Because the Laplace Transform of 0 is 0, I concern myself with:
$$\int{e^{-st}\sin{t}\space \mathrm{dt}}$$ and proceed with integration by parts.  I have $u=\sin{t}$,$du=\cos{t}$,$dv=e^{-st}$ and last but not least $dv=\frac{e^{-st}}{s}$.  This yields the equation:
$$\int{e^{-st}\sin{t}\space \mathrm{dt}}=\frac{1}{s}\left(-\sin{t}e^{-st}+\int{e^{-st}\cos{t}\space \mathrm{dt}}\right)$$ and so I begin to solve the Laplace transform of cosine.
For this, I use $u=\cos{t}$,$du=-\sin{t}$,$dv=e^{-st}$,$v=\frac{e^{-st}}{s}$.  This yields the equation:
$$\int{e^{-st}\cos{t}\space \mathrm{dt}}=\frac{-\cos{t}e^{-st}}{s}-\frac{1}{s}\int{e^{-st}\sin{t}\space \mathrm{dt}}$$.
Now, we obviously use this solution to replace the prior integral that we just solved,
 $$\int{e^{-st}\sin{t}\space \mathrm{dt}}=-\frac{\sin{t}e^{-st}}{s}+\frac{1}{s}\left( \frac{-\cos{t}e^{-st}}{s}-\frac{1}{s}\int{e^{-st}\sin{t}\space \mathrm{dt}})\right)$$
Which simplifies to:
$$(1+s^2)\int{e^{-st}\sin{t}\space \mathrm{dt}}=\frac{-\sin{t}e^{-st}}{s}+\frac{-\cos{t}e^{-st}}{s^2}$$.
Now let us suppose the bounds of our equation are $0$ and $\pi$.  This leads our terms to be as such:
$$\left[\frac{-\cos{t}e^{-st}}{s^2}\right]^{\pi}_0=\frac{e^{-\pi s}}{s^2+1}\frac{1}{s^2}$$.
The book gives the answer as merely $$\frac{e^{-\pi s}}{s^2+1}$$.  How do I get rid of my extraneous $\frac{1}{s^2}$?


text:
Q: How decode html content bound in json? I am using asp.net application and using ajax call,below is my code.Below is my web method which is working fine and give response of ajax call.
ADController adc = new ADController();
        DataTable dt = adc.GetGeneral(Convert.ToInt32( AnnouncementId));// GetAnnouncementsByIDAndRead(Convert.ToInt32(AnnouncementId), Convert.ToInt32(userid));
        JavaScriptSerializer jsSerializer = new JavaScriptSerializer();
        List<Dictionary<string, object>> parentRow = new List<Dictionary<string, object>>();
        Dictionary<string, object> childRow;
        foreach (DataRow row in dt.Rows)
        {
            childRow = new Dictionary<string, object>();
            foreach (DataColumn col in dt.Columns)
            {
                if (col.ColumnName == "description")
                {
                    childRow.Add(col.ColumnName, HttpUtility.HtmlDecode( Convert.ToString( row[col]) )as object);
                }
                else
                childRow.Add(col.ColumnName, row[col]);
            }
            parentRow.Add(childRow);
        }
        return jsSerializer.Serialize(parentRow);

following is my ajax code ,which is working fine and giving data on call fine.
 function fnshowAncDetails(AnnouncementId, userid) {
    $(".loading").show();
    var url = $("[id$='hdURLt']").val();
    $("[id$='btnSaveMD']").show();
    $.ajax({
        type: "POST",
        url: url + "/GetInfo.aspx/General",
        data: '{AnnouncementId:"' + AnnouncementId + '",userid:"' + userid + '"}',
        contentType: "application/json; charset=utf-8",
        //dataType: "json",
        success: OnSuccessSetCGiven,
        error: function (response) {

        }
    });
    var vtext = $("[id$='lblAnnoucement']").text();
    if (vtext != 0) {
        vtext = vtext - 1;
    }
    $("[id$='lblAnnoucement']").text(vtext);
}

below is my success method
  function OnSuccessSetCGiven(response) {
    var parsed = $.parseJSON(response.d);

    $("[id$='htititlen']").text(parsed[0].Title);
    $("[id$='divNotifBody']").text(parsed[0].Description);

    $("[id$='divadded']").text("By:"+parsed[0].FirstName + " " + parsed[0].LastName);
    $("#divNotifdetails").modal('show');
    $(".modal-backdrop").css('z-index', '0');
    $(".loading").hide();

    var formattedTime = parsed[0].stime.Hours + ":" + parsed[0].stime.Minutes;
    //$("[id$='divtime']").text(formattedTime);
    $("[id$='divdate']").text("Time:" +parsed[0].startdate + " " + formattedTime);
}

Now my question is in The Description there may be html tags, means formatted htmls,like
xxx
sdf. So it not loaded as bold,
how can I render formatted html?

A: Use jQuery .html function and not .text:
function OnSuccessSetCGiven(response) {
    ...
    $("[id$='divNotifBody']").html(parsed[0].Description);
    ...
}

But note that you will have JS injection vulnerability, so you must clean the HTML code in the description field and remove unwanted attributes & tags (for example:


text:
Q: When is a right-adjoint fully-faithful Let $F:\mathcal{C}\rightarrow \mathcal{D}$ be a functor and $G$ its right-adjoint. Let $S:=\{f\in \operatorname{Mor}\mathcal{C}:F(f)\in\mathcal{Iso}(\mathcal{D})\}$. I've read that $G$ is fully-faithful if and only if $\bar{F}:\mathcal{C}\lbrack S^{-1}\rbrack\rightarrow \mathcal{D}$ is an equivalence of categories. However, I can't find a proof (by myself or in the literature). Can someone give me a proof of this?

A: This is Proposition 1.3 in Gabriel and Zisman's Calculus of Fractions and Homotopy Theory.

A: Quite clearly $F$ sends arrows in $S$ to isomorphisms (that's the definition).
Now let $K: C\to E$ be any functor that also inverts arrows in $S$, and define $K^\# : D\to E$ by $K^\# := K\circ G$. Then we have a natural transformation $K\eta : K\to K\circ G\circ F$
Now $G$ being fully faithful implies that $\eta \in S$ (pointwise) so that $K\eta$ is actually a natural isomorphism. From this it follows that $[D,E]\to^{F^*} [C,E]$ is essentially surjective on the subcategory of $S$-inverting functors.
Now suppose you have a natural transformation $\theta : K\circ F\to L\circ F$ where $K,L: D\to E$ are functors. We wish to find $\delta: K\to L$ such that $\theta = \delta F$. Now let $x\in D$ and consider $\epsilon_x : FGx \to x$. Then if $\delta$ works, we have a naturality square :
$\require{AMScd} \begin{CD}
KFGx @>{\delta_{FGx}}>> LFGx\\ @V{K(\epsilon_x)}VV @VV{L(\epsilon_x)}V\\
Kx @>>{\delta_x}> Lx
\end{CD}$
which, by $\theta= \delta F$ is actually
$\require{AMScd} \begin{CD}
KFGx @>{\theta_{Gx}}>> LFGx\\ @V{K(\epsilon_x)}VV @VV{L(\epsilon_x)}V\\
Kx @>>{\delta_x}> Lx
\end{CD}$
Note that $G$ being fully faithful also implies that $\epsilon_x$ is an isomorphism, so that we get $\delta_x = L(\epsilon_x)\circ \theta_{Gx}\circ K(\epsilon_x^{-1})$, thus proving faithfulness of $F^*$, and giving us a guess as to how to prove fullness : starting from $\theta$, put $\delta := L\epsilon \circ \theta G \circ K\epsilon^{-1}$ which is clearly a natural transformation given its definition.
Next, use the naturality square above to show that $\delta FG = \theta G$. Next, look at $\eta_a: a\to GFa$ in $C$ and apply naturality of $\theta$ to it to get :
$\require{AMScd} \begin{CD}
KFa @>{KF(\eta_a)}>> KFGFx\\ @V{\theta_a}VV @VV{\theta_{GFa}}V\\
LFa @>>{LF(\eta_a)}> LFGFa
\end{CD}$
and naturality of $\delta F$ to get :
$\require{AMScd} \begin{CD}
KFa @>{KF(\eta_a)}>> KFGFx\\ @V{\delta_{Fa}}VV @VV{\delta_{FGFa}}V\\
LFa @>>{LF(\eta_a)}> LFGFa
\end{CD}$
The horizontal arrows are isomorphisms because $\eta_a\in S$ and the vertical arrows on the right are equal by what we observed above : it follows that the vertical arrows on the left are also equal : $\delta_{Fa} = \theta_a$, i.e. $\delta F= \theta$; thus proving that $F^*$ is full.
But that's the definition of $F:C\to D$ being a localization functor at $S$, so that (by definition) $D=C[S^{-1}]$ (where $=$ means something like "has the same universal property therefore is equivalent to any model of")
So the things we used about $G$ being fully faithful are that :
i) $F(\eta_a)$ is an isomorphism for all $a$
ii) $\epsilon_x$ is an isomorphism for all $x$
These are standard properties of adjunctions where the right adjoint is fully faithful, if you don't know them you should prove them (the intuitive idea is that if $G$ is fully faithful then $D$ is a full "subcategory" of $C$, embedded with $G$; and $F$ just takes the best $D$-approximation : but if you're already in $D$, then obviously this best $D$-approximation is yourself)


text:
Q: rails not making the link between dynamically added nested form and parent I've got a form 'tasks' and I am dynamically adding a child 'steps' form.
The 'steps' is added through a javascript call to render('steps/form').
The form loads fine, but when submitting the tasks form, the added step is not put into the database.
I assume this is because I'm not linking the two forms together, but I'm not entirely sure.
My code is
Tasks/new.html.erb

<%= form_for @task, :html=>{:multipart=>true} do |f| %>
  <%= f.label :task_name %>
  <%= f.text_field :task_name %>

<%= link_to "Add Step", @step, :remote=>true, :class=>'addStep %>
<%= f.submit %>
<% end %>

<% content_for(:js) do %>
   $('a.addStep').click(function(){
      $('div#newStep').append("<%= escape_javascript(render('steps/form'))%>");
   });
<% end %>

the steps/_form.html.erb is

   <%= fields_for :steps do |builder| %>
   <%= builder.label :title %>
   <%= builder.text_field :title %>
<% end %>

I believe the problem is that i'm not passing 'f' or 'task' into the 'step' form, but I couldn't figure out how to do that.

A: Try something like this:
<%= render :partial => 'steps/form',
             :locals => {:form => f} %>

Hope this helps.
Edit- 1
Do as follows:
<%= form_for @task, :html=>{:multipart=>true} do |f| %>
  <%= f.label :task_name %>
  <%= f.text_field :task_name %>

       <%= render :partial => 'steps/form',
               :locals => {:form => f} %>

<%= link_to "Add Step", @step, :onClick=>"js_function_to_change_display_property()", :class=>'addStep' %>
<%= f.submit %>
<% end %>

then you can use simple javascript to view the steps form by changing the display property of steps_form.

A: You might have to update the params in your parent controller to include the attributes of the child. e.g.
controllers/task_controller.rb
Class TasksController < ApplicationController
  ...

  def task_params
    params.require(:task).permit :name, :description ,
      steps_attributes: [:step, :step_description, :due_date]
  end
end

models/task.rb
Class Task < ActiveRecord::Base
  has_many :steps
  accepts_nested_attributes_for :steps
end

models/step.rb
Class Step < ActiveRecord::Base
  belongs_to :task
end


text:
Q: Loss in the convolution layer So I'm working on image registration to align an image to a template image. I am performing this convolution operation on a Unet output (100x100x100x32) to get a 3D deformation field (100x100x100x3). For clarification, 100x100x100 is the dimension of the image.
# transform unet output into a flow field
name = 'vxm_dense'
Conv = getattr(KL, 'Conv%dD' % ndims)
flow_mean = Conv(filters=3, kernel_size=3, padding='same',
                 kernel_initializer=KI.RandomNormal(mean=0.0, stddev=1e-5),
                 name='%s_flow' % name)(unet_model.output)

So far everything is clear, but when I run model.fit(), I notice in the logs that in addition to the actual loss, an additional loss called vxm_dense_flow_loss is logged.
Epoch 9/60
560/560 [==============================] - 734s 1s/step - loss: 0.0023 - vxm_dense_flow_loss: 0.0216

I don't understand,

*

*why is this loss calculated?

*what is the loss function used? I don't have any loss functions (e.g. mse, ncc or mi) configured for it.

*in order for the loss to be calculated, there must be a ground truth. Which ground truth is used here?

PS: The actual loss is calculated as the mean square error between the registered image and the template image.


text:
Q: Problems running the ripple emulator on Visual Studio 2013 I am trying to run the ripple emulator on Visual Studio, however I cannot seem to get pass the cannot find module './lib/plugin'error as follows:
C:\Users[user name]\Documents\Visual Studio 2013\Projects\Cordova\Cordova>call "C:\Program Files (x86)\nodejs\"\nodevars.bat
Your environment has been set up for using Node.js 0.10.33 (ia32) and npm.
------ Ensuring correct global installation of package from source package directory: E:\PROGRAM FILES (X86)\VISUAL STUDIO\COMMON7\IDE\EXTENSIONS\FUBXMEK2.O2B\packages\vs-mda
1>MDAVSCLI : error : Cannot find module './lib/plugin'
PS: The previous error I got was cannot find module 'q' however this was resolved by running npm install from CLI.
I am trying to create a Cordova application using Visual Studio. Any ideas how I can resolve the above error?

A: It seems something went wrong while installing vs-mda, you can try following to re-install:

*

*Close Visual Studio

*Open cmd

*npm install -g [path to vs-mda example C:\Users[user-name]\AppData\Roaming\npm\node_modules\vs-mda]

*npm install -g [path to vs-mda-targets example C:\Users[user-name]\AppData\Roaming\npm\node_modules\vs-mda-targets]

OR

*

*Go to Tools --> Options --> Tools for Apache Cordova --> Cordova Tools --> Clear Cordova Cache

A: For the second method above (Clear Cordova Data) try running visual studio as administrator if it fails the first time around.


text:
Q: showing product on custom page gives error i am showing product on custom page created via modules
app\design\frontend\base\default\layout\related.xml
 <?xml version="1.0"?>
    <layout version="0.1.0">
      <related_index_index>
        <reference name="root">
          <action method="setTemplate"><template>page/1column.phtml</template></action>
        </reference>
        <reference name="content">
          <block type="catalog/product" name="related_index" template="related/index.phtml"/>
        </reference>
      </related_index_index>
    </layout>

app\design\frontend\base\default\template\related\index.phtml
i just copied list.phtml content here with few modification
no it gives error
Fatal error: Call to a member function getStoreLabel() on a non-object in app\design\frontend\themefolder\themefile\template\catalog\product\price.phtml on line 53
i got few answer but i do not want to modify core files please suggest way to fix it
Line no 53 of price.html
$_specialPriceStoreLabel = $this->getProductAttribute('special_price')->getStoreLabel();

Updated code for my \app\design\frontend\base\default\template\related\index.phtml
Here i am show all related products of product
$model = Mage::getModel('catalog/product');
$product_id = Mage::app()->getRequest()->getParam('product');
$product = $model->load($product_id);

// Get all related product ids of $product.
$allRelatedProductIds = $product->getRelatedProductIds();

    $_helper = $this->helper('catalog/output');
    $store = Mage::app()->getStore();
    $code  = $store->getCode();

?>
<?php if(!count($allRelatedProductIds)): ?>
<?php foreach ($allRelatedProductIds as $id):
        $_product = $model->load($id);
        ?>

<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_product->getName();?>

 <?php echo $this->getPriceHtml($_product, true) ?>
 <?php endforeach ?>

A: Find simple solution and its work:
Open this file : app/design/frontend/[your_package]/[your_theme]/template/catalog/product/price.phtml
Find this code:
$_specialPriceStoreLabel = $this->getProductAttribute('special_price')->getStoreLabel();

And replace it with below:
$specialPriceAttr = $this->getProductAttribute('special_price');
if (!is_null($specialPriceAttr)) {
$_specialPriceStoreLabel = $this->getProductAttribute('special_price')->getStoreLabel();
} else {
$_specialPriceStoreLabel = '';
}

Reference: http://www.justwebdevelopment.com/blog/call-to-a-member-function-getstorelabel-in-price-phtml/

A: Add bellow code in file app\design\frontend\base\default\layout\related.xml
<?xml version="1.0"?>
<layout version="0.1.0">
    <related_index_index>
        <reference name="root">
          <action method="setTemplate"><template>page/1column.phtml</template></action>
        </reference>
        <reference name="content">
          <block type="catalog/product_list" name="related_index" template="related/index.phtml"/>
        </reference>
    </related_index_index>
</layout>

OR
<?xml version="1.0"?>
<layout version="0.1.0">
    <related_index_index>
        <reference name="root">
          <action method="setTemplate"><template>page/1column.phtml</template></action>
        </reference>
        <reference name="content">
          <block type="catalog/product_related" name="related_index" template="related/index.phtml"/>
        </reference>
    </related_index_index>
</layout>

Also add bellow code in file app\design\frontend\base\default\template\related\index.phtml
<?php
  $model = Mage::getModel('catalog/product');
  $product_id = Mage::app()->getRequest()->getParam('product');
  $product = $model->load($product_id);

  // Get all related product ids of $product.
    $allRelatedProductIds = $product->getRelatedProductIds();

    $_helper = $this->helper('catalog/output');
    $store = Mage::app()->getStore();
    $code  = $store->getCode();

?>
<?php if(count($allRelatedProductIds)): ?>
<?php foreach ($allRelatedProductIds as $id): ?>
    <?php $_product = Mage::getModel('catalog/product')->load($id);?>

<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_product->getName();?>

    <?php echo $this->getPriceHtml($_product, true) ?>
<?php endforeach ?>
<?php endif;?>

A: we had problem with a widget coming from MGS Megamenu (class MGS_Megamenu_Block_Product).
Their widget extends Mage_Catalog_Block_Product that only is a dummy block that crashes if getPriceHtml is called in phtml template underlay. Maybe that block should extend rather Mage_Catalog_Block_Product_Abstract.
We solved it by follow hack:
// HACK
//class MGS_Megamenu_Block_Product extends Mage_Catalog_Block_Product
class MGS_Megamenu_Block_Product extends Mage_Catalog_Block_Product_Abstract
...


text:
Q: Happy ending problem – Why not a proof by induction? I have been thinking for a while on the happy ending problem, looking for approaches to attack the Erdős–Szekeres conjecture: the smallest number of points for which any general position arrangement contains a convex subset of $n$ points is $2^{n-2}+1$.
After reviewing the most recent literature on the problem and the different lines of attack explored, I wonder if it would be worthy to consider the possibility of proving it by induction. The case $n=3$ is almost inmediate to prove, and applying the inductive hypothesis, it is easy to show that some set of $2^{(n+1)-2}+1$ points contains many distinct convex subsets of $n$ points. The tricky part would be to arrange the distinct convex subsets of $n$ points to show that they imply the existence of some convex subset of $n+1$ points.
To illustrate this idea of how the distinct convex subsets of $n$ points could help to show that there exist some convex subset of $n+1$ points, let us asume by inductive hypothesis that the conjecture is true for $n=5$, and  consider a random set $S$ of $2^{4}+1$ points:

By the inductive hypothesis, each subset of $2^3+1$ points contains a convex subset of $5$ points. Let us choose one of those subsets:

To optimize the number of distinct convex pentagons that do not intersect each other in more than some edge, we could continue selecting another subset of $2^3+1$ points, including at most two points forming an edge of the first convex pentagon found, to get (in this case):

It can be already noticed that the two convex pentagons found already restrict the possible locations of the rest of the points of $S$ in order to avoid the existence of a convex subset of $6$ points. If we continue with the same strategy, we can get:

With each found convex pentagon, it is more and more evident the existence of a convex hexagon in set $S$. Each of the convex pentagons projects a "convexity zone" where, if located any two points, would guarantee the existence of a convex hexagon:

Obviously, this is just a random set and the strategy illustrated does not intend to be the correct one to be able to prove by induction the Erdős–Skezeres conjecture; however, I think it could be worthy to explore the possibility of a proof by induction.
I would appreciate your ideas and thoughts about this possible attack strategy on the problem. Has someone tried to implement it already?


text:
Q: How to split such a string? I get a result like this
{PickupLocation=204, Jai nagar main road, Chandragandhi Nagar, Ponmeni, Madurai, Tamil Nadu 625016, DropLocation=204, Jai nagar main road, Chandragandhi Nagar, Ponmeni, Madurai, Tamil Nadu 625016, PickupLongitude=78.0928147163509, DropLongitude=78.0928147163509, PickupLatitude=9.92065524221638, DropLatitude=9.92065524221638, CustomerId=99, PhoneNumber=96788484887, CustomerName=Mayil, CustomerLastName=Kannan}

i tried like this
 public static void jsonToMap(String t) throws JSONException {

    HashMap<String, String> map = new HashMap<String, String>();
    JSONObject jObject = new JSONObject(t);
    Iterator<?> keys = jObject.keys();

    while( keys.hasNext() ){
        String key = (String)keys.next();
        String value = jObject.getString(key);
        map.put(key, value);

    }

    System.out.println("json : "+jObject);
    System.out.println("map : "+map);
}

But they don't give json format,but i want split to get the values separately,how is it possible,sorry for my poor english,i am beginner of the android.

A: Not all values in the CSV list have equals sign, and hence a map may not make complete sense to store your values.  In the code snippet below I store values without an equals sign as a key in the map with no corresponding value.  You can strip the brackets on either end, split by comma and whitespace, then possibly split again by = to obtain the map you have in mind:
String input = "...";
Map<String, String> map = new HashMap<>();
input = input.replaceAll("\\s+\\{\\s+(.*)\\s+\\}\\s+", "$1");
String[] parts = input.split(",\\s+");
for (String part : parts) {
    String[] vals = part.split("=");
    map.put(vals[0], vals.length > 1 ? vals[1] : null);
}

for (Map.Entry<String, String> entry : map.entrySet()) {
    System.out.println("key: " + entry.getKey() + ", value: " + entry.getValue());
}

Demo here:
Rextester

A: Unfortunately, this is not a valid Json. IMHO you should:

*

*split the string on commas

*for each substring, split by =

*If you have an = then you have a key/value pair to add to the dict

*If not, then you could build an array in a default key.


text:
Q: RegisterForRemoteNotifications override method not being called I have created an override for the virtual RegisterForRemoteNotifications in the AppDelegate, which looks like this:
public async override void RegisteredForRemoteNotifications(NSApplication application, NSData deviceToken)
        {
            Debug.WriteLine("This method has been reached");
            base.RegisteredForRemoteNotifications(application, deviceToken);

            var credentials = NotificationRegistrar.Credentials;
            var client = new AmazonSimpleNotificationServiceClient(credentials, RegionEndpoint.APSoutheast2);
            var request = new CreatePlatformEndpointRequest();
            request.PlatformApplicationArn = "{ARN}";
            request.Token = deviceToken.Description;

            await client.CreatePlatformEndpointAsync(request);
        }

However, my method is not being reached at all, wherever it might be (supposed) triggered from. At first, I thought this might be due to the fact I was calling the RegisterForRemoteNotifications method from outside the AppDelegate, after the app had been initialised. But when moving the call to inside DidFinishLaunching, whether before Forms.Init or after, or whatever I tried, my override is not being reached.
Now interestingly, neither is the FailedToRegisterForRemoteNotifications override being called. However, if I uncheck "Sign the application bundle" under the Mac Signing section for the project, FailedToRegisterForRemoteNotifications is called, likely due to the fact that a provisioning profile is required for APNs registration. But why do neither get called with signing with the identity and provisioning enabled? All the permissions / capabilities required are there (I assume). com.apple.developer.aps-environment has been set to development in Entitlements.
Also interesting is the fact that IsRegisteredForRemoteNotifications does change whenever I call either Register/UnregisterForRemoteNotifications, but the overrides are not called.

A: It seems that Big Sur itself is the issue for the development environment, as it is working on a production environment. The solution is to either revert back to Catalina or lower, or attempt to test notifications with a production release.


text:
Q: Unclear on how to setup JavaFX (VSCode) I have started doing a JavaFX project and I have followed the setup instructions from this question: IntelliJ can't recognize JavaFX 11 with OpenJDK 11 using VSCode. I am on a Macbook.
I got as far as the final part, where I was to set up thing with settings.json and launch.json. I followed the instructions as exactly as possible, but the error: Error: JavaFX runtime components are missing, and are required to run this application keeps showing up.
Here is what my settings.json and launch.json files look like:
settings.json
{
    "maven.view": "flat",
    "java.project.referencedLibraries": [
        "lib/**/*.jar",
        "javafx-sdk-11.0.2/**/*.jar"
    ],
    "java.dependency.packagePresentation": "hierarchical"
}

launch.json
{
    "configurations": [
        {
            "type": "java",
            "name": "CodeLens (Launch) - Main",
            "request": "launch",
            "mainClass": "src.Main",
            "projectName": "<censored>"
        },
        {
            "type": "java",
            "name": "CodeLens (Launch) - Main",
            "request": "launch",
            "vmArgs": "--module-path <path_from_root_directory_through_desktop_to_folder_with_project>/javafx-sdk-11.0.2/lib --add-modules javafx.controls,javafx.fxml",
            "mainClass": "Main",
            "projectName": "Main"
        }
    ]
}

I have replaced the actual path to the JavaFX SDK with: <path_from_root_directory_through_desktop_to_folder_with_project> for security.
The path itself is assuming the VSCode compiler starts at the root directory to find the JavaFX SDK (I've tried it assuming it starts in the project which is being run, but that still didn't work).
I have assigned "mainClass" and "projectName" to the file name of the java file containing all my code (minus the .java extension)
Here is the code for the java file I am using, if it is any help:
package src;

import javafx.scene.layout.Pane;
import javafx.scene.Scene;
import javafx.stage.Stage;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

import javafx.application.Application;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;

public class Main extends Application {

    @Override
    public void start(Stage primaryStage) throws FileNotFoundException {
        //declares a pane
        Pane pane = new Pane();

        //IMAGE ONE
        //creates a new imageView
        ImageView image1 = new ImageView(new Image(new FileInputStream("c1.gif")));

        //binds the image to the left of the center of the pane width
        image1.xProperty().bind((pane.widthProperty().divide(2)).subtract(36));

        //binds the image to the center of the pane height
        image1.yProperty().bind(pane.widthProperty().divide(2));

        //formats the image
        image1.setFitWidth(71);
        image1.setFitHeight(96);
        image1.setPreserveRatio(true);

        //adds the image
        pane.getChildren().add(image1);

        //IMAGE TWO
        //creates a new imageView
        ImageView image2 = new ImageView(new Image(new FileInputStream("c2.gif")));

        //binds the image to the center of the pane width
        image2.xProperty().bind(pane.widthProperty().divide(2));

        //binds the image to the center of the pane height
        image2.yProperty().bind(pane.widthProperty().divide(2));

        //formats the image
        image2.setFitWidth(71);
        image2.setFitHeight(96);
        image2.setPreserveRatio(true);

        //adds the image
        pane.getChildren().add(image2);

        //IMAGE THREE
        //creates a new imageView
        ImageView image3 = new ImageView(new Image(new FileInputStream("c3.gif")));

        //binds the image to the right of the center of the pane width
        image3.xProperty().bind((pane.widthProperty().divide(2)).add(36));

        //binds the image to the center of the pane height
        image3.yProperty().bind(pane.widthProperty().divide(2));

        //formats the image
        image3.setFitWidth(71);
        image3.setFitHeight(96);
        image3.setPreserveRatio(true);

        //adds the image
        pane.getChildren().add(image3);

        //SCENE SETUP
        //adds the pane with images to new scene
        Scene scene = new Scene(pane, 500, 500);

        //sets title of stage
        primaryStage.setTitle("DisplayImage");

        //displays the stage
        primaryStage.show();
        }

    public static void main(String []args) {
        launch(args);
        }
    }

Please clarify if I did something wrong.
Just to clarify, I am NOT asking if there is anything wrong with the code, I would like to know what I did wrong with using the JavaFX SDK
There might not be enough information, please let me know what other information I need to provide.

A: 1.Check the installation and environment configuration.

Reference: Getting started with JavaFX

2.Check the setting java.configuration.runtimes, from which VS Code detects the runtime required for your project and choose the appropriate configuration.

Refernece: JDK for projects

If there's nothing achieved, install another jdk and have a try.


text:
Q: /etc/resolv.conf overwritten with old DNS entries not what is in /etc/sysconfig/network-scripts/ifcfg-enp0s3 I have an Oracle Linux 7.5 VM on VirtualBox setup with a static IP address. My DNS servers have changed since I first setup the VM. I modified the file /etc/sysconfig/network-scripts/ifcfg-enp0s3 to have the IP address for the new DNS server but, when I reboot, /etc/resolv.conf keeps getting recreated with the old DNS server ip addresses.
[root@oel72 ~]# cd /etc/sysconfig/network-scripts
[root@oel72 network-scripts]# cat ifcfg-enp0s3
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s3
UUID=58524328-dc73-4b1f-9a56-e3a5d5a4edd5
DEVICE=enp0s3
ONBOOT=yes
IPV6_ADDR_GEN_MODE=stable-privacy
DNS1=IPADDRESSOFNEWDNSSERVER
DOMAIN="my domains edited for post"
IPADDR=10.0.2.6
PREFIX=24
GATEWAY=10.0.2.2
IPV6_PRIVACY=no
PROXY_METHOD=none
BROWSER_ONLY=no

[root@oel72 ~]# cat /etc/resolv.conf
# Generated by NetworkManager

search my domains edited for post
nameserver IPADDRESSOFOLDDNS1
nameserver IPADDRESSOFOLDDNS2
nameserver IPADDRESSOFOLDDNS3

I edited out the actual IP addresses and actual domain names. Hopefully that will not obscure the issue. I'm guessing that there is some command to make the system pull in /etc/sysconfig/network-scripts/ifcfg-enp0s3 again and that it will store the IP address for the new DNS but I cannot find instructions for doing so. Does anyone know how to update these?


text:
Q: XCode Source Control error I'm new to source control. I was using XCode embedded source control for my project since the very start of it. And suddenly it says
    *** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'NKorotkov@Nikolays-Mini.(none)')

and File is unversioned next to any file I try to commit. It seems like for some reason it lost my name and email. If I understand correctly I have to run those two commands in terminal to re-enter info, but I'm afraid if I won't be equal to previous info all my commi history will be messed up. How do I know what username was used before?
UPDATE
Answering to a comment here's contents of .gitconfig file
[filter "media"]
   clean = git media clean %f
   smudge = git media smudge %f
   required = true
[user]
   name = NKorotkov


text:
Q: Upload file to google drive after http get request I have two functions in separate files to split up the workflow.
const download = function(url){
    const file = fs.createWriteStream("./test.png");
    const request = https.get(url, function(response) {
        response.pipe(file);
    });
}

This function in my fileHelper.js is supposed to take a URL with an image in it and then save it locally to test.png
function uploadFile(filePath) {
    fs.readFile('credentials.json', (err, content) => {
        if (err) return console.log('Error loading client secret file:', err);
        // Authorize a client with credentials, then call the Google Drive API.
        authorize(JSON.parse(content), function (auth) {
            const drive = google.drive({version: 'v3', auth});
            const fileMetadata = {
            'name': 'testphoto.png'
            };
            const media = {
            mimeType: 'image/png',
            body: fs.createReadStream(filePath)
            };
            drive.files.create({
            resource: fileMetadata,
            media: media,
            fields: 'id'
            }, (err, file) => {
            if (err) {
                // Handle error
                console.error(err);
            } else {
                console.log('File Id: ', file.id);
            }
            });
        });
    });
}

This function in my googleDriveHelper.js is supposed to take the filePath of call and then upload that stream into my google drive. These two functions work on their own but it seems that the https.get works asynchronously and if I try to call the googleDriveHelper.uploadFile(filePath) function after the download, it doesn't have time to get the full file to upload so instead a blank file will be uploaded to my drive.

*

*I want to find a way so that when the fileHelper.download(url) is called, it automatically uploads into my drive.

*I also don't know if there is a way to create a readStream directly from the download function to the upload function, so I can avoid having to save the file locally to upload it.

A: I believe your goal as follows.

*

*You want to upload a file retrieving from an URL to Google Drive.

*When you download the file from the URL, you want to upload it to Google Drive without creating the file.

*You want to achieve this using googleapis with Node.js.

*You have already been able to upload a file using Drive API.

For this, how about this answer?
Modification points:

*

*At download function, the retrieved buffer is converted to the stream type, and the stream data is returned.

*At uploadFile function, the retrieved stream data is used for uploading.

*When the file ID is retrieved from the response value of Drive API, please use file.data.id instead of file.id.

By above modification, the file downloaded from the URL can be uploaded to Google Drive without creating a file.
Modified script:
When your script is modified, please modify as follows.
download()
const download = function (url) {
  return new Promise(function (resolve, reject) {
    request(
      {
        method: "GET",
        url: url,
        encoding: null,
      },
      (err, res, body) => {
        if (err && res.statusCode != 200) {
          reject(err);
          return;
        }
        const stream = require("stream");
        const bs = new stream.PassThrough();
        bs.end(body);
        resolve(bs);
      }
    );
  });
};

uploadFile()
function uploadFile(data) { // <--- Modified
  fs.readFile("drive_credentials.json", (err, content) => {
    if (err) return console.log("Error loading client secret file:", err);
    authorize(JSON.parse(content), function (auth) {
      const drive = google.drive({ version: "v3", auth });
      const fileMetadata = {
        name: "testphoto.png",
      };
      const media = {
        mimeType: "image/png",
        body: data, // <--- Modified
      };
      drive.files.create(
        {
          resource: fileMetadata,
          media: media,
          fields: "id",
        },
        (err, file) => {
          if (err) {
            console.error(err);
          } else {
            console.log("File Id: ", file.data.id); // <--- Modified
          }
        }
      );
    });
  });
}

For testing
For example, when above scripts are tested, how about the following script?
async function run() {
  const url = "###";
  const data = await fileHelper.download(url);
  googleDriveHelper.uploadFile(data);
}

References:

*

*Class: stream.PassThrough

*google-api-nodejs-client


text:
Q: The set of all functions from integers to a finite set is uncountable
Show that the set of functions from positive integers to the set $\{0,1,2,3,4,5,6,7,8,9\}$ is uncountable.

I suspect I should use the diagonalisation argument but I'm not sure how to approach it.

A: Following a comment above: if one is allowed to use the fact that the set of all subsets of $\mathbb{N}$, $\mathcal{P}(\mathbb{N})$, is uncountable, then it is enough to observe that the set of functions from $\mathbb{N}$ to $\{0,1,2,3,4,5,6,7,8,9\}$ contains the set $\{0,1\}^{\mathbb{N}}$ of functions from $\mathbb{N}$ to $\{0,1\}$ (via an injection). And there is a clear bijection between $\mathcal{P}(\mathbb{N})$ and $\{0,1\}^{\mathbb{N}}$.

A: So your space of functions $f: \mathbb{N}\rightarrow 10$ is referred to as $10^{\mathbb{N}}$ which contains $2^{\mathbb{N}}$. There is a canonical injection from $[0,1]$ to $2^{\mathbb{N}}$ by taking binary representations of $x\in [0,1]$.
So we have $\aleph_0<|[0,1]|\leq |2^{\mathbb{N}}|\leq |10^{\mathbb{N}}|$ so uncountable.

A: The classical diagonal argument works perfectly: for $f: \mathbb{N} \rightarrow 10^{\mathbb{N}}$, consider $g: \mathbb{N} \rightarrow \{0;..;9\}$ defined by $g(n) = 9 - f(n)(n)$ and prove $g$ isn't in the range of $f$ so $f$ is not surjective.


text:
Q: Преобразовать имя(название) переменной в строку(str) Есть список с переменными. Например, одна из них называется model_xgb, при применении обертки str, получаю это:

LGBMRegressor(bagging_fraction=0.8,...{много букв и символов} ....
subsample_for_bin=200000", subsample_freq=0)

Мне нужно, чтобы ее имя - model_xgb, а не содержание, преобразовать в строку.
Как это сделать?

A: попробуйте так:
# функция перевода имени переменной в строку
def var2str(var, vars_data = locals()):
    return [var_name for var_name in vars_data if id(var) == id(vars_data[var_name])]

# проверка работы функции на локальных переменных
def test():
    your_variable = "test"

    for index in range(1):
        print(var2str(index, locals()))

# проверка работы функции на глобальных переменных
my_variabe = 1

test()
print(var2str(my_variabe))

если нужны только глобальные:
def var2str(variable):

    return [global_var for global_var in globals() if id(variable) == id(globals()[global_var])]

my_variabe = 1
your_variable = "test"

print(var2str(my_variabe))

можно еще так:
import varname

my_variabe = 1
your_variable = "test"

print(varname.nameof(my_variabe))

но у меня не установлен модуль varname, чтобы проверить код :(

A: Нашел, как сделать:
poisson_glm[-1].__class__.__name__

"poisson_glm" - переменная.
Вызывали ее из списка:
model = [ridge_glm, poisson_glm, poisson_gbrt]

Я похоже, не совсем, правильно задал вопрос. Сорри, начинающий питонер:)


text:
Q: Class Cast Exception for Binding Provider I created SOAP Client and i need to pass the SOAP request with the Secuity header in java,
I followed this article
https://victorjabur.com/2014/11/03/how-to-consume-a-webservice-that-uses-ws-security-authentication-usernametoken-owsm-oracle-service-bus-osb/
In my code i'm using following code
Proxy p=new Proxy();
Port port=p.getPort();
BindingProvider provider=(BindingProvider)port;
But i'm getting
 ClassCastException: Stub cannot be cast to BinderProvider
I dont see any automatic generated classes implementing BindingProvider or WSBindingProvider, is this the exact problem for unable to cast?
Can any one help me with this ?

A: Setting this property may solve:
System.setProperty("javax.xml.bind.JAXBContext", "com.sun.xml.internal.bind.v2.ContextFactory");
or jvm parameter
-Djavax.xml.bind.JAXBContext=com.sun.xml.internal.bind.v2.ContextFactory


text:
Q: Constructing graphs from subsets of a minimal alphabet From an alphabet of $N$ letters, choose $n$ pairwise distinct subsets $ v_1,\dots,v_n$ of a fixed size $k$ and define a graph on $V=\{v_1,\dots,v_n\}$, which has an edge for each pair of vertices that have no letters in common.  For the occasion, we'll call such a graph a subset graph (knowing that usually the term is used in a different sense).
Special cases would be the Kneser graphs, where $V$ is the complete set of  $k$-subsets.   Obviously any finite simple graph can be realized as a subset graph if only we make $N$ big enough, maybe even $N>n$. So it makes sense to define for a given graph $G$ its "lexicalicity" $\ell(G)$ as the smallest possible such $N$. I am not sure whether it is useful to also define the "subset cardinality" $sc(G)$ as the smallest possible $k$ in such a construction, as that might be at the expense of $N$ becoming much bigger than $\ell(G)$, which would (intuitively) make the structure less interesting.  Question:

*

*Are there classes of graphs for which a construction featuring $\ell(G)$ also features $sc(G)$?

I am only interested in regular graphs here and guess anyway that the higher the "symmetry" of $G$, the smaller $\ell(G)$ and $sc(G)$.
The idea is in fact inspired by the construction mentioned here. I am probably not the first person thinking about that, so I'll ask first  what is known about $\ell(G)$. In particular:

*

*What about $\ell(G)$ if $G$ is the complement of a Kneser graph?

*For a strongly regular graph $G$, is $\ell(G)$ bounded in terms of its parameters? (Or can it even be derived from the parameters?)


text:
Q: Blend for Visual Studio 2013 - Unable to add event handler I'm using Visual Studio 2013, with Blend, to play around with creating Windows 8 apps. I used Blend to add a button, but when I went to add the name of an event handler method to the button in Blend, all the textboxes pertaining to the different events were disabled.
Screenshot as follows:

Contrast between the active textbox "Name" near the top, and the disabled textboxes that pertain to the event handler methods. The latter cannot be interacted with.
I am aware that I can add events in Visual Studio, but I was wondering if there is any reason why I can't do it in Blend.
Any help would be greatly appreciated.
Update: It looks like the issue is fixed in Blend for Visual Studio 2015.


text:
Q: A series of nonanalytic-smooth functions $f'_n = f_{n+1}$ with finite sum? Good day,
we know, in analytic functions, examples of derivative "ladders", i.e. an infinite set of functions
$$\{f_n\}_{n=-\infty}^{n=+\infty}$$
$$\frac{d}{dx}f_n=f_{n+1}$$
which have finite sums $$\sum_{n=-\infty}^{n=+\infty} f_n(x).$$ Examples:
1) Function $f_0=1$ with condition for its anti-derivatives $f_{-n}(0) = 0$
2) Bessel function $J_0(x)$ with condition for its anti-derivatives $f_{-n}(0) = 0$
Such sums necessarily evaluate into $\alpha\times\exp(x)$ (because are derivative-invariant).
My question: Is it possible to find a set of smooth non-analytic functions $f_n$ with this property?
If yes (my motivation), I think it is interesting to have a non-analytic expansion of an  analytic functions (e.g. $\exp$). All one asks for is a finite sum (and smoothness), what one gets is analyticity.

A: It is not possible to find such a sequence $f_n.$ This follows from the following theorem from A theorem on analytic functions of a real variable by R. P. Boas, Jr. The proof is an application of the Baire category theorem, similar to a classic problem about functions satisfying $f^{(n(x))}(x)=0$ for each $x$ for some integer $n(x)$.

Let $f(x)$ be a function of class $C^\infty$ on $a\leqq x\leqq b.$ At each point $x$ of $[a, b]$ we form the formal Taylor series of $f(x),$
$$\sum\limits_{k=0}^\infty \frac{f^{(k)}(x)}{k!}(t-x)^k.$$
This series has a definite radius of convergence, $\rho(x),$ zero, finite, or infinite, given by $1/\rho(x)=\overline{\lim}_{k\to\infty}|f^{(k)}(x)/k!|^{1/k}.$ The function $f(x)$ is said to be analytic at the point $x$ if the Taylor development [I believe this just means Taylor series - Dap] of $f(x)$ about $x$ converges to $f(t)$ over a neighborhood $|x-t|<c,$ $c>0,$ of the point; $f(x)$ is analytic in an interval if it is analytic at every point of the interval. [...]
THEOREM A. If there exists a number $\delta>0$ such that $\rho(x)\geqq\delta$ for $a\leqq x\leqq b,$ $f(x)$ is analytic in $[a, b].$

For each $x,$ the convergence of $\sum_{n=-\infty}^\infty f_n(x)$ implies that $f_n\to 0,$ and hence that the Taylor series of $f_0$ has infinite radius of convergence. By Theorem A, this is enough to force $f_0$ to be analytic.


text:
Q: What is the best way to add model in a collection from view? I have a Backbone Marionette app with Router and a Controller. In my app you can view a collection of texts (index route with collection fetching from server), can view existing collection of texts (indexPage route without fetching from server) and can create a new text (form route). Views of list texts and create form are different from each other and changes in region.
I want to add a successully saved model to a collection and then redirect to indexPage route, but what is the best way to get a texts collection from _FormView success callback? Or how to restruct an app to do it simple?
I can send event to a controller with Backbone.Radio but want to deal without it.
Routes
router.processAppRoutes(controller, {
    '': 'index',
    'index': 'indexPage',
    'create': 'form'
});

Controller
_Controller = Marionette.Controller.extend({
    initialize: function () {
        this.list = new _MainTexts();
    },
    index: function () {
        if (!_.size(this.list)) {

            var
            self = this;

            this.list.fetch({

                success: function (collection, response, options) {
                    self.indexPage();
                    return;
                }
            });
        }
        this.indexPage();
    },
    indexPage: function () {

        var
        textsView = new _TextsView({
            collection: this.list
        });
        application.getRegion('contentRegion').show(textsView);
    },
    form: function () {

        var
        formView = new _FormView({
            model: new _MainText()
        });
        application.getRegion('contentRegion').show(formView);
    }
});

Views
_TextView = Marionette.ItemView.extend({

    className: 'item text',
    template: function (serialized_model) {
        return _.template('
<%= texts[0].text %>
')(serialized_model);
    }
});

_TextsView = Marionette.CollectionView.extend({
    className: 'clearfix',
    childView: _TextView
});

Form view
_FormView = Marionette.ItemView.extend({
    template: '#form-template',
    ui: {
        text: 'textarea[name="text"]',
        submit: 'button[type="submit"]'
    },
    events: {
        'click @ui.submit': 'submitForm'
    },
    submitForm: function (event) {

        event.preventDefault();
        this.model.set({

            text: this.ui.text.val()
        });

        this.model.save({}, {
            success: function (model, response, options) {

                ???
            }
        });
    }
});

A: Ok, my problem solution is here. In controller action "form" I create event listener
var
formView = new _FormView({

    model: model
});

formView.on('formSave', function (model) {

    if (id == null) {

        self.list.add(model);
    }

    ...
});

Then in form view I trigger event
this.model.save({}, {

    success: function (model, response, options) {

        if (response.state.success) {

            self.trigger('formSave', model);
        }
    }
});

That's all:)


text:
Q: If 6 high school teams play each other once in a division, what is the probability that one team has a perfect 5-0 season? I tried to use inclusion exclusion, and got something close, but not quite right. I am also assuming each team is as likely to lose as to win.
For the event $A_i$ being the event that team $i$ has a perfect season, with each event having $P(A_i)=(1/2)^5=\frac{1}{32}$, by inclusion exclusion
$$
P(\cup_{1}^6 A_i)=6\frac{1}{32}-{6\choose 2}\frac{1}{32^2}+{6\choose 3}\frac{1}{32^3}-{6\choose 4}\frac{1}{32^4}+6\frac{1}{32^5}-\frac{1}{32^6}
$$
The correct answer in the book is 5/32. By messing around on wolfram alpha, it seems that if I cut off the final term, which represents the impossible event that all 6 teams have perfect seasons, I get to within .01 of the answer. But why cut off this term? It also isn't possible to have 5 teams have perfect seasons? Also, how in the world did they get such a nice simple fraction?
Thanks!

A: There are, in the tournament, $2^{15}$ possible combinations of game outcomes, each of which is equally likely.
Of these $2^{15}$ tournament results, how many have one team at five wins?
You can choose the team ($6$ ways) and having done that, five results are forced, and the remaining ten results can be any combinations, you don't care about them.
So the answer is
$$
\frac{6\cdot 2^{10}}{2^{15}} = \frac{6}{32}
$$
The correct answer in the book is using a definition of "correct" with which I was previously unfamiliar.

A: Outline
The key to this problem is first realizing that if one team has a perfect $5-0$ season, then no other team has a perfect $5-0$ season..  The probability of a particular team having a perfect season is winning all the $5$ matches, i.e. $\frac{1}{32}$. This can be any one of the teams, so the required probability is $\color{blue}{\frac{6}{32}}$

A: The implicit assumption seems to be that all teams are equally good so that each outcome of a game is equally likely. If the sport is soccer and one team is the Brazilian National team while the other 5 teams are local high schools, the record 5-0 is all but certain.
The "correct" answer therefore will depend on the ex ante distribution of ability within the division. (Though I doubt the textbook was expecting to proceed that way.)


text:
Q: Android Studio - Animation UI I've just started my work with android and android studio. I've never created any apps for android. I'd like to add some animations to my project. Before I did it in Expression Blend (Windows Phone 8). How can I do it for Android?

A: Android supports OpenGL.
This link from developer.android.com describes OpenGL's uage for animation and graphics within Android:
"OpenGL
Android supports OpenGL ES 1.0 and 2.0, with Android framework APIs as well as natively with the Native Development Kit (NDK). Using the framework APIs is desireable when you want to add a few graphical enhancements to your application that are not supported with the Canvas APIs, or if you desire platform independence and don't demand high performance."
Also see this Android Developer's page for simple UI animation.


text:
Q: How can I make a new home base? I came home to the base at the church one day to find several NPCs arguing over whether to move to a new base or not. After that cutscene ended, I opened a dialogue with one of them, where I had the option to ask him to come and look for new home bases with me. He said he had a specific place in mind. So we went out and found this place, went inside, looked around, until I got the "potential home base cleared" message.
I have the required amount of materials and people in my group to build the new base. However, when I press down on the D-Pad, I only get the option to make this base an outpost, not a new home. I have around 150 influence.
Is the issue that I need more influence? Or does it need to be an outpost before it becomes a home? Or is it something else?

A: It is possible that you haven't finished the 'Home Away from Home' mission yet, which is why you have no option to transfer to that potential home site. (You'll know when you have finished it when you are left just outside Snyder Trucking Warehouse at west Marshall and with Jacob Ritter no longer following you.)
Transferring to a new home site requires that you finish the 'Home Away from Home' mission given by Jacob Ritter, and 100 influence. Home sites also have different building materials and number of survivors requirements. You have to meet those requirements before you can transfer to a new home site.
There is no need to make a location an outpost before you transfer your home site to it. Make sure you are standing inside a valid home site before making a radio assistance call that you want to transfer your home site to that location.
I am listing here the available home sites you can transfer to and and their requirements (click the links on the name of a home site for more info on them):
Home Site —  Materials —  Survivors (base game) — Survivors (Breakdown DLC)

*

*Kirkman Residence – 30 – 8 – 6

*McReady Farmhouse – 30 – 8 – 6

*The Alamo – 20 – 5 – 0

*Savini Residence – 30 – 8 – 6

*Snyder Trucking Warehouse – 50 – 12 – 10

*Trumbull County Fairgrounds – 50 – 12 – 10

**Church of the Ascension – 20 – 5 – 0

*Note: In the base game, transferring to this home site is part of the storyline. While, in the Breakdown DLC, you can opt to make this your home site.
Attribution: Home sites requirements info are from the State of Decay wiki

A: In the mission "Home away from home", Jacob first leads you to the Savini Home Resident, where you witness a dying man reanimating. After that, the map pointer points to another place, the Snyder Trucking Warehouse. Then you get out of the car and have another talk with him, and he repeatedly insist that you choose the first home site you visited. At that point, the mission ends and the option to relocate home base is unlocked.
So, did you do all these and the option is still missing?
P.S: The relocating requirements include Influence, People and Material, nothing more. If you don't fulfill the requirements, the option will be greyed out, not missing. If it's missing then it's likely that you haven't completed the required storyline mission.


text:
Q: HTML - 'Persistance Navbar'? I was wondering if it was possible to do the following in HTML.
index.html:
<title>Awesome Website</title>
<link href="navbar.html" rel="i-dunno-what-to-put-here" type="text/html"/>

Content

navbar.html:

1

2

3

4

So pretty much - all pages link to the navbar.html and if there is one change in the navbar, then all the pages change.
Does anyone know if this is possible / how to do it?
Any help would be much appreciated.

A: I used PHP include like JEES mentioned.


text:
Q: Are namespaces in PHP "inherited"? EDIT:
Yes the problem was using \ at the beginning of the use statement. As M1ke pointed out, use goes from the root element.
Original post
I think is a PHP question but it may be Drupal.
I'm working on a headless Drupal project where is using a class (which I call Entity Model) that uses a Drupal class called EntityFieldQuery.
Before a create or use this class I bootstrap Drupal using:
require_once DRUPAL_ROOT.'/includes/bootstrap.inc';

drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

The entity model class is in the Models names space like so:
namespace Models;

use \EntityFieldQuery;

class EntityModel
{

    .....

     $query = new EntityFieldQuery();
     $query->doSomething();

    ......
}

The EntityFieldQuery is found perfectly as I use the "\" because this class is out of the Models namespace.
The problem is when this class is created is uses other classes that don't use any namespace, and I have the following error:
class Models\InsertQuery not found in ....

Here is the class used by EntityFieldQuery that uses InsertQuery
class InsertQuery_mysql extends InsertQuery ...

I don't understand why InsertQuery_mysql is found but InsertQuery
I ended up adding a "\" in InsertQuery to fix the problem like so:
class InsertQuery_mysql extends \InsertQuery ...

Actually this class in a php file called query.inc that contains two defitinion classes (in the same file, I don't know this is a a problem too)
class InsertQuery_mysql extends InsertQuery
....
class TruncateQuery_mysql extends TruncateQuery

I thought that if I use "new \ClassName()" the "default namespace" inside this class would be "\" too and not the first called class's namespace.
I don't like to modify 3rd party libraries, is any way to avoid this? I guess is a architecture problem rather than a lack of definition if someone has a better idea, I appreciate.
Thanks!
EDIT2: Adding more info...
In order of execution.
index.php:
require_once 'vendor/autoload.php';
require_once DRUPAL_ROOT.'/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
...

app/SiteController.php:
use Models\Campaign;
class SiteController {
   ...
   $campaing = new Campaign();
   ...

app/Models/Campaing.php:
namespace Models;
class Campaign extends EntityModel {
...

app/Models/EntityModel.php:
namespace Models;

use \EntityFieldQuery; //<-- this should go without \ as I say in EDIT section
class EntityModel {
...
public function getAll() {
   $query = new EntityFieldQuery(); //<--throwed Models\InsertQuery not found. It must have \ at the beginning of the class name.

A: To answer the base question (and pending further code) PHP namespaces are set by whichever namespace is declared in the file.
// Bar.php

namespace Foo;

class Bar {}

// some other file

use Foo\Bar;

$test = new Bar(); //works

// different file

namespace Foo;

$test = new Bar(); // works

// another file

require 'Bar.php';

// won't work because we are not in namespace "Foo"
$test = new Bar();

In your specific case it the use \EntityLoader should be use EntityLoader because you're exiting the namespace you want to be inside.


text:
Q: Data Tool for SSRS not installed correctly Can anybody help me that how can I installed Data Tool for SSRS correctly. During installation it is not able to located BI while I already installed BI with SQL SERVER.
Due to incomplete installation I am unable to select MS dynamic CRM Fetch from DataSource dropdown.
Window - 8,
SQL Server 2012,
VS 2012
Thank!
Jahangir

A: While installing SSMS along with BI  we will get the following services to select to install,

*

*Management tools-Basic

*Integration services

*Reporting Services

*Analysis Services

We need to select all above options to work on BI with SQL.
I hope this will help you
Thanks
Venky


text:
Q: Upgrade from 2008 RTM to 2008 R2 RTM failed due to perf-ReportServer-rsctr.dll is being used by another process I was upgrading SQL Server 2008  RTM on Windows Server 2008 R2 SP1 to SQL Server 2008 R2 RTM. I got this error:

The process cannot access the file
  'C:\Windows\SysWOW64\perf-ReportServer-rsctr.dll' because it is being
  used by another process.
Service 'MSSQLServer' Stop request timed
  out and this occurred during
  'sqlEngineConfigAction_upgrade_shutdowninstance_cpu64 ' phase and I
  stopped & disabled WMI even though it was not running and did not
  install process monitor to see who locked this dll. I also shutdown
  application servers before starting the upgrade to avoid them to
  attempt to connect to SQL Server.

After the failed upgrade  full-text search, SQL Server Replication, Database Engine Services, Analysis Services and Reporting Services status were Failed but others succeeded such as management studio & integration Services etc and then I restarted the server as it was required  but as expected after reboot server was still in 2008 RTM and when I queried select @@version.
Do you think I should upgrade SQL 2008 to latest service pack SP4 and upgrade as this bug may have been fixed on latest service packs and then upgrade to SQL Server 2008 R2 or just figure out which process or application that may be using this dll?


text:
Q: Service throwing error of EndPointNotFoundException I had tried all the things, after all that I found out in error.svclog file that client able to hit the service but service throwing EndPointNotFoundException.
I had also seen the server log to check the status and it is display below.
#Software: Microsoft Internet Information Services 7.5
#Version: 1.0
#Date: 2014-02-22 09:22:35
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status time-taken
2014-02-22 09:22:35 192.168.10.9 GET /HostWCF/Service.svc - 80 - 192.168.10.10 Mozilla/5.0+(Windows+NT+6.2;+WOW64;+rv:27.0)+Gecko/20100101+Firefox/27.0 200 0 0 60360
2014-02-22 09:22:54 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 52
2014-02-22 09:23:04 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 52
2014-02-22 09:30:24 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 1994
2014-02-22 09:30:34 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 73
2014-02-22 09:30:44 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 52
2014-02-22 09:30:54 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 54
2014-02-22 09:31:04 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 69
2014-02-22 09:31:14 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 67
2014-02-22 09:31:24 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 62
2014-02-22 09:31:34 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 67
2014-02-22 09:31:44 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 50
2014-02-22 09:31:54 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 59
2014-02-22 09:32:04 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 50
2014-02-22 09:32:14 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 54
2014-02-22 09:32:24 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 51
2014-02-22 09:32:34 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 53
2014-02-22 09:32:44 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 82
2014-02-22 09:32:54 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 79
2014-02-22 09:33:04 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 60
2014-02-22 09:33:14 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 52
2014-02-22 09:33:24 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 76
2014-02-22 09:33:34 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 49
2014-02-22 09:33:44 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 52
2014-02-22 09:33:54 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 57
2014-02-22 09:34:04 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 72
2014-02-22 09:34:14 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 51
2014-02-22 09:34:24 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 60
2014-02-22 09:34:34 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 62
2014-02-22 09:34:44 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 55
2014-02-22 09:34:54 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 95
2014-02-22 09:35:04 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 55
2014-02-22 09:35:14 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 54
2014-02-22 09:35:24 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 58
2014-02-22 09:35:34 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 57
2014-02-22 09:35:44 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 53
2014-02-22 09:35:54 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 67
2014-02-22 09:36:04 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 54
2014-02-22 09:36:14 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 60
2014-02-22 09:36:24 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 65
2014-02-22 09:36:34 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 59
2014-02-22 09:36:44 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 58
2014-02-22 09:36:54 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 56
2014-02-22 09:37:04 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 51
2014-02-22 09:37:14 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 70
2014-02-22 09:37:24 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 61
2014-02-22 09:37:34 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 61
2014-02-22 09:37:44 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 65
2014-02-22 09:37:54 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 56
2014-02-22 09:38:04 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 69
2014-02-22 09:38:14 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 55
2014-02-22 09:38:24 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 51
2014-02-22 09:38:34 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 54
2014-02-22 09:38:44 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 51
2014-02-22 09:38:54 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 57
2014-02-22 09:39:04 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 62
2014-02-22 09:39:14 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 55
2014-02-22 09:39:24 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 56
2014-02-22 09:39:34 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 55
2014-02-22 09:39:44 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 56
2014-02-22 09:39:54 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 56
2014-02-22 09:40:04 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 56
2014-02-22 09:40:14 192.168.10.9 POST /hostwcf/service.svc - 80 - 192.168.10.10 - 202 0 0 67

my service web.config file
<?xml version="1.0"?>
 <configuration>
<configSections>
</configSections>
<system.diagnostics>
<sources>
  <source name="System.ServiceModel"
          switchValue="Information, ActivityTracing"
          propagateActivity="true" >
    <listeners>
      <add name="xml"/>
    </listeners>
  </source>
  <source name="System.ServiceModel.MessageLogging">
    <listeners>
      <add name="xml"/>
    </listeners>
  </source>
  <source name="myUserTraceSource"
          switchValue="Information, ActivityTracing">
    <listeners>
      <add name="xml"/>
    </listeners>
  </source>
</sources>
<sharedListeners>
  <add name="xml"
       type="System.Diagnostics.XmlWriterTraceListener"
       initializeData="Error.svclog" />
  </sharedListeners>
</system.diagnostics>
<connectionStrings>
  <add name="Connection" connectionString="Server=.\SQLSERVER;  Database=databaseDB;Trusted_Connection=True;"/>

</connectionStrings>
 <system.web>
  <!--<webServices>
  <protocols>
    <add name ="HttpGet"/>
    <add name="HttpPost"/>
    <add name="HttpPostLocalhost"/>
    <add name="HttpSoap"/>

  </protocols>
  </webServices>-->
  <compilation debug="true" targetFramework="4.0" />
 </system.web>
 <system.webServer>
  <!--<defaultDocument>
  <files>
    <add value="Service.svc"/>
  </files>
  </defaultDocument>-->
  </system.webServer>
  <system.serviceModel>
  <bindings>
  <wsDualHttpBinding>
    <binding name="DualNewBinding">
      <!--receiveTimeout="01:10:00" sendTimeout="01:10:00"  closeTimeout="02:00:00" openTimeout ="01:40:00" useDefaultWebProxy ="True" >-->
      <security mode="None">
        <message clientCredentialType ="None"/>
      </security>
    </binding>
  </wsDualHttpBinding>
  </bindings>
  <services>
  <service
    behaviorConfiguration="HostWCF.ServiceBehavior" name="HostWCF.Service" >
    <endpoint address="" binding="wsDualHttpBinding" bindingConfiguration="DualNewBinding" contract="HostWCF.IService">
      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost/HostWCF"/>
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="HostWCF.ServiceBehavior">
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="true" />
      <serviceCredentials >
        <windowsAuthentication allowAnonymousLogons ="true"/>
      </serviceCredentials>
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
  <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>

</configuration>

my client app.congif file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
 <add name="connection" connectionString="Server=.\SQLEXPRESS;Database=TISDB;Trusted_Connection=True;"/>
 </connectionStrings>
  <system.serviceModel>
    <bindings>
        <wsDualHttpBinding>
          <binding name="WSDualHttpBinding_IService"  openTimeout="00:10:00" closeTimeout ="00:20:00" bypassProxyOnLocal ="false" receiveTimeout ="00:08:00" sendTimeout ="00:10:00" useDefaultWebProxy ="true">
            <security mode="None">
              <message clientCredentialType ="None"/>
            </security>
          </binding>
        </wsDualHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://192.168.10.9/hostwcf/service.svc" binding="wsDualHttpBinding"
            bindingConfiguration="WSDualHttpBinding_IService" contract="ServiceReference.IService"
            name="WSDualHttpBinding_IService">
            <identity>
                <dns value="192.168.10.9" />
            </identity>
        </endpoint>
    </client>
   </system.serviceModel>
 </configuration>

A: WCF was designed to be secure by default.  And that security implies that not only the server needs to know who is calling it, but also that the client needs to be sure that the server it is talking to is indeed the server it is excpecting to be.
The thing that is used for this check is the service identity.  For a client to trust the server, the identity of that server needs to match the identity definition of the client.
In your configs the service defines the identity as follows:
  <identity>
    <dns value="localhost"/>
  </identity>

and the client as follows:
    <identity>
        <dns value="192.168.10.9" />
    </identity>

Those identities don't match and thus the client is not talking to the correct endpoint ==> endpoint not found exception.
Solution:
Make the identities match, or remove the identities altogether if that security check is not required.


text:
Q: React can't update on IE 10 I'm using react-boilerplate to build an app and everything works fine on Chrome and FF, but on IE, it doesn't.
Example: I have a list, after delete an item, it should disapear from the list.
It works on Chrome and FF.
On IE, it only works if I open an dev tool.
I tried to import 'console-polyfill' or add 'webpack-strip' in webpack loaders but none of these works.
--UPDATE--
Just find out something, 1st time go to list view, saga calls to api getlist (using axios) to get items, after delete, it calls getlist again but this time, it does not really call to api (I console log on backend and there is no request to it), but the response is the one from the 1st time request, so the list can't be update.
--UPDATE 2--
Okay i got it, IE still have cache from the first call using method GET. That's why


text:
Q: location listener I am using location listener to get long & lat for my android application.
I am working with the following code:
public Location getLastKnownLocation()
{
 Location location=null;
 try
 {
 // Get the location manager
 mLocMgr = (LocationManager) ctx.getSystemService(Context.LOCATION_SERVICE);
 // List all providers:
 // List<String> providers = mLocMgr.getAllProviders();

 Criteria criteria = new Criteria();
 bestProvider = mLocMgr.getBestProvider(criteria, false);
 location = mLocMgr.getLastKnownLocation(bestProvider);
 if(location==null)
 {
  Thread.sleep(5000);
  location=mLocMgr.getLastKnownLocation(bestProvider);
 }
 }
 catch(Exception e)
 {
  Log.i("program", e.getMessage());
 }
 return location;
}

public Location updateCurrentLocation()
{
 Location mLoc=null;
 try
 {
 mLoc=getLastKnownLocation();
 mlocListener = new LocListener();
 mLocMgr.requestLocationUpdates(bestProvider, 0, 0, mlocListener);
 mLoc=getLastKnownLocation();
 }
 catch(Exception e)
 {
  Log.e("program", e.getMessage());
 }
 return mLoc;
}

It is working absolutely fine. But facing the problem when we switched off the device and start it again. Then I am getting the location null.
However after starting the google map, it starts working again.
So Could you please guys help me out on this because I don't want start the google map before starting my application. Thanking you for support!

A: Your getLastKnownLocation method is likely to fail when you power off and power on your device.
And, I see that, you are calling it before you subscribe to location update lister:
 mLoc=getLastKnownLocation();  //<<<<<<<<<<<<<
 mlocListener = new LocListener();
 mLocMgr.requestLocationUpdates(bestProvider, 0, 0, mlocListener);

Why do you need to call getLastKnownLocation() ? It will not work immediately when you start your device.
When you are using Google map, it is gracefully trying to listen to location update. And, once it gets atleast one location update, then your getLastKnownLocation will start working.
I see that your architecture need re-thinking (if your method names are appropriate)
This should be called ONLY ONCE, in some appropriate location, when your app initiates.
mLocMgr.requestLocationUpdates(bestProvider, 0, 0, mlocListener);

Then, do whatever update you need in onLocationChanged(Location location)

A: Little Flyffy Location library:
http://code.google.com/p/little-fluffy-location-library/
Simple, fast, easy!
this library notify your location updates.


text:
Q: How do I apply a Visual Studio Online Professional license to Visual Studio 2013 I recently purchased a single user license for Visual Studio Online Professional in order to make use of the fact that it grants a monthly subscription license for the Visual Studio Professional IDE as well as all the features of basic VSO.
I ran into problems trying to apply the license to Visual Studio since VSO uses Azure Active Directory accounts to authenticate and these are not considered Microsoft Accounts.  This means that when you go to Help -> Register and try to sign in you get an error telling you that it is not a MS account.
It appears that there is little or no documentation about this online.

A: To register a "Visual Studio Online" professional license within Visual Studio 2013 Professional ID you simply need to connect the trial version of Visual studio 2013 Professional to your Visual Studio Online TFS instance.
Note that this will not work if you have an MSDN license (either signin or product key applied to your Visual Studio 2013 IDE already.  You must remove these first.
To remove a product key license from VS2013 please see the answer at https://stackoverflow.com/a/22258088/285470


text:
Q: How to use a method in other class without creating a new object I'm a Java beginner working on a Java GUI project.
I create my object in my TEST CLASS and write my set get function in CLASSA.
I want to use the set get function in CLASSB, but I can only use the function by creating a new object in CLASSB. It will cover my data stored in CLASSA, that I can't get anything in CLASSB.
I can't use extends because CLASSB has already extends JFrame.

A: If you mark ClassA as static, you can call ClassA.MyFuntion() in ClassB without having to create a new object.

A: I believe what you need is to create a method of class in CLASSB, rather than of instance.
This is achieved by using the static keyword when creating the method.
public static void myMethod() {
  // logic here
}

You can take a look at this article, for better understanding.

A: Make the function a public static function and you can call it using [classname].[function](value)
heres an example. class TestA defines the function which is called in TestB
package test;

public class TestA {
    public static void square(int x) {
        int y=x*x;
        System.out.print(y);
    }
}

package test;

public class TestB {
    public static void main(String[] args) {
        int x = 2;
        TestA.square(x);
    }
}