text:
Q: What is the best way to call a native DLL, from Unity3d? Hi Everyone I am having some issues on unity3d pro, perhaps someone that has work with DLL native plugins can shed some light as to what I am doing wrong.
To begin I will explain what my goal is. I have a COM object from Siemens PLCSim software, I've gotten that to work fine with Visual Studio. Below is the test code.
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public S7PROSIMLib.S7ProSim PLCSimConn = new S7PROSIMLib.S7ProSim();

        public Form1()
        {
            InitializeComponent();
        }

        private void button_Connect_Click(object sender, EventArgs e)
        {
            PLCSimConn.Connect();
            label_CPUState.Text = PLCSimConn.GetState();
            label_ScanMode.Text = PLCSimConn.GetScanMode().ToString();
        }
    }
}

I created a unity3d project to test the same. I imported the dll to my assets, and I am able to call the methods and instances of S7PROSIMLibfrom my c# script. COM Api here, https://cache.industry.siemens.com/dl/files/855/1139855/att_29424/v1/S7WSPSCB.pdf
using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;
using S7PROSIMLib;

public class TestNative : MonoBehaviour {

    public S7ProSimClass ps;

    // Use this for initialization
    void Start () {

        ps = new S7ProSimClass ();
        ps.Connect ();
        Debug.Log (ps.GetState());

    }

}

Now at run time I get the following:
COMException
System.Runtime.InteropServices.Marshal.ThrowExceptionForHR (Int32 errorCode) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs:1031)
System.__ComObject.Initialize (System.Type t) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/__ComObject.cs:103)
(wrapper remoting-invoke-with-check) System.__ComObject:Initialize (System.Type)
Mono.Interop.ComInteropProxy.CreateProxy (System.Type t) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/Mono.Interop/ComInteropProxy.cs:108)
System.Runtime.Remoting.RemotingServices.CreateClientProxyForComInterop (System.Type type) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Runtime.Remoting/RemotingServices.cs:588)
System.Runtime.Remoting.Activation.ActivationServices.CreateProxyForType (System.Type type) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Runtime.Remoting.Activation/ActivationServices.cs:234)
TestNative.Start () (at Assets/Scripts/TestNative.cs:13)

I've watched the unity3d plugin tutorial https://www.youtube.com/watch?v=DfRYLwG1Bug which doesn't call a third party DLL.
I have read the following: https://msdn.microsoft.com/en-us/library/ms973872.aspx which has a lot of good information on unmanaged and managed DLL's.
Based on the following snippet from the link above:
Calling COM APIs
There are two ways to call COM components from managed code: through COM interop (available in all managed languages) or through C++ interop (available in C++).
For calling OLE Automation-compatible COM components, the suggestion is to use COM interop. The CLR will take care of COM component activation and parameter marshaling.
For calling COM components based on Interface Definition Language (IDL), the suggestion is to use C++ interop. The C++ layer can be very thin and the rest of the managed code can be written in any managed language. COM interop relies on information from type libraries to make correct interop calls, but type libraries typically do not contain all the information present in IDL files. Using C++ interop solves this problem by allowing direct access to these COM APIs.
I believe I already did the COM interop shown on my unity c# script above. And that didn't work. My other option is through C++ interop, but I haven't found any example online. Most of the examples are simple without calling a COM object or any other third party DLL. I would appreciate if someone can direct me in the right way. Basically it comes down to what is the best way to go about this, with minimal re writing of methods? Thank you!
Edit1: I watched this video on youtube from someone getting it to work, but I haven't been able to get a response from him. At least I know that it should work on unity3d. https://www.youtube.com/watch?v=EGFMjUJN7ZU
Edit2: Unity3d - Failed to load 'Assets/Plugins/QCARWrapper.dll' Will try with 32bit Editor as this post suggests.

A: For anyone that might need help with this. Siemens PLCSim COM type library only works with 32bit Unity Editor.
The solution was actually quite easy after lots of trial and error, and many more reading through the forums and what not. I used tlbimp.exe to generate a type library DLL, then I placed that into the assets/plugins folder also note on unity3d editor properties that the new DLL is treated as managed code. Note that this particular DLL doesn't work on 64bit Unity Editor and it threw a COMException. However the new type library DLL works fine in 32bit Unity Editor, I imagine that somewhere in the DLL there is an instruction specifying to work only in 32bit.
I documented everything on a repository here https://github.com/fredz0003/myS7ProSimLib I also placed the managed DLL for future use so you don't go to the trouble I went.
Below is a sample code:
using UnityEngine; using myS7ProSimLib;

public class TestNative : MonoBehaviour {

    /*
    * Used tlbimp.exe to generate library DLL
    * place new generated DLL on assets/plugins
    * also note that the DLL is treated as managed code
    */
    public S7ProSimClass ps;
    public bool input_0_0;

    void Start () {
        ps = new S7ProSimClass();

        ps.Connect();
        print("State " + ps.GetState());
        ps.SetScanMode(ScanModeConstants.ContinuousScan);

        // Here we pass the ref as an obj, since WriteInputPoint method
        // can take bit, word, dwords, as addresses ref obj can take the
        // for of bool, int, float, etc.
        object refInput0_0 = input_0_0;

        ps.WriteInputPoint(0, 0, ref refInput0_0);  }    }


text:
Q: Mysql total price, sum, and distinct(product) I have following mysql table:
product_id   selling_price
10            200
10            200
11            100
11            100
13            300

How can I return something like below
product_id    total    total_selling_price
10            2        400
11            2        200
13            1        300

A: SELECT  product_ID,
        COUNT(*) totalCount,
        SUM(selling_price) total_selling_price
FROM    TableName
GROUP   BY product_ID

*

*SQLFiddle Demo

*List of GROUP BY (Aggregate) Functions
OUTPUT
╔════════════╦════════════╦═════════════════════╗
║ PRODUCT_ID ║ TOTALCOUNT ║ TOTAL_SELLING_PRICE ║
╠════════════╬════════════╬═════════════════════╣
║         10 ║          2 ║                 400 ║
║         11 ║          2 ║                 200 ║
║         13 ║          1 ║                 300 ║
╚════════════╩════════════╩═════════════════════╝

A: You need group by aggregate function with count and sum.
Try this.
select   product_id, count(product_id), sum(selling_price)
from     tablename
group by product_id;

A: Giving it a shot, not tested locally
SELECT  product_id,
        COUNT(product_id),
        SUM(Amount)
FROM    yourTable
GROUP BY    product_id

redpajama_set_name: RedPajamaStackExchange


text:
Q: Last Listview item removed instead of selected one I have a listView, with items.
When I longClick on one of them, a delete button appears. But when I press it, it's the last item which is deleted and not the one I pressed ...
Here my code :
appList0 = new ArrayList<Appreciation>();
String[] app0 = settings.getString("App0", "aucune remarque").toString().split(";");
for (String app : app0)
    appList0.add(new Appreciation(app));
dataAdapter0 = new MyCustomAdapter(this,R.layout.affichageitem, appList0);
ListView listView0 = (ListView) findViewById(R.id.listView0);
listView0.setAdapter(dataAdapter0);

and the adapter
private class MyCustomAdapter extends ArrayAdapter<Appreciation> {

          private ArrayList<Appreciation> appList;

          public MyCustomAdapter(Context context, int textViewResourceId,ArrayList<Appreciation> appList) {
              super(context, textViewResourceId, appList);
              this.appList = new ArrayList<Appreciation>();
              this.appList.addAll(appList);
          }

          private class ViewHolder {
           TextView text;
           ImageButton button;
          }

          @Override
          public View getView(final int position, View convertView, ViewGroup parent) {

              ViewHolder holder=null;
              LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);

               if (convertView == null) {
                   convertView = vi.inflate(R.layout.affichageitem, null);
                   holder = new ViewHolder();
                   holder.text = (TextView) convertView.findViewById(R.id.textview);
                   holder.button = (ImageButton) convertView.findViewById(R.id.editButton);
                   convertView.setTag(holder);
               }
               else {
                   holder = (ViewHolder) convertView.getTag();
                   holder.button.setVisibility(View.INVISIBLE);
               }

               holder.text.setOnClickListener( new View.OnClickListener() {
                     public void onClick(View v) {
                          TextView tv = (TextView) v ;
                          //To DO
                         }
                });

               holder.button.setOnClickListener( new View.OnClickListener() {
                     public void onClick(View v) {
                            ListView listView0=(ListView)findViewById(R.id.listView0);

                            Log.e("DELETING : ",appList0.get(position).getValue());
                            appList0.remove(position);   //DELETING HERE
                            dataAdapter0.notifyDataSetChanged();

                            ImageButton iB = (ImageButton) v ;
                            iB.setVisibility(View.INVISIBLE);
                     }
                });

               holder.text.setOnLongClickListener( new View.OnLongClickListener() {
                     public boolean onLongClick(View v) {
                          TextView tv = (TextView) v ;
                          ImageButton editButton = (ImageButton) ((ViewGroup) v.getParent()).findViewById(R.id.editButton);
                          editButton.setVisibility(View.VISIBLE);
                          return true;
                         }
                });

               Appreciation currentApp = appList.get(position);
               holder.text.setText(currentApp.getValue());
               holder.button.setTag(currentApp);
               return convertView;

          }

         }

A: Since getView() runs for each item, you need to set a tag on the button so it can get the correct position.
Something like, before
// use position for the tag param
holder.button.setTag(position);
holder.button.setOnClickListener( new View.OnClickListener() {

then retrieve the tag from the View that was clicked and use that
 holder.button.setOnClickListener( new View.OnClickListener() {
     public void onClick(View v) {
     int position = ((Button)v).getTag();  // cast the view to Button and get the tag

      Log.e("DELETING : ",appList0.get(position).getValue());
       appList0.remove(position);   //DELETING HERE
       dataAdapter0.notifyDataSetChanged();

A: I think you have some issues with using appList0 and appList. try these changes may help:
                    Log.e("DELETING : ",appList0.get(position).getValue());
                    appList0.remove(position);   //DELETING HERE
                    dataAdapter0.notifyDataSetChanged();

to
                    Log.e("DELETING : ",appList.get(position).getValue());
                    appList.remove(position);   //DELETING HERE
                    MyCustomAdapter.this.notifyDataSetChanged();

change
      public MyCustomAdapter(Context context, int textViewResourceId,ArrayList<Appreciation> appList) {
          super(context, textViewResourceId, appList);
          this.appList = new ArrayList<Appreciation>();
          this.appList.addAll(appList);
      }

to
      public MyCustomAdapter(Context context, int textViewResourceId,ArrayList<Appreciation> appList) {
          super(context, textViewResourceId, appList);
          this.appList = appList;
      }


text:
Q: SQL Server difference between dates
I need to make a query that will compare the dates with the same 'ID_2'
If the difference between dates in column "ProdDateTime" is more than 7 and difference between dates in column "Sold" is more than 1 than it should show this rows.
here's an example:
the difference between row #12 and #13 row with ID_2=444 is more than 7 in column ProdDateTime and is more than 1 in column Sold, that's why it should show this row as an error and all the following (14,15) because they have the same error.
P.S. I used row_number and dense_rank to make ID_1 and ID_2 columns accordingly.
Do you have any tips on how to do so?
Thank you all in advance!

A: I assumed that date in "ProdDateTime" column is always in increasing order. So, here we need to compare dates from previous row value and next row value of ProdDateTime column. I have used LAG and LEAD analytical functions to solve this problem. It's just a hint for you, I have implemented for only single condition below, Maybe it works for you:-
    ;WITH ResultData
    AS
    (
        SELECT *
            ,LEAD(ProdDateTime)  OVER (PARTITION BY ID_2 ORDER BY ID_2 ) AS Lead
            ,LAG(ProdDateTime)  OVER (PARTITION BY ID_2 ORDER BY ID_2 ) AS Lag
            ,DATEDIFF(DAY, ProdDateTime, LEAD(ProdDateTime)  OVER (PARTITION BY ID_2 ORDER BY ID_2 )) AS LeadDiff
            ,DATEDIFF(DAY, LAG(ProdDateTime)  OVER (PARTITION BY ID_2 ORDER BY ID_2 ), ProdDateTime) AS LagDiff
        FROM tb
    )

    SELECT *
    FROM ResultData
    WHERE LeadDiff > 1 OR LagDiff > 1

If you are unaware from above functions, Please do search for same.
Best of luck!

A: You can select next and previous rows as the below.
SELECT
    * -- Your DATEDIFF operations
FROM
    Tbl CurrentRow LEFT JOIN
    Tbl PreviousRow ON CurrentRow.ID_1 = (PreviousRow.ID_1 + 1)
                       CurrentRow.ID_2 = PreviousRow.ID_2
                   LEFT JOIN
    Tbl NextRow     ON CurrentRow.ID_1 = (NextRow.ID_1 - 1)
                       CurrentRow.ID_2 = NextRow.ID_2


text:
Q: How to get Standard Deviation of a single number in C# How to calculate standard deviation of a single decimal value, in C#
I do it in SAS code as the following:
std(x y m ) = xSTD YSTD mSDT;

A: It is simply 0 see the wiki article.

*

*Let X be the number

*Calculate EV of [x] which is x

*Subtract EV from each element in set which is [0]

*Take the average of [0] which is 0

*Take the square root of 0 which is 0


text:
Q: Why the promise data requested from server is undefined? I am trying to get values from an ASP .NET Core API and then display them in a html page using Angular and Typescript. The request and response from server are working correctly. The response is an object and i tried to use a model class to get the values from the response.
The problem is when i try to display the values, all of values are undefined. I think the problem is with the Promise.
This is the response i got from server:
Id: 1
Name: "asd"
Description: "asd"
Syntax: "Typescript"
IdentityString: "karma"
LastModified: "2020-01-05T00:51:00"
Content: "asd"
FileId: 1
File: null

And there is the code:
fileshare.ts
export class FileShareComponent implements OnInit {

    constructor(
    private route: ActivatedRoute,
    private service: UserService,
    private http: HttpClient
    ) {}

  ngOnInit() {
    const file: string = this.route.snapshot.queryParamMap.get('file');

    this.http.get(this.service.BaseURL + '/Share?IdentityString=' + file)
            .toPromise()
            .then(res => this.service.sharedFormData = res as ShareModel);
            console.log(this.service.sharedFormData);
  }
}

ShareModel.ts
export class ShareModel {
    Id:number;
    Name: string;
    Description: string;
    Syntax: string;
    IdentityString:string;
    LastModified: string;
    Content: string;
    FileId: number;
}

service.ts
sharedFormData:ShareModel;

fileshare.html

Name:
{{service.sharedFormData.Name}}

Description:
{{service.sharedFormData.Description}}

Syntax:
{{service.sharedFormData.Syntax}}

LastModified:
{{service.sharedFormData.LastModified | date: "HH:mm dd/MM/yyyy"}}

Content:
{{service.sharedFormData.Content}}

A: Move console.log(this.service.sharedFormData); inside then().
Because right now it executes before response was received.
And it looks like your service.sharedFormData = undefined on the moment ngOnInit() is called. But I'm not sure... But if I'm right, then that's is the reason for error messages. Because this.service.sharedFormData = res happens much later. (The same thing as with console.log(this.service.sharedFormData)) But before that Angular already tries to render your HTML with service.sharedFormData = undefined


text:
Q: Grails MS SQLServer 2008 jdbc driver causes problems in tomcat What is the official way to use the microsoft jdbc driver for mssql in a grails application?
The general opinion that I found through googling is that I only have to drop the jar in the lib directory of the grails app. This works if I do a grails clean and grails compile --refresh-dependencies. But when I deploy on a real server I have two problems.
When redeploying there is this a warning in the logs.

24.05.2013 16:03:03 com.microsoft.sqlserver.jdbc.AuthenticationJNI
  WARNUNG: Failed to load the sqljdbc_auth.dll cause : no sqljdbc_auth in java.library.path

I'm not sure if its something to care about since its a warning. But I would like to have my logs clean and I have the dll in the lib directory of the application just as google is saying. Additionally on redeployment there are several messages like this that might relate to the first one:

24.05.2013 16:03:02 org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
  SCHWERWIEGEND: A web application created a ThreadLocal with key of type [org.codehaus.groovy.runtime.GroovyCategorySupport.MyThreadLocal] (value [org.codehaus.groovy.runtime.GroovyCategorySupport$MyThreadLocal@76fe8d1b]) and a value of type [null] (value [null]) but failed to remove it when the web application was stopped. To prevent a memory leak, the ThreadLocal has been forcibly removed.

And the last thing is that my coworker said, that she thinks the driver should not be installed on a per application basis but directly into tomcat. I actually don't know how to do this, but if I did it, this would cause a problem on the development machine since I don't know how to get grails run-app going without the driver in the applications lib directory.

A: You can still place the library in the lib folder of your project and just exclude this from the war generation.
You don't need to exclude the jar everytime you build your project, just follow this post tip.
In your Tomcat server the jar will be placed in the shared lib folder instead of each web application.
If after that you still get the warning about sqljdbc_auth.dll you will need to locate this file and add the folder in the Tomcat classpath (or copy to Tomcat lib folder).


text:
Q: Return from an event handling function I have two validation groups on my asp.net form.
I use the following C# code to prevent data from being submitted in case of invalid user input:
protected void btnAdd_Click(object sender, EventArgs e)
    {
        Page.Validate("g2");
        if (!Page.IsValid)
        {
            alert("fill the form with valid data");
            return;
        }
        //get user input and save them in database
        //in case of error, display error message
}

When I enter an invalid data into a text box in group "g2" and click button "btnAdd", it does not return from btnAdd_Click() as intended. Instead it seems to continue execution of statements following if(!Page.IsValid) block. Why is it so and how can it be fixed?


text:
Q: MediaPlayer button in my viewpager I am building an app with a viewpager horizontal swipe. all of the pager components function however I cannot get my button to play. There are no errors with the code, it just doesnt work. thanks for you help.
  package com.test.viewpager;
import android.app.Activity;
import android.content.Context;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class viewpager extends Activity {
public MediaPlayer mp = null;
/** Called when the activity is first created. */

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

    Button btn = (Button) findViewById(R.id.button1);
    OnClickListener listener = new OnClickListener(){
        public void onClick(View v) {
        if (mp == null) {
            mp = MediaPlayer.create(viewpager.this, R.raw.song1);
            mp.start();
            }else {
                mp.stop();
                mp = null;
            }
    }};

    if (btn != null)
        btn.setOnClickListener(listener);

                MyPagerAdapter adapter = new MyPagerAdapter();
    ViewPager myPager = (ViewPager) findViewById(R.id.myfivepanelpager);
    myPager.setAdapter(adapter);
    myPager.setCurrentItem(2);         }

public void farLeftButtonClick(View v)         {
    Toast.makeText(this, "Far Left Button Clicked", Toast.LENGTH_SHORT).show();
    }

public void farRightButtonClick(View v)         {
    Toast.makeText(this, "Far Right Elephant Button Clicked", Toast.LENGTH_SHORT).show();
    }
private class MyPagerAdapter extends PagerAdapter {
        public int getCount() {
            return 5;                 }
        public Object instantiateItem(View collection, int position) {
            LayoutInflater inflater = (LayoutInflater) collection.getContext()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            int resId = 0;
            switch (position) {
            case 0:
                resId = R.layout.page1;
                break;
                case 1:
                    resId = R.layout.page2;
                    break;
                    case 2:
                        resId = R.layout.page3;
                        break;
                        case 3:
                            resId = R.layout.page4;
                            break;
                            case 4:
                                resId = R.layout.page5;
                                break;                         }
            View view = inflater.inflate(resId, null);
            ((ViewPager) collection).addView(view, 0);
            return view;                 }
        @Override
        public void destroyItem(View arg0, int arg1, Object arg2) {
            ((ViewPager) arg0).removeView((View) arg2);                  }
        @Override
        public void finishUpdate(View arg0) {
            // TODO Auto-generated method stub
            }
            @Override
            public boolean isViewFromObject(View arg0, Object arg1) {
                return arg0 == ((View) arg1);                  }
            @Override
            public void restoreState(Parcelable arg0, ClassLoader arg1) {
                // TODO Auto-generated method stub
                }
            @Override
            public Parcelable saveState() {
                // TODO Auto-generated method stub
                return null;                 }
            @Override
            public void startUpdate(View arg0) {
                // TODO Auto-generated method stub
            }}
    }

Here is the main.xml
 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<android.support.v4.view.ViewPager
    android:layout_width="match_parent"
     android:layout_height="match_parent"
      android:id="@+id/myfivepanelpager"/>

 </LinearLayout>

here is one of the panes page3.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

 <Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/newbutton"
    android:layout_gravity= "center"

   />

A:
I cannot get my button to play. There are no errors with the code, it
  just doesnt work

That's because you're trying to inflate the button as part of the Activity's layout (main.xml). However, as you can already tell from the layouts you posted: that's not the case. The button is part of the 'page' that is displayed in the ViewPager; hence, move the button logic from the Activity's onCreate(...) to the PagerAdapter's instantiateItem(...).
That will yield something like this:
public Object instantiateItem(View collection, int position) {
    LayoutInflater inflater = (LayoutInflater) collection.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    // switch/case omitted for simplicity

    View view = inflater.inflate(resId, null);
    Button btn = (Button) findViewById(R.id.button1);
    if (btn != null) btn.setOnClickListener(new View.new OnClickListener(){
        @Override public void onClick(View v) {
            if (mp == null) {
                mp = MediaPlayer.create(viewpager.this, R.raw.song1);
                mp.start();
            } else {
                mp.stop();
                mp = null;
            }
        }
    });

    // add and return view etc.
}


text:
Q: Unlink Function Not... Unlinking So I have function that creates a file, exports data to it, lets the user download it, and then lets the user delete it. Everything works except for deleting it. I don't know if it's because the unlink function doesn't really work within a $_POST action or something else, but it'd be nice to know. I would just pass a variable to the header and have a script check for that variable in the header on load and then unlink the file from there as I've done that with success before, but the file name is dynamic, and the variables are lost when reloading the page, which the header always does (I suppose I could pass those variables you see through variables in the header, but I'd rather not if possible).
I wondered if those variables lost their value by this point in the script, but I know that can't be as they're just used a few lines before, and nothing is interrupting or changing them.
I also wondered about file permissions. I had to give _www permissions for the folder in order for the server to write to the folder, but I've checked permissions again, and _www (the server, apparently) has permissions to read, write, and execute. So it can't be permissions.
The die error does not display, either.
Lastly, I've tried removing those variables in the name of the file and just had fopen() create one with a static name and then tried to have unlink() delete it with the static name-- just to test to see if the variables changed or were lost for some reason-- but it still won't unlink with that static filename, either.
if (isset($_POST['delete'])) {
    unlink("exported-" .$result2 ."-alltime-" .$today .".csv") or die("Could not delete file! Oh noes!");
    }


text:
Q: Why doesn't strict aliasing rule apply to int* and unsigned*? In the C language, we cannot access an object using an lvalue expression that has an incompatible type with the effective type of that object as this yields to undefined behaviour. And based on this fact, the strict aliasing rule states that two pointers cannot alias each other (refer to the same object in memory) if they have incompatible types. But in p6.2.4 of C11 standard, it is allowed to access an unsigned effective type with a signed version lvalue and vice-versa.
Because of the last paragraph two pointers int *a and unsigned *b may alias each other and the change of the value of the object pointed by one of them might lead to the change of the value of the object pointed by the other (Because it is the same object).
Let's demonstrate this on the compiler level:
int f (int *a, unsigned *b)
{
    *a = 1;
    *b = 2;

    return *a;
}

The generated assembly of the above function looks like this on GCC 6.3.0 with -O2:
0000000000000000 <f>:
   0:   movl   $0x1,(%rdi)
   6:   movl   $0x2,(%rsi)
   c:   mov    (%rdi),%eax
   e:   retq

Which is quite expected because GCC doesn't optimize the return value and still reads the value *a again after the write to *b (Because the change of *b might lead to the change of *a).
But with this other function :
int ga;
unsigned gb;

int *g (int **a, unsigned **b)
{
    *a = &ga;
    *b = &gb;

    return *a;
}

The generated assembly is quite surprising (GCC -O2):
0000000000000010 <g>:
  10:   lea    0x0(%rip),%rax        # 17 <g+0x7>
  17:   lea    0x0(%rip),%rdx        # 1e <g+0xe>
  1e:   mov    %rax,(%rdi)
  21:   mov    %rdx,(%rsi)
  24:   retq

The return value is optimized and it is not read again after the write to *b. I know that int *a and unsigned *b are not compatible types but what about the rule in paragraph P6.2.4 (It is allowed to access an unsigned effective type with a signed version lvalue and vice-versa)? Why doesn't it apply in this situation? And why does the compiler make that kind of optimization in this case?
There is somthing I don't understand about this whole story of compatible types and strict aliasing. Can someone enlighten us? (And please explain why do two pointers have incompatible types but can alias each other, think of int *a and unsigned *b).

A: Given int **a and unsigned **b, the type of *a is not the signed or unsigned type corresponding to the effective type of *b, nor is *b the signed or unsigned type corresponding to the effective type of *a. Therefore, this rule permitting aliasing via corresponding signed or unsigned types does not apply. As no other rules permitting aliasing apply either, the compiler is entitled to assume the write to *b does not modify *a, and therefore the value the compiler wrote to *a in *a = &ga; is still present in *a for the return *a; statement.
The fact that int * points to a signed int does not make it a signed type. It is a pointer. int * and unsigned * are pointers to different types. Even if they were considered signed or unsigned, they would be signed or unsigned pointers to different types: If int * were a signed pointer, it would be a signed pointer to int, and the corresponding unsigned version would be an unsigned pointer to int, not any pointer to unsigned.

A: To understand the intended meaning of the signed/unsigned exemption, one must first understand the background of those types.  The C language didn't originally have an "unsigned" integer type, but was instead designed for use on two's-complement machines with quiet wraparound on overflow.  While there were a few operations, most notably the relational operators, divide, remainder, and right-shift, where signed and unsigned behaviors would differ, performing most operations on signed types would yield the same bit patterns as performing those same operations on unsigned types, thus minimizing the need for the latter.
Although unsigned types are certainly useful even on quiet-wraparound two's-complement machines, they are indispensable on platforms that do not support quiet-wraparound two's-complement semantics.  Because C did not initially support such platforms, however, a lot of code which logically "should" have used used unsigned types, and would have used them if they'd existed sooner, was written to use signed types instead.  The authors of the Standard did not want the type-access rules to create any difficulty interfacing between code which used signed types because unsigned types weren't available when it was written, and code which used unsigned types because they were available and their use would make sense.
The historical reasons for treating int and unsigned interchangeably would apply equally to allowing objects of type int* to be accessed using lvalues of type unsigned* and vice versa, int** to be accessed using unsigned**, etc.  While the Standard doesn't explicitly specify that any such usages should be allowed, it also neglects to mention some other uses that should obviously be allowed, and thus cannot be reasonably viewed as fully and completely describing everything that implementations should support.
The Standard fails to distinguish between two kinds of circumstances involving pointer-based type punning--those which involve aliasing, and those which don't-- beyond a non-normative footnote saying that the purpose of the rules is to indicate when things may alias.  The distinction is illustrated below:
int *x;
unsigned thing;
int *usesAliasingUnlessXandPDisjoint(unsigned **p)
{
  if (x)
    *p = &thing;
  return x;
}

if x and *p identify the same storage there would be aliasing between *p and x, because the creation of p and the write via *p would be separated by a conflicting access to the storage using the lvalue x.  However, given something like:
unsigned thing;
unsigned writeUnsignedPtr(unsigned **p)
{ *p = &thing; }

int *x;
int *doesNotUseAliasing(void)
{
  if (x)
    writeUnsignedPtr((unsigned**)&x);
  return x;
}

there would be no aliasing between the *p argument and x, since within the lifetime of the passed pointer p, neither x nor any other other pointer or lvalue not derived from p, is used to access the same storage as *p.  I think it's clear the authors of the Standard wanted to allow for the latter pattern.  I think it's less clear whether they wanted to allow the former even for lvalues of type signed and unsigned [as opposed to signed* or unsigned*], or didn't realize that limiting application of the rule to cases that actually involve aliasing would be sufficient to allow the latter.
The way gcc and clang interpret the aliasing rules does not extend the compatibility between int and unsigned to int* and unsigned*--a limitation which is allowable given the wording of the Standard, but which--at least in cases not involving aliasing, I would regard as contrary to the Standard's stated purpose.
Your particular example does involve aliasing in cases where *a and *b overlap, since either a was created first and a conflicting access via *b happens between such creation and the last use of *a, or b was created first and a conflicting access via *a happens between such creation and the last use of b.  I'm not sure whether the authors of the Standard intended to allow such usage or not, but the same reasons that would justify allowing int and unsigned would apply equally to int* and unsigned*.  On the other hand, gcc and clang's behavior does not seem to be dictated by what the authors of the Standard meant to say as indicated by the published Rationale, but rather by what they fail to demand that compilers do.


text:
Q: Prove V is a convex set The exercise is as below
Let $V = \{x \in \mathbb{R}^2: 2x_1^2+3x_2^2\leq4\}$
Prove: V is convex
I started the proof like this:
Let $x,y \in V$ be given. Let $\lambda \in [0,1]$. We want to show that $\lambda x + (1-\lambda) y \in V$.
Now, I know that I have to rewrite $2[\lambda x_1 + (1-\lambda)y_1]^2+3[\lambda x_2 + (1-\lambda)y_2]^2$ into something like
$\lambda(2x_1^2+3x_2^2) + (1-\lambda)(2y_1^2+3y_2^2) \leq \lambda*4+(1-\lambda)*4 = 4$
But I just can't get my head around it, can someone please make a step-by-step derivation? I am really hopeless at this point.

A: It is not so obvious how to proceed directly. A more abstract approach is useful: note that $F(x_1,x_2) = 2x_1^2+3x_2^2$ is convex (in fact, $d^2F/dx^2 = \begin{pmatrix}4&0\\ 0 & 6\end{pmatrix}$ is positive definite), so
$$2[\lambda x_1 + (1-\lambda)y_1]^2+3[\lambda x_2 + (1-\lambda)y_2]^2 = F(\lambda x+(1-\lambda y)) \leq\\ \hspace{7cm} \lambda F(x) + (1-\lambda)F(y) \leq \lambda 4 + (1-\lambda)4 = 4$$


text:
Q: Why does clicking on the 'memory indicator' in PyCharm reduce the 'Used' heap size? How to reproduce:

*

*Open a project in PyCharm.

*Enable the memory indicator.

*

*In PyCharm, click File-->Settings.

*In the Settings window, click 'Appearance and Behavior'-->Appearance.

*Under 'Window Options', click the checkbox that says 'Show memory indicator'.

*Click 'OK'.

*The indicator should appear in the bottom-right corner of the editor.

*Wait a minute or two and you should see the memory indicator indicate that PyCharm is using more memory.

*

*Example: '67 of 676' --> '172 of 676'.

*This may depend on the memory settings you have set up. In Help-->'Edit Custom VM Options', I have '-Xms' set to 128m and '-Xmx' set to 700m.

*Click on the memory indicator.

*You should see the number drop down to around where it started.

*

*Example: '172 of 676' --> '80 of 676'.

I have looked online and can't find documentation for this feature.

A: That's because clicking on the icon triggers Java's garbage collection (Idea platforms run on Java).


text:
Q: In Jaspersoft studio 6, How to calculate total for a particular row in crosstab I am using in Jaspersoft studio 6 and currently working with crosstab. I am a newbie in crosstab and have just started using it. I have created a jrxml file with crosstab(with lots of trial and error, I might add) as follows
<?xml version="1.0" encoding="UTF-8"?>

<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="MAH_Attendance_subjasper" pageWidth="1500" pageHeight="650" orientation="Landscape" columnWidth="1460" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="0e151e12-e64e-4195-aba5-d1747d8a798d">
    <property name="com.jaspersoft.studio.data.sql.tables" value=""/>
    <property name="com.jaspersoft.studio.unit." value="pixel"/>
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="MAH HR DB"/>

    <queryString language="SQL">
        <![CDATA[SELECT
    emp.emp_number AS empNumber,
    CONCAT_WS(" ",emp.first_name,emp.middle_name,emp.last_name)AS emp_name,
    att.punch_in_time AS PunchInTime,
    att.punch_out_time AS PunchOutTime,
    TIME_FORMAT(TIMEDIFF(CONCAT(DATE(att.punch_out_date)," ",(att.punch_out_time)),CONCAT(DATE(att.punch_in_date)," ",(att.punch_in_time))),'%H:%i') AS Total,
    att.shift_in_time AS Rosterin,
    att.shift_out_time AS Rosterout,
    TIME_FORMAT(TIMEDIFF(att.punch_out_time,att.shift_out_time),'%H:%i') AS Extra,
    IFNULL(DATE(att.punch_in_date),'') AS punch_in_date,
    DAYOFMONTH(att.punch_in_date) AS DayOfMonthh,
    CASE
        WHEN DAYOFWEEK(att.punch_in_date)=1 THEN 'SUN'
        WHEN DAYOFWEEK(att.punch_in_date)=2 THEN 'MON'
        WHEN DAYOFWEEK(att.punch_in_date)=3 THEN 'TUE'
        WHEN DAYOFWEEK(att.punch_in_date)=4 THEN 'WED'
        WHEN DAYOFWEEK(att.punch_in_date)=5 THEN 'THU'
        WHEN DAYOFWEEK(att.punch_in_date)=6 THEN 'FRI'
        WHEN DAYOFWEEK(att.punch_in_date)=7 THEN 'SAT'
    END AS DayOfWeeek

FROM
    hr_employees emp,
    hr_pay_periods hpr,
    hr_setup SETUP1,
    hr_setup SETUP2,
    hr_transfers tr,
    hr_emp_attendance att
        LEFT JOIN hr_leaves lv ON (att.employee_id=lv.employee_id AND att.punch_in_date BETWEEN lv.start_date AND lv.end_date)
    LEFT JOIN hr_leave_types lt ON(lt.id = lv.leave_type_id AND lt.leave_division_code='LOP')

WHERE

    emp.id =att.employee_id
    AND emp.id =tr.employee_id
    AND emp.emp_number=1
    AND tr.active_yn='1'
    AND DATE_FORMAT(tr.start_date,'%Y-%m-%d')<=DATE_FORMAT(hpr.end_date,'%Y-%m-%d')
    AND (DATE_FORMAT(tr.end_date,'%Y-%m-%d')>=DATE_FORMAT(hpr.start_date,'%Y-%m-%d') OR tr.end_date IS NULL)
    AND DATE_FORMAT(att.punch_in_date,'%Y-%m-%d') >=DATE_FORMAT(hpr.start_date,'%Y-%m-%d')
    AND DATE_FORMAT(att.punch_in_date,'%Y-%m-%d') <=DATE_FORMAT(hpr.end_date,'%Y-%m-%d')
    AND DATE_FORMAT(att.punch_in_date,'%Y-%m-%d') >=DATE_FORMAT(tr.start_date,'%Y-%m-%d')
    AND (DATE_FORMAT(att.punch_in_date,'%Y-%m-%d')<=DATE_FORMAT(tr.end_date,'%Y-%m-%d') OR tr.end_date IS NULL)
    AND SETUP1.setup_key="HR_EMPLOYEE_NUM_PREFIX"
    AND SETUP2.setup_key="HR_EMPLOYEE_NUM_SUFFIX"
   AND att.punch_in_date BETWEEN '2022-03-01' AND '2022-03-31'
    ORDER BY emp.emp_number,punch_in_date]]>
    </queryString>
    <field name="empNumber" class="java.lang.String"/>
    <field name="emp_name" class="java.lang.String"/>
    <field name="PunchInTime" class="java.sql.Time"/>
    <field name="PunchOutTime" class="java.sql.Time"/>
    <field name="Total" class="java.sql.Time"/>
    <field name="Rosterin" class="java.sql.Time"/>
    <field name="Rosterout" class="java.sql.Time"/>
    <field name="Extra" class="java.sql.Time"/>
    <field name="punch_in_date" class="java.lang.Object"/>
    <field name="DayOfMonthh" class="java.lang.Integer"/>
    <field name="DayOfWeeek" class="java.lang.String"/>
    <variable name="Variable_1" class="java.lang.String"/>
    <variable name="Variable_2" class="java.lang.String"/>
    <variable name="Variable_3" class="java.lang.String"/>
    <variable name="Variable_4" class="java.lang.String"/>
    <variable name="Variable_5" class="java.lang.String"/>
    <variable name="Variable_6" class="java.lang.String"/>
    <background>
        <band splitType="Stretch"/>
    </background>

        <band height="161" splitType="Stretch">
            <property name="com.jaspersoft.studio.unit.height" value="px"/>
            <crosstab ignoreWidth="false">
                <reportElement x="0" y="0" width="1420" height="160" uuid="b9ff42cf-4d41-4581-93ba-9a6a0d737d58">
                    <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
                    <property name="com.jaspersoft.studio.crosstab.style.header" value="Crosstab_CH"/>
                    <property name="com.jaspersoft.studio.crosstab.style.group" value="Crosstab_CG"/>
                    <property name="com.jaspersoft.studio.crosstab.style.total" value="Crosstab_CT"/>
                    <property name="com.jaspersoft.studio.crosstab.style.detail" value="Crosstab_CD"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <box>
                    <pen lineWidth="1.0" lineStyle="Solid"/>
                </box>
                <crosstabHeaderCell>
                    <cellContents>
                        <textField pattern="" isBlankWhenNull="false">
                            <reportElement key="textField-1" mode="Transparent" x="0" y="0" width="60" height="20" forecolor="#000000" backcolor="#FFFFFF" uuid="5cb94b6f-b1c1-4751-8cc9-1023a08817ba"/>
                            <box>
                                <pen lineWidth="1.0" lineStyle="Solid"/>
                                <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None">

                                <paragraph lineSpacing="Single"/>
                            </textElement>
                            <textFieldExpression><![CDATA["Date"]]></textFieldExpression>
                        </textField>
                        <textField pattern="" isBlankWhenNull="false">
                            <reportElement key="textField-1" style="CS_Sunday" mode="Transparent" x="0" y="20" width="60" height="20" forecolor="#000000" backcolor="#FFFFFF" uuid="acfafcf8-f527-474d-8627-a7132a747c48"/>
                            <box>
                                <pen lineWidth="1.0" lineStyle="Solid"/>
                                <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None">

                                <paragraph lineSpacing="Single"/>
                            </textElement>
                            <textFieldExpression><![CDATA["Day"]]></textFieldExpression>
                        </textField>
                    </cellContents>
                </crosstabHeaderCell>
                <rowGroup name="empNumber" width="60" mergeHeaderCells="false">
                    <bucket class="java.lang.String">
                        <bucketExpression><![CDATA[$F{empNumber}]]></bucketExpression>
                    </bucket>
                    <crosstabRowHeader>
                        <cellContents mode="Opaque" style="Crosstab_CH">
                            <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
                            <property name="com.jaspersoft.studio.unit.height" value="px"/>
                            <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
                            <textField pattern="" isBlankWhenNull="false">
                                <reportElement key="textField-1" mode="Transparent" x="0" y="0" width="60" height="20" forecolor="#000000" backcolor="#FFFFFF" uuid="46855b10-d1a0-4975-b4a9-0c4e63fc8004"/>
                                <box>
                                    <pen lineWidth="1.0" lineStyle="Solid"/>
                                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                    <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                </box>
                                <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None">

                                    <paragraph lineSpacing="Single"/>
                                </textElement>
                                <textFieldExpression><![CDATA["In"]]></textFieldExpression>
                            </textField>
                            <textField pattern="" isBlankWhenNull="false">
                                <reportElement key="textField-1" mode="Transparent" x="0" y="20" width="60" height="20" forecolor="#000000" backcolor="#FFFFFF" uuid="61085207-f106-4ae5-a7be-a40dd4f9e33b"/>
                                <box>
                                    <pen lineWidth="1.0" lineStyle="Solid"/>
                                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                    <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                </box>
                                <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None">

                                    <paragraph lineSpacing="Single"/>
                                </textElement>
                                <textFieldExpression><![CDATA["Out"]]></textFieldExpression>
                            </textField>
                            <textField pattern="" isBlankWhenNull="false">
                                <reportElement key="textField-1" mode="Transparent" x="0" y="40" width="60" height="20" forecolor="#000000" backcolor="#FFFFFF" uuid="577e468c-f2a4-4e42-99f1-287363338475"/>
                                <box>
                                    <pen lineWidth="1.0" lineStyle="Solid"/>
                                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                    <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                </box>
                                <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None">

                                    <paragraph lineSpacing="Single"/>
                                </textElement>
                                <textFieldExpression><![CDATA["Total"]]></textFieldExpression>
                            </textField>
                            <textField pattern="" isBlankWhenNull="false">
                                <reportElement key="textField-1" mode="Transparent" x="0" y="60" width="60" height="20" forecolor="#000000" backcolor="#FFFFFF" uuid="d89eaa0d-ddd9-4352-9fbb-46572e082ed5"/>
                                <box>
                                    <pen lineWidth="1.0" lineStyle="Solid"/>
                                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                    <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                </box>
                                <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None">

                                    <paragraph lineSpacing="Single"/>
                                </textElement>
                                <textFieldExpression><![CDATA["Roster In"]]></textFieldExpression>
                            </textField>
                            <textField pattern="" isBlankWhenNull="false">
                                <reportElement key="textField-1" mode="Transparent" x="0" y="80" width="60" height="20" forecolor="#000000" backcolor="#FFFFFF" uuid="1e60e74b-1df1-4a2b-8ba4-e639b7c95a47"/>
                                <box>
                                    <pen lineWidth="1.0" lineStyle="Solid"/>
                                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                    <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                </box>
                                <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None">

                                    <paragraph lineSpacing="Single"/>
                                </textElement>
                                <textFieldExpression><![CDATA["Roster Out"]]></textFieldExpression>
                            </textField>
                            <textField pattern="" isBlankWhenNull="false">
                                <reportElement key="textField-1" mode="Transparent" x="0" y="100" width="60" height="20" forecolor="#000000" backcolor="#FFFFFF" uuid="c9cb35b1-69d9-4075-8a74-2b6e3a5d4916">
                                    <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                                </reportElement>
                                <box>
                                    <pen lineWidth="1.0" lineStyle="Solid"/>
                                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                    <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                </box>
                                <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None">

                                    <paragraph lineSpacing="Single"/>
                                </textElement>
                                <textFieldExpression><![CDATA["Extra"]]></textFieldExpression>
                            </textField>
                        </cellContents>
                    </crosstabRowHeader>
                    <crosstabTotalRowHeader>
                        <cellContents mode="Opaque" style="Crosstab_CT">
                            <staticText>
                                <reportElement x="0" y="0" width="0" height="0" forecolor="#FFFFFF" uuid="6b02ffab-4f0f-4c9b-ab2c-46ca85f651a3"/>
                                <text><![CDATA[Total empNumber]]></text>
                            </staticText>
                        </cellContents>
                    </crosstabTotalRowHeader>
                </rowGroup>
                <columnGroup name="DayOfMonthh" height="20" totalPosition="End">
                    <bucket class="java.lang.Integer">
                        <bucketExpression><![CDATA[$F{DayOfMonthh}]]></bucketExpression>
                    </bucket>
                    <crosstabColumnHeader>
                        <cellContents mode="Opaque" style="Crosstab_CH">
                            <textField>
                                <reportElement style="CS_Sunday" x="0" y="0" width="40" height="20" uuid="718bc55d-1ed4-460e-80dd-af8703ba0c90">
                                    <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
                                </reportElement>
                                <box>
                                    <pen lineWidth="1.0" lineStyle="Solid"/>
                                </box>
                                <textElement textAlignment="Center" verticalAlignment="Middle">

                                </textElement>
                                <textFieldExpression><![CDATA[$V{DayOfMonthh}]]></textFieldExpression>
                            </textField>
                        </cellContents>
                    </crosstabColumnHeader>
                    <crosstabTotalColumnHeader>
                        <cellContents mode="Opaque" style="Crosstab_CT">
                            <staticText>
                                <reportElement x="0" y="0" width="0" height="0" forecolor="#FFFFFF" uuid="07e7807e-6981-4dab-b854-c5c8bf274b97"/>
                                <text><![CDATA[Total DayOfMonthh]]></text>
                            </staticText>
                        </cellContents>
                    </crosstabTotalColumnHeader>
                </columnGroup>
                <columnGroup name="DayOfWeeek" height="20">
                    <bucket class="java.lang.String">
                        <bucketExpression><![CDATA[$F{DayOfWeeek}]]></bucketExpression>
                    </bucket>
                    <crosstabColumnHeader>
                        <cellContents mode="Opaque" style="CS_Sunday">
                            <textField isBlankWhenNull="true">
                                <reportElement style="CS_Sunday" x="0" y="0" width="40" height="20" uuid="23a405f5-a6c2-4f4a-be59-d9d5a9e16f3f"/>
                                <box>
                                    <pen lineWidth="1.0" lineStyle="Solid"/>
                                </box>
                                <textElement textAlignment="Center" verticalAlignment="Middle">

                                </textElement>
                                <textFieldExpression><![CDATA[$V{DayOfWeeek}]]></textFieldExpression>
                            </textField>
                        </cellContents>
                    </crosstabColumnHeader>
                    <crosstabTotalColumnHeader>
                        <cellContents mode="Opaque" style="Crosstab_CG">
                            <staticText>
                                <reportElement x="0" y="0" width="40" height="20" uuid="edcbd158-c0e7-4268-aff9-0e302e553b25"/>
                                <text><![CDATA[Total DayOfWeeek]]></text>
                            </staticText>
                        </cellContents>
                    </crosstabTotalColumnHeader>
                </columnGroup>
                <measure name="PunchInTime_MEASURE" class="java.sql.Time" calculation="Count">
                    <measureExpression><![CDATA[$F{PunchInTime}]]></measureExpression>
                </measure>
                <measure name="PunchOutTime_MEASURE" class="java.sql.Time" calculation="Count">
                    <measureExpression><![CDATA[$F{PunchOutTime}]]></measureExpression>
                </measure>
                <measure name="Total_MEASURE" class="java.sql.Time">
                    <measureExpression><![CDATA[$F{Total}]]></measureExpression>
                </measure>
                <measure name="Rosterin_MEASURE" class="java.sql.Time" calculation="Count">
                    <measureExpression><![CDATA[$F{Rosterin}]]></measureExpression>
                </measure>
                <measure name="Rosterout_MEASURE" class="java.sql.Time" calculation="Count">
                    <measureExpression><![CDATA[$F{Rosterout}]]></measureExpression>
                </measure>
                <measure name="Extra_MEASURE" class="java.sql.Time" calculation="Count">
                    <measureExpression><![CDATA[$F{Extra}]]></measureExpression>
                </measure>
                <measure name="Measure1" class="java.sql.Time" calculation="Sum">
                    <measureExpression><![CDATA[$F{Extra}]]></measureExpression>
                </measure>
                <crosstabCell width="40" height="120">
                    <cellContents mode="Opaque" style="Crosstab_CD">
                        <property name="com.jaspersoft.studio.unit.width" value="px"/>
                        <textField pattern="HH:mm" isBlankWhenNull="true">
                            <reportElement style="CS_Sunday" x="0" y="0" width="40" height="20" uuid="4b55089e-2a5c-4ce4-beea-3bb57815c61b"/>
                            <box>
                                <pen lineWidth="1.0" lineStyle="Solid"/>
                            </box>
                            <textElement textAlignment="Center" verticalAlignment="Middle"/>
                            <textFieldExpression><![CDATA[$V{PunchInTime_MEASURE}]]></textFieldExpression>
                        </textField>
                        <textField pattern="HH:mm" isBlankWhenNull="true">
                            <reportElement style="CS_Sunday" x="0" y="20" width="40" height="20" uuid="bd55a1cc-0094-482b-b3ff-35197f893d52"/>
                            <box>
                                <pen lineWidth="1.0" lineStyle="Solid"/>
                            </box>
                            <textElement textAlignment="Center" verticalAlignment="Middle"/>
                            <textFieldExpression><![CDATA[$V{PunchOutTime_MEASURE}]]></textFieldExpression>
                        </textField>
                        <textField pattern="HH:mm" isBlankWhenNull="true">
                            <reportElement style="CS_Sunday" x="0" y="40" width="40" height="20" uuid="6a7f1df0-e5df-42f1-8ca7-df0d2baa4ee5"/>
                            <box>
                                <pen lineWidth="1.0" lineStyle="Solid"/>
                            </box>
                            <textElement textAlignment="Center" verticalAlignment="Middle"/>
                            <textFieldExpression><![CDATA[$V{Total_MEASURE}]]></textFieldExpression>
                        </textField>
                        <textField pattern="HH:mm" isBlankWhenNull="true">
                            <reportElement style="CS_Sunday" x="0" y="60" width="40" height="20" uuid="84b3700f-d3e9-4401-be4e-db1b6c6ea42e"/>
                            <box>
                                <pen lineWidth="1.0" lineStyle="Solid"/>
                            </box>
                            <textElement textAlignment="Center" verticalAlignment="Middle"/>
                            <textFieldExpression><![CDATA[$V{Rosterin_MEASURE}]]></textFieldExpression>
                        </textField>
                        <textField pattern="HH:mm" isBlankWhenNull="true">
                            <reportElement style="CS_Sunday" x="0" y="80" width="40" height="20" uuid="d118ce37-b5d5-4082-8244-31941463812b"/>
                            <box>
                                <pen lineWidth="1.0" lineStyle="Solid"/>
                            </box>
                            <textElement textAlignment="Center" verticalAlignment="Middle"/>
                            <textFieldExpression><![CDATA[$V{Rosterout_MEASURE}]]></textFieldExpression>
                        </textField>
                        <textField pattern="HH:mm" isBlankWhenNull="true">
                            <reportElement style="CS_Sunday" x="0" y="100" width="40" height="20" uuid="f79896f4-39d6-4de6-8c6f-1ec067bd503e"/>
                            <box>
                                <pen lineWidth="1.0" lineStyle="Solid"/>
                            </box>
                            <textElement textAlignment="Center" verticalAlignment="Middle"/>
                            <textFieldExpression><![CDATA[$V{Extra_MEASURE}]]></textFieldExpression>
                        </textField>
                    </cellContents>
                </crosstabCell>
                <crosstabCell height="120" columnTotalGroup="DayOfMonthh">
                    <cellContents>
                        <textField pattern="HH:mm">
                            <reportElement x="0" y="0" width="40" height="120" uuid="3b6da2ce-2fe5-40b4-bbfb-2fed9b9d3217"/>
                            <textFieldExpression><![CDATA[$V{Measure1}]]></textFieldExpression>
                        </textField>
                    </cellContents>
                </crosstabCell>
                <crosstabCell width="60" height="20" rowTotalGroup="empNumber" columnTotalGroup="DayOfMonthh">
                    <cellContents/>
                </crosstabCell>
                <crosstabCell height="120" columnTotalGroup="DayOfWeeek">
                    <cellContents/>
                </crosstabCell>
                <crosstabCell width="60" height="20" rowTotalGroup="empNumber" columnTotalGroup="DayOfWeeek">
                    <cellContents/>
                </crosstabCell>
            </crosstab>
        </band>

</jasperReport>

Following is the output
https://ibb.co/x75CB7Y
I have 2 requirements:

*

*I would like to show the sum for two rows - Total and Extra.

*For the Sunday columns cells, I would like to have gray color as the background.

For the second item, I know that we can use conditional style. I have tried using it but I could not get it to work. I would appriciate any help.
Edit:
I have managed to add a new measure for the sum. But as the field is of the type java.sql.Time, I am unable to get the sum of all rows. It just gives the last value of the row in the sum measure field.  I have updated the jrxml file and the output above. Is there any workaround for getting the sum of time values?


text:
Q: How to un-assign IPv4 address on google cloud sql 2nd gen How to un-assign IPv4 address on google cloud sql 2nd gen?
I tryed use this, but it doesn't work for 2nd gen sql instance.

A: Second Generation instances only support IPv4 so it doesn't make a lot of sense to unassign the IPv4 address.


text:
Q: Pull request linter I'm searching an easy way to have a sort of pull request linter.
Here is what I want to do.

*

*One of my colleagues do a pull request.

*A tool check the quality of the code (respect of the standard PSR2, check of the PHP code).

*A tool launch the unit testing of this branch.

*All the results of these tools appears in comment of the pull request.

*If all is ok, the pull request is assigned to me and I can check it manually.

If I approve and merge the pull request, a new job is trigged on the destination branch to launch unit testing automatically.
I have see tools like Jenkins but I'm not sure I will be able to do that with it, and if what I want to do is called continuous integration.

A: Yes, what you have described is exactly continuous integration. Code linters are usually just a part of it running as a separate test step. You need a tool like BuildBot, Concourse, Jenkins, GitLab for CI. GitLab is the most powerful of them as it has git hosting, issue trackers and continuous integration; you can download install GitLab locally.


text:
Q: Uploading images and text to Iphone App I am making an Iphone App. Using  a Tab Bar. The first view controller will be showing images in a scrollview and the second will simply show a text. Now I would like to add new images and change the text weekly. What would be the best way to do this?

A: There are numerous ways of accomplishing that but what about...
1) Stick your text and URLs to your images in a JSON text file on your web server. Every so often your app should check the file and refresh the text snippets and images.
2) You could also rely on an RSS feed to update the contents of your app.
3) Use a WebView and simply show a webpage from your web server.


text:
Q: Correct way to log exceptions using log4j and Solarlint compliant       public static Date convertStringToDate(String cellText) throws
      ParseException {
        Date date = null;
        SimpleDateFormat dateFormatter = new SimpleDateFormat("dd-MMM-yy");
        try {
          date = dateFormatter.parse(cellText);
        } catch (ParseException e) {
           logger.error("Error in parsing string to date" + e);
        }
        return date;
      }

I am using log4j framework to log the exception in my project.I have started using Solarlint to evaluate my static code. But for the logger.error message it says that i need to use Format Specifiers instead of string concatenation. Could some one tell me how to use logger.error("Error in parsing String to Date" + e) in Solarlint compliant fashian.  There are few examples mentioned in other posts but i didn't quite understand that is the reason for me to ask again.

A: So your Sonar is crying because you are concatenating error message with Exception e
logger.error("Error in parsing string to date" + e);

instead, you can add exception as a parameter to the logger.error method. Something like this:
logger.error("Error in parsing a string to date: {}", e.getMessage(), e);

or
logger.error("Error in parsing string to date", e);

This will fix the issue of format specifiers instead of string concatenation as well as Sonar issue.


text:
Q: Volume of a solid from rotating a function around a non-linear axis of rotation In Calculus class, we are all taught how to find the volume of a solid of rotation around any line of the form $y=a$ or $x=b$. Then in linear algebra, we are taught how to find the volume of a solid of rotation around a line of the form $y=mx$ by using the rotation matrix, $\begin{bmatrix}
\cos (x) & -\sin (x)\\
 \sin (x) & \cos (x)
\end{bmatrix}$. But is it possible to find the volume of a solid that is rotated around a non-linear axis of rotation? For example, let's say that we are rotating the function $f(x) = -x^{2} + \frac{2}{\pi } x + \frac{\pi ^{2}}{4}$ around axis of rotation $g(x) = \sin (x)$. Notice that f(x) only intersects with g(x) at two points: $\left ( -\frac{\pi }{2},-1 \right )$ and $\left ( \frac{\pi }{2},1 \right )$. So we are only rotating f(x) around g(x) between those two intersections. I provide an image just to help with visualization. The red function is the axis of rotation, the green function is the function which we are rotating, and the black lines represent the bounds of rotation. My question is then, what is the volume of that solid of rotation? The only thing I found related to this was from this question,Solids of Revolution around other functions. , but the question was still left unanswered and this question is just a slight variant of that one.
edit: Based on the comments, I tried to come up with a way to define a rotation around a non-linear axis, and this is what I have come up with. Let us cover the non-linear axis of rotation with an abundance of tangent lines of length $\Delta L $. We can rotate a function around each of those lines of length $\Delta L $. The solid of rotation would then be the solid that comes from combining all the solids generated from rotating around each of those tangent lines of length $\Delta L $ as $\Delta L \rightarrow 0$ Would this make sense as a definition of rotating around a non-linear axis?
2nd edit: In the comments, you can find a better definition to define this concept.

A: Let
$$\gamma:\quad s\mapsto{\bf r}(s)=\bigl(x(s),y(s),z(s)\bigr)$$
be a "curved" space curve, parametrized by arc length $s$. Along $\gamma$ we  have the Frenet frame, attached at the moving point ${\bf r}(s)$:
$$\eqalign{{\bf t}(s)&:=\dot{\bf r}(s)\cr {\bf n}(s)&:={\dot{\bf t}(s)\over|\dot{\bf t}(s)|}\cr {\bf b}(s)&:={\bf t}(s)\times {\bf n}(s)\cr}$$
Here ${\bf t}$ is the unit tangent vector, and it is assumed that $\dot{\bf t}(s)\ne{\bf 0}$. The vectors ${\bf n}(s)$ and ${\bf b}(s)$ then are an orthonormal basis of the normal plane to $\gamma$ at ${\bf r}(s)$.
We now assume that an additional radius function $s\mapsto\rho(s)>0$ is given. We then can create a tube $S$  along $\gamma$, of varying thickness $2\rho(s)$,  by putting
$$S:\quad (s,\phi)\mapsto {\bf p}(s):={\bf r}(s)+\rho(s)\bigl(\cos\phi\>{\bf n}(s)+\sin\phi\>{\bf b}(s)\bigr)\ .$$
This $S$ may have selfintersections when $\rho(s)$ is too large in relation to the curvature $\kappa(s)$ along $\gamma$.

A: Please click the link in my comment before proceeding.
To find the equation of the surface of revolution, one has to find a few functions:
1.$$\mathrm{\mathrm {Revolution \space of} \biggr(t,-t^2+\frac 2π+\frac {π^2}{4}\biggr),(t,sin(t)),|t|\le\frac{\pi}{2}=Rev(f,g)=Rev\bigr((x(t),y(t)),(u(t),v(t))\bigr)=Rev\biggr[\bigg(t,-t^2+\frac 2π+\frac {π^2}{4}\biggr),(t,sin(t))\bigg ],|t|\le \frac{\pi}{2}} $$
2.$$\mathrm{u'(t)=1,v'(t)=cos(t)}$$
3.$$\mathrm{A(t)=|f-g|= -t^2+\frac 2π+\frac {π^2}{4}-sin(t), \space \mathrm{if} \space g=(t,v(t))=g(x)f=(t,y(t))=f(x)}$$
4.$$\mathrm{Rev(f,g)=\big(t-Av'cos(\theta),v+Acos(\theta),Asin(\theta)\big), g=(t,v(t))=g(x),f=(t,y(t))=f(x)} $$
5. Final Answer: $$\mathrm{Rev\biggr[\bigg(t,-t^2+\frac 2π+\frac {π^2}{4}\biggr),(t,sin(t))\bigg ],|t|\le \frac{\pi}{2}=\bigg(t-\biggr(-t^2+\frac 2π+\frac {π^2}{4}-sin(t)\biggr)cos(t)cos(\theta),sin(t)+\biggr(-t^2+\frac 2π+\frac {π^2}{4}-sin(t)\biggr)cos(\theta),\biggr(-t^2+\frac 2π+\frac {π^2}{4}-sin(t)\biggr)sin(\theta)\biggr)}$$

Here is the demo of this surface. The blue outline is the original curve set:

Again, please read the reference for this question. As always correct me and please give me feedback!


text:
Q: Kotlin Coroutines, cant set info to recyclerView So I'm new to Coroutines, and I cant use it properly.My guess is that my code is setting list to recyclerView before Coroutine task is done so the list is empty. My question is how can I ensure that first of all data base information is read and then set to recyclerView.
private fun setView() {
    var info = getList().toMutableList()

    recyclerview.layoutManager = LinearLayoutManager(MainActivity())
    adapter = RecyclerViewAdapter(info, MainActivity())
    recyclerview.adapter = adapter
}

private fun getList() : List<Post> {
    var list : List<Post> = listOf()
    CoroutineScope(IO).launch {
        var info = db.userDao().getAll()
        list.forEach { Log.d("my", it.title) }
    }

    return list
}

A: Well, you are returning "list", even when coroutine has not finished yet. Are you using viewModel? A great solution would be:
On your viewModel, create a liveData to store your list
class myViewModel: ViewModel() {
     val myList = mutableLiveDataOf<List<Post>>
}

On your viewModel create a function that only calls the coroutine:
fun getList() : List<Post> {
    CoroutineScope(IO).launch {
        var info = db.userDao().getAll()
        lmyList.postValue(info) // Here you are updating you list
    }

    return list
}

Observe your list from activity/fragment:
   class myFrag: Fragment() {
     /*some code*/
     myViewModel.myList.observe(viewLifecycleOwner, Observer{ list ->
          if(!list.isNullOrEmpty()){
               /* Here you'll have your list and can set it on the adapter*/
          }
     })

   }

you'll need:
LiveData API - https://developer.android.com/topic/libraries/architecture/livedata
Coroutines on viewmodel - https://developer.android.com/topic/libraries/architecture/coroutines


text:
Q: Conda forge nbconvert package without pandoc? Background
On the quest to build a really lightweight base jupyter notebook image, I was a bit surprised by how large the unpacked miniconda + jupyter-notebook installation is. Poking around in the deployed files seems to show that a big chunk (> 130MB) of it is pandoc.
Tracing through where it's used, it's the nbconvert package - the docs (https://nbconvert.readthedocs.io/en/latest/install.html) seem to indicate that usually pandoc must be installed independently.
As I'm using conda as the package manager here, checking out the conda forge history (https://anaconda.org/conda-forge/nbconvert/) seems to suggest that the dependencies for the package changed between v4.2.0 and v5.1.1 to require pandoc.
Question
Does anyone know what the underlying reason for this becoming a dependency in the conda package is? And/or can redirect me to a better place to ask the question?


text:
Q: IllegalStateException Fragment Manager Already In Use I have been implementing Navigation drawer and tabs within some fragments of navigation drawer for a long time now. The issue never came up and it still does not appears in few fragments but it appears in only two of the fragments in navigation drawer.
In navigation drawer each item represents a fragment which are opened by following code
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
currentFragment = new SomeFragment();
home_container_drawer_layout.closeDrawers();
fragmentTransaction = setFTAnimation(fragmentTransaction);
fragmentTransaction.replace(R.id.framelayout_activity_home, currentFragment).commitNow();

As soon as the fragment is loaded I make a service call using ION wrapper that I created and on response I set up tabs dynamically in a ViewPager in that fragment
Following are two functions for setting tab listener and setting viewpager adapter
 private void addListeners() {
        pager_account_cash_mail.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tablayout_fragment_account_cash_mail));
        tablayout_fragment_account_cash_mail.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {

        @Override
        public void onTabSelected(TabLayout.Tab tab) {
            pager_account_cash_mail.setCurrentItem(tab.getPosition());
        }

        @Override
        public void onTabUnselected(TabLayout.Tab tab) {
        }

        @Override
        public void onTabReselected(TabLayout.Tab tab) {
        }
    });
}
   private void setAdapter() {
        mAdapter = new CashMailPagerAdapter(this.getChildFragmentManager(), tabs_fragments_list);
        pager_account_cash_mail.setAdapter(mAdapter);
        pager_account_cash_mail.setOffscreenPageLimit(tabs_fragments_list.size());
    }

Additionally my code contains of addTab Function which dynamically adds the tab into the tab layout after service response and after the tabs are added I make call to these two functions.
Whenever setAdapter line executes the debugger went into the getItem function of viewpager adapter and as soon as all the items are returns the app crashes saying :

Process: com.foo.myapplication, PID: 17278
                                                                                java.lang.IllegalStateException: FragmentManager is already executing transactions
                                                                                at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1626)
                                                                                at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:679)
                                                                                at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:166)
                                                                                at android.support.v4.view.ViewPager.populate(ViewPager.java:1240)
                                                                                at android.support.v4.view.ViewPager.populate(ViewPager.java:1088)
                                                                                at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1614)
                                                                                at android.view.View.measure(View.java:17356)
                                                                                at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5367)
                                                                                at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1467)
                                                                                at android.widget.LinearLayout.measureVertical(LinearLayout.java:747)
                                                                                at android.widget.LinearLayout.onMeasure(LinearLayout.java:638)
                                                                                at android.view.View.measure(View.java:17356)
                                                                                at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5367)
                                                                                at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
                                                                                at android.view.View.measure(View.java:17356)
                                                                                at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:727)
                                                                                at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:463)
                                                                                at android.view.View.measure(View.java:17356)
                                                                                at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:1085)
                                                                                at android.view.View.measure(View.java:17356)
                                                                                at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5367)
                                                                                at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
                                                                                at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
                                                                                at android.view.View.measure(View.java:17356)
                                                                                at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5367)
                                                                                at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1467)
                                                                                at android.widget.LinearLayout.measureVertical(LinearLayout.java:747)
                                                                                at android.widget.LinearLayout.onMeasure(LinearLayout.java:638)
                                                                                at android.view.View.measure(View.java:17356)
                                                                                at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5367)
                                                                                at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
                                                                                at android.view.View.measure(View.java:17356)
                                                                                at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5367)
                                                                                at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1467)
                                                                                at android.widget.LinearLayout.measureVertical(LinearLayout.java:747)
                                                                                at android.widget.LinearLayout.onMeasure(LinearLayout.java:638)
                                                                                at android.view.View.measure(View.java:17356)
                                                                                at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5367)
                                                                                at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
                                                                                at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2576)
                                                                                at android.view.View.measure(View.java:17356)
                                                                                at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2056)
                                                                                at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1199)
                                                                                at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1405)
                                                                                at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1087)
                                                                                at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6040)
                                                                                at android.view.Choreographer$CallbackRecord.run(Choreographer.java:793)
                                                                                at android.view.Choreographer.doCallbacks(Choreographer.java:606)
                                                                                at android.view.Choreographer.doFrame(Choreographer.java:575)
                                                                                at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:779)
                                                                                at android.os.Handler.handleCallback(Handler.java:739)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                at android.os.Looper.loop(Looper.java:135)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:5538)
                                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                                at java.lang.reflect.Method.invoke(Method.java:372)
                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)


text:
Q: Difference between permutations Is there a way to compute quantitatively the distance between two permutations?
Suppose we have the following two sequences of elements:
A = {0, 1, 2, 3}
B = {0, 3, 2, 1}

I could say that the permutation B differs from A because:

*

*I would require 1 swap operation in order to transform B to A

*There are 2 elements within B that have an index that is different for the same elements in A
Are there other ways to compare and describe the difference between those two?
The main goal is to define an algorithm that is able to approach the second permutation B to the first one A, such that if all the steps of this procedure are applied the outcome would be the permutation A itself.
But in order to to that I think it should be best to define first a sensible procedure that describes how much B differs from A.
Is there any known algorithm that allows to approach on permutation to another?

A: There are a few different ways to define the difference between two sequences. To name a few:
Hamming distance: the number of positions at which elements differ.
hamming(A, B)
  B[1] is different than A[1] and B[3] is different than A[3]
=> 2

Levenshtein distance: the minimum number of modifications necessary to get from one sequence to another.
levenshtein(A, B)
  replace B[1] with A[1] and replace B[3] with A[3]
=> 2

Damerau–Levenshtein distance: an extension of the former that takes into account transpositions.
damerau_levenshtein(A, B)
  transpose B[3] with B[1]
=> 1

Based upon your given example, you are interested in tracking transpositions and therefore Damerau–Levenshtein distance is your best bet.

A: Distance between permutations can be distance between lexicographic indexes of the permutations.
How to find lexicographic index is described here.


text:
Q: с помощью чекбокса отправить запросы в бд, передавая массив значений Делаю личную интеграцию под биржу криптовалют. У меня есть список ВОЗМОЖНЫХ ставок (ордеров), каждая их которых оформлена как form, передающая в input'ах данные для создания ордеров:
            <form action="order_creat.php" method="post" target="_blank" title="Покупаем крипту дешевле. Наращивается <?=$uah;?>. SHORT.">
                        <input type="text" size="5" name="s" value="<?=$b;?>" readonly>
                        <input type="text" size="7" name="quantity" value="<?= number_format($b_koll,8, '.', '');?>" class="colortext">
                        <input type="text" size="1" name="kripta" value="<?= $eth;?>" readonly>
                        <input type="text" size="4" name="oncost" value="<?= $per_cost;?>" readonly>
                        <input type="text" size="10" name="price" value="<?= number_format($b_cost,8, '.', '');?>" class="colortext">
                        <input type="text" size="5" name="on_summ" value="<?= $on_summ;?>" readonly>
                        <input type="text" size="8" name="summ" value="<?= number_format($b_summ,7, '.', '');?>" readonly>
                        <input type="text" size="5" name="block" value="<?='+'. number_format($profit,2, '.', ' ').$uah;?>">
                        <input type="text" size="1" name="block_id" value="1">

                        <input type="hidden" name="order_status" value="<?=$order_status_cr;?>">
                        <input type="hidden" name="pair" value="<?=$eth_uah;?>">
                        <input type="hidden" name="type" value="<?=$b_type;?>">

                        <?resolution_sell(number_format($b_summ,7, '.', ''), $b);?>
                    </form>
                    <form action="order_creat.php" method="post" target="_blank" title="Покупаем валюту дешевле. Наращивается <?=$eth;?>. SHORT.">
                        <input type="text" size="5" name="s" value="<?= $b;?>" readonly>
                        <input type="text" size="7" name="quantity" value="<?= number_format($bkk_koll,6, '.', '');?>" class="colortext">
                        <input type="text" size="1" name="kripta" value="<?= $eth;?>" readonly>
                        <input type="text" size="4" name="oncost" value="<?= $per_cost;?>" readonly>
                        <input type="text" size="10" name="price" value="<?= number_format($bkk_cost,8, '.', '');?>" class="colortext">
                        <input type="text" size="5" name="on_summ" value="<?= $on_summ;?>" readonly>
                        <input type="text" size="8" name="summ" value="<?= number_format($bkk_summ,7, '.', '');?>" readonly>
                        <input type="text" size="5" name="block" value="<?='+'. number_format($bkk_profit,6, '.', ' ').$eth;?>">
                        <input type="text" size="1" name="block_id" value="1">

                        <input type="hidden" name="order_status" value="<?=$order_status_cr;?>">
                        <input type="hidden" name="pair" value="<?=$eth_uah;?>">
                        <input type="hidden" name="type" value="<?=$b_type;?>">

                        <?resolution_sell(number_format($bkk_summ,7, '.', ''), $b);
                        echo $b_komis_str .' - '. number_format($b_komis,6, '.', ' ') . $eth;
                        ?>
                    </form>

возле каждой такой ВОЗМОЖНОЙ ставки есть кнопка "Создать ордер", которая передаёт по api на биржу данные для создания ордера:
pair - валютная пара
quantity - кол-во по ордеру
price - цена по ордеру
type - тип ордера, может принимать следующие значения:
+ некоторые данные для записи мне в базу.
Задача следующая: я хочу сделать так, чтоб не нажимать возле каждой ставки "Создать ордер", а отметить их чекбоксами и один раз нажав "создать ордера" отправить эти все данные. Я знаю, что через чек-боксы можно передавать данные в массиве, но они передаются из одного поля. А у меня полей много. Можно ли это решить? Спасибо.

A: <?php

    $countOfCurrencies = 2; // количество предполагаемых данных (форм)
    if ( isset($_POST) && count($_POST) != 0 ){
        for ($i=0; $i < $countOfCurrencies; $i++) {
            if ( isset($_POST['cur_'][$i]['check']) && $_POST['cur_'][$i]['check']=='on' ){
                // обработка отправленной пары (пример)

                $data = new array();
                $data[0] = $_POST['item'][$i][0];
                $data[1] = $_POST['item'][$i][1];
                $data[2] = $_POST['item'][$i][2];
                $db->insert($data);
                unset($data);
            }
        }
    }
?>

<form action="?" method="POST">
    <input type="checkbox" name="cur_[0][check]">Валюта 1

    <input type=text name="item[0][0]">

    <input type=text name="item[0][1]">

    <input type=text name="item[0][2]">

    <input type="checkbox" name="cur_[1][check]">Валюта 2

    <input type=text name="item[1][0]">

    <input type=text name="item[1][1]">

    <input type=text name="item[1][2]">

    <input type="submit" name="save" value="создать ордера" />
</form>


text:
Q: What game is this red-haired Mario character from? In the Glove and Boots video What Happened to Pauline?, at 1:28 there's an image of a of red-haired girl in a white dress playing volleyball.
She's placed below a photo of Toadette and Rosalina, and just above the Banana Fairy from Donkey Kong 64.

Who is this mystery character and what game is she from?

A: That is the White Mage from the Final Fantasy series.
She shows up as a playable character in Mario Sports Mix and Mario Hoops 3-on-3.


text:
Q: Replacing "it" with "that" in some cases? Is that okay? Someone on Facebook said that iPhone 7 doesn't have features according the price.
So I said:

Go for Galaxy S8. That even has fast-charging feature.

Is it right to replace it with that here?

A: We use that commonly to point to a thing or person with singular nouns when the thing or person is often distant/invisible from the speaker. For example:
That's Steven in the blue shirt, isn't it? (pronoun)
As in the your sentence; Go for galaxy s8. That even has fast charging feature

*

*that also plays here a role of pronoun for galaxy s8 you have mentioned in the preceding sentence. Also, you can use it. It's fine.

*Your sentence is right.

A: "It" and "that" both work here, but your sentence needs more articles.  It should be one of the following:

Go for the Galaxy S8. That even has a fast-charging feature.
Go for the Galaxy S8. It even has a fast-charging feature.

"A Galaxy S8" could work, too, and "the fast-charging feature" could work, especially if it's a feature that's been previously mentioned or discussed or which has been much mentioned elsewhere (so that the reader is likely to be familiar with it even if it's not been mentioned in the conversation).
Also, "a fast-charge feature" would perhaps sound better than "a fast-charging feature", though both are correct.  It's also possible to omit the word "feature" and just say "fast charging" on its own.  Here, the article wouldn't be needed: "That has fast charging."


text:
Q: asp:GridView change header cell style I would like to change style of my header cell after clicking on it. I'm using GridView control in .Net 2.0. Oh! my grid is sortable so after clicking on header, postback is triggered

A: youll have to do in JS or jQuery ( if you want to prevent postbacks).
for saving the states of the style between each postback - i will suggest to save style and column location - in a hidden field which will be read after each postback  - at the client side - and will - regenerate the style.