text:
Q: customized adapter.notifyDataSetChanged() not working i am using a customized adapter of list view to show an image and title.
In my application i add and remove the items in the list and i have to show that changes on the interface.
on any change in data i get all list from data base and store it in adapter list and then call adapter.notifyDataSetChanged(); but interface is not showing any change.
on the other hand when i directly add or remove item from adapter it respond correctly.
i have used simple adapter and for that adapter.notifyDataSetChanged(); is working fine but for customized it is not responding.
i have also tried many solution on the stackoverflow but non of them work.
like
Updating the list view when the adapter data changes
Android List view refresh
Adapter.notifyDataSetChanged() is not working
notifyDataSetChange not working from custom adapter
i doing this as folows
at oncreate
enter code here

            product_data = new ArrayList<Product>();
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        value = extras.getInt("list_id");
    }
    product_data = db.getAllProductsstatus(value, 1);
    Collections.reverse(product_data);

    adapter = new ProductAdopter(this,
            R.layout.listview_item_row, product_data, 2);
    ListView listView1 = (ListView)findViewById(R.id.listView1);
    listView1.setAdapter(adapter);
    registerForContextMenu(listView1);

and in onMenuItemSelected
enter code here
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo)item.getMenuInfo();

      int menuItemIndex = item.getItemId();
      String listItemName = adapter.getItem(info.position)._name;
      int id = adapter.getItem(info.position)._id;

         if(menuItemIndex == 0)
        {

            db.deleteProduct(adapter.getItem(info.position));

            product_data = db.getAllProducts(value);
            Collections.reverse(product_data);
            //adapter.remove(adapter.getItem(info.position));
            adapter.notifyDataSetChanged();
        }
        else if(menuItemIndex == 1){
            String name ;
            if (adapter.getItem(info.position)._status == 0){
                popall("bar code", "no bar code entered");
            }
            else {
            popall("bar code", adapter.getItem(info.position)._bar_code);
            }
        }
        else if (menuItemIndex == 2){
            adapter.getItem(info.position)._status = 0;
            adapter.getItem(info.position)._bar_code = "0";
            db.updateProduct(adapter.getItem(info.position));
                product_data = db.getAllProductsstatus(value, 1);
            adapter.notifyDataSetChanged();

            popall("alert", "successfully done");
        }
      return true;
}

my customized adapter class is given below
public class ProductAdopter extends ArrayAdapter<Product> {
    Context context;
    int layoutResourceId;
    List<Product> data = null;
    int source;
    public ProductAdopter(Context context, int layoutResourceId, List<Product> product_data, int source) {
        // TODO Auto-generated constructor stub
        super(context, layoutResourceId, product_data);
        this.layoutResourceId = layoutResourceId;
        this.context = context;
        this.data = product_data;
        this.source = source;
    }
   // public ProductAdopter(MainActivity context2, int listviewItemRow, List<Product> product_data) {
        // TODO Auto-generated constructor stub
    //}
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View row = convertView;
        ProductHolder holder = null;

        if(row == null && source == 1)
        {
            LayoutInflater inflater = ((MainActivity)context).getLayoutInflater();
            row = inflater.inflate(layoutResourceId, parent, false);

            holder = new ProductHolder();
            holder.imgIcon = (ImageView)row.findViewById(R.id.imgIcon);
            holder.txtTitle = (TextView)row.findViewById(R.id.txtTitle);

            row.setTag(holder);
        }
        if(row == null && source == 2)
        {
            LayoutInflater inflater = ((purchased)context).getLayoutInflater();
            row = inflater.inflate(layoutResourceId, parent, false);

            holder = new ProductHolder();
            holder.imgIcon = (ImageView)row.findViewById(R.id.imgIcon);
            holder.txtTitle = (TextView)row.findViewById(R.id.txtTitle);

            row.setTag(holder);
        }
        if(row == null && source == 3)
        {
            LayoutInflater inflater = ((Skiped)context).getLayoutInflater();
            row = inflater.inflate(layoutResourceId, parent, false);

            holder = new ProductHolder();
            holder.imgIcon = (ImageView)row.findViewById(R.id.imgIcon);
            holder.txtTitle = (TextView)row.findViewById(R.id.txtTitle);

            row.setTag(holder);
        }

        else
        {
            holder = (ProductHolder)row.getTag();
        }

        Product product = data.get(position);
        holder.txtTitle.setText(product.getName());
        if(product.icon.equals("no")){
            holder.imgIcon.setImageResource(R.drawable.blank);
        }
        else{
            File imgFile = new  File(product.icon);
            if(imgFile.exists()){

                Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
                Bitmap resized = Bitmap.createScaledBitmap(myBitmap, 70, 70, true);

                holder.imgIcon.setImageBitmap(resized);
                myBitmap.recycle();
            }
        }

        return row;
    }
    static class ProductHolder
    {
        ImageView imgIcon;
        TextView txtTitle;
    }

}

A: The problem is that in your onMenuItemSelected() you have this line:
product_data = db.getAllProducts(value);

When you created the adapter in onCreate(), you gave it a reference to product_data. At that point your changes to product_data would propagate into the adapter, because it has a reference to your list.
But as soon as you assign a new list to your product_data variable (like you do in the onMenuItemSelected()) the adapter now has a reference to the old list, while your product_data now points to a new list. So your adapter doesn't know about your changes in the new list.
Instead of reassigning the variable, try clearing it and copying your items like this:
product_data.clear();
product_data.addAll(db.getAllProducts(value));

On another note, if you read your data from the database, you should consider using a CursorAdapter instead.
Here is a simple tutorial:
http://blog.cluepusher.dk/2009/11/16/creating-a-custom-cursoradapter-for-android/

A: The problem in your code is that, you are notifying your adapter
To refresh the list but you are not supplying fresh data
(I.e after add/remove items.) To it.
Do as follow :
    if(menuItemIndex == 0) { db.deleteProduct(adapter . Get item(info.position)); product_data = db.getAllProducts(value);
    Collections.reverse(product_data);

    adapter = new ProductAdopter(this, R.layout.listview_item_row, product_data, 2); ListView listView1 = (ListView)findViewById(R.id.listView1);
    listView1.setAdapter(adapter);

 //adapter.remove(adapter.getItem(info.position));
//adapter.notifyDataSetChanged();

}

Doing this you are supplying new data to adapter
So it will refresh list view to show fresh changed
data even without calling
adapter.notifyDataSetChanged();
Also you need to make list view object as
global in order to use it while
Settimg new adapter in onMenuItemSelected ()
I hope this will solve your problem.


text:
Q: Contour plot from data.txt using matplotlib I am a new one for python.
I am trying to plot a contour plot.
I have data set in data.txt
enter code here
#coding:utf-8

from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt

x = []
y = []
z = []
f = open("data1.txt")
line = f.readline()
while line:
    c,d,e = line.split()
    x.append(c)
    y.append(d)
    z.append(e)

    line = f.readline()

f.close()

x = [ float ( x ) for x in x if x ]
y = [ float( y ) for y in y if y ]
z = [ float( z ) for z in z if z ]

fig=plt.figure()
ax = fig.gca(projection = '3d')

ax.plot(x,y,z)

ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
plt.show()

and then I can get the figure like this
enter image description here
I hope it looks like this

A: Actually, I just want to provide more detail, but I can not find the edit.
data.txt like this:
0.166666657 0   0
0   0   0
0.166666657 0.100000001 0
0   0.100000001 0
0.333333313 0   0
0.333333313 0.100000001 0
0.49999997  0   0
0.49999997  0.100000001 0
0.833333254 0   0
0.833333254 0.100000001 0
1.166666627 0   0
1.166666627 0.100000001 0
1.499999881 0   0
1.499999881 0.100000001 0
1.874999881 0   0
1.874999881 0.100000001 0
2.249999762 0   0
2.249999762 0.100000001 0
2.624999762 0   0
2.624999762 0.100000001 0
2.999999762 0   0
2.999999762 0.100000001 0
3.399999857 0   0
3.399999857 0.100000001 0
3.799999952 0   0
3.799999952 0.100000001 0
4.199999809 0   0
4.199999809 0.100000001 0
4.599999905 0   0
4.599999905 0.100000001 0
5   0   0
5   0.100000001 0
0.166666657 1.100000024 0
0   1.100000024 0
0.333333313 1.100000024 0
0.49999997  1.100000024 0
0.833333254 1.100000024 0
1.166666627 1.100000024 0
1.499999881 1.100000024 0
1.874999881 1.100000024 0
2.249999762 1.100000024 0
2.624999762 1.100000024 0
2.999999762 1.100000024 0
3.399999857 1.100000024 0
3.799999952 1.100000024 0
4.199999809 1.100000024 0
4.599999905 1.100000024 0
5   1.100000024 0
0.166666657 2.139130354 0
0   2.139130354 0
0.333333313 2.139130354 0
0.49999997  2.139130354 0
0.833333254 2.139130354 0
1.166666627 2.139130354 0
1.499999881 2.139130354 0
1.874999881 2.139130354 0
2.249999762 2.139130354 0
2.624999762 2.139130354 0
2.999999762 2.139130354 0
3.399999857 2.139130354 0
3.799999952 2.139130354 0
4.199999809 2.139130354 0
4.599999905 2.139130354 0
5   2.139130354 0
0.166666657 3.178260803 0
0   3.178260803 0
0.333333313 3.178260803 0
0.49999997  3.178260803 0
0.833333254 3.178260803 0
1.166666627 3.178260803 0
1.499999881 3.178260803 0
1.874999881 3.178260803 0
2.249999762 3.178260803 0
2.624999762 3.178260803 0
2.999999762 3.178260803 0
3.399999857 3.178260803 0
3.799999952 3.178260803 0
4.199999809 3.178260803 0
4.599999905 3.178260803 0
5   3.178260803 0
0.166666657 4.217391491 0
0   4.217391491 0
0.333333313 4.217391491 0
0.49999997  4.217391491 0
0.833333254 4.217391491 0
1.166666627 4.217391491 0
1.499999881 4.217391491 0
1.874999881 4.217391491 0
2.249999762 4.217391491 0
2.624999762 4.217391491 0
2.999999762 4.217391491 0
3.399999857 4.217391491 0
3.799999952 4.217391491 0
4.199999809 4.217391491 0
4.599999905 4.217391491 0
5   4.217391491 0
0.166666657 5.256521702 0
0   5.256521702 0
0.333333313 5.256521702 0
0.49999997  5.256521702 2.83E-06
0.833333254 5.256521702 2.83E-06
1.166666627 5.256521702 0
1.499999881 5.256521702 0
1.874999881 5.256521702 0
2.249999762 5.256521702 0
2.624999762 5.256521702 0
2.999999762 5.256521702 0
3.399999857 5.256521702 0
3.799999952 5.256521702 0
4.199999809 5.256521702 0
4.599999905 5.256521702 0
5   5.256521702 0
0.166666657 6.29565239  8.05E-04
0   6.29565239  7.13E-04
0.333333313 6.29565239  0.001456573
0.49999997  6.29565239  0.002108717
0.833333254 6.29565239  0.001104275
1.166666627 6.29565239  4.31E-06
1.499999881 6.29565239  4.41E-07
1.874999881 6.29565239  1.51E-07
2.249999762 6.29565239  8.77E-08
2.624999762 6.29565239  3.19E-08
2.999999762 6.29565239  4.64E-09
3.399999857 6.29565239  0
3.799999952 6.29565239  0
4.199999809 6.29565239  0
4.599999905 6.29565239  0
5   6.29565239  0
0.166666657 7.3347826   0.001146442
0   7.3347826   7.14E-04
0.333333313 7.3347826   0.002594632
0.49999997  7.3347826   0.005290068
0.833333254 7.3347826   0.003493796
1.166666627 7.3347826   1.02E-05
1.499999881 7.3347826   1.57E-06
1.874999881 7.3347826   3.58E-07
2.249999762 7.3347826   3.00E-07
2.624999762 7.3347826   2.37E-07
2.999999762 7.3347826   1.27E-07
3.399999857 7.3347826   3.90E-08
3.799999952 7.3347826   9.40E-09
4.199999809 7.3347826   2.12E-09
4.599999905 7.3347826   1.88E-10
5   7.3347826   0
0.166666657 8.373912811 0.001143811
0   8.373912811 6.32E-04
0.333333313 8.373912811 0.002098797
0.49999997  8.373912811 0.005743471
0.833333254 8.373912811 0.004605132
1.166666627 8.373912811 1.37E-04
1.499999881 8.373912811 4.47E-06
1.874999881 8.373912811 2.96E-07
2.249999762 8.373912811 2.47E-07
2.624999762 8.373912811 2.42E-07
2.999999762 8.373912811 1.68E-07
3.399999857 8.373912811 8.93E-08
3.799999952 8.373912811 5.37E-08
4.199999809 8.373912811 3.07E-08
4.599999905 8.373912811 1.25E-08
5   8.373912811 5.02E-09
0.166666657 9.413043022 0.00184233
0   9.413043022 0.001671778
0.333333313 9.413043022 0.001969866
0.49999997  9.413043022 0.005147494
0.833333254 9.413043022 0.004489599
1.166666627 9.413043022 3.14E-04
1.499999881 9.413043022 8.36E-06
1.874999881 9.413043022 3.07E-07
2.249999762 9.413043022 6.62E-08
2.624999762 9.413043022 6.94E-08
2.999999762 9.413043022 8.02E-08
3.399999857 9.413043022 8.42E-08
3.799999952 9.413043022 7.29E-08
4.199999809 9.413043022 5.00E-08
4.599999905 9.413043022 2.44E-08
5   9.413043022 1.11E-08
0.166666657 10.45217419 0.002082661
0   10.45217419 0.002093853
0.333333313 10.45217419 0.002018111
0.49999997  10.45217419 0.005188842
0.833333254 10.45217419 0.004552273
1.166666627 10.45217419 3.55E-04
1.499999881 10.45217419 9.66E-06
1.874999881 10.45217419 4.04E-07
2.249999762 10.45217419 5.71E-08
2.624999762 10.45217419 7.03E-08
2.999999762 10.45217419 6.99E-08
3.399999857 10.45217419 6.44E-08
3.799999952 10.45217419 5.49E-08
4.199999809 10.45217419 4.20E-08
4.599999905 10.45217419 2.36E-08
5   10.45217419 1.19E-08
0.166666657 11.4913044  0.002068915
0   11.4913044  0.002088516
0.333333313 11.4913044  0.002010661
0.49999997  11.4913044  0.00519882
0.833333254 11.4913044  0.004531486
1.166666627 11.4913044  3.27E-04
1.499999881 11.4913044  8.68E-06
1.874999881 11.4913044  3.48E-07
2.249999762 11.4913044  6.64E-08
2.624999762 11.4913044  8.28E-08
2.999999762 11.4913044  7.60E-08
3.399999857 11.4913044  6.23E-08
3.799999952 11.4913044  5.33E-08
4.199999809 11.4913044  4.11E-08
4.599999905 11.4913044  2.32E-08
5   11.4913044  1.20E-08
0.166666657 12.53043461 0.002039805
0   12.53043461 0.00205601
0.333333313 12.53043461 0.001996976
0.49999997  12.53043461 0.00518821
0.833333254 12.53043461 0.004489759
1.166666627 12.53043461 2.94E-04
1.499999881 12.53043461 7.44E-06
1.874999881 12.53043461 2.93E-07
2.249999762 12.53043461 8.34E-08
2.624999762 12.53043461 9.43E-08
2.999999762 12.53043461 8.56E-08
3.399999857 12.53043461 6.54E-08
3.799999952 12.53043461 5.54E-08
4.199999809 12.53043461 4.20E-08
4.599999905 12.53043461 2.37E-08
5   12.53043461 1.28E-08
0.166666657 13.56956482 0.002015376
0   13.56956482 0.002027846
0.333333313 13.56956482 0.001984971
0.49999997  13.56956482 0.00516937
0.833333254 13.56956482 0.004446038
1.166666627 13.56956482 2.66E-04
1.499999881 13.56956482 6.17E-06
1.874999881 13.56956482 2.33E-07
2.249999762 13.56956482 8.64E-08
2.624999762 13.56956482 9.96E-08
2.999999762 13.56956482 9.09E-08
3.399999857 13.56956482 6.92E-08
3.799999952 13.56956482 5.97E-08
4.199999809 13.56956482 4.49E-08
4.599999905 13.56956482 2.50E-08
5   13.56956482 1.37E-08
0.166666657 14.60869598 0.001994169
0   14.60869598 0.002003726
0.333333313 14.60869598 0.001972914
0.49999997  14.60869598 0.00514606
0.833333254 14.60869598 0.004404811
1.166666627 14.60869598 2.44E-04
1.499999881 14.60869598 5.02E-06
1.874999881 14.60869598 1.86E-07
2.249999762 14.60869598 8.74E-08
2.624999762 14.60869598 1.00E-07
2.999999762 14.60869598 9.21E-08
3.399999857 14.60869598 7.31E-08
3.799999952 14.60869598 6.60E-08
4.199999809 14.60869598 4.99E-08
4.599999905 14.60869598 2.69E-08
5   14.60869598 1.43E-08
0.166666657 15.64782619 0.001974078
0   15.64782619 0.00198149
0.333333313 15.64782619 0.001958905
0.49999997  15.64782619 0.005118577
0.833333254 15.64782619 0.00436624
1.166666627 15.64782619 2.27E-04
1.499999881 15.64782619 4.16E-06
1.874999881 15.64782619 1.65E-07
2.249999762 15.64782619 8.83E-08
2.624999762 15.64782619 9.88E-08
2.999999762 15.64782619 7.91E-08
3.399999857 15.64782619 6.45E-08
3.799999952 15.64782619 7.41E-08
4.199999809 15.64782619 5.63E-08
4.599999905 15.64782619 2.85E-08
5   15.64782619 1.43E-08
0.166666657 16.68695641 0.0019543
0   16.68695641 0.001960144
0.333333313 16.68695641 0.001943025
0.49999997  16.68695641 0.00508678
0.833333254 16.68695641 0.004329463
1.166666627 16.68695641 2.15E-04
1.499999881 16.68695641 3.58E-06
1.874999881 16.68695641 1.47E-07
2.249999762 16.68695641 9.03E-08
2.624999762 16.68695641 9.72E-08
2.999999762 16.68695641 7.90E-08
3.399999857 16.68695641 6.91E-08
3.799999952 16.68695641 6.71E-08
4.199999809 16.68695641 4.71E-08
4.599999905 16.68695641 2.93E-08
5   16.68695641 1.37E-08
0.166666657 17.72608757 0.001934777
0   17.72608757 0.001939479
0.333333313 17.72608757 0.001926098
0.49999997  17.72608757 0.005051369
0.833333254 17.72608757 0.004294238
1.166666627 17.72608757 2.07E-04
1.499999881 17.72608757 3.31E-06
1.874999881 17.72608757 1.44E-07
2.249999762 17.72608757 9.24E-08
2.624999762 17.72608757 9.57E-08
2.999999762 17.72608757 9.21E-08
3.399999857 17.72608757 8.63E-08
3.799999952 17.72608757 7.10E-08
4.199999809 17.72608757 4.89E-08
4.599999905 17.72608757 2.94E-08
5   17.72608757 1.30E-08
0.166666657 18.76521683 0.001915514
0   18.76521683 0.001919387
0.333333313 18.76521683 0.001908651
0.49999997  18.76521683 0.00501325
0.833333254 18.76521683 0.004260369
1.166666627 18.76521683 2.03E-04
1.499999881 18.76521683 3.28E-06
1.874999881 18.76521683 1.62E-07
2.249999762 18.76521683 9.38E-08
2.624999762 18.76521683 9.44E-08
2.999999762 18.76521683 9.26E-08
3.399999857 18.76521683 8.98E-08
3.799999952 18.76521683 8.77E-08
4.199999809 18.76521683 6.38E-08
4.599999905 18.76521683 2.92E-08
5   18.76521683 1.23E-08
0.166666657 19.80434799 0.001896351
0   19.80434799 0.001899629
0.333333313 19.80434799 0.001890444
0.49999997  19.80434799 0.004972469
0.833333254 19.80434799 0.004226807
1.166666627 19.80434799 2.01E-04
1.499999881 19.80434799 3.37E-06
1.874999881 19.80434799 1.74E-07
2.249999762 19.80434799 9.48E-08
2.624999762 19.80434799 9.37E-08
2.999999762 19.80434799 7.90E-08
3.399999857 19.80434799 7.88E-08
3.799999952 19.80434799 9.01E-08
4.199999809 19.80434799 6.46E-08
4.599999905 19.80434799 2.90E-08
5   19.80434799 1.18E-08
0.166666657 20.84347916 0.001877118
0   20.84347916 0.001879973
0.333333313 20.84347916 0.001871425
0.49999997  20.84347916 0.004928756
0.833333254 20.84347916 0.004192216
1.166666627 20.84347916 2.01E-04
1.499999881 20.84347916 3.53E-06
1.874999881 20.84347916 1.90E-07
2.249999762 20.84347916 9.63E-08
2.624999762 20.84347916 9.34E-08
2.999999762 20.84347916 7.97E-08
3.399999857 20.84347916 8.21E-08
3.799999952 20.84347916 9.26E-08
4.199999809 20.84347916 6.55E-08
4.599999905 20.84347916 2.90E-08
5   20.84347916 1.15E-08
0.166666657 21.88260841 0.001857258
0   21.88260841 0.001860346
0.333333313 21.88260841 0.001851503
0.49999997  21.88260841 0.004882752
0.833333254 21.88260841 0.004156424
1.166666627 21.88260841 2.02E-04
1.499999881 21.88260841 3.73E-06
1.874999881 21.88260841 2.10E-07
2.249999762 21.88260841 9.82E-08
2.624999762 21.88260841 9.35E-08
2.999999762 21.88260841 9.51E-08
3.399999857 21.88260841 9.99E-08
3.799999952 21.88260841 9.55E-08
4.199999809 21.88260841 6.67E-08
4.599999905 21.88260841 2.93E-08
5   21.88260841 1.16E-08
0.166666657 22.92173958 0.001835249
0   22.92173958 0.001838622
0.333333313 22.92173958 0.00183039
0.49999997  22.92173958 0.004835702
0.833333254 22.92173958 0.004120183
1.166666627 22.92173958 2.03E-04
1.499999881 22.92173958 3.96E-06
1.874999881 22.92173958 2.35E-07
2.249999762 22.92173958 1.00E-07
2.624999762 22.92173958 9.41E-08
2.999999762 22.92173958 9.63E-08
3.399999857 22.92173958 1.03E-07
3.799999952 22.92173958 9.82E-08
4.199999809 22.92173958 6.83E-08
4.599999905 22.92173958 2.96E-08
5   22.92173958 1.14E-08
0.166666657 23.96086884 0.001811466
0   23.96086884 0.001814246
0.333333313 23.96086884 0.001808798
0.49999997  23.96086884 0.004788195
0.833333254 23.96086884 0.004083806
1.166666627 23.96086884 2.04E-04
1.499999881 23.96086884 4.22E-06
1.874999881 23.96086884 2.65E-07
2.249999762 23.96086884 1.02E-07
2.624999762 23.96086884 9.50E-08
2.999999762 23.96086884 9.73E-08
3.399999857 23.96086884 8.69E-08
3.799999952 23.96086884 8.26E-08
4.199999809 23.96086884 6.98E-08
4.599999905 23.96086884 2.88E-08
5   23.96086884 8.91E-09
0.166666657 25  0.001788157
0   25  0.001790103
0.333333313 25  0.001787562
0.49999997  25  0.004740176
0.833333254 25  0.004047134
1.166666627 25  2.06E-04
1.499999881 25  4.49E-06
1.874999881 25  2.97E-07
2.249999762 25  1.04E-07
2.624999762 25  9.61E-08
2.999999762 25  9.85E-08
3.399999857 25  8.92E-08
3.799999952 25  8.51E-08
4.199999809 25  7.10E-08
4.599999905 25  2.70E-08
5   25  5.35E-09
0.166666657 26.03913116 0.001766148
0   26.03913116 0.00176749
0.333333313 26.03913116 0.00176692
0.49999997  26.03913116 0.004691813
0.833333254 26.03913116 0.004010193
1.166666627 26.03913116 2.07E-04
1.499999881 26.03913116 4.78E-06
1.874999881 26.03913116 3.32E-07
2.249999762 26.03913116 1.05E-07
2.624999762 26.03913116 9.69E-08
2.999999762 26.03913116 9.95E-08
3.399999857 26.03913116 1.09E-07
3.799999952 26.03913116 1.05E-07
4.199999809 26.03913116 7.17E-08
4.599999905 26.03913116 2.54E-08
5   26.03913116 2.87E-09
0.166666657 27.07826042 0.001745309
0   27.07826042 0.001746275
0.333333313 27.07826042 0.00174681
0.49999997  27.07826042 0.00464339
0.833333254 27.07826042 0.003973283
1.166666627 27.07826042 2.09E-04
1.499999881 27.07826042 5.06E-06
1.874999881 27.07826042 3.72E-07
2.249999762 27.07826042 1.07E-07
2.624999762 27.07826042 8.01E-08
2.999999762 27.07826042 8.28E-08
3.399999857 27.07826042 1.10E-07
3.799999952 27.07826042 1.06E-07
4.199999809 27.07826042 7.17E-08
4.599999905 27.07826042 2.39E-08
5   27.07826042 1.31E-09
0.166666657 28.11739159 0.001725479
0   28.11739159 0.001726249
0.333333313 28.11739159 0.001727173
0.49999997  28.11739159 0.004595153
0.833333254 28.11739159 0.003936669
1.166666627 28.11739159 2.11E-04
1.499999881 28.11739159 5.33E-06
1.874999881 28.11739159 4.16E-07
2.249999762 28.11739159 1.09E-07
2.624999762 28.11739159 8.16E-08
2.999999762 28.11739159 8.40E-08
3.399999857 28.11739159 1.11E-07
3.799999952 28.11739159 1.07E-07
4.199999809 28.11739159 7.11E-08
4.599999905 28.11739159 2.27E-08
5   28.11739159 4.56E-10
0.166666657 29.15652084 0.001706611
0   29.15652084 0.001707332
0.333333313 29.15652084 0.001708043
0.49999997  29.15652084 0.004547331
0.833333254 29.15652084 0.003900517
1.166666627 29.15652084 2.13E-04
1.499999881 29.15652084 5.61E-06
1.874999881 29.15652084 4.60E-07
2.249999762 29.15652084 1.12E-07
2.624999762 29.15652084 1.01E-07
2.999999762 29.15652084 1.03E-07
3.399999857 29.15652084 1.10E-07
3.799999952 29.15652084 1.06E-07
4.199999809 29.15652084 7.03E-08
4.599999905 29.15652084 2.17E-08
5   29.15652084 9.12E-11
0.166666657 30.19565201 0.001688751
0   30.19565201 0.001689551
0.333333313 30.19565201 0.001689468
0.49999997  30.19565201 0.004499969
0.833333254 30.19565201 0.003864868
1.166666627 30.19565201 2.16E-04
1.499999881 30.19565201 5.88E-06
1.874999881 30.19565201 5.00E-07
2.249999762 30.19565201 1.15E-07
2.624999762 30.19565201 1.04E-07
2.999999762 30.19565201 1.05E-07
3.399999857 30.19565201 1.10E-07
3.799999952 30.19565201 1.06E-07
4.199999809 30.19565201 6.88E-08
4.599999905 30.19565201 2.02E-08
5   30.19565201 6.42E-31
0.166666657 31.23478317 0.001671921
0   31.23478317 0.001672991
0.333333313 31.23478317 0.001671203
0.49999997  31.23478317 0.004452467
0.833333254 31.23478317 0.003829332
1.166666627 31.23478317 2.18E-04
1.499999881 31.23478317 6.15E-06
1.874999881 31.23478317 5.33E-07
2.249999762 31.23478317 1.19E-07
2.624999762 31.23478317 1.07E-07
2.999999762 31.23478317 8.86E-08
3.399999857 31.23478317 9.31E-08
3.799999952 31.23478317 1.06E-07
4.199999809 31.23478317 6.65E-08
4.599999905 31.23478317 1.80E-08
5   31.23478317 9.74E-17
0.166666657 32.27391434 0.001655185
0   32.27391434 0.001656952
0.333333313 32.27391434 0.00165242
0.49999997  32.27391434 0.004404099
0.833333254 32.27391434 0.003793394
1.166666627 32.27391434 2.21E-04
1.499999881 32.27391434 6.43E-06
1.874999881 32.27391434 5.58E-07
2.249999762 32.27391434 1.22E-07
2.624999762 32.27391434 1.10E-07
2.999999762 32.27391434 9.08E-08
3.399999857 32.27391434 9.43E-08
3.799999952 32.27391434 1.06E-07
4.199999809 32.27391434 6.43E-08
4.599999905 32.27391434 1.56E-08
5   32.27391434 1.59E-16
0.166666657 33.31304169 0.001637113
0   33.31304169 0.001639473
0.333333313 33.31304169 0.001632962
0.49999997  33.31304169 0.004355155
0.833333254 33.31304169 0.003756959
1.166666627 33.31304169 2.24E-04
1.499999881 33.31304169 6.71E-06
1.874999881 33.31304169 5.74E-07
2.249999762 33.31304169 1.24E-07
2.624999762 33.31304169 1.14E-07
2.999999762 33.31304169 1.12E-07
3.399999857 33.31304169 1.14E-07
3.799999952 33.31304169 1.07E-07
4.199999809 33.31304169 6.21E-08
4.599999905 33.31304169 1.33E-08
5   33.31304169 6.17E-17
0.166666657 34.35217285 0.001618719
0   34.35217285 0.001621301
0.333333313 34.35217285 0.001613861
0.49999997  34.35217285 0.004306195
0.833333254 34.35217285 0.003720024
1.166666627 34.35217285 2.26E-04
1.499999881 34.35217285 6.97E-06
1.874999881 34.35217285 5.84E-07
2.249999762 34.35217285 1.26E-07
2.624999762 34.35217285 1.17E-07
2.999999762 34.35217285 1.16E-07
3.399999857 34.35217285 1.17E-07
3.799999952 34.35217285 1.08E-07
4.199999809 34.35217285 5.98E-08
4.599999905 34.35217285 1.09E-08
5   34.35217285 0
0.166666657 35.39130402 0.00160178
0   35.39130402 0.001604649
0.333333313 35.39130402 0.001595963
0.49999997  35.39130402 0.004257447
0.833333254 35.39130402 0.003682485
1.166666627 35.39130402 2.28E-04
1.499999881 35.39130402 7.19E-06
1.874999881 35.39130402 5.89E-07
2.249999762 35.39130402 1.28E-07
2.624999762 35.39130402 1.23E-07
2.999999762 35.39130402 1.22E-07
3.399999857 35.39130402 1.21E-07
3.799999952 35.39130402 1.09E-07
4.199999809 35.39130402 5.76E-08
4.599999905 35.39130402 8.67E-09
5   35.39130402 0
0.166666657 36.43043518 0.001586818
0   36.43043518 0.001590049
0.333333313 36.43043518 0.001579753
0.49999997  36.43043518 0.004209202
0.833333254 36.43043518 0.003644162
1.166666627 36.43043518 2.30E-04
1.499999881 36.43043518 7.35E-06
1.874999881 36.43043518 5.63E-07
2.249999762 36.43043518 1.32E-07
2.624999762 36.43043518 1.30E-07
2.999999762 36.43043518 1.30E-07
3.399999857 36.43043518 1.26E-07
3.799999952 36.43043518 1.11E-07
4.199999809 36.43043518 5.57E-08
4.599999905 36.43043518 6.56E-09
5   36.43043518 0
0.166666657 37.46956635 0.001574376
0   37.46956635 0.001578042
0.333333313 37.46956635 0.001565765
0.49999997  37.46956635 0.004161684
0.833333254 37.46956635 0.00360471
1.166666627 37.46956635 2.30E-04
1.499999881 37.46956635 7.47E-06
1.874999881 37.46956635 5.47E-07
2.249999762 37.46956635 1.37E-07
2.624999762 37.46956635 1.41E-07
2.999999762 37.46956635 1.40E-07
3.399999857 37.46956635 1.33E-07
3.799999952 37.46956635 1.15E-07
4.199999809 37.46956635 5.42E-08
4.599999905 37.46956635 4.71E-09
5   37.46956635 0
0.166666657 38.50869751 0.00156499
0   38.50869751 0.00156916
0.333333313 38.50869751 0.001554553
0.49999997  38.50869751 0.004114951
0.833333254 38.50869751 0.003563612
1.166666627 38.50869751 2.30E-04
1.499999881 38.50869751 7.53E-06
1.874999881 38.50869751 5.40E-07
2.249999762 38.50869751 1.43E-07
2.624999762 38.50869751 1.53E-07
2.999999762 38.50869751 1.50E-07
3.399999857 38.50869751 1.40E-07
3.799999952 38.50869751 1.19E-07
4.199999809 38.50869751 5.31E-08
4.599999905 38.50869751 3.20E-09
5   38.50869751 0
0.166666657 39.54782486 0.001559128
0   39.54782486 0.001563856
0.333333313 39.54782486 0.001546646
0.49999997  39.54782486 0.004068604
0.833333254 39.54782486 0.003520042
1.166666627 39.54782486 2.28E-04
1.499999881 39.54782486 7.46E-06
1.874999881 39.54782486 4.96E-07
2.249999762 39.54782486 1.51E-07
2.624999762 39.54782486 1.67E-07
2.999999762 39.54782486 1.62E-07
3.399999857 39.54782486 1.49E-07
3.799999952 39.54782486 1.23E-07
4.199999809 39.54782486 5.24E-08
4.599999905 39.54782486 2.01E-09
5   39.54782486 0
0.166666657 40.58695602 0.001557189
0   40.58695602 0.001562508
0.333333313 40.58695602 0.001542515
0.49999997  40.58695602 0.00402231
0.833333254 40.58695602 0.003473383
1.166666627 40.58695602 2.25E-04
1.499999881 40.58695602 7.29E-06
1.874999881 40.58695602 4.41E-07
2.249999762 40.58695602 1.61E-07
2.624999762 40.58695602 1.83E-07
2.999999762 40.58695602 1.74E-07
3.399999857 40.58695602 1.59E-07
3.799999952 40.58695602 1.28E-07
4.199999809 40.58695602 5.20E-08
4.599999905 40.58695602 1.10E-09
5   40.58695602 0
0.166666657 41.62608719 0.001559507
0   41.62608719 0.001565435
0.333333313 41.62608719 0.001542578
0.49999997  41.62608719 0.003975823
0.833333254 41.62608719 0.003422832
1.166666627 41.62608719 2.19E-04
1.499999881 41.62608719 6.98E-06
1.874999881 41.62608719 3.90E-07
2.249999762 41.62608719 1.71E-07
2.624999762 41.62608719 1.97E-07
2.999999762 41.62608719 1.84E-07
3.399999857 41.62608719 1.69E-07
3.799999952 41.62608719 1.33E-07
4.199999809 41.62608719 5.13E-08
4.599999905 41.62608719 4.35E-10
5   41.62608719 0
0.166666657 42.66521835 0.001566453
0   42.66521835 0.001572977
0.333333313 42.66521835 0.001547318
0.49999997  42.66521835 0.003928092
0.833333254 42.66521835 0.003366552
1.166666627 42.66521835 2.12E-04
1.499999881 42.66521835 6.46E-06
1.874999881 42.66521835 3.55E-07
2.249999762 42.66521835 1.84E-07
2.624999762 42.66521835 2.07E-07
2.999999762 42.66521835 1.88E-07
3.399999857 42.66521835 1.77E-07
3.799999952 42.66521835 1.35E-07
4.199999809 42.66521835 4.83E-08
4.599999905 42.66521835 7.85E-11
5   42.66521835 0
0.166666657 43.70434952 0.001578647
0   43.70434952 0.001585725
0.333333313 43.70434952 0.001557476
0.49999997  43.70434952 0.003878461
0.833333254 43.70434952 0.003302994
1.166666627 43.70434952 2.01E-04
1.499999881 43.70434952 5.50E-06
1.874999881 43.70434952 3.21E-07
2.249999762 43.70434952 2.16E-07
2.624999762 43.70434952 2.31E-07
2.999999762 43.70434952 1.96E-07
3.399999857 43.70434952 1.81E-07
3.799999952 43.70434952 1.26E-07
4.199999809 43.70434952 3.70E-08
4.599999905 43.70434952 9.44E-33
5   43.70434952 0
0.166666657 44.74347687 0.001597669
0   44.74347687 0.001605199
0.333333313 44.74347687 0.001574791
0.49999997  44.74347687 0.003826279
0.833333254 44.74347687 0.003227598
1.166666627 44.74347687 1.85E-04
1.499999881 44.74347687 3.70E-06
1.874999881 44.74347687 2.66E-07
2.249999762 44.74347687 2.53E-07
2.624999762 44.74347687 2.41E-07
2.999999762 44.74347687 1.87E-07
3.399999857 44.74347687 1.82E-07
3.799999952 44.74347687 1.01E-07
4.199999809 44.74347687 1.64E-08
4.599999905 44.74347687 0
5   44.74347687 0
0.166666657 45.78260803 0.001628722
0   45.78260803 0.001636415
0.333333313 45.78260803 0.001605077
0.49999997  45.78260803 0.003774526
0.833333254 45.78260803 0.003118682
1.166666627 45.78260803 1.40E-04
1.499999881 45.78260803 1.67E-06
1.874999881 45.78260803 2.18E-07
2.249999762 45.78260803 2.84E-07
2.624999762 45.78260803 2.88E-07
2.999999762 45.78260803 2.14E-07
3.399999857 45.78260803 1.46E-07
3.799999952 45.78260803 4.78E-08
4.199999809 45.78260803 2.25E-09
4.599999905 45.78260803 0
5   45.78260803 0
0.166666657 46.8217392  0.001690754
0   46.8217392  0.001697367
0.333333313 46.8217392  0.001670087
0.49999997  46.8217392  0.003727587
0.833333254 46.8217392  0.002997055
1.166666627 46.8217392  9.83E-05
1.499999881 46.8217392  9.59E-07
1.874999881 46.8217392  2.28E-07
2.249999762 46.8217392  2.85E-07
2.624999762 46.8217392  3.03E-07
2.999999762 46.8217392  1.91E-07
3.399999857 46.8217392  5.81E-08
3.799999952 46.8217392  6.35E-09
4.199999809 46.8217392  6.64E-18
4.599999905 46.8217392  0
5   46.8217392  0
0.166666657 47.86087036 0.00184302
0   47.86087036 0.00184606
0.333333313 47.86087036 0.001831784
0.49999997  47.86087036 0.003697354
0.833333254 47.86087036 0.002873334
1.166666627 47.86087036 8.88E-05
1.499999881 47.86087036 1.15E-06
1.874999881 47.86087036 2.26E-07
2.249999762 47.86087036 1.98E-07
2.624999762 47.86087036 1.55E-07
2.999999762 47.86087036 6.60E-08
3.399999857 47.86087036 3.55E-09
3.799999952 47.86087036 6.64E-18
4.199999809 47.86087036 6.64E-18
4.599999905 47.86087036 0
5   47.86087036 0
0.166666657 48.90000153 0.002088528
0   48.90000153 0.002102719
0.333333313 48.90000153 0.002067088
0.49999997  48.90000153 0.003463022
0.833333254 48.90000153 0.002490708
1.166666627 48.90000153 5.84E-05
1.499999881 48.90000153 8.99E-07
1.874999881 48.90000153 1.17E-07
2.249999762 48.90000153 6.36E-08
2.624999762 48.90000153 2.43E-08
2.999999762 48.90000153 3.43E-09
3.399999857 48.90000153 0
3.799999952 48.90000153 0
4.199999809 48.90000153 0
4.599999905 48.90000153 0
5   48.90000153 0
0.166666657 49.90000153 0.001112131
0   49.90000153 0.001126061
0.333333313 49.90000153 0.001093095
0.49999997  49.90000153 0.001618409
0.833333254 49.90000153 0.001088696
1.166666627 49.90000153 1.46E-05
1.499999881 49.90000153 2.99E-07
1.874999881 49.90000153 1.77E-08
2.249999762 49.90000153 0
2.624999762 49.90000153 0
2.999999762 49.90000153 0
3.399999857 49.90000153 0
3.799999952 49.90000153 0
4.199999809 49.90000153 0
4.599999905 49.90000153 0
5   49.90000153 0
0.166666657 50  0
0   50  0
0.333333313 50  0
0.49999997  50  0
0.833333254 50  0
1.166666627 50  0
1.499999881 50  0
1.874999881 50  0
2.249999762 50  0
2.624999762 50  0
2.999999762 50  0
3.399999857 50  0
3.799999952 50  0
4.199999809 50  0
4.599999905 50  0
5   50  0

and I hope the picture looks like:
enter image description here

redpajama_set_name: RedPajamaStackExchange


text:
Q: How do I properly update the WordPress database password? A site that I manage was recently compromised, and I am going through the steps to harden and re-secure the site. I would like to change the MySQL database password and want to make sure I do not take the site down (for more than a minute).
I am also concerned that if I manually change the database password directly in the wp-config.php file that it will be visible and un-encrypted. For example, if my initial password at install was "please" it would display in the wp-config.php file as "aDQps4txy".
So what is the best way to go about updating the database password?

A: This is technically challenging. WordPress must have access to your DB password in plain text. Having access to the wp-config.php contents is already a breach of security in progress.
There are alternate approaches to configuration, such as loading credentials via environment variables, but in practice they are used exceedingly rarely because PHP's configuration file is a reasonable solution already.
It's not clear why you assume someone will get access to the configuration file. As a low-hanging fruit, you can place it outside of the web accessible directory. WordPress will scan for the configuration file up one directory level above itself. For subdirectory installs, you could use require to load configuration content from elsewhere, but even that is rarely done.

A: Your actual DB password is stored unencrypted in the wp-config.php, i.e., if your password is foobar, the corresponding line in wp-config.php is:
/** MySQL database password */
define('DB_PASSWORD', 'foobar');

As @Rarst pointed out:

Having access to wp-config.php contents is already breach of security in progress.

This is because PHP is a hypertext preprocessor. Anyone who accesses wp-config.php via their web browser will have the file routed through the server-side PHP interpreter. The interpreter passes only those data onto the client (the web browser) that it has been instructed to output. The DB password is not outputted by PHP. When I access my wp-config.php through my browser, I get an empty page with no source code at all because this file does not output anything at all.
However, it is not true that having the DB password stored unencrypted is completely risk-free. Anyone who gets the chance to bypass the PHP interpreter and hence read the file's source will gain access to your password. This is also what @Rarst meant. To be clear, this can also be a man-in-the-middle who is eavesdropping on your unencrypted FTP connection. The moment you download wp-config.php through an insecure FTP connection (in contrast to an encrypted SFTP connection) in order to edit it and re-upload it again to your server, the possibility your password being spied on does exist.
The easiest way to prevent most attacks is to keep your server up-to-date through security updates and to ensure to always use secure protocols (HTTP/FTP over TLS = HTTPS/FTPS instead of HTTP/FTP, alternatively SFTP, and SSH instead of Telnet) when dealing with sensitive data, i.e. when acting as administrator.
Read more on https://codex.wordpress.org/Hardening_WordPress.

A: One way this stuff can be exposed without CLI access is if the PHP module in Apache is absent or broken for whatever reason. In that case, it just dumps the raw PHP. I've not tested this recently; this was a few years ago. But it is not cool.
Technically, since WordPress is open source, you can just do something like this:
define('DB_PASSWORD', '`cat /etc/wp_db_pass | base64 -d`');
to create a safer place for the WordPress password file. In this example I'm assuming you created the password like so:
echo 'mypassword' | base64 > /etc/wp_db_pass

However, if you don't have commandline access you might be able to do something similar over FTP.


text:
Q: Jboss Múltiplos context-root apontando mesmo war boa noite.
É possível eu configurar no Jboss vários context-root apontando para o mesmo war? Caso não seja possível no jboss, existe alguma forma de eu fazer isso?
Obrigado

A: Acho que é possível sim, acabei achando esse comando caso vc use o jboss 7+
Pin your application via jboss-web.xml to context-root path1 and add rewrite rule to standalone.xml as shown:
<virtual-server name="default-host" enable-welcome-root="false">
     <alias name="localhost"/>
     <rewrite name="rule-1"  pattern="^/path1(.*)$" substitution="/path2/$1" flags="NC"/>
 </virtual-server>

A: Senhores, no final consegui resolver seguindo a documentação abaixo:
http://jbossweb.jboss.org/modules/rewrite.html
Meu rewrite.properties ficou assim:
RewriteRule ^/path1(.*)$  /path2$1 [NC]


text:
Q: LsaOpenPolicy, LsaAddAccountRights with POLICY_CREATE_ACCOUNT access mask I am using the LsaAddAccountRights function to assign SE_SERVICE_LOGIN_RIGHT to specified local machine/domain accounts during installation of my service.
During the call to LsaOpenPolicy I pass both flags POLICY_CREATE_ACCOUNT and POLICY_LOOKUP_NAMES as parts of the access mask - and all things are working great.
I am just worried about having POLICY_CREATE_ACCOUNT as one of the flags, as the function documentation for LsaAddAccountRights reads:

The LsaAddAccountRights function assigns one or more privileges to an
  account. If the account does not exist, LsaAddAccountRights creates
  it.

I am unclear in which context this account gets created.
When I do not add POLICY_CREATE_ACCOUNT access as part of the access flags to LsaOpenPolicy I can not add SE_SERVICE_LOGIN_RIGHT to an existing account - hence I need to add this flag.
I don't want to be somehow adding accounts when the user misspells the account name.


text:
Q: Selenium click doesn't work with angularjs ng-click event I'm looking to verify a particular external function is called on a ng-click event. The input declaration is as follows. This works fine in the browsers, so there are no problems functionally, only during testing with Selenium I'm not seeing the correct result. myFunction is calling an external myExternalFunction, which is the behaviour I'm trying to validate. We already have jasmine tests with spies validating this behaviour in a different environment, but Selenium is needed anyways. Also we don't use protractor at the moment. I'm looking for a solution with Selenium.
<input class="myClass" ng-click="myFunction()">

In the C# Selenium tests, I'm writing:
// Creating the mock external function since the context doesn't have it.
IJavaScriptExecutor executor = WebDriver as IJavaScriptExecutor;
executor.ExecuteScript("window.called='false'");
executor.ExecuteScript("window.external = {}");

// The behavior will be just setting the called variable to true.
// We will retrieve the variable and check the value to see if the function was called.
executor.ExecuteScript("window.external.myExternalFunction = function() {window.called = 'true';}");

// Select the element - there's only one element with this classname
IWebElement element = WebDriver.FindElement(By.ClassName("myClass"));
string value = "";
// Verified via debugging that the element is actually valid.
// Tried the following options.

// 1) Just click and wait for event propagation - didn't work.
element.Click(); // Didn't do anything so added a Thread Sleep to make sure.
Thread.Sleep(1000);
value = WebDriver.ExecuteJavaScript<string>("return window.called;"); // returns false - expected to be true.

// 2) Use the actions to focus and click.
IWebDriver driver = WebDriver;
Actions a = new Actions(driver);
a.MoveToElement(element).Perform();
a.MoveToElement(element).Click().Perform();
Thread.Sleep(1000);
value = WebDriver.ExecuteJavaScript<string>("return window.called;"); // returns false - expected to be true.

// 3) Select and click via javascript instead.
executor.ExecuteScript("angular.element('.myClass').click();");
Thread.Sleep(1000);
value = WebDriver.ExecuteJavaScript<string>("return window.called;"); // returns false - expected to be true.

I'm pretty much out of ideas at this stage. Is there no way to make Selenium play nice with angularjs? Similar question here: Selenium click event does not trigger angularjs ng-click without conclusive answer.

A: I would suggest, use xpath for locating the element and you should be good. Please share the xpath, if possible.

A: You can use css selector and It should work :
By.cssSelector("input[ng-click='myFunction()']")


text:
Q: Is exist methods for tune GETNEXT for many many many of sequential OIDs? I am coding in C some tool for monitoring ethernet switch by snmp v1 and Net-SNMP lib.
In one of the step I get FDB table from switch.
It gets by request getnext with OID .1.3.6.1.2.1.17.7.1.2.2.1. After I get for example:
getnext .1.3.6.1.2.1.17.7.1.2.2.1     answer .1.3.6.1.2.1.17.7.1.2.2.1.2.1.144.2.166.50.206.43 3
getnext .1.3.6.1.2.1.17.7.1.2.2.1.2.1.144.2.166.50.206.43   answer .1.3.6.1.2.1.17.7.1.2.2.1.2.1.144.2.166.50.206.63      6
getnext .1.3.6.1.2.1.17.7.1.2.2.1.2.1.144.2.166.50.206.63   answer .1.3.6.1.2.1.17.7.1.2.2.1.2.1.144.2.166.50.206.126    4
getnext  .1.3.6.1.2.1.17.7.1.2.2.1.2.1.144.2.166.50.206.126 answer  .1.3.6.1.2.1.17.7.1.2.2.1.2.41.0.21.100.59.187.78    26
getnext .1.3.6.1.2.1.17.7.1.2.2.1.2.41.0.21.100.59.187.78   answer NULL

Unfortunately some switch ports have a very large number of rows and the full cycle of getnext takes long time.
Is there any method to get all rows of getnext
OID .1.3.6.1.2.1.17.7.1.2.2.1 etc. at one request?
Or may be have other methods for get its requests faster?


text:
Q: read data from ODBC using DataSet I have created ODBS user DNS for database, opened VS, created DataSet and imported one table members. I would like to read all records from dataset, how to do that? I have tried query below but it return no result. I can preview data using preview menu in designer but do not find a way to get data using code.
    var dataSet = new DataSet1();
    var membersDataTable = dataSet.members;

    var take = membersDataTable.Take(100);

A: It looks like you have created the schema for a DataSet, but you have not run any queries to load the DataSet.
using (OdbcConnection connection =
               new OdbcConnection(connectionString))
    {
        string queryString = "SELECT * FROM Members";
        OdbcDataAdapter adapter =
            new OdbcDataAdapter(queryString, connection);

        // Open the connection and fill the DataSet.
        try
        {
            connection.Open();
            adapter.Fill(dataSet);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
        // The connection is automatically closed when the
        // code exits the using block.


text:
Q: installing pandas on python - where did numpy go? So I'm trying to open a website/url extract an excel file on the site, edit it, and then put it on a different website. I found another comment on this site that has excellent advice for how to do this using import pandas.
I downloaded pandas (and some other modules) from the python website, and wrote the code. But when I try to run it I get the following error
Warning (from warnings module):
  File "C:\Python27\lib\site-packages\pandas\io\excel.py", line 626
    .format(openpyxl_compat.start_ver, openpyxl_compat.stop_ver))
UserWarning: Installed openpyxl is not supported at this time. Use >=1.6.1 and <2.0.0.
Traceback (most recent call last):
  File "C:\Python27\more_url_stuff.py", line 6, in <module>
    socket = urllib2.urlopen(link)
  File "C:\Python27\lib\urllib2.py", line 127, in urlopen
    return _opener.open(url, data, timeout)
  File "C:\Python27\lib\urllib2.py", line 410, in open
    response = meth(req, response)
  File "C:\Python27\lib\urllib2.py", line 523, in http_response
    'http', request, response, code, msg, hdrs)
  File "C:\Python27\lib\urllib2.py", line 448, in error
    return self._call_chain(*args)
  File "C:\Python27\lib\urllib2.py", line 382, in _call_chain
    result = func(*args)
  File "C:\Python27\lib\urllib2.py", line 531, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 401: Unauthorized

What is going on?
Is there an easier way to download the excel file from the internet?
I just started coding with Python last week so I'm still confused with some simple things.

A: Update:
Pandas 0.15.2 has been released, and it works pretty well with the most current version of openpyxl (2.0 or later). This answer is outdated.

OK, it appears that you have obtained the most recent version of pandas (==0.14.0), and this one requires some specific version of the Openpyxl. If you don't care about giving up new features introduced in newer version, try uninstall your existing openpyxl and install an older version.
pip uninstall openpyxl
pip install openpyxl==1.8.6

If you simply want to download the file and save it to a local folder, here is an easier way:
import urllib
URL_to_the_file = "http://real-chart.finance.yahoo.com/table.csv?s=SPY&a=00&b=29&c=1993&d=05&e=13&f=2014&g=d&ignore=.csv"
urllib.urlretrieve (URL_to_the_file, "downloaded.csv")


text:
Q: Amazon alexa API for my Android app I would like to include a voice API for my Android app,
 I was searching for amazon's alexa but couldn't find any API s to work (
link1
link2
)
 , can anyone point me to any voice API that I can work with inorder to tell my app to do things when the user is asking for them?
Thanks..

A: The Alexa Voice Service is announced yet not publicly available yet. You can signup to get an email when it becomes available.


text:
Q: R dplyr complete with multiple constant columns My data frame looks like the following:
df <- data.frame("Name"=c("Bob", "Bob", "Emma"), "Age"=c(23,23,78), "Gender"=c("Male", "Male", "Female"), "Item"=c("house", "car", "house"), "Value"=c(5,1,3))
df
  Name Age Gender  Item Value
1  Bob  23   Male house     5
2  Bob  23   Male   car     1
3 Emma  78 Female house     3

I am trying to "fill" the missing rows with all the existing values of the "Item" column, knowing that the values of the "Age" and "Gender" columns are dependent on the "Name" one.
I try to get this result (see the 4th row) without joining two data frames together:
 Name Age Gender  Item     Value
1  Bob  23   Male house        5
2  Bob  23   Male   car        1
3 Emma  78 Female house        3
4 Emma  78 Female   car  unknown

I tried combinations of the complete function but it computes all possible combinations of the first 3 columns:
library(tidyverse)

df %>% complete(Name, Age, Gender, nesting(Item), fill=list(Value="unknown"))

  Name     Age Gender Item  Value
 1 Bob      23 Female car   unknown
 2 Bob      23 Female house unknown
 3 Bob      23 Male   car   1
 4 Bob      23 Male   house 5
 5 Bob      78 Female car   unknown
 6 Bob      78 Female house unknown
 7 Bob      78 Male   car   unknown
 8 Bob      78 Male   house unknown
 9 Emma     23 Female car   unknown
10 Emma     23 Female house unknown
11 Emma     23 Male   car   unknown
12 Emma     23 Male   house unknown
13 Emma     78 Female car   unknown
14 Emma     78 Female house 3
15 Emma     78 Male   car   unknown
16 Emma     78 Male   house unknown

A: Actually, I was close:
df %>% complete(nesting(Name, Age, Gender), Item, fill=list(Value="unknown"))
 Name    Age Gender Item  Value
1 Bob      23 Male   car   1
2 Bob      23 Male   house 5
3 Emma     78 Female car   unknown
4 Emma     78 Female house 3


text:
Q: Android SQL Database without Firebase i want to make login method without Firebase.
i read about greenrobot database instead of Firebase database.
my question is that greendao online or it's local database?
For example two users using the app and entered the same email so the application show email already in use.
Can i do it in greenrobot database?


text:
Q: What's the shortest distance between a point and a line segment? Okay, so, we've already been over this. I don't mean me and you, I mean, just, you know, me. Anyway, the method I first found to do it is as follows.
So let's establish some variables:
$LX,$ $LY,$ $SX,$ $SY,$ $PX,$ $PY$
$A,$ $B,$ $C,$ $H$
(Segment = LS, point = P, X = axis, Y = axis, ABCH = trigonometric stuff)
And now here's the method:
$A = \sqrt{(PX-LX)^2+(PY-LY)^2}$
$B = \sqrt{(LX-SX)^2+(LY-SY)^2}$
$C = \sqrt{(PX-SX)^2+(PY-SY)^2}$
$H = \sqrt{A^2 - \left(\frac{C^2 - (B^2 + A^2)}{-2B}\right)}$
And that's the answer.
Well, this method doesn't work, because it may have two points for the line + segment but when I tested it, it may only show the segment of the points but the thing extended the line to a real line when doing the testing. I mean the line-plane-realm-flune-space line. Anyway, I'm, um, asking for a new formula that actually cuts the line off at the points so if you have the point right in the direction of the segment and move it away from it, when it doesn't touch the line anymore the value actually gets higher, I guess. Also since I found out I don't know a lot of people's fancy notation I suppose you're gonna have to break  it down. Anyhow I think you just have to make an adjustment to the above formula to actually get the answer for a segment instead of a line. Bye!

A: Express the position of any point on the infinite line as $\vec l + t (\vec s - \vec l)$, where $\vec l$ and $\vec s$ are the start and end point of the line segment and $t$ is a real-valued parameter. Write the point $\vec p$ as $\vec p=\vec l + t (\vec s-\vec l)+ u \vec p_\perp$, where $\vec p_\perp$ is a line orthogonal to the first line. Compute $t$ by the usual procedure, i.e., multiply both sides of this with the vector $\vec s -\vec l$. If $t<0$ reset to $t=0$ and if $t>1$ reset to $t=1$ so move the foot point to a position in the line segment. Insert that $t$ into the expression of the point on the infinite line and compute the distance to $\vec p$ by the usual Pythagorean formula.


text:
Q: Is there a way in R to detect how often a package is used? Recently, I found that there are many packages that I don't use much, and some of them may never be used again. I would like to delete these packages, but I am worrying that some packages that I often use may depend on these rarely used ones.
So I am wondering whether there is a way in R to detect how often a package is used?
Thank you!

A: I have never seen a package able to quantify the use of R packages.
Further, I see a risk in simply remove package, as there can be dependencies you are not aware of.
However, there is the package miniCRAN, which can show you dependencies between packages. So my suggestion would be that you scan for all your packages installed on your system and look for dependencies. In that way you could find packages which can be removed without breaking other packages even if you are using the functionality on a very rare basis.
One more recommendation is to not use system wide installed packages, but use packages dedicated to your projects. There are multiple tools which can be used in this context: renv, packrat. The goal of such approaches is to get a independent package libraries for each project. If the project is no longer in your focus you can easily remove the packages without touching the functionality of other projects,


text:
Q: Reporting statistics in Spring Web Flow We have an enterprise application using Spring 3.2.8 and Spring Web Flow 2.3.3 deployed on the Websphere 8 server. We wish to report statistics like no. of incomplete flows, the state at which user terminate the flow, time spent at individual states etc. We thought of using Spring Instrumentation. However, could not find instrumentation jar package for Spring 3.2 and Webflow 2.3. Where can I find the complete distribution of Spring 3.2 instrumentation jars? Or which other tool can I use for my purpose with Websphere 8? Please help.

A: I just did a google search.  If I read the webpage correctly, instrumented spring is a paid product.
From http://static.springsource.com/projects/instrumentation/index.html:

Instrumented Spring Framework, Web Services, Web Flow, and Security are available as part of a tc Server Spring Edition 2.x subscription or evaluation, which includes integration with Hyperic HQ. Instrumented Spring products are also available to Spring Enterprise subscribers.


text:
Q: Devstack installation failed with error message "ERROR: Editable requirements are not allowed as constraints" I encounter the following error when I run the script stack.sh:
Using python 3.6 to install setuptools!=24.0.0,!=34.0.0,!=34.0.1,!=34.0.2,!=34.0.3,!=34.1.0,!=34.1.1,!=34.2.0,!=34.3.0,!=34.3.1,!=34.3.2,!=36.2.0,!=48.0.0,!=49.0.0
+ inc/python:pip_install:187               :   sudo -H LC_ALL=en_US.UTF-8 http_proxy= https_proxy= no_proxy= PIP_FIND_LINKS= SETUPTOOLS_SYS_PATH_TECHNIQUE=rewrite python3.6 -m pip install -c /opt/stack/requirements/upper-constraints.txt --ignore-installed 'setuptools!=24.0.0,!=34.0.0,!=34.0.1,!=34.0.2,!=34.0.3,!=34.1.0,!=34.1.1,!=34.2.0,!=34.3.0,!=34.3.1,!=34.3.2,!=36.2.0,!=48.0.0,!=49.0.0'
DEPRECATION: Constraints are only allowed to take the form of a package name and a version specifier. Other forms were originally permitted as an accident of the implementation, but were undocumented. The new implementation of the resolver no longer supports these forms. A possible replacement is replacing the constraint with a requirement.. You can find discussion regarding this at https://github.com/pypa/pip/issues/8210.
ERROR: Editable requirements are not allowed as constraints
++./stack.sh:main:752                       err_trap
++./stack.sh:err_trap:530                   local r=1
stack.sh failed: full log in /opt/stack/logs/stack.sh.log.2021-05-10-115040
Error on exit

And a little higher I have this warning:
  Attempting uninstall: pip
    Found existing installation: pip 21.1.1
    Uninstalling pip-21.1.1:
      Successfully uninstalled pip-21.1.1
Successfully installed pip-21.1.1
WARNING: Running pip as root will break packages and permissions. You
should install packages reliably by using venv:
https://pip.pypa.io/warnings/venv

Any idea why?
Thanks


text:
Q: GUI button and entry widgets I have a project for CS and it is dealing with GUI's in python.
It's a three part project with 3 different classes. In the last class when I am trying to add a button widget or entry widget I keep on getting an error:
global name 'Button' is not defined

from Spotter import Spotter
from Cloud import Cloud
from Tkinter import tkinter, Tk, StringVar
from random import randint
import time
import math

class Cloudspotting (Spotter):

     # create the buttons
     def __init__(self, root):
         Spotter.__init__(self, root)
         # the result binding variable
         self.result = StringVar()
         self.result.set('')

         # create the buttons and result entry
         self.startBtn = Button(self.frame, text='Start', command=self.start)
         self.stopBtn = Button(self.frame, text='Stop', command=self.stop)
         self.clearBtn = Button(self.frame, text='Clear', command=self.clear)
         self.resultEntry = Entry(self.frame, textvariable=self.result, state='readonly')

         # display the buttons and entry on the frame
         self.startBtn.grid(row=2, column=1)
         self.stopBtn.grid(row=2, column=2)
         self.clearBtn.grid(row=2, column=3)
         self.resultEntry.grid(row=2, column=4, columnspan=2)

         # clouds
         self.clouds = None

A: You need to properly import tkinter. I recommend not using global imports. Remove all of your attempts at importing tkinter and do it like this:
import Tkinter as tk
...
self.result = tk.StringVar()
...
self.startBtn = tk.Button(...)
...

Notice how this imports tkinter with the name tk (for brevity), and then prefix tkinter classes with tk.. This makes it clear that you are using the Button class from tkinter and not from some other module.


text:
Q: How to solve $ab\bmod c = d$ How can $ab\bmod c = d$ be solved, if $b$, $c$ and $d$ are known?
A similar algorithm is used by LCGs (weak PRNG) to give random values.
To solve this, I used WolframAlpha which quickly solved, but shown nothing about process.
What is the process to solve such problems?


text:
Q: I cannot upload variables to database I tried to upload video filenames and other variables to the database, but the insert statement won't work. Anyway the videofile-name and the thumbnail-filename are both uploaded to the right folders.
I've checked and there's nothing wrong with the sql statement. But why won't it work can anyone tell me?
PHP code
<?php

    session_start();

if (isset($_POST['submit'])) {

    $videoName = $_POST['videoName'];
    $videoDesc = $_POST['description'];
    $category = $_POST['category'];
    $level = $_POST['level'];
    $userId = $_SESSION['userId'];

    $videoFile = $_FILES["videoFile"];
    $videoFileName = $videoFile['name'];
    $videoFileType = $videoFile['type'];
    $videoFileTempName = $videoFile['tmp_name'];
    $videoFileError = $videoFile['error'];

    $videoFileExt = explode(".", $videoFileName);
    $videoFileActualExt = strtolower(end($videoFileExt));
    $videoAllowed = array("mp4", "mov", "avi");

    $thumbFile = $_FILES["thumbnail"];
    $thumbFileName = $thumbFile["name"];
    $thumbFileType = $thumbFile["type"];
    $thumbFileTempName = $thumbFile["tmp_name"];
    $thumbFileError = $thumbFile["error"];

    $thumbFileExt = explode(".", $thumbFileName);
    $thumbFileActualExt = strtolower(end($thumbFileExt));
    $thumbAllowed = array("jpg", "jpeg", "png");

    if (in_array($videoFileActualExt, $videoAllowed)) {
        if(in_array($thumbFileActualExt, $thumbAllowed)) {
            if ($videoFileError === 0) {
                if ($thumbFileError === 0) {

                            $videoFullName = $videoFile . "." . uniqid("", true) . "." . $videoFileActualExt;
                            $videoFileDestination = "../video/" . $videoFullName;

                            $thumbFullName = $thumbFile . "." . uniqid("", true) . "." . $thumbFileActualExt;
                            $thumbFileDestination = "../thumbnail/" . $thumbFullName;

                            include 'dbh.inc.php';

                            if(empty($videoName) or empty($videoDesc)) {
                                header("Location: ../uploadVideo.php?upload=empty");
                                exit();
                            } else {
                                    move_uploaded_file($videoFileTempName, $videoFileDestination);
                                    move_uploaded_file($thumbFileTempName, $thumbFileDestination);

                                $sql = "INSERT INTO video (filnavn, thumbnail, videoName, descript, idMusician, categoryName, idLevel) VALUES ('$videoFullName', '$thumbFullName', '$videoName', '$videoDesc', $userId, '$category', $level);";
                                mysqli_query($conn, $sql);

                                    header("Location: ../uploadVideo.php?upload=success");
                                    exit();
                                }

                } else {
                    echo "You had a thumbnail error!";
                    exit();
                }
            } else {
                echo "You had a video error!";
                exit();
            }
        } else {
            echo "You need to upload a proper thumbnail file type";
            exit();
        }
    } else {
        echo "You need to upload a proper video file type!";
        exit();
    }
} else {

}

A: You cannot insert or in this way in the if() condition, you must always use the logical operator as
 if(empty($videoName) || empty($videoDesc))

Because of that your execution of code must have stopped at that point.


text:
Q: How to add event handler and other attributes to select_month and select_year in rails 4.1? I would like to add event handler to select tag  with select_month tag in rails 4. And also i want add custom attributes to select tag how can i add ??
Can somebody explain through code ?
Example how o/p should be:
    <select id="test" name="test" onchange="test()" testing="testing">
           <option value="1">One</option>
    </select>


text:
Q: Gradle clean is considered up-to-date I have written a custom plugin which does nothing with the clean task. My plugin applies LifecycleBasePlugin (so it will have build, check, clean etc).
If I call gradle clean it is said to be up to date and nothing happens. I suppose from the source it should delete the build directory /project.getBuildDir()/ where I also put my built files to.
The output of gradle -im clean:
Selected primary task 'clean' from project :
Tasks to be executed: [task ':clean']
:clean (Thread[main,5,main]) started.
:clean
 Skipping task ':clean' as task onlyIf is false.
:clean SKIPPED
:clean (Thread[main,5,main]) completed. Took 0.011 secs.

I have also tried to delete .gradle.

A: you can execute command below
gradle build --refresh-dependencies

or
delete .gradle folder in your user folder and compile again.
in linux or Mac,
~/.gradle

in windows
C:User¥your-id¥.gradle

please try.


text:
Q: Conditional probability given a pdf First time posting here. I'm having trouble conceptualising the following question. Any tips or pointers would be greatly appreciated. Direction to a solution to a similar problem would also be fantastic - i'm not so much looking for a solution, as how to go about solving this kind of problem.
5 weight lifters work out each day. The risk of injury within 5 hours of working out, X, varies from day to day according to the pdf
f(x) ={ 10x, 0 ≤ x ≤ 0.1
      { 15/7(1−x), 0.1 < x ≤ 1
Derive a formula for the conditional probability of exactly 2 injuries (2 people) within 5 hours of exercise among the 5 weight lifters on any given random day (number of injuries follows a Binomial distribution)
Many thanks.


text:
Q: Conditionally extend template with Odoo QWeb I added a boolean field to my stock.picking.type model called x_is_dropship_aggregate_picking_type. This field is False for all picking types in my database except for one.
I am trying to make some changes to the Kanban card for the picking type that has x_is_dropship_aggregate_picking_type == true, but I can't seem to get it to work.
Here's my template created through the Odoo V10 UI. It inherits from the stock.picking.type.kanban view:
<?xml version="1.0"?>
<data>
    <xpath expr="//field[@name='count_picking_backorders']" position="after">
        <field name="x_is_dropship_aggregate_picking_type"/>
    </xpath>
    <templates>
        <t t-extend="kanban-box">
            <t t-if="record.x_is_dropship_aggregate_picking_type.raw_value" t-jquery="button" t-operation="replace">
                <button class="btn btn-primary">
                    100 To Receive
                </button>
            </t>
        </t>
    </templates>
</data>

As you can see on this line:
<t t-if="record.x_is_dropship_aggregate_picking_type.raw_value" t-jquery="button" t-operation="replace">

I am attempting to only alter the parent template if the value of this field is true. Unfortunately, every Kanban card within the view is getting changed, not just the one I want. It seems that t-if and t-jquery do not working together in that way.
Is there any way to conditionally alter this view and leave it unchanged otherwise?


text:
Q: Android NDK API list? Is there a way/tool to enumerate all the C function prototypes (not sure if that's the right term) from the .h files in the NDK folder subdirectories (i.e. C:\android-ndk-r8b\platforms\android-9\arch-arm\usr\include) and produce something like a javadoc?  The reason I'm asking is because we have a developer on our end who is trying to port his Windows code over to the android platform and before he begins to go forward with such an effort, he needs to know what API calls are supported so he can begin changing his code base to make it Android-NDK compliant.  I've run across the following links in my search for an answer:
http://mobilepearls.com/labs/native-android-api/#c++
C:/android-ndk-r8b/docs/STABLE-APIS.html
C:/android-ndk-r8b/docs/CPLUSPLUS-SUPPORT.html

A: The right way to check if the code is compliant is to compile it and see what breaks. Win32 API surely would - there's even no point in checking if an NDK counterpart exists. The C/C++ RTL is a little more tricky - some functions have counterparts, some don't. But enumerating them all and matching by hand is, frankly, a waste of time. A compiler will do the same much faster.

A: For starters, let the code be Linux compliant. The minute differences between Android libs and Linux can usually be resolved incrementally. Note that you have a moving target here: platform-14 supports much more Linux headers than 9.

A: http://www.tenouk.com/Module000linuxnm3.html
can you use libs instead of .h files?
the link explains using 'nm' to dump symbols from libs


text:
Q: make element move as mouse moves I have this nifty little thing going right now. It is partially what I am looking for. When you try to run the code, press down on the image and move it with your mouse:

<!DOCTYPE html>

it works fine, but I want it to basically move wherever my mouse moves. So if im moving my mouse, it should follow my mouse. you can see an example here www.poolhouse.co in the header (only works on desktop). How would I do this with the code below? Is it possible?

A: You have to change mousedown to mouseover

//Make the DIV element draggagle:
dragElement(document.getElementById("mydiv"));

function dragElement(elmnt) {
  var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
  if (document.getElementById(elmnt.id + "header")) {
    /* if present, the header is where you move the DIV from:*/
    document.getElementById(elmnt.id + "header").onmouseover = dragMouseDown;
  } else {
    /* otherwise, move the DIV from anywhere inside the DIV:*/
    elmnt.onmouseover = dragMouseDown;
  }

  function dragMouseDown(e) {
    e = e || window.event;
    e.preventDefault();
    // get the mouse cursor position at startup:
    pos3 = e.clientX;
    pos4 = e.clientY;
    document.onmouseup = closeDragElement;
    // call a function whenever the cursor moves:
    document.onmousemove = elementDrag;
  }

  function elementDrag(e) {
    e = e || window.event;
    e.preventDefault();
    // calculate the new cursor position:
    pos1 = pos3 - e.clientX;
    pos2 = pos4 - e.clientY;
    pos3 = e.clientX;
    pos4 = e.clientY;
    // set the element's new position:
    elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
    elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
  }

  function closeDragElement() {
    /* stop moving when mouse button is released:*/
    document.onmouseup = null;
    document.onmousemove = null;
  }
}
#mydiv {
  position: absolute;
  z-index: 9;
  background-color: #f1f1f1;
  text-align: center;
  border: 1px solid #d3d3d3;
}

#mydivheader {
  padding: 10px;
  cursor: move;
  z-index: 10;
  background-color: #2196F3;
  color: #fff;
}

Working Fiddle


text:
Q: Lua make upvalue into constant The program, I'm writing lua script for, doesn't support saving of upvalues. Hence function fun would not be valid after restoring program state:
gen=function(par)
    local a=par
    return function() print(a) end
    end
fun=gen(2)

On the other hand simple functions without closures like gen are saved and loaded normally.
I'd like to create a bunch of functions similar to fun with different values of parameter a in the above. Programmatic equivalent of:
fun1=function()
    local a=1
    print(a)
end
fun2=function()
    local a=2
    print(a)
end
--and so on

Are there possibilities of doing so?

A: You can create a table that behaves just as your function (but, since it's a table, it should hopefully be restored correctly):
gen = function(par)
    return setmetatable({a = par}, {
            __call = function(self)
                print(self.a)
            end
        })
end

fun = gen(1)  -- Note: fun is a table, but can be called like a function.
fun()

If you need to add parameters to your table-function, you can simply do so by adding parameters to the __call metamethod:
gen = function(par)
    return setmetatable({a = par}, {
            __call = function(self, something)
                print(self.a, something)
            end
        })
end

fun = gen(1)
fun("foobar")   -- Outputs "1   foobar"

Check out the Lua manual, section 'Metatables and Metamethods' for more info!


text:
Q: I have a function with 3 variables that I want to minimize the objective function I have imported all the packages
def f(x,y,z):

   return (1364*(z + x)**2 - (2728*(z + x)**3)/3 - 1600*y**2 + (3200*y**3)/3 \
                 - (5114092463576843*z**2)/4398046511104 + \
                 (5114092463576843*z**3)/6597069766656 + 1364*x**2 \
                 - (2728*x**3)/3 + 1364*(y - x)**2 + (2728*(y - x)**3)/3 \
                 + 1364*(z - y + x)**2 - (2728*(z - y + x**3)/3 \
                         - 20799363518172179/105553116266496)**(1/2)

x0 = [0.3, 0.2, 0.2]
H = np.array(hessian(f, (x, y, z)))

res = minimize(f, [0,0,0], method='nelder-mead', options={'xtol': 1e-8, 'disp': True})

I have invalid syntax error in X0, H and res

A: I broke down your equation into additive terms just for visualization.
def f(x,y,z):
    a = 1364 * (z + x) ** 2
    b = (2728 * (z + x) ** 3) / 3
    c = 1600 * y ** 2
    d = (3200 * y ** 3) / 3
    e = (5114092463576843 * z ** 2) / 4398046511104
    g = (5114092463576843 * z ** 3) / 6597069766656
    h = 1364 * x ** 2
    i = (2728 * x ** 3) / 3
    j = 1364 * (y - x) ** 2
    k = (2728 * (y - x) ** 3) / 3
    l = 1364 * (z - y + x) ** 2
    m = (2728 * (z - y + x ** 3) / 3 - 20799363518172179 / 105553116266496) ** (1 / 2)
    return (a - b - c + d - e + g + h - i + j + k + l - m)

The leading "(" before "a" didn't have ")" after "m" assuming that's where you wanted it. please make sure that all the terms above is correct.


text:
Q: SwiftUI and dynamic NSSortDescriptors in @FetchRequest I have a list with items that contain a title and a date. User can set what to sort on (title or date).
However I can't figure out how to change the NSSortDescriptor dynamically.
import SwiftUI
import CoreData

struct ContentView: View {
    @Environment(\.managedObjectContext) private var viewContext

    @FetchRequest(sortDescriptors: [NSSortDescriptor(keyPath: \Test.title, ascending: true)], animation: .default) private var items: FetchedResults<Test>

    @State private var sortType: Int = 0
    @State private var sortDescriptor: NSSortDescriptor = NSSortDescriptor(keyPath: \Test.title, ascending: true)

    var body: some View {
        Picker(selection: $sortType, label: Text("Sort")) {
            Text("Title").tag(0)
            Text("Date").tag(1)
        }
        .pickerStyle(SegmentedPickerStyle())
        .onChange(of: sortType) { value in
            sortType = value

            if sortType == 0 {
                sortDescriptor = NSSortDescriptor(keyPath: \Test.title, ascending: true)
            } else {
                sortDescriptor = NSSortDescriptor(keyPath: \Test.date, ascending: true)
            }
        }

        List {
            ForEach(items) { item in
                let dateString = itemFormatter.string(from: item.date!)
                HStack {
                    Text(item.title!)
                    Spacer()
                    Text(dateString)
                }
            }
        }

        .onAppear(perform: {
            if items.isEmpty {
                let newEntry1 = Test(context: self.viewContext)
                newEntry1.title = "Apple"
                newEntry1.date = Date(timeIntervalSince1970: 197200800)

                let newEntry2 = Test(context: self.viewContext)
                newEntry2.title = "Microsoft"
                newEntry2.date = Date(timeIntervalSince1970: 168429600)

                let newEntry3 = Test(context: self.viewContext)
                newEntry3.title = "Google"
                newEntry3.date = Date(timeIntervalSince1970: 904903200)

                let newEntry4 = Test(context: self.viewContext)
                newEntry4.title = "Amazon"
                newEntry4.date = Date(timeIntervalSince1970: 773402400)

                if self.viewContext.hasChanges {
                    try? self.viewContext.save()
                }
            }
        })
    }
}

private let itemFormatter: DateFormatter = {
    let formatter = DateFormatter()
    formatter.dateStyle = .short
    formatter.timeStyle = .none
    return formatter
}()

When I change
@FetchRequest(sortDescriptors: [NSSortDescriptor(keyPath: \Test.title, ascending: true)], animation: .default) private var items: FetchedResults<Test>
to
@FetchRequest(sortDescriptors: [sortDescriptor], animation: .default) private var items: FetchedResults<Test>
the error "Cannot use instance member 'sortDescriptor' within property initializer; property initializers run before 'self' is available" appears.
I also tried to store the NSSortDescriptor in a UserDefault and create an init that creates it's own FetchRequest.. still no dynamic sorting...
Anyone a pointer where to look to solve this problem?
Whole project found here: https://github.com/l1ghthouse/FRDSD

A: Solved! Thanks to Asperi pointing to this QA: https://stackoverflow.com/a/59345830/12299030
import SwiftUI
import CoreData

struct ContentView: View {
    @Environment(\.managedObjectContext) private var viewContext

    @AppStorage("firstLaunch") var firstLaunch: Bool = true
    @State var sortDescriptor: NSSortDescriptor = NSSortDescriptor(keyPath: \Test.title, ascending: true)
    @State private var sortType: Int = 0

    var body: some View {
        Picker(selection: $sortType, label: Text("Sort")) {
            Text("Title").tag(0)
            Text("Date").tag(1)
        }
        .pickerStyle(SegmentedPickerStyle())
        .onChange(of: sortType) { value in
            sortType = value

            if sortType == 0 {
                sortDescriptor = NSSortDescriptor(keyPath: \Test.title, ascending: true)
            } else {
                sortDescriptor = NSSortDescriptor(keyPath: \Test.date, ascending: true)
            }
        }

        ListView(sortDescripter: sortDescriptor)

        .onAppear(perform: {
            if firstLaunch == true {
                let newEntry1 = Test(context: self.viewContext)
                newEntry1.title = "Apple"
                newEntry1.date = Date(timeIntervalSince1970: 197200800)

                let newEntry2 = Test(context: self.viewContext)
                newEntry2.title = "Microsoft"
                newEntry2.date = Date(timeIntervalSince1970: 168429600)

                let newEntry3 = Test(context: self.viewContext)
                newEntry3.title = "Google"
                newEntry3.date = Date(timeIntervalSince1970: 904903200)

                let newEntry4 = Test(context: self.viewContext)
                newEntry4.title = "Amazon"
                newEntry4.date = Date(timeIntervalSince1970: 773402400)

                if self.viewContext.hasChanges {
                    try? self.viewContext.save()
                }

                firstLaunch = false
            }
        })
    }
}

struct ListView: View {
    @FetchRequest var items: FetchedResults<Test>
    @Environment(\.managedObjectContext) var viewContext

    init(sortDescripter: NSSortDescriptor) {
        let request: NSFetchRequest<Test> = Test.fetchRequest()
        request.sortDescriptors = [sortDescripter]
        _items = FetchRequest<Test>(fetchRequest: request)
    }

    var body: some View {
        List {
            ForEach(items) { item in
                let dateString = itemFormatter.string(from: item.date!)
                HStack {
                    Text(item.title!)
                    Spacer()
                    Text(dateString)
                }
            }
        }
    }
}

private let itemFormatter: DateFormatter = {
    let formatter = DateFormatter()
    formatter.dateStyle = .short
    formatter.timeStyle = .none
    return formatter
}()


text:
Q: Removing missing from ggplots bar chart I have been using the following code to generate a ggplots bar-chart of a particular variable:
    ggplot(RPSdata, aes(x = RF.Age)) +
  geom_bar(col="black",
           fill ="grey",
           alpha = .8) +
  (aes(y = (..count..)/sum(..count..))) +
             scale_y_continuous(labels=percent) +
  labs(title="Risk Factor - Age", x ="Estimate", y="Proportion of Total") +
  ggtitle("Risk Factor - Age") + theme(plot.title = element_text(hjust = 0.5)) +
  scale_x_discrete(labels = c("No", "Yes", "Not Sure", "Missing"))

I am happy with the result, but would also like to produce a version with the NAs/missing excluded, both from the chart and also from the calculations of the percentages in the Y axis. How do I do this?
Many thanks indeed
Data sample:
> dput(head(RPSdata, 5))
structure(list(ï..ID.Rank = c(NA_integer_, NA_integer_, NA_integer_,
NA_integer_, NA_integer_), Identifiable = c(0L, 0L, 0L, 0L, 0L), Population.Risk = structure(c(1L,
2L, 1L, 2L, 2L), .Label = c("1", "2", "3", "4", "5", "6"), class = "factor"),
    Personal.Risk = c(50, 50, 60, 70, 25), Comparative.Risk.Age = structure(c(3L,
    5L, 3L, 4L, 4L), .Label = c("1", "2", "3", "4", "5"), class = "factor"),
    Comparative.Risk.Current = structure(c(NA, 3L, NA, 4L, NA
    ), .Label = c("1", "2", "3", "4", "5"), class = "factor"),
    Comparative.Risk.Ex = structure(c(NA, NA, NA, NA, 3L), .Label = c("1",
    "2", "3", "4", "5"), class = "factor"), Score.Exposure = structure(c(1L,
    1L, 2L, NA, 1L), .Label = c("1", "2", "4", "5"), class = "factor"),
    RF.Age = structure(c(3L, 2L, 3L, NA, 2L), .Label = c("0",
    "1", "2"), class = "factor"), RF.Pollution = structure(c(3L,
    2L, 2L, NA, 1L), .Label = c("0", "1", "2"), class = "factor"),
    RF.Asbestos = structure(c(NA, 1L, 1L, NA, 1L), .Label = c("1",
    "2"), class = "factor"), RF.Asthma = structure(c(2L, 2L,
    2L, NA, 2L), .Label = c("0", "1", "2"), class = "factor"),
    RF.BMI = structure(c(3L, 2L, 2L, NA, 3L), .Label = c("0",
    "1", "2"), class = "factor"), RF.Gene = structure(c(3L, 2L,
    3L, NA, 1L), .Label = c("0", "1", "2"), class = "factor"),
    RF.COPD = structure(c(2L, 2L, 2L, NA, 3L), .Label = c("0",
    "1", "2"), class = "factor"), RF.History = structure(c(1L,
    2L, 2L, NA, 3L), .Label = c("0", "1", "2"), class = "factor"),
    RF.Diet = structure(c(3L, 2L, 2L, NA, 2L), .Label = c("0",
    "1", "2"), class = "factor"), RF.Radon = structure(c(3L,
    2L, 3L, NA, 3L), .Label = c("0", "1", "2"), class = "factor"),
    RF.Smoking = structure(c(2L, 2L, 2L, NA, 2L), .Label = c("0",
    "1", "2"), class = "factor"), RF.Second.Smoke = structure(c(2L,
    2L, 2L, NA, 2L), .Label = c("0", "1", "2"), class = "factor"),
    Survival.One.Year = c(90, 50, 70, 80, 75), Survival.Five.Year = c(50,
    NA, 50, NA, 50), Survival.Ten.Year = c(20, NA, 15, NA, 25
    ), Worry.Frequency = structure(c(1L, 4L, 2L, 2L, 3L), .Label = c("1",
    "2", "3", "4"), class = "factor"), Worry.Intensity = structure(c(4L,
    4L, 3L, 3L, 3L), .Label = c("1", "2", "3", "4"), class = "factor"),
    Mental.Health.One = structure(c(4L, 4L, 2L, 4L, 3L), .Label = c("0",
    "1", "2", "3"), class = "factor"), Mental.Health.Two = structure(c(3L,
    4L, 2L, 3L, 2L), .Label = c("0", "1", "2", "3"), class = "factor"),
    Mental.Health.Three = structure(c(3L, 4L, 2L, 4L, 4L), .Label = c("0",
    "1", "2", "3"), class = "factor"), Mental.Health.Four = structure(c(4L,
    4L, 2L, 4L, 4L), .Label = c("0", "1", "2", "3"), class = "factor"),
    PHQ4 = c(10L, 12L, 4L, 11L, 9L), PHQ4.Anx = c(5L, 6L, 2L,
    5L, 3L), PHQ4.Dep = c(5L, 6L, 2L, 6L, 6L), PHQ4.Bin = c(3L,
    3L, 1L, 3L, 3L), Dep.Bin = c(1L, 1L, 0L, 1L, 1L), Anx.Bin = c(1L,
    1L, 0L, 1L, 1L), Survival.Complete.Sense = c(1L, 0L, 1L,
    0L, 1L), Survival.Semi.Sense = c(1L, 1L, 1L, 1L, 1L), PLCO.actual = c(NA_real_,
    NA_real_, NA_real_, NA_real_, NA_real_), Age = c(NA_integer_,
    NA_integer_, NA_integer_, NA_integer_, NA_integer_), Sex = c(NA,
    NA, NA, NA, NA), Female = c(NA_integer_, NA_integer_, NA_integer_,
    NA_integer_, NA_integer_), Ethnicity = structure(c(NA_integer_,
    NA_integer_, NA_integer_, NA_integer_, NA_integer_), .Label = c(" ",
    "Any Other Ethnic Group", "Asian/Asian Brit - Pakistani",
    "Black/Blk Brit-Any oth Blk b/g", "Black/Blk Brit-Caribbean",
    "Mixed-White & Black African", "Not Known", "Not Stated",
    "White - any other White b/g", "White - British", "White - Irish"
    ), class = "factor"), Ethnicity.Code = c(NA_integer_, NA_integer_,
    NA_integer_, NA_integer_, NA_integer_), Education = c(NA,
    NA, NA, NA, NA), Education.Code = c(NA_integer_, NA_integer_,
    NA_integer_, NA_integer_, NA_integer_), Pack.Years = c(NA_integer_,
    NA_integer_, NA_integer_, NA_integer_, NA_integer_), Previous.condition = structure(c(NA_integer_,
    NA_integer_, NA_integer_, NA_integer_, NA_integer_), .Label = c(" ",
    "Angina", "Asthma", "Chronic kidney disease", "COPD", "Diabetes",
    "Heart attack", "Heart failure", "High blood pressure", "High cholesterol",
    "Lung or pulmonary fibrosis", "Mini-stroke (TA)", "None",
    "Peripheral vascular disease/Claudication", "Pneumonia",
    "Rheumatoid arthritis", "Stroke", "Tuberculosis or TB"), class = "factor"),
    Previous.condition.code = c(NA_integer_, NA_integer_, NA_integer_,
    NA_integer_, NA_integer_), Prevous.condition.any = c(NA_integer_,
    NA_integer_, NA_integer_, NA_integer_, NA_integer_), Asbestos = structure(c(NA_integer_,
    NA_integer_, NA_integer_, NA_integer_, NA_integer_), .Label = c(" ",
    "no", "no (but high risk occupation)", "yes"), class = "factor"),
    Asbestos.code = c(NA_integer_, NA_integer_, NA_integer_,
    NA_integer_, NA_integer_), BMI = c(NA_real_, NA_real_, NA_real_,
    NA_real_, NA_real_), Family.Lung.Cancer = c(NA_integer_,
    NA_integer_, NA_integer_, NA_integer_, NA_integer_), Personal.Cancer.History = c(NA_integer_,
    NA_integer_, NA_integer_, NA_integer_, NA_integer_), Smoking.status.direct = structure(c(NA_integer_,
    NA_integer_, NA_integer_, NA_integer_, NA_integer_), .Label = c(" ",
    "current smoker", "former smoker"), class = "factor"), Smoking.status.directandderived.code = c(NA_integer_,
    NA_integer_, NA_integer_, NA_integer_, NA_integer_), Comparative.sense = structure(c(4L,
    2L, 4L, 2L, 3L), .Label = c(" ", "Anon Current", "Anon Ex",
    "Blank", "Completed Both", "Current Completed as Ex", "Current Correct",
    "Ex Completed Current", "Ex Correct"), class = "factor"),
    Valid.Comparative.Smoke = c(0L, 1L, 0L, 1L, 1L), PLCO_Quartiles = c(NA_integer_,
    NA_integer_, NA_integer_, NA_integer_, NA_integer_), filter_. = c(0L,
    0L, 0L, 0L, 0L), Education_3Groups = c(NA_integer_, NA_integer_,
    NA_integer_, NA_integer_, NA_integer_), Education_2Groups = c(NA_integer_,
    NA_integer_, NA_integer_, NA_integer_, NA_integer_), PersonalRisk_Quintiles = c(5L,
    5L, 5L, 5L, 3L), PersonalRisk_Quintiles_NHSOnly = c(5L, 5L,
    5L, 5L, 4L), BMI_Cat = c(NA_integer_, NA_integer_, NA_integer_,
    NA_integer_, NA_integer_), Age_mean = c(NA_integer_, NA_integer_,
    NA_integer_, NA_integer_, NA_integer_), CompRiskAge_3groups = c(2L,
    3L, 2L, 3L, 3L), Asbestos_2groups = c(NA_integer_, NA_integer_,
    NA_integer_, NA_integer_, NA_integer_), RF.History_binary = c(0L,
    1L, 1L, NA, 0L), RF.Age_Binary = c(0L, 1L, 0L, NA, 1L), RF.Pollution_Binary = c(0L,
    1L, 1L, NA, 0L), RF.Asbestos_Binary = c(NA, 1L, 1L, NA, 1L
    ), RF.Gene_Binary = c(0L, 1L, 0L, NA, 0L), RF.COPD_Binary = c(1L,
    1L, 1L, NA, 0L), RF.Radon_Binary = c(0L, 1L, 0L, NA, 0L),
    RF.Smoking_Binary = c(1L, 1L, 1L, NA, 1L), RF.Second.Smoke_Binary = c(1L,
    1L, 1L, NA, 1L), RF.BMI_Binary = c(0L, 0L, 0L, NA, 0L), RF.Diet_Binary = c(0L,
    0L, 0L, NA, 0L), RF.Asthma_Binary = c(0L, 0L, 0L, NA, 0L),
    PopulationRisk_correct = c(0L, 0L, 0L, 0L, 0L), PopRisk_3groups = c(3L,
    3L, 3L, 3L, 3L), Worry.Freq_Any = c(0L, 1L, 1L, 1L, 1L),
    Worry.Intensity_Any = c(1L, 1L, 1L, 1L, 1L), PLCOthreshold = c(NA_integer_,
    NA_integer_, NA_integer_, NA_integer_, NA_integer_), ComparativeMulti_High = c(1L,
    2L, 1L, 2L, 2L), ComparativeMulti_Low = c(1L, 1L, 1L, 1L,
    1L)), row.names = c(NA, 5L), class = "data.frame")

A: This would help:
#Code
ggplot(subset(RPSdata,!is.na(RF.Age)), aes(x = RF.Age)) +
  geom_bar(col="black",
           fill ="grey",
           alpha = .8) +
  (aes(y = (..count..)/sum(..count..))) +
  scale_y_continuous(labels=scales::percent,limits = c(0,1)) +
  geom_text(stat='count', aes(label=..count..),vjust=-0.25)+
  labs(title="Risk Factor - Age", x ="Estimate", y="Proportion of Total") +
  ggtitle("Risk Factor - Age") + theme(plot.title = element_text(hjust = 0.5)) +
  scale_x_discrete(labels = c("No", "Yes", "Not Sure", "Missing"))


text:
Q: MYSQL Query Optimization- Joins/Unions vs. table query This is somewhat of a conceptual question. In terms of query optimization and speed, I am wondering which route would have the best performance and be the fastest. Suppose I am using JFreeChart (this bit is somewhat irrelevant). The entire idea of using JFreeChart with a MYSQL database is to query for two values, an X and a Y. Suppose the database is full of many different tables, and usually, the X and the Y come from two different tables. Would it be faster, in the query for the chart, to use joins and unions to get the two values...or... first create a table with the joined/union values, and then run queries on this new table (no joins or unions needed)? This would all be in one code mind you. So, overall: joins and unions to get X and Y values, or create a temporary table joining the values and then querying the chart with those.

A: It would, of course, be faster to pre-join the data and select from a single table than to perform a join. This assumes that you're saving one lookup per row and are properly using indexes in the first place.
However, even though you get performance improvements from dernormalization in such a manner, it's not commonly done. A few of the reason why it's not common include:

*

*Redundant data takes up more space

*With redundant data, you have to update both copies whenever something changes

*JOINs are fast

JOINs on multiple rows can improve (they don't always require a lookup per row) with such things as the new Batched Key Access joins in MySQL 5.6, but it only helps with some queries, hence you have to tell MySQL which join type you want. It's not automatic.


text:
Q: GTM Cookies consent - current state in custom HTML as variable? I have cookie consent in GTM and every built-in tag work well (Analytics, etc). I know that I can make condition for "Custom HTML" via "Require additional consent for tag to fire" but I need add custom HTML as:
<script type="text/javascript">
var xyzSymbol = {{Symbol of order}};
var xyzPrice = {{Total price of order}};
var hasAdStorageConsent = ?????  // true or false if has user "ad_storage"
</script>
<script type="text/javascript" src="//www.xyz.cz/rs/static/rc.js"></script>

Does exists a variable with current ad_storage state? Or has a callback for it? or something etc.
Thank you for any help.


text:
Q: SSIS Execute SQL Task, Rows affected on MERGE Statement (Oracle & SQL Server) I have an SSIS package where I need to execute a MERGE statement with an Execute SQL Task. I need to do this both on an Oracle DB and a SQL Server 2012 DB. My question is, how can I get the number of rows affected as a ResultSet so I can save it on a variable in the SSIS package? I don't need to know if updated or inserted, and I don't want to create a procedure on Oracle because the MERGE is dynamic and calculated in the package through expressions in variables. I just want to get the value of the rows affected back.
P.S.: If I can't use the Execute SQL Task, can i at lease use a Script to run the MERGE? The problem is, from what I read, that ExecuteNonQuery() on Oracle does not return the rows affected with a MERGE. And I couldn't find any information for SQL Server. Can anyone help?
Thanks in advance.
UPDATE: I just checked a script with ExecuteNonQuery() for SQL Server, and it did return the number or rows affected. It would however be better if I could avoid the script and use the Execute SQL Task, but how do I get the rows affected as a ResultSet?

A: On SQL Server you can use the OUTPUT clause with the merge statement. Here's something for you to read up.
And for Oracle, read this:  PLSQL: Get number of records updated vs inserted when a merge statement is used
https://www.simple-talk.com/sql/learn-sql-server/implementing-the-output-clause-in-sql-server-2008/


text:
Q: Remember Me option with devise rails3 I have used devise 2.2.4, On login page remember_me option is not working. It is also not throwing any error, neither it is saving anything in remember_at field in user table.
class User < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :token_authenticatable, :confirmable,
  # :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,:token_authenticatable,:recoverable,      :rememberable, :trackable, :validatable#,:authentication_keys => [:login]

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation, :remember_me, :username, :dealer_detail_id
  validates :username, :password, :password_confirmation, :presence => true
  validates_uniqueness_of :username #, :if => :email_changed?

end


text:
Q: How does updating embedded documents work in MongoDB? This is probably an obvious question, but I can't find a clear answer to it.
In MongoDB, suppose I embed document food into document super_market. When I make a change to the food document, will the embedded document in super_market automatically get updated?

A: Your question denotes a structure like this:
example Super_market:
{ "super_market_name": "SuperMart",
  "address": "1 Main Street",
  "food": { "food_name":"apple" }
}

It sounds like you're asking about a food document that is separate from the super_market and linked to it.
If you embed the 'food' document as above, the embedded document is the one that you would be altering.  It doesn't exist in a separate location that you would modify.  If you update super_market.food, the embedded document is the one (and only) that will be affected.


text:
Q: UILabel text is not updating on iPad We have a delegate method which will be called for approximately 20 times in a second. In the delegate method we are updating our UILabel which represents the counter like below mentioned code:
    - (void) counterUpdated:(NSString *) value
    {
        lblCounter.text = [NSString stringWithString:value];

        // [[NSRunLoop mainRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.5]];

        // [lblCounter setNeedDisplay];

    }

I read similar problems in stack overflow and I implemented the solutions over there and I checked with keeping [lblCounter setNeedDisplay]; method and [[NSRunLoop mainRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.5]]; after updating lblCounter, but it is not working well as expected.
Any pointers?

A: Try using Grand Central Dispatch in order to run this in the main thread:
dispatch_async(dispatch_get_main_queue(), ^{
    lblCounter.text = value;
});


text:
Q: python rolling cumulative return with groupby I have the following dataframe and would like to get the rolling cumulative return over the last lets say for this example 2 periods grouped by an identifier. For my actual case I need a longer period, but my problem is more with the groupby:
        id        return
2012     1           0.5
2012     2           0.2
2013     1           0.1
2013     2           0.3

The result should look like this:
        id        return        cumreturn
2012     1           0.5         0.5
2012     2           0.2         0.2
2013     1           0.1         0.65
2013     2           0.3         0.56

It is import that the period is rolling. I have the following formula so far:
df["cumreturn"] = df.groupby("id")["return"].fillna(0).pd.rolling_apply(df,5,lambda x: np.prod(1+x)-1)

However, I get the following error: AttributeError: 'Series' object has no attribute 'pd'. I know how to get the rolling cumulative return. However, I just cant figure out how to combine it with groupby.

A: Let's try this:
df_out = (df.set_index('id', append=True)
            .assign(cumreturn=df.groupby('id')['return'].rolling(2,min_periods=1)
                                .apply(lambda x: np.prod(1+x)-1)
            .swaplevel(0,1)).reset_index(1))

Output:
      id  return  cumreturn
2012   1     0.5       0.50
2012   2     0.2       0.20
2013   1     0.1       0.65
2013   2     0.3       0.56


text:
Q: Course Enrolment Date set to 1/1/1970 I have registered a new account and have an Enrolment key for the course.
I finished the course and after that I run cron.php  so that the results will reflect the report.
But everytime I do that the Enrolment Date in the Report will be set to 1/1/1970
I looked up in the database and checked the mdl_course_completions and the timeenrolled is set to 0.
I changed the data and it changes what is showing in the report in the Enrolment Date Column.
I created again a new account with the Enrolment key and finished a course and the Enrolment Date is again set to 1/1/1970
Is there a way to fix that? Please help. Thanks.
Note: The users that I have registered are using Enrolment key to enrol in a course.
I am using Moodle version: Moodle 3.0.7 (Build: 20161114)


text:
Q: How to initialize a discriminated union from another discriminated union in F#? With the following F# definitions, how can the Model be initialized?
open System
open System.Windows

type ContactDetail = { Id: Guid; Name: string; Content: string; Text: string }
type Internet      = { Id: Guid; Name: string; Content: string; Text: string }
type PhoneNumber   = { Id: Guid; Name: string; Content: string; Text: string }
type Address       = { Id: Guid; Name: string; Content: string; Text: string }

    module Testing =
        type Details =
            | ContactDetail of ContactDetail
            | Internet      of Internet
            | PhoneNumber   of PhoneNumber
            | Address       of Address

        let contactDetail  : ContactDetail = {Id=Guid.NewGuid(); Name="Contact Detail"; Content="Content for Contact Detail"; Text="here is the contact detail text" }
        let internet       : Internet = {Id=Guid.NewGuid(); Name="Internet";       Content="Content for Internet";       Text="here is the internet text" }
        let phoneNumber    : PhoneNumber =  {Id=Guid.NewGuid();Name="Phone Number";   Content="Content for phone number";   Text="here is the phone number text" }
        let address        : Address = {Id=Guid.NewGuid(); Name="Address";        Content="Content for Address";        Text="here is the Address text" }

        let details   = [ContactDetail contactDetail
                         Internet      internet
                         PhoneNumber   phoneNumber
                         Address       address
                         ]

        type DetailsWithId = DetailsWithId of Details * Guid

        type Model = {
          ClickCount: int
          Message: string
          Details: DetailsWithId list
        }

More specifically, I need Details of the Model to be a list (or seq). Is type DetailsWithId already a list because of type Details?
TIA

A: As explained in the comment, a value of your Details type represents just a single detail - one of the several possible details listed. A value of type Details list is a list of details (which can possibly be empty, or it can include multiple instances of the same detail type).
If this is not what you need, then it'd be good to find a model that better captures the structure of your domain.
If this is what you want, then I would still change two things about your data types:

*

*First, I'd rethink how you're storing IDs. In your model, you have Id field in the individual records, but then, again, in the DetailsWithId type. I suppose the question is how to automatically copy the ID from the record to the ID in the DetailsWithId type. There is no easy way to do this, but it's better to design your types so that you do not need to do this.

*Second, your four record types i.e. ContactDetail, Internet, etc. are all the same. Wouldn't it be easier to use just one type?
I think working with your data would be a lot easier (unless there is something about your domain that you did not document in the question), if you used a type definition like this:
type DetailKind =
    | ContactDetail
    | Internet
    | PhoneNumber
    | Address

type Detail =
  { Id: Guid
    Name: string
    Content: string
    Text: string
    Kind: DetailKind }

type Details = Detail list


text:
Q: What do you call the software used in airplane that allow the airplane to fly even if its shape wouldn't allow it to fly? What do you call the software used in airplane that allow the airplane to fly even with a bad shape? I remember there was a name, but I think I forgot it. Does the term apply to other things than airplane? I think modern plane cannot fly without the software.

A: I am no expert in aeronautics or aerodynamics but I believe the system you may be referring to is called "Fly-by-wire" or more narrowly "Digital Fly-by-wire" or more accurately a "Digital flight control system"
See this Wikipedia article for more information.
Digital flight control systems enable inherently unstable combat aircraft, such as the Lockheed F-117 Nighthawk and the Northrop Grumman B-2 Spirit flying wing to fly in usable and safe manners.