text:
Q: How to do linear regression in pgfplots for data with nan? I am trying to use pgfplots to plot a linear regression to my data. If there is a nan in my data set, no fit is generated, with the warning:
NOTE: coordinate (1,nan) has been dropped because it is unbounded (in y).
(see also unbounded coords=jump).

and similar warnings for the other points in the set.
If I set an ignore chars and change the nan to that character, compiling fails with the error:
! Package pgfplots Error: input table '<inline_table>' has an unbalanced number
 of columns in row '2' (expected '2' cols; got '1'). Maybe the input table is c
orrupted? If you need unbalanced data, consider using 'nan' in empty cells (per
haps combined with 'unbounded coords=jump').

The following MWE reproduces this problem:
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\pgfplotsset{compat=1.10}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot table[x=X,y={create col/linear regression={y=Y}}]{
X Y
1 nan
2 1
3 2
4 3
};
\end{axis}
\end{tikzpicture}
\end{document}

How can I have nan in my data set and still generate a fit, or how can I have an ignored character?

A: Currently, PGFPlots can't handle nan values when calculating the regression line. Adding this capability is quite simple though, only two lines need to be added to a (rather long) internal macro.
If you put the following code in your preamble after \usepackage{pgfplots}, your code will work:
\makeatletter
% #1: keys
\def\pgfplotstable@linear@regression#1{%
    \begingroup
    \pgfqkeys{/pgfplots/table/create col/linear regression}{/pgf/fpu,#1}%
    \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/x}{\pgfplotstable@xsrc}%
    \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/y}{\pgfplotstable@ysrc}%
    \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/table}{\pgfplotstable@table}%
    \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/xmode}{\pgfplotstable@xmode}%
    \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/ymode}{\pgfplotstable@ymode}%
    \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/variance}{\pgfplotstable@variance@colname}%
    \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/variance list}{\pgfplotstable@variance@list}%
    \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/variance src}{\pgfplotstable@variance@table}%
    %
    \ifx\pgfplotstable@table\pgfutil@empty
        \pgfutil@ifundefined{pgfplotstablename}{}{% query the name of the actual table struct
            \let\pgfplotstable@table=\pgfplotstablename
        }%
    \fi
    \ifx\pgfplotstable@table\pgfutil@empty
        \pgfplots@error{Sorry, I couldn't determine a value for create col/linear regression/table. Which table should I load?}%
    \fi
    \ifx\pgfplotstable@xsrc\pgfutil@empty
        \pgfplotsifinaddplottablestruct{%
            \pgfutil@ifundefined{pgfplots@plot@tbl@x}{}{%
                \let\pgfplotstable@xsrc=\pgfplots@plot@tbl@x
                \ifx\pgfplotstable@ysrc\pgfutil@empty
                    \pgfplotstablegetcolsof\pgfplots@table
                    \ifnum\pgfplotsretval=2
                    \else
                        \pgfplotsthrow{invalid argument}{\pgfplotstable@ysrc}{Sorry, I don't which column should be used as `y' for the linear regression. Please provide 'linear regression={y=<colname>}'}\pgfeov%
                    \fi
                \fi
            }%
        }{}%
    \fi
    \ifx\pgfplotstable@xsrc\pgfutil@empty
        \def\pgfplotstable@xsrc{[index]0}%
    \fi
    \ifx\pgfplotstable@ysrc\pgfutil@empty
        \def\pgfplotstable@ysrc{[index]1}%
    \fi
    %
    \t@pgfplots@toka=\expandafter{\pgfplotstable@table}%
    \t@pgfplots@tokb=\expandafter{\pgfplotstable@xsrc}%
    \t@pgfplots@tokc=\expandafter{\pgfplotstable@ysrc}%
    \edef\pgfplots@loc@TMPa{{\the\t@pgfplots@tokb}\noexpand\of{\the\t@pgfplots@toka}}%
    \edef\pgfplots@loc@TMPb{{\the\t@pgfplots@tokc}\noexpand\of{\the\t@pgfplots@toka}}%
    \expandafter\pgfplotstablegetcolumn\pgfplots@loc@TMPa\to\pgfplotstable@X
    \expandafter\pgfplotstablegetcolumn\pgfplots@loc@TMPb\to\pgfplotstable@Y
    %
    \edef\pgfplotstable@xmode{\pgfplotstable@xmode}%
    \expandafter\pgfplotstable@linear@regression@prepare@mode\expandafter{\pgfplotstable@xmode}{x}%%
    \edef\pgfplotstable@ymode{\pgfplotstable@ymode}%
    \expandafter\pgfplotstable@linear@regression@prepare@mode\expandafter{\pgfplotstable@ymode}{y}%%
    %
    \ifx\pgfplotstable@variance@list\pgfutil@empty
        % check 'variance' key (loaded from table)
        \pgfplotslistnewempty\pgfplotstable@VARIANCE
        \ifx\pgfplotstable@variance@colname\pgfutil@empty
        \else
            \ifx\pgfplotstable@variance@table\pgfutil@empty
                \t@pgfplots@toka=\expandafter{\pgfplotstable@table}%
                \t@pgfplots@tokb=\expandafter{\pgfplotstable@variance@colname}%
                \edef\pgfplots@loc@TMPa{{\the\t@pgfplots@tokb}\noexpand\of{\the\t@pgfplots@toka}}%
                \expandafter\pgfplotstablegetcolumn\pgfplots@loc@TMPa\to\pgfplotstable@VARIANCE
            \else
                \t@pgfplots@toka=\expandafter{\pgfplotstable@variance@colname}%
                \t@pgfplots@tokb=\expandafter{\pgfplotstable@variance@table}%
                \edef\pgfplotstable@loc@TMPa{%
                    \noexpand\pgfplotstablegetcolumn{\the\t@pgfplots@toka}\noexpand\of{\the\t@pgfplots@tokb}\noexpand\to\noexpand\pgfplotstable@VARIANCE}%
                \pgfplotstable@loc@TMPa
            \fi
        \fi
    \else
        % load from list:
        \expandafter\pgfplotslistnew\expandafter\pgfplotstable@VARIANCE\expandafter{\pgfplotstable@variance@list}%
    \fi
    %
    \pgfplotslistnewempty\pgfplotstable@Xparsed
    %
    \pgfmathfloatcreate{0}{0.0}{0}%
    \let\pgfplotstable@S=\pgfmathresult
    \let\pgfplotstable@Sxx=\pgfmathresult
    \let\pgfplotstable@Sx=\pgfmathresult
    \let\pgfplotstable@Sy=\pgfmathresult
    \let\pgfplotstable@Sxy=\pgfmathresult
    \pgfutil@loop
    \pgfplotslistcheckempty\pgfplotstable@X
    \ifpgfplotslistempty
        \pgfplots@loop@CONTINUEfalse
    \else
        \pgfplots@loop@CONTINUEtrue
    \fi
    \ifpgfplots@loop@CONTINUE
        \pgfplotslistpopfront\pgfplotstable@X\to\pgfplotstable@x
        \pgfplotslistpopfront\pgfplotstable@Y\to\pgfplotstable@y
        %
        \pgfplotstableparsex{\pgfplotstable@x}%
        \let\pgfplotstable@x=\pgfmathresult
        \expandafter\pgfplotslistpushback\pgfmathresult\to\pgfplotstable@Xparsed
        \pgfplotstableparsey{\pgfplotstable@y}%
        \let\pgfplotstable@y=\pgfmathresult
        \pgfmathfloatifflags{\pgfplotstable@y}{3}{}{% <---- This is new. The "3" stands for "nan"
        %
        \pgfplotslistcheckempty\pgfplotstable@VARIANCE
        \ifpgfplotslistempty
            \pgfmathfloatcreate{1}{1.0}{0}%
            \let\pgfplotstable@invsqr=\pgfmathresult
        \else
            \pgfplotslistpopfront\pgfplotstable@VARIANCE\to\pgfplotstable@variance
            \pgfmathfloatparsenumber{\pgfplotstable@variance}%
            \let\pgfplotstable@variance=\pgfmathresult
            \pgfmathfloatmultiply@{\pgfplotstable@variance}{\pgfplotstable@variance}%
            \let\pgfplotstable@sqr=\pgfmathresult
            \pgfmathfloatreciprocal@{\pgfplotstable@sqr}%
            \let\pgfplotstable@invsqr=\pgfmathresult
        \fi
        %
        \pgfmathfloatadd@{\pgfplotstable@S}{\pgfplotstable@invsqr}%
        \let\pgfplotstable@S=\pgfmathresult
        %
        \pgfmathfloatmultiply@{\pgfplotstable@x}{\pgfplotstable@invsqr}%
        \let\pgfplots@table@accum=\pgfmathresult
        \pgfmathfloatadd@{\pgfplotstable@Sx}{\pgfplots@table@accum}%
        \let\pgfplotstable@Sx=\pgfmathresult
        %
        \pgfmathfloatmultiply@{\pgfplotstable@x}{\pgfplots@table@accum}%
        \let\pgfplots@table@accum=\pgfmathresult
        \pgfmathfloatadd@{\pgfplotstable@Sxx}{\pgfplots@table@accum}%
        \let\pgfplotstable@Sxx=\pgfmathresult
        %
        \pgfmathfloatmultiply@{\pgfplotstable@y}{\pgfplotstable@invsqr}%
        \let\pgfplots@table@accum=\pgfmathresult
        \pgfmathfloatadd@{\pgfplotstable@Sy}{\pgfplots@table@accum}%
        \let\pgfplotstable@Sy=\pgfmathresult
        %
        \pgfmathfloatmultiply@{\pgfplotstable@x}{\pgfplots@table@accum}%
        \let\pgfplots@table@accum=\pgfmathresult
        \pgfmathfloatadd@{\pgfplotstable@Sxy}{\pgfplots@table@accum}%
        \let\pgfplotstable@Sxy=\pgfmathresult
        }% <---- This is new.
    \pgfutil@repeat
    %
    \pgfmathparse{\pgfplotstable@S * \pgfplotstable@Sxx - \pgfplotstable@Sx *\pgfplotstable@Sx}%
    \let\pgfplotstable@delta=\pgfmathresult
    %
    \pgfmathparse{(\pgfplotstable@S * \pgfplotstable@Sxy - \pgfplotstable@Sx * \pgfplotstable@Sy) / \pgfplotstable@delta}%
    \let\pgfplotstable@a=\pgfmathresult
    %
    \pgfmathparse{(\pgfplotstable@Sxx * \pgfplotstable@Sy - \pgfplotstable@Sx * \pgfplotstable@Sxy) / \pgfplotstable@delta}%
    \let\pgfplotstable@b=\pgfmathresult
    %
    \pgfplotslistnewempty\pgfplotstable@RESULT
    \pgfplotslistforeachungrouped\pgfplotstable@Xparsed\as\pgfplotstable@x{%
        \pgfmathfloatmultiply@{\pgfplotstable@x}{\pgfplotstable@a}%
        \let\pgfplotstable@tmp=\pgfmathresult
        \pgfmathfloatadd@{\pgfplotstable@tmp}{\pgfplotstable@b}%
        \ifx\pgfplotstableparseylogbase\pgfutil@empty
        \else
            \pgfplotstableparseyinv@{\pgfmathresult}%
        \fi
        \pgfmathfloattosci{\pgfmathresult}%
        \expandafter\pgfplotslistpushback\pgfmathresult\to\pgfplotstable@RESULT
    }%
    \pgfmathfloattosci\pgfplotstable@a
    \let\pgfplotstable@a=\pgfmathresult
    %
    \pgfmathfloattosci\pgfplotstable@b
    \let\pgfplotstable@b=\pgfmathresult
    %
    \global\let\pgfplotstableregressiona\pgfplotstable@a%
    \global\let\pgfplotstableregressionb\pgfplotstable@b%
    \let\pgfplotsretval=\pgfplotstable@RESULT
    \pgfmath@smuggleone\pgfplotsretval
    \endgroup
}%
\makeatother

Full code:
\documentclass[tikz, border=5mm]{standalone}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\pgfplotsset{compat=1.10}

\makeatletter
% #1: keys
\def\pgfplotstable@linear@regression#1{%
    \begingroup
    \pgfqkeys{/pgfplots/table/create col/linear regression}{/pgf/fpu,#1}%
    \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/x}{\pgfplotstable@xsrc}%
    \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/y}{\pgfplotstable@ysrc}%
    \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/table}{\pgfplotstable@table}%
    \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/xmode}{\pgfplotstable@xmode}%
    \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/ymode}{\pgfplotstable@ymode}%
    \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/variance}{\pgfplotstable@variance@colname}%
    \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/variance list}{\pgfplotstable@variance@list}%
    \pgfkeysgetvalue{/pgfplots/table/create col/linear regression/variance src}{\pgfplotstable@variance@table}%
    %
    \ifx\pgfplotstable@table\pgfutil@empty
        \pgfutil@ifundefined{pgfplotstablename}{}{% query the name of the actual table struct
            \let\pgfplotstable@table=\pgfplotstablename
        }%
    \fi
    \ifx\pgfplotstable@table\pgfutil@empty
        \pgfplots@error{Sorry, I couldn't determine a value for create col/linear regression/table. Which table should I load?}%
    \fi
    \ifx\pgfplotstable@xsrc\pgfutil@empty
        \pgfplotsifinaddplottablestruct{%
            \pgfutil@ifundefined{pgfplots@plot@tbl@x}{}{%
                \let\pgfplotstable@xsrc=\pgfplots@plot@tbl@x
                \ifx\pgfplotstable@ysrc\pgfutil@empty
                    \pgfplotstablegetcolsof\pgfplots@table
                    \ifnum\pgfplotsretval=2
                    \else
                        \pgfplotsthrow{invalid argument}{\pgfplotstable@ysrc}{Sorry, I don't which column should be used as `y' for the linear regression. Please provide 'linear regression={y=<colname>}'}\pgfeov%
                    \fi
                \fi
            }%
        }{}%
    \fi
    \ifx\pgfplotstable@xsrc\pgfutil@empty
        \def\pgfplotstable@xsrc{[index]0}%
    \fi
    \ifx\pgfplotstable@ysrc\pgfutil@empty
        \def\pgfplotstable@ysrc{[index]1}%
    \fi
    %
    \t@pgfplots@toka=\expandafter{\pgfplotstable@table}%
    \t@pgfplots@tokb=\expandafter{\pgfplotstable@xsrc}%
    \t@pgfplots@tokc=\expandafter{\pgfplotstable@ysrc}%
    \edef\pgfplots@loc@TMPa{{\the\t@pgfplots@tokb}\noexpand\of{\the\t@pgfplots@toka}}%
    \edef\pgfplots@loc@TMPb{{\the\t@pgfplots@tokc}\noexpand\of{\the\t@pgfplots@toka}}%
    \expandafter\pgfplotstablegetcolumn\pgfplots@loc@TMPa\to\pgfplotstable@X
    \expandafter\pgfplotstablegetcolumn\pgfplots@loc@TMPb\to\pgfplotstable@Y
    %
    \edef\pgfplotstable@xmode{\pgfplotstable@xmode}%
    \expandafter\pgfplotstable@linear@regression@prepare@mode\expandafter{\pgfplotstable@xmode}{x}%%
    \edef\pgfplotstable@ymode{\pgfplotstable@ymode}%
    \expandafter\pgfplotstable@linear@regression@prepare@mode\expandafter{\pgfplotstable@ymode}{y}%%
    %
    \ifx\pgfplotstable@variance@list\pgfutil@empty
        % check 'variance' key (loaded from table)
        \pgfplotslistnewempty\pgfplotstable@VARIANCE
        \ifx\pgfplotstable@variance@colname\pgfutil@empty
        \else
            \ifx\pgfplotstable@variance@table\pgfutil@empty
                \t@pgfplots@toka=\expandafter{\pgfplotstable@table}%
                \t@pgfplots@tokb=\expandafter{\pgfplotstable@variance@colname}%
                \edef\pgfplots@loc@TMPa{{\the\t@pgfplots@tokb}\noexpand\of{\the\t@pgfplots@toka}}%
                \expandafter\pgfplotstablegetcolumn\pgfplots@loc@TMPa\to\pgfplotstable@VARIANCE
            \else
                \t@pgfplots@toka=\expandafter{\pgfplotstable@variance@colname}%
                \t@pgfplots@tokb=\expandafter{\pgfplotstable@variance@table}%
                \edef\pgfplotstable@loc@TMPa{%
                    \noexpand\pgfplotstablegetcolumn{\the\t@pgfplots@toka}\noexpand\of{\the\t@pgfplots@tokb}\noexpand\to\noexpand\pgfplotstable@VARIANCE}%
                \pgfplotstable@loc@TMPa
            \fi
        \fi
    \else
        % load from list:
        \expandafter\pgfplotslistnew\expandafter\pgfplotstable@VARIANCE\expandafter{\pgfplotstable@variance@list}%
    \fi
    %
    \pgfplotslistnewempty\pgfplotstable@Xparsed
    %
    \pgfmathfloatcreate{0}{0.0}{0}%
    \let\pgfplotstable@S=\pgfmathresult
    \let\pgfplotstable@Sxx=\pgfmathresult
    \let\pgfplotstable@Sx=\pgfmathresult
    \let\pgfplotstable@Sy=\pgfmathresult
    \let\pgfplotstable@Sxy=\pgfmathresult
    \pgfutil@loop
    \pgfplotslistcheckempty\pgfplotstable@X
    \ifpgfplotslistempty
        \pgfplots@loop@CONTINUEfalse
    \else
        \pgfplots@loop@CONTINUEtrue
    \fi
    \ifpgfplots@loop@CONTINUE
        \pgfplotslistpopfront\pgfplotstable@X\to\pgfplotstable@x
        \pgfplotslistpopfront\pgfplotstable@Y\to\pgfplotstable@y
        %
        \pgfplotstableparsex{\pgfplotstable@x}%
        \let\pgfplotstable@x=\pgfmathresult
        \expandafter\pgfplotslistpushback\pgfmathresult\to\pgfplotstable@Xparsed
        \pgfplotstableparsey{\pgfplotstable@y}%
        \let\pgfplotstable@y=\pgfmathresult
        \pgfmathfloatifflags{\pgfplotstable@y}{3}{}{% <---- This is new. The "3" stands for "nan"
        %
        \pgfplotslistcheckempty\pgfplotstable@VARIANCE
        \ifpgfplotslistempty
            \pgfmathfloatcreate{1}{1.0}{0}%
            \let\pgfplotstable@invsqr=\pgfmathresult
        \else
            \pgfplotslistpopfront\pgfplotstable@VARIANCE\to\pgfplotstable@variance
            \pgfmathfloatparsenumber{\pgfplotstable@variance}%
            \let\pgfplotstable@variance=\pgfmathresult
            \pgfmathfloatmultiply@{\pgfplotstable@variance}{\pgfplotstable@variance}%
            \let\pgfplotstable@sqr=\pgfmathresult
            \pgfmathfloatreciprocal@{\pgfplotstable@sqr}%
            \let\pgfplotstable@invsqr=\pgfmathresult
        \fi
        %
        \pgfmathfloatadd@{\pgfplotstable@S}{\pgfplotstable@invsqr}%
        \let\pgfplotstable@S=\pgfmathresult
        %
        \pgfmathfloatmultiply@{\pgfplotstable@x}{\pgfplotstable@invsqr}%
        \let\pgfplots@table@accum=\pgfmathresult
        \pgfmathfloatadd@{\pgfplotstable@Sx}{\pgfplots@table@accum}%
        \let\pgfplotstable@Sx=\pgfmathresult
        %
        \pgfmathfloatmultiply@{\pgfplotstable@x}{\pgfplots@table@accum}%
        \let\pgfplots@table@accum=\pgfmathresult
        \pgfmathfloatadd@{\pgfplotstable@Sxx}{\pgfplots@table@accum}%
        \let\pgfplotstable@Sxx=\pgfmathresult
        %
        \pgfmathfloatmultiply@{\pgfplotstable@y}{\pgfplotstable@invsqr}%
        \let\pgfplots@table@accum=\pgfmathresult
        \pgfmathfloatadd@{\pgfplotstable@Sy}{\pgfplots@table@accum}%
        \let\pgfplotstable@Sy=\pgfmathresult
        %
        \pgfmathfloatmultiply@{\pgfplotstable@x}{\pgfplots@table@accum}%
        \let\pgfplots@table@accum=\pgfmathresult
        \pgfmathfloatadd@{\pgfplotstable@Sxy}{\pgfplots@table@accum}%
        \let\pgfplotstable@Sxy=\pgfmathresult
        }% <---- This is new.
    \pgfutil@repeat
    %
    \pgfmathparse{\pgfplotstable@S * \pgfplotstable@Sxx - \pgfplotstable@Sx *\pgfplotstable@Sx}%
    \let\pgfplotstable@delta=\pgfmathresult
    %
    \pgfmathparse{(\pgfplotstable@S * \pgfplotstable@Sxy - \pgfplotstable@Sx * \pgfplotstable@Sy) / \pgfplotstable@delta}%
    \let\pgfplotstable@a=\pgfmathresult
    %
    \pgfmathparse{(\pgfplotstable@Sxx * \pgfplotstable@Sy - \pgfplotstable@Sx * \pgfplotstable@Sxy) / \pgfplotstable@delta}%
    \let\pgfplotstable@b=\pgfmathresult
    %
    \pgfplotslistnewempty\pgfplotstable@RESULT
    \pgfplotslistforeachungrouped\pgfplotstable@Xparsed\as\pgfplotstable@x{%
        \pgfmathfloatmultiply@{\pgfplotstable@x}{\pgfplotstable@a}%
        \let\pgfplotstable@tmp=\pgfmathresult
        \pgfmathfloatadd@{\pgfplotstable@tmp}{\pgfplotstable@b}%
        \ifx\pgfplotstableparseylogbase\pgfutil@empty
        \else
            \pgfplotstableparseyinv@{\pgfmathresult}%
        \fi
        \pgfmathfloattosci{\pgfmathresult}%
        \expandafter\pgfplotslistpushback\pgfmathresult\to\pgfplotstable@RESULT
    }%
    \pgfmathfloattosci\pgfplotstable@a
    \let\pgfplotstable@a=\pgfmathresult
    %
    \pgfmathfloattosci\pgfplotstable@b
    \let\pgfplotstable@b=\pgfmathresult
    %
    \global\let\pgfplotstableregressiona\pgfplotstable@a%
    \global\let\pgfplotstableregressionb\pgfplotstable@b%
    \let\pgfplotsretval=\pgfplotstable@RESULT
    \pgfmath@smuggleone\pgfplotsretval
    \endgroup
}%
\makeatother

\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot [only marks] table {
X Y
1 nan
2 1
3 2.5
4 3
};
\addplot [no markers] table[x=X,y={create col/linear regression={y=Y}}]{
X Y
1 nan
2 1
3 2.5
4 3
};
\end{axis}
\end{tikzpicture}
\end{document}

A: Run with xelatex. nan is defined as a PostScript function which deletes the x value:
\RequirePackage{filecontents}
\documentclass[pstricks]{standalone}
\usepackage{pst-plot}
\begin{filecontents*}{LSM.data}
X Y
1 nan
1 1
3 1.8
4 3.3
\end{filecontents*}

\begin{document}

\begin{pspicture}(-1,-2)(5,4)
\psaxes{->}(4.5,3.5)
\readdata[ignoreLines=1]{\data}{LSM.data}
\pstVerb{/nan { pop } def }
\listplot[plotstyle=LSM,PstDebug=1,linecolor=blue]{\data}% PstDebug to print the equation
\listplot[plotstyle=dots,linecolor=blue]{\data}
\end{pspicture}

\end{document}


text:
Q: Examples of usage of Generics in .Net (C#/VB.NET) What are some examples of where you would use generics in C#/VB.NET and why would you want to use generics?

A: Example 1: You want to create triple class
Class Triple<T1, T2, T3>
{
   T1 _first;
   T2 _second;
   T3 _Third;
}

Example 2: A helper class that will parse any enum value for given data type
static public class EnumHelper<T>
{
   static public T Parse(string value)
   {
       return (T)Enum.Parse(typeof(T), value);
   }
}

A: Simply, you declare a type or method with extra tags to indicate the generic bits:
class Foo<T> {
    public Foo(T value) {
        Value = value;
    }
    public T Value {get;private set;}
}

The above defines a generic type Foo "of T", where the T is provided by the caller. By convention, generic type arguments start with T. If there is only one, T is fine - otherwise name them all usefully: TSource, TValue, TListType etc
Unlike C++ templates, .NET generics are provided by the runtime (not compiler tricks). For example:
Foo<int> foo = new Foo<int>(27);

All Ts have been replaced with int in the above. If necessary, you can restrict generic arguments with constraints:
class Foo<T> where T : struct {}

Now Foo<string> will refuse to compile - as string is not a struct (value-type). Valid constraints are:
T : class // reference-type (class/interface/delegate)
T : struct // value-type except Nullable<T>
T : new() // has a public parameterless constructor
T : SomeClass // is SomeClass or inherited from SomeClass
T : ISomeInterface // implements ISomeInterface

Constraints can also involve other generic type arguments, for example:
T : IComparable<T> // or another type argument

You can have as many generic arguments as you need:
public struct KeyValuePair<TKey,TValue> {...}

Other things to note:

*

*static members etc are defined per generic type combination - so a static field on Foo<int> is separate to that on Foo<float>.

*methods can be generic too - try to avoid using the same names as the class uses, as you won't be able to disambiguate

*nested types inherit the generic types from their parents

for example:
class Foo<T> {
    class Bar<TInner> {} // is effectively Bar<T,TInner>, for the outer T
}

A: One common, and extremely helpful, use of generics is strongly-typed collection classes. Traditionally, all collection classes had to be passed objects, and return objects when queried. You had to handle all the type conversion yourself. With generics, you don't have to do that. You can have List(Of Integer), and when you request values from it, you'll get integers. You won't get objects that you then have to convert to integers.

A: The most common reasons and use cases for generics are described in the MSDN documentation mentioned before. One benefit of generics I'd like to add is that they can enhance the tool support in the development process. Refactoring tools like those integrated in Visual Studio or ReSharper rely on static type analysis for providing assistance while coding. As generics usually add more type information to your object model, there is more information for such tools to analyse and to help you coding.
On a conceptual level, generics help you solving "cross-cutting" concerns independently from your application domain. Regardless whether you are developing a financial application or a book store, you will sooner or later need to maintain collections of things, be it accounts, books or whatever. The implementation of such collections usually needs to know little to nothing about the things to be maintained in those collections. Hence, the generic collections shipped with the .NET framework are a primary example for a generics use case.

A:     private void button1_Click_1(object sender, RoutedEventArgs e)
    {
        TextValue<string, int> foo = new TextValue<string, int>("",0);
        foo.Text = "Hi there";
        foo.Value = 3995;
        MessageBox.Show(foo.Text);
    }

    class TextValue<TText, TValue>
    {
        public TextValue(TText text, TValue value)
        {
            Text = text;
            Value = value;
        }
        public TText Text { get; set; }
        public TValue Value { get; set; }
    }

A: A basic example would be:
class Other{
 class Generic<T>
{
  void met1(T x);
}
static void Main()
{
  Generic<int> g = new Generic<int>();
  Generic<string> s = new Generic<string>();
}
}

A:     private void button1_Click_1(object sender, RoutedEventArgs e)
    {
        TextValue<string, int> foo;
        List<TextValue<string, int>> listTextValue = new List<TextValue<string, int>>();
        for (int k = 0; k < 5; ++k)
        {
            foo = new TextValue<string, int>("",0);
            foo.Text = k.ToString();
            foo.Value = k;
            listTextValue.Add(foo);
            otherList.
            MessageBox.Show(foo.Text);
        }

    }

    class TextValue<TText, TValue>
    {
        public TextValue(TText text, TValue value){Text = text; Value = value;}
        public TText Text { get; set; }
        public TValue Value { get; set; }
    }

redpajama_set_name: RedPajamaStackExchange


text:
Q: Solar inverter with mains backup I'm looking for a way to partially power an applicance (a fridge freezer for argument's sake) using solar/renewable energy.
I don't expect the couple of hundred watts of solar power to be sufficient to fully power what I have in mind, but wondered if such a device as the following exists or is easily made so as to reduce energy bills but not have to interfere with the incoming mains power supply or investing in a bank of batteries.
What I'm imagining is a solar inverter which plugs into the mains (230V AC) and also takes 12V DC as input (from the panels), and only uses mains power to "top up" any requirements not met by solar, with a 3 pin UK plug socket as output to plug the appliance into?
Does such a device exist, and if it doesn't is there good reason for it not to exist?
[edit] I've found this http://www.amazon.co.uk/dp/B00C0D8C3W but it's unclear whether it will flow back into the grid?

A: If you have a solar powered inverter that works some of the time (because the sun don't shine all the time) AND your inverter works from 12V (from some kind of solar regulator and battery?) then why complicate things by trying to get your fridge/freezer dual powered from the inverter output and mains AC.
Simplest way (to me) is take your AC mains, step it down with a transformer, convert to DC (bridge rectifier), regulate to +13.4 volts and feed onto the 12V your inverter is using. Call it a "power supply".
If the solar stuff aint producing the goods (energy wise), the 12 volts will be topped-up from the power supply. If the solar panels are producing the energy then, by careful control of the "power-supply", it'll barely consume any energy.
I think this overcomes several headaches of trying to ensure your solar inverter AC output doesan' "clash" with the real AC mains.

A: To add to Andy's post. So, you have your solar array and your power supply, feeding and building up the batteries. but as others mentioned, it's a very inefficient system. So there are units available to handle it another way.
The AC into the house goes through a relay which is normally selected to feed city AC to the appliance(s)
The solar panels feed a battery "pack" which feeds an inverter after the charge is full. This triggers the relay to switch over to the inverter output. When the charge goes too low to feed proper AC current out of the inverter, the relay switches back to city AC.
Now you are providing some of your own power while still having enough to power everything.


text:
Q: How to use python-docx to insert an image into a word's self-selected graphic? I have a word document, such as Figure 1, the black part on the left is a self-selected graphics.

I now want to insert a picture in the self-selected graphic on the left, and the effect after insertion is shown below:

How to use python-docx to achieve the above function?


text:
Q: Ckeditor.js:211 - Cannot set property "dir" of undefined ( issue occurs for only one user) For some reason this error is coming up but only on one persons machine and CKeditor will not load  Cannot set property of "dir" undefined - line 211 ckeditor.js, I have tested the same setup in my machine with no issues.
For the same url path it works for me, but it shows "Failed to load resources: net:: ERR_CONTENT_DECODING_FAILED " for that particular user.enter image description here


text:
Q: Polynomial Ring of Linear Algebraic Group During lectures, we defined the Linear Algebraic group as the algebraic set
$
GL(V):=k^{n^2}-V(Det)
$
Where $V(Det)$ are the matrices with $0$ determinant.
Then we proceed by identifying the polynomial ring of $GL(V)$ as
$
k[GL(V)]=k[T_{1,1},...,T_{n,n},1/(det(T_{i,j}))]
$
What is this identification? is $T_{1,1}$ just taking the element in position 1,1 of the matrix? Why is it written in this way?
I am ok that $k[V]\cong k[X_1,...,X_n]$ if $k$ is of dimension $n$ but I can't connect it with $k[GL(V)]$.
Thanks for your help!

A: $k[\mathbb{A}^{n^2}] = k[T_{1,1},\dotsc,T_{n,n}]$ should be known. If you identify $\mathbb{A}^{n^2}$ with $\mathbb{A}^{n \times n}$ (matrices), then in fact $T_{ij}$ is the regular function which evaluates the matrices at the entry $(i,j)$.
In general, if $f$ is a regular function on an affine variety $X$, then $k[X \setminus V(f)] = k[X][1/f]$. This is a basic fact which can be found in every text on algebraic geometry. Now apply this to $X=\mathbb{A}^{n \times n}$ and $f = \mathrm{det}$.
In order to illustrate this, here is an example: For $n=2$ we have $k[\mathrm{GL}_2] = k[T_{11},T_{12},T_{21},T_{22},1/(T_{11} T_{22} - T_{12} T_{21})]$. For example, $(T_{11}+T_{22})/(T_{11} T_{22} - T_{12} T_{21})$ is contained in this ring. As a regular function on $\mathrm{GL}_2$ it maps an invertible matrix to its trace divided by its determinant.

A: $k^{n^2}$ is identified with the vector space generated by the entries of the matrices. $T_{ij}$ is the indeterminate representing the entry at position $i,j$ and this corresponds to the $i,j$th coordinate in $k^{n^2}$ . All polynomials on the general linear group can have roots except for multiples of the determinant, so the determinant is invertible.


text:
Q: Calculate the intersection (x,y) between f(x) and g(x), in limits range a and b Input (from file):
x^2-x+2,
x^3-1,
-2 2

Desired output:
intersection: (1.5747,2.9051)

I need to calculate the x,y coordinate intersection between two math functions using Newton Rephson algorithm, first, I input from the file then use func_sum to calculate the two function f and g, and send h function (res of f and g) to the NR function to find the root. I'm not sure if I'm doing it right, I'm trying to find a solution.
import random

def diff(f):
    ''' returns the numeric derivative of f '''
    h = 0.000001
    return (lambda x: (f(x+h)-f(x))/h)

def NR(f, epsilon=10**(-10), n=100):
    ''' finds an approximation to a root of
    f using the Newton Raphson method '''
    deriv = diff(f)
    x0 = random.uniform(-10, 10)
    while (abs(deriv(x0))<epsilon):
        x0 = random.uniform(-10, 10)
    x=x0; y=f(x); count=1
    print("{0}. x={1}, f(x)={2}".format(count,x,y))
    while(abs(y) > epsilon and count <= n):
        count += 1
        y=f(x)
        x = x - y/deriv(x)
        print("{0}. x={1}, f(x)={2}".format(count,x,y))
    if count > n:
        return None
    return (lambda a,b : x in range(a,b))

def func_sum(f_Func, g_Func):
    ''' function calculate the sum of f and g '''
    def h(x):
        return f_Func(x) + g_Func(x)
    return h

def main():
    f=open('input.txt','r')
    line=f.read().split('\n')
    f_Func = eval('lambda x:'+ line[0]) # f(x)
    g_Func = eval('lambda x:'+ line[1]) # g(x)
    h_Func = func_sum(f_Func,g_Func)
    # f(h) = f(x)+ g(x)
    limts = line[2].split()
    a = int(limts[0]) ; b = int(limts[1]) # a b are limits
    print('intersection: ', NR(h_Func)(a,b))

main()


text:
Q: postgresql unable to start postgresql log file:

* Starting PostgreSQL 9.1 database server
* The PostgreSQL server failed to start. Please check the log output:
2012-02-24 04:26:07 GMT FATAL:  "/var/lib/postgresql/9.1/main" is not a valid data directory
2012-02-24 04:26:07 GMT DETAIL:  File "/var/lib/postgresql/9.1/main/PG_VERSION" does not contain valid data.
2012-02-24 04:26:07 GMT HINT:  You might need to initdb.

this happened when my ubuntu oneiric crashed. What to do now? Thank you.

A: I had the same problem. This file only contains the version of postgreql, so it should contain '9.1'.
So just try:
echo 9.1 > "/var/lib/postgresql/9.1/main/PG_VERSION"

and start the DB server again with:
service postgresql start

Have fun, MBR.


text:
Q: How to use dictionary inside regex in python? Using a variable inside regex is easy and one way of achieving this is as:
>>> z = '23'
>>> re.sub(r'p[kv]', r"%s" %z, 'pvkkpkvkk')
'23kk23vkk'

But what if the replacement values are stored in a dictionary as:
d = {'k':'23', 'v':'24'}

and I want to use the dictionary to substitute the replacement values. I want something like this:
re.sub(r'p([kv])', r"%s" %d[\1], 'pvkkpkvkk')

I know this won't work. Please help me out to find the correct regex. Expected output is same as above.

A: You can pass an arbitrary function, that takes a single match object and returns a string to replace it, as the repl for re.sub; for example:
>>> import re
>>> d = {'k': '23', 'v': '24'}
>>> re.sub(
    r'p([kv])',
    lambda match: d[match.group()[1]],
    'pvkkpkvkk',
)
'24kk23vkk'


text:
Q: Sudo giving error after installing homebrew and Laravel Valet I had just installed homebrew and afterwards I installed Laravel Valet.
I am now not able to run any sudo commands at all, and it basically broke my computer.
This is the errors I get when running sudo in terminal
>>> /etc/sudoers.d/brew: Alias `BREW' already defined near line 1 <<<
>>> /etc/sudoers.d/valet: Alias `VALET' already defined near line 1 <<<
sudo: parse error in /etc/sudoers.d/brew near line 1
sudo: no valid sudoers sources found, quitting

Any help appreciated
This is my sudoer for /etc/sudoers.d/brew:
Cmnd_Alias BREW = /usr/local/bin/brew *
%admin ALL=(root) NOPASSWD: BREW

And this is my sudoer for /etc/sudoers.d/valet:
Cmnd_Alias VALET = /usr/local/bin/valet *
%admin ALL=(root) NOPASSWD: VALET

A: The problem seems when trying to disable password requirement for group admin or users brew and valet. Try to change each sudoers.d file to something as :
Cmnd_Alias BREW = /usr/local/bin/brew *
brew ALL=NOPASSWD: ALL

or in a general way, as inside admin group
Cmnd_Alias BREW = /usr/local/bin/brew *
%admin ALL=NOPASSWD: BREW


text: Q: Application Insights QuickPulse (live metrics stream) not showing up I have an ASP.NET Core 3.1 web app, hosted in IIS, behind a corporate proxy. I've already configured the HttpClient's default proxy in startup.cs, so I'm receiving request telemetry and so on. The problem is, the live metrics stream isn't working - my server doesn't show up. I've also configured the system proxy (via inetcpl.cpl) and it still doesn't work. Any ideas on what else I could try?


text:
Q: Can't get rid off "Login failed for user IIS APPPOOL\NETWORKSERVICE" I'm trying to access a sql server database from an ASP NET app configured to work with IIS.
I have several questions now,
1) Authentication in IIS: I need to know if my authentication settings for the site are ok:

I tried with Windows Authentication set to Disabled, but the problem continues.
2) Are the settings for the user NT AUTHORITY\Sericio de red well configured? ("Servicio de red" means Network Service)

3) When I added the login for network service, I only found "Servicio de red", I guess it's the equivalent for NetworkService, I'm I right?, My windows 7 ultimate is an spanish version, I just changed the windows interface by using a windows upgrade to make it appear in english. Is there a problem with it?, I guess it's right because the access to the database is being done through the IIS APPPOOL\Servicio de red user.
My DefaultAppPool identity is set to to AppPoolIdentity
If you want to see what I have tried, see this thread.
The whole project, along with a backup of the database I'm using can be found here, called MyServiceSolutionInIIS
What I'm trying is to build a WCF Data Service that offers information that comes from an entity data model generated from a sql server database. This service will be used by a WPF App as a client.
I'd like to avoid creating a user for it, I think it can be done with the App Pool

A: Okay so the way this works is, whatever application pool your endpoint is running under passes its credentials to the SQL Server. So, you have two options:

*

*Run the default application pool under NetworkService, or;

*Use SQL Authentication when connecting with your web service to the SQL Server.

Honestly, the latter is the most common, but in your situation you may be just fine by changing the default application pool to run under NetworkService.

A: This has nothing to do with the authentication you've chosen (well, mostly nothing.. you can control which credentials anonymous users run under).  Every website runs in an app pool, and this app pool has an AppPoolIdentity.
I'm a little confused as to why it would be claiming it's IIS AppPool\NetworkService, since NetworkService should be NT AUTHORITY\NetworkService, or IIS AppPool\MyAspService or IIS AppPool\DefaultAppPool.
There is a lot more information on App Pool Identities here:
http://www.iis.net/learn/manage/configuring-security/application-pool-identities
Note: There is a bug in IIS 7.5 (the version of IIS that comes with Windows 7 and Windows Server 2008 R2) that sometimes causes authentication problems with AppPoolIdentities if the users password changes (say, if you have mandatory password change policies).  There is a hotfix here:
http://support.microsoft.com/kb/2545850/en-us
More info here:
IIS application using application pool identity loses primary token?

A: There so many scenarios in which this issue occurs.
First thing you need to clear if you are using windows authentication and you are not mentioning any username password in your connection string then:
What happens when you run your code through localhost: when you run your wcf test client from localhost, it will be able to communicate to database as local debug mode application is calling database by your account's service. So it has access to database because devenv.exe is running under your user account.
But when you deploy your web service in IIS. Now understand this service runs under IIS not under your account. So you need to assign access rights to IIS service to access the sql server for windows authentication. Here your web service would not be able to communicate to the SQL server because of access rights issue and Login Failed for user_______ (here your user will come)
So if you are using windows authentication to connect your database, you just have to change the IIS Application pool settings. You need to change IIS Application pool's identity to:
local System (for single windows user).
Network Service (for intranet users or domain users)
Below are the Steps for windows authentication WCF:
•Open IIS (windows+R (run) then type inetmgr, then click ok)
•double click your PC name under Connections
•Click Application Pools
•Select your app pool (DefaultAppPool)
•Then under actions on the right click Advanced Settings:
•Go to Process Model section and
•click on Identity.
•Now select LocalSystem (for single windows authentication user).
 or select Network Service (for Intranet users)
Now open your sql server management studio: open run-> then type ssms then press ok in ssms, login using your windows authentication account. open security tab expand logins tab then you will be able to view your account.
Now open properties of your account go to userMapping then select the database you want to connect then check the role membership services you want to use for the selected database click ok. (For network services i.e. intranet users you need to configure above settings for NT AUTHORITY\SYSTEM user too)
add Trusted_Connection=True; property in your connection string. Save it & deploy the web service. Restart app pool.
you will be able to connect the database now.


text:
Q: Why the fetchall is returning a list with only one element, that is a tuple which contains a string with the tuples instead of a list of tuples? It returns this:
[('("Murder in the First (1995)",2018,57)',), ('("U-571 (2000)",2020,53)',), ('("Money Train (1995)",2019,52)',), ('("Picnic at Hanging Rock (1975)",2019,52)',)]

Instead of this:
[("Murder in the First (1995)",2018,57),("U-571 (2000)",2020,53),("Money Train (1995)",2019,52), ("Picnic at Hanging Rock (1975)",2019,52)]

Here is my code:
`
        db_conn = None
        db_conn = db_engine.connect()

        db_result = db_conn.execute(select([func.getTopSales(2018,2020)]))

        print(db_result.fetchall())
        return db_result

`
I try to getting it as a dict and adding to a list because the values are the tuple but in string, but when I cast it it does not work.
The psql code of the function is this:
`
create or replace function getTopSales(y1 int, y2 int)
returns table (titulo char,
               año int,
               ventas int) as $$
    with prod_year_sales as ( /*The products with their sales and the year of the sale*/
    select
        orderdetail.prodid,
        extract (year from orders.orderdate) as "year",
        count(orderdetail.prodid) as sales
    from
        orderdetail
    natural join
        orders
    where
        extract(year from orders.orderdate) between y1 and y2 group by orderdetail.prodid, "year"),
    max_sales_year_prod as ( /*The products with most sales by year*/
    select
        a.prodid,
        a."year",
        a.sales
    from
        prod_year_sales a
    inner join (
        select
            "year",
            max(sales) sales
        from
            prod_year_sales
        group by
            ("year")) as b on
        a."year" = b."year"
        and a.sales = b.sales)
    select /*Get title of the movies that correspond to the sold products*/
        movietitle,
        main."year",
        sales
    from
        imdb_movies im
    inner join (
        select
            movieid,
            "year",
            sales
        from
            max_sales_year_prod m
        inner join products p on
            m.prodid = p.prodid) as main on im.movieid  = main.movieid order by(sales) desc;
$$ language sql;

`
This is the function that the python file is calling and expect the same as if I execute a query.


text:
Q: Updating prop from child component and re-using it again (Beginner at React at work, building first app to learn it.)
It's explained better with this Codesandbox
Main component renders a pokemon list and has two <PokemonBio /> and <Pagination /> child components. <PokemonBio /> has filteredPokemon prop passed to it which is a filter bound to input, <Pagination /> has that same prop, but it's only rendered once. How <Pagination /> works is take the same prop and break it down into currentPokemons which is a part of the whole array only shown on the clicked 'page'.
Because <Pagination /> doesn't re-render, the filteredPokemon prop won't update. So inside the <Pagination /> I thought to emit the currentPokemons to the parent component and pass that down as as a prop instead of the filteredPokemon, but this is just confusing and doesn't seem efficient. In the end I would like to use the input and pagination on the same data. I'd appreciate any help or tips.

A: so there were multiple issue, main one being passing props to state. So when props value changes it wont reflect on state. To solve this either you have to update state whenever props changes using componentDidUpdate or consume prop directly which is best option.
Others were like items with same Id, looping over same thing twice & logic issues.
Final solution can be found here
I quite enjoyed this, dealing with pagination is not easy.

A: The problem is with the render key, you should change the "id" on the PokemonData page so each pokemon has a unique id.


text:
Q: Overload resolution ambiguous I have following code:
void f(bool);
void f(std::function<bool()>);

int main()
{
    f([](){ return true;});
}

This is an ambiguous call in clang/gcc but works in vs. Link: https://godbolt.org/z/xcuoIN
Why is this happening. Bool and function returning bool are different types.


text:
Q: How can I batch convert videos into 4:3? I've got about 112 videos, each ~240MB. All of them are in 16:9 and I'd like to change them to 4:3.
What's the most nonresource-intensive and convenient way I can accomplish this without losing any quality?

A: You can use ffmpeg.
ffmpeg -i <input, use a glob> -vf scale=<resolutionx>x<resolutiony>,setdar=16:9

A single command should do it.

A: Most video converters will stretch the image vertically.
You will need to find one that will convert the 16:9 video so it is minimized and
has black borders on top and bottom, or people are going to appear elongated.
For a list of converters, see the article
Best Free Audio-Video Format Conversion Program.
You will just have to experiment until you find a converter that does it correctly.


text:
Q: How can I get the color of a pixel on screen with Node.js or C? I am trying to get the color of a pixel on my screen using node.js. I want it to be returned in RGB format, e.g. (255, 0, 0). My current solution is to use screenshot-desktop to screenshot my entire screen in JPG format, decode it to get the raw pixel data, and get the color of a given pixel. However, this lags out my entire computer for 1-2 seconds as it is taking the screenshot. This is unusable as I would like to do this multiple times per second. So my question is: How can I get the color of a given pixel on the screen, without taking a full screenshot?
I am using Linux with X11. There is an X11 library for node.js, so I asssume I should use that to get the pixel color, I'm just not sure how. If you could show me how to do it in C then I can easily use node.js to do the same thing.
Thanks!

A: Oh my gosh I just figured it out after posting this. I was using robotjs for reading the mouse position and I totally forgot it can do screen stuff too! So, the solution would be to do
var robot = require('robotjs');
var color = robot.getPixelColor(x, y);

A: X11 solution using x11 node library ( I am the author ):

*

*query windows tree with QueryTree starting at the root window

*get every child geometry using GetGeometry request

*if your point is not inside any child, use current window id and get 1x1 pixmap from the current image: GetImage(format, currentWindow, x, y, 1, 1, planeMask) ( 2 for format and 0xffffffff for plane mask should work ). Make sure you calculate relative x y position as you travers windows tree.

*if child window covers your point query children for that window and repeat again. Note that QueryTree returns windows in bottom to top stacking order so make sure you pick last one covering your point

Once you have 1x1 pixmap from the topmost window under your point - the buffer should contain only color bytes for your image, RGB order and bit mask might depend on red_mask, green_mask, blue_mask from display.screen[0].depths[visual].
If you cache "topmost window" between requests and only start from root when no match anymore the above solution might be much more performant then the one using robotjs ( although much more low level and complicated ) Good luck!


text:
Q: Converting FTP data sync to Azure services I have an old legacy application built on .NET remoting, and transferring data via XML via with FTP.
Esentially, a CRM system is sending XML files to a directory on the web server, which has a windows service that uses a filewatcher to process the incoming XML file, updating the database.
Similarly, changes on the web application serialize down into an XML file into an out folder, that the CRM polls via FTP every 5 minutes.
Trying to map the best services to convert this to for Azure.

A: You could use Azure Blobs or Azure Files for this.
Azure Blobs: This is the lowest cost option, while still providing high throughput. However, note that Azure Blobs do not have File Watcher functionality, so you would have to poll the directory every few minutes to check for a new file. If you delete files after processing them, then this is really easy - all you have to do is list and see if there are any files. If you want to retain the files, then you might have to do more, since the file list will get big over time. Let me know if this is the case and I can suggest some options.
Azure Files: This is an SMB share that you can mount from a VM in the same region. This will map pretty closely to your exising filesystem based code, including FileWatcher. However, note that Azure Files can only be mounted by a VM in the same region.


text:
Q: FORTRAN: Save array and use in another programme Is it possible to create an array in one programme and then use it in other programmes? The array I am looking to create is very large and its creation will take a while so I don't want to make it anew every time I run the main programme but instead just use it after creating it once in the other programme. Because of its size I'm not sure if printing it to file and then reading it back in would not also be quite inefficient?
It is an integer array of dimensions 1:300 000  and 100.

A: Long comment:
There are many formats in which you can save data: Fortran unformatted sequential, Fortran unformatted direct, Fortran unformatted stream, NetCDF, HDF5, VTK, ...  Really difficult to answer this with any definite answer. We really don't know how time consuming it is to compute it, so we cannot judge whether saving would be more time consuming or not.
Definitely you should be looking for unformatted or binary formats.
Edit: your array is actually not that big. The saving and reading will ne quick. Just use an unformatted file form.


text:
Q: Use Closure Library inside Chrome DevTools I've checked out the Closure library as instructred, but can't find a way to use the library (i.e. goog.require('math') inside the Console just for trying it out and testing purposes.
Thanks in advance.

A: Once Closure Library's base.js is loaded, you can reference the library in the Chrome Dev Tools console.
closure-test.html (load base.js)
<!doctype html>

  <title>Closure Library Test</title>

Closure Library Test

Chrome Dev Tools Console
> goog.require('goog.math');
<* undefined

Observing Resources | Frames | (closure-test.html) | Scripts, math.js will be loaded.
> goog.math.modulo(-1, 8);
<* 7


text:
Q: Trying to convert Rich Text to HTML with embedded images and file attachments I've been reading about some xPages functionality about wrapping a document with DominoDocument.wrap(...) that is supposed to do this for you.  However, I am in a stand along Java program.
Is it possible to get the xPages Jar Files to import into my application somehow?  I do have the basic Notes Jars working.

A: it is unlikely you will get this working using the DominoDocument class. when you wrap the Document, it creates a 'DominoRichTextItem', during this process it extracts the attachments to the local filesystem so that the web server can easily serve the content during the user's browsing/editing session.
this attachment extraction process relies on the user's session information, as well as the xpages applications 'persistence service'.
you are better of trying to emulate this idea by using the standard notes API to extract the text/html mime part, and the extracting attachments/inline image mime parts for whatever your purpose


text:
Q: dplyr - mutate_each - colswise coercion to POSIXlt fails I recently came across dplyr and - as a newbie - like it very much. Hence, I try to convert some of my base-R code into dplyr-code.
Working with air traffic control data, I am struggling with coercing timestamps using lubridate and as.POSIXlt to parse  timestamps embedded in a mutate_each() call. I need the POSIXlt format as I have to work with local times (at different locations) later on.
Reading in the data delivers a data frame of characters. The following is a simplistic example:
ICAO_ADEP <- c("DGAA","ZSPD","UAAA","RJTT","KJFK","WSSS")
MVT_TIME_UTC <- c("01-Jan-2013 04:02:24", NA,"01-Jan-2013 04:08:18", NA,"01-Jan-2013 04:17:11","01-Jan-2013 04:21:52")
flights <- data.frame(ICAO_ADEP, MVT_TIME_UTC)

The function I wrote reads as follows:
make_POSIXlt <- function(vec, tz="UTC"){
vec <- parse_date_time(vec, orders="dmy_hms", tz=tz)
vec <- as.POSIXlt(vec, tz=tz)
}

The code works fine when executed with a single column:
flights$MVT_TIME_UTC <- make_POSIXlt(flights$MVT_TIME_UTC)

If I run the following dplyr code the function fails:
flights$BLOCK_TIME_UTC <- mutate_each(flights, funs(make_POSIXlt(.)), MVT_TIME_UTC)
Error: wrong result size (9), expected 6 or 1

The issue should be linked with the as.POSIXlt call. If this line is commented out the code works within mutate_each and coerces the timestamp into POSIXct.
Any idea/help on what is wrong?
Obviously, my data has several timestamps that I would like to coerce with mutate_each (or any other suitable dplyr function) ...

A: Revisiting my question about 4 years later, I realised that I forgot to mark it as answered. However, this also gives me the chance to document how this (relatively) simple type coercion can (meanwhile) elegantly solved with dplyr and lubridate.
Key lesson learned:

*

*never use POSIXlt with a data frame (and its later brother tibble,
although you can now work with list columns).

*coerce date-timestamps with the helpful parser functions from the lubridate package.

For the example from above
ICAO_ADEP <- c("DGAA","ZSPD","UAAA","RJTT","KJFK","WSSS")
MVT_TIME_UTC <- c("01-Jan-2013 04:02:24", NA,"01-Jan-2013 04:08:18", NA,"01-Jan-2013   04:17:11","01-Jan-2013 04:21:52")
flights <- data.frame(ICAO_ADEP, MVT_TIME_UTC)

flights <- flights %>% mutate(MVT_TIME_UTC = lubridate::dmy_hms(MVT_TIME_UTC)

will coerce the timestamps in MVT_TIME_UTC. Check the documentation on lubridate for other parsers and/or how to handle local time zones.


text:
Q: NullPointerException from Eclipse Compiler I am receiving the following message from my Eclipse compiler, and my project fails to compile....
Internal compiler error: java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.problem.ProblemReporter.missingTypeInMethod(ProblemReporter.java:5075)
I've tried updating Eclipse, restarting eclipse, closing and opening the project, refreshing, cleaning/rebuilding, etc.  I'm out of ideas.

A: That seems to be the bug 250297, fixed in eclipse 3.4.2. Also fixed in the 3.5 (M4, November 2008, as mentioned in this JDT release notes)

The failure occurs on line (>>>):

public void missingTypeInMethod(MessageSend messageSend, MethodBinding method)
{
    List missingTypes = method.collectMissingTypes(null);
>>> TypeBinding missingType = (TypeBinding) missingTypes.get(0);

It would indicate that though we identified a missing type (which we try to complain against), we fail to locate it inside the method signature...

So... if you are using an "older" version of eclipse (like 3.4, or 3.4.1), a good solution is to upgrade (that is, install another fresh version of eclipse, 3.4.2 or 3.5.1), while reusing your same workspace.
The error should then go away.

A: I had this problem as late as Eclipse Luna (4.4). The only way I found to get rid of it was to upgrade to Eclipse Mars (4.5.0). I don't know if this is relevant to the issue, but I upgraded to java 8 shortly before the problem arose.
HTH.


text:
Q: chromeless is not saving image in correct location [OSX] [node 8.4.0] [chromeless 1.3.0]
I am trying to implement a test using chromeless.  I am running the sample in a local instance, with one change of specifying the imagePath to save the image. It is running and saving an image however the image is being saved in the default location still. Any ideas on what I am doing wrong? My desire is to save the image relative to the directory the test was executed in.
Modified line below.
.screenshot({ filePath: './images/test1.png'} );

As I said it all runs but the image is still saved in the following location
/var/folders/r1/4xfjz/T/cjavyrbo70000kk.png

A: Looks like a known problem. See https://github.com/graphcool/chromeless/issues/282


text:
Q: where to release NSArray used in different methods of same class In my iOS project i am creating an NSArray that can contains integer values. There are several functions in this class that do their task on that NSArray. So i thought to create NSArray as private attribute of that class. In viewDidLoad i am allocating memory to this array i.e
myArray = [[NSArray alloc] init];

myArray will be used in several method of this class. When i analyze my code it shows memory leak as i am allocating myArray and not releasing it.
If i write [myArray release] in dealloc or viewDidUnload warning still there. If i release myArray in last method of class that is using this array, xCode wont allow me to do.
Here is How i am declaring it in my class
.h file
@interface FightVC : UIViewController
{
    NSArray *myArray;
}

I want to know what is possible solution of this. other then using autorelease . I don't want to make it public so i am not writing this array as property.
Thanks in advance

A: Using a private @property as mentioned in the other answer is probably the nicest and cleanest way to do this. Raw instance variables aren't a very modern way of doing things. However, if you are going down that road, you can implement a getter for your ivar in which you release the old ivar and retain the new one:
- (void)setMyArray:(NSArray *)array {
    [myArray release];
    myArray = [array retain];
}

That's the typical pattern anyway (which is what having an @property does for you automatically).
After that, you can create the array, use the setter, and then release the object:
NSArray *newArray = [[NSArray alloc] init];
[self setMyArray:newArray];
[newArray release];

That should keep the analyzer from squawking at you. A few things stick out to me though:
1) [[NSArray alloc] init] isn't likely to do what you want it to do. It's going to create an empty, immutable array. You probably either want an NSMutableArray, or you want to instantiate it with objects already in it using a different initializer.
2) NSArrays aren't really suited for holding integers themselves, they hold objects. You can either use an NSPointerArray or you can put the integers into NSNumbers and put them into an NSArray.

A: To make a property private, you have to create an anonymous category.
In your .m file:
@interface myClass ()

@property (nonatomic, retain) NSArray *myPrivateArray;

@end

@implementation myClass

// Class code here

@end

To release your array, simply set the property to nil.
self.myPrivateArray = nil;


text:
Q: Problems with strtotime() on remote server I am having trouble with strtotime working on the localhost, but not the remote server.
I am using the following code to parse the dates for the days in each week;
$monday = date('Y-m-d', strtotime('monday this week +'.$x.' week'));
$tuesday = date('Y-m-d', strtotime('tuesday this week +'.$x.' week'));
$wednesday = date('Y-m-d', strtotime('wednesday this week +'.$x.' week'));
$thursday = date('Y-m-d', strtotime('thursday this week +'.$x.' week'));
$friday = date('Y-m-d', strtotime('friday this week +'.$x.' week'));
$saturday = date('Y-m-d', strtotime('saturday this week +'.$x.' week'));
$sunday = date('Y-m-d', strtotime('sunday this week +'.$x.' week'));

This works correctly in localhost.
On the remote server it returns;
2018-10-22
2018-10-22
2018-10-22
2018-10-22
2018-10-22
2018-10-22
2018-10-28

So it is parsing the correct date for Monday and Sunday.  Every other day parses the same date as Monday.

A: The server was running php version 5.6.
The issue was resolved by installing version 7.1.


text:
Q: Mvc 4 View utilizing wrong model I have this error: http://i.imgur.com/C4xKucH.png
I know my Message model isent queryable. I'm intending to use a diffrent model, and I don't quite know why/how it is using my "Message" model. I'm intending to use my model "GraphModel". This is how my View looks:
@model ChatProj.Models.GraphModel
@using Infragistics.Web.Mvc
@using System.Linq
@{
    ViewBag.Title = "RealTime chart";
}
<style>
    #chart1
    {
        position: relative;
        float: left;
    }
    #legend1
    {
        position: relative;
        float: left;
        margin-left: 15px;
    }
</style>
<script type="text/javascript">
    $.ig.loader({
        scriptPath: "js/",
        cssPath: "css/",
        resources: "igDataChart.Category"
    });

    $.ig.loader(function () {
        var queued = 0, data = [], updateData, currCPU = 10.0, currMem = 1024, connection;

        $("#chart1").igDataChart("option", "dataSource", data);
        $("#chart1").igDataChart("option", "series", [{
            name: "series1", dataSource: data
        }, {
            name: "series2", dataSource: data
        }]);
        $("#chart1").igDataChart("option", "axes", [{
            name: "xAxis", dataSource: data
        }]);

        var updateData = function (newItem) {
            data.push(newItem);
            $("#chart1").igDataChart("notifyInsertItem", currCPU, data.length - 1, newItem);
            queued++;
            if (queued > 2000) {
                oldItem = data[0];
                data.shift();
                $("#chart1").igDataChart("notifyRemoveItem", currCPU, 0, oldItem);
                queued--;
            }
        }

        var generateRandomItem = function () {
            var newItem = {}, currDate = new Date(),
            hours = currDate.getHours(), minutes = currDate.getMinutes(),
            seconds = currDate.getSeconds();

            if (Math.random() > .5) {
                currCPU += Math.random() * 2.0;
            } else {
                currCPU -= Math.random() * 2.0;
            }

            if (Math.random() > .5) {
                currMem += Math.random() * 5.0;
            } else {
                currMem -= Math.random() * 5.0;
            }

            if (currMem <= 0) {
                currMem = 0;
                currMem += Math.random() * 5.0;
            }

            if (currMem > 4096) {
                currMem = 4096;
                currMem -= Math.random() * 5.0;
            }

            if (currCPU <= 0) {
                currCPU = 0;
                currCPU += Math.random() * 2.0;
            }

            if (currCPU > 100) {
                currCPU = 100;
                currCPU -= Math.random() * 2.0;
            }

            if (hours > 12) {
                hours = hours - 12;
            }
            if (hours < 10) {
                hours = "0" + hours;
            }
            if (minutes < 10) {
                minutes = "0" + minutes;
            }
            if (seconds < 10) {
                seconds = "0" + seconds;
            }

            newItem.DateString = hours + ":" + minutes + ":" + seconds;
            newItem.CPUUsage = currCPU;
            newItem.MemUsage = currMem;

            return newItem;
        }

                window.setInterval(function () {
                    var newItem = generateRandomItem();

                    updateData(newItem);
                }, 33);

        /*connection = $.connection('/MessageDataStream');

        connection.received(function (dataItem) {
            var newItem = dataItem;

            updateData(newItem);
        });

        connection.start();*/
    });
    </script>
@(
 Html.Infragistics().DataChart(Model.AsQueryable())
               .ID("chart1")
               .Width("500px")
               .Height("500px")
               .VerticalZoomable(true)
               .HorizontalZoomable(true)
               .WindowResponse(WindowResponse.Immediate)
               .Legend((l) =>
               {
                   l.ID("legend1").Width("150px");
               })
               .Axes((axes) =>
               {
                   axes.CategoryX("xAxis").Label((item) => item.DateString)
                       .LabelExtent(50);
                   axes.NumericY("yAxis")
                       .MinimumValue(0)
                       .MaximumValue(100)
                       .LabelExtent(30);
                   axes.NumericY("yAxis2")
                       .MinimumValue(0)
                       .MaximumValue(4096)
                       .LabelExtent(40)
                       .MajorStroke("transparent")
                       .LabelLocation(AxisLabelsLocation.OutsideRight);
               })
               .Series((series) =>
               {
                   series
                   .Line("series1")
                   .Title("CPU usage")
                   .XAxis("xAxis").YAxis("yAxis")
                   .ValueMemberPath((item) => item.CPUUsage)
                   .Thickness(2);

                   series
                   .Line("series2")
                   .Title("Available Memory")
                   .XAxis("xAxis").YAxis("yAxis2")
                   .ValueMemberPath((item) => item.MemUsage)
                   .Thickness(2);
               }).DataBind().Render()

 )

This is how my controller looks like:
public ActionResult Chart()
        {
            return View(new GraphModel());
        }

I'm wondering why it is trying to use my "Message" and not my intended "GraphModel" model?
Edit: "GraphModel" looks like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ChatProj.Models
{
    public class GraphModel
        : List<GraphData>
    {

    }

    public class GraphData
    {
        //public double messagesPM { get; set; }
        //public string DateString { get; set; }

        public string DateString { get; set; }
        public double CPUUsage { get; set; }
        public double MemUsage { get; set; }

    }
}

And "Message" model looks like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ChatProj.Models
{
    public class Message
    {
        public int MessageID { get; set; }
        public string Name { get; set; }
        public string MessageString { get; set; }
        public DateTime MessageDate { get; set; }

    }
}


text:
Q: Android studio keeps reverting to an older copy of XML I was making changes in one of the xml files in my Android Studio project on Windows 10 then this after clicking Ctrl + s by mistake, it never saves the current file and then I receive this error:
Following errors occurred on attempt to save files: Cannot save blabla.xml. Unable to open the file for writing.
This window keeps appearing prior to building:

A: *

*Copy content of xml, save to place outside of android
studio

*Delete file from android studio

*Create new file with same name

*Copy saved content to new xml.

This fixed my problem invalidate/restart didn't worked.


text:
Q: What are the architecture options for express + socket.io + mongoDB I'm developing a MMO game that needs continous socket connection with the server.
There are some requirements for my architechture.

*

*User Authentication over socket.io connection.

*Realtime user interaction with each other.

*Must handle MASSIVE amount of calculations and database CRUD operations.

*I am targeting modern browsers and planing to use new technologies and old known performance increaser technics like Web workers, Web sockets, Local storage, Link prefetching, Data URI.

The question is:
What are the recommended methods and modules for that kind of application?
Thanx and sorry for my poor language skills.

A: You should try express.io.
It's a realtime-web framework that makes it easy to combine express & socket.io.  Which means that your regular web and realtime web components should play nicely together.
It has session support and routing features.  Also, there is a lot of documentation and example code.
It's way simpler to setup a basic app, then using both libraries separately.
app = require('express.io')
app.http().io()

// your game code goes here :)

app.listen(7076)

For mongo, my favorite is mongo-skin, but mongoose is also very popular.
Best of Luck!
DISCLAIMER: I wrote it :)


text:
Q: Unable to prepare route[api/user] for serialisation. Uses Closure - Laravel LogicException  : Unable to prepare route [api/user] for serialization. Uses Closure.

  at /var/www/html/dev_laravel/vendor/laravel/framework/src/Illuminate/Routing/Route.php:917
    913|      */
    914|     public function prepareForSerialization()
    915|     {
    916|         if ($this->action['uses'] instanceof Closure) {
  > 917|             throw new LogicException("Unable to prepare route [{$this->uri}] for serialization. Uses Closure.");
    918|         }
    919|
    920|         $this->compileRoute();
    921|

  Exception trace:

  1   Illuminate\Routing\Route::prepareForSerialization()
      /var/www/html/dev_laravel/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteCacheCommand.php:62

  2   Illuminate\Foundation\Console\RouteCacheCommand::handle()
      /var/www/html/dev_laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:32

When i trying to run the laravel command
php artisan route:cache

I try to find out the solution but not get the correct solution.
https://github.com/laravel/framework/issues/22034
Is this laravel bug still or fixed the bug?
I have the code on web.php file
Route::get('/', function () {
    return view('welcome');
});
Route::resource('photos', 'PhotoController@index');

I'm Using Laravel 5.8. Just installed and migrated database. I'm beginner for laravel.
Can anyone let me know the correct solution?
Thanks in advance

A: It is not a bug. You can not use Closure based routes like that if you want to cache the routes. Direct any Closure based route to a Controller method instead and you will be fine. [You have one in web.php and the error is pointing out one in api.php]
The Closure based route you have in web.php could be replaced with:
Route::view('/', 'welcome');

This would direct it to a Controller that just handles returning view files.
The Closure based route in api.php should point to a Controller:
Route::middleware('auth:api')->get('user', 'SomeController@user');

Consider any routes that come with the laravel/laravel project as being functional but are there for demonstration purposes.

"Closure based routes cannot be cached. To use route caching, you must convert any Closure routes to controller classes."

Laravel 5.8 - Docs - Controllers - Route Caching

A: EDIT:

AS OF LARAVEL 8.X YOU CAN ALSO CACHE CLOSURE BASED ROUTES

When you run the command php artisan route:cache
Laravel will cache all your routes and store it in specified Cache Driver
Now Comming to your Error Message:
As the error Message Clearly Says that
Closure Routes can't be Cached
And even the Laravel Docs says that Route Caching
By Default Laravel Comes with Four routes files
And this will have 2 Closure based routes
Solution:

*

*You can remove them if you no longer using that routes

*Make a Controller and Move that to Controller

LogicException  : Unable to prepare route [api/user]
Which means that
Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});

This Code in Your routes/api.php is causing the issue So
Route::middleware('auth:api')
->get('/user', 'SomeController@method');

Or you can remove that if not using that

A: You could not use specific method when you use resource for the routing.
You can use
Route::resource('photos', 'PhotoController');

Or
Route::get('photos', 'PhotoController@index');


text:
Q: Не могу заблокировать переход с фрагмента в MainActivity У меня такая проблема:
в MainActivity загружается фрагмент HomeFragment.

Вот, если нажать на кнопку назад, то меня возвращает в MainActivity и соответственно экран белый.
Попытался исправить - добавлял onBackPressed без super - итог, эта проблема исправилась, но у меня в приложении есть другие разделы (тоже фрагменты) и из них вернуться к HomeFragment стало невозможно. Как можно исправить?
Код загрузки фрагмента:
private void loadFragment(Fragment fragment) {
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.replace(R.id.frame_container, fragment);
    transaction.addToBackStack(null);
    transaction.commit();
}

Остальные разделы приложения вызываются этим же кодом из HomeFragment.


text:
Q: Datasnap Delphi XE7 - ApplyUpdates(0) issue I have a datasnap server app developed originally with XE5 that was working fine with a client app on a mobile tablet accessing a Firebird database on a server. I have recompiled the code with XE7.  The only change I had to make to the code to compile without any errors was to add DataSnap.DSProviderDataModuleAdapter to the uses of the methods unit. Have replaced the server app on the server (stop service/uninstall/reinstall/start service) and now I can no longer insert/update records in the database on the server. Whenever I reach the line of code to ApplyUpdates(0) I get the following error:
Remote Error: Access violation at address 0093CB3F in module Snackerservice.exe. Read of address 00000000.
Retrieving data from the database to display on the tablet is not a problem so the connection is working.
If I change the server app back to the one developed under XE5......all works fine again. The other strange thing is that there are no problems with the XE7 compiled app when using 'localhost' to access a copy of the database on my development machine......only when accessing through an IP connection to a server.
Can someone please help me solve this frustrating problem.
Bill Zwirs
To hopefully make it a little clearer, here is a bit of code that causes the issue:
iLic := ServerMethodsClient.Get_Licences;
iDev := ServerMethodsClient.Get_NumDevices;
if (iDev < iLic) then
begin
  iDevID := ServerMethodsClient.Get_NewDevID;
  MobClientDM.DevicesClient.Open;
  MobClientDM.DevicesClient.Insert;
  MobClientDM.DevicesClientDEVID.AsInteger:= iDevID;
  MobClientDM.DevicesClientMACADDRESS.AsString := sMacAddress;
  MobClientDM.DevicesClient.Post;
  if (MobClientDM.DevicesClient.ChangeCount > 0) then
    MobClientDM.DevicesClient.ApplyUpdates(0);         ....................Error occurs here
end;

A: Problem solved at last.
When I installed the server app on the server I also added Midas.dll to the directory which worked fine until I compiled with XE7. So I have now included MidasLib in the uses clause of the server app and removed the Midas.dll file from the install directory. Compiled and installed and all works good again.
Hope this helps others who might have a similar problem.
Bill Zwirs


text:
Q: Extreme point based-packing algorithm (3D) I am trying to implement a 3D packing algorithm using the extreme point-based approach. The paper which introduced this approach can be seen here: Extreme Point-Based Heuristics for Three-Dimensional Bin Packing
At the end of the paper there is also an algorithm (Algorithm 1 Update3DEPL) in pseudo code. I have quite a hard time to understand what the author meant with the following:

*

*What is he referring to with the identifiers Yx, Yz, Xy, Xz, Zx, Zy? I know that he uses this to index the array, however i don't know what he means by this. I am pretty sure tho that the author wants to refer to an pair of axis each time but then again I have no clue what that means.

*What I am even more confused about is what the function CanTakeProjection does and what it needs the above mentioned symbols (Yx, Yz, ...) for? Also the explanation of the function didn't help me:

CanTakeProjection: function returning true if an EP k lie on the side of an item k

How should the extremePoint k not lie on a side of an item k ever? Or is this a typo and it should be like following:

CanTakeProjection: function returning true if an EP k lie on the side of an item i

(Note the 'i' at the end instead of the 'k'.)
But again, what does it mean that an extremePoint lies on the side of an item? And which side does it mean? Any? Or a specific defined by the given parameter Xy (for example).
I hope I made clear what my problem is. It's quite tricky to explain. I would highly appreciate it if anyone could clarify this for me or point me in the right direction.

A: The identifiers relate to the performed projections according to Figure 5, e.g. Y_x means project the Y coordinate (north edge) of item k on to the on to the x-axis where it intersects with the X coordinate (east edge) of item i.
CanTakeProjection() determines whether the resulting projection is a valid extreme point according to their extreme point definition, which includes:

*

*need not necessarily touch the surface of item k (touching k is not guaranteed, see Fig. 4b),

*need not necessarily touch item i (see Fig. 4a and especially 4b), and

*that an item that is placed with the south west corner on the extreme point must not overlap with any other item. Some cases can be excluded without knowing the dimensions of the item, e.g. if the extreme points touches the southern border of another item i (excluding the south east corner).

See the following C++ implementation.
std::array<int, 6> maxBound = {-1, -1, -1, -1, -1, -1};
std::array<ExtremePoint, 6> newExtremePoints;

// Depending on the implementation, the initial extreme points might never be used.
newExtremePoints[Projection::YX] = ExtremePoint(newItem.X, newItem.Y + newItem.Dy, newItem.Z);
newExtremePoints[Projection::YZ] = ExtremePoint(newItem.X, newItem.Y + newItem.Dy, newItem.Z);
newExtremePoints[Projection::XY] = ExtremePoint(newItem.X + newItem.Dx, newItem.Y, newItem.Z);
newExtremePoints[Projection::XZ] = ExtremePoint(newItem.X + newItem.Dx, newItem.Y, newItem.Z);
newExtremePoints[Projection::ZX] = ExtremePoint(newItem.X, newItem.Y, newItem.Z + newItem.Dz);
newExtremePoints[Projection::ZY] = ExtremePoint(newItem.X, newItem.Y, newItem.Z + newItem.Dz);

// Extreme point projections for container walls can be handled here or elswhere.
// For example, introduce auxiliary items as west and south container walls (and one for the container floor if overhang is allowed), and perform the projection onto those, then enter the for loop.

for (const Cuboid* const item: container.PlacedItems)
{
    int projectedX = item->X + item->Dx;
    int projectedY = item->Y + item->Dy;
    int projectedZ = item->Z + item->Dz;

    // Project the Y coordinate (bottom north west point) of item k in the negative x-direction where it intersects with the X coordinate (east face) of item i.
    if (IsProjectionValidYX(newItem, item) && projectedX > maxBound[Projection::YX])
    {
        newExtremePoints[Projection::YX] = ExtremePoint(projectedX, newItem.Y + newItem.Dy, newItem.Z);
        maxBound[Projection::YX] = projectedX;
    }

    if (IsProjectionValidYZ(newItem, item) && projectedZ > maxBound[Projection::YZ])
    {
        newExtremePoints[Projection::YZ] = ExtremePoint(newItem.X, newItem.Y + newItem.Dy, projectedZ);
        maxBound[Projection::YZ] = projectedZ;
    }

    if (IsProjectionValidXY(newItem, item) && projectedY > maxBound[Projection::XY])
    {
        newExtremePoints[Projection::XY] = ExtremePoint(newItem.X + newItem.Dx, projectedY, newItem.Z);
        maxBound[Projection::XY] = projectedY;
    }

    if (IsProjectionValidXZ(newItem, item) && projectedZ > maxBound[Projection::XZ])
    {
        newExtremePoints[Projection::XZ] = ExtremePoint(newItem.X + newItem.Dx, newItem.Y, projectedZ);
        maxBound[Projection::XZ] = projectedZ;
    }

    if (IsProjectionValidZX(newItem, item) && projectedX > maxBound[Projection::ZX])
    {
        newExtremePoints[Projection::ZX] = ExtremePoint(projectedX, newItem.Y, newItem.Z + newItem.Dz);
        maxBound[Projection::ZX] = projectedX;
    }

    if (IsProjectionValidZY(newItem, item) && projectedY > maxBound[Projection::ZY])
    {
        newExtremePoints[Projection::ZY] = ExtremePoint(newItem.X, projectedY, newItem.Z + newItem.Dz);
        maxBound[Projection::ZY] = projectedY;
    }
}

And the methods to check if a projection results in a valid extreme point:
bool ExtremePoints::IsProjectionValidYX(const Cuboid& newItem, const Cuboid* const item)
{
    return newItem.X >= item->X + item->Dx && newItem.Y + newItem.Dy < item->Y + item->Dy && newItem.Z < item->Z + item->Dz;
}

bool ExtremePoints::IsProjectionValidYZ(const Cuboid& newItem, const Cuboid* const item)
{
    return newItem.Z >= item->Z + item->Dz && newItem.Y + newItem.Dy < item->Y + item->Dy && newItem.X < item->X + item->Dx;
}

bool ExtremePoints::IsProjectionValidXY(const Cuboid& newItem, const Cuboid* const item)
{
    return newItem.Y >= item->Y + item->Dy && newItem.X + newItem.Dx < item->X + item->Dx && newItem.Z < item->Z + item->Dz;
}

bool ExtremePoints::IsProjectionValidXZ(const Cuboid& newItem, const Cuboid* const item)
{
    return newItem.Z >= item->Z + item->Dz && newItem.X + newItem.Dx < item->X + item->Dx && newItem.Y < item->Y + item->Dy;
}

bool ExtremePoints::IsProjectionValidZX(const Cuboid& newItem, const Cuboid* const item)
{
    return newItem.X >= item->X + item->Dx && newItem.Z + newItem.Dz < item->Z + item->Dz && newItem.Y < item->Y + item->Dy;
}

bool ExtremePoints::IsProjectionValidZY(const Cuboid& newItem, const Cuboid* const item)
{
    return newItem.Y >= item->Y + item->Dy && newItem.Z + newItem.Dz < item->Z + item->Dz && newItem.X < item->X + item->Dx;
}

A: Probably not helpful 2 years later...but I found your question when looking for the same answer.  Ultimately, I figured them out.

What is he referring to with the identifiers Yx, Yz, Xy, Xz, Zx, Zy? I know that he uses this to index the array, however i don't know what he means by this. I am pretty sure tho that the author wants to refer to an pair of axis each time but then again I have no clue what that means.

It's basically the conglomeration of X,Y,Z's of the current item being packed and the X,Y,Z's of every item already packed (since it's a loop), to get all new appropriate extreme points.  Example...Yx is the x:(x + width) of the ith item, y:y + length of the item being packed, z of the item being packed.  Xy is the x:(x + width) of the item being packed, y:(y + length) of the ith item, z of the item being packed.

What I am even more confused about is what the function CanTakeProjection does and what it needs the above mentioned symbols (Yx, Yz, ...) for? Also the explanation of the function didn't help me: "CanTakeProjection: function returning true if an EP k lie on the side of an item k"
  How should the extremePoint k not lie on a side of an item k ever? Or is this a typo and it should be like following: "CanTakeProjection: function returning true if an EP k lie on the side of an item i"

If you actually draw out the extreme points it makes sense. Sometimes an extreme point calculation won't be touching the new packed item at all.  So that is not a valid extreme point. So it is correct being 'k'.  Early in the paper, it refers to a Corner points algorithm, which tries a new item on each point.  The more you pack the slower the algorithm gets.  These guys realized that you don't really care about each point, just the furthest out in each axis direction, e.g. extreme point.  So the CanTakeProjection is just saying, is the calculated point touching item k...we know it'll be touching item i.
The one the threw me was the Clustered Height-Area sort, and what was j in that calculation.  It seems easy now, but j is just 0, 1, 2, 3, ... until you get to the box height, then each item's height must be greater than the lower bound and less than or equal to the upper bound, then sorted by decreasing cluster.
They could have definitely added a sentence here and there to make the paper way more understandable.


text:
Q: Twitter Bootstrap & Google Maps I have a navbar and 100% x 100% google map in my app. I would like to add a sidebar on the right with different filters. Reason for adding it on the right side is because of better experience on smaller screens as the right content is pushed below.
The map renders full screen with fluid (%) values when I just add the map after the last nav bar div, like this:
Map is visible:

Map is not visible if I try to add it inside a span to control the size of it and add a side bar.

Sidebar

Link

Link

Link

I don't want to add a fixed value to the map, since it defeats the purpose of fluid.
Thanks in advance for any tips on how I can make the map visible inside a container-fluid.

A: Posted the answer I found as comment before, but to make it more visible, here is the answer: https://github.com/twbs/bootstrap/issues/2475

You must add a javascript callback that will manually set the height
  of the map-canvas when the window is resized, for example.

$(window).resize(function () {
    var h = $(window).height(),
        offsetTop = 60; // Calculate the top offset

    $('#map-canvas').css('height', (h - offsetTop));
}).resize();

A: I have done it already.
First time I try with same as your problem. A GPS map in bootstrap content-tab.
And I just load or initial map with tab click event by something like this.
var map = undefined;
var marker = undefined;
var position = [13.821805500000002, 100.84968549999999];
var latlng;

function initialize() {

    latlng = new google.maps.LatLng(position[0], position[1]);
    var myOptions = {
        zoom: 11,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    marker = new google.maps.Marker({
        position: latlng,
        map: map,
        draggable: true,
        title: "Your current location!"
    });

    google.maps.event.addListener(marker, 'drag', function() {
        $('#txtlat').val(marker.position.lat());
        $('#txtlng').val(marker.position.lng());
    }
    );
}

    $(document).ready(function() {
          $("div.tabbable ul.nav  a[href=#gps_tab]").bind('click', function() {
                  initialize();
                 $("#map_canvas").show();
           });
    });


text:
Q: oracle cursor is not updating data I made an example to better explain the situation:
I have two tables
CREATE TABLE AA
(
    ID NUMBER NOT NULL PRIMARY KEY,
    REFERENCE NVARCHAR2(100) NULL
)

CREATE TABLE BB
(
    ID NUMBER NOT NULL PRIMARY KEY,
    IDA NUMBER NOT NULL,
    REFERENCE NVARCHAR2(100) NULL,

    FOREIGN KEY (IDA) REFERENCES AA(ID)
)

and some records
INSERT INTO AA VALUES(1, NULL)
INSERT INTO AA VALUES(2, NULL)
INSERT INTO AA VALUES(3, NULL)
INSERT INTO AA VALUES(4, NULL)
INSERT INTO AA VALUES(5, NULL)

INSERT INTO BB VALUES(6, 1, 'AAA')
INSERT INTO BB VALUES(7, 2, 'BBB')
INSERT INTO BB VALUES(8, 3, 'CCC')

I have to set REFERENCE field of AA with the value that's in BB by IDA.
So I decided to use a cursor
DECLARE
    idA NUMBER;
    reference NVARCHAR2(100);

    CURSOR ref_cursor
    IS
        SELECT IDA, REFERENCE FROM BB;
BEGIN

    OPEN ref_cursor;

    LOOP
        FETCH ref_cursor into idA, reference;
        EXIT WHEN ref_cursor%NOTFOUND;

        UPDATE AA
        SET REFERENCE = reference
        WHERE ID = idA;

        DBMS_OUTPUT.put_line('reference of movement ' || idA || ' updated with ' || reference);

    END LOOP;

    CLOSE ref_cursor;
END;

By executing it, I get an output
reference of movement 1 updated with AAA
reference of movement 2 updated with BBB
reference of movement 3 updated with CCC

That's exactly what I want, but when I check the data by star-selecting the table I found the REFERENCE column still NULL.
So I found this other cursor
DECLARE
    CURSOR ref_cursor
    IS
       SELECT IDA, REFERENCE FROM BB;

BEGIN
    FOR ref_c IN ref_cursor
    LOOP
         UPDATE AA SET REFERENCE = ref_c.REFERENCE WHERE ID = ref_c.IDA;
    END LOOP;
END;

This one is actually doing the update. Why are these 2 cursors different?

A: When a SQL statement is processed inside a PL/SQL block, the SQL name resolution takes priority so, table fields have precedence over variables with the same name. To solve this issue you have two ways:

*

*change the variable name.

*add a prefix to the variable name as you already did in your second query.

A: In the first cursor you wrote
UPDATE AA
        SET REFERENCE = reference
        WHERE ID = idA;

I think you should rename the variable to different name


text:
Q: What is the possible Payment error that has to handle while developing? At the time of developing payment methods on my project, what are the things has to be handled.
What are the payments errors possible?
EX:

*

*Duplicate transaction error

*Invalid card error

*Expired card error

anything else??


text:
Q: angular 2 ngFor Cannot read property of undefined I have a nested object with data that I am trying to access with ngFor.
I am able to reach the first part of the data with the first ngFor (app_name, time_stamp etc)
But for some reason I am not getting to the nested object of test_cases. When I try it breaks the whole page and the console keeps telling me "Cannot read property 'test_cases' of undefined" and I can't seem to figure out why...
(first part of) data inside the component:
    export class AppComponent {
        tests = TESTS;

        var TESTS: Test[] = [
            {
                "app_name": "website",
                "time_stamp": "2018-01-20T12:00:00Z",
                "test_cases": [
                    {
                        "test_name": "View article",
                        "status": true,
                     }]
         }]

HTML partial:

---- {{ item.app_name }} ----

 Time:  {{item.time_stamp}}

{{subItem.test_name}}

A: For peeps who are struggling with this:
John Montgomery and Andres M answered this in the comments, I had to put the second div inside the first.


text:
Q: Calculate the sum of multiple currency formatted elements I am trying to create a sub-total based on a series of currency formatted numbers but am struggling converting the numbers back to integers so that they can be added. Here's what I have tried:

$(function() {
  var totals = $('.price');

  var sum = 0;
  for (var i = 0; i < totals.length; i++) {
    //strip out dollar signs and commas
    $(totals[i].text()).replace(/[^\d.]/g, '');

    //convert string to integer
    var ct = parseFloat($(totals[i].text()));
    sum += ct;
  }

  console.log(sum);
});

$195,000.20

$21,404.00

$7,000.00

$450.00

A: replace() doesn't modify the string passed in (and it couldn't here anyway, since it's the result of a function). It just returns the modified value.
Save the result of replace(), and sum based on that:

$(function() {
  var totals = $('.price');

  var sum = 0;
  for (var i = 0; i < totals.length; i++) {
    //strip out dollar signs and commas
    var v = $(totals[i]).text().replace(/[^\d.]/g, '');

    //convert string to integer
    var ct = parseFloat(v);
    sum += ct;
  }

  console.log(sum);
});

$195,000.20

$21,404.00

$7,000.00

$450.00

Also: note the typo -- you want $(totals[i]).text(), not $(totals[i].text())


text:
Q: How to activate RemoteFX on WIN7 Guest Hyper-V on WIN10 Host? Have Win7 Pro gen1 Hyper-V, all updates, RemoteFX added with 512Mb, SLAT Vt-x etc. OK AMD r9 280x 3GB videocard, Remote FX works on Win10 Guest but only with 512MB max, not working w 1GB video RAM. How to make it active on WIN7 Hyper-V guest Running/accessed from same host? Or if it only fork via RD, hot to connect properly to have RFX??
Cheers!


text:
Q: Update module from Database in entity framework without using third party tools In Entity Framework, I always use the Update module from Database option, but It's not covering all kind of updates, sometimes it's more easier to delete the EF and add it back than fixing and verifying whether this option reflected the updates or not,
In my current project i have added a Self-Join relation and then i used the Update module from Database option, but it didn't update it correctly,
I can find that table and the new relation in the Module diagram but in the code behind it's not reflecting the update correctly, This time i have my custom changes on the EF? It is not possible to delete and add again this time, My question is:

Is there any reliable and easy way to update the EF from DB without
  using third party tools?

A: After clicking the Update module from Database , Two clicks are needed, orderly:

*

*Right Click on the .tt file and choose Run Custom Tool. Wait Until is Finished.

*Right Click on the .Context.tt file and choose Run Custom Tool. Wait Until is Finished.

I used this method in Visual Studio 2012 for many scenarios and it's updating fine with no errors.
Hope this helps.


text:
Q: Is there a way to have two binary from one project? I have some *.c files. I want to have two binary from them
for example:
a.c b.c -> ab

d.c e.c -> de

The a.c and d.c has main() function.
This is my code:
gcc  a.c b.c -o  ab.o -c
gcc -o ab ab.o
gcc  d.c e.c -o  de.o -c
gcc -o de de.o

I put this code in post-build-steps in codeblocks. The problem is when I compile the project it fails because of two main.

A: You can use a Makefile and put two binaries on it.
You can find some informations on this topic for example : A Makefile with Multiple Executables


text:
Q: Is there a replacement for high voltage capacitors? Does anybody know if there is a replacement for tuning capacitors in an LC circuit that can support several kV (let's say 4kV)?
The LC tuning circuit is used as a load for a power amplifier. C varies between 30pF and 1nF, L is fixed, and the frequency range is 1-5MHz. The load is driven with 10us pulses with a period of 10ms, with a max. power of 200W.
The current tuning circuit uses vacuum variable capacitors and step motors to tune the capacitors and I would like to remove any moving parts.
I've been looking at varicap diodes, but these are for small voltages.

A: It would be possible to implement a "somewhat clunky" version of what you're wanting using digital control, solid-state HV switchgear, and multiple fixed-value HV caps...something similar to the illustration below (incomplete, but I think it conveys the intent).

simulate this circuit – Schematic created using CircuitLab
Now, the caps themselves aren't a problem, you can find all of them for under $10USD at you favorite mail/internet-order component supplier. HOWEVER solid-state switching of 4KV+ is an WNTIRELY different story! The transistor I labelled in the diagram will cost about $30/each for ordering quantities of 25+ (which you'll need), not to mention the diodes & the control circuitry (did I mention that all the MOSFETS I found had a Vgs MAX of +-20V?...you'll have to match the control signals to your 4KV signal frequency)
With that all said, there will most definitely be some unwanted noise/parasitics in the circuit from all those diodes & MOSFETS, any you may end up having to gate both ends of each cap (for better isolation of "switched off caps")...but it would be 4kV capable, solid-state, and (somewhat) adjustable between 5pF & 1nF+.
(P.S. the 1uH inductor in the illustration is just a placeholder for your fixed inductor in the amplifier tank)


text:
Q: Is Java 6 on Mavericks safe to use? I have some web applications (java applets) which have trouble running with Java 7 and java 64 bit.
The tech support wants me to install Java 6 and disable Java 7, here are the instructions:

*

*Please download and install the Java update named "JavaForOSX2013-05.dmg" from Apple for better security. For OS X 10.7 and above: http://support.apple.com/kb/DL1572

*After that, please follow the instructions below to re-enable the Apple-provided Java SE 6 web plug-in and Web Start functionality: http://support.apple.com/kb/HT5559

Security-wise, is it safe to setup OS X this way?

A: Nothing is safe in security terms, all that you can say is that there is a risk and try to quantify it.
For Java there are often exploits for Java applets and at some time Apple found that they and Oracle could not produce a fix quick enough to stop a well known exploit. Apple then put out a change to Safari to block all Java applets if the Java version was below a given version and this version limit is increased regularly.
The latest Apple-provided Java installer as of 17 Oct 2014 is Java for OS X 2014-001. It fixes the vulnerabilities listed here by providing a version of Java version 1.6.0_65.
Also see this answer
There will be vulnerabilities in that but Apple have so far decided none of those known to them are serious enough to block the use of this version or produce a new version.


text:
Q: Grouping radio buttons together with a containing element? The standard way to group radio buttons together is to assign each one a name attribute, and set each one in a certain group to the same "group name" like so:

    Group 1:

    <input type="radio" name="group1" value="val1">
    <input type="radio" name="group1" value="val2">

    Group 2:

    <input type="radio" name="group2" value="val3">
    <input type="radio" name="group2" value="val4">

However, having to come up with a different "group name" is a real pain when you're developing some partial code for web pages that could be used multiple times on the page.  It would be much nicer if you could instead group the radio buttons together with a surrounding element, something like this:

    Group 1:

    <radiogroup>
        <input type="radio" value="val1">
        <input type="radio" value="val2">
    </radiogroup>

    Group 2:

    <radiogroup>
        <input type="radio" value="val3">
        <input type="radio" value="val4">
    </radiogroup>

Is something like this possible?  Otherwise if my partial code is included twice on a page, the 2 instances of the first 2 inputs will all be included in the same group, and the 2 instances of the second 2 inputs will all be included in the same group.  What I want, though, is 4 groups; 2 groups per partial include.

A: There doesn't seem to be a way to do this.  What I ended up doing in the end was generating a new GUID for each partial and appending it to the name attribute of the radio buttons in that partial.

A: I used the span attribute with an ID to group lists of radio buttons together.


text:
Q: Grails form error: Tag [null] is missing required attribute [name] or [field] Tag [null] is missing required attribute [name] or [field].

What does this error mean and what should I be looking for?
I went through the Grails docs and I have a valid name and type (which are the only required attributes according to the docs) for each form element, and it still returns that error.  (I'd post my entire form, but it has some organization-sensitve stuff in it.)


text:
Q: Which is the name of the Azure VideoIndexer apikey parameter? Today I am facing a problem:
I am trying to automate an azure logic app deployment with a VideoIndexer service from Azure, using Terraform but it ask me for a parameter called API Key (on the web side).
The official documentation is this:
https://learn.microsoft.com/en-us/azure/azure-video-analyzer/video-analyzer-for-media-docs/logic-apps-connector-tutorial
But I cannot find the name of the apiKey parameter (and no, it isn't apiKey)
Anyone could help here? And for help me to avoid doing a question like that: how can I check an Apiconnection to see which parameters are registered?
Maybe this example could help you (I didn't find the answer there, but maybe you have better eyes than me): https://www.returngis.net/2021/04/como-desplegar-azure-logic-apps-con-terraform/

A: The apiKey for the videoindexer is named 'Ocp-Apim-Subscription-Key'
See also the example on this page: https://learn.microsoft.com/en-us/azure/azure-video-analyzer/video-analyzer-for-media-docs/video-indexer-use-apis