text:
Q: Positioning of rotated longtable in apa6 I am finishing a manuscript with the apa6 package in LaTeX. Everything went fine except one thing: I need to place a rotated longtable at the end of the manuscript. The table itself works and has no problems but it won't move to the end of the manuscript when I remove the option floatsintext (all other tables in the document, however, do). I think the problem is that the longtable is situated in a landscape-environment, which obviously is not recognized by apa6. Replacing landscape with sidewaystable or similar things do not work. I am glad for any suggestions on how to make this wide longtable work in apa6.
Minimal example:
\documentclass[12pt
               ,man % manuscript mode; jou man doc
               ,babel, american % language
               %,biblatex % loads biblatex or apacite
               ,a4paper % default:letter
               % ,floatsintext
               ,noextraspace %removes extra space after headings; closer to "true" double-spacing
               %,mask
               ,longtable
               %,helv % font in man mode
               %,tt   % font in man mode
               %,draftfirst
               %,draftall
               ]{apa6}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{rotating}
\usepackage{pdflscape}
\usepackage{lipsum}
\usepackage{threeparttablex}
\usepackage{amsmath}
\usepackage{siunitx}

%% for the huge table to avoid boxes warnings
\newcommand{\rr}{\raggedright}
\newcommand{\tn}{\tabularnewline}

\title{Longtables and Me: An Endless Story}
\shorttitle{Longtables}

\author{Me}
\affiliation{MeU}

\authornote{
Empty
}

\abstract{
Empty.
}

\keywords{Empty}

\begin{document}

\lipsum

\begin{landscape}

\begin{ThreePartTable}

\begin{TableNotes}
\rr \footnotesize %
\textit{Note.}
Just a TableNote to explain some stuff.
\end{TableNotes}

\begin{longtable}{p{7.3cm}
                  S[table-format = 5]
                  l
                  l
                  S[table-format = 2.2]
                  c
                  p{5cm}}

\caption{Longitudinal Studies Included in the Analysis} \\
\label{tab:studies} \\

\toprule
1st Column  & {2nd Column}  &  3rd Column   &  4th Column  &  {5th Column}  &  6th  &  7th Column\\
\midrule
\endfirsthead

\multicolumn{7}{l}{{\tablename} \thetable{} (continued)} \\[0.5ex]

\toprule
1st Column  & {2nd Column}  &  3rd Column   &  4th Column  &  {5th Column}  &  6th  &  7th Column\\
\midrule
\endhead

\rr An Entry   & 1234  & ABCD    & glo  & 99.32  & 2  & Some more text \\

\rr An Entry   & 1234  & ABCD    & glo  & 99.32  & 2  & Some more text \\

\rr An Entry   & 1234  & ABCD    & glo  & 99.32  & 2  & Some more text \\

\rr An Entry   & 1234  & ABCD    & glo  & 99.32  & 2  & Some more text \\

\rr An Entry   & 1234  & ABCD    & glo  & 99.32  & 2  & Some more text \\

\rr An Entry   & 1234  & ABCD    & glo  & 99.32  & 2  & Some more text \\

\rr An Entry   & 1234  & ABCD    & glo  & 99.32  & 2  & Some more text \\

\rr An Entry   & 1234  & ABCD    & glo  & 99.32  & 2  & Some more text \\

\rr An Entry   & 1234  & ABCD    & glo  & 99.32  & 2  & Some more text \\

\rr An Entry that is quite long and breaks to the next line   & 1234  & ABCD    & glo  & 99.32  & 2  & Some more text \\

\rr An Entry   & 1234  & ABCD    & glo  & 99.32  & 2  & Some more text \\

\rr An Entry   & 1234  & ABCD    & glo  & 99.32  & 2  & Some more text \\

\rr Another rather long Entry that also breaks and extends over two lines   & 1234  & ABCD    & glo  & 99.32  & 2  & Some more text \\

\rr An Entry   & 1234  & ABCD    & glo  & 99.32  & 2  & Some more text \\

\bottomrule

\insertTableNotes

\end{longtable}

\end{ThreePartTable}
\end{landscape}

\lipsum

\end{document}

A: This seems to work, but only if you only use landscape for tables.
I'm not familiar with apa6, but I suspect that a lot of the packages you are adding are automatically loaded.  You might try commenting them out one at a time in you document and see if you get any errors.
\documentclass[12pt
               ,man % manuscript mode; jou man doc
               ,babel, american % language
               %,biblatex % loads biblatex or apacite
               ,a4paper % default:letter
               % ,floatsintext
               ,noextraspace %removes extra space after headings; closer to "true" double-spacing
               %,mask
               ,longtable
               %,helv % font in man mode
               %,tt   % font in man mode
               %,draftfirst
               %,draftall
               ]{apa6}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{rotating}
\usepackage{pdflscape}
\usepackage{lipsum}
\usepackage{threeparttablex}
\usepackage{amsmath}
\usepackage{siunitx}

%\usepackage{endfloat}

\DeclareDelayedFloatFlavor*{landscape}{table}

%% for the huge table to avoid boxes warnings
\newcommand{\rr}{\raggedright}
\newcommand{\tn}{\tabularnewline}

\title{Longtables and Me: An Endless Story}
\shorttitle{Longtables}

\author{Me}
\affiliation{MeU}

\authornote{
Empty
}

\abstract{
Empty.
}

\keywords{Empty}

\begin{document}

\listoftables

\begin{table}[htp]
\caption{this is actually a table}
\end{table}

\lipsum[1-3]

\begin{landscape}

\begin{ThreePartTable}

\begin{TableNotes}
\rr \footnotesize %
\textit{Note.}
Just a TableNote to explain some stuff.
\end{TableNotes}

\begin{longtable}{p{7.3cm}
                  S[table-format = 5]
                  l
                  l
                  S[table-format = 2.2]
                  c
                  p{5cm}}

\caption{Longitudinal Studies Included in the Analysis} \\
\label{tab:studies} \\

\toprule
1st Column  & {2nd Column}  &  3rd Column   &  4th Column  &  {5th Column}  &  6th  &  7th Column\\
\midrule
\endfirsthead

\multicolumn{7}{l}{{\tablename} \thetable{} (continued)} \\[0.5ex]

\toprule
1st Column  & {2nd Column}  &  3rd Column   &  4th Column  &  {5th Column}  &  6th  &  7th Column\\
\midrule
\endhead

\rr An Entry   & 1234  & ABCD    & glo  & 99.32  & 2  & Some more text \\

\rr An Entry   & 1234  & ABCD    & glo  & 99.32  & 2  & Some more text \\

\rr An Entry   & 1234  & ABCD    & glo  & 99.32  & 2  & Some more text \\

\rr An Entry   & 1234  & ABCD    & glo  & 99.32  & 2  & Some more text \\

\rr An Entry   & 1234  & ABCD    & glo  & 99.32  & 2  & Some more text \\

\rr An Entry   & 1234  & ABCD    & glo  & 99.32  & 2  & Some more text \\

\rr An Entry   & 1234  & ABCD    & glo  & 99.32  & 2  & Some more text \\

\rr An Entry   & 1234  & ABCD    & glo  & 99.32  & 2  & Some more text \\

\rr An Entry   & 1234  & ABCD    & glo  & 99.32  & 2  & Some more text \\

\rr An Entry that is quite long and breaks to the next line   & 1234  & ABCD    & glo  & 99.32  & 2  & Some more text \\

\rr An Entry   & 1234  & ABCD    & glo  & 99.32  & 2  & Some more text \\

\rr An Entry   & 1234  & ABCD    & glo  & 99.32  & 2  & Some more text \\

\rr Another rather long Entry that also breaks and extends over two lines   & 1234  & ABCD    & glo  & 99.32  & 2  & Some more text \\

\rr An Entry   & 1234  & ABCD    & glo  & 99.32  & 2  & Some more text \\

\bottomrule

\insertTableNotes

\end{longtable}

\end{ThreePartTable}
\end{landscape}

\hrule
\lipsum[1-3]

\end{document}


text:
Q: Ternary search tree with all suggestions autocomplete in C# I wonder is it possible to modify ternary search tree to check that word exists AND find all words that starts with that word ( or finish by that word ?) ?
For example do => dog dogs etc.
From this site is a sample code. First load all words to ternary tree then we can use method to check if word exists.
public class TernaryTree
{
    private Node m_root = null;

    private void Add(string s, int pos, ref Node node)
    {
        if (node == null) { node = new Node(s[pos], false); }

        if (s[pos] < node.m_char) { Add(s, pos, ref node.m_left); }
        else if (s[pos] > node.m_char) { Add(s, pos, ref node.m_right); }
        else
        {
            if (pos + 1 == s.Length) { node.m_wordEnd = true; }
            else { Add(s, pos + 1, ref node.m_center); }
        }
    }

    public void Add(string s)
    {
        if (s == null || s == "") throw new ArgumentException();

        Add(s, 0, ref m_root);
    }

    public bool Contains(string s)
    {
        if (s == null || s == "") throw new ArgumentException();

        int pos = 0;
        Node node = m_root;
        while (node != null)
        {
            int cmp = s[pos] - node.m_char;
            if (s[pos] < node.m_char) { node = node.m_left; }
            else if (s[pos] > node.m_char) { node = node.m_right; }
            else
            {
                if (++pos == s.Length) return node.m_wordEnd;
                node = node.m_center;
            }
        }

        return false;
    }
}

class Node
{
    internal char m_char;
    internal Node m_left, m_center, m_right;
    internal bool m_wordEnd;

    public Node(char ch, bool wordEnd)
    {
        m_char = ch;
        m_wordEnd = wordEnd;
    }
}

This make me loome large in my mind :(
Any way to get that words could be anything. However I am weak in algorithms with that level..
I hope that I don't duplicate any questions about this.
Any suggestion I will appreciate for.

A: It is possible to use ternary tree for that, but I'd not recommend that (not easy to do so).
I think there are two different approaches you can use:
A., Use a standard Trie instead of a Ternary tree, so your seek time will be considered constant, no matter how many items you have in the Trie.
A C# implementation is achievable, but keep in mind, Trie needs average/high level of algorithm knowledge.
B., Use a standard, sorted Array (string[]). As your requirement is just to create autocompletion based on the prefix, store all your words in a string[] and start a binary search on that.
The seek time is not constant but logarithmic, but even if you have millions of words stored in that array, each seek can be measure in a fraction of a millisecond (for instance, if you have a million words in that array, only 20 operations are required to find the one you are looking for). Even if binary search was not successful, you will have an index that is a closest match (but the index will be a negative value, indicating that the match was not successful). So, in this array:
A
C
D
E

if you search for B, you will get the index 0, pointing to A. If you start stepping up, you will see the items after 'B' (or 'dog' in your example).
So, even you have a full or partial match after binary search, keep listing the items from the array until the searched keyword is at the beginning of the dictionary word.

redpajama_set_name: RedPajamaStackExchange


text:
Q: To solve $x^2dx^2 +y^2dy^2 -z^2dz^2 + 2xydxdy = 0.$ I have solved differential equations of the form $Px +Qy+Rz =0$. But I am having difficulty to solve this:
$$x^2dx^2 +y^2dy^2 -z^2dz^2 + 2xydxdy = 0.$$

A: The differential equation can be written
$$(x\, dx + y\, dy)^2 = z^2\, dz^2,$$
or
$$du^2 = z^2\,dz^2 \quad (u = xy).$$
Then $du = \pm z\, dz$, so $u = \pm \frac{z^2}{2} + C$, where $C$ is a constant. That is,
$$xy \pm \frac{z^2}{2} = C.$$


text:
Q: MVC binding model to dropdownlist in view I am fairly new to MVC and am trying to get away form using WebForms, but some things are confusing me as to what I need to get certain things done.
In my view "/areas/admin/cars/form.cshtml" I want to use @Html.Dropdownfor, passing in a list of my car manufacturers which is defined by the CarManufacturer.cs model. How do I do this please?
I am using nhibernate - not sure if that makes any different...
Model;
public class CarManufacturer
    {
        public virtual int Id { get; set; }
        public virtual string Manufacturer { get; set; }
        //***do i need the below line?***
        public SelectList CarManufacturerList { get; set; }
    }

    public class CarManufacturerMap : ClassMapping<CarManufacturer>
    {
        public CarManufacturerMap()
        {
            Table("CarManufacturers");
            Id(x => x.Id, x => x.Generator(Generators.Identity));
            Property(x => x.Manufacturer, x => x.NotNullable(true));
        }
    }

The Controller calling the form is carController.cs
    public ActionResult New()
            {
                //re-susing views for add and edit
                return View("Form", new CarsForm
                {
                    IsNew = true,
                });
            }

            public ActionResult Edit(int id)
            {
                var car = Database.Session.Load<Car>(id);
                if (car == null)
                    return HttpNotFound();

                return View("Form", new CarsForm
                {
                    ...do stuff here to populate form fields!...
                });
            }

ViewModel;
public class CarsForm
    {
        //do I need the below line?
        public IList<CarManufacturer> Manufacturers { get; set; }

        public bool IsNew { get; set; }//whether add or edit action to be used
        public int? CarId { get; set; }
...more fields
}

Many thanks for patience and help with a new MVC'er!

A: I usually add dropdownlist data to viewbag. You can remove the lists from your viewmodel and entity class.
your controller would look like this.
public ActionResult New()
{
    ViewBag.Manufacturers = new SelectList(
        Database.Session.Load<Manufacturer>(),
        "Manufacturer",
        "Manufacturer");
    return View("Form", new CarsForm
    {
        IsNew = true,
    });
}

public ActionResult Edit(int id)
{
    var car = Database.Session.Load<Car>(id);
    if (car == null)
        return HttpNotFound();

    ViewBag.Manufacturers = new SelectList(
        Database.Session.Load<Manufacturer>(),
        "Manufacturer",
        "Manufacturer",
        car.Manufacturer); //sets the initial value
    return View("Form", new CarsForm
    {
        ...do stuff here to populate form fields!...
    });
}

Then in your view you just add your @Html.DropDownListFor
@Html.DropDownListFor(model => model.Manufacturer, (SelectList)ViewBag.Manufacturers)

A: This is one approach, and personally my preferred approach in smaller projects, but there are a few ways to skin this particular cat.
Hopefully you will have noticed that Html.DropDownListFor takes a List<SelectListItem> so you can go ahead and declare one in your view model, but you'll also need the Id of the particular manufacturer selected:
public class CarsForm
{
    public int ManufacturerId { get; set; }
    public List<SelectListItem> Manufacturers { get; set; }

    // Other properties
}

As a side note, the naming convention for view models would be CreateCarViewModel for example.
In your New method, you will need to instantiate Manufacturers from your database, usually it will be something like this:
viewModel.Manufacturers = (from m in dbContext.Manufacturers
                          orderby m.Name
                          select new SelectLisItem { Text = m.Name, Value = m.Id.ToString() }).ToList()

Now, in your View you can do:
@Html.DropDownListFor(model => model.Manufacturers, Model.ManufacturerId, "Please select")


text:
Q: Configuring minipage environment to incorporate width I'd like to configure tex4ht to set the width of a minipage div class based on the width specified in the LaTeX source.  Here's what I have so far:
The tex file is:
\documentclass{article}
\begin{document}
\begin{minipage}[c]{0.6\textwidth}
  Some text
\end{minipage}
\hfill
\begin{minipage}[c]{0.3\textwidth}
  some more text
\end{minipage}
\end{document}

and my cfg file (with inspiration from https://www.mail-archive.com/tex4ht@tug.org/msg00764.html) is:
\Preamble{html}
\Configure{HtmlPar}
{\EndP\Tg
}
{\EndP\Tg
}
{\HCode{
\Hnewline}}
{\HCode{
\Hnewline}}
\ConfigureEnv{minipage}{\ifvmode\IgnorePar\fi\EndP\HCode{
}}{\ifvmode\IgnorePar\fi\EndP\HCode{
\Hnewline}}{}{}
\Css{div.minipage {
 float: left;
 margin: 1ex 1em 1ex 0;
 }
}
\Css{div.minipage:last-child {
 clear: none;
 float: right;
 margin: 1ex 0 1ex 1em;
 }
}
\begin{document}
\EndPreamble

For instance, I'd like the first minipage in the above tex example (with width of 0.6\textwidth) to result in a corresponding div with width 60%.  So essentially, referencing this example, I'm looking for a way to:

*

*extract only the "0.6" from \begin{minipage}[c]{0.6\textwidth}

*multiply 0.6*100 = 60

*insert 60, along with a % sign, into the width of the div

I may be a bit out of my element with this; I've been frantically trying to learn tex4ht and feel I have only a tenuous grasp of most aspects.  This community's questions and answers have been tremendously helpful to me, and I'll sincerely appreciate any guidance on this issue.

A: This is little bit complicated, because minipage is not usual environment, but system of several macros dealing with optional parameters. This is modified cfg file:
\Preamble{html}
\Configure{HtmlPar}
{\EndP\Tg
}
{\EndP\Tg
}
{\HCode{
\Hnewline}}
{\HCode{
\Hnewline}}
\makeatletter
% to strip fraction from \textwidth
\def\striptextwidth#1\textwidth{#1}
% we must refer to minipage from the css file, because tags are beeing
% written before we know dimensions
\newcount\mini@count
% save original minipage
\let\oldiimini\@iiiminipage
% redefine minipage
\def\@iiiminipage#1#2[#3]#4{%
% calculate dimensions and save it to macro
\xdef\miniwidth{\strip@pt\dimexpr(\striptextwidth#4pt)*100\relax\%}
\oldiimini{#1}{#2}[#3]{#4}
}

\ConfigureEnv{minipage}{\advance\mini@count by 1\relax\ifvmode\IgnorePar\fi\EndP\HCode{
}}
{\ifvmode\IgnorePar\fi\EndP\HCode{
\Hnewline}%
% we must write dimension here to the css file
\Css{\#minipage\the\mini@count{width:\miniwidth;}}%
}{}{}
\makeatother
\Css{div.minipage {
 float: left;
 margin: 1ex 1em 1ex 0;
 }
}
\Css{div.minipage:last-child {
 clear: none;
 float: right;
 margin: 1ex 0 1ex 1em;
 }
}
\begin{document}
\EndPreamble

we can get all minipage parameters from \@iiiminipage macro, so we have to redefine it, strip \textwidth from parameter with width, calculate percents and save it to a macro so we can use it later.
Unfortunately, we can't use this calculated value directly in opening tag, because these are written before @iiiminipage is called, so we must generate unique id attribute for each minipage and write width to the css file.
Result with borders:


text:
Q: C# and C++ code in same .NET application? I'm supposed to work with Open CV, which can be programmed in C++ and deploy it in a .NET graphic interface application. I'd really like to work with C # for the interface traits.
What's the best approach for this?

A: I know of two ways that C# and C++ can be used in the same application.
The simplest way works where the components to be written in C++ and C# can be separated such that one component relies on the other, but they are not mutually dependent. In this case just create two assemblies, one in C# and one in VC++, and reference one from the other. This is the simplest way to do it, not least because it is supported in the UI of Visual Studio.
However, that approach will not work if there is a mutual dependency, ie, class A needs to know about class B and class B needs to know about class A, where class A is to be written in C++ and class B is to be written in C#. It is still possible to write the classes in different languages like that, using a lesser known feature of .NET called multi-file assemblies, or netmodules.
See How to: Build a Multifile Assembly and Multifile Assemblies for instructions. It is useful to remember that the C++ compiler is generally more clever than the others. I seem to remember the procedure was to get C# to compile its half to a NetModule, then pass that to the C++ compiler and linker which was capable of linking it to the C++ parts and creating the final assembly.
An alternative approach, if you only intend to write a small amount of C# code, would be to learn the VC++ syntax for the .NET features you want to use and avoid C# altogether. VC++ can declare managed interfaces and types just like C# can, and if you will not be writing much actual code in C# then this might be easier.


text:
Q: Fetch all nodes of html and apply a new coustom Id to each and every node I am working to fetch all nodes of parsed HTML for that I am working on Simple HTML DOM Parser I am able to get all div or all span tags with this
foreach($html->find("div") as $e)
{
   //here I got all div tags which are contained in html object but I want all tags not divs
   //then I am addin coustom attribute like this way
  $e->setattribute("My_id","abc");
}

Any help will be highly appreciated.

A: For that I have just added phpquery library.
$doc = phpQuery::newDocument($html);
$ul = pq('*');
$i = 1;
foreach($ul as $li) {
   pq($li)->attr('sws_id', $i);
    $i++;
}

to install phpQuery you can find this library via git follow this url.
https://github.com/rrmodi88/phpQuery


text:
Q: Phpmyadmin - Stored procedure with transaction isn't working So, I've been using XAMPP v3.2.2 with PHPmyadmin. I've tried to create a stored procedure using transactions with this code:
CREATE PROCEDURE nuevoRegistro (IN fecha DATE, IN hora TIME, IN preciofecha DECIMAL(18,2), IN preciototal DECIMAL(18,2), IN notas TEXT, IN usuario_idusuario BIGINT(20), IN cliente_idcliente BIGINT(20), IN tarea_idtarea BIGINT(20))
BEGIN

DECLARE exit handler for sqlexception
  BEGIN
      ROLLBACK;
END;

DECLARE exit handler for sqlwarning
BEGIN
     ROLLBACK;
END;

START TRANSACTION;

INSERT INTO registro VALUES('',fecha,hora,preciofecha,preciototal,notas,usuario_idusuario,cliente_idcliente,tarea_idtarea);

COMMIT;

END

My delimiter is //.
Phpmyadmin allows me to create the procedure with this, but when i call it my table registro isn't affected. What i'm doing wrong?.


text:
Q: Автозаполнение web-формы Есть сайт https://www.dropbox.com/login
Как сделать ярлык для автоматического входа с подстановкой логина и пароля?
A: Ответ на ваш вопрос - userscript'ы.
http://vizr.ru/page/tri-greasemonkey-scriptish-jquery-userscript-dlja-oblegchenija-web-serfinga
http://habrahabr.ru/post/129343/


text:
Q: asp.net imagebutton new window I have a Telerik Grid. In that I have the following code in an .aspx page. What I want to happen is that when the user click on the imagebutton control it launches a new window to show that image. Note, I have seen some code which use Postback but they are blocked by popup blockers. The control's image is set via codebehind but that should not matter for this question. Here is my code. Thanks!
<asp:ImageButton ID="prod_image_main" runat="server" AlternateText="Product Main Image"
                Height="500PX" Width="540PX"  />

A: Try to open a new window with a javascript function:
function OpenW() {
    window.open('NewForm.aspx', '', "height=200,width=200");
}

And in your imageButton set the onclientclick:
<asp:ImageButton ID="prod_image_main" runat="server" AlternateText="Product Main Image"
                Height="500PX" Width="540PX" onclientclick="OpenW()"  />

And load the image at the onload of NewForm.

A: Instead of using an asp:ImageButton control why not just use a link?  That way you can simply set the target attribute of the link to _blank and have it open in a new window.
Something like this:

A: Based on Mike Evan's answer here is what works for me.
ASPX FILE:
<asp:HyperLink runat="server" ID="hpl_mainimg" Target="_blank">
<asp:Image ID="prod_image_main" runat="server" AlternateText="Product Main Image"
                Height="500PX" Width="540PX"  /> </asp:HyperLink>

Code Behind C#
prod_image_main.ImageUrl = File.Exists(Server.MapPath("images_products/" + rdr["image_1"].ToString())) ? "images_products/" + rdr["image_1"].ToString() : "images_missing/NotAvailable_RS.jpg";
prod_image_main.ToolTip = rdr["itemtitle"].ToString();
hpl_mainimg.NavigateUrl = prod_image_main.ImageUrl.ToString();


text:
Q: Does JaxB Load Entire All data into into Memory before marshalling? I keep hearing around that JAXB is a slower XML marshaller/unmashaller. This is because it loads all data into memory at once. StaX has been suggested as an alternative because it is a streaming API which only loads the particular line you are currently working on into memory.
Seems to me that JAXB would only be slower when unmarshalling because you feed it an XML file to parse. Where as if you are mashalling XML the data is probably coming into your program outside of JAXB (assuming it wasn't originally XML) and thus JaxB has no control over how much data is loaded into memory.
Is this a correct assumption? I'm trying to get a clearer undestanding of how JAXB marshals XML and how difference it is compared to streaming APIs.

A: Jaxb needs to keep all data in memory in order to resolve references.
When you have object A referenced by object B, what gets stored in the XML record of object B is the id of object A.  Therefore, the id of object A must be known at the time that object B is being saved. Since JAXB cannot foresee which objects are referenced by which, it needs to have them all in memory while saving.
The same thing holds true when loading: when JAXB loads the XML record of object B, it will find in it the id of object A. So, it will need to be able to find object A by id (in a map maintained internally by JAXB) so that it can store a reference to object A within the newly created object B.
So, yes, JAXB needs to keep everything in memory.
I do not know whether JAXB is smart enough to detect the case where you have no objects referencing one another so as to skip all of that stuff. But if you do not have objects referencing one another, then you probably do not need something as sophisticated as JAXB.

A: JAXB doesn't load all the data before unmarshalling, but since it's supposed to create Java objects/values for all XML elements and attributes, it will end up loading all the data during unmarshalling.
Otherwise your object model would be incomplete.
Streaming APIs are good for reading large XML files, assuming you don't need all the information at the same time. If you can process the first part before continuing, you won't need to hold on to that data, and it can be freed, allowing reused of the memory.

The same goes for marshalling. JAXB requires that the entire object model is built in memory before marshalling. It isn't JAXB that "loads" the data, it just consumes it.
Streaming APIs are also good for writing large XML files, since it can be built incrementally.


text:
Q: Nodejs and calculation heavy operations, utilizing cpu to the maximum with worker threads, while still getting some responsiveness I'm trying to solve the following scenario in nodejs in a performant meaner.

*

*I have a 100Mb worth of jsons which I need to process and the time function to process each entry is about O(sweet_jesus(n)). In real time it takes about ~4-5 seconds for each entry.

*The only silver lining that I can totally run the processing of each entry individually (about 900 entries in total), they are unrelated.

My first choice was to go for worker_threads with node-worker-threads-pool:
import fs from 'fs';
import path from 'path';
import _ from 'lodash';
import moment from 'moment';
import workerPool from 'node-worker-threads-pool';

function generateShortEvaluationsByWorkers(){
    const pool = new workerPool.StaticPool({
        size: 10,
        task: path.resolve('src/simulator/evaluationGenerator.js')
    });
    let simulationEvaluations = [];
    const promises = [];

    fs.readdirSync(path.resolve(`results/companies`)).forEach(file => {
        const rawData = fs.readFileSync(path.resolve(`results/companies/${file}`));
        const company = JSON.parse(rawData);

        console.log(new Date(), ": company parsed, sending it for processing:", file);

        promises.push(pool.exec(company).then(result=>{
            simulationEvaluations.push(result);
        }));
    });

    Promise.all(promises).then(()=>{
        fs.writeFileSync(
            path.resolve(`results/bundles/simulationEvaluations.json`), JSON.stringify(simulationEvaluations, null, 2)
        );
        pool.destroy();
    })
}

The above code runs beautifully, it shows that the I/O - of reading all the files and feeding it to the pool - takes about 5-6 seconds...
 But after that there is absolutely no difference whatsoever compared to running whole thing in a single thread. The logs do show that the processing of the individual files no longer happen in order as before, so I guess there are some threading happening in the background, but the total time does not change one bit. It takes about an hour either way.
Also my hyper-threaded Intel 8750 with 6 cores (12 logical) shows 86% utilization goes to the node process. So my alleged 10 separate thread doesn't even manage to utilize one full core.  - EDIT: I was a retard it does make a huge difference I wrote down the times wrong...
After this I crank the thread pool size up to 100 and slice the number of files down to a 100. And that's where freaky stuff starts to happen. First, all my CPU cores go brrrr and my laptop properly melts through the table as one would expect. OS gives zero responsiveness everything is a slideshow.
The first 20 or so files gets processed within the same second after which the processing of individual files go to ~3 seconds each (neatly after each other, one message 3-5 seconds after the other). The last 10 or so files gets processed within the same second again.

*

*Why does 10 threads doesn't make a difference compared to 1 thread?

*Shouldn't I see files to be processed in clusters, where the cluster size is comparable to the number of logical cores, instead of timestamps one after the other?

*Is there a way to "leave" a core to process something else, while calculations still go to Neptune with all the other cores?

EDIT: I wont delete this, maybe somebody will learn from it :)
So to answer my own questions:

*

*It does, I could not measure, could not write, and could not read my CPU meter either at this point... totally my fault

*This one I still don't fully get, but after a few runs I suspect that when you start a whole buttload of threads, you make the whole system hang so much just by the strain of starting them all that by the time its able to spew out the first log, its already done with a bunch of calculation.

*Yeah this is also kinda obvious, do not use so many threads that the thread management itself will make the OS throw a shitfit.

In the end I got the best results with 11 threads btw.


text:
Q: any property toString() method gives StackOverflowError on JavaFX Why this give StackOverflowError? please check the sample code
public class JavaApplication5 {

    public static void main(String[] args) {
        // TODO code application logic here

        Student st = new Student();
        st.setId(1);
        st.setName("Asus");
        st.setSurname("Corparation");
        System.out.println(st.toString());

    }

}

public class Student {

    private StringProperty name;
    private StringProperty surname;
    private IntegerProperty id;

    public IntegerProperty idProperty(){
        if(id == null){
            id= new SimpleIntegerProperty(this, "id");
        }
        return id;
    }

    public int getId(){
        return idProperty().get();
    }

    public void setId(int stdId){
        idProperty().set(stdId);
    }

    public StringProperty nameProperty(){
        if(name == null){
            name = new SimpleStringProperty(this, "name");
        }
        return name;
    }

    public String getName(){
        return nameProperty().get();
    }

    public void setName(String stdName){
        nameProperty().set(stdName);
    }

    public StringProperty surnameProperty(){
        if(name == null){
            name = new SimpleStringProperty(this, "surame");
        }
        return name;
    }

    public String getSurname(){
        return surnameProperty().get();
    }

    public void setSurname(String stdSurname){
        nameProperty().set(stdSurname);
    }

    @Override
    public String toString() {
        return "Student{" + "name=" + name + ", surname=" + surname + ", id=" + id + '}';
    }

}

can this cause this problem? When I debug the code the class IntegerPropertyBase.java always return back my toString method when append bean and so that the infinite recursion cause this error in my opinion.

A: When you call toString of a property it returns a debug string which includes information about the property owner. This in turn calls toString of the owner and you get a infinite recursion.
Therefore it does not make sense to call toString of a property in the toString method of the owner.
You can solve this by writing Student.toString as
@Override
public String toString() {
    return "Student{" + "name=" + getName() + ", surname=" + getSurname() + ", id=" + getId() + '}';
}

(But you need to instantiate surname).


text:
Q: EntityFramework Core 3.1 + with MySql or Pomelo rename table to use DBFirst I have done two test projects, one with MySQL.EntityFramworkCore and another with Pomelo.EntityFrameworkCore and in both of them the same thing happened to me when obtaining the model from the database.
1.- Scaffold-DbContext 'server = x.x.x.x.x; user = xxxx; password = xxxx; database = name;' MySql.EntityFrameworkCore -OutputDir Models -f
2.- Scaffold-DbContext 'server = x.x.x.x.x; user = xxxx; password = xxxx; database = name;' Pomelo.EntityFrameworkCore.MySql -OutputDir Models -f

I have tables like the following in my database:
brand_cars
and when performing the dbFirst process.
It changes my name to BrandCars.
In SQLServer exist the parameter -UseDatabaseNames, but in mysql I have not found it
In the connector options I have not found this option.
https://mysqlconnector.net/connection-options/
Is there a possibility to force that you do not change the name of the database table when performing dbFirst?
The versions of my connectors are as follows:
-For the Pomelo project
Microsoft.EntityFrameworkCore.Tools 3.1.12
Pomelo.EntityFrameworkCore.MySql 3.2.4
Pomelo.EntityFrameworkCore.MySql.Design 1.1.2
-For the MySQL project
Microsoft.EntityFrameworkCore.Design 5.0.3
Microsoft.EntityFrameworkCore.Tools 5.0.3
MySql.EntityFrameworkCore 5.0.0

A: Works fine for me using Pomelo.EntityFrameworkCore.MySql in its 5.0.0-alpha.2 (or nightly build) release.
I tested it using the following SQL:
drop database if exists `So66530902`;
create database `So66530902`;
use `So66530902`;

CREATE TABLE `ice_creams` (
    `IceCreamId` int NOT NULL AUTO_INCREMENT,
    `Name` longtext CHARACTER SET utf8mb4 NULL,
    CONSTRAINT `PK_IceCreams` PRIMARY KEY (`IceCreamId`)
);

I then executed the following command, using the --use-database-names parameter:
dotnet ef dbcontext scaffold "server=127.0.0.1;uid=root;pwd=;port=3308;database=So66530902" Pomelo.EntityFrameworkCore.MySql -c Context -o Models --use-database-names

The result is the following class:
using System;
using System.Collections.Generic;

#nullable disable

namespace IssueConsoleTemplate.Models
{
    public partial class ice_cream
    {
        public int IceCreamId { get; set; }
        public string Name { get; set; }
    }
}

It should be mentioned that if you don't want EF Core to change the database table names in any way, you should also add the --no-pluralize flag in addition to --use-database-names.


text:
Q: Reason for align in book? When I use the documentclass book, I notice that it will align even numbered pages to the right and odd numbered pages to the left, so that when printed, the text of my document will be closer to the center.
Is there a typographical reason for this, or even a logical one? I would have assumed the opposite alignment so that you would never have the problem that text would become hard to read in the center (oddly worded, sorry) when printed.


text:
Q: How does java lib deal with the received data when socket read timeout? If a socket reads timeout(connection not closed) and later os receives the data, how  does the java lib deal with the data?
Eg.Two tcp connections/sockets are in the connection pool. One thread reads timeout  and return(release the connection to the connection pool) and then another thead uses the same connection; then another thead maybe receives the response data of the first thread. I think it's not right. How does java lib(eg.httpclint) prevent another thread from receiving the response data of the previous thread's request when two threads use the same connection in turn?
Thx!

A: It depends on what kind of data you are receiving here. If it is strictly based on which thread will handle the received data, then you need to make sure the data is identified using some kind of a GUID and Thread ID combination so that the sender and receiver know that the message has been consumed or lost. Ideally, you should not have a situation where your logic is dependent on the underlying threads unless that logic is OS-layer specific.


text:
Q: Django json dumps help I have the following code that I need help encoding to JSON and appending the data to a file, foo.json
Here is my code:
user = request.user
print 'USER ID ', user.id // 83
sour = json.dumps({"toast" : [{"uid" : user.id }]})
print 'Sour Toast: ', sour.toast # I'm getting this error: AttributeError: 'str' object has no attribute 'toast'

Basically I want to create a json file which contains the user.id value that can accessible from my front end through jQuery.
If anyone can help me with the error I'm getting or with any tips on where to go after i fix this error, I would greatly appreciate it.

A: json.dumps returns you a string. So when you do:
sour = json.dumps({"toast" : [{"uid" : user.id }]})
print sour

Simple prints a string that looks like this:
{"toast" : [{"uid" : user.id }]}

Not an actual object or dict you can get individual values from, just a string you can print or write to a file or whatever else you want to do with strings. It looks like you want to print this:
Source Toast: [{"uid":83}]

To do that you'd want to do the following:
sour = json.dumps([{"uid":83}])
print "Sour Toast: ", sour


text:
Q: How to add Foldername infront of a File instead of creating one? I tried to copy everything in an folder to an other folder, but i try to Not Create a subfolder in the targetpath instead i try to take the name of the subfolder in the sourcepath and add it infront of the tagetpath and set a underscore betwen them
Exaple:
sourcefolder
├file1.txt
├subfolder1
|└file2.txt
└subfolder2
 ├subfolder3
 |└file3.txt
 └subfolder4
  └file4.txt

Gets to:
 targetfolder:
 ├file1.txt
 ├subfolder1_file2.txt
 ├subfolder2_subfolder3_file3.txt
 ├subfolder2_subfolder4_file4.txt

Currently i just get it with folders:
foreach (string dirPath in Directory.GetDirectories(sourcePath, "*", SearchOption.AllDirectories))
{
    Directory.CreateDirectory(dirPath.Replace(sourcePath, targetPath));
}

foreach (string srcPath in Directory.GetFiles(sourcePath, "*.*", SearchOption.AllDirectories))
{
    newPath = srcPath.Replace(sourcePath, targetPath);
    File.Copy(srcPath, newPath, true);
}

And i tried it with :
private void showDeletefiles(string filePath)
    {
        string[] installfiles = Directory.GetFiles(Path.GetDirectoryName(filePath));
        string[] subfolders = Directory.GetDirectories(Path.GetDirectoryName(filePath));
        string appdatafolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
        int i = 0;

        foreach (string file in installfiles)
        {
            string fileName = Path.GetFileName(file);
            string fileextension = Path.GetExtension(fileName);

                if (!File.Exists(sourcefoldervalueLabel + file) && fileextension != ".manifest")
                {
                    File.Copy(filePath + fileName, appdatafolder+ fileName, true);
                }
                if (subfolders.Length >= 0)
                {
                    string[] subfolderfiles = Directory.GetFiles(subfolders[i]);
                    string foldername = Path.GetFileName(subfolders[i]);
                    i++;

                    foreach (string subfiles in subfolderfiles)
                    {
                        File.Copy(filePath + fileName, appdatafolder + foldername + "_" + subfiles, true);
                    }
                }
            }
       }

The problem is i go only into the first "subfolder"

A: You can generate a FileInfo object from each of your strings and extract the proper information from there. This should work, assuming you have a path of "DirectoryLetter:\Folder\Files" or "DirectoryLetter:\Files". Note this is obviously not the most efficient code with the use of string.Replace and of course this will have to be tested with all your common scenarios.
var fileInfos = Directory.GetFiles(@"DirectoryToTraverseHere", "*.*", SearchOption.AllDirectories)
                         .Select(file => new FileInfo(file));

foreach (var fileInfo in fileInfos)
{
   string newFileInfo;
   if (fileInfo.Directory.Parent.Name == fileInfo.Directory.Root.Name)
   {
      newFileInfo = string.Format("{0}_{1}", fileInfo.Directory.FullName, fileInfo.Name);
   }
   else
   {
      newFileInfo = string.Format("{0}_{1}{2}", fileInfo.Directory.Parent.FullName,
                                              fileInfo.Directory.Name,
                                              fileInfo.Name);
   }

   File.Copy(fileInfo.FullName, Path.Combine("TargetDirectory", newFileName));
}

A: I solved my Question by myself:
The Code:
    string[] installfiles = Directory.GetFiles(Path.GetDirectoryName(filePath));
        string[] subfolders = Directory.GetDirectories(Path.GetDirectoryName(filePath));
        string appdatafolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
        int i = 0;

        foreach (string file in installfiles)
        {
            string fileName = Path.GetFileName(file);
            string fileextension = Path.GetExtension(fileName);

            if (!Directory.Exists(appdatafolder))
            {
                Directory.CreateDirectory(appdatafolder);
            }
                File.Copy(filePath + fileName, appdatafolder + fileName, true);
            if (subfolders.Length >= 0 && i < subfolders.Length)
            {
                string[] subfolderfiles = Directory.GetFiles(subfolders[i]);
                string foldername = Path.GetFileName(subfolders[i]);
                i++;
                foreach (string subfiles in subfolderfiles)
                {
                    string subfilesname = Path.GetFileName(subfiles);
                    File.Copy(filePath + fileName, appdatafolder + foldername + "_" + subfilesname, true);
                }
            }
        }

This is how i needed it hopefully it helps you out :)


text:
Q: Extracting Gurobi Solution Index I have a bunch of gurobi variables
y[0],y[1],...,y[n]
x[0],x[1],...,x[m].
I would like to be able to figure out the indices of the optimal y's that are not zero.  In other words, if the optimal solution is y[0]=0, y[1]=5, y[2]=0, y[3]=1, I would like to return [1,3].  So far, I have
F = []
for v in model.getVars():
   if v.varName[0]=='y' and v.x>0:
     F.append[v.varName]

This, in the above example, would give me ['y[1]', 'y[3]'].  Since this output is a string, I'm not sure how I can get the 1 and 3 out of it.  Please help.
Thanks in advance!

A: I am using the following which works:
Index_List = []
for v in m.getVars():
       if v.varName[0] == 'y' and v.x>0:

           Index = int(v.varName[2])

           for j in range(3,3+100)):
               BOOL = False
               try:
                   IndexNEW =int(v.varName[j])
                   Index = 10*Index+IndexNEW
                   BOOL = True
               except ValueError:
                   ()
               if not BOOL:
                   break
       Index_List.append(Index)

The resulting Index_List is as desired.  There must be a better way though.

A: Assuming
from gurobipy import *
m = Model()

If you create a gurobi tupledict for your variables with
x = m.addVars(nx, vtype=GRB.INTEGER, name="x")
y = m.addVars(ny, vtype=GRB.INTEGER, name="y")
# ...your constraints and objective here..

then you can directly call the attributes for your variables (in your case the .X attribute for the variable value in the current solution). Using a list comprehension it could be done with:
m.optimize()
if m.status == GRB.OPTIMAL:
    indices = [i for i in range(ny) if y[i].X > 0]

where nx and ny are the number of your variables.


text:
Q: Use Comma as decimal separator for android EditText with MvvmCross I'm developing an application for Android using Xamarin with MvvmCross.
I have an EditText defined this way:
<EditText
            local:MvxBind="Text PorcentagemDesconto"
            android:inputType="number|numberDecimal"
            android:nextFocusDown="@+id/valorDesconto"
            android:layout_width="1dp"
            android:layout_weight="0.3"
            android:layout_height="wrap_content"
            android:hint="%"
            android:focusableInTouchMode="true" />

When I click on the EditText, the keyboard don't gives me the option to insert a Comma, only a Dot to use as decimal separator. The problem here is that when I insert the number 2.22 for example, the Binding assumes that the value is 222, because my device is using the pt-BR locale, that uses commas for decimals and dots for thousands.
I already did the following to solve the problem:
Created a ValueConverter that replaces the dot for the comma
public class DecimalValueConverter : MvxValueConverter
{
    public override object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        return value;
    }

    public override object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        var strValue = value?.ToString();
        if (string.IsNullOrEmpty(strValue))
            return null;

        strValue = strValue.Replace(".", ",");

        return strValue;
    }
}

but this way, as soon as the user enters the first decimal digit, the cursor moves to the start of the EditText, so, I also used the TextChanged event of the EditText to set the selection on the end of the input to solve that.
var porcentagemDesconto = v.FindViewById<EditText>(Resource.Id.porcentagemDesconto);
porcentagemDesconto.TextChanged += (s, e) =>
{
    Activity.RunOnUiThread(() =>
    {
        if (porcentagemDesconto.Text != null)
        {
            porcentagemDesconto.SetSelection(porcentagemDesconto.Text.Length);
        }
    });
};

But to be honest, I did not like this solution. I would need to either write the event code for ALL my EditTexts that accespt decimals, or create a custom view that does that.
I find very hard to belive that I would need to create a custom view and a ValueConverter just to use a comma as a decimal separator, so, I'm wondering if there's a better way to solve my problem.
EDIT:
I've also already tried to use the android:digits="0123456789,-", but this way the comma don't appear on the keyboard, only the dot. The only difference is that this way, when I click the dot, nothing happens.

A: That's an Android bug that is unfixed since 2009.
You have to set android:digits.
<EditText
    local:MvxBind="Text PorcentagemDesconto"
    android:inputType="number|numberDecimal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:hint="%"
    android:digits="0123456789,-"
    android:focusableInTouchMode="true" />

If you want to deploy your app for different countries, you have to use a string resource android:digits="@string/localized_digits with
values-de/strings.xml e.g. german
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="localized_digits">0123456789,-</string>
</resources>

values/strings.xml default
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="localized_digits">0123456789.-</string>
</resources>

Or use a more generic approach and set it via code:
// extension method
public static class EditTextExtension
{
    public static void FixDigits(this EditText text)
    {
        var decimalSign = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;
        var digits = $"0123456789{decimalSign}-";
        text.KeyListener = DigitsKeyListener.GetInstance(digits);
    }
}

// usage
FindViewById<EditText>(Resource.Id.txtNumber).FixDigits();

Or you add thr functionality of the extension method FixDigits() to your custom EditText class.


text:
Q: How to use variable from another method in a WinForms C# Application I'm attempting to create a simple WinForms application written in C# that:

*

*Takes user input from a text box.

*Uses the data from that text box, and stores it in a user_command variable, which is then used in a method that runs the string in that variable in windows cmd.

E.g: I enter "calc.exe" in the text box. The program then passes that into cmd, therefore opening the calculator.
I am unaware of how I use that data from that text-box and put it into System.Diagnostics.Process.Start("CMD.exe", user_command);
I will leave all the code below:
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace gui_1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        public void button1_Click(object sender, EventArgs e)
        {
            string user_command = textBox1.Text;

        }

        private void textBox1_TextChanged(object sender, EventArgs e, string user_command)
        {
            System.Diagnostics.Process.Start("CMD.exe", user_command);
        }
    }
}

The errors I get are:
Error   CS0123  No overload for 'textBox1_TextChanged' matches delegate 'EventHandler'  gui_1

A: The problem here is you put a third parameters on your textBox1_TextChange eventhandler which causing you the error.
I suggest you put the System.Diagnostics.Process.Start("CMD.exe", user_command); on to the button1_Click event, and remove the 3rd parameter on your textBox1_TextChange.
When you click the button1 it will run the CMD.exe with the user_command as argument.
namespace gui_1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        public void button1_Click(object sender, EventArgs e)
        {
            string user_command = textBox1.Text;
            System.Diagnostics.Process.Start("CMD.exe", user_command);
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }
    }
}

EDIT:
executing different process with arguments.
try to type on your textbox1 before clicking the button1 c:\test.txt.
this will try to open test.txt file on your drive c: on the notepad and ask you if you want to create the file if it is not existing.
    public void button1_Click(object sender, EventArgs e)
    {
        string user_command = textBox1.Text;
        System.Diagnostics.Process.Start("notepad.exe", user_command);
    }

EDIT2:
executing CMD.exe to execute the parameter.
/c argument will execute the arguments entered on textbox1 upon starting the CMD.exe
    public void button1_Click(object sender, EventArgs e)
    {
        string user_command = textBox1.Text;
        System.Diagnostics.Process.Start("CMD.exe", "/c " + user_command);
    }

A: The eventargs (e) should contain the value in the checkbox. put a breakpoint and inspect it. I am sure you will find the text in there.
Remove your third parameter to start matching the overload again !
I hope this code is for educational purposes since it will open a huge gap in the security of the server it is running on.


text:
Q: MIME type ('text/html') is not executable, and strict MIME type checking is enabled while trying to render angular2 using express I'm trying to use Angular2 and NodeJS, express in my new project and running into an issue. Ive used cli to ng build the Angular2 project and have the dist folder generated.
Now when I try to point this folder using express, I can see only the "Hello world" html in the index.html. In the networks tab on dev tools on chrome, I can see the .js files getting called with 200OK but however they seem to return the index.html in response. And on browser console, I see errors on the js files as below.
Refused to execute script from 'https://localhost:8080/inline.bundle.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
Same error for rest of the js files.
I've tried:
    1. CORS to allow *
    2. Content-type: application/javascript on before res.sendFile(__dist+'index.html');
    3. ng serve seem to work file from localhost:4200 though. But I need express to render the page.
Not sure how to solve the issue. Any suggestions are appreciated.

A: Try
app.use(express.static('your angular dist folder here'))
For more info about serving static files, you can get here.


text:
Q: Angular mouseover and leave not working MAT-MENU I have a mat-sidenav and a list of mat-item and mat-menu. Then when I hover over of one of the items I want the menu to display. This part is working. But then when I move off of that menu or item and over a new item I want its menu to display.
https://stackblitz.com/edit/angular-xsscrm
I have included a stackblitz with a demo of the behavior.
What is wrong here I have both on enter and exit, but then when I leave a menu on to a new one, it doesnt open unless I click on it.
Thanks for the help

A: The issue here is that when a menu opens, it creates an overlay with a backdrop that overlaps all elements. This backdrop is causing the mouse events to not be 'seen' by the listening element until the overlay is dismissed via a mouse click. Luckily, the menu control has a flag to remove the backdrop; setting this to false fixes the issue you're seeing.
Side note: you have an *ngFor on the <mat-list> element, but I think you want to move it to the <mat-list-item> element instead because you want many list items, not many lists. Since you're using the local variable of *ngFor outside of the <mat-list-item>, you can create an <ng-container> element to house your *ngFor. See below stackblitz:
https://stackblitz.com/edit/angular-xsscrm-kx6jyd
Another side note: this behavior is similar to a tooltip. Perhaps that would be a better control for your use-case? https://material.angular.io/components/tooltip/overview


text:
Q: all possible Taylor's and Laurent series of $\frac{2z-3}{z^2-3z+2} $ about $z=0$ Find all possible Taylor's and Laurent series of $\frac{2z-3}{z^2-3z+2} $ about $z=0$
I solved it as
$$\frac{2z-3}{z^2-3z+2}  = \frac{1}{z-2} + \frac{1}{z-1}$$
$$= \frac{-1}{2}{(1+\frac{z}{2}+\frac{z^2}{4}+.....)} - (1+z+z^2+z^3)$$
Is this answer correct ? Is the above series both Taylor as well as Laurent ?

A: Your result is only for $|z|<1$ and you are missing two other cases.
To expand $$\frac{2z-3}{z^2-3z+2}=-\left(\frac{1}{1-z} +\frac{1}{2-z}\right)$$
there are two singularities at $z=1$ and $z=2$. So we can have three different cases.
It is all about the region of convergence (RoC) of the geometric series, since $$\displaystyle\sum_{n=a}^\infty r^n=\frac{r^a}{1-r},\color{red} {\text{when } |r|<1}$$

*

*If $|z|<1$, then

$$\frac{1}{1-z}=\sum_{n=0}^{\infty}z^n$$
$$\frac{1}{2-z}=\frac{1/2}{1-z/2}=\frac12\sum_{n=0}^{\infty}\left(\frac z2\right)^n$$

*

*If $1<|z|<2$, then

$$\frac{1}{1-z}=-\frac{1/z}{1-1/z}=-\sum_{n=1}^{\infty}\left(\frac 1z\right)^n$$
$$\frac{1}{2-z}=\frac{1/2}{1-z/2}=\frac12\sum_{n=0}^{\infty}\left(\frac z2\right)^n$$

*

*If $|z|>2$, then

$$\frac{1}{1-z}=-\frac{1/z}{1-1/z}=-\sum_{n=1}^{\infty}\left(\frac 1z\right)^n$$
$$\frac{1}{2-z}=-\frac{1}{2}\cdot\frac{2/z}{1-2/z}=-\frac12\sum_{n=1}^{\infty}\left(\frac 2z\right)^n$$

A: What you wrote is correct. I would add just one more step, merging your series into a single one:$$-\left(1+\frac12\right)-\left(1+\frac14\right)z-\left(1+\frac18\right)z^2+\cdots$$This is the Taylor series of your function at $z=0$ and it is its Laurent series too.


text:
Q: How to derive integrals with error function? How to derive this integral
$\int_{-\infty}^{\infty}erf(\lambda x)\mathcal{N}(\mu, \sigma ^2)dx$
and this
$\int_{-\infty}^{\infty}(erf(\lambda x)-const)^2\mathcal{N}(\mu, \sigma ^2)dx$
where
$erf(x)=\frac{2}{\sqrt\pi}\int_{0}^{x}{e}^{-t^2}dx$ - is the error function
$\mathcal{N}(\mu, \sigma ^2)=\frac{1}{\sigma\sqrt{2\pi}}{e}^{-\frac{(x-\mu)^2}{2\sigma^2}}$ - is pdf of the normal distribution
From this paper: "...it can be shown by parameter differentiation with respect to mu and then integrating with respect to mu..." they have got quite simple result but I really don't understand how this trick works.
Edit:
So in order to summarize and make everything clear:
My original goal was deriving aforesaid integrals. It is much easier to do if one knows $\int_{-\infty}^{\infty}\Phi(\lambda x)\mathcal{N}(\mu, \sigma ^2)dx$ and $\int_{-\infty}^{\infty}\Phi^2(\lambda x)\mathcal{N}(\mu, \sigma ^2)dx$
Based on what @ir7 has shown $\int_{-\infty}^{\infty}\Phi(\lambda x)\mathcal{N}(\mu, \sigma ^2)dx =\Phi\left(\frac{\lambda \mu}{\sqrt{1+\lambda^2\sigma^2}}\right)$ and from definition  $erf(x)=2\Phi(\sqrt{2}x)-1$ and $\Phi(x)=\frac{1}{2}erf(\frac{x}{\sqrt{2}})+\frac{1}{2}$ we obtain:
\begin{equation}\int_{-\infty}^{\infty}erf(\lambda x)\mathcal{N}(\mu, \sigma ^2)dx = \int_{-\infty}^{\infty}(2\Phi(\lambda\sqrt{2}x)-1)\mathcal{N}(\mu, \sigma ^2)dx=2\int_{-\infty}^{\infty}\Phi(\lambda\sqrt{2}x)\mathcal{N}(\mu, \sigma ^2)dx-1=2\Phi\left(\frac{\lambda\sqrt{2}\mu}{\sqrt{1+2\lambda^2\sigma^2}}\right)-1=erf\left(\frac{\lambda\mu}{\sqrt{1+2\lambda^2\sigma^2}}\right)\end{equation}
\begin{equation}\int_{-\infty}^{\infty}erf(\lambda x)\mathcal{N}(\mu, \sigma ^2)dx = erf\left(\frac{\lambda\mu}{\sqrt{1+2\lambda^2\sigma^2}}\right)\end{equation}
In the case of $\int_{-\infty}^{\infty}\Phi^2(\lambda x)\mathcal{N}(\mu, \sigma ^2)dx$ ...

A: Hint: The "trick" they are refering to is differentiation under integral. We have:
$$\frac{d}{dy} \int_a^b f(x,y)dx =\int_a^b  \frac{\partial}{\partial y} f(x,y)dx,$$
if $f(x,y)$ and $\frac{\partial}{\partial y} f(x,y)$ are continuous in both variables and are, respectively, bounded in absolute value by two functions $g(x)$ and $h(x)$, both independent of $y$, such that $\int_a^b g(x)dx$ and $\int_a^b h(x)dx$ exist and are finite.
Note that ($\sigma >0$, $\lambda >0$):
$$   F(\sigma,\mu) \triangleq \int_{-\infty}^{\infty} \Phi(\lambda x)\frac{1}{\sigma} {\cal N}\left(\frac{x-\mu}{\sigma}\right) dx = \int_{-\infty}^{\infty} \Phi( \lambda\sigma y+\lambda\mu) {\cal N}\left(y\right) dy .$$
where $\cal N$ is standard normal probability density function and $\Phi$ is standard normal cumulative distribution function.
Using the diferentiation under integral, its derivative wrt $\mu$ is
$$  \frac{\partial}{\partial \mu} F(\sigma,\mu) = \int_{-\infty}^{\infty}  \lambda{\cal N}(\lambda\sigma y+\lambda\mu) {\cal N}\left(y\right) dy =
\frac{\lambda}{\sqrt{1+\lambda^2\sigma^2}} {\cal N}\left(\frac{\lambda\mu}{\sqrt{1+\lambda^2\sigma^2}}\right). $$
Finally, integrating wrt to $\mu$ from $-\infty$ to $\tilde{\mu}$ and noting that $\lim\limits_{\tilde{\mu}\to -\infty}F(\sigma, \tilde{\mu}) = 0$, we get:
$$ F(\sigma, \tilde{\mu}) = \Phi\left(\frac{ \lambda\tilde{\mu}}{\sqrt{1+\lambda^2\sigma^2}}\right),$$
as per paper's statement.
You can check by yourself that the conditions of the theorem are met, the equalities I stated without full details are true, and adapt the result to the error function.
EDIT1: The following general formulae should help for the second integral (using the same method):
$$\int_{-\infty}^{\infty}  \exp(Ay) \Phi(By+C) {\cal N}_{d,e^2}\left(y\right) dy  =
\exp\left(Ad+0.5e^2A^2\right)\Phi\left(\frac{ABe^2+Bd+C}{\sqrt{1+B^2e^2}} \right),$$
$$\int_{-\infty}^{x}  \exp(Ay) \Phi(By+C) {\cal N}_{d,e^2}\left(y\right) dy  =
\exp\left(Ad+0.5e^2A^2\right)\Phi_2\left(\frac{x-d}{e}-Ae,\frac{ABe^2+Bd+C}{\sqrt{1+B^2e^2}}; \frac{-Be}{\sqrt{1+B^2e^2}}\right),$$
$$\int_{-\infty}^x \Phi(y) dy = x\Phi(x) +  {\cal N}(x), $$
where $\Phi_2(\cdot,\cdot;\rho)$ is the cdf of bivariate standard normal with correlation $\rho$:
$$ \Phi_2(x,y;\rho) =\frac{1}{2\pi\sqrt{1-\rho^2}}\int_{-\infty}^x \int_{-\infty}^y \mathrm e^{-.5\frac{u^2-2\rho uv+v^2}{1-\rho^2}}dudv.$$
So, denote $$G\left(\sigma, \mu\right)\triangleq \int_{-\infty}^{\infty}  \Phi(\lambda\sigma y+\lambda\mu)^2 {\cal N}\left(y\right) dy.$$
Then $$\frac{\partial}{\partial \mu} G(\sigma,\mu) = \int_{-\infty}^{\infty}  2\lambda \Phi(\lambda\sigma y+\lambda\mu) {\cal N}(\lambda\sigma y+\lambda\mu){\cal N}\left(y\right) dy $$
$$ = \int_{-\infty}^{\infty}  2\lambda \Phi(\lambda\sigma y+\lambda\mu){\cal N}\left(\sqrt{1+\lambda^2\sigma^2} y+\frac{\lambda^2\sigma\mu}{\sqrt{1+\lambda^2\sigma^2}}\right) {\cal N}\left(\frac{\lambda\mu}{\sqrt{1+\lambda^2\sigma^2}}\right)dy$$
$$ = 2\lambda {\cal N}\left(\frac{\lambda\mu}{\sqrt{1+\lambda^2\sigma^2}}\right)
\int_{-\infty}^{\infty}   \Phi(\lambda\sigma y+\lambda\mu){\cal N}\left(\sqrt{1+\lambda^2\sigma^2} y+\frac{\lambda^2\sigma\mu}{\sqrt{1+\lambda^2\sigma^2}}\right) dy $$
$$ =\frac{2\lambda}{\sqrt{1+\lambda^2\sigma^2} } {\cal N}\left(\frac{\lambda\mu}{\sqrt{1+\lambda^2\sigma^2}}\right)
\int_{-\infty}^{\infty}   \Phi\left(\lambda\sigma \frac{z-\frac{\lambda^2\sigma\mu}{\sqrt{1+\lambda^2\sigma^2}}}{\sqrt{1+\lambda^2\sigma^2} }+\lambda\mu\right){\cal N}\left(z\right) dz $$
$$=\frac{2\lambda}{\sqrt{1+\lambda^2\sigma^2} } {\cal N}\left(\frac{\lambda\mu}{\sqrt{1+\lambda^2\sigma^2}}\right)\Phi\left(\frac{\lambda\mu}{\sqrt{1+\lambda^2\sigma^2}}\frac{1}{\sqrt{1+2\lambda^2\sigma^2}} \right). $$
It follows:
$$G(\sigma, \tilde{\mu}) = \frac{2\lambda}{\sqrt{1+\lambda^2\sigma^2} } \int_{-\infty}^{\tilde{\mu}}{\cal N}\left(\frac{\lambda\mu}{\sqrt{1+\lambda^2\sigma^2}}\right)\Phi\left(\frac{\lambda\mu}{\sqrt{1+\lambda^2\sigma^2}}\frac{1}{\sqrt{1+2\lambda^2\sigma^2}} \right) d\mu$$
$$ =2 \int_{-\infty}^{\frac{\lambda\tilde{\mu}}{\sqrt{1+\lambda^2\sigma^2}}}{\cal N}\left(z\right)\Phi\left(\frac{z}{\sqrt{1+2\lambda^2\sigma^2}} \right) dz $$
$$ = 2\Phi_2\left(\frac{\lambda\tilde{\mu}}{\sqrt{1+\lambda^2\sigma^2}},0; -\frac{1}{\sqrt{2+2\lambda^2\sigma^2}}\right). $$
These calculations need to be verified.
Alternatively, the probabilistic interpretation of $G(\sigma,\mu)$ is
$$\mathbb{E}\left[\Phi\left(\lambda\sigma X+\lambda\mu\right)^2\right],$$ and has been partially studied here Closed forms for various expectations involving the standard normal CDF (note Stein's Lemma referenced therein).
EDIT2:
$$\int_{-\infty}^{\infty}  \lambda{\cal N}(\lambda\sigma y+\lambda\mu) {\cal N}\left(y\right) dy= \lambda \int_{-\infty}^{\infty} \frac{1}{\sqrt{2\pi}}\mathrm e^{-.5(\lambda\sigma y+\lambda\mu)^2}\frac{1}{\sqrt{2\pi}}\mathrm e^{-.5y^2} dy$$
$$ = \lambda \int_{-\infty}^{\infty} \frac{1}{\sqrt{2\pi}}\mathrm e^{-.5\left(\sqrt{1+\lambda^2\sigma^2} y+\frac{\lambda^2\sigma\mu}{\sqrt{1+\lambda^2\sigma^2}}\right)^2}\frac{1}{\sqrt{2\pi}}\mathrm e^{-.5\left(\frac{\lambda\mu}{\sqrt{1+\lambda^2\sigma^2}}\right)^2}  dy$$
$$= \lambda {\cal N}\left(\frac{\lambda\mu}{\sqrt{1+\lambda^2\sigma^2}}\right) \int_{-\infty}^{\infty} \frac{1}{\sqrt{2\pi}}\mathrm e^{-.5\left(\sqrt{1+\lambda^2\sigma^2} y+\frac{\lambda^2\sigma\mu}{\sqrt{1+\lambda^2\sigma^2}}\right)^2}dy$$
$$ =\lambda {\cal N}\left(\frac{\lambda\mu}{\sqrt{1+\lambda^2\sigma^2}}\right) \frac{1}{\sqrt{1+\lambda^2\sigma^2}}, $$
with last equality coming from a variable change.


text:
Q: Combining methodcaller and attrgetter with sorted I want to get a list of PosixPath objects and have it sorted based on the corresponding file sizes. I am trying to to this using sorted function. The key that I want to use for sorting is object.stat().st_size, where object is an PosixPath object, stat() returns an os.stat_result object, and st_size is the size of the file corresponding to the PosixPath object. I know how to sort based on either an object method or an object attribute using operator.methodcaller or operator.attrgetter, but I can't figure out how to use an attribute of the object returned by methodcaller.
I tried the following and some variations but it does not work:
from operator import attrgetter, methodcaller
from pathlib import Path

sorted(Path('my_directory').glob('*.extension'), key=methodcaller('stat').st_size)

A: They are not meant to be combined. You should use a lambda as key:
from pathlib import Path
sorted(Path('.').glob('*.py'), key=lambda p: p.stat().st_size)

Or, if you want to change the sort field dynamically:
key_field = 'st_mtime'
sorted(Path('.').glob('*.py'),
       key=lambda p: attrgetter(key_field)(p.stat()))

And, well, if you really want to use methodcaller and attrgetter, you could do:
sorted(Path('.').glob('*.py'), key=lambda p: attrgetter('st_size')(methodcaller('stat')(p)))

A: Function composition is not native in Python.
One readable way to apply your logic is to use the direct rather than functional route:
res = sorted(Path('.').glob('*.py'), key=lambda p: p.stat().st_size)

There are, however, 3rd party libraries that do offer this functionality, such as toolz:
from toolz import compose
from operator import attrgetter, methodcaller

get_size = compose(attrgetter('st_size'), methodcaller('stat'))

res = sorted(Path('.').glob('*.py'), key=get_size)

In my opinion, if you would like a functional solution, you should use or write a composition higher-order function, such as the above, to ensure your code is readable.
Related: Nested lambda statements when sorting lists


text:
Q: INDEX/MATCH MAX vba My question is about finding the student name from range (D2:D296) who contains the highest value from range(N2:N296). I have done the below code and could not execute well.
My bad, I did not mentioned earlier about that my datas are from diff worksheet which is Sheet1.
Sub highestmark()
Dim Result As Long
Dim rng As range
Dim rnng As range

Set rng = ThisWorkbook.Worksheets("Sheet1").range("$N$2:$N$296")
Set rnng= This Workbook.Worksheets("Sheet1").range("$D$2:$D$296")
Result = Index(rnng, Match(Max(rng), rng))

[B3] = Result

End Sub
Im kinda new to vba, i appreciate the comments earlier, again, my bad that i didnt write it down clearer just now and my bad that i write weird codes.

A: Well, can't see what you did, but based on your question:
=INDEX(D2:D296,MATCH(MAX(N2:N296),N2:N296,0))

A: You can also use:
    Option Explicit

    Sub HighestValue()

        Dim Lastrow As Long, MaxValue As Long
        Dim rngValues As Range, rngNames As Range
        Dim MaxName As String

        With ThisWorkbook.Worksheets("Sheet1")

            Lastrow = .Cells(.Rows.Count, "B").End(xlUp).Row

            Set rngValues = .Range(Cells(2, 2), Cells(Lastrow, 2))
            Set rngNames = .Range(Cells(2, 1), Cells(Lastrow, 1))

            MaxValue = Application.Max(rngValues)

            MaxName = Application.WorksheetFunction.Index(rngNames, Application.WorksheetFunction.Match(MaxValue, rngValues, 0))

        End With

    End Sub

A: Add Application or WorksheetFunction if you are using native worksheet functions to VBA code.
Dim Result As Long
Dim rng As range
Dim rnng As range

Set rng = ThisWorkbook.Worksheets("Sheet1").range("N2:N296")
Set rnng= ThisWorkbook.Worksheets("Sheet1").range("D2:D296")
Result = Application.Index(rnng, Application.Match(Application.Max(rng), rng, 0))

[B3] = Result


text:
Q: Need alternative approach for executing a SQL query into loop Problem: One of my client's requirement is to receive orders from the client (Stored in txnorder table) and generate packing slips against them (Stored in txnpackingslip table). Now Sometimes there are more items packed than ordered which is not an issue, the problem arises when I've to generate a report for Packing more than order (Referenced as Negative Orders). There are more than 1400 customers, more than 300 rows are updated daily in the txnorder table and more than 250 rows in txnpacking slip table.
the MySQL server is centralized on a web hosting.
What I've Done: I've already written a Stored Procedure as below, but with centralized server it is taking more than 90 seconds to extract results while the row count of order table is 1600 and packinslip 1400
Stored Procedure: `
CREATE DEFINER=`root`@`localhost` PROCEDURE `NegativeOrders`(
    IN pcinput INT
    )
BEGIN
    SELECT
    DISTINCT(o.ocode) AS "Code",
    o.opcode, (o.obdl - IFNULL(p.pbdl,0)) AS "Req_Bdl",
    (o.obox - IFNULL(p.pbox,0)) AS "Req_Box"
    FROM
        (SELECT DISTINCT(orderprdcode) AS ocode,
        orderpartycode AS opcode, (SUM(orderbdl)) AS obdl,
        (SUM(orderbox)) AS obox
        FROM txnorder WHERE orderpartycode = pcinput
        GROUP BY orderprdcode) o
    LEFT JOIN
        (SELECT DISTINCT(packprodcode) AS pcode,
        packpartycode AS ppcode,
        (SUM(packbdl)) AS pbdl,
        (SUM(packbox)) AS pbox
        FROM txnpackingslip WHERE packpartycode = pcinput
        GROUP BY packprodcode) p
    ON o.ocode = p.pcode
    GROUP BY o.ocode
    HAVING req_bdl < 0 OR req_box < 0;

    END$$

DELIMITER ;

This is the SQL Fiddle Created : NegativeOrderFiddle
Note: I'm open to adapt any relevant approach other than optimizing my SQL


text:
Q: why Hex data output differently? I am writing a very simple code to test the Hex data on c++
int main()
{
    unsigned char bytestosend[4] = {0xB5, 0x62, 0x06, 0x08};

    cout << &bytestosend << endl;
}

The data that comes on the terminal is : 0xbfa1ef58
how could this happen ?
and when I remove the '&' it gives me strange symbols

A: When you use the & it is outputting the address of the array and when you don't it is printing it as ASCII data.

A: The '&' means 'address of' in this context. You are printing the location of bytestosend in memory rather than the contents of it.
Remove that '&' and you won't get what you want either. Now that stream insertion operator (operator >>) sees a char array, so it's going to try to print your array as if it was a string. Your array isn't null terminated, so that output might go on for a while.
If you want to print all four of the elements of bytestosend in hex use something like this:
std::cout.flags (std::ios::hex | std::ios::showbase);
std::cout << int(bytestosend[0]) << ", "
          << int(bytestosend[1]) << ", "
          << int(bytestosend[2]) << ", "
          << int(bytestosend[3]) << std::endl;


text:
Q: Mobile Version of Site Always Opens Up Much Bigger Than Screen Im trying to open up my latest site design on my phone and have it match the screen when i go to the url.  However, it always open up much bigger and I have to double tap the screen to resize it to the correct size.
I've tried:
<meta name="viewport" content="width=device-width, initial-scale=1">

But nothing is working. Please view source on my site and html at:
http://directsellers.org/NeverTakeNo4Answer/LetsGo.html
and tell me what I need to fix.  Thanks.

A: I faced the problem like you did.
So you have to set your html and body width, not in pecentage or pixels, but in vw (viewport width). For example:
body, html {
 width: 100vw;
 min-width: 100vw;
 max-width: 100vw;

 overflow-x: hidden
 overflow-y: auto
}

I did this way, and it works.

A: You are missing the CSS for the Responsive Design. You need to target the device width using media queries and write CSS for mobile and tablets.
Please follow the link below to get an idea about it.
http://www.zell-weekeat.com/how-to-write-mobile-first-css

A: You give fixed Width. just give width:100%. to all div and content. it will automatically responsive


text:
Q: Row reduction error I'm having trouble with row reduction on the following matrix when I try to find the eigenvector for $\lambda$=1.
1/7 * \begin{bmatrix}
    2 & 6 & 3  \\
    6 & -3 & 2 \\
    3 & 2 & -6\\
\end{bmatrix}
For $\lambda$ = 1 this becomes
1/7* \begin{bmatrix}
    1 & 6 & 3  \\
    6 & -4 & 2 \\
    3 & 2 & -7\\
\end{bmatrix}
But when I row reduce this I get
1/7 * \begin{bmatrix}
    1 & 6 & 3  \\
    0 & -40 & -16 \\
    0 & -16 & -16\\
\end{bmatrix}
The eigenvector that I should be getting is (3,2,1). Any idea where I'm going wrong?

A: The characteristic polynomial for the matrix $A=\begin{bmatrix}2&6&3\\6&-3&2\\3&2&-6\end{bmatrix}$ is $\chi(\lambda)=\det(A-\lambda I)$ which one finds to be equal to:
$-\lambda^3-7\lambda^2+49\lambda+343$.  After some algebraic manipulation, you will find it can be written as:
$\chi(\lambda)=-(\lambda+7)(\lambda+7)(\lambda-7)$
That implies that for $A$, the eigenvalues are $7,-7,-7$
The actual matrix we are interested in is $(\frac{1}{7} A)$.  By properties of matrices, the eigenvectors of $(\frac{1}{7} A)$ are the same as the eigenvectors of $A$ and the corresponding eigenvalues of $(\frac{1}{7} A)$ are $\frac{1}{7}$ times the eigenvalues of $A$.  That is to say, the eigenvalues of $(\frac{1}{7} A)$ are $1,-1,-1$
We try to find the eigenvector of $1$ for $(\frac{1}{7}A)$.  This is the same as trying to find the eigenvector of $7$ for $A$.
So, we row reduce $A-7I$  (not $A-I$).  I.e. row reduce $\begin{bmatrix}2-7&6&3\\6&-3-7&2\\3&2&-6-7\end{bmatrix}=\begin{bmatrix}-5&6&3\\6&-10&2\\3&2&-13\end{bmatrix}$
Completing the rowreduction process, one sees it row reduces to $\begin{bmatrix}1&0&-3\\0&1&-2\\0&0&0\end{bmatrix}$ implying an eigenvector is $\begin{bmatrix}3\\2\\1\end{bmatrix}$ (and so the eigenspace for the eigenvalue is the span of this vector)


text:
Q: How to connect to iPage mysql database I am trying to create a data-source in my web-logic domain to remotely connect to ipage mysql database, but I don't know which driver to use, where is the host name and the port?? I have the database name and user name and password that I created in the ipage site.

A: suppose your domin name is abc.com then your host should be abccom
$db= new mysqli("domaincom.ipagemysql.com","DB_user","password","DB_name");
if($db->connect_error)
{
    echo "ERROR: (".$db->connect_errno.") ".$db->connect_error;
    exit();
}

--------edited
to connectto mysql database you need to you need to have the following 4 things
1- host           //to access mysql DB at ipage use host=domain.ipagemysql.com (remember doamin without .com or .net see 1st line of my answer)
2- user           //you may know
3- password       //you may know
4- database_name  //you may know

I dont know the interface of webLogic how to input these.


text:
Q: Euler–Lagrange for cabin on a Ferris wheel - solution with special function I am looking for a special function which solves the equation of motion of a cabin on a Ferris wheel.
The e.o.m. reads
$$ \ddot{\phi} + a \, \sin\phi + b \, \sin(\phi - \tau) = 0 $$
with
$$ a = gl^{-1}\Omega^{-2} $$
$$ b = Rl^{-1} $$
$$ \tau = \Omega t $$
$R$ is the radius of the wheel, $\Omega$ is its angular velocity. $l$ and $m$ are length and mass of the pendulum representing the cabin. $\tau$ is the dimensionless time, derivative is w.r.t. $\tau$.
Does anybody know an exact solution of this diff. eq. in terms of special functions?


text:
Q: ant is looking for location from within location I'm building a java web application. And I have to do things a certain way as directed by instructions.
When I type "ant deploy" to build a war file, it fails. It says the file can't be found.
But it is obviously looking in the wrong place. It says...

C:\Users\Dave\Desktop\springapp\springapp\C:Program
  FilesApacheapache-maven-3.0.4-binapache-maven-3.0.4\boot does not
  exist

Of course that doesn't exist! But I can't find why it thinks that is the valid location. It looks like it is tacking the location that it is looking for - at the end of the current directory. But I can't change directories, because if I do, it then can't find the build.xml file that it needs.
I have ant, maven, and tomcat for this project.
I have a system variable location set for each TOMCAT_HOME and MAVEN_HOME.
The build.properties file in the project file has maven.home set as the correct location.
How can I change where it is looking for that file?

A:
The build.properties file in the project file has maven.home set as the correct location.

From the look of that path I suspect your build.properties contains something like
maven.home=C:\Program Files\Apache\....

Backslash is an escape character in properties files so you need to either use forward slashes instead of backslashes or double them up.  You should also escape the colon
maven.home=C\:\\Program Files\\Apache\\....


text:
Q: error: 'List' is not a template type I am a beginner in c++ so please excuse me if I my mistakes below turn out to be silly. Still, I am stuck with my code and would appreciate any help.
I get the following error when trying to compile through make via g++:
In file included from A.cpp:2:
List.h:20: error: 'List' is not a template type
A.cpp: In member function 'void A::NowyObiekt(int)':
A.cpp:6: error: 'list_a' was not declared in this scope
make: *** [A.o] Error 1

My code is separated into the following tiny files:

*

*A.h : http://pastebin.com/QQ04xx2j (header)

*A.cpp : below
#include "A.h"
#include "List.h"

void A::NewObject(int i)
{
        list_a.Add(i);
}

int A::Compare(int a, int b)
{
        if ( a>b ) return 1;
        if ( a<b ) return -1;
        else return 0;
}

*List.h : below (header)
#ifndef LIST_H
#define LIST_H
template<typename T>
class Node
{
    Node()
    {
        nxt = pre = 0;
    }
    Node(const T& el, Node *n = 0, Node *p = 0 )
    {
        dana = el; nxt = n; pre = p;
    }
    T dana;
    Node *nxt, *pre;
};

template<typename T>
class List
{
public:
    List()
    {
        head = tail = 0;
    }
    void Add(const T&);
protected:
    Node<T> *head,*tail;
};

#endif

*List.cpp : http://pastebin.com/a3HQ9yZ4

*prog.cpp : below (main)
#include "List.h"
#include "A.h"

int main()
{
    int i = 5;
    class List list_a;
    class A obj;

    obj.Add(i);
}

*and the makefile is : http://pastebin.com/GTR5jW54
As noted, I am still a beginner, so please be understanding. I would be thankful for any help and clear explanations. Thanks in advance.

A: There are a couple of problems with your code: The first is that you don't declare any variable named list_a anywhere. That error should be pretty obvious. The other is that you use the List class without giving it template parameters.
And last a small note about your question: As your files are indeed very small, you could put them in the question and not link to them.
Edit: About the List  template problem.
You already use Node properly in List, i.e. declare the nodes as Node<T>. When you use List you simply has to do the same. For example, to declare a list of integers:
List<int> my_int_list;

Also, as you only use public functions in List from the class A, you don't need the friend declaration. If you do need to use protected or private members (which IMO is a sign of bad design) you need to make that friend-declaration templated as well:
friend class List<sometype>;

And finally, your code will not compile anyway... The reason being that when you are using a template-class, the whole class has to be fully defined (i.e. complete with its function implementations). You can solve this by putting the functions in the header file. And when defining the functions, you need the template parameter there as well:
template<typename T>
void List<T>::Add(const T& el)
{
    Node<T>* head = new Node<T>(el);
    if ( Compare(el,i) > i )
        std::cout << "Ok" << std::endl;
}

Note that I added the template parameter in a couple of places.


text:
Q: json xml converter having array in json string I need to convert a json to xml and later on converting that json back to xml, but i am loosing the json array object while this conversion -
I am using org.json lib.
Json String -
{
    "readResult": {
        "errors": [{
            "code": 400
        }]
    }
}

Codebase - using org.json lib
String xml = XML.toString(new JSONObject("inputjsonstring"));
String json = XML.toJSONObject(xml).toString();

Output xml and json -
XML - <readResult><errors>400</errors></readResult>
JSON -
{
        "readResult": {
            "errors": {
                "code": 400
            }
        }
}

Here this json doesn't have any array as it was in original json. Please suggest alternate library to do the same.

A: Json specification says that json can have datatypes like string,number, boolean, array, object and null.
single element array in json is a special case which gives problem with some api like org.json. Because these library treat single element array as normal json object and not an json array object.
To solve this problem we need a library which support all the datatypes of a Json. We can use xslt transformation to solve this problem. In XSLT 3.0 there are 2 funtions json-to-xml() and xml-to-json() which works perfect for this problem. I have solved similar problem using this way. These functions transform json to xml and vice versa considering all the data type of json. for eg. In a json if you give value as number, boolean or string library will maintain these data types at the time of converstion (xml to json or vice versa so that after conversion in xml you can see particular datatype of a value in genrated xml). We can see in genrated xml that any key in json is always string type.
More on below link
xslt 3.0 json-to-xml and xml-to-json conversion
Check both conversion examples on below xsltfiddle links
Json to xml convertion
https://xsltfiddle.liberty-development.net/6qVRKvS
get back Json from previous xml
https://xsltfiddle.liberty-development.net/94hvTyU
Below is a complete java example of this conversion using XSLT and Saxon 9.8 HE (HE means home edition. It's open source product provides implementations of XSLT (3.0)
First you need to run json2XML.java which will genrate outputSampleXML.xml. This outputSample.XML will have conversion from json to xml and it will be input of our next program named xml2json.java. This program will give you back your original json containing single array element.
pom.xml dependency
    <dependency>
        <groupId>net.sf.saxon</groupId>
        <artifactId>Saxon-HE</artifactId>
        <version>9.8.0-8</version>
    </dependency>

    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.8.2</version>
    </dependency>

inputJSON.xml
<your_data_here>
{
    "Request": [{
        "price": "1400",
        "test": "dummydata"
    }]
}
</your_data_here>

json2xml.xsl
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="3.0">
    <xsl:output indent="yes" />
    <xsl:template match="your_data_here">
        <xsl:copy-of select="json-to-xml(.)" />
    </xsl:template>
</xsl:stylesheet>

json2XML.java
public class json2XML {
public static void simpleTransform(String sourcePath, String xsltPath, String resultDir) {
    TransformerFactory tFactory = TransformerFactory.newInstance();
    try {
        Transformer transformer = tFactory.newTransformer(new StreamSource(new File(xsltPath)));
        transformer.transform(new StreamSource(new File(sourcePath)), new StreamResult(new File(resultDir)));
    } catch (Exception e) {
        e.printStackTrace();
    }
}
public static void main(String[] args) {
    simpleTransform("src/main/java/sampleJSON.xml", "src/main/java/json2xml.xsl",
            "src/main/java/outputSampleXML.xml");
    System.out.println("Done!!!");

}

}
outputSampleXML.xml
<?xml version="1.0" encoding="UTF-8"?>
<map xmlns="http://www.w3.org/2005/xpath-functions">
   <array key="Request">
      <map>
         <string key="price">1400</string>
         <string key="test">dummydata</string>
      </map>
   </array>
</map>

xml2json.xsl
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="3.0">
  <xsl:output omit-xml-declaration="yes"/>
  <xsl:template match="/">
      <xsl:value-of select="xml-to-json(., map { 'indent' : true() })"/>
  </xsl:template>
</xsl:stylesheet>

xml2JSON.java
public class json2XML {
public static void simpleTransform(String sourcePath, String xsltPath, String resultDir) {
    TransformerFactory tFactory = TransformerFactory.newInstance();
    try {
        Transformer transformer = tFactory.newTransformer(new StreamSource(new File(xsltPath)));
        transformer.transform(new StreamSource(new File(sourcePath)), new StreamResult(new File(resultDir)));
    } catch (Exception e) {
        e.printStackTrace();
    }
}
public static void main(String[] args) {
    simpleTransform("src/main/java/sampleJSON.xml", "src/main/java/json2xml.xsl",
            "src/main/java/outputSampleXML.xml");
    System.out.println("Done!!!");

}

}
Output on Console on running xml2JSON.java
{
    "Request": [{
        "price": "1400",
        "test": "dummydata"
    }]
}

Note you can keep both the xsl file in a java String object as a constant and use them as inputStream in transformer java code. So that you won't need to make seprate xsl files. But that is other part of problem and need not to concentrate here.

A: Underscore-java can convert json to xml and vice versa. I am the maintainer of the project.
Resulted xml:
<?xml version="1.0" encoding="UTF-8"?>
<readResult>
  <errors array="true">
    400
  </errors>
</readResult>

A: There is no way that from the XML string
<readResult>
     <errors>
           400
     </errors>
 </readResult>

, the library can "guess" that code is an array
To do these kind of things, you will need to go via a Java model and use a Library such as Jackson to regenerate the JSON
There are several alternatives to map from XML to Java: XStream is one of them

A: Maybe you can be helped with the JSON-XML mapping described here:

The readers and writers produced by the JsonReaderWriterFactory provide an XML API over JavaScript Object Notation (JSON) content. (source)

It can convert:
{
    "readResult": {
        "errors": [{
            "code": 400
        }]
    }
}

to:
<root type="object">
    <readResult type="object">
        <errors type="array">
            <item type="object">400</item>
        </errors>
    </readResult>
</root>

NB: I also implemented this conversion in JavaScript and in PHP.


text:
Q: How to detect if a specific mob is dead in 1.15 So I am trying to be able to detect if a specific mob is dead and then execute a command. I have already tagged the mob "boss1" and I know that you need a tag to detect the entity but I don't know the commands to actually detect it.

A: You will need to check for the entity using /execute.
/execute unless entity @e[tag=boss1] run ...

Run the command unless there is an entity with the tag boss1.
When the boss dies, you can put the command to run after the run parameter.


text:
Q: OpenGL ES antialiasing with rendering using GL_LINES I am struggling to render smooth lines using GL_LINES.
I have borrowed the MultisampleConfigChooser from the following link: MultisampleConfigChooser.java
It seemed to find the multisample configuration without any errors.
Here is the code I use to render the lines on the screen:
    GLES20.glUseProgram(this.lineDrawProgram);

    GLES20.glEnableVertexAttribArray(mPositionHandle);
    GLES20.glVertexAttribPointer(
            mPositionHandle, 2,
            GLES20.GL_FLOAT, false,
            6*4, linesData);

    linesData.position(2);

    GLES20.glEnableVertexAttribArray(mColorHandle);

    GLES20.glVertexAttribPointer(
            mColorHandle, 4,
            GLES20.GL_FLOAT, false,
            6*4, linesData);

    linesData.position(0);

    GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, matrix, 0);

    GLES20.glDrawArrays(GLES20.GL_LINES, 0, this.numLines*2);

    GLES20.glDisableVertexAttribArray(mPositionHandle);
    GLES20.glDisableVertexAttribArray(mColorHandle);

Blending is enabled with GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA.
One more mention is that I am drawing the lines to a texture which is bound to an FBO as a color attachment. I have not added any extra code to enable multisampling for the FBO.
Here is the code I use to setup the FBO and texture:
    int[] fbo = new int[1];
    int[] tex = new int[1];
    enGLES20.glGenTextures(1, tex, 0);
    GLES20.glGenFramebuffers(1, fbo, 0);

    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, tex[0]);
    GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0,GLES20.GL_RGBA, this.width, this.height, 0,GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);

    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, fbo[0]);
    GES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, tex[0], 0);
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);

The resulting lines still look like crap:

Please help me get these lines to look smooth.
BTW there are many different small lines in the screenshot, no curved lines or anything exotic.


text:
Q: Data binding in templateCache for dir-pagination-control is broken in IE We've used the following directive for pagination in our angular application.
https://github.com/michaelbromley/angularUtils/tree/master/src/directives/pagination
While using 'dir-pagination-conrol' the pageNumber is not extrapolated to its value, instead {{ pageNumber }} is itself getting displayed in UI only in IE.

I've tried using dir-pagination-control both as element and attribute since the author has mentioned in lots of places that we should use it as attribute.
dir-pagination-controls direction-links="true" max-size="5"> /dir-pagination-controls>
div dir-pagination-controls={ direction-links:true, max-size:5}> /div>
I'm actually loading the pagination result as an iframe in a Microsoft SharePoint modal dialog - SP.UI.ModalDialog.
https://msdn.microsoft.com/en-us/library/office/ff410058(v=office.14).aspx
The above behaviour - {{pageNumber}} being displayed, happens only if I use SP.UI.ModalDialog. If i instead do this :
window.parent.location = 'some url'
to display the pagination result, then the data binding happens correctly and appropriate page numbers are displayed.
From code - dirPagination.js:
$templateCache.put('angularUtils.directives.dirPagination.template', 'ul class="pagination" ng-if="1 < pages.length">
«
‹
{{1+1}}
›
»
/ul');
This is where the template for dirPaginationControls is set. I think the expression is not evaluated for some reason. I even tried to change it to some thing like {{1+1}} to check if it evaluates to 2, instead {{1+1}} only is being displayed.
So I feel the data binding in templateCache isn't working if we are loading it using SP.UI.ModalDialog.
Is there any other way we can do data binding other than {{ }} to evaluate and display the result or I am missing out on anything?
Any suggestion/feedback is very much appreciated.
Thanks :)

A: The problem seemed to be with Microsoft SharePoint modal dialog - SP.UI.ModalDialog itself. So I changed my code to use a normal Javascript popup window and it worked.


text:
Q: Django html issue with templates and views My issue is that I can't seem to translate the dictionary into a table here's the error:
Could not parse ["appid"] from 'game[''appid"]

HTML code:

  Game ID
  Game Name
  Hours Played

{% for game in games %}
{# each game object is a dictionary with "appid", "name " and "playtime_forever" keys #}

  {{ game["appid"] }}
  {{game["name"]}}
  {{ game["playtime_forever"] }}

views.py code:
~~~~  There's stuff here but it shouldn't be important. ~~~~
return render(request,'hackathon/SteamAPI.html', game)

When I run the server it shows:
game:
[{u'appid': 4000,
  u'has_community_visible_stats': True,
  u'img_icon_url': u'd9101cbeddcc4ff06c7fa1936c3f381b0bbf2e92',
  u'img_logo_url': u'dca12980667e32ab072d79f5dbe91884056a03a2',
  u'name': u"Garry's Mod",
  u'playtime_forever': 0},

A: Django templates do not support [] indexing. Instead of
game["appid"]

you should use
game.appid

The same applies for game.name and game.playtime_forever
As an unrelated note, you should also close your for loop:

{% endfor %}

A: Dictionary should be accessed this way in Django Templates.
choices = {'key1':'val1', 'key2':'val2'}

{% for key, value in choices.items %}

{{key}} - {{value}}

 {% endfor %}


text:
Q: Argument 'Expression' cannot be converted to type 'ObjectCollection' I am new to VB and am trying to divide the contents of two list boxes. However every time I try it is coming up with errors such as; Argument 'Expression' cannot be converted to type 'ObjectCollection'. I have been changing around the code but have not since had any luck. I would be very appreciative to any help, thanks!
    Dim pSmokers As Short
    pSmokers = (Val(lstSmoker.Items)) / (Val(lstTotal.Items)) * 100
    lstTotal.Items.Add(pSmokers)

A: Assuming that lstSmoker is listBox, you are not using it properly. This will not work
Val(lstSmoker.Items)

You need to do something like this
Short.Parse(lstSmoker.Items(0)) ' Where "0" is index of your item in listbox

Again, this is assuming your item in list control is string. So your code will looke like this:
pSmokers = Short.Parse(lstSmoker.Items(0)) / Short.Parse(lstTotal.Items(0)) * 100

Unfortunately I don't know how you keep data in your list. May be you want to have count of items in the list calculated rather than data. Then do this
pSmokers = lstSmoker.Items.Count / lstTotal.Items.Count * 100

!!! But now you running into problem that if pSmokers is short, you having a division here. Means, you will get decimal number. So, you need to change the data type of pSmokers
You also may run into division by "0" issue if there are no smokers. To prevent it do
If lstTotal.Items.Count > 0 Then
    Dim pSmokers as Decimal = lstSmoker.Items.Count / lstTotal.Items.Count * 100
    txtTotal.text= pSmokers.ToString("G")
End If


text:
Q: How to write a column header in Excel from an existing file in Python I have this script that scrapes some text and print a list of names in an excel file. I couldn't figure out how to print a column name that doesn't come from scraped text.
The following writes the scraped list correctly:
    block = [h5.get_text() for h5 in main_block.find_all('h5', class_='Company_line-title')]
    worksheet.write_column(1,0,block)
    workbook.close()

I wanted to add in the first column and row the name "Company". I tried to create a list like:
comp = ['Company']
worksheet.write_column(0,0,comp)
but it didn't work.

A: for one cell use write() with cell number and use string variable instead of a list. exm below:
worksheet.write('A1', 'Company')  #OR worksheet.write(0, 0, 'Company')

or
var='Company'
worksheet.write('A1', var)

my code:
li=['A','B','C']

workbook   = xlsxwriter.Workbook('filename.xlsx')

worksheet = workbook.add_worksheet()
worksheet.write('A1', 'Company')  #OR worksheet.write(0, 0, 'Company')
worksheet.write_column(1,0,li)

excel file


text:
Q: Message Order in Apache ActiveMQ Artemis Cluster I am trying to implement message ordering in Apache Artemis cluster. Producers/Consumers connecting to the cluster implement High availability. So at one point of time there will be two instances of same application connecting to topic or queue. So far, I could find following two methods which can be used to achieve ordering in Red Hat AMQ / Artemis cluster:

*

*Message Groups  (is reliable only when there is one consumer per node in the cluster as per the documentation)

*Exclusive Queues (Message order is preserved only on a single node).

I fully understand using cluster and expecting message ordering are conflicting requirements, but its still a requirement to be implemented in the project I am working on as the consumers are unable to handle the complexity of handling out of order messages.
What are the alternatives to the above that can be used to implement message ordering in Artemis ActiveMQ  /  Red Hat AMQ Cluster?

A: In a clustered environment an exclusive consumer is tied to each queue on each broker, so depending on the message load balancing configuration, you could have one consumer per broker receiving messages. This breaks ordering. Your producer and consumers need to be on the same broker instance to preserve ordering.
As you say, clustered message groups functionality is not reliable, nevertheless it may be useful in some, very specific use cases. Also note that, for HA it's not sufficient to have a cluster of brokers. You need to explicitly configure HA (shared-store or replication), otherwise, if a broker fails permanently, then all its messages would be lost.


text:
Q: php combining text on images more than once? I am trying to print users personal data like name, email, phone number on screen, using separate images, rather than printing out in clear text on page, thus getting cache possibly by Google. Trying to print like below:
Name - image with name text created on fly
Email - image with email text created on fly
Phoneno - image with number text created on fly
The code I have provided merges text into an image ie name, but only allows me to create one image to send back to browser, how can I try to get my script to send more than one image back to browser?
I have tried adding more parameters to my function function 'create_image($name,$email,$number)' but only prints one field to browser, perhaps something to do with header()?
<?php
//Send a generated image to the browser
$name="Bob";$email="bob@email.co.uk";$number="12345678901";
create_image($name);

function create_image($value)
{

    //Set the image width and height
    $width = 250;
    $height = 20;

    //Create the image resource
    $image = ImageCreate($width, $height);

    //We are making three colors, white, black and gray
    $white = ImageColorAllocate($image, 255, 255, 255);
    $black = ImageColorAllocate($image, 0, 0, 0);
    $grey = ImageColorAllocate($image, 204, 204, 204);

    //Make the background black
    ImageFill($image, 0, 0, $black);

    //Add randomly generated string in white to the image
    //imagestring ( resource $image , int $font-(font size) , int $x-(from left) , int $y-(from right) , string $string , int $color-(font-colour) )
    ImageString($image, 5, 10, 3, $value, $white);

    //Tell the browser what kind of file is come in
    header("Content-Type: image/jpeg");

    //Output the newly created image in jpeg format
    ImageJpeg($image);

    //Free up resources
    ImageDestroy($image);
}
?>

Thanks for any replies

A: $name="Bob";$email="bob@email.co.uk";$number="12345678901";
switch ($_GET['option']) {
    case 'name':
        create_image($name);
        break;
    case 'email':
        create_image($email);
        break;
    case 'number':
        create_image($number);
        break;
}

And call your script with scriptname.php?option=name

A: its not really a best practice, but I i would try to change your function, that it saves the images to a file, and returns the file path, when theres is a valid file.
So you don't have to create every call a new image (which is slow), and you get a valid filepath, which means you don't have to care about headers and so on