text:
Q: In what sense is $\Pi x: A.B$ the same as $B[x := a_1] \times B[x := a_2]$ when A is a finite type with two elements $a_1$ and $a_2$ This is in the context of the Type Theory system $\lambda P$ as presented in Chapter 5 of "Type Theory and Formal Proof: An Introduction" by Rob Nederpelt and Herman Guevers.
Since I am unsure of how standard $\lambda P$ is in the literature, I'll just mention that it is a system of type theory in which in addition to terms depending on terms, there are types depending on terms.
The full paragraph in the text is:
"Martin-Löf (1980) calls a $\Pi$-type the Cartesian product of a family of types. If one considers A to be a finite type, say with two elements $a_1$ and $a_2$, then $\Pi x: A. B$ is indeed the same as $B[x := a_1] \times B[x := a_2]$, the Cartesian product and as a generalization of the function space (if $x \notin \operatorname{FV}(B)$, then $\Pi x : a. B$ is just $A \to B$)"
This equivalence to Cartesian products is not further explained. I have tried to make sense of it by considering concrete examples but have fallen short.
One possible reason I am failing to understand this is that I do not understand how (or even know if it is possible that) a type in beta-normal form can contain a free term, whereas in systems $\lambda \to$, $\lambda 2$, $\lambda \underline{\omega}$, I had no issue finding examples of the situations equivalent to this (for terms dependent on terms, terms dependent on types, and types dependent on terms).

A: Welcome to MSE ^_^
I am not familiar with Nederpelt and Guevers' book, so I'm sorry if the language I use is not the language used in your reference. I will try to explain everything as I go, in case some notation I use is unfamiliar.
A dependent type $\prod_{a:A} B(a)$ is indeed a generalization of the cartesian product. The easiest example is when $A = \text{Bool}$ with two values $T$ and $F$.
Let's consider two types $B(T)$ and $B(F)$.
Then the type $\prod_\text{x:Bool}B(x)$ is inhabited by functions $f$ so that
$f(T) : B(T)$ and $f(F) : B(F)$. One can view such a function $f$ as selecting an element $f(x)$ of each $B(x)$.
Now, there is a natural (and eventually obvious) identification between these functions $f$ and a pair $(b_1,b_2) : B(T) \times B(F)$. Our function $f$ is totally specified by $f(T)$ and $f(F)$, so we can package those values up as a tuple. Dually, a tuple whose first element is in $B(T)$ and second is in $B(F)$ gives us the data of a function!
$$\left ( f : \prod_{x:\text{Bool}}B(x) \right ) \mapsto \bigg ( (f(T),f(F)) : B(T) \times B(F) \bigg )$$
$$\bigg ( (x,y) : B(T) \times B(F) \bigg ) \mapsto
\left ( \lambda b . \text{if } b = T \text{ then } x \text{ else } y : \prod_{b:\text{Bool}} B(b) \right )$$
Following Homotopy Type Theory, my preferred interpretation of this phenomenon is geometric.
Consider the following picture:

Here we have two types, which you should view as "floating above" the type of booleans below. Then elements of $\prod_{x : \text{Bool}}B(x)$ are exactly functions out of $\text{Bool}$ so that the value of $f(x)$ lies above $x$. In this way, as I said earlier, an element of the $\prod$-type selects one element out of each of the pieces. Hopefully this picture, and the idea of a $\prod$-type as a "selector" helps explain in a different way why $\prod_{x : \text{Bool}}B(x)$ is the same as $B(T) \times B(F)$. They both represent ways to choose one element from $B(T)$ and one from $B(F)$!
At this point I will suggest a small exercise. Let $\mathbf{3}$ denote a type with three values: $x$, $y$, and $z$. Now fix 3 new types, say $B(x)$, $B(y)$, and $B(z)$. Do you see why $\prod_{t:\mathbf{3}}B(t)$ is the same as $B(x) \times B(y) \times B(z)$? Make sure you understand why that is before moving on!

Let's move on to a trickier example now. Let $\mathbb{Z}$ denote the type of integers. Now pick a type $B(n)$ for each integer $n : \mathbb{Z}$. What does an element of $\prod_{n : \mathbb{Z}} B(n)$ look like?
You should train yourself, pavlovianly, to pull the following picture to mind:

Again, we have a function out of $\mathbb{Z}$, which selects one element of each $B(n)$. The analogy to cartesian products is slightly less clear now. But this is where we start generalizing. If $f : \prod_{n : \mathbb{Z}}B(n)$, then what type might you give the following "term"?
$$(\ldots, f(-2), f(-1), f(0), f(1), f(2), \ldots)$$
This "term" is a tuple with $\mathbb{Z}$ many entries, and the $n$th entry comes from $B(n)$. If you had to assign a type to something like this, you might say it has type $\ldots \times B(-2) \times B(-1) \times B(0) \times B(1) \times B(2) \times \ldots$.
It is in this sense, that $\prod_{n : \mathbb{Z}} B(n)$ is a "cartesian product". The functions inhabiting this $\prod$-type have exactly the same information as an infinite tuple indexed by $\mathbb{Z}$! But because functions are finitary, they can be expressed in type theory, while formalizing an "infinite tuple" is almost impossible!

It's time for the last example. What about $\prod_{a:A}B(a)$? Again, the response should be pavlovian:

Here we write $B$ to mean the collection of all the $B(a)$s viewed as one type. (As a remark, $B$ is exactly the sum-type $\Sigma_{a:A}B(a)$!) Then functions $f : A \to B$ so that $f(a) : B(a)$ are exactly elements of $\prod_{a:A}B(a)$. Again, we are selecting one element from each $B(a)$. So we can think of this function as a "tuple indexed by $A$", and so we identify it with a "cartesian product" of one type for each element of $A$! This is exactly where the $\prod$ notation comes from - we are producting together the family of types $B(a)$. This is extra useful, as $A$ might not be ordered neatly in the way that $\mathbb{Z}$ is. So it is less clear how one might write a tuple with one entry for each value of $A$! In this case, if we want to show that we're thinking of $f$ as a tuple rather than a function, we might write something like $(f_a)_{a:A} : \prod_{a:A} B(a)$.

This was a long ride, but I hope it made some sense! I know $\prod$-types confused me when I was first getting started, but after I worked these "bubble" pictures into my subconscious (the bubbles are called "fibres", by the way), their properties became really obvious! The important thing to keep in mind is that, as far as type theory is concerned, a $\prod$-type is just a type full of functions. Their normal forms look just like functions. You can evaluate them, and you create them via $\lambda$-abstraction. But as humans, we have the power to think of them as more than functions. The confusion you're feeling with regards to $f$ not having a clean codomain is common. It is solved (as I alluded to earlier) by the introduction of $\sum$-types, but even without $\sum$-types, $\prod$-types have introduction and elimination rules just like anything else - there's nothing scary lying under the hood.
To get some practice, can you see (intuitively!) why the following facts must be true? Can you then formalize this intuition with an equivalence of types?

*

*$\prod_{x:\mathbf{1}}A(x) \cong A(x)$ when $\mathbf{1}$ is the type with only one inhabitat

*$\prod_{x:X}B(x) \cong \mathbf{0}$ whenever one of the $B(x)$s are $\mathbf{0}$ (the type with no inhabitants)

I hope this helps ^_^


text:
Q: How to add NestJS to existing Angular Project without two seperated node_modules? I have a Angular project which is getting data from Google Firestore.
All clear and working.
Now I want to switch from Firestore to own MySQL database, with NestJS and TypeORM.
When adding a subfolder, for example "server", creating a new Nest project with Nest CLI within, it's working too, but I got two node_modules folders, one for the Angular project and one for the Nest project under "server".
How can I use one node_modules folder for both?
The most examples I found are either for a Angular project or a Nest project standalone, a few have both projects but I don't get the magic behind them.
Can someone give me a hint please?
Thanks in advance,
Robert

A: You can clone my repo here https://github.com/malik-evans/presentable.
I'm a nest/angular fan so I've been working at it for a while.  After running. Npm install, run the serve:dev script in the package.json. give angular a while to compile before expecting the ui to load.

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to pass data through a Tkinter button function, problems with lambda Start page has two buttons: pull data and plot data in a new frame. figure(f,a) has been defined, but is not included in the section of code below:
 button1 = ttk.Button(self, text="Show Graph",
                            command=lambda: controller.show_frame(PageTwo))
 button1.pack()

 button2 = ttk.Button(self, text="PL3",
                            command=lambda: animate(3))
 button2.pack()

Button2 launches the function "animate" it takes in an argument(J), pulls data corresponding to J then plots a scatter plot.
def animate(j)
   a.plot(Date, Left,"go", label = "price")
   title = "Left Fid"
   a.set_title(title)

Button1 then shows the figure in a new frame
class PageTwo(tk.Frame):
def __init__(self, parent, controller):
    tk.Frame.__init__(self, parent)
    label = tk.Label(self, text="Graph page", font=LARGE_FONT)
    label.pack(pady=10,padx=10)

    button1 = ttk.Button(self, text="back to home",
                        command=lambda: controller.show_frame(StartPage))
    button1.pack()

    canvas = FigureCanvasTkAgg(f,self)
    canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand = True)

    canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand = True)

The issue: The data I want to get plotted is being correctly executed by animate. I can see the data in the command prompt. The new tkinter window pops up, but without plotting any of the data generated from "animate".
If I REMOVE the LAMBDA from Button 2, I see the correct plot in the new frame, but is not how I want to structure the code for the future.  I can not remove lambda because eventually there will be 30 buttons just like Button 2.
What is going on with LAMBDA in button 2?

A:
What is going on with LAMBDA in button 2?

The command parameter in tkinter.Button expects a references to a function.
lambda is syntax to create an anonymous, simple function. It's syntax is virtually identical to a function's signature.
def func(a, *args, b = 2, **kwargs):
    return a+b
func = lambda a, *args, b = 2, **kwargs: a+b

Because lambda is an easy way to create a function, people often use it in tkinter to bundle functions with predetermined arguments specific to the given callback/command.

Button2 launches the function "animate" it takes in an argument(J), pulls data corresponding to J then plots a scatter plot. [...]
Button1 then shows the figure in a new frame [...]
If I REMOVE the LAMBDA from Button 2, I see the correct plot in the new frame

Removing the lambda keyword executes animate(3) immediately when the code is executed to configure button2 instead of creating an anonymous function. The command for button2 is then set to whatever animate(3) returns. If it is not callable, then it is effectively ignored.
Because you did not provide workable code for animate or controller.show_page, it's not possible for any of us to know for sure what it does, but from the results it is safe to assume that animate stores the figure in an attribute/variable, and then controller.show_page (or some portion of PageTwo which is not provided) retrieves the figure from that attribute/variable. This is why the code appears to still be working: because with only one figure to store, button1 will always retrieve the correct figure. If you had multiple buttons, presumably button1 would always display the figure for the last button created no matter which button was pressed, as that is the most recently stored figure.
Obviously, the issue at the center of all this is likely how animate is storing the figure and the way controller.show_page/PageTwo is retrieving the figure. Two generalized explanations:

*

*Something is created after or during the initialization of PageOne which interacts with figure (and/or influences the instantiation of PageTwo). With lambda, this object has a certain value while being created which is not changed until after the object has completed its process (whether that's initializing, calling a subsequent method, setting a tertiary variable, etc). Without lambda, animate is called immediately which changes this object to reflect the creation of figure.

*The variable housing figure or another intermediary variable is being garbage collected because you aren't maintaining a reference to it.

Since I think the first is more likely, I'll specifically pick out a and f as candidates: neither of these variables are method parameters (and they don't appear to be pulled from controller, per your code), so they are references that could easily be changed during execution in a higher scope.
If you reduce your code to a MVCE, it would be easier to see what exactly the problem is. You also might find that the issue goes away when you writing the MVCE, which will tell you exactly what went wrong and will let you fix it right away instead of waiting for Stack Overflow answers.


text: Q: Firefox freezes frequently in Ubuntu 16.04 Firefox freezes frequently in Ubuntu 16.04. It only happens with Firefox, everything else works fine. Most of this occurs when i am browsing facebook, it freezes for a while and then displays unresponsive script error. What is the underlying issue?


text:
Q: SQL CAST(int as varchar) throws error Good evening,
I'm trying to convert an int to a varchar using the CAST() function but it gives me the following error:
syntax error, unexpected VARCHAR

and this is the code
CAST(p2v as varchar)

and i also tried
CAST(p2v as varchar(MAX))

I got the same problem when i try using CONVERT()

A: It must be char, not varchar

The type for the result can be one of the following values:

*

*BINARY[(N)]

*CHAR[(N)]

*DATE

*DATETIME

*DECIMAL[(M[,D])]

*SIGNED [INTEGER]

*TIME

*UNSIGNED [INTEGER]

From http://dev.mysql.com/doc/refman/5.5/en/cast-functions.html#function_cast


text:
Q: SOCRATA SODA query for array item (SELECT & GROUP BY) Is it possible to select or group by an item within an array using SoQL?
For example, here is an item returned by the SODA API:
{
  "business_name" : "ACME CO",
  "phone_number" : {
      "phone_number" : "2145551234"
  },
  "zip_code" : "75235"
}

I would like to group by the phone number, but can't find a way to support it.  The phone number is not available as a non-array object, and the site does not support adding it to the group by via its GUI.
Trying something like the following causes an error stating all GROUP BY arguments must be column names:
$select=hospital_name%2Cphone_number&$group=hospital_name%2Cphone_number.phone_numer

Thanks in advance!


text:
Q: PHPExcel - No content in my excel file I try to export a list of timesheets in an Excel file but anything appear when I open my Excel file. Excel display this message :
"Désolé... Nous avons trouvé un problème dans le contenu de "test_export.xlsx", mais nous pouvons essayer de récupérer le maximum de contenu. Si la source de ce classeur est fiable, cliquez sur Oui."
If I click on yes, my spreadsheet is empty.
Here is my code in my TimesheetController :
public function exportAction()
{

    $request = $this->getRequest();
    $em = $this->getServiceLocator()->get('Doctrine\ORM\EntityManager');
    $timesheetsArray = array();
    $timesheetsObject = array();

    if($request->isPost())
    {

        $data = $request->getPost();
        foreach($data['rows'] as $id)
        {
            $timesheetsObject[] = $em->getRepository($this->repositoryName)->find($id);
        }
        foreach($timesheetsObject as $object){
            $object->setIdFiche((string)$object->getIdFiche());
            $object->setEvaUser((string)$object->getEvaUser());
            $object->setId((string)$object->getId());
            $object->setProject((string)$object->getProject());
            $object->setUser((string)$object->getUser());
            $object->setEstimatedTime((string)$object->getEstimatedTime());
            $object->setTimeSpend((string)$object->getTimeSpend());
            $object->setStartDate($object->getStartDate()->format('Y-m-d H:i:s'));
            $object->setEndDate($object->getEndDate()->format('Y-m-d H:i:s'));
            $timesheetsArray[] = $object->getArrayCopy();
        }

    }

    $export = new Export\ExportExcel();
    $export->export($timesheetsArray);

    return new ViewModel(array(
        'export' => $export
    ));

}

And here is my ExportExcel class :
class ExportExcel {

public function __construct(){

}

function export($timesheets)
{
    /** Error reporting */
    error_reporting(E_ALL);
    ini_set('display_errors', TRUE);
    ini_set('display_startup_errors', TRUE);
    date_default_timezone_set('Europe/London');

    $workbook = new \PHPExcel();
    $workbook->createSheet();
    $workbook->getActiveSheet()->fromArray($timesheets, NULL, 'A2');

    // Redirect output to a client's web browser (Excel2007)
    header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
    header('Content-Disposition: attachment;filename="test_export.xlsx"');
    header('Cache-Control: max-age=0');
    // If you're serving to IE 9, then the following may be needed
    header('Cache-Control: max-age=1');

    // If you're serving to IE over SSL, then the following may be needed
    header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
    header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
    header ('Pragma: public'); // HTTP/1.0

    $objWriter = \PHPExcel_IOFactory::createWriter($workbook, 'Excel2007');
    $objWriter->save('php://output');
}

}

I work with PHP, ZendFramework and DoctrineORM.
Have you a solution for me ?
Thanks !
And sorry if my english is not good.

A: So I found where the second call was. But if I remove this, there are not save of my Excel file because my Export button don't go to the export view.
Have you a solution ?

A: Bug found : actually, there was a double call of the function and between those two calls the isPost() was reset to 'false' so the condition wasn't true at the second call. That's why the Excel array was empty at the end.


text:
Q: how to read nested elements using Linq to xml I am trying to read the nested elements in the xml below. So far I have been able to read data in chantier/data element, but now the problem lies in how can I read the data inside <questions><sitePreparation> and <ctm>? Xml file and code have been shorted a bit because they are too long. Any help is much appreciated.
<?xml version="1.0" encoding="UTF-8"?>
<Audit>
    <controls>
        <guid>
           0001
        </guid>
        <templateVersion>
                    1.0
        </templateVersion>
    </controls>
    <chantier>
        <data>
            <V2>V2</V2>
            <V3>V3</V3>
            <V3_1>V3_1</V3_1>
            <V4>V4</V4>
            <oresTiersPanel>
                <S1_2>S1_2</S1_2>
            </oresTiersPanel>
            <agentsTiersPanel>
                <S1_2_2>S1_2_2</S1_2_2>
            </agentsTiersPanel>
        </data>
        <questions>
            <sitePreparation>
                <P1_Question>P1_Q</P1_Question>
                <P6_Question>P6_Q</P6_Question>
            </sitePreparation>
            <ctm>
                <C1_Question>C1_Q</C1_Question>
                <C2_Question>C2_Q</C2_Question>
                <C2_1>C2_1</C2_1>
            </ctm>
        </questions>
    </chantier>
</Audit>

private static void ReadXml()
{
    XDocument xdoc = XDocument.Load("sipp.xml");

    if (xdoc.Root != null)
    {
        var chantier = from ch in xdoc.Root.Elements("chantier").Elements("data")
                       let agentsTiersPanel = ch.Element("agentsTiersPanel")
                       where agentsTiersPanel != null
                       select new
            {
                v2 = (string)ch.Element("V2"),
                v3 = (string)ch.Element("V3"),
                v3_1 = (string)ch.Element("V3_1"),
                v4 = (string)ch.Element("V4"),
                S1_2_2 = (string)agentsTiersPanel.Element("S1_2_2"),
                S1_2_2_1 = (string)agentsTiersPanel.Element("S1_2_2_1"),
                S1_2_3 = (string)agentsTiersPanel.Element("S1_2_3"),
                S3 = (string)ch.Element("S3"),
               S3_1 = (string)ch.Element("S3_1"),
                P1_Question = (string)ch.Element("P1_Question")
            };

        foreach (var item in chantier)
        {
            Console.WriteLine(item.v2 + " " + item.v3);
        }
    }
}

A: Sample of reading questions elements:
var questions = xdoc.Root.Elements("chantier")
                    .Elements("questions").FirstOrDefault();

if (questions != null)
{
    var sitePreparation = questions.Element("sitePreparation");
    if (sitePreparation != null)
    {
        Console.WriteLine((string)sitePreparation.Element("P1_Question"));
        Console.WriteLine((string)sitePreparation.Element("P6_Question"));
    }
}

If you want return P1 and P6 questions as part of your anonymous object, then keep in mind, that ch is a data element of chantier, not chantier element itself. That's why ch.Element("P1_Question") returns null. With skipping null elements query should look like:
var chantiers =
   from chantier in xdoc.Root.Elements("chantier")
   let data = chantier.Element("data")
   let questions = chantier.Element("questions")
   where data != null && questions != null
   select new {
      V2 = (string)data.Element("V2"),
      V3 = (string)data.Element("V3"),
      V3_1 = (string)data.Element("V3_1"),
      V4 = (string)data.Element("V4"),
      S1_2_2 = (string)data.Element("agentsTiersPanel").Element("S1_2_2"),
      P1_Question = (string)questions.Element("sitePreparation")
                                     .Element("P1_Question")
   };

Output:
[
  {
     V2: "V2",
     V3: "V3",
     V3_1: "V3_1",
     V4: "V4",
     S1_2_2: "S1_2_2",
     P1_Question: "P1_Q"
  }
]

A: It might be easier to deserialize it into an object. You can use the Paste special feature within VS to get a class representation of your XML structure. From there, it is pretty straightforward as far as deserialization goes:
private Audit GetAuditNodes()
{
    Audit audit = null;
    XmlSerializer serializer = new XmlSerializer(typeof(Audit));
    string uri = "data.xml";

    try
    {
        XmlReaderSettings settings = new XmlReaderSettings();
        settings.CheckCharacters = false;
        settings.CloseInput = true;
        settings.DtdProcessing = DtdProcessing.Ignore;
        settings.IgnoreComments = true;
        settings.IgnoreWhitespace = true;

        using (XmlReader reader = XmlReader.Create(uri, settings))
        {
            audit = (Audit)serializer.Deserialize(reader);
        }
    }
    catch (Exception exc)
    {
         //log an error or something
    }

    return audit;
}

You have much cleaner code and can also work with a strongly typed object


text:
Q: Arctangents of odd powers of the golden ratio While trying to answer this MSE question, I found that arctangents of many odd powers of the golden ratio $\varphi=\frac{1+\sqrt5}2$ are expressible as rational linear combinations of arctangents of positive integers:
$$\begin{align}
\arctan\varphi&=2\arctan1-\frac12\,\arctan2\\
\arctan\varphi^3&=\arctan1+\frac12\,\arctan2\\
\arctan\varphi^5&=4\arctan1-\frac32\,\arctan2\\
\arctan\varphi^7&=3\arctan1+\frac12\,\arctan2-\arctan5\\
\arctan\varphi^9&=\arctan1-\frac12\,\arctan2+\arctan4\\
\arctan\varphi^{11}&=5\arctan1+\frac12\,\arctan2-\arctan5-\arctan34\\
\arctan\varphi^{13}&=3\arctan1-\frac12\,\arctan2+\arctan4-\arctan89\\
\arctan\varphi^{15}&=-2\arctan1+\frac32\,\arctan2+\arctan11
\end{align}$$
I was not able to find such a representation for $\arctan\varphi^{17}$ though.

Question 1. Can we prove that it does not exist?

I also could not find such a representation for any positive even power.

Question 2. Can we prove that it does not exist for any positive even power?

Question 3. Is there a simple way to determine if such a representation exists for a given power?

A: Q1, Q2: Such a representation exists for all odd powers of $\varphi$ as we can show by induction. Using the arctangent identity, let us first write:
$\arctan \varphi^{2n+1} = \arctan\frac{\varphi^{2n+1}+v}{1-\varphi^{2n+1}v} - \arctan v$
Next, we set the argument $\frac{\varphi^{2n+1}+v}{1-\varphi^{2n+1}v}$ equal to $\varphi^{2n-1}$ in order to set up an induction and solve for $v$. After moving terms around and simplifying via identities involving $\varphi$, we end up with $v = \frac{\varphi^{2n-1}-\varphi^{2n+1}}{1+\varphi^{4n}} = -\frac{1}{L_{2n}}$ where $L_n$ is the $n^{th}$ Lucas number. As $\arctan\left(-\frac{1}{x}\right) = -(2\arctan 1-\arctan x)$, this proves the claim for odd powers of $\varphi$.
Q3: For even powers if we set up the analogous equation:
$\arctan \varphi^{2n} = \arctan\frac{\varphi^{2n}+v}{1-\varphi^{2n}v} - \arctan v$
However in this case, setting $\frac{\varphi^{2n}+v}{1-\varphi^{2n}v} = \varphi^{2n-2}$ and solving for $v$ gives $v=\frac{-1}{F_{2n-1}\sqrt{5}}$. This implies there cannot be a rational expression for $\arctan\varphi^{2n}$ in terms of $\arctan\varphi^{2n-2}$ and arctangents of integers for, if there were such an expression, the arctangent identity could then be applied to these terms to express $\frac{-1}{F_{2n-1}\sqrt{5}}$ as a rational number. Similar problems with $\sqrt{5}$ appearing in the expression for $v$ occur if we try setting the argument $\frac{\varphi^{2n}+v}{1-\varphi^{2n}v} = \varphi^k$ for other powers $k$ such as $k=2n-1$, so if any $\arctan \varphi^{2n}$ happen to be rational combinations of arctangents of integers, such expressions ought to be unrelated to one another unlike the situation for odd powers.
As a side note, this difference between the even and odd powers reminds me of the situation of values of the $\zeta$ function at integers where the $\zeta(2n)$ have simple closed form expressions while it is unknown if any $\zeta(2n+1)$ have a closed form expression. Perhaps someone with more familiarity of $\zeta$ values can comment on whether we might expect such similar behavior here.

A: It may be helpful to transform this from a problem involving tangents to one involving complex exponentials.  Note that $\exp(2 i \arctan(x)) = \dfrac{i-x}{i+x}$.  Thus an identity $2 \arctan(x) = \sum k_j \arctan(x_j)$ for integers $k_j$ implies
$$ \left(\dfrac{i-x}{i+x}\right)^2 = \prod_j \left( \dfrac{i-x_j}{i+x_j} \right)^{k_j} \tag{1}$$
Conversely, (1) implies
$2 \arctan(x) = \sum_{j} k_j \arctan(x_j) + n \pi$ for some integer $n$.
Thus to have an identity for $2 \arctan(x)$ as an integer linear combination
of $\arctan(x_j)$ (with $x_1 = 1$ to take care of the $n\pi$), we need $((i-x)/(i+x))^2$ to be in the group generated by $((i-x_j)/(i+x_j))$.
In the case at hand, for odd $n$ I get
$$ \left( \dfrac{i - \phi^n}{i+\phi^n}\right)^2 = \dfrac{L_{2n} - 6 - 4 i L_n}{L_{2n}+2}  = \dfrac{i+2}{i-2} \prod_{k=1}^{(n-1)/2} \left(\dfrac{i+L_{2k}}{i-L_{2k}}\right)^2$$
(I admit I might not have found these formulas without seeing Pakk's comment to ARupinski's answer).
 For even $n$, on the other hand, I get
$$\left(\dfrac{i-\phi^n}{i+\phi^n}\right)^2 = \dfrac{L_{2n} - 6 - 4 i \sqrt{5} F_n}{L_{2n}+2}$$
and clearly you need some factors involving $\sqrt{5}$ to have any hope.


text:
Q: Why is Ninja-ide unable to see the installed version of sip? am trying to install and run Ninja-ide.  I have followed the instructions in the documentation here
I move to the Ninja-ide folder and run the suggested command:
$ python ninja-ide.py

and get the following:
XXXX-XXXX-MacBook-Pro:ninja-ide twmeggs$ python ninja-ide.py
Traceback (most recent call last):
  File "ninja-ide.py", line 26, in <module>
    import ninja_ide
  File "/Users/XXXX/ninja-ide/ninja_ide/__init__.py", line 48, in <module>
import sip
ImportError: No module named sip

so I try to re-install sip with:
XXXX-XXXX-MacBook-Pro:ninja-ide $ brew install sip

only to be told that it's already installed:
Error: sip-4.13.3 already installed

Now, I will hold my hands up here and say that I'm only just getting used to using a shell to execute commands and only just getting used to the files/directory/folder layouts within a Mac, so it's completely possible that I've messed up something simple here.
If someone could offer some help, or even a nudge in the right direction it would be much appreciated.
Thanks

A: Thanks for the thought seumas - I didn't have to do that in the end.
Turns out that although I'd downloaded and unzipped sip I hadn't installed it correctly.  I needed to run:
$ python configure.py
$ make
$ make install

from the sip folder
Once I'd done that I had to repeat the same for the PyQt package.  Having done that I could then launch Ninja-ide from the shell with no problems.

A: Sounds like you could have two different versions of python, try running:
brew doctor

It will tell you what duplicates exist, if you installed python via brew try editing your path to place usr/local/bin before usr/bin as described here
python homebrew by default


text:
Q: Printing cursor and exception values (both won't work) I wrote a question days ago and I finally managed to find the solution, but I have one more question now. A DBMS.OUTPUT_PUT.LINE message must be shown when introducing the name of a continent and, if that name is not on the database, an error will be shown. My problem here is that the correct message appears, but the error message won't. What could it be? Thanks in advance! As I said on my last question, some names are written in Spanish since my teacher want us to, but they can be easily understood.
DECLARE
  no_existe EXCEPTION;
  variable number;
  CURSOR listado_paises is
    SELECT *
      FROM paises
     WHERE paises.cod_continente in
           (select cod_continente
              FROM continentes
             WHERE nombre = '&escribe_nombre_cont');
BEGIN
  FOR i in listado_paises
  LOOP
    UPDATE paises
       SET visualizado = 'Si'
     WHERE cod_continente = i.cod_continente;

    SELECT count(*)
      into variable
      FROM paises
     WHERE paises.cod_continente in
           (select cod_continente
              FROM continentes
             WHERE nombre = '&escribe_nombre_cont');

    IF variable = 0 THEN RAISE no_existe; END IF;
    DBMS_OUTPUT.PUT_LINE('Nombre pais: ' || i.nombre);
    COMMIT;
  END LOOP;
 EXCEPTION
  WHEN no_existe THEN
       DBMS_OUTPUT.PUT_LINE('El continente no existe, por favor, revise el nombre');
END;

This code if working fine, it's just that the second message won't show up!

A: You aren't seeing the message because you're obtaining and checking variable within the cursor loop; but if the value doesn't exist then the cursor query finds no rows and you don't go inside loop in the first place, so you never reach the count query.
Move the check to before the loop:
...
BEGIN

    SELECT count (*) into variable
    FROM paises
    WHERE paises.cod_continente in
    (select cod_continente FROM continentes WHERE nombre = '&escribe_nombre_cont');

    IF variable = 0 THEN
        RAISE no_existe;
    END IF;

    for i in listado_paises loop
        UPDATE paises
        SET visualizado ='Si'
        WHERE cod_continente = i.cod_continente;

        DBMS_OUTPUT.PUT_LINE ('Nombre pais: ' || i.nombre);
        --COMMIT;
    END LOOP;
EXCEPTION
    WHEN no_existe THEN
        DBMS_OUTPUT.PUT_LINE ('El continente no existe, por favor, revise el nombre');
END;

Committing inside the loop looks wrong; if some other error is thrown then you'll have a mix of updated and not-updated rows. Better to treat as a single transaction and commit/rollback the whole thing.
Of course, you don't need to update each row one-by-one, you can do a single update; and don't really need PL/SQL. But presumably this approach is required by your assignment.


text:
Q: What can an ISP do to block IPSEC traffic? Every so often we encounter a problem where we cannot get an IPSEC VPN tunnel to work.  Sometimes we know the local authorities restrict use of IPSEC (e.g. Bangladesh), and have to get some kind of exemption.  Other times the ISP changes something and the connection drops (e.g. Haiti).
I assume there are a bunch of things that might prevent IPSEC from working.  For example, blocking UDP port 500 would prevent IKE.
Rather than looking for a resolution for a specific problem, can anyone give a list of what different things an ISP might do to block IPSEC traffic, either on purpose or by accident?
The answer to this question will be useful in troubleshooting, but also letting ISPs know what specific things they need to fix when we can't get our VPN up!

A: Drawing on Chapter 4 of IPsec Virtual Private Network Fundamentals the following architectural issues can disrupt IPsec traffic:

*

*Firewall not allowing required protocols

*

*ISAKMP (Port 500)

*ESP (IP Protocol 50)

*AH (IP Protocol 51)

*Firewall (or router) not handling fragmented IPsec packets, such as

*

*not replying to ICMP-Unreachable packets - breaking Path MTU Detection

Some of these things could result from an ISP introducing new equipment that by default does one of the above (blocking ICMP-Unreachable seems quite a likely default setting).  They may not realise they need to fix such problems in order to support their customers who use IPSEC - and it may not affect all their customers.

A: There's really not much we can do to answer this "question" -- they can block IKE, they can block L2TP/GRE/other tunneling protocols, they can block any packet that looks like it might be using ESP/AH, etc.
-- The exhaustive list of ways things can break is (usually) infinite: Without details of how your VPNs are set up and a specific breakage to troubleshoot it's nigh impossible to give you much more detail than the above, though I'm sure others can list specific breakages they've encountered and how they were resolved...


text:
Q: How to access the second last viewcontroller in a navigation controller? In my storyboard the User has to fill a form.
After that I push a new ViewController onto the navigation stack.
If I now want to change things onto the second last ViewController I need to access it via the navigation stack (I guess). How do I gain access to it?
I use this function to get back to the last ViewController, but before I go back I wish to manipulate some labels.
- (IBAction)btnBackTapped:(id)sender {
    //magic to manipulate labels on the secound last VC ...
    [self.navigationController popViewControllerAnimated:true];
}

any ideas?

A: Here is code that will take you to your desired controller in navigation stack.
second last controller is at index 1.
UIViewController * VC = [self.navigationController.viewControllers objectAtIndex:1];


text:
Q: what's the difference between haazelcast Imap and ICache? I want to know when it's better to use Imap and when to use Icache.
There is a big ambuity to choose between both of them.
I know this question may be a duplicate of Difference in IMap and ICache in Hazelcast but is it possible to get more details on when to choose one of them.
Both interfaces have some common methods but the way to choose is very difficult.
Thanks

A: Do you want to query objects your cache? Do you want more efficiency oriented capabilities for example, pipelining and performing async map operations? Do you want more eviction policies even custom ones? Would you rather send your processing to the cache rather than being limited to shuffle data back and forth? Yes to any of these, then use Hazelcast Maps.


text:
Q: Pass props in Vue Router with multiple components I'm trying to pass a prop to a component in the router if on a specific route.
All the tutorial found only use one component so the prop can simple be appended to the list.
But with multiple components it doesnt work.
name: "Room",
  components: {
    navbar: TitleRooms,
    content: Room,
    props: {
        title: "message"
      }
  }

I tried this, but it simply does nothing.
name: "Room",
  components: {
    navbar: {
      TitleRooms,
      props: {
        title: "message"
      }
    },
    content: Room
  }

I also tried this one, but it also doesn't work.
Is there an option to do this properly with multiple nested named router-views?

A: As far as I can tell you're trying to do this:
name: "Room",
components: {
  navbar: TitleRooms,
  content: Room
},
props: {
  navbar: {
    title: "message"
  },
  content: false
}

This should pass the value "message" for the proptitletoTitleRooms. It won't pass any props toRoom. If you want to pass props to both components you can just change thefalse` to an appropriate object containing the props you want.

A: Actually your route renders Room component, so this one receives params. Of course Navbar can receive its props, but you should do it via template. Do:
<navbar :title="title" />

Which binds this.title in Room component (from route param) to Navbar


text:
Q: Print only the name of variable with the class factor I have the data set in which some are factors as well some are numerical/integer, so what should be the command to return only the name of factor class.
aa bb cc dd
1  12 P  43
4  23 Q  78
8  34 Q  89
9  86 P  78
7  67 P  98
9  76 Q  74

So, now if I want to print only the name of variable with the class factor, i.e. cc, so what should be my R command?
Thanks in advance

A: You can do:
names(Filter(is.factor, data))

This also is a little longer but might be using less memory:
names(data)[sapply(data, is.factor)]


text:
Q: JQ Change column values I have a table with 3 columns and some values in them, and I need to make some selector which can change value of "price" between the price with tax and without (in Czech rep. it is 21% now).
Table looks like this:

<colgroup><col></colgroup>

    ...
    ...
    Price

    Price of thing
    how long
    4PRICE

    .
    .
    .
    .

And for selector use something like:
With ax/Without tax

link to table

A: Just to help you a little bit to start here is a jsfiddle which gives you a idea how you can start your Problem
HTML

        Product
        Price (€)

        Apple
        10

        Banana
        5

        Orange
        12

<button class="tax">switch tax</button>

JS
var tax = "1.2" //20%
$(document).ready(function () {
    $(".tax").click(function () {
        if ($(".priceheader").attr("data-taxstate") == "n") {
            $(".price").each(function () {
                $(this).html(parseFloat($(this).html()) * tax);
            });
            $(".priceheader").attr("data-taxstate", "y");
        } else {
            $(".price").each(function () {
                $(this).html(parseFloat($(this).html()) / tax);
            });
            $(".priceheader").attr("data-taxstate", "n");
        }
    });
});

But this is just a start. You have to round the right way, and also you have to make it then sure, that there is no single value where switching will change its value.
Next steps
This is just a start of what you are looking for. You have to round your values and there are also much more beautiful ways to solve that, depending what you try to get :)
Better would be perhaps to calculate the tax value, but save the original value in a data-* attribute and don't calculate back.
Hope this helps you!


text:
Q: In topological groups. Is every neighborhood of $e$ supset of a neighborhood subgroup? Let $G$ be a topological group, $U$ is a neighborhood of $e$ which is the unit element of $G$.
My question is does there exist a neighborhood $H \subseteq U$ of $e$ s.t.

*

*$H$ is a subgroup of $G$?

*$H$ is a normal subgroup of $G$?

If 1 is true, then it seems can be concluded that there is a symmetric neighborhood $H$ of $e$ such that $H \cdot H \subseteq U$.
Update:
Unfortunately I have found both 1 and 2 are falsifiable, e.g. $U=(e^{-i\frac{\pi}{6}},e^{i\frac{\pi}{6}})$ in $S^1$

A: Yes; let $H = e$.
To see that the answer is no to all of your questions in general if $H$ is required to be nontrivial, let $G = S^1$. I don't understand what you mean by "topological subgroup." Every subgroup automatically inherits the subspace topology and is a topological group with respect to this topology.


text:
Q: The sinc function strikes again Recall $\text{sinc}(x)=\frac{\sin x}x$. It's a familiar exercise that $\int_0^{\infty}\text{sinc}(x)\,dx=\frac{\pi}2$.
But, at present, I wish to ask about the following claim on a "sinc-ing" product which is supported by extensive numerical computations.

Question. Is it true that
  $$\int_0^{\infty}dx\prod_{n=1}^{\infty}\text{sinc}\left(\frac{x}{2n-1}\right)
=2\int_0^{\infty}dx\prod_{n=1}^{\infty}\cos\left(\frac{x}n\right)\,\,?$$

A: We can start with a substitution $x=2y$
$$\int_0^{\infty}dx\prod_{n=1}^{\infty}\text{sinc}\left(\frac{x}{2n-1}\right)=2\int_0^{\infty}dy\prod_{n=1}^{\infty}\text{sinc}\left(\frac{2y}{2n-1}\right).$$
Now the double angle formula
$$\text{sinc}(2a)= \text{sinc}\left(a\right)\cos(a)$$
can be iterated to arrive to the familiar formula for $\text{sinc}$
$$\text{sinc}(2a)=\prod_{i=0}^{\infty}\cos\left(\frac{a}{2^i}\right).$$
This means that
$$\prod_{n=1}^{\infty}\text{sinc}\left(\frac{2y}{2n-1}\right)=\prod_{m= 1}^{\infty}\cos\left(\frac{y}{m}\right)$$
because every $m\in \mathbb N$ can uniquely be written as $2^i(2n-1)$ for some $i\geq 0$ and $n\geq 1$. And this, in turn, proves the integral identity.


text:
Q: Spring hibernate: org.hibernate.exception.SQLGrammarException My DAO layer code is as follows:
package com.app.dao;
import javax.annotation.Resource;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;
import com.app.pojo.InterviewerPojo;

@Repository("interviewer_details_dao")
public class InterviewerDetailsDaoImpl implements InterviewerDetailsDao {

    @Resource(name="sessionFactory")
    private SessionFactory factory;
    /*private HibernateTemplate template;
    public void setSessionFactory(){
        template = new HibernateTemplate(factory);
    }*/
    /*private HibernateTemplate template = new HibernateTemplate(sessionFactory);*/
    @Override
    public void saveInterviewDetails(InterviewerPojo interviewerPojo) {

/*      Session sess = factory.getCurrentSession();
        try{
            sess.getTransaction().wasCommitted();
        Transaction trans = sess.beginTransaction();
        System.out.println("a");
        sess.saveOrUpdate(interviewerPojo);
        sess.getTransaction().commit();}
        catch(Exception e){
            throw e;
        }*/
        System.out.println("b");
        factory.getCurrentSession().save(interviewerPojo);
    /*  System.out.println(interviewerPojo);
        template.saveOrUpdate(interviewerPojo);
        System.out.println("b");*/

        System.out.println("done");

    }

}

the same code as above was running if i am getting the values from database as follows
sessionFactory.getCurrentSession().createQuery("select m from emp m).list;
But as I writing another page to insert values then it is having problem
*As you can see i used same concept, I populated MODEL(POJO) class by another MODEL(pojo) which i have taken from database by above query*
and now debugging goes upto "template.saveOrUpdate" and throws exception as follows

org.hibernate.exception.SQLGrammarException: You have an error in your
  SQL syntax; check the manual that corresponds to your MySQL server
  version for the right syntax to use near 'value for
  hibernate_sequence' at line 1     at
  org.hibernate.exception.internal.SQLStateConverter.convert(SQLStateConverter.java:100)
    at
  org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
    at
  org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
    at
  org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:129)
    at
  org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
    at $Proxy24.executeQuery(Unknown Source)    at
  org.hibernate.id.SequenceGenerator.generateHolder(SequenceGenerator.java:112)
    at
  org.hibernate.id.SequenceHiLoGenerator$1.getNextValue(SequenceHiLoGenerator.java:85)
    at
  org.hibernate.id.enhanced.OptimizerFactory$LegacyHiLoAlgorithmOptimizer.generate(OptimizerFactory.java:350)
    at
  org.hibernate.id.SequenceHiLoGenerator.generate(SequenceHiLoGenerator.java:82)
    at
  org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:120)
    at
  org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:204)
    at
  org.hibernate.event.internal.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:55)
    at
  org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:189)
    at
  org.hibernate.event.internal.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:49)
    at
  org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:90)
    at org.hibernate.internal.SessionImpl.fireSave(SessionImpl.java:642)
    at org.hibernate.internal.SessionImpl.save(SessionImpl.java:635)    at
  org.hibernate.internal.SessionImpl.save(SessionImpl.java:631)     at
  com.app.dao.InterviewerDetailsDaoImpl.saveInterviewDetails(InterviewerDetailsDaoImpl.java:40)
    at
  com.app.service.SaveInterviewerDetailsServiceImpl.saveDetails(SaveInterviewerDetailsServiceImpl.java:25)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at
  sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)   at
  sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)   at
  java.lang.reflect.Method.invoke(Unknown Source)   at
  org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
    at
  org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
    at
  org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    at
  org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
    at
  org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at
  org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    at $Proxy19.saveDetails(Unknown Source)     at
  com.app.controllers.EmployeePromoteController.validateDetails(EmployeePromoteController.java:67)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at
  sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)   at
  sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)   at
  java.lang.reflect.Method.invoke(Unknown Source)   at
  org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
    at
  org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
    at
  org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
    at
  org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
    at
  org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
    at
  org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
    at
  org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
    at
  org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
    at
  org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
    at
  org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)     at
  javax.servlet.http.HttpServlet.service(HttpServlet.java:728)  at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at
  org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at
  org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at
  org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at
  org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at
  org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at
  org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:931)
    at
  org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at
  org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at
  org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
    at
  org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    at
  org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source) Caused by:
  com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an
  error in your SQL syntax; check the manual that corresponds to your
  MySQL server version for the right syntax to use near 'value for
  hibernate_sequence' at line 1     at
  sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown
  Source)   at
  sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
  Source)   at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)     at
  com.mysql.jdbc.Util.getInstance(Util.java:382)    at
  com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052)    at
  com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3593)    at
  com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3525)    at
  com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1986)     at
  com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2140)  at
  com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2626)   at
  com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2111)
    at
  com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2273)
    at
  org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
    at
  org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at
  sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)   at
  sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)   at
  java.lang.reflect.Method.invoke(Unknown Source)   at
  org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122)
    ... 61 more

POJO source code:
package com.app.pojo;
import java.io.Serializable;
import javax.persistence.*;

@SuppressWarnings("serial")
@Entity @Table(name="interviewer")
public class InterviewerPojo implements Serializable {
    private int eid;

    private int vid;

    @Id @GeneratedValue(strategy=GenerationType.SEQUENCE)
    private int i_eid;

    private String i_name;

    private String password;

    public int getEid() {
        return eid;
    }

    public void setEid(int eid) {
        this.eid = eid;
    }
}

Hibernate config:
<property name="hibernateProperties">
    <props>
        <prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
        <prop key="hibernate.formatsql">true</prop>
        <prop key="hibernate.showsql">true</prop>
        <prop key="hibernate.hbm2ddl.auto">validate</prop>
    </props>
</property>

A: In your error log, it showed that you're using MySQL. However, you configured Hibernate dialect was HSQLDialect.

org.hibernate.dialect.HSQLDialect

You should remove this dialect property, Hibernate can automatically detect the right dialect through JDBC driver. Or you modify to the correct dialect on your own.


text:
Q: Anchor Tag's On Click Event is Firing, but Default is not I have an anchor tag wrapped around a radio input. When I click on them, the radio button gets checked, but the anchor tag does not do anything.

  <input type="radio" />

I tried adding an onclick handler to the anchor tag to see if it was being clicked and it worked as expected:

  <input type="radio" />

This also showed me that the anchor tag was being clicked twice so I added event.stopPropagation to the input tag:

  <input onclick="event.stopPropagation();" type="radio" />

A: It's invalid html5. Per the spec, the content model of the a element states that it can not have interactive content a descendant. A non-hidden input is interactive content.


text:
Q: Convert into format YYYY-MM-DD I want this gmt time into YYYY-MM-DD format but i went through the procedure it give parse exception error.
I want to convert this String type of Fri Apr 08 2016 00:00:00 GMT+0530 (IST) into date format so that i can insert into my mqysql data base.

A: If you want to get "YYYY-MM-DD" formate of mysql date format this code could help.
        DateTimeFormatter dateTimeFormatter=DateTimeFormatter.ofPattern("YYYY-MM-dd");
        DateTimeFormatter formatter=DateTimeFormatter.ofPattern("EEE MMM dd yyyy hh:mm:ss zZ (z)");
        TemporalAccessor parse = formatter.parse("Fri Apr 08 2016 00:00:00 GMT+0530 (IST)");
        LocalDate localDate=LocalDate.from(parse);
        String formated= dateTimeFormatter.format(localDate);

        System.out.println("formated:"+formated);


text:
Q: Cannot make a generic item in Kotlin I want to make the following line of code generic:
val newItem: Item = documentChange.document.toObject<Item>(Item::class.java)

Works fine. However, when I try to make it generic:
val addedItem: T = documentChange.document.toObject<T>(T::class.java)

Android Studio is complaining:

Cannot use 'T' as reified type parameter. Use a class instead.

Screenshot
How can I make it generic?

A: You need to make a function inline and add reified keyword to the generic parameter:
inline fun <reified T> someFun() {
    //...
    val addedItem: T = documentChange.document.toObject<T>(T::class.java)
}

A: Here is a code for getting the document in a generic way
    inline fun <reified T> getDocumentItemByName(directory: String, crossinline returnResult: (result : T) -> Unit) {

        firestore.collection(directory).get()
            .addOnSuccessListener {
                OnSuccessListener<QueryDocumentSnapshot> { documentSnapshot ->

                    var entity = documentSnapshot.toObject<T>(T::class.java)
                    returnResult(entity)

                }
            }
            .addOnFailureListener { exception ->
                Log.w(TAG, "Error getting documents: ", exception)
            }
    }


text:
Q: Do I need to include jQuery core alongside jQuery mobile? Is it necessary to include the core of jQuery, or is the mobile framework sufficient alone?
From what I`ve tried, I concluded that both files are necessary, but I would like to be sure on this issue.

A: http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.js
Based on the code, it doesn't redefine jQuery but extends it so yes, you need the core.
(function( jQuery, window, undefined ) {

})( jQuery, this );

It passes the jQuery object when defining jQuery.mobile. See the demo which includes core before mobile.

A: The docs give you all the information you need to know:

A jQuery Mobile site must start with an HTML5 'doctype' to take full advantage of all of the framework's features. (Older devices with browsers that don't understand HTML5 will safely ignore the 'doctype' and various custom attributes.) In the 'head', references to jQuery, jQuery Mobile and the mobile theme CSS are all required to start things off.

In short, yes, jQuery core is required.


text:
Q: How linux installation process works can anyone explain me how Linux installation process works?
With Windows, installation process starts with Windows Setup. It's a program that installs Windows. Setup starts and restarts a computer, collects informations, copies files, and applies settings.
What is for Linux like Setup for Windows, and are there any major differences between installation process of Linux and Windows?
Thanks in advance!

A: The Linux installation is very similar to the Windows one, except for a few things:

*

*Linux installation starts by booting from an external device (CD/DVD, USB Drive, ...), when Windows installation usually starts by booting a CD, or from the hard drive of a new PC.

*The Linux installation also has a step of collecting information, and copying files. A big difference is that the user has a little more control on the way to install the system on Linux than on Windows. For example, experiences users can choose how organize the disk partitions (Swap, /home, etc...).

*Also a big difference is that Linux installation usually allows to choose which software you want to install. The choice can often be done by groups, or individually.

*The post installation step provides the way to choose the root password, and eventually create new users.

I think that in general, the Linux installation allows more options and control than the Windows one.

A: Xavier posted a good summary of the overall process, for a Red Hat (Fedora/CentOS) distribution.  With Ubuntu (and flavours), you tend not to get options regarding which software packages to install (you can install those later).
Additionally, there is no root account setup.  Ubuntu uses sudo by default and leaves the root password unset.  So the difference between Red Hat and Ubuntu in this instance is that Ubuntu has you set up a user account that will have sudo access which allows you to do root things, or fully activate the root account if you choose.
I haven't used any other distributions in any depth, so I cannot comment on how their installation process may differ.


text:
Q: What is the difference in how you would have to access these two PHP arrays? I have two PHP arrays in a section of a website I'm building for a class. One contains data that I created with a simple foobar array bit, and the other is created from a fetchAll() PDO call. I can't access the PDO array's element for some reason, so I created a sample array and called var_export() on both arrays to see if there were any differences. Here is the code:
if ($dao->userExistsLogin($_POST["email"], $_POST["password"]))
{
    $useremail = $_POST["email"];
    $_SESSION["authenticated"] = "true";
    $logger->LogDebug("email from post array in login handler: " . $_POST["email"]);
    $user_results = $dao->getIDFromEmail($useremail);
    $logger->LogDebug(print_r($user_results, true));
    $array = [
        "foo" => "bar",
        "bar" => "foo",
    ];
    $logger->LogDebug(var_export($array, true));
    $logger->LogDebug(var_export($user_results, true));
    $logger->LogDebug(gettype($user_results));
    $_SESSION['user_id'] = $user_results['id'];
    header("Location: http://localhost/WIWO/user_account.php");
}

The GetIDFromEmail function is here:
    public function getIDFromEmail($email)
    {
        $conn = $this->getConnection();
        $getIDFromEmailQuery = "SELECT * FROM user WHERE email=:email";
        $query = $conn->prepare($getIDFromEmailQuery);
        $query->bindParam(":email", $email);
        $query->execute();
        $result = $query->fetchAll(PDO::FETCH_ASSOC);
        $this->logger->LogDebug(print_r($result, true));
        return $result;
    }

And here's what's in my logger from the var_export() commands:
2020-10-31 17:57:10 - DEBUG --> array (
  'foo' => 'bar',
  'bar' => 'foo',
)
2020-10-31 17:57:10 - DEBUG --> array (
  0 =>
  array (
    'id' => '251',
    'email' => 'heck',
    'institution' => 'heck',
    'access' => '1',
  ),
)

Why can I not access the second array at $_SESSION['user_id'] = $user_results['id'];? For some reason that line totally fails to do anything. I know the session is started and correct because other variables stored in the SESSION superglobal are showing up correctly, but the user_id never gets set. Does it have something to do with "0 =>" showing up in the var_export() of the second array? I notice that doesn't show up in the first array - is the second array malformed or something?

A: You're using PDOStatement::fetchAll(), which will always return an array of rows. Instead you might want to use PDOStatement::fetch() which will return precisely one row.
I haven't seen the userExistsLogin() method, but you could probably simplify your code if you have that method return the user id on success, and something falsey (e.g. 0, FALSE or NULL) on error. This will not only reduce code complexity, but it will reduce database load as well.


text:
Q: Customer custom attribute not included in collection by default in edit account information I've created a custom customer attribute "Skype", for more detail you can visit here:-
http://nimb.ws/CrM0YF
I've displayed & saved(in the backend) successfully this attribute on the registration page.
but I want to add this attribute in customer edit account so that he can update this attribute.
Here is the path:-
app/design/frontend/Packagetheme/themename/Magento_Customer/templates/form/edit.phtml

            <?= $block->escapeHtml(__('Skype')) ?>

                <input type="text" name="skype"  id="skype" value="<?= $block->escapeHtmlAttr($block->getCustomer()->getSkype()) ?>" title="<?= $block->escapeHtmlAttr(__('Skype')) ?>" class="input-text" >

But I'm not able to set value using(in customer collection custom attributes not included so I'm not able to set this value):-
<?= $block->escapeHtmlAttr($block->getCustomer()->getSkype()) ?>

I also tried using object manager but didn't get success.
Here is My script:-
1-  CustomerSetup.php
<?php

namespace Test\Customerform\Setup;

use Magento\Eav\Model\Config;
use Magento\Eav\Model\Entity\Setup\Context;
use Magento\Eav\Setup\EavSetup;
use Magento\Framework\App\CacheInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\CollectionFactory;

class CustomerSetup extends EavSetup {

    protected $eavConfig;

    public function __construct(
        ModuleDataSetupInterface $setup,
        Context $context,
        CacheInterface $cache,
        CollectionFactory $attrGroupCollectionFactory,
        Config $eavConfig
        ) {
        $this -> eavConfig = $eavConfig;
        parent :: __construct($setup, $context, $cache, $attrGroupCollectionFactory);
    }

    public function installAttributes($customerSetup) {
        $this -> installCustomerAttributes($customerSetup);
        $this -> installCustomerAddressAttributes($customerSetup);
    }

    public function installCustomerAttributes($customerSetup) {

        $customerSetup -> addAttribute(\Magento\Customer\Model\Customer::ENTITY,
            'skype',
            [
            'label' => 'Skype',
            'system' => 0,
            'position' => 100,
            'sort_order' =>100,
            'visible' =>  true,
            'note' => '',

                        'type' => 'varchar',
                        'input' => 'text',

            ]
            );

        $customerSetup -> getEavConfig() -> getAttribute('customer', 'skype')->setData('is_user_defined',1)->setData('is_required',0)->setData('default_value','')->setData('used_in_forms', ['adminhtml_customer', 'checkout_register', 'customer_account_create', 'customer_account_edit', 'adminhtml_checkout']) -> save();

    }

    public function installCustomerAddressAttributes($customerSetup) {

    }

    public function getEavConfig() {
        return $this -> eavConfig;
    }
}

2- InstallData.php
<?php

namespace Test\Customerform\Setup;

use Magento\Eav\Setup\EavSetup;
use Magento\Eav\Setup\EavSetupFactory;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;

/**
 * @codeCoverageIgnore
 */
class InstallData implements InstallDataInterface
{
    /**
     * EAV setup factory
     *
     * @var EavSetupFactory
     */
    private $eavSetupFactory;

    /**
     * Init
     *
     * @param EavSetupFactory $eavSetupFactory
     */
    public function __construct(EavSetupFactory $eavSetupFactory)
    {
        $this->eavSetupFactory = $eavSetupFactory;
    }

    /**
     * {@inheritdoc}
     * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
     */
    public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {
        /** @var EavSetup $eavSetup */
        $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
        if (version_compare($context->getVersion(), '1.0.0') < 0){

                $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
                $customerSetup = $objectManager->create('Allin\Customerform\Setup\CustomerSetup');
                $customerSetup->installAttributes($customerSetup);

        }

    }
}

How can I achieve this?

A: Use below code in installer script of custom customer attributes :
$used_in_forms=array();
$used_in_forms[]="adminhtml_customer";
$used_in_forms[]="checkout_register";
$used_in_forms[]="customer_account_create";
$used_in_forms[]="customer_account_edit";
$used_in_forms[]="adminhtml_checkout";
$attribute->setData("used_in_forms", $used_in_forms)
            ->setData("is_used_for_customer_segment", true)
            ->setData("is_system", 0)
            ->setData("is_user_defined", 1)
            ->setData("is_visible", 1)
            ->setData("sort_order", 100);
    $attribute->save();

Hope this helps you !!!


text:
Q: IntelliJ IDEA 2017.3 cannot create new maven module? I have just updated my IntelliJ IDEA to 2017.3 but I cannot seem to insert new Maven module? When I try to insert it nothing happens at all. I have opened idea.txt log and found this:
2017-12-01 11:25:28,464 [ 551502]  ERROR - llij.ide.plugins.PluginManager - IntelliJ IDEA 2017.3  Build #IU-173.3727.127
2017-12-01 11:25:28,464 [ 551502]  ERROR - llij.ide.plugins.PluginManager - JDK: 1.8.0_152-release
2017-12-01 11:25:28,464 [ 551502]  ERROR - llij.ide.plugins.PluginManager - VM: OpenJDK 64-Bit Server VM
2017-12-01 11:25:28,464 [ 551502]  ERROR - llij.ide.plugins.PluginManager - Vendor: JetBrains s.r.o
2017-12-01 11:25:28,464 [ 551502]  ERROR - llij.ide.plugins.PluginManager - OS: Windows 10
2017-12-01 11:25:28,464 [ 551502]  ERROR - llij.ide.plugins.PluginManager - Last Action: NewModuleInGroup
2017-12-01 11:25:38,059 [ 561097]   INFO - ide.actions.ShowFilePathAction -
Exit code 1
2017-12-01 11:26:42,204 [ 625242]  ERROR - llij.ide.plugins.PluginManager - org/jetbrains/plugins/gradle/settings/GradleProjectSettings
java.lang.NoClassDefFoundError: org/jetbrains/plugins/gradle/settings/GradleProjectSettings
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at com.intellij.openapi.extensions.AbstractExtensionPointBean.findClass(AbstractExtensionPointBean.java:42)
    at com.intellij.openapi.extensions.AbstractExtensionPointBean.instantiate(AbstractExtensionPointBean.java:63)
    at com.intellij.ide.util.projectWizard.ModuleBuilderFactory.createBuilder(ModuleBuilderFactory.java:32)
    at com.intellij.ide.util.projectWizard.ModuleBuilder.getAllBuilders(ModuleBuilder.java:74)
    at com.intellij.ide.projectWizard.ProjectTypeStep.a(ProjectTypeStep.java:279)
    at com.intellij.ide.projectWizard.ProjectTypeStep.<init>(ProjectTypeStep.java:117)
    at com.intellij.ide.projectWizard.NewProjectWizard.init(NewProjectWizard.java:50)
    at com.intellij.ide.projectWizard.NewProjectWizard.<init>(NewProjectWizard.java:39)
    at com.intellij.openapi.roots.ui.configuration.actions.NewModuleAction.actionPerformed(NewModuleAction.java:58)
    at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.java:220)
    at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:237)
    at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.a(ActionMenuItem.java:321)
    at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:911)
    at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.runOnOwnContext(IdeFocusManagerImpl.java:136)
    at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.actionPerformed(ActionMenuItem.java:311)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
    at com.intellij.openapi.actionSystem.impl.ActionMenuItem.a(ActionMenuItem.java:130)
    at com.intellij.openapi.application.TransactionGuardImpl.a(TransactionGuardImpl.java:88)
    at com.intellij.openapi.application.TransactionGuardImpl.a(TransactionGuardImpl.java:111)
    at com.intellij.openapi.application.TransactionGuardImpl.submitTransaction(TransactionGuardImpl.java:120)
    at com.intellij.openapi.application.TransactionGuard.submitTransaction(TransactionGuard.java:122)
    at com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.java:130)
    at com.intellij.ui.plaf.beg.BegMenuItemUI.a(BegMenuItemUI.java:521)
    at com.intellij.ui.plaf.beg.BegMenuItemUI.access$300(BegMenuItemUI.java:48)
    at com.intellij.ui.plaf.beg.BegMenuItemUI$MyMouseInputHandler.mouseReleased(BegMenuItemUI.java:541)
    at java.awt.Component.processMouseEvent(Component.java:6541)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
    at java.awt.Component.processEvent(Component.java:6306)
    at java.awt.Container.processEvent(Container.java:2237)
    at java.awt.Component.dispatchEventImpl(Component.java:4897)
    at java.awt.Container.dispatchEventImpl(Container.java:2295)
    at java.awt.Component.dispatchEvent(Component.java:4719)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4889)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4526)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4467)
    at java.awt.Container.dispatchEventImpl(Container.java:2281)
    at java.awt.Window.dispatchEventImpl(Window.java:2746)
    at java.awt.Component.dispatchEvent(Component.java:4719)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:764)
    at java.awt.EventQueue.access$500(EventQueue.java:98)
    at java.awt.EventQueue$3.run(EventQueue.java:715)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
    at java.awt.EventQueue$4.run(EventQueue.java:737)
    at java.awt.EventQueue$4.run(EventQueue.java:735)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:734)
    at com.intellij.ide.IdeEventQueue.h(IdeEventQueue.java:822)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:646)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:366)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.ClassNotFoundException: org.jetbrains.plugins.gradle.settings.GradleProjectSettings PluginClassLoader[org.jetbrains.kotlin, 1.2.0-release-IJ2017.3-1] com.intellij.ide.plugins.cl.PluginClassLoader@6e1fc42d
    at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:63)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 61 more

It seems like there is an issue with Gradle classes missing, but I don't use Gradle at all in any of my projects. What should I do?

A: There was an issue with Kotlin plugin. Will be fixed with the soon version update. In the meantime the workaround is to either Enable Gradle plugin or disable Kotlin plugin.


text:
Q: How can i add non integer values as hours to a date in R for the length of an input vector The units are hrs. But i still have the same problem, because it doesn´t add all the values. This is the code i have.
initialdates<-function(randomvariable){
  date_0<-"2017-01-01 00:00:00"
  vector_dates<-c(date_0)
  for(i in length(randomvariable)){
    vector_dates<-append(vector_dates,as.POSIXct("2017-01-01 00:00:00")+sum(randomvariable[1:i]))
  }
  return(vector_dates)
}

initialdates(randomvariablegenerator(100))

The output I am getting is the following
"2017-01-01 00:00:00 cst"  "2017-01-01 00:03:47 cst"

Why I am not getting all of the other elements from the loop

A: You can convert date/time to POSIXct format and add number (including decimals) to it.
Keep in mind that when your add a number to POSIXct then its added as seconds.
The problem in above function:
initialdates<-function(randomvariable){
  date_0<-"2017-01-01 00:00:00"
  vector_dates<-c(as.POSIXct(date_0))  #Convert to date before adding to vector
  for(i in 1:length(randomvariable)){  #loop should go 1:length(randomvariable)
    vector_dates<-append(vector_dates,as.POSIXct("2017-01-01 00:00:00")+sum(randomvariable[1:i]))
  }
  return(vector_dates)
}
# Random generated as described in OP
randomvariablegenerator <- function(n){
  return (42*rbeta(n,.123,2.77))
}

# Test type of value function is returning. Test with n = 3 (small value)
ret_val <- initialdates(randomvariablegenerator(3))

#> str(ret_val)
# POSIXct[1:4], format: "2017-01-01 00:00:00" "2017-01-01 00:00:00" "2017-01-01 # 00:00:24" ...
# Returned value is in POSIXct format (date/time)
> as.POSIXct("2017-01-01 00:00:00") + 100  #100 is converted in 1 min
[1] "2017-01-01 00:01:40 GMT"   #100 is converted in 1 min, 40 seconds

> as.POSIXct("2017-01-01 00:00:00") + 600
[1] "2017-01-01 00:10:00 GMT"    #600 is converted in 6 min.

> as.POSIXct("2017-01-01 00:00:00") + 2 * 60 * 60
[1] "2017-01-01 02:00:00 GMT"     #2 hours has been added

> as.POSIXct("2017-01-01 00:00:00") + 2.5 * 60 * 60
[1] "2017-01-01 02:30:00 GMT"   #2 hours has been added

#You can even add decimal of seconds(up to millisecond accuracy) i.e
> a <- as.POSIXct("2017-01-01 00:00:00") + 10.6
> a
[1] "2017-01-01 00:00:10 GMT"    #Make a note that 0.6 sec is hidden part

> a <- a + 10.4   #add 10.4
> a
[1] "2017-01-01 00:00:21 GMT"  # 0.6 hidden part is added with 0.4 to make it 21


text:
Q: Is it different a SQL query inside of stored procedure than a SQL executed from PHP? Let me explain.
I used a large SELECT sentence with multiple joins inside my PHP code. It's big because some joins depends on some values from first tables (something like if table1.column_a=1 then alias_b=table2.column_a, if table1.column_a=2 then alias_b=table3.column_b, ...) and because I send condition from my html form which can be changed dynamically (sometimes it could just have some_date>='2017/09/01', but it could turn into something more complex like some_date>='2017/09/01' and (name like J%on not sec_name='Doe') ...").
I received the instruction of make a stored procedure for this query and for more time i take analyze this i can't find some way for make this query dynamic without putting it inside of string into the stored procedure and receiving the WHERE condition as stored procedure parametter (in the stored procedure i have somthing like SET @sql = CONCAT('SELECT ... JOIN ... JOIN... WHERE ',param_condition); PREPARE stmt FROM @sql;..." )
My question is... is this the same as sending the sql from php?

A: Yes, preparing and executing a statement from a stored procedure is pretty much the same as sending the query from PHP. The only difference is whether the work of concatenating all the pieces is done in the PHP code running on the client, or the MySQL server.
If the contents of the query being constructed is dependent on other table data, it may be better to do it in a stored procedure, so you don't need multiple round trips between the database and PHP to get all the information.
But if it's only dependent on parameters already available in PHP, it's probably best to construct the query in PHP, if only because (IMHO) the PHP syntax is likely to be easier to understand. The performance difference should be minor -- string concatenation is simple for both PHP and MySQL. But I generally think that anything that isn't dependent on SQL data should not be done in the database server.


text:
Q: Creating and Exporting Certificate for Remote Desktop Connection Manager v2.7 Can anyone help me create a certificate to use with the new version of Remote Desktop Connection Manager v2.7? I see the new version removed the "Store as plain text" option, but added using a certificate to the list.
I was wondering if anyone knew how to create a certificate (self-signed or whatever) that I could install on both computers to allow me to pass the config file between machines. I haven't been able to find anything online!
Thanks in advance.

A: If you in Remote Desktop Connection Manager click on the Help menu, and Usage, you will see a web page. On the Contents list, click on Encryption Settings (Under Local Options). There you will see how to create a personal certificate that RDCMan can use.
You will first need to get makecert.exe if you don't have it on your computer. You can get it by installing Windows SDK or Visual Studio.


text:
Q: Update list column using client object model code in SharePoint 2013 goes in onFailure without giving errors I am using javascript to write the client object model code in SharePoint 2013. I want to update a column of the form library but I am not able to do it.
The code goes in the onFailure method without giving any sort of exception. Please guide regarding how to update the column value and how can I debug this code.
The following is the code for updating:
      currentItem.set_item('_Status', 'Approved');
      currentItem.update();
      context.executeQueryAsync(on_myUpdate_Success, on_myUpdate_Failure);

The onsuccess and onfailure functions are:
       function on_myUpdate_Success() {
            alert('Updated Successfully.');
        }
      function on_myUpdate_Failure(sender, args) {
          alert('Error while updating the data. Error: ' + args.get_message() + ' StackTrace: ' + args.get_stackTrace());
          ULS.enable = true;
          ULSOnError('Error while updating the data mansi' + args.get_message(), document.location.href, 0);
          //if debugging
          alert(args.get_message());
      }

Please guide.

A: I'm not sure how you are getting the current item, but info on how to update an item using javascript is found here http://msdn.microsoft.com/en-us/library/hh185011(v=office.14).aspx.
Are you doing this within an App? Can you get the current item? For debugging I normally use Chrome developer tool (F12). Then step through the code and use watch windows and/or console. It is also possible to debug in Internet Explorer using its developer tool, but I find Chrome easier to use.


text:
Q: EF code first self reference many to many In one of business scenario need to create Model in code first approach like
Business has many Vendors
Vendors can belongs to many Businesses
So need to create many to many between Business and Vendors, but Vendor is logically Business itself (self reference). Vendor Model is not exist physically.
How to create BusinessVendor model with many to many relationship with Business itself and separate columns IsActive and VendorType in association table i.e. BusinessVendor?
Update:
    public class Business
    {
        public Business()
        {
            this.Users = new HashSet<User>();
            this.Departments = new HashSet<Department>();
            this.Addresses = new HashSet<Address>();
            this.BusinessProducts = new HashSet<BusinessProduct>();
            this.Vendors = new HashSet<Vendor>();
        }

        [Key]
        public int BusinessId { get; set; }

        [Required]
        [Display(Name = "Business Name")]
        public string Name { get; set; }

        [Required]
        [Display(Name = "PAN Number")]
        public string PAN { get; set; }

        [Required]
        [DataType(DataType.EmailAddress)]
        [RegularExpression(@"[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}", ErrorMessage = "Incorrect Email Format")]
        public string Email { get; set; }

        public string Fax { get; set; }

        [Required]
        [Display(Name = "Registration Number")]
        public string RegistrationNumber { get; set; }

        [Required]
        [Display(Name ="Business ID")]
        public string DisplayName { get; set; }

        public virtual ICollection<Address> Addresses { get; set; }
        public virtual ICollection<User> Users { get; set; }
        public virtual ICollection<Department> Departments { get; set; }

        public virtual ICollection<BusinessProduct> BusinessProducts { get; set; }

        public virtual ICollection<CategoryOfProduct> ProductCategories { get; set; }

        public virtual ICollection<Vendor> Vendors { get; set; }

    }

public class Vendor
    {

        [Key]
        public int VendorId { get; set; }

        [Required, ForeignKey("Client")]
        public int BusinessId { get; set; }

        public int VendorTypeId { get; set; }

        [ForeignKey("VendorTypeId")]
        public virtual VendorType VendorType { get; set; }

        public bool IsActive { get; set; }

        public virtual Business Client { get; set; }

        public virtual ICollection<Business> Businesses { get; set; }

    }

protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
modelBuilder.Entity<Business>()
                  .HasMany(c => c.Vendors)
                  .WithMany(c => c.Businesses)
                  .Map(op =>
                  {
                      op.MapLeftKey("BusinessId");
                      op.MapRightKey("VendorId");
                      op.ToTable("BusinessVendors");
                  });

}

But now getting issue with Cascade delete as

Introducing FOREIGN KEY constraint
  'FK_dbo.BusinessVendors_dbo.Vendors_VendorId' on table
  'BusinessVendors' may cause cycles or multiple cascade paths. Specify
  ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN
  KEY constraints. Could not create constraint. See previous errors.


text:
Q: MySQL application performance issue We want to get better performance with our application based on MySQL and PHP.
The current situation is an e-learning system that receives some "bursts" of queries depending on the day of the week and/or the hour of the day.
(hundreds of students starting drills at the same time from different schools for example)
As you may guess, these systems need real time calculations all the time.
We have very few slow queries in general and we try to improve them when they appear in the logs.
The hardware is self hosted, it's currently a VPS and it's not our hardware, but we keep hardware upgrade as part of the solution.
We have a specific table that is read/write intensive. We think it comes to disk access to that table. (study logs)
We are trying to figure out a hardware and/or software setup that could increase performance especially when that log table is needed.
One solution we are thinking about, is using replication to balance the "write" and "read" queries. (proxySQL + replication)
Our fear with that setup is what happens if the master is non available...
One software possibility we are currently developing is creating a "summary" table that is calculated only once a day or so. That should release some stress at least on 2 screens of the application. The bottleneck in that case seemed to be regarding the creation of temporary table and number of join tables.
I can add details as needed, please don't hesitate to ask.
EDIT: reformulate
What are the possible MySQL setups available to get better performance? Replication, cluster, other?
Thank you very much for your time.

A: Since you are not putting any code to your question I just answer you generally:

*

*Calculate memory usage by memory_get_usage(). put it at the last line of your codes

*Check loading average by sys_getloadavg(). put it at the last line of your codes

*Check running time by microtime(). Accurate way to measure execution times of php scripts

*Check which query cost you more by: select * from sys.x$statement_analysis

*Calculate performance just by ONE run and try to make it better.

*Find where you are hashing. for example find where you are using crypt. some hashing method can cost you too much. find where you really don't need them and on that place you can use low cost hashing like sha1 or md5. for example if you hashing user avatars inside a public folder you can lower your cost by using something like md5. But you NEVER EVER go for performance where security matters. for example for password hashing never go for performance.

*You can cache some place that can be cached. It can really help you for overall performance. read PHP Cache Dynamic Pages To Speed Up Load Times. Also you can cache with Apache How To Configure Content Caching Using Apache Modules On A VPS and nginx A Guide to Caching with NGINX and NGINX Plus.

*In your queries don't use something that is not working with indexes (you can't always do that but do it as you can). For example find_in_set makes high impact on performance. Specially when you are dealing with huge archives.

*If you really think making Log can impact on your performance, save log in another server. You can connect from current server to MySQL on another server by using IP. Also you can make API for this.

*Always think about better architecture. Sometimes with reviewing codes you see something can be drop or replace with better idea.


text:
Q: Elastic Beanstalk Returning 503 Errors My Elastic Beanstalk application is returning 503 server at capacity errors. I know that this happens when the application can't be reached but the application is stable everywhere else and I have tested it.
I believe that the issue is with my nginx.conf override:
"/opt/elasticbeanstalk/#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf" :
mode: "000664"
owner: root
group: root
encoding: plain
content: |
  #WE COME FROM env.config!
    upstream nodejs {
      server 127.0.0.1:8081;
      keepalive 256;
     }
     server {
      listen 80;
        if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2})") {
            set $year $1;
            set $month $2;
            set $day $3;
            set $hour $4;
        }
        access_log /var/log/nginx/healthd/application.log.$year-$month-$day-$hour healthd;
        access_log  /var/log/nginx/access.log  main;

        location / {
          root /var/app/current/public/dist;
          proxy_set_header   Connection "";
          proxy_http_version 1.1;
          proxy_set_header        Host            $host;
          proxy_set_header        X-Real-IP       $remote_addr;
          proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        }

        gzip on;
        gzip_comp_level 4;
        gzip_types text/html text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

     }

container_commands:
01_replace_nginx_eb_conf:
command: "mv -f        '/opt/elasticbeanstalk/#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf' '/tmp/deployment/config/#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf'"
ignoreErrors: false

I'd like to be able to serve my 'dist' folder of the app which contains a React web application through EBS.
I'm not very familiar with DevOps or nginx. Are there any glaring issues here that would cause my app to always be 503?


text:
Q: How to see complete list of processes in top When I do 'top', I learn that there are many processes running out of which many are in sleep state. I need to see complete snapshot of all processes at that point. the 'top' is able to show listing of processes, which fit in one screen.How do I get complete listing?
Among other things, I am interested in seeing list of all processes, which are in "sleeping" state. I don't think, I can get process state in output of "ps" command

A: You can get process states with coreutils ps
$ ps aux

will list all that, and more. Here's how you can decode them, from the man page:

PROCESS STATE CODES
Here are the different values that the s, stat and state output specifiers (header "STAT" or "S") will display to describe the state of a process:

   D    uninterruptible sleep (usually IO)
   R    running or runnable (on run queue)
   S    interruptible sleep (waiting for an event to complete)
   T    stopped, either by a job control signal or because it is being traced.
   W    paging (not valid since the 2.6.xx kernel)
   X    dead (should never be seen)
   Z    defunct ("zombie") process, terminated but not reaped by its parent.

For BSD formats and when the stat keyword is used, additional characters may be displayed:

   <    high-priority (not nice to other users)
   N    low-priority (nice to other users)
   L    has pages locked into memory (for real-time and custom IO)
   s    is a session leader
   l    is multi-threaded (using CLONE_THREAD, like NPTL pthreads do)
   +    is in the foreground process group.

A: top -b seems to be doing the trick.


text:
Q: Is this a criterion for uniform distribution modulo one? For all $k \in \mathbb N$ let $a_k$ be strictly positive bounded weights, i.e. there are constants $C_1$ and $C_2$ such that $0<C_1\le a_k \le C_2$. Now a real valued sequence $(x_k)_{k \in \mathbb N}$ satisfies $\lim_{n \to \infty}\frac{1}{n} \sum_{k=1}^n (a_k)^m e^{2\pi i x_km}=0$ for all non-zero integers $m$. Does this imply that the sequence $x_k$ is uniformly distributed modulo one?
It is similar to the Weyl criterion and would surely not be true if we consider just weights $a_k$ where the condition would only imply weighted uniform distribution modulo one. But with the weights $(a_k)^m$ depending on the parameter $m$ this could be true.
Any thoughts or potential counterexamples would be highly appreciated.

A: I provide a sequence $(x_k)_k$ that is not uniformly distributed but satisfies $\frac{1}{N}\sum_{k \le N} a_k^m e^{2\pi i x_k m} \to 0$ as $N \to \infty$ for each $m \ge 1$, where $a_k = 1$ if $k$ is odd and $a_k = 3$ if $k$ is even. Let $x_k = 0$ if $k$ is odd. Then, for any $m \ge 1$, $\sum_{\substack{k \le N \\ 2 \nmid k}} e^{2\pi i x_k m} = \frac{1}{2}N+o(N)$, so it suffices to have, for any $m \ge 1$, $\sum_{\substack{k \le N \\ 2 \mid k}} e^{2\pi i x_k m} = \frac{-1}{2\cdot 3^m}N+o(N)$.
Rescaling, our general problem is to find a sequence $(x_k)_k$ such that $$\sum_{k \le N} e^{2\pi i x_k m} = \frac{-1}{3^m}N+o(N)$$ for each $m \ge 1$. I feel like there's a reference that guarantees this result, but let me say what I came up with (which has probably already been done somewhere). Let $f : \mathbb{T} \to \mathbb{C}$ be such that $\hat{f}(0) = 1$, $\hat{f}(m) = -\frac{1}{3^m}$ for $m \ge 1$, and $\hat{f}(m) = \overline{\hat{f}(-m)}$ for $m \le -1$. Since the fourier coefficients decay rapidly, $f$ is continuous. Also, $f$ is real, due to how the negative fourier coefficients are defined. In fact, $f(x) = 1-2\sum_{m \ge 1} \frac{1}{3^m}\sin(2\pi m x)$, which in particular shows $f$ is non-negative. Therefore, for each $N \ge 1$, we may take rational approximations $\frac{j_0}{M_N},\dots,\frac{j_{N-1}}{M_N}$ to $f(\frac{0}{N}),f(\frac{1}{N}),\dots,f(\frac{N-1}{N})$ with $j_i \in \mathbb{Z}^{\ge 0}$ for each $i$. Let $s_N$ denote a block of length $T_N := j_0+\dots+j_{N-1}$ that has $\frac{t}{N}$ appearing $j_t$ times. Define our sequence $(x_k)_k$ by $2^{2^1+T_1}$ consecutive $s_1$'s, followed by $2^{2^2+T_2}$ consecutive $s_2$'s, followed by $2^{2^3+T_3}$ consecutive $s_3$'s, etc.. Then, for any $m \ge 1$, if $N$ is large enough, $$\frac{1}{N}\sum_{k \le N} e^{2\pi i x_k m} \approx \frac{1}{N_0}\sum_{t=0}^{N_0-1} f(\frac{t}{N_0})e^{2\pi i \frac{t}{N_0}m} \approx \int_0^1 f(x)e^{2\pi i xm}dx = \frac{-1}{3^m},$$ for some large $N_0$, the first approximation holding due to $f$ having mean $1$ (I'll leave details/quantifiers to you).


text:
Q: drawing a grid in jScrollPane i want to draw a grid,that consists of nodes(circles) and every circle is connected with all its neighbors.
something like this
i want to add the nodes dynamically,so i have to draw them in a scrollPanel.
i have tried to make jPanel with gridLayout,and add ellipse(as component) to every jPanel, and then add them to jScrollPanel,but the the size of the components gets smaller.
like this
can anybody help?
thanks!


text:
Q: foreach loop syntax for map in Apex want the foreach loop syntax for accessing map value, like what we do for array or list
for(OBJ o[SELECT Id,B FROM OBJ]){
     m1.put(o.Id, o.B);
}

please provide technical details

A: Map<Id, OBJ> map = new Map<Id, OBJ>([SELECT Id, B FROM OBJ]);

for(OBJ o : map.values()) {
    System.debug(o.B);
}

A: You can iterate over the map keyset then grab the value using each key.
for (Id key : m1.keySet()) {

    OBJ o = m1.get(key);

}

A: Here is SF workbook for all the For Loops:
https://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_loops_for.htm


text:
Q: Meteor Async ValidatedMethod gets called with function parameters undefined someMethod = new ValidatedMethod({
    name: 'someMethodName',
    validate: new SimpleSchema({
        subId: {type: String, min:1},
        planId: {type: String}
    }).validator(),
    async run(params){
        try{
                     //params is undefined
        }

    }
});

Using async run(params) causes params to be undefined (seems like the context switches to Global context). Removing the async works fine (except that I cannot use await in the method body anymore obviously).
Why is this, and how can I still use await inside a ValidatedMethod?
Note1 : I call the method from the client like so -- and get the same result if I try to use a regular Meteor.methods({}) definition. I am calling the method using Meteor.apply from the client
ClientHelpers.callWithPromise = function(methodName, methodArgs){
  //methodArgs must be an array
  return new Promise(function(resolve, reject){
    Meteor.apply(methodName, methodArgs, {wait:true}, function(error, result){
      if (error){
        reject(error);
      }
      console.log(result);
      resolve(result);
    });
  });
}

Then, calling on client (am sure paramsObject is correct):
var myResult = await ClientHelpers.callWithPromise('someMethodName', [paramsObject]);

Note 2: I have also traced it through to the internals of Meteor.apply , where it is in fact sending the paramsObject over DDP, in debug session:
  // Sends the DDP stringification of the given message object
  _send(obj) {
    this._stream.send(DDPCommon.stringifyDDP(obj));
  }

Many thanks for any insight.


text:
Q: Web API - Authentication credentials in the HTTP header vs body with SSL? I'm sending username and password in the HTTP Body for authentication to each controller action in a Web API. I do the authentication in each controller using the username/password.  It's using SSL.
Are there any security reasons why it's better to send the authentication credentials in the HTTP Header than in the HTTP body?
If I was using Basic Authentication I can see how having the credentials in the header are necessary as in this question but I'm not so I don't see the purpose.  It seems just as secure in either as long as it's using SSL.

A: From an SSL perspective the security of the credentials in header (HTTP Basic auth) or body (e.g. form based logon) of an HTTP request is equal.
However if the client is a regular web browser you should consider the following:
Browsers cache the credentials used with HTTP basic authentication the users usually face the problem that for performing a log-out they would have to close their browser.
On the other side a form-based logon usually created a session cookie that is time restricted and can be deleted any time.