text:
Q: Find the remainder when you divide $x^{81} + x^{49} + x^{25} + x^{9} + x$ by $x^{3}-x$. Find the remainder when you divide $x^{81} + x^{49} + x^{25} + x^{9} + x$ by $x^{3}-x$.

Attempt:
Let $f(x) = x^{81} + x^{49} + x^{25} + x^{9} + x$, then the remainder of $f(x)$ divided by $(x-1)$ is $f(1)$, divided by $(x+1)$ is $f(-1)$.
Now since $x^{3}-x = x(x^{2}-1)=x(x-1)(x+1)$ is there any relation between the remainder of $f(x)$ divided by $x^{3}-x$ and remainder when $f(x)$ divided by $(x-1)$ and $(x+1)$?

A: Hint
$$x^{81} + x^{49} + x^{25} + x^{9} + x=(x^{3}-x)Q(x)+R(x)$$where $$R(x)=ax^2+bx+c$$and $$R(0)=0\\R(1)=5\\R(-1)=-5$$

A: There are a few ways to do this problem : one of which is a more general method which turns out to be very elaborate in this case. Let $p(x) = x^3 - x$.
The first is to note that $x^3 \equiv x \mod p(x)$, therefore $x^{2n+1} \equiv x \mod p(x)$ for all $n \geq 0$(show this by induction). Thus, the given expression simplifies to $$
q(x) = x^{81} + x^{49}  + x^{25} + x^9+x \equiv x+x+x+x+x \equiv 5x \mod p(x)
$$
which is the answer.

For the more general method, we have the Chinese remainder theorem for polynomials. We find the remainder when $q(x)$ is divided by $x, x+1$ and $x-1$, which are the relatively prime factors of $x^3 - x$. The CRT guarantees a unique polynomial modulo $x^3-x$ that leaves those remainders modulo $x,x+1$ and $x-1$ respectively, which then will be the remainder.
For example, it is clear that $q(x) \equiv 0 \pmod {x}$, and that $q(1) = 5$ and $q(-1) = -5$.
Thus, $q(x) \equiv -5 \pmod{x+1}$ and $q(x) \equiv 5 \pmod{x-1}$.
While the CRT provides us with an algorithm for computing the remainder in this case, we may also proceed by brute force : the remainder must be $ax^2+bx+c$, a degree two polynomial since $x^3-x$ is of degree $3$.
By substituting $x = 0$, $x= 1$ and $x=-1$ we get $c = 0 ; a+b = 5$ and $a-b = -5$. Thus, from here we get $a=c=0$ and $b=5$, thus the remainder is $5x$.

A: As the degree of the divisor is $3$, so the degree of the remainder is at most $2$. Let the remainder $R\left(x\right)$ be $ax^2+bx+c$. As $x^3-x=x\left(x-1\right)\left(x+1\right)$, we'll find that: $$\begin{cases} R\left(-1\right)=a-b+c=\left(-1\right)^{81}+\left(-1\right)^{49}+\left(-1\right)^{25}+\left(-1\right)^9+\left(-1\right)=-5 \\ R\left(0\right)=c=0^{81}+0^{49}+0^{25}+0^9+0=0 \\ R\left(1\right)=a+b+c=1^{81}+1^{49}+1^{25}+1^9+1=5 \end{cases}$$ After some calculation, you'll get $a=0,b=5,c=0$, so the remainder is $\boxed{5x}$.

A: You may use

*

*$(x^2-1)|(x^{2k} -1)$ by applying $(x^2)^k - 1 = (x^2-1)(x^{2(k-1)} + \cdots + x^2 + 1)$
\begin{eqnarray*} x^{81} + x^{49} + x^{25} + x^{9} + x
& = & x\left((x^2)^{40} -1  + (x^2)^{24} -1  + (x^2)^{12} -1 + (x^2)^{4} -1  + 4+1\right) \\
& = & x((x^2-1)p(x) + 5)\\
& = & x(x^2-1)p(x) + 5x
\end{eqnarray*}
So, the remainder is $5x$.

A: The remainder is a quadratic polynomial $g(x)$ that is divisible by $x$ (since $f(x)$ is divisble by $x$ and has remainders $f(1)$ and $f(-1)$ from division on $(x-1)$ and $(x+1)$ respectively.
One may argue that:
$$
g(x)=f(1)\frac{x+1}{2}+f(-1)\frac{x-1}{-2} + \gamma(x^2-1)
$$
From the fact $g(0) = 0$, one can find the coefficient $\gamma=\frac{f(1)-f(-1)}2$.

A: Hint:
Let $$x^{81}+x^{49}+x^{25}+x^9+x=p(x)(x^3-x)+ax(x-1)+bx(x+1)+c(x-1)(x+1)$$
where $a,b,c$ are arbitrary constants
Put $x=0,-1,1$ to find $a,b,c$

A: $$x^{81} + x^{49} + x^{25} + x^{9} + x=\left(x^{81}-x\right)+\left(x^{49}-x\right)+\left(x^{25}-x\right)+\left(x^9-x\right)+5x.$$
Can you end it now?


text:
Q: AngularJS Navigation between controller Index pages I am new to AngularJs . I have 2 controllers in my MVC3 application with corresponding index pages.
Let's say the first controller is LoginController and the other one is DashboardController.
Each index page has different layouts. I want to navigate to DashboardController  index.cshtml page if login is successful. How can I navigate to DashboardController index page from the current LoginController index page with the help of angularjs $routeprovider?
app.js
angular.module('testModule', ['ngRoute'])
.controller('LoginController', function ($scope, $http, $location) {
$scope.Authenticate = function () {
    $scope.Login.UserId = 2;
    $scope.Login.RoleId = 501;
    $scope.Login.AcctPassword = 'sss';
    var postform = JSON.stringify($scope.Login);
    if ($scope.Login.Username != '') {

        $http.post('/Login/Authenticate', postform).success(function (data) {
            if (data.Status == false) {
                alert(data.errorMessage);
            }
            else {
                $location.path("/Dashboard");
            }
        });
    }
};
})
.config(['$routeProvider', '$locationProvider',
  function ($routeProvider, $locationProvider) {

    $routeProvider
   .when('/', {templateUrl: '/Login/Index.cshtml',controller: 'LoginController'  })
   .when('/Temp', {templateUrl: '/Login/TempView.cshtml',controller: 'LoginController' })
   .when('/Dashboard', { templateUrl: '/Dashboard/Listing', controller: 'DashboardController' })
   .otherwise({ redirectTo: '/' });

    $locationProvider.html5Mode(true); //Remove the '#' from URL.
  } ]);

The Dashboard is an Area in my Project. Listing is the controller in Dashboard Area with an index.cshtml page .

A: I would rather inject $window into your LoginController.
You could then define this method in the controller :
$scope.go = function(path = "#/Dashboard/") {
  return $window.location = path;
};

Then use it in your template:
<ANY ng-click="go()"/>
<ANY ng-click="go('#/Temp/')"/>

redpajama_set_name: RedPajamaStackExchange


text:
Q: Scanning an array of strings for match in Ruby I have an array:
a = ["http://design.example.com", "http://www.domcx.com", "http://subr.com"]

and then I want to return true if one of the elements in that array matches the string:
s = "example.com"

I tried with include? and any?.
a.include? s
a.any?{|w| s=~ /#{w}/}

I don't know how to use it here. Any suggestions?

A: You can use any? like:
[
  "http://design.example.com",
  "http://www.domcx.com",
  "http://subr.com"
].any?{ |s| s['example.com'] }

Substituting your variable names:
a = [
  "http://design.example.com",
  "http://www.domcx.com",
  "http://subr.com"
]
s = "example.com"
a.any?{ |i| i[s] }

You can do it several other ways also, but the advantage using any? is it will stop as soon as you get one hit, so it can be much faster if that hit occurs early in the list.

A: How is the below:
a=["http://design.example.com", "http://www.domcx.com", "http://subr.com"]
s= "sus"
p a.any? { |w| w.include? s } #=> false

a=["http://design.example.com", "http://www.domcx.com", "http://subr.com"]
s= "design.example"
p a.any? { |w| w.include? s } #=>true

a=["http://design.example.com", "http://www.domcx.com", "http://subr.com"]
s= "desingn.example"
p a.any? { |w| w.include? s } #=>false

a=["http://design.example.com", "http://www.domcx.com", "http://subr.com"]
s= "example"
p a.any? { |w| w.include? s } #=>true

a=["http://design.example.com", "http://www.domcx.com", "http://subr.com"]
s= "example.com"
p a.any? { |w| w.include? s } #=>true


text:
Q: android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked using fragments It happens when i call the inp(its used to retrieve data from the database) function in OneFragment.java what it does is catches all the data and stores it in the db and grabs it and added to the list view the insertion works fine when i try to retrieve it  gives the error is that is a problem with db closing? or with context passing? iam new tho this
DatabaseHelper.java
package info.androidhive.UcCollegeNotifier;

/**
 * Created by Extreme on 4/15/2017.
 */

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

import java.util.ArrayList;
import java.util.List;

import android.util.Log;

public class DatabaseHandler extends SQLiteOpenHelper {

    // All Static variables
    // Database Version
    private static final int DATABASE_VERSION = 1;

    // Database Name
    private static final String DATABASE_NAME = "contactsManager";

    // Contacts table name
    private static final String TABLE_CONTACTS = "contacts";

    // Contacts Table Columns names
    private static final String KEY_ID = "id";
    private static final String KEY_DATE = "date";
    private static final String KEY_TIME = "time";
    private static final String KEY_NEWS = "news";
    private static final String KEY_VALID = "valid";

    public DatabaseHandler(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
       //context.deleteDatabase(DATABASE_NAME);
    }

    // Creating Tables
    @Override
    public void onCreate(SQLiteDatabase db) {
        //String CREATE_CONTACTS_TABLE = "CREATE TABLE " + TABLE_CONTACTS + "(" + KEY_ID + " INTEGER PRIMARY KEY," + KEY_DATE + " TEXT,"+KEY_TIME +"TEXT," + KEY_NEWS +"TEXT," + KEY_VALID + " TEXT)";
//        db.execSQL("CREATE TABLE contacts1(id INTEGER AUTOINCREMENT, date VARCHAR,time VARCHAR,news VARCHAR);");
Log.d("Creadeted","DB Creadeted");
        String CREATE_CONTACTS_TABLE = "CREATE TABLE " + TABLE_CONTACTS + "("
                + KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + KEY_DATE + " TEXT,"
                + KEY_TIME + " TEXT," + KEY_NEWS + " TEXT,"+ KEY_VALID+ " TEXT"+")";
        db.execSQL(CREATE_CONTACTS_TABLE);
//
// db.execSQL(
//                "create table contacts1 " +
//                        "(id integer primary key, date text,time text,news text, valid text)"
//        );
    }

    // Upgrading database
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        // Drop older table if existed
        db.execSQL("DROP TABLE IF EXISTS " + TABLE_CONTACTS);

        // Create tables again
        onCreate(db);
    }

    /**
     * All CRUD(Create, Read, Update, Delete) Operations
     */

    // Adding new contact
    public void addContact(String id,String date,String time,String news,String valid) {
        SQLiteDatabase db = this.getWritableDatabase();

        ContentValues values = new ContentValues();
      // values.put(KEY_ID,id ); // Contact Name
        values.put(KEY_DATE,date); // Contact Phone
        values.put(KEY_TIME,time ); // Contact Phone
        values.put(KEY_NEWS,news);
        db.insert(TABLE_CONTACTS, null, values);
        //values.put(KEY_VALID,valid);
        //Log.d("Insering",id);
        Log.d("Insering",date);
        Log.d("Insering",time);
        Log.d("Insering",news);
       // Log.d("Insering",valid);

        // Inserting Row

        db.close(); // Closing database connection
    }

    // Getting single contact
//    Contact getContact(int id) {
//        SQLiteDatabase db = this.getReadableDatabase();
//
//        Cursor cursor = db.query(TABLE_CONTACTS, new String[] { KEY_ID,
//                        KEY_DATE, KEY_TIME,KEY_NEWS,KEY_VALID }, KEY_ID + "=?",
//                new String[] { String.valueOf(id) }, null, null, null, null);
//        if (cursor != null)
//            cursor.moveToFirst();
//
////        Contact contact = new Contact(Integer.parseInt(cursor.getString(0)),
////                cursor.getString(1), cursor.getString(2));
//        // return contact
//        return contact;
//    }

    // Getting All Contacts
    public List<Contact> getAllContacts() {

        List<Contact> contactList = new ArrayList<Contact>();
        // Select All Query
        String selectQuery = "SELECT  * FROM " + TABLE_CONTACTS;

        SQLiteDatabase db = this.getWritableDatabase();
        Cursor cursor = db.rawQuery(selectQuery, null);

        // looping through all rows and adding to list
        if (cursor.moveToFirst()) {
            do {
                Contact contact = new Contact();
                contact.setID((Integer.parseInt(cursor.getString(0))));
                contact.setDate(cursor.getString(1));
                contact.setTime(cursor.getString(2));
                contact.setNews(cursor.getString(3));

                // Adding contact to list
                contactList.add(contact);
            } while (cursor.moveToNext());
        }

        // return contact list
        return contactList;
    }

    // Updating single contact
//    public int updateContact(Contact contact) {
//        SQLiteDatabase db = this.getWritableDatabase();
//
//        ContentValues values = new ContentValues();
//        values.put(KEY_NAME, contact.getName());
//        values.put(KEY_PH_NO, contact.getPhoneNumber());
//
//        // updating row
//        return db.update(TABLE_CONTACTS, values, KEY_ID + " = ?",
//                new String[] { String.valueOf(contact.getID()) });
//    }

    // Deleting single contact
    public void deleteContact(Contact contact) {
        SQLiteDatabase db = this.getWritableDatabase();
        db.delete(TABLE_CONTACTS, KEY_ID + " = ?",
                new String[] { String.valueOf(contact.getID()) });
        db.close();
    }

    // Getting contacts Count
    public int getContactsCount() {
        String countQuery = "SELECT  * FROM " + TABLE_CONTACTS;
        SQLiteDatabase db = this.getReadableDatabase();
        Cursor cursor = db.rawQuery(countQuery, null);
        cursor.close();

        // return count
        return cursor.getCount();
    }

}

OneFragment.java
public class OneFragment extends Fragment {
    public static  boolean flagt;
    public static String[] ids;
    public static String[] date;
    public static String[] time;
    public static String[] news;
    public static String[] valid;
    public static String log;

    public static String strArray[]={"Hello there","hi"};
            //=new String[10];
           ArrayList<String> listItems=new ArrayList<String>();
    //private ListView mainListView ;
    ArrayAdapter<String> adapter;
    List<Map<String,List<String>>> list = new ArrayList<Map<String,List<String>>>();//This is the final list you need
    Map<String, List<String>> map1 = new HashMap<String, List<String>>();//This is one instance of the   map you want to store in the above map
    List<String> arraylist1 = new ArrayList<String>();
   // List<Map<String, String>> data = new ArrayList<Map<String, String>>();
    //String ts;
boolean ts;
    private ProgressDialog loading;
    DatabaseHandler db=new DatabaseHandler(getActivity());
    public OneFragment() {

        // Required empty public constructor

    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

       // getda();
        //getData();
      ts=MainActivity.chek();
      if(ts) {
           Toast.makeText(getActivity(),"Loggin found",Toast.LENGTH_SHORT).show();
           getData();
       }

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.fragment_one, container, false);
       //ArrayAdapter<String> ListViewAdapter =new ArrayAdapter<String>(getActivity(),android.R.layout.simple_list_item_1,ids);
//        ts=MainActivity.chek();
//       if(ts) {
//          Toast.makeText(getActivity(),"Loggin found",Toast.LENGTH_SHORT).show();
//           getData();
//       }
        // Inflate the layout for this fragment
       // return inflater.inflate(R.layout.fragment_one, container, false);
        //Toast.makeText(getActivity(),"e,lladasd",Toast.LENGTH_SHORT).show();
//        ListView ls=(ListView)view.findViewById(R.id.lis1);
//       ListViewAdapter =new ArrayAdapter<>(getActivity(),android.R.layout.simple_list_item_1,strArray);
//        ls.setAdapter(ListViewAdapter);
        ListView ls=(ListView)view.findViewById(R.id.list);
        adapter=new ArrayAdapter<String>(getActivity(),
                android.R.layout.simple_list_item_1,
                arraylist1);
ls.setAdapter(adapter);

return view;
    }

    public class Config {
        public static final String DATA_URL = "http://kambi.appsmash.in/kuntham.php";
        public static final String k_date12 = "id";
        public static final String k_first = "date";
        public static final String k_second = "time";
        public static final String k_third = "news";
        public static final String k_compli = "valid";
        public static final String JSON_ARRAY = "result";
    }

    private void getData() {
        //String id = editTextId.getText().toString().trim();
        //if (id.equals("")) {
        //Toast.makeText(this, "Please enter an id", Toast.LENGTH_LONG).show();
        //return;
        Toast.makeText(getActivity(), "e,lladasd", Toast.LENGTH_SHORT).show();

        String url = Config.DATA_URL;

        StringRequest stringRequest = new StringRequest("http://disapp.000webhostapp.com/ucgrab.php/ucgrab.php", new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                showJSON(response);
            }
        },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Toast.makeText(getActivity(), error.getMessage().toString(), Toast.LENGTH_LONG).show();
                    }
                });

        RequestQueue requestQueue = Volley.newRequestQueue(getActivity());
        requestQueue.add(stringRequest);

    }

    private void showJSON(String response) {
        //ParseJSON pj=new ParseJSON(json)
        //pj.parseJSON();
//        String date123 = "";
//        String first1 = "";
//        String second2 = "";
//        String third3 = "";
//        String compli4 = "";
        try {
            JSONObject jsonObject = new JSONObject(response);
            JSONArray result = jsonObject.getJSONArray(Config.JSON_ARRAY);
            JSONObject collegeData = result.getJSONObject(0);
//            date123 = collegeData.getString(Config.k_date12);
//            first1 = collegeData.getString(Config.k_first);
//            second2 = collegeData.getString(Config.k_second);
//            third3 = collegeData.getString(Config.k_third);
//            compli4 = collegeData.getString(Config.k_compli);
            ids= new String[result.length()];
            date= new String[result.length()];
            time= new String[result.length()];
            news= new String[result.length()];
            valid= new String[result.length()];
            for(int i=0;i<result.length();i++) {
                JSONObject jo = result.getJSONObject(i);
                ids[i] = jo.getString("id");
                date[i] = jo.getString("date");
                time[i] = jo.getString("time");
                news[i] = jo.getString("news");
                valid[i] = jo.getString("valid");
                //Used to show data get from server
//                Toast.makeText(getActivity(), ids[i].toString(), Toast.LENGTH_SHORT).show();
//                Toast.makeText(getActivity(), date[i].toString(), Toast.LENGTH_SHORT).show();
//                Toast.makeText(getActivity(), time[i].toString(), Toast.LENGTH_SHORT).show();
//                Toast.makeText(getActivity(), news[i].toString(), Toast.LENGTH_SHORT).show();
//                Toast.makeText(getActivity(), valid[i].toString(), Toast.LENGTH_SHORT).show();
                DatabaseHandler db = new DatabaseHandler(getActivity());
                db.addContact(ids[i], date[i], time[i], news[i], valid[i]);

//if()
//{
//   flagt=true;
//}
//            }
//            if(flagt==true)
//            {
//                inp();
            }

                //Log.d("Reading: ","Reading all contacts..");
//                List<Contact> contacts = db.getAllContacts();
//
//                for (Contact cn : contacts) {
//                    log = "Date: " + cn.getDate() + "Time: " + cn.getTime()+"Notification"+cn.getNews()+";";
//                    // Writing Contacts to log
//                    getda(log);
//                    Log.d("Name: ", log);
////                    ArrayList<String> planetList = new ArrayList<String>();
////                    planetList.addAll( Arrays.asList(log) );
////                    listAdapter = new ArrayAdapter<String>(this,R.layout.fragment_one, planetList);
//                    //ListView ls=(ListView)view.findViewById(R.id.lis1
//                    //ArrayAdapter<String> ListViewAdapter =new ArrayAdapter<String>(getActivity(),android.R.layout.simple_list_item_1,ids);
//                   String strArray[] = log.split(";");
//                    System.out.println("String Array is : ");
////                    for(i=0; i < strArray.length; i++){
////                        //System.out.println(strArray[i]);
////                        //ListViewAdapter.add("log");
////                      //  getda(log);
////                    }
//                }

//            Map<String, String> datum = new HashMap<String, String>(2);
//            datum.put("First Line", "First line of text");
//            datum.put("Second Line","Second line of text");
//            listItems.add(datum);

        } catch (JSONException e) {
            e.printStackTrace();
        }

//        Toast.makeText(getActivity(), date123, Toast.LENGTH_SHORT).show();
//        Toast.makeText(getActivity(), first1, Toast.LENGTH_SHORT).show();
//        Toast.makeText(getActivity(), second2, Toast.LENGTH_SHORT).show();
//        Toast.makeText(getActivity(), third3, Toast.LENGTH_SHORT).show();
//        Toast.makeText(getActivity(), compli4, Toast.LENGTH_SHORT).show();

    }
    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        if (isVisibleToUser) {
            Toast.makeText(getActivity(), "chhosed one", Toast.LENGTH_LONG).show();
          //  getData();

        }
    }

    //Log.d("Reading: ","Reading all contacts..");
//    List<Contact> contacts = db.getAllContacts();
//
//    for (Contact cn : contacts) {
//        String log = "Id: "+cn.getID()+" ,Name: " + cn.getDate() + " ,Phone: " + cn.getTime()+",NEws"+cn.getNews();
//        // Writing Contacts to log
//        Log.d("Name: ", log);
//    }
    public void getda(String log)
    {

        arraylist1.add(log);//And so on..
        map1.put(log,arraylist1);
//And so on...
        list.add(map1);//In this way you can add.
        //listItems.add(log);
        adapter.notifyDataSetChanged();

    }
    public void inp()
    {
        List<Contact> contacts = db.getAllContacts();

                for (Contact cn : contacts) {
                    log = "Date: " + cn.getDate() + "Time: " + cn.getTime()+"Notification"+cn.getNews()+";";
                    // Writing Contacts to log
                    getda(log);
                    Log.d("Name: ", log);

//                    ArrayList<String> planetList = new ArrayList<String>();
//                    planetList.addAll( Arrays.asList(log) );
//                    listAdapter = new ArrayAdapter<String>(this,R.layout.fragment_one, planetList);
                    //ListView ls=(ListView)view.findViewById(R.id.lis1
                    //ArrayAdapter<String> ListViewAdapter =new ArrayAdapter<String>(getActivity(),android.R.layout.simple_list_item_1,ids);
                   String strArray[] = log.split(";");
                    System.out.println("String Array is : ");
//                    for(i=0; i < strArray.length; i++){
//                        //System.out.println(strArray[i]);
//                        //ListViewAdapter.add("log");
//                      //  getda(log);
//                    }
                }
    }
}

A: Found the solution the problem was with
DatabaseHandler db=new DatabaseHandler(getActivity());

Which is in the "onefragment" file I have splitted the operation into two
First one is in the top section
 DatabaseHandler db;

And on the Oncreate()
db =new DatabaseHandler(getActivity());

Thanks to this thread for helping me(kdehairy)
SQLite database in combination with fragments


text:
Q: TypeScript get specific string combinations for array of strings I'm trying to create a name-twister to get the correct format and combination "surname, givenName" for my api....
You should be able to put in a string array, for example:
["John", "Paul", "Stirling"])
and it should return all string combinations that fit into the schema:

*

*John, Paul Stirling

*John, Stirling Paul

*Paul, John Stirling

*Paul, Stirling John

*Stirling, John Paul

*Stirling, Paul John

I was thinking about working with a sorting algorithm. The problem is that there is no fixed number of names entered. The user can also enter only "John" and "Paul" or maybe even 4 names.
I would highly appreciate, if someone would come up with a solution idea!! Thanks in advance!


text:
Q: Python: setting configuration parameters What's your preferred way of processing configuration parameters?
For example:
test(this=7)

could be processed by:
def test(**kw):
  this = kw.pop('this', 1)
  that = kw.pop('that', 2)

or
def test(**kw):
  if 'this' in kw:
      this = kw['this']
  else:
      this = 1
  if 'that' in kw:
      that = kw['that']
  else:
      that = 2

Is there a better (more pythonic) way?

A: If the possible parameters and defaults are fixed, the Pythonic way is to write:
def test(this=1, that=2):
    ...

If the parameter list is dynamic, your approach with kwds.pop() has a nice advantage of letting you verify that all the arguments were used (detecting misspelled parameter names for example).  It is instructive to look at a fragment from the code generated by collections.namedtuple('Point', ['x', 'y'], verbose=True).  Notice the final check to make sure all arguments were consumed from kwds:
    def _replace(_self, **kwds):
        'Return a new Point object replacing specified fields with new values'
        result = _self._make(map(kwds.pop, ('x', 'y'), _self))
        if kwds:
            raise ValueError('Got unexpected field names: %r' % kwds.keys())
        return result

A: I personally like to loop through the key/value pair's like so:
def test(**kw):
    for k, v in kw.items():
        if k == 'this':
            something = v
        # etc...


text:
Q: IOS ARC: Unable to use #define constant directly I have a constant in my MyClass.m file named:
#define kUDUserHistory              @"kUDUserHistory";

With no-ARC I was able to use it directly but now I have to copy it in second variable and then use it. If I try to use it directly in ARC it shows an error 'Expected Expression'.
no-ARC
[[NSUserDefaults standardUserDefaults] setObject:data forKey:kUDUserHistory];

ARC
NSString *key = kUDUserHistory;
[[NSUserDefaults standardUserDefaults] setObject:data forKey:key];

My specific Question are:

*

*Whay I am not able to use constant directly in this case?

*What is the best approach to manage constants especially in ARC?

A: #define kUDUserHistory              @"kUDUserHistory";

Should be:
#define kUDUserHistory              @"kUDUserHistory"

For your answer:
[[NSUserDefaults standardUserDefaults] setObject:data forKey:@"kUDUserHistory";];

Passing it first to an NSString:
NSString *key = @"kUDUserHistory";;

That's why it works.

A: You can also use
in .h file
extern NSString * const kUDUserHistory;
in .m file
NSString * const kUDUserHistory = @"kUDUserHistory";


text:
Q: Narrowing an object of type unknown I have read multiple posts and issues on here with respect to narrowing an object of type unknown in TypeScript. But I have not found this specific question or solution.
Most solutions I find state to do something like this.
const result: unknown = {
  movieName: "test",
};

if (
  typeof result === "object" &&
  result !== null &&
  "movieName" in result &&
  typeof result.movieName === "string" // <-- Error Here
) {}

The error states

Property 'movieName' does not exist on type 'object'

How do I narrow it so that it knows that the unknown thing is an object which contains the property movieName? How do I access result.movieName for an unknown type?
edit: perhaps it's not possible? and the recommendation in the comments below of declaring it as a Record<string, unknown> may be the only way per this GitHub request?

A: UPDATE FOR TS4.9+
TypeScript 4.9 will introduce support for in operator narrowing of unlisted properties, as implemented in microsoft/TypeScript#50666, as a fix for microsoft/TypeScript#21732 mentioned below.  At that point the above code will just work without modification:
const result: unknown = {
    movieName: "test",
};

if (
    typeof result === "object" &&
    result !== null &&
    "movieName" in result &&
    typeof result.movieName === "string" // <-- okay
) {
    result.movieName.toUpperCase(); // <-- okay
}

Playground link to code

PREVIOUS ANSWER FOR TS4.8-
This is currently a missing feature in TypeScript.  See microsoft/TypeScript#21732 for the relevant feature request.  Right now when you use the in operator as a type guard like k in result, it only really does any meaningful narrowing if the type of result is a union where some members are known to have the key k and others are not.  It does not assert the existence of a property with key k.  So in your case, where the type of result is just object (narrowed from unknown), nothing meaningful happens.
The workaround I sometimes use is to write my own user-defined type guard function which behaves the way I want in to behave.  For example:
function hasKey<K extends string, T extends object>(
    k: K, o: T
): o is T & Record<K, unknown> {
    return k in o;
}

Now, instead of writing k in result, I write hasKey(k, result):
if (
    typeof result === "object" &&
    result !== null &&
    hasKey("movieName", result) &&
    typeof result.movieName === "string" // okay
) {
    result.movieName.toUpperCase(); // okay
}

This works how you want, and is arguably the closest you can get to type safety here, at least until something is done to address microsoft/TypeScript#21732 natively.
Playground link to code


text:
Q: Find the probability that the product of 2 dice throws is a multiple of 3 I am a retired person who studies maths as a hobby.
This is the problem I am struggling with:
2 unbiased dice are thrown. Find the probability that the product of the scores is a) odd, b) a multiple of 3, c) a multiple of 12.
I know the total number of possibilities is $6 \times 6 = 36$
As regards a) an odd number x an odd number = an odd number
so the probability is $\frac{1}{2} \times\frac{1}{2} = \frac{1}{4}$
Now for b) I would have thought if one dice rolls a 3 or a 6 then any  score on the other dice would give a product which is a multiple of 3. Since there is a $\frac{1}{3}$ chance of this happening on any one dice I would have thought the probability is $\frac{1}{3}$.
But the book says $\frac{5}{9}$
As regards c) I was able to work out this as $\frac{7}{36}$, but only by actually counting the possible outcomes. I don't know the method.

A: For second, the favorable outcomes are as follows -
If you take $3$ on first dice, $6$ favorable outcomes
If you take $6$ on first dice, again $6$ favorable outcomes
If you take $3$ on second dice, only $4$ additional outcomes as two were counted with first being $3$ or $6$.
Similarly for $6$ on second dice.
So total favorable outcomes $ = 6 + 6 + 4 + 4 = 20$.
But there is an easier way to do this. As we know, $3$ or $6$ on any dice would give product as multiple of $3$. So for product not to be multiple of $3$, we have to get from $(1, 2, 4, 5)$ on both dice. That probability is $\frac{4}{6} \times \frac{4}{6} = \frac{4}{9}$.
So probability that the product is multiple of $3 = 1 - \frac{4}{9} = \frac{5}{9}$.
For third as you rightly said, we count the favorable outcomes as below.
$12 = 3 \times 4$ or $2 \times 6$ so $4$ favorable outcomes - $(3,4), (4,3),(2,6),(6,2)$
$24 = 4 \times 6$ so $2$ favorable outcomes $(4,6), (6,4)$.
$36 = 6 \times 6$ so $1$ favorable outcome $(6,6)$.
That leads to $\frac{7}{36}$.

A: I do not think you need "a method". Simply drawing a table like the following it is very easy to see the favourable outcomes

total 20 favourable on 36 possible.


text:
Q: Kernel Panic mt7601uap I wanted to create a wifi hotspot on my ubuntu 16.04 with mt7601usb wifi adapter .
 So I cloned and compiled mt7601uap driver from here which is supposed to be ap only .
But after rebooting im stuck with a kernel panic (screen shot attached) . Removing the usb and rebooting and blacklisting the driver works but I need the driver to setup a wifi hotspot, any suggestions?


text:
Q: Ionic 3 - approxItemHeight not working in virtualScroll I have a virtualScroll where I'm specifying approxItemHeight:
<ion-list [virtualScroll]="myArray" [approxItemHeight]="'320px'">
    <ion-item *virtualItem="let myItem"></ion-item>
</ion-list>

The approxItemHeight value seems to be ignored when ionic creates the list.
Here's the ion-list element on page load:
<ion-list class="list list-ios virtual-scroll" ng-reflect-virtual-scroll="[object Object],[object Object" ng-reflect-approx-item-height="320px" style="height: 89px;">

The style of the whole list is specified as 89px, even though I specified approxItemHeight to be 320px.
Here's the first ion-item element in the list on page load:
<ion-item class="item item-block item-ios virtual-position" aria-posinset="2" aria-setsize="2" style="transform: translate3d(0px, 44px, 0px);">

After scrolling the list its height is properly calculated, though this is no longer the result of the initial calculation using approx dimensions, at this point the elements have already been initialized and everything is calculated according to their actual rendered size.
The only solution I found so far is to define min-height for the list element via css, though I'm not sure if it's a proper solution and whether or not it'll result in problems in the future.
Can you please help me understand what's going on?

A: By the Ionic document:

The approximate width and height of each template is used to help
  determine how many cells should be created, and to help calculate the
  height of the scrollable area.

We can understand that the approximate width and height is NOT used to fix the size of the item. So if you want to determine the size of each item, just do it in css.


text:
Q: Is it possible to duplicate and modify the Offset command in ArtCAM 2011? I am using ArtCAM Insignia 2011 build 215. I see there are Offset.htm and Offset.atext files within the HTML folder within ArtCam 2011. Is it possible to just make it offset it out a distance and then inwards a different distance without a pop up window? So basically a macro using modified HTML and Javascript of the Offset command. And secondly, how would it be possible to add this duplicate script/function/button/add-in so ArtCAM can use it?

A: To those wondering, it is possible.
Here is a link to my ArtCam forum post which contains a solution (posted by me).

I was able to modify the Offset command and use it in ArtCAM using the Toolbox. I created a folder in ArtCAM 2011 > Toolbox. I then copied the .htm and .atext files from offset and also the images and put it in the folder I made. I renamed Offset.htm to index.htm to follow the pattern of the other examples in Toolbox. I opened index.htm and edited what I needed. After that, in ArtCAM, I opened the toolbox window (Window tab on the top > Toolbars and docking windows > Toolbox (second to last for me)) and clicked the refresh button and my add-in appeared!

ArtCam forum link


text:
Q: Different inner margins with tikzposter Is there a way to create different margins on different edges with tikzposter?
More precisely, I would like to have a bigger distance from the left edge of the poster to the text than on the right.
There is the innermargin option used as follows:
\documentclass[25pt,
    a0paper,
    portrait,
    innermargin = 4cm
    ]{tikzposter}

But this sets both the margin on the left and on the right to the same value. How can I choose different values?
Thanks

A: Don't know if it can be done directly, but you could hack it by shifting all blocks etc. to the right or left a bit. You could do it by adding the appropriate option to all the blocks, but it can be done globally as well, as in the example below.
\documentclass[a2paper, innermargin=4cm]{tikzposter}
\title{foo}
\author{bar}
\makeatletter
\define@key{block}{bodyoffsetx}{\TP@blockbodyoffsetx=2cm}
\define@key{block}{titleoffsetx}{\TP@blocktitleoffsetx=2cm}
\makeatother
\begin{document}
\maketitle
\begin{columns}
\column{0.5}
\block{foo}{bar}
\column{0.5}
\block{foo}{bar}
\end{columns}
\block{foo}{bar}
\block{}{baz}
\end{document}


text:
Q: Maven integration-test failed: includes0 has null value My build recently started failing when trying to do mvn clean install I've not noticed previously because it builds and executes junit tests fine from eclipse. Any idea regarding the cause of the below error?
Maven log snippet:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.979s
[INFO] Finished at: Thu Jan 23 09:13:43 GMT 2014
[INFO] Final Memory: 25M/220M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.11:integration-test (failsafe-integration-tests) on project ThinkFinance: Execution failsafe-integration-tests of goal org.apache.maven.plugins:maven-failsafe-plugin:2.11:integration-test failed: includes0 has null value -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.11:integration-test (failsafe-integration-tests) on project ThinkFinance: Execution failsafe-integration-tests of goal org.apache.maven.plugins:maven-failsafe-plugin:2.11:integration-test failed: includes0 has null value
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution failsafe-integration-tests of goal org.apache.maven.plugins:maven-failsafe-plugin:2.11:integration-test failed: includes0 has null value
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 19 more
Caused by: java.lang.NullPointerException: includes0 has null value
    at org.apache.maven.surefire.booter.PropertiesWrapper.addList(PropertiesWrapper.java:172)
    at org.apache.maven.plugin.surefire.booterclient.BooterSerializer.serialize(BooterSerializer.java:95)
    at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:147)
    at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:100)
    at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:199)
    at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAllProviders(AbstractSurefireMojo.java:176)
    at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:134)
    at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:97)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    ... 20 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

Pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>My Company2</groupId>
    <version>1.0.0</version>
    <artifactId>MyCompany</artifactId>
    <packaging>jar</packaging>

    <name>MyCompany</name>
    <url>http://www.example.com</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <profiles>
        <profile>
            <id>parallel</id>
            <properties>
                <include.tests>**/ParallelRunners/*Tests.java</include.tests>
                <junit.threadCount>15</junit.threadCount>
                <junit.parallel>classes</junit.parallel>
            </properties>
        </profile>
        <profile>
            <id>allTestsSequential</id>
            <properties>
                <include.tests>
                    **/P0Regression.java
                </include.tests>
            </properties>
        </profile>
        <profile>
            <id>smoke</id>
            <properties>
                <include.tests>
                    **/RunSmokeTests.java
                </include.tests>
            </properties>
        </profile>
        <profile>
            <id>ThisTest</id>
            <properties>
                <include.tests>
                    **/RunThisTest.java
                </include.tests>
            </properties>
        </profile>
        <profile>
            <id>All</id>
            <properties>
                <include.tests>
                    **/All.java
                </include.tests>
            </properties>
        </profile>
        <profile>
            <id>clearWebserverCache</id>
            <properties>
                <include.tests>
                    **/clearWebserverCache.java
                </include.tests>
            </properties>
        </profile>
    </profiles>
    <dependencies>
        <dependency>
            <groupId>My Company2</groupId>
            <artifactId>SeleniumFrameworkCore</artifactId>
            <version>1.0.0</version>
        </dependency>
        <dependency>
            <groupId>net.masterthought</groupId>
            <artifactId>cucumber-reporting</artifactId>
            <version>0.0.21</version>
        </dependency>
        <dependency>
            <groupId>com.jcraft</groupId>
            <artifactId>jsch</artifactId>
            <version>0.1.29</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.18</version>
        </dependency>
        <!-- these 2 are needed for communicating wih a REST API usin JSON Strings as the data interchange format.
        It might eventually make sense to move this to a seperate core project -->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.2.6</version>
        </dependency>
        <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
            <version>1.1.1</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.11</version>
                <configuration>
                    <perCoreThreadCount>false</perCoreThreadCount>
                    <threadCount>${junit.threadCount}</threadCount>
                    <parallel>${junit.parallel}</parallel>
                    <includes>
                        <include>${include.tests}</include>
                    </includes>
                </configuration>
                <executions>

                    <execution>
                        <id>failsafe-integration-tests</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>integration-test</goal>
                        </goals>
                    </execution>
                    <!-- DisABLED FAILSAFE VERIFY WHILE TESTING POSH REPORTER
                    <execution>
                        <id>failsafe-verify</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                    -->
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.14</version>
                <configuration>
                    <!-- Disable unit tests -->
                    <skip>true</skip>
                </configuration>
            </plugin>
                <plugin>
                    <groupId>My Company2</groupId>
                    <artifactId>posh-cucumber-reporter-mojo</artifactId>
                    <version>0.0.1</version>
                    <executions>
                        <execution>
                            <id>execution</id>
                            <phase>verify</phase>
                            <goals>
                                <goal>generate</goal>
                            </goals>
                            <configuration>
                                <projectName>My Company Smoke Tests </projectName>
                                <outputDirectory>${project.build.directory}/cucumber-html-reports</outputDirectory>
                                <jsonLocation>${project.build.directory}/JSON/</jsonLocation>
                                <buildNumber>RC_2014_01_21_1 Revision: 27309 on QA 64</buildNumber>
                                <enableFlashCharts>true</enableFlashCharts>
                                <skippedFails>true</skippedFails>
                                <undefinedFails>true</undefinedFails>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
        </plugins>
    </build>

    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <dependencyLocationsEnabled>false</dependencyLocationsEnabled>
                </configuration>
                <!-- Only generate project reports -->
                <reportSets>
                    <reportSet>
                        <reports>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jxr-plugin</artifactId>
                <version>2.3</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>2.14</version>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>failsafe-report-only</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>findbugs-maven-plugin</artifactId>
                <version>2.5.2</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-pmd-plugin</artifactId>
                <version>3.0</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>2.10</version>
                <configuration>
                    <configLocation>CheckStyle.xml</configLocation>
                </configuration>
            </plugin>
              <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.9.1</version>
                <configuration>
                  <groups>
                    <group>
                      <title>Test Step Documentation</title>
                      <!--
                      Include packages:
                        MyApp.StepDefinitions
                      and all subpackages
                      -->
                      <packages>MyApp.StepDefinitions*</packages>
                    </group>
                    <group>
                      <title>MyApp Documentation</title>
                      <packages>MyApp*</packages>
                    </group>
                  </groups>
                </configuration>
              </plugin>
        </plugins>
    </reporting>

</project>

A: What is the value for the include.test property? Could it be that it's not set properly, i.e. it will be null just like the error message says?
<includes>
    <include>${include.tests}</include>
</includes>

Try running mvn -Dinclude.test=A and see if the error message changes (shouldn' be a NullpointerExcpetionat least.

A: Thanks for the suggestions everyone. I ran mvn clean and then a profile. That did the trick.
call mvn clean
call mvn -Psmoke verify -e -fae

Note: mvn clean install still gives build failure. I think this may be a seperate question: What is the purpose of mvn install, do I even need it?


text:
Q: Python getting next line following a certain Condition I am trying to find a good way to return a value in a url page.
I want that everytime "span class=" button" is listed I can grab the next line

"span class=" button"
0.87

I want to get 0.87
I am trying:
 import urllib

 url = 'http://test.com'
 sock = urllib.urlopen(url)
 content = sock.read().splitlines()
 sock.close()

 for i in content:
     i = i.strip()

This is where I get stuck, how do I get the next line?

A: If this is HTML you could use an html parser like BeautifulSoup
buttons = soup.findAll('span', {'class': 'button'})
for button in buttons:
  button.nextSibling

this uses nextSibling which looks like it has been changed to next_sibling in the most recent version of beautiful soup?
Python has a built in HTMLParser
if your data is
<span class="button">
0.87
</span>

you could create a class like in the example


text:
Q: add code to move each byte of i1 into the unsigned chars c1 through c4 with the high order byte going into c1 and the low order into c4 Inside the block denoted by the _asm keyword, add code to move each byte of i1 into the unsigned chars c1 through c4 with the high order byte going into c1 and the low order into c4.
#include <iostream>

using namespace std;

void main ()
            {
            unsigned char c1;
            unsigned char c2;
            unsigned char c3;
            unsigned char c4;
            unsigned long i1 (0xaabbccee);

            _asm
                        {
                        }

            cout.flags (ios::hex);
            cout << "results are " << (unsigned int) c1 << ", "
                                                << (unsigned int) c2 << ", "
                                                << (unsigned int) c3 << ", "
                                                << (unsigned int) c4 << endl;
            }

A: If you want to do it in c++ here is a way. To use _asm you might want to tag the question as such. You can use bit masking such that:
unsigned char c1, c2, c3, c4;
unsigned long long i1;
c1 = 0xFF & (i1 >> 24);
c2 = 0xFF & (i1 >> 16);
c3 = 0xFF & (i1 >> 8);
c4 = 0xFF & i1;

you can also automate this if you need to, to work with other arithmetic types:
template <typename T>
std::vector<unsigned char> getBits(T data){
    std::vector<unsigned char> ret;
    for(int i = 0; i < sizeof(T); i++)
        ret.push_back(0xFF & (data >> i*8));
    return ret;
}

Technically you can omit 0xFF & in both examples, as the type will implicitly do that when casting.
With inline assembly in g++ you can do this via something like:
#include <iostream>

int main(){
    unsigned char c1, c2, c3, c4;
    unsigned long long i1(0xaabbccee);
    asm(R"(
        .intel_syntax noprefix
        mov rax, %[i1]
        mov %[c4], al
        shr rax, 8
        mov %[c3], al
        shr rax, 8
        mov %[c2], al
        shr rax, 8
        mov %[c1], al
        .att_syntax
)"
        : [c1] "=r" (c1), [c2] "=r" (c2), [c3] "=r" (c3), [c4] "=r" (c4)
        : [i1] "r"(i1)
        : "rax");

    std::cout
    << (unsigned int) c1 << " "
    << (unsigned int) c2 << " "
    << (unsigned int) c3 << " "
    << (unsigned int) c4 << " ";

    return 0;
}

This is a bit different from how you wanted to but I have no idea how other compilers do it (I barely have an idea how gcc does it), but I hope this can be of some help. Also I assumed x86_64 as the architecture, hence rax.


text:
Q: How to align X/Y ranges of different scatter plots in ggplot2 I'm plotting several scatter plots with X/Y data. The problem is that, in order to compare the plots, the X/Y axes need to be aligned. I can do this manually but would definitely prefer an automatic solution.
For illustration, I use here one data set from which I want to plot two subsets (in reality though I have two or more completely independent data sets, each with their own time line!) The dataset as a whole is given below.
First plot:
ggplot(df[1:100,], aes(x=X, y= Y, color=starttime_ms)) +
  geom_point(size = 0.5) +
  scale_color_gradientn(colors = c("forestgreen", "gold", "red"), name = "time (ms)") +
  stat_density2d()

The second plot:
ggplot(df[100:200,], aes(x=X, y= Y, color=starttime_ms)) +
  geom_point(size = 0.5) +
  scale_color_gradientn(colors = c("forestgreen", "gold", "red"), name = "time (ms)") +
  stat_density2d()

The result:

As can be seen the X/Y axes cover different ranges. How can they be aligned? (And if I may add a second question: how can the two plots be produced in one go and shown immediately side-by-side?)
EDIT:
I've found a solution to the second question - using the package cowplot - so only the question of how to align the X/Y axes of two independent data sets remains to be answered.
library(cowplot)
a <- ggplot(df[1:100,], aes(x=X, y= Y, color=starttime_ms)) +
  geom_point(size = 0.5) +
  scale_color_gradientn(colors = c("forestgreen", "gold", "red"), name = "time (ms)") +
  stat_density2d()

b <- ggplot(df[100:200,], aes(x=X, y= Y, color=starttime_ms)) +
  geom_point(size = 0.5) +
  scale_color_gradientn(colors = c("forestgreen", "gold", "red"), name = "time (ms)") +
  stat_density2d()

plot_grid(a, b)

Data:
df <- structure(list(X = c(886.995, 876.414, 890.29, 870.686, 889.886,
                           878.858, 893.737, 875.862, 889.03, 878.506, 888.412, 879.659,
                           869.97, 813.237, 825.718, 820.695, 833.845, 809.99, 827.442,
                           822.203, 833.764, 813.335, 836.974, 823.124, 840.259, 829.392,
                           839.988, 817.891, 834.928, 826.655, 834.157, 824.684, 834.119,
                           826.621, 835.76, 825.053, 835.486, 826.374, 836.49, 834.75, 846.584,
                           834.155, 847.473, 831.293, 842.564, 830.842, 842.428, 828.199,
                           841.25, 823.716, 838.123, 823.475, 840.047, 830.131, 845.919,
                           821.53, 835.386, 830.319, 837.443, 827.744, 838.258, 837.11,
                           847.505, 827.565, 838.85, 823.371, 838.15, 856.02, 887.157, 867.535,
                           887.932, 864.748, 877.356, 866.45, 880.88, 863.509, 879.835,
                           868.479, 875.554, 862.731, 875.356, 859.63, 869.753, 860.095,
                           871.778, 853.611, 870.142, 852.563, 869.566, 858.956, 872.494,
                           852.913, 873.889, 856.914, 867.625, 858.928, 876.012, 861.61,
                           851.618, 788.261, 798.379, 777.557, 798.956, 777.083, 801.887,
                           778.075, 798.864, 785.822, 799.679, 781.541, 795.737, 785.299,
                           795.836, 792.412, 799.156, 776.022, 792.404, 787.949, 781.935,
                           793.567, 771.902, 707.73, 779.717, 788.547, 767.614, 792.656,
                           774.669, 817.467, 808.79, 821.175, 804.167, 817.827, 804.583,
                           819.402, 806.682, 818.105, 809.101, 820.088, 795.661, 817.472,
                           806.363, 817.635, 803.629, 813.491, 800.27, 800.459, 758.664,
                           785.968, 772.512, 781.696, 769.386, 792.597, 778.636, 793.8,
                           779.889, 797.779, 777.738, 799.166, 785.231, 795.49, 783.717,
                           798.131, 786.995, 795.558, 783.907, 798.121, 792.489, 801.123,
                           793.859, 802.535, 796.445, 800.297, 783.966, 796.06, 774.731,
                           779.655, 710.941, 721.324, 690.261, 726.259, 664.783, 706.26,
                           653.884, 699.744, 669.978, 725.24, 711.67, 753.881, 756.447,
                           795.456, 795.915, 870.223, 855.74, 880.141, 873.236, 901.025,
                           899.759, 916.765, 915.548, 941.198), Y = c(664.026, 658.045,
                                                                      661.254, 659.364, 664.259, 655.926, 663.828, 659.352, 663.331,
                                                                      656.485, 663.223, 653.781, 665.414, 674.523, 692.033, 683.056,
                                                                      690.348, 683.422, 691.038, 683.172, 690.431, 681.307, 691.108,
                                                                      679.978, 685.968, 679.486, 685.47, 682.479, 686.535, 679.308,
                                                                      687.094, 682.646, 686.844, 679.004, 686.636, 679.37, 687.812,
                                                                      677.968, 686.345, 672.169, 685.389, 675.053, 688.141, 675.668,
                                                                      687.256, 676.59, 688.574, 678.659, 689.709, 679.089, 687.647,
                                                                      680.711, 689.211, 679.563, 684.627, 680.587, 688.103, 678.541,
                                                                      687.672, 678.981, 685.274, 676.507, 684.368, 678.961, 686.621,
                                                                      681.139, 688.232, 672.178, 663.962, 656.615, 661.313, 655.927,
                                                                      662.064, 654.477, 663.896, 659.962, 668.294, 662.895, 668.242,
                                                                      662.718, 670.333, 662.663, 670.956, 664.628, 674.369, 667.075,
                                                                      673.834, 666.489, 671.39, 664.739, 673.173, 666.36, 671.923,
                                                                      666.652, 673.249, 664.564, 673.67, 663.489, 686.796, 719.946,
                                                                      721.271, 721.361, 722.227, 723.032, 721.333, 721.793, 721.419,
                                                                      723.948, 724.301, 722.893, 723.387, 722.16, 722.367, 720.927,
                                                                      725.513, 723.396, 726.414, 722.724, 726.956, 730.555, 728.354,
                                                                      784.936, 729.929, 730.318, 732.103, 730.996, 727.628, 713.195,
                                                                      708.602, 711.194, 708.453, 713.616, 711.269, 715.176, 709.092,
                                                                      716.382, 707.973, 715.003, 712.65, 716.613, 708.856, 717.138,
                                                                      711.883, 717.754, 712.86, 726.009, 738.927, 741.762, 736.506,
                                                                      741.965, 738.143, 741.771, 736.247, 740.68, 736.025, 738.213,
                                                                      733.757, 736.281, 731.712, 737.712, 732.11, 738.117, 731.557,
                                                                      740.61, 732.95, 736.509, 730.86, 734.704, 726.97, 731.913, 724.131,
                                                                      732.462, 730.361, 738.381, 732.796, 736.228, 738.229, 746.993,
                                                                      739.654, 734.988, 735.721, 734.151, 725.623, 732.994, 721.506,
                                                                      718.839, 702.851, 705.922, 693.595, 690.521, 677.954, 667.812,
                                                                      643.589, 647.281, 630.427, 631.522, 615.858, 621.84, 607.178,
                                                                      609.407), starttime_ms = c(329011, 329028, 329045, 329061, 329078,
                                                                                329095, 329111, 329128, 329145, 329161, 329178, 329195, 329211,
                                                                                329228, 329245, 329261, 329278, 329295, 329311, 329328, 329345,
                                                                                329361, 329378, 329395, 329411, 329428, 329445, 329461, 329478,
                                                                                329495, 329511, 329528, 329545, 329561, 329578, 329595, 329611,
                                                                                329628, 329645, 329661, 329678, 329695, 329711, 329728, 329745,
                                                                                329761, 329778, 329795, 329811, 329828, 329845, 329861, 329878,
                                                                                329895, 329911, 329928, 329945, 329961, 329978, 329995, 330011,
                                                                                330028, 330045, 330061, 330078, 330095, 330111, 330128, 330145,
                                                                                330161, 330178, 330195, 330211, 330228, 330245, 330261, 330278,
                                                                                330295, 330311, 330328, 330345, 330361, 330378, 330395, 330411,
                                                                                330428, 330445, 330461, 330478, 330495, 330511, 330528, 330545,
                                                                                330561, 330578, 330595, 330611, 330628, 330645, 330661, 330678,
                                                                                330695, 330711, 330728, 330745, 330761, 330778, 330795, 330811,
                                                                                330828, 330845, 330861, 330878, 330895, 330911, 330928, 330945,
                                                                                330961, 330995, 331011, 331028, 331045, 331061, 331078, 331095,
                                                                                331111, 331128, 331145, 331161, 331178, 331195, 331211, 331228,
                                                                                331245, 331261, 331278, 331295, 331311, 331328, 331345, 331361,
                                                                                331378, 331395, 331411, 331428, 331445, 331461, 331478, 331495,
                                                                                331511, 331528, 331545, 331561, 331578, 331595, 331611, 331628,
                                                                                331645, 331661, 331678, 331695, 331711, 331728, 331745, 331761,
                                                                                331778, 331795, 331811, 331828, 331845, 331861, 331878, 331895,
                                                                                331911, 331928, 331945, 331961, 331978, 331995, 332011, 332028,
                                                                                332045, 332061, 332078, 332095, 332111, 332128, 332145, 332161,
                                                                                332178, 332195, 332211, 332228, 332245, 332261, 332278, 332295,
                                                                                332311, 332328, 332345)), row.names = c(42488L, 42491L, 42493L,
                                                                                42497L, 42499L, 42502L, 42504L, 42507L, 42509L, 42512L, 42514L,
                                                                                42517L, 42519L, 42522L, 42524L, 42527L, 42529L, 42532L, 42534L,
                                                                                42537L, 42539L, 42542L, 42544L, 42547L, 42549L, 42552L, 42554L,
                                                                                42557L, 42559L, 42562L, 42564L, 42567L, 42569L, 42572L, 42574L,
                                                                                42577L, 42579L, 42582L, 42584L, 42587L, 42589L, 42592L, 42594L,
                                                                                42597L, 42599L, 42602L, 42604L, 42607L, 42609L, 42612L, 42614L,
                                                                                42618L, 42620L, 42623L, 42625L, 42628L, 42630L, 42634L, 42636L,
                                                                                42640L, 42642L, 42646L, 42648L, 42651L, 42653L, 42656L, 42658L,
                                                                                42661L, 42663L, 42666L, 42668L, 42671L, 42673L, 42676L, 42678L,
                                                                                42681L, 42683L, 42686L, 42688L, 42691L, 42693L, 42696L, 42698L,
                                                                                42701L, 42703L, 42706L, 42708L, 42711L, 42713L, 42716L, 42718L,
                                                                                42721L, 42723L, 42726L, 42728L, 42731L, 42733L, 42736L, 42738L,
                                                                                42742L, 42744L, 42748L, 42750L, 42754L, 42756L, 42759L, 42761L,
                                                                                42764L, 42766L, 42769L, 42771L, 42774L, 42776L, 42779L, 42781L,
                                                                                42784L, 42786L, 42789L, 42794L, 42796L, 42799L, 42801L, 42805L,
                                                                                42807L, 42811L, 42813L, 42816L, 42818L, 42821L, 42823L, 42826L,
                                                                                42828L, 42831L, 42833L, 42837L, 42839L, 42842L, 42844L, 42847L,
                                                                                42849L, 42852L, 42854L, 42857L, 42859L, 42862L, 42864L, 42867L,
                                                                                42869L, 42872L, 42874L, 42877L, 42879L, 42883L, 42885L, 42888L,
                                                                                42890L, 42893L, 42895L, 42898L, 42900L, 42903L, 42905L, 42908L,
                                                                                42910L, 42913L, 42915L, 42918L, 42920L, 42923L, 42925L, 42928L,
                                                                                42930L, 42933L, 42935L, 42938L, 42940L, 42943L, 42945L, 42948L,
                                                                                42950L, 42953L, 42955L, 42958L, 42960L, 42963L, 42965L, 42968L,
                                                                                42970L, 42973L, 42975L, 42978L, 42980L, 42983L, 42985L, 42988L,
                                                                                42990L, 42993L, 42995L, 42998L, 43000L), class = "data.frame")

A: Here's one method. Start by storing the plots:
library(ggplot2)

p1 <- ggplot(df[1:100,], aes(x=X, y= Y, color=starttime_ms)) +
  geom_point(size = 0.5) +
  scale_color_gradientn(colors = c("forestgreen", "gold", "red"),
                        name = "time (ms)") +
  stat_density2d()

p2 <- ggplot(df[100:200,], aes(x=X, y= Y, color=starttime_ms)) +
  geom_point(size = 0.5) +
  scale_color_gradientn(colors = c("forestgreen", "gold", "red"),
                        name = "time (ms)") +
  stat_density2d()

Now get the combined x and y axis limits, with pretty breaks, and assign them to each plot:
xbreaks <- pretty(c(layer_data(p1)$x, layer_data(p2)$x))
ybreaks <- pretty(c(layer_data(p1)$y, layer_data(p2)$y))

p1 <- p1 + scale_x_continuous(breaks = xbreaks, limits = range(xbreaks)) +
           scale_y_continuous(breaks = ybreaks, limits = range(ybreaks))

p2 <- p2 + scale_x_continuous(breaks = xbreaks, limits = range(xbreaks)) +
  scale_y_continuous(breaks = ybreaks, limits = range(ybreaks))

Both plots will now have the same x and y axis. To plot them together on the same page, we simply use the patchwork package:
library(patchwork)

p1 + p2

A: As @PaulStaffordAllen suggests, facet_wrap is the way to go.  To use it, you need to add a column to your data that defines the facets.
df %>%
  mutate(group=row_number() <= 100)  %>%
  ggplot(aes(x=X, y= Y, color=starttime_ms, group=group)) +
    geom_point(size = 0.5) +
    scale_color_gradientn(colors = c("forestgreen", "gold", "red"), name = "time (ms)") +
    stat_density2d() +
    facet_wrap(vars(group))

The group=group in the aes() call should calculate statistics (ie the density and colour) within facets, but this plot does not match your separate graphs.  I'm not sufficiently familiar with your data to know why that might be.  But I notice your colour scales are different between the two plots as well as the axes...


text:
Q: Translation of object in matrix I'm working on some simulation of gas particles.
My problem is that I made 3 two-dimensional integer tables. One for pressure value of particle, and another two to describe x and y movement of particle.
Although I make arraycopy and clone it still somehow manage to change values in global table
private void translate() {
    int [][] VectorXBuff = new int[500][500];
    System.arraycopy(VectorX.clone(), 0, VectorXBuff, 0, VectorX.length);
    int [][] VectorYBuff = new int[500][500];
    System.arraycopy(VectorY.clone(), 0, VectorYBuff, 0, VectorX.length);
    int [][] FieldBuff = new int[500][500];
    System.arraycopy(FieldMatrix.clone(), 0, FieldBuff, 0, VectorX.length);

    for (int y = 0; y < FieldMatrix.length; y++){
        for (int x = 0; x < FieldMatrix.length; x++){
            if(FieldBuff[x][y]!= 0 && FieldBuff[x][y]!= 9 ){
                FieldBuff[x + VectorXBuff[x][y]][y + VectorYBuff[x][y]] = Integer.valueOf(FieldBuff[x][y]);
                FieldBuff[x][y] = 0;
                VectorXBuff[x + VectorXBuff[x][y]][y + VectorYBuff[x][y]] = Integer.valueOf(VectorXBuff[x][y]);
                VectorYBuff[x + VectorXBuff[x][y]][y + VectorYBuff[x][y]] = Integer.valueOf(VectorYBuff[x][y]);
                VectorXBuff[x][y] = 0;
                VectorYBuff[x][y] = 0;
            }
        }
    }
}

A: This is because you only copy one dimension of your two dimension array. So you are still referencing the same arrays and therefore modifying it in the original one.
Basically, you have a source object [[1,2],[3,4]] and when you do a copy you are copying the pointer to [1,2] and [3,4] into a new array.
As the clone does a shallow copy (check Does calling clone() on an array also clone its contents?) this in the end resumt to just creating another array of the exactly same instances of arrays in memory.


text:
Q: Is there another function than fig.show() to show a figure? I'm  currently trying to learn how to built a map on global mapping tool (pygmt), but whenever I try fig.show() nothing happens. I tried to change graphic backend in tools preferences. The code works because when I use fig.savefig('myfig.png') I have the picture. I'm using spyder 4, on windows 10. I want to mention that tkinter doesn't work either (spyder crashes). And I can't try it on jupyter because I can't find the gmt kernel on jupyter.
the code:
import pygmt as gmt

fig = gmt.Figure()
fig.coast(shorelines="1/0.5p", region=[-180, 180, -60, 60], projection="M10i")

fig.show()
fig.savefig('gmttest.png')


text:
Q: How can I hide the first equation number as in the picture in latex? How can I hide the first equation number as in the picture in latex

\documentclass{article}
\begin{document}
\begin{align}
R=p(S\text{ working})&= p(i\text{ working}) p(S\text{ working}|i\text{ working})\\
&+ p(i\text{ faild})p(S\text{ working}|i\text{ faild})
\end{align}
\end{document}


text:
Q: Does InvalidateVisual works in a lazy way? If I call InvalidateVisual in my custom WPF control, when does the actual layout evaluation and rendering process happen?
Immediately or - similarly as in WinForms - when I finish my processing?

A: The online help answers your question:
Online help for InvalidateVisual:

This method calls InvalidateArrange internally.

Online help for InvalidateArrange:

Invalidates the arrange state (layout) for the element. After the invalidation, the element will have its layout updated, which will occur asynchronously unless subsequently forced by UpdateLayout.

In other words: InvalidateVisual does not have an effect immediately; it waits until your current code has finished (unless you have calls to UpdateLayout).
You also can look at Microsoft's reference source: http://referencesource.microsoft.com/#q=UIElement.InvalidateArrange . You will see that InvalidateArrange() does not call any blocking code; it returns immediately.


text:
Q: Android: BitmapFactory issue Good Day
I'm trying to display captured image in gridview as well save it in Sqlite Database..in the logcat appear this

E/BitmapFactory: Unable to decode stream:
  java.lang.NullPointerException W/System.err:
  java.lang.NullPointerException W/System.err:  at
  .CameraFragment.previewCapturedImage(CameraFragment.java:259
  W/System.err:  at
  CameraFragment.onActivityResult(CameraFragment.java:215)

which point to this line in my code
bitmap.compress(Bitmap.CompressFormat.PNG, 0, stream);

here is the code
 @Override
        public View onCreateView(LayoutInflater inflater,  ViewGroup container,  Bundle savedInstanceState) {
            View view = inflater.inflate(R.layout.fragment_camera, container, false);

            final DatabaseAdapter DBadapter = new DatabaseAdapter(getActivity());
            DBadapter.open();
            myLists = new ArrayList<Images>();
            myLists = DBadapter.getImagesList();
            // imageView = (ImageView) view.findViewById(R.id.imageListView);
            Button myButton = (Button) view.findViewById(R.id.camerabutton);
            myButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                   // fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);// create a file to save the image
                   // intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name
                    startActivityForResult(intent, CAMERA_CAPTURE_IMAGE_REQUEST_CODE); // start the image capture Intent

                }
            });
            adapter = new ImageListAdapter(getActivity(), R.layout.img_list_view, myLists);
            myGridView = (GridView) view.findViewById(R.id.gridView);
            myGridView.setAdapter(adapter);

 private File createImageFile() throws IOException {
        // Create an image file name
        String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
        String imageFileName = "JPEG_" + timeStamp + "_";
        File storageDir = Environment.getExternalStoragePublicDirectory(
                Environment.DIRECTORY_PICTURES);
        File image = File.createTempFile(
                imageFileName,  /* prefix */
                ".jpg",         /* suffix */
                storageDir      /* directory */
        );

        // Save a file: path for use with ACTION_VIEW intents
        mCurrentPhotoPath = "file:" + image.getAbsolutePath();
        return image;
    }
        }

        @Override
            public void onActivityResult(int requestCode, int resultCode, Intent data) {
                super.onActivityResult(requestCode, resultCode, data);
              if (requestCode==CAMERA_CAPTURE_IMAGE_REQUEST_CODE&&resultCode == Activity.RESULT_OK){

                           previewCapturedImage();

                   Toast.makeText(getActivity(), "InvoiceFile saved successfully", Toast.LENGTH_LONG).show();

                }
                       else if (resultCode == getActivity().RESULT_CANCELED) {
                           // user cancelled Image capture
                           Toast.makeText(getActivity(), "User cancelled image capture", Toast.LENGTH_SHORT)
                                   .show();}
                       else {
                           // failed to capture image

                           Toast.makeText(getActivity(), "Sorry! Failed to capture image", Toast.LENGTH_SHORT)
                                   .show();
                       }}
         private void previewCapturedImage() {

        BitmapFactory.Options bmOptions = new BitmapFactory.Options();
         ByteArrayOutputStream stream = new ByteArrayOutputStream();
                    Bitmap bitmap = BitmapFactory.decodeFile(mCurrentPhotoPath, bmOptions);
        bitmap.compress(Bitmap.CompressFormat.PNG, 0, stream);

                    byte[] byte_arr = stream.toByteArray();
                    images.setImageBlob(byte_arr);
                    // Add Image Path To List
                    myLists.add(images);
                    // Refresh Gridview Image Thumbnails

                    adapter.notifyDataSetChanged();
                    DBadapter.insertImage(images);

                }

any Help will be appreciate

A: Below code is working fine for me.If you need more details http://mylearnandroid.blogspot.in/2014/02/multiple-choose-custom-gallery.html
 if(resultCode == Activity.RESULT_OK) {
             MediaScannerConnection.scanFile(getApplicationContext(), new String[] { imageUri.getPath() }, null,
               new MediaScannerConnection.OnScanCompletedListener() {
              @Override
              public void onScanCompleted(String path, Uri uri) {
               Log.i("Scanned = ", "Scanned " + path);
               runOnUiThread(new Runnable() {
                public void run() {
                 //UI Works
                 loadData();
                }
               });
   }
     });

A: Because BitmapFactory.decodeFile(pathName, opts) returns null for you. From documentation about return value:

The decoded bitmap, or null if the image data could not be decoded, or, if opts is non-null, if opts requested only the size be returned (in opts.outWidth and opts.outHeight)

First, check the mCurrentPhotoPath value, if photo is there and it is correct.
Second, try to use BitmapFactory.decodeFile(pathName) instead.


text:
Q: Kill old thread and start new thread in System.Threading I have created a thread for my ip scanner application. Now when the user click the start button, it will start the thread, do scan and generate ID.
ID | printer_ip
---------------
 1 | 10.0.0.0
 2 | 10.0.0.1
 3 | 10.0.0.2

But the problem is that when the user want to re-click the start button again to rescan before the previous process finish, it looks like the ID become mess.
ID | printer_ip
---------------
 1 | 10.0.0.0
 4 | 10.0.0.3
 2 | 10.0.0.1

I notice that this is because the old thread is still running while the new thread is running. Therefore how to kill the old thread whenever the user re-click the start scan button? can I use Thread.Abort() method? If yes, where should I place it?
     private void StartClick(object sender, System.EventArgs e)
     {
        sercher = new Thread(new ThreadStart(Serche));
        try
        {
            IPAddress from = IPAddress.Parse(ipFrom.Text);
            IPAddress to = IPAddress.Parse(ipTo.Text);
        }
        catch (FormatException fe)
        {
            MessageBox.Show(fe.Message);
            return;
        }
        sercher.Name = "Network searching thread";
        sercher.Start();
        //add.Items.Add("-->> >>> Please wait while processing is done <<< <<--");
        Thread.Sleep(1);
    }

A: The correct way to kill a thread is to use a flag.  You check the flag in the thread, and quit it if it raised.  For example:
while (!IsCancelled)
{
  //Scan a single IP here...
}

When you click "Start" again, you should first raise the flag (IsCancelled = true), call Thread.Join to wait for that thread to stop, and only then start the thread again.
P.S.  Do not be tempted to use Thread.Abort!  This is very, very bad.


text:
Q: Snowflake integration with Jumpcloud throws http 400 error I have enabled AWS private link to access snowflake and there is no Issue with the Link, when Integrating with SSO using Jumpcloud, after login it just throws 400 Error
For Troubleshhot I have tried but they didn't work

*

*https://support.snowflake.net/s/article/Error-400-Bad-Request-while-SSO-login-to-Snowflake

*https://community.snowflake.com/s/article/Configuring-your-IDP-to-Snowflake-by-providing-required-properties-in-a-SAML-Response
This is JumpCloud SSO Setting

Here is complete SAML Response, but still getting 400 Error any Idea from snowflake troubleshooting will help to resolve this Issue
<?xml version="1.0" encoding="UTF-8"?>
    <saml2p:Response xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol"
                     Consent="urn:oasis:names:tc:SAML:2.0:consent:unspecified"
                     Destination="https://8GWIFI.ORG.SG.AP-SOUTHEAST-1.AWS.PRIVATELINK.snowflakecomputing.com/fed/login/"
                     ID="AUZZ04QP5VMGW46F5YJZROMK164PY2C1QQ6XNXJJ"
                     InResponseTo="id-6417485141254017599_-1"
                     IssueInstant="2020-05-13T07:59:21.927Z"
                     Version="2.0">
      <saml2:Issuer xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion"
                    Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity">https://8gwifi.org</saml2:Issuer>
      <saml2p:Status>
        <saml2p:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success" /></saml2p:Status>
      <saml2:Assertion xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion"
                       ID="OVOSTV678D3AU2SQM6PSUDG2YHNSQMN4HJR9SGI2"
                       IssueInstant="2020-05-13T07:59:21.927Z"
                       Version="2.0">
        <saml2:Issuer Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity">https://8gwifi.org</saml2:Issuer>
        <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
          <ds:SignedInfo>
            <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
            <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" />
            <ds:Reference URI="#OVOSTV678D3AU2SQM6PSUDG2YHNSQMN4HJR9SGI2">
              <ds:Transforms>
                <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
                <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" /></ds:Transforms>
              <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
              <ds:DigestValue>nxftTo6YnJGZR+qhRSJlPoMuNMMFwoxftmNAX/YDQaI=</ds:DigestValue>
            </ds:Reference>
          </ds:SignedInfo>
          <ds:SignatureValue>
    cvamdwGY/8VZ+n4gDoLoEt+z6fZCLmPuvv/u4qeYOZd/fMg28Jz7kt2FU27WDHbOkx21LEFJ/g2Mlt8X++MP8hhHNqqb8x42YZzyHTv4dmfz3xapSQ17iDJILlfsc2odr5xPjkScz+wNPxCTUsA8kCrfeTfnGJOyn7t6uq7zMh87uUmlIob04CYbV/1SZpD2Xz6Jij9UsBiP82QSbTWAs4gePDcnS0TKe0HGfkNYxhCQBlIR40tBrte4KRpxuoXo00aMXXR0f0qilfU2nvYWeZVnQFBLfFOKZmlKxuhRUyiEYr9iVTjI8uxLt9oJ/XFFC5cuZjRl1FlKExGwouGbcpHUt7Gx9XeCPlVD3z9bi33X4Hi8mwbD6uX0lcgcJQ82RbppIya+7Q0bTzSh5nCKAu+vIlTXNKlHnwM5ax7HNxfDJedcLgEpaJ0qntnH67TyjFQg/NPOb54wtjkOi9/qxnI/ND2EMnWP4O6jMlmwknLLEuW2iqgF9wBN0mM4EfmgniaUjixWVvr0aT2sFNcC7BalUkdBJWXCN6PYabm2exye4zYb2C9FyiDjzrsLYuctXCU19js1vhukIftYMG13ds+ZSL6enseFSHKqI1EYNWOogmGkgZJWOeH7BL5Xgeq5HhBn8teUvGc519p7J/2LkoGfEyJ4K0SPyTLoC1R5poA=
    </ds:SignatureValue>
          <ds:KeyInfo>
            <ds:X509Data>
              <ds:X509Certificate>
    M=........
    .................
    </ds:X509Certificate>
            </ds:X509Data>
          </ds:KeyInfo>
        </ds:Signature>
        <saml2:Subject>
          <saml2:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress">anish2good@yahoo.co.in</saml2:NameID>
          <saml2:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
            <saml2:SubjectConfirmationData InResponseTo="id-6417485141254017599_-1"
                                           NotOnOrAfter="2020-05-13T08:04:21.927Z"
                                           Recipient="https://8GWIFI.ORG.SG.AP-SOUTHEAST-1.AWS.PRIVATELINK.snowflakecomputing.com/fed/login/" /></saml2:SubjectConfirmation>
        </saml2:Subject>
        <saml2:Conditions NotBefore="2020-05-13T07:54:21.927Z"
                          NotOnOrAfter="2020-05-13T08:04:21.927Z">
          <saml2:AudienceRestriction>
            <saml2:Audience>https://8GWIFI.ORG.SG.AP-SOUTHEAST-1.AWS.PRIVATELINK.snowflakecomputing.com/fed/login/</saml2:Audience>
          </saml2:AudienceRestriction>
        </saml2:Conditions>
        <saml2:AuthnStatement AuthnInstant="2020-05-13T07:59:21.927Z"
                              SessionIndex="ed8df976-6c7d-458e-ad23-1657133d3a00">
          <saml2:AuthnContext>
            <saml2:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</saml2:AuthnContextClassRef>
          </saml2:AuthnContext>
        </saml2:AuthnStatement>
      </saml2:Assertion>
    </saml2p:Response>

A: To get SSO to work with PrivateLink, you need to contact support.
By default you can configure SSO only on Public URL or Private URL. You cannot have SSO configured for both the URls.
Also SSO by default is enabled on the Public URL. You can check this out by using the Public URL in the JumpBox configuration and confirm if this works.
So if this works and you want to have SSO over Private URL, contact support and they will enable the SSO for the PrivateLink.


text:
Q: How to remove a binding from a style setter in code behind? I have WPF datagrid, where the user will add columns at runtime. I'm defining the foreground of each cell of the new column using a binding and valueconverter like this:
//binding for color
Binding bindingForeground = new Binding
{
    Converter = new BatchAnalysisForegroundConverter(),
    ConverterParameter = columnStartIndex + i,
    Mode = BindingMode.OneTime
};

//set the foreground binding to the cell style
Style originalCellStyle = Application.Current.TryFindResource(typeof(DataGridCell)) as Style;
Style newCellStyle = new Style
{
    BasedOn = originalCellStyle,
    TargetType = typeof(DataGridCell)
};
newCellStyle.Setters.Add(new Setter(DataGridCell.ForegroundProperty, bindingForeground));
batchCol.CellStyle = newCellStyle;

When later at runtime when the user decides to remove that column, I do so like this:
  dg.Columns.Remove(inColumn);

However, the problem is that even though the column is removed, the binding keeps going, causing the value converter code to run on the removed column.
I could solve this by adding a check in the value converter, to prevent running code on the removed column, but I would prefer to remove the binding.
I tried by setting the path of the binding to null, but get an error: 'Binding cannot be changed after it has been used.'
I tried BindingOperations.ClearAllBindings(inColumn), didn't work.
I tried originalCellStyle.Setters.Add(new Setter(DataGridCell.ForegroundProperty, null)) but get the error 'After a 'SetterBaseCollection' is in use (sealed), it cannot be modified.'
I tried originalCellStyle.Setters.RemoveAt(2) and get the same error.
How would I do that?


text:
Q: Counting number of keys hashed to each slots Suppose $K= \{ k^2:1\leq k\leq 100 \} $ as the set of keys that hashed by two hash functions
$$ a)\;\;  h(k)=k\mod 12 $$
$$b)\;\; h(k)=k\mod 11 $$
I want to show that $a$ is not a good choice because it hash even numbers to slots with even index. But I try to find out how many elements hashed to each index for $a$ and $b$ to show that $a$ increases our cost for a search operation. I find out in $a$, if $k=12t$ like $12,24,36,\dots$ hashed to index $0$ but is there a simple way to speed up my computations?

A: For b), $h(x)=0$ iff $x$ is a multiple of $11$, so for approximately $\frac1{11}$ of the keys. The rest splits approximately evenly among the five remainders  1, 4, 9, 5, 3 (whereas 2, 6, 7, 8, 10 are never congruent to squares), so $\approx \frac2{11}$ of the keys  per class.

For a), we have a bit more work because 12 is not prime. But we can factor it as $4\cdot 3$ and investigate the parts separately (at least approximately) per the Chinese Remainder Theorem. Modulo $4$, a square is either $0$ for even or $1$ for odd numbers. Modulo $3$, a square is either $0$ (for the multiples of $3$) or $1$ (for all others). By combining these results, we see that approximately $\frac12\cdot \frac13=\frac16$ each are $0$ or $9$ modulo $12$, approximately $\frac12\cdot \frac23=\frac13$ each are $1$ or $4$ modulo $12$.
If you are unhappy with the word "approximately" occurring so often, note that the remainder of $x^2\bmod 12$ depends only on $x\bmod 6$, so the mentioned proportions hold exactly for every group of six consecutive keys. So if we had $K=\{\,k^2\mid 5\le k\le 100\,\}$, we'd have exactly 16 times 0, 16 times 9, 32 times 1, and 32 times 4. The additional keys $1$, $4$, $9$, $16$ modify the stats to: 16 times 0, 17 times 9, 33 times 1, and 34 times 4.


text:
Q: update properties file at runtime I have one Project (say A) which uses Spring. Project A internally depends on other project (Say B) for few Task. So B Project URL is configurable in server.properties file of A Project.
So now each time URL for B project get changed then I have to shutdown A Project, change the URL in server.properties file and then again start the server.
So I have requirement as to ask user to enter the new URL using GUI and change the URL at runtime.
I know it is possible to change the value of the property at runtime but it will be set only for that session and not an actual modification to properties file, and once the server is restarted again it will refer to old URL because actual changes are present in Session and not to actual Properties file.
my actual need is that changes should be reflected in properties file(for future restart of server it should work) as well as in beans configuration File(for current session - I am aware of how to do.)
Now my requirement is, whenever any changes comes in configuration then it should also physically change the properties file...is there any neat way to do this instead of reading File and search for that key and then replace substring.
Is there any third party api to do this nicely.

A: You can look at commons configuration. See file based save and reload here.

A: You can update properties file at runtime by using Commons Configuration API then get value by key. Here is good working example update and read properties
Hope this help!


text:
Q: How to change language in a command-line software on debian i'm using 'exif' on a server (Debian GNU/Linux 6.0.6 (squeeze)) and unlike on my dev computer (Mac OS X through MacPort) it runs in french :
exif -h
Utilisation: exif [OPTION...] fichier
  -v, --version                      Display software version
  -i, --ids                          Montre les ID plutôt que les noms des marqueurs
  -t, --tag=marqueur                 Sélection du marqueur
      --ifd=IFD                      Sélection de l'IFD
  -l, --list-tags                    Liste tous les marqueurs EXIF
  -|, --show-mnote                   Show contents of tag MakerNote
      --remove                       Supprime le marqueur ou l'ifd
  -s, --show-description             Montre la description du marqueur
  -e, --extract-thumbnail            Extrait la vignette
  -r, --remove-thumbnail             Supprime la vignette
  -n, --insert-thumbnail=FICHIER     Insère le FICHIER comme vignette
      --no-fixup                     Do not fix existing tags in files
  -o, --output=FICHIER               Write data to FILE
      --set-value=STRING             Value of tag
  -c, --create-exif                  Create EXIF data if not existing
  -m, --machine-readable             Output in a machine-readable (tab delimited) format
  -w, --width=WIDTH                  Width of output
  -x, --xml-output                   Output in a XML format
  -d, --debug                        Show debugging messages

I check my /etc/default/locale and it was
LANG=fr_FR
LANGUAGE=fr_FR:fr

which I changed in
LANG=en_EN
LANGUAGE=en_EN:en

without any consequences.
Any hint on how to force this machin to execute this software in english ?
Because i need to have exif-data labels in english :)
Thanks !

A: The /etc/default/locale file sets uhm... "global" defaults. That means, these defaults are read by any "top-level" shell when it starts up, and is then inherited by processes it runs.
Long story short, this means such defaults are applied to:

*

*All daemons (programs running in background) as they're started using shell scripts located in /etc/init.d.

*Interactive shells you run in your login session.

So merely changing that file requires a reboot.
But, as the contents of that file is just a shell script that sets a bunch of the so-called "environment variables", to effect one particular program you just have to make that program see different contents of these variables.
The simlest way to achieve this is to just put their assignment before the program to run, that is, at your shell prompt you can do:
$ LANG=en exif -h

and see exif talking to you in English (the $ character here denotes a shell prompt -- do not type it).
The second way is to make all the programs in the current shell see the new contents of the variables; this is done via "exporting" them, as @clarkw showed: an exported variable and its contents is inherited by the environment of all the processes run from the shell, so the following also works:
$ export LANG=en
$ exif -h

or
$ LANG=en
$ export LANG
$ exif -h

These environment variables are described in the locale(1) manual page.
And the last tip: do not change the contents of /etc/default/locale by hand — use the Debian way to manage it: run
# dpkg-reconfigure locales

which will first ask you which locales to compile and install (you can skip this step) and then which one to pick as the default.
Update: here's a page on the Debian wiki dedicated to locales which pretty much explains everything needed including the environment variables.