text:
Q: How to Display ListView, with 3 edit text stored on 3 columns on SQLite Database? I am trying to build an application where the user will enter 3 data on 3 edit texts which are then stored to 3 columns on the database. The user display them on a listview which allows them to select the whole item to edit either one of the text fields or delete the entire item as a whole. So far the adding of data to the database is still working, it is being stored to 3 different columns . As for the display, it only display the first edit text which is the first column of data in the database which is BodyTemp.
ViewRecords.java
package mdad.project;
import java.util.ArrayList;
import com.example.manandhowproject.R;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class ViewRecords extends Activity {
    DatabaseHelper dbhelper;
    ListView listView;

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

        dbhelper = new DatabaseHelper(this);
        listView = (ListView) findViewById(R.id.listView);
        populateListView();
    }

    private void populateListView()
    {
        Cursor records = dbhelper.getRecords();
        ArrayList<String> listRec = new ArrayList<String>();
        while(records.moveToNext()){
            listRec.add(records.getString(1));
        }
    ListAdapter adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,listRec);
    listView.setAdapter(adapter);

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
             String BTemp = adapterView.getItemAtPosition(i).toString();
             String HRate = adapterView.getItemAtPosition(i).toString();
             String Bmi = adapterView.getItemAtPosition(i).toString();

             Cursor data = dbhelper.getRecID(BTemp, HRate, Bmi);
             int recID = -1;
             while(data.moveToNext()){
                 recID = data.getInt(0);
             }
             if(recID > -1){

                 Intent editScreenIntent = new Intent(ViewRecords.this, EditDel.class);
                 editScreenIntent.putExtra("id",recID);
                 editScreenIntent.putExtra("Body Temperature",BTemp);
                 editScreenIntent.putExtra("Heart Rate",HRate);
                 editScreenIntent.putExtra("BMI",Bmi);
                 startActivity(editScreenIntent);
             }
             else{
                 Toast.makeText(getApplicationContext(), "No ID Associated", Toast.LENGTH_LONG).show();
             }
         }
     });
 }}

DatabaseHelper.java
package mdad.project;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseHelper extends SQLiteOpenHelper {

        public static final String DATABASE_NAME = "medrec.db";
        public static final String TABLE_NAME = "myrec_data";
        public static final String COL1 = "ID";
        public static final String COL2 = "BodyTemp";
        public static final String COL3 = "HeartRate";
        public static final String COL4 = "BMI";

     public DatabaseHelper(Context context) {
            super(context, TABLE_NAME, null, 1);
        }

    @Override
    public void onCreate(SQLiteDatabase db) {

    String createTable = "CREATE TABLE " + TABLE_NAME + " (ID INTEGER PRIMARY KEY AUTOINCREMENT, " + COL2 + " TEXT, " + COL3 + " TEXT, " + COL4 + " TEXT);";
    db.execSQL(createTable);

    }

    @Override
    public void onUpgrade (SQLiteDatabase db,int i, int i1)
    {
         db.execSQL("DROP IF TABLE EXISTS " + TABLE_NAME);
         onCreate(db);
    }

     public boolean addRecord(String BodyTemp, String HeartRate, String BMI) {
            SQLiteDatabase db = this.getWritableDatabase();
            ContentValues contentValues = new ContentValues();
            contentValues.put(COL2, BodyTemp);
            contentValues.put(COL3, HeartRate);
            contentValues.put(COL4, BMI);

            long result = db.insert(TABLE_NAME, null, contentValues);

            if (result == -1) {
                return false;
            } else {
                return true;
            }
        }

     public Cursor getRecords()
     {
         SQLiteDatabase db = this.getWritableDatabase();
         String query = "SELECT * FROM " + TABLE_NAME;
         Cursor records = db.rawQuery(query, null);
         return records;
     }

     public Cursor getRecID(String BTemp, String Hrate, String Bmi){
            SQLiteDatabase db = this.getWritableDatabase();
            String query = "SELECT " + COL1 + " FROM " + TABLE_NAME +
                    " WHERE " + COL2 + " = '" + BTemp + "AND" + COL3 + " = '" + Hrate + "AND" + COL4 + " = '" + Bmi +"'";
            Cursor data = db.rawQuery(query, null);
            return data;
        }

    public void updateBtemp(String bodytemp, int selectedID,
            String selectedBtemp) {
          SQLiteDatabase db = this.getWritableDatabase();
          String query = "UPDATE " + TABLE_NAME + " SET " + COL2 +
                    " = '" + bodytemp + "' WHERE " + COL1 + " = '" + selectedID + "'" +
                    " AND " + COL2 + " = '" + selectedBtemp + "'";
            db.execSQL(query);

    }

    public void updateHrate(String heartrate, int selectedID,
            String selectedHrate) {
        SQLiteDatabase db = this.getWritableDatabase();
          String query = "UPDATE " + TABLE_NAME + " SET " + COL3 +
                    " = '" + heartrate + "' WHERE " + COL1 + " = '" + selectedID + "'" +
                    " AND " + COL3 + " = '" + selectedHrate + "'";
            db.execSQL(query);

    }

    public void updateBMI(String bmi, int selectedID, String selectedBMI) {
        SQLiteDatabase db = this.getWritableDatabase();
          String query = "UPDATE " + TABLE_NAME + " SET " + COL4 +
                    " = '" + bmi + "' WHERE " + COL1 + " = '" + selectedID + "'" +
                    " AND " + COL4 + " = '" + selectedBMI + "'";
            db.execSQL(query);

    }

    public void deleteBtemp(int selectedID, String selectedBtemp) {
           SQLiteDatabase db = this.getWritableDatabase();
            String query = "DELETE FROM " + TABLE_NAME + " WHERE "
                    + COL1 + " = '" + selectedID + "'" +
                    " AND " + COL2 + " = '" + selectedBtemp + "'";

            db.execSQL(query);

    }

    public void deleteHrate(int selectedID, String selectedHrate) {
           SQLiteDatabase db = this.getWritableDatabase();
            String query = "DELETE FROM " + TABLE_NAME + " WHERE "
                    + COL1 + " = '" + selectedID + "'" +
                    " AND " + COL3 + " = '" + selectedHrate + "'";

            db.execSQL(query);

    }

    public void deleteBMI(int selectedID, String selectedBMI) {
           SQLiteDatabase db = this.getWritableDatabase();
            String query = "DELETE FROM " + TABLE_NAME + " WHERE "
                    + COL1 + " = '" + selectedID + "'" +
                    " AND " + COL4 + " = '" + selectedBMI + "'";

            db.execSQL(query);

    }

}

EditDel.java
package mdad.project;
import com.example.manandhowproject.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class EditDel extends Activity {

    Button btnSave,btnDelete;
    EditText etBT, etHR, etBMI;

    DatabaseHelper dbhelper;

    private String selectedBtemp, selectedHrate, selectedBMI;
    private int selectedID;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.editdel);
        btnSave = (Button) findViewById(R.id.btnSave);
        btnDelete = (Button) findViewById(R.id.btnDelete);
        etBT = (EditText) findViewById(R.id.etBT);
        etHR = (EditText) findViewById(R.id.etHR);
        etBMI = (EditText) findViewById(R.id.etBMI);
        dbhelper = new DatabaseHelper(this);

        Intent receivedIntent = getIntent();

        selectedID = receivedIntent.getIntExtra("id",-1);
        selectedBtemp = receivedIntent.getStringExtra("BTemp");
        selectedHrate = receivedIntent.getStringExtra("Hrate");
        selectedBMI = receivedIntent.getStringExtra("Bmi");

        etBT.setText(selectedBtemp);
        etHR.setText(selectedHrate);
        etBMI.setText(selectedBMI);

        btnSave.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String bodytemp = etBT.getText().toString();
                String heartrate = etHR.getText().toString();
                String bmi = etBMI.getText().toString();
                if(!bodytemp.equals("") && !heartrate.equals("") && !bmi.equals("")){
                    dbhelper.updateBtemp(bodytemp,selectedID,selectedBtemp);
                    dbhelper.updateHrate(heartrate,selectedID,selectedHrate);
                    dbhelper.updateBMI(bmi,selectedID,selectedBMI);

                }else{
                    toastMessage("Please ensure all fields are filled.");
                }
            }
        });

        btnDelete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
               dbhelper.deleteBtemp(selectedID,selectedBtemp);
               dbhelper.deleteHrate(selectedID,selectedHrate);
               dbhelper.deleteBMI(selectedID,selectedBMI);
                etBT.setText("");
                etHR.setText("");
                etBMI.setText("");
                toastMessage("removed from database");
            }
        });

    }

    /**
     * customizable toast
     * @param message
     */
    private void toastMessage(String message){
        Toast.makeText(this,message, Toast.LENGTH_SHORT).show();
    }
}

A: Your variable name have to be same.
In ViewRecords, you set variable to
Intent editScreenIntent = new Intent(ViewRecords.this, EditDel.class);
editScreenIntent.putExtra("id",recID);
editScreenIntent.putExtra("Body Temperature",BTemp);
editScreenIntent.putExtra("Heart Rate",HRate);
editScreenIntent.putExtra("BMI",Bmi);
startActivity(editScreenIntent);

So in EditDel, you need to getIntent with same variable name
 selectedBtemp = receivedIntent.getStringExtra("Body Temperature");
 selectedHrate = receivedIntent.getStringExtra("Heart Rate");
 selectedBMI = receivedIntent.getStringExtra("BMI");


text:
Q: Make sense to use code formatter template arbitrary in team? I am working on a Java project, about ten developers in team. And we all use Eclipse as IDE.
To make source code in more consistent style in team, I am wondering if it makes sense to use code formatter template arbitrary? I mean only thing prior to checking in code is to use code formatter in Eclipse.
In general, I know the team will benefit from consistent code style. The problem is - should it works as a force rule? maybe it's too rigid.
Example 1: The template forces the maximum line width as 80. but it's ugly if some lines are broken into many lines. sure I know the 80 is configurable.
Example 2: Formatted code by Eclipse:
int green = 1;
int red = 1;
int orange = 1;

My prefer code:
int green  = 1;
int red    = 1;
int orange = 1;

So my opinion is to use code template, but not rigid, violation to the template is allowable and necessary. What is your opinion about it?

A: I'd rather create a document that assembles the rules, and get everyone to read it.
The rules are there to be broken, and you not always want your code formatter to automatically do the work for you (in my case this often happens with multiline if statements).
And because you will not always apply to the coding standard, everytime someone uses an automatic formatter, he/she will cause havoc in your git/svn/cvs, changing lines, that actually did not change.
So my advice - don't use automatic formatting, and convince/learn/force people to write readable code. And make code reviews too!

A: What we use is checkstyle, configured both in Eclipse (to help developers while coding) and as a Maven plugin to make automatic validations and reports. It checks Sun/Oracle Java code conventions (they are the de facto standard) and other good practices. Everyone know the rules and can apply some small automatic formatting tips that match the conventions (i.e. spacing, ...). We also make code reviews.
In most cases, I would try to avoid taking personal opinions into account because that only leads to flame wars in the development teams. For example, in your example 2, Eclipse applies the "standard" formatitng, so I would not try to use another format just because someone personally thinks that it could be easier to understand.
In my opinion this has several advantages:

*

*From a "collective code ownership" point of view, all the code seems to be written by the very same person.

*It is easier to move developers between different projects.

*The code is easier to read an maintain.

*It does not matter if anyone prefer other IDE.

For new projects, once you have automatic checkstyle validations with Maven, I think it is a good idea to make strict validations. That is, treat code style errors as compilation errors (not just warnings), the build is broken if the code style is not valid. It requires a little bit of discipline at the beginning, but it leads to a higher code quality at the end.

A: We check the formatter configuration into version control, and have the formatter configured as save action.
This requires everyone to use eclipse, but you already do that.
It has the following advantages:

*

*formatting is consistent

*nobody spends time formatting the code

*nobody argues about formatting in a code review

It has the disadvantage that on occasion the formatter will do something weird. This can be adressed as follows:

*

*rewrite the statement in question (for instance, extract local variables to shorten lines and avoid line wrapping)

*give hints to the formatter (for instance, you can force line breaks to remain by following them with //

*disable the formatter for a section of code using an on/off tag

redpajama_set_name: RedPajamaStackExchange


text:
Q: R ggplot2: manually set fill colour without "fill" aesthetic? Suppose a violin plot created using ggplot2 with only one factor (on the horizontal axis). This plot shows colorless violins as the single factor is used for the x-axis.
For example, this quick MWE:
oneplot <- ggplot(ToothGrowth, aes(x=dose, y=len)) +
  geom_violin()
oneplot

Is it possible afterwards to set the fill colours? In my actual setting, the plot is generated through a large procedure in charge of multiple things and it does not assign a "fill" aesthetics; it just delivers a plot that can be changed post-hod with additional graphic directives such as scale_fill_manual.
I was hoping that I could add some directives, e.g.,
oneplot + scale_fill_manual(breaks = c(0.5,1,2), values = c("orange", "purple","blue"))

but for the moment, the fillings stay utterly colorless!

A: Not very well known, but you can use aes as an additive plot component too.
So:
oneplot <- ggplot(ToothGrowth, aes(x=factor(dose), y=len)) +
  geom_violin()
oneplot

oneplot + aes(fill = supp)

This does assume that your fill variable is present in the data, so supp must be present in ToothGrowth. However, we can update the data component too, using the special operater %+%:
oneplot %+% filter(ToothGrowth, dose < 2) + aes(fill = supp)

These techniques can be very useful when making slight variations of the same plot. Define the large structure once, then update the data or aesthetics for each plot.

A: I think the specific result you were looking for (which is really just a follow-on from Axeman's excellent answer) is:
oneplot +
  aes(fill = factor(dose)) +
  scale_fill_manual(breaks = c(0.5,1,2), values = c("orange", "purple","blue"))


text:
Q: Drop Multiple Column Using single Alter I searched a lot on web, but couldn't find the answer for dropping multiple columns in single alter statement using SQL Server 2008.
I tried following query
ALTER TABLE TableToDropColumn DROP (Field2, Field3)

but it throws an error

Msg 102, Level 15, State 1, Line 1
  Incorrect syntax near '('.

A: ALTER TABLE TableToDropColumn DROP COLUMN Field2, Field3

SQLFiddle demo

A: ALTER TABLE TableToDropColumn DROP Field2, DROP Field3

A: ALTER TABLE TableToDropColumn DROP COLUMN Field2, Field3

On a side note:
You may also need to know how to get rid of the wasted space which is created after the above command.You can do ALTER TABLE ... REBUILD. Actually DROP COLUMN does not physically remove the data and the space is consumed even for records added after the columns were dropped. So thats why you need to use ALTER TABLE ... REBUILD to get rid of the wasted space


text:
Q: filter array of object from another array with multiple elements in javascript I have object and an array:
const response = [
   { id: 1, product: 'EL' },
   { id: 2, product: 'AC' },
   { id: 3, product: 'AC' },
   { id: 4, product: 'AD' },
   { id: 5, product: 'DE' },
];
const elProd = [
    "EL"
    "DE"
];

i want to filter out the product which has product code in elProd array.
my expectation is below:
const response = [

    { id: 2, product: 'AC' },
    { id: 3, product: 'AC' },
    { id: 4, product: 'AD' },

];

what I tried :
 response.filter(obj => {return obj.product == elProd .includes(obj.product)})

A: You need only the check with includes.

const
    response = [{ id: 1, product: 'EL' }, { id: 2, product: 'AC' }, { id: 3, product: 'AC' }, { id: 4, product: 'AD' }, { id: 5, product: 'DE' }],
    elProd = ["EL", "DE"],
    result = response.filter(obj => !elProd.includes(obj.product));

console.log(result);

A:

const response = [{
    id: 1,
    product: 'EL'
  },
  {
    id: 2,
    product: 'AC'
  },
  {
    id: 3,
    product: 'AC'
  },
  {
    id: 4,
    product: 'AD'
  },
  {
    id: 5,
    product: 'DE'
  },
];
const elProd = [
  "EL",
  "DE"
];
const filteredresp = response.filter((resp) => elProd.indexOf(resp.product) !== -1);
console.log(filteredresp);

A: response.filter(obj => {return !elProd.includes(obj.product)});

A: You almost got it, but you have a typo. You need a comma in the elProd array. Here's the code:

const response = [
    { id: 1, product: "EL" },
    { id: 2, product: "AC" },
    { id: 3, product: "AC" },
    { id: 4, product: "AD" },
    { id: 5, product: "DE" },
];
const elProd = [
    "EL", // <-- Add the comma.
    "DE",
];

// Don't forget to negate the includes here to exclude those you don't want.
const filtered = response.filter((obj) => !elProd.includes(obj.product));

// Result.
console.log(filtered);

A: You could use filter and some

const response = [
  { id: 1, product: 'EL' },
  { id: 2, product: 'AC' },
  { id: 3, product: 'AC' },
  { id: 4, product: 'AD' },
  { id: 5, product: 'DE' },
];
const elProd = [
   "EL",
   "DE"
]

res=response.filter(o=>!elProd.some(p=>o.product==p))
console.log(res)


text:
Q: How to open all the Bootstrap 5 accordions simultaneously without closing the ones that were already open I have an accordion
How can I open all the accordion items at the same time when clicking on a single Accordion Item?
Let's say we have this scenario:
Accordion Item #1 open
Accordion Item #2 closed
Accordion Item #2 closed
If we click on item #2 or #3, the three accordions will be opened (the Accordion #1 will remain opened) and then if we click again on some Accordion Item, the 3 accordions will close simultaneously.

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">

      <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
        Accordion Item #1
      </button>

        This is the first item's accordion body.

      <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
        Accordion Item #2
      </button>

        This is the second item's accordion body.

      <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
        Accordion Item #3
      </button>

        This is the third item's accordion body.

@nontechguy Answer edited:

      <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">

               <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target=".panelsStayOpen">
               Accordion Item #1
               </button>

                  This is the second item's accordion body. It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the .accordion-body, though the transition does limit overflow.

               <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target=".panelsStayOpen">
               Accordion Item #2
               </button>

                  This is the second item's accordion body. It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the .accordion-body, though the transition does limit overflow.

               <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target=".panelsStayOpen">
               Accordion Item #3
               </button>

                  This is the third item's accordion body. It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the .accordion-body, though the transition does limit overflow.

A: Hopefully, starting to solve part of your request?
All the accordian-items will open and close simultaneously when clicking any accordian-item.

      <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">

               <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target=".panelsStayOpen">
               Accordion Item #1
               </button>

                  This is the second item's accordion body. It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the .accordion-body, though the transition does limit overflow.

               <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target=".panelsStayOpen">
               Accordion Item #2
               </button>

                  This is the second item's accordion body. It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the .accordion-body, though the transition does limit overflow.

               <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target=".panelsStayOpen">
               Accordion Item #3
               </button>

                  This is the third item's accordion body. It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the .accordion-body, though the transition does limit overflow.

A: I don't think Bootstrap has anything by default for your test case. What you want is to detect the show or hide events on the collapse, and then manually control every accordion. I took the basic example from their documentation, and modified it. Do you want something like this?

const accordion = document.getElementById('accordionExample'),
        accordionCollapses = Array.from(document.querySelectorAll('.accordion-collapse'));

accordionCollapses.forEach((accordionCollapse) => {
  accordionCollapse.addEventListener('show.bs.collapse', (event) => {
    accordionCollapses.forEach((accordionCollapse) => {
      accordionCollapse.className = 'accordion-collapse collapsing';
      accordionCollapse.style.height = '100%';
      setTimeout(() => accordionCollapse.className = 'accordion-collapse collapse show', 350);
      accordionCollapse.parentElement.querySelector('.accordion-button').className = 'accordion-button';
    });
  });

  accordionCollapse.addEventListener('hide.bs.collapse', (event) => {
    accordionCollapses.forEach((accordionCollapse) => {
      accordionCollapse.className = 'accordion-collapse collapsing';
      accordionCollapse.className = 'accordion-collapse collapse';
      accordionCollapse.parentElement.querySelector('.accordion-button').className = 'accordion-button collapsed';
    });
  });
});
<!DOCTYPE html>

    <meta charset="UTF-8">
    <title>Document</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">

          <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
            Accordion Item #1
          </button>

            Less content

          <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
            Accordion Item #2
          </button>

            This is the second item's accordion body. It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the .accordion-body, though the transition does limit overflow. This is the second item's accordion body. It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the .accordion-body, though the transition does limit overflow. This is the second item's accordion body. It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the .accordion-body, though the transition does limit overflow.

          <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
            Accordion Item #3
          </button>

            This is the third item's accordion body. It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the .accordion-body, though the transition does limit overflow.

JSFiddle, if you need.


text:
Q: ASIHTTPRequest - Setting to ignore cache/proxy I am using ASIHTTPRequest and pulling content from our server which has Squid cache on it.  It seems that ASIHTTPRequest is not getting the newest content version.
How can I tell it to ignore the cache so that I can get the newest version? Or is there a better way to do this?
The following is what I am using:
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:serviceUrl];
[request setDownloadCache:[ASIDownloadCache sharedCache]];
[request setCachePolicy:ASIAskServerIfModifiedCachePolicy|ASIFallbackToCacheIfLoadFailsCachePolicy];
[request setCacheStoragePolicy:ASICachePermanentlyCacheStoragePolicy];
[request setTimeOutSeconds:50.0];
[request addRequestHeader:@"CacheControl" value:@"no-cache"];
[request startSynchronous];

A: It looks like the Header should be:
CacheControl: reload

That should tell squid to fetch the request from the server, but that depends on the configuration of the squid server. Maybe this feature is disabled ?
Can you do a forced reload in a browser ?
I think no-cache just means that the server should not update it's cache.


text:
Q: How to find specific table element with selenium webdriver in java? I found a table element using
WebElement tableElement = selectorboxelement.findElement(By.xpath("//ancestor::table"));

selectorboxelement is a webelement that I found by using
WebElement selectorboxelement = driver.findelement(By.Name("p_part_chkbox"));

The reason I did this, is because I couldn't find the ID or name of the table, but the above element was within the table so it was an easy way to get ahold of the table. Now how do I pull information from specific cells of this table?
Edit: Here is the HTML Code for the table. There's not enough room for the whole code, but the code just repeats until all of the info is there.

<TITLE>***************</TITLE>

<FORM ACTION="Schedule.PrioritySummary" METHOD="POST" NAME="to1_PS_Page">
<INPUT TYPE="hidden" NAME="P_PERSON_ID" VALUE="BZRGJH">
<INPUT TYPE="hidden" NAME="p_mode" VALUE="EDIT">
<INPUT TYPE="hidden" NAME="p_type" VALUE="SCHEDULE">
<INPUT TYPE="hidden" NAME="p_space_duns" VALUE="">
<INPUT TYPE="hidden" NAME="p_onum" VALUE="">
<INPUT TYPE="hidden" NAME="p_proc" VALUE="">
<INPUT TYPE="hidden" NAME="p_zcode" VALUE="BL62">
<INPUT TYPE="hidden" NAME="c_sort_one" VALUE="part_number">
<INPUT TYPE="hidden" NAME="c_sort_two" VALUE="priority">
<INPUT TYPE="hidden" NAME="c_sort_three" VALUE="commit_mode">
<INPUT TYPE="hidden" NAME="c_sort_four" VALUE="po_rel_sort">
<INPUT TYPE="hidden" NAME="p_supplier" VALUE="">
<INPUT TYPE="hidden" NAME="p_zcodes_space" VALUE="">
<INPUT TYPE="hidden" NAME="p_duns" VALUE="">
<INPUT TYPE="hidden" NAME="p_part" VALUE="">
<INPUT TYPE="hidden" NAME="p_sort_type" VALUE="none">
 Part #:<INPUT TYPE="text" NAME="p_pnum" SIZE="12" MAXLENGTH="12"><INPUT TYPE="submit" VALUE="GO">
</FORM>
<FORM ACTION="Schedule.PrioritySummary" METHOD="POST" NAME="to2_PS_Page">
<INPUT TYPE="hidden" NAME="P_PERSON_ID" VALUE="BZRGJH">
<INPUT TYPE="hidden" NAME="p_mode" VALUE="EDIT">
<INPUT TYPE="hidden" NAME="p_type" VALUE="SCHEDULE">
<INPUT TYPE="hidden" NAME="p_space_duns" VALUE="">
<INPUT TYPE="hidden" NAME="p_pnum" VALUE="">
<INPUT TYPE="hidden" NAME="p_proc" VALUE="">
<INPUT TYPE="hidden" NAME="p_zcode" VALUE="BL62">
<INPUT TYPE="hidden" NAME="c_sort_one" VALUE="po_rel_sort">
<INPUT TYPE="hidden" NAME="c_sort_two" VALUE="part_number">
<INPUT TYPE="hidden" NAME="c_sort_three" VALUE="priority">
<INPUT TYPE="hidden" NAME="c_sort_four" VALUE="commit_mode">
<INPUT TYPE="hidden" NAME="p_sort_type" VALUE="none">
<INPUT TYPE="hidden" NAME="p_supplier" VALUE="">
<INPUT TYPE="hidden" NAME="p_zcodes_space" VALUE="">
<INPUT TYPE="hidden" NAME="p_duns" VALUE="">
<INPUT TYPE="hidden" NAME="p_part" VALUE="">
 Order #: <INPUT TYPE="text" NAME="p_onum" SIZE="12" MAXLENGTH="12"><INPUT TYPE="submit" VALUE="GO">
</FORM>
<FORM ACTION="Schedule.PrioritySummary" METHOD="POST"  NAME="to3_PS_Page">
<INPUT TYPE="hidden" NAME="P_PERSON_ID" VALUE="BZRGJH">
<INPUT TYPE="hidden" NAME="p_mode" VALUE="EDIT">
<INPUT TYPE="hidden" NAME="p_type" VALUE="SCHEDULE">
<INPUT TYPE="hidden" NAME="p_space_duns" VALUE="">
<INPUT TYPE="hidden" NAME="p_pnum" VALUE="">
<INPUT TYPE="hidden" NAME="p_onum" VALUE="">
<INPUT TYPE="hidden" NAME="p_zcode" VALUE="BL62">
<INPUT TYPE="hidden" NAME="c_sort_one" VALUE="po_rel_sort">
<INPUT TYPE="hidden" NAME="c_sort_two" VALUE="part_number">
<INPUT TYPE="hidden" NAME="c_sort_three" VALUE="priority">
<INPUT TYPE="hidden" NAME="c_sort_four" VALUE="commit_mode">
<INPUT TYPE="hidden" NAME="p_sort_type" VALUE="none">
<INPUT TYPE="hidden" NAME="p_supplier" VALUE="">
<INPUT TYPE="hidden" NAME="p_zcodes_space" VALUE="">
<INPUT TYPE="hidden" NAME="p_duns" VALUE="">
<INPUT TYPE="hidden" NAME="p_part" VALUE="">
<SELECT NAME="p_proc"><OPTION VALUE="0">< Select Processor ><OPTION VALUE="KXH">K.Hr 918040497243         <OPTION VALUE="SJF">S. Fox 586-484-0855       </SELECT><INPUT TYPE="submit" VALUE="GO">
</FORM>

Mfg. DUNS: 178522926

KAUTEX INC

Z-code: BL62

Select One or More	<FORM ACTION="Schedule.PrioritySummary" METHOD="POST"  NAME="to4_PS_Page">
<INPUT TYPE="hidden" NAME="P_PERSON_ID" VALUE="BZRGJH">
<INPUT TYPE="hidden" NAME="iv_group" VALUE="">
<INPUT TYPE="hidden" NAME="p_mode" VALUE="EDIT">
<INPUT TYPE="hidden" NAME="p_type" VALUE="SCHEDULE">
<INPUT TYPE="hidden" NAME="p_space_duns" VALUE="">
<INPUT TYPE="hidden" NAME="p_duns_number" VALUE="">
<INPUT TYPE="hidden" NAME="p_zcode" VALUE="BL62">
<INPUT TYPE="hidden" NAME="p_pnum" VALUE="">
<INPUT TYPE="hidden" NAME="p_onum" VALUE="">
<INPUT TYPE="hidden" NAME="p_proc" VALUE="">
<INPUT TYPE="hidden" NAME="p_sort_type" VALUE="part_num">
<INPUT TYPE="hidden" NAME="c_sort_one" VALUE="part_number">
<INPUT TYPE="hidden" NAME="c_sort_two" VALUE="priority">
<INPUT TYPE="hidden" NAME="c_sort_three" VALUE="commit_mode">
<INPUT TYPE="hidden" NAME="c_sort_four" VALUE="po_rel_sort">
<INPUT TYPE="hidden" NAME="p_supplier" VALUE="">
<INPUT TYPE="hidden" NAME="p_zcodes_space" VALUE="">
<INPUT TYPE="hidden" NAME="p_duns" VALUE="">
<INPUT TYPE="hidden" NAME="p_part" VALUE="">
<INPUT TYPE="image" NAME="p_img" SRC="/apps/space/img/Part_Number_Button2.gif" border="0">	</FORM>
Description	<FORM ACTION="Schedule.PrioritySummary" METHOD="POST"  NAME="to5_PS_Page">
<INPUT TYPE="hidden" NAME="P_PERSON_ID" VALUE="BZRGJH">
<INPUT TYPE="hidden" NAME="iv_group" VALUE="">
<INPUT TYPE="hidden" NAME="p_mode" VALUE="EDIT">
<INPUT TYPE="hidden" NAME="p_type" VALUE="SCHEDULE">
<INPUT TYPE="hidden" NAME="p_space_duns" VALUE="">
<INPUT TYPE="hidden" NAME="p_duns_number" VALUE="">
<INPUT TYPE="hidden" NAME="p_zcode" VALUE="BL62">
<INPUT TYPE="hidden" NAME="p_pnum" VALUE="">
<INPUT TYPE="hidden" NAME="p_onum" VALUE="">
<INPUT TYPE="hidden" NAME="p_proc" VALUE="">
<INPUT TYPE="hidden" NAME="p_sort_type" VALUE="ordr_num">
<INPUT TYPE="hidden" NAME="c_sort_one" VALUE="po_rel_sort">
<INPUT TYPE="hidden" NAME="c_sort_two" VALUE="part_number">
<INPUT TYPE="hidden" NAME="c_sort_three" VALUE="priority">
<INPUT TYPE="hidden" NAME="c_sort_four" VALUE="commit_mode">
<INPUT TYPE="hidden" NAME="p_supplier" VALUE="">
<INPUT TYPE="hidden" NAME="p_zcodes_space" VALUE="">
<INPUT TYPE="hidden" NAME="p_duns" VALUE="">
<INPUT TYPE="hidden" NAME="p_part" VALUE="">
<INPUT TYPE="image" NAME="p_img" SRC="/apps/space/img/Order_Number_Button2.gif" border="0">	</FORM>
Last Commit	<FORM ACTION="Schedule.PrioritySummary" METHOD="POST"  NAME="to6_PS_Page">
<INPUT TYPE="hidden" NAME="P_PERSON_ID" VALUE="BZRGJH">
<INPUT TYPE="hidden" NAME="iv_group" VALUE="">
<INPUT TYPE="hidden" NAME="p_mode" VALUE="EDIT">
<INPUT TYPE="hidden" NAME="p_type" VALUE="SCHEDULE">
<INPUT TYPE="hidden" NAME="p_space_duns" VALUE="">
<INPUT TYPE="hidden" NAME="p_duns_number" VALUE="">
<INPUT TYPE="hidden" NAME="p_zcode" VALUE="BL62">
<INPUT TYPE="hidden" NAME="p_pnum" VALUE="">
<INPUT TYPE="hidden" NAME="p_onum" VALUE="">
<INPUT TYPE="hidden" NAME="p_proc" VALUE="">
<INPUT TYPE="hidden" NAME="p_sort_type" VALUE="none">
<INPUT TYPE="hidden" NAME="p_supplier" VALUE="">
<INPUT TYPE="hidden" NAME="p_zcodes_space" VALUE="">
<INPUT TYPE="hidden" NAME="p_duns" VALUE="">
<INPUT TYPE="hidden" NAME="p_part" VALUE="">
<INPUT TYPE="image" NAME="p_img" SRC="/apps/space/img/Due_Now_Button2.gif" border="0">	</FORM>
Due 11/03	Due 11/10	Due 11/17	Due 11/24	Future	Total	SNR

<FORM ACTION="Schedule.SchedForm" METHOD="POST" NAME="toSchedForm"onSubmit="if (this.ACTION1.value == 'single_order')
                                    {
                                       if (to_SchedForm(this))
                                       {
                                           return true
                                       }
                                       else
                                       {
                                          return false
                                       }
                                    }
                                    else
                                    {
                                       if (to_MultiSchedForm(this))
                                       {
                                          document.toSchedForm.action="Schedule.multi_schedform";return true
                                       }
                                       else
                                       {
                                          return false
                                    }
                                       return false
                                 }">
<INPUT TYPE="hidden" NAME="P_EMS_DIVISION" VALUE="M ">
<INPUT TYPE="hidden" NAME="P_DOC_PREFIX" VALUE="XQ">
<INPUT TYPE="hidden" NAME="P_DOC_NUMBER" VALUE="APHL ">
<INPUT TYPE="hidden" NAME="P_DOCUMENT_TYPE" VALUE="Q">
<INPUT TYPE="hidden" NAME="P_PART_DLS" VALUE="A">
<INPUT TYPE="hidden" NAME="P_PART_PLS" VALUE=" ">
<INPUT TYPE="hidden" NAME="P_PART_NUM" VALUE="23214821">
<INPUT TYPE="hidden" NAME="p_mode_chk" VALUE="CR">
<INPUT TYPE="hidden" NAME="p_chkbox_cnt" VALUE="1">

<INPUT TYPE="checkbox" NAME="p_part_chkbox" VALUE="1">
********
TANK ASM - FUEL
*******
-
12
0
0
0
0
0
****
-

<INPUT TYPE="hidden" NAME="P_EMS_DIVISION" VALUE="M ">
<INPUT TYPE="hidden" NAME="P_DOC_PREFIX" VALUE="XQ">
<INPUT TYPE="hidden" NAME="P_DOC_NUMBER" VALUE="APHL ">
<INPUT TYPE="hidden" NAME="P_DOCUMENT_TYPE" VALUE="Q">
<INPUT TYPE="hidden" NAME="P_PART_DLS" VALUE="A">
<INPUT TYPE="hidden" NAME="P_PART_PLS" VALUE=" ">
<INPUT TYPE="hidden" NAME="P_PART_NUM" VALUE="***********">
<INPUT TYPE="hidden" NAME="p_mode_chk" VALUE="CR">
<INPUT TYPE="hidden" NAME="p_chkbox_cnt" VALUE="2">

<INPUT TYPE="checkbox" NAME="p_part_chkbox" VALUE="2">
********
TANK ASM - FUEL
J1UJ3  -000
-
*****
0
0
0
0
0
********
-

A: Get the rows from it:
List<WebElement> tableRows = table.findElements(By.xpath("tr"));

And then table cells either:
List<WebElement> tableCells= table.findElements(By.xpath("tr/td"));

OR - Loop through all tableRows in a for loop and get the cells by
for(WebElement row : tableRows) {
    List<WebElement> cells = row.findElements(By.xpath("td"));
   }

And finally you can get the value in the cell by using
for(WebElement cell : tableCells) {
    System.out.println( "Value = " + cell.getText());
}


text:
Q: How much set theory does the category of sets remember? Question. Let $M$ be a model of enough set theory. Then we can form a category $\mathbf{Set}_M$ whose objects are the elements of $M$ and whose morphisms are the functions in $M$. To what extent is $M$ determined by $\mathbf{Set}_M$ as a category up to equivalence?
For example, suppose $M$ and $N$ are models of ZF. Then are $\mathbf{Set}_M$ and $\mathbf{Set}_N$ equivalent as categories if and only if $M$ and $N$ are isomorphic?

I expect the answer will depend on exactly what we assume about $M$.
For instance, let $M$ be a model of ZFA and let $M'$ be the universe of pure sets in $M$. Then $M \cong M'$ if and only if $M$ has no atoms; but the inclusion $\mathbf{Set}_{M'} \hookrightarrow \mathbf{Set}_M$ is an equivalence as soon as $M$ satisfies the axiom "each set is in bijection with some pure set", which happens if e.g. $M$ satisfies the axiom of choice.
On the other hand, suppose $M$ is a transitive model of ZF. By transitive closure / Mostowski collapse, every set in $M$ is obtained from a "ZF-tree" in $M$, i.e. a set $T$ (in $M$) equipped with a well-founded extensional binary relation $E$ and a unique $E$-maximal element. The notion of ZF-tree is one that can be formulated in the internal language of a topos, so the collection of ZF-trees is recoverable from $\mathbf{Set}_M$ up to equivalence, and hence, $M$ is (exactly!) recoverable from $\mathbf{Set}_M$ up to equivalence.
Following Benedikt Löwe, a somewhat more sophisticated version of the above should work to recover well-founded models $M$ of ZFA with ($M$-)countably many atoms from $\mathbf{Set}_M$.
But what about, say:

*

*Non-well-founded models of ZF(A)?

*Weaker fragments of ZF, e.g. Mac Lane set theory?

*Set theories where the category of sets is not a topos, e.g. NBG or NF(U)?

To keep the question from being too open-ended, let me say that I would be happy to know the answer just for (possibly non-well-founded) models of ZF.

A: This is not an answer, but it's just more convenient to write a big chunk of text here instead of in a comment. I mostly just have a few small comments (that might be flawed in one way or the other). First, $\textbf{Set}_{\mathcal M}\simeq\textbf{Set}_{\mathcal N}$ holds for any two countable models of ZFC $\mathcal M$ and $\mathcal N$. The reason for this is that for every $\alpha$ we can fix bijections $F_\alpha:\aleph_\alpha^{\mathcal M}\to\omega$ and $G_\alpha:\aleph_\alpha^{\mathcal N}\to\omega$, and then define a functor $e:\textbf{Set}_{\mathcal M}\to\textbf{Set}_{\mathcal N}$ as
$e(f:\aleph_\alpha^{\mathcal M}\to\aleph_\beta^{\mathcal M}):=F_\beta^{-1}\circ G_\beta\circ f\circ F_\alpha^{-1}\circ G_\alpha:\aleph_\alpha^{\mathcal N}\to\aleph_\beta^{\mathcal N}$,
which is both essentially surjective and fully faithful, so an equivalence.
But if either model is uncountable, then an equivalence $e$ would at least require that

*

*$\text{Card}^V(\kappa)=\text{Card}^V(e(\kappa))$ (since $\hom_{\mathcal M}(1,\kappa)\approx\hom_{\mathcal N}(1,e(\kappa))$)

*$\text{Card}^V((\kappa^\lambda)^{\mathcal M})=\text{Card}^V((e(\kappa)^{e(\lambda)})^{\mathcal N})$ (since $\hom_{\mathcal M}(\lambda,\kappa)\approx\hom_{\mathcal N}(e(\lambda),e(\kappa))$)

So, (1) at least requires that $|\mathcal M|=|\mathcal N|$. Also, $\textsf{Set}_V\simeq\textsf{Set}_L$ would at least imply $\textsf{GCH}$ by (2).


text:
Q: How to disable iPhone notifications from Facebook Places? I've got this long-running annoyance about the Facebook iPhone app.
Now, I do want notifications from Facebook e.g. when someone posts on my wall/timeline or mentions me in a comment.  However, every now and again, some of my friends check in (or whatever it's technically called) somewhere with Facebook, and I get a big alert about it:

I most certainly do not want these notifications! And I don't really follow why Facebook considers someone's random check-in an event that I should be notified about.
Question is, how can I disable these—or all Facebook Places related notifications, while at it? Are there any settings on the Facebook website related to this?
I'm asking at Webapps SE, and not e.g. Apple SE, because I'm pretty sure the iPhone app doesn't have any related settings. The only FB notification setting I see is this one:

(...and as said, I wouldn't want to turn off all FB notifications.)

A: Turns out I was wrong; you can configure this on iPhone.
As the guide on this page taught me:

*

*Open Settings

*Scroll down to the application list and select Facebook

*Choose Push Notifications

Now, in my case it was probably Nearby Friends that I mostly wanted to disable. I ended up turning off some others too:

A: This has been driving me crazy because the notifications show up in the web browser Facebook, but the settings can only be accessed and turned off from the Facebook iOS app.
Note that the Facebook app has a new UI and that these settings are now inside the iOS app. I already had all Facebook iOS notifications off.
Even worse, Facebook's notion of what's nearby makes no sense for an urban area. 15 miles away, across the bridge, who cares? Stop notifying me.
Thanks.

A: here is how to remove it : go to your facebook on your phone; slide to the right so you can see newsfeed, messages, etc etc , go to Account Setting, then go to Notifications, then go to Mobile Push, then uncheck NEARBY FRIENDS.......There you have it !!!


text:
Q: Eclipse/pydev can't resolve module I'm using PyDev within Eclipse (Oxygen) and have Python 3.6 installed. The Preferences and project properties both show Python 3.6 being used. But when I try to use calendar, I get
<bound method TextCalendar.formatyear of <calendar.TextCalendar object at 0x1073839e8>>

when I print it out. And Eclipse/PyDev can't resolve calendar
In idle3 if I print out calendar, it shows that it's coming from Python 3.6,
<module 'calendar' from '/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/calendar.py'>

How do I get this properly configured?
Thanks.

A: My imports included:
from calendar import calendar

This is what caused the problem. Changing it to just
import calendar

got the correct module.


text:
Q: Symfony Localized Routes - Optional Locale I'd like the following urls to serve the appropriate actions:

*

*/ - indexAction

*/fr - indexAction

*/foo - detailsAction (slug = foo)

*/fr/foo - detailsAction (slug = foo)

I have added the following action methods:
/**
 * @Route("/{_locale}", name="home", defaults={"_locale": ""}, requirements={"_locale": "fr|es"})
 */
public function indexAction() {
    ...
}

/**
 * @Route("/{_locale}/{slug}", name="details", defaults={"_locale": ""}, requirements={"_locale": "fr|es"})
 */
public function detailsAction($slug) {
    ...
}

This works fine if I go to /, /fr and /fr/foo. However when I go to /foo it doesn't find a matching route. I'd appreciate it if someone could show me how to this.
Please note that ideally i'd like to achieve this without having to add multiple @Route annotations for a particular action method. That way I can use the UrlGenerator and point to the same name to produce the localized and none localized route whether I pass the _locale parameter or not.

A: I have managed to get this to work although my solution is slightly hacky. First I removed {_locale} part of the path, the defaults and requirements from my routes above.
Then when I created my routes I said:
$routes = new RouteCollection();

// Load the routes
...

$routes->addPrefix('/{_locale}', ['_locale' => ''], ['_locale' => '|fr|es']);

This automatically adds the localization bits (removed above) to the routes so it can easily be configured in one place. I changed RouteCollection to my own type with the following:
use Symfony\Component\Routing\RouteCollection as BaseRouteCollection;

class RouteCollection extends BaseRouteCollection {
    public function addPrefix($prefix, array $defaults = [], array $requirements = []) {
        foreach ($this->all() as $route) {
            $route->setPath($prefix . rtrim($route->getPath(), '/'));
            $route->addDefaults($defaults);
            $route->addRequirements($requirements);
        }
    }
}

This makes sure the localized home page route doesn't end with a forward slash e.g. /fr/.
Finally I had to override the Route class with the following:
use ReflectionProperty;
use Symfony\Component\Routing\Route as BaseRoute;

class Route extends BaseRoute {
    public function compile() {
        // Call the parent method to get the compiled route
        $compiledRoute = parent::compile();

        // Override the regex property
        $property = new ReflectionProperty($compiledRoute, 'regex');
        $property->setAccessible(true);
        $property->setValue($compiledRoute, str_replace('^/', '^/?', $compiledRoute->getRegex()));

        return $compiledRoute;
    }
}

This is particularly hacky but does save you from having to add a heap more code. All it does is replace the regular expression so that the first forward slash is optional which allows the /foo url to work. Note: You will have to make sure your RouteCollection is a collection of this class and not the Symfony Route class.
Hope this helps.


text:
Q: NOT apply css to a div We have our template designed by a design agency, they delivered us the HTML/CSS template. they have this in their css file:
div{
    float: left;
}

Now we're implementing a new chat software on the website, which the above line is applying on the chat software and it is ruining all it's css. when I clear the above line the whole template goes ruined up, and when we have it the chat software css is ruined... .
I tried to put the chat software put it after  and change the above css to:
body div{
    float: left;
}

But since the chat software is loading some js files, it brings it to the body of page and so it's css still not working well.
How I could fix this?
Thanks in advance.

A: you can put chat in a div with special ID and set float:none; to inner divs, here is the code:
HTML:

    /* chat goes here */

CSS:
#ChatContainer div{
    float: none;
}

A: Write this on that particular chat holding div(element).

 /*this will move it to right*/

or by CSS

.class{
    float:right /*or left*/
}

If you want to keep it permanent on the bottom of screen on right side as Google mail or other.

or by CSS

.class{
    position:fixed;
    bottom:0;
    right:0;
}

There are many other ways. But without more info i can only help you that much.

A: You can replace the following:
div{
    float: left;
}

with the following:
div:not(#chat){
    float: left;
}

Or
div:not([id='chat']){
    float: left;
}

Here the
 for the chat-box need to be given the id attribute as id='chat'. So your html need to contain the following as the code of the chat-box:

    code for chatbox.

The solution is based on the method of applying CSS style on all elements except with a specific id. Try it. Hope this will help.

A: You can create a different CSS file for chat software and override the style properties for same.
Or you can also try giving class to your body tag for chat software and use the same CSS given below,
body.chatbody div{
    float: left;
}


text:
Q: No tests available on mocha I have 2 samples Mocha web tests which I'm trying to run using Velocity. For some reason I don't see any tests running.
This is what I did
meteor create test
meteor add mike:mocha
meteor

I see the mark at the right top of my screen, I can add tests with a button, so I did it.
My architecture looks like this
.meteor
client
lib
public
server
tests
     Mocha
          Client
                sampleClientTest.js
          Server
                sampleServerTest.js

Finally, my console is empty, both on windows and chrome
Thoughts ?

A: I realize I'm 5 months late, but I'll answer in case someone else runs into this problem.
The problem you're having might be related to this issue, the tests seem to work when you visit the mirror listed on the terminal after you start the server.
Try opening localhost:3000 and then the mirror in a new tab


text:
Q: Two different widths on two different browsers hello guys i have a div which contains a link and a div , i gave a width of 70% to the link and a width of 30% to the div (summing it up to 100%). its working fine in chrome , but its not working in safari ..the width property of the link is not taking any effect in safari.Please help

.rec-p-b {
    width: 70%;
    background-color: #fff;
    border-radius: 0px;
    padding: 7px 10px;
}
.rec-p-b1 {
    width: 30%;
    background-color: #02020294;
    border: 1px solid #034039;
    border-radius: 0px;
    padding: 0px 5px;
}

  Profile View
  <button class="recomment_button rec-p-b1">

  </button>

A: I think the problem is the padding you add. Try use box-sizing: border-box

* { box-sizing: border-box }

.rec-p-b {
    width: 70%;
    background-color: #fff;
    border-radius: 0px;
    padding: 7px 10px;
}
.rec-p-b1 {
    width: 30%;
    background-color: #02020294;
    border: 1px solid #034039;
    border-radius: 0px;
    padding: 0px 5px;
}

  Profile View
  <button class="recomment_button rec-p-b1">

  </button>

A: Apply display: block to anchor tag
Apply following properties to both(anchor & div):
box-sizing: border-box;
float: left;

A: *

*The link tag is an inline element, so you should set it display: block, or inline-block, or float: left to floating it as block element.

*You had added the padding beside adding the width, the total size will be equal padding + width. To fix it, you should add box-sizing: border-box; to your css to merge the with as 100% of the size:
.rec-p-b {
    float: left;
    width: 70%;
    background-color: #fff;
    border-radius: 0px;
    padding: 7px 10px;
    box-sizing: border-box;
}
.rec-p-b1 {
    float: left;
    width: 30%;
    background-color: #02020294;
    border: 1px solid #034039;
    border-radius: 0px;
    padding: 0px 5px;
    box-sizing: border-box;
}


text:
Q: Reduce Object items based on Array using underscore Having this:
array = []
array.push(111,2122,333,9)

obj.user = {
    '111'  : {},
    '2122' : {},
    '333'  : {},
    '44'   : {}
}

How can I get a new object containing only the elements that exist in the array?
In the case above, it would return:
{
    '111': {},
    '2122': {},
    '111': {}
}

I have tried this:
var newObj = _.keys(_.pick(obj.user, function(value, key) {
  if ( _.indexOf(array, parseInt(key)) != -1 ) {
    return obj.user[key]
  }
}));

Which works fine when testing on jsfiddle, but it crashes my app with process out of memory. The objects/arrays are not that large, maybe 20-30 items, but that piece of code gets executed quite a lot of times.

A: You can use _.pick:
const result = _.pick(obj.user, array);

Live Example:

const array = [];
array.push(111,2122,333,9)

const obj = {
  user: {
    '111'  : {},
    '2122' : {},
    '333'  : {},
    '44'   : {}
  }
};

const result = _.pick(obj.user, array);

console.log(result);
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js"></script>


text:
Q: How to generate a unique identifier for a hash with a certain content? For a caching layer, I need to create a unique sha for a hash. It should be unique for the content of that hash. Two hashes with the same config should have the same sha.
in_2014 = { scopes: [1, 2, 3], year: 2014 }
not_in_2104 = { scopes: [1, 2, 3], year: 2015 }
also_in_2014 = { year: 2014, scopes: [1, 2, 3] }

in_2014 == also_in_2014 #=> true
not_in_2104 == in_2014  #=> false

Now, in order to store it and quickly look this up, it need to be turned
into something of a shasum. Simply converting to string does not work,
so generating a hexdigest from it does not work either:
require 'digest'
in_2014.to_s == also_in_2014.to_s #=> false
Digest::SHA2.hexdigest(in_2014.to_s) == Digest::SHA2.hexdigest(also_in_2014.to_s) #=> false

What I want is a shasum or some other identifier that will allow me to
compare the hashes with one another. I want something like the last test that will return true if the contents of the hashes match.
I could sort the hashes before to_s, yet that seems cludgy to me. I
am, for one, afraid that I am overlooking something there (a sort returns an array, no longer a hash, for one). Is there
something simple that I am overlooking? Or is this not possible at all?
FWIW, we need this in a scenario like below:
Analysis.find_by_config({scopes: [1,2], year: 2014}).datasets
Analysis.find_by_config({account_id: 1337}).datasets

class Analysis < ActiveRecord::Base
  def self.find_by_config(config)
    self.find_by(config_digest: shasum_of(config))
  end

  def self.shasum_of(config)
     #WAT?
  end

  def before_saving
    self.config_digest = Analysis.shasum_of(config)
  end
end

Note that here, Analysis does not have columns "scopes" or "year" or
"account_id". These are arbitrary configs, that we only need for looking
up the datasets.

A: I wouldn't recommend the hash method because it is unreliable. You can quickly confirm this by executing {one: 1}.hash in your IRB, the same command in your Rails console, and then in the IRB and/or Rails Console on another machine. The outputs will differ.
Sticking with Digest::SHA2.hexdigest(string) would be wiser.
You'll have to sort the hash and stringify it of course. This is what I would do:
hash.sort.to_s

If you don't want an array, for whatever reason, turn it back into a hash.
Hash[hash.sort].to_s #=> will return hash

And, for whatever reason, if you don't want to turn the hash into an array and then back into a hash, do the following for hash-to-sorted-hash:
def prepare_for_sum( hash )
  hash.keys.sort.each_with_object({}) do |key, return_hash|
    return_hash[key] = hash[key]
  end.to_s
end

Using some modifications in the method above, you can sort the values too; it can be helpful in case of Array or Hash values.

A: Turns out, Ruby has a method for this exact case: Hash.hash.
in_2014.hash == also_in_2014.hash


text:
Q: Beckhoff How to Open and Read a file in TWINCAT 3 C++ in a CycleUpdate? I am learning to use TWINCAT 3 with C++ and as my first work, I decided open a .txt file and get a number inside, and put on an string or an integer.
I have read all the documentation and have many questions. I discovered that I can't use the C++ libraries, just the TWINCAT functions. Then I got lost.
First: What are the exacts steps to Open a file in TWINCAT 3 with C++?
Second: How can I read the data in the file and put in an string or integer?
I would like to do that in a CycleUpdate.
I am sorry if it is a noob question.

A: As a first step, you have to understand that TwinCAT is providing you a PLC with real-time capabilities. Which means each task you program will need to be executed at every cycle: your task must NOT exceed a certain duration.
Many accesses to the operating system require a lot of wait times, that you would not keep in a real-time system. For that, most of function blocks you will find are equipped with an "Execute" boolean input (or similar) and outputs like "Busy", "Done" and "Error" (even "ErrorID"). These are here in order to start a process and check periodically (i.e. in each cycle) whether the process is complete.
You cannot manage a file opening, reading, writing or closing (OS functions) within a single CycleUpdate. This is the cost for assuring real-time capabilities besides.


text:
Q: chained selectfield in wtforms Flask I am building an application where I need to ask User its Location.For that, I am using SelectField of WTForm Flask. Here we ask the user to select its state from the dropdown. After using the selected state name, we populate district column. I have written the code but it's not able to change district column values after we change state name.

Form Code
class AddForm(Form):
     state=SelectField('State',coerce=int,default=29)
     district= SelectField("District",default=29)
     submit = SubmitField('Submit')

View Code
@app.route('/add', methods=['GET', 'POST'])
def add():
     form = AddForm()
     location_dao = DAOFactory.getDAO('LocationDAO')
     states=location_dao.getStates();
     form.state.choices=states
     form.district.choices=location_dao.getDistricts(form.state.data);
     if form.validate_on_submit():
         data={}
         data['state']=form.state.data
         data['district']=form.district.data
         success = location_dao.addLocation(data)
         if success is not None:
             msg='done!!!'
         else:
             msg='Something went wrong'
         flash(msg)
         return redirect(url_for('main.welcome'))
   return render_template('location/add.html',form = form)

Any help is appriciated. Thank You


text:
Q: MongoDB: "Could not connect to any servers in your MongoDB Atlas cluster (whitelist)" I am having an issue which I tried to fix for a long time.
I am trying to connect to Mongo Atlas cloud from nodejs viamongoose.
It's not my first time but I just can't find the answer.
Mongoose version: 5.9.22
Here is my code:
  const express = require('express')
    const mongoose = require('mongoose')
    const bodyparser = require('body-parser')

    const app = express()
    app.use(bodyparser.json())

  mongoose.connect("mongodb+srv://dudvil1:password@cluster0.guxmm.mongodb.net/shopping_list?
  retryWrites=true&w=majority", {
      useNewUrlParser: true,
      useUnifiedTopology: true
  })
          useNewUrlParser: true,
          useUnifiedTopology: true
      })
      .then(() => console.log('mongo connected'))
       .catch(err => console.log(err));

    const port = process.env.PORT || 5000

    app.listen(port, () => console.log(`server started in port ${port}`))

My whitelist settings include only 0.0.0.0/0
My username and password in the Database access is very simple and without any special characters, but always get the same error:
 MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://docs.atlas.mongodb.com/security-whitelist/
    at NativeConnection.Connection.openUri (C:\Users\Dudu\Desktop\MERN\node_modules\mongoose\lib\connection.js:826:32)
    at Mongoose.connect (C:\Users\Dudu\Desktop\MERN\node_modules\mongoose\lib\index.js:335:15)
    at Object.<anonymous> (C:\Users\Dudu\Desktop\MERN\server.js:10:10)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10)
    at internal/main/run_main_module.js:17:11 {
  message: "Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://docs.atlas.mongodb.com/security-whitelist/",
  reason: TopologyDescription {
    type: 'ReplicaSetNoPrimary',
    setName: null,
    maxSetVersion: null,
    maxElectionId: null,
    servers: Map {
      'cluster0-shard-00-02.guxmm.mongodb.net:27017' => [ServerDescription],
      'cluster0-shard-00-00.guxmm.mongodb.net:27017' => [ServerDescription],
      'cluster0-shard-00-01.guxmm.mongodb.net:27017' => [ServerDescription]
    },
    stale: false,
    compatible: true,
    compatibilityError: null,
    logicalSessionTimeoutMinutes: null,
    heartbeatFrequencyMS: 10000,
    localThresholdMS: 15,
    commonWireVersion: null
  }
}

Thanks a lot.

A: You can try the following steps:

*

*Click on the Network Access.

*Click on the edit button located right next to the delete button.

*Click on "ADD CURRENT IP ADDRESS" Button and click confirm.

This way you will be able to access your database from any IP address.
Let me know if it works out for you :)

A: I had the same problem with my strapi app, I solved the problem adding 2 options in my database config:
'AUTHENTICATION_DATABASE', null
'DATABASE_SSL', true

In strapi database.js:
options: {
    authenticationDatabase: env('AUTHENTICATION_DATABASE', null),
    ssl: env.bool('DATABASE_SSL', true),
  },

A: use current IP address
1)Go to network access on mongodb
2)select current Ip ADDRESS

A: I had the same problem. don't add your ip address from your terminal or network preference. Instead...

*

*Go to MongoDb Network Access, Then click edit on the ip address, or add Ip address if you haven't added any.

*Click add the current IP address then click confirm... vuala you're set.


text:
Q: How to use the classes of the host application from a Qt plugin? I have linking problems by creating a Qt C++ plugin to extend the functionality of my application. The code compiles and everithing works, but only as long as I use the Qt library classes, like QString for example. The moment I give to the plugin's class a reference to an object from the classes defined in the host app, the project is not linked anymore. Creating the plugin I follow the procedure from the Qt documentation and take into consideration the given examples - echo and plug&paint. However, such case is not covered there.

update
Here is the error:

myPlugin.obj:-1: error: LNK2019: unresolved external symbol "public: class QString __cdecl myClass::answer(void)const " (?answer@myClass@@QEBA?AVQString@@XZ) referenced in function "public: virtual class QString __cdecl myPlugin::echo(class myClass *)" (?echo@myPlugin@@UEAA?AVQString@@PEAVmyClass@@@Z)

And here is the project that causes it:
plugtest.pro
TEMPLATE = subdirs

SUBDIRS += \
    host \
    plugin

host.pro
QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = host
TEMPLATE = app

SOURCES += main.cpp\
        MainWindow.cpp \
    myClass.cpp

HEADERS  += MainWindow.h \
    myClass.h \
    plugInterface.h

FORMS    += MainWindow.ui

MainWindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QMessageBox>
#include <QPluginLoader>
#include <QDir>
#include "myClass.h"
#include "plugInterface.h"

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private slots:
    void on_button_clicked();

private:
    bool loadPlugin();

    Ui::MainWindow *ui;

    plugInterface *m_interface;

    myClass *m_class;
};

#endif // MAINWINDOW_H

myClass.h
#ifndef MYCLASS_H
#define MYCLASS_H

#include <QObject>

class myClass : public QObject
{
    Q_OBJECT
public:
    explicit myClass(QObject *parent = 0);

    QString answer() const;
    void setAnswer(const QString &str);

private:
    QString m_answer;
};

#endif // MYCLASS_H

plugInterface.h
#ifndef PLUGINTERFACE_H
#define PLUGINTERFACE_H

#include <QString>
#include "myClass.h"

class plugInterface
{
public:
    virtual ~plugInterface() {}
    virtual QString echo(myClass *value) = 0;
};

#define PlugInterface_iid "example.suite.app.PluginInterface"

Q_DECLARE_INTERFACE(plugInterface, PlugInterface_iid)

#endif // PLUGINTERFACE_H

MainWindow.cpp
#include "MainWindow.h"
#include "ui_MainWindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    if (!loadPlugin())
    {
        QMessageBox::information(this, "Error", "Could not load the plugin");
    }

    m_class = new myClass(this);
    m_class->setAnswer("Good!");
}

MainWindow::~MainWindow()
{
    delete ui;
}

bool MainWindow::loadPlugin()
  {
      QDir pluginsDir(qApp->applicationDirPath());

      if (pluginsDir.dirName().toLower() == "debug" || pluginsDir.dirName().toLower() == "release")
      pluginsDir.cd("plugins");

      foreach (QString fileName, pluginsDir.entryList(QDir::Files))
      {
          QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName));
          QObject *plugin = pluginLoader.instance();
          if (plugin) {
              m_interface = qobject_cast<plugInterface *>(plugin);
              if (m_interface)
                  return true;
          }
      }

      return false;
  }

void MainWindow::on_button_clicked()
{
    ui->lineResult->setText(m_interface->echo(m_class));
}

myClass.cpp
#include "myClass.h"

myClass::myClass(QObject *parent) : QObject(parent)
{

}

QString myClass::answer() const
{
    return m_answer;
}

void myClass::setAnswer(const QString &str)
{
    m_answer = str;
}

plugin.pro
  TEMPLATE        = lib
  CONFIG         += plugin
  QT             += widgets
  INCLUDEPATH    += ../host
  HEADERS         = myPlugin.h
  SOURCES         = myPlugin.cpp
  TARGET          = $$qtLibraryTarget(myPlugin)
  DESTDIR         = ../plugins

myPlugin.h
#ifndef MYPLUGIN_H
#define MYPLUGIN_H

#include <QObject>
#include "plugInterface.h"

class myPlugin : public QObject, plugInterface
{
    Q_OBJECT
    Q_PLUGIN_METADATA(IID "example.suite.app.PluginInterface")
    Q_INTERFACES(plugInterface)

public:
    QString echo(myClass *value) Q_DECL_OVERRIDE;
};

#endif // MYPLUGIN_H

myPlugin.cpp
#include "myPlugin.h"

QString myPlugin::echo(myClass *value)
{
    return value->answer();
}

A: The solution that worked for me is to make the myClass a part of a library and include it dynamically in both the plug-in and the host. However, I am curious if this could be done without creating a library.


text:
Q: Can't add a file to git, seriously Solved, as explained in a comment under the accepted answer.
I have been using Git since years and I am really surprised that I there is one specific file that I can't add to the staging area in one of my repos! I don't want to delete and recreate the repo but to understand what is going on and fix it. Also, now I am worried that maybe there are other files that are not being added to the repo (or in other repos).
I have one repo in which I have just committed and pushed successfully a bunch of files, and then I have realized that one of them, init.el, didn't get uploaded.
This is what I have:

*

*Running git add init.el does not produce any output

*The file (or a pattern matching it) is not specified in any .gitignore file (in the current folder, in a child folder, or in one of the parent directories until the root).

*There is not parent Git repository that I have accidentally created and that is messing with that file

*The file (or a patter matching it) is not listed in .git/info/exclude

*The file (or a pattern matching it) does not appear when I run git ls-files --others -i --exclude-standard
I have then tried removing the file rm init.el, which correctly leads to
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
    modified:   .gitignore

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
    deleted:    init.el

Then, I have tried doing git rm init.el, which again correctly led to
rm 'init.el'

But putting back the file and then adding the file with git add init.el shows no output, and the file is still missing from the staging area (I have checked this with git status, git diff --cached and by committing and pushing (see next line)).
Trying to commit, push and double check what is going on in Github confirms that the file has not been added.
You never stops learning, is there anything standard that I am unaware of that may be triggering this behavior, or is this an error and so is there a way I can repair the repo?
EDIT, to answer one comment

*

*pwd gives /Users/my_user/.my_spacemacs.d

*cat .gitignore gives

.DS_Store
spacemacs_d_backup2020/

*

*find . -name '.gitignore' gives

./spacemacs_d_backup2020/.gitignore
./.gitignore

*

*finally, cat ./spacemacs_d_backup2020/.gitignore gives

.DS_Store

A: Let's talk about what git says when you talk to it. First, here's a folder with some files in it:
$ ls
a.txt   b.txt

Now I'll try to add a.txt to the staging area:
$ git add a.txt
$

Hmm, git didn't say anything. That's just like what you reported:

Running git add init.el does not produce any output

Darn. Why isn't it being added? Okay, let's try something else:
$ git status
On branch master
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
    new file:   b.txt

Hmm, it didn't list a.txt. I'm getting worried! Okay, let's try a different way:
$ git diff --cached
diff --git a/b.txt b/b.txt
new file mode 100644
index 0000000..ce01362
--- /dev/null
+++ b/b.txt
@@ -0,0 +1 @@
+hello

Hmm, again it didn't mention a.txt. That's just like what you reported:

the file is still missing from the staging area (I have checked this with git status, git diff --cached

You also said:

The file (or a pattern matching it) does not appear when I run git ls-files --others -i --exclude-standard

OK, let me try that too:
$ git ls-files --others -i --exclude-standard
$

Nothing! Gosh, this is terrible. Why isn't a.txt being added to the staging area?
Because it's already in the staging area. The problem here is not that a.txt is not in the staging area; it's a misunderstanding of what the staging area is — possibly of what git itself is.
Here's the thing to remember:

*

*Every commit contains all the files.

*By default, every new commit contains all the same files as the previous commit. (The only differences will be files you have changed.)

*By default, the staging area contains all the files in the last commit.

*When you ask questions like git status or git diff, git only tells you what is new and different. It doesn't report what exists.
So that explains the mystery. Before all of this started, I already added and committed a.txt. So it is already in the staging area and it is already in the last commit.
So when I say git add a.txt, git says to itself: "Yep, well, a.txt is already in the staging area, and it hasn't changed, so nothing new here, move along, folks, move along" — and it doesn't reply.
And when I say git diff --cached, git doesn't mention a.txt because diff means "difference", and a.txt in the staging area is not different from a.txt in the last commit.
But none of that means that a.txt is not in the last commit or that it is not in the staging area. On the contrary, it means exactly the opposite. It means that it is in both of those places.
Now let's talk about lists.
Let's say we want to know what files are in the staging area. That's what git ls-files is for, plain and simple:
$ git ls-files
a.txt
b.txt

Look, there it is! a.txt is there after all! Okay, let's say we want to know what's in the most recent commit. Remember, what's in the most recent commit is also what was in the previous commit, and the commit before that, and the commit before that, except for any changes we may have performed each time. Every commit contains all the files, by default. So if a.txt has ever been committed, it is sufficient to see if it is in the latest commit. And here's how to do that:
$ git ls-tree --name-only HEAD
a.txt

There it is again!
So you see, a.txt was not failing to be added after all. It's just that I didn't understand what git was telling me.
Finally, you also say

Trying to commit, push and double check what is going on in Github confirms that the file has not been added

Well, I can't explain that one. But I can't look over your shoulder and see what you're doing at GitHub — and GitHub is hard to use. Maybe the problem is just one of not knowing how to look. If you are on a branch locally and you commit and push, and you then go to GitHub and hunt for a file, you might not find it, because GitHub by default doesn't show you the branch you were working on; it shows master (or main).
So here's my guess as to what's going on: You are on a branch locally, and you already added-and-committed init.el, perhaps quite a while ago, and you have not changed it since then. That, as I think I've demonstrated, would explain the phenomena you have described in your question.


text:
Q: Vertical SeekBar behaves strangely when initiated on a thread I'm using a simple Vertical SeekBar that is working fine if I initiate it on the onCreate function. But if I initiate the SeekBar on a different thread the thumb position does not work as expected.
The code I'm using to initiate the SeekBar:
public class MainActivity extends Activity {
AbsoluteLayout mainLayout;
VerticalSeekBar seekBar;
Context context;

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

    context=this;
    mainLayout=(AbsoluteLayout)findViewById(R.id.main_layout_id);
    Thread thread1 =new Thread(runnable1);
    thread1.start();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}
private Runnable runnable1 = new Runnable(){
    @Override
    public void run() {
        seekBar=new VerticalSeekBar(context);
        loadMainScreen.sendEmptyMessage(0);
    }
};

Handler loadMainScreen = new Handler() {
    @Override
    public void handleMessage(Message msg) {
        super.handleMessage(msg);
            AbsoluteLayout.LayoutParams parameters = new AbsoluteLayout.LayoutParams(40,200,150,30);
            mainLayout.addView(seekBar,parameters);
        }
};
  }

I do not think the problem is on the SeekBar but I will show the code anyway.
public class VerticalSeekBar extends SeekBar implements OnSeekBarChangeListener {

public VerticalSeekBar(Context context) {
    super(context);
    this.setOnSeekBarChangeListener(this);
}

public VerticalSeekBar(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
}

public VerticalSeekBar(Context context, AttributeSet attrs) {
    super(context, attrs);
}

protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(h, w, oldh, oldw);
}

@Override
protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(heightMeasureSpec, widthMeasureSpec);
    setMeasuredDimension(getMeasuredHeight(), getMeasuredWidth());
}

protected void onDraw(Canvas c) {
    c.rotate(-90);
    c.translate(-getHeight(), 0);

    super.onDraw(c);
}

@Override
public boolean onTouchEvent(MotionEvent event) {
    if (!isEnabled()) {
        return false;
    }

    switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN:
    case MotionEvent.ACTION_MOVE:
    case MotionEvent.ACTION_UP:
        setProgress(getMax() - (int) (getMax() * event.getY() / getHeight()));
        onSizeChanged(getWidth(), getHeight(), 0, 0);
        break;

    case MotionEvent.ACTION_CANCEL:
        break;
    }
    return true;
}

@Override
public void onProgressChanged(SeekBar seekBar, int progress,
        boolean fromUser) {
    // TODO Auto-generated method stub
}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {
    // TODO Auto-generated method stub
}

@Override
public void onStopTrackingTouch(SeekBar seekBar) {
    // TODO Auto-generated method stub
}
 }

I try changing the Context I'm passing to the variable context to getApplicationContext() and getBaseContext() but it did not work.
If I put the initialization on a runOnUiThread it crashes because the SeekBar is not initialized when I try to add to the layout. If I put both the initialization and the addView on a runOnUiThread it works but that is not what I want.
I was wondering if there is something I could do regarding the Context to make it work. Any different ideas are welcome.
Thanks in advance


text:
Q: Any reason not to make heavy use of PHP's exec()? If I control the server environment and filter out harmful injections, any reason why I shouldn't exec( 'mkdir '.$perm.' '.$name ) in PHP?
And rather than using php GD, can I not use exec('mogrify -resize '.$width.' '.$myfile) ?
And for almost any other file-system/file-manipulation operation, can I not use command-line via exec and parse the result? Am I being n00b?
I have to write some thumbnailing/resizing logic (again!!!!), and will gladly take a shortcut if I see one - providing it's not a mouse trap...

A: Well, one big argument against this is that you make the script more dependent on the underlying system. It won't be as easy to port it to another server that doesn't have ImageMagick, or runs Windows where the command line commands look different.
Other than that, I'd say there is nothing fundamentally wrong with it. If IM is available, I'd gladly use that for resize operations.
Note that there is a PHP extension featuring an interface to IM as well.

A: On UNIX exec() will make a fork of the initiating process, such as apache, which is a costly OS action.


text:
Q: Can the Addons Warning be disabled? Since the Shadowlands Prepatch, I'm getting the dialog in the image below every time I log in, and sometimes after logging out of a character to switch to another.  The way I want my addons to be set up is that they are enabled, but the "Load out of date addons" checkbox is disabled, so as they are updated they'll already be enabled.  Unfortunately, the first option actively disables the addons (so even after they update I have to enable them manually), and the second option enables all of them and also enables "load out of date addons," and there does not seem to be a way to cancel it without taking action.  Is there an option somewhere to disable this dialog?  Even when I hit load anyway it seems to come up every time I log in.

A: This is unfortunately something that happens with every major/minor patch. The check against your addons happen every time you log in until the addons are patched or removed. Your best way to avoid this message is to just disable them (as much as you don't want to). And then re-enable them when the addon has been updated.
What you're asking the game to do is to contradict itself, if you want an addon enabled then it has to be checked during loading. But if it's out of date, you're going to get that message. But if you check the box that says "Load out of date addons" you won't get that warning message, but you'll also have addons that may or may not work properly because they're enabled and out of date.
You can't have it both ways.

A: I believe that this dialog is misleading. It will not untick all out of date addons, it will just permanently untick "load out of date addons". So you can accept it once and be happy.


text:
Q: Predicting Real Numbers Here is an astounding riddle that at first seems impossible to solve.  I'm certain the axiom of choice is required in any solution, and I have an outline of one possible solution, but would like to see how others might think about it.

$100$ rooms each contain countably many boxes labeled with the natural numbers.  Inside of each box is a real number.  For any natural number $n$, all $100$ boxes labeled $n$ (one in each room) contain the same real number.  In other words, the $100$ rooms are identical with respect to the boxes and real numbers.
Knowing the rooms are identical, $100$ mathematicians play a game.  After a time for discussing strategy, the mathematicians will simultaneously be sent to different rooms, not to communicate with one another again.  While in the rooms, each mathematician may open up boxes (perhaps countably many) to see the real numbers contained within.  Then each mathematician must guess the real number that is contained in a particular unopened box of his choosing.  Notice this requires that each leaves at least one box unopened.
$99$ out of $100$ mathematicians must correctly guess their real number for them to (collectively) win the game.
What is a winning strategy?

A: Before entering, the mathematicians agree on a choice of representatives for real sequences when two sequence are equivalent if they are equal past some index ; and a re-labeling of $\Bbb N$ into $M \times \Bbb N$ where $M$ is the set of mathematicians.
Once a mathematician $m$ is in the room, he opens every box not labeled $(m,x)$ for $x \in \Bbb N$, and for $m' \neq m$ he carefully notes the greatest index $x(m')$ (which is independent of $m$) where the sequence $(m',x)$ has a different value from that of its corresponding representative, and $x(m') = -1$ if it is the representative.
Then, $m$ computes $y(m) = \max_{m' \neq m} x(m') +1$, and opens every box labeled $(m,x)$ for $x > y(m)$. He finds the representative of that sequence, and guesses what's inside box $(m,y(m))$ according to that representative. He has the risk of guessing wrong if $y(m) \le x(m)$ (he is the only one not knowing the value of $x(m)$).
If there is an $m$ such that $x(m') < x(m)$ for every $m' \neq m$, then $m$ will be the only mathematician that can answer wrongly (for the others, $y(m') > x(m) > x(m')$). If there are several $m$ whose $x(m)$ tie for greatest, then they will all answer correctly.

A: Found this via Reddit. Here's my writeup of the solution.

The strategy involves the axiom of choice like so: the mathematicians group sequences of real numbers such that two sequences are in the same group if and only if they agree on all but the first few terms.
For example, let $\pi_i$ denote the $i$-th digit of $\pi$ (i.e. $\pi_0=3,\pi_1 = 1,\pi_2=4,\dots$).
Then the sequences $(\gamma,e,\sqrt 2,2^{4/3},\pi_1,\pi_2,\pi_3,\dots)$ and $(\ln(2),\gamma,-7.8,\pi_0,\pi_1,\pi_2,\pi_3,...) $
 are in the same group, because they both are equal on all but the first 4 elements.
The Axiom of Choice is required to choose an arbitrary representative from each group. For example, I can choose $(1.49,3,-\cos(4),\pi_0,\pi_1,\pi_2,...)$ to represent the group I described above, but since there's infinitely many groups and I only have a finite amount of space to describe my strategy, I must appeal to the Axiom of Choice to produce a "choice function" that tells me which representative should be chosen from each of the groups.

Now I'll describe the plan. Let's say I'm mathematician #1. I'm going to open every box except 1, 101, 201, 301, and so on. Meanwhile mathematician #2 will open every box except 2, 102, 202, 302, etc., and in general mathematician #$n$ will open all boxes except those labeled $n,100+n,200+n,300+n,...$.
Back to me. I know what's inside the boxes that my buddy in room 2 didn't open. Let's suppose the numbers are:

*

*2 -> 1739218.33

*102 -> sqrt(5)-sqrt(2)

*202 -> Arctan(37.238)

*302 -> 382

*402 -> -832.019

*502 -> 4

*602 -> $\pi_3$

*702 -> $\pi_4$

*802 -> $\pi_5$

*...

Okay, I know the group that falls in. (Coincidentally, it's the group I talked about above.) I'm going to write a note that it started matching the representative from box $602$ onward. Let's write that note like this: "x(2)=6". I'll repeat that process for #3, noting "x(3)=5" for box $503$, and for #4, perhaps I note that "x(4)=7" for box $704$, and so on.
What I've done is defined $x(m)$ for $m\in\{2,\dots,100\}$ to be the first box that disagrees with the associated representative given by the Axiom of Choice. However, I don't know the value of $x(1)$ since I haven't opened boxes $1,101,201,\dots$ yet.
What I can do though is let $y(1) = \max(x(2),...,x(100))+1$ be larger than all the observed numbers. It just so happened that $x(4)=7$ was the biggest, so $y(1)=8$.
It's finally time to open most of the remaining boxes. I'll open all the boxes in my sequence $1, 101, 201, \dots$, starting with the box given by $y(1)=8$: box $801$. (Since $y(1)$ has to be at least $1$, this strategy always leaves at least box $001$ closed.) Let's see what I got (let $e_i$ denote the $i$-th digit of $e$):

*

*1 -> ???

*101 -> ???

*...

*701 -> ???

*801 -> 7pi+sqrt(3)

*901 -> $e_{9}$

*1001 -> $e_{10}$

*1101 -> $e_{11}$

*...

Seeing those last digits, I know enough to figure out which group it belongs to: the group with representative $(\sqrt 2,e_1,e_2,e_3,...)$.
I now know enough to make my guess. I'm going to use the representative, and pick the box given by $y(1)-1=7$, which is the maximum value of $\{x(2),\dots,x(100)\}$ (which we said was $x(4)$ in this example). In this case, the seventh entry is $e_7=1$ (note that we're zero-indexing so that the first entry goes with box $001$). So I'll guess that box $701$ contains $1$.

Of course, mathematician #$n$ will do exactly the same thing by considering the values of $\{x(1),\dots,x(n-1),x(n+1),\dots,x(100)\}$,
computing $y(n)$, and so on. Now, I need to prove to you that these strategies work.
To do this, I just need to prove that if I'm wrong, then everyone else is right! (99/100 ain't bad, according to the rules.)
Okay, I'm wrong, so what happened? Obviously, the box given by $y(1)-1$ didn't match the Axiom of Choice's representative. That means that $x(1)>y(1)-1$, since $x(1)$ is the number for which every other mathematician knew the boxes from that point forward matched the Axiom of Choice's representative.
With this information, I realize something. $y(1)-1\geq x(n)$ for every other number n, since $y(1)$ is defined to be the maximum of the $x(n)$ plus one! So here's what I now know:
$x(n)\leq y(1)-1<x(1)$
This is great news. Everyone else defined $y(n)$ knowing $x(1)$, and $x(1)$ has just been shown to be bigger than the other $x(n)$. So:
$x(n)\leq y(1)-1<x(1)<x(1)+1=y(n)$
So, for each mathematician #$n$, all boxes $x(1)$ and onward match the representative given by the Axiom of Choice. Every mathematician #$n$ opened $x(1)+1$ onward, and guessed the choice function's $x(1)$ entry for the $x(1)$ box, which has to match up!
Thus, if I'm wrong, everyone else has to be right. And that beats the game.


text:
Q: Generator not working as expected in python I've been working on a genetic algorithm in PyTorch, and I've run into an issue while trying to mutate my model's parameters. I've been using the .apply() function to randomly change a model's weights and biases. Here is the exact function I made:
def mutate(m):
    if type(m) == nn.Linear:
        m.weight = nn.Parameter(m.weight+torch.randn(m.weight.shape))
        m.bias = nn.Parameter(m.bias+torch.randn(m.bias.shape))

This function does work for sure, I've tested it, but this isn't the weird part. While trying to use this function for every model in a list, the same mutation happens to each and every model. I obviously don't want this, as I want variety in my population. Here is a reproduceable example:
import torch
import torch.nn as nn
population_size = 5 #Size of the population
population = [nn.Linear(1,1)]*population_size #Creating my population, each agent is a player in this list
dummy_input = torch.rand(1) #Random input
def mutate(m): #Mutation function
    if type(m) == nn.Linear:
        m.weight = nn.Parameter(m.weight+torch.randn(m.weight.shape))
        m.bias = nn.Parameter(m.bias+torch.randn(m.bias.shape))
population = list(x.apply(mutate) for x in population) #This is the line I've been having issues with
for i in population:
    print (i(dummy_input)) #This is here to show that all the models are mutating in the same way and outputting the same thing

This code has the following output:
tensor([-2.0366], grad_fn=<AddBackward0>)
tensor([-2.0366], grad_fn=<AddBackward0>)
tensor([-2.0366], grad_fn=<AddBackward0>)
tensor([-2.0366], grad_fn=<AddBackward0>)
tensor([-2.0366], grad_fn=<AddBackward0>)

As you can see, all the models mutated in the same way, and are yielding the same output.
This is running in Python 3.9, thank you all in advance.

A: When x is a mutable object and you write [x]*n you are essentially creating a list of n references to the same object x.
What you want in your case is something like
[nn.Linear(1,1) for _ in range(population_size)]

A: It looks like creating a list of linear parameters in the way you do simply copies the initial nn.Linear object. For example, setting population[0].weight = nn.Parameter() sets all linear layer weights in population list to an empty parameter value. In your case, the final random weight and bias assigned by the mutate function is given to all layers in the population list since they are all copies of one another.
Changing the fourth line of your code to population = [nn.Linear(1,1) for _ in range(population_size)] creates five unique linear layers and fixes this problem.


text:
Q: How can I create a new model that is an extention of an existing model with an additional field Currently the additional field is calculted in the grid columnCfgs using an xtype of templatecolumn. I need to add this field to the grid data store so that it can be used to filter the grid data.

A: Model classes fields property is processed in a special fashion. Instead of replacing the parent class' ones as a normal property would, child fields are appended to them.
See this example:
Ext.define('Base', {
    extend: 'Ext.data.Model'
    ,fields: ['foo','bar']
});

Ext.define('Extended', {
    extend: 'Base'
    ,fields: ['baz']
});

var record = Ext.create('Extended');

record.fields.each(function(field) {
    console.log(field.name);
});

That gives the following output:
foo
bar
id
baz


text:
Q: Getting comma separated values into input field I am struggling already for some time to create script that deletes and adds values to field. The point is that when I click on div - there will be images inside, it will copy part of its class to field, or remove if it's already copied there. All the values in field input_8_3 need to be comma separated without spaces except the last one and in case there is only one value there shouldn't be any comma. The same with field input_8_4, but there I need only erased values.
In addition I need divs to change class on click, one click to add class, another to remove it, but this is how far could I get with my issue.
I need this for deleting images in custom field in Wordpresses frontend. input_8_3 goes to meta and input_8_4 to array in function to delete chosen images.
Thanks in advance!

(function($){
$('.thumbn').click(function() {
    var text = $(this).attr("id").replace('img-act-','')+',';
    var oldtext = $('#input_8_3').val();
    $('#input_8_3').val(text+oldtext);
});
})(jQuery);

(function($){
$('div.thumbn').click(function() {
    $(this).removeClass('chosen-img');
});
})(jQuery);

(function($){
$('.thumbn').click(function() {
    $(this).addClass('chosen-img');
});
})(jQuery);
.thumbn {
    width: 85px;
    height: 85px;
    background: #7ef369;
    float: left;
    margin: 10px;
}
.chosen-img.thumbn{background:#727272}
input{width:100%}

<input type="text" id="input_8_3" readonly="" value="3014,3015,3016,3017,3018" class="form-control data_lable">
<input type="text" id="input_8_4" readonly="" value="" class="form-control data_lable">

EDIT: I changed value of input_8_3. All the numbers in img-act-**** and values in input_8_3 are the same on load.

A: I've made a JS of it working.
https://jsfiddle.net/jatwm8sL/6/
I've added these:
var array = [3008,3009,3010,3011,3012];

$("#input_8_3").val(array.join());

and changed your click functions to this
var array = [3008,3009,3010,3011,3012];
var array1 = [];

$("#input_8_3").val(array.join());

(function($){
$('div.thumbn').click(function() {
    var text = $(this).attr("id").replace('img-act-','');
  var oldtext = $('#input_8_3').val();
    if ($(this).hasClass('chosen-img'))
  {
    $('#input_8_3').val(text+oldtext);
    var index = array.indexOf(text);
    if (index !== -1)
    {
        array.splice(index, 1);
    }

    array1.push(text);
    $(this).removeClass('chosen-img');
  }
  else
  {
    array.push(text);
    var index = array1.indexOf(text);
    if (index !== -1)
    {
        array1.splice(index, 1);
    }
    $(this).addClass('chosen-img');
  }
  $("#input_8_3").val(array.join());
  $("#input_8_4").val(array1.join());
  console.log(array1);
});
})(jQuery);

Basically, you need to check if it has a class and then remove if it has and add it if it doesn't.
Also, it's better to use a javascript array than to play around with html values as you change javascript arrays while HTML should really just display them.
If anything is unclear, let me know and I'll try to explain myself better

A:

var transformNumbers = (function () {
    var numerals = {
        persian: ["۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹"],
        arabic: ["٠", "١", "٢", "٣", "٤", "٥", "٦", "٧", "٨", "٩"]
    };
    function fromEnglish(str, lang) {
        var i, len = str.length, result = "";

        for (i = 0; i < len; i++)
            result += numerals[lang][str[i]];
        return result;
    }
    return {
        toNormal: function (str) {
            var num, i, len = str.length, result = "";

            for (i = 0; i < len; i++) {
                num = numerals["persian"].indexOf(str[i]);
                num = num != -1 ? num : numerals["arabic"].indexOf(str[i]);
                if (num == -1) num = str[i];
                result += num;
            }
            return result;
        },
        toPersian: function (str, lang) {
            return fromEnglish(str, "persian");
        },
        toArabic: function (str) {
            return fromEnglish(str, "arabic");
        }
    }
})();
  document.getElementById('ApproximateValue').addEventListener('input', event =>
            event.target.value = TolocalInt(event.target.value)
        );
        function TolocalInt(value)
        {
            if ((value.replace(/,/g, '')).length >= 9) {
                value = value.replace(/,/g, '').substring(0, 9);
            }
            var hasZero = false;
            var value = transformNumbers.toNormal(value);
            var result = (parseInt(value.replace(/[^\d]+/gi, '')) || 0);
            if (hasZero) {
                result = '0' + (result.toString());
            }
            return result.toLocaleString('en-US');
        }
<input id="ApproximateValue" name="ApproximateValue"  type="text" maxlength="12" />