text:
Q: How can a text box automatically pic the date and time before submitting a form in asp.net c# MVC? I am working on a razor view, that submits a form to database. It has three textboxes to store the title, amount and Date.
Although it works properly, But I don't want to enter the date manually, I want the form to automatically pick the date and time while submitting a form in a hidden manner, not allowing the users to change the date and time while submitting the form.
This is the razor view:
@using (Html.BeginForm("Request", "Requester", FormMethod.Post, new { enctype = "multipart/form-data" }))
{

    @Html.LabelFor(a => a.title)
    @Html.TextBoxFor(a => a.title, new { @class = "form-control" })

    @Html.LabelFor(a => a.amount)
    @Html.TextBoxFor(a => a.amount, new { @class = "form-control" })

    @Html.LabelFor(a => a.date_and_time)
    @Html.TextBoxFor(a => a.date_and_time, new { @class = "form-control" })

<button class="btn btn-primary">Request</button>
}

This is the model:
   public class Events
{
    public int Id { get; set; }
    public string title { get; set; }
    public string amount { get; set; }
    public DateTime date_and_time { get; set; }

  }

A: You can do something like this
        [HttpPost]
    public ActionResult Request(Events event)
    {
        event.date_and_time = DateTime.Now();

        //then do other operations or just save it in the the database
    }

A: There are two simple approaches.
Approach 1

    @Html.LabelFor(a => a.date_and_time)
    <input type="datetime-local"...>

Approach 2

    @Html.TextBoxFor(a => a.date_and_time, new { @type = "date", @class = "form-control
datepicker" })

Approach 2, unfortunately, only supports type "date". You may also consider using jquery datetimepicker or Bootstrap datetimepicker.


text:
Q: Create X509Certificate2 from PEM files ASP .Net 4.5 I'm having trouble generating a X509Certificate2 object from 2 .PEM files. I have 2 different files with the extension .PEM for both, and their content is

"-----BEGIN RSA PRIVATE KEY-----

{text}

-----END RSA PRIVATE KEY-----"

for one and

-----BEGIN CERTIFICATE REQUEST-----

{text}

-----END CERTIFICATE REQUEST-----"

for the other.
Problem: I need to generate a X509Certificate2 object using that.
I have tried to deliver an array []base64 but it has not worked.
I have tried to deliver you the file path, the file name, but I think you need the contents of .PEM.
I have searched but I have not gotten anything.
I have also not managed to transform the file to PFX.
I would be very grateful if you could help me with some information link or some code example, since I have not achieved anything.
Here I leave my last code used:
public static X509Certificate2 GetX509Certificate2()
{
    X509Certificate2 myCert = null;
    try
    {
        var pemCert = CargarCertificado();
        var pemPass = CargarLlave();
        myCert = new X509Certificate2(pemCert, pemPass);
    }
    catch (Exception e)
    {
        throw e;
    }
    return myCert;
}

public static SecureString CargarLlave()
{
    SecureString resp = new SecureString();
    string path = @"C:\PRIVATE_KEY.pem";
    var text = File.ReadAllText(path).Replace("-----BEGIN RSA PRIVATE KEY-----", "").Replace("-----END RSA PRIVATE KEY-----", "");
    resp = new NetworkCredential("", text).SecurePassword;
    return resp;
}

public static Byte[] CargarCertificado()
{
    Byte[] bytes;
    string path = @"C:\CERTIFICATE_REQUEST.pem";
    var text = File.ReadAllText(path).Replace("-----BEGIN CERTIFICATE REQUEST-----", "").Replace("-----END CERTIFICATE REQUEST-----", "");
    bytes = Encoding.ASCII.GetBytes(text);
    return bytes;
}

The exception now says:

The requested object cannot be found.

stack trace:

System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
en System.Security.Cryptography.X509Certificates.X509Utils._QueryCertBlobType(Byte[] rawData)
en System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromBlob(Byte[] rawData, Object password, X509KeyStorageFlags keyStorageFlags)
en System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(Byte[] rawData, SecureString password)

redpajama_set_name: RedPajamaStackExchange


text:
Q: Jboss Fuse cluster on external PC I have a problem with clusering Jboss Fuse. What I have to do is make a cluster with 4 containers but 2 of them have to be on another pc (virtual for now). My qestion is: how can I connect another 2 containers from another pc to my cluster? I'm not asking about deploying anything what will manage my nodes, but simply how to connect reomote containers to my cluser.
Sorry for my byt english and maby a silly qestion but I'm fresh in fuse :)

A: The clustering (i.e. load balancing of NMR traffic) of Fuse ESB is done using ActiveMQ Network of Brokers mechanism.
You can read a step-by-step guide on how to setup Fuse ESB cluster here:
fusesource.com/docs/esb/3.5/deploy_guide/DeployESBClusterConfig.html
and more information on how to establish a network of brokers on ActiveMQ (Fuse MB) here:
http://fusesource.com/docs/esb/4.4.1/amq_clustering/FuseMBClusterFaultTolerence.html
The general pattern suggested is to have a pair of master and slave on each host and interconnect the master of host A with the slave of host B, and vice versa.
However, if you interested just in ESB failover setup, it can be done using locking on the shared file system or database (jdbc):
http://fusesource.com/docs/esb/4.4.1/esb_runtime/ESBRuntimeFailoverFileLock.html


text:
Q: Put vertical rotated text within minipage environment I am creating a cheat sheet for a class and wanted to add some vertical text here:

How do I go about doing this?
Here is the code that I have thus far:
CODE
\documentclass{article}
\usepackage[landscape]{geometry}
\usepackage[table]{xcolor}
\usepackage{mathtools}
\usepackage{multicol}
\usepackage{amssymb,amsthm}
\usepackage{tikz}
\usepackage{rotating}
\usepackage[most]{tcolorbox}
\usepackage{float}

\advance\topmargin-1in
\advance\textheight3in
\advance\textwidth3in
\advance\oddsidemargin-1.5in
\advance\evensidemargin-1.5in
\parindent0pt
\parskip2pt
\newcommand{\hr}{\centerline{\rule{3.5in}{1pt}}}

\begin{document}

\begin{multicols*}{3}

\newtcolorbox{mybox}[2][]{text width=0.97\textwidth,fontupper=\scriptsize,
fonttitle=\bfseries\sffamily\scriptsize, colbacktitle=black,enhanced,
attach boxed title to top left={yshift=-2mm,xshift=3mm},
boxed title style={sharp corners},top=3pt,bottom=2pt,
  title=#2,colback=white}

%%------------ Single Side-Band (SSB) ---------------
\hspace{-0.2cm}
\begin{minipage}{0.31\textwidth}
    \begin{mybox}{Single Side-Band (SSB)}
\begin{tabular}{l l}

\begin{minipage}{4.2cm}
\vspace*{-0.3cm}
\begin{figure}[H]
\hspace*{-0.7cm}
\includegraphics[scale=0.3]{example-image-a}
%\caption{Plot Showing Animated Rotation about the x-Axis}%
\label{fig:quad_Demod}
\end{figure}
\end{minipage} &
\begin{minipage}{3.5cm}
\vspace*{-2cm}

Phase Shifting method:\\
\hspace*{-1.8cm}
$\phi_{SSB} =  A_{c}[m(t)\cos 2\pi f_{c}t\mp\hat{m}(t)\sin2\pi f_{c}t]$
\end{minipage}
\end{tabular}

\vspace*{1.25cm}
Demod of SSB-SC:$=A_{c}m(t)+\underbrace{A_{c}[m(t)\cos 4\pi f_{c}t\mp \hat{m}(t)\sin4\pi f_{c}t]}_{\text{Suppressed by LPF}}$

% Text to place vertically to the right:
\vspace*{-3.8cm}
\rotatebox{270}{
%\hspace*{3cm}
{\tiny
\begin{minipage}{5cm}
\begin{align*}
  \phi_{SSB} = & A_{c}[m(t)\cos 2\pi f_{c}t\mp\hat{m}(t)\sin2\pi f_{c}t] + A\cos2\pi f_{c}t, \\
             = & E(t)\cos(2\pi f_{c}t + \theta(t))\\
  \text{where}\quad E(t) = & A_{c}\sqrt{[A+m(t)]^{2} + [\hat{m}(t)]^{2}} \text{ and } \theta(t)=%
  -\tan^{-1}\left\{ \frac{\hat{m}(t)}{A + m(t)} \right\}
\end{align*}
\end{minipage}
}
}
%
%

    \end{mybox}
\end{minipage}

\end{multicols*}
\end{document}

EDIT
I made an edit by placing the text in a minipage environment and I was able to rotate the text.  The text box now appears to the left of the tcolorbox.  How to move the text box to the right as depicted in the image above?  Thanks!

A: Probably a year late for @Joe but I think is worth offering a xcoffin solution.
Many question posted in this forum are related with positioning graphics or text material in a page, according to a particular design: covers, title-pages, beamer  slides, posters, TOC, etc.
I appreciate the package xcoffin because provides, within a  very simple  environment, a solution for most of my problems on those issues.
Over time I got rid of geometry, rotate, titlepage, positioning, float and similar packages.
xcoffin has only a handful of intuitive commands that allows the assembly of the boxes and the fine tuning quite fast.
This is very important in the one-time jobs -- as I guess is this case --, like thesis or books covers, when you do not want to invest time in learning a new set of commands and the incompatibilities of a new package, to be used only once.
This particular problem is even easier than the example showed in the xcoffin documentation for two reason:

*

*It does not have specific requirements over the relative position of the material with respect to another, thus allowing to use a single reference origin (in this case the insertion point) and

*being a one time job (against to being a template or a class) there is not need to complicate the code with new lengths, commands or relative references to the boxes widths or heights, or different fonts.
The final tuning can be done manually, adjusting sizes and positions until a visually pleasant outcome is obtained.
Only five coffins are needed for the material supplied: the tcolorbox, the image-a and the three equations.
An extra box is used to collect the joined coffins and produce the output.
The proposed solution  is independent of the page size and its orientation.  (e.g. commenting out the geometry package).
One can only hope that xcoffin will some day  abandon the x!
    \documentclass{article}

    \usepackage[landscape,margin=0cm]{geometry}
    \usepackage{xcolor}
    \usepackage{amsmath}
    \usepackage[most]{tcolorbox}
    \usepackage{xcoffins}

    %% from the original, not needed in this case. xcoffin will work in any case
    %\usepackage{mathtools}
    %\usepackage{multicol}
    %\usepackage{amssymb,amsthm}
    %\usepackage{tikz}
    %\usepackage{rotating}
    %\usepackage{float}

    \pagestyle{empty}
    \parindent=0pt
    \parskip=2pt

    \newlength{\lmargin}
    \setlength{\lmargin}{1.5em}

    \begin{document}

    %%%%%%%%  Create & Set 6 coffins
    \NewCoffin\CheatSheet
    \NewCoffin\borderframe
    \NewCoffin\imageA
    \NewCoffin\eqPSM
    \NewCoffin\eqDemod
    \NewCoffin\eqPhi

    \SetHorizontalCoffin\CheatSheet{} %Coffin to hold the combined joined output

    \SetHorizontalCoffin\imageA{\includegraphics[width=2.7cm]{example-image-a}}

    \SetHorizontalCoffin\eqDemod{%
    Demod of SSB-SC: $=A_{c}m(t)+\underbrace{A_{c}[m(t)\cos 4\pi f_{c}t\mp \hat{m}(t)\sin4\pi f_{c}t]}_{\text{Suppressed by LPF}}$%
    }

    \SetVerticalCoffin\eqPSM{186pt}{%  PSM eq width =186pt
    \centering Phase Shifting method:\\%
    $\phi_{SSB} =  A_{c}[m(t)\cos 2\pi f_{c}t\mp\hat{m}(t)\sin2\pi f_{c}t]$%
    }

    \SetVerticalCoffin\eqPhi{338pt}{% phi eq width =338pt
    \begin{flalign*}
    \phi_{SSB} &=  A_{c}[m(t)\cos 2\pi f_{c}t\mp\hat{m}(t)\sin2\pi f_{c}t] + A\cos2\pi f_{c}t,\\%
    &=  E(t)\cos(2\pi f_{c}t + \theta(t))\\%
    \text{where}\quad E(t) &=  A_{c}\sqrt{[A+m(t)]^{2} + [\hat{m}(t)]^{2}} \text{ and } \theta(t)=%
    -\tan^{-1}\left\{ \frac{\hat{m}(t)}{A + m(t)} \right\}%
    \end{flalign*}
    }

    \SetHorizontalCoffin\borderframe{%
    \begin{tcolorbox}[%
    width=338pt+3\lmargin,% phi eq width =338pt
    height=338pt+2\lmargin,%  phi eq height =338pt after rotation
    fontupper=\scriptsize,%
    fonttitle=\bfseries\sffamily\scriptsize,%
    colbacktitle=black,enhanced,%
    attach boxed title to top left={yshift=-3mm,xshift=3mm},%
    boxed title style={sharp corners},top=3pt,bottom=2pt,%
    title=Single Side-Band (SSB),colback=white]
    \end{tcolorbox}
    }%

    %%%%%%%  Assembly

    \JoinCoffins*\CheatSheet[l,b]\borderframe[l,t]

    \JoinCoffins*\CheatSheet[l,b]\imageA[l,t](\lmargin,  -2\baselineskip)

    \JoinCoffins*\CheatSheet[l,b]\eqPSM[r,t](\lmargin+290pt, -2\baselineskip) %Demod eq width = 290pt

    \JoinCoffins*\CheatSheet[l,b]\eqDemod[l,t](\lmargin, -3\baselineskip-58pt) % image A height =58pt

    \RotateCoffin\eqPhi{-90}

    \JoinCoffins*\CheatSheet[l,b]\eqPhi[l,b](\lmargin+290pt, -2\baselineskip)

    %%%%%%%%%% Ouput

    \noindent\TypesetCoffin\CheatSheet(20pt,-100pt) %20pt right & 100pt down from upper left insertion point

    \end{document}

A: Here's a tikz option that might suit. (Updated for US Letter size paper.)
\documentclass{article}
\usepackage[landscape,margin=0cm]{geometry}
\usepackage{mathtools}
\usepackage{amssymb,amsthm}
\usepackage{multicol}
\usepackage[most]{tcolorbox}
\usepackage{tikz}
\usetikzlibrary{positioning}

\newtcolorbox{mybox}[2][]{width=\linewidth,fontupper=\scriptsize,
  fonttitle=\bfseries\sffamily\scriptsize, colbacktitle=black, enhanced,
  attach boxed title to top left={yshift=-2mm,xshift=3mm},
  boxed title style={sharp corners},top=2mm, bottom=1mm, left=1.5mm,
  right=1.5mm, title=#2, colback=white}

\pagestyle{empty}
\parindent=0pt
\parskip=2pt

\begin{document}

\begin{multicols*}{3}

\begin{mybox}{Single Side-Band (SSB)}
\begin{tikzpicture}[node distance=2mm, inner sep=0pt, outer sep=0pt]
  \node (image) {\includegraphics[width=2.7cm]{example-image-a}};
  \node (phase) [align=center, text width=5.5cm, right=of image.north east,
      anchor=north west] {
    Phase Shifting method: \\
    $\phi_{SSB} =  A_{c}[m(t)\cos 2\pi f_{c}t\mp\hat{m}(t)\sin2\pi f_{c}t]$
  };
  \node [below=of image.south west, anchor=north west,text width=7.5cm] {
    Demod of SSB-SC: \\
    \quad$=A_{c}m(t)+\underbrace{A_{c}[m(t)\cos 4\pi f_{c}t\mp \hat{m}(t)\sin4\pi f_{c}t]}_{\text{Suppressed by LPF}}$};
  \node [rotate=90, text width=8.1cm, below=of phase.south east, anchor=south
  east, font=\tiny] {
    \begin{align*}
      \phi_{SSB} = & A_{c}[m(t)\cos 2\pi f_{c}t\mp\hat{m}(t)\sin2\pi f_{c}t] + A\cos2\pi f_{c}t, \\
                 = & E(t)\cos(2\pi f_{c}t + \theta(t)) \\
      \text{where}\quad E(t) = & A_{c}\sqrt{[A+m(t)]^{2} + [\hat{m}(t)]^{2}} \text{ and } \theta(t)=-\tan^{-1}\left\{ \frac{\hat{m}(t)}{A + m(t)} \right\}
    \end{align*}
  };
\end{tikzpicture}
\end{mybox}

\end{multicols*}
\end{document}

A:  *File List*
 article.cls    2018/09/03 v1.4i Standard LaTeX document class
  size10.clo    2018/09/03 v1.4i Standard LaTeX file (size option)
geometry.sty    2018/04/16 v5.8 Page Geometry
  keyval.sty    2014/10/28 v1.15 key=value parser (DPC)
   ifpdf.sty    2018/09/07 v3.3 Provides the ifpdf switch
  ifvtex.sty    2016/05/16 v1.6 Detect VTeX and its facilities (HO)
 ifxetex.sty    2010/09/12 v0.6 Provides ifxetex conditional
mathtools.sty    2018/01/08 v1.21 mathematical typesetting tools
    calc.sty    2017/05/25 v4.3 Infix arithmetic (KKT,FJ)
 mhsetup.sty    2017/03/31 v1.3 programming setup (MH)
 amsmath.sty    2017/09/02 v2.17a AMS math features
 amstext.sty    2000/06/29 v2.01 AMS text
  amsgen.sty    1999/11/30 v2.0 generic functions
  amsbsy.sty    1999/11/29 v1.2d Bold Symbols
  amsopn.sty    2016/03/08 v2.02 operator names
 amssymb.sty    2013/01/14 v3.01 AMS font symbols
amsfonts.sty    2013/01/14 v3.01 Basic AMSFonts support
  amsthm.sty    2017/10/31 v2.20.4
multicol.sty    2018/04/20 v1.8s multicolumn formatting (FMi)
tcolorbox.sty    2018/07/26 version 4.14 text color boxes
     pgf.sty    2015/08/07 v3.0.1a (rcs-revision 1.15)
  pgfrcs.sty    2015/08/07 v3.0.1a (rcs-revision 1.31)
everyshi.sty    2001/05/15 v3.00 EveryShipout Package (MS)
  pgfrcs.code.tex
 pgfcore.sty    2010/04/11 v3.0.1a (rcs-revision 1.7)
graphicx.sty    2017/06/01 v1.1a Enhanced LaTeX Graphics (DPC,SPQR)
graphics.sty    2017/06/25 v1.2c Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    2016/01/03 v1.10 sin cos tan (DPC)
graphics.cfg    2016/06/04 v1.11 sample graphics configuration
  pdftex.def    2018/01/08 v1.0l Graphics/color driver for pdftex
  pgfsys.sty    2014/07/09 v3.0.1a (rcs-revision 1.48)
  pgfsys.code.tex
pgfsyssoftpath.code.tex    2013/09/09  (rcs-revision 1.9)
pgfsysprotocol.code.tex    2006/10/16  (rcs-revision 1.4)
  xcolor.sty    2016/05/11 v2.12 LaTeX color extensions (UK)
   color.cfg    2016/01/02 v1.6 sample color configuration
 pgfcore.code.tex
pgfcomp-version-0-65.sty    2007/07/03 v3.0.1a (rcs-revision 1.7)
pgfcomp-version-1-18.sty    2007/07/23 v3.0.1a (rcs-revision 1.1)
verbatim.sty    2014/10/28 v1.5q LaTeX2e package for verbatim enhancements
 environ.sty    2014/05/04 v0.3 A new way to define environments
trimspaces.sty    2009/09/17 v1.1 Trim spaces around a token list
etoolbox.sty    2018/08/19 v2.5f e-TeX tools for LaTeX (JAW)
    tikz.sty    2015/08/07 v3.0.1a (rcs-revision 1.151)
  pgffor.sty    2013/12/13 v3.0.1a (rcs-revision 1.25)
 pgfkeys.sty
 pgfkeys.code.tex
 pgfmath.sty
 pgfmath.code.tex
  pgffor.code.tex
    tikz.code.tex
  xparse.sty    2018-10-17 L3 Experimental document command parser
   expl3.sty    2018-10-31 L3 programming layer (loader)
expl3-code.tex    2018-10-31 L3 programming layer
l3pdfmode.def    2018-10-31 v L3 Experimental driver: PDF mode
listingsutf8.sty    2016/05/16 v1.3 Allow UTF-8 in listings input (HO)
listings.sty    2018/09/02 1.7 (Carsten Heinz)
 lstmisc.sty    2018/09/02 1.7 (Carsten Heinz)
listings.cfg    2018/09/02 1.7 listings configuration
pdftexcmds.sty    2018/09/10 v0.29 Utility functions of pdfTeX for LuaTeX (HO)
infwarerr.sty    2016/05/16 v1.4 Providing info/warning/error messages (HO)
ifluatex.sty    2016/05/16 v1.4 Provides the ifluatex switch (HO)
 ltxcmds.sty    2016/05/16 v1.23 LaTeX kernel commands for general use (HO)
stringenc.sty    2016/05/16 v1.11 Convert strings between diff. encodings (HO)
pdfescape.sty    2016/05/16 v1.14 Implements pdfTeX's escape features (HO)
shellesc.sty    2016/06/07 v0.02a unified shell escape interface for LaTeX
supp-pdf.mkii
epstopdf-base.sty    2016/05/15 v2.6 Base part for package epstopdf
  grfext.sty    2016/05/16 v1.2 Manage graphics extensions (HO)
kvdefinekeys.sty    2016/05/16 v1.4 Define keys (HO)
kvoptions.sty    2016/05/16 v3.12 Key value format for package options (HO)
kvsetkeys.sty    2016/05/16 v1.17 Key value parser (HO)
etexcmds.sty    2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO)
epstopdf-sys.cfg    2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live
inputenc.sty    2018/08/11 v1.3c Input encoding file
example-image-a.pdf    Graphic file (type pdf)
    umsa.fd    2013/01/14 v3.01 AMS symbols A
    umsb.fd    2013/01/14 v3.01 AMS symbols B
 ***********

(non answer, but too long for a comment)

A: I copied your code, but the results were a little different. So I made a few small changes to your document in order to obtain a similar image. You can see the code below:
\documentclass{article}
\usepackage[landscape]{geometry}
\usepackage[table]{xcolor}
\usepackage{mathtools}
\usepackage{multicol}
\usepackage{amssymb,amsthm}
\usepackage{tikz}
\usepackage{rotating}
\usepackage[most]{tcolorbox}
\usepackage{float}

\advance\topmargin-1in
\advance\textheight3in
\advance\textwidth3in
\advance\oddsidemargin-1.5in
\advance\evensidemargin-1.5in
\parindent0pt
\parskip2pt
\newcommand{\hr}{\centerline{\rule{3.5in}{1pt}}}

\def\clap#1{%
    \hbox to0pt{\hss#1\hss}%
}

\begin{document}

\begin{multicols*}{3}

\newtcolorbox{mybox}[2][]{text width=0.97\textwidth,fontupper=\scriptsize,
fonttitle=\bfseries\sffamily\scriptsize, colbacktitle=black,enhanced,
attach boxed title to top left={yshift=-2mm,xshift=3mm},
boxed title style={sharp corners},top=3pt,bottom=2pt,
  title=#2,colback=white}

%%------------ Single Side-Band (SSB) ---------------
\hspace{-0.2cm}
\begin{minipage}{0.35\textwidth}
    \begin{mybox}{Single Side-Band (SSB)}
        \begin{tabular}{l l}

            \begin{minipage}{4.2cm}
%               \vspace*{-0.3cm}
                \begin{figure}[H]
                    \hspace*{-0.5cm}
                    \includegraphics[scale=0.35]{example-image-a}
                    %\caption{Plot Showing Animated Rotation about the x-Axis}%
                    \label{fig:quad_Demod}
                \end{figure}
            \end{minipage} &
            \begin{minipage}{3.5cm}
                \vspace*{-2cm}

                Phase Shifting method:\\
                \hspace*{-1.8cm}
                $\phi_{SSB} =  A_{c}[m(t)\cos 2\pi f_{c}t\mp\hat{m}(t)\sin2\pi f_{c}t]$
            \end{minipage}
        \end{tabular}

        \vspace*{1.25cm}
        Demod of SSB-SC:$=A_{c}m(t)+\underbrace{A_{c}[m(t)\cos 4\pi f_{c}t\mp \hat{m}(t)\sin4\pi f_{c}t]}_{\text{Suppressed by LPF}}$

% Text to place vertically to the right:
\vspace*{-3.8cm}
\hfill\clap{
    \rotatebox{270}{
    %\hspace*{3cm}
    {\tiny
    \begin{minipage}{5cm}
        \begin{align*}
            \phi_{SSB} = & A_{c}[m(t)\cos 2\pi f_{c}t\mp\hat{m}(t)\sin2\pi f_{c}t] + A\cos2\pi f_{c}t, \\
                 = & E(t)\cos(2\pi f_{c}t + \theta(t))\\
              \text{where}\quad E(t) = & A_{c}\sqrt{[A+m(t)]^{2} + [\hat{m}(t)]^{2}} \text{ and } \theta(t)=%
  -\tan^{-1}\left\{ \frac{\hat{m}(t)}{A + m(t)} \right\}
        \end{align*}
    \end{minipage}
    }}
}
%
%

    \end{mybox}
\end{minipage}

\end{multicols*}
\end{document}

Specifically, note that I have defined a new command \clap, which is similar to \llap or \rlap, but works aligning to the center. I have used this command on your whole \rotatebox, so I can align with respect to its center, eliminating the corresponding width, which is unnecessary for the result. (You can experiment the effects of replacing \clap with \rlap or \llap in order to comprehend this mechanism.) Finally, I have put a \hfill command before \clap so it aligns with the right margin.
This is the simplest way to work with your code without modifying it too much. As an alternative, I would recommend using a tikzpicture environment as recommended in the other answers.
I hope this helps!


text:
Q: Which container should I choose to implement a heap? I am trying to make my own libraries in c++ and want to implement heap data structure.
I have already coded all the algorithms for the insert, delete and find for the heap
What I need is a container to hold the heap.
I know that they are implemented as arrays, but since arrays have to be a constant size and I don't like to reallocate memory too many times. Should i use vector as my container for heap?
I have implemented vector myself.


text:
Q: Jquery script not working as expected in ASP.NET UpdatePanel I am working on creating a nested gridview. I am using an example from: http://www.aspsnippets.com/Articles/ASPNet-Nested-GridViews-GridView-inside-GridView-with-Expand-and-Collapse-feature.aspx
The problem is the "minus" of the script does not remove the nested gridview. What seems to be happen is the "plus" function seems to trigger again and again.

     <asp:GridView ID="GridView1" runat="server"  Width = "100%" AutoGenerateColumns = "False" Font-Names = "Arial" CssClass="table table-hover table-bordered"
                            Font-Size = "11pt" AlternatingRowStyle-BackColor = "#F18903" HeaderStyle-BackColor = "#F18A07" AllowPaging ="True"
                            DataKeyNames="Rut" OnPageIndexChanging  = "OnPaging" onrowediting="EditCustomer"  OnRowDataBound="OnRowDataBound" onrowupdating="UpdateCustomer" onrowcancelingedit="CancelEdit" >
                                 <Columns>
                                    <asp:TemplateField>
                                    <ItemTemplate>

                                        <asp:Panel ID="pnlOrders" runat="server" Style="display: none">
                                        <asp:GridView ID="gvOrders" runat="server" AutoGenerateColumns="false" CssClass = "ChildGrid">
                                    <Columns>
                                         <asp:BoundField ItemStyle-Width="150px" DataField="Nombre" HeaderText="Order Id" />
                                         <asp:BoundField ItemStyle-Width="150px" DataField="Rut" HeaderText="Date" />
                                    </Columns>
                                    </asp:GridView>
                                    </asp:Panel>
                                    </ItemTemplate>
                                    </asp:TemplateField>

                                    <asp:TemplateField  HeaderText = "Nombre" >
                                       <ItemTemplate>
                                        <asp:Label ID="lblNombre" runat="server" Text='<%# Eval("Nombre")%>'></asp:Label>
                                       </ItemTemplate>
                                    </asp:TemplateField>

                                   <asp:TemplateField   HeaderText = "Rut">
                                       <ItemTemplate >
                                        <asp:Label ID="lblRut" DataField="Rut" runat="server" Text='<%# Eval("Rut")%>'></asp:Label>
                                       </ItemTemplate>
                                   </asp:TemplateField>

                                  <asp:TemplateField   HeaderText = "Fecha de Nacimiento">
                                     <ItemTemplate>
                                        <asp:Label ID="lblFecha_Nac" runat="server" Text='<%# Eval("Fecha_Nac")%>'></asp:Label>
                                     </ItemTemplate>
                                     <EditItemTemplate>

                                          <asp:TextBox ID="txtFecha_Nac" runat="server" Text='<%# Eval("Fecha_Nac")%>'></asp:TextBox>

                                    </EditItemTemplate>
                                  </asp:TemplateField>

                                  <asp:TemplateField  HeaderText = "Celular">
                                     <ItemTemplate>
                                        <asp:Label ID="lblCelular" runat="server" Text='<%# Eval("Celular")%>'></asp:Label>
                                     </ItemTemplate>
                                     <EditItemTemplate>
                                        <asp:DropDownList ID="txtCelular" runat="server" >
                                            <asp:ListItem Text="SI" Value="1" />
                                            <asp:ListItem Text="NO" Value="0" />
                                        </asp:DropDownList>
                                    </EditItemTemplate>
                                  </asp:TemplateField>

                                    <asp:CommandField  EditText="Editar" ShowEditButton="True" />

                                    <asp:TemplateField HeaderText="Informacion Adicional" >
                                       <ItemTemplate>
                                         <asp:Button ID="Btn1" runat="server"
                                            Text="Ver Mas" CommandArgument="Button1"
                                            OnClick="Btn1_Click"/>
                                        </ItemTemplate>
                                      </asp:TemplateField>

                                     <asp:TemplateField HeaderText="Cambio Final" >
                                       <ItemTemplate>
                                         <asp:Button ID="BtnCambio" runat="server"
                                            Text="Check" CommandArgument="Button1"
                                            OnClick="Btn1_ClickCambioFinal"/>
                                        </ItemTemplate>
                                      </asp:TemplateField>

                                     <asp:TemplateField HeaderText="Image">
                                         <EditItemTemplate>
                                             <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                                         </EditItemTemplate>
                                         <ItemTemplate>
                                             <asp:Image ID="Image1" runat="server" />
                                         </ItemTemplate>
                                     </asp:TemplateField>
                                </Columns>

                                <AlternatingRowStyle BackColor="#FBEDBB"  />
                                 <HeaderStyle BackColor="#F18A07" />
                            </asp:GridView>

                              </ContentTemplate>
                                <Triggers>
                                    <asp:AsyncPostBackTrigger ControlID = "GridView1" />
                                </Triggers>
                            </asp:UpdatePanel>

A: I would assume that you need to re-subscribe to the events. JavaScript is executed top-down which means that after you have subscribed to the event, elements created later will not trigger that event.
Like the following example:
function myEventHandler () {
    // In here you perform your event-specific code
    eventSubscription();
}

var eventSubscription = function () {
    // Make sure to unsubscribe to prevent event to fire multiple times
    $('.myClass').unbind('click');
    // Re-subscribe to event
    $('.myClass').on('click', myEventHandler);
}

// Call the eventSubscription to hook your events
eventSubscription();

A: As noMad17 said, you need to re-subscribe to your js methods after a postback, even though you're using an updatePanel. Here is my code:
//js file:
$(document).ready(function () {
   loadConfiguration();
 });

function loadConfiguration()
{
     //add your configuration here
}
//aspx file
<asp:UpdatePanel runat="server" ID="upnl1" UpdateMode="Conditional" >
        <ContentTemplate>

</asp:UpdatePanel>

After postback, UpdatePanel is build and all the content inside it as well, so it will load the js code inside add_load again.
Hope it helps

A: This is an issue with what event is bound when the document is ready.
If you want to "toggle" between two function calls, there are many addon that can help you with that (see this SO question).
An easy way to implement it would be to use jquery one function as mentionned by Tushar Gupta.
function plus() {
    $(this).closest("tr").after("
	" + $(this).next().html() + "
");
    $(this).attr("src", "images/minus.png");
    $(this).one("click", minus);
}
function minus() {
    $(this).attr("src", "images/plus.png");
    $(this).closest("tr").next().remove();
    $(this).one("click", plus);
}

$(document).ready(function(){
    $("[src*=plus]").one("click", plus);
    //You might want to change the selector with a class
    // to your img so you don't have to worry about
    // opened or closed by default
});

Hope this helps!
Explanations :
The on function bind the event to the DOM element when it is called. In your case, when the document is ready.
When the document is loaded, all your table lines are showing the expand image. Therefore, the "plus click" function is bound to all the img tags.
On the other hand, there are no element showing the minus sign (yet). So no "minus click" function is bound.
The on function doesn't care if you change your element attributes. Remember that your selector selects the elements, even though you filter through the attribute.
In the link you provided, the author used the live function. This function is now deprecated, but it was basically a on function, that would work on the selector now and in the future. This is not the case anymore with the on function.


text:
Q: Cómo generar un objeto desde un formulario - Javascript Dispongo de dos clases:

*

*Disco

*Tienda

Los discos se guardan en la tienda siempre y cuando al introducirlos en un formulario estén correctamente rellenados los campos. Si todo está OK, pulsamos el botón "Guardar disco" y llamaremos a la función addDisco(disco), función a la cual le pasamos el disco con los datos del formulario.
Mi duda está en los comentarios siguientes: ¿cómo relleno con los datos del formulario un objeto de tipo Disco? ¿Se puede crear un div para mostrar el error en caso de que: "El campo nombre no es correcto"?
Os dejo el código probado y testeado de las clases Disco y Tienda.
//Clase Disco. Le pasamos los atributos necesarios. Método constructor.
var Disco = function(nombre, cantante, ano, tipo, estanteria){
    this.nombre = nombre;
    this.cantante = cantante;
    this.ano = ano;
    this.prestado = false;

    //Comprobamos que existe el tipo de musica pasado por argumento.
    comprueba_tipo = function(tipo){
        //Array de tipos de musica.
        var array_tipos = ["rock", "pop", "puck", "indie"];
        //Si no existe en el array... establecemos la primera posición de éste.
        if(array_tipos.indexOf(tipo)<0){
            return array_tipos[0];
        }else{
            return tipo;
        }
    }

    //Establece la propiedad tipo de musica en funcion parametro tipo.
    this.setTipoMusica = function(tipo){
        this.tipo = comprueba_tipo(tipo);
    }
    this.tipo = comprueba_tipo(tipo);

    //Comprobamos que la porpiedad estanteria sea un valor entre 1 y 10. En caso
    //contrario, establecer el valor 0 por defecto.
    var comprueba_estanteria = function(estanteria){
        //Si la estanteria está entre 1 y 10, OK!
        if(isNaN(new Number(estanteria))){
                estanteria = 0;
        }else{
            //Si no esta entre 1 y 10, por defecto toma el valor 0.
            if(estanteria<1 || estanteria>10){
                estanteria = 0;
            }
        }
        return estanteria;
    }

    //Establece la propiedad estanteria validando que sea un valor numerico entre 1 y 10.
    this.setEstanteria = function(estanteria){
        this.estanteria = comprueba_estanteria(estanteria);
    }
    this.estanteria = comprueba_estanteria(estanteria);

    //Cambia la propiedad del estado del disco.
    this.presta = function(nuevoEstado){
        this.prestado = nuevoEstado;
    }

    //Metodo toString().
    this.toString = function(){
        return "El nombre del disco es "+this.nombre+" del cantante "+this.cantante+" fue publicado en "+this.ano+" de tipo de musica "+this.tipo+" en la estanteria "+this.estanteria+". Prestado: "+this.prestado+"";
    }
}

//Comprobar la clase. Creamos un objeto pasandole datos a los argumentos.
/*var miDisco = new Disco("MachupichuPop", "Osmar", 1990, "pop", 8);
console.log(miDisco.toString());
miDisco.presta(true);
miDisco.setEstanteria(3);
miDisco.setTipoMusica("mamamam");
console.log(miDisco.toString());*/

//Clase Tienda. Constructor sin parametros.
var Tienda = function(){
    //Creamos un array de discos.
    this.numTotalDiscos = new Array();

    //Devuelve el numero total de discos.
    this.getNumeroDiscos = function(){
        return this.numTotalDiscos.length;
    }

    //Devuelve el numero de discos que no estan prestados.
    this.getNumeroDiscosDisponibles = function(){
        var cantidad = 0;
        for(var i=0; i<this.numTotalDiscos.length; i++){
            if(this.numTotalDiscos[i].prestado==false){
                cantidad++;
            }
        }
        return cantidad;
    }

    //Añade un disco al array.
    this.addDisco = function(disco){
        this.numTotalDiscos.push(disco);
    }

    //Muestra los titulos de los discos almacenados.
    this.getTituloDisco = function(i){
        return this.numTotalDiscos[i].titulo;
    }

    //Devuelve el objeto Disco que esta en la posicion i-esima.
    this.getDisco = function(pos){
        return this.numTotalDiscos[pos];
    }

    //Elimina el disco cuyo titulo coincide con el que se pasa como parametro.
    this.deleteDisco = function (titulo){
        for(var i=0; i<this.numTotalDiscos.length; i++){
            if(this.numTotalDiscos[i].nombre == titulo){
                this.numTotalDiscos.splice(i,1);
                break;
            }
        }
    }

    //Devuelve verdadero si existe el disco cuyo titulo coincide con el que se pasa.
    this.existeDisco = function(tituloRecibido){
        var existe = false;
        for(var i=0; i<numTotalDiscos.length;i++){
            var titulo = this.numTotalDiscos[i].nombre;
            if(titulo==tituloRecibido)
                existe = true;
                break;
        }
        return existe;
    }

    //Modifica el titulo de un disco si existe.
    this.modificaDisco = function(titulo, nuevoDisco){
        for(var i=0; i<this.numTotalDiscos.length; i++){
            if(this.numTotalDiscos[i].nombre == titulo){
                this.numTotalDiscos[i] = nuevoDisco;
                break;
            }
        }
    }
}

//Creamos una tienda, y en ella insertamos varios discos para comprobar el funcionamiento.
var miTienda = new Tienda();
var miDisco1 = new Disco("MachupichuPop111", "Osmar111", 1989, "pop", 3);
miDisco1.presta(true);
var miDisco2 = new Disco("MachupichuPop222", "Osmar222", 1990, "pop", 8);
var miDisco3 = new Disco("MachupichuPop333", "Osmar33", 1956, "indie", 11);
miDisco3.presta(false);
miTienda.addDisco(miDisco1);
miTienda.addDisco(miDisco2);
miTienda.addDisco(miDisco3);
console.log(miDisco1);
console.log(miDisco2);
console.log(miDisco3);
console.log("Tengo "+miTienda.getNumeroDiscos()+ " disco/s en la tienda");
console.log("Tengo "+miTienda.getNumeroDiscosDisponibles()+ " disco/s prestados en mi tienda");
console.log("En la posicion 3 está el objeto Disco:[[[ "+miTienda.getDisco(2)+" ]]]"); //[2] es la posicion 3, empieza a contar el array desde pos[0].

Código HTML:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

        <title>Mi tienda de discos</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <link rel="stylesheet" type="text/css" href="style/formulario.css" />

Tienda de discos

        <form id="formulario">

                Nombre del disco
                <input type="text" name="nombre" id="nombre"  />

                Cantante
                <input type="text" name="cantante" id="cantante"  />

                Año
                <input type="text" name="anio" id="anio"  />

                Estantería
                <input type="text" name="estanteria" id="estanteria"  />

                Tipo de música
                <select name="tipo" id="tipo">
                    <option selected value="none">Elige uno...</option>
                    <option  value="rock">Rock</option>
                    <option value="pop">Pop</option>
                    <option value="punk">Punk</option>
                    <option value="indie">Indie</option>
                </select>

                Prestado:

                  <input type="radio" name="prestado" id="prestado_si" value="si" />Si
                  <input type="radio" name="prestado" id="prestado_no" value="no" checked="checked"/>No

                <input type="button" id="guardar" value="Guardar disco" />
                <input type="button" id="eliminar" value="Eliminar disco" />
                <input type="button" id="ver" value="Ver disco" />
                <input type="button" id="modificar" id="enviar" value="Modificar disco" />

                Todavía no tienes ningún disco.

        </form>

Código Javascript (aquí las dudas, mirar comentarios):
/*Creo un objeto/instancia de la clase Tienda.*/
var miTienda = new Tienda();

/* Registro un evento para cuando termine de cargarse el documento se cargen los eventos necesarios.
 */
window.addEventListener('load', iniciar, true);

//Función que se ejecuta tras cargarse el documento y registra el resto de eventos.
function iniciar(){
    //Evento para validar que los campos estén con información correcta y NO estén vacíos.
    document.getElementById('guardar').addEventListener('click', validarCampos, false);
}

/******************************************************************************
 **************** FUNCIONES PARA LA COMPROBACION DE LOS CAMPOS ****************
 ******************************************************************************/

//Función que se encarga de validar los campos del formulario.
function validarCampos(evento){
    //Valido los diferentes apartados del formulario. Si todo está OK...
    if (validarCamposText(this) && comprobarNombre() && comprobarCantante() && comprobarAnio() && comprobarEstanteria() && confirm("¿Desea enviar el disco?")){
        return true;
        //Guardamos el disco en la tienda. Para ello tenemos la variable/objeto tienda llamada "miTienda".
        //Si todo está correcto, llamaremos a la función "GuardarDisco()". A la cuál tendremos que pasarle el objeto Disco, ¿no?
    }else{
        //Cancelar el evento por defecto del envío del formulario.
        evento.preventDefault();
        return false;
    }
}

//----------------------------------------------------------//
//Funcion para validar todos los campos input de tip "text".
function validarCamposText(objeto){
    //La propiedad form del botón enviar contiene la referencia del formulario dónde está ese botón submit.
    var formulario = objeto.form;

    //Recorremos en un array todos los elementos del formulario.
    for (var i=0; i<formulario.elements.length; i++){
        //Eliminamos la clase Error que estaría asignada a algún campo.
        formulario.elements[i].className="";
    }

    //Recorremos en un array todos los elementos del formulario.
    for (var i=0; i<formulario.elements.length; i++){
        //Escogemos los que son de tipo "text" y los que están vacíos...
        if (formulario.elements[i].type == "text" && formulario.elements[i].value.trim()==""){
            //Mostramos en un div, llamado "errores", un mensaje para el usuario de que el campo está vacío.
            document.getElementById("errores").innerHTML="El campo "+formulario.elements[i].name+" no puede estar vacío.";
            formulario.elements[i].className="error";
            formulario.elements[i].focus();
            return false;
        //Aprovechamos para tratar el campo "Año", sólo debería admitir un valor numérico entre 200 y 2017.
        }else if (formulario.elements[i].id=="anio"){
            if (isNaN(formulario.elements[i].value) || formulario.elements[i].value <2000 || formulario.elements[i].value >2017){
                document.getElementById("errores").innerHTML="El campo "+formulario.elements[i].name+" es incorrecto o el año no está entre 2000 y 2017.";
                formulario.elements[i].className="error";
                formulario.elements[i].focus();
                return false;
            }
        }else if (formulario.elements[i].id=="estanteria"){
            if (isNaN(formulario.elements[i].value) || formulario.elements[i].value <0 || formulario.elements[i].value >10){
                document.getElementById("errores").innerHTML="El campo "+formulario.elements[i].name+" es incorrecto o la estantería no está entre 0 o 10.";
                formulario.elements[i].className="error";
                formulario.elements[i].focus();
                return false;
            }
        }
    }
    return true;
}

//Función para comprobar que el campo nombre no está vacío.
function comprobarNombre(){
    if (!document.getElementById("nombre").value.trim()==""){
        var nombre = document.getElementById('nombre').value;
        //console.log(nombre);
        return true;
    }else{
        document.getElementById("errores").innerHTML="El campo NOMBRE es obligatorio.";
        document.getElementById("nombre").focus();
        return false;
    }
}

//Función para comprobar que el campo cantante no está vacío.
function comprobarCantante(){
    if (!document.getElementById("cantante").value.trim()==""){
        var cantante = document.getElementById('cantante').value.trim();
        //console.log(cantante);
        return true;
    }else{
        document.getElementById("errores").innerHTML="El campo CANTANTE es obligatorio.";
        document.getElementById("cantante").focus();
        return false;
    }
}

//Función para comprobar que el campo anio no está vacío. Se deberá controlar con una expresión
//regular que tenga el formato: 2003, 2013, 2015... --> 4 dígitos.
function comprobarAnio(){
    //4dígitos.
    var patron = /^\d{4}$/;
    //Analizamos el patrón.
    if (patron.test(document.getElementById("anio").value)){
        document.getElementById("anio").className="";
        return true;
    }else{
        document.getElementById("errores").innerHTML="El campo AÑO es obligatorio.";
        document.getElementById("anio").focus();
        return false;
    }
}

//Función para comprobar que el campo estanteria no está vacío.
function comprobarEstanteria(){
    if (!document.getElementById("estanteria").value==""){
        var estanteria = document.getElementById('estanteria').value;
        //console.log(estanteria);
    }else{
        document.getElementById("errores").innerHTML="El campo ESTANTERIA es obligatorio.";
        document.getElementById("estanteria").focus();
        return false;
    }
}

A: var nombre = document.getElementById("inputNombre").value;
var cantante = document.getElementById("inputCantante").value;
var ano = document.getElementById("inputAno").value;
var tipo = document.getElementById("inputTipo").value;
var estanteria = document.getElementById("inputEstanteria").value;
var disco = new Disco(nombre,cantante,ano,tipo,estanteria);

En el caso de un radio button sería así:
var radioButtons= document.getElementsByName('nombreRadio');
var radio;

for (var i = 0, i < radioButtons.length; i++) {
    //Así cogemos el valor del radio que esté checked
    if (radioButtons[i].checked) {
        radio = radioButtons[i].value;
        break;
    }
}

Así tendrías el objeto disco con los datos de los input y solo quedaría añadirlo con addDisco.


text:
Q: Why captcha shown after adding required characters to answer?
Possible Duplicate:
How often do captchas appear?

Those rules are not true:

*

*one edit every 30 seconds

*one answer every 60 seconds

*one question every 60 seconds

This was first answer in few hours. Also no questions where asked. During answer submit SO asked to add more characters to answer body. After adding characters, captcha was displayed.
UPDATE: Imagine situation, when you need to add one more character. Then you have to wait 30 seconds before posting answer? Not good.
BTW good usability advise - if there are less than minimum allowed characters in answer body, then just make submit button disabled, or show error text on client side before submitting answer to server.

A: The rules are explained in full here, the relevant section being:

There is a maximum of ... one question every 60 seconds

From your comments, you wrote an answer and submitted it.  This was then disallowed by the quality rules which asked you to add more characters.  As you said, you did this quickly then re-submitted your answer.
This counts as 2 submissions inside of 60 seconds (even though only one made it past the quality filters) which caused the CAPTCHA to be triggered due to the rule above.
With your rep, however, the CAPTCHA should then be muted for a glorious five minutes :L

A: Dude everyone knows that this is necessary otherwise a hacker could post as many questions as he wanted with some computer program just to mess up our community


text:
Q: ScrollMagic not working with jQuery linked at bottom of page Is there a way to use ScrollMagic when jQuery is loaded from the bottom of the page? It works if I put jQuery in the  but not if I don't. So far the site has been working well with all the scripts loading at the bottom and I don't want to change that, just for ScrollMagic.
Moving inline SM scripts into linked .js files doesn't seem to help.

A: You can do it from the bottom, first load jquery and then ScrollMagic.
here is a ScrollMagic wiki link that might help.
Did you try the new ScrollMagic 2.0? there is no jquery dependency anymore, as well as gsap.


text:
Q: Mysql stop at first desired WHERE Lets say i have this statement:

select * from t1
join t2 on t1.id = t2.user_id
where A
OR B
OR C ;

this query will perform all where conditions and return all of them results at once. i just want to get the result of first where clause that has a result  and the order of where clauses is important. how should i rewrite this query to get desired result?

A: If you want to order the results, then use order by:
select *
from t1 join
     t2
     on t1.id = t2.user_id
where A OR B OR C
order by (case when A then 1 when B then 2 when C then 3 end);

If you want one row, then add limit 1 to this query:
select *
from t1 join
     t2
     on t1.id = t2.user_id
where A OR B OR C
order by (case when A then 1 when B then 2 when C then 3 end)
limit 1;

If you want more than one row, then I would count the number of matching rows for each condition, and use that information in the where:
select *
from t1 join
     t2
     on t1.id = t2.user_id cross join
     (select sum(A) as num_A, sum(B) as num_B, sum(C) as num_C
      from t1 join
           t2
           on t1.id = t2.user_id
     ) tt
where A or
      (num_A = 0 and B) or
      (num_A = 0 and num_B = 0 and C);

A: Try this:
select * from t1
join t2 on t1.id = t2.user_id
where
CASE    WHEN EXISTS(select * from t1 join t2 on t1.id = t2.user_id where A)
            THEN A
        WHEN EXISTS(select * from t1 join t2 on t1.id = t2.user_id where B)
            THEN B
        WHEN EXISTS(select * from t1 join t2 on t1.id = t2.user_id where C)
            THEN C
        ELSE FALSE
END


text:
Q: Track behaviour - Java MIDI I am removing events from a MIDI Track and I assumed that by doing so the total duration of the Track would reduce accordingly, If there are no events in the Track then I thought that the size of the Track would be 0.
Unfortunately it seems it is not the case, even though the events are removed the size in Ticks does not change and only increases as more are added.
Is this normal MIDI/Java behaviour?
Edit:
This is the method that removes all of the events from the Track:
public static boolean Remove() {
    //TODO: Test the bejeezus out of it.

    if(_sequencer.isRunning()){
        _sequencer.stop();
    }

    for (int i = 0; i < _track.size(); i++) {
        if (!_track.remove(_track.get(i))) {
            Logger.Add("MIDI Event not removed");
            return false;
        }
    }

    //Used for debugging purposes
    long z = _track.ticks();
}

Yet when I use some crude debugging techniques and check the amount of ticks directly after removing the events, I find this;

It seemingly makes no difference, I don't really understand why it's doing it. I assumed that the size of Ticks depends on the amount of events in the Track, therefore if there were 10 events in a track the tick size would be 10 (As I set the tick length to 1 when adding them to the track) likewise if there were no events the size would be 0.
Adding events:
public static void AddMessage(int channel, int pitch, long tick, int velocity) {
        _track.add(CreateNoteOnEvent(channel, pitch, tick, velocity));
        _track.add(CreateNoteOffEvent(channel, pitch tick, velocity));
    }

A: After many hours debugging I managed to track the bug down, the way I was removing events meant that half of them would never be considered which led to the size of the track never reaching zero.
Any event I added would then be placed after the already existing events which would explain why I was hearing multiple notes in certain parts.
The answer to that question (and this one) can be found here: Unable to Remove Events from Track
Thanks for your time, I greatly appreciate it.


text:
Q: notifyItemChanged() make the RecyclerView scroll and jump to UP i have a RecycleView with an adapter that show a list of servers
and the user must select one server.
when i call notifyItemChanged(previousPosition) inside the onClick() method
to make the old server unselected and the new server selected,
that's make the RecycleView list jump to up exactly in the middle of list.
and this problem happen just when i click on one of the last 2 or 3 servers inside the RecycleView list
here is the code of my RecyclerView.Adapter :
public class ServerAdapter extends RecyclerView.Adapter<ServerAdapter.ServerViewHolder> {

    private List<Server> listServers = new ArrayList<>();
    private int[] icons = new int[]{R.drawable.server1,R.drawable.server2,R.drawable.server3,R.drawable.server4,R.drawable.server5,R.drawable.server6,R.drawable.offline};
    private int selected = 0;
    private int previousSelected = 0;

    public ServerAdapter(List<Server> listServers){
        this.listServers = listServers;
    }

    @Override
    public ServerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.server_relative_layout,parent,false);
        return new ServerViewHolder(view);
    }

    @Override
    public void onBindViewHolder(final ServerViewHolder holder, final int position) {
        if(position == selected){
            holder.getBackground().setSelected(true);
        }else{
            holder.getBackground().setSelected(false);
        }
        holder.getBackground().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(position != selected){
                    previousSelected = selected;
                    selected = position;
                    holder.getBackground().setSelected(true);
                    notifyItemChanged(previousSelected);
                }
            }
        });
        holder.getImageServer().setImageResource(icons[position%6]);
        holder.getTextNameServer().setText(listServers.get(position).getName());
        holder.getTextConnected().setText(listServers.get(position).getUrl());
    }

    @Override
    public int getItemCount() {
        return listServers.size();
    }

    public class ServerViewHolder extends RecyclerView.ViewHolder{
        private ImageView imageServer;
        private TextView textNameServer;
        private TextView textConnected;
        private View background;
        public ServerViewHolder(View itemView) {
            super(itemView);
            imageServer = (ImageView)itemView.findViewById(R.id.imageServer);
            textNameServer = (TextView)itemView.findViewById(R.id.textNameServer);
            textConnected = (TextView)itemView.findViewById(R.id.textConnected);
            background = itemView;
        }

        public ImageView getImageServer() {
            return imageServer;
        }

        public TextView getTextConnected() {
            return textConnected;
        }

        public TextView getTextNameServer() {
            return textNameServer;
        }

        public View getBackground() {
            return background;
        }
    }
}

any solutions to solve this problem ? thanks.
The problem happened exactly when i specify the layout height and do not let it to wrap_content
<android.support.v7.widget.RecyclerView
    android:layout_width="wrap_content"
    android:layout_height="400dp"
    android:id="@+id/serverRecyclerView"
    android:layout_margin="10dp"
/>

or when i put it below something for expample like that :
<android.support.v7.widget.RecyclerView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/serverRecyclerView"
    android:layout_margin="10dp"
    android:layout_below="@+id/image"/>

my code exactly is :
<android.support.v7.widget.RecyclerView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/serverRecyclerView"
    android:layout_margin="10dp"
    android:layout_alignTop="@+id/imageBall"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    android:layout_toRightOf="@+id/camera"
    android:layout_toEndOf="@+id/camera"/>

A:

 android:descendantFocusability="blocksDescendants"

android:descendantFocusability="blocksDescendants"
this attr solve my bug

A: RecyclerView.ItemAnimator animator = myRecyclerListView.getItemAnimator();
if (animator instanceof SimpleItemAnimator) {
    ((SimpleItemAnimator)animator).setSupportsChangeAnimations(false);
}

A: My RecyclerView was inside ConstraintLayout, and I also had such problem and calling setAutoMeasureEnabled(false) of RecyclerView's LayoutManager did not fix the issue for me, furthermore this method is deprecated in 28.0.0 version. What I did is that, I wrapped my RecyclerView with RelativeLayout and now it works like a charm. As mentioned in bugtracker, this "issue" is intented behaviour in LinearLayout and is not going to be fixed. So if it is possible, just wrap your RecyclerView something like this:
<RelativeLayout
    android:id="@+id/container_messages_list"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:background="@drawable/chat_back_pattern"
    app:layout_constraintBottom_toTopOf="@+id/bottom_view"
    app:layout_constraintTop_toBottomOf="@+id/toolbar">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/messages_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    </android.support.v7.widget.RecyclerView>
</RelativeLayout>

A: Looks like this is a bug: https://code.google.com/p/android/issues/detail?id=203574
The best workaround seems to be Bart's answer to set the RecyclerView's LinearLayoutManager's AutoMeasure property to false.

  LinearLayoutManager llm = new LinearLayoutManager(context);
  llm.setAutoMeasureEnabled(false);
  recyclerView.setLayoutManager(llm);

The set FixedSize to true solution had way too many side-effects...
RecyclerView.setHasFixedSize(true)

A: I don't know why, but I used:
RecyclerView.setHasFixedSize(true)

This worked for me. I hope it can help.

A: for anyone who stumbles upon this issue, try using
yourRecyclerView.notifyItemChanged(int position, Object payload);

This one did the trick for me.
Using
setAutoMeasureEnabled(false);

also worked but in some edge cases recycler view was acting weird. Good luck!

A: RecyclerView can perform several optimizations if it can know in advance that RecyclerView's size is not affected by the adapter contents. RecyclerView can still change its size based on other factors (e.g. its parent's size) but this size calculation cannot depend on the size of its children or contents of its adapter (except the number of items in the adapter).
If your use of RecyclerView falls into this category, set this to true. It will allow RecyclerView to avoid invalidating the whole layout when its adapter contents change.
If we have a RecyclerView with match_parent as height/width, we should add setHasFixedSize(true) since the size of the RecyclerView itself does not change inserting or deleting items into it.
setHasFixedSize should be false if we have a RecyclerView with wrap_content as height/width because each element inserted by the adapter could change the size of the RecyclerView depending on the items inserted/deleted, so, the size of the RecyclerView will be different each time we add/delete items.
recyclerView.setHasFixedSize(true);

*

*true if adapter changes cannot affect the size of the RecyclerView.
References
 Android Developers Reference - RecyclerView
Understanding RecyclerView setHasFixedSize - Gastón Saillén

A: I came across the similar problem, just take care of the xml layout file.
Do not use the layout_below , layout_above or others similar properties in RecyclerView or RecyclerView's parent view.
You can use LinearLayout weight , layout_marginBottom or sth to achieve
layout_below or other.

A: The late answer better than nothing, if you're using NestedScrollView as the parent view of RecyclerView you should delete it.

A: I had a similar problem and I tryed all solutions listed above, but noone worked.
I was already padding the "Payloads" to "notifyItemChanged(position, payloads)" because I just needed to "upload" a checkbox value so I was passing the value inside "Payloads" without recalling the update of the entire viewholder.
This solution worked for all view holders in my recycler view except for the last one (and probably for all "recycled" ones, I mean those who recall the "onBindViewHolder" by "recycling" an existing view).
I think using "notifyItemChanged" will works if you have only the recyclerview and I also think that this problem of "auto-scrolling" is raised by nested scroll views & recycler views.
I was in the case exposed by "raed", so "ScroolView -> RecyclerView -> "n" x RecyclerView". I have a scroolview wich contains a recyclerview whose viewholders can contains a recycler views.
Delete the parent ScrollView is a really weird solution and I couldn't use it, so I setted the "onStopNestedScroll" inside the "ScrollView" and not inside the RecyclerView.
Personally I used it programmatically before the code part which calls the "notifyItemChanged" method by doing:
msvContainer.onStopNestedScroll(mRecyclerView);

Where "msvContainer" is my ScrollView which contains the RecyclerView, and "mRecyclerView" is my RecyclerView contained by the ScrollView.
This way worked 99% because the first time I call "notifyItemChanged" the view scroll up only for the ScrollView, so it hides a button inside my ScrollView which is below my RecyclerView but it doesn't scroll the RecyclerView items. After the first call "notifyItemChanged" works properly.
I found that calling:
msvContainer.stopNestedScroll();

works too. But i suggest to use the first method with the target view if you have multiple nested scroll views.
Anyway you should call "startNestedScroll" after you ran out of the critical part of re-updating your view holder because the targeted view, so in my case the RecyclerView, won't scroll until you call this method so it won't recycler his view holders too.
(In my case that I have multiple Recycler View inside a parent Recycler View inside a parent Scroll View if I was in need to call "notifyItemChanged" inside the most inner Recycler View i would use the "stopNestedScroll" method for every parent view and then re-activated the scroll after the scroll-critical part)
Hope this is helpful, have a nice coding!
Bye

A: In my case, all I did was to set the height of the recyclerview to "match_parent". Then in your MainActivity, do;
recyclerView.smoothScrollToPosition(yourAdapter.getItemCount()-1);
Thats all...


text:
Q: Illegal operation in Greasemonkey script compiler I have a Greasemonkey script and I'm using a Greasemonkey to xpi compiler
I use this script:
// ==UserScript==
// @name           Teste Script
// @author         Bla
// ==/UserScript==

var Main = setInterval(
    function () {
        alert(window.location.href);
    }, 1000);

and when I install the xpi, I keep getting this error:

Error: Illegal operation on WrappedNative prototype object

Already tried window.alert and it still shows the same error.

A: Well, It looks like the converter is somehow broken.
If i take an hello world script with this content:
// ==UserScript==
// @name          Webmonkey's Hello World
// @namespace     http://www.webmonkey.com
// @description   A basic example of Greasemonkey that causes an alert at each page load.
// @include       *
// ==/UserScript==

alert('Monkey sez... "Hello World!"');

The error is still there. So i don't suspect that your code is the problem, more the compiler.
I've never created an XPI by myself, but i think that you should try it by hand and see if that works. Perhaps will this problem be fixed in the future ( watch his github page for updates )


text:
Q: Assumption of error of logistic regression I know there are debates about whether the error exists and its distribution in the case of logistic regression.
Suppose we assume that the error term follows the logistic distribution. Are we looking for a set of betas that will make the error term generated accordingly (in the population) satisfy the logistic distribution using maximum likelihood?


text:
Q: How to initialize the arrayList when creating a new method I am creating a program to find the sum of any two array element equal to the given value I required. When checking for appropriate patches
ex.,
import java.util.ArrayList;
import java.util.Arrays;

public class PairedSums {

    public static ArrayList<Integer> pairedOfValues(int[] a,int givenValue){
        Arrays.sort(a);

        ArrayList<Integer> arrayList;
        int n = a.length - 1;
        if (a[0] == givenValue){
            arrayList = new ArrayList<>();
            arrayList.add(a[0]);
            return arrayList;
        }
        else if (a[n] == givenValue){
            arrayList = new ArrayList<>();
            arrayList.add(a[0]);
            return arrayList;
        }
        else {
            int low = 0;
            int high = n;
            while (a[low] < a[high]){
                if (a[low] == givenValue){
                    arrayList = new ArrayList<>();
                    arrayList.add(a[low]);
                    return arrayList;
                }
                else if (a[high] == givenValue){
                    arrayList = new ArrayList<>();
                    arrayList.add(a[high]);
                    return arrayList;
                }
                else if ((low == high )){
                    arrayList = new ArrayList<>();
                    arrayList.add(a[high]);
                    return arrayList;
                }
                if (a[low] == 0){
                    low++;
                }
                else if (a[high] == 0){
                    high--;
                }
                else {
                    int sum = a[low] + a[high];
                    if (sum == givenValue){
                        arrayList = new ArrayList<>();
                        arrayList.add(a[low]);
                        arrayList.add(a[high]);
                        return arrayList;
                    }
                    else {
                        if (sum < givenValue){
                            low++;
                        }
                        else {
                            high--;
                        }
                    }
                }
            }
        }
        return null;
    }

    public static void main(String[] args){
        int[] a = {10, 0, -1, 20, 25, 30};
        int givenValue = 45;
    ArrayList<Integer> arr = pairedOfValues(a,givenValue);
        System.out.println(arr);
    }
}

I have keep initialize the array every time I am doing it and adding it manually. I have try to create a method
 public static ArrayList<Integer> sum(ArrayList<Integer> arr,int[] a,int i){
        arr = new ArrayList<>();
        arr.add(a[i]);
        return arr;
    }

but when I declare it in the if else statement it says the ArrayList variable is not initialized which is correct. Is there any way I could initialize it in the method only so that I might not have to initialize it over and over again.

A: Your code is correct (algorithm is not perfect, but it does not matter). I've just put you code into my IDE and got ~10 warnings and fixed all of them. When you have to create List with predefined amount of items, do use Collections.singletonList() and/or Arrays.asList(). Below is you code with little formatting, I think it looks much better and does not have your problem:
public static List<Integer> pairedOfValues(int[] a, int givenValue) {
    Arrays.sort(a);

    int n = a.length - 1;

    if (a[0] == givenValue || a[n] == givenValue)
        return Collections.singletonList(a[0]);

    int low = 0;
    int high = n;

    while (a[low] < a[high]) {
        if (a[low] == givenValue)
            return Collections.singletonList(a[low]);

        if (a[high] == givenValue || low == high)
            return Collections.singletonList(a[high]);

        if (a[low] == 0)
            low++;
        else if (a[high] == 0)
            high--;
        else {
            int sum = a[low] + a[high];

            if (sum == givenValue)
                return Arrays.asList(a[low], a[high]);

            if (sum < givenValue)
                low++;
            else
                high--;
        }
    }

    return Collections.emptyList();
}

P.S. I think this you algorithm does not cover situations, when given arr has more than one pairs. Do look at my one, it has less code with same functionality (this is only for your further investigation).
public static List<Integer> pairedOfValues(int[] arr, int givenValue) {
    if (arr == null || arr.length < 2)
        return Collections.emptyList();

    Arrays.sort(arr);

    List<Integer> res = new ArrayList<>();

    for (int i = 0; i < arr.length - 1; i++) {
        for (int j = i + 1; j < arr.length && arr[i] + arr[j] <= givenValue; j++)
            if (arr[i] + arr[j] == givenValue) {
                res.add(arr[i]);
                res.add(arr[j]);
            }
    }

    return res;

}


text:
Q: PyQGIS: selecting WMS timestamp in a standalone script I'm trying to create a standalone python script that uses PyQGIS to create a map with a raster layer read from WMS.
My idea was to create a QgsRasterLayer with provider set to wms with the time argument encoded into the URL.
To test, I've just tried adding them in the python console within QGIS:
# default time
url1 = "layers=MCD43C3_M_BSA&styles=rgb&bbox=-180,-90,180,90&height=512&width=512&crs=CRS:84&format=image/png&url=https://neo.gsfc.nasa.gov/wms/wms?version%3D1.3.0"

# selected time 2017-01-01
url2 = "layers=MCD43C3_M_BSA&styles=rgb&bbox=-180,-90,180,90&height=512&width=512&crs=CRS:84&format=image/png&time=2017-01-01&url=https://neo.gsfc.nasa.gov/wms/wms?version%3D1.3.0"

iface.addRasterLayer(url1, "default", "wms")
iface.addRasterLayer(url2, "selection", "wms")

However, I get the same raster both times, and the developer panel indicates the time parameter is not included in the query:

Is there a simple way I'm missing where I can select a date out of the available time steps from a WMS layer?
Edit:
til_b's excellent answer below has shown that one can use owslib to interact with the WMS server and with that easily select dates from the layer's time axis.
The issue is the intended use:
I want to use this WMS source to create a map using PyQGIS. I could indeed try to obtain the image some other way and then plug in into PyQGIS for mapping, but that seems overly complicated and has some gotchas:

*

*I need to define the image shape beforehand (I suppose that could be calculated from extent, resolution, dpi etc.)

*Some servers limit the max image shape to tiles (e.g. 512) so I'd need to get multiple tiles and stitch them together myself

*I need to encode the geoinfo myself if I want to map it together with other geospatial data

Doing all of this myself feels a lot like re-inventing the wheel - particularly it's already being handled by PyQGIS with the notable issue that I can't select a date!
I really think there must be a way to do this with PyQGIS since you can clearly do it with the GUI. Either it's a bit more elaborate (maybe using the Temporal Controller perhaps), or I'm just missing the obvious! (or neither and it's a bug ... )

A: Use owslib per their instructions at https://geopython.github.io/OWSLib/usage.html#wms .
OWSlib passes any additional HTTP parameters directly to the server (checked with a simple netstat -lp 9999 listening socket).
Order of commands to test the behaviour:
In a linux shell: netstat -lp 9999. Leave running.
In python:
from owslib.wms import WebMapService
wms = WebMapService('http://localhost:9999/?bar=baz', version='1.3.0')

The request that arrives on the netstat socket is
GET /?bar=baz&service=WMS&request=GetCapabilities&version=1.3.0 HTTP/1.1
Host: localhost:9999
User-Agent: python-requests/2.22.0
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive

It contains the bar=baz parameters.
You should then be able to produce an output image using "plain" OWSlib with the extra parameter arrriving at the server.
It the server supports image/geotiff as output format you can plug that directly into QGIS, if not you'll have to write a world file for the jpeg or png image with the following code (ripped from a real project, redacted, so may need some tweaking to run, but you can see the ideas):
def wf_params(ul,lr,size):
    """ul: upper left corner.
lr: lower right corner.
Only for straight-edge rectangles!"""
    ### World file writing from
    ### https://gis.stackexchange.com/questions/269581/creating-tfw-world-files-from-tiff-coordinates-in-excel
    width, height = size
    xul,yul = ul  # -> coordinates of the upper left corner
    xlr,ylr = lr  # -> coordinates of the lower rigth corner

    #print("%.3f %.3f" % (width,height))
    #print("%.3f %.3f" % (xul,yul))
    #print("%.3f %.3f" % (xlr,ylr))

    A = (xlr-xul)/width
    D = 0
    B = 0
    E = (ylr-yul)/height
    #center of the upper left pixel
    C = xul + (A * .5)
    F = yul + (E * .5)
    return (A,D,B,E,C,F)

def writeWF(params,fullpath):
    """Write a world file from the parameters produced by wf_param"""
    print("Writing worldfile to %s" % fullpath)
    f = open(fullpath,'w')
    for p in params:
        f.write("%.3f\n" % p);
    f.close()

...

bb = <the bounding box used for the owslib WMS request, given as [lowerleftX, lowerleftY, upperrightX, upperrightY>

# size of the requested WMS image
outsize = 512

upperleft  = (bb[0],bb[3])
lowerright = (bb[2],bb[1])

parms = wf_params(upperleft,lowerright,outsize)

writeWF(parms ,full_outname_world)

A: Looking at the source code, it turns out to select a specific date you need

*

*"time-aware" layer

*select the time using the start/end format

Regarding 1), I've linked in the comments to a thread in the dev mailinglist which explains the required components.
Essentially it boils down to adding the following query arguments to your url:

*

*allowTemporalUpdates=true

*temporalSource=provider

*type=wmst

*timeDimensionExtent
with the timeDimensionExtent to be defined by the capabilities from the server.
Regarding 2), if all is needed is one date, we can just use the same date as both start and end, which results in a query time=2017-01-01/2017-01-01 (for this example).
Using the shortcut of copying the time aware URL from the GUI (pointed out by @til_b), everything seems to work:
# original non time-aware URL
url1 = "layers=MCD43C3_M_BSA&styles=rgb&bbox=-180,-90,180,90&height=512&width=512&crs=CRS:84&format=image/png&url=https://neo.gsfc.nasa.gov/wms/wms?version%3D1.3.0"

# new time aware URL with time query 2017-01-01
url2 = "allowTemporalUpdates=true&contextualWMSLegend=0&crs=CRS:84&dpiMode=7&featureCount=10&format=image/png&layers=MCD43C3_M_BSA&styles&temporalSource=provider&timeDimensionExtent=2000-02-01/2016-04-01/P1M,2016-06-01/2017-02-01/P1M&type=wmst&time=2017-01-01/2017-01-01&url=https://neo.gsfc.nasa.gov/wms/wms?version%3D1.3.0"

iface.addRasterLayer(url1, "default", "wms")
iface.addRasterLayer(url2, "selection", "wms")

Not only are the two layers different now, the developer panel is also showing the TIME query as expected:

A: It's probably as simple as sticking the parameter urlencoded into the QGIS layer URI string.
url2 = "layers=MCD43C3_M_BSA&styles=rgb&bbox=-180,-90,180,90&height=512&width=512&crs=CRS:84&format=image/png&url=https://neo.gsfc.nasa.gov/wms/wms?version%3D1.3.0%3Dtime=2017-01-01"

Your original code had the parameter time as a part of the URL for QGIS addRasterLayer. You want it as part of the WMS URL inside the URL that gets to addRasterLayer.
From the "Add WMS Layer" dialog it works:

So what you can do is add the layer via the dialog and then get its URI from the python console. Select the layer, open the python console and run iface.activeLayer().dataProvider().uri(). I am not really sure how to get that URI in a format to stick back into pyqgis to create a URI programmatically. I have done that for MSSQL layers, but never for WMS layers...


text:
Q: Select a Cell in a row where a match is found in same row I am trying to fill a cell from a row if a match is found in an other TAB.
In this example, I want to fill NAME Column if I find the ID in TAB2. So basically, formula would be:
If I find ID in TAB2, then fill NAME from TAB2 in TAB1..
TAB1
------------------------------------
| ID             | NAME            |
------------------------------------
| 12245          | ERIC            |
| 12246          |                 |
| 12247          |                 |
| 12248          | JANE            |

TAB2
------------------------------------
| ID             | NAME            |
------------------------------------
| 12245          | ERIC            |
| 12248          | JANE            |

I hope I made myself clear...


text:
Q: RegEx to select part of match I'm using gvim to edit a document. An excerpt of the document is:
ST*123*foo
WIL*ST*bar
Z91*R*Station

Using regex, I'd like to select ST in the second line, where it exists between two * (and is not at the start of a line), so I can highlight it a specific color.
I thought \*ST\* might work, but it selects the *s, which I don't want. I've also tried (to no avail) a few variations of {} in an attempt to select x characters from my selection.

A: You will need to use a lookahead and a lookbehind assertion:
/\v(\*)@<=ST(\*)@=

Details:

*

*\v: Very magic to avoid excessive escaping

*(\*)@<=: Lookbehind to assert that we have * behind

*ST: Match ST:

*(\*)@=: Lookahead to assert that we have * ahead


text:
Q: I2C communication with DAC I am trying to use a DAC8571 (datasheet) and I'm trying to set up a communication between this convertor and an Arduino Mega via I2C.
The communication between the Arduino and my computer is done using LabView and LINX VIs (MakerHub).
My I2C communication is already working between a sensor and the Arduino Mega and I just would like to add the DAC. The problem is that the DAC does not react at all when I write on the I2C with the Arduino.
My first worry is that the DAC is not working at all (could I have broken it with the heat while soldering?). I have two of them and I am testing them on a breadboard. When I connect them (pin1 = 5V, pint2 = 5V, pin3 = not connected, pin4 = voltmeter, pin8=gnd, pin7,6 = I2C with 10k pull-ups, A0 = gnd), no one gives 0V at the output as I would expect and they give different outputs (I guess at least one of them is broken). Is there a way to test the DAC without using the I2C communication? I want to avoid the I2C communication because maybe the mistake is there.
Just for additional information I add the VI I used to test the DAC:

SITUATION UPDATE:
I tried to read the I2C bus at the DAC address (76) and I get a sequence of bytes (0, 30, 16), which is exactly what it should give because it is what I have set... BUT, the DAC output doesn't change :/.
ADDITIONAL INFO:
To set the value of the DAC (address 76 = 1001100 plus write bit = 0) I use three Bytes: 16 = 00010000 (Command = Write temporary register and load DAC with data), x (first 8 bit to be loaded starting from MSB) and y (second group of 8 bits). In the picture x = 0 and y = 30. When I read from the DAC, it gives me its status 0, 30 and 16, but the output had not been updated.
I have tried both my DAC and they both react in the same way with respect to the I2C, but one has a fixed output at about 0.5V and the other at 5V.

A: Not that I'm aware of, however an alternative solution to debug this is to use an oscilloscope or logic analyzer to check the binary message's Ack bit to see if there's a handshake, bit 9 on SCL signal.

If it doesn't acknowledge, then you either

*

*have the wrong address of the DAC

*setup I2C communication at wrong baudrate

*missing or have wrong pull-down/up resistors values

If it does acknowledge then you either

*

*aren't sending the right messages to make it work

*don't have a valid voltage for it to reference

Response to Update
You should read the datasheet.
It's clear that the DAC responds to the uC, however it's not clear based on what you've given to us whether your set of exchanged messaged with the DAC is appropriate, and it looks like it's a set of bytes that need to be exchanged for a single command.
On top of that, you need to ensure the rest of settings are set to the appropriate application, like power mode, scaling of voltage, etc...

A: I finally bought 3 more DAC8571. Soldering them with extra care (do not heat them too much and grounded myself periodically) solved the problem. I think the ones I was trying previously were dead.
In order to have it working I plugged:
(pin1 = 5V, pint2 = 5V, pin3 = connected to the output i.e. pin4, pin4 = voltmeter, pin8=gnd, pin7,6 = I2C with 10k pull-ups, A0 = gnd).


text:
Q: Monotone Class Theorem for Functions
Suppose $\mathcal F$ is a collection of real-valued functions on $X$ such that the constant functions are in $\mathcal F$ and $f + g$, $fg$, and $cf$ are in $\mathcal F$ whenever $f, g \in \mathcal F$ and $c \in \mathbb R$. Suppose $f \in \mathcal F$ whenever $f_n \to f$ and each $f_n \in \mathcal F$. Define the function $$\textbf1_A(x) = \begin{cases} 1, & x \in A;\\ 0, & x \notin A. \end{cases}$$ Prove that $\mathcal A = \{A \subseteq X : \textbf 1_A \in \mathcal F\}$ is a $\sigma$-algebra.

I have the following result at my disposal:
Monotone Class Theorem: Suppose $\mathcal A_0$ is an algebra, $\mathcal A$ is the smallest $\sigma$-algebra containing $\mathcal A_0$, and $\mathcal M$ is the smallest monotone class containing $\mathcal A_0$. Then $\mathcal M = \mathcal A$.
Notes: here are some observations I've made:

*

*$\emptyset \in \mathcal A$ since $\textbf 1_\emptyset = 0$ is constant and $\mathcal F$ contains all constant functions, similarly $X \in \mathcal A$.

*If $A \in \mathcal A$, then $\textbf 1_A \in \mathcal F$; notice that $1 - \textbf 1_A = \textbf 1_{A^c} \in \mathcal F$ since finite sums are of elements in $\mathcal F$ are in $\mathcal F$, hence $A^c \in \mathcal A$.

*Let $A_1, A_2 \in \mathcal A$, then $\textbf 1_{A_1}, \textbf 1_{A_2} \in \mathcal F$. Observe that $\textbf 1_{A_1 \cap A_2} = \textbf 1_{A_1} \cdot \textbf 1_{A_2} \in \mathcal F$. By mathematical induction if $A_1, \ldots, A_n \in \mathcal A$, then $\bigcap_{i = 1}^n A_i \in \mathcal A$.

*Since we have finite intersections and complements, we get finite unions: $\bigcup_{i = 1}^n A_i \in \mathcal A$.

So $\mathcal A$ is an algebra. At this point we can choose to make $\mathcal A_0 := \mathcal A$ our algebra.
The problem with showing the result directly comes down to showing if $A_i \in \mathcal A$, then $\bigcup_{i = 1}^\infty A_i \in \mathcal A$.
I'm guessing I want to show that $\mathcal M := \mathcal A_0$ is a monotone class. Once we've done this, since $\mathcal A_0 = \mathcal M$, $\mathcal M$ is obviously the smallest monotone class containing $\mathcal A_0$. By the monotone class theorem $\mathcal M = \sigma(\mathcal A_0)$ is a $\sigma$-algebra, correct? (Question 1)
So let's try to show that $\mathcal M$ is a monotone class.

*

*Let $A_k \in \mathcal M$ with $A_k \nearrow A$. In particular, we have that $A_1 \subseteq A_2 \subseteq \cdots$ and $A := \bigcup_{k = 1}^\infty A_k$. Observe that (by hypothesis), $$\lim_{n \to \infty} \textbf 1_{A_n} = \textbf 1_{\bigcup_{k = 1}^\infty A_k}$$ and hence $\bigcup_{k = 1}^\infty A_k \in \mathcal A$. Is this step valid? It seems obvious, but I'm not sure if I've made an assumption here that I shouldn't have (Question 2)

*Let $A_k \in \mathcal M$ with $A_k \searrow A$. In particular, we have that $A_1 \supseteq A_2 \supseteq \cdots$ and $A := \bigcap_{k = 1}^\infty A_k$. Observe that (by hypothesis) $$\lim_{n \to \infty} \textbf 1_{A_n} = \textbf 1_{\bigcap_{k = 1}^\infty A_k}$$ and hence $\bigcap_{k = 1}^\infty A_k \in \mathcal A$.

If the reasoning in the above two steps is valid about the limit being correct, then can I skip having to use the monotone class theorem and just observe the following? (Question 3)
Let $A_k \in \mathcal A$, then $\textbf 1_{A_k} \in \mathcal F$. Define $B_n = \bigcup_{k = 1}^n A_k \in \mathcal A$ since we've already established that it is an algebra and algebras have finite unions. Define $f_n = \textbf 1_{B_n}$ and notice that $\lim_{n \to \infty} f_n = \lim_{n \to \infty} \textbf 1_{B_n} = \textbf 1_{\cup_{k = 1}^\infty A_k} \in \mathcal F$ by hypothesis. Hence $\bigcup_{k = 1}^\infty A_k \in \mathcal A$. Conclude by definition that $\mathcal A$ is a $\sigma$-algebra.
If my reasoning fails somewhere, I would appreciate any hints/full proofs that establish the result using the monotone class theorem, if just because I feel I lack understanding of how to use it and I think this is a good example where it's usable.

A: Everything you did seems fine to me. For completeness's sake, here's a succinct solution:
Firstly, $\boldsymbol{1}_\varnothing = 0 \in \mathcal F \implies \varnothing \in \mathcal A$. Next for $A \in \mathcal A$, we have $\boldsymbol{1}_{A^c} = 1 - \boldsymbol{1}_{A} \in \mathcal F \implies A^c \in \mathcal A$.
And finally, suppose $(A_k)_{k=1}^\infty$ is a sequence of sets in $\mathcal A$. Let us consider the sequence $\left(\prod_{k=1}^n \boldsymbol{1}_{A_k}\right)_{n=1}^\infty$ of functions in $\mathcal F$. If $x \in \bigcap_{k=1}^\infty A_k$, then $\prod_{k=1}^n\boldsymbol{1}_{A_k}(x) = 1$ for all $n$. On the other hand if $x \notin \bigcap_{k=1}^\infty A_k$, then $\prod_{k=1}^n \boldsymbol{1}_{A_k}(x) = 0$ for all sufficiently large $n$. Thus $\lim_{n \to \infty}\prod_{k=1}^n \boldsymbol{1}_{A_k} = \boldsymbol{1}_{\bigcap_{k=1}^\infty A_k}$ pointwise, implying that $\mathcal A$ is closed under countable intersections. It follows that $\mathcal A$ is indeed a $\sigma$-algebra.


text:
Q: ORA-06550: line 1, column 7 (PL/SQL: Statement ignored) Error I am getting following error for the stored procedure and not able to understand the issue (must be from db side) While googling, I found similar issues but couldn't get the solution. Can any one help me please find the error in PROCEDURE ??
Error :-
18:58:50,281 ERROR [STDERR] java.sql.SQLException: ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'SP_DIST_RETAILER_REMAP'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored

Stored Prodedure(SP_DIST_RETAILER_REMAP) :-
CREATE OR REPLACE PROCEDURE SMAPRD02.SP_DIST_RETAILER_REMAP (
      i_old_dist_code IN VARCHAR2,
      i_new_dist_code IN VARCHAR2,
      i_territory_remapping IN NUMBER,
      i_remapping_reason IN VARCHAR2,
      i_trans_doneby_rolename IN VARCHAR2,
      i_trans_doneby_id IN NUMBER,
      i_trans_dist_rolename IN VARCHAR2,
      i_trans_ret_rolename IN VARCHAR2,
      i_activity_type IN VARCHAR2,
      i_ret_list IN V_ARRAY,
      result OUT VARCHAR2,
      i_o_query OUT VARCHAR2
)
AS

--i_ret_codes OUT VARCHAR2;

v_dist_count NUMBER;
v_ret_count NUMBER;
v_ret_codes VARCHAR2(10000)  := '';
v_flag VARCHAR2(10) := 'true';
v_trans_id NUMBER;
v_query VARCHAR2(10000);

BEGIN

IF i_territory_remapping = 1 then

SELECT count(*) into v_dist_count FROM tblemployee where EMPCODE = i_new_dist_code and circle_code = (select emp.circle_code
        from tblemployee emp where emp.empcode = i_old_dist_code) and upper(user_type) like upper('%dist%') and upper(ACCESS_TO) in ('SALES','BOTH') and upper(stage) not in (upper('InActive'));

ELSE

SELECT count(*) into v_dist_count FROM tblemployee where EMPCODE = i_new_dist_code and circle_code = (select emp.circle_code from tblemployee emp
   where emp.empcode = i_old_dist_code) and cluster_code = (select emp.cluster_code from tblemployee emp where emp.empcode = i_old_dist_code)
   and upper(user_type) like upper('%dist%') and upper(ACCESS_TO) in ('SALES','BOTH') and upper(stage) not in (upper('InActive'));

END IF;

IF v_dist_count =0 THEN

result := 'invalid_new_dist_code';

v_flag := 'false';

ELSIF v_dist_count = 1 THEN

SELECT count(*) into v_ret_count FROM tblretailer t where t.DIST_CODE = i_old_dist_code and (upper(t.ACCESS_TO) = 'SALES' or upper(t.ACCESS_TO) = 'BOTH');

--SELECT count(*) into v_ret_count FROM tblretailer t where t.DIST_CODE = i_old_dist_code and upper(t.ACCESS_TO) = 'SALES' and upper(t.stage) in ('APPROVED','INACTIVE');

IF v_ret_count=i_ret_list.count THEN

   IF i_territory_remapping = 1 THEN

   result := 'no_ret_left';

   v_flag := 'false';

   END IF;

ELSE
    IF i_territory_remapping != 1 THEN

    result := 'ret_left';

    v_flag := 'false';

    END IF;

END IF;

END IF;

IF i_ret_list is null or i_ret_list.count = 0 THEN

    result := 'empty retailers list';

    v_flag := 'false';

END IF;

/*FOR i IN i_ret_list.FIRST .. i_ret_list.LAST
      LOOP

          IF v_ret_codes is null
           THEN
            v_ret_codes := ''''||i_ret_list(i)||'''';
          ELSE

            v_ret_codes  := v_ret_codes||','''||i_ret_list(i)||'''';

          END IF;

           IF v_ret_codes is null
           THEN
            v_ret_codes := i_ret_list(i);
          ELSE

            v_ret_codes  := v_ret_codes||','||i_ret_list(i);

          END IF;

      END LOOP;

i_ret_codes := v_ret_codes;

v_flag := 'false';
result := 'success';*/

IF v_flag = 'true' THEN

FOR i IN i_ret_list.FIRST .. i_ret_list.LAST
      LOOP

         IF v_ret_codes is null
           THEN
            v_ret_codes := ''''||i_ret_list(i)||'''';
          ELSE

            v_ret_codes  := v_ret_codes||','''||i_ret_list(i)||'''';

          END IF;

      END LOOP;

--i_ret_codes := v_ret_codes;

--update tblretailer set dist_code=i_new_dist_code,DIST_ID=to_number(i_new_dist_code),cluster_code=(select cluster_code from tblemployee where empcode = i_new_dist_code),FOSID='',FOS_CODE='',DSR_ID='',DSR_CODE='',LAST_UPDATED_DATE=sysdate where retcode in (v_ret_codes);

v_query := 'update tblretailer set dist_code='||i_new_dist_code||',DIST_ID=to_number('||i_new_dist_code||'),cluster_code=(select cluster_code from tblemployee where empcode = '||i_new_dist_code||'),FOSID='''',FOS_CODE='''',DSR_ID='''',DSR_CODE='''',LAST_UPDATED_DATE=sysdate where retcode in ('||v_ret_codes||')';

execute immediate (v_query);

--i_query :='update tblretailer set dist_code='||i_new_dist_code||',DIST_ID=to_number('||i_new_dist_code||'),cluster_code=(select cluster_code from tblemployee where empcode = '||i_new_dist_code||'),FOSID='',FOS_CODE='',DSR_ID='',DSR_CODE='',LAST_UPDATED_DATE=sysdate where retcode in ('||v_ret_codes||');';

insert into TBL_TRANSFER_SUP_MASTER(MASTER_ID,TRANS_ID,TRANS_DONEBY_ROLENAME,TRANS_DONEBY_ID,TRANS_FROM_ROLENAME,TRANS_FROM,TRANS_TO_ROLENAME,TRANS_TO,ACTIVITY_CODE,TRANS_DATE,TRANSFER_REASON,LAST_UPDATED_DATE)
                 values(SUP_MASTER_TRANS_ID_SEQ.nextval,SUP_MASTER_TRANS_ID_SEQ.nextval,i_trans_doneby_rolename,i_trans_doneby_id,i_trans_dist_rolename,i_old_dist_code,i_trans_dist_rolename,i_new_dist_code,'101',sysdate,i_remapping_reason,sysdate) return TRANS_ID into v_trans_id;

FOR i IN i_ret_list.FIRST .. i_ret_list.LAST
      LOOP

      insert into TBL_TRANSFER_SUP_DTLS(DTLS_ID,TRANS_ID,TRANS_ON_ROLENAME,TRANS_ON_ID,LAST_UPDATED_DATE)
             values(SUP_DTLS_ID_SEQ.nextval,v_trans_id,i_trans_ret_rolename,i_ret_list(i),sysdate);

      END LOOP;

IF SQL%ROWCOUNT>0 THEN

result := 'success';

ELSE

result := 'failure';

END IF;

--update tblstock set NEW_DIST_CODE_REMAP=i_new_dist_code,REMAP_DATE=sysdate,LAST_UPDATED_DATE=sysdate where (DIST_CODE=i_old_dist_code or NEW_DIST_CODE_REMAP=i_old_dist_code) and RET_CODE in (v_ret_codes);

v_query := 'update tblstock set NEW_DIST_CODE_REMAP='||i_new_dist_code||',REMAP_DATE=sysdate,LAST_UPDATED_DATE=sysdate where (DIST_CODE='||i_old_dist_code||' or NEW_DIST_CODE_REMAP='||i_old_dist_code||') and RET_CODE in ('||v_ret_codes||')';

execute immediate (v_query);

i_o_query := v_query;

insert all into TBL_ACTIVITY_LOG (LOG_ID,TRANS_ID,ACTIVITY_DONEBY_ROLENAME,ACTIVITY_DONEBY_ID,ACTIVITY_REFERENCE_ID,ACTIVITY_CODE,ACTIVITY_DATE)
                values(ACTIVITY_LOG_TRANS_ID_SEQ.NEXTVAL,ACTIVITY_LOG_TRANS_ID_SEQ.NEXTVAL,i_trans_doneby_rolename,i_trans_doneby_id,v_trans_id,
                act_code,sysdate) select log_config.ACTIVITY_CODE act_code from TBL_ACTIVITY_LOG_CONFIG log_config
               where upper(log_config.ACTIVITY_TYPE)= upper(i_activity_type);

END IF;

END;
/

Java Code :-
try{
            if(ret_list.size()>0)
                ret_code = ret_list.toArray();
             con = ConnectionManager.getDirectConnection();
             ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor(PropertyLoader.RET_SECONDARY_V_ARRAY,con);
             ARRAY array_to_pass = new ARRAY( descriptor,con, ret_code );
             cstmt = con.prepareCall("{ call SP_DIST_RETAILER_REMAP(?,?,?,?,?,?,?,?,?,?,?,?)}");
             cstmt.setString(1,old_dist_code.trim());
             cstmt.setString(2,new_dist_code.trim());
             if(territory_remapping)
             cstmt.setInt(3,1);
             else
             cstmt.setInt(3,2);
             cstmt.setString(4,remapping_reason);
             cstmt.setString(5,userVO.getRolename().trim());
             cstmt.setInt(6,userVO.getEmpid());
             cstmt.setString(7,PropertyLoader.DISTRIBUOTR_ROLENAME);
             cstmt.setString(8,PropertyLoader.RETAILER_ROLENAME);
             cstmt.setString(9,PropertyLoader.ACTIVITY_TYPES_RETAILER_REMAPPING);
             cstmt.setArray(10,array_to_pass);
             cstmt.registerOutParameter(11,Types.VARCHAR);
             cstmt.registerOutParameter(12,Types.VARCHAR);
             /*cstmt.registerOutParameter(13,Types.VARCHAR);*/
             cstmt.execute();
             status = cstmt.getString(11);
             System.out.println("Remap Update Query  "+cstmt.getString(12));
             //System.out.println(cstmt.getString(13));

        }

A: If the value stored in PropertyLoader.RET_SECONDARY_V_ARRAY is not "V_ARRAY", then you are using different types; even if they are declared identically (e.g. both are table of number) this will not work.
You're hitting this data type compatibility restriction:

You can assign a collection to a collection variable only if they have
  the same data type. Having the same element type is not enough.

You're trying to call the procedure with a parameter that is a different type to the one it's expecting, which is what the error message is telling you.

A: The procedure which you are using is should be properly declared in the place which you are using it. For an example if it is under a user and in a package then it should be in that order. The username, package and procedurename.


text:
Q: https websites getting stooped automatically 443 port We are using cPanel with CSF Firewall.
The port 443 getting blocked in CSF firewall and all the websites running with https getting stooped automatically.
There is no issue with port 80 and websites running without SSL working fine.
If we restart the CSF firewall, the websites are started working again. But after sometime again facing the same issue.

A: You can open ports via CSF in /etc/csf/csf.conf:
TCP_IN = "80,443"
After appending ports you have to execute this command to apply your changes:
csf -r


text:
Q: set timer to change an UIButton properties How can I make a timer that change the properties of a UIButton from hidden to show, and from show to hidden alternating between 4 buttons?
I'm using xCode 4.4
Thanks!

A:
 NSTimer *aTimer = [NSTimer scheduledTimerWithTimeInterval: 2.0
                      target: self
                      selector:@selector(onTick:)
                      userInfo: nil repeats:YES];

And, onTick method should look like this
-(void)onTick:(NSTimer *)timer {
   //This is where you need to set your button hidden property.
}

Check this link out.It's well detailed.


text:
Q: How to keep elements under a li element in the same line? I want my elements under a li to display in the single line. If the characters exceeds the length of the div then it should wrap.
Here is the link of my fiddle.
http://jsfiddle.net/NmhB5/
Now I want that in that div my all element inside a li element should be in the same like. For Example:
O 1.abcdefghijklmnopqrstuvwxyz
O 2. 12345678901234567890

and like that.
Now as we can see that it is exceeding the length of the div so I want to wrap it like this.
O 1. abcdefghijklmnopqrstuv
     wxyz
O 2. 12345678901234567890

How can I do that?

A: You could add this
span {
   display: inline-block;
   word-break:break-all; /* add this */
}

JSfiddle Demo

A: You can do it using the below CSS:
span {
    display: block;
    word-break: break-all;
}

Also, given that you are effectively numbering the list again, why not use the ordered list (
) tags instead of using an unordered list (
) and then adding an extra span for the numbering.
I would recommend the below markup:

abcdefghijklmnopqrstuvwxyz

123456789012345678901234567890

abcdefghijklmnopqrstuvwxyz

123456789012345678901234567890

CSS:
div {
   right: 0px;
   width: 200px;
   border: double;
   position: absolute;
}

li {
    word-break: break-all;
}

Demo
Note: You may want to refer to this thread on when to use UL or OL in html?. But the crux of both this answer and the one posted by Paulie_D are the same in the sense that both use the word-break property.
Update: For wrapping around whole word to the next line when it overflows, you can use the below setting.
li {
    word-wrap: break-word;
    /* Webkit supports word-break: break-word; also but it seems to be non-standard */
}

Updated Demo

A: you know you can have a ordered list with numbers, for example http://www.w3schools.com/cssref/playit.asp?filename=playcss_ol_list-style-type&preval=decimal-leading-zero
for example
html

 jguhiuo

 jhii

css
 ol#myList
{
list-style-type:decimal;
}

link
http://jsfiddle.net/NmhB5/5/


text:
Q: Can Kafka consumer be paused for definite interval and resume automatically after the interval Can kafka consumer be paused for a definite time interval say 2 mins and get resumed automatically once the given time interval is over. Or can we provide time window to pause command?

A: Yes, we are using this for very very long processing time and in order processing  of events, there is api in kafka client called pause and resume, you need to remember that in order that your consumer won't die you must keep calling poll() , pause makes it that poll request won't return any new records but will refresh the "timers" on poll request, when you wish you can call the resume and then poll again,
I am not a fan of this way of using kafka, as I would like kafka to be more of real time streaming machine and it somehow felt to me like against that logic , but it is working,

A: Yes, KafkaConsumer has a pause method. As a parameter it takes a collection of partitions. This method does not affect partition subscription and does not cause a group rebalance. Later, you can use resume method to resume a subscription.