text:
Q: How to iterate/while a mapping variables from environment to message assembly in IBM Integration Bus (toolkit)? I have a SOAP node, that retrieve information from a URL in a tree structure.
Then i have a compute node to define each environment variable to each namespace variable of the SOAP retrieve.
And finally, i have a mapping node, to move the content to my message assembly structure in XML.
The error its giving me it's this (IN THE COMPUTE NODE):
I have a structure like this:
ListDocs
Description
DocType
ListTypes
 Attribute
 Lenght
 Description
 Nature
 Required

ListDocs
Description
DocType
ListTypes
 Attribute
 Lenght
 Description
 Nature
 Required

ListDocs
Description
DocType
ListTypes
 Attribute
 Lenght
 Description
 Nature
 Required

The problem is that, when i do the definition of the variables, I do it like the code below, in the COMPUTE NODE:
WHILE I < InputRoot.SOAP.Body.ns:obterTiposDocProcessosResponse.ns:return.ns75:processo.ns75:listaTiposDocumentos
DO

  SET Environment.Variables.XMLMessage.return.process.listDocs.description = InputRoot.SOAP.Body.ns75:processo.ns75:listDocs.ns75:description;

  SET Environment.Variables.XMLMessage.return.process.listDocs.tipoDocumento = InputRoot.SOAP.Body.ns75:processo.ns75:listDocs.ns75:DocType;

  SET Environment.Variables.XMLMessage.return.process.listDocs.listTypes.attribute = InputRoot.SOAP.Body.ns75:processo.ns75:listDocs.ns75:listTypes.ns75:atribbute;

  SET Environment.Variables.XMLMessage.return.process.listDocs.listTypes.lenght = InputRoot.SOAP.Body.ns75:processo.ns75:listDocs.ns75:listTypes.ns75:lenght;

  SET Environment.Variables.XMLMessage.return.process.listDocs.listTypes.description = InputRoot.SOAP.Body.ns75:processo.ns75:listDocs.ns75:listTypes.ns75:description;

  SET Environment.Variables.XMLMessage.return.process.listDocs.listTypes.nature = InputRoot.SOAP.Body.ns75:processo.ns75:listDocs.ns75:listTypes.ns75:nature;

  SET Environment.Variables.XMLMessage.return.process.listDocs.listTypes.required = InputRoot.SOAP.Body.ns75:processo.ns75:listDocs.ns75:listTypes.ns75:required;

  SET I = I+1;

END WHILE;

BUT, in my XML final structure, it only prints the values of my first listDocs, and i want to print all of my listDocs structures.
NOTE: WITH THE WHILE LIKE THIS, IT DOESN'T EVEN WORK. I HAVE TO REMOVE THE WHILE TO PRINT THE FIRST listDocs like i said Above.
Any help?
I NEED HELP TO LOOP THE STRUCTURES, WITH A WHILE OR SOMETHING.

A: You should try to use the following synthax :
DECLARE I INTEGER 1;
DECLARE J INTEGER;
J = CARDINALITY(InputRoot.SOAP.Body.ns:obterTiposDocProcessosResponse.ns:return.ns75:processo.ns75:listaTiposDocumentos[])
WHILE I <= J DO
   SET Environment.Variables.XMLMessage.return.process.listDocs.description = InputRoot.SOAP.Body.ns75:processo.ns75:listDocs[I].ns75:description;
   ....
END WHILE;

You only missed the CARDINALITY function to get the number of elements, and also the [] to define the table, and then using this [I] while accessing the elements
Note : in my sample above, the environment will be overridden at each iteration of the loop, so only the last record will be printed. You can use the [I] in the output as well if you want to construct a table in output, or you can use the following code to push each message to the output terminal (this means you have one message in input, and 3 message coming out of the output terminal)
PROPAGATE TO TERMINAL 'Out';

So for example, based on your code, if you want to generate 3 messages based on your input containing multiple element :
DECLARE I INTEGER 1;
DECLARE J INTEGER;
J = CARDINALITY(InputRoot.SOAP.Body.ns:obterTiposDocProcessosResponse.ns:return.ns75:processo.ns75:listaTiposDocumentos[])
WHILE I <= J DO
   SET Environment.Variables.XMLMessage.return.process.listDocs.description = InputRoot.SOAP.Body.ns75:processo.ns75:listDocs[I].ns75:description;
   SET Environment.Variables.XMLMessage.return.process.listDocs.tipoDocumento = InputRoot.SOAP.Body.ns75:processo.ns75:listDocs[I].ns75:DocType;
   SET Environment.Variables.XMLMessage.return.process.listDocs.listTypes.attribute = InputRoot.SOAP.Body.ns75:processo.ns75:listDocs[I].ns75:listTypes.ns75:atribbute;
   SET Environment.Variables.XMLMessage.return.process.listDocs.listTypes.lenght = InputRoot.SOAP.Body.ns75:processo.ns75:listDocs[I].ns75:listTypes.ns75:lenght;
   SET Environment.Variables.XMLMessage.return.process.listDocs.listTypes.description = InputRoot.SOAP.Body.ns75:processo.ns75:listDocs[I].ns75:listTypes.ns75:description;
   SET Environment.Variables.XMLMessage.return.process.listDocs.listTypes.nature = InputRoot.SOAP.Body.ns75:processo.ns75:listDocs[I].ns75:listTypes.ns75:nature;
   SET Environment.Variables.XMLMessage.return.process.listDocs.listTypes.required = InputRoot.SOAP.Body.ns75:processo.ns75:listDocs[I].ns75:listTypes.ns75:required;
   PROPAGATE TO TERMINAL 'Out';
END WHILE;
RETURN FALSE;

For your global information, the RETURN TRUE is the instruction "pushing" the message built in the ESQL code to the output terminal. If you use PROPAGATE instruction (same effect), you should RETURN FALSE to avoid sending an empty message after looping on your records. Another way to do it is to propagate on another terminal (i.e : 'out1'), and keep the return true. In this case, you would have all you records coming out from the out1 terminal, and a message going out of the output temrinal (due to the return true) once all the messages have been propagated (this might be useful in many situations)

A: So the key to understanding IIB and ESQL is that you are looking at in memory Trees built from nodes.
Each Node has pointers/REFERENCEs to PARENT, NEXTSIBLING, PREVSIBLING, FIRSTCHILD and LASTCHILD Nodes.
Nodes also have FIELDNAME, FIELDNAMESPACE, FIELDTYPE and FIELDVALUE attributes.
And last but not least that you are building Output Trees by navigating Input Trees. The Environment Tree, which you are using, is a special long lasting Tree that you can both read from and write to.
So in your code InputRoot.SOAP.Body.ns75:processo.ns75:listDocs can be thought of as shorthand for instructions to navigate to the ns75:listDocs Node. The dots '.' tell ESQL interpreter the name of the child Node of the current Node. If you were telling someone how to navigate the Nodes it would go something like this.

*

*Start at InputRoot. InputRoot is a special Node that is automatically available to you in your ESQL Modules code.

*Navigate to the first child Node of InputRoot that has the name SOAP

*Navigate to the first child Node of SOAP that has the name Body

*Navigate to the first child Node of Body that has the name listDocs and is in the ns75 namespace.

In the absence of a subscript ESQL assumes you want the first Node that matches the specified name ns75:listDocs and ns75:listDocs[1] both refer to the same Node.
This explains what was happening in your code. You were always navigating to the same listDocs[1] node in the InputRoot and Environment Trees.
@Jerem's code improves on what you were doing by at least navigating across the listDocs nodes in the Input tree.
For each iteration of the loop the subscript [I] gets incremented and thus it chooses a different listDocs Node. The listDocs Nodes are siblings and thus the code will access the first, second and third instance of the listDocs Nodes.
InputRoot.SOAP.Body.ns75:processo.ns75:listDocs[1] <-- Iteration I=1
InputRoot.SOAP.Body.ns75:processo.ns75:listDocs[2] <-- Iteration I=2
InputRoot.SOAP.Body.ns75:processo.ns75:listDocs[3] <-- Iteration I=3

To correct @Jerem's answer you'd need to use subscripts on the lefthand side of the statement as well. Picking the description field as an example you'd need to change your code as follows.
SET Environment.Variables.XMLMessage.return.process.listDocs[I].listTypes.description = InputRoot.SOAP.Body.ns75:processo.ns75:listDocs[I].ns75:listTypes.ns75:description;

Using subscripts is regarded as a performance no no. Imagine you had 10,000 listDocs this would result in each and every iteration of the loop walking down the tree over the InputRoot, SOAP, Body, ns75:processo Nodes and then across the listDocs sibling nodes until it found the ns75:listDocs[I] Node.
This means by the time we get round to processing ns75:listDocs[10000] it will have had to repetetively walked over all the other listDocs Nodes time and time again, In fact we can calculate it would have walked over (4 x 10,000) + ((10,000 x (10,000 + 1)) / 2) = 50,045,000 Nodes
So it's REFERENCE's to the rescue and also the answer to your question. Try a loop like this.
DECLARE ns75 NAMESPACE 'http://something.or.other.from.your.wsdl';
DECLARE InListDocsRef REFERENCE TO
InputRoot.SOAP.Body.ns75:processo.ns75:listDocs;
WHILE LASTMOVE(InListDocsRef) DO
    DECLARE EnvListDocsRef REFERENCE TO Environment;
    CREATE LASTCHILD OF Environment.Variables.XMLMessage.return.process AS EnvListDocsRef NAME 'listDocs';

    SET EnvListDocsRef.description           = InListDocsRef.ns75:description;
    SET EnvListDocsRef.tipoDocumento         = InListDocsRef.ns75:DocType;
    SET EnvListDocsRef.listTypes.attribute   = InListDocsRef.ns75:listTypes.ns75:atribbute;
    SET EnvListDocsRef.listTypes.lenght      = InListDocsRef.ns75:listTypes.ns75:lenght;
    SET EnvListDocsRef.listTypes.description = InListDocsRef.ns75:listTypes.ns75:description;
    SET EnvListDocsRef.listTypes.nature      = InListDocsRef.ns75:listTypes.ns75:nature;
    SET EnvListDocsRef.listTypes.required    = InListDocsRef.ns75:listTypes.ns75:required;

    MOVE InListDocsRef NEXTSIBLING REPEAT NAME;
END WHILE;

The code above only walks over 4 + 10,000 Nodes i.e. 10 thousand Nodes vs 50 million Nodes.
A couple of other useful things to know about setting references are:

*

*To point to the last element you can use a subscript of [<]. So to point to the last ListItem in the aggregate MyList you would code  Environment.MyList.ListItem[<]

*You can use an asterisk * to set a reference to an element in the tree that you don't know the name of e.g. Environment.MyAggregate.* points to the first child of MyAggregate regardless of it's name.

*You can also use asterisks * to choose an element irregardless of it's namespace InListDocsRef.*:listTypes.*:description

*For anonymous namespaced elements use *:*  but be very careful * and *:* are not the same thing the first means no namespace any element and the second means any namespace any element.

*To process lists in reverse combine the [<] subscript with the PREVIOUSSIBLING option of MOVE.

So a chunk of code for reversing a list might go something like:
DECLARE MyReverseListItemWalkingRef REFERENCE TO Environment.MyList.ListItem[<];
WHILE LASTMOVE(MyReverseListItemWalkingRef) DO
    CREATE LASTCHILD OF OuputRoot.ReversedList.Item NAME 'Description' VALUE MyReverseListItemWalkingRef.Desc;

    MOVE MyReverseListItemWalkingRef PREVIOUSSIBLING REPEAT NAME;
END WHILE;

Learn how to use REFERENCES they are extremely powerful and one of your simplest options when it comes to performance.


text:
Q: Tensorflow GPU installation Error Windows 10 Anaconda I am having a tough time trying to setup Tensorflow for GPU use. I am no Windows 10, have already downloaded CUDA® Toolkit 8.0, cuDNN v5.1. and uninstalled Visual C++ 2015 redistributable and reinstalled as suggested by On Windows, running "import tensorflow" generates No module named "_pywrap_tensorflow" error but this did not have any effect. I am also not really sure about the PATH or if everything is included correctly there. Here is the error I keep getting (sorry it is not properly quoted but I kept getting formatting errors):

Microsoft Windows [Version 10.0.14393] (c) 2016 Microsoft Corporation.
  All rights reserved.
C:\Users\Austin>activate test_env
(test_env) C:\Users\Austin>python
Python 3.5.3 | packaged by
  conda-forge | (default, Feb  9 2017, 15:12:38) [MSC v.1900 64 bit
  (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for
  more information.
>>> import tensorflow as tf
Traceback (most recent call last): File
  "C:\Anaconda3\envs\test_env\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",
  line 18, in swig_import_helper return importlib.import_module(mname)
  File "C:\Anaconda3\envs\test_env\lib\importlib__init__.py", line 126,
  in import_module return _bootstrap._gcd_import(name[level:], package,
  level) File "", line 986, in _gcd_import
  File "", line 969, in _find_and_load File
  "", line 958, in _find_and_load_unlocked
  File "", line 666, in _load_unlocked File
  "", line 577, in module_from_spec File
  "", line 914, in create_module
  File "", line 222, in
  _call_with_frames_removed ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
  "C:\Anaconda3\envs\test_env\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",
  line 41, in  from tensorflow.python.pywrap_tensorflow_internal
  import * File
  "C:\Anaconda3\envs\test_env\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",
  line 21, in
  _pywrap_tensorflow_internal = swig_import_helper() File "C:\Anaconda3\envs\test_env\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",
  line 20, in swig_import_helper return
  importlib.import_module('_pywrap_tensorflow_internal') File
  "C:\Anaconda3\envs\test_env\lib\importlib__init__.py", line 126, in
  import_module return _bootstrap._gcd_import(name[level:], package,
  level) ImportError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "", line 1, in
  File
  "C:\Anaconda3\envs\test_env\lib\site-packages\tensorflow__init__.py",
  line 24, in  from tensorflow.python import * File
  "C:\Anaconda3\envs\test_env\lib\site-packages\tensorflow\python__init__.py",
  line 51, in  from tensorflow.python import pywrap_tensorflow
  File
  "C:\Anaconda3\envs\test_env\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",
  line 52, in  raise ImportError(msg) ImportError: Traceback
  (most recent call last): File
  "C:\Anaconda3\envs\test_env\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",
  line 18, in swig_import_helper return importlib.import_module(mname)
  File "C:\Anaconda3\envs\test_env\lib\importlib__init__.py", line 126,
  in import_module return _bootstrap._gcd_import(name[level:], package,
  level) File "", line 986, in _gcd_import
  File "", line 969, in _find_and_load File
  "", line 958, in _find_and_load_unlocked
  File "", line 666, in _load_unlocked File
  "", line 577, in module_from_spec File
  "", line 914, in create_module
  File "", line 222, in
  _call_with_frames_removed ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
  "C:\Anaconda3\envs\test_env\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",
  line 41, in  from tensorflow.python.pywrap_tensorflow_internal
  import * File
  "C:\Anaconda3\envs\test_env\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",
  line 21, in
  _pywrap_tensorflow_internal = swig_import_helper() File "C:\Anaconda3\envs\test_env\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",
  line 20, in swig_import_helper return
  importlib.import_module('_pywrap_tensorflow_internal') File
  "C:\Anaconda3\envs\test_env\lib\importlib__init__.py", line 126, in
  import_module return _bootstrap._gcd_import(name[level:], package,
  level) ImportError: No module named '_pywrap_tensorflow_internal'
Failed to load the native TensorFlow runtime.
See
  https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions.  Include the entire stack trace
  above this error message when asking for help.
>>>

And here is what I get for my PATH (I think this is the problem, but I really don't know enough about what the PATH even is...)

(test_env) C:\Users\Austin>PATH
  PATH=C:\Anaconda3\envs\test_env;C:\Anaconda3\envs\test_env\Library\mingw-w64\bin;C:\Anaconda3\envs\test_env\Library\usr\bin;C:\Anaconda3\envs\test_env\Library\bin;C:\Anaconda3\envs\test_env\Scripts;C:\Program
  Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin;C:\Program
  Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\libnvvp;C:\Program Files
  (x86)\Tesseract-OCR;C:\Anaconda3;C:\Anaconda3\Scripts;C:\Program
  Files\NVIDIA GPU Computing
  Toolkit\cudnn-8.0-windows10-x64-v5.1\cuda;C:\Program Files\Common
  Files\microsoft
  shared\ClickToRun;C:\Users\Austin\AppData\Local\Microsoft\WindowsApps;C:\Users\Austin\AppData\Local\atom\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;
(test_env) C:\Users\Austin>

A: Figured it out. Needed to copy the contents of the  downloaded cudnn into the respective locations inside the CUDA folder (i.e. lib, bin, etc.)

redpajama_set_name: RedPajamaStackExchange


text:
Q: C++ overloaded new issue I have made a small mechanism that replaces the regular new operator.
Basically we allocate a pool of memory (like 16mb) and when new is called, return
an offset to it that grows until there is no more room and we make another pool. A pool
is deleted only when all of the elements in that pool are freed.
I have tested this class and it works great and around 8-15 times faster than the original new.
There is a problem however: I incorporated it into my other project which is huge in size, it
works normally except the memory usage grows very quickly. Basically the pools aren't freed because
some items in them are not deleted at all. Also, there are many calls to new(0) from STL containers
to which I dont know how should it respond.
Here is the code:
namespace rt
{
      class pool
      {
            friend class alloc;
            private:
                    unsigned int _numRecords;
                    unsigned int _sizeLeft;
                    char*        _ptr;
                    char*        _data;

      };

      class alloc
      {
            public:
                   alloc();

                   alloc(int mb);

                   ~alloc();

                   void* allocate(unsigned int size);

                   void constructPool(unsigned int idx);

                   void destroyPool(unsigned int idx);

                   void deallocate(void* ptr);

            private:
                    const static unsigned int           _numPools = 256;
                    const static unsigned int           _poolSize = 15*1024*1024;
                    const static unsigned int           _poolReplaceBound = 1*1024*1024; // if 1mb or less left we can replace it
                    pool*                               _pools[_numPools];
                    unsigned int                        _curPoolIdx;

      };

That was the header.
Here is the implementation:
namespace rt
{
          class pool
          {
                friend class alloc;
                private:
                        unsigned int _numRecords;
                        unsigned int _sizeLeft;
                        char*        _ptr;
                        char*        _data;

          };

      class alloc
      {
            public:
                   alloc();

                   alloc(int mb);

                   ~alloc();

                   void* allocate(unsigned int size);

                   void constructPool(unsigned int idx);

                   void destroyPool(unsigned int idx);

                   void deallocate(void* ptr);

            private:
                    const static unsigned int           _numPools = 256;
                    const static unsigned int           _poolSize = 15*1024*1024;
                    const static unsigned int           _poolReplaceBound = 1*1024*1024; // if 1mb or less left we can replace it
                    pool*                               _pools[_numPools];
                    unsigned int                        _curPoolIdx;

      };

      extern alloc default_allocator;
}

#define RT_SAFE_MEM
namespace rt
{
      alloc default_allocator;

      alloc::alloc()
      {
                     for(int i = 0; i < _numPools; i++) _pools[i] = NULL;
                     _curPoolIdx = 0;
                     constructPool(_curPoolIdx);
      }

      alloc::~alloc()
      {

      }

      void alloc::constructPool(unsigned int idx)
      {
                                    _pools[idx] = (pool*)malloc(sizeof(pool));
                                    _pools[idx]->_numRecords = 0;
                                    _pools[idx]->_sizeLeft = _poolSize;
                                    _pools[idx]->_data = (char*)calloc(_poolSize, 1);

                                    _pools[idx]->_ptr = _pools[idx]->_data;
      }

      void alloc::destroyPool(unsigned int idx)
      {
           free(_pools[idx]->_data);
           free(_pools[idx]);
           _pools[idx] = NULL;
      }

      void* alloc::allocate(unsigned int size)
      {
            if(size == 0)
            {
                    return NULL;
            }
            #ifdef RT_SAFE_MEM

                                  if(size > _poolSize)
                                  {
                                          MessageBox(NULL, "Allocation size exceeded maximum.", "Executor", MB_OK);
                                          return NULL;
                                  }
                                  if(*(_pools[_curPoolIdx]->_ptr) != 0)
                                  {
                                                                  //leak
                                                                  unsigned int leaksize = strlen(_pools[_curPoolIdx]->_ptr);
                                                                  char str[50];
                                                                  sprintf(str, "Memory corruption detected: wrote extra %u bytes. \nExporting to corrupt.txt", leaksize);
                                                                  FILE* fp = fopen("corrupt.txt", "w");
                                                                  fwrite(_pools[_curPoolIdx]->_ptr, 1, leaksize, fp);
                                                                  fclose(fp);
                                                                  MessageBox(NULL, str, "Executor", MB_OK);
                                                                  return NULL;
                                  }

            #endif

            if(_pools[_curPoolIdx]->_sizeLeft <= size)
            {
                                              //not enough size in this pool
                                              //make a new one
                                              _curPoolIdx++;
                                              //printf("expand");
                                              constructPool(_curPoolIdx);
                                              return allocate(size);

            }
            else
            {
                void* ans = (void*)_pools[_curPoolIdx]->_ptr;
                _pools[_curPoolIdx]->_ptr+=size;
                _pools[_curPoolIdx]->_sizeLeft-=size;
                _pools[_curPoolIdx]->_numRecords++;
                return ans;
            }
      }

      void alloc::deallocate(void* ptr)
      {
           for(int i = 0; i <= _curPoolIdx; i++)
           {
                   if(ptr >= _pools[i]->_data && ptr < _pools[i]->_ptr)
                   {
                          //pool i contains this object
                          //printf("found %d\n", i);
                          _pools[i]->_numRecords--;
                          if(_pools[i]->_numRecords == 0 && _pools[i]->_sizeLeft <= _poolReplaceBound)
                          {
                                                    //replace this pool
                                                    printf("replacing %d\n", i);
                                                    destroyPool(i);
                                                    if(_curPoolIdx == 0) constructPool(0);
                                                    else
                                                    {
                                                        for(int j = i; j < _numPools-1; j++)
                                                        {
                                                                _pools[j] = _pools[j+1];
                                                        }
                                                        _curPoolIdx--;
                                                    }

                          }
                          return;
                   }
           }
           #ifdef RT_SAFE_MEM
                  char str[50];
                  sprintf(str,  "Attempted to deallocate foreign memory at 0x%.8X.", ptr);
                  MessageBox(NULL, str, "Executor", MB_OK);
           #endif
      }

}
If anyone sees a bug or a major problem, let me know.
Thanks!

A: I suggest you do all the below steps:

*

*Write a test program to test that your program runs bug-free or "has any problems"

*use a debugger to find bugs, not the SO's audience :-P

*Instead of posting a full listing of your code you should write-up what your code does - this will serve you as a great reference point in future and also will be a useful documentation for what (and how) your code does


text:
Q: ¿Como cambiar el color del subrayado de un TextView en Android? Estoy agregando el subrayado a un TextView de esta manera:
TextView register = (TextView)findViewById(R.id.txt_register);
SpannableString content = new SpannableString(getString(R.string.text));
content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
register.setText(content);

Lo que me agrega el subrayado del mismo color del TextView, habrá alguna forma de cambiar el color del subrayado.

A: Buscando en Stack Overflow en ingles encontre la respuesta a lo que queria respondida por el usuario Bojan Kseneman
Primero se definen los atributos personalizados en el archivo styles.xml
<declare-styleable name="UnderlinedTextView" >
<attr name="underlineWidth" format="dimension" />
<attr name="underlineColor" format="color" />
</declare-styleable>

Crear una clase personalizada para TextView
public class UnderlinedTextView extends AppCompatTextView {
    private Rect mRect;
    private Paint mPaint;
    private float mStrokeWidth;

    public UnderlinedTextView(Context context) {
        this(context, null, 0);
    }

    public UnderlinedTextView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public UnderlinedTextView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context, attrs, defStyleAttr);
    }

    private void init(Context context, AttributeSet attributeSet, int defStyle) {

        float density = context.getResources().getDisplayMetrics().density;

        TypedArray typedArray = context.obtainStyledAttributes(attributeSet, R.styleable.UnderlinedTextView, defStyle, 0);
        int underlineColor = typedArray.getColor(R.styleable.UnderlinedTextView_underlineColor, 0xFFFF0000);
        mStrokeWidth = typedArray.getDimension(R.styleable.UnderlinedTextView_underlineWidth, density * 2);
        typedArray.recycle();

        mRect = new Rect();
        mPaint = new Paint();
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setColor(underlineColor);
        mPaint.setStrokeWidth(mStrokeWidth);
    }

    public int getUnderLineColor() {
        return mPaint.getColor();
    }

    public void setUnderLineColor(int mColor) {
        mPaint.setColor(mColor);
        invalidate();
    }

    public float getUnderlineWidth() {
        return mStrokeWidth;
    }

    public void setUnderlineWidth(float mStrokeWidth) {
        this.mStrokeWidth = mStrokeWidth;
        invalidate();
    }

    @Override
    protected void onDraw(Canvas canvas) {

        int count = getLineCount();

        final Layout layout = getLayout();
        float x_start, x_stop, x_diff;
        int firstCharInLine, lastCharInLine;

        for (int i = 0; i < count; i++) {
            int baseline = getLineBounds(i, mRect);
            firstCharInLine = layout.getLineStart(i);
            lastCharInLine = layout.getLineEnd(i);

            x_start = layout.getPrimaryHorizontal(firstCharInLine);
            x_diff = layout.getPrimaryHorizontal(firstCharInLine + 1) - x_start;
            x_stop = layout.getPrimaryHorizontal(lastCharInLine - 1) + x_diff;

            canvas.drawLine(x_start, baseline + mStrokeWidth, x_stop, baseline + mStrokeWidth, mPaint);
        }
        super.onDraw(canvas);
    }
}

Uso de la clase en el Layout:
<some.package.UnderlinedTextView
    android:id="@+id/tvTest"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="10dp"
    android:layout_marginLeft="20dp"
    android:layout_marginRight="20dp"
    android:gravity="center"
    android:text="This is a demo text"
    android:textSize="16sp"
    app:underlineColor="#ffc112ef"
    app:underlineWidth="3dp"/>

Resultado ejemplo:

A: Crea un UndelineSpan pero definiendo otro color:
   UnderlineSpan underlineSpan = new UnderlineSpan();
   TextPaint tp = new TextPaint();
   tp.setColor(Color.GREEN);  //*Color verde!
   underlineSpan.updateDrawState(tp);

Ejemplo:
    TextView textView = (TextView)findViewById(R.id.textView);
    SpannableString content = new SpannableString("Jorgesys was here! ce faci mama!");

    UnderlineSpan underlineSpan = new UnderlineSpan();
    TextPaint tp = new TextPaint();
    tp.setColor(Color.GREEN);
    underlineSpan.updateDrawState(tp);

    content.setSpan(underlineSpan, 0, content.length(), 0);
    textView.setText(content);


text:
Q: Interesting question regarding evolution of algorithm under certain conditions On a random string of six digits containing numbers of the set $S=\{1,2,3,4,5,6\}$, repeat the following operation:
If $k$ is the first number of the string, then reverse the order of first $k$ numbers of the string.
For example: $342561\rightarrow 243561\rightarrow 423561\rightarrow 532461\rightarrow 642351\rightarrow 153426$
Prove that any such string would terminate with $1$ at the first position.
Now on checking a few examples, I have made a few observations:
$1.$ The last digit of the string is an increasing monovariant.
$2.$ The first digit of string is always a different number unless the last digit changes. This means that until the last digit of the string change, no number that appeared in the first position in the string will ever repeat.
$3.$ When the last digit reaches its maximum value (which is $6$ here), the observation $2$ works the same but for th second last digit now instead of the last one.
Now the first observation can be explained by the fact that the last digit will only change when we would have $6$ in the first position and no number in the string is greater than $6$.
The third observation can be explained by the fact that when the last digit reaches the value of $6$, this value would never change as all the numbers are less than $6$. Thus, the observation $2$ would now work with the second last digit instead of the last digit since it would be the same as applying the algorithm to  a string of length $5$ instead of $6$.
Now if I can prove observation $2$, then I can say that since no number occuring in the first position repeats, we would have either $6$ or $1$ in the first position sometime in atmost $6$ steps. If we obtain $6$ before $1$ in the first position, then $6$ would move to the last position. Similarily after $6$ have moved to the last position, we would either have $1$ or $5$ in the first position after atmost $5$ steps and so on.
This indicates that after some finite steps, the sequence is bound to have $1$ at the first position.
Now I need help to prove observation $2$. Please help.
THANKS

A: The idea is as follows:
6 can be the first digit in the sequence at most once. After that, it's permanently stuck as the last digit of the sequence.
5 can be the first digit in the sequence at most twice. After 5 is the first digit, it'll be the 5th digit and can only move downwards if 6 becomes the 1st digit. But that can only happen once.
In general, $6 - n$ can be the first digit at most $2^n$ times. For after each time $6-n$ is the first digit, it only be dislodged from its position by a higher number; this dislodging can occur at most $\sum\limits_{i = 0}^{n - 1} 2^i = 2^n - 1$ times. You can use well-founded induction to make this argument rigorous.
Thus, the process will eventually terminate with 1.

A: Let us consider a generalized version of this problem where we are given some permutation $\pi$ of $[1, n]$ and let $f$ denote the function mapping such a permutation to the one resulting by applying the given operation.
Further, we will call $\pi$ correct for $k$ if $\pi(k) = k$.
We begin by observing 2 properties of $f$:

*

*$f$ preserves the correctness of a permutation $\pi$ at $k$ if $\pi(1) < k$, i.e. reversing the order of the first $\ell < k$ elements of the permutation does not change the position of $k$.

*$f(\pi)$ is correct for $\pi(1)$, i.e. $f(\pi)$ is correct for the first element of $\pi$.

A simple corollary of these properties is that if $\pi$ is correct at $k$ and $f(\pi)$ is not then $f(\pi)$ must be correct for some $j > k$ on which $\pi$ is not correct.
This follows from the fact that $k$ can only be moved to an incorrect position if the first element of $\pi$ is some $j > k$.
Now consider the following energy function $E$:
$$ E \colon S_{[1, n]} \to \mathbb R,
\pi \mapsto \sum_{\pi \text{ correct for } k} 2^{k} $$
Using the properties of $f$ established above we find that $E(f(\pi)) \geq E(\pi)$ with the inequality being strict exactly for all $\pi$ on which $f$ is not stationary.
As $S_{[1, n]}$ is finite, it follows that the state $f^m(\pi)$ of the algorithm (started on some initial permutation $\pi$) attains a maximal energy value after $p \leq |S_{[1, n]}| < \infty$ steps. We conclude that $f^p(\pi)$ must hence be a stationary point of $f$ which is equivalent to $f^p(\pi)$ being correct for 1.


text:
Q: Ubuntu 20 USB device descriptor read/8, error -110 I did a fresh install of Ubuntu 20 on my Dell Laptop 2 days ago. I do have a Dell Display link docking station. I am experiencing the device descriptor error as mentioned in the subject.
When that happens, only the laptop keyboard and the touch pad works for me. No other USB port on my laptop works for me.
Previously I was using Ubuntu 20, but that was a migration from the Ubuntu 18 LTS. There I had no such issue before.
[ 8270.247510] usb 1-9: new high-speed USB device number 16 using xhci_hcd
[ 8275.503438] usb 1-9: device descriptor read/64, error -110
[ 8291.118961] usb 1-9: device descriptor read/64, error -110
[ 8291.227112] usb usb1-port9: attempt power cycle
[ 8291.879114] usb 1-9: new high-speed USB device number 17 using xhci_hcd
[ 8297.135243] usb 1-9: device descriptor read/8, error -110
[ 8302.511250] usb 1-9: device descriptor read/8, error -110
[ 8302.750767] usb 1-9: new high-speed USB device number 18 using xhci_hcd
[ 8307.887137] usb 1-9: device descriptor read/8, error -110
[ 8313.263174] usb 1-9: device descriptor read/8, error -110
[ 8313.370569] usb usb1-port9: unable to enumerate USB device

I read several threads saying this is related to some power issue. The advice in those threads is to reboot the machine. Yes, I know that can solve the problem but for me this problems happens again after some time.
Can some one help me understand what is the real issue? I do not suppose that there is any issue with the power supplied by my docking station as it was working fine before 2 days.


text:
Q: Return a JSON object from doview method of a basic portlet I want to return a JSON object from the doview method of a basic portlet to dojo.rawXhrPost (handle as:xml) method of Javascript. How to do that?

A: I am going to guess that you are working with Java portlets. There may be other solutions specific to your container, but you don't say what that is.
The correct way to serve a resource from a portlet context is via the serveResource method by using a resource URL. If you're still using JSR 168 portlets, you'll have to resort to using a servlet.
Any AJAX calls to a render URL to invoke doView are likely to re-render all your page's portlets and the surrounding theme. You'll have to deal with a load of junk data in your JavaScript and there may be unintended side-effects.

A: The  way to handle ajax calls is to use resourceURL.In serveResource send the result of ajax call as response.getWriter().write(result). But if you want to use renderURL or actionURL you cannot handle the ajax calls as they'll load entire the portal page ( or can say as all the portlets in the portal page are loaded )


text:
Q: Delete Version history Is it possible to delete Particular version history using pnp or J-query?

A: You could delete version history by PowerShell script in SharePoint online. For more detailed information, refer to the article below.
SharePoint Online: Delete Version History using PowerShell CSOM.
In PnP PowerShell commands, there is no such PnP PowerShell command to delete the version history.
To use jQuery, you could get the specific version history by REST API, and then delete it. For more detailed information, refer to the post below.
https://social.msdn.microsoft.com/Forums/office/en-US/22bc1a22-d958-49d7-81a3-6009c39d88ac/delete-previous-versions-from-a-document-library-using-javascriptrest?forum=sharepointdevelopment


text:
Q: Change an existing field of value type float to an optional float in a protobuf message I have a message of the following type
message Foo {
    string bar = 1;
    float baz = 2;
}

Is there any problem in converting it to the following for use in Go ?

message Foo {
    string bar = 1;
    optional float baz = 2;
}

Is the preferred way to deprecate and create a new field in the proto in this case as well ?

A: The optional will make the field a pointer type. So in Go generated code, optional float will become *float32, which of course is not float32.
To deprecate a field, use [deprecated = true] field option:
message Foo {
    string bar = 1;
    float baz = 2 [deprecated = true];
}

If in subsequent releases of your protobuf schema you actually remove the field altogether from the message, you might want to add reserved 2, where 2 is the number of the field you removed.
message Foo {
    string bar = 1;
    reserved 2;
}

This helps preventing other people or future you from adding a new field in position 2. This is relevant in case you have outdated clients which still expect a float in position 2.
PS: optional fieds in Proto3 are supported from version 3.15

A: depends on how deeply integrated that particular message is in your code base - meaning

*

*are you storing the marshaled binary representation somewhere like your database

*are different parts of your code base using different versions of the message you are modifying - e.g. older versions of your android/ios apps and such

point being if you use a message structure to unmarshal encoded data, that was not generated with the very same message structure, into - bad things will happen.
The docs recommend adding a new element to circumvent such scenarios entirely. If that is not something you want to do, take the above points into consideration.

A: I suggest you to use the FloatValue type defined in the google.protobuf package. As example:

syntax = "proto3";

import "google/protobuf/wrappers.proto";

message Foo {
  string bar = 1;
  google.protobuf.FloatValue baz = 2;
}

Will generate a pb files with the content:

type Foo struct {
    state         protoimpl.MessageState
    sizeCache     protoimpl.SizeCache
    unknownFields protoimpl.UnknownFields

    Bar string                 `protobuf:"bytes,1,opt,name=bar,proto3" json:"bar,omitempty"`
    Baz *wrapperspb.FloatValue `protobuf:"bytes,2,opt,name=baz,proto3" json:"baz,omitempty"`
}

You can use as follow:
  f := Foo{
      Bar:           "Bar",
      Baz:           &wrapperspb.FloatValue{Value: float32(3)},
  }

  var floatValue float32
  if f.Baz != nil {
      floatValue = f.Baz.GetValue()
  }


text:
Q: Pandasql not working when I add an analytical function I'm having an issue with the pandasql library. The library works great until I attempt an analytical function in which case I get the error:
**Error message**
OperationalError: near "(": syntax error

The table and code used is as follow:
question_id, average
ksjhf          324
9nsof          245
oi2hf          674

from pandasql import sqldf

q1 = """SELECT *, ROW_NUMBER() OVER ( PARTITION BY question_id ORDER BY average) AS question_number FROM ordered"""

sqldf( q1 )

A: pandasql uses a sqlite in memory database by default. sqlite only supports analytic functions as of version 3.25.0.  You must upgrade sqlite.  If you're in a Google Colab notebook, this should do it.  Be sure to restart your runtime.
If you're not using Colab, using a later version of Python would be the easiest way to go if that's an option.


text:
Q: Semi-transparent menu item on hover to background image is there any way to make menu item hover transparent to background image?
As you can see, image in background is set with background-size cover option and background can scale in different screen size.
HTML:

Menu 1

Menu 2

Menu 3

CSS:
div.header{
  background: url('http://de.fwsx.co/mbergs/images/home-header.jpg') no-repeat;
  background-size: cover;
  height: 400px;
}

p:first-child,
p:last-child {
  height: 50px;
}

div.menu-container {
  background: #fff;
}

div.menu-container ul li {
  display: inline-block;
  list-style: none;
}

div.menu-container ul li a {
  display: block;
  height: 50px;
  line-height: 50px;
  padding: 0 20px;
}

div.menu-container ul li a:hover {
  background: rgba(64,161,47, 0.6);
}

jsFiddle: https://jsfiddle.net/qwLp9f9y/1/
Edit: Full width menu container must stay solid white.
Thanks.

A: I'd recommend to switch to a table Layout to acheive this: https://jsfiddle.net/Lv0rkhun/1/
I can't think of a way doing it with ul/li Elements.

      Menu 1
      Menu 2
      Menu 3

A: I have removed the background from the container (only way to solve this in a cross browser way).
To be able to reproduce visually the white background on the container, I have added small shadows to the li's  (to fill the gap between one and the next) and a before pseudo element on the first one, and the last one, to cover the margins on both sides

div.header{
  background: url('http://de.fwsx.co/mbergs/images/home-header.jpg') no-repeat;
  background-size: cover;
  height: 400px;
}

p:first-child,
p:last-child {
  height: 50px;
}

div.menu-container ul li {
  display: inline-block;
  list-style: none;
  background: #fff;
  box-shadow: 5px 0px white;
  position: relative;
}

.menu-container li:first-child:before {
  content: "";
  position: absolute;
  width: 500px;
  height: 100%;
  top: 0px;
  right: 100%;
  background-color: white;
}
.menu-container li:last-child:before {
  content: "";
  position: absolute;
  width: 500px;
  height: 100%;
  top: 0px;
  left: 100%;
  background-color: white;
}
div.menu-container ul li a {
  display: block;
  height: 50px;
  line-height: 50px;
  padding: 0 20px;
}

div.menu-container li:hover {
  background: rgba(64,161,47, 0.4);
}

Menu 1

Menu 2

Menu 3


text:
Q: MS Access syntax error in FROM clause I have the following query and I have no idea why I am getting the error Syntax error in FROM clause.
SELECT *
FROM t_object
INNER JOIN
(
   SELECT *
   FROM t_objectproperties tag
   WHERE tag.Property = 'Location'
     AND tag.Value = 'Queens'
) AS location
   ON t_object.Object_ID = location.Object_ID
INNER JOIN
(
   SELECT *
   FROM t_objectproperties tag
   WHERE tag.Property = 'Room'
     AND tag.Value = 'King'
) AS type
   ON t_object.Object_ID = type.Object_ID

A: MS Access requires that you use parentheses around your multiple joins:
SELECT *
FROM (t_object
INNER JOIN
(
   SELECT *
   FROM t_objectproperties as tag
   WHERE tag.Property = 'Location'
     AND tag.Value = 'Queens'
) AS location
   ON t_object.Object_ID = location.Object_ID)
INNER JOIN
(
   SELECT *
   FROM t_objectproperties as tag
   WHERE tag.Property = 'Room'
     AND tag.Value = 'King'
) AS type
   ON t_object.Object_ID = type.Object_ID

This could also be rewritten as:
SELECT *
FROM (t_object as o
       INNER JOIN t_objectproperties as location
         ON o.Object_ID = location.Object_ID)
       INNER JOIN t_objectproperties as type
         ON o.Object_ID = type.Object_ID
WHERE location.Property = 'Location'
  AND location.Value = 'Queens'
  AND type.Property = 'Room'
  AND type.Value = 'King'


text:
Q: How does the compiler in Java decide on unreachable code? How does a compiler decide on with unreachable code?
consider these
public class Test15 {

    public static final boolean verdict = false;
    public static final int verdictInt = 2;

    public static void main(String[] args) throws IOException {

        // case1
        if (verdict) {
            System.out.println(1);
        } else {
            System.out.println(2);
        }// compiles

        //case 2
        int val = 5;
        switch (val) {
         case verdictInt:System.out.println(3);
                        break;
        }// compiles

        //case 3
        while (false) {

        }// does not compile

        //case 4
        return 6;
        return 7;
        //does not compile

    }
}

So when the compiler decides that code is unreachable.Is it because of (for a lack of a better term) hard code(like case 4).Because as per my knowledge, verdict,verdictInt also qualify as compile time constants and according too.
And as per my reading,being able to use the constant verdictInt as a switch case label indicates that it is a compile time constant.
Please let me know in case there are any basic flaws in my reasoning.

A: The Java Language Specification section on unreachable code is a good, but long read.  I'll condense it into what translates for your question.
Case 1:
verdict could be seen as a flag variable; it may or may not be used for debug purposes.  If it is, then breaking compilation would result in a major design goal miss. The specification explicitly calls this out:

The rationale for this differing treatment [with if as opposed to while] is to allow programmers to
  define "flag variables" such as:
static final boolean DEBUG = false;

and then write code such as:
if (DEBUG) { x=3; }

The idea is that it should be possible to change the value of DEBUG
  from false to true or from true to false and then compile the code
  correctly with no other changes to the program text.

Case 2:
Your switch statement can complete normally by the rules of the JLS:

A switch statement can complete normally iff at least one of the following is true:

*

*The switch block is empty or contains only switch labels.

*The last statement in the switch block can complete normally.

*There is at least one switch label after the last switch block statement group.

*The switch block does not contain a default label.

*There is a reachable break statement that exits the switch statement.

Your switch doesn't have a default label, so your switch can complete normally.  It just falls out of the switch.
Case 3:
This explicitly does not compile.  Case 1 called some attention to it, but here it's spelled out, emphasis mine:

A while statement can complete normally iff at least one of the
  following is true:

*

*The while statement is reachable and the condition expression is not    a constant expression (§15.28) with value true.

*There is a reachable break statement that exits the while statement.
The contained statement is reachable iff the while statement is reachable and the condition expression is not a constant expression
  whose value is false.

The condition expression is false, so you can't reach the contained statement, by definition.
Case 4:
return is a special case; it completes abruptly.  Once a statement completes abruptly, any statements after that are not reachable by definition.

A: In case 3, it knows it is not a loop because the value is always false.
In case 4, it knows that there have been an infinite loop before, so it says unreachable code.
But return 7; is unreachable also because there is return 6; before it that always run.
It is like doing :
printf("Hello");
return 0;
printf("Never reached code");

I don't know if this will give an unreachable error :
final int i = 5; float x = 0;
while(i<8) {
    x += 0.001f;
    // Do Nothing
}
printf("Hello World");


text:
Q: I am getting access denied to internal hard drive and failed to enumerate objects On Tuesday I noticed I was getting access denied to my data drive. I am running Windows 10. I have 3 other drives. The problem is only with this drive. I have gone through the properties and went into advanced security settings to change owner (as it had changed), and checked replace child object permission entries box. when I hit reply I still get an error, 'failed to enumerate objects in container. Access is denied. I then went to elevated CMD and tried:
takeown /F "full path of folder or drive" /A /R /D Y
and
icacls "full path of folder or drive" /setowner "Administrators" /T /C
I am logged in as an administrator. No matter what I read and try, I am still getting access denied to the hard drive. I did also delete the last several windows updates that were installed around that time. any advice would be helpful.


text:
Q: Bootstrap confidence intervals for betas in a linear mixed model I am trying to calculate bootstrap intervals for my beta coefficients in linear mixed effect models.
I used the lme()function from the nlme package. My model looks like this
baseline <- lme(rt ~ condition*congruent*type, random= ~1 | id, data= dat, method= "ML")

My fixed effects are all two-level factors.
I know how to bootstrap but I am unsure about the random effects structure. Can anyone give me an example with lme() or suggest any article/internet page on how to do it?
Thanks a lot!


text:
Q: Dynamically modifying the DOM in Angular I'm running Angular Version 6 -- I'm trying to perform functionality in Angular that is fairly trivial in vanilla JavaScript.
this.value is the value of a search from an input element, places is an array with city and state properties -- the goal is to highlight the text being searched on each result in a list of results.
Is there a way to perform this in Angular? -- Based on reading the ElementRef documentation, it seems like directly modifying the DOM in this way is not suggested.
HTML

JavaScript
const suggestions = document.querySelector('.suggestions');
const html = places.map(place => {
const regex = new RegExp(this.value, 'gi');
const cityName = place.city.replace(regex, `<span class="hl">${this.value}</span>`);
const stateName = place.state.replace(regex, `<span class="hl">${this.value}</span>`);
return `<li><span class="name">${cityName}, ${stateName}</span></li>`;
}).join('');

suggestions.innerHTML = html;

A: Solution:
using ngFor and binding [innerHTML]
HTML

JS
buildHTML(place) {
  const regex = new RegExp(this.value, 'gi');
  const cityName = place.city.replace(regex, `<span class="hl">${this.value}</span>`);
  const stateName = place.state.replace(regex, `<span class="hl">${this.value}</span>`);
  return `<li><span class="name">${cityName}, ${stateName}</span></li>`;
}


text:
Q: call API and then display data using Vue.js in the page I have my api and in my typescript file
const Book = {
   async getBookType(intID: string): Promise<Book[]> {
        // const intId = API.Product.getCurrentId();
        const intId = '';
        const response = await http.get('/myasset/booktypes', {
            params: {
            int_id: intID,
            },
        });
        const bookTypes = JSON.parse(JSON.stringify(response.data));
        return bookTypes;
   },
};

Now on my bookpage.vue,  I need to call api response and load data in my page.
Can you give example on how to display it using vue.js  ...
When i check the response body in postman i got this
"adventure": 1,
"biography": 2,
"drama": 1
"romance": 1

So i need to simple display them in the page.
Thanks in advance.

A: Try this way :

new Vue({
  el: '#app',
  data: {
    response: {
      data: {}
    }
  },
  mounted() {
    // You can get this data from an API, FOr the demo purpose I am just mocking this response.
    this.response.data = {
      "adventure": 1,
      "biography": 2,
      "drama": 1,
      "romance": 1
    }
  }
})

      {{ item }} - {{ response.data[item] }}


text:
Q: Is the sentence "How much were your shares diluted?" correct? Is the sentence "How much were your shares diluted?" correct?
Should it be "How much were your shares diluted to"?

A: They're both correct. And so is

How much were your shares diluted by?

Incidentally, the answer to

How much were your shares diluted?

would be My shares were diluted to 40% of their original value. or My shares were diluted by 60%. Simply giving a quantity would be ambiguous.
In contrast, the answers to

How much were your shares diluted by?

and

How much were your shares diluted to?

could be answered with a quantity (like 60%, for example) without any ambiguity.


text:
Q: jQuery Slidertron Overflow I am using the Slidertron lib for a slideshow in one of my website. However, when I look at it depending of some resolutions, I can see the next slide in the current one, which should not happen.
CSS:
#slider {margin-left:auto;margin-right:auto;width:100%;position:relative;}
#slider .viewer {width:75%;height:400px;margin:0 auto;overflow:hidden;border:1px solid red;}
#slider .viewer .reel {display:none;height: 375px;}
#slider .slide {border:1px solid blue;}
#slider .viewer .reel .slide {position: relative;width:1100px;height:375px;}

HTML:

                1
                2
                3
                4
                5

Slide 1 text.

Slide 2 text.

jQuery (kind of irrelevant since this is working well):
        $(function () {
        $('#slider').slidertron({
            viewerSelector: '.viewer',
            reelSelector: '.viewer .reel',
            slidesSelector: '.viewer .reel .slide',
            indicatorSelector: '.indicator span',
            speed: 'slow',
            navPreviousSelector: '.previous',
            navNextSelector: '.next',
            advanceDelay: 40000
        });
    });

FYI, I added the two border just to see the delimitations of my divs.

A: You have a 25px difference between .viewer & .reel in your CSS!
For me, the best way jquery.slidertron works is when i strictly telling him image sizes with css.
/*slider*/
#slider {
    margin: 0 auto;
    position: relative;
    width: 960px;
    height: 300px;
}
#slider .viewer {

    width: 960px;
    height: 300px;
    overflow: hidden;
}
#slider .viewer .reel {

    display: none;
    width: 960px;
    height: 300px;
}
#slider .viewer .reel .slide {

    position: relative;
    width: 960px;
    height: 300px;
}
/*slider*/


text:
Q: How to get image saved into session variable PHP FILE 1:
$_SESSION['imguserF'] =  $_FILES['imguser'];

FILE 2:

Photo:
<input id=\"imgrace\" type=\"file\" name=\"imguser\" />

When I create a session variable, file 2 opens. I want that when file2 be open, the image saved into session variable be selected into the input.
How can I get that value and insert it into the input?

A: I will try to break it down as much as i can:
First we have your form:
Php can not read elements like javascript or css can so you need to include what you want inside form. In form you must define the method you are going to use (post,get) and the action which is your php file. I provide you a sample form to help you understand
<form method="post" action="test2.php">

Photo:
<input id="imgrace" type="file" name="imguser"/>
    <input type="submit" id="imguser" name="imguser2"/>
</form>

After that we move to php section:
In php file i need to receive what i am sending. The method that i set in html must be the one that receives in php and of course the same file name. I present you a sample of php file:
$data=$_POST['imguser'];
echo "";

What this 2 files are doing is simple. I upload an image from the html page, i capture it and display it in php page. My variable $data has all the info i need (the image name) to display the image and except of display i can simple store it into a DB. Also you need to submit your form. Php is not real-time like ajax calls or javascript functions so needs to "refresh".


text:
Q: Message Queues and Multiple Subscribers My team is discussing using RabbitMQ for microservice to microservice communication (among other things).  We are also supporting a SAP backend that will be pushing data to us in a method undecided at this time (likely through Boomi or Idocs).  We know next to nothing about RabbitMQ, except the general concepts of a message queue and what we've been able to determine from a high level look at their documentation.  The general pattern seems to be a consumer is subscribed to one or more queues, and Rabbit pushes to those queues based on rules that are highly configurable, but messages on an individual queue only get read completely "once" before being removed (this is a generalization, as there are a lot of options around confirmations and stuff).
This is a very simple image of a setup where each consumer only cares about distinct topics for them:

Whereas this is a more complex one, where a single topic gets split accross multiple queues.  However, when we configure the queues, we need to know where to send the topics, and we still need one queue per consumer of that message

What I am envisioning instead is one huge message pipeline that all messages go through, with individual subscribers reading the messages relevant to them.  Something closer to this concept:

My goal for this is to keep everything as loosely coupled as possible.  With designs 1 or 2, we have to update the queueing system or exchange every time a new consumer gets added.  With the third design, the queueing system is agnostic to what is consuming it, and instead just knows it needs to send messages.  The consumers can then just read off the queue, grabbing copies of relevant messages to them.
Does this design make sense?  We can't be the first ones to desire a system like this, as it should be a pretty common need (changes occur in a system, and multiple consumers need to act on them).

A: In the third diagram you are proposing, if Consumer 1 gets to the message first (and ACKS it), Consumers 2 and 3 will never receive it. If that is what you want then fine. If you want each Consumer to receive the message, then you need separate queue for each consumer.
The 3rd diagram is pretty much the scenario when you have multiple servers with the same consumer deployed. If Consumer 1 is deployed on 3 servers you don't care which servers gets to the message first.
To answer your concern, in diagram 1 and 2, your queuing system doesn't care about what queues are created. Or rather, your producer doesn't care because it's the consumer who should be creating and binding queues not the producer. The producer pushes a message with a routing key to an exchange. That's where its job ends. Then when you add a new consumer, it should create the queue and bind to the exchange with the routing key.

A: Perhaps, you can use something like Apache NIFI for message routing/transformation and kafka as a message broker. Both open source options.

*

*Producers publish message to a Topic as per a normalized schema model > > >

*Apache NIFI collects the message, does any transformation as per consumer needs from common schema model to consumer model (if desired) and routes it to specific topic for consumer > > >

*Consumers (many-many) can be subscribed to different topics and consume those messages.
A few highlights, Topics in Kafka are always multi-subscriber; that is, a topic can have zero, one, or many consumers that subscribe to the data written to it.
Queues by nature are not multi-subscriber.
Topics on Kafka, also provide ordering and at least once delivered guarantees to consumers.
https://kafka.apache.org/intro#kafka_mq

A: Typically the producer sticks the message onto a single queue that all consumers read from, with locking to ensure only one gets the message.
However, the 3rd scenario works brilliantly if all consumers receive the same message and decide whether they will process it or not. I've used that approach many times with great success, but you must have a way of differentiating which consumer will process the message and if you cannot, then all of them will. This may not be such a problem, for example a UI can use such a system and a message will be passed to all consumers (eg UI elements) that pass the criteria (eg they are under the mouse cursor when the event is raised)
So ultimately the answer here is "it depends" on what your messages are and how your consumers process them.
For further reading I'd look at the zeromq guide, they go into some detail about lots of different message queuing systems and the benefits/disadvantages of them.


text:
Q: Display companyname and logo in dropdownlist I want to display company name and logo in dropdownlist.I have fetch all the company name in dropdownlist but i am not able to add logo with name.
I have xml file where company name and images are specified.
Structure of xml file:
 <ente>
    <nazione>ALBANIA</nazione>
    <name>Tirana</name>
    tvsh-albania.png
    <descri>TVSH - Rruga Ismail Quemali 11, Tirana</descri>
    <latitudine>41.321102</latitudine>
    <longitudine>19.823112</longitudine>
    <zoom>-4</zoom>
  </ente>

I have all images in image folder also.
I have use this code:
 Protected Sub BindDataToGridviewDropdownlist()
        Dim xmlreader As New XmlTextReader(Server.MapPath("XMLFILE.xml"))
        Dim ds As New DataSet()
        ds.ReadXml(xmlreader)
        xmlreader.Close()

            If ds.Tables.Count <> 0 Then

                ddlDetails.DataSource = ds

            ddlDetails.DataTextField = "nome"
            ddlDetails.DataValueField = "nome"
            ddlDetails.DataBind()
            End If
    End Sub

What i need to do so i can also display image with company name.

A: Dropdown list out of the box does not support adding images. Look for 3rd party components.

A: I think it's quite hard to achieve in html and .net but it should be easier with a jQuery plugin, for example this one

A: Try this using jQuery
http://www.htmldrive.net/items/show/749/Image-Select-Elements-with-jQuery-and-CSS3.html
Or try this
http://designwithpc.com/Plugins/ddSlick
At example 2.. the HTML need to look like this
 <select id="demo-htmlselect">
        <option value="0" data-imagesrc="http://dl.dropbox.com/u/40036711/Images/facebook-icon-32.png"
            data-description="Description with Facebook">Facebook</option>
        <option value="1" data-imagesrc="http://dl.dropbox.com/u/40036711/Images/twitter-icon-32.png"
            data-description="Description with Twitter">Twitter</option>
        <option value="2" selected="selected" data-imagesrc="http://dl.dropbox.com/u/40036711/Images/linkedin-icon-32.png"
            data-description="Description with LinkedIn">LinkedIn</option>
        <option value="3" data-imagesrc="http://dl.dropbox.com/u/40036711/Images/foursquare-icon-32.png"
            data-description="Description with Foursquare">Foursquare</option>
    </select>

You can create that HTML from Code Behind by binding to a repeater
<asp:Repeater id="rp" runat="server">
    <HeaderTemplate>
        <select id="demo-htmlselect">
    </HeaderTemplate>

    <ItemTemplate>
        <option value='<%#Container.DataItem("name")%>' data-imagesrc='<%#Container.DataItem("img")%>'
            data-description='<%#Container.DataItem("descri")%>'>
                <%#Container.DataItem("name")%>
        </option>
    </ItemTemplate>

    <FooterTemplate>
    </select>
    </FooterTemplate>
</asp:Repeater>


text:
Q: Damned if you do, damned if you don't: Rust compiler complains regardless whether there's a lifetime parameter or not I am trying to decide whether I should add a lifetime parameter to my impls, but it seems I'm in a "damned if you do, damned if you don't" situation because the compiler complains regardless whether there's a lifetime parameter or not.
pub struct TurtleRef<'a> {
    t: &'a BorrowedTurtle<'a>,
}

impl TurtleRef<'_> {
    pub fn borrowed_turtle(&self) -> BorrowedTurtle {
        *self.t
    }

    pub fn new(r: Turtle) -> TurtleRef {
        TurtleRef{t: &BorrowedTurtle{ t:r}}
    }
}

pub struct BorrowedTurtle<'a> {
    t: Turtle<'a>,
}

impl<'a> std::ops::Deref for BorrowedTurtle<'_> {
    type Target = Turtle<'a>;

    fn deref(&self) -> &Self::Target {
        &self.t
    }
}

impl<'a> std::ops::DerefMut for BorrowedTurtle<'_> {
    type Target = Turtle<'a>;
    fn deref_mut(&mut self) -> &mut Self::Target {
        &self.t
    }
}

pub struct Turtle<'a> {
    children: Vec<Turtle<'a>>,
}

Turtle has more fields, but I removed them for simplicity. You can see the code snippet here. The code throws the error
error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
  --> src/campus.rs:54:6
   |
54 | impl<'a> std::ops::Deref for BorrowedTurtle<'_> {
   |      ^^ unconstrained lifetime parameter

No problem, I'll just remove the parameter since it's causing such a fuss. But after removing it, I get a whole bunch of new errors:

error[E0261]: use of undeclared lifetime name `'a`
  --> src/campus.rs:55:26
   |
55 |     type Target = Turtle<'a>;
   |                          ^^ undeclared lifetime
   |
help: consider introducing lifetime `'a` here
   |
54 | impl<'a> std::ops::Deref for BorrowedTurtle<'_> {
   |     ^^^^
help: consider introducing lifetime `'a` here
   |
55 |     type Target<'a> = Turtle<'a>;
   |                ^^^^

Whatever you say, I'll just go ahead and add that parameter to target. But now I get yet another error:
error[E0658]: generic associated types are unstable
  --> src/campus.rs:55:5
   |
55 |     type Target<'a> = Turtle<'a>;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information

So no matter what I do, it seems I run into a major error. How do I stop these errors without starting over from scratch? I'd like to keep the impls, structs, and deref functions, so the only thing I should change is their implementation.
On another note, I get the error
error[E0437]: type `Target` is not a member of trait `std::ops::DerefMut`
  --> src/campus.rs:64:5
   |
64 |     type Target = Turtle<'a>;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `std::ops::DerefMut`

because Turtle doesn't implement DerefMut, and in fact Turtle should not implement DerefMut. Is there a slight modification of Turtle which results in something that already implements DerefMut?

A: There are a couple of issues here. Firstly:
error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
  --> src/campus.rs:54:6
   |
54 | impl<'a> std::ops::Deref for BorrowedTurtle<'_> {
   |      ^^ unconstrained lifetime parameter

You either use an anonymous lifetime or you don't. Here, you declare the 'a, so use it:
impl<'a> std::ops::Deref for BorrowedTurtle<'a> {

To use an elided lifetime, you don't have to declare it:
impl std::ops::Deref for BorrowedTurtle<'_> {

However, here you have to refer to the lifetime in Target, so you cannot elide it.
Second:
error[E0437]: type `Target` is not a member of trait `std::ops::DerefMut`
  --> src/lib.rs:28:5
   |
28 |     type Target = Turtle<'a>;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `std::ops::DerefMut`

DerefMut does not have a Target member because it reuses that from its supertrait, Deref. This is to ensure that items must Deref and DerefMut to the same Target:
impl<'a> std::ops::Deref for BorrowedTurtle<'a> {
    type Target = Turtle<'a>;

    fn deref(&self) -> &Self::Target {
        &self.t
    }
}

impl std::ops::DerefMut for BorrowedTurtle<'_> {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.t
    }
}

Lastly, you will now get errors that 'a is not used:
error[E0392]: parameter `'a` is never used
  --> src/lib.rs:15:27
   |
15 | pub struct BorrowedTurtle<'a> {
   |                           ^^ unused parameter
   |
   = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData`

This is because you have a couple of recursive types where the lifetime isn't actually being used:
// 'a isn't actually used for anything

pub struct Turtle<'a> {
    children: Vec<Turtle<'a>>,
}

pub struct BorrowedTurtle<'a> {
    t: Turtle<'a>,
}

I will assume that for the purpose of this answer you omitted other relevant fields that use the 'a, so that's all!

A: Since DerefMut inherit from Deref, you don't have to specify Target, pub trait DerefMut: Deref { use the Target define in Deref implementation.
Deref trait is very special, it can't really be use by "normal" user, almost only std can implement it for new type.
This is because it's borrow self and return a reference of "something else" problem is this something else can't be temporary, std use it control over rust ecosystem to be able to do that for example Vec implementation:
impl<T, A: Allocator> ops::DerefMut for Vec<T, A> {
    fn deref_mut(&mut self) -> &mut [T] {
        unsafe { slice::from_raw_parts_mut(self.as_mut_ptr(), self.len) }
    }
}

as you can see slice is a "fat pointer" so it doesn't need more than a reference to be valid, you can almost only implement Deref to return Target for type like slice.
Another example is for PathBuf:
impl ops::Deref for PathBuf {
    type Target = Path;
    #[inline]
    fn deref(&self) -> &Path {
        Path::new(&self.inner)
    }
}

Here it's even more clear Path::new create a fat pointer. So, Target can't be something else that something that can't be self contained or already exist in your Self.
As the documentation said:

Because of this, Deref should only be implemented for smart pointers to avoid confusion.

I think what you really want is to implement Borrow. All that said... here a working code:
impl<'a> std::ops::Deref for BorrowedTurtle<'a> {
    type Target = Turtle<'a>;

    fn deref(&self) -> &Self::Target {
        &self.t
    }
}

impl std::ops::DerefMut for BorrowedTurtle<'_> {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.t
    }
}

Do as you wish.


text:
Q: error in loading contourf I recently encountered this error when updating to ubuntu 14.04 64bit. I cannot understand what is going on. Suspecting a PATH/LIBRARY etc. error. Similar happens when trying to load programs that I used with MCR. What could be the problem? These errors are common, but all of them at the same time, it is hard to find an answer as well. Thanks in advance.
when i use

Z = peaks(20); >> contourf(Z,10)

I get these:
No appropriate method, property, or field initialized for class specgraph.contourgroup.

Error in specgraph.contourgroup/schema>LdoUpdateColorAction (line 209) if h.initialized

Warning: Error occurred while evaluating listener callback. > In specgraph.contourgroup.contourgroup at 19 In contourf at 79 No appropriate method, property, or field initialized for class specgraph.contourgroup.

Error in specgraph.contourgroup/schema>LdoUpdateColorAction (line 209) if h.initialized

Warning: Error occurred while evaluating listener callback. > In specgraph.contourgroup.contourgroup at 19 In contourf at 79 No appropriate method, property, or field initialized for class specgraph.contourgroup.

Error in specgraph.contourgroup/schema>LdoMarkDirtyAction (line 244) if h.initialized

Warning: Error occurred while evaluating listener callback. > In specgraph.contourgroup.contourgroup at 19 In contourf at 79 No appropriate method, property, or field initialized for class specgraph.contourgroup.

Error in specgraph.contourgroup/schema>LdoModeSwitchAction (line 195) if strcmp(get(h,modeprop),'auto') && h.initialized

Warning: Error occurred while evaluating listener callback. > In specgraph.contourgroup.contourgroup at 19 In contourf at 79 No appropriate method, property, or field initialized for class specgraph.contourgroup.

Error in specgraph.contourgroup/schema>LdoModeSwitchAction (line 195) if strcmp(get(h,modeprop),'auto') && h.initialized

Warning: Error occurred while evaluating listener callback. > In specgraph.contourgroup.contourgroup at 19 In contourf at 79 No appropriate method, property, or field initialized for class specgraph.contourgroup.

Error in specgraph.contourgroup/schema>LdoUpdateColorAction (line 209) if h.initialized

Warning: Error occurred while evaluating listener callback. > In specgraph.contourgroup.contourgroup at 19 In contourf at 79 No appropriate method, property, or field initialized for class specgraph.contourgroup.

Error in specgraph.contourgroup/schema>LdoUpdateChildrenAction (line 201) if h.initialized

Warning: Error occurred while evaluating listener callback. > In specgraph.contourgroup.contourgroup at 19 In contourf at 79 No appropriate method, property, or field initialized for class specgraph.contourgroup.

Error in specgraph.contourgroup/schema>LdoModeSwitchAction (line 195) if strcmp(get(h,modeprop),'auto') && h.initialized

Warning: Error occurred while evaluating listener callback. > In specgraph.contourgroup.contourgroup at 19 In contourf at 79 No appropriate method, property, or field initialized for class specgraph.contourgroup.

Error in specgraph.contourgroup/schema>LdoModeSwitchAction (line 195) if strcmp(get(h,modeprop),'auto') && h.initialized

Warning: Error occurred while evaluating listener callback. > In specgraph.contourgroup.contourgroup at 19 In contourf at 79 No appropriate method, property, or field initialized for class specgraph.contourgroup.

Error in specgraph.contourgroup/schema>LdoModeSwitchAction (line 195) if strcmp(get(h,modeprop),'auto') && h.initialized

Warning: Error occurred while evaluating listener callback. > In specgraph.contourgroup.contourgroup at 19 In contourf at 79 No appropriate method, property, or field initialized for class specgraph.contourgroup.

Error in specgraph.contourgroup/schema>LdoModeSwitchAction (line 195) if strcmp(get(h,modeprop),'auto') && h.initialized

Warning: Error occurred while evaluating listener callback. > In specgraph.contourgroup.contourgroup at 19 In contourf at 79 No public field initialized exists for class specgraph.contourgroup.

Error in specgraph.contourgroup (line 20) h.initialized = 1;

Error in contourf (line 79) h = specgraph.contourgroup('Parent', parax, 'Fill', 'on', ...

A: Try restoring MATLAB to its default search path by using:
>>restoredefaultpath;
>>rehash toolboxcache;

Try using contourf now. If it works, save the path settings, using:
>>savepath;

You will need to add your custom folders back to the MATLAB path yourself as this will restore MATLAB to its default path settings.


text:
Q: Why don't mathematicians work on 'difference-asymptotic' of prime counting function? Mathematicians back in 19th century tried to find a function that satisfies $$\lim_{x\to\infty}\frac{\pi(x)}{f(x)}=1$$ and $f(x)$ turns out to be $\frac{x}{\ln x}$, or any function asymptotic to it(like $\text{Li}(x)$). They proved it rigorously and now it is known as the Prime Number Theorem.
However, I don't see much work on finding a function that satisfies $$\lim_{x\to\infty}(\pi(x)-g(x))=0$$ As far as I know, $$\lim_{x\to\infty}(\pi(x)-\frac{x}{\ln x})=\infty$$ so $\frac{x}{\ln x}$ cannot be a candidate of $g(x)$.
Moreover, if such function is discovered, it will be very useful in the sense that estimation of number of primes below some large $N$ can become more and more precise as $N$ grows. This would surely be more powerful than PNT.
Why only little work has done by mathematicians to figure out $g(x)$?

A: In brief, because what you're suggesting is overwhelmingly more powerful than the multiplicative difference, to the point where none of the known techniques can even come close. It's not that this isn't studied; indeed, 'additive differences' on the PNT and related functions - but as noted in a comment, they're usually only as good as being able to say $\pi(x)=f(x)+O(x^\alpha)$ for some $\alpha$ (typically with $\alpha\gt 1/2$). Note that these sorts of asymptotics imply the 'multiplicative' equalities you mention (since then $\pi(x)/f(x)=1+O^*(x^{\alpha-1})$), but the additive results you're requesting are even stronger than reducing $\alpha$ to zero.

A: The question you are suggesting, in its exact form, would basically be a lost fight. Should you be able to find such function $g(x)$, this would mean
$$\forall \epsilon > 0\ \exists x_0 \in \mathbb{N}\ \forall x \in \mathbb{N}, x > x_0: |\pi(x) - g(x)| < \epsilon.$$
If you plug in $\epsilon = 1/2$, this tells you that from some $x_0$ on the function value $g(x)$ differs from the $x$-th prime by less than a half, in other words, that you could just round it to the nearest integer to get the $x$-th prime. I doubt anyone nowadays hopes that a closed form like that could be found.


text:
Q: Behaviour Difference For Arrow-Functions vs Functions In Javascript I wanted to understand the behavior of a normal function vs arrow functions.
Arrow Function:

function arrowFunc() {
  return () => arguments
}

console.log(arrowFunc(1, 2, 3)(1))

Normal Function

function normalFunc() {
  return function() {
    return arguments
  }
}

console.log(normalFunc(1, 2, 3)(1))

Both the results are expected to be same, but looks like arrowFunc defined above considers the first arg list, where as the normalFunc considers the second set of arg list.
Also tried babel-compilation to understand the difference, but looks like the behavior is different as shown below:
Babel Output:

"use strict";

function arrowFunc() {
  var _arguments = arguments;

  return function() {
    return _arguments;
  };
}

console.log(arrowFunc(1, 2, 3)(1));

function normalFunc() {
  return function() {
    return arguments;
  };
}

console.log(normalFunc(1, 2, 3)(1));

A:
Both the results are expected to be same

No, they're not.

From the first line of the MDN page on arrow functions (emphasis mine):

An arrow function expression has a shorter syntax than a function
  expression and does not have its own this, arguments, super, or
  new.target.

And further down the same page:

Arrow functions do not have their own arguments object. Thus, in
  this example, arguments is simply a reference to the arguments of the
  enclosing scope [...]

And in the ECMAScript specification:

NOTE: Arrow functions never have an arguments objects. (sic)


text:
Q: Python - missing positional argument I am trying to learn a bit about threading by building some code  that will maintain a list and eventually send values from that list to a to-be-created function.    When I call QueryReport.add I get the error TypeError: add() missing 1 required positional argument: 'user'.  I am trying to pass in report and user list values.  It is my belief the add method needs self but that self for some reason seems to be throwing off the call I made because now I dont have the right number of positional aruguments.  In many other code examples I see methods defined with self and two other values with the idea that when the mthod is called two values are passed.  Any thoughts on what I am doing wrong?  Since I cant get past this syntax error, is there anything else as blantly wrong?
from threading import *

class QueueReport(Thread):
  def __init__(self):
    Thread.__init__(self)
    self.reports_to_call = []

  def add(self, report, user):
    self.reports_to_call.append([report, user])
    print("Added Value")

  def run(self):
    print("Running")
    #print(reports_to_call)
    #will loop and send values from this list to another function

if __name__ == '__main__':
  t1 = QueueReport()
  t1.run()

  QueueReport.add("mainreport", "user")

A: You are attempting to add to the class QueueReport instead of the instance of the class t1. When you call the function on the class, there is no self so it treats "mainreport" as self and "user" as report.
What you want to do is t1.add("mainreport", "user").
The wrinkle is, if run is an infinite loop it will block execution and t1.add will never happen.
What you can do is create a separate thread for t1.run.
from threading import Thread
thread = Thread(target=t1.run)
thread.start()
t1.add("mainreport", "user")

Edit: silly me, I did not see that you were already using threading.

A: You are using the Class method instead of using the instantiation of the class.
Because of that, self is not given to the method, hence missing a parameter.
Try doing t1.add("mainreport", "user")


text:
Q: Proving $\int \int _Rf\left(\sqrt{\ \frac{x^2}{3}+\frac{y^2}{5}}\right)dA=2\pi \sqrt{\ 15}\int _0^1\ f\left(p\right)pdp$ Where where f is a continous function on $[0,1]$ and The region R is bounded by the ellipse $5x^2 + 3y^2 = 15$
I'm confused how to approach this, I just recently started with double integration and i have only completed the topic Change of order of integration and now i moved onto Change of variable.
So far i am familiar with question in change of variable where the transformation of the plane is given clearly for example $$T:ℝ^2\rightarrow \ ℝ^2,\ T\left(x,y\right)=\left(u+av,v\right)$$
In such cases like this transforming from xy-plane to uv-plane is fairly easy for me as the instructions are given clearly, but the question at hand is a bit confusing since its a little unclear to me. The only progress i made is draw the region R which is attached below:

Any help to walk me through the derivation is greatly appreciated

A: I think i figured out how to solve this, I'm simply posting the answer in case someone else is also stuck in the same question:
First we can use polar coordinate system to solve this, our region R is enclosed in the ellipse given by $5x^2 +3y^2 =15$ rewriting it as $\frac{x^2}{3}+\frac{y^2}{5}=1$, take the substitution as : $$x=r\sqrt{\ 3}\cos \theta, y= r\sqrt{\ 5}\sin \theta  $$ putting it into the ellipse equation we get: $r=1$ and taking the Jacabian we get
$J\left(r,\theta \right) = \left|\begin{array} {}
\frac {dx}{dr} & \frac {dx}{d\theta}\\
\frac {dy}{dr} & \frac {dy}{d\theta}\end{array}\right|=r\sqrt{\ 15}$
$\int _0^1\ \int _0^{2\pi}f\left(\sqrt{\ r^2}\ \right)r\sqrt{\ 15}d\theta dr$
$2\pi \sqrt{\ 15}\int _0^1\ f\left(\sqrt{\ r^2}\ \right)rd\theta dr$


text:
Q: Official guidelines for using functions newly added to base R I am writing a package that performs a statistical analysis while handling missing values. I am using the wonderful, life-changing function anyNA which was added sometime after 3.0 (commit). Another recently added function that people might want to use is OlsonNames.
So as I am using this function, my package won't work on older versions of R. I see four options for dealing with this.

*

*Make the whole package depend on R >= 3.1 in DESCRIPTION.

*Redefine the function in my source.

*Redefine the function if the user is using <3.1 and don't define it if they are using >= 3.1 or make the function check the version each time e.g.
anyNA <- function(x)
  if(as.numeric(R.Version()$minor) > 3.1){
    return(anyNA(x)
  } else {
    return(any(is.NA(x))
  }
}

or
if(as.numeric(R.Version()$minor) > 3.1){
  anyNA <- base::anyNA
} else {
  anyNA <- function(x) any(is.na(x))
}

I'm not even sure this second one would work in package source code.

*Rewrite my code using any(is.na(x)).
My concrete question is is there an official CRAN preference for one of these?
Failing that, are there good reasons to use one over the others? To my eyes they all have failings. 1) It seems unnecessary to require users have R >= 3.1 for the sake of a small function. 2) If I redefine the function, any improvements made to the function in R base won't get used in my package. 3) This mostly seems messy. But also, if the base R version of the function changes I might end up with hard to fix bugs that only occur in certain R versions. 4) Code readability is reduced.


text:
Q: Convert MySQL query in to Entity Framework query syntax Please can somebody help me convert this MySQL query in to Entity Framework?
Im using that in an ASP .NET project but I only know how to do basic queries in Entity Framework. This seems way too complicated and I cant find a working solution since many hours now...
 $rs = mysql_query("SELECT barcode,latitude,longitude,date_time,location_name
                    FROM sDetails
                    JOIN users on (users.id=sDetails.UserId)
                    WHERE  (latitude and longitude is not null)
                       and (latitude <> 100000 and longitude <> 100000)
               and id='$UserId'
            ORDER BY date_time desc");

A: Assuming you have generated an Entity Framework model from the database you should be able to do something like (c# example):
 var q = context.Details.Where( d => d.UserId = "$UserID" ).
             Where( d => d.latitude.HasValue && d.latitude != 100000 && .. etc ).
             OrderByDescending( d => d.date_time ).
             Select( d => new {d.barcode, d.latitude, d.longitude, etc ... };

I'm not sure why you have a join since you're not selecting anything from the users tables.

A: Thanks @Phil
the code you gave above, seems to work mostly, but it still shows an error at
var q = context.ScanDetails.Where

Error 3: 'System.Web.HttpContext' does not contain a definition for
  'ScanDetails' and no extension method 'ScanDetails' accepting a first
  argument of type 'System.Web.HttpContext' could be found (are you
  missing a using directive or an assembly reference?)

this is the code I have so far:
public class read : IHttpHandler
{
    sqlEntities _db = new sqlEntities();

    public bool IsReusable { get { return true; } }

    public void ProcessRequest(HttpContext context)
    {
        //Write out the JSON you want to return.

       var q = context.ScanDetails.Where( d => d.UserId = "1" ).
         Where( d => d.latitude.HasValue && d.latitude != 100000  ).
         OrderByDescending( d => d.date_time ).
         Select( d => new {d.barcode, d.latitude, d.longitude };

           // stuff to do here

    }

    public IQueryable<ScanDetail> scanData { get; set; }
}


text:
Q: Running unit tests with Nose inside a Python environment such as Autodesk Maya? I'd like to start creating unit tests for my Maya scripts.  These scripts must be run inside the Maya environment and rely on the maya.cmds module namespace.
How can I run Nose tests from inside a running environment such as Maya?

A: Use the mayapy executable included in your maya install instead of the standard python executable.
In order for this work you'll need to run nose programmatically.  Create a python file called runtests.py and put it next to your test files.  In it, include the following code:
import os
os.environ['PYTHONPATH'] = '/path/to/site-packages'

import nose
nose.run()

Since mayapy loads its own pythonpath, it doesn't know about the site-packages directory where nose is.  os.environ is used to set this manually inside the script.  Optionally you can set this as a system environment variable as well.
From the command line use the mayapy application to run the runtests.py script:

/path/to/mayapy.exe runtests.py

You may need to import the maya.standalone depending on what your tests do.
import maya.standalone
maya.standalone.initialize(name='python')


text:
Q: MySQL PID changes MySQL server is running for 95days but the mysqld pid is changed few times.
Why mysqld changes its pid, any ideas ? How can I know that the mysqld pid has changed and what is the cause behind the change of the pid ?
Regards
Supratik

A: My guess is that the server restarts itself every now and then to avoid resource leaks (memory, connections). Many big sites ran into trouble because of that in the past (server would run out of connections and not being able to answer any requests anymore), so that probably made it into the install scripts.
If you want to find out exactly, I suggest to check the crontab of root or the user the MySQL is running under.

A: Check if the mysql log is being rotated. The server may have been restart during log file rotate.

A: If you want to find out what the current MySQL pid is you can find it in the file /var/run/mysqld/mysqld.pid (Thats in Ubuntu could be differnt in other distros).


text:
Q: Out Of Memory Exception - Loading Datatable I am trying to create a datatable and load a single row in to the datatable. I am using this datatable as table type parameter. But this method is enclosed in a ParallelProcessor. Some records are being updated but for some I get the below Out of memory exception.
ParallelProcessor.EnqueueAsync(() =>
{
public DataTable Getrecords(List<testData> testData)
        {
            DataTable table = new DataTable();
            table.Columns.Add("ID", typeof(int));
            var data = testData.Select(x => x.ID);

            foreach (var item in data)
            {
                DataRow dr = table.NewRow();
                dr["ID"] = item;
                table.Rows.Add(dr);
            }
            return table;
        }
});
ParallelProcessor.WaitForQueueCompletion();

Below is the error which I get for some records

System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.Data.RBTree1.TreePage..ctor(Int32 size) at System.Data.RBTree1.AllocPage(Int32 size)
at System.Data.RBTree`1.GetNewNode(K key)
at System.Data.DataTable.SetNewRecordWorker(DataRow row, Int32 proposedRecord, DataRowAction action, Boolean isInMerge, Boolean suppressEnsurePropertyChanged, Int32 position, Boolean fireEvent, Exception& deferredException)
at System.Data.DataTable.InsertRow(DataRow row, Int64 proposedID, Int32 pos, Boolean fireEvent)

It is perfectly working on some environments.


text:
Q: Remove excess padding after transformY on predecessor's ::after (Wow, that was a lousy title!)
I created a little quarter-circle to display after a div. I then used transformY to move it back up the div so that some content overlaps, which is the user's design requirement.
However, doing so leaves some excess space at the bottom of the div... the div retains the full height after the transform. I'd like to reduce that height.
I'm working in a page builder (ClickFunnels). Here's the link: https://www.goupperpeninsula.com/get-your-arts-on
Here's the CSS:
#section-1852710000::after,
#section-1852710000::before {
    content: '';
    position: relative;
    display: block;
    background: #ffe121;
    width: 285px;
    height: 285px;
}

#section-1852710000::after {
    border-top-right-radius: 285px;
    -webkit-transform: translateY(-50%);
    -ms-transform: translateY(-50%);
    transform: translateY(-50%);
}

Here's the space I'd like to eliminate:

I feel like I'm missing something obvious, I'm just not quite sure what it is!

A: This is expected. A transform is purely visual and does not affect layout. I'd try negative margin instead.
Here's a demo of the different behaviours I keep around.

* {
  box-sizing: border-box;
}

h3 {
  text-align: center;
}

.page {
  margin: 0 auto;
  text-align: center;
}

.wrapper {
  border: 5px solid black;
  margin: 5px;
  display: inline-block;
  background: lightblue;
  vertical-align: top;
}

.box {
  width: 100px;
  height: 350px;
  background: lightgrey;
  border: 1px solid grey;
  padding: 10px;
  text-align: center;
}

.position {
  position: relative;
  top: -25px;
}

.margin {
  margin-top: -25px;
}

.transform {
  transform: translateY(-25px);
}

DEMONSTRATING THE DIFFERENCE BETWEEN RELATIVE POSITIONING AND POSITIVE/NEGATIVE MARGINS AND TRANSFORMS

This box is the specimen for comparison purposes.

It is a grey box inside a blue box with a black border.

This grey box is moved using relative positioning.

The page remembers where it was and allocates that space as though the element was still there.

This grey box is moved using negative margin.

See how the wrapper div has 'shrunk'?

      ↓ ↓

This grey box is moved using a transform.

The page remembers where it was and allocates that space as though the element was still there.