text:
Q: NULL Pointer Exception Error Application Crashed After Clicking on Recycler List Item I am working on an android application that is showing data in Recycle List View Holder. When I Click on List Item in Recycler View Holder the application crashes.
public class UserRecyclerAdapterSavedUsers extends RecyclerView.Adapter<UserRecyclerAdapterSavedUsers.UserViewHolder> {

private List<User> listUsers;
Context mContext;
ItemClickListenerLongPressed itemClickListenerLongPressed;

public UserRecyclerAdapterSavedUsers(List<User> listUsers) {
    this.listUsers = listUsers;
}

@Override
public UserViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View itemView = LayoutInflater.from(parent.getContext())
            .inflate(R.layout.item_user_recycler_second, parent, false);

    return new UserViewHolder(itemView);
}

@Override
public void onBindViewHolder(UserViewHolder holder, int position) {
    holder.textViewID.setText(listUsers.get(position).getUserid());
    holder.textViewName.setText(listUsers.get(position).getName());
    holder.textViewPassword.setText(listUsers.get(position).getPassword());
    holder.textViewRole.setText(listUsers.get(position).getRole());

}

public void setItemClickListenerLongPressed(ItemClickListenerLongPressed itemClickListenerLongPressed){
    this.itemClickListenerLongPressed=itemClickListenerLongPressed;
}

@Override
public int getItemCount() {
    Log.v(UserRecyclerAdapterSavedUsers.class.getSimpleName(),""+listUsers.size());
    return listUsers.size();
}

/**
 * ViewHolder class
 */
public class UserViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {

    //public AppCompatTextView ID;
    public AppCompatTextView textViewID;
    public AppCompatTextView textViewName;
    public AppCompatTextView textViewPassword;
    public AppCompatTextView textViewRole;

    public UserViewHolder(View view) {
        super(view);

        textViewID = (AppCompatTextView) view.findViewById(R.id.textViewID);
        textViewName = (AppCompatTextView) view.findViewById(R.id.textViewName);
        textViewPassword = (AppCompatTextView) view.findViewById(R.id.textViewPassword);
        textViewRole = (AppCompatTextView) view.findViewById(R.id.textViewRole);
    }

    @Override
    public void onClick(View v) {
        if (itemClickListenerLongPressed != null) itemClickListenerLongPressed.onClick(v, getAdapterPosition());
        Toast.makeText(mContext, "USMAN", Toast.LENGTH_SHORT).show();

    }
}

}
Here is the users List activity
public class UsersListActivity extends AppCompatActivity implements ItemClickListenerLongPressed{

AppCompatActivity activity = UsersListActivity.this;

AppCompatTextView textViewName;
RecyclerView mRecyclerView;
AppCompatButton textViewButtonNewUser;
UserRecyclerAdapterSavedUsers userRecyclerAdapterSavedUsers;
List<User> listUsers;

DatabaseHelper databaseHelper;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_user_record_updated_list);
    mRecyclerView= (RecyclerView) findViewById(R.id.recyclerViewUsers);
    mRecyclerView.setAdapter(userRecyclerAdapterSavedUsers);
    userRecyclerAdapterSavedUsers.setItemClickListenerLongPressed(this);

    initViews();
    initObjects();
}

@Override
public void onBackPressed() {
    super.onBackPressed();
    startActivity(new Intent(UsersListActivity.this,AdminMain.class));
    finish();
}

@Override
protected void onRestart() {
    super.onRestart();
}

/**
 * This method is to initialize views
 */
private void initViews() {
    textViewName = (AppCompatTextView) findViewById(R.id.textViewName);
    textViewButtonNewUser = (AppCompatButton) findViewById(R.id.btnaddnew);
    mRecyclerView = (RecyclerView) findViewById(R.id.recyclerViewUsers);
    textViewButtonNewUser.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(UsersListActivity.this,UserRecordSaveActivity.class));
        }
    });

}

/**
 * This method is to initialize objects to be used
 */
private void initObjects() {
    listUsers = new ArrayList<>();
    userRecyclerAdapterSavedUsers = new UserRecyclerAdapterSavedUsers(listUsers);

    RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext());
    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setAdapter(userRecyclerAdapterSavedUsers);
    databaseHelper = new DatabaseHelper(activity);

    String emailFromIntent = getIntent().getStringExtra("USERS");
    textViewName.setText(emailFromIntent);

    getDataFromSQLite();
}

/**
 * This method is to fetch all user records from SQLite
 */
private void getDataFromSQLite() {
    // AsyncTask is used that SQLite operation not blocks the UI Thread.
    new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... params) {
            listUsers.clear();
            listUsers.addAll(databaseHelper.getAllUser());

            return null;
        }

        @Override
        protected void onPostExecute(Void aVoid) {
            super.onPostExecute(aVoid);
            userRecyclerAdapterSavedUsers.notifyDataSetChanged();
        }
    }.execute();
}

@Override
public void onClick(View view, int position) {

}

}
When I clicked on the List Item it crashed and the error was caused by Toast. As I remove the toast the Error goes because of using a try catch item not clicked.
Here is the image of Error.
After Removing try catch It again shows error but this time the error is shown on AlertDialog. Builder.  Here is the image of error without try catch.
Image after removing try and catch
ERROR BEFORE REMOVING TOAST OVER ON CLICK
Image after adding toast logcat Error
Image After Adding Toast
The error is now on users list activity
Image after eidting of code
The actual data in list when removing the click listener
Actual data in list by removing the click listener
Here is my recycler layout file
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
card_view:cardCornerRadius="4dp">
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/Indigo"
    android:orientation="vertical"
    android:padding="16dp">

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

        <android.support.v7.widget.AppCompatTextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:text="User ID"
            android:textColor="@color/colorTextHint" />

        <android.support.v7.widget.AppCompatTextView
            android:id="@+id/textViewID"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="User ID"
            android:textColor="@android:color/darker_gray" />
    </LinearLayout>

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

        <android.support.v7.widget.AppCompatTextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:text="Name"
            android:textColor="@color/colorTextHint" />

        <android.support.v7.widget.AppCompatTextView
            android:id="@+id/textViewName"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Name"
            android:textColor="@android:color/darker_gray" />
    </LinearLayout>

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

        <android.support.v7.widget.AppCompatTextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:text="@string/hint_password"
            android:textColor="@color/colorTextHint" />

        <android.support.v7.widget.AppCompatTextView
            android:id="@+id/textViewPassword"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/hint_password"
            android:textColor="@android:color/darker_gray" />
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:orientation="horizontal">

        <android.support.v7.widget.AppCompatTextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:text="Role"
            android:textColor="@color/colorTextHint" />

        <android.support.v7.widget.AppCompatTextView
            android:id="@+id/textViewRole"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Role"
            android:textColor="@android:color/darker_gray" />
    </LinearLayout>

</LinearLayout>

Here is the Image of Logcat
Logcat Image at Updating Data
Here is the IMEIRecord Save activity Adapter like user record..
public class IMEIRecyclerAdapter extends RecyclerView.Adapter<IMEIRecyclerAdapter.ImeiViewHolder> {

private List<User> ListImei;
Context mContext;
ItemClickListenerLongPressed itemClickListenerLongPressed;
View itemView;

public IMEIRecyclerAdapter(List<User> ListImei) {
    this.ListImei = ListImei;
}

@Override
public ImeiViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    itemView = LayoutInflater.from(parent.getContext())
            .inflate(R.layout.item_user_recycler_imei, parent, false);

    return new ImeiViewHolder(itemView);
}

@Override
public void onBindViewHolder(ImeiViewHolder holder, int position) {
    final User user= ListImei.get(position);
    holder.textViewImeiId.setText(ListImei.get(position).getImeiid());
     holder.textViewImeiNo.setText(ListImei.get(position).getImei());
}

public void setItemClickListenerLongPressed(ItemClickListenerLongPressed itemClickListenerLongPressed) {
    this.itemClickListenerLongPressed = itemClickListenerLongPressed;
}

@Override
public int getItemCount() {
    Log.v(UsersRecyclerAdapter.class.getSimpleName(),""+ListImei.size());
    return ListImei.size();
}

public void displayingAlertDialogimei() {
    final User user= new User();
    //displaying alert dialog box
    AlertDialog.Builder builder = new AlertDialog.Builder(itemView.getContext());
    builder.setTitle("Choose Option");
    builder.setMessage("Update or Delete?");
    builder.setPositiveButton("Update", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {

            //go to update activity
            goToUpdateActivity(user.getUserid());
            dialog.cancel();

        }
    });
    builder.setNeutralButton("Delete", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {

            //go to update activity
            dialog.cancel();

        }
    });
    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    AlertDialog alert11 = builder.create();
    alert11.show();
}

private void goToUpdateActivity(String userid) {
    Intent goToUpdate = new Intent(mContext, RoughUser.class);
    goToUpdate.putExtra("USER_ID", userid);
    mContext.startActivity(goToUpdate);

}

public class ImeiViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{

    public AppCompatTextView textViewImeiId;
    public AppCompatTextView textViewImeiNo;
    LinearLayout layout;

    public ImeiViewHolder(View view) {
        super(view);
        textViewImeiId = (AppCompatTextView) view.findViewById(R.id.textViewImeiId);
        textViewImeiNo = (AppCompatTextView) view.findViewById(R.id.textViewImeiNo);
        layout = (LinearLayout) view.findViewById(R.id.list_view_imei);

        layout.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        displayingAlertDialogimei();
    }
}

}

A: You have not declare mContext in your adapter class.
In Adapter class constructor may change like this.
public UserRecyclerAdapterSavedUsers(List<User> listUsers,Context context) {
    this.mContext= context;
    this.listUsers1 = listUsers;
    user= new User();
}

and Recycle view Activity class you have to change
UserRecyclerAdapterSavedUsers myAdapter = new RecyclerViewAdapter(yourList,this);

A: first add id to your parent LinearLayout  as, android:id="@+id/list_view"
and then update adapter class
public class UserRecyclerAdapterSavedUsers extends RecyclerView.Adapter<UserRecyclerAdapterSavedUsers.UserViewHolder> {

private List<User> listUsers;
Context mContext;
ItemClickListenerLongPressed itemClickListenerLongPressed;
View itemView;

public UserRecyclerAdapterSavedUsers(List<User> listUsers) {
this.listUsers = listUsers;
}

@Override
public UserViewHolder onCreateViewHolder(ViewGroup parent, int viewType)       {
itemView = LayoutInflater.from(parent.getContext())
        .inflate(R.layout.item_user_recycler_second, parent, false);

return new UserViewHolder(itemView);
}

@Override
public void onBindViewHolder(UserViewHolder holder, int position) {
holder.textViewID.setText(listUsers.get(position).getUserid());
holder.textViewName.setText(listUsers.get(position).getName());
holder.textViewPassword.setText(listUsers.get(position).getPassword());
holder.textViewRole.setText(listUsers.get(position).getRole());

}

public void setItemClickListenerLongPressed(ItemClickListenerLongPressed itemClickListenerLongPressed){
this.itemClickListenerLongPressed=itemClickListenerLongPressed;
}

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

private void displayingAlertDialog() {
    //displaying alert dialog box
    AlertDialog.Builder builder = new AlertDialog.Builder(itemView.getContext());
    builder.setMessage("your toast message here...");
    builder.setCancelable(true);

    builder.setPositiveButton(
            "Ok",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();

                }
            });

    AlertDialog alert11 = builder.create();
    alert11.show();
}

/**
 * ViewHolder class
 */
public class UserViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {

//public AppCompatTextView ID;
public AppCompatTextView textViewID;
public AppCompatTextView textViewName;
public AppCompatTextView textViewPassword;
public AppCompatTextView textViewRole;
LinearLayout layout;

public UserViewHolder(View view) {
    super(view);

    textViewID = (AppCompatTextView) view.findViewById(R.id.textViewID);
    textViewName = (AppCompatTextView) view.findViewById(R.id.textViewName);
    textViewPassword = (AppCompatTextView) view.findViewById(R.id.textViewPassword);
    textViewRole = (AppCompatTextView) view.findViewById(R.id.textViewRole);
    layout = view.findViewById(R.id.list_view);

    layout.setOnClickListener(this);
}

@Override
public void onClick(View v) {
    displayingAlertDialog();
}
}

A: Use the Recyclerview Item click like this click here
and then you can access the interface in your activity or fragment and then you can add whatever you need.

*

*giving toast and populating AlertDialog inside the Adapteris not the  proper way of coding


text:
Q: Open new Apple Pages files in an old computer I have and old iMac 24 has OS X Yosemite 10.10.5 and Pages 5.5.3. I need to open some Apple Pages files created in a new Mac computer. The new computer has the last version of Mac OS MacOS Sierra and the last Pages. I am not sure about the versions.
I cannot update the iMac 24 to OS Sierra. If I try in the App Store it says: "This version of macOS 10.12.2 cannot be installed on this computer". I suppose the computer is too old.
Is there any way I can open the Apple Pages files in the old iMac 24?

A: I could open the old files if I uploaded them to iCloud. iCloud always has the last version of Pages and Numbers. That method works well.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Can we deploy EJB 3.x as a separate jar from war (No EAR) on JBoss EAP 6.4 for container managed transactions? I have application in which we do distributed deployment means restws.war, serverEjb.jar and Dao.jar separately and war has there dependency in jboss-deployment-structure.xml.
We are using RestEasy (2.3.10.Final), EJB3 and Spring JDBC Template (4.3.0.RELEASE).
Structure is:
Rest.war
Ejb.jar
DAO.jar

With jboss-deployment-structure.xml
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
  <deployment>
<dependencies>
        <module name="deployment. Ejb.jar"/>
        <module name="deployment.DAO.jar"/>
</dependencies>
  </deployment>
</jboss-deployment-structure>

We have stateless Local session bean with CMT, there is no error in the log while deployment but when we access EJB method no rollback is happening on runtime exception rather each sql statement commits after the execution.
EJB File looks like
@Stateless
public class ProductService {

    @Inject
    ProductDAO productDAO;
    public Product getProduct() {
        Product product =productDAO.getProduct();
        return product;
    }

    public Product createProduct(Product product) {
        return productDAO.createProduct(product);

    }
}

RestEasy Service looks like
@Path("/json/product")
public class ProductService {

    @Inject
    ProductService productService;

    @GET
    @Path("/get")
    @Produces("application/json")
    public Product getProduct() {

        return productService.getProduct();

    }
    @POST
    @Path("/post")
    @Consumes("application/json")
    public Response createProduct(Product product) {
        product=productService.createProduct(product);
        String result = "Product created : " + product;
        return Response.status(201).entity(result).build();
    }
}

If I combine these jar in as WAR using same compiled jar by removing the MANIFEST.MF Dependencies then EJB behavior is as expected and truncation rollback.

War Structure:

Rest.war

    META-INF

    WEB-INF

        classes

        lib

            ejb.jar

            DAO.jar

            …. Third party jar

beans.xml

web.xml

I used same/similar code base to build a ear fine then also it works.

Ear Structure:

ear-application-1.0.ear

    lib

        DAO.jar

        …. Third party jar

    META-INF

        application.xml

    ejb.jar

    web.war

application.xml
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" version="6">
  <display-name>ear-application</display-name>
  <module>
    <web>
      <web-uri>web.war</web-uri>
      <context-root>/rest</context-root>
    </web>
  </module>
  <module>
    <ejb> ejb.jar</ejb>
  </module>
  <library-directory>lib</library-directory>
</application>

Please help me understanding and resolving this issue.


text:
Q: Considering AWS KMS, what would be a proper solution when the encrypted data is used pretty often? I am studying AWS KMS applied to PHP application.
What happens with performance when the encrypted/decrypted data is heavily used?
On solution would be calling AWS KMS pretty often, let's say once per script run. But I am worried about the performance of my php application because of the roundtrips to aws.
An alternative, which I don't like that much is to call AWS KMS once per session: I just decrypt what I need and then keep it as session variable.
What would be the proper design pattern when the data that needs to be kept is used pretty often?
Thanks!

A: You could've used AWS Encryption SDK to implement data key caching which would solve the problem of calling KMS endpoint each time you want to decrypt. But, the Encryption SDK is not available for PHP. I'm not aware of any other solutions :(


text:
Q: Xbacklight won't help to change brightness in lubuntu I have an old acer laptop with following graphics hardware:
00:02.0 VGA compatible controller [0300]:
Intel Corporation System Controller Hub (SCH Poulsbo) Graphics Controller [8086:8108] (rev 07)
    Subsystem: Acer Incorporated [ALI] Device [1025:0244]

I used xbacklight's xbacklight -set XX and xbacklight -dec XX commands but they don't work. If I put these commands, the output is

No outputs have backlight property

A: You should set the brightness from /sys/class/backlight/intel_backlight/brightness file, see my answer in: i3wm, adjust brightness through command line


text:
Q: Cannot install Languages I try to install languages on my ubuntu 12.04. Unfortunately, it is not working, I only get info: "Software database is broken. It is impossible to install or remove any software. Please use the package manager "Synaptic" or run sudo apt-get install -f. in a terminal to fix this issue at first"
I did try to use this command and many other, without success. Any command that I run basically does not detect anything and I still cannot use German keyboard layout. Anyone out there that could help? Ubuntu is really overwhelming..

A: The keyboard layout is different from the system language (or language support).
If you want to change the keyboard layout click on Dash and write "keyboard" . You will see the keyboard layout settings. Open it and you can change the layout from there. It is not necessary to have installed the German language to add in keyboard layout the German language.


text:
Q: Find solution of stochastic differential equations I need to solve this system of stochastic differential equations:
$$\begin{cases}
dX_1(t)=dt+dW_1(t),  \\[2ex]
dX_2(t)=X_1(t)dW_2(t),
\end{cases}$$
where $W_1(t), W_2(t)$ are independent Wiener processes.
From the first equation I found:
$$X_1(t) = t + W_1(t)$$
Then, I substituted $X_1(t)$ in the second equation:
$$dX_2(t)=(t+W_1(t))dW_2(t)=tdW_2+W_1(t)dW_2(t)$$
And I'm stuck on this step. I will be grateful for any help.


text:
Q: a floating action button above popup window Basically I am developping a android UI which contains a floating action button as well as a popup Window. I have set up two differents layout separately, one is activiy_main and another is popup. My goal is to make UI which is quite similar to that of google map.
https://www.google.com/url?sa=i&source=images&cd=&cad=rja&uact=8&ved=2ahUKEwjXoo2GvP_hAhVrAGMBHRGXCuYQjRx6BAgBEAU&url=https%3A%2F%2Fwww.androidauthority.com%2Fgoogle-maps-multi-stop-directions-700971%2F&psig=AOvVaw3dtFX_biqy1dEV9tUjVGlh&ust=1556976616072449
Just like in this picture, there is a floating action button GPS(the white round one which is beyond the popup window.)
I want to make the button be at the bottom of the mapview when the popup window is not displayed(That's why i have left the main_activity in coordinatorlayout) and when it is poped up, the button should go up with the window which makes it always beyond it. Normally I think i can make this by organising them in one relative layout. However, I want to separete two layouts.
Is it a way to position a view in one layout relative above another view in another layout?
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.constraint.ConstraintLayout
        android:id="@+id/linearLayout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <AutoCompleteTextView
            android:id="@+id/search_view"
            android:layout_width="292dp"
            android:layout_height="43dp"
            android:layout_marginStart="8dp"
            android:layout_marginLeft="8dp"
            android:layout_marginTop="8dp"
            android:layout_marginEnd="8dp"
            android:layout_marginRight="8dp"
            app:layout_constraintEnd_toStartOf="@+id/ButtonEnvoyer"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <ImageButton
            android:id="@+id/ButtonEnvoyer"
            android:layout_width="54dp"
            android:layout_height="46dp"
            android:layout_marginTop="4dp"
            android:layout_marginEnd="8dp"
            android:layout_marginRight="8dp"
            android:src="@drawable/places_ic_search"
            android:text="Recherche"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toEndOf="@+id/search_view"
            app:layout_constraintTop_toTopOf="parent" />

        <org.osmdroid.views.MapView
            android:id="@+id/map"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="1.0"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/ButtonEnvoyer"
            app:layout_constraintVertical_bias="0.0" />

    </android.support.constraint.ConstraintLayout>

        <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|right"
        android:layout_margin="16dp"
        android:src="@drawable/cursor"
        android:tint="@android:color/black"
        app:backgroundTint="@android:color/holo_blue_dark"
        app:layout_anchorGravity="bottom|right|end" />

</android.support.design.widget.CoordinatorLayout>

popup.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="154dp"
        android:gravity="center"
        android:orientation="vertical">

        <TextView
            android:id="@+id/position"
            android:layout_width="match_parent"
            android:layout_height="154dp"
            android:layout_margin="10dp"
            android:layout_marginTop="30dp"
            android:background="@android:color/white"
            android:gravity="center"
            android:padding="10dp"
            android:text="1333"
            android:textSize="18sp" />

    </LinearLayout>

</LinearLayout>

and popup window:
 public void pop(String pos){

        popupView = View.inflate(this, R.layout.popup, null);
        popupWindow = new PopupWindow(popupView, WindowManager.LayoutParams.MATCH_PARENT,
                WindowManager.LayoutParams.WRAP_CONTENT);
        TextView tv = popupView.findViewById(R.id.position);
        tv.setText(pos);
        popupWindow.setBackgroundDrawable(new BitmapDrawable());
        popupWindow.setFocusable(true);

        popupWindow.setOutsideTouchable(true);

        animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0, Animation.RELATIVE_TO_PARENT, 0,
                Animation.RELATIVE_TO_PARENT, 1, Animation.RELATIVE_TO_PARENT, 0);
        animation.setInterpolator(new AccelerateInterpolator());
        animation.setDuration(200);

        popupWindow.showAtLocation(popupView, Gravity.BOTTOM, 10, 10);
        popupView.startAnimation(animation);

    }

A: You could extend your pop(String pos) method with something similar as described below to animate the Floating Action Button:
First, should measure the size of the popup window, in order to calculate how much the button should be translated (note that the bottom padding of the FAB is substracted, in order to keep the same padding between popup window and FAB):
popupView.measure(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
int fabTranslationY = popupView.getMeasuredHeight() - fab.getPaddingBottom();

Next, set a dismiss listener on the popup window, so that the FAB goes back to it's initial position after the window is dismissed:
popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
        @Override
        public void onDismiss() {
            ObjectAnimator fabAnimator = ObjectAnimator.ofFloat(fab, "translationY", 0);
            fabAnimator.setDuration(200);
            fabAnimator.setInterpolator(new AccelerateInterpolator());
            fabAnimator.start();
        }
    });

Finally, construct and start the translate animation of the FAB:
ObjectAnimator fabAnimator = ObjectAnimator.ofFloat(fab, "translationY", -fabTranslationY);
fabAnimator.setDuration(200);
fabAnimator.setInterpolator(new AccelerateInterpolator());
fabAnimator.start();

Note: fab = findViewById(R.id.fab);
Don't forget to read about ObjectAnimator here.


text:
Q: While loop always ending one loop early What seems to be happening here is that my while loop ends 1 loop early every time. It is set so that it will keep going until t->next is NULL. although it always stopped one early, even though the ->next pointer is indeed pointing to something. Here is the code. I have all the formal declarations and other things done in other parts of my code, so I won't post them here to keep it simple
int job_allocated(const int job)
{
  ALLOCPTR t = alloclist;

  int sizeofjob = 0;

  while(t->next!=NULL)
  {

    if(t->id==job)
    {

        sizeofjob=sizeofjob+t->size;
    }

    cout << t << endl;
    cout << t->id << endl;
    cout << t->next << endl;
    t=t->next;

}

here is the output
0x600010540
2
0x600010520
0x600010520
3
0x600010500
0x600010500
2
0x6000104e0

As you can see the ->next pointer does indeed point to memory, but for some reason the while loop ends right after, instead of running one more time.
In my main I have 4 Jobs that I have allocated, yet the loop will not go to the last one.

A: It should be while (t != NULL). If you write while (t->text != NULL) you both open yourself up to undefined behavior for an empty list, and cause the loop to not process t when t points to the last node (remember, if t points to the last node, then t->next is NULL, and the loop will not run).


text:
Q: Solving Equation from 3rd degree with unknown coefficients I Try to get the simplest  real root for the following equation but I failed
eqn1= c1 c2 K1^2 m2 + c2 K1 K2 m2 \[Alpha]1 + c1 K1 K2 m2 \[Delta] -
   K2^2 m2 \[Alpha]1 \[Delta] + K2^2 T^3 \[Alpha]1 \[Alpha]2 \[Mu]2 +
   T^2 (-c2 K1 K2 \[Alpha]1 \[Alpha]2 +
      K2^2 \[Alpha]1 \[Alpha]2 \[Delta] + c1 K1 K2 \[Mu]2 -
      K2^2 \[Alpha]1 \[Mu]2 + K2^2 m2 \[Alpha]1 \[Alpha]2 \[Mu]2 -
      K2^2 \[Alpha]1 \[Alpha]2 \[Rho]2) + K2^2 m2 \[Alpha]4 \[Sigma] +
    T (-c1 c2 K1^2 + c2 K1 K2 \[Alpha]1 -
      c2 K1 K2 m2 \[Alpha]1 \[Alpha]2 + c1 K1 K2 \[Delta] -
      K2^2 \[Alpha]1 \[Delta] + K2^2 m2 \[Alpha]1 \[Alpha]2 \[Delta] +
       c1 K1 K2 m2 \[Mu]2 - K2^2 m2 \[Alpha]1 \[Mu]2 -
      c1 K1 K2 \[Rho]2 + K2^2 \[Alpha]1 \[Rho]2 +
      K2^2 \[Alpha]4 \[Sigma]) == 0;

Solve[{eqn1, 0 < c1 < 1, 0 < c2 < 1, 0 < K1 < 1, k1 < K2 < 1 , 0 < m2 < 1,
  0 < \[Sigma] < 1, 0 < \[Delta] < \[Sigma], 0 < m2 < 1,
  0 < \[Rho]2 < m2, 0 < \[Alpha]1 < 1,
  0 < \[Alpha]2 < \[Alpha]1}, T, Reals]

but the result is a huge; can any one give me suggetion ?
Thanks,


text:
Q: InterfaceVpcEndpoint vs VpcEndpoint in AWS CDK AWS CDK provides an InterfaceVpcEndpoint and a VpcEndpoint. What is the difference between these two constructs?

A: Its about CDK constructs. You should know that there are 3 levels of constructs: L1 (low-level), L2 (regular) and L3 (high-level patterns).
InterfaceVpcEndpoint is L2 used to create interface VPC endpoints. VpcEndpoint class is a support class which is parent of InterfaceVpcEndpoint. You can think of VpcEndpoint as being somewhere between L2 and L1. You shouldn't use, or even cant use it directly, as its used to encapsulate common functionality between Interface VPC endpoints and Gateway VPC endpoints.
So to create interface endpoint, use InterfaceVpcEndpoint. Similarly to create gateway endpoint, use GatewayVpcEndpoint. Both are L2 constructs.


text:
Q: php restfull Url for API I'm creating  API , I should get the response in the JSON format. I would like to know the best practices and the API should be created.
I have Googled for many REST API tutorials. They were good and I have acquired some knowledge on it, But I want to get a sample model of the code so that I can refer to it and build my own api.

A: You can see some useful resources here :

*

*Building A RESTful PHP Server: Routing the Request

*Creating a Simple REST API


text:
Q: Accessing iCloud Calendar using authentication service Is there a way to access Apple iCloud using an authentication service like OAuth or another similar service? I am trying to get access to a users calendar data. I have found a way to access their servers using CalDAV and a users login info. However I don't want to be storing sensitive user information in order to access the servers.

A: My understanding is that iCloud does not offer any such authentication service. The best you can do is to ask the users to create App specific passwords: https://support.apple.com/en-us/HT204397


text:
Q: Prove that $V$ is a complete space Let $V$ be the space of real sequences with a finite number of elements $\neq 0$ ($ \exists  N_x$ so that $x_k=0 \forall k>N_x$. Define $$||\vec x||_1=\sum_{k=1}^{N_x}|x_k|$$
Prove that $V$ is a complete space with that norm
I haven´t been able to concrete anything: I need to prove that every cauchy sequence converges.
Let $x$ be a cauchy sequence in $V$(note that $x=(x^1,x^2,...)$ where each $x^n$ is a sequence with a finite number of elements $\neq 0$)
so I need to prove that: $\forall \epsilon>0$ $\exists  N(\epsilon)$ so that  $\forall n>N$, $||x^n-y||_1<\epsilon$ where $y$ is the limit sequence
By hypothesis we know that $x$ is a cauchy sequence hence: $\exists N_1$ so that $\forall m,n>N_1$ $||x^n-x^m||_1<\epsilon$ that is $$\sum_{k=1}^{l}|x^n_k-x^m_k|<\epsilon$$
I took $l=$max{${p,q}$} where p is there number such that $\forall k>p$, $x^n_k=0$ and $q$ is the number such that $\forall k>q$, $x^m_k=0$
Bu I don´t know how to continue from here. Can you lend me a hand please? I would really appreciate it :)

A: This is not true because the sequence $$a_n =\sum_{j=1}^n \frac{1}{2^j} e_j $$ is Cauchy but it has no limit.

A: The space $V$ you're dealing with is a subspace of $l^1$, the set of all real sequences $x$ such that
$$
\sum_{k=0}^{\infty}|x(k)|
$$
is convergent (note the absolute value; I use function notation because of what follows).
The norm on this space is precisely
$$
\|x\|_1=\sum_{k=0}^{\infty}|x(k)|.
$$
This is a complete space because it's the set of Lebesgue integrable functions on $\mathbb{N}$ with the "counting measure" and there is no nonempty set with measure $0$, so equality almost everywhere is the same as equality.
Note that $V$ is a subspace of $l^1$ and that the norm induced on $V$ by $l^1$ is exactly the same as in your definition.
The subspace $V$ is dense in $l^1$. If $x\in l^1$, we can define $x_n$ as the "truncation of $x$ beyond $n$":
$$
x_n(k)=\begin{cases}
x(k)&\text{if $k\le n$}\\
0&\text{if $k>n$}
\end{cases}
$$
and it should be easy to see that
$$
\lim_{n\to\infty}x_n=x
$$
in the space $l^1$ with the $\|\cdot\|_1$ norm. Moreover, $x_n\in V$, for all $n$.
Therefore $V$ is not complete.


text:
Q: Insert new element in an array of object and sort the array I have an array of objects that contains the name and marks of students. like below
How can I calculate the 'average' marks each student has and compare the 'average' marks to get the top student. I don't want to use ES6

var Students = [{
    name: "Bob",
    marks: [78, 80, 89, 90, 68]
  },
  {
    name: "Alin",
    marks: [87, 60, 59, 70, 68]
  },
  {
    name: "bikash",
    marks: [82, 60, 79, 60, 80]
  }
];

var average;
var newArray = [];
for (let i = 0; i < Students.length; i++) {
  var marks = Students[i]["marks"];
  var total = 0;
  console.log(marks);
  for (var j = 0; j < marks.length; j++) {
    total += marks[j];
  }
  average = total / marks.length;
  newArray.push(average)
  var msg = Students[i]["name"] + " has average mark: " + average;
  console.log(msg)

}

console.log(newArray)

I want to insert the average numbers in an object along with the names like
[{name: "Bob", average:89.4},{name: "Alin", average:87.2},{name: "Bikash", average:89.4} ]
and sort the object.
Finally, I want to have console.log as Bob is the Top student
OR
Alin and Bob are the brightest students (in case both of them have the same average number)

A: Don't push the average into a new array, add it as a property of Students[i] with Students[i].average = average;.
Then you can sort the array using that property, and print the to students from the sorted array.

var Students = [{
    name: "Bob",
    marks: [78, 80, 89, 90, 68]
  },
  {
    name: "Alin",
    marks: [87, 60, 59, 70, 68]
  },
  {
    name: "bikash",
    marks: [82, 60, 79, 60, 80]
  }
];

var average;
for (let i = 0; i < Students.length; i++) {
  var marks = Students[i]["marks"];
  var total = 0;
  for (var j = 0; j < marks.length; j++) {
    total += marks[j];
  }
  average = total / marks.length;
  Students[i].average = average;
  var msg = Students[i]["name"] + " has average mark: " + average;
  console.log(msg)

}
Students.sort((s1, s2) => s2.average - s1.average);
var topAvg = Students[0].average;
var topStudents = Students.filter(s => s.average == topAvg).map(s => s.name).join(", ");
console.log(`Top Students are ${topStudents} with mark ${topAvg}`);

A: I have used non ES6 functins, instead traditional for loop and other. Please, find answers for your three questions:

*

*Creating a list/array of object in this format: [ { name: 'Alin', average: 68.8 }, ..]

*Sorting a list/array with average value

*Getting students with the highest average grade.
     const Students = [{
     name: 'Bob',
     marks: [78, 80, 89, 90, 68],
 },
     {
         name: 'Alin',
         marks: [87, 60, 59, 70, 68],
     },
     {
         name: 'bikash',
         marks: [82, 60, 79, 60, 80],
     },
     {
         name: 'Doston',
         marks: [78, 80, 89, 90, 68],
     },
 ];

 var average;
 var data = [];
 for (var i = 0; i < Students.length; i++){
     var marks = Students[i]["marks"];
     var total = 0;
     console.log(marks);
     for (var j = 0; j < marks.length; j++ ) {
         total += marks[j];
     }
     average = total / marks.length;

     var msg = Students[i]["name"] + " has average mark: " + average;
     console.log(msg);

     // Answer for the first question:
     var item = {"name": Students[i]["name"], "average": average};
     data.push(item);

 }

 function compareAndSort(a,b) {
     return parseInt(a.average, 10) - parseInt(b.average, 10);
 }

 data.sort(compareAndSort);

 // Answer for the second question: sort [ { name: 'Alin', average: 68.8 }, ..]
 console.log(data);

 // Answer for the third question - getting students who has highest mark is last since it is sorted
 var bestStudent = data[data.length - 1];
 console.log(bestStudent.name + " has got the highest mark: " + bestStudent.average);

 var bestStudents = [bestStudent];

 // check if there is only one person with this highest mark
 for (var i = 0; i < data.length; i ++) {
     if (data[i].average >= bestStudent.average && data[i].name !== bestStudent.name) {
         bestStudents.push(data[i]);
     }
 }

 // all best students
 console.log(bestStudents);

I have added some data to the JSON input, so that you get two best students

A: Instead of using loops, I used the built-in array methods, which tend to be much more readable (although they would be a lot more readable if you used ES6 syntax).
I use the Array.prototype.map method to convert the list of marks into the average. In order to find this average, I use Array.prototype.reduce to add up all of the values, and then I divide by the length of the marks array. I then sort the array using Array.prototype.sort.
In order to get the top students, I use Array.prototype.filter in order to select only the students will average marks equal to the top average mark, which since the averages array is sorted, will be averages[0].average.

var Students = [
  {
    name: "Bob",
    marks: [78, 80, 89, 90, 68]
  },
  {
    name: "Alin",
    marks: [87, 60, 59, 70, 68]
  },
  {
    name: "bikash",
    marks: [82, 60, 79, 60, 80]
  }
];

var averages = Students.map(function(student) {
  return {
    name: student.name,
    average: student.marks.reduce(function(a, b) {
      return a + b;
    }) / student.marks.length
  };
}).sort(function(a, b) {
  return b.average - a.average;
});

var top_students = averages.filter(function(student, _i, arr) {
  return student.average === arr[0].average;
});

console.log("Averages:");
console.log(averages);

console.log("Top Students:\n");
console.log(top_students);

A: You don't need an additional array. In theory, calling sort is less efficient than to gather the best student(s) during your loop.
So:

var students = [{name: "Bob",marks: [78,80,89,90,68] },{name: "Alin",marks: [87,60,59,70,68]},{name: "bikash",marks: [82,60,79,60,80]}];

var topAverage = -1;
var topStudents = [];
var newArray = [];
for (let i = 0; i < students.length; i++){
    var marks = students[i].marks;
    var total = 0;
    for (var j = 0; j < marks.length; j++ ) {
        total += marks[j];
    }
    var average = total / marks.length;
    // Keep topAverage & topStudents up to date:
    if (average >= topAverage) {
        if (average > topAverage) {
            topStudents.length = 0; // clear previous content
            topAverage = average;
        }
        topStudents.push(students[i].name);
    }
}

console.log("Top student(s): " + topStudents + " with an average of " + topAverage);

A:

var Students = [{
    name: "Bob",
    marks: [78, 80, 89, 90, 68]
  },
  {
    name: "Alin",
    marks: [87, 60, 59, 70, 68]
  },
  {
    name: "bikash",
    marks: [82, 60, 79, 60, 80]
  }
];

console.log (
  Students.map (
    student => (
      {
        name: student.name,
        average:
          student.marks.reduce ((a, m) => a + m, 0) /
          student.marks.length
      }
    )
  ).sort ((a, b) => b.average - a.average)
);


text:
Q: Problem with solving simultaneous equations
In part v of part a of the question, they asked me to find the coordinates of point P. I know that:
Also note that part v of question relates back to part iv(for context)

*

*$|OP| = |AP| = |BP| = 5\sqrt{14}$

*$|OP| = \sqrt{x^2+y^2+z^2}$

*$|AP| = \sqrt{(x-4)^2 + (y+1)^2 + (z+3)^2}$

*$|BP| = \sqrt{(x-3)^2 + (y+4)^2 + (z-1)^2}$
Now I think I should equate them, getting the following:
$[1] x+3y-4z=0$
$[2] -4x+y+3z=-13$
$[3] -3x+4y-z=-13$
But when I put it in the CAS calculator, it gives me this:
$z=z$, $x=z+...$, $y=z+...$
Firstly, what does that mean?
Secondly, however, that cannot be right as I was expecting a single point of intersection. I cannot substitute "$z=z$" into one of the coordinates so where did I go wrong?

A: This means the system of equations proposed is possible but underdetermined. Indeed, this is the case because the third line from the coefficient matrix equals the first line plus the second line. Hence the solution set is the intersection of two planes, whose geometrical interpretation is a line.


text:
Q: Rendering Offscreen Content On Windows Phone Basically I have control (such as a Grid) which is twice the width of the page.
The idea is to animate the control so that it slides left and the unseen half is shown - but it is not rendered.
Is there a way to force offscreen rendering or force render on the fly (as the animation is playing)?
Thanks in advance,
Jamie

A: One way to do this is to have a single wide grid, and have two render transforms (TranslateTransform specifically) - one for the left content, and one for the right content. The "left" content would have a TranslateTransform X value of 0, while the right one would have an X value of 480, effectively creating a double wide grid. To perform a side, just use a Storyboard with a double animation of -480 to the X value of both transforms.
It sounds a little complicated but it's not too bad, let me know if you need more details!
XAML:
<Grid x:Name="LayoutRoot" Background="Transparent">
    <Grid.Resources>
        <Storyboard x:Key="SlideLeftStoryboard">
            <DoubleAnimation From="0" To="-480" Duration="0:0:0.5" Storyboard.TargetName="BlueTransform" Storyboard.TargetProperty="X">

            </DoubleAnimation>
            <DoubleAnimation From="480" To="0" Duration="0:0:0.5" Storyboard.TargetName="RedTransform" Storyboard.TargetProperty="X">

            </DoubleAnimation>
        </Storyboard>
        <Storyboard x:Key="SlideRightStoryboard">
            <DoubleAnimation From="-480" To="0" Duration="0:0:0.5" Storyboard.TargetName="BlueTransform" Storyboard.TargetProperty="X">

            </DoubleAnimation>
            <DoubleAnimation From="0" To="480" Duration="0:0:0.5" Storyboard.TargetName="RedTransform" Storyboard.TargetProperty="X">

            </DoubleAnimation>
        </Storyboard>
    </Grid.Resources>
    <Border Name="BlueBorder" Background="Blue">
        <Border.RenderTransform>
            <TranslateTransform x:Name="BlueTransform" X="0">

            </TranslateTransform>
        </Border.RenderTransform>
        <Button Click="SlideLeft_Click">
            <TextBlock>
                Slide Left
            </TextBlock>
        </Button>
    </Border>
    <Border Name="RedBorder" Background="Red">
        <Border.RenderTransform>
            <TranslateTransform x:Name="RedTransform" X="480">

            </TranslateTransform>
        </Border.RenderTransform>
        <Button Click="SlideRight_Click">
            <TextBlock>
                Slide Right
            </TextBlock>
        </Button>
    </Border>

</Grid>

Code Behind:
public partial class MainPage : PhoneApplicationPage
{
    Storyboard slideLeftStoryboard;
    Storyboard slideRightStoryboard;
    // Constructor
    public MainPage()
    {
        InitializeComponent();
        this.Loaded += new RoutedEventHandler(MainPage_Loaded);
    }

    void MainPage_Loaded(object sender, RoutedEventArgs e)
    {
        slideLeftStoryboard = LayoutRoot.Resources["SlideLeftStoryboard"] as Storyboard;
        slideRightStoryboard = LayoutRoot.Resources["SlideRightStoryboard"] as Storyboard;
    }

    private void SlideLeft_Click(object sender, RoutedEventArgs e)
    {
        slideLeftStoryboard.Begin();
    }

    private void SlideRight_Click(object sender, RoutedEventArgs e)
    {
        slideRightStoryboard.Begin();
    }
}


text:
Q: How do I latex the following diagram in the tikz-cd environment? I am a little new to the tikz-cd commutative diagram package. How would I latex the following diagram in the tikz-cd environment?

Thanks in advance!

A: It's good practice to try to do your own diagrams and ask for help where you are stuck. Otherwise you'll not learn anything.
\documentclass{standalone}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}
 & & & H_n(X_{n+1},X_n) = 0 & \\
H_n(X_{n-1}) = 0 \ar[rd] & & H_n(X_{n+1})\cong H_n(X) \ar[ru] & & \\
 & H_n(X_n) \ar[ru,"i_n"] \ar[rd,"j_n"] & & & \\
H_n(X_{n+1},X_n) = 0 \ar[ru,"\partial_{n+1}"] \ar[rr,"d_{n+1}"] & & H_n(X_n,X_{n-1}) \ar[dr,"\partial_n"'] \ar[rr,"d_n"] & & H_{n-1}(X_{n-1},X_{n-2}) \\
 & & & H_{n-1}(X_{n-1}) \ar[ru,"j_{n-1}"'] & \\
 & & H_{n-1}(X_{n-2}) = 0 \ar[ru] & & \\
\end{tikzcd}
\end{document}


text:
Q: Is there any [un]official info about SwingX-WS 1.1 and its development status? I've been keeping an eye for almost a year on swingx-ws (on SwingX website, via Google and whatnot [1,2, etc.]), to see if version 1.1 eventually made it to become a released milestone (I'm using v1.0 but there are some JXMapViewer bugs that, according to JIRA, are being addressed in v1.1).
Am I looking in the wrong places? Is development still active?
(If you can suggest a nice alternative library for dealing with online maps in Swing that you particularly like, please do)
EDIT: see this question for an update.

A: Now that SwingX 1.6.4 is out, SwingX-WS support has been dropped altogether! Boo ...:(
What a pity... such a nice and useful tool abandoned. I'll end up embedding browser-based maps into desktop applications.
-EDIT-
JXMapViewer has been resurrected here: https://github.com/msteiger/jxmapviewer2
-EDIT bis-
See this question for an update.


text:
Q: Extract url and title in R I'm having difficulty extracting a specific selection of text from the source code of a website. I can extract the entire list but I only need one country, for example Argentina in this case.
The source code is:

Afghanistan - Ministry of Finance
Argentina - Federal Administration of Public Revenues

I only need "Federal Administration of Public Revenues" and "http://www.afip.gob.ar/english/"
So far I have:
argurl <- readLines("http://oceantax.co.uk/links/tax-authorities-worldwide.html")

strong <-as.matrix(grep("
",argurl))
strong1starts <- grep("
Argentina",argurl)
rowst1st <- which(grepl(strong1starts, strong))
strong1ends <- strong[rowst1st + 1 ,]-1
data1 <- as.matrix(argurl[strong1starts:strong1ends])

A: library(rvest)

url <- "http://oceantax.co.uk/links/tax-authorities-worldwide.html"
pg <- html(url)

# get the country node

# XPath version
country <- pg %>% html_nodes(xpath="//a[contains(@title, 'Argentina')]")

# CSS Selector version
country <- pg %>% html_nodes("a[title~=Argentina]")

# use one of the above then:

country %>% html_text()       # get the text of the anchor
country %>% html_attr("href") # get the URL of the anchor


text:
Q: Getting a Uncaught TypeError: Cannot read property 'use' of undefined on Vue.use(Vuex) In my vue frontend i tried to setup Vuex. On my store page (inside the store dir, file name index.js).Im using Vue 3.0
When i run the code i get the Cannot read property 'use' of undefined on Vue.use(Vuex) line
This is the chunk of the code
import Vue from "vue";
import Vuex from "vuex";
import Api from "../services/api";

Vue.use(Vuex);//here i get the error

export default new Vuex.Store({
  state:{
  articles:[]
  },...

A: You need to use Vuex 4 to be Vue 3 compatible, and Vuex 4 introduced a few breaking changes, and one of them is how to initialize the store. Basically instead of using new Vuex.Store, you now use createStore to create the store object and no need to use Vue.use(Vuex) anymore in your store.js.
import { createStore } from 'vuex';

export const store = createStore({
  state: {...}
  // other stuff
})

And in your main.js file:
import { createApp } from 'vue';
import { store } from 'path/to/store.js';

const app = createApp({...})
app.use(store);

You can also see the full Vuex 4 example on github


text:
Q: How do you find the disk size of a Postgres / PostgreSQL table and its indexes I'm coming to Postgres from Oracle and looking for a way to find the table and index size in terms of bytes/MB/GB/etc, or even better the size for all tables.  In Oracle I had a nasty long query that looked at user_lobs and user_segments to give back an answer.
I assume in Postgres there's something I can use in the information_schema tables, but I'm not seeing where.

A: Just for info, I have got the excelent answer from @aib and modified it a little for:

*

*getting only tables from "public" schema

*show also materialized views data and index size

On materialized view we can use index for refreshing materialized views concurrently, which allows using them while updating.
Well,  my query will be the following:
SELECT
    table_name,
    pg_size_pretty(table_size) AS table_size,
    pg_size_pretty(indexes_size) AS indexes_size,
    pg_size_pretty(total_size) AS total_size
FROM (
    SELECT
        table_name,
        pg_table_size(table_name) AS table_size,
        pg_indexes_size(table_name) AS indexes_size,
        pg_total_relation_size(table_name) AS total_size
    FROM (
        -- tables from 'public'
        SELECT table_name
        FROM information_schema.tables
        where table_schema = 'public' and table_type = 'BASE TABLE'
        union
        -- materialized views
        SELECT oid::regclass::text as table_name
        FROM pg_class
        WHERE relkind = 'm'
        order by table_name
    ) AS all_tables
    -- ORDER BY total_size DESC
    order by table_name
) AS pretty_sizes

A: Try the Database Object Size Functions. An example:
SELECT pg_size_pretty(pg_total_relation_size('"<schema>"."<table>"'));

For all tables, something along the lines of:
SELECT
    table_schema || '.' || table_name AS table_full_name,
    pg_size_pretty(pg_total_relation_size('"' || table_schema || '"."' || table_name || '"')) AS size
FROM information_schema.tables
ORDER BY
    pg_total_relation_size('"' || table_schema || '"."' || table_name || '"') DESC;

Edit: Here's the query submitted by @phord, for convenience:
SELECT
    table_name,
    pg_size_pretty(table_size) AS table_size,
    pg_size_pretty(indexes_size) AS indexes_size,
    pg_size_pretty(total_size) AS total_size
FROM (
    SELECT
        table_name,
        pg_table_size(table_name) AS table_size,
        pg_indexes_size(table_name) AS indexes_size,
        pg_total_relation_size(table_name) AS total_size
    FROM (
        SELECT ('"' || table_schema || '"."' || table_name || '"') AS table_name
        FROM information_schema.tables
    ) AS all_tables
    ORDER BY total_size DESC
) AS pretty_sizes;

I've modified it slightly to use pg_table_size() to include metadata and make the sizes add up.

A: If the database name is snort, the following sentence give it size:
psql -c "\l+ snort" | awk -F "|" '{print $7}'

A: Try this : (Index size/usage statistics)
SELECT
    t.tablename,
    indexname,
    c.reltuples AS num_rows,
    pg_size_pretty(pg_relation_size(quote_ident(t.tablename)::text)) AS table_size,
    pg_size_pretty(pg_relation_size(quote_ident(indexrelname)::text)) AS index_size,
    CASE WHEN indisunique THEN 'Y'
       ELSE 'N'
    END AS UNIQUE,
    idx_scan AS number_of_scans,
    idx_tup_read AS tuples_read,
    idx_tup_fetch AS tuples_fetched
FROM pg_tables t
LEFT OUTER JOIN pg_class c ON t.tablename=c.relname
LEFT OUTER JOIN
    ( SELECT c.relname AS ctablename, ipg.relname AS indexname, x.indnatts AS number_of_columns, idx_scan, idx_tup_read, idx_tup_fetch, indexrelname, indisunique FROM pg_index x
           JOIN pg_class c ON c.oid = x.indrelid
           JOIN pg_class ipg ON ipg.oid = x.indexrelid
           JOIN pg_stat_all_indexes psai ON x.indexrelid = psai.indexrelid )
    AS foo
    ON t.tablename = foo.ctablename
WHERE t.schemaname='public'
ORDER BY 1,2;

A: Show database sizes:
\l+
e.g.
=> \l+
 berbatik_prd_commerce    | berbatik_prd     | UTF8     | en_US.UTF-8 | en_US.UTF-8 |                       | 19 MB   | pg_default |
 berbatik_stg_commerce    | berbatik_stg     | UTF8     | en_US.UTF-8 | en_US.UTF-8 |                       | 8633 kB | pg_default |
 bursasajadah_prd         | bursasajadah_prd | UTF8     | en_US.UTF-8 | en_US.UTF-8 |                       | 1122 MB | pg_default |

Show table sizes:
\d+
e.g.
=> \d+
 public | tuneeca_prd | table | tomcat | 8192 bytes |
 public | tuneeca_stg | table | tomcat | 1464 kB    |

Only works in psql.
(Summary of @zkutch's answer.)

A: PostgreSQL tables have three components:  the table itself, any indexes on it, and potentially TOAST data.  There's a couple of examples showing how to slide and dice the available information various ways at http://wiki.postgresql.org/wiki/Disk_Usage

A: check this wiki. https://wiki.postgresql.org/wiki/Disk_Usage

SELECT *, pg_size_pretty(total_bytes) AS total
    , pg_size_pretty(index_bytes) AS INDEX
    , pg_size_pretty(toast_bytes) AS toast
    , pg_size_pretty(table_bytes) AS TABLE
  FROM (
  SELECT *, total_bytes-index_bytes-COALESCE(toast_bytes,0) AS table_bytes FROM (
      SELECT c.oid,nspname AS table_schema, relname AS TABLE_NAME
              , c.reltuples AS row_estimate
              , pg_total_relation_size(c.oid) AS total_bytes
              , pg_indexes_size(c.oid) AS index_bytes
              , pg_total_relation_size(reltoastrelid) AS toast_bytes
          FROM pg_class c
          LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
          WHERE relkind = 'r'
  ) a
) a

A: The Query below will serve you
SELECT nspname || '.' || relname AS "relation",
  pg_size_pretty(pg_total_relation_size(C.oid)) AS "total_size"
FROM pg_class C
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
  AND C.relkind <> 'i'
  AND nspname !~ '^pg_toast'
ORDER BY pg_total_relation_size(C.oid) DESC
LIMIT 20;

See this Link: https://wiki.postgresql.org/wiki/Disk_Usage

A: Try this script to find all table size:
SELECT
    table_schema || '.' || table_name AS TableName,
    pg_size_pretty(pg_total_relation_size('"' || table_schema || '"."' || table_name || '"')) AS TableSize
FROM information_schema.tables
ORDER BY
    pg_total_relation_size('"' || table_schema || '"."' || table_name || '"') DESC

For other different script to find size in PostgreSQL, Please visit this url:
http://www.dbrnd.com/2015/05/how-to-find-size-of-database-and-table-in-postgresql/


text:
Q: Android: What are the recommended configurations for Proguard? I'm developing apps for Android and using Proguard to obfuscate the code.
Currently i'm using ProGuard configurations:
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class com.android.vending.licensing.ILicensingService

To maintain custom components names that are used on layouts XML:
-keep public class custom.components.**

To remove debug logs:
-assumenosideeffects class android.util.Log {
    public static *** d(...);
    public static *** v(...);
}

To avoid changing names of methods invoked on layout's onClick:
-keepclassmembers class * {
 public void onClickButton1(android.view.View);
 public void onClickButton2(android.view.View);
 public void onClickButton3(android.view.View);
}

-keepclasseswithmembernames class * {
    native <methods>;
}

-keepclasseswithmembernames class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembernames class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

The question is (are):
Are any other tags recommended? Why and what for?
It's possible to make a comment on a proguard.cfg file? I would like to have it with comments for what some lines are doing so that other developers don't have doubts about why i added.
Also in proguard, is it possible to maintain the comment header of a file (with the copyright)? If it's not, or it's not a good policy where should i add the copyright?

A: Android SDK (r20 or higher)
Please check the predefined proguard.config refered in project.properties
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt

More info: http://proguard.sourceforge.net/manual/examples.html#androidapplication
Here you can check a proguard "default" file that I keep updating: https://medium.com/code-procedure-and-rants/android-my-standard-proguard-ffeceaf65521

Android SDK (r19 or lower)
Based on my answer Enabling ProGuard in Eclipse for Android I've ended up with this generic file. I've added comments to remember what each line is for. It might help people out there so here it is:
-optimizationpasses 5

#When not preverifing in a case-insensitive filing system, such as Windows. Because this tool unpacks your processed jars, you should then use:
-dontusemixedcaseclassnames

#Specifies not to ignore non-public library classes. As of version 4.5, this is the default setting
-dontskipnonpubliclibraryclasses

#Preverification is irrelevant for the dex compiler and the Dalvik VM, so we can switch it off with the -dontpreverify option.
-dontpreverify

#Specifies to write out some more information during processing. If the program terminates with an exception, this option will print out the entire stack trace, instead of just the exception message.
-verbose

#The -optimizations option disables some arithmetic simplifications that Dalvik 1.0 and 1.5 can't handle. Note that the Dalvik VM also can't handle aggressive overloading (of static fields).
#To understand or change this check http://proguard.sourceforge.net/index.html#/manual/optimizations.html
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

#To repackage classes on a single package
#-repackageclasses ''

#Uncomment if using annotations to keep them.
#-keepattributes *Annotation*

#Keep classes that are referenced on the AndroidManifest
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class com.android.vending.licensing.ILicensingService

#To remove debug logs:
-assumenosideeffects class android.util.Log {
    public static *** d(...);
    public static *** v(...);
}

#To avoid changing names of methods invoked on layout's onClick.
# Uncomment and add specific method names if using onClick on layouts
#-keepclassmembers class * {
# public void onClickButton(android.view.View);
#}

#Maintain java native methods
-keepclasseswithmembernames class * {
    native <methods>;
}

#To maintain custom components names that are used on layouts XML.
#Uncomment if having any problem with the approach below
#-keep public class custom.components.package.and.name.**

#To maintain custom components names that are used on layouts XML:
-keep public class * extends android.view.View {
    public <init>(android.content.Context);
    public <init>(android.content.Context, android.util.AttributeSet);
    public <init>(android.content.Context, android.util.AttributeSet, int);
    public void set*(...);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

#Maintain enums
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

#To keep parcelable classes (to serialize - deserialize objects to sent through Intents)
-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

#Keep the R
-keepclassmembers class **.R$* {
    public static <fields>;
}

###### ADDITIONAL OPTIONS NOT USED NORMALLY

#To keep callback calls. Uncomment if using any
#http://proguard.sourceforge.net/index.html#/manual/examples.html#callback
#-keep class mypackage.MyCallbackClass {
#   void myCallbackMethod(java.lang.String);
#}

#Uncomment if using Serializable
#-keepclassmembers class * implements java.io.Serializable {
#    private static final java.io.ObjectStreamField[] serialPersistentFields;
#    private void writeObject(java.io.ObjectOutputStream);
#    private void readObject(java.io.ObjectInputStream);
#    java.lang.Object writeReplace();
#    java.lang.Object readResolve();
#}

A: In your project file called project.properties, set following value:
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt

This will take the latest version of Proguard settings from Android SDK.

A: For standard builds with Ant or Eclipse, the Android SDK (r20 or higher) already provides a suitable configuration, referenced by the property proguard.config in the file project.properties (as Michal points out in his answer). In older releases, you always had to specify your own complete configuration, so older advice (like the first answer) can lead to some confusion.
For custom builds, you can find the latest recommended configuration in the ProGuard manual > Examples > A complete Android application. The Proguard distribution also contains a sample file examples/android.pro
Notably, you may want to preserve annotations, and setters in View extensions.
You can add comments after a hash character '#', as extensively done in the sample files.


text:
Q: Spinbox change values on keypress in qml Is it possible to automatically change the value of the spinbox on keypress instead of enter? The problem is the following, lets suppose we go to the input where we have the number one:

And now i change it to number 10, but dont click on enter:

Now i click on the plus sign and it goes to number two:

How can this be changed in a way that when i loose focus, or click in the minus or plus sign of the spinbox in automatically takes in account the last digited number?
This is what is happening with QtQuick.Controls 2.0
An example:
import QtQuick 2.9
import QtQuick.Controls 2.0

ApplicationWindow {
    id: window
    title: "Stack"
    visible: true
    height: 200
    width: 400
    Item {
        id: page
        anchors.fill: parent
        width:parent.width
        height: parent.height
            Column{
                width:parent.width
                spacing:10
                SpinBox {
                    id: spinBox1

      width: 100
                height: 30
                stepSize: 1
                editable: true
            }
        }
}

}

A: You could use the property "contentItem" of SpinBox and adding a TextInput.
The TextInput has the signal handler "onTextChanged".
SpinBox {
            id: spinbox
            value: 10
            editable: true
            contentItem: TextInput {
                text: spinbox.textFromValue(spinbox.value, spinbox.locale)
                font: spinbox.font
                horizontalAlignment: Qt.AlignHCenter
                verticalAlignment: Qt.AlignVCenter
                readOnly: !spinbox.editable
                validator: spinbox.validator
                inputMethodHints: Qt.ImhFormattedNumbersOnly
                onTextChanged: {
                   spinbox.value =  parseInt(text);
                }
            }
        }


text:
Q: expo development client error: No scheme specified for development client I am trying to get EAS builds and development clients working on Expo SDK 44, but I ran into the following error in http://localhost:19002/:
Error loading DevTools
No scheme specified for development client

Unfortunately, there isn't any additional logs regarding this error.
Here is my eas.json file:
{
  "cli": {
    "version": ">= 0.48.2"
  },
  "build": {
    "development": {
      "releaseChannel": "dev2",
      "developmentClient": true,
      "distribution": "internal",
      "android": {
        "gradleCommand": ":app:assembleDebug"
      },
      "ios": {
        "buildConfiguration": "Debug"
      }
    },
    "preview": {
      "releaseChannel": "preview1",
      "distribution": "internal"
    },
    "production": {
      "releaseChannel": "prod4"
    }
  },
  "submit": {
    "production": {}
  }
}

And my app.json:
{
  "expo": {
    "name": "Truffle",
    "slug": "simmer2",
    "version": "1.0.7",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "splash": {
      "image": "./assets/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "hooks": {
      "postPublish": [
        {
          "file": "sentry-expo/upload-sourcemaps",
          "config": {
            "organization": "truffle-tg",
            "project": "truffle-tg",
            "authToken": "c5dc914d80434bdca0762c1404179552e6695d7813114928945fc2c1c9fab08a"
          }
        }
      ]
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "supportsTablet": true,
      "bundleIdentifier": "com.simmer2.foodie",
      "buildNumber": "1.0.6",
      "infoPlist": {
        "NSPhotoLibraryUsageDescription": "Truffle accesses your library so you can upload a picture for your profile.",
        "NSLocationWhenInUseUsageDescription": "Truffle uses your location to find restaurants near you."
      },
      "config": {
        "googleMapsApiKey": "AIzaSyDD2MM_1D1ztXv8iAzVReIQUVjetfAfyoo"
      }
    },
    "android": {
      "adaptiveIcon": {
        "foregroundImage": "./assets/adaptive-icon.png",
        "backgroundColor": "#FFFFFF"
      },
      "config": {
        "googleMaps": {
          "apiKey": "AIzaSyBGnK6cBCTMxM5O2be5pwi-zVoIWNBsdVA"
        }
      },
      "softwareKeyboardLayoutMode": "pan",
      "package": "com.simmer2.foodie",
      "versionCode": 7
    },
    "web": {
      "favicon": "./assets/favicon.png"
    },
    "plugins": [
      "sentry-expo"
    ]
  }
}

I did add import 'expo-dev-client'; at the top of App.tsx file, because according to the documentation (https://docs.expo.dev/development/getting-started/), this improves the error messaging during the development process, but I didn't see any additional error messages.
Do you have any guidance on why the build does not work on the dev client? Thanks!

A: 7 months has passed, so guessing you found a way. My suggestion would be to add a scheme to the app.json:
{
  "expo": {
    "name": "Truffle",
    "slug": "simmer2",
    "scheme": "truffle"
    "version": "1.0.7",
    ...


text:
Q: Multiple checkbox lists auto-generated by jQuery I want to add multiple checkboxes to my project which are used to define role and rights for my project.
Please see my following CSHTML and jQuery code.
CSHTML code :
@using (@Html.BeginForm())
{

                                    Web Menu Rights

                            Department Name :
                            @Html.DropDownList("DEPARTMENT", null, "--Select One--", new { style = "width: 280px", @id = "DEPARTMENT", @name = "DEPARTMENT" })
                            <input type="button" id="btnView" name="btnView" value="View" class="btn btn-flat btn-primary" />

                                                    Main Menu

                                                Title :

                                                Is Display

                                        @foreach (var a in ViewBag.List_H)
                                        {
                                            var obj_id = @a.OBJECT_ID;
                                            var chkView = "chkView_";

                                                    @a.OBJECT_NAME :

                                                    <input id="hfObjId_B" name="hfObjId_B" type="hidden" value="@obj_id" />
                                                    @if (@a.DEPT_ID_B == 1)
                                                    {
                                                        <input type="checkbox" id="@chkView@obj_id" class="chkView" checked="checked"/>

                                                    }
                                                    else
                                                    {
                                                        <input type="checkbox" id="@chkView@obj_id" class="chkView" />
                                                    }

                                        }

                                                    Quick Links

                                        @foreach (var a in ViewBag.List_D)
                                        {
                                            var obj_id = @a.OBJECT_ID;
                                            var chkView = "chkView_";

                                                    @a.OBJECT_NAME :

                                                    <input id="hfObjId_B" name="hfObjId_B" type="hidden" value="@obj_id" />
                                                    @if (@a.DEPT_ID_B == 1)
                                                    {
                                                        <input type="checkbox" id="@chkView@obj_id" class="chkView" checked="checked"/>

                                                    }
                                                    else
                                                    {
                                                        <input type="checkbox" id="@chkView@obj_id" class="chkView" />
                                                    }

                                        }

                                                <input id="btnSave" type="submit" value="Save" name="btnSave" class="btn btn-flat btn-primary" />
                                                <input id="btncancel" name="btncancel" type="submit" value="Cancel" class="btn btn-flat btn-danger" onclick="window.location = '@Url.Action("Web_Menu_Rights", "web_portal_entry")'; return false;" />

                                                    Main Menu

                                                Title :

                                                Is Display

                                        @foreach (var a in ViewBag.List_H)
                                        {
                                            var obj_id = @a.OBJECT_ID;
                                            var chkView2 = "chkView2_";

                                                    @a.OBJECT_NAME :

                                                    <input id="hfObjId_F" name="hfObjId_F" type="hidden" value="@obj_id" />
                                                    @if (@a.DEPT_ID_F == 1)
                                                    {
                                                        <input type="checkbox" id="@chkView2@obj_id" class="chkView2" checked="checked"/>

                                                    }
                                                    else
                                                    {
                                                        <input type="checkbox" id="@chkView2@obj_id" class="chkView2" />
                                                    }

                                        }

                                                    Quick Links

                                        @foreach (var a in ViewBag.List_D)
                                        {
                                            var obj_id = @a.OBJECT_ID;
                                            var chkView2 = "chkView2_";

                                                    @a.OBJECT_NAME :

                                                    <input id="hfObjId_F" name="hfObjId_F" type="hidden" value="@obj_id" />
                                                    @if (@a.DEPT_ID_F == 1)
                                                    {
                                                        <input type="checkbox" id="@chkView2@obj_id" class="chkView2" checked="checked"/>

                                                    }
                                                    else
                                                    {
                                                        <input type="checkbox" id="@chkView2@obj_id" class="chkView2" />
                                                    }

                                        }

                                                <input id="btnSave2" type="submit" value="Save" name="btnSave2" class="btn btn-flat btn-primary" />
                                                <input id="btncancel2" name="btncancel" type="submit" value="Cancel" class="btn btn-flat btn-danger" onclick="window.location = '@Url.Action("Web_Menu_Rights", "web_portal_entry")'; return false;" />

}

jQuery :

My problem is that I want be able to dynamically add multiple check box values with their own id; how would I do this?

A: Try this:
Add hidden field on your page and try to store value in hidden field.
by using View to controller so there is need of hidden field. i hope this will help for you.
CSHTML :

                    <input type="hidden" id="hidObjects_B" name="hidObjects_B" />
                    <input type="hidden" id="hidObjects_F" name="hidObjects_F" />

                                    Web Menu Rights

                            Department Name :
                            @Html.DropDownList("DEPARTMENT", null, "--Select One--", new { style = "width: 280px", @id = "DEPARTMENT", @name = "DEPARTMENT" })
                            <input type="button" id="btnView" name="btnView" value="View" class="btn btn-flat btn-primary" />

                                                    Main Menu

                                                Title :

                                                Is Display

                                        @foreach (var a in ViewBag.List_H)
                                        {
                                            var obj_id = @a.OBJECT_ID;
                                            var chkView = "chkView_";

                                                    @a.OBJECT_NAME :

                                                    <input id="hfObjId_B" name="hfObjId_B" type="hidden" value="@obj_id" />
                                                    @if (@a.DEPT_ID_B == 1)
                                                    {
                                                        <input type="checkbox" id="@chkView@obj_id" class="chkView" checked="checked"/>

                                                    }
                                                    else
                                                    {
                                                        <input type="checkbox" id="@chkView@obj_id" class="chkView" />
                                                    }

                                        }

                                                    Quick Links

                                        @foreach (var a in ViewBag.List_D)
                                        {
                                            var obj_id = @a.OBJECT_ID;
                                            var chkView = "chkView_";

                                                    @a.OBJECT_NAME :

                                                    <input id="hfObjId_B" name="hfObjId_B" type="hidden" value="@obj_id" />
                                                    @if (@a.DEPT_ID_B == 1)
                                                    {
                                                        <input type="checkbox" id="@chkView@obj_id" class="chkView" checked="checked"/>

                                                    }
                                                    else
                                                    {
                                                        <input type="checkbox" id="@chkView@obj_id" class="chkView" />
                                                    }

                                        }

                                                <input id="btnSave" type="submit" value="Save" name="btnSave" class="btn btn-flat btn-primary" />
                                                <input id="btncancel" name="btncancel" type="submit" value="Cancel" class="btn btn-flat btn-danger" onclick="window.location = '@Url.Action("Web_Menu_Rights", "web_portal_entry")'; return false;" />

                                                    Main Menu

                                                Title :

                                                Is Display

                                        @foreach (var a in ViewBag.List_H)
                                        {
                                            var obj_id = @a.OBJECT_ID;
                                            var chkView2 = "chkView2_";

                                                    @a.OBJECT_NAME :

                                                    <input id="hfObjId_F" name="hfObjId_F" type="hidden" value="@obj_id" />
                                                    @if (@a.DEPT_ID_F == 1)
                                                    {
                                                        <input type="checkbox" id="@chkView2@obj_id" class="chkView2" checked="checked"/>

                                                    }
                                                    else
                                                    {
                                                        <input type="checkbox" id="@chkView2@obj_id" class="chkView2" />
                                                    }

                                        }

                                                    Quick Links

                                        @foreach (var a in ViewBag.List_D)
                                        {
                                            var obj_id = @a.OBJECT_ID;
                                            var chkView2 = "chkView2_";

                                                    @a.OBJECT_NAME :

                                                    <input id="hfObjId_F" name="hfObjId_F" type="hidden" value="@obj_id" />
                                                    @if (@a.DEPT_ID_F == 1)
                                                    {
                                                        <input type="checkbox" id="@chkView2@obj_id" class="chkView2" checked="checked"/>

                                                    }
                                                    else
                                                    {
                                                        <input type="checkbox" id="@chkView2@obj_id" class="chkView2" />
                                                    }

                                        }

                                                <input id="btnSave2" type="submit" value="Save" name="btnSave2" class="btn btn-flat btn-primary" />
                                                <input id="btncancel2" name="btncancel" type="submit" value="Cancel" class="btn btn-flat btn-danger" onclick="window.location = '@Url.Action("Web_Menu_Rights", "web_portal_entry")'; return false;" />

Jquery:
 $("#btnSave").click(function () {
            var cnt = $("input:checked").length;
            if (cnt > 0) {
                var Add = "";
                $("#trobjname_B > #dept_id_b").each(function () {
                    var id_chkView = $(this).find('.chkView').attr('id');
                    var isView = $('#' + id_chkView).is(':checked') ? "1" : "0";
                    Add += $(this).find("#hfObjId_B").val() + "!";
                    Add += isView + "$";
                });
                $("#hidObjects_B").val(Add);
            }
            else {
                alert("Please check atleast one checkbox");
                return false;
            }
        });


text:
Q: JDialog unmovable form JTable cell editor I have customized the JTable cell editor in order to allow enter data from JDialog frame. I have used an editable combobox for that, I have added an ActionListener for combobox to display The dialog.
I have got my JDialog visible, but I want to make it unmovable, so the user can't move it.
Here is my code so far,
package VIEW;

import VIEW.statManager.SearchProduitEvent;
import VIEW.statManager.SearchProduitEventListener;
import java.awt.Component;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.AbstractCellEditor;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JTable;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import javax.swing.table.TableCellEditor;
import javax.swing.text.JTextComponent;

public class ProduitCellEditor extends AbstractCellEditor implements       TableCellEditor,ActionListener, SearchProduitEventListener {

    private JComboBox combo;
    private SearchProduitUi searchProduitUi;
    private String value = "value";
    public ProduitCellEditor() {

        combo = new JComboBox();
        combo.setEditable(true);
        combo.setActionCommand("combo");

        searchProduitUi = new SearchProduitUi();
        searchProduitUi.setSearchProduitEventListener(this);
        searchProduitUi.setSize(500,300);
        searchProduitUi.setLocationRelativeTo(combo);
    }

    @Override
    public Object getCellEditorValue() {
        return value;
     }

    @Override
    public Component getTableCellEditorComponent(JTable jtable, Object o, boolean bln, int i, int i1) {
        return combo;
     }

    public void actionPerformed(ActionEvent event) {
        Point comboPosition = combo.getLocationOnScreen();
         searchProduitUi.setLocationRelativeTo(combo);
         searchProduitUi.setLocation(comboPosition.x ,comboPosition.y + combo.getHeight());
         searchProduitUi.setVisible(true);

     }

    @Override
    public void searchDialogEventOccured(SearchProduitEvent ev) {
        value = ev.getProduit().getDesignation();
        fireEditingStopped();

      }
  }

A: JDialog#setUndecorated will remove the frame decorations, including the close/minimise/maximise controls and make it impossible for the user to move the window.

import java.awt.EventQueue;
import java.awt.GridBagLayout;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.border.EmptyBorder;

public class Test1 {

    public static void main(String[] args) {
        new Test1();
    }

    public Test1() {
        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                try {
                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
                    ex.printStackTrace();
                }

                JPanel content = new JPanel(new GridBagLayout());
                content.setBorder(new EmptyBorder(8, 8, 8, 8));
                JLabel label = new JLabel("Hello world");
                content.add(label);

                JDialog dialog = new JDialog();
                dialog.setUndecorated(true);
                dialog.setTitle("Testing");
                dialog.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                dialog.setContentPane(content);
                dialog.pack();
                dialog.setLocationRelativeTo(null);
                dialog.setVisible(true);
            }
        });
    }

}


text:
Q: window.onload function can not be stopped I am trying to use window.onload to initialize the page with struts2 action, but it falls into some kind of looping and keeps calling the init javascript function.
My code comes as follows:
javascript
<script>
    function init(){
        document.getElementById("test").action="test";
        document.getElementById("test").submit();
    }
    window.onload=init;
</script>

jsp file
<html>
    <body onload="init();">
        ...
        <s:form id="test" method="post">
            <s:select id="selectThing" onchange="init();">...</s:select>
        </s:form>
    </body>
</html>

A: The init() will be called at each refresh, that is what you ask the code to do. Additionally why are you calling this in onchange event.


text:
Q: Compute the Galois group over $F_{101}$ The problem is as follows:
Determine the Galois group of the polynomial $f(x)=x^4-2$ over the finite field with $101$ elements, $\mathbb{F}_{101}$.
I am not really sure how to go about this, but here are some things I've thought about:
So, I know that Finite fields have cyclic Galois group. So, if $f(x)$ were irreducible over $\mathbb{F}_{101}$ then it would follow that it's splitting field is $\mathbb{F}_{101^4}$, and hence its Galois group would by isomorphic to $\mathbb{Z}_4.$ Similarly, if it reduced into a linear and a cubic, then the Galois group would be isomorphic to $\mathbb{Z}_3,$ and so on..
But in this case, it doesn't seem like it is the intention of the problem to check how $f(x)$ factors over $\mathbb{F}_{101}$. There seem to be way too many things that could happen. If it were over a field $\mathbb{F}_p$ for a reasonably small prime $p$ then one could check the irreducibility of $f(x)$ over this field.
The roots of $f(x)$ are certainly $\sqrt[4]{2}\zeta_4^k$, for $k=0,1,2,3,$ where $\zeta_4$ is the $4th$ primitive root of unity, so it is a root of the cyclotomic polynoial $\Phi_4(x)$. This in turn is a factor of $x^{101}-x$. So, in particular, it splits completely over $\mathbb{F}_{101}$, since this last one is the splitting field of $x^{101}-x.$
Hence, the splitting field of $f(x)$ over $\mathbb{F}_{101}$ is $\mathbb{F}_{101}(\sqrt[4]{2}).$
So, I guess, then the question is really if the following is true $$x^4\equiv 2\mod 101$$ for any $x$ in $\mathbb{F}_{101}.$
Another approach would be, i think, to try and compute the discriminant of $f(x)$ and it's cubic resolvent, but i am encountering similar issues of whether a polynomial is irreducible over this field. So, this approach seems to be even less worth pursuing.
I'd appreciate any help, or if there is any general strategy how to approach similar problems?!

A: Why don't you see if $2$ is quadratic residue mod $101?$ WHat about $-1?$

A: If you know the result that $2$ is a square modulo a prime $p$ if and only if $p \equiv \pm 1 \mod 8$, then you can do this with virtually no calculation. Since $101 \equiv 5 \mod 8$ (you do need to do that calculation!), $2$ is a non-square in ${\mathbb F}_{101}$. Since $4$ does not divide $102$ (more calculation!), it follows that the splitting field of $x^4-2$ must be ${\mathbb F}_{101^4}$.
To see this, let  $\beta$ be a square root of $2$ in ${\mathbb F}_{101^2}$. Let $w$ be a primitive element of ${\mathbb F}_{101^2}$ and $\beta = w^k$. So $w^{2k}=\beta^2=2 \in {\mathbb F}_{101}$, hence $102 \vert 2k$. So, if $k$ was even, we would have $102 \vert k$, but then $\beta \in {\mathbb F}_{101}$, contradiction. So $k$ is odd, and hence $\beta$ has no square root in ${\mathbb F}_{101^2}$. So the splitting field is not ${\mathbb F}_{101^2}$, and it must be ${\mathbb F}_{101^4}$.

A: Let $\alpha$ be a root of $X^4-2$ in $\overline{\mathbf{F}_{101}}$, what can you say about $\alpha^{{101}^k}$ for $k = 1,2,3$?


text:
Q: function returning a const value I have a following function which accepts a enum value and based upon the enum value returns a constant value(which is in a different class). Now i get a "Constant initializer missing" Error.
public const int Testfunction(TESTENUM TestEnum)
{
    switch(TestEnum)
    {
      case TestEnum.testval1:
         return testclass.constvalue;
      case TestEnum.testVal2:
         return testclass.constvalue1;
      case TestEnum.testVal3:
         return testclass.constvalue2;
    }
}

*

*how exactly the function's return type would be? (I am using object return type and this does not throw any error)

*Is there any other option to achieve the same?

A: Removing "const" keyword from your function return type should solve the problem
It should be like this
public int Testfunction(TESTENUM TestEnum)
{
    ...

Return type cannot be declared constant

A: .NET methods cannot return const any type..
The const keyword is invalid there: remove it.

A: What's happening here is the compiler thinks that you are trying to declare a public constant integer field named Testfunction, and is extremely surprised to discover that there is no = 123; following the identifier. It's telling you that it expected the initializer.
There are a number of places in the C# compiler where the development team anticipated that C and C++ users would use a common C/C++ syntax erroneously. For example, there's a special error message for int x[]; that points out that you probably meant int[] x;. This is an example of another place where the compiler could benefit from a special-purpose error message that detects the common mistake and describes how to fix it. You might consider requesting that feature if you think it's a good one.
More generally, "const" in C# means something different than it means in C or C++. C# does not have the notion of a "const function" that does not mutate state, or a "const reference" that provides a read-only view of potentially-mutable data. In C# "const" is only used to declare that a field (or local) is to be treated as a compile-time constant. (And "readonly" is used to declare that a field is to be written only in the constructor, which is also quite useful.)

A: The most likely working code:
public static class TestClass
{
    public const int constValue1 = 1;
    public const int constValue2 = 2;
    public const int constValue3 = 3;
}

enum TestEnum
{
    testVal1, testVal2, testVal3
}

public int TestFunction(TestEnum testEnum)
{
    switch (testEnum)
    {
        case TestEnum.testVal1:
            return TestClass.constValue1;
        case TestEnum.testVal2:
            return TestClass.constValue2;
        case TestEnum.testVal3:
            return TestClass.constValue3;
    }
    return 0; // all code paths have to return a value
}

First, according to const (C# Reference):

The const keyword is used to modify a declaration of a field or local variable. It specifies that the value of the field or the local variable is constant, which means it cannot be modified.

In C#, const is only used as a modifier of a field (like TestClass.constValue1) or local variable, not suitable for a function return type.

So you are from the great C/C++ kingdom. Thinking with my very limited knowledge to C/C++, const return types in C/C++ is only meaningful with pointers...
// C++ code
const int m = 1;

// It returns a pointer to a read-only memory
const int* a(){
    return &m;
}

But unless you are using unsafe code, there is no pointer in C#. There are only value types (like int/DateTime/TestEnum/structs) and reference types (like string/classes). There are a lot more to read about on the web.
So as int is a value type in C#, when you returns it, it gets copied. So even if you are returning a "constant int" the returned value is not a constant and modifying the return value will not "change the constant and cause a SegFault".

Well, I forgot to answer your questions...

*

*How exactly the function's return type would be? (I am using object return type and this does not throw any error)
Like what I showed in the code above, int.
const int blah = 1 only declares a variable/field blah of type int which one must not modify it (by doing blah = 2). In C# const int is not a type.

*Is there any other option to achieve the same?
Well... I think I don't actually need to answer this...


text:
Q: Excel - Update values automatically using vlookup I am a poker and slots streamer and I use excel alot to export values for my stream overlay.
I have come to a difficult situation where I need one of the bellow behaviors:

*

*Create a button to send a value to a specific cell using something like VLOOKUP

*Automatically make a cell update on higher of two values, or else keep it's value.

I'll attach some images for you to better understand:
I have a table on this sheet where I keep all info about the games
Slots Sheet
On this second sheet I have a dropdown on Column B where I pick the game from the first sheet and then fill up C (Best Win) and D (Best Multiplier) columns with Vlookup
SlotStream Sheet
On this second sheet I have some referral cells where I keep the scores for this day on this slot and add the bet size between parenthesis
Today Result + Bet size
So basically, I have a new highscore on this slot "Sweet Bonanza", and I need to keep its "best win" and "best x" updated on the first sheet, using the columns S and T from the second sheet.
One important thing here is that after the stream I will delete the inputs on the second sheet (slotstream), so the values should be sent and kept on the first sheet.
It's my first post here so I am sorry if I did not make myself clear. If you have any question please feel free to ask me.
Thank you in advance.
Ricardo Mateus