text:
Q: activemq constantly retrying error messages and not picking up new messages I have an activemq instance set up with tomcat for background message processing. It is set up to retry failed messages every 10 minutes for a retry period.
Now some dirty data has entered the system because of which the messages are failing. This is ok and can be fixed in the future. However, the problem is that none of the new correct incoming messages are getting processed and the error messages are constantly getting retried.
Any tips on what might be the issue, or how the priority is set? I haven't controlled the priority of the messages manually.
Thanks for your help.
-Pulkit
EDIT : I was able to solve the problem. The issue was that by the time all the dirty messages were handled, it was time for them to be retried. Thus none of the new messages were being consumed by the queue.
A dirty message was basically a message that was throwing an exception out due to some dirty data in the system. the redelivery settings was to do redeliveries every 10 mins for 1 day.
    maximumRedeliveries=144
    redeliveryDelayInMillis=600000
    acknowledge.mode=transacted

A: ActiveMQ determines redelivery for a consumer based on the configuration of the RedeliveryPolicy that's assigned the ActiveMQConnectionFactory.  Local redelivery halts new message dispatch until the rollbed back transaction messages are successfully redelivered so if you have a message that's causing you some sort of error such that you are throwing an exception or rolling back the transaction then it will get redelivered up to the max re-deliveries setting in the policy.  Since your question doesn't provide much information on your setup and what you consider an error message I can't really direct you to a solution.
You should look at the settings available in the Redelivery Policy.  Also you can configure redelivery to not block new message dispatch using the setNonBlockingRedelivery method.


text:
Q: PureJS iframe load button I load iframe with button, when i add a second button it doesn't work.
HTML:

Test

Script:
var button = document.querySelector(".button");
var iframeContainer = document.querySelector(".iframe_container");

button.addEventListener("click", function () {
  var dataId = button.getAttribute("data-id");
  if (dataId != null && dataId != undefined) {
    iframeContainer.innerHTML = "";
    iframeContainer.innerHTML =
      '';
   }
});

What i want to do=

Test

Test 2

... but the second button is not working.

A: document.querySelector only catch the first DOM matching element ! You need querySelectorAll + do a loop on all element with the class, so you can add a listener on each.
 var buttons = document.querySelectorAll(".button");
 var iframeContainers = document.querySelectorAll(".iframe_container");

    for (let i = 0; i < buttons.length; i++){
        buttons[i].addEventListener("click", function () {
            var dataId = buttons[i].getAttribute("data-id");
            if (dataId != null && dataId != undefined) {
                iframeContainers[i].innerHTML = "";
                 iframeContainers[i].innerHTML =
                    '';
            }
        });
    }

redpajama_set_name: RedPajamaStackExchange


text:
Q: i want one (left or right side depending on user's choice)of the linearlayout to be replaced with a custom Linear layout I am very new in android app development and had a problem in making a app. I am making a app related to cricket. I want one (left or right side depending on user's choice) of the linearlayout to be replaced with a custom Linear layout. This is my code for MainActivity
package com.pratham.cricket1;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    public TextView t1,t2;
    public int ta,tb;
    public int w1,w2;
    public int balls,w,t;
    LinearLayout l1,l2;
    RelativeLayout r1;
    ViewGroup vg1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Intent i2=getIntent();
        Bundle b2=i2.getExtras();
        if(!b2.isEmpty()){
            balls=b2.getInt("Balls");
            t=b2.getInt("Team won toss");
            w=b2.getInt("Winning team chose");

        }else{}
         t1=findViewById(R.id.TeamA);
         ta=0;
         t2=findViewById(R.id.TeamB);
         ta=0;

         w1=0;
         w2=0;
         l1=(LinearLayout)findViewById(R.id.a);
         l2=(LinearLayout)findViewById(R.id.b);
         vg1=(ViewGroup)l2.getParent();
         r1=(RelativeLayout)findViewById(R.id.bowling);
         TeamABatting();

    }
    public void a1(View view){
        score_add(1,t1);

    }
    public void a2(View view){
        score_add(2,t1);

    }
    public void a3(View view){
        score_add(3,t1);

    }
    public void a4(View view){
        score_add(4,t1);

    }
    public void a6(View view){
        score_add(6,t1);

    }
    public void b1(View view){
        score_add(1,t2);

    }
    public void b2(View view){
        score_add(2,t2);

    }
    public void b3(View view){
        score_add(3,t2);

    }
    public void b4(View view){
        score_add(4,t2);

    }
    public void b6(View view){
        score_add(6,t2);

    }
    public  void score_add(int a ,TextView t3){
        if(t3==findViewById(R.id.TeamA)){
            ta+=a;
           Score_doner(t3,ta,w1);
        }
        if(t3==findViewById(R.id.TeamB)){
            tb+=a;
            Score_doner(t3,tb,w2);
        }

    }
    public void TeamAOut(View view){
        w1++;
        Score_doner(t1,ta,w1);
    }
    public void TeamBOut(View view){
        w2++;
        Score_doner(t2,tb,w2);
    }
    public void Score_doner(TextView t4,int runs,int wicket){
        t4.setText(Integer.toString(runs)+"/"+Integer.toString(wicket));

    }
    public void TeamABatting(){
        vg1.removeView(l2);
        View v1=getLayoutInflater().inflate(R.layout.bowling,null);
        vg1.addView(v1);

    }
    public void TeamBBatting(){
        vg1.removeView(l1);
        View v1=getLayoutInflater().inflate(R.layout.bowling,null);
        vg1.addView(v1);

    }
}

This is my main .xml
?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:weightSum="2"
    android:orientation="horizontal"
    tools:context="com.pratham.cricket1.MainActivity">

    <LinearLayout

        android:id="@+id/a"
        android:background="@drawable/border"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:orientation="vertical">

        <TextView
            style="@style/common_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Team A" />
        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">

        <TextView
            style="@style/common_text"
            android:textSize="96dp"
            android:text="0/0"
            android:id="@+id/TeamA"
            android:layout_width="match_parent"
            android:layout_height="160dp" />

        </RelativeLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <Button
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:onClick="a1"
                android:text="+1" />

            <Button
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:onClick="a2"
                android:text="+2" />

        </LinearLayout>

        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:onClick="a3"
            android:text="+3" />

        <Button
            android:layout_width="match_parent"
            android:layout_height="84dp"
            android:onClick="a4"
            android:text="+4" />

        <Button
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:onClick="a6"
            android:text="+6" />
        <Button
            android:onClick="TeamAOut"
            android:textColor="@android:color/black"
            android:textStyle="bold"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="OUT!!"
            android:background="#f70303"
            />

    </LinearLayout>
    <LinearLayout
        android:id="@+id/b"
        android:background="@drawable/border"
        android:orientation="vertical"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1">
        <TextView
            android:text="Team B"
            style="@style/common_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">

        <TextView
            android:textSize="96dp"
            style="@style/common_text"
            android:text="0/0"
            android:id="@+id/TeamB"
            android:layout_width="match_parent"
            android:layout_height="160dp"
             />
        </RelativeLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <Button
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:onClick="b1"
                android:text="+1" />

            <Button
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:onClick="b2"
                android:text="+2" />

        </LinearLayout>

        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:onClick="b3"
            android:text="+3" />

        <Button
            android:layout_width="match_parent"
            android:layout_height="84dp"
            android:onClick="b4"
            android:text="+4" />

        <Button
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:onClick="b6"
            android:text="+6" />

        <Button
            android:onClick="TeamBOut"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#f20404"

            android:text="OUT!!"
            android:textColor="@android:color/black"
            android:textStyle="bold" />

    </LinearLayout>

</LinearLayout>

I want it to be divided in exact half the screen. But I am not achieving the end result.Ignore the excessive coding lines, I will DRY them later. This is the linearlayout I want it to be replaced it with
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout

    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="0dp"
    android:layout_weight="1"
    android:background="@drawable/border"
    android:layout_height="match_parent"
    >

        <RelativeLayout

            android:id="@+id/bowling"
            android:layout_width="match_parent"

            android:layout_height="match_parent"

            >

                <TextView
                    android:id="@+id/hello"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="16dp"
                    android:layout_marginTop="16dp"
                    android:text="Balls Left:"
                    android:textColor="@android:color/black"
                    android:textSize="16sp" />

                <TextView
                    android:id="@+id/ballsleft"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="16dp"
                    android:layout_marginTop="16dp"
                    android:layout_toRightOf="@id/hello" />

                <ListView
                    android:id="@+id/overs"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_below="@id/ballsleft">

                </ListView>

        </RelativeLayout>
</LinearLayout>

I want it to be dynamically added based on user's choice.The layouts should cover only half of the screen
enter image description here
It is like the image below.
But i want it exactly half.of the screen

A: I think the problem is with the viewGroup that you are taking named as v1 and v2. What I have tried is directing removing the view from l1 and l2 and adding a new view through inflater in the linear layout respectively.
Code below is a glimpse the two methods of TeamA and TeamB.
  public void TeamABatting(){
        l2.removeAllViews();
        View v1=getLayoutInflater().inflate(R.layout.demo,null);
        l2.addView(v1);

    }
    public void TeamBBatting(){
        l1.removeAllViews();
        View v1=getLayoutInflater().inflate(R.layout.demo,null);
        l1.addView(v1);

    }

Hope that helps.
Edited Part. here is the full code of the activity.
public class Main2Activity extends AppCompatActivity {

    public TextView t1,t2;
    public int ta,tb;
    public int w1,w2;
    public int balls = 10,w =1,t =1;
    LinearLayout l1,l2;
    RelativeLayout r1;
    ViewGroup vg1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_activity);

        t1=findViewById(R.id.TeamA);
        ta=0;
        t2=findViewById(R.id.TeamB);
        ta=0;

        w1=0;
        w2=0;
        l1=(LinearLayout)findViewById(R.id.a);
        l2=(LinearLayout)findViewById(R.id.b);
        vg1=(ViewGroup)l2.getParent();
        r1=(RelativeLayout)findViewById(R.id.bowling);
        TeamABatting();

    }

    public void a1(View view){
        score_add(1,t1);

    }
    public void a2(View view){
        score_add(2,t1);

    }
    public void a3(View view){
        score_add(3,t1);

    }
    public void a4(View view){
        score_add(4,t1);

    }
    public void a6(View view){
        score_add(6,t1);

    }
    public void b1(View view){
        score_add(1,t2);

    }
    public void b2(View view){
        score_add(2,t2);

    }
    public void b3(View view){
        score_add(3,t2);

    }
    public void b4(View view){
        score_add(4,t2);

    }
    public void b6(View view){
        score_add(6,t2);

    }
    public  void score_add(int a ,TextView t3){
        if(t3==findViewById(R.id.TeamA)){
            ta+=a;
            Score_doner(t3,ta,w1);
        }
        if(t3==findViewById(R.id.TeamB)){
            tb+=a;
            Score_doner(t3,tb,w2);
        }

    }
    public void TeamAOut(View view){
        w1++;
        Score_doner(t1,ta,w1);
    }
    public void TeamBOut(View view){
        w2++;
        Score_doner(t2,tb,w2);
    }
    public void Score_doner(TextView t4,int runs,int wicket){
        t4.setText(Integer.toString(runs)+"/"+Integer.toString(wicket));

    }
    public void TeamABatting(){
        l2.removeAllViews();
        View v1=getLayoutInflater().inflate(R.layout.demo,null);
        l2.addView(v1);

    }
    public void TeamBBatting(){
        l1.removeAllViews();
        View v1=getLayoutInflater().inflate(R.layout.demo,null);
        l1.addView(v1);

    }
}


text:
Q: Prevent command prompt from closing automatically (CS Script) I'm experimenting with CS-Script and my problem is that each time I run a script the console window is automatically closed when the script exits. How can I prevent this from happening?

A: If you don't want to change the script itself then open a command window and execute the script from the command line.  The only reason the console closes after the script completes is because it was created by the script itself.  The script will not close a console that you opened.

A: I don't how you call it but you can always call it with "Ctrl + R" > cmd.exe /k [your command] or Console.ReadLine() in your script.

A: A poor way concists of adding a Console.Read() at the end of you script.


text:
Q: Combining SQL `raiserror` with `select` in C# I want to know if there is a way of using both SQL raiserror and retrieving the selected result in C#. ExecuteReader() in C# will throw an exception when raiserror occurs, but I still want to use the reader to capture any data returned.
Below is a simplified example. If this is not possible I will use raiserror for general cases and select for specific cases.
if (some-error)
begin
    select  @Message = 'ERROR: script made a booboo',
            @State = 'State Info'
    raiserror (@Messsage, 16, 1)
    goto exit_sp
end

exit_sp:
    select  @Message 'Message', @State 'State'

A: If you lower the severity to 10 or below (from memory) it will not raise an exception, but will be available via the InfoMessage event on the connection. Note, however, that because of how TDS works, you should ensure that you Read() etc to the end of all results; for example, if you have multiple selects and then a raiserror, and you only read the first select before dropping the data-reader, there is a chance you won't see the message (the TDS will be killed).


text:
Q: Move files from /dev/sda1 to /dev/sda3 $ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            7,8G     0  7,8G   0% /dev
tmpfs           1,6G  9,5M  1,6G   1% /run
/dev/sda1        23G   22G     0 100% /
tmpfs           7,8G  696K  7,8G   1% /dev/shm
tmpfs           5,0M  4,0K  5,0M   1% /run/lock
tmpfs           7,8G     0  7,8G   0% /sys/fs/cgroup
/dev/sda3       477M  4,0K  477M   1% /boot/efi
/dev/sda5       888G   22G  822G   3% /home
tmpfs           1,6G   80K  1,6G   1% /run/user/1000

l noticed that I put all my files in the partition /dev/sda1 (system partition 23 GB) however I left empty /dev/sda5 which has 888 GB.
How can I access sda5 and put all the files there?
edit1

sudo du -h /var/cache
260K    /var/cache/cracklib
5,2M    /var/cache/debconf
1,4M    /var/cache/fontconfig
4,0K    /var/cache/cups/rss
6,4M    /var/cache/cups
4,0K    /var/cache/fwupdate
40K /var/cache/dictionaries-common
120K    /var/cache/ldconfig
24K /var/cache/man/sv
52K /var/cache/man/fr
20K /var/cache/man/gd
20K /var/cache/man/az
20K /var/cache/man/hi
20K /var/cache/man/hr
20K /var/cache/man/eu
20K /var/cache/man/fr.ISO8859-1
20K /var/cache/man/shn
20K /var/cache/man/bn
20K /var/cache/man/sq
20K /var/cache/man/oc
20K /var/cache/man/oldlocal
20K /var/cache/man/tr
20K /var/cache/man/zh_TW
20K /var/cache/man/hy
20K /var/cache/man/ne
20K /var/cache/man/km
20K /var/cache/man/en_AU
20K /var/cache/man/cs
20K /var/cache/man/ps
20K /var/cache/man/vi
20K /var/cache/man/lt
20K /var/cache/man/cy
20K /var/cache/man/he
20K /var/cache/man/ug
20K /var/cache/man/ml
20K /var/cache/man/ko
20K /var/cache/man/th
20K /var/cache/man/el
20K /var/cache/man/my
20K /var/cache/man/et
52K /var/cache/man/de
20K /var/cache/man/ku
20K /var/cache/man/zh_HK
20K /var/cache/man/bo
20K /var/cache/man/ca@valencia
20K /var/cache/man/ar
20K /var/cache/man/si
20K /var/cache/man/ca
20K /var/cache/man/fa
20K /var/cache/man/ast
20K /var/cache/man/kk
20K /var/cache/man/gl
32K /var/cache/man/es
20K /var/cache/man/hu
20K /var/cache/man/uk
20K /var/cache/man/bs
20K /var/cache/man/nn
20K /var/cache/man/sk
20K /var/cache/man/en_CA
20K /var/cache/man/eo
20K /var/cache/man/sl
20K /var/cache/man/io
20K /var/cache/man/id
20K /var/cache/man/mhr
28K /var/cache/man/pt
20K /var/cache/man/fo
20K /var/cache/man/pa
24K /var/cache/man/pl
20K /var/cache/man/fi
20K /var/cache/man/ms
28K /var/cache/man/ja
20K /var/cache/man/ta
28K /var/cache/man/ru
20K /var/cache/man/nb
20K /var/cache/man/fr_CA
20K /var/cache/man/lv
20K /var/cache/man/nl
20K /var/cache/man/pt_BR
20K /var/cache/man/fr.UTF-8
20K /var/cache/man/bg
20K /var/cache/man/uz
20K /var/cache/man/ce
20K /var/cache/man/en_GB
20K /var/cache/man/fy
20K /var/cache/man/sr
20K /var/cache/man/se
20K /var/cache/man/zh_CN
28K /var/cache/man/it
20K /var/cache/man/be
20K /var/cache/man/ro
20K /var/cache/man/te
20K /var/cache/man/da
3,8M    /var/cache/man
100K    /var/cache/app-info/xmls
5,5M    /var/cache/app-info/xapian/default
5,5M    /var/cache/app-info/xapian
5,6M    /var/cache/app-info
8,0K    /var/cache/lightdm/dmrc
12K /var/cache/lightdm
4,0K    /var/cache/fonts
420K    /var/cache/samba
4,0K    /var/cache/apt/archives/partial
80K /var/cache/apt/archives
89M /var/cache/apt
700K    /var/cache/postgresql/dicts
704K    /var/cache/postgresql
4,0K    /var/cache/pm-utils
4,0K    /var/cache/apparmor
113M    /var/cache

**EDIT2**

l took the last lines

    du -h /

    8,5M    /usr/share/texlive/texmf-dist/scripts
    12K /usr/share/texlive/texmf-dist/metafont/config
    32K /usr/share/texlive/texmf-dist/metafont/base
    112K    /usr/share/texlive/texmf-dist/metafont/misc
    160K    /usr/share/texlive/texmf-dist/metafont
    212K    /usr/share/texlive/texmf-dist/web2c
    8,0K    /usr/share/texlive/texmf-dist/mft/knuth-local
    20K /usr/share/texlive/texmf-dist/mft/base
    32K /usr/share/texlive/texmf-dist/mft
    20K /usr/share/texlive/texmf-dist/texdoc
    159M    /usr/share/texlive/texmf-dist
    92K /usr/share/texlive/readme-html.dir
    161M    /usr/share/texlive
    4,0K    /usr/share/libsensors4
    2,1G    /usr/share
    457M    /usr/bin
    11G /usr

du -h /var

4,0K    /var/cache/pm-utils
4,0K    /var/cache/apparmor
113M    /var/cache
5,0G    /var

du -h /lib

208K    /lib/terminfo
20K /lib/apparmor
124K    /lib/sysvinit
8,0K    /lib/resolvconf
651M    /lib

sudo du -h /root
72K /root/tensorflow/tensorflow/tools/test
44K /root/tensorflow/tensorflow/tools/pip_package
16K /root/tensorflow/tensorflow/tools/compatibility/testdata
64K /root/tensorflow/tensorflow/tools/compatibility
48K /root/tensorflow/tensorflow/tools/benchmark
2,8M    /root/tensorflow/tensorflow/tools
62M /root/tensorflow/tensorflow
633M    /root/tensorflow
5,3G    /root

A: I believe you did the right thing with separating your /home from your /(root), but maybe were overly-optimistic on how much data an ubuntu install will use, and appear to be using your root account for something.
The /usr directory is where the programs are installed generally. This will grow as you install more software on your system.
The /var directory is where your data/cache/databases/logs are stored. It used to be considered best practice to separate this from the '/' in order to prevent system instability if the logs grew too fast and choked the system.
The /home is where your users data should go and it is always a good idea to keep it separate from '/'.
The /root in the root user home directory, and in modern linux distros it is considered bad security practice to use the root account, so it's size should be quite small. In this situation it is not, and it is filling /sda.
Solution A: Stop using the root account, and migrate it's data to another (new) account.
Steps:

*

*Create a new user using for example users-admin. Assign desired group permissions (including sudo privileges)

*Copy data across (from /root to /home/newuser) using something like rsync rsync -arv /root /home/newuser

*Remove old root data -- with care (perhaps just Downloads and Documents to start with)
Solution B: Re-partition -- which can be dangerous and lead to data loss.
Steps:

*

*boot into live cd/dvd/usb

*split sda5 into 3 (50 Gb for /var; 100Gb for /root; remainder stays as /home) using gparted

*edit the system fstab (not the live environment fstab) to have /var and /root mounted separately

*copy then delete the data from old /root and old /var to new locations. 'rsync -ar' would be best as it would preserve file creation and modification times

*get back into your system and hope for the best
It would be lovely if someone would be able to offer a simpler solution :-)


text:
Q: Debian - port redirect I have device, that sends some RAW data (NetFlow v9). I can set only IP adress and PORT of "data collector". For Example 192.168.0.10:8080.
Is it some simple solution at Debian to redirect this to specific php script on common webserver port (:80), for example 192.168.0.10/SaveFromDevice.php? And how i can get sended data to $_GET["data"]?
Thank you


text:
Q: Skipping work-tree in git for glob patterns My remote repo has .log files that are getting used for code execution. Hence they need to be tracked by Git. While other developers work on this repo, they push their changes related to log files. When I pull those changes, it creates conflicts.
For temporarily ignoring these tracked files, I have tried the below option:
git ls-files *.log* -z | xargs -0 git update-index --skip-worktree

However, this will only skip worktree for log files that are currently present. If there are new log files added into tracking by other developers, I will need to re-run this command. Is there a way to configure git to skip the worktree for all files having *.log* glob pattern?

A: No (but see footnote 2 at the bottom, which is an answer to a question you did not quite ask).  The --skip-worktree option sets a flag bit on an existing index entry.  New index entries never have either or the assume-unchanged or skip-worktree bits set.
New index entries will be created when:

*

*you use git add to copy a file into Git's index, when the file was not there before; or

*you use git checkout or git switch, or one of Git's other index-manipulation commands, to copy a file into Git's index that was not there before.

If there are new log files added into tracking by other developers ...

It's important to realize that unless you share the repository itself—which is generally a bad idea—other developers are not changing which files are tracked, because the concept of tracked vs untracked, for some work-tree file, is based on your repository and work-tree.
That is:

*

*Git is about commits.  Users make new commits and add them to their Git repository, and then you have your Git repository connect to their Git repository (or to some central sharing site to which they have sent their commits) and get the commits from them.  (That is, they might run git push in their repository, which would send their commits to the central sharing site.  Then you run git fetch origin to get those commits into your own repository.  If you're using git pull, note that git pull first runs git fetch, then runs a second Git command to do something with the fetched commits.)

*While commits contain files, the files inside a commit are in a read-only, compressed and de-duplicated format that only Git itself can read.  These files are frozen for all time.  They are not useful on their own.  (But they are de-duplicated, so that if hundreds of commits have the same data in some file—which is often the case because every commit has every file in it—there's really only one copy of the file, shared by all those commits.)

*So, when you git checkout a specific commit, your Git copies the files from the given commit.
So the main idea here is that when you are working with some commit, there are two copies of the files from that commit.  One, the frozen Git-only copy, is in the current commit, and the other, which you can read and write and generally work with, is in your working tree or work-tree.  Here, Git is like most version control systems: they all have to do something like this, since there's a committed copy that literally can't change, and a usable copy that can.
But here, Git departs from other version control systems by keeping a third copy, in between the frozen committed copy and your usable work-tree copy.  This third copy is actually not really a copy because it's in Git's frozen format, and already de-duplicated.  What makes it different from the committed copy is that it is not in a commit: it's in Git's index.  This means you can replace it wholesale, by substituting in a new de-duplicated copy of some other file.
That's what git add does: it creates an all-new index entry, to hold the file name and new, but already de-duplicated (Git blob object), file content; or it replaces the existing entry's content (the internal blob object hash ID), while keeping the file name and flags from the existing index entry.1  This is where your --skip-worktree flag comes in.
The index, which Git also calls the staging area, only contains entries for files that will go into the next commit.  These are the files that Git knows about.  They're already in Git's index, right now.  The index holds the file's name and mode, a de-duplicated internal Git blob object hash ID, and a bunch of other cache information Git finds useful.  That includes the skip-worktree bit.
But because the index represents the next commit you will make, it contains only those files that will be in the next commit.  If a file doesn't exist, it can't be in the next commit—so it isn't in the index and therefore there is no skip-worktree bit for it.
Similarly, because the index represents the next commit you will make, when you use git checkout to select a commit to work on / with, Git will fill its index from that commit, so that the next commit is similar.  Suppose someone has created a new log file, that has never existed before, in a new commit.  As soon as you have Git check out this commit, Git will need to add the log file to its index.  This will be a new entry and won't have the skip-worktree bit set.
This also brings us to the definition of an untracked file, and hence by contrast, a tracked file.  An untracked file is any file that is in your work-tree right now that is not in Git's index right now.  A tracked file is therefore one that is in Git's index right now.  That's all there is to it, but:

*

*Your work-tree is under your control: you can create and remove files any time.

*Git's index is under Git's control.  Checking out a commit fills it.  But you have some control too: git add copies into it, and git rm removes from both Git's index and your work-tree.

Since you can only set the assume-unchanged and skip-worktree flags on index entries, you can only set them on files that are (currently) tracked.  The set of tracked files changes, at least potentially, as you switch from one commit to another.  If you want to set particular bits on particular index entries, you have to do that as you switch from one commit to another.2

1Because git add means make the index copy match the work-tree copy, git add can also remove from the index any file that is no longer present in your work-tree.  With the skip-worktree bit set, though, git add won't make the index copy match the work-tree copy: it won't copy an updated file back into Git's index, and it won't remove, from Git's index, any file that is missing in your work-tree.  This second part relates directly to footnote 2.
2This isn't entirely true: Git supports something called sparse checkouts, where Git will deliberately set the skip-worktree bit on some new index entries.  This is in fact the original intent for the skip-worktree bit.  However, the way this works is that you list, for Git, the files that should appear in your work-tree.  Git will then make sure not to copy committed (and now indexed) files into your work-tree if they're marked "do not check out due to sparse checkouts".  That is, git checkout will see that this file should not be checked out, and will instead set the skip-worktree bit.
The problem here is that of course these files also won't appear in your work-tree.  That is, these *.log* files won't be checked out at all.  They will be in Git's index, and therefore will be in new commits that you make, but you won't be able to look at the files.  This might be OK for your particular purpose.  In that case, stop setting the bit manually, and look into sparse checkouts.


text:
Q: Switch home page language i've setted evrything to create a new hompage in another language(in Magento 2.3), but when i go to frontend doesn't show the choice to selected "spanish hompage". someone could help me?
enter image description here

A: You have to create new store view and assign your home page to this store view. Check the screenshots
Create Store View
Go to: Stores-> Configurations-> General-> Web
Change CMS Home Page under Default Pages

A: thank you, but i've alredy done it! i have setted a store view, than in store configuration (spanish store view) i've setted cms default home page and selected spanish home, but it doesn't show this option in the frontend!!


text:
Q: Does anybody share me the code to implement the Azure single sign on by using clientid, redirect uri, tenant I'd without showing any login popup? Does anybody share me the code of Azure single sign on by using clientid, redirect uri, tenant I'd to implement that in my asp net windows application without showing any login popup to user and that automatically get the users current login authentication?
Azure single sign on without showing popup
startup.cs
PublicClientApplicationBuilder builder= PublicClientApplicationBuilder.Create(clientId).WithAuthority(authorityUrl).WithRedirectUri(redirectUrl);
IPublicClientApplication app = builder.Build();
AuthenticationResult result = await app.AcquireTokenInteractive(scopes) .ExecuteAsync();
string accessToken = result.AccessToken;

A: Check the below steps to Implement SSO without showing the login popup.
In Visual Studio create a new Web Application with .NET 4.7 Framework and select None in Authentication.

Add new class file with name startup.cs.

*

*In Azure Active Directory create the new App Registration.

*

*In the newly created App Registrations => Overview pane, you can find the details of client and TenantID.

My Web.config file:
 <appSettings>
    <add key="ClientId" value="****" />
    <add key="Tenant" value="****" />
    <add key="Authority" value="https://login.DomainName.com/{0}/v2.0" />
    <add key="redirectUri" value="https://localhost:PortNo/" />
  </appSettings>

But that access token dont have any user data. framework 4.7

*

*Check whether you have provided the correct Authority URL.

Make sure you have given the Redirect URI Correctly.
We need to provide both local as well as Deployed Application URL.

Refer the GitHub which uses AcquireTokenByIntegratedWindowsAuthAsync, which authenticates the user with Windows Credentials.


text:
Q: Low quality audit tells you the answer So, I was in the low quality queue, and I came across a particularly easy audit.
https://stackoverflow.com/review/low-quality-posts/4053045
One part of it that got my attention was this warning which essentially tells you straight out to recommend deletion:

Our system has identified this post as possible spam; please review carefully

Are you meant to see those messages on audits?  Do they make audits too easy?


text:
Q: how to user expect and send with a request and sleep When the password appeare
I want to use expect to autoinput the result of a request after 5s
macOS shell expect
expect << !
set timeout -1
spawn bundle exec fastlane fastlane-credentials add --username sakura
expect "*Password*"
sleep 5
send `curl http://localhost/a.txt`

interact
!

the sleep can't effect
the curl http://localhost/a.txt used before the Password,I want to after

A: In tcl language, send command interpret at every first time, so the sleep will not work for interact with your process. Put sleep before expect should work, but U need save password in temp file as a storage. More detail, example codes show as:
#!/usr/bin/expect

set timeout -1
spawn bundle exec fastlane fastlane-credentials add --username sakura
sleep 5
send_user "[exec curl -s http://localhost/a.txt -o /tmp/_passwd.txt]"
set fp [open "/tmp/_passwd.txt" r]
set passwd [read $fp]
close $fp
send_user "[exec rm -f /tmp/tmp/_passwd.txt]"
puts $passwd
expect "*Password*"
send '$passwd\r'
interact


text:
Q: How can i read texfile line by line and add to array using C# Am using AfricasTalking C# class to send Airtime. First you create and array of numbers to send airtime. Below is a code to create Arraylist. Instead i want to read numbers from a text file and add to rec1.
ArrayList AirtimeRecipientsList = new ArrayList();

// Declare hashtable to hold the first number
// Please ensure you include the country code for phone numbers (+254 for Kenya in this case)
// Please ensure you include the country code for phone numbers (KES for Kenya in this case)
// Specify the country currency and the amount as shown below

Hashtable rec1 = new Hashtable();
rec1["phoneNumber"] = txtPhoneNo.Text;
rec1["amount"] = "KES "+ txtAmount.Text;

// Add recipient to list
AirtimeRecipientsList.Add(rec1);

// Declare hashtable to hold the another number
//Hashtable rec2 = new Hashtable();
//rec2["phoneNumber"] = "+254733YYYZZZ";
//rec2["amount"] = "KES XXX";

// Add recipient to list
//AirtimeRecipientsList.Add(rec2);`

A: Assuming your text file has phone number and amount separated by comma or any character like this "123456789, KES 500" on each line without quotes.
Here is some code.
    var recipients = System.IO.File.ReadAllLines(path to text file);
    ArrayList recipientsList = new ArrayList();
     foreach(var line in recipients)
         {
           Hashtable rec1 = new Hashtable();
          rec1["phoneNumber"] = line.Split(',')[0];
          rec1["amount"] = line.Split(',')[1];
           recipientsList.Add(rec1)
         }

That's it.


text:
Q: Rails Search Box So I have a search box working in my application, however it only returns a result if the search matches exactly what is submitted, as opposed to something like it. Heres my code for the search method;
def self.search(search)
    if search
        where(:title => ["title LIKE ?", "#{search}"])
    else
        all
    end
end

The "title LIKE ?" doesn't seem to be returning results which are like the query, only ones which are exactly the same.
What am I missing here?

A: Try this
where(["title LIKE ?", "%#{search}%"])

A: Here is another way if you want to avoid string queries (using arel):
where(arel_table[:title].matches("%#{search}%"))


text:
Q: Rotate by an angle theta on y-axis a joint oriented in Euler angles I have a joint (of a human skeleton) with no translation (located at the origin with X,Y,Z = 0,0,0) and orientation defined in Euler angles (e.g. X = -111 degrees, Y = 82 degrees, and Z = -123 degrees), as shown in the figure below:

I want to rotate that joint by an angle theta (e.g., θ = -60 degrees) on Y-axis (e.g., the orientation will be X = -165 degrees, Y = 22 degrees, and Z = -173 degrees), as shown in the figure below:

I want to implement a function for that rotation, but I cannot get the maths. One of my thoughts was to convert the Euler representation to a vector, then rotate, and then get back the Euler angles, but I cannot figure how to convert these Euler angles to an orientation vector, and then how to get back the Euler angles from the rotated vector.
Thanks


text:
Q: Adding Menu item into NavigationView without create menu.xml I get data from the server , Is there a way to add items to a NavigationView without create a folder menu and puts items in the xml file ?
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/DrawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="********">

    <FrameLayout
        android:id="@+id/ContentFrame"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <android.support.design.widget.NavigationView
        android:id="@+id/DrawerNavView"
        android:layout_height="match_parent"
        android:layout_width="wrap_content"
        android:layout_gravity="end"
        android:fitsSystemWindows="true" />

</android.support.v4.widget.DrawerLayout>

MainActivity.java
@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        drawerNavView = (NavigationView) findViewById(R.id.DrawerNavView);

The code above crash the app.


text:
Q: MIPS convert float into an integer I've tried looking at it a couple different ways, one of them was using binary to shift left/right but I just wasn't able to find a combination to make it work for anything besides a few selected numbers each time. So how do you convert a float into an integer?
.data
five: .float 10.0

.text

main:
    la  $a1 five
    l.s $f12 ($a1)
    #conversion here

    li $v0 2# print float, which will print 10.0 (should print integer)
    syscall

    li $v0 10
    syscall

A: Disclaimer: I'm not an expert on MIPS arch.
As suggested in the comments, a quick lookup for MIPS FP reference gives the desired instruction: cvt.w.s.
.data
    five: .float 5.0
.text

#Convert five into an integer
la $t1, five
l.s $f12, ($t1)             #f12 = five
cvt.w.s $f0, $f12           #f0 = (int) five

#Print five
li $v0, 2
syscall

#Print (int)five
li $v0, 1
mfc1 $a0, $f0               #a0 = (int)five
syscall

#Exit
li $v0, 10
syscall

This will print

5.05

As there is no space between the 5.0 and the 5.
If you want to do it by hand, you can start from this answer.


text:
Q: How to link single-threaded CRT libc.lib? I have an application which uses an old .lib file which in-turns depend on single-threaded libc.lib.
As I read on MSDN, Single-Threaded libc.lib is no longer supported and I should use Multi-threaded ones. How do I force that .lib to use multi-threaded version of libc.lib or how do I get libc.lib (single-threaded one) on visual studio 2012 ?

A: Find the lib owner and ask for a rebuild. If you cannot get a new release, build a DLL wrapper for the lib in a pre-VS2005 version of Visual Studio then use the DLL in your VS2012 project.


text:
Q: Relative size of Python Tkinter scale widget I'm using the place() method of assigning the location of slider bars on my application window. I am using relx, rely, and relwidth to control where the sliders go to make sure they scale up when I maximize the window.
The slider bars are in a horizontal position, and take up most of the width of my screen. I can't figure out how to adjust the "thickness/height?" of the slider bar relative to the screen.
You can do width = ... to adjust the thickness permanently, but I'm finding that you can't use relheight = ... to do it relative to the screen.
Can someone help me adjust this parameter relative to the parent widget size?
sweetSlider = Scale(app, orient=HORIZONTAL,width=30,from_=0,to=100,showvalue=0,variable=sweetVar)
sweetSlider.place(relx=0.15,rely=0.06,relwidth=0.7)

In the above, relx and rely are the placement of the upper left corner of the slider on my GUI screen (app). relwidth=0.7 sets the width of the slider always to 70% the width of the screen.
I wish to set the other dimension of the slider, the "height" in the same manner (to maybe 10% of the screen size). The relheight parameter works with buttons, but it doesn't seem to work with the slider.


text:
Q: Any later versions of python 3 that are compatible with python 3.2.5? my school told me to use python 3.2.5 for compatibility reasons as that's the version that they use, but I've found that a few modules I would like, don't work with python 3.2
I was wondering if there's a way to have two versions of python installed or if any later versions are compatible with python 3.2.5?

A: You can certainly have multiple versions of python installed. In my case I have coworkers that prefer Python 2.7 and so I have a virtual environment set up that will use python 2.7 instead of 3.4 (which i prefer). There are lots of useful cases when environments will save you headaches so do learn about them earlier than later.
Personally, I like to use the Anaconda distribution of python. With anaconda you can use conda create --name env_name python=3.x package package1 this will create a python environment with python version 3.x named env_name and install packages: package and package1. If you want an empty environment simply omit packages. The documentation for this can be found here.
However, as Antti Haapala points out 3.2 is not necessarily the most stable or compatible of versions. In fact conda has dropped 3.2 for environment creation, running conda create --name env_name python=3.2 returns an error.
I'm sure your school has some reason they want to stick to 3.2, but in my opinion you might be best served by using 3.3 (or later) instead.
ps. referring to your previous question about pip; with anaconda there is a command conda which accomplishes the same thing. For example you can run conda install pandas to install pandas. If a package can't be found, searching the anaconda  site will give you info on how to add packages from other owners.


text:
Q: Swift - Get keyboard input as the user is typing I have an app in swift, where the texfield is located at the bottom of the screen, and when the user tries to type anything, the keyboard covers the textfield, so the user is unable to see what he/she is typing. To solve this, I would like to get the keyboard input from the user, with every stroke/"type" (everytime the user presses a key), and then display it onto a view, which is located just above the keyboard. If this is not possible, or very complex, you are more than welcome to suggest alternative solutions.

A: You need to register as observer for notifications to see when the keyboard appears and disappears. Then you would move your view up on show, or restore it to original on hide.
My implementation moves the whole view up by keyboard height, but if you want you can just move UITextField up.
You can take a look at this tutorial, or see my implementation in the answer:
http://www.ioscreator.com/tutorials/move-view-behind-keyboard-ios8-swift
Add observers in viewDidAppear
override func viewWillAppear(animated:Bool) {
    super.viewWillAppear(animated)

    NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(_:)), name: UIResponder.keyboardWillShowNotification, object: nil)
    NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(_:)), name: UIResponder.keyboardWillHideNotification, object: nil)
}

You then need the methods to move the view in keyboardWillShow and keyboardWillHide new methods.
@objc func keyboardWillShow(_ notification: NSNotification) {
    let info = notification.userInfo!
    let keyboardSize = (info[UIResponder.keyboardFrameBeginUserInfoKey] as! NSValue).cgRectValue

    let keyboardHeight:CGFloat = keyboardSize.height

    //let animationDuration:CGFloat = info[UIResponder.keyboardAnimationDurationUserInfoKey] as! CGFloat

    UIView.animate(withDuration: 0.25, delay: 0, options: .curveEaseInOut, animations: {
        self.view.transform = CGAffineTransform(translationX: 0, y: -keyboardHeight)
        }, completion: nil)

}

And to move the view to original state:
@objc func keyboardWillHide(_ notification: NSNotification) {
    UIView.animate(withDuration: 0.25, delay: 0, options: .curveEaseInOut, animations: {
        self.view.transform = CGAffineTransform.identity
        }, completion: nil)
}

And at the end remove the observer in viewDidDisappear
override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)
    NotificationCenter.default.removeObserver(self)
}

A: To go along with Stefan Salatics answer I use the following code as the keyboard will often times still cover the textfield.
-(void) keyboardWillShow:(NSNotification *)note
{
// Get the keyboard size
CGRect keyboardBounds;
[[note.userInfo valueForKey:UIKeyboardFrameBeginUserInfoKey] getValue: &keyboardBounds];

// Start animation
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:0.3f];

// Get Keyboard height and subtract the screen height by the origin of the textbox and height of text box to position textbox right above keyboard
self.scrollView.contentOffset = CGPointMake(0,keyboardBounds.size.height-([UIScreen mainScreen].bounds.size.height - commentBox.frame.origin.y - commentBox.frame.size.height));

[UIView commitAnimations];
}

A: The following is how I did for that problem. I hope this method solve your problem.
This is the textfield you want to use.
@IBOutlet var userID : UITextField!

You need to write this function.
func textFieldShouldReturn(textField: UITextField!)-> Bool
{   userID.resignFirstResponder( )
    return true
}

In your desired function, you need to write this syntax.
@IBAction func login(sender: AnyObject)
{
    userID.resignFirstResponder( )
}

This is in ViewDidLoad or ViewDidAppear
override func viewDidLoad( )
{
    userID.delegate = self;
}

I hope this is useful for you.

A: Although Stefan's Answer is better for your current implementation. Your question was how to get every stroke a user types.
For the sake of completion
class viewController: UIViewController, UITextFieldDelegate{
    var textField = UITextField()

    override func viewDidLoad() {
        textField.delegate = self
    }

    func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
        //string is used here as the value of the textField.
        //This will be called after every user input in the textField
    }
}

string can be used to see what the latest user input is. You could store a local variable with the current value and compare it to the "new" value to see what has been changed.


text:
Q: Why does GDB start a new shell and how to disable this behaviour? I was figuring out a problem where starting the application from GDB results in a symbol lookup error, but starting it from the shell works.
It turns out that whenever you start a program from within GDB it will start a new shell and thus override all environment variables I had set before starting GDB (like LD_LIBRARY_PATH).
This is not really the behavior I want. Can someone explain the rationale behind this, or tell me how I can turn this off?

A: I am guessing that you unconditionally set LD_LIBRARY_PATH in your ~/.cshrc or the like. So if from a shell prompt you do this:
export LD_LIBRARY_PATH=foo  # or for csh:
setenv LD_LIBRARY_PATH foo
$SHELL -c 'echo $LD_LIBRARY_PATH'

the result is something other than foo. Don't do that.
Usually this happens to CSH users, who neglected to protect their ~/.cshrc against non-interactive shells. It could also happen to BASH users who set their BASH_ENV.

A: I meet the same problem. I find that in inferior.h (source code of gdb gdb/inferior.h)
there is a macro STARTUP_WITH_SHELL, there is also a piece of comment as
/* If STARTUP_WITH_SHELL is set, GDB's "run"
   will attempts to start up the debugee under a shell.
   This is in order for argument-expansion to occur. E.g.,
   (gdb) run *
   The "*" gets expanded by the shell into a list of files.
   While this is a nice feature, it turns out to interact badly
   with some of the catch-fork/catch-exec features we have added.
   In particular, if the shell does any fork/exec's before
   the exec of the target program, that can confuse GDB.
   To disable this feature, set STARTUP_WITH_SHELL to 0.
   To enable this feature, set STARTUP_WITH_SHELL to 1.
   The catch-exec traps expected during start-up will
   be 1 if target is not started up with a shell, 2 if it is.
   - RT
   If you disable this, you need to decrement
   START_INFERIOR_TRAPS_EXPECTED in tm.h. */
#define STARTUP_WITH_SHELL 1
#if !defined(START_INFERIOR_TRAPS_EXPECTED)
#define START_INFERIOR_TRAPS_EXPECTED   2
#endif

Then I set STARTUP_WITH_SHELL as 0 and decremented START_INFERIOR_TRAPS_EXPECTED
and recompiled my gdb. After that gdb didn't start from shell any more.

A: When you start gdb from the shell, you start it as a new process, there's no way around that. In Unix new processes inherit some of the environment of the parent.
To make sure a variable is inherited, if you're using a bourne-like shell, try exporting it:
export LD_LIBRARY_PATH=...

A: The debuggee (inferior in gdb parlance) is always started with a clean environment in order to get more reproducible results. In order to set a variable there, use the
set env VARNAME=VALUE

command before running.


text:
Q: How to create a variable length scrollview with choose able indices I am attempting to create a scrollview that is variable length that has X amount of objects. These are currently set up as Linear layouts that are just names "item0", etc... I am attempting to make this list variable in size, so that once a item is chosen it can move to the next step and be removed from the list. this is what i have currently. This is definitly not the correct way to do this and i am hoping someone could shed some light on how to correctly continue.
Thank you
-Steven
    <ScrollView
        android:id="@+id/scroll"
        android:layout_width="wrap_content"
        android:layout_height="100dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/Description">

        <android.support.v7.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <LinearLayout
                android:id="@+id/lin0"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <LinearLayout
                    android:id="@+id/lin1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content">

                    <ImageView
                        android:layout_width="34dp"
                        android:layout_height="34dp"
                        android:src="@drawable/sample" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:gravity="center"
                        android:text="item0"
                        android:textColor="#000"
                        android:textSize="18dp" />
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/lin2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content">

                    <ImageView
                        android:layout_width="34dp"
                        android:layout_height="34dp"
                        android:src="@drawable/sample" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:gravity="center"
                        android:text="item1"
                        android:textColor="#000"
                        android:textSize="18dp" />
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/lin3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content">

                    <ImageView
                        android:layout_width="34dp"
                        android:layout_height="34dp"
                        android:src="@drawable/sample" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:gravity="center"
                        android:text="item2"
                        android:textColor="#000"
                        android:textSize="18dp" />
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/lin4"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content">

                    <ImageView
                        android:layout_width="34dp"
                        android:layout_height="34dp"
                        android:src="@drawable/sample" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:gravity="center"
                        android:text="item04"
                        android:textColor="#000"
                        android:textSize="18dp" />
                </LinearLayout>
            </LinearLayout>

        </android.support.v7.widget.CardView>
    </ScrollView>


text:
Q: How do I read the following XML in Apex? What class or function could I use to parse this data?
<CONTACT>
    <SDICTIONARY>
        <CONTACTNAME>ABC</CONTACTNAME>
        <SYNONYMNAME>ABC1</SYNONYMNAME>
    </SDICTIONARY>
    <SDICTIONARY>
        <CONTACTNAME>ADALYN</CONTACTNAME>
        <SYNONYMNAME>ADEALIDE</SYNONYMNAME>
    </SDICTIONARY>
    <SDICTIONARY>
        <CONTACTNAME>AILBERT</CONTACTNAME>
        <SYNONYMNAME>ALBERT</SYNONYMNAME>
    </SDICTIONARY>
</CONTACT>

A: Generally speaking, if you're dealing with XML, you will need to build a parser.
Regular expressions may be able to help in the simplest of situations. However, from a computation theory perspective, regular expressions are less powerful than XML. Regular expressions work on so called "regular languages" whereas XML, I believe, is a context-free language.
My preferred method of parsing XML is to use the Dom.Document and Dom.XMLNode classes along with creating different classes for each tag in your XML schema (at least until you get down to the very last levels, which tend to be basic types like String and Integer)
In your provided example you only need two classes. I'd propose a structure like this:
public Class myXMLParser{
    public Class Contact{
        public List<SDictionary> contactInfo;
    }

    public Class SDictionary{
        public String contactName;
        public String synonymName;
    }
}

Using the Dom classes comes down to two basic operations:

*

*Load your XML into an instance of Dom.Document

*

*If your XML is coming from a web callout, you can use
HttpResponse.getBodyDocument()

*If your XML is in a plain string, you can use Dom.Document.load(myXMLString)

*Loop over child nodes in your XML using Dom.Document.getRootElement().getChildElements()
The class structure that I proposed earlier will allow us to spread the complexity of looping over the children over multiple classes. This way, we won't end up with a giant, and very intimidating, wall of nested if/else blocks.
I hesitate to give you a substantial example using the XML that you provided in your question because it doesn't appear that you have put any effort into researching this yourself. A well-explained example could pretty much be copy/pasted and just work, but that wouldn't lead to you understanding how or why it works.
Instead, I'll give an example of how to parse the following XML
<library>

    <name>Science Fiction</name>
    <book>
      <title>Ender's Game</title>
      <author>Orson Scott Card</author>
    </book>
    <book>
      <title>Nightfall</title>
      <author>Issac Asimov</author>
    </book>

    <name>Fantasy</name>
    <book>
      <title>The Hobbit</title>
      <author>J.R.R. Tolkien</author>
    </book>
    <book>
      <title>A Song of Fire and Ice</title>
      <author>George R. R. Martin</author>
    </book>

</library>

to parse this XML
public Class myXMLParser{

    public Library parse(String xmlInput){
        Dom.Document myXml = new Dom.Document();
        myXml.load(xmlInput);

        Library result;

        // We'll basically be re-using the general structure of this loop throughout
        //    the parsing logic for the inner classes.
        // Check the node name, create an appropriate instance of an inner class,
        //    and then pass the responsibility to parse the current node
        //    to that inner class.

        for(Dom.XmlNode node :myXml.getRootElement().getChildElements()){
            if(node.getName() == 'CONTACT'){
                result = new Library();
                result.process(node);
            }
        }

        return result;
    }

    public Class Library{
        public List
 sections;

        public Library(){
            sections = new List
();
        }

        // Having all of the child classes implement a 'process' method
        //    makes it easier to break up the parsing into small, well-defined
        //    chunks.
        // This causes our parsing to be recursive.

        public void process(Dom.XmlNode inputNode){

            // This loop should look familiar.
            // The logic has changed a little bit, but it is essentially the
            //    same loop as we run in the outer class

            for(Dom.XmlNode node :inputNode.getChildElements()){
                if(node.getName() == 'section'){
                    Section entry = new Section();
                    entry.process(node);

                    // Since we can run into many 'section' nodes, we need
                    //    to add the result to a list after it has finished being parsed.
                    sections.add(entry);
                }
            }
        }
    }

    public Class Section{
        public String name;
        public List<Book> books;

        public Section(){
            books = new List<Book>();
        }

        public void process(Dom.XmlNode inputNode){
            // More of the same general loop.
            // Dom.XmlNode.getText() is what you use to get at the value inside
            //   an XML node. It always returns a string, so you'll need to type-cast
            //   the result if you expect an Integer, Boolean, etc...

            for(Dom.XmlNode node :inputNode.getChildElements()){
                if(node.getName() == 'name'){
                    name = node.getText();
                } else if(node.getName() == 'book'){
                    Book singleBook = new Book();
                    singleBook.process(node);
                    books.add(singleBook);
                }
            }
        }
    }

    public class Book{
        String title;
        String author;

        public Book(){
        }

        // The leaf nodes in your XML schema are likely all primitive types.
        // A leaf node means it doesn't have any children
        //    (other than a text node, that is).
        // Without more children, we have nothing more to call process() on, so our
        //   recursion ends here.

        public void process(Dom.XmlNode inputNode){
            for(Dom.XmlNode node :inputNode.getChildElements()){
                if(node.getName() == 'title'){
                    title = node.getText();
                }else if(node.getName() == 'author'){
                    author = node.getText();
                }
            }
        }
    }
}


text:
Q: SymPy - apply limits to an indefinite integral In SymPy, is it possible to apply limits to an indefinite integral and evaluate it?
import sympy
from sympy.abc import theta

y = sympy.sin(theta)

Y_indef = sympy.Integral(y)
Y_def = sympy.Integral(y, (theta, 0, sympy.pi / 2))

Y_def.evalf() produces a number.
I'm looking for something like Y_indef.evalf((theta, 0, sympy.pi/2)) to get the same answer.

A: I do not know of a direct way, however you can extract the information from Y_indef in order to create a definite integral:
>>> indef = Integral(x)
>>> to_be_integrated, (free_var,) = indef.args
>>> definite = Integral(to_be_integrated, (free_var, 1, 2))

.args is a general attribute containing anything needed to construct most SymPy objects.
Edit: To address the comments to the questions.

*

*SymPy may succeed evaluating definite integral and at the same time fail to solve their indefinite version. This is due to the existence of additional algorithms to be applied to definite integrals.

*Both definite and indefinite integrals are instances of the same class. The only difference is what they contain in their .args. The need for different classes is not yet felt, given that SymPy mostly uses Integral as a flag to say that it can not solve the integral (i.e. the integrate function returns Integral when all of the implemented algorithms fail).


text:
Q: HTML To Image To Base64 I am struggling with this situation, where I have some HTML markup in a JavaScript variable.
What I want is, to convert the value of that variable into an image and get the base64 value:
var print_markup = '';
print_markup += '
' + $scope.config.business_name + '
';
print_markup += '
' + $scope.config.business_address + '
';

I tried this html2canvas but it needs a dom element as its argument not an HTML string, or I am not using it right.
html2canvas(print_markup, {
    onrendered: function(canvas) {
        var dataURL = canvas.toDataURL();
        var base64String = dataURL.split(',')[1];

   }
})

But I get this:

html2canvas.js:592 Uncaught (in promise) Proxy must be used when rendering url

A: Please refer the link : here
var node = document.getElementById('my-node');

domtoimage.toPng(node)
    .then (function (dataUrl) {
        var img = new Image();
        img.src = dataUrl;
        document.appendChild(img);
    })
    .catch(function (error) {
        console.error('oops, something went wrong!', error);
    });

A: As @Kaiido suggested, the html2canvas's first argument is an element that is appended to the original document,
See this html2canvas for more informations


text:
Q: What is my mistake in calculating $**(x\wedge y)$? According to Wikipedia, we have that the Hodge star is defined so that
$$\alpha\wedge *\beta=\langle A,B\rangle\omega,$$
so it seems that in 4-dimensional space with basis $x,y,z,w$ and $\omega=x\wedge y\wedge z\wedge w$, we should have
$$*(x\wedge y)=z\wedge w$$
and also
$$*(z\wedge w)=x\wedge y$$
because $\langle x\wedge y, x\wedge y\rangle=1$ and $\langle w\wedge z, w\wedge z\rangle=1.$
However, again according to Wikipedia, we have
$$**(\eta)=-1^{k(n-k)}s\eta,$$
where $s=1$ if $\langle\cdot,\cdot\rangle$ is an inner product.  So, we should have
$$**(x\wedge y)=-x\wedge y.$$
Which step am I making a mistake in?

A: In the formula $**(\eta)=(-1)^{k(n-k)}s\eta,$ $n$ is the dimension of the vector space and $k$ is the degree of $\eta$.  So in your case with $\eta=x\wedge y$, $n=4$ and $k=2$ so $(-1)^{k(n-k)}$ is $1$, not $-1$.


text:
Q: How to make step response of exp function in Matlab? G = exp(-s) * (0.8*s^2+s+2)/(s^2+s);
T = feedback(ss(G),1);
step(T)

this is example from Matlab's documentation, but it's not working, when copy and paste to program, even if I declare that 's' is syms.

A: Define s using
s = tf('s');


text:
Q: Visual C# webclient no status code when exception message is The underlying connection was closed: An unexpected error occurred on a receive I have a windows form application in C# that uses Webclient to download the source code of a website, I am displaying the status code in case of exception. When the Webexception message is

The underlying connection was closed: An unexpected error occurred on a receive

The status code is not shown, rather the program breaks with the error:

Object reference not set to an instance of an object

My code is like:
string source = "";
try
{
  source = await client.DownloadStringTaskAsync("URL");
}
catch(WebException er)
{
  textbox1.AppendText("\r\nError: " + er.Message + "Status Code: " + ((HttpWebResponse)er.Response).StatusCode);
}

A: From MSDN on the value of WebException.Response:

If a response is available from the Internet resource, a WebResponse
  instance that contains the error response from an Internet resource;
  otherwise, null.

*

*from http://msdn.microsoft.com/en-us/library/system.net.webexception.response(v=vs.110).aspx
It's possible for the WebException.Response to be null if there is no response available. You should take that out of your catch block and instead just print the exception message. Or, if you want to print the WebException.Response if one exists, do a null check.


text:
Q: Create form data in PDF Java I want to extract one object's details to a PDF file and also wants to have a facility within that exported PDF file to amend/edit the data.
For eg: Try to export student object details to PDF in some very specific format like display name in first row, age in second row etc and once the data is exported I should be able to edit it too ( like changing the retrieved age).
Initially I was thinking of creating a GUI within this application which shows the data and user can edit before performing any action like printing, mailing etc, but wanted to avoid this GUI creation and directly deal with the exported PDF there.
I'm very new to this area and tried googling about it, but couldn't find one correct solution.
The object in the question is a java object and I'm trying to view this java object details in PDF file.
Any pointers would greatly help me.

A: What it sounds like you're trying to do is to serialize and deserialize a Java object into a PDF Form. This is straightforward, but it isn't a small amount of work.
Ignoring XFA, in PDF land a Form is a hierarchical tree of fields. The nodes in the tree have names and may also have values that will be projected downward (such as field type or default value). The leaves are all represented by widget annotations.
The main field types in PDF are:

*

*Text

*Button

*Choice

*Signature

From there is straight forward to map the following types:

*

*Numeric

*Boolean

*String

*Enum

*EnumSet

It is possible to do more complex types like Date, but there is no native support and you would need to depend on undocumented js libraries from Adobe.
If your type includes no more than this, then it's doable. Both iText and JoltImage can work as a back end for this, but you'll need to have a fairly good understanding of PDF to use iText and at least a rudimentary understand for JoltImage.  For example, to make a set of radio buttons in JoltImage, you would do something like this:
    // make a document
    PdfGeneratedDocument doc = new PdfGeneratedDocument();
    // add a form
    doc.setForm(new PdfForm());
    // make a page
    PdfGeneratedPage page = doc.addPage(PdfDefaultPages.letter());
    // create a font resource
    String font = doc.getResources().getFonts().addFromFontName("Arial");

    String[] values = new String[] { "Yes", "No", "Undecided" };
    PdfBounds[] bounds = new PdfBounds[] {
        new PdfBounds(72, 700, 12, 12),
        new PdfBounds(72, 680, 12, 12),
        new PdfBounds(72, 660, 12, 12)
    };
    // a RadioButtonFormField is a hierarchy of a parent field with a child
    // RadioButtonWidgetAnnotation for each choice.
    // This call, in addition to making all the fields will add the
    // annotations to the page supplied.
    RadioButtonFormField ff = RadioButtonFormField.makeRadioSet(doc.getResources(), page, "Choice", values[0], values[0],
        values, bounds);

    // Add the parent field to the form tree
    doc.getForm().getFields().add(ff);

    // add labels onto the page.
    // labels are not typically part of the widget annotation.
    for (int i = 0; i < values.length; i++)
    {
        page.getDrawingList().add(new PdfTextLine(font, 12, values[i], new PdfPoint(bounds[i].getRight() + 4, bounds[i].getBottom())));
    }
    doc.save("radiobuttons.pdf");

A: Download Chapter6 of my book and read the part about creating a form using OpenOffice (or LibreOffice) in section 6.3.5. This is the template in which you define fields for the student's "name", 'age", etc...
Once you have this template with the fields "name" and "age", you can use iText to fill out this form like this:
public void manipulatePdf(String src, String dest) throws DocumentException, IOException {
    PdfReader reader = new PdfReader(src);
    PdfStamper stamper = new PdfStamper(reader,
            new FileOutputStream(dest));
    AcroFields fields = stamper.getAcroFields();
    fields.setField("student", "Anil Pradhan");
    fields.setField("age", "25");
    stamper.close();
    reader.close();
}

In this example, src is the path to your empty template and dest is the path to a newly created form that is filled out.
If you have dest, you can also programmatically retrieve the content of the fields. For instance:
PdfReader reader = new PdfReader(src);
AcroFields fields = reader.getAcroFields();
String name = fields.getField("name");
String age = fields.getField("age");

It's as simple as this. You can find more examples here and be sure to download the free ebook The Best iText Questions on StackOverflow to learn more about other options.

A: Have you looked at Jasper Reports:
Jasper Reports Library
With this library you can define the template of the PDF, you can decide what and where you should put all the information you want. I have used it and it is quite good generating reports.


text:
Q: data store with a "get or block" operation? I'm looking for a data store that has a "get or block" operation. This operation would return the value associated with a key/query if that value exists or block until that value is created.
It's like a pub/sub message queue but with a memory to handle the case when the subscriber connects after the publisher has published the result.
This operation allows unrelated processes to rendezvous with each other, and it seems that it would be a very useful architectural building block to have - especially in a web environment - i.e. a web request comes in which kicks off a backend server process to do some work and the web client can get the results via a future AJAX call.
Here is an blog post I found on how to accomplish this sort of operation with mongodb:
http://blog.mongodb.org/post/29495793738/pub-sub-with-mongodb
What other solutions are in use today? Can I do the same thing with redis or rabbitmq? I've looked at the docs for both, but it's unclear exactly how it would work. Should I roll my own server with 0MQ? Is there something out there specifically tailored for this problem?

A: Your are correct both Redis[1] and rabbitmq[2] have pub/sub capabilities.
[1] http://redis.io/topics/pubsub
[2] http://www.rabbitmq.com/tutorials/tutorial-three-python.html


text:
Q: What happens if using GPGPU APIs in a DLL and in the calling application I'm currently designing a dll (and so) library, that will build offload tasks to CUDA, SYCL, OpenCL or Vulkan (not yet decided).
As it is unknown what the application will do (might also use the same APIs), my question is, whether there might arise runtime issues for one of the APIs, when using it it in the DLL and in the application.
I'd guess that, creating two contexts in SYCL/OpenCL/Vulkan wouldn't hurt and should separate the API calls accordingly. Is that right and is it sufficient to just explicitly create a context / stream (in CUDA) in the DLL?
Would it additionally be possible to hand a buffer object from the DLL to the application, so that the calling application could directly use the same buffer on their context or is it required to copy to the host first?

A: I have the feeling that it should work if you keep using the same API.
Of course if you are mixing a lot of API it might be quite more complex.
If for example you have a SYCL implementation with an OpenCL back-end, you can share the buffer on the device between some SYCL and OpenCL use cases. Buy if you want to use the same data between SYCL implementation incompatible with CUDA and CUDA, then you need probably to involve some intermediate host storage.


text:
Q: Geyer: nonparametric bootstrap hypothesis tests typically have no power. Why? I came across this page and was surprised and confused by the following:

A naive person attempting to do a bootstrap test just calculates a P-value as something like
mean(tstat.star > tstat.hat)
where tstat.hat is the value of the test statistic calculated for the actual data and tstat.star is a vector of values of the test statistic calculated for bootstrap samples.
The resulting test is a valid hypothesis test in the sense that a test with nominal significance level α actually has that significance level.
But (a big but!) this test typically has no power. It rejects the null hypothesis with probability α regardless of what the alternative is. No matter how large the deviation of the true parameter value from the null hypothesis, the naive bootstrap test typically doesn't find any "statistical significance."

He goes on to say

There are a variety of special situations in which something that makes sense as a nonparametric bootstrap hypothesis test can be done. Efron and Tibshirani, Chapter 16 describe a few. But if you don't see a general principle in their explanation, don't worry. There isn't any.

I'm having a hard time coming up with an example in which the test has no power, regardless of the true parameter value. Also, based on the second quote, I suppose the standard examples for nonparametric hypothesis testing are considered by Geyer to be special situations?
I understand that for tests that don't involve just shuffling or otherwise manipulating data labels, it can be difficult to sample from the null hypothesis, but it seems that Geyer is already assuming a valid test, i.e., this is not the failure mode he has in mind.

A: Here is how I would interpret Geyer in a simulation:
set.seed(132090)
X <- rnorm(20, mean = 2, sd = 4)

# test statistic calculated for the actual data  H0: mu = 0
tstat.hat <- (mean(X) - 0) / (sd(X) / sqrt(20))

# vector of values of the test statistic calculated for bootstrap samples
tstat.star <- numeric(100000)
for (i in seq_along(tstat.star))
{
  Xi <- sample(X, size = 20, replace = TRUE)
  tstat.star[i] <- (mean(Xi) - 0) / (sd(X) / sqrt(20))
}

# expect this to be near 0.5 for a symmetric distribution
#   Not sure why this is considered to be a valid hypothesis test with alpha significance
mean(tstat.star > tstat.hat)
#> [1] 0.49865

# this makes more sense as a valid hypothesis test  H0: mu < 0
mean(tstat.star <= 0)
#> [1] 0.10838
t.test(X, alternative = "greater")$p.value
#> [1] 0.1212443

# also agree with the confidence interval idea, of course
quantile(tstat.star, probs = c(0.025, 0.975))
#>       2.5%      97.5%
#> -0.7010223  3.1392164
c(mean(X) + qt(0.025, df = 20-1)*sd(X)/sqrt(20), mean(X) + qt(0.975, df = 20-1)*sd(X)/sqrt(20))
#> [1] -0.8450756  3.1445932

############

# if null is true H0: mu = 0

set.seed(12290)
X <- rnorm(20, mean = 0, sd = 4)

tstat.hat <- (mean(X) - 0) / (sd(X) / sqrt(20))

tstat.star <- numeric(100000)
for (i in seq_along(tstat.star))
{
  Xi <- sample(X, size = 20, replace = TRUE)
  tstat.star[i] <- (mean(Xi) - 0) / (sd(X) / sqrt(20))
}

# same
mean(tstat.star > tstat.hat)
#> [1] 0.4944

mean(tstat.star < 0)
#> [1] 0.4627

quantile(tstat.star, probs = c(0.025, 0.975))
#>      2.5%     97.5%
#> -1.755945  2.046421

If you look down the page in the link, Geyer does the same type of thing:
x <- rnorm(20, 0, 1)
y <- rnorm(20, 0, 1)

theta.hat <- cor(x, y)

n <- length(x)
nboot <- 1e5
theta.star <- double(nboot)
for (i in 1:nboot) {
  k.star <- sample(n, replace = TRUE)
  theta.star[i] <- cor(x[k.star], y[k.star])
}

## lower-tailed test of theta = 0
ltpv <- mean(theta.star <= 0)
ltpv
#> [1] 0.95744

## upper-tailed test of theta = 0
utpv <- mean(theta.star >= 0)
utpv
#> [1] 0.04256

## two-tailed test of theta = 0
2 * min(ltpv, utpv)
#> [1] 0.08512


text:
Q: laravel: odd behavior when query is empty I have a model
I call it this way:
Sight::filter(['type'=>'menu']);

and in model:
public function scopeFilter($query,$params)
{
    return $query
        ->wherePublish(1)
        ->whereIn_special(1)
        ->latest()
        ->first();
}

when there is one or more records, it works normally.
but when database is empty I get an odd behavior:
with dd(Sight::filter(['type'=>'menu']))
or
$query
        ->wherePublish(1)
        ->whereIn_special(1)
        ->latest()
        ->first();
        dd($query);

I got this result:

But with
dd(
$query
            ->wherePublish(1)
            ->whereIn_special(1)
            ->latest()
            ->first();
)

I got Null so it is right!
how can I return Null? what is my wrong?

A: You shouldn't be calling first() inside of a scope - you are only meant to adjust the query by constraining it. You should call first() in your chain after applying the filter() scope. If you want to use the same syntax rather than chaining like that you would be best to define a custom static method.
public static function filter($params)
{
    return self::wherePublish(1)
        ->whereIn_special(1)
        ->latest()
        ->first();
]

Also note that in your example your scope accepts an argument (and you pass it one) but it isn't actually used in your code.


text:
Q: I'm trying to add a mailto link to my website; its works fine offline, but online it gives me a 404 error I'm using Dreamweaver CS6 to built a basic webiste for a friend;
On the contact page, I'm trying to add a mailto link ; it does not work wen I upload into Filezilla but works fine when I try it offline (I use Firefox 52.0.1 and the host is Godaddy)).
Here is the code for the page:

And if I click online on the link, I got that page :

Any clue of what is happening?
A4

A: I've visited your website with Firefox and Chrome. Everything works fine for me.
From your screenshot it looks, like the error you're getting is because you've forgotten about putting "mailto:" in front of your e-mail, but I can see in the code, that it's there, and of course it works for me.
My guess is that first you didn't add "mailto:', then added it, but for some reason Firefox is still showing you the old version of your website. To force complete refresh on Mac, you can press: Command + Shift + R. This should solve your problem.


text:
Q: code snippet and Behaviour of Arrow function and Normal function Can anyone help me understand the output of the below small es6 program?
I know the difference between arrow function and normal function.
The Arrow function runs in parent's scope.
The Normal function runs in its own scope.
PFB the programme that's confusing me.
function Temp(){
  this.x =99;
  y =88;
  var z =77;

  setTimeout(function(){console.log(this.y+"::",this.x,"--",this.z),5});
  setTimeout(()=>{console.log(this.y+"||",this.x,"--",this.z),5});

  doit(function (){ console.log(this.y+":",this.x,"_",this.z);})
  doit(()=>{console.log(this.y+"|",this.x,"-",this.z);});

  function doit(task){
    this.i =0;
    task();
  }
}

new Temp();

Output
88:: undefined --undefined
undefined|| 99 --undefined
88: undefined -undefined
undefined| 99-undefined

es6 Playground
es6console link
Wanted to know the association between variable declaration and function (arrow/normal).

A: If you are not declaring a variable (e.g. not using this.y or one of const, let and var) it is attached to the global scope (for browsers that is window).
When you call an anonymous function, it uses the global scope (window).
I added comments on your code.

function Temp() {
  this.x = 99; // local scope
  y = 88; // global scope (attached on window as it is not declared)
  // this.y is never

  setTimeout(function() { // Scope is window/global
    console.log('log1', this.y + ":::", this.x)
  }, 5);

  setTimeout(() => { // Scope is Temp
    console.log('log2', this.y + "||", this.x)
  }, 5);

  doit(function() { // Because it is an anonymous function
                    // the scope is now that of window
    console.log('log3', this.y + ":", this.x);
  })
  doit(() => { // Arrow function: the scope of Temp
    console.log('log4', this.y + "|", this.x);
  });

  function doit(task) {
    this.i = 0;
    task();
  }
}

new Temp();

So to recap: Always declare variables using const or let. Also for better understanding, use the new class syntax. It is just a syntax sugar, but still helps to make your code better understandable.


text:
Q: Cache static table in memory SQL Server CE 3.5? I'm working on a windows mobile 6.5 app and my .NET is not that great yet. I have a table in my database that is very rarely updated and is used in joins with other throughout the app. The performance is not good enough. The device has more than enough memory to store the whole table, so I was wondering whether I could make the SQL Server CE store the table in RAM and get an instant speed up throughout?
I would deal with updates to this table separately as it's only done in one place and rarely.
Or is there a better solution?
I could just bash out a hash table and change all my queries to use it instead, but was wondering whether there was a lazier/more elegant way of doing it.


text:
Q: React state array seemingly reverts to original I have a state array like so:
const [menusActive, setMenusActive] = useState([
    "MainMenu"
]);

It keeps track of what menus are visible. My method for this is sending a menu key/name to a function toggleArrayItem() which adds the key to the array if it doesn't exist, or removes it if it does:
function toggleArrayItem(arr, item) {
    console.log('item: ', item);
    console.log('arr: ', arr);
    let returnArray = [];
    if (arr.includes(item) === true) {
        console.log('removing item: ', item);
        returnArray = arr.filter(i => i !== item) // remove item
    } else {
        console.log('adding item: ', item);
        returnArray = [ ...arr, item ]; // add item
    }
    console.log('returnArray: ', returnArray);
    return returnArray;
}

When a menu item is clicked it performs the following:
    let existingMenu = [...menusActive];
    console.log('menu were sending to toggleArrayItem is: ', existingMenu);
    let updatedMenu = toggleArrayItem(existingMenu, menuName);
    setMenusActive(updatedMenu);

While debugging I check for menuActive updates via:
useEffect(() => {
    console.log('menusActive after: ', menusActive);
}, [menusActive]);

The console output makes sense on the first menu click...
menu were sending to toggleArrayItem is:  ["MainMenu"]
MenuDock.js:36 item:  SubMenu
MenuDock.js:37 arr:  ["MainMenu"]
MenuDock.js:43 adding item:  SubMenu
MenuDock.js:46 returnArray:  (2) ["MainMenu", "SubMenu"]
MenuDock.js:54 menusActive after:  (2) ["MainMenu", "SubMenu"]

But doesn't when I click the same menu item again:
menu were sending to toggleArrayItem is:  ["MainMenu"]
MenuDock.js:36 item:  SubMenu
MenuDock.js:37 arr:  ["MainMenu"]
MenuDock.js:43 adding item:  SubMenu
MenuDock.js:46 returnArray:  (2) ["MainMenu", "SubMenu"]
MenuDock.js:54 menusActive after:  (2) ["MainMenu", "SubMenu"]

What happened to the second array item, "SubMenu" that was just declared as existing in menusActive before I tried a second menu click (which I believed would remove "SubMenu" rather than trying to add it again)?

Full component
I summarised what I thought was relevant in the above, so as not to overwhelm. In case I've left anything useful out, here is the full component:

export const MenuDock = ({ side, menuJSON }) => {

    const [menuListItemArray, setMenuListItemArray] = useState([]);
    const [menusActive, setMenusActive] = useState([
        "MainMenu"
    ]);

    function handleItemClick(menuName) {
        if (menuName !== "none") {
            let existingMenu = [...menusActive];
            console.log('menu were sending to toggleArrayItem is: ', existingMenu);
            let updatedMenu = toggleArrayItem(existingMenu, menuName);
            setMenusActive(updatedMenu);

        }
    }

    function toggleArrayItem(arr, item) {
        console.log('item: ', item);
        console.log('arr: ', arr);
        let returnArray = [];
        if (arr.includes(item) === true) {
            console.log('removing item: ', item);
            returnArray = arr.filter(i => i !== item) // remove item
        } else {
            console.log('adding item: ', item);
            returnArray = [ ...arr, item ]; // add item
        }
        console.log('returnArray: ', returnArray);
        return returnArray;
    }

    useEffect(() => {
        // Toggle visible menus
        console.log('menusActive after: ', menusActive);
    }, [menusActive]);

    useEffect(() => {

        let jsxArray = [];

        let json2Array = [...menuJSON.MainMenu];
        let menuSort = [];
        menuSort['MainMenu'] = [];

        for (const [key, element] of Object.entries(json2Array)) {
            menuSort['MainMenu'].push(element);
            if (element.submenu !== "none" && element.submenu !== undefined) {
                let submenuKeys = Object.keys(element.submenu);
                let subKey = submenuKeys[0];
                menuSort[subKey] = [];
                element.submenu[subKey].forEach(subelement => {
                    menuSort[subKey].push(subelement);
                });

            }
        };

        for (const [key, menus] of Object.entries(menuSort)) {

            let itemArray = [];
            for (const [k2, items] of Object.entries(menuSort[key])) {

                function pcbValues(e) {
                    handleItemClick(items.submenukey);
                }

                itemArray.push(<MenuItem label={items.label} action={items.action} submenuKey={items.submenukey} handleClick={pcbValues} />)
            }
            jsxArray.push(<MenuList menuArray={itemArray} key={key} />);
        }

        setMenuListItemArray(jsxArray)

    }, []);

    return (

            {menuListItemArray}

    );
};

A: The problem is that the menusActive array that the handler function has in its scope is only the array from the initial render. See here:
useEffect(() => {
    let jsxArray = [];
    // other code omitted
    for (const [key, menus] of Object.entries(menuSort)) {
        let itemArray = [];
        for (const [k2, items] of Object.entries(menuSort[key])) {
            function pcbValues(e) {
                handleItemClick(items.submenukey);
            }
            itemArray.push(<MenuItem label={items.label} action={items.action} submenuKey={items.submenukey} handleClick={pcbValues} />)
        }
        jsxArray.push(<MenuList menuArray={itemArray} key={key} />);
    }
    setMenuListItemArray(jsxArray)
}, []);

The stateful menuListItemArray changes exactly once: right after the component mounts, in the effect hook. After the effect hook runs and the state gets populated, it stays like that forever. What this means is that this section of a MenuItem here never changes either:
function pcbValues(e) {
    handleItemClick(items.submenukey);
}
itemArray.push(<MenuItem label={items.label} action={items.action} submenuKey={items.submenukey} handleClick={pcbValues} />)

And, at the time that the effect hook runs, the handleItemClick that was declared at the top of the component references the initial array - the ["MainMenu"], and nothing else. Calling setMenusActive later doesn't change the fact that the menusActive that the handler function that the JSX (created right after the initial render) has scope of is only the initial stateful array.
This code here is one of the reasons why putting JSX into state can easily lead to problems. A better approach is to put (serializable) plain arrays, objects, and primitives into state, and then turn the state into JSX when returning at the end of the component. Something like this:
export const MenuDock = ({ side, menuJSON }) => {
    const [menuListObj, setMenuListObj] = useState([]);
    // ...
    useEffect(() => {

        let jsxArray = [];

        let json2Array = [...menuJSON.MainMenu];
        let menuSort = [];
        menuSort['MainMenu'] = [];

        for (const [key, element] of Object.entries(json2Array)) {
            menuSort['MainMenu'].push(element);
            if (element.submenu !== "none" && element.submenu !== undefined) {
                let submenuKeys = Object.keys(element.submenu);
                let subKey = submenuKeys[0];
                menuSort[subKey] = [];
                element.submenu[subKey].forEach(subelement => {
                    menuSort[subKey].push(subelement);
                });

            }
        };
        setMenuListObj(menuSort);
    }, []);
    return (

            {
                Object.entries(menuListObj).map((key, menuItems) => <MenuList {...{ menuItems, key, handleItemClick }} />)
            }

    );
};

where the MenuList component takes the menuItems, key, handleItemClick props (which are now guaranteed to be from the most recent update!) and turns them into JSX itself (replacing what was previously <MenuItem label={items.label} action={items.action} submenuKey={items.submenukey} handleClick={pcbValues} />)


text:
Q: How to use Lagrange Multipliers, when the constraint surface has a boundary? The method called Lagrange Multipliers is used to find critical points of $f(x_1,x_2,\ldots,x_n)$, when $f$ is constrained to the level set $S = \{ x\in \mathbb{R}^n \, | \, g(x_1,x_2,\ldots,x_n)=0 \}$.
These critical points may be used to locate local minima and maxima.
When $S$ is a compact set, we know that a global max and min of $f$ exist on $S$.
Do we also have to check what happens on the boundary of $S$, in case a boundary exists ?

A: Another example to supplement that of Sharkos: $f(x,y)=x+y$ and $g(x,y)=\sqrt{x}+\sqrt{y}-1.$ Then the only critical point found by LaGrange is at $(1/4,1/4)$ where $f=1/2$, but the max of $f=1$ occurs at both points $(1,0),(0,1)$. The constraint region here is the inwardly bent curve $y=(1-\sqrt{x})^2$ for $0 \le x \le 1$ and has $(1,0),(0,1)$ as its boundary points.
ADDED: Teddy has in a comment noted that when $\nabla g$ is not defined, one considers that to be a critical point. So here is another example, similar to the above, which avoids that issue. Let $f(x,y)=x+y$ and $g(x,y)=x^{3/2}+y^{3/2}-1$. Note that the implicit radicals in the constraint impose that $x,y \ge 0$, and that this means we have
$$\nabla g = ((3/2)x^{1/2},(3/2)y^{1/2}),$$ which exists and is nonzero at all points on the constraint curve (it's the zero vector only at the origin, clearly not on the constraint curve).
In this case the constraint curve is the graph of $y=(1-x^{3/2})^{2/3}$ on the interval $[0,1]$, having endpoints at $(1,0),(0,1)$, and the graph bends outward away from the origin. There is now only one critical point at $(x,y)=(a,a)$ where $a=(1/4)^{1/3}$. At that point, $f=2^{1/3}\approx. 1.259$, while at the "boundary of constraint region" points $(1,0),(0,1)$ we have $f=1$. So if we seek the minimum we would have to look at the boundary points of the constraint region, at non-critical points.

A: Yes. For example, $f(x,y) = x^2+y^2$ and $g(x,y)=|x|+|y|-1$. Then $S$ is a series of smooth lines joined at sharp corners. The maxima are attained at these corners. You can make a more convoluted $g$ to make these corners just ends.


text:
Q: I'm easy to please / I'm easy to be pleased We have a phrase:

I'm easy to please.

This means:

I can be pleased easily.

Shouldn't the phrase be:

I'm easy to be pleased.

Just like:

The game is easy to be played.?

Thank you.

A: Adjectives With Passive Infinitives
You may also see adjectives inserted into a passive infinitive construction, such as fit, ready, eager, and easy. Check out these examples from "A History of the English Language:"
"With adjectives, passive infinitives are generally only used in PDE [present-day English] when an active infinitive may lead to ambiguity, as in the case of likely or fit, cf. you are not fit to be seen...Another adjective which has retained the option of using a passive infinitive is ready. Thus the well-known ambiguity of (113) can be avoided by using the variant in (114):
(113) The lamb is ready to eat.
(114) The lamb is ready to be eaten."
Olga Fischer and Wim van der Wurff, "Syntax."
"Other adjectives still allowing the passive infinitive tend to be like ready in that they can occur in both the easy-to-please construction...and the eager-to-please construction (where it is to be interpreted as the subject of the infinitive)."

A: Try these instead:

? I'm easy to be pleased.
  → ✔ I'm easily pleased.
? The game is easy to be played.
  → ✔ The game is easily played.

While easy to be in these sentences is not necessarily ungrammatical in a purely syntactical sense, it is unidiomatic.
In both cases, the word you're looking for is an adverb. In the original constructions, what's being used instead is a phrase that makes use of a so-called flat adverb (or bare adverb). Although this is sometimes done (drive slow rather than drive slowly), it's not normally used in this particular context—and certainly not when a single normal adverb can take the place of a flat adverbial phrase.

A: 1 and 2 are correct.  Don't think 3 is. 4 shouuld be transformed into 'to play'. I'll try to find this grammar with its exceptions(passive used), and mmaybe will return)

A: Mostly we use an active infinitive instead of a passive infinitive with some adjectives like easy, difficult, impossible, etc. in a clause in which the subject is really the object of the infinitive. This use is a special construction (according to Michael Swan). So you should say:
I am easy to please = It's easy to please me = To please me is easy = I am easily pleased.
This game is easy to play = It's easy to play this game = To play this game is easy = This game is easily played.