问:
Save Data generated by PCLCRYPTO
I'm using PCLCRYPTO. I need to save the information in a text file in Windows to be retrieved on Android and Windows Phone.

The Encrypt function returns in Bytes and I would like to save the information in a text file to be retrieved on the other devices.

Would anyone know how to turn the bytes into text and what to write to the file to be recovered from the other devices?

The functions are:

```<code>public static byte[] EncryptAes(string data, string password, byte[] salt)
{
    byte[] key = CreateDerivedKey(password, salt);

    ISymmetricKeyAlgorithmProvider aes = WinRTCrypto.SymmetricKeyAlgorithmProvider.OpenAlgorithm(SymmetricAlgorithm.AesCbcPkcs7);
    ICryptographicKey symetricKey = aes.CreateSymmetricKey(key);
    var bytes = WinRTCrypto.CryptographicEngine.Encrypt(symetricKey, Encoding.UTF8.GetBytes(data));
    return bytes;
}

public static string DecryptAes(byte[] data, string password, byte[] salt)
{
    byte[] key = CreateDerivedKey(password, salt);

    ISymmetricKeyAlgorithmProvider aes = WinRTCrypto.SymmetricKeyAlgorithmProvider.OpenAlgorithm(SymmetricAlgorithm.AesCbcPkcs7);
    ICryptographicKey symetricKey = aes.CreateSymmetricKey(key);
    var bytes = WinRTCrypto.CryptographicEngine.Decrypt(symetricKey, data);
    return Encoding.UTF8.GetString(bytes, 0, bytes.Length);
}
</code>```

答:
The same way you get a string in the decrypt method.

```<code>Encoding.UTF8.GetString(bytes, 0, bytes.Length)
</code>```

Just save the string you get from the bytes in a text file.

Title: Save Data generated by PCLCRYPTO

Body:
I'm using PCLCRYPTO. I need to save the information in a text file in Windows to be retrieved on Android and Windows Phone.

The Encrypt function returns in Bytes and I would like to save the information in a text file to be retrieved on the other devices.

Would anyone know how to turn the bytes into text and what to write to the file to be recovered from the other devices?

The functions are:

public static byte[] EncryptAes(string data, string password, byte[] salt)
{
    byte[] key = CreateDerivedKey(password, salt);

    ISymmetricKeyAlgorithmProvider aes = WinRTCrypto.SymmetricKeyAlgorithmProvider.OpenAlgorithm(SymmetricAlgorithm.AesCbcPkcs7);
    ICryptographicKey symetricKey = aes.CreateSymmetricKey(key);
    var bytes = WinRTCrypto.CryptographicEngine.Encrypt(symetricKey, Encoding.UTF8.GetBytes(data));
    return bytes;
}

public static string DecryptAes(byte[] data, string password, byte[] salt)
{
    byte[] key = CreateDerivedKey(password, salt);

    ISymmetricKeyAlgorithmProvider aes = WinRTCrypto.SymmetricKeyAlgorithmProvider.OpenAlgorithm(SymmetricAlgorithm.AesCbcPkcs7);
    ICryptographicKey symetricKey = aes.CreateSymmetricKey(key);
    var bytes = WinRTCrypto.CryptographicEngine.Decrypt(symetricKey, data);
    return Encoding.UTF8.GetString(bytes, 0, bytes.Length);
}

Body:
The same way you get a string in the decrypt method.

Encoding.UTF8.GetString(bytes, 0, bytes.Length)

Just save the string you get from the bytes in a text file.


来源: stackexchange

问:
Save data into external files in AS3, with out server?
HI

How can I save some text information in local hard-disk with out the server support. I know shared object, but i dont use this. I need to save all these function in anther external file as text.

Is there any way to do that in AS3.0.

I don't prefer Flex, am working in Action Script 3.0 & Flash IDE

EDIT:

My swf is saved in a local machine. So
  no server interaction or browser
  interaction. the swf is running a
  local folder and read txt files from
  local folder, and save once press the
  save button.

答: You could try to use XML to save and retrieve data ( it could act as a local database)</p>

ContentLicense: CC BY-SA 2.5


问:
Is it possible to develop cross platform packages if am using mac?
I am developing a package that should target cross-platforms,
When targeting the frameworks net40 or net45x, I can't build the project, since the net40 sdk is not installed on my mac.

Is it possible to develop cross platform libraries on mac, or do I need windows to do that ?

my csproj file

```<code><Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <PackageId>ID</PackageId>
    <VersionSuffix>$(VersionSuffix)</VersionSuffix>
    <TargetFrameworks>net45;net451;netstandard1.3</TargetFrameworks>
  </PropertyGroup>

  <ItemGroup Condition=" '$(TargetFramework)' == 'net45' OR '$(TargetFramework)' == 'net451' ">
    <Reference Include="System"/>
    <Reference Include="System.Data"/>
    <Reference Include="System.Xml"/>
    <Reference Include="System.Xml.Linq"/>
    <Reference Include="Microsoft.CSharp"/>
  </ItemGroup>

  <ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
    <PackageReference Include="System.Reflection.TypeExtensions" Version="4.3.0"/>
    <PackageReference Include="ReflectionBridge" Version="0.0.12"/>
  </ItemGroup>
</Project>
</code>```

答:
When you target netstandard1.2 or lower, your library runs already on net45 and net451 according to the documentation. That is the purpose of the .NET Standard. No need to add net45 and net451.

However, if you indeed require netstandard1.3 (which is supported by net46 or higher) and want to target net40 additionally (which is not supported by any .NET Standard), there is no way to compile it on .NET Core based environment (your Mac). In this case Windows is the only option, since there is no .NET Framework SDK for Mac (which the net moniker implies).

ContentLicense: CC BY-SA 3.0

Body:
I am developing a package that should target cross-platforms,
When targeting the frameworks net40 or net45x, I can't build the project, since the net40 sdk is not installed on my mac.

Is it possible to develop cross platform libraries on mac, or do I need windows to do that ?

my csproj file

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <PackageId>ID</PackageId>
    <VersionSuffix>$(VersionSuffix)</VersionSuffix>
    <TargetFrameworks>net45;net451;netstandard1.3</TargetFrameworks>
  </PropertyGroup>

  <ItemGroup Condition=" '$(TargetFramework)' == 'net45' OR '$(TargetFramework)' == 'net451' ">
    <Reference Include="System"/>
    <Reference Include="System.Data"/>
    <Reference Include="System.Xml"/>
    <Reference Include="System.Xml.Linq"/>
    <Reference Include="Microsoft.CSharp"/>
  </ItemGroup>

  <ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
    <PackageReference Include="System.Reflection.TypeExtensions" Version="4.3.0"/>
    <PackageReference Include="ReflectionBridge" Version="0.0.12"/>
  </ItemGroup>
</Project>


问:
Pandas dataframe a particular case of merging
How can I merge the rows of the dataframe1 into the dataframe2 ?

If one of the corresponding values is NaN then the value should be
copied from the other.

If both are NaN then NaN.

If none are NaN then the first one.

Dataframe1

Dataframe2

Thanks in advance

答:
You can use combine_first:

```<code>df
Out:
   col1  col2  col3  col4
0   NaN   NaN   3.0     4
1   1.0   2.0   NaN     5

df.loc[0].combine_first(df.loc[1])
Out:
col1    1.0
col2    2.0
col3    3.0
col4    4.0
Name: 0, dtype: float64
</code>```

In the specified format:

```<code>df.loc[0].combine_first(df.loc[1]).to_frame('Row1-2').T
Out:
        col1  col2  col3  col4
Row1-2   1.0   2.0   3.0   4.0
</code>```

An alternative:

```<code>df.loc[[0]].fillna(df.loc[1])
Out:
   col1  col2  col3  col4
0   1.0   2.0   3.0     4
</code>```

And a cleaner version of filling from @MaxU:

```<code>df.bfill().iloc[[0]]
Out:
   col1  col2  col3  col4
0   1.0   2.0   3.0     4
</code>```

Body:
You can use combine_first:

df
Out:
   col1  col2  col3  col4
0   NaN   NaN   3.0     4
1   1.0   2.0   NaN     5

df.loc[0].combine_first(df.loc[1])
Out:
col1    1.0
col2    2.0
col3    3.0
col4    4.0
Name: 0, dtype: float64

In the specified format:

df.loc[0].combine_first(df.loc[1]).to_frame('Row1-2').T
Out:
        col1  col2  col3  col4
Row1-2   1.0   2.0   3.0   4.0

An alternative:

df.loc[[0]].fillna(df.loc[1])
Out:
   col1  col2  col3  col4
0   1.0   2.0   3.0     4

And a cleaner version of filling from @MaxU:

df.bfill().iloc[[0]]
Out:
   col1  col2  col3  col4
0   1.0   2.0   3.0     4


问:
QSslSocket: cannot call unresolved function
I am running Qt 5.7.1 (MSVC 2015, 32 bit) with Qt Creator 4.2.0. I have a problem with QSslSocket. I am getting the following errors:

```<code>qt.network.ssl: QSslSocket: cannot call unresolved function SSLv23_client_method
qt.network.ssl: QSslSocket: cannot call unresolved function SSL_CTX_new
qt.network.ssl: QSslSocket: cannot call unresolved function SSL_library_init
qt.network.ssl: QSslSocket: cannot call unresolved function ERR_get_error
qt.network.ssl: QSslSocket: cannot call unresolved function ERR_get_error
</code>```

I have gone to the following location openssl github and downloaded the zip file. I have moved the "libeay32.dll" and "ssleay32.dll" files to my release directory, and I am still getting these errors. Is there anyone who has gotten the QSslSocket working that can give me steps to get the socket working or has any suggestions?

答:
You need to Add support to OppenSSL manually, since android dropped the support of it, and i am using QT 5.9 and its not make it for you
so its your mission to create openSSL lib

You can download it directly here
https://wiki.openssl.org/index.php/Binaries

or here https://indy.fulgan.com/SSL/

and then copy these filed and include them to your project

```<code>libcrypto.so
libssl.so
</code>```

That should work correctly

Or you can generate your libcrypto.so and libssl.so using this script
, just follow it step by step
https://github.com/ekke/android-openssl-qt

Body:
I am running Qt 5.7.1 (MSVC 2015, 32 bit) with Qt Creator 4.2.0. I have a problem with QSslSocket. I am getting the following errors:

qt.network.ssl: QSslSocket: cannot call unresolved function SSLv23_client_method
qt.network.ssl: QSslSocket: cannot call unresolved function SSL_CTX_new
qt.network.ssl: QSslSocket: cannot call unresolved function SSL_library_init
qt.network.ssl: QSslSocket: cannot call unresolved function ERR_get_error
qt.network.ssl: QSslSocket: cannot call unresolved function ERR_get_error

I have gone to the following location openssl github and downloaded the zip file. I have moved the "libeay32.dll" and "ssleay32.dll" files to my release directory, and I am still getting these errors. Is there anyone who has gotten the QSslSocket working that can give me steps to get the socket working or has any suggestions?

Body:
You need to Add support to OppenSSL manually, since android dropped the support of it, and i am using QT 5.9 and its not make it for you
so its your mission to create openSSL lib

You can download it directly here
https://wiki.openssl.org/index.php/Binaries

or here https://indy.fulgan.com/SSL/

and then copy these filed and include them to your project

libcrypto.so
libssl.so

That should work correctly

Or you can generate your libcrypto.so and libssl.so using this script
, just follow it step by step
https://github.com/ekke/android-openssl-qt


问:
ZipFile module in Python - Runtime problems
I'm doing a little script to zip multiple folders in multiple zip files following a certain structure. I've built the structure as a list. Here are some entries:

```<code>['E:\Documents\UFSCar\Primeiro Ano\Primeiro Semestre\Cálculo 1',
'E:\Documents\UFSCar\Primeiro Ano\Segundo Semestre\Estatistica',
'E:\Documents\UFSCar\Primeiro Ano\Segundo Semestre\Estruturas Discretas',
'E:\Documents\UFSCar\Primeiro Ano\Segundo Semestre\Introdução à Engenharia']
</code>```

Down here are the 2 methods resposible for zipping the files together.

```<code>def zipit (path, archname):
    # Create a ZipFile Object primed to write
    archive = ZipFile(archname, "w", ZIP_DEFLATED) # "a" to append, "r" to read
    # Recurse or not, depending on what path is
    if os.path.isdir(path):
        zippy(path, archive)
    else:
        archive.write(path)
    archive.close()
    return "Compression of \""+path+"\" was successful!"

def zippy(path,archive):
    paths = os.listdir(path)
    for p in paths:
        p = os.path.join(path,p)
        if os.path.isdir(p):
            zippy(p,archive)
        else:
            archive.write(p)
    return
</code>```

The main part os the script is like this:

```<code>for i in range(len(myList)):
    zipit(myList[i],os.path.split(myList[i])[1])
</code>```

I've used numerical indexes because this made the script run well for a larger number of files. Before that, only 2 zipfiles we're written. This way, about 8 make its way to the end. No clue why.

The script simply iterates over the list and compresses each one as a separated zipfile. The problem happens when the size of the list is bigger. I get the following error message.

```<code>Traceback (most recent call last):
  File "E:\Documents\UFSCar\zipit.py", line 76, in <module>
    zipit(listaDisciplinas[i],os.path.split(listaDisciplinas[i])[1])
  File "E:\Documents\UFSCar\zipit.py", line 22, in zipit
    zippy(path, archive)
  File "E:\Documents\UFSCar\zipit.py", line 11, in zippy
    zippy(p,archive)
  File "E:\Documents\UFSCar\zipit.py", line 11, in zippy
    zippy(p,archive)
  File "E:\Documents\UFSCar\zipit.py", line 13, in zippy
    archive.write(p)
  File "C:\Python27\lib\zipfile.py", line 994, in write
    mtime = time.localtime(st.st_mtime)
ValueError: (22, 'Invalid argument')
</code>```

Do anyone knows what may cause this error?
thanks!

EDIT:

I've used the code provided below to teste the files, the problem were the files with problems with their "last modified" timestamp. For some reason unknown, some of them had the the last modification in the 2049 year.

In that case, the Python zipfile module failed in compressing the files as a ValueError was thrown.

My solution: edit the problematic files to chance their timestamp. Maybe someday I verify is there is a better solution.

Thanks for the help of everyone.

答:
See if this works any better. At a minimum, you'll find out which file is failing and why.</p>

```<code>import os
import os.path
from time import localtime
from zipfile import ZipFile, ZIP_DEFLATED

def zipper(zipfilename, directory):
    archive = ZipFile(zipfilename, "w", ZIP_DEFLATED)
    for root, dirs, files in os.walk(directory):
        for f in files:
            path = os.path.join(root, f)
            try:
                archive.write(path)
            except ValueError, err:
                print "Error compressing %s" % path
                s = os.stat(path)
                print s.st_mtime
                print localtime(s.st_mtime)
                print str(err)
    archive.close()

if __name__ == '__main__':
    zipper('foo.zip', '.')
</code>```

Body:
I'm doing a little script to zip multiple folders in multiple zip files following a certain structure. I've built the structure as a list. Here are some entries:

['E:\Documents\UFSCar\Primeiro Ano\Primeiro Semestre\Cálculo 1',
'E:\Documents\UFSCar\Primeiro Ano\Segundo Semestre\Estatistica',
'E:\Documents\UFSCar\Primeiro Ano\Segundo Semestre\Estruturas Discretas',
'E:\Documents\UFSCar\Primeiro Ano\Segundo Semestre\Introdução à Engenharia']

Down here are the 2 methods resposible for zipping the files together.

def zipit (path, archname):
    # Create a ZipFile Object primed to write
    archive = ZipFile(archname, "w", ZIP_DEFLATED) # "a" to append, "r" to read
    # Recurse or not, depending on what path is
    if os.path.isdir(path):
        zippy(path, archive)
    else:
        archive.write(path)
    archive.close()
    return "Compression of \""+path+"\" was successful!"

def zippy(path,archive):
    paths = os.listdir(path)
    for p in paths:
        p = os.path.join(path,p)
        if os.path.isdir(p):
            zippy(p,archive)
        else:
            archive.write(p)
    return

The main part os the script is like this:

for i in range(len(myList)):
    zipit(myList[i],os.path.split(myList[i])[1])

I've used numerical indexes because this made the script run well for a larger number of files. Before that, only 2 zipfiles we're written. This way, about 8 make its way to the end. No clue why.

The script simply iterates over the list and compresses each one as a separated zipfile. The problem happens when the size of the list is bigger. I get the following error message.

Traceback (most recent call last):
  File "E:\Documents\UFSCar\zipit.py", line 76, in <module>
    zipit(listaDisciplinas[i],os.path.split(listaDisciplinas[i])[1])
  File "E:\Documents\UFSCar\zipit.py", line 22, in zipit
    zippy(path, archive)
  File "E:\Documents\UFSCar\zipit.py", line 11, in zippy
    zippy(p,archive)
  File "E:\Documents\UFSCar\zipit.py", line 11, in zippy
    zippy(p,archive)
  File "E:\Documents\UFSCar\zipit.py", line 13, in zippy
    archive.write(p)
  File "C:\Python27\lib\zipfile.py", line 994, in write
    mtime = time.localtime(st.st_mtime)
ValueError: (22, 'Invalid argument')

Do anyone knows what may cause this error?
thanks!

EDIT:

I've used the code provided below to teste the files, the problem were the files with problems with their "last modified" timestamp. For some reason unknown, some of them had the the last modification in the 2049 year.

In that case, the Python zipfile module failed in compressing the files as a ValueError was thrown.

My solution: edit the problematic files to chance their timestamp. Maybe someday I verify is there is a better solution.

Thanks for the help of everyone.

Body:
See if this works any better. At a minimum, you'll find out which file is failing and why.

import os
import os.path
from time import localtime
from zipfile import ZipFile, ZIP_DEFLATED

def zipper(zipfilename, directory):
    archive = ZipFile(zipfilename, "w", ZIP_DEFLATED)
    for root, dirs, files in os.walk(directory):
        for f in files:
            path = os.path.join(root, f)
            try:
                archive.write(path)
            except ValueError, err:
                print "Error compressing %s" % path
                s = os.stat(path)
                print s.st_mtime
                print localtime(s.st_mtime)
                print str(err)
    archive.close()

if __name__ == '__main__':
    zipper('foo.zip', '.')


问:
how to model complex shapes using representative points?
I want to reduce the amount of white pixels in this image to just some candidate or representative points in the output image (goal is to model different types of shapes)

if you just connect the gray points in the output image together you have the same path but with less white pixels. this path should have only one starting point and one ending point and covers all path from starting to ending.

I can solve it using CCA(connected component analysis) and some if then else rules ! but it seems slow.

I need this Algorithm to reduce the amount of pixels needed to describe shapes.

what is the fastest and accurate algorithm here ?

I also welcome those methods that can increase the accuracy of shape modeling by increasing the candidate points.

答:
I experimented with approximating the contour with polylines using approxPolyDP. When the shape is closed, this is simple and always produce a good approximation. But when the shape is open, like the sample image in question, sometimes the ordering of approximated points is not maintained (I've given an example of this below). It's difficult to describe every detail of the approach, so I've commented the c++ code as best as I can. Hope this helps.

Gradient direction at polyline approximated points (red dots are polyline approx. points offset by some amount in the opposite gradient direction, and blue dots are in gradient direction):

Final approximated points (a point within a red blob) and order of navigation (blue arrows)

Example shapes and gradient directions. Note the difference between closed and open shapes. For the closed shape, the red dots are all located to one side of the stroke. For open shapes, red dots are located on both sides of the stroke.

Shape on the top left gets the order of navigation wrong because the contour doesn't start from a tip of the shape. However, it does a good pointwise approximation.

```<code>int _tmain(int argc, _TCHAR* argv[])
{
    Mat im = imread("1.png", 0);
    Mat roi = Mat::zeros(im.size(), CV_8UC1);
    /* find the gradient at every point */
    Mat dx, dy;
    Sobel(im, dx, CV_32F, 1, 0, 7);
    Sobel(im, dy, CV_32F, 0, 1, 7);
    /* take the distance transform */
    Mat dist;
    distanceTransform(im, dist, CV_DIST_L2, 5);
    /* max stroke radius */
    double th;
    minMaxLoc(dist, NULL, &th);

    /* for display/debug purposes */
    Mat rgb = Mat::zeros(im.size(), CV_8UC3);
    Mat rgb2;
    cvtColor(im, rgb2, CV_GRAY2BGR);
    Mat rgb3 = Mat::zeros(im.size(), CV_8UC3);

    Mat tmp = im.clone();
    // find contours, get every point with CV_CHAIN_APPROX_NONE
    vector<vector<Point>> contours;
    vector<Vec4i> hierarchy;
    findContours(tmp, contours, hierarchy, CV_RETR_CCOMP, CV_CHAIN_APPROX_NONE, Point(0, 0));

    for(int idx = 0; idx >= 0; idx = hierarchy[idx][0])
    {
        /* draw contours */
        drawContours(rgb, contours, idx, Scalar(0, 255, 255), 2, 8);
        drawContours(rgb2, contours, idx, Scalar(0, 255, 255), 1, 8);
        drawContours(rgb3, contours, idx, Scalar(0, 255, 255), 1, 8);

        /* polyline approximztion of the contour */
        vector<Point> poly;
        approxPolyDP(contours[idx], poly, th, false);
        /*
            now we'll sample the gradient along the points in the polyline,
            find another opposite point in the coitour in the gradient direction,
            then find the peak location in the distance image (looks like the
            mid point should also work, but I didn't try it).
        */
        for (Point& pt: poly)
        {
            /* sample dx, dy at our point of interest */
            float x = dx.at<float>(pt);
            float y = dy.at<float>(pt);
            float n = sqrtf(x*x + y*y);
            /*
                select another point in the direction of the gradient that intersects the stroke:
                by choosing a point that's around 2.5 times the max stroke radius, we hope
                to cross the stroke with this line
            */
            Point pt2(pt.x + 2.5*th*x/n, pt.y + 2.5*th*y/n);
            /* offset the first point a bit in the opposite gradient direction */
            Point pt1(pt.x - .5*th*x/n, pt.y - .5*th*y/n);
            /* draw a thick line */
            line(roi, pt1, pt2, Scalar(255, 255, 255), 2, 8);
            /*
                display the points
            */
            line(rgb3, pt1, pt2, Scalar(255, 255, 255), 2, 8);
            line(rgb2, pt1, pt2, Scalar(0, 255, 255), 2, CV_AA);
            circle(rgb2, pt1, 3, Scalar(0, 0, 255), -1, CV_AA);
            circle(rgb2, pt2, 3, Scalar(255, 0, 0), -1, CV_AA);
        }

        /* dilate the lines so that nearby lines can merge */
        Mat kernel = getStructuringElement(MORPH_ELLIPSE, Size(3, 3));
        morphologyEx(roi, roi, CV_MOP_DILATE, kernel, Point(-1, -1), 1);
        /* only for debug */
        morphologyEx(rgb3, rgb3, CV_MOP_DILATE, kernel, Point(-1, -1), 1);
        /* we are interested in lines segments that are within the shape */
        roi &= im;
        /* collect all these line segments */
        vector<vector<Point>> regions;
        findContours(roi, regions, CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE, Point(0, 0));
        /*
            now that we have all the info about lines segments,
            we can use the image for other purposes such as a mask
        */
        roi.setTo(Scalar(0, 0, 0));
        /* our points of interest when we approximate the shape */
        vector<Point> shapeApprox;
        /*
            for each point on the shape contour, see if it is within a line segment
            that we found using gradients. if so, find the peak location from the distance image.
            it is a point in the skeleton
        */
        for (Point& pt: contours[idx])
        {
            for (size_t i = 0; i < regions.size(); i++)
            {
                if (-1 != pointPolygonTest(regions[i], pt, false))
                {
                    /* using roi as a mask to find the peak location from distance image */
                    drawContours(roi, regions, i, Scalar(255, 255, 255), -1);
                    double mx;
                    Point mxLoc;
                    minMaxLoc(dist, NULL, &mx, NULL, &mxLoc, roi);
                    /*
                        if this point is not already in the list, add it.
                        as the gradient line can intersect the shape contour at two
                        points most of the time, we'll find the same peak twice
                    */
                    if (shapeApprox.end() == find(shapeApprox.begin(), shapeApprox.end(), mxLoc))
                    {
                        //cout << mx << " @ " << mxLoc << endl;
                        shapeApprox.push_back(mxLoc);
                    }
                    /* no need to test other gradient lines */
                    break;
                }
            }
            /* reset the mask */
            roi.setTo(Scalar(0, 0, 0));
        }
        /* draw the (possibly merged) gradient line segments */
        drawContours(rgb, regions, -1, Scalar(0, 0, 255), -1);
        /* draw the shape approximation */
        for (size_t i = 1; i < shapeApprox.size(); i++)
        {
            arrowedLine(rgb, shapeApprox[i-1], shapeApprox[i], Scalar(255, 0, 0), 2, CV_AA, 0, .1);
            //imshow("approx", rgb);
            //waitKey(0);
        }
    }

    imshow("debug", rgb3);
    imshow("points", rgb2);
    imshow("approx", rgb);
    waitKey(0);

    return 0;
}
</code>```

Body:
I experimented with approximating the contour with polylines using approxPolyDP. When the shape is closed, this is simple and always produce a good approximation. But when the shape is open, like the sample image in question, sometimes the ordering of approximated points is not maintained (I've given an example of this below). It's difficult to describe every detail of the approach, so I've commented the c++ code as best as I can. Hope this helps.

Gradient direction at polyline approximated points (red dots are polyline approx. points offset by some amount in the opposite gradient direction, and blue dots are in gradient direction):

Final approximated points (a point within a red blob) and order of navigation (blue arrows)

Example shapes and gradient directions. Note the difference between closed and open shapes. For the closed shape, the red dots are all located to one side of the stroke. For open shapes, red dots are located on both sides of the stroke.

Shape on the top left gets the order of navigation wrong because the contour doesn't start from a tip of the shape. However, it does a good pointwise approximation.

int _tmain(int argc, _TCHAR* argv[])
{
    Mat im = imread("1.png", 0);
    Mat roi = Mat::zeros(im.size(), CV_8UC1);
    /* find the gradient at every point */
    Mat dx, dy;
    Sobel(im, dx, CV_32F, 1, 0, 7);
    Sobel(im, dy, CV_32F, 0, 1, 7);
    /* take the distance transform */
    Mat dist;
    distanceTransform(im, dist, CV_DIST_L2, 5);
    /* max stroke radius */
    double th;
    minMaxLoc(dist, NULL, &th);

    /* for display/debug purposes */
    Mat rgb = Mat::zeros(im.size(), CV_8UC3);
    Mat rgb2;
    cvtColor(im, rgb2, CV_GRAY2BGR);
    Mat rgb3 = Mat::zeros(im.size(), CV_8UC3);

    Mat tmp = im.clone();
    // find contours, get every point with CV_CHAIN_APPROX_NONE
    vector<vector<Point>> contours;
    vector<Vec4i> hierarchy;
    findContours(tmp, contours, hierarchy, CV_RETR_CCOMP, CV_CHAIN_APPROX_NONE, Point(0, 0));

    for(int idx = 0; idx >= 0; idx = hierarchy[idx][0])
    {
        /* draw contours */
        drawContours(rgb, contours, idx, Scalar(0, 255, 255), 2, 8);
        drawContours(rgb2, contours, idx, Scalar(0, 255, 255), 1, 8);
        drawContours(rgb3, contours, idx, Scalar(0, 255, 255), 1, 8);

        /* polyline approximztion of the contour */
        vector<Point> poly;
        approxPolyDP(contours[idx], poly, th, false);
        /*
            now we'll sample the gradient along the points in the polyline,
            find another opposite point in the coitour in the gradient direction,
            then find the peak location in the distance image (looks like the
            mid point should also work, but I didn't try it).
        */
        for (Point& pt: poly)
        {
            /* sample dx, dy at our point of interest */
            float x = dx.at<float>(pt);
            float y = dy.at<float>(pt);
            float n = sqrtf(x*x + y*y);
            /*
                select another point in the direction of the gradient that intersects the stroke:
                by choosing a point that's around 2.5 times the max stroke radius, we hope
                to cross the stroke with this line
            */
            Point pt2(pt.x + 2.5*th*x/n, pt.y + 2.5*th*y/n);
            /* offset the first point a bit in the opposite gradient direction */
            Point pt1(pt.x - .5*th*x/n, pt.y - .5*th*y/n);
            /* draw a thick line */
            line(roi, pt1, pt2, Scalar(255, 255, 255), 2, 8);
            /*
                display the points
            */
            line(rgb3, pt1, pt2, Scalar(255, 255, 255), 2, 8);
            line(rgb2, pt1, pt2, Scalar(0, 255, 255), 2, CV_AA);
            circle(rgb2, pt1, 3, Scalar(0, 0, 255), -1, CV_AA);
            circle(rgb2, pt2, 3, Scalar(255, 0, 0), -1, CV_AA);
        }

        /* dilate the lines so that nearby lines can merge */
        Mat kernel = getStructuringElement(MORPH_ELLIPSE, Size(3, 3));
        morphologyEx(roi, roi, CV_MOP_DILATE, kernel, Point(-1, -1), 1);
        /* only for debug */
        morphologyEx(rgb3, rgb3, CV_MOP_DILATE, kernel, Point(-1, -1), 1);
        /* we are interested in lines segments that are within the shape */
        roi &= im;
        /* collect all these line segments */
        vector<vector<Point>> regions;
        findContours(roi, regions, CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE, Point(0, 0));
        /*
            now that we have all the info about lines segments,
            we can use the image for other purposes such as a mask
        */
        roi.setTo(Scalar(0, 0, 0));
        /* our points of interest when we approximate the shape */
        vector<Point> shapeApprox;
        /*
            for each point on the shape contour, see if it is within a line segment
            that we found using gradients. if so, find the peak location from the distance image.
            it is a point in the skeleton
        */
        for (Point& pt: contours[idx])
        {
            for (size_t i = 0; i < regions.size(); i++)
            {
                if (-1 != pointPolygonTest(regions[i], pt, false))
                {
                    /* using roi as a mask to find the peak location from distance image */
                    drawContours(roi, regions, i, Scalar(255, 255, 255), -1);
                    double mx;
                    Point mxLoc;
                    minMaxLoc(dist, NULL, &mx, NULL, &mxLoc, roi);
                    /*
                        if this point is not already in the list, add it.
                        as the gradient line can intersect the shape contour at two
                        points most of the time, we'll find the same peak twice
                    */
                    if (shapeApprox.end() == find(shapeApprox.begin(), shapeApprox.end(), mxLoc))
                    {
                        //cout << mx << " @ " << mxLoc << endl;
                        shapeApprox.push_back(mxLoc);
                    }
                    /* no need to test other gradient lines */
                    break;
                }
            }
            /* reset the mask */
            roi.setTo(Scalar(0, 0, 0));
        }
        /* draw the (possibly merged) gradient line segments */
        drawContours(rgb, regions, -1, Scalar(0, 0, 255), -1);
        /* draw the shape approximation */
        for (size_t i = 1; i < shapeApprox.size(); i++)
        {
            arrowedLine(rgb, shapeApprox[i-1], shapeApprox[i], Scalar(255, 0, 0), 2, CV_AA, 0, .1);
            //imshow("approx", rgb);
            //waitKey(0);
        }
    }

    imshow("debug", rgb3);
    imshow("points", rgb2);
    imshow("approx", rgb);
    waitKey(0);

    return 0;
}


问:
Upgrading python3.4 to python3.6 on ubuntu breaks pip
I'm attempting to install python3.6 on my machine after I currently have python3.4. However, after installation trying to run pip under python3.6 gives me the error:

```<code>Traceback (most recent call last):
  File "pip3", line 7, in <module>
    from pip import main
  File "/usr/lib/python3/dist-packages/pip/__init__.py", line 59, in <module>
    from pip.log import logger
  File "/usr/lib/python3/dist-packages/pip/log.py", line 9, in <module>
    import colorama, pkg_resources
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1520, in <module>
    register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
    from apport.packaging_impl import impl as packaging
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 20, in <module>
    import apt
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

Original exception was:
Traceback (most recent call last):
  File "pip3", line 7, in <module>
    from pip import main
  File "/usr/lib/python3/dist-packages/pip/__init__.py", line 59, in <module>
    from pip.log import logger
  File "/usr/lib/python3/dist-packages/pip/log.py", line 9, in <module>
    import colorama, pkg_resources
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1520, in <module>
    register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
</code>```

There were several comments on the internet about that error being encountered, However, none of them contain any actual resolution suggestion. Does anyone have any idea how I could fix this?

答:
I managed to solve it without installing anything from sources.
Here's what I did:

First, install pip for Python3.x (for some weird reason I didn't have it...)

```<code>$ sudo apt-get install python3-pip
</code>```

It is an old version...

```<code>$ pip3 --version
pip 1.5.4 from /usr/lib/python3/dist-packages (python 3.4)
</code>```

... so upgrade it to the latest

```<code>$ sudo pip3 install --upgrade pip
</code>```

Now it is much better

```<code>$ sudo pip3 --version
pip 9.0.1 from /usr/local/lib/python3.4/dist-packages (python 3.4)
</code>```

Then upgrade virtualenvvwrapper

```<code>$ sudo pip3 install --upgrade virtualenvwrapper
# ...
Successfully installed pbr-3.0.1 six-1.10.0 stevedore-1.22.0 virtualenv-15.1.0 virtualenv-clone-0.2.6 virtualenvwrapper-4.7.2
</code>```

Now creating a new virtualenv works:

```<code>$ mkvirtualenv -p `which python3.6` <VIRTUALENV_NAME>
</code>```

pip also works:

```<code>$ pip install django
# ...
Successfully installed django-1.11.2 pytz-2017.2

$ pip freeze
Django==1.11.2
pytz==2017.2
</code>```

Note: Now I realize it's a bit more than what you asked for, but (without knowing where exactly you failed) I guess you should be OK after step 2.

Body:
I'm attempting to install python3.6 on my machine after I currently have python3.4. However, after installation trying to run pip under python3.6 gives me the error:

Traceback (most recent call last):
  File "pip3", line 7, in <module>
    from pip import main
  File "/usr/lib/python3/dist-packages/pip/__init__.py", line 59, in <module>
    from pip.log import logger
  File "/usr/lib/python3/dist-packages/pip/log.py", line 9, in <module>
    import colorama, pkg_resources
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1520, in <module>
    register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
    from apport.packaging_impl import impl as packaging
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 20, in <module>
    import apt
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

Original exception was:
Traceback (most recent call last):
  File "pip3", line 7, in <module>
    from pip import main
  File "/usr/lib/python3/dist-packages/pip/__init__.py", line 59, in <module>
    from pip.log import logger
  File "/usr/lib/python3/dist-packages/pip/log.py", line 9, in <module>
    import colorama, pkg_resources
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1520, in <module>
    register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'

There were several comments on the internet about that error being encountered, However, none of them contain any actual resolution suggestion. Does anyone have any idea how I could fix this?

Body:
I managed to solve it without installing anything from sources.
Here's what I did:

First, install pip for Python3.x (for some weird reason I didn't have it...)

$ sudo apt-get install python3-pip

It is an old version...

$ pip3 --version
pip 1.5.4 from /usr/lib/python3/dist-packages (python 3.4)

... so upgrade it to the latest

$ sudo pip3 install --upgrade pip

Now it is much better

$ sudo pip3 --version
pip 9.0.1 from /usr/local/lib/python3.4/dist-packages (python 3.4)

Then upgrade virtualenvvwrapper

$ sudo pip3 install --upgrade virtualenvwrapper
# ...
Successfully installed pbr-3.0.1 six-1.10.0 stevedore-1.22.0 virtualenv-15.1.0 virtualenv-clone-0.2.6 virtualenvwrapper-4.7.2

Now creating a new virtualenv works:

$ mkvirtualenv -p `which python3.6` <VIRTUALENV_NAME>

pip also works:

$ pip install django
# ...
Successfully installed django-1.11.2 pytz-2017.2

$ pip freeze
Django==1.11.2
pytz==2017.2

Note: Now I realize it's a bit more than what you asked for, but (without knowing where exactly you failed) I guess you should be OK after step 2.


问:
Mandatory App update in windows store app
I have made an update for windows store app as a mandatory update. In my application I have checked weather an update is a mandatory update or not.In some machines it shows as a mandatory update and in some machines it shown as not a mandatory update. What could be the reason for it?.</p>

答:
"Shown as mandatoy update" - in there store or do you have some own logic that displays whether it's mandatory or not? For there shouldn't be any hint from MS except when talking to the update API.

The mandatory status of a package update is not enforced by Microsoft, and the OS does not provide a UI to indicate to users that a mandatory app update must be installed. Developers are intended to use the mandatory setting to enforce mandatory app updates in their own code.

Source (bottom)

Also Mattew is right, it only works for versions gte 1607 .


问:
why there is "ï»¿" when doing file comparison
in the beginning of the file when doing diff.</p>

答: UTF-8 file being interpreted as Windows-1252. Those three symbols are the UTF-8 BOM when displayed as bytes in Windows-1252 encoding.</p>


问:
If statement doesn't work, the program enters directly the "else" statement
I am trying to write a program which detects "idle" status but I don't see the problem in my code. Could someone help me please with an useful tip? Here's my code:</p>

```<code>package idlestatus;

import java.awt.MouseInfo;

public class Idlestatus {

    public static void main(String[] args) throws InterruptedException {
        Integer firstPointX = MouseInfo.getPointerInfo().getLocation().x;
        Integer firstPointY = MouseInfo.getPointerInfo().getLocation().y;
        Integer afterPointX;
        Integer afterPointY;
        while (true) {
            Thread.sleep(10000);
            afterPointX = MouseInfo.getPointerInfo().getLocation().x;
            afterPointY = MouseInfo.getPointerInfo().getLocation().y;
            if (firstPointX == afterPointX && firstPointY == afterPointY) {
                System.out.println("Idle status");
            } else {
                System.out.println("(" + firstPointX + ", " + firstPointY + ")");
            }
            firstPointX = afterPointX;
            firstPointY = afterPointY;

        }

    }
}
</code>```

答:
You are comparing two objects memory addresses , which is Integer object(wrapper class).

```<code>if (firstPointX == afterPointX && firstPointY == afterPointY)
</code>```

What you want to do is compare values in these two objects. To do that you need to use like below:

```<code>if (firstPointX.equals(afterPointX) && firstPointY.equals(afterPointY))
</code>```

Wrapper / covering classes:

There is a wrapper class for each primitive data type.

Primitive types are use for performance reasons(Which better for your
program).

Cannot create objects using primitive types.

Allows a way to create objects and manipulate basic types(i.e.
converting types).

Exsample:

```<code>Integer - int
Double - double
</code>```

Body:
I am trying to write a program which detects "idle" status but I don't see the problem in my code. Could someone help me please with an useful tip? Here's my code:

package idlestatus;

import java.awt.MouseInfo;

public class Idlestatus {

    public static void main(String[] args) throws InterruptedException {
        Integer firstPointX = MouseInfo.getPointerInfo().getLocation().x;
        Integer firstPointY = MouseInfo.getPointerInfo().getLocation().y;
        Integer afterPointX;
        Integer afterPointY;
        while (true) {
            Thread.sleep(10000);
            afterPointX = MouseInfo.getPointerInfo().getLocation().x;
            afterPointY = MouseInfo.getPointerInfo().getLocation().y;
            if (firstPointX == afterPointX && firstPointY == afterPointY) {
                System.out.println("Idle status");
            } else {
                System.out.println("(" + firstPointX + ", " + firstPointY + ")");
            }
            firstPointX = afterPointX;
            firstPointY = afterPointY;

        }

    }
}

Body:
You are comparing two objects memory addresses , which is Integer object(wrapper class).

if (firstPointX == afterPointX && firstPointY == afterPointY)

What you want to do is compare values in these two objects. To do that you need to use like below:

if (firstPointX.equals(afterPointX) && firstPointY.equals(afterPointY))

Wrapper / covering classes:

There is a wrapper class for each primitive data type.

Primitive types are use for performance reasons(Which better for your
program).

Cannot create objects using primitive types.

Allows a way to create objects and manipulate basic types(i.e.
converting types).

Exsample:

Integer - int
Double - double


问:
Disable Jupyter Notebook automatic hyperlink
In my notebook, I print some data from scraped web pages. Some of these are hyperlinks without tags e.g. https://stackoverflow.com. Unfortunately, Notebook prints these out as an actual hyperlink (i.e. wraps it in  tags) on the output page and shortens it. (So the final result in HTML looks like this: https://stacko....) The field is set to code, but this still happens. Is there a way to disable this behaviour?

答:
Solution:

Enter the following text in the empty cell of your Jupyter notebook:

```<code>%%javascript
Jupyter.utils.autoLinkUrls = function (txt) {
    return txt;
}
</code>```

Explanation:

The ability to locate URLs in text output and convert them to hyperlinks appeared in IPython notebook (a Jupyter's predecessor) as a result of a merge request in Oct' 2012. Since then every piece of output is scanned for URLs and each found URL is replaced with an anchor href=.../>. There's no easy way to alter this behavior because function autoLinkUrls(...) doesn't provide any configuration parameters.

So, the only way to disable URL "autolinking" is to simply replace JavaScript function autoLinkUrls, which is exposed through global Jupyter object, and %%javascript magic command makes the job done.

Body:
Solution:

Enter the following text in the empty cell of your Jupyter notebook:

%%javascript
Jupyter.utils.autoLinkUrls = function (txt) {
    return txt;
}

Explanation:

The ability to locate URLs in text output and convert them to hyperlinks appeared in IPython notebook (a Jupyter's predecessor) as a result of a merge request in Oct' 2012. Since then every piece of output is scanned for URLs and each found URL is replaced with an anchor <a href=.../>. There's no easy way to alter this behavior because function autoLinkUrls(...) doesn't provide any configuration parameters.

So, the only way to disable URL "autolinking" is to simply replace JavaScript function autoLinkUrls, which is exposed through global Jupyter object, and %%javascript magic command makes the job done.


问:
Experiencing a bug with this Batch code
I'm using batch to make a program that notifies when someone is on their ftp server. Now I have a script that checks then sends a command to rainmeter's NXT-OS skin to open up a notifier. It does this by trying to download a file from the ftp server, because if the file is there it means the user is online. If it isn't there then we know it is not. I have it set so the files do not exist. However right now I am experiencing a bug where it makes the whistle sound of a notification without any popup box. Can someone look at this code and see how it could be sending half of a command when nobody is online? Thanks! Note: The included code is not the whole thing since the code includes ftp server addresses and passwords. Thanks!

Get Rainmeter

(Run on Windows)

Get NXT-OS

```<code>Rem This is where it checks if the files were downloaded
if exist on.%friend1% set Friend1Stat=On
if exist on.%friend2% set Friend2Stat=On
if exist on.%friend3% set Friend3Stat=On
if exist on.%friend4% set Friend4Stat=On
if exist on.%friend5% set Friend5Stat=On

if exist on.%friend1% set /p Friend1Name=<on.%friend1%
if exist on.%friend2% set /p Friend2Name=<on.%friend2%
if exist on.%friend3% set /p Friend3Name=<on.%friend3%
if exist on.%friend4% set /p Friend4Name=<on.%friend4%
if exist on.%friend5% set /p Friend5Name=<on.%friend5%
if not exist log.txt echo. >log.txt
echo %time% %date% >>log.txt
set >>log.txt

if %Friend1Stat%==on goto friend1
goto friend1b
:back1
if %friend2stat%==on goto friend2
goto friend2b
:back2

if %friend3stat%==on goto friend3
goto friend3b
:back3

if %friend4stat%==on goto friend4
goto friend4b
:back4

if %friend5stat%==on goto friend5
goto friend5b
:back5

echo Complete. Waiting 60 seconds before starting again.
choice /c q /d q /t 60 /n
goto TESTFORFRIENDS

:friend1
if %friend1run%==yes goto back1
set friend1run=yes
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'Online-Friend1', style = 2, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = '%friend1name% is Online', body = '%friend1name% is on their computer.%time%'})" "nxt-os\Notify"
goto back1

:friend1b
if %Friend1run%==no goto back1
set friend1run=no
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'Online-Friend1', style = 2, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = '%friend1name% is Offline', body = '%friend1name% is no longer on their computer. %time%'})" "nxt-os\Notify"
goto back1

:friend2
if %friend2run%==yes goto back2
set friend2run=yes
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'Online-Friend2', style = 2, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = '%friend2name% is Online', body = '%friend2name% is on their computer.%time%'})" "nxt-os\Notify"
goto back2

:friend2b
if %Friend2run%==no goto back2
set friend2run=no
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'Online-Friend2', style = 2, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = '%friend2name% is Offline', body = '%friend2name% is no longer on their computer. %time%'})" "nxt-os\Notify"
goto back2

:friend3
if %friend3run%==yes goto back3
set friend3run=yes
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'Online-Friend3', style = 3, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = '%friend3name% is Online', body = '%friend3name% is on their computer.%time%'})" "nxt-os\Notify"
goto back3

:friend3b
if %Friend3run%==no goto back3
set friend3run=no
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'Online-Friend3', style = 3, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = '%friend3name% is Offline', body = '%friend3name% is no longer on their computer. %time%'})" "nxt-os\Notify"
goto back3

:friend4
if %friend4run%==yes goto back4
set friend4run=yes
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'Online-Friend4', style = 4, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = '%friend4name% is Online', body = '%friend4name% is on their computer.%time%'})" "nxt-os\Notify"
goto back4

:friend4b
if %Friend4run%==not goto back4
set friend4run=no
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'Online-Friend4', style = 4, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = '%friend4name% is Offline', body = '%friend4name% is no longer on their computer. %time%'})" "nxt-os\Notify"
goto back4

:friend5
if %friend5run%==yes goto back5
set friend5run=yes
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'Online-Friend5', style = 5, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = '%friend5name% is Online', body = '%friend5name% is on their computer.%time%'})" "nxt-os\Notify"
goto back5

:friend5b
if %Friend5run%==not goto back5
set friend5run=no
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'Online-Friend5', style = 5, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = '%friend5name% is Offline', body = '%friend5name% is no longer on their computer. %time%'})" "nxt-os\Notify"
goto back5

:nosettings
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'no-settings', style = 2, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = 'Set Up ITCMD Notifier', body = 'Open the Location of the Notifier and edit settings.ini Then Restart the program.'})" "nxt-os\Notify"

echo :: Set Friend Usernames here! (Users set their own usernames) >settings.ini
echo. >>settings.ini
echo set Friend1=Set>>settings.ini
echo set Friend2=Set>>settings.ini
echo Set Friend3=Set>>settings.ini
echo Set Friend4=Set>>settings.ini
echo Set Friend5=Set>>settings.ini
echo. >>settings.ini
echo. >>settings.ini
echo :: Note: Do not change anything but the friend uernames! Fatal errors could occur. >>settings.ini
exit /b
</code>```

Thanks a bunch in advance! If you have any questions let me know!

答:
I discovered something in the rainmeter log files:

```<code>Rainmeter: Debugging: ITCMD has sent an invalid notification type
</code>```

I realized that the numbers for "style" went up to 3 4 and 5 when I would use Find and replace to replace all the numbers in %friend2% or %Friend2Name% as well! Thanks for your help anyways. Hope this helps anyone else!

Title: Experiencing a bug with this Batch code

Body:
I'm using batch to make a program that notifies when someone is on their ftp server. Now I have a script that checks then sends a command to rainmeter's NXT-OS skin to open up a notifier. It does this by trying to download a file from the ftp server, because if the file is there it means the user is online. If it isn't there then we know it is not. I have it set so the files do not exist. However right now I am experiencing a bug where it makes the whistle sound of a notification without any popup box. Can someone look at this code and see how it could be sending half of a command when nobody is online? Thanks! Note: The included code is not the whole thing since the code includes ftp server addresses and passwords. Thanks!

Get Rainmeter

(Run on Windows)

Get NXT-OS

Rem This is where it checks if the files were downloaded
if exist on.%friend1% set Friend1Stat=On
if exist on.%friend2% set Friend2Stat=On
if exist on.%friend3% set Friend3Stat=On
if exist on.%friend4% set Friend4Stat=On
if exist on.%friend5% set Friend5Stat=On

if exist on.%friend1% set /p Friend1Name=<on.%friend1%
if exist on.%friend2% set /p Friend2Name=<on.%friend2%
if exist on.%friend3% set /p Friend3Name=<on.%friend3%
if exist on.%friend4% set /p Friend4Name=<on.%friend4%
if exist on.%friend5% set /p Friend5Name=<on.%friend5%
if not exist log.txt echo. >log.txt
echo %time% %date% >>log.txt
set >>log.txt

if %Friend1Stat%==on goto friend1
goto friend1b
:back1
if %friend2stat%==on goto friend2
goto friend2b
:back2

if %friend3stat%==on goto friend3
goto friend3b
:back3

if %friend4stat%==on goto friend4
goto friend4b
:back4

if %friend5stat%==on goto friend5
goto friend5b
:back5

echo Complete. Waiting 60 seconds before starting again.
choice /c q /d q /t 60 /n
goto TESTFORFRIENDS

:friend1
if %friend1run%==yes goto back1
set friend1run=yes
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'Online-Friend1', style = 2, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = '%friend1name% is Online', body = '%friend1name% is on their computer.%time%'})" "nxt-os\Notify"
goto back1

:friend1b
if %Friend1run%==no goto back1
set friend1run=no
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'Online-Friend1', style = 2, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = '%friend1name% is Offline', body = '%friend1name% is no longer on their computer. %time%'})" "nxt-os\Notify"
goto back1

:friend2
if %friend2run%==yes goto back2
set friend2run=yes
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'Online-Friend2', style = 2, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = '%friend2name% is Online', body = '%friend2name% is on their computer.%time%'})" "nxt-os\Notify"
goto back2

:friend2b
if %Friend2run%==no goto back2
set friend2run=no
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'Online-Friend2', style = 2, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = '%friend2name% is Offline', body = '%friend2name% is no longer on their computer. %time%'})" "nxt-os\Notify"
goto back2

:friend3
if %friend3run%==yes goto back3
set friend3run=yes
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'Online-Friend3', style = 3, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = '%friend3name% is Online', body = '%friend3name% is on their computer.%time%'})" "nxt-os\Notify"
goto back3

:friend3b
if %Friend3run%==no goto back3
set friend3run=no
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'Online-Friend3', style = 3, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = '%friend3name% is Offline', body = '%friend3name% is no longer on their computer. %time%'})" "nxt-os\Notify"
goto back3

:friend4
if %friend4run%==yes goto back4
set friend4run=yes
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'Online-Friend4', style = 4, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = '%friend4name% is Online', body = '%friend4name% is on their computer.%time%'})" "nxt-os\Notify"
goto back4

:friend4b
if %Friend4run%==not goto back4
set friend4run=no
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'Online-Friend4', style = 4, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = '%friend4name% is Offline', body = '%friend4name% is no longer on their computer. %time%'})" "nxt-os\Notify"
goto back4

:friend5
if %friend5run%==yes goto back5
set friend5run=yes
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'Online-Friend5', style = 5, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = '%friend5name% is Online', body = '%friend5name% is on their computer.%time%'})" "nxt-os\Notify"
goto back5

:friend5b
if %Friend5run%==not goto back5
set friend5run=no
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'Online-Friend5', style = 5, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = '%friend5name% is Offline', body = '%friend5name% is no longer on their computer. %time%'})" "nxt-os\Notify"
goto back5

:nosettings
"C:\Program files\Rainmeter\rainmeter.exe" ^!CommandMeasure "Notify" "notify({name = 'ITCMD', group = 'no-settings', style = 2, sound = 1, icon = 'Resources\\Images\\Welcome.png', title = 'Set Up ITCMD Notifier', body = 'Open the Location of the Notifier and edit settings.ini Then Restart the program.'})" "nxt-os\Notify"

echo :: Set Friend Usernames here! (Users set their own usernames) >settings.ini
echo. >>settings.ini
echo set Friend1=Set>>settings.ini
echo set Friend2=Set>>settings.ini
echo Set Friend3=Set>>settings.ini
echo Set Friend4=Set>>settings.ini
echo Set Friend5=Set>>settings.ini
echo. >>settings.ini
echo. >>settings.ini
echo :: Note: Do not change anything but the friend uernames! Fatal errors could occur. >>settings.ini
exit /b

Thanks a bunch in advance! If you have any questions let me know!

Body:
I discovered something in the rainmeter log files:

Rainmeter: Debugging: ITCMD has sent an invalid notification type

I realized that the numbers for "style" went up to 3 4 and 5 when I would use Find and replace to replace all the numbers in %friend2% or %Friend2Name% as well! Thanks for your help anyways. Hope this helps anyone else!


问:
Removing/ hiding Mongo ObjectID from the KeystoneJS URL
Is there any way to remove or hide the mongo Object ID from the URLs generated by the Keystone.js website.

Example:

When I try to go to any product posted using the CMS admin from the website I can see the exact same MongoID (_id) of that document attached with the URL:

http://abc.def/xyz/58a6d7eb177b563c595683ba

答: Within the Admin UI there isn't a way of hiding the Mongo DB item document. That's how the Admin UI knows what document it's looking at. You can create your own administrative interface that is disjoint from the one that comes with Keystone, then implement your own method for URL based document viewing (by the item's name, key, or some other meaningful information).</p>


问:
How to work with detached object in CF9?
If User is an entity, and I need to store User in Session, it will be detached on next request.

AFAIK there're only 2 methods to handle these detached objects

EntityMerge(session.user) - update DB with session's object (unsafe)

session.userID - entityLoadByPK() again on next request (more load)

Are these the only 2 workarounds?  Any other ways?

According to Advanced Techniques with ColdFusion 9 ORM Integration Slide Deck Concurrency with method #1 will throw error if entity has been changed on merge, but how is this useful? catch the exception and use method #2?

When to use EntityReload()?  I thought it works the same way as EntityMerge(entity) but it doesn't.

Thanks!

答: I generally just use a lightweight proxy object (containing top-level properties only) in session and only load the full entity as needed in exactly the same use case as you've described.  Don't use method #1 unless you really want to burn yourself (experience talking there).</p>


问:
jQuery UI Autocomplete On contenteditable with Multiple Selections
I got jQuery UI Autocomplete working on a contenteditable="true" div by adding $.fn.val = $.fn.html; to the top of the function. However, every other feature that was working on an input element has now broken using a div. The features such as setting a minimum number of characters and allowing multiple selections doesn't work anymore. I get error messages such as Can't find variable extractLast and TypeError: undefined is not an object (evaluating 'val.split'). Is there a way to let jQuery pull text() or html() from my div instead of trying to look for an input or textarea's val()?

```<code>$(function() {

    $.fn.val = $.fn.html;

    function split(val) {
        return val.split(/,\s*/);
    }

    function extractLast(term) {
        return split(term).pop();
    }

    $("#div")
        .autocomplete({
            delay: 0,
            highlightClass: "bold-text",
            autoFocus: true,
            search: function() {
                // custom minLength for multiple selections
                var term = extractLast(this.value);
                if (term.length < 3) {
                    $(this).autocomplete("close");
                    return false;
                }
            },
            source: function(request, response) {
                // delegate back to autocomplete, but extract the last term
                response($.ui.autocomplete.filter(
                    availableTags, extractLast(request.term)));
            },
            select: function(e, ui) {
                var terms = split(this.value);
                // remove the current input
                terms.pop();
                // add the selected item
                terms.push(ui.item.value);
                // add placeholder to get the comma-and-space at the end
                terms.push("");
                this.value = terms.join(", ");
                return false;
            }
        });
});
</code>```

答: Use javascript's this.innerHTML instead of this.value, but this will retrieve tags as well. Or use jQuery's $(this).text() to get the text value from an [Object HTMLDivElement].

Body:
I got jQuery UI Autocomplete working on a contenteditable="true" div by adding $.fn.val = $.fn.html; to the top of the function. However, every other feature that was working on an input element has now broken using a div. The features such as setting a minimum number of characters and allowing multiple selections doesn't work anymore. I get error messages such as Can't find variable extractLast and TypeError: undefined is not an object (evaluating 'val.split'). Is there a way to let jQuery pull text() or html() from my div instead of trying to look for an input or textarea's val()?

$(function() {

    $.fn.val = $.fn.html;

    function split(val) {
        return val.split(/,\s*/);
    }

    function extractLast(term) {
        return split(term).pop();
    }

    $("#div")
        .autocomplete({
            delay: 0,
            highlightClass: "bold-text",
            autoFocus: true,
            search: function() {
                // custom minLength for multiple selections
                var term = extractLast(this.value);
                if (term.length < 3) {
                    $(this).autocomplete("close");
                    return false;
                }
            },
            source: function(request, response) {
                // delegate back to autocomplete, but extract the last term
                response($.ui.autocomplete.filter(
                    availableTags, extractLast(request.term)));
            },
            select: function(e, ui) {
                var terms = split(this.value);
                // remove the current input
                terms.pop();
                // add the selected item
                terms.push(ui.item.value);
                // add placeholder to get the comma-and-space at the end
                terms.push("");
                this.value = terms.join(", ");
                return false;
            }
        });
});


问:
Laravel mix versioning doesn't remove old built files
I am using Laravel 5.4 with mix to version my javascript and scss files.
The problem is: it doesn't clean the previous built files and simply add a new one with a different file name i.e. app.9d3e179e85922aad6ccf.js

In a new project I started, I do not have this issue. Mix correctly replaces the old file with the latest built version.

Is there somewhere where I can make the change?

答:
This is an issue with the laravel-mix library which can't be addressed here. There are many open issues on GitHub referring to the same problem. You can check the most recent one for some workarounds till the official library gets a permanent fix.

https://github.com/JeffreyWay/laravel-mix/issues/814

Possible solutions in case the link doesn't work in the future.

There are few possible solution for now.

Let files go in default directories.

js mix.js('./resources/assets/js/app.js', 'public/js/app.js')

Tell npm to delete your bundle folder before building new

Use the clean-webpack-plugin package https://github.com/johnagan/clean-webpack-plugin


问:
"Main" value in package.json file in Protractor project
I launched the npm init command in my Protractor project in order to generate a package.json file.

The default value for the "main" field is "index.js", which makes no sense in my project. Anyway, I left it like that and my npm install ran well.

Is the "main" field parameter important in a Protractor project? If so, which file value I put in it, and how will it be used? Thank you.

答: Nope. main is used to distinguish the primary module for an application. It has no purpose in a protractor project. You can safely delete that line from your package.json.


问:
getting access violation error while accessing allocated memory
I have allocated memory of 100 MB using malloc

```<code>block = (char *)malloc(sizeof(10485760));  // char *block is a global variable
</code>```

and then I assigned value in block to some local variable say localblock

```<code>char *localblock = block;
</code>```

when I tried to access location after 1 MB and copying string in that location im getting access violation error

```<code>int si = 1048576;

for (int i=0; i < si; ++i)
    ++localptr;
</code>```

strcpy(localblock,"random_string"); <--- im getting error here .please help me

答:
when you use malloc the allocation is not guaranteed.

block = (char *)malloc(sizeof(10485760));is trying to allocate space for 10485760 which is an int - meaning 4/8 bytes on 32/64-bit machine. "random_string" is longer then that, hence your error

Body:
I have allocated memory of 100 MB using malloc

block = (char *)malloc(sizeof(10485760));  // char *block is a global variable

and then I assigned value in block to some local variable say localblock

char *localblock = block;

when I tried to access location after 1 MB and copying string in that location im getting access violation error

int si = 1048576;

for (int i=0; i < si; ++i)
    ++localptr;

strcpy(localblock,"random_string"); <--- im getting error here .please help me


问:
How format data object in Javascript or VueJs
I'm trying to build small application in VueJs where I'm receiving data in following format:

```<code>{
    "interactions":[
        {
            "id":14,
            "user_id":1,
            "schedule":"2017-06-04 05:02:12",
            "type":"Meeting",
            "with_client":0,
            "event_type":"2",
            "venue":"Mumbai",
            "created_at":"2017-06-04 07:15:37",
            "updated_at":"2017-06-04 07:15:37",
            "deleted_at":null,
            "meeting":{
                "id":14,
                "user_id":1,
                "schedule":"2017-06-04 05:02:12",
                "type":"Meeting",
                "with_client":0,
                "event_type":"2",
                "venue":"Mumbai",
                "created_at":"2017-06-04 07:15:37",
                "updated_at":"2017-06-04 07:15:37",
                "deleted_at":null,
                "clients_association":[
                    {
                        "id":4,
                        "company_id":8,
                        "salutation":"Mr",
                        "first_name":"Check 2",
                        "last_name":"Contact",
                        "number":"098765",
                        "email":"check2@contact.com",
                        "alt_email":null,
                        "address":null,
                        "city":null,
                        "state":null,
                        "country":null,
                        "profile":"Investor-Senior",
                        "sectors_interested":"[\"Financial Services\",\"Metals & Mining\",\"Real Estate\",\"Cement\"]",
                        "companies_interested":"[9]",
                        "created_at":"2017-06-03 06:29:38",
                        "updated_at":"2017-06-03 06:29:38",
                        "deleted_at":null,
                        "pivot":{
                            "interaction_id":14,
                            "contact_id":4
                        }
                    },
                    {
                        "id":5,
                        "company_id":9,
                        "salutation":"Ms",
                        "first_name":"Ammy",
                        "last_name":"Contact",
                        "number":null,
                        "email":"ammy@contact.com",
                        "alt_email":null,
                        "address":null,
                        "city":null,
                        "state":null,
                        "country":null,
                        "profile":"Company-Promoter",
                        "sectors_interested":"[\"Pharmaceuticals\",\"Infrastructure\",\"Metals & Mining\",\"Auto\",\"Auto Ancillaries\",\"Real Estate\",\"Telecoms\",\"Capital Goods\"]",
                        "companies_interested":"[7]",
                        "created_at":"2017-06-03 06:30:50",
                        "updated_at":"2017-06-03 06:30:50",
                        "deleted_at":null,
                        "pivot":{
                            "interaction_id":14,
                            "contact_id":5
                        }
                    }
                ],
                "contacts_association":[
                    {
                        "id":2,
                        "company_id":5,
                        "salutation":"Mr",
                        "first_name":"Check",
                        "last_name":"Contact",
                        "number":"234567890",
                        "email":"check@contact.com",
                        "alt_email":null,
                        "address":"Thane",
                        "city":"Thane",
                        "state":"Maharastra",
                        "country":"India",
                        "profile":"Research-Corporate Access",
                        "sectors_interested":"[\"Infrastructure\",\"Financial Services\",\"Capital Goods\",\"Pharmaceuticals\",\"Real Estate\"]",
                        "companies_interested":"[7]",
                        "created_at":"2017-06-02 19:32:30",
                        "updated_at":"2017-06-02 19:32:30",
                        "deleted_at":null,
                        "pivot":{
                            "interaction_id":14,
                            "contact_id":2
                        }
                    },
                    {
                        "id":3,
                        "company_id":4,
                        "salutation":"Mr",
                        "first_name":"Check 1",
                        "last_name":"Contact",
                        "number":null,
                        "email":"check1@contact.com",
                        "alt_email":null,
                        "address":null,
                        "city":null,
                        "state":null,
                        "country":null,
                        "profile":"Investor-Research Head",
                        "sectors_interested":"[\"Economics\",\"Real Estate\",\"Auto\",\"Consumer\",\"Logistics\",\"Oil & Gas\",\"Industrial\",\"Capital Goods\"]",
                        "companies_interested":"[8]",
                        "created_at":"2017-06-03 06:28:03",
                        "updated_at":"2017-06-03 06:28:03",
                        "deleted_at":null,
                        "pivot":{
                            "interaction_id":14,
                            "contact_id":3
                        }
                    },

                ],
                "stellar_participants":[
                    {
                        "id":1,
                        "name":"Analyst",
                        "email":"analyst@example.com",
                        "address":null,
                        "city":null,
                        "state":null,
                        "country":null,
                        "role":"Analyst",
                        "supervisor_id":null,
                        "created_at":null,
                        "updated_at":null,
                        "deleted_at":null,
                        "pivot":{
                            "interaction_id":14,
                            "user_id":1
                        }
                    }
                ]
            }
        },
    ]
}
</code>```

There are lot more information which is being received I want to have it in a format something like this:

```<code>forEach(client_association)
{
    if(this.client_name == null)
    {
        this.client_name = client_association.first_name+ ' '+client.assciation.last_name
    }
    else
    {
        this.client_name = this.client_name + ', ' + client_association.first_name+ ' '+client_association.last_name
    }
}
forEach(stellar_participants)
{
    if(this.stellar_participants_name == null)
    {
        this.stellar_participants_name = stellar_participants.name
    }
    else
    {
        this.stellar_participants_name = this.stellar_participants_name + ', ' + stellar_participants.name
    }
}
forEach(contacts_participants)
{
    if(this.contacts_participants_name == null)
    {
        this.contacts_participants_name = contacts_participants.first_name + ' ' + contacts_participants.last_name
    }
    else
    {
        this.contacts_participants_name = contacts_participants.first_name + ' ' + contacts_participants.last_name
    }
}
</code>```

So my final format will be:

```<code>meeting_date = 2017-06-04 05:02:12 //Schedule
meeting_call = Meeting //type
event_type = 2 //event_type
venue = Mumbai //venue
with_client = 0
stellar_participants = Analyst //stellarParticipants
clients_association = Check 2 Contact, Ammy Contact //adding all the names in clients association
contacts_association = Check Contact, Check 1 Contact //adding all the names in contacts association
</code>```

so that it takes it into one variable and it gets easier while filtering the data. Please guide me how to achieve this. Thanks

答:
Possible solution: just straightforward map through your data. This code creates an array where each element is an object representing one element in interactions array:

var a = {
    "interactions":[
        {
            "id":14,
            "user_id":1,
            "schedule":"2017-06-04 05:02:12",
            "type":"Meeting",
            "with_client":0,
            "event_type":"2",
            "venue":"Mumbai",
            "created_at":"2017-06-04 07:15:37",
            "updated_at":"2017-06-04 07:15:37",
            "deleted_at":null,
            "meeting":{
                "id":14,
                "user_id":1,
                "schedule":"2017-06-04 05:02:12",
                "type":"Meeting",
                "with_client":0,
                "event_type":"2",
                "venue":"Mumbai",
                "created_at":"2017-06-04 07:15:37",
                "updated_at":"2017-06-04 07:15:37",
                "deleted_at":null,
                "clients_association":[
                    {
                        "id":4,
                        "company_id":8,
                        "salutation":"Mr",
                        "first_name":"Check 2",
                        "last_name":"Contact",
                        "number":"098765",
                        "email":"check2@contact.com",
                        "alt_email":null,
                        "address":null,
                        "city":null,
                        "state":null,
                        "country":null,
                        "profile":"Investor-Senior",
                        "sectors_interested":"[\"Financial Services\",\"Metals & Mining\",\"Real Estate\",\"Cement\"]",
                        "companies_interested":"[9]",
                        "created_at":"2017-06-03 06:29:38",
                        "updated_at":"2017-06-03 06:29:38",
                        "deleted_at":null,
                        "pivot":{
                            "interaction_id":14,
                            "contact_id":4
                        }
                    },
                    {
                        "id":5,
                        "company_id":9,
                        "salutation":"Ms",
                        "first_name":"Ammy",
                        "last_name":"Contact",
                        "number":null,
                        "email":"ammy@contact.com",
                        "alt_email":null,
                        "address":null,
                        "city":null,
                        "state":null,
                        "country":null,
                        "profile":"Company-Promoter",
                        "sectors_interested":"[\"Pharmaceuticals\",\"Infrastructure\",\"Metals & Mining\",\"Auto\",\"Auto Ancillaries\",\"Real Estate\",\"Telecoms\",\"Capital Goods\"]",
                        "companies_interested":"[7]",
                        "created_at":"2017-06-03 06:30:50",
                        "updated_at":"2017-06-03 06:30:50",
                        "deleted_at":null,
                        "pivot":{
                            "interaction_id":14,
                            "contact_id":5
                        }
                    }
                ],
                "contacts_association":[
                    {
                        "id":2,
                        "company_id":5,
                        "salutation":"Mr",
                        "first_name":"Check",
                        "last_name":"Contact",
                        "number":"234567890",
                        "email":"check@contact.com",
                        "alt_email":null,
                        "address":"Thane",
                        "city":"Thane",
                        "state":"Maharastra",
                        "country":"India",
                        "profile":"Research-Corporate Access",
                        "sectors_interested":"[\"Infrastructure\",\"Financial Services\",\"Capital Goods\",\"Pharmaceuticals\",\"Real Estate\"]",
                        "companies_interested":"[7]",
                        "created_at":"2017-06-02 19:32:30",
                        "updated_at":"2017-06-02 19:32:30",
                        "deleted_at":null,
                        "pivot":{
                            "interaction_id":14,
                            "contact_id":2
                        }
                    },
                    {
                        "id":3,
                        "company_id":4,
                        "salutation":"Mr",
                        "first_name":"Check 1",
                        "last_name":"Contact",
                        "number":null,
                        "email":"check1@contact.com",
                        "alt_email":null,
                        "address":null,
                        "city":null,
                        "state":null,
                        "country":null,
                        "profile":"Investor-Research Head",
                        "sectors_interested":"[\"Economics\",\"Real Estate\",\"Auto\",\"Consumer\",\"Logistics\",\"Oil & Gas\",\"Industrial\",\"Capital Goods\"]",
                        "companies_interested":"[8]",
                        "created_at":"2017-06-03 06:28:03",
                        "updated_at":"2017-06-03 06:28:03",
                        "deleted_at":null,
                        "pivot":{
                            "interaction_id":14,
                            "contact_id":3
                        }
                    },

                ],
                "stellar_participants":[
                    {
                        "id":1,
                        "name":"Analyst",
                        "email":"analyst@example.com",
                        "address":null,
                        "city":null,
                        "state":null,
                        "country":null,
                        "role":"Analyst",
                        "supervisor_id":null,
                        "created_at":null,
                        "updated_at":null,
                        "deleted_at":null,
                        "pivot":{
                            "interaction_id":14,
                            "user_id":1
                        }
                    }
                ]
            }
        },
    ]
};

var res = a.interactions.map(i => Object.assign({
  'meeting_date': i.schedule,
  'meeting_call': i.type,
  'event_type': i.event_type,
  'venue': i.venue,
  'with_client': i.with_client
  }, {
   'stellar_participants': i.meeting.stellar_participants.map(sp => sp.name).join(', ')
  }, {
   'clients_association': i.meeting.clients_association.map(ca => ca.first_name + ' ' + ca.last_name).join(', ')
  }, {
   'contacts_association': i.meeting.contacts_association.map(ca => ca.first_name + ' ' + ca.last_name).join(', ')
  }));

console.log(res)```

Body:
I'm trying to build small application in VueJs where I'm receiving data in following format:

{
    "interactions":[
        {
            "id":14,
            "user_id":1,
            "schedule":"2017-06-04 05:02:12",
            "type":"Meeting",
            "with_client":0,
            "event_type":"2",
            "venue":"Mumbai",
            "created_at":"2017-06-04 07:15:37",
            "updated_at":"2017-06-04 07:15:37",
            "deleted_at":null,
            "meeting":{
                "id":14,
                "user_id":1,
                "schedule":"2017-06-04 05:02:12",
                "type":"Meeting",
                "with_client":0,
                "event_type":"2",
                "venue":"Mumbai",
                "created_at":"2017-06-04 07:15:37",
                "updated_at":"2017-06-04 07:15:37",
                "deleted_at":null,
                "clients_association":[
                    {
                        "id":4,
                        "company_id":8,
                        "salutation":"Mr",
                        "first_name":"Check 2",
                        "last_name":"Contact",
                        "number":"098765",
                        "email":"check2@contact.com",
                        "alt_email":null,
                        "address":null,
                        "city":null,
                        "state":null,
                        "country":null,
                        "profile":"Investor-Senior",
                        "sectors_interested":"[\"Financial Services\",\"Metals & Mining\",\"Real Estate\",\"Cement\"]",
                        "companies_interested":"[9]",
                        "created_at":"2017-06-03 06:29:38",
                        "updated_at":"2017-06-03 06:29:38",
                        "deleted_at":null,
                        "pivot":{
                            "interaction_id":14,
                            "contact_id":4
                        }
                    },
                    {
                        "id":5,
                        "company_id":9,
                        "salutation":"Ms",
                        "first_name":"Ammy",
                        "last_name":"Contact",
                        "number":null,
                        "email":"ammy@contact.com",
                        "alt_email":null,
                        "address":null,
                        "city":null,
                        "state":null,
                        "country":null,
                        "profile":"Company-Promoter",
                        "sectors_interested":"[\"Pharmaceuticals\",\"Infrastructure\",\"Metals & Mining\",\"Auto\",\"Auto Ancillaries\",\"Real Estate\",\"Telecoms\",\"Capital Goods\"]",
                        "companies_interested":"[7]",
                        "created_at":"2017-06-03 06:30:50",
                        "updated_at":"2017-06-03 06:30:50",
                        "deleted_at":null,
                        "pivot":{
                            "interaction_id":14,
                            "contact_id":5
                        }
                    }
                ],
                "contacts_association":[
                    {
                        "id":2,
                        "company_id":5,
                        "salutation":"Mr",
                        "first_name":"Check",
                        "last_name":"Contact",
                        "number":"234567890",
                        "email":"check@contact.com",
                        "alt_email":null,
                        "address":"Thane",
                        "city":"Thane",
                        "state":"Maharastra",
                        "country":"India",
                        "profile":"Research-Corporate Access",
                        "sectors_interested":"[\"Infrastructure\",\"Financial Services\",\"Capital Goods\",\"Pharmaceuticals\",\"Real Estate\"]",
                        "companies_interested":"[7]",
                        "created_at":"2017-06-02 19:32:30",
                        "updated_at":"2017-06-02 19:32:30",
                        "deleted_at":null,
                        "pivot":{
                            "interaction_id":14,
                            "contact_id":2
                        }
                    },
                    {
                        "id":3,
                        "company_id":4,
                        "salutation":"Mr",
                        "first_name":"Check 1",
                        "last_name":"Contact",
                        "number":null,
                        "email":"check1@contact.com",
                        "alt_email":null,
                        "address":null,
                        "city":null,
                        "state":null,
                        "country":null,
                        "profile":"Investor-Research Head",
                        "sectors_interested":"[\"Economics\",\"Real Estate\",\"Auto\",\"Consumer\",\"Logistics\",\"Oil & Gas\",\"Industrial\",\"Capital Goods\"]",
                        "companies_interested":"[8]",
                        "created_at":"2017-06-03 06:28:03",
                        "updated_at":"2017-06-03 06:28:03",
                        "deleted_at":null,
                        "pivot":{
                            "interaction_id":14,
                            "contact_id":3
                        }
                    },

                ],
                "stellar_participants":[
                    {
                        "id":1,
                        "name":"Analyst",
                        "email":"analyst@example.com",
                        "address":null,
                        "city":null,
                        "state":null,
                        "country":null,
                        "role":"Analyst",
                        "supervisor_id":null,
                        "created_at":null,
                        "updated_at":null,
                        "deleted_at":null,
                        "pivot":{
                            "interaction_id":14,
                            "user_id":1
                        }
                    }
                ]
            }
        },
    ]
}

There are lot more information which is being received I want to have it in a format something like this:

forEach(client_association)
{
    if(this.client_name == null)
    {
        this.client_name = client_association.first_name+ ' '+client.assciation.last_name
    }
    else
    {
        this.client_name = this.client_name + ', ' + client_association.first_name+ ' '+client_association.last_name
    }
}
forEach(stellar_participants)
{
    if(this.stellar_participants_name == null)
    {
        this.stellar_participants_name = stellar_participants.name
    }
    else
    {
        this.stellar_participants_name = this.stellar_participants_name + ', ' + stellar_participants.name
    }
}
forEach(contacts_participants)
{
    if(this.contacts_participants_name == null)
    {
        this.contacts_participants_name = contacts_participants.first_name + ' ' + contacts_participants.last_name
    }
    else
    {
        this.contacts_participants_name = contacts_participants.first_name + ' ' + contacts_participants.last_name
    }
}

So my final format will be:

meeting_date = 2017-06-04 05:02:12 //Schedule
meeting_call = Meeting //type
event_type = 2 //event_type
venue = Mumbai //venue
with_client = 0
stellar_participants = Analyst //stellarParticipants
clients_association = Check 2 Contact, Ammy Contact //adding all the names in clients association
contacts_association = Check Contact, Check 1 Contact //adding all the names in contacts association

so that it takes it into one variable and it gets easier while filtering the data. Please guide me how to achieve this. Thanks


问:
Quicktime Java dependency using Maven Apache
How do you tell Netbeans where the library is?

Using Eclipse I am able to import QTJava.jar and it understand what I want. However, I can't seem to find the relevant dependency using Maven on Netbeans, and don't known how to import a local library.

答: This is a proprietary library for which no public download or POM file is available. You will have to import it into your local Maven repository manually.</p>


问:
Using `std::min` as an algorithm parameter
So I ran into this problem: I need to replace every element of the std::vector<int> with the minimum of whatever came before it (inclusive).

Naturally std::partial_sum comes to mind - if I could pass std::min as the BinaryOp, it would do the job.

Well turns out I can't do that because std::min<int> is an overloaded function - it works for both int and initializer_list<int> and partial_sum template can't be instantiated with the unknown type.

Usually this is resolved by having a class with a templated operator(), like std::plus<void> etc, but standard library doesn't seem to have one for min and max.

I feel like I either have to implement my own T min<T>(T,T), which will be an exact clone of std::min with the exception of not having an initializer_list overload, or to implement my own class min akin to std::plus. Both feel kinda wrong because one would expect standard library to have such a basic thing, and also basic things are often tricky to implement:)

So here are my questions:

Is there any proper way to solve the problem in question? i.e. without introducing new vague constructs/writing more than a couple of lines of code.

Is it correct to assume that this became a problem in C++11, after initializer_list overload of min was introduced? So C++11 broke the code that relied on explicitly instantiated std::min?

Thank you!

答:
You can initialise a pointer-to-function variable of appropriate type and pass that, or explicitly static_cast.</p>

```<code>int& (*min)(int&, int&) = std::min<int>;
std::partial_sum(v.begin(), v.end(), v.begin(), min);
</code>```

Body:
You can initialise a pointer-to-function variable of appropriate type and pass that, or explicitly static_cast.

int& (*min)(int&, int&) = std::min<int>;
std::partial_sum(v.begin(), v.end(), v.begin(), min);


问:
Javascript check value does not exist
In Javascript I can do this...

```<code>myvalue = "greenapples"

if ( myvalue ) {
    alert ("My Value is " + myvalue )
}
</code>```

But how do I do the opposite?  I want to display an alert if myvalue is not set.

Anyone have an example I can see?

答:
1st Way..

```<code>var myvalue = "greenapples";

if (myvalue === undefined){
alert("My Value Is "+ myvalue)
}
</code>```

2nd Way

```<code>var myvalue = "greenapples";

    if (!myvalue ) {
      alert("My Value is" + myvalue);  // Javascript executes this row
    } else {
      alert("This Is  Already Set");
    }
</code>```

3rd Way

The typeof operator will check if the variable is really undefined.

```<code>var myvalue = "greenapples";
if (typeof myvalue === 'undefined' || myvalue=== null) {
    // variable is undefined and null then
   alert("My Value Is "+ myvalue);
}
</code>```

Title: Javascript check value does not exist

Body:
In Javascript I can do this...

myvalue = "greenapples"

if ( myvalue ) {
    alert ("My Value is " + myvalue )
}

But how do I do the opposite?  I want to display an alert if myvalue is not set.

Anyone have an example I can see?

Body:
1st Way..

var myvalue = "greenapples";

if (myvalue === undefined){
alert("My Value Is "+ myvalue)
}

2nd Way

var myvalue = "greenapples";

    if (!myvalue ) {
      alert("My Value is" + myvalue);  // Javascript executes this row
    } else {
      alert("This Is  Already Set");
    }

3rd Way

The typeof operator will check if the variable is really undefined.

var myvalue = "greenapples";
if (typeof myvalue === 'undefined' || myvalue=== null) {
    // variable is undefined and null then
   alert("My Value Is "+ myvalue);
}


问:
How to view the database tables in application servers?
I'm writing Java objects to the built in database using JPA methods like EntityManager#persist and persist. The entity is now stored in a table database. How can I view the contents of the database? I want to see how the object graph was mapped to tables, check how much storage it takes, and so on.

I'm using Wildfly 10.1, Hibernate or EclipseLink and whatever the default database is. I looked in the management console but didn't find the tables. I'm not looking for a software recommendation, tutorial etc. Just for steps to view the database.

答: It is apparently impossible to view the database through Wildfly or any other built in means in the IDE.</p>


问:
check if string contains only unique chars using .at(int)
Really basic question but I can't figure this out.  My program checks if a string is unique by setting flags for each ASCII in an array to true if found in the string.  It's not working(it compiles, but doesn't give correct answer), and I can't for the life of my figure out why.

The output I get is 0:

main.cpp

```<code>#include "main.hpp"
#include <iostream>

bool isUnique(std::string str) {

    if(str.length() > 128)
        return false;

    bool theChars[128];

    for(int i = 0; i < str.length(); i++) {
        int loc = str.at(i);

        if(theChars[loc])
            return false;
        else
            theChars[loc] = true;
    }

    return true;
}

int main() {

    std::string timmy = "abcdefghijklmnop";
    std::cout << isUnique(timmy);

    return 0;
}
</code>```

答:
easier way is use set:

```<code>#include <iostream>
#include <set>
using namespace std;
bool isUnique(string str) {
    set<char>st(str.begin(),str.end());
    if(st.size()==str.size())
        return true;
    return false;
}

int main() {

    string timmy = "abcdefghijklmnop";
    cout << boolalpha<<isUnique(timmy)<<endl;
    timmy = "aaaaabbbcdefghijklmnop";
    cout << boolalpha<<isUnique(timmy)<<endl;
    return 0;
}
</code>```

p.s. if not use boolalpha, it will print 1 for true and 0 for false.

Body:
Really basic question but I can't figure this out.  My program checks if a string is unique by setting flags for each ASCII in an array to true if found in the string.  It's not working(it compiles, but doesn't give correct answer), and I can't for the life of my figure out why.

The output I get is 0:

main.cpp

#include "main.hpp"
#include <iostream>

bool isUnique(std::string str) {

    if(str.length() > 128)
        return false;

    bool theChars[128];

    for(int i = 0; i < str.length(); i++) {
        int loc = str.at(i);

        if(theChars[loc])
            return false;
        else
            theChars[loc] = true;
    }

    return true;
}

int main() {

    std::string timmy = "abcdefghijklmnop";
    std::cout << isUnique(timmy);

    return 0;
}

Body:
easier way is use set:

#include <iostream>
#include <set>
using namespace std;
bool isUnique(string str) {
    set<char>st(str.begin(),str.end());
    if(st.size()==str.size())
        return true;
    return false;
}

int main() {

    string timmy = "abcdefghijklmnop";
    cout << boolalpha<<isUnique(timmy)<<endl;
    timmy = "aaaaabbbcdefghijklmnop";
    cout << boolalpha<<isUnique(timmy)<<endl;
    return 0;
}

p.s. if not use boolalpha, it will print 1 for true and 0 for false.