Q: Confidence Interval for Random Set Coverage Question:
If I pick n random integers from the range [0:m-1], what is x such that I have a 95% chance of picking x or more unique values?
How do I generalize this to create a 99% one sided confidence interval?
(Each pick has a uniform 1/m chance of picking each integer in the range)
My Attempt (WRONG):
Odds of picking value i on one read: 1/m
Odds of not picking value i on one read: (m-1)/m
Odds of not picking value i on n reads: ((m-1)/m)^n
Expected number of unique values:
coverage = m * (1 - ((m-1)/m)^n)
Up to this point seems to be right based on empirical tests.
To build the confidence interval, I assume all m values in the range have the same independent chance of being chosen on each read (WRONG), and use the binomial distribution.
from scipy.stats import binom
n,p = m, coverage
mean, var, skew, kurt = binom.stats(n,p, moments='mvsk')
min_bound, max_bound = binom.interval(0.95,n,p)

This ever so slightly inflates the 95% confidence interval, such that nearly all of my empirical tests end up inside the interval.
What distribution am I supposed to be using here instead?
How can I calculate a one sided interval for this distribution (since python can only do a 2 sided one)
Why?:
I'm building a model for genome read coverage and I need to create a lower bound for percentage of genome (of length g) covered given n reads of length k.
Rather than trying to compute it directly, I'm using this simplification:
Divide the genome into m=g/k buckets, each of length ~k.  Assume each read covers exactly 1 bucket.


Q: Get Gps location(long,lat) and time in this Android application I need help form my android app. in this app,NOW, i take some data from a form end then i put it on a db. but i need to show and i need to put in to a db the current GPS Location and the Current Time Too.I already tried to use tutorial and see other posts on the forum with NO results. I need help because I don't understand how to work the location Listener and whereI have to change the project.
Thanks.
This is my Code
FORM.java
 import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AutoCompleteTextView;

public class Form extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

    public void onAddClick(View botton) {
        AutoCompleteTextView spedID = (AutoCompleteTextView) findViewById(R.id.SpedID);
        AutoCompleteTextView spedCliente = (AutoCompleteTextView) findViewById(R.id.SpedCliente);
        AutoCompleteTextView spedCorriere = (AutoCompleteTextView) findViewById(R.id.SpedCorriere);

        Intent intent = new Intent();
        intent.setClass(this, Result.class);

        intent.putExtra("SpedID", spedID.getText().toString());
        intent.putExtra("SpedCliente", spedCliente.getText().toString());
        intent.putExtra("SpedCorriere", spedCorriere.getText().toString());
        startActivity(intent);
    }

    public void onCancelClick(View botton) {
        Intent intent = new Intent();
        intent.setComponent(new ComponentName(this, Result.class));
        intent.putExtra("Cancel", "Cancel");
        startActivity(intent);
    }

}

RESULT.java
import android.app.Activity;
import android.content.ContentValues;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.widget.TextView;

public class Result extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.result);

        TextView resultText = (TextView) findViewById(R.id.resultText);
        Bundle bundle = getIntent().getExtras();

        if (bundle.getString("Cancel") != null) {
            resultText.setText(getString(R.string.cancelOp));
        } else {
            String spedID = bundle.getString("SpedID");
            String spedCliente = bundle.getString("SpedCliente");
            String spedCorriere = bundle.getString("SpedCorriere");
            insertSpedizione(spedID, spedCliente, spedCorriere); // metodo per
                                                                    // inserire
                                                                    // dati in
                                                                    // db
            resultText.setText(getString(R.string.resultOk) + "\n" + spedID
                    + "\n" + spedCliente + "\n" + spedCorriere);
        }
    }

    private void insertSpedizione(String idsped, String cliente,
            String idcorriere) {
        // metodo insertspedizione riceve in ingresso i parametri sped,cliente
        // etc etc
        DatabaseHelper databaseHelper = new DatabaseHelper(this);
        SQLiteDatabase db = databaseHelper.getWritableDatabase(); // creo un
                                                                    // database
                                                                    // Srivibile

        ContentValues cv = new ContentValues(); // Hashmap
        cv.put(DatabaseHelper.IDSPED, idsped); // nome colonna, valore
        cv.put(DatabaseHelper.CLIENTE, cliente);// nome colonna, valore
        cv.put(DatabaseHelper.IDCORRIERE, idcorriere);// nome colonna, valore

        db.insert("spedizioni", DatabaseHelper.IDSPED, cv); // faccio un insert
                                                            // nella TABLE
                                                            // spedizioni con
                                                            // parametri IDSPED
                                                            // not null e il
                                                            // ContentValues
        db.close(); // quando abbiamo finito chiudiamo
    }

}

DATABASEHELPER.java
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseHelper extends SQLiteOpenHelper {
    public static final String DATABASE_NAME = "datasped.db"; // nome database
                                                                // che viene
                                                                // creato da
                                                                // SQLiteOpenHelper
    public static final String IDSPED = "idsped";
    public static final String CLIENTE = "cliente";
    public static final String IDCORRIERE = "idcorriere";

    public DatabaseHelper(Context context) {
        super(context, DATABASE_NAME, null, 1); // 1 è la versione iniziale del
                                                // database che viene aggiornata
                                                // con onUpgrade
    }

    @Override
    public void onCreate(SQLiteDatabase db) { // onCreate crea la
                                                // tabella(formattazione,
                                                // indici, etc) con tutti i dati
                                                // ce voglio nel .db
        db.execSQL("CREATE TABLE spedizioni (_id INTEGER PRIMARY KEY AUTOINCREMENT,idsped TEXT, cliente TEXT,idcorriere TEXT);");
    }// in questo caso mi basta creare una Table semplice con id incrementale
        // per ogni dato inserito

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // cambia
                                                                                // la
                                                                                // versione
                                                                                // del
                                                                                // database
        android.util.Log.w("spedizioni",
                "Ugrading database, which will destroy all old data");
        db.execSQL("DROP TABLE IF EXIST spedizioni");
        onCreate(db); // ricreo il Database
    }

}

MANIFEST.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="matteo.android.SpedyGo" android:versionCode="1"
    android:versionName="1.0">
    <uses-sdk android:minSdkVersion="9" />

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".Form" android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name=".Result" android:label="@string/result">
        </activity>
    </application>
</manifest>

STRINGS.xml
<resources>
    <string name="hello">Hello World, Form!</string>
    <string name="app_name">SpedyGo</string>
    <string name="InserisciSpedizione">Inserisci Spedizione</string>
    <string name="textsped">Id Spedizione</string>
    <string name="textcliente">Cliente</string>
    <string name="textCorriere">Id Corriere</string>
    <string name="cancel">Cancella</string>
    <string name="confirm">Conferma</string>

    <string name="result">Risultato</string>
    <string name="resultOk">Operazione Avvenuta con Successo</string>
    <string name="cancelOp">Operazione Cancellata</string>
</resources>

MAIN.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TextView android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:text="@string/InserisciSpedizione"
        android:textSize="30sp" android:textStyle="bold" android:gravity="center" />
    <LinearLayout android:layout_width="match_parent"
        android:layout_height="wrap_content" android:id="@+id/linearLayout1">
        <TextView android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:text="@string/textsped"
            android:textStyle="bold" android:padding="5sp" android:width="120sp"
            android:textSize="16sp"></TextView>
        <AutoCompleteTextView android:layout_weight="1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" android:width="500sp" android:id="@+id/SpedID"></AutoCompleteTextView>
    </LinearLayout>
    <LinearLayout android:layout_width="match_parent"
        android:layout_height="wrap_content" android:id="@+id/linearLayout1">
        <TextView android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:textStyle="bold"
            android:padding="5sp" android:text="@string/textcliente"
            android:textSize="16sp" android:width="120sp"></TextView>
        <AutoCompleteTextView android:layout_weight="1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" android:width="500sp" android:id="@+id/SpedCliente"></AutoCompleteTextView>
    </LinearLayout>
    <LinearLayout android:layout_width="match_parent"
        android:layout_height="wrap_content" android:id="@+id/linearLayout1">
        <TextView android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:textStyle="bold"
            android:padding="5sp" android:text="@string/textCorriere"
            android:textSize="16sp" android:width="120sp"></TextView>
        <AutoCompleteTextView android:layout_weight="1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" android:width="500sp" android:id="@+id/SpedCorriere"></AutoCompleteTextView>
    </LinearLayout>
    <LinearLayout android:layout_width="match_parent"
        android:layout_height="wrap_content" android:id="@+id/linearLayout2">
        <Button android:layout_height="wrap_content" android:text="@string/cancel"
            android:layout_width="130sp" android:onClick="onCancelClick"></Button>
        <Button android:layout_height="wrap_content" android:text="@string/confirm"
            android:layout_width="130sp" android:onClick="onAddClick"></Button>
    </LinearLayout>
</LinearLayout>

RESULT.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TextView android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:textStyle="bold"
        android:focusableInTouchMode="false" android:textSize="25sp"
        android:padding="10sp" android:gravity="center" android:text="@string/result" />
    <TextView android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:textStyle="bold"
        android:focusableInTouchMode="false" android:textSize="20sp"
        android:padding="10sp" android:gravity="center" android:text=""
        android:id="@+id/resultText" />

</LinearLayout>

A: Declare private LocationManager locationManager;
then
locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
        locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, new GeoUpdateHandler());

next create a class GeoUpdateHandler which implements LocationListener and has the function
public void onLocationChanged(Location location) {
            int lat = (int) (location.getLatitude() * 1E6);
            int lon = (int) (location.getLongitude() * 1E6);
            String tim = String.format("%d", location.getTime());}

A: Here is a simple example of retrieving the location of a user, using the Network Provider
// Acquire a reference to the system Location Manager
        myLocManager = (LocationManager)getSystemService( Context.LOCATION_SERVICE );

        // Define a listener that responds to location updates
        locationListener = new LocationListener()
        {
                    @Override
                    public void onLocationChanged(Location location)
                    {
                        // Return a string representation of the latitude & longitude. Pass it to the textview and update the text
                        String tempLat = ""+location.getLatitude();
                        String tempLon = ""+location.getLongitude();

                        tempLat = refineStrg( tempLat );
                        tempLon = refineStrg( tempLon );

                        // Store/set lat and long values
                        storeLat_storeLong( tempLat, tempLon );
                    }

                    @Override
                    public void onProviderDisabled(String arg0)
                    {
                        // TODO Auto-generated method stub

                    }

                    @Override
                    public void onProviderEnabled(String provider)
                    {
                        // TODO Auto-generated method stub

                    }

                    @Override
                    public void onStatusChanged(String provider, int status, Bundle extras)
                    {
                        // TODO Auto-generated method stub
                    }
        };
        // The two lines below request location updates from the network location provider
        myLocManager.requestLocationUpdates( LocationManager.NETWORK_PROVIDER, 0, 0,locationListener );

Remember to include the proper permissions in the manifest file for accessing user location (consult the website I posted in my comment)
Finally to retrieve the current time you could use the Calendar or Date class, like so:
Calendar cal = Calendar.getInstance();
cal.getTime();

Look here for info on how to use the Date class over the Calendar.


Q: Using dlls written in C# in Java Project I'm working on a Java project and I'm not very familiar with using Java
I usually use C# with aforge for my computer vision projects
now I have to use Java and I want to use the aforge DLLs which are written in C#
is there a way to do this ?
Thank you

A: It is possible, but you'll need to do some work to get them calling properly. I've never done it myself, but until someone better equipped to answer the question comes along here's a few places to start.
Take a look at the JNI (Java Native Interface, google or wikipedia can tell you more), which lets you call out from Java to other languages. There seems to be a project called jni4net ( http://jni4net.sourceforge.net ) which is intended to do exactly what you want, but it's in alpha at the moment and might not be stable enough. Still it could be worth having a look.
You can also do it yourself, calling through the JNI as a C call which will then get through to the CLR eventually, but it looks like a lot of effort. I know this isn't a quick and easy solution, but it might give you a couple of places to get started. also http://www.codeproject.com/KB/cross-platform/javacsharp.aspx seemed to be a fairly good look at how to go about it.
As all of the other answers so far have said though, it's fiddly and a pain. If you can do something else instead, it will probably be worth it.

A: Have a look at Jni4Net and this stack overflow question: is there an effective tool to convert c# to java?

A: You would have to use native calls which would a) be really irritating to keep up to date and B) defeat the huge advantage of java being cross-platform.
Your best bet might be to try to find something that can convert C# to java--or better yet recode your C# code into java.
In the long run it will save you a lot of stress.

A: No sure about this possibility but your idea is not so good.
You still can use COM or hook or try ngen but this ways all are weird.
Java is very similar C# . Try to code in Java or something like stab , I think that is much easer to code in some JVM-based langue for jvm.

A: Diferent compilers dud, it's not possible. Unless You use java sharp language in visual studio, then the compilers mach.


Q: How to zoom in and zoom out terminal console in linux I am able to zoom in the Ubuntu Terminal by Pressing Ctrl - Shift and ++ . But I donot know how to zoom out the Ubuntu Terminal.
Is there any short-cuts available for doing so?

A: Try this following method:

*

*Zoom In :  Ctrl+Shift++

*Zoom Out:  Ctrl+-

*Zoom 100%:  Ctrl+0
Hope this helps!

A: To zoom in do

ctrl Shift +

To zoom out do

ctrl -

A: Try the following keystrokes
Ctrl + -

A: Ctrl + - doesn't work for me. But a workaround is to change the shortcut for the Zoom Out action.
Right click on the terminal and select Preferences. Then Shortcuts. Then change the Shortcut Key for Zoom Out to whatever you want. I chose Ctrl + Backspace.


Q: Turning Ubuntu 18.04 Server into the Most Efficiently Wordpress Hosting Server (architecture) Dear advanced programmers,
Till now I have been using a Linux (3 core, NVME, Ubuntu 20.04) Ubuntu VPS Server to host just 5 WordPress websites, using Apache2, MySQL, PHP, certbot (doing option 2 HTTP->Https redirect). While performing Google Page Speed Insight I have found out that "Server response times (TTFB)" was horrible at least 2 seconds, while the total page load time is 2.6 seconds. This is horrible, since it is clear the Server is causing this I have executed 'sudo htop' and I have opened the same website 14 times at once (so acting like 14 unique users).
And all my 3 cores were full! 100% they cannot handle just 14 requests? So I need to change something in my architecture this can't go on like this, otherwise I need to have 4 cores VPS for just 1 website, which is too expensive. So basically I am looking for THE MOST EFFICIENT WAY to host WordPress Websites on a Linux VPS. As in the Server needs to be quick as possible in handling DATABASE requests and WWW file sharing requests.
Any smart guy who can tell me how to do it better?
What I found now:
NGINX > Apache. So exactly the same environment as before but just NGINX (I think it will actually not change so much, just a small improvement which I am not looking for). Maybe using Docker? Please help me!
Shortly: The goal of me is to have a multi-WordPress hosting so efficiently as possible on a Linux VPS.
The New Server of me (all praises to God) will have the following specs:

*

*6 CPU vCore

*16 GB RAM

*300 GB SSD

*Ubuntu 18.04 (the hosting has only 18.04, and not 20.14 :( )

The reason why I have chosen to use Linux-Ubuntu is because of its speed (efficiency) but if there are any better OS please let me know, this is my first time Linux, but Windows was too slow and expensive so I am 3 months into Linux-Ubuntu.
Here a screenshot of the sudo htop when I requested 14 times at once just one website of me, all cores are outrun immediately, while without before doing that it was just 2%. (btw Hosting is in The Netherlands, and I am requesting the website from The Netherlands):
The ScreenShot
P.s. I am thinking about using Docker, since I get every week a new customer to make a WordPress website, and I want to set it up and delete/freeze his WordPress website most efficiently as possible. Is Docker faster than LAMP/LEMP in Ubuntu, or does using Docker to execute LAMP/LEMP do make it slower?
Thanks in advanceee! #LookingForTheMostOptimalAndEfficientWordPressHostingServer

A: I followed this tutorial and it helped me a lot: https://spinupwp.com/install-wordpress-ubuntu/
Unless someone else shows me a faster way, then I will see this question as answered, thanks all.


Q: Binding a callbacks to an expiring shared_ptr? I am familiar with std::shared_ptr and std::weak_ptr and know how they work. However, I would like the std::shared_ptr to emit a callback, like a boost signal. This would allow std::weak_ptr, who still refer to the deleted object, to be cleaned up right in time.
Is there maybe already some smart pointer implementation, which will report the destruction?
Explanation
I think there might be a small design flaw in std::weak_ptrs, that can lead to false memory leaks. By "false memory leak" I mean an object, that is still accessible by the program, but whose reason of existence is not valid anymore. The difference to a true memory leak is, that the true memory leak is completely unknown by the program, while the false leak is just a part that wasn't cleaned up properly.
Another description can be found at codingwisdom.com

Use Watchers

*

*One of the problems with freeing an object is that you may have done so while other things are still pointing at it.  This introduces dangling pointers and crashes!  To combat the evil of dangling pointers, I like to use a basic "watcher" system.  This is not unlike the weak reference discussed above.  The implementation is like this:

*Create a base class "Watchable" that you derive from on objects that should broadcast when they're being deleted.  The Watchable object keeps track of other objects pointing at it.
  Create a "Watcher" smart pointer that, when assigned to, adds itself to the list of objects to be informed when its target goes away.
This basic technique will go a long way toward solving dangling pointer issues without sacrificing explicit control over when an object is to be destroyed.

Example
Let's say we implement the observer pattern using boost Boost Signals2. We have a class Observable, that contains one or more signals and another class Observer, that connects to Observable's  signals.
What would happen to Observable's slots, when a observing Observer is deleted? When we do nothing, then the connection would point to nowhere and we would probably receive a segmentation fault, when emitting the signal.
To deal with this issue, boost's slots also offer a method track(const weak_ptr<void>& tracked_object). That means, if I call track and pass a weak_ptr to Observer, then the slot won't be called when the weak_ptr expired. Instead, it will be deleted from the signal.
Where is the problem? Let's we delete an Observer and never call a certain signal of Observable ever again. In this case, the tracked connection will also never be deleted. Next time we emit the signal it will be cleaned up. But we don't emit it. So the connection just stays there and wastes resources.
A solution would be: when owning shared_ptr should emit a signal when it is destroying it's object. This would allow other other objects to clean up right in time. Everything that has a weak_ptr to the deleted object might register a callback and false memory leaks could be avoided.

A: //
// create a C function that does some cleanup or reuse of the object
//
void RecycleFunction
(
   MyClass * pObj
)
{
   // do some cleanup with pObj
}

//
// when you create your object and assign it to a shared pointer register a cleanup function
//

    std::shared_ptr<MyClass> myObj = std::shared_ptr<MyClass>(  new MyClass,
                                                                RecycleFunction);

Once the last reference expires "RecyleFunction" is called with your object as parameter. I use this pattern to recycle objects and insert them back into a pool.

A:
This would allow std::weak_ptr, who still refer to the deleted object,
  to be cleaned up right in time.

Actually, they only hold weak references, which do not prevent the object from being destroyed. Holding weak_ptrs to an object does not prevent it's destruction or deletion in any fashion.
The quote you've given sounds to me like that guy just doesn't know which objects own which other objects, instead of having a proper ownership hierarchy where it's clearly defined how long everything lives.
As for boost::signals2, that's what a scoped_connection is for- i.e., you're doing it wrong.
The long and short is that there's nothing wrong with the tools in the Standard (except auto_ptr which is broken and bad and we have unique_ptr now). The problem is that you're not using them properly.


Q: How to solve an authentication error on Belboon webservice in .NET? This is what i've tried in VB.NET, but i always get an authentication error ("Unauthorized (user= transaction=1)"):
Dim s As com.belboon.api.BelboonHandler = New com.belboon.api.BelboonHandler
s.Credentials = New System.Net.NetworkCredential(username, password)
's.RequestEncoding = Text.ASCIIEncoding.UTF8
s.UseDefaultCredentials = False
's.PreAuthenticate = True
's.UserAgent = ": Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 4.0.20506)"
's.InitializeLifetimeService()
's.UnsafeAuthenticatedConnectionSharing = False

s.getAccountInfo()

There is only an example in PHP delivered by Belboon. I've tried this too, and it works fine:
define('WSDL_SERVER', 'http://api.belboon.com/?wsdl');
// SOAP options (http://de.php.net/manual/de/soapclient.soapclient.php)
$config = array(
'login' => 'YOUR_LOGIN_NAME',
'password' => 'YOUR_WEBSERVICE_PASSWORD',
'trace' => true
);
try {
$client = new SoapClient(WSDL_SERVER, $config);
$result = $client->getAccountInfo();
echo '<pre>';
print_r($result);
} catch( Exception $e ) {

But what might the auth error in VB.NET be caused by? The credentials are definitely the same in both examples...

A: Sorry, got it myself. Like explained here:
https://intellitect.com/calling-web-services-using-basic-authentication/


Q: JSP convert string to object As the title said, I want to execute following code
<%
  String res = "response.sendError ( HttpServletResponse.SC_UNAUTHORIZED,\"You don't have enough privileges\" );";
%>
<%=res%>

so when I execute this code I need to get http 401 Unauthorized error.
Since it is in string format I get following string in browser instead of get http 401 Unauthorized error

response.sendError ( HttpServletResponse.SC_UNAUTHORIZED,"You don't have enough privileges" );

So how can I convert this string into object so that I can get http 401 Unauthorized error.

A: Just use:
<% response.sendError(...); %>

The <% ... %> delimiters already execute code directly.


Q: Android UriMatcher doesn't match wildcards I have a ContentProvider and I need to match some URIs containing UUIDs as wildcards.
UriMatcher from ContentProvider:
public static final Uri CONTENT_URI_NOTIFICATIONS = Uri.parse("content://" + AUTHORITY + "/" + BASE_PATH_NOTIFICATIONS);
public static final Uri CONTENT_URI_USERS  = Uri.parse("content://" + AUTHORITY + "/" + BASE_PATH_USERS);

private static final int NOTIFICATIONS = 40;
private static final int USER_ID = 70;

private static final UriMatcher sURIMatcher = new UriMatcher(UriMatcher.NO_MATCH);

static
{
    sURIMatcher.addURI(AUTHORITY, BASE_PATH_NOTIFICATIONS, NOTIFICATIONS);
    sURIMatcher.addURI(AUTHORITY, BASE_PATH_USERS + "/*", USER_ID);
}

Query Code for NOTIFICATIONS:
 Uri uri = Uri.parse(String.valueOf(MyContentProvider.CONTENT_URI_NOTIFICATIONS));
 return new CursorLoader(getActivity(), uri, projection, null, null, null);

Query Code for USER_ID:
String userId = "73279386-5459-4316-9ff9-7c6b7b84029a";
Uri uri = Uri.parse(MyContentProvider.CONTENT_URI_USERS + "/" + userId);
return new CursorLoader(getActivity(), uri, projection, null, null, null);

From the above UriMatcher, the NOTIFICATIONS URI matches, but the USER_ID does not. Any idea what could be wrong here ? Worth noting is that when I used to have integers instead of UUIDs for representing users and used to have # instead of * in the UriMatcher, everything worked as intended. After switching to the wildcard, the matcher stopped matching the URIs containing UUIDs.

A: Apparently the order in which you add the URIs counts. If you have set like below, USER_DETAILS won't be recognized anymore. You have to switch the order and add USER_DETAILS first.
sURIMatcher.addURI(AUTHORITY, BASE_PATH_USERS + "/*", USER_ID);
sURIMatcher.addURI(AUTHORITY, BASE_PATH_USERS + "/details", USER_DETAILS);


Q: Can't get fresh Ubuntu server to update/upgrade I've got a fresh Ubuntu 17.04 server, I've configured networking and can resolve all addresses as I'd expect, however when I run sudo apt update I get to ~19% at which point I get a load of messages indicating failures, such as...
err http://security.ubuntu.com/ubuntu zesty-security release 404 not found  [91.189.88.162 80]

and then
Repository http://security.ubuntu.com/ubuntu zesty-security does not have a release file

this is repeated several times.
All the listed URIs are reachable/resolve from terminal.
sudo apt-get upgrade

Fails with
 reading package list... done
 building dependency tree
 reading state information... done
 calculating upgrade... done
 0 upgraded, 0 newely installed, 0 to remove and 0 upgraded

The problem is that without updates I can't get any other packages to install and I'm not familiar enough with linux to deal with it.
Anyone got any thoughts on why updates aren't taking?
I know I'm supposed to be on 17.10 by now but I was hoping that'd be able to be sorted with an upgrade!

A: Ubuntu 17.04, released in 2017-April (hence 17.04) came with nine months of support; 2017-04 + 9 months = 13-Jan-2018 EOL (End-Of-Life).
Sometime after EOL (no length-of-time is defined) the repos get moved from archives.ubuntu.com (where Ubuntu versions look for updates) to old-releases.ubuntu.com, so your 17.04 is looking for updates where they were.
Given it's a clean install - just use 17.10, or an LTS (long term support; five years of support) version if you don't want to upgrade often.
If you looked (eg. opened-in-a-browser) the address you specified http://security.ubuntu.com/ubuntu has artful (17.10), xenial (16.04), trusty (14.04) & other supported releases (inc. 'in-test' 18.04), but will discover the 'zesty' (17.04) & other post-EOL release folders are gone.


Q: Inner Product on $\mathbb{R}$ and on $\mathbb{C}$ This is a question of the book Linear Algebra of Kenneth Hoffman.
Describe explicitly all inner products on $\mathbb{R}$ and on $\mathbb{C}$.
I think that if $<,>$ is one inner product on $\mathbb{R}$ (or $\mathbb{C}$) then $< ,>=K[,]$, where $[,]$ is the standard inner product. Is that correct?

A: Yes. If $x\in\mathbb{R}$ then $x=x\cdot1$ is how $x$ is written in the basis $\{1\}$ of $\mathbb{R}$, where $\cdot$ is the multiplication by an scalar. Therefore $(x,y)=(x\cdot1,y\cdot1)=xy(1,1)$. Therefore $(x,y)=(1,1)[x,y]$, in your notation $[x,y]=xy$. So, you $K$ is the number $(1,1)$.
Exactly the same explanation works for $\mathbb{C}$ except that the $y$ comes out of the scalar product as $\overline{y}$. So, we get $(x,y)=x\overline{y}(1,1)$. But $[x,y]=x\overline{y}$.
More care is needed when $\mathbb{C}$ is being considered as a vector space over $\mathbb{R}$, i.e. the scalars are only the real numbers.


Q: Can't access file in Alias-directory via download-script i'm working on a download-script atm. The php-files are located in the xampp htdocs-directory, while the folder containing the files is located on an external HDD.
I've already set up an Alias for the external drive:
<Directory "h:/Filme">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
Order allow,deny
Allow from all
</Directory>
Alias /filme "H:/Filme"

This is the download-script:
<?php

$download_dir = "filme/";
$files = array(
                "1" => "300.avi",
                "2" => "asdf.txt",
                "3" => "doc.pdf",
                "4" => "bild3.jpg",
              );
$file = $download_dir.$files[$_GET['id']];

header("Content-Type: x-type/subtype");
header("Content-Length: ".filesize($file));
header("Content-Disposition: attachment; filename=".$files[$_GET['id']]);

readfile($file);
?>

Download is started via:
asdf.txt

Now, the problem is the following:
i can acces files, like for example asdf.txt, by typing localhost/filme/asdf.txt in my browser's address-bar.
However, the file i can download using the download-script says:

Warning:  filesize(): stat failed for filme/asdf.txt in C:\Program Files\xampp\htdocs\download.php on line 26

Warning:  readfile(filme/asdf.txt): failed to open stream: No such file or directory in C:\Program Files\xampp\htdocs\download.php on line 32

And i honestly have NO idea how to fix this O.o
TY for answers etc <3

A: There is a difference between the path structure in HTTP and in the file system. PHP knows nothing about the defined alias for HTTP access.
You have to define the path to the files in a way that the file system understands. Which probably means to use
$download_dir = "H:/Filme/";


Q: Export a string or an array to CSV I have a very simple array that I'd like to export to CSV:
var uniqueCounties = ["555","123","345"];

I have tried using methods found online but I have been getting various errors, and all the methods online deal with nested arrays.
My function at the moment is converting to a string. I was hoping it would simplify the process but I'm still now sure how to progress:
function download_csv() {
        var csv = uniqueCounties.toString();
        console.log(csv);
    }

I was originally trying this method:
uniqueCounties.forEach(function(infoArray, index){

   dataString = infoArray.join(",");
   csvContent += index < data.length ? dataString+ "\n" : dataString;

});

But kept getting the error infoArray.join is not a function.

A: If you have a 2d array of strings (or anything that you are ok with toString-ing) for example:
const input = [
  ["555","123","345"],
  [1, 2, 3],
  [true, false, "foo"]
]

Then you can do something like this:
function toCsv(input) {
  return input.map(row => row.join(',')).join('\n')
}

const csvString = toCsv(input)

Resulting in this string:
555,123,345
1,2,3
true,false,foo

If you just want to convert a single 1d array to csv, like in the example then:
const uniqueCounties = ["555","123","345"]

// If you want each value as a column
const csvAsSingleRow = uniqueCounties.join(',')

// If you want each value as a row
const csvAsSingleColumn = uniqueCounties.join('\n')

This gets more and more complicated if you want to include escaping, etc... In that case I'd recommend looking for a library that does this well.


Q: Trying to multithread program. C++/CLI Hey i'm trying to multithread my program in c++/cli but i'm having problems with creating the threads the code im using is:
private: Void startThread() {
    MoveProj.Velocity = Variables.Velocity;
    MoveProj.ProjectilePos = Projectile1.ProjectilePos;
    Thread^ MotionThread1 = gcnew Thread(gcnew ParameterizedThreadStart(MoveProj, MotionThread::MoveProjectile));
    Thread^ MainThread = gcnew Thread(gcnew ThreadStart());
}

but i'm getting the errors
Error   44  error C3350: 'System::Threading::ParameterizedThreadStart' : a delegate constructor expects 2 argument(s)   c:\users\gaz\documents\visual studio 2012\projects\projectilemotion\projectilemotion\Simulation.h   344
Error   89  error C3350: 'System::Threading::ParameterizedThreadStart' : a delegate constructor expects 2 argument(s)   c:\users\gaz\documents\visual studio 2012\projects\projectilemotion\projectilemotion\Simulation.h   344
Error   45  error C3350: 'System::Threading::ThreadStart' : a delegate constructor expects 2 argument(s)    c:\users\gaz\documents\visual studio 2012\projects\projectilemotion\projectilemotion\Simulation.h   345
Error   90  error C3350: 'System::Threading::ThreadStart' : a delegate constructor expects 2 argument(s)    c:\users\gaz\documents\visual studio 2012\projects\projectilemotion\projectilemotion\Simulation.h   345
Error   43  error C3867: 'MotionThread::MoveProjectile': function call missing argument list; use '&MotionThread::MoveProjectile' to create a pointer to member c:\users\gaz\documents\visual studio 2012\projects\projectilemotion\projectilemotion\Simulation.h   344
Error   88  error C3867: 'MotionThread::MoveProjectile': function call missing argument list; use '&MotionThread::MoveProjectile' to create a pointer to member c:\users\gaz\documents\visual studio 2012\projects\projectilemotion\projectilemotion\Simulation.h   344

any help with this would be a great help as its for my college(British so senior year for americnas i think) computing project and my tutor wants it in relatively soon.

A: The error message is telling you what to do:

function call missing argument list;
    use '&MotionThread::MoveProjectile' to create a pointer to member
         ^

Therefore, here's the correct syntax:
Thread^ MotionThread1 = gcnew Thread(
    gcnew ParameterizedThreadStart(MoveProj, &MotionThread::MoveProjectile));
                                             ^

For the other one, you're currently trying to create a delegate, without telling it what method the delegate should point to. Try something like this:
Thread^ MainThread = gcnew Thread(gcnew ThreadStart(this, &MyClass::MainMethod));
                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^

Edit
I didn't read through your full code. If you expect people to take their time to help you, you need to take some time & spend the effort to distill it down to just what's needed.
I will, however, comment on the errors you're getting.

error C2440: 'initializing' :
    cannot convert from 'MotionThread' to 'MotionThread ^'

You've got a variable somewhere that's a reference type, but you're using it without the ^. This is valid C++/CLI, but none of the managed APIs will work with that easily. Switch the member to a ^ and use gcnew.

error C3352: 'float Allformvariables::CalcCurrentVelocity(System::Object ^)' :
    the specified function does not match the delegate type 'void (void)'

As the error message says: You're trying to construct a delegate that doesn't take any parameters and returns void, and the method you're passing doesn't match that. Either fix the method or switch to a different delegate type.

error C3754: delegate constructor: member function 'MotionThread::MoveProjectile'
    cannot be called on an instance of type 'MotionThread'

I have a feeling this one will go away when you add the missing ^ that I mentioned above.


Q: Issue with cron job scheduling I am trying to schedule a job every 10 minute during PST hours. What I am trying is:
0,10 8-15 * * * /path-to-script

But this thing is not working, any help is much appreciated.


Q: Questions auto bumped by the Community User even though they are locked https://serverfault.com/questions/159509/printer-on-different-networkip-range-can-i-print-to-it
This question on Server Fault was just bumped to the front page like any other question that has no upvoted answers and is a bit old. The thing is, it's been locked. Shouldn't these be treated as "closed" questions and not be poked to the front page? The documentation says that locked and closed questions aren't bumped.
As of today, the question has been bumped every month, and received its last bump 2 days ago.
The whole point of bumping these posts is to get new contributions, but a locked post can't have any content added or revised.

Edited: as of today, 2017-03-30, the same question is yet again bumped:

A: The "documentation" was wrong; the guy who wrote that was full of crap.
As far as I can tell, the system has never stopped locked questions from being bumped - they just tend to not qualify for other reasons (no answers, deleted, etc.).
In fact, it's extremely unusual to end up with a locked question that has nothing better than 0-scored answers: out of the 1.9 million questions on Stack Overflow that qualify for bumping as I type this, there are exactly two that are locked - one for a "content dispute" and another for "off-topic comments". (I've now unlocked them both.)
Excluding Stack Overflow, there are only 7 locked, bumpable questions anywhere else on the network - all of them locked for "historical significance", which means they'll never stop being bumped since the answers can never be upvoted or downvoted. I reviewed and deleted all of them, which takes care of the immediate problem.
Long-term, the proper fix here is to ensure locking is used responsibly; there's rarely ever a reason to leave a question locked for months or years at a time, and even more rarely a reason to use "historical significance" on unanswered questions - I'll make a note to review the guidance in place here.


Q: Fastest way to create a Shortcut ignoring drive mapping When I create a shortcut to a network file using standard Windows Explorer "Right-click -> Create Shortcut", the shortcut link takes advantage of my network drive mapping, which substitutes a single letter and colon for a big chunk of the path.
This makes the shortcut harder to share with my co-workers, who don't have the same mapping.
I want a shareable shortcut which links to the full path of the file, ignoring the mapping.
My current solution involves opening another instance of Windows Explorer, starting at the network root, finding the same file without using the mapped drive, then creating the shortcut.
It's acceptable since I don't do it very often, but does anyone know a better way?

A: You can always create it manually, if you know the name or the ip address of the share? You could do something like
\\servername\share

or
\\ip\share

A: The easiest way I know is to drag and drop using the Right-click on the mouse.  I actually WANT to use the mapping drive and am unable to, so my problem is your solution!


Q: Microsoft Azure - same login for windows app and web app I created two separate apps

*

*browser app (web app)
 For authentication I am using adal.js, and its working fine.

*non browser app (console app)
 for authentication adal.net and its working fine.
Problem:
For both browser app and for non browser, I have to login. so twice login on same machine.
Question.
What to do to merge these web and console app to one application, where user can authenticate once (single sign in ) and use both console app and web app.

A: As your applications are separate, essentially in the background meaning a different application ID and set of keys then merging the logins will not be possible. The authentication is based on OAuth so each application is treated as a separate resource meaning you'll need a valid token to authenticate requests against it.
Think of it another way, if you login to say Facebook or Twitter who both use OAuth then you login to the website, you have to login to the application on the mobile device again, that token cannot be used for another application.

A: It depends on the browser you were using.
If you were using the same browser for the web app and console app, the Azure AD will issue the cookies when you first time. And then the second sign-in request should be sign-in without users enter the credential again based on the cookies.


Q: Overriding default SWIG name for static class functions I have several classes that I am using swig to wrap for an embedded Lua script. We have already defined what we want the function calls to look like.
display.writeLine("Hello")

The problem is that SWIG doesn't seem to have an option to define how it generates the library name. The c++ class looks like this.
class Display
{
public:
    static void writeLine(char *);
}

I can easily get SWIG to wrap this function, it's just that always shows up like this
    Display_writeLine()
So instead of just using my custom namespace, I would have to do
display.Display_writeLine()

which is not what I want. I have tried experimenting with the rename rules but nothing seems to work. Right now I have an extern C function that then calls my static function but it's an extra call I don't need. Seems like it should be something simple...

A: You can easily make a shortcut for your function that does same of function code and load the file on start:
display = {}

function display.writeline(str)
      display.Display_writeLine(str)
end


Q: Visual Studio 2012 I am Having some issues with Visual Studio 2012, When build my solution and run the debug it says MSVCP100D.dll is missing
Screen dump:

When i try to run my program using Release it compiles fine and runs but then it randomly  runs into run time error:

it then will not build any more underlining these CV_8U & CV_8UC3
I am using OpenCV library, also my code worked perfectly fine on Visual Studio 2010; but i decided to upgrade to 2012.
I would ideally Build my solution using DEBUG..........
Any solutions or suggestions...?
Regards

A: It looks like you are linking against the opencv libs for Visual Studio 2010. You will have to compile the opencv library for Visual Studio 2012 yourself as the pre-built ones are for Visual Studio 2010.
The information on how to do that can be found under Installation by Making Your Own Libraries from the Source Files.


Q: copy multiple files and give prefix and keep originals how do i copy files in unix. i want to keep the originals and add a prefix to the originals.
i have the following:
file1.csv
file2.csv
file3.csv
file4.csv
...
fileX.csv

what I will end up with after giving the command(with "H_" being the prefix in this example):
file1.csv
file2.csv
file3.csv
file4.csv
...
fileX.csv
H_file1.csv
H_file2.csv
H_file3.csv
H_file4.csv
...
H_fileX.csv

I was looking at the cp or mv command, but have no luck yet

A: for file in *.csv; do
    cp "$file" "H_$file"
done

A: for f in *.csv; do cp -v -- "$f" "H_$f"; done


Q: I can't get magnific-popup animations to work I've been through the excellent documentation for this and it's great.
http://dimsemenov.com/plugins/magnific-popup/documentation.html
I have the basic pop up working fine.
My problem is with the animations. I just can't get them to work. Apologies if I've missed something very basic but I've spent too long on this now and hope someone can point out my mistake. It currently just appears no fade nothing.
I've played with it on codepen and can recreate the issue by removing the CSS so perhaps this is not getting through correctly, although I know it is linking as it is styling the pop up just not the animations.
Here is my html:

My JavaScript from the same page:

My CSS
@charset "UTF-8";
/* CSS Document */

/* Magnific Popup CSS */
.mfp-bg {
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 502;
  overflow: hidden;
  position: fixed;
  background: #0b0b0b;
  opacity: 0.8;
  filter: alpha(opacity=80); }

.mfp-wrap {
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 503;
  position: fixed;
  outline: none !important;
  -webkit-backface-visibility: hidden; }

.mfp-container {
  height: 100%;
  text-align: center;
  position: absolute;
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
  padding: 0 8px;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box; }

.mfp-container:before {
  content: '';
  display: inline-block;
  height: 100%;
  vertical-align: middle; }

.mfp-align-top .mfp-container:before {
  display: none; }

.mfp-content {
  position: relative;
  display: inline-block;
  vertical-align: middle;
  margin: 0 auto;
  text-align: left;
  z-index: 505; }

.mfp-inline-holder .mfp-content,
.mfp-ajax-holder .mfp-content {
  width: 100%;
  cursor: auto; }

.mfp-ajax-cur {
  cursor: progress; }

.mfp-zoom-out-cur,
.mfp-zoom-out-cur .mfp-image-holder .mfp-close {
  cursor: -moz-zoom-out;
  cursor: -webkit-zoom-out;
  cursor: zoom-out; }

.mfp-zoom {
  cursor: pointer;
  cursor: -webkit-zoom-in;
  cursor: -moz-zoom-in;
  cursor: zoom-in; }

.mfp-auto-cursor .mfp-content {
  cursor: auto; }

.mfp-close,
.mfp-arrow,
.mfp-preloader,
.mfp-counter {
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none; }

.mfp-loading.mfp-figure {
  display: none; }

.mfp-hide {
  display: none !important; }

.mfp-preloader {
  color: #cccccc;
  position: absolute;
  top: 50%;
  width: auto;
  text-align: center;
  margin-top: -0.8em;
  left: 8px;
  right: 8px;
  z-index: 504; }

.mfp-preloader a {
  color: #cccccc; }

.mfp-preloader a:hover {
  color: white; }

.mfp-s-ready .mfp-preloader {
  display: none; }

.mfp-s-error .mfp-content {
  display: none; }

button.mfp-close,
button.mfp-arrow {
  overflow: visible;
  cursor: pointer;
  background: transparent;
  border: 0;
  -webkit-appearance: none;
  display: block;
  padding: 0;
  z-index: 506; }

button::-moz-focus-inner {
  padding: 0;
  border: 0; }

.mfp-close {
  width: 44px;
  height: 44px;
  line-height: 44px;
  position: absolute;
  right: 0;
  top: 0;
  text-decoration: none;
  text-align: center;
  opacity: 0.65;
  padding: 0 0 18px 10px;
  color: white;
  font-style: normal;
  font-size: 28px;
  font-family: Arial, Baskerville, monospace; }
  .mfp-close:hover, .mfp-close:focus {
    opacity: 1; }
  .mfp-close:active {
    top: 1px; }

.mfp-close-btn-in .mfp-close {
  color: #333333; }

.mfp-image-holder .mfp-close,
.mfp-iframe-holder .mfp-close {
  color: white;
  right: -6px;
  text-align: right;
  padding-right: 6px;
  width: 100%; }

.mfp-counter {
  position: absolute;
  top: 0;
  right: 0;
  color: #cccccc;
  font-size: 12px;
  line-height: 18px; }

.mfp-arrow {
  position: absolute;
  top: 0;
  opacity: 0.65;
  margin: 0;
  top: 50%;
  margin-top: -55px;
  padding: 0;
  width: 90px;
  height: 110px;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0); }

.mfp-arrow:active {
  margin-top: -54px; }

.mfp-arrow:hover,
.mfp-arrow:focus {
  opacity: 1; }

.mfp-arrow:before, .mfp-arrow:after,
.mfp-arrow .mfp-b,
.mfp-arrow .mfp-a {
  content: '';
  display: block;
  width: 0;
  height: 0;
  position: absolute;
  left: 0;
  top: 0;
  margin-top: 35px;
  margin-left: 35px;
  border: solid transparent; }
.mfp-arrow:after,
.mfp-arrow .mfp-a {
  opacity: 0.8;
  border-top-width: 12px;
  border-bottom-width: 12px;
  top: 8px; }
.mfp-arrow:before,
.mfp-arrow .mfp-b {
  border-top-width: 20px;
  border-bottom-width: 20px; }

.mfp-arrow-left {
  left: 0; }
  .mfp-arrow-left:after,
  .mfp-arrow-left .mfp-a {
    border-right: 12px solid black;
    left: 5px; }
  .mfp-arrow-left:before,
  .mfp-arrow-left .mfp-b {
    border-right: 20px solid white; }

.mfp-arrow-right {
  right: 0; }
  .mfp-arrow-right:after,
  .mfp-arrow-right .mfp-a {
    border-left: 12px solid black;
    left: 3px; }
  .mfp-arrow-right:before,
  .mfp-arrow-right .mfp-b {
    border-left: 20px solid white; }

.mfp-iframe-holder {
  padding-top: 40px;
  padding-bottom: 40px; }

.mfp-iframe-holder .mfp-content {
  line-height: 0;
  width: 100%;
  max-width: 900px; }

.mfp-iframe-scaler {
  width: 100%;
  height: 0;
  overflow: hidden;
  padding-top: 56.25%; }

.mfp-iframe-scaler iframe {
  position: absolute;
  display: block;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.6);
  background: black; }

.mfp-iframe-holder .mfp-close {
  top: -40px; }

/* Main image in popup */
img.mfp-img {
  width: auto;
  max-width: 100%;
  height: auto;
  display: block;
  line-height: 0;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  padding: 40px 0 40px;
  margin: 0 auto; }

/* The shadow behind the image */
.mfp-figure:after {
  content: '';
  position: absolute;
  left: 0;
  top: 40px;
  bottom: 40px;
  display: block;
  right: 0;
  width: auto;
  height: auto;
  z-index: -1;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.6); }

.mfp-figure {
  line-height: 0; }

.mfp-bottom-bar {
  margin-top: -36px;
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  cursor: auto; }

.mfp-title {
  text-align: left;
  line-height: 18px;
  color: #f3f3f3;
  word-break: break-word;
  padding-right: 36px; }

.mfp-figure small {
  color: #bdbdbd;
  display: block;
  font-size: 12px;
  line-height: 14px; }

.mfp-image-holder .mfp-content {
  max-width: 100%; }

.mfp-gallery .mfp-image-holder .mfp-figure {
  cursor: pointer; }

@media screen and (max-width: 800px) and (orientation: landscape), screen and (max-height: 300px) {
  /**
   * Remove all paddings around the image on small screen
   */
  .mfp-img-mobile .mfp-image-holder {
    padding-left: 0;
    padding-right: 0; }

  .mfp-img-mobile img.mfp-img {
    padding: 0; }

  /* The shadow behind the image */
  .mfp-img-mobile .mfp-figure:after {
    top: 0;
    bottom: 0; }

  .mfp-img-mobile .mfp-bottom-bar {
    background: rgba(0, 0, 0, 0.6);
    bottom: 0;
    margin: 0;
    top: auto;
    padding: 3px 5px;
    position: fixed;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box; }

  .mfp-img-mobile .mfp-bottom-bar:empty {
    padding: 0; }

  .mfp-img-mobile .mfp-counter {
    right: 5px;
    top: 3px; }

  .mfp-img-mobile .mfp-close {
    top: 0;
    right: 0;
    width: 35px;
    height: 35px;
    line-height: 35px;
    background: rgba(0, 0, 0, 0.6);
    position: fixed;
    text-align: center;
    padding: 0; }

  .mfp-img-mobile .mfp-figure small {
    display: inline;
    margin-left: 5px; } }
@media all and (max-width: 800px) {
  .mfp-arrow {
    -webkit-transform: scale(0.75);
    transform: scale(0.75); }

  .mfp-arrow-left {
    -webkit-transform-origin: 0;
    transform-origin: 0; }

  .mfp-arrow-right {
    -webkit-transform-origin: 100%;
    transform-origin: 100%; }

  .mfp-container {
    padding-left: 6px;
    padding-right: 6px; } }
.mfp-ie7 .mfp-img {
  padding: 0; }
.mfp-ie7 .mfp-bottom-bar {
  width: 600px;
  left: 50%;
  margin-left: -300px;
  margin-top: 5px;
  padding-bottom: 5px; }
.mfp-ie7 .mfp-container {
  padding: 0; }
.mfp-ie7 .mfp-content {
  padding-top: 44px; }
.mfp-ie7 .mfp-close {
  top: 0;
  right: 0;
  padding-top: 0; }

  /*html,body {margin:0; padding:10px; -webkit-backface-visibility:hidden;
    background-color: #eee3da;
}*/

/* text-based popup styling */
.white-popup {
  position: relative;
  background: #FFF;
  padding: 25px;
  width:auto;
  max-width: 400px;
  margin: 0 auto;
}

/*

====== Zoom effect ======

*/
.mfp-zoom-in {

  /* start state */
  .mfp-with-anim {
    opacity: 0;
    transition: all 0.2s ease-in-out;
    transform: scale(0.8);
  }

  &.mfp-bg {
    opacity: 0;
      transition: all 0.3s ease-out;
  }

  /* animate in */
  &.mfp-ready {
    .mfp-with-anim {
      opacity: 1;
      transform: scale(1);
    }
    &.mfp-bg {
      opacity: 0.8;
    }
  }

  /* animate out */
  &.mfp-removing {

    .mfp-with-anim {
      transform: scale(0.8);
      opacity: 0;
    }
    &.mfp-bg {
      opacity: 0;
    }

  }

}

/*

====== Newspaper effect ======

*/
.mfp-newspaper {

  /* start state */
  .mfp-with-anim {
    opacity: 0;
    -webkit-transition: all 0.2s ease-in-out;
    transition: all 0.5s;

    transform: scale(0) rotate(500deg);
  }

  &.mfp-bg {
    opacity: 0;
      transition: all 0.5s;
  }

  /* animate in */
  &.mfp-ready {
    .mfp-with-anim {
      opacity: 1;
      transform: scale(1) rotate(0deg);
    }
    &.mfp-bg {
      opacity: 0.8;
    }
  }

  /* animate out */
  &.mfp-removing {

    .mfp-with-anim {
      transform: scale(0) rotate(500deg);
      opacity: 0;
    }
    &.mfp-bg {
      opacity: 0;
    }

  }

}

/*

====== Move-horizontal effect ======

*/
.mfp-move-horizontal {

  /* start state */
  .mfp-with-anim {
    opacity: 0;
    transition: all 0.3s;

    transform: translateX(-50px);
  }

  &.mfp-bg {
    opacity: 0;
      transition: all 0.3s;
  }

  /* animate in */
  &.mfp-ready {
    .mfp-with-anim {
      opacity: 1;
      transform: translateX(0);
    }
    &.mfp-bg {
      opacity: 0.8;
    }
  }

  /* animate out */
  &.mfp-removing {

    .mfp-with-anim {
      transform: translateX(50px);
      opacity: 0;
    }
    &.mfp-bg {
      opacity: 0;
    }

  }

}

/*

====== Move-from-top effect ======

*/
.mfp-move-from-top {

  .mfp-content {
   vertical-align:top;
  }

  /* start state */
  .mfp-with-anim {
    opacity: 0;
    transition: all 0.2s;

    transform: translateY(-100px);
  }

  &.mfp-bg {
    opacity: 0;
      transition: all 0.2s;
  }

  /* animate in */
  &.mfp-ready {
    .mfp-with-anim {
      opacity: 1;
      transform: translateY(0);
    }
    &.mfp-bg {
      opacity: 0.8;
    }
  }

  /* animate out */
  &.mfp-removing {

    .mfp-with-anim {
      transform: translateY(-50px);
      opacity: 0;
    }
    &.mfp-bg {
      opacity: 0;
    }

  }

}

/*

====== 3d unfold ======

*/
.mfp-3d-unfold {

  .mfp-content {
    perspective: 2000px;
  }

  /* start state */
  .mfp-with-anim {
    opacity: 0;
    transition: all 0.3s ease-in-out;
    transform-style: preserve-3d;
    transform: rotateY(-60deg);
  }

  &.mfp-bg {
    opacity: 0;
      transition: all 0.5s;
  }

  /* animate in */
  &.mfp-ready {
    .mfp-with-anim {
      opacity: 1;
      transform: rotateY(0deg);
    }
    &.mfp-bg {
      opacity: 0.8;
    }
  }

  /* animate out */
  &.mfp-removing {

    .mfp-with-anim {
      transform: rotateY(60deg);
      opacity: 0;
    }
    &.mfp-bg {
      opacity: 0;
    }

  }

}

/*

====== Zoom-out effect ======

*/
.mfp-zoom-out {

  /* start state */
  .mfp-with-anim {
    opacity: 0;
    transition: all 0.3s ease-in-out;
    transform: scale(1.3);
  }

  &.mfp-bg {
    opacity: 0;
      transition: all 0.3s ease-out;
  }

  /* animate in */
  &.mfp-ready {
    .mfp-with-anim {
      opacity: 1;
      transform: scale(1);
    }
    &.mfp-bg {
      opacity: 0.8;
    }
  }

  /* animate out */
  &.mfp-removing {

    .mfp-with-anim {
      transform: scale(1.3);
      opacity: 0;
    }
    &.mfp-bg {
      opacity: 0;
    }

  }

}

/*

====== "Hinge" close effect ======

*/

@keyframes hinge {
    0% { transform: rotate(0); transform-origin: top left; animation-timing-function: ease-in-out; }
    20%, 60% { transform: rotate(80deg); transform-origin: top left; animation-timing-function: ease-in-out; }
    40% { transform: rotate(60deg); transform-origin: top left; animation-timing-function: ease-in-out; }
    80% { transform: rotate(60deg) translateY(0); opacity: 1; transform-origin: top left; animation-timing-function: ease-in-out; }
    100% { transform: translateY(700px); opacity: 0; }
}

.hinge {
  animation-duration: 1s;
    animation-name: hinge;
}
.mfp-with-fade {
  // before-open state
  .mfp-content,
  &.mfp-bg {
    opacity: 0;
    transition: opacity .5s ease-out;
  }
  // open state
  &.mfp-ready {
    .mfp-content {
     opacity: 1;
    }
    &.mfp-bg {
      opacity: 0.8; // background opacity
    }
  }

  // closed state
  &.mfp-removing {
    &.mfp-bg {
      opacity: 0;
    }
  }
}

A: I ran into this same problem and after banging my head against all the hard surfaces in my office I discovered that I need to rename the css classes to match the fade example he provided here.
So for example the mfp-zoom-out animation:
.mfp-zoom-out .mfp-with-anim should be .mfp-zoom-out.mfp-bg
.mfp-zoom-out.mfp-bg stays the same
.mfp-zoom-out.mfp-ready .mfp-with-anim should be .mfp-zoom-out.mfp-ready .mfp-content
.mfp-zoom-out.mfp-ready.mfp-bg should be .mfp-zoom-out.mfp-bg.mfp-ready
.mfp-zoom-out.mfp-removing .mfp-with-anim should be .mfp-zoom-out.mfp-removing .mfp-content
.mfp-zoom-out.mfp-removing.mfp-bg should be .mfp-zoom-out.mfp-bg.mfp-removing

A: You can also make great use of animate.css (http://daneden.github.io/animate.css/). Once you initialize the popup make sure you add animate class along with the desired animation class from the library. For example animate fadeIn.

A: Check i have code for Fade-zoom animation for first dialog and Fade-move animation for second dialog.
You can get magnific-popup.css and magnific-popup.min.js files in the dist folder...Files can be downloaded from https://github.com/dimsemenov/Magnific-Popup

    <title></title>

 <link rel="stylesheet" href="magnific-popup.css">

Dialog with CSS animation

      Open with fade-zoom animation

      Open with fade-slide animation

Dialog example

This is dummy copy. It is not meant to be read. It has been placed here solely to demonstrate the look and feel of finished, typeset text. Only for show. He who searches for meaning here will be sorely disappointed.

A: In case anyone interested in the .mfp-move-from-top animation below is the code:
.mfp-move-from-top .mfp-content{
    vertical-align:bottom;
}

.mfp-move-from-top .mfp-with-anim{
    opacity: 0;
    transition: all 0.2s;
    transform: translateY(-100px);
}

.mfp-move-from-top.mfp-bg {
    opacity: 0;
    transition: all 0.2
}

.mfp-move-from-top.mfp-ready .mfp-with-anim {

    opacity: 1;
    transform: translateY(0);
}

.mfp-move-from-top.mfp-bg.mfp-ready {
    opacity: 0.8;

}

.mfp-move-from-top.mfp-removing .mfp-with-anim {
    transform: translateY(-50px);
    opacity: 0;
}

.mfp-move-from-top.mfp-removing.mfp-bg {
    opacity: 0;
}

A: I had the same problem. found the solution here:
just change
beforeOpen: function() {
    this.st.mainClass = this.st.el.attr('data-effect');
}
to this (adds a space and then the class, in case option is being used):

into
beforeOpen: function() {
    this.st.mainClass += ' ' + this.st.el.attr('data-effect');
}


Q: How to fix an error with implementation socket.io in Chrome Extension? I want to use socket.io in its extension, but when I import the library, it throws the error "Uncaught ReferenceError: document is not defined". I realized that this socket.io does document and window checks, however, in the background.js I can't use either the document API or the window object. I use manifest v3. What should I do to use sockets?
error image
background.js image


Q: Como salvar um vídeo capturado pela webcam sem mostrá-lo usando OpenCV em python? Estou começando a aprender Computer Vision. Estou usando o módulo OpenCV para Python 3. Lendo tutoriais, decobri o seguinte script:
import cv2

cap = cv2.VideoCapture(0)

fourcc = cv2.VideoWriter_fourcc(*'DIVX')
out = cv2.VideoWriter('output.avi',fourcc, 20.0, (640,480))

while(cap.isOpened()):
    ret, frame = cap.read()
    if ret==True:
        out.write(frame)

        cv2.imshow('frame',frame)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
    else:
        break

cap.release()
out.release()
cv2.destroyAllWindows()

Ele mostra imagens capturadas pela webcam e as salva em um vídeo. O script se encerra ao pressionar a tecla "q". Porém, eu gostaria de um script que salvasse o vídeo mas não o mostrasse. Tentei retirar a seguinte linha do script:
cv2.imshow('frame',frame)

Deu certo, porém o script não se encerrava mais ao pressionar a tecla "q", porque a tecla deve ser pressionada na janela que é aberta com a parte do script que eu retirei. Então como posso criar uma condição de parada sem criar a janela que mostra o vídeo?

A: O problema é que a função waitKey do OpenCV depende da existência de uma janela para capturar uma tecla pressionada (isto é, a tecla é de fato pressionada no contexto da janela que, portanto, precisa não apenas existir como também estar com o foco).
Se você não cria uma janela e usa essa função com um timeout (você usou 1 milissegundo), a função apenas espera o tempo e retorna -1 porque jamais uma tecla vai ser pressionada.
Se você deseja encerrar de forma "elegante" mas sem usar uma janela, uma sugestão é simplesmente capturar o sinal de término do processo no terminal (isto é, capturar o pressionamento das teclas CTRL+C. Eis um exemplo (que contém outras pequenas sugestões de melhoria também):
import sys
import signal
import cv2

end = False

# --------------------------------------
def signal_handler(signal, frame):
    global end
    end = True

# --------------------------------------
cap = cv2.VideoCapture(0)

# Tenta abrir a webcam, e já falha se não conseguir
if not cap.isOpened():
    print('Não foi possível abrir a web cam.')
    sys.exit(-1)

# Cria o arquivo de video de saída
fourcc = cv2.VideoWriter_fourcc(*'DIVX')
out = cv2.VideoWriter('output.avi',fourcc, 20.0, (640,480))

# Captura o sinal de CTRL+C no terminal
signal.signal(signal.SIGINT, signal_handler)
print('Capturando o vídeo da webcam -- pressione Ctrl+C para encerrar...')

# Processa enquanto o usuário não encerrar (com CTRL+C)
while(not end):
    ret, frame = cap.read()
    if ret:
        out.write(frame)
    else:
        print('Oops! A captura falhou.')
        break

print('Captura encerrada.')

# Encerra tudo
cap.release()
out.release()

Se esperar o pressionamento de CTRL+C também não serve pra você, você vai ter que usar outra alternativa dependendo da sua necessidade. Você pode implementar um contador de tempo e encerrar após um intervalo pré-programado (usando o agendamento de tarefas) ou mesmo encerrar a partir da indicação por outro programa (usando comunicação entre processos).


Q: comparing Gregorian calendar date values I am trying to set up part of a program that allows a person to view transactions of an account based on the date of the transaction. The user enters the month day and year to view transactions and that is compared to the date that is connected to a given transaction. I am having difficult writing the lines of code that determine if the date is equal
if(aBank.getAccounts().get(i).getTransaction().get(j).getTransDate().get(Calendar.MONTH).compareTo(month)==0){
                        if(aBank.getAccounts().get(i).getTransaction().get(j).getTransDate().get(Calendar.DAY_OF_MONTH).compareTo(day)==0){
                            if(aBank.getAccounts().get(i).getTransaction().get(j).getTransDate().get(Calendar.YEAR).compareTo(year)==0){

The error that I am receiving is "cannot invoke compareTo(int) on the primitive type int"
see full code below:
System.out.println("Enter the account number of the account that you want to view transactions for");
            number=keyboard.nextLong();
            System.out.println("Enter the month day and year of the date that the transactions were completed");
            int month=keyboard.nextInt()-1;
            int day=keyboard.nextInt();
            int year=keyboard.nextInt();
            found=false;
            try{
            for(int i=0;i<aBank.getAccounts().size();i++){
                if (aBank.getAccounts().get(i).getAccountNumber().compareTo(number)==0){
                    found=true;
                    System.out.println("Below is a list of transactions completed on "+month+ "/" +day+ "/" +year);
                    for (int j=0;j<aBank.getAccounts().get(i).getTransaction().size();j++){
                    if(aBank.getAccounts().get(i).getTransaction().get(j).getTransDate().get(Calendar.MONTH).compareTo(month)==0){
                        if(aBank.getAccounts().get(i).getTransaction().get(j).getTransDate().get(Calendar.DAY_OF_MONTH).compareTo(day)==0){
                            if(aBank.getAccounts().get(i).getTransaction().get(j).getTransDate().get(Calendar.YEAR).compareTo(year)==0){
                                aBank.getAccounts().get(i).getTransaction().get(j).toString();
                                break;
                            }
                        }

                    }

                }

A: For primitive values you can just use ==
aBank.getAccounts().get(i).getTransaction().get(j).getTransDate().get(Calendar.YEAR)==year

A: Just use:
aBank.getAccounts().get(i).getTransaction().get(j).getTransDate().get(Calendar.MONTH) == month

A: If all of the XYZ.getTransDate() returns Calendar, then
XYZ.getTransDate().get(SOMETHING) returns  primitive int. Primitives do not have comapreTo method, just use ==
so instead of XYZ.getTransDate().get(MONTH).compareTo(month) == 0 use
XYZ.getTransDate().get(MONTH) == month

A: This should work:
Calendar transDate = aBank.getAccounts().get(i).getTransaction().get(j).getTransDate();
if (transDate.get(Calendar.YEAR) == year &&
    transDate.get(Calendar.MONTH) == month &&
    transDate.get(Calendar.DAY_OF_MONTH) == day) {

    // do something
}

Even better if you use something like Apache Commons Lang:
if (DateUtils.isSameDay(aBank.getAccounts().get(i).getTransaction().get(j).getTransDate(),
                        Calendar.getInstance().set(year, month, day)) {
    ...
}


Q: Wildfly 10 : log which cipher is used for https Before removing/restricting ciphers enabled on https-listener, I would like to identify which cipher is used by clients.
How could I make a log file of that ?
Thank you


Q: Recaptcha Solving With Python In Selenium Chrome Session (2Captcha) I want to resolve ReCaptcha on websites via Python with the Selenium module.
My question is: How can I send a 2Captcha request from within the Selenium Chrome Browser, that resolves the ReCaptcha and validates the successful outcome within the selenium chrome page?
I want the script to click on the submit button after it is resolved so I can continue my Selenium script.
The code below successfully resolve the ReCaptcha but that is outside Selenium.
import requests
from time import sleep

# Add these values
API_KEY = 'FILLINAPIKEYHERE'  # Your 2captcha API KEY
site_key = 'FILLINTHEPAGE'SRECAPTCHAKEYHERE'  # site-key, read the 2captcha docs on how to get this
url = 'THEWEBPAGETHATNEEDSRESOLVEMENT'  # example url
proxy = 'PROXY:PORTINHERE'  # example proxy

proxy = {'http': 'http://' + proxy, 'https': 'https://' + proxy}

s = requests.Session()

# here we post site key to 2captcha to get captcha ID (and we parse it here too)
captcha_id = s.post("http://2captcha.com/in.php?key={}&method=userrecaptcha&googlekey={}&pageurl={}".format(API_KEY, site_key, url), proxies=proxy).text.split('|')[1]
# then we parse gresponse from 2captcha response
recaptcha_answer = s.get("http://2captcha.com/res.php?key={}&action=get&id={}".format(API_KEY, captcha_id), proxies=proxy).text
print("solving ref captcha...")
while 'CAPCHA_NOT_READY' in recaptcha_answer:
    sleep(5)
    recaptcha_answer = s.get("http://2captcha.com/res.php?key={}&action=get&id={}".format(API_KEY, captcha_id), proxies=proxy).text
recaptcha_answer = recaptcha_answer.split('|')[1]

# we make the payload for the post data here, use something like mitmproxy or fiddler to see what is needed
payload = {
    'key': 'value',
    'gresponse': recaptcha_answer  # This is the response from 2captcha, which is needed for the post request to go through.
    }

# then send the post request to the url
response = s.post(url, payload, proxies=proxy)

# And that's all there is to it other than scraping data from the website, which is dynamic for every website.


Q: “Nevertheless” vs. “but”

*

*We can't afford to buy a new car. [Nevertheless | But], my wife wants to continue to look for one.

*Sales of new cars have been down the past six months, [nevertheless | but] this is expected to change soon.

Which one must be chosen in each case? Which one would you use?

A: "We can’t afford to buy a new car. Nevertheless, my wife wants to continue to look for one."
Nevertheless is an adverb usually following a concession  make sense in the sentence, consequently  can be used, and conveys the meaning that second sentence follows a concession. As an adverb it also modifies and tells us about the second sentence.
"We can’t afford to buy a new car. But, my wife wants to continue to look for one."
But is a conjunction which conveys the meaning of a generic opposition, contrast: even if we can’t afford to buy a new car, my wife still wants to continue to look for one.
"Sales of new cars have been down the past six month, nevertheless, this is expected to change soon."
Nevertheless conveys the opposition of the second sentence against first sentence, and tells us about the status of the second sentence which is going to change.
"Sales of new cars have been down the past six month, but, this is expected to change soon."
But as a conjunction transmits a simple, generic opposition (contrast) sense.
As a result both words can be used, nevertheless they transmit different meanings and have different functions.

A:
nevertheless = never the less

It means "will not become worse".
So the sentence before it will say a bad situation, and then the sentence after it will say the situation will become a little better.
The word "but" is a neutral vocabulary.
One reference is from Wiktionary: https://en.m.wiktionary.org/wiki/nevertheless


Q: html FileReader : convert blob to image file? client side code

   <input type='file' id='fileInput'class='width70_prop' onchange="readURL(this);"></input>
   <button onclick="sendPost()">sendPost</button>

serverside code

    <?
          $FileName = $_POST['img_name'];
          $data = $_POST['data'];
          list($header, $content) = split('[,]', $data);
          file_put_contents($FileName, base64_decode($content));
          print "Data Written";
     ?>

    <button onclick="showImg()">show</button>

the blob sent to server had infomation about header and its content.
when I split header then save decoded its content, it worked....
I changed above code which now works. thx guys

A: oops.. someone beat me to it...
When you read files as Dataurl on the clientside: reader.readAsDataUrl(...)
the file is encoded in to a base64 string..  That's why if you save the data directly, it's not in the correct format.
As the previous answer states, you base64_decode your data into the correct format.

A: First, there isn't anything in $_POST["data"] because the index (data) is named by the key in the JSON key : value pair, not the JavaScript var.
Secondly, you should change this:
$Handle = fopen($FileName, 'w');
fwrite($Handle, $data);
print "Data Written";
fclose($Handle);

to this:
file_put_contents($FileName, base64_decode($data));


Q: Angular *ngIf Condition with OR in component html I am trying to get an *ngIf with an OR but the second option is ignored.
Here is the code:

  show something

How can I get this to work?

A: Using router.url != '/one' || router.url != '/two' means:
If router.url != '/one' returns true

If router.url != '/two' returns true

The second condition is never evaluated if the first condition is met because you are using OR

A: That's correct that you second condition is ignored, as when router.url != '/one' it already satisfies condition and second one is never evaluated, try this way

  show something

A: Run this code, maybe it'll explain something:

Current URL: {{ router.url }}

Statement: router.url != '/one' - {{ router.url != '/one' }}

Statement: router.url != '/two' - {{ router.url != '/two' }}

Statement: router.url != '/one' || router.url != '/two' - {{ router.url != '/one' || router.url != '/two' }}

  show something

A: Your condition is always true, because it checks if a value is either different from either one or another. So the condition would only be false if router.url were at the same time equal to both '/one' and '/two', which is logically impossible.

A: Check your values to make sure the problem is not related to your data and replace != by !==.
However, in your case, I think you should be using and &&, because with an ||, your div will show up since if your route is /one or /two the condition will be true.
Try this:

  show something

Which is the same as:

  show something


Q: PostgresQL grouping columns with aggregate I currently have a table with the following columns:
asset, asset_alt, price, price_alt, time

Trying to view the combined values to ideally return something like this:
asset, price, time

Wherein the asset and asset_alt values would be combined into one column (asset) and the price would be derived from either price or price_alt depending on the asset.
I have tried something like this, but it doesn't provide proper averages for the assets and also doesn't follow the ideal return format mentioned above.
SELECT
ab.asset,
ab.asset_alt,
time_bucket('01:00:00'::interval, ab."time") AS bucket,
avg(ab.price) AS price,
avg(ab.price_alt) AS price_alt,
FROM assets ab
GROUP BY ab.asset, ab.asset_alt, (time_bucket('01:00:00'::interval, ab."time"));

A:
Wherein the asset and asset_alt values would be combined into one column (asset)
What is a relation between asset_alt and asset?

If asset_alt is empty then use asset:
select
COALESCE(ab.asset_alt, ab.asset) AS asset, -- join assets columns in one
-- use right price column
CASE
  WHEN ab.asset_alt IS NOT NULL THEN ab.price_alt
  ELSE ab.price
END AS price
 FROM FROM assets ab
GROUP BY
  COALESCE(ab.asset_alt, ab.asset),
  CASE
   WHEN ab.asset_alt IS NOT NULL THEN ab.price_alt
   ELSE ab.price
  END


Q: Laravel and Angular. Issue with query results from Laravel when I search using Postman and Chrome I'm using Angular 4 and Laravel 5.4.
When I'm using Postman and querying the next route: http://ventas.dev./api/ubigeo, it return two records because I have the next code:
$tot = Ubigeo::where('dist', 'like', '%'. $request->input('term') . '%')->count();
return response()->json(["ubigeo" => $tot], 201);

But when I call the same route from Angular it return all records from Ubigeo table.
Why I have this problem?
From Postman:
https://ibb.co/n5PraF
From Chrome (Angular):
https://ibb.co/bW8HFF

A: How many results do you get when you fire the reuquest directly on your database? Which result are you getting?
Is it possible that there is an error with your custom route? Do you have two server running?

A: My error was stupid. I was sending a null value in my term variable:
let obj = 'term='+term;

And it was necessary to do so:
let obj = {term: term};

All my new Angular function service code is:
loadUbigeo(term:string){
    let obj = {term: term};
    let body = JSON.stringify(obj);
    let headers = new Headers({
      'Content-Type': 'application/json'
    });

    return this.http.post(`${this.sett.url}/ubigeo`, body, { headers })
                    .map(res => {
                      return res.json();
                    });
  }


Q: IntelliJ gets stuck on "Copying resources" Had a problem trying to debug a Java application that I had using IntelliJ IDEA 13.
When attempting debugging, it would get stuck in the make process, displaying "Copying resources" indefinitely.

A: For some reason, it got stuck because I had manually created two named pipes in the same folder. Deleting the pipes allowed the make process to terminate successfully.
EDIT: I'm only posting this because Googling did not give me any good results, and I think it would save someone else some time if they could find it easily when it occurs.

A: I was having the same problem. I think its because i had setup angular project for UI inside my webapp folder, because of this it was loading all the dependencies from node_modules folder which takes lot of time.
When i took backup of my that angular project and deleted it from the webapp, it worked.


Q: Availability of SSO in Outlook addin The Identity API requirement sets lists that the SSO is still in preview for Office addin.
Any tentative dates when SSO will be available for Outlook-addin ?

A: SSO is currently available in the Preview API Requirement Set for Outlook Add-ins.

A: It is available in Outlook add-ins (in preview). Please see SSO in Office Add-ins, Preview status.


Q: My Java program compiles without any errors, but will not fully run Here is the error that I am receiving.
thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Scanner.java:864)
at java.util.Scanner.next(Scanner.java:1485)
at java.util.Scanner.nextDouble(Scanner.java:2413)

Here is the code that I am working with. I am able to enter the "last name" but then I get the error message that is displayed above. Any help would be greatly appreciated.
import java.util.*;
public class lab81
{
public static void main(String args[])
{
Scanner input = new Scanner(System.in);
System.out.print("Enter last name:");
double lastName;
lastName = input.nextDouble();
System.out.print("Enter first name:");
double firstName;
firstName = input.nextDouble();
System.out.print("Enter this years units:");
double thisYearsUnits;
thisYearsUnits = input.nextDouble();
System.out.print("Enter last years units:");
double lastYearsUnits;
lastYearsUnits = input.nextDouble();
double numberOfUnits = thisYearsUnits;
final double UNITS1 = 1000;
final double UNITS2 = 3000;
final double UNITS3 = 6000;
final double BONUS1 = 25;
final double BONUS2 = 50;
final double BONUS3 = 100;
final double BONUS4 = 200;
if(thisYearsUnits < lastYearsUnits)
{
   double bonusAmount;
   bonusAmount = 0;
   System.out.println(lastName + ", " + firstName);
   System.out.println("Bonus is $" + bonusAmount);
}
else if(numberOfUnits <= UNITS1)
{
   double bonusAmount;
   bonusAmount = BONUS1;
   System.out.println(lastName + ", " + firstName);
   System.out.println("Bonus is $" + bonusAmount);
}
else if(numberOfUnits <= UNITS2)
{
   double bonusAmount;
   bonusAmount = BONUS2;
   System.out.println(lastName + ", " + firstName);
   System.out.println("Bonus is $" + bonusAmount);
}
else if(numberOfUnits <= UNITS3)
{
   double bonusAmount;
   bonusAmount = BONUS3;
   System.out.println(lastName + ", " + firstName);
   System.out.println("Bonus is $" + bonusAmount);
}
else if(numberOfUnits > UNITS3)
{
   double bonusAmount;
   bonusAmount = BONUS4;
   System.out.println(lastName + ", " + firstName);
   System.out.println("Bonus is $" + bonusAmount);
}
}
}

A: You are trying to parse characters into a double and that's why it's throwing an exception.
Declare your first name & last name as strings and get them from input by using
Input.nextLine()

Instead of
Input.nextDouble()

A: Are you storing text into your firstname and lastname variables? That is obvious data type mismatch. Use Strings, they are what stores text.
String firstname;
// Stuff
firstname = input.nextLine();

Doubles are for floating point number of a certain length. Also, use int whenever possible.
final int UNITS1 = 1000;
final int UNITS2 = 3000;
final int UNITS3 = 6000;
final int BONUS1 = 25;
final int BONUS2 = 50;
final int BONUS3 = 100;
final int BONUS4 = 200;
// Stuff
int bonusAmount;

Work on your primitive datatype knowledge. Hope this helps!

A: Cases when these exception are thrown:-
InputMismatchException − if the next token does not match the Float regular expression, or is out of range
lastname=scaner.nextDouble();

At this line you would have been entering string value, however it expecting double.
NoSuchElementException − if the input is exhausted
IllegalStateException − if this scanner is closed


Q: Looking for a safe, portable password-storage method I'm working on C++ project that is supposed to run on both Win32 and Linux, the software is to be deployed to small computers, usually working in remote locations - each machine likely to contain it's own users/service-men pool.
Recently, our client has requested that we introduce access control via password protection.
We are to meet the following criteria :

*

*Support remote login

*Support remote password change

*Support remote password reset EDITED

*Support data retrieval on accidental/purposeful deletion

*Support secure storage

I'm capable of meeting the "remote" requirements using an existing library, however what I do need to consider is a method of storing this data, preferably in a way that will work on both platforms and will not let the user see it/read it, encryption is not the issue here - it's the storage method itself.
Can anyone recommend a safe storage method that could help me meet those criteria?
EDIT
We're initially considering using a portable SQLite database, however what we are interested in, is limiting the access to the file with the data to users. How can we achieve that? (file not visible to the user, file cannot be opened manually by user etc.)
EDIT 2
Cheers for the responses flowing in so far, Can we focus on ways to limit the access to the file itself? Encryption is not the issue here. What we're looking for is a way to hide and or backup the file, and only permit the "MyApp.exe" to work with it.
So far we're also investigating Alternate NTFS Streams, however we're not sure if this will work on Linux

A: For logon you want to store an iterated salted hash of the password not the password itself.  Two possibilities are:

*

*bcrypt - A modified form of blowfish that increases the work factor

*PBKDF2 - A function from the PKCS#5 spec that uses HMAC with a hash function and random salt to iterate over a password many times.

However, this will not work with your requirements:

*

*Support remote password retrieval

I am hoping you can convince the client that what they really mean is to reset the password, in which case you can still use a password hash.

*

*Support data retrieval on accidental/purposeful deletion

This requirementment is harder to work around and will require you to weaken security by storing encrypted passwords in the database so they can be reversed.  To do this you should use a master key, encrypt each password with a random IV using a cipher like AES/CBC or AES/CTR mode.  You should regularly rekey the master key and reencrypt all the passwords .  You will then need a mechanism for working out when to allow password retrieval (e.g. mother's maiden name etc)
To use the password to encrypt data use the PKDF2 function from PKCS#5 to generate a key from the password.

A: Never store the password itself. Hash the password using a salt and store that.

A: You could use a SQLite database.  As it's just a file you can use standard file permissions to restrict access. e.g. chmod 600 foo.dbs will restrict access to the file so that only the owner can read/write to it.
Then as others have suggested you store a hashed password in the database and it'll be reasonably secure.
Rumour has it that there's a commercial version of SQLite available that encrypts the entire database file.  However, this shouldn't be a substitute for storing hashed passwords, merely an addition to hashing.
edit: Here's the link to the commercial version of sqlite with support for encryption of the entire DB.

A: I'm not quite sure if I fully understand your question. But anyway.
How about setting up a user "FooUser" (assuming your product is "Foo"). Store the file / database at a location with read/write permitions only for user FooUser. Access file / database via service / daemon impersonating FooUser.

A: First and foremost, neve store the plain-text password, instead store its hash. Using a salt is a good idea too if you expect the number of users to become large enough to have password collisions.
Do you actually need to store password on all of the systems, or can you get away with a centralized, password server, solution? If a server based solution is acceptable then a decent challenge response scheme can authenticate people without revealing their password or its hash. Secure communication witht the server using certificates, to make forgery harder and then just don't allow access to the password storage on the server, through whatever means is appropriate, which can be OS specific since there is only one, or just don't let people onto the server.

A: I think the right way to go is:

*

*in memory, you concatenate user name + password + some cookie (lets say: megan fox").

You then apply a commercial hash algorithm to it. I use SHA (System.Security.Cryptography.SHA1CryptoServiceProvider) from .NET Framework but I am sure it is no problem to make it work in C++ or perhaps get it for C++.
So, even if someone gets to look the stored hash, there is no way he can know the password. Event if he wants to compare identical passwords, he will get nothing because of the user name + cookie concatenation.
Your login code must create the hash and compare it against the stored one
Problem is, you do not get to recover the password. But I think this is something good.
Hope this helps.


Q: Cypress installation on a 32-bit server For some reason, I have to install Cypress (version: 7.2.0) on a 32-bit machine. I notice that only 64-bit is supported on Linux:
https://docs.cypress.io/guides/getting-started/installing-cypress#System-requirements
But, a 32-bit release is available for Windows. So I guess it is possible to somehow build Cypress (version: 7.2.0) for 32-bit Linux. I just need some help to point me in the right direction to build and install Cypress (version: 7.2.0) on a 32-bit Linux server.
Thanks!


Q: Running multiple functions at the same time? This must be a question asked a lot, and yet I couldn't quite find what I'm looking for.
Imagine this:

*

*A program starts up "Hello, what's your name?"

*You enter a number and it goes "Your name can't be a number!"

You keep entering a number and keep getting that error, while in the background it just keeps track of how long the program has been running, by doing n++ every second, no matter what goes on in the text/input part. Eventually you could enter something like "time" and then it shows how long you've been there, in seconds...
SO my question is: Just how the hell would you go about doing that? To have them run independently?
Thanks in advance!
Edit: I'm not trying to do this timing thing in particular, it's just the easiest example I could come up with to ask about running functions independently..

A: You don't need to run parallel tasks in order to measure the elapsed time. An example in C++11:
#include <chrono>
#include <string>
#include <iostream>

int main()
{
    auto t1 = std::chrono::system_clock::now();

    std::string s;
    std::cin >> s;
    // Or whatever you want to do...

    auto t2 = std::chrono::system_clock::now();
    auto elapsedMS =
        (std::chrono::duration_cast<std::chrono::milliseconds>(t2 - t1)).count()

    std::cout << elapsedMS;
}

EDIT:
Since it seems you are interested in a way to launch several tasks in parallel, here is a hint (again, using C++11):
#include <ctime>
#include <future>
#include <thread>
#include <iostream>

int long_computation(int x, int y)
{
    std::this_thread::sleep_for(std::chrono::seconds(5));

    return (x + y);
}

int main()
{
    auto f = std::async(std::launch::async, long_computation, 42, 1729);

    // Do things in the meanwhile...
    std::string s;
    std::cin >> s;
    // And we could continue...

    std::cout << f.get(); // Here we join with the asynchronous operation
}

The example above starts a long computation that will take at least 5 seconds, and in the meanwhile does other stuff. Then, eventually, it calls get() on the future object to join with the asynchronous computation and retrieve its result (waiting until it is finished if it hasn't finished yet).

A: If you really want to use threads, not just counting time you can use boost.
Example:
include <boost/thread.hpp>

void task1() {
    // do something
}

void task2() {
    // do something
}

void main () {
    using namespace boost;
    thread thread1 = thread(task1);
    thread thread2 = thread(task2);
    thread2.join();
    thread1.join();
}

A:
I'm not trying to do this timing thing in particular, it's just the easiest example I could come up with to ask about running functions independently..

Then you may want to look into multithreading. In C++11, you can do this:
#include <thread>
#include <iostream>

void func1() {
    std::cout << "func1" << std::endl;
}

void func2() {
    std::cout << "func2" << std::endl;
}

int main() {
    std::thread td1(func1);
    std::thread td2(func2);
    std::cout << "Started 2 threads. Waiting for them to finish..." << std::endl;
    td1.join();
    td2.join();
    std::cout << "Threads finished." << std::endl;
    return 0;
}

If you're not using C++11, you still have options. You can look into:

*

*Boost Threads (Requires Boost of course)

*POSIX threads

A: Firstly you don't need to increment your own time variable.  Just record the time when the program starts and the time command will return the difference between time now and start time.
More generally -

*

*It's possible to kick off a long-running task in another thread.  You'll need to research this on your own; try googling that phrase.

*Event-driven programming might be more appropriate for this use case.  Try "C++ event driven IO" for google, or something.