text:
Q: Как сравнить 2 массива на совпадения с учетом порядка? Есть 2 массива:
Ответы на вопросы: testOne = ['WHY','HOW','HOW','WHOSE','WHAT','WHERE','LONG','DI','IS','WHICHE','WERE'];
Ответы на вопросы от пользователя
testOneUser = ['WHY','HOW','HOW','WHOSE','WHAT','WHERE','LONG','DI','IS','WHICHE','WERE'];

Как получить точное количество правильных ответов? Сейчас я перебираю массивы но если просто встречается совпадение то оно засчитывается в массив с результатом
var testOne = ['WHY','HOW','HOW','WHOSE','WHAT','WHERE','LONG','DI','IS','WHICHE','WERE'];
    $('#test-one-finish').click(function() {
        var testOneUser = $('#test-1 input').map(function() {
            return $(this).val();
        }).toArray();
        var testOneChek = [];
        for(var i=0;i<testOne.length;i++){

           for(var j=0;j<testOneUser.length;j++){

             if(testOne[i] == testOneUser[j]){
                 testOneChek.push(testOne[i]);
             }

          }
        }
        $.cookie('test-one-result',testOneChek.length);
    });

A:

var testOneChek = [];
for (var i = 0; i < Math.min(testOne.length, testOneUser.length); i++) {
  if (testOne[i] == testOneUser[i]) {
    testOneChek.push(i);
  }
}


text:
Q: Methods of testing EJB 3.1 I am working currently with the theme of testing EJBs in the version 3.1 and I do have only some experience with it. So I take look at the literature and found out three different ways/methods of testing EJBs (Version 3.0 and newer)
1) Use of simple POJT (Plain Old Java Tests)
2) Use of an embedded Container
3) Test of the application in the application server
After I figured out these the different methods I started some research on my own and found out some possibilities.
For case 1) tools like JUnit or TestNG are nearly perfect and to solve the problems of the annotations the library EasyGloss can be used. For very simple beans EasyGloss isn't necessary. The "local" testing works fine until the bean need access to Contexts (e.g. sessionContext), uses Transactions or Interceptors.
I use JBoss AS 7.1.1 and as far as I know this application server doesn't provide an embedded Container. So I can switch to Glassfish (what I do not prefer) or use some alternatives like OpenEJB or Arquillian to handle tests for case 2).
I know that you guys have a lot more experience and knowledge of testing Jave EE and EJBs. So I want to ask you if you would share your experience with me and maybe give some tips and tricks, more thoughts or example code of efficient tests of ejbs.
Edit:
Added more informations für case 1).

A: An embedded container is a part of EJB 3.1, so even JBoss AS 7 has to implement it.
Arquillian is a very good option as well, and since AS 7 starts so fast the extra overhead of an external AS is not that much.
You can also combine Arquilluan with the embedded container that AS 7 should offer.

A: As Vineet pointed out there is a JBoss Embedded Container. However, as long as you do not use AS specific classes there should not be a problem when using the embedded Glassfish container (here is an easy example). Embedded containers are especially interesting if you do use the provided EJB infrastructure intensively; as you mentioned Interceptors, Transactions etc. Otherwise the advantage compared to plain unit testing is not that big.
When testing your application in the application server and your components are Remote Beans you can test them directly via JNDI lookup in your Unit Test; you can also integrate Remote Beans as testing hooks. However, Arquillian is especially interesting in case you want to test CDI or Local beans, as you cannot access them remotely.
I think it is essential to compare a tool/technology like embedded container or Arquillian to plain unit testing. Is there a big advantage? Are there any tests I cannot cover without the tool?
Just because something is new and cool does not mean you necessarily benefit from it :)

redpajama_set_name: RedPajamaStackExchange


text:
Q: Null pointer exception in android project In my project am getting nullpointerexception in the class shown below also I have attached the logcat and the java class below.In the if case i have given condition like "if(name == null)" am not sure it's correct or wrong If wrong means suggest me the correct  code to solve NPE..
Thank you in advance
public void onClick(DialogInterface dialog,int id)
 {
                        // yes();
Intent tablewise = new Intent(Seating_Engagement.this,LoginForm.class);
                            startActivity(tablewise);
                            finish();

                        }
                })

logcat:
10-13 10:25:33.914  24201-24201/com.sentientit.theiWedplanner E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.NullPointerException
            at com.sentientit.theiWedplanner.Seating_Engagement$2.onClick(Seating_Engagement.java:77)
            at android.view.View.performClick(View.java:4421)
            at android.view.View$PerformClick.run(View.java:18190)
            at android.os.Handler.handleCallback(Handler.java:725)
            at android.os.Handler.dispatchMessage(Handler.java:92)
            at android.os.Looper.loop(Looper.java:175)
            at android.app.ActivityThread.main(ActivityThread.java:5279)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
            at dalvik.system.NativeStart.main(Native Method)
10-13 10:25:45.445  24201-24206/com.sentientit.theiWedplanner I/dalvikvm﹕ threadid=3: reacting to signal 3
10-13 10:25:45.578  24201-24206/com.sentientit.theiWedplanner I/dalvikvm﹕ Wrote stack traces to '/data/anr/traces.txt'

In line 77 the exception occurs i have marked the line as (77) in the java file below
Seating_Engagement
    import android.app.AlertDialog;
    import android.app.Dialog;
    import android.app.ProgressDialog;
    import android.content.Context;
    import android.content.DialogInterface;
    import android.content.Intent;
    import android.net.ConnectivityManager;
    import android.net.NetworkInfo;
    import android.os.Bundle;
    import android.support.v4.app.FragmentActivity;
    import android.view.View;
    import android.widget.Button;

    import com.bugsense.trace.BugSenseHandler;

    import java.util.StringTokenizer;

    public class Seating_Engagement extends FragmentActivity{

        ProgressDialog myProgressDialog = null;
        String username=welcomeuser1.usernamevalue;
        String result=null;
        String nameresult=null;
        String Table,Chart=null;
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);       BugSenseHandler.initAndStartSession(this, "68640bea");

            setContentView(R.layout.seatingchart);

            Button familywise=(Button)findViewById(R.id.familywise);
            Button tablewisesummary=(Button)findViewById(R.id.tableclassify);
            Button assignedguest=(Button)findViewById(R.id.assignedguest);
            Button notassignedguest=(Button)findViewById(R.id.notassignedguest);
            Button tablechair=(Button)findViewById(R.id.tableclass);
            Button groupwise=(Button)findViewById(R.id.groupwise);
            Button tablewise=(Button)findViewById(R.id.tablewisesummary);
            Button familywisesummary=(Button)findViewById(R.id.familywisesummary);
            Button groupwisesummary=(Button)findViewById(R.id.groupwisesummary);
            Button arrangementsummary=(Button)findViewById(R.id.totaltables);

             Button back=(Button)findViewById(R.id.back);
            Button seatingoverview =(Button)findViewById(R.id.seatingview);

            back.setOnClickListener(new View.OnClickListener() {

                //@Override
                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    finish();
                }
            });

            seatingoverview.setOnClickListener(new View.OnClickListener() {

                //@Override
                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub

                    if(username.equals("null"))
                    {
                        Dialog locationError = new AlertDialog.Builder(
                                Seating_Engagement.this)
                        .setIcon(0)
                        .setTitle("Message!")
                        .setPositiveButton(R.string.ok1,
                                new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog,
                        int id) {
                        // yes();
 (77)   Intent tablewise = new Intent(Seating_Engagement.this,LoginForm.class);
                            startActivity(tablewise);
                            finish();
                            }
                    })
                        .setMessage("Registered users can access this page. Click 'Yes' to login")
                        .setNegativeButton(R.string.no,
                                new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog,
                                    int id) {

                            }
                        })

                        .create();
                        locationError.show();
                    }
                    else
                    {
                        Dialog locationError = new AlertDialog.Builder(
                                Seating_Engagement.this)
                        .setIcon(0)

                        .setPositiveButton("Table",
                                new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog,
                                    int id) {
                                // yes();
                                Intent tablewise = new Intent(Seating_Engagement.this,
                                        Seating_EngagementTable.class);
                                startActivity(tablewise);
                                //  finish();

                            }
                        })

                        .setNegativeButton("Chart",
                                new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog,
                                    int id) {
                                Intent tab=new Intent(Seating_Engagement.this,Seating_Engagementviewtable.class);
                                startActivity(tab);
                                finish();

                            }
                        })

                        .create();
                        locationError.show();

                    }

                }
            });

            notassignedguest.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {

                    Intent tablewise=new Intent(Seating_Engagement.this,Engagement_Notyetseated.class);
                    startActivity(tablewise);
                    //                  finish();

                }

            });

            assignedguest.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    Intent tablewise=new Intent(Seating_Engagement.this,Engagement_AssignedGuest.class);
                    startActivity(tablewise);
                    //finish();

                }

            });

            tablechair.setOnClickListener(new View.OnClickListener() {

                //@Override
                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    Intent tablewise=new Intent(Seating_Engagement.this,Engagement_TableClassify.class);
                    startActivity(tablewise);
                    //                  finish();

                }
            });

            tablewisesummary.setOnClickListener(new View.OnClickListener() {

                //@Override
                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub

                    if(username.equals("null"))
                    {
                        Dialog locationError = new AlertDialog.Builder(
                                Seating_Engagement.this)
                        .setIcon(0)
                        .setTitle("Message!")
                        .setPositiveButton(R.string.ok1,
                                new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog,
                                    int id) {
                                // yes();
                                Intent tablewise = new Intent(Seating_Engagement.this,
                                        LoginForm.class);
                                startActivity(tablewise);
                                finish();

                            }
                        })
                        .setMessage("Registered users can access this page. Click 'Yes' to login")
                        .setNegativeButton(R.string.no,
                                new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog,
                                    int id) {

                            }
                        })

                        .create();
                        locationError.show();
                    }
                    else
                    {
                        Dialog locationError = new AlertDialog.Builder(
                                Seating_Engagement.this)
                        .setIcon(0)

                        .setPositiveButton("Table",
                                new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog,
                                    int id) {
                                // yes();
                                Intent tablewise = new Intent(Seating_Engagement.this,
                                        Engagement_TableChairSummary.class);
                                startActivity(tablewise);
                                //finish();

                            }
                        })

                        .setNegativeButton("Chart",
                                new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog,
                                    int id) {
                                Intent tab=new Intent(Seating_Engagement.this,Engagement_ViewTable.class);
                                startActivity(tab);
                                finish();

                            }
                        })

                        .create();
                        locationError.show();

                    }

                }
            });

            familywisesummary.setOnClickListener(new View.OnClickListener() {

                //@Override
                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub

                    if(username.equals("null"))
                    {
                        Dialog locationError = new AlertDialog.Builder(
                                Seating_Engagement.this)
                        .setIcon(0)
                        .setTitle("Message!")
                        .setPositiveButton(R.string.ok1,
                                new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog,
                                    int id) {
                                // yes();
                                Intent tablewise = new Intent(Seating_Engagement.this,
                                        LoginForm.class);
                                startActivity(tablewise);
                                finish();

                            }
                        })
                        .setMessage("Registered users can access this page. Click 'Yes' to login")
                        .setNegativeButton(R.string.no,
                                new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog,
                                    int id) {

                            }
                        })

                        .create();
                        locationError.show();
                    }
                    else
                    {
                        Dialog locationError = new AlertDialog.Builder(
                                Seating_Engagement.this)
                        .setIcon(0)

                        .setPositiveButton("Table",
                                new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog,
                                    int id) {
                                // yes();
                                Intent tablewise = new Intent(Seating_Engagement.this,
                                        Engagement_Familywisesummary.class);
                                startActivity(tablewise);
                                //finish();

                            }
                        })

                        .setNegativeButton("Chart",
                                new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog,
                                    int id) {
                                Intent tab=new Intent(Seating_Engagement.this,Engagement_Familyviewtable.class);
                                startActivity(tab);
                                finish();

                            }
                        })

                        .create();
                        locationError.show();

                    }

                }
            });

            groupwisesummary.setOnClickListener(new View.OnClickListener() {

                //@Override
                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub

                    if(username.equals("null"))
                    {
                        Dialog locationError = new AlertDialog.Builder(
                                Seating_Engagement.this)
                        .setIcon(0)
                        .setTitle("Message!")
                        .setPositiveButton(R.string.ok1,
                                new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog,
                                    int id) {
                                // yes();
                                Intent tablewise = new Intent(Seating_Engagement.this,
                                        LoginForm.class);
                                startActivity(tablewise);
                                finish();

                            }
                        })
                        .setMessage("Registered users can access this page. Click 'Yes' to login")
                        .setNegativeButton(R.string.no,
                                new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog,
                                    int id) {

                            }
                        })

                        .create();
                        locationError.show();
                    }
                    else
                    {
                        Dialog locationError = new AlertDialog.Builder(
                                Seating_Engagement.this)
                        .setIcon(0)

                        .setPositiveButton("Table",
                                new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog,
                                    int id) {
                                // yes();
                                Intent tablewise = new Intent(Seating_Engagement.this,
                                        Engagement_Groupwisesummary.class);
                                startActivity(tablewise);
                                //finish();

                            }
                        })

                        .setNegativeButton("Chart",
                                new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog,
                                    int id) {
                                Intent tab=new Intent(Seating_Engagement.this,Engagement_Groupviewtable.class);
                                startActivity(tab);
                                finish();

                            }
                        })

                        .create();
                        locationError.show();

                    }

                }
            });

            familywise.setOnClickListener(new View.OnClickListener() {

                //@Override
                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub

                    //  String user_url ="http://mobileapps.iwedplanner.com/mobileapps/iwedplanner/mobile/tabledisplay.aspx?unme="+username+"&occasion=Engagement";
                    String user_url ="http://mobileapps.iwedplanner.com/mobileapps/iwedplanner/mobile/version21/seating-table-display.aspx?unme="+username+"&occasion=Engagement";

                    httpclass obj = new httpclass();
                    result = obj.server_conn(user_url);

                    StringTokenizer st = new StringTokenizer(result, "|");
                    result = st.nextToken();

                    //  String user ="http://mobileapps.iwedplanner.com/mobileapps/iwedplanner/mobile/Notallocated_familywise.aspx?unme="+username+"&occasion=Engagement";

                    String user="http://mobileapps.iwedplanner.com/mobileapps/iwedplanner/mobile/version21/notallocated_familywise.aspx?unme="+username+"&occasion=Engagement";

                    httpclass objg = new httpclass();
                    nameresult = objg.server_conn(user);

                    StringTokenizer s = new StringTokenizer(nameresult, "|");
                    nameresult = s.nextToken();

                    if(result.equals("There is no table"))
                    {

                        alertbox("Assignment", "None of the table has been created");

                    }
                    else if(nameresult.equals("No Guests"))
                    {

                        alertbox("Assignment", "No Guest invited");

                    }
                    else
                    {
                        boolean netvalue = false;
                        ConnectivityManager cm = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);

                        NetworkInfo info = cm.getActiveNetworkInfo();
                        if (info != null && info.isAvailable()) {
                            netvalue = true;
                            Intent tablewise=new Intent(Seating_Engagement.this,Engagement_FamilwiseAllocation.class);

                            startActivity(tablewise);
                            //  finish();
                        }
                        else
                        {
                            alertbox("Message!", "No Internet Connection!");
                        }
                    }

                }
            });

            groupwise.setOnClickListener(new View.OnClickListener() {

                //@Override
                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub

                    //  String user_url ="http://mobileapps.iwedplanner.com/mobileapps/iwedplanner/mobile/tabledisplay.aspx?unme="+username+"&occasion=Engagement";

                    String user_url ="http://mobileapps.iwedplanner.com/mobileapps/iwedplanner/mobile/version21/tabledisplay.aspx?unme="+username+"&occasion=Engagement";

                    httpclass obj = new httpclass();
                    result = obj.server_conn(user_url);

                    StringTokenizer st = new StringTokenizer(result, "|");
                    result = st.nextToken();

                    //  String user ="http://mobileapps.iwedplanner.com/mobileapps/iwedplanner/mobile/Not_allocated_notfamily.aspx?unme="+username+"&occasion=Engagement";
                    String user="http://mobileapps.iwedplanner.com/mobileapps/iwedplanner/mobile/version21/Not_allocated_notfamily.aspx?unme="+username+"&occasion=Engagement";

                    httpclass objg = new httpclass();
                    nameresult = objg.server_conn(user);

                    StringTokenizer s = new StringTokenizer(nameresult, "|");
                    nameresult = s.nextToken();
                    if(result.equals("There is no table"))
                    {

                        alertbox("Summary", "None of the table has been created");

                    }
                    else if(nameresult.equals("No Guests"))
                    {

                        alertbox("Assignment", "No Guest invited");

                    }
                    else
                    {

                        Intent tablewise=new Intent(Seating_Engagement.this,Engagement_GroupWiseAllocation.class);
                        startActivity(tablewise);
                        //finish();
                    }

                }
            });

            tablewise.setOnClickListener(new View.OnClickListener() {

                //@Override
                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub

                    if(username.equals("null"))
                    {
                        Dialog locationError = new AlertDialog.Builder(
                                Seating_Engagement.this)
                        .setIcon(0)
                        .setTitle("Message!")
                        .setPositiveButton(R.string.ok1,
                                new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog,
                                    int id) {
                                // yes();
                                Intent tablewise = new Intent(Seating_Engagement.this,
                                        LoginForm.class);
                                startActivity(tablewise);
                                finish();

                            }
                        })
                        .setMessage("Registered users can access this page. Click 'Yes' to login")
                        .setNegativeButton(R.string.no,
                                new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog,
                                    int id) {

                            }
                        })

                        .create();
                        locationError.show();
                    }
                    else
                    {
                        Dialog locationError = new AlertDialog.Builder(
                                Seating_Engagement.this)
                        .setIcon(0)

                        .setPositiveButton("Table",
                                new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog,
                                    int id) {
                                // yes();
                                Intent tablewise = new Intent(Seating_Engagement.this,
                                        Engagement_TableWiseSummary.class);
                                startActivity(tablewise);
                                //finish();

                            }
                        })

                        .setNegativeButton("Chart",
                                new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog,
                                    int id) {
                                Intent tab=new Intent(Seating_Engagement.this,Engagement_Tableviewtable.class);
                                startActivity(tab);
                                finish();

                            }
                        })

                        .create();
                        locationError.show();
                    }

                }
            });

            arrangementsummary.setOnClickListener(new View.OnClickListener() {

                //@Override
                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub

                    // String user_url ="http://mobileapps.iwedplanner.com/mobileapps/iwedplanner/mobile/tabledisplay.aspx?unme="+username+"&occasion=Engagement";

                    String user_url ="http://mobileapps.iwedplanner.com/mobileapps/iwedplanner/mobile/version21/tabledisplay.aspx?unme="+username+"&occasion=Engagement";

                    httpclass obj = new httpclass();
                    result = obj.server_conn(user_url);

                    StringTokenizer st = new StringTokenizer(result, "|");
                    result = st.nextToken();

                    if(result.equals("There is no table"))
                    {

                        alertbox("Summary", "None of the table has been created");

                    }
                    else
                    {

                        Intent tablewise=new Intent(Seating_Engagement.this,Engagement_TotalSeatingStatus.class);
                        startActivity(tablewise);
                        //  finish();
                    }
                }

            });

        }
        protected void alertbox(String title, String mymessage)
        {
            new AlertDialog.Builder(this)
            .setMessage(mymessage)
            .setTitle(title)
            .setCancelable(true)
            .setNeutralButton(android.R.string.ok,
                    new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int whichButton){}
            })
            .show();
        }
        @Override
        public void onStart() {
            super.onStart();
            // The rest of your onStart() code.
            //  EasyTracker.getInstance(this).activityStart(this);  // Add this method.
        }

        @Override
        public void onStop() {
            super.onStop();
            // The rest of your onStop() code.
            // EasyTracker.getInstance(this).activityStop(this);  // Add this method.
        }

    }

A: You are not checking username for null properly. That is where your NPE lies, the username is null, yet you call the "equals()" method on it.
Change it to:
if(username == null){
   (...)
}

A: try this...
  if (TextUtils.isEmpty(username)) {

        //code here

    } else{

        //code here
    }

or
   if(username.equals("")){

    Toast.makeText(getApplicationContext(), "Please Enter Username", Toast.LENGTH_SHORT).show();
 }
 else{

     //code here

 }

A: You can change (77)   Intent tablewise = new Intent(Seating_Engagement.this,LoginForm.class);
to
Intent tablewise = new Intent(getActivity(),LoginForm.class);
getActivity().startActivity(tablewise);

A: final String user= username.getText().toString();

if (user.matches("")) {
    username.setError("Please Enter Name");
}


text:
Q: unable to detect .pcf fonts i want to install Profonts, and it comes with .pcf (bitmap) files.
installing .tff is easy but they don't contain any bitmaps shapes so they might look not as clean as the original
i have tried to add this on fonts.conf

      ProFont

and i have tried to add the font path
xset fp+ /usr/local/fonts/bitmap

xset fp rehash

and update using:
fc-cache -f -v

but the profont still missing.
the result of fc-cache -f -v is :

/usr/local/share/fonts/bitmap: caching, new cache contents: 0 fonts, 0 dirs

no fonts found, but lot of fonts found in other directory
i use Debian 8.4 jessie, KDE 4.14.2

A: PCF fonts should go into misc/ not bitmap/, I can install the fonts on that website without going through any special configuration.  I only drop the files into the correct folder.  Let's go step by step:
Get the font:
mkdir -p ~/.local/share/fonts/misc
cd ~/.local/share/fonts/misc
wget -O pro.zip http://tobiasjung.name/downloadfile.php?file=profont-x11.zip

Place the font files directly under ~/.local/share/fonts/misc, and, as an extra zip them to save space.
unzip pro.zip
mv profont-x11/P*.pcf .
for f in *.pcf; do gzip "$f"; done

Force a cache update (just like you are doing), and we have the fonts:
$ fc-cache -f
$ fc-match -a pro | grep Pro
ProFont_r400-12.pcf.gz: "ProFont" "Regular"
ProFont_r400-11.pcf.gz: "ProFont" "Regular"
ProFont_r400-15.pcf.gz: "ProFont" "Regular"
ProFont_r400-10.pcf.gz: "ProFont" "Regular"
ProFont_r400-17.pcf.gz: "ProFont" "Regular"
ProFont_r400-22.pcf.gz: "ProFont" "Regular"
ProFont_r400-29.pcf.gz: "ProFont" "Regular"

If you use the fontconfig defaults there is no need to tweak fonts.conf or edit the font path.
Notes:

*

*I'm using the local fontconfig path (~/.local, i.e. per user), per system path would be simply /usr/share/fonts/misc/.

*If you really want to use bitmap/ instead of misc/ you do need the xset call.


text:
Q: PHP mkdir with form input and security I'm trying to make the folder with mkdir but no success, I can see that the path is correct but $_post isn't getting the name of folder from form input ($_post['foldername' is empty) don't know what's the problem. (I have all the permissions to make the folder safe_mode is off

A: You need to use $_POST to get the filename.
As has been posted in the comments, you also need to do something with $_POST['filename'] to insure that the user is not trying to post a relative path to your script and trying to create folders in locations that you don't intend.  At the very least make sure that the variable doesn't contain '..'  Since you are prepending a path, I don't think that you have to worry about a direct path to '/' but you may also want to invalidate inputs with a '/' in them.

A: You could always try this:
<?php
include("models/db-settings.php");
include("models/config.php");

$foldername = $_POST["foldername"];
$filename   = $foldername;
$path       = __DIR__ . "/uploads/" . $loggedInUser->username;
$fullPath   = $path . "/" . $filename;
if (!file_exists($fullPath)){
    mkdir($fullPath, 0777);
    echo "The directory was successfully created.";
}
echo $fullPath;

?>

<form action="mkdir.php" method="post">
    <input type="text" name="foldername" id="foldername" value="FolderName">
    <input type="submit" value="submit">
</form>

A: Change
if (!file_exists($path)) {
        mkdir("$path/$filename", 0777);
        echo "The directory was successfully created.";
    }

to
if (!is_dir($path)) {
        mkdir("$path/$filename", 0777);
        echo "The directory was successfully created.";
  }


text:
Q: Listen to DNS requests I'm trying to listen to DNS request of browsers on my localhost.
I've wrote this code:
WSADATA wsaData;
unsigned char hostname[100];

int sockfd;
struct addrinfo hints, *servinfo, *p;
int rv;
int numbytes;
struct sockaddr_storage their_addr;
char buf[1000];
socklen_t addr_len;

memset(&hints, 0, sizeof hints);
hints.ai_family = AF_UNSPEC; // set to AF_INET to force IPv4
hints.ai_socktype = SOCK_DGRAM;
hints.ai_flags = AI_PASSIVE; // use my IP

if (WSAStartup(MAKEWORD(2,0), &wsaData) != 0)
{
    fprintf(stderr, "WSAStartup failed.\n");
    exit(1);
}

if ((rv = getaddrinfo(NULL, "53", &hints, &servinfo)) != 0) {
    fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
    return 1;
}

// loop through all the results and bind to the first we can
for(p = servinfo; p != NULL; p = p->ai_next) {
    if ((sockfd = socket(AF_INET, SOCK_DGRAM,IPPROTO_UDP)) == -1) {
        perror("listener: socket");
        continue;
    }

    if (bind(sockfd, p->ai_addr, p->ai_addrlen) == -1) {
        closesocket(sockfd);
        perror("listener: bind");
        continue;
    }

    break;
}

if (p == NULL) {
    fprintf(stderr, "listener: failed to bind socket\n");
    return 2;
}

freeaddrinfo(servinfo);

printf("listener: waiting to recvfrom...\n");
addr_len = sizeof their_addr;
if ((numbytes = recvfrom(sockfd, buf, 1000-1 , 0,(struct sockaddr *)&their_addr, &addr_len)) == -1) {
    perror("recvfrom");
    exit(1);

    printf("listener: packet is %d bytes long\n", numbytes);
    buf[numbytes] = '\0';
    printf("listener: packet contains \"%s\"\n", buf);
}

closesocket(sockfd);

I get some weird packets of 39 bytes with some characters I can't read...And it's always getting packets on 53 also when not surfing to anything, is this not the good way to listen to dns requests?
I've changed my DNS Ip to 127.0.0.1 on windows.
Kind regards,

A: DNS is not a text-based protocol like HTTP, you are supposed to decode the packets. Look into RFC 1035 for details.

A: I've parsed like this:
    pointer = substring( buffer, 14, numbytes-18);
    //printf("Substring: %s \n",pointer);
    //printf("listener: packet contains \"%x\"\n", buffer);

    for( i = 0; i < strlen(pointer); i++)
    {
        // Indien kleiner als 32 dan moet het een . worden
        if(pointer[i] < 32)
            result[i] = '.';
        // Indien groeter als 32 en kleiner als 127 is het een char
        else if(pointer[i] > 32 && pointer[i] < 127)
            result[i] = (char)(pointer[i]);
        else
            continue;
    }
    result[i] = '\0';

Then in your result you have something like "www.google.com".


text:
Q: Replacing URLs in Strings - Perl I have a bunch of strings that have URLs in them and I need to remove the URL and replace it with a different one. The only way I can think of to do it is with split:
($start, $url, $end) = split(/:/);

But I don't think this is the right way to go about it, because if the url is at the start or end of the string it won't work properly.
Any ideas greatly appreciated :)

A: Try using URI::Find.

A: The already-suggested URI::Find looks to be a good bet.
Alternatively, Regexp::Common can provide suitable URLs to match URLs, for instance:
use Regexp::Common qw(URI);
my $string = "Some text, http://www.google.com/search?q=foo and http://www.twitter.com/";
$string =~ s{$RE{URI}}{http://stackoverflow.com/}g;

The above would replace both the URLs with http://stackoverflow.com/ as an example.

A: URI::URL is your friend.
#!/usr/bin/perl
use strict;
use URI::Split qw(uri_split uri_join);
my ($scheme, $auth, $path, $query, $frag) = uri_split($uri);
my $uri = uri_join($scheme, $auth, $path, $query, $frag);

A: if you also have multiple input files, and need to consistently change strings in all input files, this script can come in handy:
http://unixgods.org/~tilo/replace_string/


text:
Q: MacBook Air shuts down on fully charged, healthy battery I have a MacBook Air 13" High Sierra, early 2015.  The computer is only a year old. Battery life is good, amperage good, holding a charge.  The problem is, the very instant I unplug the Magsafe adapter it shuts down. Goes black.  Dead.  I've reset the SMC to no avail.  I'm attaching images to show that the battery is indeed fine. Before I take this to the Apple store I thought I would check in with this bright, enlightened community.

A: I have a MacBook Pro 2009 with the exact same problem. I followed many internet threads. None of the advices worked, even after replacing the battery with a new one. Finally I changed the power setting to "better battery life" in the system preferences and the problem went away.  Previously I had it on "higher performance"


text:
Q: Prove or disprove: analytical function Prove or disprove:
There exist an analytical function $f(z)$ in a deleted neighbourhood of $z=0$ such that $f^2(z) = z$.
I disproved it with the following argument:
the function $f(z)$ is given by choosing an analytical branch for the function $\sqrt{z}$, but every analytical branch of $\sqrt{z}$ doesn't contain some points from the neighbourhood of $z=0$ because of the logarithm.
is that a good disprovement?
Thanks in advance!


text:
Q: how to compare two storyboards using xcode For File comparison we have FileMerge in the xcode.
How do we compare two storyboard with slight difference.
Do we have any tool in xcode or any third party tool available ?
Thanks

A: I don't think there is a way to compare with xcode. You may use two instances of xcode running side by side to identify the visual differences.
Given that Storyboards are XML based files:

*

*If working on different branches, make sure xcode version is same for both storyboards and they have the same starting device & orientation. This would avoid many differences to pop up during comparsion.

*Use a standard file comparator (e.g. kaleidoscope, p4merge or filemerge)
In order to resolve the conflicts use:

*

*Any of the mergeTools: Very happy with using Visual Studio Code recently (2018) to do small manual merges.

Some tips related to storyboards: http://www.xmcgraw.com/10-practical-tips-for-ios-developers-using-storyboards/


text:
Q: Authorization error on GCP when trying firebase login remotely from a CLI: Error 400: invalid_request I am trying to do:
firebase login --no-localhost

After I connect to the GCP remote server (using terminal Cygwin64 on Win11). I am getting an authentication address on the CLI that I should paste into my browser. It starts with "https://accounts.google.com/o/oauth2/auth?client_id="
After pasting this address on my browser I get:

Authorization Error
Error 400: invalid_request
The version of the app you're using doesn't include the latest security features to keep you protected. Please make sure to download from a trusted source and update to the latest, most secure version.

I have installed the dirsync-win64.exe and installed on my PC which should get me the latest update for my understanding, but the result is the same.
Note that I have a paying user account on GCP.
I read somewhere there were security updates by GCP, and I may need to change the user type, but I see that I am already the owner of both GCP and the Firebase.
p.s. first few times I tried without the --localhost but when I pasted the address above, it first directed me to choose the Google user for login, then after choosing it I got to approve the Firebase CLI access to my account, and after I approved I got this error:

This site can't be reached
localhost refused to connect.

Any suggestions?


text:
Q: Green tinted flickering screen with FFmpeg + v4l2loopback-dkms I have a Raspberry PI 4 with a Raspberry 7" touch screen, where buster is installed with Ffmpeg, Gstreamer, and v4l2loopback-dkms.
To that I have attached a USB video grabber dongle, where I have a Pioneer rearcam attached.
Now my goal is to loopback /dev/video0 to /dev/video1, but in that process my stream is getting a green tint, and it's flickering a lot.
Video0 is looking fine in VLC, so I guess it's my command that is wrong somehow.
I have tried various pix_fmt formats, but they more or less end up with the same result.
Can someone see what could be wrong please?
ffmpeg -f rawvideo -video_size "720x480" -i /dev/video0 -fv4l2 -pix_fmt yuv422 /dev/video1

Video adapter output

A: ffmpeg -f v4l2 -i /dev/video0 -vf format=yuv420p -f v4l2 /dev/video1

*

*Input -f should be v4l2, not rawvideo.

*Output pixel format needs to be yuv420p, not yuv422p.


text:
Q: Why can the Klein-Gordon field be Fourier expanded in terms of ladder operators? Using the plane wave ansatz
$$\phi(x) = e^{ik_\mu x^\mu}$$
the solution to the Klein-Gordon equation $(\Box + m^2) \phi(x) =0$ can be written as a sum of solutions, since the equation is linear and the superposition principle holds, as
$$\phi(x) = \sum_{{k}} \left( Ae^{ik_\mu x^\mu} + Be^{-ik_\mu x^\mu} \right).$$
How does one find the coefficients? More exactly, why does it turn out they are the annihilation and creation operators with the factor $1/\sqrt{2E}$?
The various books and sources I've checked just confused me even more. Peskin and Schroeder just plug in the integral equation (Fourier modes) by analogy with the harmonic oscillator solution. Schwartz gives a very strange reason that the energy factor is just for convenience. In Srednicki the author writes it as $f(k)$ without an explicit form. In Mandl and Shaw, they just state the equation without any justification.
My best guess is that those come from the quantization process, but how does one do it in this case explicitly?

A: Let us start with the ansatz (I'll assume mostly plus metric signature)
\begin{equation}
  \hat\phi(x) = \int \frac{\mathrm{d}^3 \mathbf{k}}{(2\pi)^{3/2}}\left(\hat A_\mathbf{k} e^{i k\cdot x} + \hat B_\mathbf{k}e^{-ik\cdot x}\right)
\end{equation}
where $\hat A_\mathbf{k}$ and $\hat B_\mathbf{k}$ are some arbitrary operators and $k^0 = E_k$. We first note that $\phi$ is a real field which means that we must have $B_\mathbf{k} = A_\mathbf{k}^\dagger$. Also a quantum field must obey the equal time commutation relation
\begin{equation}
  \left[ \hat \phi(\mathbf{x},t),\hat{\dot\phi} (\mathbf{y},t)\right] = i\delta(\mathbf{x-y}).
\end{equation}
Plugging our ansatz into this relation we get the condition
\begin{equation}
  2E_k \left[\hat A_\mathbf{k}, \hat A_\mathbf{k'}^\dagger \right] = \delta(\mathbf{k-k'})
\end{equation}
This is just the ladder operator commutation relation with an extra normalization factor. For convenience we can define a rescaled operator $\hat a_\mathbf{k} \equiv \sqrt{2E_k}\hat A_\mathbf{k}$ which has the conventional commutation relation.
Detailed calculation
Taking the time derivative of the field we get
\begin{equation}
 \hat{\dot \phi}(x) = \int \frac{\mathrm{d}^3 \mathbf{k}}{(2\pi)^{3/2}}\left(-iE_k\hat A_\mathbf{k} e^{-i E_kt + i\mathbf{k\cdot x}} + iE_k\hat A_\mathbf{k}^\dagger e^{i E_kt - i\mathbf{k\cdot x}}\right).
\end{equation}
Then the commutator between the field and its time derivative (more generally its conjugate) is
\begin{eqnarray}
\left[ \hat \phi(\mathbf{x},t),\hat{\dot\phi} (\mathbf{y},t)\right] = \int \frac{\mathrm{d}^3 \mathbf{k}\mathrm{d}^3 \mathbf{k'}}{(2\pi)^{3}}\left\{iE_{k'}\left[\hat A_\mathbf{k},\hat A_\mathbf{k'}^\dagger\right] e^{-i(E_k-E_{k'})t+i(\mathbf{k\cdot x - k'\cdot y)}} + iE_k\left[\hat A_\mathbf{k'},\hat A_\mathbf{k}^\dagger\right] e^{i(E_k-E_{k'})t-i(\mathbf{k\cdot x - k'\cdot y)}}\right\} = \int \frac{\mathrm{d}^3 \mathbf{k}\mathrm{d}^3 \mathbf{k'}}{(2\pi)^{3}}\left\{iE_{k'}\left[\hat A_\mathbf{k},\hat A_\mathbf{k'}^\dagger\right] e^{-i(E_k-E_{k'})t} + iE_k\left[\hat A_\mathbf{-k'},\hat A_\mathbf{-k}^\dagger\right] e^{i(E_k-E_{k'})t}\right\}e^{i(\mathbf{k\cdot x - k'\cdot y)}}
\end{eqnarray}
where we have used the fact that operators commute with themselves and changed variables $\mathbf{k\rightarrow -k}$, $\mathbf{k'\rightarrow -k'}$ in the second term. This should be equal to the delta function
\begin{equation}
 i\delta(\mathbf{x-y}) = i \int \frac{\mathrm{d}^3 \mathbf{k}}{(2\pi)^3}e^{i\mathbf{k\cdot(x-y)}}  = i \int \frac{\mathrm{d}^3 \mathbf{k}\mathrm{d}^3 \mathbf{k'}}{(2\pi)^3}\delta(\mathbf{k-k'})e^{i(\mathbf{k\cdot x - k'\cdot y)}}
\end{equation}
which means we must have
\begin{equation}
 \left[\hat A_\mathbf{k},\hat A_\mathbf{k'}^\dagger\right] + \left[\hat A_\mathbf{-k'},\hat A_\mathbf{-k}^\dagger\right] = \frac{\delta(\mathbf{k-k'})}{E_k}
\end{equation}
to which $\left[\hat A_\mathbf{k},\hat A_\mathbf{k'}^\dagger\right]=\delta(\mathbf{k-k'})/2E_k$ is the solution.

A: The action functional of the real scalar field is:
$$ \mathcal{A} = \frac{1}{2} \int\mathrm{d}^4 x \left(\partial_a \phi \partial^a \phi - m^2 \phi^2 \right) = \int \mathrm{d}t \int \frac{d^3 \mathbf{k}}{(2\pi)^3} \frac{1}{2}\left[ |\dot{q}_{\mathbf{k}}|^2 - \omega^2_{\mathbf k}|q_{\mathbf k}|^2 \right]$$
where the second equality refers to an infinite number of harmonic oscillators, related to the scalar field by a spatial Fourier transform:
$$ \phi(t,\mathbf x) = \int \frac{\mathrm{d}^{3}\mathbf{p}}{(2\pi)^3}\;q_{\mathbf{p}}(t)e^{i\mathbf{p}\cdot\mathbf{x}}$$
Note that we're operating in the Heisenberg picture, where only operators evolve in time and not states. The quantization problem of the field has now been reduced to quantization of harmonic oscillators.
Expressing the harmonic oscillator in terms of creation and annihilation operators, which is a different basis:
$$ q(t) = \frac{1}{\sqrt{2\omega}}\left[a(t) + a^{\dagger}(t) \right] $$
The time evolution of the creation and annihilation operators can be found by solving Heisenberg's equation of motion, yielding the result for the harmonic oscillator:
$$ q_{\mathbf p}(t) = \frac{1}{\sqrt{2\omega_{\mathbf p}}}\left[a_{\mathbf p}e^{-i\omega_{\mathbf p}t} + a^{\dagger}_{-\mathbf p}e^{i\omega_{\mathbf p}t} \right] $$
where the $-\mathbf p$ subscript in the second operator is introduced for later convenience. Substituting this into the field expression as a Fourier transform:
$$ \phi(t,\mathbf x) = \int \frac{\mathrm{d}^{3}\mathbf{p}}{(2\pi)^3}\frac{e^{i\mathbf{p}\cdot\mathbf{x}}}{\sqrt{2\omega_{\mathbf p}}}\left[a_{\mathbf p}e^{-i\omega_{\mathbf p}t} +  a^{\dagger}_{-\mathbf p}e^{i\omega_{\mathbf p}t} \right] =  \int \frac{\mathrm d^3{\mathbf p}}{(2\pi)^3}\frac{1}{\sqrt{2\omega_{\mathbf p}}}\left[a_{\mathbf p} e^{-ip_{\mu}x^{\mu}} + a_{\mathbf p}^{\dagger}e^{ip_{\mu}x^{\mu}}\right]$$
by flipping the sign of $\mathbf p$ in the second term.

A: You might feel more comfortable if we run the reasoning 'in reverse' a bit. I'm basically just recounting what all the standard texts do, but without jumping ahead in the interpretation.

*

*We begin with the canonically quantized Klein-Gordon field $\phi(\mathbf{x})$ and its conjugate momentum $\pi(\mathbf{x})$, so that $[\phi(\mathbf{x}), \pi(\mathbf{y})] \propto i \delta(\mathbf{x}-\mathbf{y})$.

*We know that generally physics is nicer in Fourier space, especially for free fields where plane waves are classical solutions, so we define the Fourier transforms $\phi(\mathbf{p})$ and $\pi(\mathbf{p})$.

*By analogy with the harmonic oscillator, we suspect that the quantity
$$a_{\mathbf{p}} \propto \phi(\mathbf{p}) + i \pi(\mathbf{p})/\omega_p$$
will be nice to work with. At this stage, $a_{\mathbf{p}}$ is just some operator with no physical interpretation.

*When we compute the commutation relations, we find
$$[a_{\mathbf{p}}^\dagger, a_{\mathbf{q}}] \propto \delta(\mathbf{p}-\mathbf{q})$$
with an annoying energy-dependent proportionality constant, and all other commutators zero.

*From undergraduate quantum mechanics, these commutation relations imply that applying $a_{\mathbf{p}}^\dagger$ gives a ladder of states for each value of $\mathbf{p}$. Then we physically interpret $(a_{\mathbf{p}}^\dagger)^n |0 \rangle$ to contain $n$ particles of momentum $\mathbf{p}$, so that $a_{\mathbf{p}}^\dagger$ really is a creation operator, i.e. it creates particles.

*The only issue is that these states are not normalized; we get an annoying energy-dependent normalization factor. (To see this, try calculating the norm of $a_{\mathbf{p}}^\dagger |0 \rangle$ using the commutation relation above.) Tracing backwards, we find that it goes away if we replace $a_{\mathbf{p}}$ with $\sqrt{\omega_{\mathbf{p}}} a_{\mathbf{p}}$, recovering the standard definition.

When Peskin does this whole thing in one step, you should view it as just a very inspired definition (where we've outlined where the 'inspiration' might come from above), not a statement that needs to be proved. It's a more advanced version of guessing a sinusoid to solve the harmonic oscillator.

A: You do not need any Ansatz. The KG equation in coordinates $\left(\partial_\mu \partial^\mu + m^2 \right)\phi (x) =0$ needs to be translated to momentum coordinates using:
$$\phi (x) = \frac{1}{(2\pi)^4} \int_{\mathbb R^4} ~d^4 k ~ \tilde{\phi}(k) e^{ik_\mu x^\mu}$$
Can you do this calculation?

A: The factor in the denominator comes from integration over the time component of the momentum four vector (which is E). When you do a Fourier transform you go from d^4 x to d^4 k.  You then impose the energy constraint equating E^2 to k^2. The delta function of k_0^2 is the delta function of k_0 divided by its derivative at k_0 = E. You then get an integral over three dimensional momentum space, but divided by 2E.
You can find a fairly detailed explanation of this in Ashok Das' book "Lectures on Quantum Field Theory" which in general has much more detail than most books.


text:
Q: First column in distinct select is default order if no order by clause is defined While working I just noted SQL Server order by first, second columns in select list when it has distinct and it is not as per random order or in order records were created.
Can any one please confirm own experience ?

A: If the Distinct Sort operator is the last one in the query execution plan, then it seems a reasonable assumption that the final order will be by the columns in order. However, if you truly want them to be ordered a certain way, you should not rely on this assumption. You ought to explicitly add an ORDER BY clause. It just isn't worth the potential small performance gain to risk things not coming out right. There are other operators that can ensure DISTINCTness such as an aggregate. Are you sure it will come out sorted?
Hey, what if the engine becomes smart enough to determine that the rows being returned are already distinct and nothing further needs to be done (such as ordering or any kind of aggregate or other stream to discard duplicate rows)? This could be fairly easy, depending on whether primary key columns or unique columns from underlying tables are (all) included. For example, if you have a clustered index on OrderID, any query that contains OrderID where there is no possibility of the value being repeated, is provably distinct already!
It is a bad habit to rely on side-effects of certain operations. Think about views: for a long time, you were allowed to put ORDER BY in a view, and it worked, even though it should never have been relied on. Then, people upgraded their SQL Server databases and found--whoops--that the old behavior was no longer supported. I worked with a SQL 2000 database where, after upgrading to SQL 2005 and changing the compatibility mode, several data tables in the front end were no longer sorted--whoops.
And think about parallelism--this breaks a task up into smaller pieces. Parallelism already has been shown to break Scope_Identity() in some cases in some versions of SQL Server. And if one worker thread completes before another, its results may be streamed to the client before other threads are complete--thus suddenly changing order.
Do it right. Add an ORDER BY. Don't speculate any longer about what would or could or should happen. Or what wouldn't or couldn't or shouldn't.

A: Checking the execution plan of a query with DISTINCT confirms your observation.


text:
Q: how to define page size when I resize the browser size How to set the size of the web page to be scalable depending on the client monitor resolution. When I open my web page with resolution 1680x1050 the page is looking good, but when I change the monitor resolution to smaller everything is changed on the page. In css and html the size of the components I define in (%).

A: You probably have fixed paddings and/or margins, which may cause the problem. Example:

    some content

    some content

This layout will have its divs side by side till the width of the page drops to near 96px.
Solutions:

*
*Use a percentage padding and margin

*Use the new css3 coolness:

.box-sizing {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    -o-box-sizing: border-box;
    box-sizing: border-box;
}

A: As far as I know, there is no straight forward way to do this.
You need to either make your page a fixed size that is small enough to fit most browsers, or you shouldn't make the page a fixed size.


text:
Q: How to Sign out and Delete Users Register By FirebaseUI Swift 5 I want to give my app the ability to Log out/delete the user and when I type this code
    @IBAction func deleteTheAccountButtonHasBeenTapped(_ sender: Any) {

    let user = Auth.auth().currentUser
    var credential: AuthCredential

    user?.reauthenticateAndRetrieveData(with: credential, completion: {(authResult, error) in
        if let error = error {
            // An error happened.
            print(error)
        }else{
            //user re-authenticated
            user?.delete { error in
              if let error = error {
                // An error happened.
                print(error)
              } else {
                // Account deleted.
                let vc = UIStoryboard.init(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "LoginVC") as! LoginVC
                self.present(vc, animated:true, completion:nil)
              }
            }

        }
    })
}

I got this error:

Variable 'credential' used before being initialized

any one can help me?

A: The error message is pretty explicit: you're using credential before you initialized it.
In order to delete the user, you need to first reauthenticate them, as shown in the documentation on reauthenticating the user. Your version doesn't implement this comment from that code:
// Prompt the user to re-provide their sign-in credentials

How to reauthenticate the user depends on the provider. For example for email/password, you'd get them with:
credential = EmailAuthProvider.credential(withEmail: email, password: password)

A handy place to find similar snippets for other providers is in the documentation on linking accounts.


text:
Q: PHP function to list files from path I have a variable which contains a path to folder ($path_to_folder)
Looking how to build a function who will return all the files in this folder as a comma separated list..
I have tried
$files = dirList($path_to_folder);
sort($files);

but I could not use this as my function
Thanks...

A: If you're looking to turn it into a comma separated list you could do the following:
$files = implode( ',', scandir( $directory ) );

Of course you will probably want to make sure that the scandir() gets an actual result so you'll want to bring that out to the following:
$files = scandir( $directory );

if( $files )
{
    $files = implode( ',', $files );
}

Reference: http://php.net/manual/en/function.scandir.php


text:
Q: What are the most important issues to consider in upper-half plane model? I hope you can help me, I need to do a research project about this model of hyperbolic geometry. Honestly, I've never studied the subject, and I'm not sure that subjects should give more importance. Although I considered two issues:
1) Möbius transformations.
2) Distance and lengths.
Another issue to consider?
Thank you :)

A: Talking about a model, rather than the thing that its modeling, is a very narrow subject. The specific length formula, the way that angles are calculated within a model and the set of automorphisms for a particular model are pretty much the only particulars that one can turn one's attention to.
Regarding hyperbolic geometry itself, not specific models of it, the nature of hyperbolic triangles is probably the most interesting and easily accessible area of study, in particular the relationship between their areas and their angle sum.


text:
Q: EclipseLink JPA2 Criteria Query preparing statement Background: I'm writing a little desktop application with connection to existing SQL Server DB.
I'm quite familiar with writing SQL queries but this time I want to give JPA a shot. I have my entities mapped and everything is fine, but I'm little worried about perfomance.
I made some profiling and the result is that the JPA code is not really slower than mapping by hands. But there is a still one problem that is bugging me.
I've recorded the queries with SQL Server Profiler and Eclipse link is constantly calling exec sp_prepexec and exec sp_unprepare with the same query but diffent parameters.
I've rewriten the code to use parameters in query, but still no luck.
The class code is:
In constructor I create EntityManagerFactory and EntityManager
    emf = Persistence.createEntityManagerFactory("ZapytaniaOKonta_1.0");
    em = emf.createEntityManager();
    query=prepareQuery();

In prepareQuery I prepare the query using criteria builder and parameters
    CriteriaBuilder builder = em.getCriteriaBuilder();
    CriteriaQuery<Uczestnik> criteria = builder.createQuery(Uczestnik.class);
    Root<Uczestnik> uczestnikRoot = criteria.from(Uczestnik.class);
    criteria.select(uczestnikRoot);
    ParameterExpression<Boolean> peselFilterParameter = builder.parameter(Boolean.class, "peselFilterParameter");
    ParameterExpression<String> peselParameter = builder.parameter(String.class, "peselParameter");
    Predicate peselPredicate = orBuilder(builder, uczestnikRoot, peselParameter, peselFilterParameter, Uczestnik_.pesel);

    ParameterExpression<Boolean> nipFilterParameter = builder.parameter(Boolean.class, "nipFilterParameter");
    ParameterExpression<String> nipParameter = builder.parameter(String.class, "nipParameter");
    Predicate nipPredicate = orBuilderNip(builder, uczestnikRoot, nipParameter, nipFilterParameter, Uczestnik_.nip);

    ParameterExpression<Boolean> regonFilterParameter = builder.parameter(Boolean.class, "regonFilterParameter");
    ParameterExpression<String> regonParameter = builder.parameter(String.class, "regonParameter");
    Predicate regonPredicate = orBuilder(builder, uczestnikRoot, regonParameter, regonFilterParameter, Uczestnik_.regon);

    criteria.where(builder.and(peselPredicate, nipPredicate, regonPredicate));
    uczestnikPeselRegonNipQuery = em.createQuery(criteria);
    return uczestnikPeselRegonNipQuery;

when using the query I set all the parameters and call
    query.getResultList();

So my question is how can I make EclipseLink or other JPA2 provider use prepared statements?

A: EclipseLink does not use a statement cache by default.  To enable one use,
"eclipselink.jdbc.cache-statements"="true"
This can only be used with EclipseLink's connection pooling.  When using a JavaEE DataSource, you need to enable statement caching in your JavaEE server's DataSource config.


text:
Q: Collection prefactors of arbitrary functions I generated a very lengthy expression in Mathematica which can be written in the form $f(x,y,z)\log(x-y+z) + g(x,y,z)\log(x+y+z) + h(x,y)\log(x+y-z)$ etc. I would like to collect the functions $f(x,y,z)$ etc.
I know that Collect does this for polynomials. My question is if there is a function/routine which generalizes this to, e.g. in this case, logarithms.

A: Let's suppose you have the expression
expr1 = f[x, y, z] Log[x + y - z] + g[x, y, z] Log[x + y - z] + h[x, y, z] Log[x + y + z];

First, we Collect terms with the same Log expression:
expr2 = Collect[expr1, _Log]
(* (f[x, y, z] + g[x, y, z]) Log[x + y - z] + h[x, y, z] Log[x + y + z] *)

At this point, there are a couple of options. Here's one:
expr3 = List @@@ List @@ expr2
(* {{f[x, y, z] + g[x, y, z], Log[x + y - z]}, {h[x, y, z], Log[x + y + z]}} *)

and if you only want the functions:
expr3[[All,1]]
(* {f[x, y, z] + g[x, y, z], h[x, y, z]} *)

Alternatively, extract the coefficients using CoefficientList:
expr3 = Module[{i = 0, x},
  CoefficientList[expr2 /. Log[__] :> x[i++], Reverse@Array[x, i, 0]]
 ]
(* {{0, f[x, y, z] + g[x, y, z]}, {h[x, y, z], 0}} *)

Then, we can do
DeleteCases[Flatten@expr3, 0]
(* {f[x, y, z] + g[x, y, z], h[x, y, z]} *)


text:
Q: Trailing Ampersand character not shown in jquery tooltip (only in IE) When I have the Jquery tooltip applied on a image element, defined as such:
<img id="c" title="abc & ced &" src="info.png" />

The actual tooltip that is shown is:
"abc & ced "

In firefox, and when I add a trailing space after the last &amp, it works as intended:
"abc & ced &"

Is this an IE bug? I seem to be having it in version 7, 8 and 9 of IE...
Edit; the Jquery tooltip used is the one from http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/

A: Crazy stuff. Weird IE bug somehow.
$("a")[0].innerHTML = "error & error &"
//IE removes "&" at the end

The tooltip plugin sets the innerHTML of his helper element. IE removes trailing "&"
1) double-escape it (title looks wrong on non-JS browsers, works fine everywhere else)
2) Change .html() to .text() in the tooltip plugin. Titles including html code will fail.
3) Trailing space workaround
4) inspect further


text:
Q: Backend .Net program to work with database I'm working on a project for my school assignment, and I may have a problem.
I'm creating web portal which is all about reservations and ads. Reservations for a single ad are stored in a row and whenever one of them expires (duration: 5 days), it is supposed to be marked as expired, and the next one from the row is supposed to get sequence number 1, and be marked as active (was pending).
I need a solution to get this done :(
Is there a way to make a project besides my .NET project to run in the background and check these things all the time?
Thank you all so much!
If there is any thing I can explain better please do ask.
Language : C# .Net
Database : mySql
Tools    : Visual Studio 2012, Workbench, ...

A: Essentially you have at least two options, look at using SQLDependency so that when 'it' is marked as expired sqlserver will inform your application and you can do what you like.
Or use a polling system, from within your existing project simply poll the database say every 60 mins to see if 'it' is marked as expired, and then, do what you like.
There's no need for a seperate project.
EDIT: Not sure if sqldependency will work with mySql, maybe something like SqlCacheDependency could be used instead, although to be honest unless you must absolutely have 'live' data a polling solution is nice and easy and more maintainable, something like sqldependency is bug ridden and can be a pain to implement.

A: You could write programatically your changes in a helper class that checks if the time that has passed is >=5 days and then do whatever you need. Have a look at
http://hangfire.io/
I have found this very useful in creating reccuring background jobs.
note: Of course this will all work if you are using EF6


text:
Q: How long were Daenerys' dragons locked up? How much time passes between Daenerys locking up her dragons, and Tyrion freeing them? Weeks? Months? Years?

A: Game of Thrones
The timeline in Game of Thrones is deliberately vague with events in the same episode in different areas sometimes being months apart. Whilst the unofficial timeline is one season = one year this doesn't really hold up when you look at some events between seasons. However, seeing as this is the best we really have I shall answer from that perspective.
Daenerys first chains up Viserion and Rhaegal in Season 4 Episode 10, "The Children", and Tyrion releases them in Season 6 Episode 2, "Home". They then break out of the catacombs in Season 6 Episode 9, "Battle of the Bastards". The links are to YouTube clips showing these events happening.
Looking at this it would appear that both dragons were locked up for somewhere in between one to two years. Though I'd imagine it is more likely somewhere between the lower half of that estimate.
A Song of Ice and Fire
TL;DR: We can't know for sure but estimates put it around 6 months.
Before we get into an answer based on the books there are two important things you need to remember. Firstly, sizes and times of locations and events in the books have been left vague on purpose as George does not want people obsessing over these things; that isn't why he wrote the books.

[How big is Westeros? Is it the size of Europe, or even larger?]
I have deliberately tried to be vague about such things, so I don't have obsessive fans with rulers measuring distances on the map and telling me Ned couldn't get from X to Y in the time I say he did.
However, if you really must know, you can figure out the distances for yourself. The Wall is a hundred leagues long. A league is three miles. Go from there.
But if you turn up any mistakes in travel times by using that measure, let it be your secret.
Westeros, So Spake Martin, Size of Westeros

Then when looking into the writing itself George believes in using the "unreliable narrator". In the same way as when you look back in history events might not be described exactly the same as what happens, the same happens in the books. The chapters are told from the point of view of characters and so events may be mis-remembered or interpreted differently between characters and at different times.

There was a long discussion about mistakes and inconsistencies. He used the eyes changing color example, and also mentioned receiving an email about horses changing sex. George gets frustrated when there's mistakes in the books--not just because mistakes can be embarrassing, though. He said there are inconsistencies in the books that are NOT mistakes. He believes in the "unreliable narrator" -- you can't always trust what people say because they might be remembering it wrong, or you get two different stories depending on who's doing the telling. He feels that mistakes such as eye color changes can distract from the planned inconsistencies, making them less effective.
Westeros, So Spake Martin, To Be Continued (Chicago, IL; May 6-8)

So when measuring times in Westeros we need to know a relative scale for how long a year/month is. Whilst we have no exact timing for a month except they are measured in "moon turns" (how long is a moon turn? We don't know, likely the same as ours though ~30 days), we do know a year consists of twelve moon turns.

[What is the cycle of a year? Why do they count years when seasons are strange?]
Twelve moon tuns to a year, as on earth. Even on our earth, years have nothing to do with the seasons, or with the cycles of the moon. A year is a measure of a solar cycle, of how long it takes the earth to make one complete revolution around the sun. The same is true for the world of Westeros. Seasons do not come into it.
Westeros, So Spake Martin, Asshai.com Forum Chat

I have yet to properly double check, looking at other events in it, it does appear to be accurate, but this timeline for the whole series puts it around 6 months. A Dance with Dragons takes place solely in the year 300 AC so we already have an upper bound for the time they were placed in chains of a year.
Daenerys originally chains up Viserion and Rhaegal in "Daenerys II" of the book. The mentioned timeline puts this at the start of the year, the twentieth of the first month.

Viserion's claws scrabbled against the stones, and the huge chains rattled as he tried to make his way to her again. When he could not, he gave a roar, twisted his head back as far as he was able, and spat golden flame at the wall behind him. How soon till his fire burns hot enough to crack stone and melt iron?
Once, not long ago, he had ridden on her shoulder, his tail coiled round her arm. Once she had fed him morsels of charred meat from her own hand. He had been the first chained up. Daenerys had led him to the pit herself and shut him up inside with several oxen. Once he had gorged himself he grew drowsy. They had chained him whilst he slept.
Rhaegal had been harder. Perhaps he could hear his brother raging in the pit, despite the walls of brick and stone between them. In the end, they had to cover him with a net of heavy iron chain as he basked on her terrace, and he fought so fiercely that it had taken three days to carry him down the servants' steps, twisting and snapping. Six men had been burned in the struggle.
A Dance with Dragons, Daenerys II

Quentyn Martell later tries to tame and steal one of the dragons for himself, in the process they manage to escape; this happens in "The Dragontamer". However, the dragons are seen to be free in "The Queen's Hand" by Ser Barristan Selmy having escaped during the aftermath of the previous mentioned event. The timeline puts this event at the fifteenth day of the seventh month.

He took his last shuddering breath in the bleak black dawn, as cold rain hissed from a dark sky to turn the brick streets of the old city into rivers. The rain had drowned the worst of the fires, but wisps of smoke still rose from the smoldering ruin that had been the pyramid of Hazkar, and the great black pyramid of Yherizan where Rhaegal had made his lair hulked in the gloom like a fat woman bedecked with glowing orange jewels.
[...]
Ser Barristan went out onto the terrace. The rain had stopped, though a wall of slate-grey clouds hid the setting sun as it made its descent into Slaver's Bay. A few wisps of smoke still rose from the blackened stones of Hazdar, twisted like ribbons by the wind. Far off to the east, beyond the city walls, he saw pale wings moving above a distant line of hills. Viserion. Hunting, mayhaps, or flying just to fly. He wondered where Rhaegal was. Thus far the green dragon had shown himself to be more dangerous than the white.
A Dance with Dragons, The Queen's Hand

Taking these times together the difference is 5 months, 3 weeks, 4 days from our calendar. This would then be ~6 months when we take into account an error margin and the fact that Westerosi months aren't exactly the same as ours.


text:
Q: Android studio firebase submission form I'm new to Android studio. I was able to create login and auth for my app using firebase.
I'm now trying to create a submission form for the user to create and log all the fields in firebase. I would also need the ability as admin to approve the submission request and notify user by push notification or email. The email is one of the fields in  the submission form.
Looking for some guidance.
Thanks

A: Use Firebase Realtime Database + Firebase Functions.
You can see examples here.

A: You'll need to use FirebaseDatabase for that, go through this to set things up-
https://firebase.google.com/docs/database/android/start/
So first of all, add a EditText fields (simplest way) for each entry you want in your xml such as emails, password, etc.
<EditText
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:hint="Enter Email"/>
</EditText>

Next, in your java file, convert these entries to strings.
Create a DatabaseReference (Make sure you have included firebase database library in you app level build.gradle file) and point to the location where you want to store the form entries.
Create a HashMap in which you store id and entry of each field. Directly upload this map instead of uploading each and every field separately.
Don't forget to check that the entries aren't empty.
Somewhat like this-
//global variables in class
private EditText email;
private DatabaseReference mdatabase;
//inside onCreate() method
mdatabase=FirebaseDatabase.getInstance().getReference().child("Wherever you want to store this data");
email = (EditText) findViewById(R.id.emailf);
String mymail = email.getText().toString();
  if(!TextUtils.isEmpty(myname)&&!TextUtils.isEmpty(mymail)&&!TextUtils.isEmpty(mypass))
{
//create a map
HashMap< String,String> hm =
   new HashMap< String,String>();
   hm.put("email", mymail);
   hm.put("password", mypass);
   hm.put("name", myname);
mdatabase.setValue(hm).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if(task.isSuccessful())
{
//do whatever you want, your details have been uploaded to your database- mdatabase
}
}
});
}

Push Notifications can be implemented using Firebase Cloud Messaging service and node.js
You'll also need to learn about Firebase Functions, very necessary.
Begin here-
https://firebase.google.com/docs/cloud-messaging/
and here-
https://www.youtube.com/watch?v=BsCBCudx58g
and then here-
https://www.youtube.com/watch?v=2MYgZQjX7N0&list=PLk7v1Z2rk4hjxP_CHAhjXQN3zrcEhluF_
I hope this answered your question!


text:
Q: icCube definition of the icc-schema.xml In the icc-schema.xml jdbcDatatable column there is a tableType and a type attribute.
Example:

column name="first_opened_date" tableType="TIMESTAMP" type="DATETIME" selected="true" primaryKey="false"
column name="prepared_food" tableType="BIT" type="BOOLEAN" selected="true" primaryKey="false"

I guessed the tableType refers to the data type as defined in the database and the type is an icCube internal identifier roughly related to java.sql.Types.
If this is right, the former [tableType] can be read from the java.sql.Metadata.getColumns.getString("TYPE_NAME") and the later [type] must be inferred from the java.sql.Metadata.getColumns.getString("DATA_TYPE").
Is my guessing correct? Do you have a correspondence table? What is the impact of a wrong or missing attributes?

A: Assuming we are talking about JDBC tables.
"tableType" is not used as such within the code; it is displayed as an indication.
The name is derived from the java.sql.Types integer as returned by the meta-information.
"type" is the actual data type of the column. Values read from the DB are converted
to this data type and then used to build dimensions and facts. This is the type displayed
in the table UI as "Output Type". Possible values are:
DATE
DATETIME
BOOLEAN
DOUBLE
FLOAT
SHORT
INTEGER
LONG
STRING
UPPERCASE_STRING
JAVA_OBJECT
DB_TYPE_UNSUPPORTED

The mapping from java.sql.Types is as following:
DATE                from: Types.DATE
DATETIME            from: Types.TIMESTAMP
BOOLEAN             from: Types.BIT, Types.BOOLEAN
DOUBLE              from: Types.FLOAT, Types.DOUBLE, Types.NUMERIC, Types.DECIMAL
FLOAT               from: Types.REAL
SHORT               from: Types.TINYINT, Types.SMALLINT
INTEGER             from: Types.INTEGER
LONG                from: Types.BIGINT, Types.ROWID
STRING              from: Types.VARCHAR, Types.LONGVARCHAR, Types.NVARCHAR, Types.LONGNVARCHAR, Types.CHAR, Types.NCHAR
UPPERCASE_STRING    from: n/a
JAVA_OBJECT         from: Types.JAVA_OBJECT
DB_TYPE_UNSUPPORTED from: n/a

Hope that helps.

A: In complement to @Polizzi 's answer, and just in case you need it the other way round:

    tableType = JDBCType.valueOf(dbtype).getName();
    switch(dbtype){
        case Types.DATE:
            type = "DATE";
            break;
        case Types.TIMESTAMP:
            type = "DATETIME";
            break;
        case Types.BIT:
            type = "BOOLEAN";
            break;
        case Types.BOOLEAN:
            type = "BOOLEAN";
            break;
        case Types.FLOAT:
            type = "DOUBLE";
            break;
        case Types.DOUBLE:
            type = "DOUBLE";
            break;
        case Types.NUMERIC:
            type = "DOUBLE";
            break;
        case Types.DECIMAL:
            type = "DOUBLE";
            break;
        case Types.REAL:
            type = "FLOAT";
            break;
        case Types.TINYINT:
            type = "SHORT";
            break;
        case Types.SMALLINT:
            type = "SHORT";
            break;
        case Types.INTEGER:
            type = "INTEGER";
            break;
        case Types.BIGINT:
            type = "LONG";
            break;
        case Types.ROWID:
            type = "LONG";
            break;
        case Types.VARCHAR:
            type = "STRING";
            tableType = "VARCHAR("+length+")";
            break;
        case Types.LONGVARCHAR:
            type = "STRING";
            tableType = "LONGVARCHAR("+length+")";
            break;
        case Types.NVARCHAR:
            type = "STRING";
            tableType = "NVARCHAR("+length+")";
            break;
        case Types.LONGNVARCHAR:
            type = "STRING";
            tableType = "LONGVARCHAR("+length+")";
            break;
        case Types.CHAR:
            type = "STRING";
            tableType = "CHAR("+length+")";
            break;
        case Types.NCHAR:
            type = "STRING";
            tableType = "NCHAR("+length+")";
            break;
        case Types.JAVA_OBJECT:
            type = "JAVA_OBJECT";
            break;
        default:
            type = "DB_TYPE_UNSUPPORTED";
    }


text:
Q: wxWebView and JavaScript I am trying to write a program in C++ and wxWidgets that accesses YouTube and start the video with JavaScript.
It uses the YouTube JavaScript API, documentation for which is found here.
I wrote the following piece of code to play 'O, Canada', specifically the one here.
wxWebView *webview = wxWebView::New(this, wxID_ANY, "http://www.youtube.com/watch?v=zwDvF0NtgdU");
webview->RunScript("function onYouTubePlayerReady(playerId) {document.getElementById('watch-player').playVideo();}");

Running the above code fails to fulfill its intended purpose, giving me the following error and a crash:

....\src\msw\wxwebview_ie.cpp(762): "assert "document" failed in wxWebViewIE::GetDocument().

I know that my code successfully LOADS the page, but running the JavaScript (the RunScript() function) seems to result in the error.
I am using wxWidgets 2.9.3 on Windows.

A: This should have been fixed in revision 71030 which is more recent than the 2.9.3 build that you are using. You can get the updated code either through SVN or a daily snapshot. If that still doesn't fix it please file a bug on the wxWidgets Trac.

A: The problem is actually because I call the JavaScript too early, before the page is loaded. If I call it a bit later, it works.


text:
Q: NTAG213 Mifare Ultralight with Authentication I am new to NFC Android and I have been stuck for days trying to write in NTAG213 after set password to it
but it failed and i don`t know what happen can any one help me
updated with more information about code
    // write PACK:
    mifareUltralight
        .writePage(
            pageOffset: 44, data: Uint8List.fromList([pack[0], pack[1], 0, 0]))
        .then((value) {
      setState(() {
        messageTXT = 'write PACK';
      });
    });

    // write PWD:
    mifareUltralight
        .writePage(
            pageOffset: 43,
            data: Uint8List.fromList([pwd[0], pwd[1], pwd[2], pwd[3]]))
        .then((value) {
      setState(() {
        messageTXT = 'write PWD';
      });
    });
    //set PROT
    bool prot =
        false; // false = PWD_AUTH for write only, true = PWD_AUTH for read and write
    int authlim = 0;
    // value between 0 and 7
    mifareUltralight
        .transceive(
            data: Uint8List.fromList([
      0xA2, // WRITE
      42, // page address
      ((object[0] & 0x078) | (prot ? 0x080 : 0x000) | (authlim & 0x007)),
      object[1], object[2], object[3]
    ]))
        .then((value) {
      setState(() {
        messageTXT = 'PWD_AUTH for write only0';
      });
    });

    // set AUTH0
    int auth0 = 0x00;
    // value between 0 and 7

    mifareUltralight
        .writePage(
            pageOffset: 41,
            data: Uint8List.fromList([
              object1[0], // keep old value for byte 0
              object1[1], // keep old value for byte 1
              object1[2],
              auth0
            ]))
        .then((value) {
      setState(() {
        messageTXT = 'PWD_AUTH for write only2';
      });
    });
  }

mifareUltralight
        .transceive(
            data: Uint8List.fromList([0x1B, pwd[0], pwd[1], pwd[2], pwd[3]]))
        .then((value) {
      if ((value != null) && (value.length >= 2)) {
        Ndef ndef = Ndef.from(tag);

        try {
          NdefMessage message = NdefMessage([
            NdefRecord.createUri(Uri.parse(url)),
          ]);
          ndef.write(message).then((value) {
            print('write success');
          });
        } catch (e) {
          print(e.toString());
        }
      }
    });

A: Update
Now that we see more code, the first place to start is that all these transceive commands will return a value if they are successful or not.
So it would be good to do error checking of all these commands sent to the tag, by checking the return valve to see which bit goes wrong.
From the datasheet for the Tag the ACK and NAK values are

Table 23.ACK and NAK valuesCode (4-bit) ACK/NAK
Ah Acknowledge (ACK)
0h NAK for invalid argument (i.e. invalid page address)
1h NAK for parity or CRC error
4h NAK for invalid authentication counter overflow
5h NAK for EEPROM write error

So the return value should always be Ah
Original
Just setting a password on the tag does not protect anything by default.
You also need to set the AUTH0 bytes (Byte 3 of page 0x29h on ntag213 - see datasheet of tag for details) as by default no memory pages are protected by the password you just set.
You need to change the value from protecting page 0xFFh and upwards (i.e no pages) to protecting at least page 0x04h (or 0x00h) and upwards to have any effect on access to NDEF data.
Changing the value Byte 3 of page 0x29h is done with a standard write command, so read page 0x29h, change the last byte of the 4 bytes read and write back to the page.
You should also be aware of the PROT bit of the Access byte memory address that changes between read and write for the password protection (default is password protect write access), this is also changed by a standard write command to the right memory page.


text:
Q: In pypyodbc, How to query a table for its distinct values, truncate old table and append the distinct values to the empty table I have a table that for whatever reason has some dupes after a process runs.  Each row should be a distinct report.  I'm trying to do this with a for look on the cursor object after doing the .fetchall method and it is working somewhat.  But it only inserts one row.
import pypyodbc

conn_str = ('Driver={SQL Server};Server=*****************;Trusted_Connection=yes;')

con = pypyodbc.connect(conn_str)
cur = con.cursor()
cur.execute("SELECT DISTINCT TDate, Report, Records, Status from Elig_Own.DST_Report_Status_Test")
rows = cur.fetchall()
for row in rows:
        TDate = row[0]  # first item in the tuple iterable
        Report = row[1] # Second
        Records = row[2] # third
        Status = row[3]  # fourth
        cur.execute("truncate table Elig_own.DST_Report_Status_Test")
        cur.execute('''INSERT into Elig_Own.DST_Report_Status_Test (TDate, Report, Records, Status)
                        VALUES (?, ?, ?, ?)''',(TDate, Report, Records, Status))

con.commit()
con.close()

If I just print "row" within the for loop I get the list of tuples with all the fields and values I need for my table but I'm not sure how to pass these back into the empty table, all of the rows, not just one.  Why am I getting only one?

A: You are truncating (emptying) the table each time you iterate through your for loop. Therefore, when the loop finishes, your table will only contain the last row you inserted. You probably want to execute the TRUNCATE TABLE just once, before you enter the loop.


text: Q: Иконка приложения меняется только после смены идентификатора Есть проект на Android Studio в котором я тестирую приложение на своем телефоне. При попытке смены иконки ничего не происходит даже если очистить кэш, переустановить приложение или перезагрузить телефон. Смена иконки происходит лишь только в том случае если я в конфиге меняю widget id на новый. Подскажите с чем это связано и как решить?


text:
Q: Last inserted id with EF 4.1 , MVC 3 I'm using asp.net mvc 3 and EF 4.1 with visual studio 2010 and im new to it.
i have a problem about last inserted id. i have two table in my db "points_Order" and "points_OrderDetails".
                            db.Order.Add(po);
                            db.SaveChanges();
                           //second thing i have tried
                            var orderID = (from oi in db.Order
                                           select oi.ID)
                                           .Max(i => i);
                           // and this first thing
                            pod.OrderID = po.ID;
                            pod.OrderID = orderID;
                            db.OrderDetails.Add(pod);
                            db.SaveChanges();

context class:
public class points_Order {
    [Key]
    public int ID { get; set; }
    public string Owner { get; set; }
    public DateTime Date { get; set; }
    public byte Status { get; set; }
    public int Total { get; set; }
    //public virtual points_OrderDetails OrderDetail { get; set; }
}

public class points_OrderDetails {
    [Key]
    public int OrderID { get; set; }
    public string OrderType { get; set; }
    public int Amount { get; set; }
    public int ItemID { get; set; }
    public int ItemRecord { get; set; }
    public string ItemCode { get; set; }
    public byte Plus { get; set; }
    public byte Degree { get; set; }
    public string Kind { get; set; }
    public string Sex { get; set; }
    public string Race { get; set; }
    public string Tier { get; set; }
    public string SetItem { get; set; }
    public string SOX { get; set; }
    //public Blues Blue { get; set; }
}

public DbSet<points_Order> Order { get; set; }
public DbSet<points_OrderDetails> OrderDetails { get; set; }

im getting the error "{"Cannot insert the value NULL into column 'OrderID', table 'db.dbo.points_OrderDetails'; column does not allow nulls. INSERT fails.\r\nThe statement has been terminated."}"
what can i do? am i doing something wrong?

A: If you define a relationship from order -> order details in your model, it should work like this:
po.Details.Add(pod); // or pod.Order = po;
db.Order.Add(po);
db.SaveChanges();

EF should figure out the relations for you, no need to set ID's manually.
UPDATE: you're trying to do something that is not supported. You have a one-to-one mapping; EF does not support it the way you intend to (shared primary key). See http://weblogs.asp.net/manavi/archive/2011/05/01/associations-in-ef-4-1-code-first-part-5-one-to-one-foreign-key-associations.aspx for an explanation on how to model one-to-one in EF.


text:
Q: Unattended IIS installation on Windows 7 64bit Ent Tried different approached but no luck. Can anyone point me in the right direction with e.g. pkgmgr - the examples I've found doesn't work on 64bit, even when I change to the correct version number and processor architecture.
Thanks


text:
Q: *.tlb vs *.pdb for .NET 6 COM Interop Debugging I upgrade Visual Studio Solution (90+ C# Projects) from .NET Framework 4.72 to .NET 6.
What is the difference between *.tlb and *.pdb files. When upgrading to .NET 6, I of course have to provide debugging information in .NET 6. I do not know, whether to register *.tlb or *.pdb files.
Could anybody clarify the following please:

*

*Are *.tlb and *.pdb similar, except that .tlb are for COM Interop and *.pdb for regular .NET 6 applications? If they are different, what is the key difference?

*When generating *.comhost.dll for COM Interop, should I generate and register *.pdb or *.tlb to provide debugging information?

As far as I understand, *.pdb files contain symbol information and *.tld files contain type libraries. My understanding is that both are practically the same thing and both provide debugging information?
Main information sources:

*

*PDB

*TLB


text:
Q: Is it possible to write a code that opens a program and the login is hidden? First code: To hide the program when it is running.
Dim WShell
Set WShell = CreateObject("WScript.Shell")
WShell.Run "program name", 0
Set WShell = Nothing

Second code: Runs the program and puts an email and logs in.
Set a = CreateObject("WScript.Shell")
a.Run "program name\"
WScript.Sleep (5000)
a.SendKeys ("email")
a.SendKeys Chr(9)
a.SendKeys "{Enter}"

I am trying to merge the first code with the second code, but I failed
where I want to run the program and login to it via email automatically hidden.

A: VBScript cannot send keystrokes to hidden windows, meaning what you're asking is not possible in VBScript. It might be possible with AutoIt, though, using the ControlSend method:
Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Wait for 2 seconds.
    Sleep(2000)

    ; Send a string of text to the edit control of Notepad. The handle returned by WinWait is used for the "title" parameter of ControlSend.
    ControlSend($hWnd, "", "Edit1", "This is some text")

    ; Wait for 2 seconds.
    Sleep(2000)

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)

    ; Now a screen will pop up and ask to save the changes, the classname of the window is called
    ; "#32770" and simulating the "TAB" key to move to the second button in which the "ENTER" is simulated to not "save the file"
    WinWaitActive("[CLASS:#32770]")
    Sleep(500)
    Send("{TAB}{ENTER}")
EndFunc   ;==>Example


text:
Q: MinGW compiling wrong I'm writing a program in C for an assignment and I'd like to work on it on my Windows 10 desktop, however I'm encountering a strange issue when using MinGW.
The program I have written is as seen below:
#include <stdio.h>
int main(){
    //set up variables
    int a, b, c, d;

    //prompt user for integers
    printf("Please enter four different integers:\n");
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &d);

    //return sum
    int sum = a+b+c+d;
    printf("Sum is: %d", sum);

    return 0;
}

When I compile this, the output looks like this: (Where 1, 2, 3 and 4 are the inputted numbers)
1
2
3
4
Please enter four different integers:
Sum is: 10

This obviously should not happen because that's out of order. To try and troubleshoot, I compiled this same code using GCC on my laptop running Arch and the output looked like this: (Where 1, 2, 3 and 4 are the inputted numbers)
Please enter four different integers:
1
2
3
4
Sum is: 10

This is what the output should look like. I am using Eclipse Mars as an IDE on both the Linux and the Windows computers. I also tried the same on my other laptop that dual boots Windows 10 and Ubuntu and had the same results between MinGW and GCC.
If anyone has any ideas why MinGW would be acting this way I'd greatly appreciate it! Thanks!

A: Different systems/libraries have different heuristics for when to flush the output of a buffered stream. In order to portably ensure that your printf() statement is flushed and printed to the console before reading with scanf(), you need to interleave an explicit call to fflush(stdout).


text:
Q: Finding an estimated solution of the equation I have a truncation function defined as:
function f = phi_b(x, b)
if b == 0
  f = sign(x);
else
  f = -1 * (x<-b) + 1*(x>b) + (1/b) * x .* ((x>=-b & x<=b));
end;

It is used to truncate the observations which in my particular case corresponds to white noise:
model = arima('Constant',0,'AR',{0},'Variance',1);
y = simulate(model, 100);

The function I need in the end is:
 r = @(b) (1/100) * sum((phi_b(y,b)).^2);

The problem is in finding the solution of the equation r(b)==0.1. Usual procedures like the one below will not work:
solve(r(b)==0.1, b)

Is there any way to solve such types of equations?

A: If the result of r(b) is a vector, you could invoke the min function and see where in this vector the closest value would be to 0.1.  You can do something like:
result = r(b);
[val,index] = min(abs(result - 0.1));

val will contain how "close" 0.1 is with the best element in the vector that matches this criteria and index will tell you where in the result vector this element is.  For example, if val = 0.00001 and index = 7, this means that the best value in result is 0.00001 away from 0.1.  Also, index 7 in result is where this best element is located.  To see what the actual value is, do r(7) or r(index).
Interestingly enough, you can use val as a way of measuring the resolution of your data.  In other words, if val is very large, this could mean that you need to introduce more values in your vector at a smaller step size.  If val is quite small, this could mean that what you originally specified as your b vector is adequate enough.  I'm not familiar with the function so I have not considered whether or not there could be no solutions to the data you have provided to your r function.