text:
Q: Tabular* environment stretching table more than page width I am using trying to use the tabular* environment to stretch a table to the page width. However the table gets stretched more than the page width defined on the preamble ...
Here's my code:
\documentclass[12pt,a4paper]{article}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{natbib}
\usepackage{url}
\usepackage{float}
\usepackage{placeins}
\usepackage[font=small,labelfont=bf,margin=\parindent,tableposition=top]{caption}

\setcounter{MaxMatrixCols}{10}

\addtolength{\oddsidemargin}{-.875in}
\addtolength{\evensidemargin}{-.875in}
\addtolength{\textwidth}{1.75in}
\addtolength{\topmargin}{-.875in}
\addtolength{\textheight}{1.50in}

\parskip = 0pt
\pagestyle{plain}
\setlength{\parskip}{.0in}
\renewcommand{\baselinestretch}{1.3}
\newcommand{\figref}[1]{Figure~\ref{#1}}
\newcommand{\tabref}[1]{Table~\ref{#1}}
\newcommand{\secref}[1]{Section~\ref{#1}}
\newcommand{\eqnref}[1]{equation (\ref{#1})}
\newcommand{\chapref}[1]{Chapter~\ref{#1}}

\newenvironment{Question}[2][Question]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}

    \FloatBarrier
\begin{table}[!htbp]

  \centering
  \caption{AAAA}
  \caption*{AAAA}
  \setlength\tabcolsep{0pt}
    \begin{tabular*}{\textwidth}{l @{\extracolsep{\fill}} cccccll}
    \hline
\hline
\multicolumn{8}{c}{Panel A:}                                                                                \\ \hline
   & $\delta_1$           & t-stat               &                      & $\delta_2$           & t-stat               &  & $R^2$ \\ \cline{2-3} \cline{5-6} \cline{8-8}
1  & -0.06                & -0.40                &                      & 0.8                  & 16.0                 &  & 0.05  \\
2  & 0.04                 & 0.23                 &                      & 3.3                  & 54.3                 &  & 0.39  \\
3  & 0.03                 & 0.19                 &                      & 1.7                  & 41.0                 &  & 0.27  \\
4  & 0.17                 & 0.89                 &                      & 2.2                  & 36.0                 &  & 0.22  \\
5  & 0.12                 & 0.88                 &                      & 1.2                  & 28.0                 &  & 0.15  \\
6  & 0.02                 & 0.13                 &                      & -1.9                 & -32.7                &  & 0.19  \\
7  & 0.04                 & 0.40                 &                      & 0.2                  & 5.9                  &  & 0.01  \\
8  & 0.13                 & 0.61                 &                      & 1.9                  & 27.2                 &  & 0.14  \\
9  & -0.02                & -0.22                &                      & -0.5                 & -14.8                &  & 0.05  \\
10 & 0.14                 & 1.11                 &                      & 0.3                  & 6.8                  &  & 0.01  \\
11 & -0.21                & -1.14                &                      & 0.5                  & 8.7                  &  & 0.02  \\
12 & -0.22                & -2.16                &                      & 0.4                  & 12.5                 &  & 0.03  \\ \hline
   & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} &  &       \\
   & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} &  &       \\ \hline
\multicolumn{8}{c}{Panel B:}                                                                                \\ \hline
   & $\delta_1$           & t-stat               &                      & $\delta_2$           & t-stat               &  & $R^2$ \\ \cline{2-3} \cline{5-6} \cline{8-8}
1  & -0.13                & -0.58                &                      & 3.83                 & 55.00                &  & 0.40  \\
2  & -0.02                & -0.17                &                      & 2.35                 & 49.92                &  & 0.35  \\
3  & -0.05                & -0.39                &                      & 1.66                 & 40.55                &  & 0.26  \\
4  & -0.09                & -1.19                &                      & 0.79                 & 33.25                &  & 0.19  \\
5  & 0.00                 & 0.13                 &                      & -0.44                & -37.38               &  & 0.23  \\ \hline
   & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} &  &       \\
   & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} &  &       \\ \hline
\multicolumn{8}{c}{Panel C:}                                                                                \\ \hline
   & $\delta_1$           & t-stat               &                      & $\delta_2$           & t-stat               &  & $R^2$ \\ \cline{2-3} \cline{5-6} \cline{8-8}
1  & 0.07                 & 0.76                 &                      & -0.91                & -32.58               &  & 0.19  \\
2  & 0.04                 & 0.61                 &                      & 0.05                 & 2.24                 &  & 0.00  \\
3  & -0.05                & -0.65                &                      & 0.38                 & 14.25                &  & 0.04  \\
4  & -0.01                & -0.16                &                      & 0.69                 & 25.03                &  & 0.12  \\
5  & -0.10                & -0.60                &                      & 2.00                 & 37.21                &  & 0.23  \\ \hline
\end{tabular*}

  \label{tab:Reg1}%
\end{table}%

A: When using the @{\extracolsep{\fill}} device, LaTeX sets the width of each intercolumn space to 2\tabcolsep+\fill. The default value of \tabcolsep, at least in most document classes I'm familiar with, is 6pt.
If the "natural" width of the tabular* environment, i.e., with \fill=0pt (note: \fill can not be negative), exceeds the width of the text block, three possible remedies should be considered:

*

*Eliminate the whitespace to the left of the first column and to the right of the final column (total savings: 2\tabcolsep);

*Execute the instruction \setlength\tabcolsep{0pt}. That way, each intercolumn whitespace is equal to \fill; and

*Reduce the font size, e.g., by executing an instruction such as \small or \footnotesize.
The code below shows the results of using a tabular* with 14 instead of "just" 6 data columns to create an example of the table's width exceeding that of the text block. The first tabular* environment uses the default value of \tabcolsep, whereas the second uses \tabcolsep=0pt.

\documentclass{article}
\usepackage{booktabs,caption}
\begin{document}
\begin{table}[!htbp]
    \caption{\texttt{\textbackslash tabcolsep=6pt} (default)} \label{tab:default}
    \begin{tabular*}{\textwidth}{@{} l @{\extracolsep{\fill}} *{14}{c} @{}}
    \toprule
    & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & 13 & 14  \\
    \midrule
    \textbf{Historical } \\
    Lab1 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0& 1.0 & 1.0 \\
    Lab2 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0& 1.0 & 1.0 \\
    \bottomrule
    \end{tabular*}

    \bigskip\bigskip
    \setlength\tabcolsep{0pt} % default: 6pt
    \caption{\texttt{\textbackslash tabcolsep=0pt}} \label{tab:alt}
    \begin{tabular*}{\textwidth}{l @{\extracolsep{\fill}} *{14}{c} }
    \toprule
    & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & 13 & 14  \\
    \midrule
    \textbf{Historical } \\
    Lab1 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0& 1.0 & 1.0 \\
    Lab2 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0& 1.0 & 1.0 \\
    \bottomrule
    \end{tabular*}
\end{table}

\end{document}

Addendum, posted after the OP augmented his/her posting to show a "real" table: Not sure what your concern is about the tabular material not fitting in the width of the text block. I did notice, though, that the table is too tall to fit into the text block. However, that's because you've changed the lowel-level TeX macro \baselineskip. Instead of modifying \baselineskip directly, I would load the setstretch package and issue the command \setstretch{1.3}; that way, material in footnotes, tables, and arrays will not be stretched vertically.
Your table has two unneeded column and a lot of unnecessary statements, c.f., all those \multicolumn{1}{l}{} directives. With some clean-up, replacing all \hline directives with \midrules and all \cline statements with \cmdirules, and using the dcolumn package to align numeric data on the respective decimal markers, one gets:

\documentclass[12pt,a4paper]{article}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{natbib}
\usepackage{url}
\usepackage{float}
\usepackage{placeins}
\usepackage[font=small,labelfont=bf,margin=\parindent,tableposition=top]{caption}

%\setcounter{MaxMatrixCols}{10}

%\usepackage[showframe]{geometry}

\addtolength{\oddsidemargin}{-.875in}
\addtolength{\evensidemargin}{-.875in}
\addtolength{\textwidth}{1.75in}
\addtolength{\topmargin}{-.875in}
\addtolength{\textheight}{1.50in}

\parskip = 0pt
\pagestyle{plain}
\setlength{\parskip}{.0in}
%\renewcommand{\baselinestretch}{1.3}

\usepackage{setspace}
\setstretch{1.3}

\usepackage{dcolumn}
\newcolumntype{d}[1]{D..{#1}}

\newcommand{\mc}[1]{\multicolumn{1}{c}{#1}}

\newcommand{\figref}[1]{Figure~\ref{#1}}
\newcommand{\tabref}[1]{Table~\ref{#1}}
\newcommand{\secref}[1]{Section~\ref{#1}}
\newcommand{\eqnref}[1]{equation (\ref{#1})}
\newcommand{\chapref}[1]{Chapter~\ref{#1}}

\newenvironment{Question}[2][Question]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}
\begin{document}

    \FloatBarrier
\begin{table}[!htbp]

  %%\centering
  \caption{AAAA}
  \caption*{AAAA}
  \setlength\tabcolsep{0pt}
    \begin{tabular*}{\textwidth}{l @{\extracolsep{\fill}} *{5}{d{2.2}}}
\midrule
\multicolumn{6}{c}{Panel A:}\\
\midrule
& \mc{$\delta_1$} & \mc{t-stat}  & \mc{$\delta_2$} & \mc{t-stat} &  \mc{$R^2$} \\
   \cmidrule{2-3} \cmidrule{4-5} \cmidrule{6-6}
1  & -0.06 & -0.40 & 0.8   & 16.0  &  0.05  \\
2  & 0.04  & 0.23  & 3.3   & 54.3  &  0.39  \\
3  & 0.03  & 0.19  & 1.7   & 41.0  &  0.27  \\
4  & 0.17  & 0.89  & 2.2   & 36.0  &  0.22  \\
5  & 0.12  & 0.88  & 1.2   & 28.0  &  0.15  \\
6  & 0.02  & 0.13  & -1.9  & -32.7 &  0.19  \\
7  & 0.04  & 0.40  & 0.2   & 5.9   &  0.01  \\
8  & 0.13  & 0.61  & 1.9   & 27.2  &  0.14  \\
9  & -0.02 & -0.22 & -0.5  & -14.8 &  0.05  \\
10 & 0.14  & 1.11  & 0.3   & 6.8   &  0.01  \\
11 & -0.21 & -1.14 & 0.5   & 8.7   &  0.02  \\
12 & -0.22 & -2.16 & 0.4   & 12.5  &  0.03  \\
\midrule
\\ \\
\midrule
\multicolumn{6}{c}{Panel B:}\\
\midrule
& \mc{$\delta_1$} & \mc{t-stat}  & \mc{$\delta_2$} & \mc{t-stat} &  \mc{$R^2$} \\
\cmidrule{2-3} \cmidrule{4-5} \cmidrule{6-6}
1  & -0.13 & -0.58 & 3.83  & 55.00 &  0.40  \\
2  & -0.02 & -0.17 & 2.35  & 49.92 &  0.35  \\
3  & -0.05 & -0.39 & 1.66  & 40.55 &  0.26  \\
4  & -0.09 & -1.19 & 0.79  & 33.25 &  0.19  \\
5  & 0.00  & 0.13  & -0.44 & -37.38 &  0.23  \\
\midrule
\\ \\
\midrule
\multicolumn{6}{c}{Panel C:}\\
\midrule
& \mc{$\delta_1$} & \mc{t-stat}  & \mc{$\delta_2$} & \mc{t-stat} &  \mc{$R^2$} \\
\cmidrule{2-3} \cmidrule{4-5} \cmidrule{6-6}
1  & 0.07  & 0.76  & -0.91 & -32.58 &  0.19  \\
2  & 0.04  & 0.61  & 0.05  & 2.24  &  0.00  \\
3  & -0.05 & -0.65 & 0.38  & 14.25 &  0.04  \\
4  & -0.01 & -0.16 & 0.69  & 25.03 &  0.12  \\
5  & -0.10 & -0.60 & 2.00  & 37.21 &  0.23  \\
\midrule
\end{tabular*}

  \label{tab:Reg1}%
\end{table}%
\end{document}

A: Your table fits in the stated margins. This is what I get if I add \usepackage{showframe} and the missing \begin{document} and \end{document}

As you clearly see, it fits in the box representing the text block margins.

Here is how I'd typeset it: enlarging the table will simply make it unreadable.
\documentclass[12pt,a4paper]{article}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage[font=small,labelfont=bf,margin=\parindent,tableposition=top]{caption}

\begin{document}

\begin{table}[!htbp]
\centering
\caption{AAAA}\label{tab:Reg1}

\begin{tabular}{
  @{}
  r
  S[table-format=-1.2]
  S[table-format=-1.2]
  S[table-format=-1.2]
  S[table-format=-2.2]
  S[table-format=1.2]
  @{}
}
\toprule
\multicolumn{6}{c}{Panel A:} \\
\midrule
& {$\delta_1$} & {t-stat} & {$\delta_2$} & {t-stat} & {$R^2$} \\
\cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(lr){6-6}
 1 & -0.06 & -0.40 &  0.8 &  16.0 & 0.05  \\
 2 &  0.04 &  0.23 &  3.3 &  54.3 & 0.39  \\
 3 &  0.03 &  0.19 &  1.7 &  41.0 & 0.27  \\
 4 &  0.17 &  0.89 &  2.2 &  36.0 & 0.22  \\
 5 &  0.12 &  0.88 &  1.2 &  28.0 & 0.15  \\
 6 &  0.02 &  0.13 & -1.9 & -32.7 & 0.19  \\
 7 &  0.04 &  0.40 &  0.2 &   5.9 & 0.01  \\
 8 &  0.13 &  0.61 &  1.9 &  27.2 & 0.14  \\
 9 & -0.02 & -0.22 & -0.5 & -14.8 & 0.05  \\
10 &  0.14 &  1.11 &  0.3 &   6.8 & 0.01  \\
11 & -0.21 & -1.14 &  0.5 &   8.7 & 0.02  \\
12 & -0.22 & -2.16 &  0.4 &  12.5 & 0.03  \\
\midrule[\heavyrulewidth]
\multicolumn{6}{c}{Panel B:} \\
\midrule
& {$\delta_1$} & {t-stat} & {$\delta_2$} & {t-stat} & {$R^2$} \\
\cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(lr){6-6}
 1 & -0.13 & -0.58 &  3.83 &  55.00 & 0.40  \\
 2 & -0.02 & -0.17 &  2.35 &  49.92 & 0.35  \\
 3 & -0.05 & -0.39 &  1.66 &  40.55 & 0.26  \\
 4 & -0.09 & -1.19 &  0.79 &  33.25 & 0.19  \\
 5 &  0.00 &  0.13 & -0.44 & -37.38 & 0.23  \\
\midrule[\heavyrulewidth]
\multicolumn{6}{c}{Panel C:} \\
\midrule
& {$\delta_1$} & {t-stat} & {$\delta_2$} & {t-stat} & {$R^2$} \\
\cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(lr){6-6}
 1 &  0.07 &  0.76 & -0.91 & -32.58 & 0.19  \\
 2 &  0.04 &  0.61 &  0.05 &   2.24 & 0.00  \\
 3 & -0.05 & -0.65 &  0.38 &  14.25 & 0.04  \\
 4 & -0.01 & -0.16 &  0.69 &  25.03 & 0.12  \\
 5 & -0.10 & -0.60 &  2.00 &  37.21 & 0.23  \\
\bottomrule
\end{tabular}

\end{table}

\end{document}


text:
Q: How to scan images using camera in Black berry? I have started  one project in which I want to implement QR code scanning functionality.  Say for example: ZXing in android.  I want to implement for blackberry OS 6 and above. I want to scan live images using camera.  Is it possible?  If yes, then how it possible?

A: You have to use the Barcode API. It was released for OS 6.0. Before that, there was ZXing (added in 5.0) but no livescan functionality.
Here you are the how-to:
http://supportforums.blackberry.com/t5/Java-Development/How-to-use-the-Barcode-API/ta-p/574569

A: Please check this in your eclips folder
path is

Eclipse\plugins\net.rim.ejde.componentpack6.0.0_6.0.0.29\components\samples\com\rim\samples\device\barcodescandemo

barcodescandemo demo is QRcode reader
please check it you can find all things

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to perform Noise Pollution Mapping using ArcGIS for Desktop? I've been trying to do a noise pollution map, and I really don't know where to start with the information I have. The end result needs to be like in the link below.
I've seen the question, Creating noise maps using ArcGIS for Desktop or Open Source Desktop GIS? but it doesn't give an accurate metod, and I don't know how to go about it. I've searched for weeks and weeks now about a simple method, and I'm none the wiser.
Data I have:

*

*parameter - speed (roads)

*environments (hard ground=lakes and soft ground= grassland)

*sound data i.e. dB accounting to number of vehicles

What are the tools I can use in ArcGIS for Desktop to achieve a map like the link above?
I only have access to ArcGIS for Desktop.

A: We used SPreAD-GIS to model outdoor sound for our 500+ sq mi siren system build as detailed in this ArcNews article. I used SPreAD-GIS with some extensive modifications to allow it to do parallel processing and in_memory datasets (takes a long time to process 200 sirens over 500 sq mi otherwise).
This requires Spatial Analyst and a version of ArcGIS that is 9.3.1 or higher. (I have used SPreAD-GIS with ArcGIS 10.0 and 10.1.)
But... spatial analyst is used for Euclidean distance calculations and cost path calculations which can be done easily with numpy. All the other calculations are simple raster algebra that can be done with numpy as well.
If you do not have access to the Spatial Analyst extension or are not comfortable with python, this is not really an option. But if you are, you can readily adopt this model.


text:
Q: Find all possible sub arrays from array Z that sum up to X I have a relatively complex issue, I need an algorithm to find all possible sub arrays from an array that sum up to X, so for the given array:
{2,8,12,45,32,7,6,5}

lets say we need subarrays that sum to 20, some would be:
{8,12} {2,7,6,5} {12,6,2}

however there will be combinations like:
{7,7,6} {5,5,5,5} {8,8,2,2}

I will need all possible sums.
I have done a solution doing brute force checking of all possibilities however it takes way too long (in some cases in excess of 30 minutes) to complete, so I do need a smarter solution that I've been bumping my head over for a couple of days now.

A: Your question seems to indicate that answers which repeat numbers are acceptable, and you don't want to generate all possible ways the summands can be ordered. I'll base my answer on that.
I'd implement this in C++. As data structure, I'd probably use something like this:
struct partial_sum {
  int min_last_summand;
  std::vector< std::pair<partial_sum*, int> > prefixes;
};

std::map<int, partial_sum*> m;

The central piece here is the map m. It maps the value of a sum to some information about how to obtain it. You'd initialize it with 0 mapped to NULL. The prefixes member would store data about all possible ways to obtain a given sum. The first part of each pair gives a pointer to information about all summands except the last, while the second part gives that last member. This gives you a form of directed acyclic graph, as sums can be prefixes of many sums, and sums can have many different prefixes, but the value of every prefix sum is smaller than that of the current sum.
The central iteration step would remove the minimal elkement from m, and generate all possible ways you can add an element from your input set to the value you just removed. So you'd check the map whether you need to insert a new entry for the new sum. And for existing and new entries alike, you create a new item in the prefixes list, with the pointer you just removed from the map as first part, and the last summand you added as the second.
I'd only generate sums in ascending (or rather non-descending) order of summands, to avoid generating all permutations. To make things easier, I'd maintain this min_last_summand information. It should always contain the minimum of all the second elements from the pairs in the prefixes list. When generating new sums, you can skip those where the last summand would be less than the minimal last summand of the prefix, as that would imply a summand being smaller than its predecessor. You could also avoid generating sums where the total value is greater than your target sum.
When printing the results, you'll have to recurse over the part of the DAG reachable from your target sum, and list all paths from there to the root NULL. So in each recursion step, you'd have a pointer to the current partial sum. If that pointer is NULL, you emit a sum consisting of zero summands. Otherwise, you iterate over all prefixes. For each prefix, you recurse to generate all possible ways to write that prefix, but only if the min_last_summand of the first element is no greater than the current last summand, and also only if the second element is no greater than the summand that will follow it. Which means that you'll have to pass that following summand as an argument to your recursive calls. Taken together, this avoids generating sums with descending steps in them.
The approach above assumes that your program will terminate after one run, so you don't have to worry about freeing memory. If you do, you'll probably have to store pointers to all the objects you created, so you can free them all.


text:
Q: How to inject constants into other modules in angular typescript? In angular1, we define constants in this fashion,
angular.module('taskApp', [
  'ui.router',
  'angular-loading-bar',
  'ngMessages',
])
.constant('url', {
   BASE: 'http://localhost:3222',
   BASE_API: 'http://localhost:3222/v1'
});

then I can inject it into any module I want like so,
Auth.$inject = ['$http', 'url'];

function Auth($http, url)

Now using typescript, I'd like to do the same, I've seen this approach: Inject Angular Constants in TypeScript, which seems to be okay, but not the approach i'm looking for.
From my research
  static $inject = ["$resource", "url"];
  constructor(private $resource: ng.resource.IResourceService, private url: ng.IModule)

I'm using IModule, because it is the only hint from angular's tsd file
/**
 * Register a constant service, such as a string, a number, an array, an object or a function, with the $injector. Unlike value it can be injected into a module configuration function (see config) and it cannot be overridden by an Angular decorator.
 *
 * @param name The name of the constant.
 * @param value The constant value.
 */
constant(name: string, value: any): IModule;
constant(object: Object): IModule;

but can't find right property to retrieve my variables

A: One way to do it would be to define an interface that describes the constant.
interface URL_CONSTANTS {
   BASE: string,
   BASE_API: string
}

Then you'd be able to use that as the type for the injected constant.
static $inject = ["$resource", "url"];
constructor(private $resource: ng.resource.IResourceService, private url: URL_CONSTANTS)


text:
Q: Sending Images to Several Instances of a ViewController in Swift I download several "events" from CloudKit in my program. Each one contains a picture, title, and location. The second two are used right away and there is no problem. The image is only seen if the user clicks on the info button on the annotation that shows the picture using a separate view controller.  I am having trouble getting the images to be passed to the ViewController before it is used while also keeping each event's picture separate.
Here is where each record is queried from CloudKit and put into a for loop that send then to the method below:
func loadEvent(_ completion: @escaping (_ error:NSError?, _ records:[CKRecord]?) -> Void)
    {
        //...record is downloaded from cloudkit

                for record in records
                {
                    if let asset = record["Picture"] as? CKAsset,
                        let data = NSData(contentsOf: asset.fileURL),
                        let image1 = UIImage(data: data as Data)
                    {
                        self.drawEvents(record["LocationF"] as! CLLocation, title1: record["StringF"] as! String, pic1: image1)
                    }
                }
            }

Here is where the variables are assigned and used to create the point annotation (it is a custom one that includes an image):
func drawEvents(_ loc: CLLocation, title1: String, pic1: UIImage)
    {
        mapView.delegate = self
        let center = CLLocationCoordinate2D(latitude: loc.coordinate.latitude, longitude: loc.coordinate.longitude)
        let lat: CLLocationDegrees = center.latitude
        let long: CLLocationDegrees = center.longitude
        self.pointAnnotation1 = CustomPointAnnotation()
        self.pointAnnotation1.imageName = pic1
        self.pointAnnotation1.title = title1
        self.pointAnnotation1.subtitle = "Event"
        self.pointAnnotation1.coordinate = CLLocationCoordinate2D(latitude: lat, longitude: long)
        self.pinAnnotationView = MKPinAnnotationView(annotation: self.pointAnnotation1, reuseIdentifier: nil)
        self.mapView.addAnnotation(self.pinAnnotationView.annotation!)
    }

Here is the function that makes EventPage appear when the info button on an MKMapAnnotation is clicked:
    func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {

            let eventPageViewController:EventPageViewController = storyboard?.instantiateViewController(withIdentifier: "EventPage") as! EventPageViewController

            self.present(eventPageViewController, animated: true, completion: nil)
        }

Here is the ViewController for EventPage:
class EventPageViewController: UIViewController {

    @IBOutlet weak var eventPic: UIImageView!

    var photo: UIImage!

    override func viewDidLoad() {
        super.viewDidLoad()

        let firstViewController:FirstViewController = storyboard?.instantiateViewController(withIdentifier: "Home") as! FirstViewController

        photo = firstViewController.pointAnnotation1.imageName
        //photo is nil

        eventPic.image = photo
   }
}

A: Intead of storing your annotations in a single instance property (which means that you only have access to the last one), store them in an array, although you don't need to store them at all in order to respond to taps.
var annotations = [CustomPointAnnotation]()

func drawEvents(_ loc: CLLocation, title1: String, pic1: UIImage)
{
    mapView.delegate = self
    let center = CLLocationCoordinate2D(latitude: loc.coordinate.latitude, longitude: loc.coordinate.longitude)
    let lat: CLLocationDegrees = center.latitude
    let long: CLLocationDegrees = center.longitude
    var newAnnotation = CustomPointAnnotation()
    newAnnotation = CustomPointAnnotation()
    newAnnotation.imageName = pic1
    newAnnotation.title = title1
    newAnnotation.subtitle = "Event"
    newAnnotation.coordinate = CLLocationCoordinate2D(latitude: lat, longitude: long)
    self.mapView.addAnnotation(newAnnotation)
    self.annotations.append(newAnnotation)
}

The annotation view that is tapped is passed to your delegate method, so you know which item it is. The annotation view's annotation property is your CustomPointAnnotation instance.
func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {

    let eventPageViewController:EventPageViewController = storyboard?.instantiateViewController(withIdentifier: "EventPage") as! EventPageViewController

    if let annotation = view.annotation as CustomPointAnnotation {
        eventPageViewController.photo = annotation.imageName
    }

    self.present(eventPageViewController, animated: true, completion: nil)
}


text:
Q: Cluster points by spheres in 3D space There is 3D space, limited with a cube, with edge=2000.
The center of coordinate system is point (0; 0; 0), so the maximum/minimal coordinate value is 1000/-1000.
There are 10000 points generated with discrete uniform distribution inside of K spheres, located in the cube.
Radius (R) of each sphere is 250.
Centers of spheres are located at the distance of not less than 2*R.
It is required to determine which point related to which sphere.
Input: array of 10000 structures, like:
struct Point {

            int number;
            int x;
            int y;
            int z;

}

where number is unique id of the point, x,y,z - it's coordinates.
Output:
array of 10000 structures, like:
struct Point {

            int number;
            int cluster_id;

}

where cluster_id is unique cluster id of a sphere that point belongs to.
Initially I considered a following solution:
1) Find Euclidian distance for each point from  center of coordinates (0;0;0) to point's coordinates.
2) Sort this array of distances in descending order.
3) Get the point from the sorted array of distances and put in a new Set of Cluster Maximals.
4) Compare following point from the array to each value from the Set of Cluster Maximals (initially 1 value).
If it's Euclidian distance less than or equal to 2*R, then
mark this point as belonging to Kth cluster (range=1..N), otherwise add the point to the Set of Cluster Maximals.
5) Repeat step 4.
Two concerns I have:
1) There is an issue that my algorithm would work only in case if Claster Maximals are located on the surface of the spheres.
2) Plus, according to the task requirements, there could be the case when 2 spheres can have 1 and only common point.
I think in case if point belongs to 2 spheres, it is ok to mark it with cluster_id of any of these 2 shperes.
Could you please provide a proper solution to the task?

A: As the radius is given, find the point with the most neighbors.
Take the average of its neighbors as center, and remove everything within the radius.
Repeat until no dense points remain.
Perform some postprocessing to further optimize for unassigned points and to ensure the minimum distance.


text:
Q: Add custom powershell parameter attribute to enable filtering I'm writing a function that's basically a convenience wrapper around an external program that it'll invoke. Several of the parameters will be forwarded to the external program, but not all.
I was writing
$ArgsToFwd = @()
switch ($PSBoundParameters.Keys) {
  '--server' {$ArgsToFwd += @('--server',$server)}
  '--userid' {$ArgsToFwd += @('--userid',$userid)}
  ...
}

but then I thought it might be better to define a custom parameter attribute that could let me do something like:
params(
[Parameter()]
[IsExternal()]
[string]$Server
)
#...
foreach ($key in $PSBoundParameters.Keys) {
    if (<#a test for the custom [IsExternal] attribute#>) {
        $ArgsToFwd += @($key, $PSBoundParameters[$key])
    }
}

But I can't quite figure it out. Can that be done?

A: If you want to use custom attributes, there are 3 things you need to do:

*

*Define a custom Attribute type

*Decorate your function's parameters with instances of said attribute

*Write a mechanism to discover the attribute decorations and do something with them at runtime

Let's start with step 1, by defining a custom class that inherits from System.Attribute:
class ProxyParameterAttribute : Attribute
{
  [string]$Target

  ProxyParameterAttribute([string]$Target){
    $this.Target = $Target
  }
}

Attribute annotations map directly back to the target attribute's constructor, so in this case, we'll be using it like [ProxyParameter('someValue')] and 'someValue' will then be stored in the $Target property.
Now we can move on to step 2, decorating our parameters with the new attribute. You can omit the Attribute part of the name when applying it in the param block, PowerShell is expecting all annotations to be attribute-related anyway:
function Invoke-SomeProgram
{
  param(
    [ProxyParameter('--server')]
    [Parameter()]
    [string]$Server
  )

  # ... code to resolve ProxyParameter goes here ...
}

For step 3, we need a piece of code that can discover the attribute annotations on the parameters of the current command, and use them to map the input parameter arguments to the appropriate target names.
To discover declared parameter metadata for the current command, the best entry point is $MyInvocation:
# Create an array to hold all the parameters you want to forward
$argumentsToFwd = @()

# Create mapping table for parameter names
$paramNameMapping = @{}

# Discover current command
$currentCommandInfo = $MyInvocation.MyCommand

# loop through all parameters, populate mapping table with target param names
foreach($param in $currentCommandInfo.Parameters.GetEnumerator()){
  # attempt to discover any [ProxyParameter] attribute decorations
  $proxyParamAttribute = $param.Value.Attributes.Where({$_.TypeId -eq [ProxyParamAttribute]}, 'First') |Select -First 1
  if($proxyParamAttribute){
    $paramNameMapping[$param.Name] = $proxyParamAttribute.Target
  }
}

# now loop over all parameter arguments that were actually passed by the caller, populate argument array while taking ProxyParameter mapping into account
foreach($boundParam in $PSBoundParameters.GetEnumerator()){
  $name = $boundParam.Name
  $value = $boundParam.Value
  if($paramNameMapping.ContainsKey[$name]){
    $argumentsToFwd += $paramNameMapping[$name],$value
  }
}

Now that the parameters how been filtered and renamed appropriately, you can invoke the target application with the correct arguments via splatting:
.\externalApp.exe @argumentsToFwd

Putting it all together, you end up with something like:
class ProxyParameterAttribute : Attribute
{
  [string]$Target

  ProxyParameterAttribute([string]$Target){
    $this.Target = $Target
  }
}
function Invoke-SomeProgram
{
  param(
    [ProxyParameter('--server')]
    [Parameter()]
    [string]$Server
  )

  # Create an array to hold all the parameters you want to forward
  $argumentsToFwd = @()

  # Create mapping table for parameter names
  $paramNameMapping = @{}

  # Discover current command
  $currentCommandInfo = $MyInvocation.MyCommand

  # loop through all parameters, populate mapping table with target param names
  foreach($param in $currentCommandInfo.Parameters.GetEnumerator()){
    # attempt to discover any [ProxyParameter] attribute decorations
    $proxyParamAttribute = $param.Value.Attributes.Where({$_.TypeId -eq [ProxyParamAttribute]}, 'First') |Select -First 1
    if($proxyParamAttribute){
      $paramNameMapping[$param.Name] = $proxyParamAttribute.Target
    }
  }

  # now loop over all parameter arguments that were actually passed by the caller, populate argument array while taking ProxyParameter mapping into account
  foreach($boundParam in $PSBoundParameters.GetEnumerator()){
    $name = $boundParam.Name
    $value = $boundParam.Value
    if($paramNameMapping.ContainsKey[$name]){
      $argumentsToFwd += $paramNameMapping[$name],$value
    }
  }

  externalApp.exe @argumentsToFwd
}

You can add other properties and constructor arguments to the attributes to store more/different data (a flag to indicate whether something is just a switch, or a scriptblock that transforms the input value for example).
If you need this for multiple different commands, extract the step 3 logic (discovering attributes and resolving parameter names) to a separate function or encapsulate it in a static method on the attribute class.


text:
Q: DokuWiki: Include content from Django Application The "intranet knowledge base" of the company I work for is our DokuWiki.
I want to add some data to dokuwiki of a django application.
I found the dokuwiki plugin include, but this seems to be only able to include wiki pages, not external resources (via https://....).
How can I add content from a web application to dokuwiki?
Support for authentication (dokuwiki needs a password to access the web application) would be good.

A: You can use an iframe, with the iframe plugin.
Note that the other application needs authentication of its own.
But it is applied then on that included page also, depending if you are logged into the browser. Displaying authenticated pages on behalf of this wiki is an other question, needs more complex approach.


text:
Q: grep with variable in a variable I want to filter the svlog file by date and  split the result by the space,
so when i enter the date,  it didn't work for me,
please refer to the script that I wrote below, the problem was in this command:
ligne=`cat /var/log/svlog | grep  "\$day"`

, it doesn't consider "\$day". i also tried this "^\$day", this  "$day" and this "${day}" but the same result.
#!/bin/bash

echo SCRIPT-LOG
echo enter date
read day

ligne=`cat /var/log/svlog | grep  "\$day"`

$ligne >> log1.txt

awk '{split($ligne,numbers," ")} END {for(n in numbers){ print numbers[n] }}'>lo

"Monit_Sub.sh" 11 lines, 211 characters

$ sudo ./Monit_Sub.sh
SCRIPT-LOG
enter date
Apr 26
./Monit_Sub.sh: line 8: Apr: command not found

$

A: Change
ligne=`cat /var/log/svlog | grep  "\$day"`

to
ligne=$(grep "$day" /var/log/svlog)

To feed the contents of $ligne to awk, use
echo "$ligne" | awk ...


text:
Q: Installing cuDNN on elementry os gives segmentaion fault I'm installing cuDNN from official nvidia site. I already installed CUDA.
Following commands were used during installtion:
 tar -xzvf cudnn-9.0-linux-x64-v7.tgz
 sudo cp cuda/include/cudnn.h /usr/local/cuda/include
 sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
 sudo chmod a+r /usr/local/cuda/include/cudnn.h

Everything is fine upto here. Now when I run this command:
 /usr/local/cuda/lib64/libcudnn*

It gives me segmentaion fault. I can't figure out the problem !

A: I also meet the problem, and I have tried the deb package, but it doesn't work.
But after I rebooting the system, the problem doesn't appear.


text:
Q: The Hahn-Banach Separation Theorem for LCTVS I am currently reading through the text "Topological Vector Spaces" by Robertson, and I have come across the following proposition on page 29/30:
Proposition 5.  (Hahn-Banach Separation theorem.) Let $ E $ be a convex space.  Suppose that $ A $ and $ B $ are disjoint convex sets and that $ A $ is open.  Then there is a continuous linear form $ f $ such that $ f(A) $ and $ f(B) $ are disjoint ($ f $ separates $ A $ and $ B $).
(In this text, a convex space is just short for a locally convex topological vector space.)
The proof begins by stating that the set $ A - B $ is open and convex and does not contain the origin.
Unless I am missing something very trivial, isn't $ A - B = A $ since $ A $ and $ B $ are disjoint? Furthermore, why does $ A - B $ not contain the origin?
Any insight on this would be greatly appreciated.  Thanks!

A: The notation $A - B$ probably means the set $\{ x - y \mid x \in A, y \in B \}$, rather than the set theoretic difference. This is open because it is the union of the sets $A - y$ for $y \in B$. I leave the proof of convexity to you.
If $0 \in A - B$, then there exist $x \in A$ and $y \in B$ such that $x - y = 0$, i.e. $x=  y$, contradicting the disjointness of $A$ and $B$.


text:
Q: Windows Driver keeps changing back no matter what On Windows 10, when I update a video driver, and then restart, it changes it back to the old driver. Why? How to force it to keep a specific video driver?

A: Sometimes Windows Updates will "update" newer driver you got from vendor to an older version in Microsoft's repository.
Instead of reinstalling the newer one again, try to revert the "update" in the device property.


text:
Q: Is it possible to convert a field of varchar(32) to BLOB in Firebird database I would like to keep data which is already saved into a Table field varchar(32) and to convert it to BLOB in Firebird database.
I am using a software: IBExpert ....
If it is possible, how to do that ?

A: Let's consider you have table TEST with one column NAME:
create table test (name varchar(32));
insert into test values('test1');
insert into test values('test2');
insert into test values('test3');
commit;
select * from test;

It is possible to change the column from varchar to BLOB by the following script:
alter table test add name_blob blob;
update test set name_blob = name;
commit;
alter table test drop name;
alter table test alter column name_blob to name;
commit;
select * from test;

A: Specifically in IBExpert it easy to do with Firebird 2.1 and Firebird 2.5 via direct modifications of system tables (this "obsolete" method was prohibited in Firebird 3 but nothing was introduced to replace it).
This works in both directions, VARCHAR to BLOB and BLOB to VARCHAR.
You have to have a DOMAIN - that is, a named data type, in SQL, and that domain should be of BLOB type - then IBExpert itself would issue the command, that Firebird 2.x executes, if you set Firebird 2.x in database options.
If you don't have IB Expert then the following command you have to issue:
CREATE DOMAIN T_TEXT_BLOB AS   -- prerequisite
BLOB SUB_TYPE 1;

update RDB$RELATION_FIELDS     -- the very action
set RDB$FIELD_SOURCE = 'T_TEXT_BLOB'
   /* the name of the blob domain to be set as the field's new data type */
where RDB$FIELD_SOURCE = '.....' /* name of the column */
  and RDB$RELATION_NAME = '....' /* name of the table */

See also:

*

*https://firebirdsql.org/file/documentation/reference_manuals/fblangref25-en/html/fblangref25-ddl-domn.html

*https://firebirdsql.org/file/documentation/reference_manuals/fblangref25-en/html/fblangref-appx04-relfields.html
When you create a column or change its datatype without explicitly naming the type (like just varchar(10)) then under the hood Firebird creates automatically-managed one-per-column user domains with names like RDB$12345, so while you can do that too, perhaps having an explicit named domain would be more practical and more safe.
This method however fails on Firebird 3, where you do have to copy the whole table, as shown by Maxim above.

*

*http://tracker.firebirdsql.org/browse/CORE-6052
FB devs warn about some "bugs" and "it never worked properly" however refuse to give details.

UPDATE I finally managed to reproduce the bug mentioned in the tracker.
At least in Firebird 2.1 reference counting is broken w.r.t. BLOB payloads.
So the trick seems to be to instantly re-write implicit blobs into explicit, tricking Firebird to think we supplied new content for all the BLOB values.
Assuming the names from Maxim's answer above...
To trigger and demonstrate the bug take the "vanilla" VarChar database, apply the conversion described above, and issue the following commands:

*

*update test set name = name -- trying to force data conversion, but instead forcing Firebird reference counting bug

*select cast( name as VarChar(200) ) from test - or actually any command that would try to actually read the field contents - any such attempt would be shot down with the infamous invalid BLOB ID Firebird error.

To work around the bug we must prevent Firebird from (broken) reference counting. So, we must do a fake update, invoking expression evaluator, so that Firebird optimizer would loose track of value sources and would fail to realize the data was not really changed.

*

*update test set name = '' || name || '' -- really forcing data over-writing and conversion, bypassing BLOB reference counting.

*select cast( name as VarChar(200) ) from test - now works like a charm (albeit 200 was too short a string and you would be stuck with "overflow" error
The update command can be any other triggering expression evaluator, for example  update test set name = cast( name as VarChar( NNN ) ) - but you would need to devise large enough NNN for specific column of specific table. So, string concatenations with empty string is universal and does the work, at least on Firebird 2.1.

The above stands for Firebird 2.1.7 Win32. I did not manage to trigger "invalid BLOB id" with Firebird 2.5.8 Win64 - it "just worked".
At least using the single-connection schema update script, which is anyway the intended way to do database upgrades.
Maybe if I would do schema upgrades while simultaneously there would be users actively working - the FB 2.5 would get broken too, don't know.
Whether to use this shortcut risky way disregarding FB developers' hints, or to use "official" Maxim's answer, possibly dismounting and then re-creating half the database which happened to have "dependencies" upon the field to be dropped, stays up to the reader.


text:
Q: Find maximum of the difference between each cell of a raster and its surrounding cells I would like to do the following for each cell (let's call it cell_i) of a raster:

*

*Define a neighboring region around cell_i (for instance, a region defined by the 8 surrounding cells of cell_i).

*For each cell in the region defined in (1), find the difference between its value and the value of cell_i.

*For all the differences computed in (2), find the minimum.

*Store the minimum value from (3) in a new raster in the same spatial location as cell_i.

Are there existing tools that can do this?
If not, can you provide pointers on how to script this (ideally in ArcPy)?
I think that I have the algorithm down (for instance, I would know how to implement this if the raster was a matrix in matlab or 2D array in C#).
What are the commands needed, such as iterating through the original raster and saving values in a new raster?

A: This workaround can be done with GDAL python module. I used a small raster to make easier the corroboration of minimum values of the difference between each raster cell and its neighboring region around it. As the values in the periphery of raster has not 8 surrounding cells, next code add a "ring" of -999 values to facilitate the evaluation of differences (incorporated in 'new_list' list) in this area. This 'new_list' was used for determining minimum values before they be incorporated in 'raster' list. This 'raster' list was reshaped as one numpy array, with the same number of rows and columns that the original raster, and used for obtaining resulting raster.
from osgeo import gdal, osr
import numpy as np

driver = gdal.GetDriverByName('GTiff')
filename = "/home/zeito/pyqgis_data/test.tif"
dataset = gdal.Open(filename)
band = dataset.GetRasterBand(1)

cols = dataset.RasterXSize
rows = dataset.RasterYSize

data = band.ReadAsArray()

#inserting ring of -999 around data values
data = np.insert(data, 0, -999, axis = 0)
data = np.insert(data, 0, -999, axis = 1)
data = np.insert(data, len(data), -999, axis = 0)
data = np.insert(data, len(data[0]), -999, axis = 1)

print data

raster = [ ]

for i in range(1, rows + 1):
    for j in range(1, cols + 1):
        val = data[i][j]
        new_list = [ data[i-1][j-1], data[i-1][j], data[i-1][j+1],
                     data[i][j-1], data[i][j+1],
                     data[i+1][j-1], data[i+1][j], data[i+1][j+1]]

        print val
        print new_list

        #list with differences
        new_list = [ val - item for item in new_list if item != -999]

        #determining minimum
        raster.append(np.min(new_list))

#creating numpy array with minimum values by cell
raster = np.asarray(np.reshape(raster, (rows, cols)))

transform = dataset.GetGeoTransform()

# Create gtif file
driver = gdal.GetDriverByName("GTiff")

output_file = "/home/zeito/pyqgis_data/minimum_differences.tif"

dst_ds = driver.Create(output_file,
                       cols,
                       rows,
                       1,
                       gdal.GDT_Float32)

#writting output raster
dst_ds.GetRasterBand(1).WriteArray( raster )

#setting extension of output raster
# top left x, w-e pixel resolution, rotation, top left y, rotation, n-s pixel resolution
dst_ds.SetGeoTransform(transform)

wkt = dataset.GetProjection()

# setting spatial reference of output raster
srs = osr.SpatialReference()
srs.ImportFromWkt(wkt)
dst_ds.SetProjection( srs.ExportToWkt() )

#Close output raster dataset
dataset = None
dst_ds = None

Above code was run at the Python Console of QGIS and, there were printed the corroboration values (see next image).

Resulting raster was obtained as expected (by using Value Tool plugin to corroborate cell raster values):

A: I agree, focal statistics is probably the way to go :
http://desktop.arcgis.com/en/arcmap/10.3/tools/spatial-analyst-toolbox/focal-statistics.htm
Use the "Minimum" setting to get what you are looking for, except that will include the value of the central cell itself if this happens to be the lowest value. Is that acceptable?


text:
Q: Who finishes first? Gearman or Mongo PHP insert? I'm looking at running Gearman ( http://gearman.org) and storing data in Mongo using the Mongo PHP library to manage inserts/updates. So the steps are...
STEPS:

*

*Insert some data into mongo via php mongo insert. When I insert the data I
am able to grab the new item "_id" from the initial data object.

*Run php snippet to send Gearman server a job to do passing the _id as
the data.

*The gearman PHP script runs pretty much instantly and
grabs the _id from mongo and does some work with it.

My question is... will the data even be in Mongo before gearman starts looking for it. In other words is the _id not a good way to detect if the new data is stored. Is there a way to check this? I need the PHP to be paused (blocked sort of speak) before the PHP code send off the job to gearman since the gearman service will kick in immediately and look for the _id in mongo. Is this possible? My understanding is if the mongo insert runs asynchronously there could be enough lag inserting the item that is longer than the time it takes the gearman php script to start... missing the new _id and the data.


text:
Q: How to check device compatibility for finger print authentication in android API lower than 23 I am working with finger print authentication using android 5.0 api. My requirement is, if current device is supports finger print authentication, then I will go through finger print authentication else will use normal way, but need to check every device of api 18 and above if they have finger print scanner or not.
So, any one can tell me, how to check device compatibility for finger print authentication in android.
Thanks in advance.

A: You can use Build.VERSION.SDK_INT
Log.i("TEST", "API Level is: " + Build.VERSION.SDK_INT);

So:
if (Build.VERSION.SDK_INT > 18) {
    // do the job.
}

A: FingerprintManager fingerprintManager = (FingerprintManager)getSystemService(FINGERPRINT_SERVICE);

if(Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2){
          if(!fingerprintManager.isHardwareDetected()){
               //your device doesn't have fingerprint Sensor
          }else{
            // do your code..
          }
    }


text:
Q: SoapUI Mock Server on AWS EC2 with Load Balancer SSL I'm trying to setup a SoapUI Mock Service on an AWS EC2 Windows instance with a Load Balancer that has an SSL certificate. The problem I'm encountering is I cannot connect to the Mock Server from my ReadyAPI desktop application.
I have successfully setup the same SoapUI Mock Service on an AWS EC2 Windows instance without a Load Balancer. What I did is I just created a SoapUI Project with 3 operations and generated their corresponding mock services; I assigned port 9090 which I also opened in Windows Firewall. I run the mock services and connect ReadyAPI from my desktop using the endpoint (http://EC2-IP Address:9090); I was able to sent request and received response from the mock services in my AWS EC2 Windows instance. But this same procedure fails for my EC2 windows instance that has a Load Balancer and an SSL certificate.
I have my AWS EC2 Certificate .PEM file, from which I generated a Private and Public key using PuTTY Key Generator, I tried to use both keys on ReadyAPI keystore but it asked for a password which I don't remember creating when I created the AWS certificate keyPair .PEM file. I also tried to register the generated Putty Private key in Windows Certificates but it cannot recognize the file type with .ppk extension.
I believe I'm still missing some steps, I'm hoping the community can point me to the right direction as to  what to research and use. Thank you.

A: I just found out that I need a "Custom TCP Rule" in the EC2 Security Group Inbound permission for port 9090. After I added this, I was then able to connect to my Mock Service.


text:
Q: Create directive in angularJs I'm trying to create a directive in angularJS. But it's not working. What I have done is as follow.
my main html code

Hello Plunker!

    <myCustomer></myCustomer>

My Js code :
var app = angular.module('birthdayToDo', []);

app.controller('main', function($scope) {
  $scope.employees=[
                    {
                      Name:"Amit",
                      Email:"Amit@gmail.com"
                    },
                    {
                      Name:"Ajay",
                      Email:"Ajay@gmail.com"
                    },
                    {
                      Name:"Rahul",
                      Email:"Rahul@gmail.com"
                    },
                    {
                      Name:"Aakash",
                      Email:"Aakash@gmail.com"
                    },
                    {
                      Name:"Rohit",
                      Email:"Rohit@gmail.com"
                    },
                  ];

});
app.directive('myCustomer', function() {
    var directive = {};

    directive.restrict = 'E'; /* restrict this directive to elements */
    directive.templateUrl = "directiveFile.html";

    return directive;
  });

my directiveFile.html code

    SNo.
    Name
    Email

    {{$index+1}}
    {{employee.Name}}
    {{employee.Email}}

But this code is not working . What's wrong I'm doing.
Plunker link

A: You have 2 option of naming:
1.
app.directive('myCustomer', function()
<my-customer> </my-customer>

2.
app.directive('mycustomer', function()
<mycustomer>  </mycustomer>

A: Change
<myCustomer></myCustomer>

To this:
<my-customer></my-customer>

A: Directives uses snake case.
change your HTML to this
<my-customer></my-customer>

Always remember ng-app, ng-click, etc


text:
Q: Apache Camel XSLT I am new to XSLT, trying to create an endpoint using XSLT.
I know how to call xsl file from particular directory. My question is how to add the xsl file within the camel route and can use it in xslt endpoint.
I tried writing XSL thing within javascript in camel route like ,
<script>
<javascript>
    ...xsl code goes here
</javascript>
</script>

While doing this getting error "org.apache.camel.builder.script.ScriptEvaluationException - Failed to evaluate: js". Is there any other way to set in header or body.
Any help would be most welcome.

A: Camel has a XSLT component which you can use:
<to uri="xslt:myXslFile.xsl" />

You can read more about this component in the documentation.

A: According to the Camel Docs:

To provide a dynamic stylesheet at runtime you can define a dynamic URI. See How to use a dynamic URI in to() for more information.

I guess (did not tried it) it could be something like <toD uri="xsl:${header.foo}"/> to load the stylesheet from the header named foo. The toD is to route to a dynamic endpoint.

A: You can try the following in your spring dsl route
 <camel:to uri="xslt:YourXSLFile.xsl" />


text:
Q: What is pagination in the context of Spring Data JPA? I am bit confused what pagination means in the context of Spring Data. Is it to do with how much data is retrieved per round trip to the data source? Please can someone explain this concept.

A: Yep, it's exactly what you do when you add a LIMIT(rowcount, offset) clause in your SQL statement.
This is mostly used when you want to display "pages" of data when the result of your query gets too big, hence the Pagination concept.


text:
Q: Fixed DIV when scrolling in a pop up window I'm looking for a CSS/JQuery method of keeping a DIV (which contains navigation buttons) visible when scrolling or content extends the viewable window size.
I have come across CSS code like this:
.element { position:fixed; Bottom:0px }

But my request is for use within a pop up window / dialog and this code doesn't seem to work for my scenario.
I have a pop up window which displays a 'next' and 'previous' button at the bottom and each "page" is a fieldset which is animated in or out of view.
There are a few fieldsets which go beyond the height of the pop up window and so the scroll activates. But I want to keep my button DIV in view at all times, along the bottom of the pop up window.
Trying to use the CSS above does not seem to set the element within the pop up window, rather it is positioning based on the parent window.
Is there a way to create a fixed DIV to remain visible when scrolling within a pop up window?
Any help would be greatly appreciated.
EDIT:
Code for the pop up window:

    <form id="msform">

User Details

Level Selection

Access Items

Summary

        <fieldset id="fsDetails">

Enter user details

            @*
This is step 1
*@

                <input type="text" name="RequestedFor" id="RequestedFor" placeholder="Requested For   " readonly title="Requested For" tabindex="-1" />
                <input type="text" name="DirectorateName" id="DirectorateName" placeholder="Directorate   " title="Directorate" tabindex="1" style="border-color:red;" />
                <input type="text" name="Dept" id="Dept" placeholder="Department   " title="Department" tabindex="3" />
                <input type="text" name="ForOtherStaff" id="ForOtherStaff" placeholder="Form For Other Staff? (Enter Username)   " onblur="getUserForForm()" title="Form For Other Staff? (Enter Username)" tabindex="5" />
                <select id="Title" name="Title" title="User Title" onchange="onTitleChange()" tabindex="7">
                    <option value="">Select Title...</option>
                    <option value="Mr">Mr</option>
                    <option value="Mrs">Mrs</option>
                    <option value="Ms">Ms</option>
                </select>

                <input type="hidden" name="UserName" id="UserName" /><input type="hidden" name="FormId" id="FormId" />

                <input type="text" name="RequestDate" id="RequestDate" placeholder="Request Date  " readonly title="Request Date" tabindex="-1" />
                <select id="PhysicalSite" name="PhysicalSite" onchange="onSiteChange()" title="Site" tabindex="2" style="border-color:red;"></select>
                <input type="text" name="PhoneNo" id="PhoneNo" placeholder="Phone Number   " title="Phone Number" tabindex="4" />
                <input type="text" name="Payroll" id="Payroll" placeholder="Payroll Number   " title="Payroll Number" tabindex="6" />
                <input type="text" name="ReplacedName" id="ReplacedName" placeholder="Replaced Name  " title="Replaced Name" tabindex="8" />
                <input type="hidden" name="UserEmail" id="UserEmail" /><input type="hidden" name="RequestId" id="RequestId" />

            <input type="text" name="Comments" id="Comments" placeholder="Comments  " title="Comments" tabindex="9" />

                <input type="button" name="save" class="save action-button" value="Save" tabindex="9" />
                <input type="button" name="next" class="next action-button" value="Next" tabindex="10" />

        </fieldset>
        <fieldset id="fsLevel" title="hidden">

Access Level / Item Selection

To add items using a role, please go to next section (Access Item)

                Access Level

                @(Html.Kendo().DropDownList()
                .Name("AccessLevel")
                .HtmlAttributes(new { style = "width:100%;text-align:left;margin-bottom:4px;float:left;" })
                .DataTextField("Description")
                .DataValueField("Code")
                        //.AutoBind(false)
                .DataSource(source =>
                {
                    source.Read(read =>
                    {
                        read.Action("GetAccessLevelList", "Home").Type(HttpVerbs.Post);

                    });//.ServerFiltering(false);

                })
                .Events(e => e.Change("AccessListRebind"))
                        //.Events(e => e.DataBound("DropDownDefaults"))
                )

                    @(Html.Kendo().MultiSelect()
                .Name("lstAccessLevel")
                .Events(e => e.Change("onAccessLevelItemChange"))
                .AutoBind(false)
                .IgnoreCase(true)
                    .Placeholder("Click here to select item(s)                                    ......")
                    .HtmlAttributes(new { style = "width:100%; float:left;display:block;" })
                    .DataTextField("AccessItemDesc")
                    .DataValueField("AccessItemCode")
                    .DataSource(dataSource => dataSource
                    .Read(read => read
                         .Action("GetAccessLevelItems", "Home").Type(HttpVerbs.Post)
                         .Data("AccessItemFilter")

                    )))

Summary of default / selected access items

                        Name
                        Value
                        Id

                <input type="button" name="previous" class="previous action-button" value="Previous" />
                <input type="button" name="save" class="save action-button" value="Save" />
                <input type="button" name="next" class="next action-button" value="Next" />

        </fieldset>
            </fieldset>

</form>

The code for opening the pop up:
    function OpenForm() {
    var dialog, form;

    dialog = $("#win1").dialog({

        autoOpen: false,

        height: 600,

        width: 650,

        modal: true,

        center: true,

        resizable: false,

    });

    dialog.center;

    form = dialog.find("form").on("submit", function (event) {

        event.preventDefault();

        addUser();

    });

    var formId, requestStatus, modeColor;
    var statusLabel = '';

    if (pFormId) {
        formId = ' Form Id: ' + pFormId;
        statusLabel = 'View Status History'
    }
    else
        formId = 'New Form';

    if ((pRequestStatus == 'APPROVED') || (pRequestStatus == 'PENDING') || (pRequestStatus == 'REJECTED')) {
        requestStatus = ' Read Only Mode  ';
        modeColor = 'indianred';
    }
    else {
        requestStatus = ' Edit Mode  ';
        modeColor = 'darkgray';
    }

    dialog.dialog({ title: pSystemName + ' - ' + pFormTypeName });
    dialog.dialog("open");

    //stop main window scrolling
    $('body').css('overflow', 'hidden');

    $("#lblfooter").remove();
    $("#lblfooter2").remove();
    $("#lblfooter3").remove();
    $("#win1").parent().append('' + formId + '' + statusLabel +
         '' + requestStatus + '');

}


text:
Q: Mysql update with php I have a point system were there's a quiz. when they click submit from the quiz i want them to get +1 into points in mysql. i got a datbase called login and table users, and in the users i want the points to be updated with 1+ when they have taken the quiz.
the code for the quiz_form i use:
:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Registration Form</title>

<form id="form1" name="form1" method="post" action="script.php">

Quiz1

UserName:

<input name="txtusername" type="text" id="txtusername" value="<?php
session_start();

if ($_SESSION['username'])
{

     echo "".$_SESSION['username'];

}

else
    header ("location: welcome1.html");

?>
" />

Who is Obama?
<input type="password" name="txtPassword" id="txtPassword" />

  What was the bing thing that were going to happend in 2012?
  <input type="text" name="txtemail" id="txtemail" />

What is a farrari?

<input type="text" name="txtnummer" id="txtnummer" />

What is a spoon used for?

<input type="text" name="txtnummer" id="txtnummer" />

Witch letter does this url start with?

<input type="text" name="txtnummer" id="txtnummer" />

Are COD a game?

<input type="text" name="txtnummer" id="txtnummer" />

<input type="submit" name="btnRegister" id="btnRegister" value="submit" />

</form>

<form id="form1" name="form1" method="post" action="script2.php">

Quiz2

UserName:

<input name="txtusername" type="text" id="txtusername" value="<?php

if ($_SESSION['username'])
{

     echo "".$_SESSION['username'];

}

else
    header ("location: welcome1.html");

?>
" />

Who evented facebook?
<input type="password" name="txtPassword" id="txtPassword" />

  What is a cat?
  <input type="text" name="txtemail" id="txtemail" />

What is a lamborgini?

<input type="text" name="txtnummer" id="txtnummer" />

What is goodel used for?

<input type="text" name="txtnummer" id="txtnummer" />

What is the last letter in this url

<input type="text" name="txtnummer" id="txtnummer" />

Are Counter strik a game?

<input type="text" name="txtnummer" id="txtnummer" />

<input type="submit" name="btnRegister" id="btnRegister" value="submit" />

</form>

<form id="form1" name="form1" method="post" action="script3.php">

Quiz3

UserName:

<input name="txtusername" type="text" id="txtusername" value="<?php

if ($_SESSION['username'])
{

     echo "".$_SESSION['username'];

}

else
    header ("location: welcome1.html");

?>
" />

What is yourube used for?
<input type="password" name="txtPassword" id="txtPassword" />

  What is a dog?
  <input type="text" name="txtemail" id="txtemail" />

What is a kebab?

<input type="text" name="txtnummer" id="txtnummer" />

Who is the most famed tenager in 2012/13?

<input type="text" name="txtnummer" id="txtnummer" />

What is the 4th letter in this url?

<input type="text" name="txtnummer" id="txtnummer" />

100*2 - 5 +105 -55 +45=

<input type="text" name="txtnummer" id="txtnummer" />

<input type="submit" name="btnRegister" id="btnRegister" value="submit" />

</form>

here is the script i use for the quiz:
<?php
//=============Configuring Server and Database=======
$host        =    'localhost';
$user        =    'root';
$password    =    '';
//=============Data Base Information=================
$database    =    'login';

$conn        =    mysql_connect($host,$user,$password) or die('Server Information is not Correct'); //Establish Connection with Server
mysql_select_db($database,$conn) or die('Database Information is not correct');

//===============End Server Configuration============

//=============Starting Registration Script==========

$username    =    mysql_real_escape_string($_POST['txtusername']);

//=============To Encrypt Password===================

//============New Variable of Password is Now with an Encrypted Value========

if(isset($_POST['btnRegister'])) //===When I will Set the Button to 1 or Press Button to register
{
$query = mysql_query("SELECT * FROM quiz WHERE username='$username'");
if(mysql_num_rows($query) > 0 ){
echo "Sorry but you can only take a quize once:S";

}else{

mysql_query ("insert into quiz(username)values('$username')");
$sql = "UPDATE users SET points = COALESCE(level,0)+1 WHERE username = $username";
header('location: succes.php');
}
}
?>

again, this work great. but i just need so they get 1 more points. so if they have 10 points and take this quiz they get 11 after clicking submit

A: Try this update query
 $qry = "UPDATE users SET points = points+1 WHERE username = $username"

and as was said in comments, start using PDO or MySqli with prepared statements for your future codes, as old mysql commands are deprecated.

A: I think you have a problem over here:
$sql = "UPDATE users SET points = COALESCE(level,0)+1 WHERE username = $username";

so, if you are doing like this.
try this,
$sql = "UPDATE users SET points = COALESCE(level+1,0) WHERE username = $username";


text:
Q: Error when parsing line of CSV text I fail parsing a CSV file in C. I need to file a struct with data from that file. This is the relevant part of my structure:
typedef struct Info {
    /* Some strings, integers, etc. */
    char correct; /* This is the value I can't set */
    short int status;
} t_info;

One line from my file looks like this xxxxxx;xxxxxxx;xxxxxxx;D;254 (the D is my problem, see below).
    char line[1024]; /* Buffer */
    t_info info;

    fgets(line, sizeof(line), fp);

    strcpy(info.xxxxxx, getLine(line, 1)); /* Works */
    strcpy(info.xxxxxx, getLine(line, 2)); /* Works */
    strcpy(info.xxxxxx, getLine(line, 3)); /* Works */
    strcpy(info.correct, getLine(line, 4)); /* Crashs! */

The getLine() function is taken from this post:
const char *getLine(char *line, int num)
{
    const char *tok, *tmp = strdup(line);

    for (tok = strtok(tmp, ";"); tok && *tok; tok = strtok(NULL, ";\n"))
    {
        if (!--num)
            return tok;
    }

    return NULL;
}

What is my problem?

A: Can not save into a char using strcpy().
typedef struct Info {
    char correct; /* This is the value I can't set */
} t_info;

strcpy(info.correct, getLine(line, 4)); /* Crashs! */

Use
info.correct = *getLine(line, 4);

Your compiler should have warned about this.  Review compiler settings.

A: The simplest way to fix this would be to get the first character of the line, and use that for the char.
info.correct = getLine(line, 4)[0];

Perhaps sscanf might be more suitable for your application (guide here) or (similar answer).


text:
Q: google drive API search all children file with given folder ID Here is how my folder is structured in google drive:
Picture
    |----------Date1
                 |-----Pic1.png
                 |-----Pic2.png
    |----------Date2
                 |-----Pic3.png
                 |-----Pic4.png

Right now I only have the ID of Picture folder (the parentID folder). Now I want to get Pic1 picture (inside Date1 folder). Is it possible to query only 1 time to get the picture with only the Picture folder's ID or I will have to query multiple times (get the Date1 and Date2 folder ID, then continue querying) ?
Here is my code right now
$imageName= "Pic1" // name of the image I want to find, which is Pic1
$folderId = "PictureFolderId" // Folder Picture's ID
$optParams = array(
            'pageSize' => 1,
            'fields' => 'nextPageToken, files(contentHints/thumbnail,fileExtension,id,name,size)',
            'q' =>"mimeType contains 'image/' AND name contains '".$imageName."' AND '".$folderId."' in parents"
          );
          $results = $googleDriveService->files->listFiles($optParams);

        if (count($results->getFiles()) == 0) {
            print "No files found.\n";
        } else {
            // Do something.
        }

A: If I understand you correctly, you want to:

*

*Retrieve all the image files which are descendants (children, grandchildren, etc.) of a certain folder.

*You want to retrieve this with a single API call.

Answer:
It is currently not possible to retrieve files in sub-folders with a single call. That's because a File resource (and a "folder" is a File) does not have information on what files are contained in this parent folder (let alone files contained in "sub-folders") and it only has information on the immediate parents of this folder, and not grandparents and so on, so to speak.
In order to retrieve all "descendants" of a certain folder, two main methods can be used (largely based on this answer by pinoyyid):
Method 1. List all folders:

*

*List all folders in your Drive via Files: list, disregarding whether they have the main folder ID in parents. Let's call this list All folders.

*Filter All folders, according to whether they have the main folder ID in parents. Let's call this list Direct children.

*For each element in Direct children, filter All folders according to whether they have the corresponding direct child in parents. This way, you will retrieve a list of Grandchildren. Repeat the same process for each Grandchildren element, then for each Great-grandchildren and so on, until no folders are left. With this, you will have retrieved all the folders which are descendant of the main folder ID.

*Once you have all the descendant folders, you have to make another Files: list to find the images which are children of any of those folders, or from the main folder. The search query could be something like this:

mimeType contains 'image/' AND ('mainFolderId' in parents OR 'descendant1ID' in parents OR 'descendant2ID' in parents OR...)

*

*Note: This method requires less API calls and will be more appropriate if the file tree is relatively large.

Method 2. Iterate recursively:

*

*Use Files: list to list all files in your main folder which are either folders (and so their own children should be listed) or images. In this case, the search query would be something like:

(mimeType = 'application/vnd.google-apps.folder' OR mimeType contains 'image/') AND 'folderId' in parents

*

*For each child returned by this call, check if it's an image (MIME type containing image/) or a folder (MIME type: application/vnd.google-apps.folder). For each folder, list all files contained in it, using the method from previous step.

*Repeat these two steps until there is no folder left. All the images you have retrieved are the "descendants" of your main folder.

Notes:
There is an open feature request in Issue Tracker to include ancestors in query searches, which could allow the retrieval of children in subfolders, and making this whole process much more easy. You could click the star on the top left of the referenced page in order to keep track of this request and to help prioritize it:

*

*Issue #111763024. When will you allow us to use "ancestors" field in searches?
Reference:

*

*How do I search sub-folders and sub-sub-folders in Google Drive?


text:
Q: End Time should be greater than Start Time I have two time pickers one is for start Time and another for End Time, The End Time must be always greater than start time. I am using eonasdan datetimepicker. If start date is greater than end date it should not allow or we need to get pop. Please help me out with this
Here's what i have done so far

$('#starttime,#endtime').datetimepicker({
  format: 'HH:mm'
});

var start_time = $('#Start_Time').val();

var end_time = $('#End_Time').val();

if (Date.parse(start_time) > Date.parse(end_time)) {
  alert('start time should be smaller');
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker-standalone.min.css" rel="stylesheet"/>

      Start Time

        <input type='text' class="form-control" id="Start_Time" />

      End Time

        <input type='text' class="form-control" id="End_Time" />

A: You may need to update the endTime.minDate on each startTime.change event.
Try to follow my example:

function TimePickerCtrl($) {
  var startTime = $('#starttime').datetimepicker({
    format: 'HH:mm'
  });

  var endTime = $('#endtime').datetimepicker({
    format: 'HH:mm',
    minDate: startTime.data("DateTimePicker").date()
  });

  function setMinDate() {
    return endTime
      .data("DateTimePicker").minDate(
        startTime.data("DateTimePicker").date()
      )
    ;
  }

  var bound = false;
  function bindMinEndTimeToStartTime() {

    return bound || startTime.on('dp.change', setMinDate);
  }

  endTime.on('dp.change', () => {
    bindMinEndTimeToStartTime();
    bound = true;
    setMinDate();
  });
}

$(document).ready(TimePickerCtrl);
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker-standalone.min.css" rel="stylesheet"/>

      Start Time

        <input type='text' class="form-control" id="Start_Time" />

      End Time

        <input type='text' class="form-control" id="Start_Time" />

A:  var startDate = Date.parse($('#txtdatetimepicker1').val());
 var endDate = Date.parse($('#txtdatetimepicker2').val());
 if (startDate >= endDate) { alert("Please enter proper date") }

A: Disable the past dates than start date in end_time text box. Something like this, please replace textbox id as in your html code.
$( "#startDate" ).datepicker({
  onSelect: function(dateText, inst) {
    $('#endDate').datepicker('option', 'minDate', $(this).val());
  },
  minDate: 0
});
$( "#endDate" ).datepicker({
  onSelect: function(dateText, inst) {
    if($( "#startDate" ).val() == ''){
      $( "#endDate" ).val('');
    }
  },
})

A: I did some thing with timepicker
Fiddle Link Over here...!
https://fiddle.jshell.net/kxL0f1gc/

<link href="https://adminlte.io/themes/AdminLTE/plugins/timepicker/bootstrap-timepicker.min.css">

Try this HTML Code

                                Start Time
                                <input id="start" name="start" ng-model="start" type="text" required="required" class="form-control start" />

                                End Time
                                <input id="end" name="end" ng-model="end" type="text" required="required" class="form-control end" />

$('.start, .end').timepicker({
  showInputs: false,
  minuteStep: 1,
});
$( "#end, #start" ).change(function() {
var time = $("#start").val();
var hours = Number(time.match(/^(\d+)/)[1]);
var minutes = Number(time.match(/:(\d+)/)[1]);
var AMPM = time.match(/\s(.*)$/)[1];
if(AMPM == "PM" && hours<12) hours = hours+12;
if(AMPM == "AM" && hours==12) hours = hours-12;
var sHours = hours.toString();
var sMinutes = minutes.toString();
if(hours<10) sHours = "0" + sHours;
if(minutes<10) sMinutes = "0" + sMinutes;
var time2 = $("#end").val();
if(time2=="")
  {
   var time2 = "00:00 AM";
  }
  var hours2 = Number(time2.match(/^(\d+)/)[1]);
  var minutes2 = Number(time2.match(/:(\d+)/)[1]);
  var AMPM2 = time2.match(/\s(.*)$/)[1];
  if(AMPM2 == "PM" && hours2<12) hours2 = hours2+12;
  if(AMPM2 == "AM" && hours2==12) hours2 = hours2-12;
  var sHours2 = hours2.toString();
  var sMinutes2 = minutes2.toString();
  if(hours2<10) sHours2 = "0" + sHours2;
  if(minutes2<10) sMinutes2 = "0" + sMinutes2;
  var comparehour = sHours2-sHours;
  var comparemin = sMinutes2-sMinutes;
  if(comparehour<0)
  {
   $("#end").val(time);
  }
 else if((comparehour==0) && (comparemin<0))
  {
   $("#end").val(time);
  }
  });

A: Set time validation with AM and PM
   var startTime = $('.StartTime').datetimepicker({
     "allowInputToggle": true,
     "showClose": true,
     "showClear": true,
     "showTodayButton": true,
     "format": ' hh:mm A',
     "useCurrent": false
   })

   var endTime =  $('.EndTime').datetimepicker({
    "allowInputToggle": true,
    "showClose": true,
    "showClear": true,
    "showTodayButton": true,
    "format": ' hh:mm A',
    "useCurrent": false })
   .on("dp.change", function (e) {
        minDate: startTime.data("DateTimePicker").date()
        bindMinEndTimeToStartTime(startTime);
        bound = true;
        setMinDate(endTime,startTime);
    });

    function setMinDate(endTime,startTime) {
        return
        endTime.data("DateTimePicker").minDate(startTime.data("DateTimePicker").date()
      );
   }

  function bindMinEndTimeToStartTime(startTime) {
      var bound = false;
      return bound || startTime.on('dp.change', setMinDate);
  }


text:
Q: .NET Application Updater Component without Webdav Does the .NET Application Updater Component (http://windowsclient.net/articles/appupdater.aspx) work without the WebDav protocol?

A: Quote from the page you linked:
The .NET Application Updater component uses HTTP-DAV to download the application update and thus requires a Web server that supports HTTP-DAV.
Although the source code is supplied, so you could possibly modify it to work another way.


text:
Q: What is the correct way to pass and consume a byte array containing audio data? I've been trying to create a WepAPI C# REST service that will return a byte array containing  audio (generated by a TTS service, in this case AWS Polly).  I am lost as to how to consume the array in the javascript client.
My WebAPI service is as follows...
var client = new AmazonPollyClient("secret", "secret", Amazon.RegionEndpoint.USWest2);

var ssreq = new SynthesizeSpeechRequest();
ssreq.Text = "hello world";
ssreq.VoiceId = VoiceId.Nicole;

var ttsresp = new TTSResp();

//// mp3 request
ssreq.OutputFormat = OutputFormat.Mp3;
var ssresp1 = client.SynthesizeSpeechAsync(ssreq).GetAwaiter().GetResult();
var ms = new MemoryStream();
ssresp1.AudioStream.CopyTo(ms);
var bytes = ms.ToArray();
ttsresp.Audio = ms.ToArray();

return Ok(ttsresp);

The reason I am returning an object is that I want to attach other metadata.
My javascript client is as follows...
var context;    // Audio context
var buf;        // Audio buffer

window.onload = function () {
    context = new AudioContext();
}

function getSound() {

    $.ajax({
        url: 'api/test',
        success: function (data) {
            console.log('success', data);

            var u8a = new Uint8Array(data.Audio.length);
            u8a.set(new Uint8Array(data.Audio), 0);

            //error here - DOMException: Unable to decode audio data
            context.decodeAudioData(u8a.buffer, play);
        },
        fail: function (err) {
            console.log('fail', err);
        }
    });
}

function play(audioBuffer) {
    var source = context.createBufferSource();
    source.buffer = audioBuffer;
    source.connect(context.destination);
    source.start(0);
}

My audio bytes returned are as follows...
"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"
Any help greatly appreciated...

A: The data that you received is base64-encoded. Before you can actually play it as audio, you need to base64-decode it into a byte array. (I did this and the data attached to the question is an mpga / mp3 file, after saving.)


text:
Q: JPA EntityManager blocks after @Transactional method I have a Spring-JUnit test with a setup method that uses JPA Entities to setup test data. Within the test itself, legacy code uses JDBC-Templates to query the inserted test data. When the legacy code issues a query, the call to jdbcTemplate.query(...) hangs.
My Unit Test looks like this:
@TransactionConfiguration(defaultRollback = false)
@ContextConfiguration(locations = { "/testContext.xml" })
@Transactional
public class MyTest {

    @PersistenceContext(unitName = "someUnit")
    private EntityManager entityManager;

    @Test
    public void test() {
        // here some legacy Code is called that uses JDBC Templates to query
        // the inserted test data. The legacy code hangs upon jdbcTemplate.query(...)
    }

    @Before
    public void before() {
        this.entityManager.persist(new Entity1(...));
        this.entityManager.persist(new Entity2(...));
    }

}

My question is: Why doesn't the enitymanager commit upon exiting the before() method? Or does it commit and immediately start a new transaction, that still references the stored entity? I also tried to do without the junit annotation @Before annotation and manually call the before() method. But this gives the same result.
Any advice is highly appreciated.

A: Test class
@ContextConfiguration(locations = { "/testContext.xml" })
@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = false)
@RunWith(SpringJUnit4ClassRunner.class)
@Transactional
public class MyTest extends AbstractTransactionalJUnit4SpringContextTests{

    @PersistenceContext(unitName = "someUnit")
    private EntityManager entityManager;

    @Autowired
    private BeforeService beforeService;

    @Test
    public void test() {
        beforeService.before();
        // here some legacy Code is called that uses JDBC Templates to query
        // the inserted test data. The legacy code hangs upon jdbcTemplate.query(...)
    }

}

Before Service
public class BeforeService {

    private EntityManager entityManager;

    @PersistenceContext
    public void setEntityManager(final EntityManager entityManager) {
        this.entityManager = entityManager;
    }

    @Transactional(propagation=Propagation.REQUIRES_NEW)
    public void before() {
        entityManager.persist(new Entity1(...));
        entityManager.persist(new Entity2(...));
    }
}

I hope I've given you all the answers about your question.


text:
Q: Require modules globally in a Exppress JS app and use a router level middleware after the HTTP request Bellow is the "users" module of my nodeJS application.
/**
 *  record.js
 */

var express = require('express'),
    router = express.Router();

// Config.
var config = require('../config/config');

// Validator class.
var validator = require('validator');

// User module.
var User = require('../models/user');

// Error middleware.
var errors = require('../middleware/errors');

/**
 *  --- Crypto. -------------------------------------------
 */

var crypto = require('crypto'),
    key = config.secretKey;

var encrypt = function (data) {
    var cipher = crypto.createCipher('aes-256-cbc', key);
    var crypted = cipher.update(data, 'utf8', 'base64');
    crypted += cipher.final('base64');
    return crypted;
};

var decrypt = function (data) {
    var decipher = crypto.createDecipher('aes-256-cbc', key);
    var decrypted = decipher.update(data, 'base64', 'utf8');
    decrypted += decipher.final('utf-8');
    return decrypted;
};

/**
 *  --- Register user. ----------------------------------------
 */

router.post('/user', function (req, res, next) {

    var email = validator.toString(req.body.email),
        password = validator.toString(req.body.password);

    if (!validator.isEmail(email)) {
        res.locals.validationError = 'isEmail';
        return next();
    }

    if (!validator.isLength(password, 3, 20)) {
        res.locals.validationError = {
            'type': 'isLength',
            'minLength': 3,
            'maxLength': 20
        };
        return next();
    }

    // Generate a hash, from the passowrd.
    var hash = encrypt(password);

    User.create({
        email: req.body.email,
        password: hash
    }, function (err, user) {

        if (err) {
            res.locals.dbError = err;
            return next();
        }

        // Prevent exposing sensitive data.
        var data = {
            'id': user._id,
            'email': user.email
        };

        // HTTP 201 - Created.
        return res.status(201).send(data);
    });
}, errors);

module.exports = router;

I believe in best practices, which leads me to the following questions.

*

*As you can see, I use dependency injection to require several other modules which the  "router" requires. (config, validator, etc.).

I will basically need to require the **validator module in every section of the app, and I am wondering if I can require it once globally and just reference it where I need it.**
Basically, is requiring a module inn different modules of an application the way to go?

*I use a "error" middleware, you can see it in action after the POST request.
If I'll have several HTTP requests in this module, is there a way I can inform express to use the middleware after each HTTP request, from a single place?

Something like the following, just that I want the middle ware to execute after the request, not before:
app.all('*', errors)

Right not the middleware executes before.

*What do you think of the coding style of the module? How would you refactor it? What would you change? I am just learning NodeJS, this is my first server side API and I want to get good habits.

A:
I will basically need to require the validator module in every section of the app, and I am wondering if I can require it once globally and just reference it where I need it.

Yes, you can, with global.validator = require('validator');. However, this is not a best practice, it's a worst practice. The node practice of explicit dependency declaration is favored as it is more readable, easier to track during refactoring, and fails earlier when things go wrong. We have a huge body of browser code as evidence that splitting a project into module files makes things better and declaring each module's dependencies makes things better, so don't revert to the old browser style of a single concatenated file that gets dependencies as globals.

I use a "error" middleware, you can see it in action after the POST request. If I'll have several HTTP requests in this module, is there a way I can inform express to use the middleware after each HTTP request, from a single place?

express has a built-in error handling middleware pattern you should read up on and use instead of this ad-hoc scheme you have built. To use it, pass an error to next:
if (err) {
  return next(err);
}

And code your error middleware as a 4-parameter middleware added after your main routes:
app.use(function error(err, req, res, next) {...});