问:
Object modified in the function is not being modified outside the function
I'm building a code to parse some JSON details received from the server into a javascript object. The object has many objects inside it.

Then I have another function to create HTML element and apply that object's values (using for - in loop) into HTML tags' "innerHTML".

I have included the code i use below,

```<code>// This one is executed on the 'onLoad' event.

function requestDriverListings() {

**//This object stores the received object from server.**

var drivers = {};

// ***This function requests details from the server and the function in the arguments is executed once the details are received.***

sendUserData ({}, "request driver.php", function (request) {
listDrivers(request,drivers); console.log(drivers); displayDrivers(drivers);});

}

</code>```

This one is the function to create a HTML Element and stores the received data in it and the use JSON.parse() to parse them into a Object.

The driver parameter is the Object passed in the above code.
request parameter has no effect on this problem. (It is the XHR responseText.)

```<code>
function listDrivers (request,driver) {
    var response = document.createElement("html");
    response.innerHTML = request;
    driver = response.querySelector("#drivers").innerHTML;
    var stripComma = driver.lastIndexOf(",");
    driver = JSON.parse(driver.substring(0,stripComma) +"}");

}
</code>```

Here is the displayDrivers function.

drivers Object is passed into driveParsed  in the first function.

requestAPage() is a function to request the displaying element from the server. the function in it's arguments is the function to apply the Objects details into the HTML innerHTML.

```<code>
function displayDrivers (driveParsed) {
    var driverElement = document.createElement("div");
    driverElement.id = "driverElement";
    driverElement.style.display = "none";
    document.getElementById("driverContainer").appendChild(driverElement);

    requestAPage("Drivers.html", "drivers", "driverElement", function() {  selectDrivers();});

    var selectDrivers = function () {

    for (var x=0; x<=Object.keys(driveParsed).length; x++) {
         var driverParsed = driveParsed[x];
         setDriversDetails(driveParsed,x);
         var element = createAElement( "div", {"margin-top": "10px;"});
         element.id = driveParsed.name;
         element.className  = "container border";
         element.innerHTML = driverElement.innerHTML;
         document.getElementById("driverContainer").appendChild(element);

    }

    };

}
</code>```

================================================================

My problem is this displayDrivers() is not getting the modified drivers Object.

Please help me to solve this problem. Sorry for the long description.

答:
One problem is that inside listDrivers you assign a new value to the driver variable (which is an argument). This means the original variable, drivers, that was passed to the function as second argument, is disconnected from the local function variable driver: they are now two distinct, unrelated objects.

If you want the drivers variable to get a value from calling the function, then let that be the return value of the function, so you would call it like this:

```<code>sendUserData ({}, "request driver.php", function (request) {
    var drivers = listDrivers(request);  // <-----
    console.log(drivers);
    displayDrivers(drivers);
});
</code>```

Then the listDrivers function would look like this:

```<code>function listDrivers (request) { // <--- only one argument
    // declare new variable:
    var driver = response.querySelector("#drivers").innerHTML;
    // ... rest of your code comes here ...
    // ... and finally:
    return driver; // <---- return it
}
</code>```

Body:
I'm building a code to parse some JSON details received from the server into a javascript object. The object has many objects inside it.

Then I have another function to create HTML element and apply that object's values (using for - in loop) into HTML tags' "innerHTML".

I have included the code i use below,

// This one is executed on the 'onLoad' event.

function requestDriverListings() {

**//This object stores the received object from server.**

var drivers = {};

// ***This function requests details from the server and the function in the arguments is executed once the details are received.***

sendUserData ({}, "request driver.php", function (request) {
listDrivers(request,drivers); console.log(drivers); displayDrivers(drivers);});

}

This one is the function to create a HTML Element and stores the received data in it and the use JSON.parse() to parse them into a Object.

The driver parameter is the Object passed in the above code.
request parameter has no effect on this problem. (It is the XHR responseText.)

function listDrivers (request,driver) {
    var response = document.createElement("html");
    response.innerHTML = request;
    driver = response.querySelector("#drivers").innerHTML;
    var stripComma = driver.lastIndexOf(",");
    driver = JSON.parse(driver.substring(0,stripComma) +"}");

}

Here is the displayDrivers function.

drivers Object is passed into driveParsed  in the first function.

requestAPage() is a function to request the displaying element from the server. the function in it's arguments is the function to apply the Objects details into the HTML innerHTML.

function displayDrivers (driveParsed) {
    var driverElement = document.createElement("div");
    driverElement.id = "driverElement";
    driverElement.style.display = "none";
    document.getElementById("driverContainer").appendChild(driverElement);

    requestAPage("Drivers.html", "drivers", "driverElement", function() {  selectDrivers();});

    var selectDrivers = function () {

    for (var x=0; x<=Object.keys(driveParsed).length; x++) {
         var driverParsed = driveParsed[x];
         setDriversDetails(driveParsed,x);
         var element = createAElement( "div", {"margin-top": "10px;"});
         element.id = driveParsed.name;
         element.className  = "container border";
         element.innerHTML = driverElement.innerHTML;
         document.getElementById("driverContainer").appendChild(element);

    }

    };

}

================================================================

My problem is this displayDrivers() is not getting the modified drivers Object.

Please help me to solve this problem. Sorry for the long description.

Body:
One problem is that inside listDrivers you assign a new value to the driver variable (which is an argument). This means the original variable, drivers, that was passed to the function as second argument, is disconnected from the local function variable driver: they are now two distinct, unrelated objects.

If you want the drivers variable to get a value from calling the function, then let that be the return value of the function, so you would call it like this:

sendUserData ({}, "request driver.php", function (request) {
    var drivers = listDrivers(request);  // <-----
    console.log(drivers);
    displayDrivers(drivers);
});

Then the listDrivers function would look like this:

function listDrivers (request) { // <--- only one argument
    // declare new variable:
    var driver = response.querySelector("#drivers").innerHTML;
    // ... rest of your code comes here ...
    // ... and finally:
    return driver; // <---- return it
}


来源: stackexchange

问:
It is possible to know if a string is encoded in base64?
Simple as that.

I'm making an app where the user has to scan a QR code (which basically is a base64 encoded string), is there any way to verify that the string is encoded in base64 before decode and follow the flow of the application?

My code would be responsible for that is:

```<code>func captureOutput(captureOutput: AVCaptureOutput!, didOutputMetadataObjects metadataObjects: [AnyObject]!, fromConnection connection: AVCaptureConnection!) {

    if metadataObjects == nil || metadataObjects.count == 0 {
        qrCodeFrameView?.frame = CGRectZero
        return
    }

    let metadataObj = metadataObjects[0] as AVMetadataMachineReadableCodeObject

    if metadataObj.type == AVMetadataObjectTypeQRCode {
        let barCodeObject = videoPreviewLayer?.transformedMetadataObjectForMetadataObject(metadataObj as AVMetadataMachineReadableCodeObject) as AVMetadataMachineReadableCodeObject
        qrCodeFrameView?.frame = barCodeObject.bounds

        if metadataObj.stringValue != nil /* Verify that string is base 64 before continue */ {
            let decodedData = NSData(base64EncodedString: metadataObj.stringValue, options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters)
            let decodedString = NSString(data: decodedData!, encoding: NSUTF8StringEncoding)
            println(decodedString)
        }

        /* More code */

    }
}
</code>```

答:
You can create a string extension to validate this and make use of guardor a simple if would also do

```<code>  extension String
  {
    func isStringBase64() -> Bool {
        guard Data(base64Encoded: self) != nil else {
            return false
        }
        return true
    }
}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
Simple as that.

I'm making an app where the user has to scan a QR code (which basically is a base64 encoded string), is there any way to verify that the string is encoded in base64 before decode and follow the flow of the application?

My code would be responsible for that is:

func captureOutput(captureOutput: AVCaptureOutput!, didOutputMetadataObjects metadataObjects: [AnyObject]!, fromConnection connection: AVCaptureConnection!) {

    if metadataObjects == nil || metadataObjects.count == 0 {
        qrCodeFrameView?.frame = CGRectZero
        return
    }

    let metadataObj = metadataObjects[0] as AVMetadataMachineReadableCodeObject

    if metadataObj.type == AVMetadataObjectTypeQRCode {
        let barCodeObject = videoPreviewLayer?.transformedMetadataObjectForMetadataObject(metadataObj as AVMetadataMachineReadableCodeObject) as AVMetadataMachineReadableCodeObject
        qrCodeFrameView?.frame = barCodeObject.bounds

        if metadataObj.stringValue != nil /* Verify that string is base 64 before continue */ {
            let decodedData = NSData(base64EncodedString: metadataObj.stringValue, options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters)
            let decodedString = NSString(data: decodedData!, encoding: NSUTF8StringEncoding)
            println(decodedString)
        }

        /* More code */

    }
}

Body:
You can create a string extension to validate this and make use of guardor a simple if would also do

  extension String
  {
    func isStringBase64() -> Bool {
        guard Data(base64Encoded: self) != nil else {
            return false
        }
        return true
    }
}

ContentLicense: CC BY-SA 4.0


问:
Methods for quickly calculating standard deviation of large number set in Numpy
What's the best(fastest) way to do this?

This generates what I believe is the correct answer, but obviously at N = 10e6 it is painfully slow. I think I need to keep the Xi values so I can correctly calculate the standard deviation, but are there any techniques to make this run faster?

```<code>def randomInterval(a,b):
    r = ((b-a)*float(random.random(1)) + a)
    return r

N = 10e6
Sum = 0
x = []
for sample in range(0,int(N)):
    n = randomInterval(-5.,5.)
    while n == 5.0:
        n = randomInterval(-5.,5.) # since X is [-5,5)
    Sum += n
    x = np.append(x, n)

A = Sum/N

for sample in range(0,int(N)):
    summation = (x[sample] - A)**2.0

standard_deviation = np.sqrt((1./N)*summation)
</code>```

答: Using the formulas found on this wiki page for Variance, you could compute it in one loop without  storing a list of the random numbers (assuming you didn't need them elsewhere).</p>

Body:
What's the best(fastest) way to do this?

This generates what I believe is the correct answer, but obviously at N = 10e6 it is painfully slow. I think I need to keep the Xi values so I can correctly calculate the standard deviation, but are there any techniques to make this run faster?

def randomInterval(a,b):
    r = ((b-a)*float(random.random(1)) + a)
    return r

N = 10e6
Sum = 0
x = []
for sample in range(0,int(N)):
    n = randomInterval(-5.,5.)
    while n == 5.0:
        n = randomInterval(-5.,5.) # since X is [-5,5)
    Sum += n
    x = np.append(x, n)

A = Sum/N

for sample in range(0,int(N)):
    summation = (x[sample] - A)**2.0

standard_deviation = np.sqrt((1./N)*summation)


问:
Deployment of php7 on appengine
I'm an absolute beginner on the Google app engine.

I have gone through the documentations for deploying a basic php app. The guidelines for deploying php7 apps aren't very clear to me.

Let's say I have a CMS written in php MySQLi. Assuming the project has privileges (in separate folders) for admin, users and guests, and I want to deploy it on Google app engine;

What are the configuration(s) that are most recommended for this option.

Asides the Google SDK, is there any GUI application that could help make the process easier?

Does the SDK also have version control on them? How do it update codes without re-deploying the whole project all over again?

答:
For #1 you probably should go through Choosing an App Engine environment first. I can't help with more details as I'm not a PHP developer (which is also why I can't answer #2).

For #3 GAE itself only tracks versions at the entire service level, each deployment consisting of the entire set of the service's deployable artifacts.

However it may be able to skip unnecessarily uploading unchanged artifacts. I know it does it at least for python standard environment services if re-deploying from the same workspace, in rsync style. You can confirm this by increasing the deployment verbosity via the --verbosity option. I'm unsure if the fact that I was using git for the project mattered.

For the flexible environment services things are a bit more complex, since the deployment artifacts are docker images, see How can I speed up Rails Docker deployments on Google Cloud Platform?

If you'll have a multi-service app each service can be deployed individually, but a service deployment in itself is a complete one, not an incremental one, creating a new version of the service.

The app-level configs (applicable to all services) are individually re-deployable, without re-deploying any of the services:

To deploy the other configuration files of your service, you must
  target and deploy each file separately. For example:

```<code>gcloud app deploy cron.yaml
gcloud app deploy dispatch.yaml
gcloud app deploy index.yaml
</code>```

Title: Deployment of php7 on appengine

Body:
For #1 you probably should go through Choosing an App Engine environment first. I can't help with more details as I'm not a PHP developer (which is also why I can't answer #2).

For #3 GAE itself only tracks versions at the entire service level, each deployment consisting of the entire set of the service's deployable artifacts.

However it may be able to skip unnecessarily uploading unchanged artifacts. I know it does it at least for python standard environment services if re-deploying from the same workspace, in rsync style. You can confirm this by increasing the deployment verbosity via the --verbosity option. I'm unsure if the fact that I was using git for the project mattered.

For the flexible environment services things are a bit more complex, since the deployment artifacts are docker images, see How can I speed up Rails Docker deployments on Google Cloud Platform?

If you'll have a multi-service app each service can be deployed individually, but a service deployment in itself is a complete one, not an incremental one, creating a new version of the service.

The app-level configs (applicable to all services) are individually re-deployable, without re-deploying any of the services:

To deploy the other configuration files of your service, you must
  target and deploy each file separately. For example:

gcloud app deploy cron.yaml
gcloud app deploy dispatch.yaml
gcloud app deploy index.yaml


问:
Webpack QuillJS outputs SVG path instead of inlining it
Im trying to install QuillJS with Symfony-Encore.
Somehow the SVG-Icons for the toolbar do not load as expected.

The output just shows the SVG`s path:

```<code><span class="ql-formats">
    <button type="button" class="ql-bold">/build/images/bold.89e9c638.svg</button>
    <button type="button" class="ql-italic">/build/images/italic.b802b8f9.svg</button>
</span>
</code>```

How do I resolve this path and embed or link the corresponding svg-icon?
I guess some kind of loader configuration is missing or smth like this.

I Embed Quill as separate components:

```<code>import Quill from 'quill/core';
// ... more quill packages
</code>```

Edit:

I added HTML-Loader to inline the svg`s into my HTML with this config:

```<code>{
    test: /\.svg$/,
    use: [{
        loader: 'html-loader',
        options: {
            minimize: true
        }
    }]
}
</code>```

I'm now getting this error(s).

These relative modules were not found:

../assets/icons/align-left.svg in ./node_modules/quill/ui/icons.js

../assets/icons/align-center.svg in ./node_modules/quill/ui/icons.js

../assets/icons/align-right.svg in ./node_modules/quill/ui/icons.js

../assets/icons/background.svg in ./node_modules/quill/ui/icons.js

../assets/icons/align-justify.svg in ./node_modules/quill/ui/icons.js
  ...

The paths theme correct. I totally don't know whats wrong here.

Thanks for your help :-)

答:
If your issue concerns Laravel Mix: on GitHub there is a discussion about the problem in Mix itself, and a solution involving modifying your webpack.mix.js file as follows:</p>

```<code>mix.extend('quill', webpackConfig => {
    const { rules } = webpackConfig.module;

    // 1. Exclude quill's SVG icons from existing rules
    rules.filter(rule => /svg/.test(rule.test.toString()))
        .forEach(rule => rule.exclude = /quill/);

    // 2. Instead, use html-loader for quill's SVG icons
    rules.unshift({
        test: /\.svg$/,
        include: [path.resolve('./node_modules/quill/assets')],
        loaders: [{ loader: 'html-loader', options: { minimize: true } }]
    });

    // 3. Don't exclude quill from babel-loader rule
    rules.filter(rule => rule.exclude && rule.exclude.toString() === "/(node_modules|bower_components)/")
        .forEach(rule => rule.exclude = /node_modules\/(?!(quill)\/).*/);
});

// …

mix.js(/* ... */)
   .quill()
</code>```

Body:
Im trying to install QuillJS with Symfony-Encore.
Somehow the SVG-Icons for the toolbar do not load as expected.

The output just shows the SVG`s path:

    <button type="button" class="ql-bold">/build/images/bold.89e9c638.svg</button>
    <button type="button" class="ql-italic">/build/images/italic.b802b8f9.svg</button>

How do I resolve this path and embed or link the corresponding svg-icon?
I guess some kind of loader configuration is missing or smth like this.

I Embed Quill as separate components:

import Quill from 'quill/core';
// ... more quill packages

Edit:

I added HTML-Loader to inline the svg`s into my HTML with this config:

{
    test: /\.svg$/,
    use: [{
        loader: 'html-loader',
        options: {
            minimize: true
        }
    }]
}

I'm now getting this error(s).

These relative modules were not found:

../assets/icons/align-left.svg in ./node_modules/quill/ui/icons.js

../assets/icons/align-center.svg in ./node_modules/quill/ui/icons.js

../assets/icons/align-right.svg in ./node_modules/quill/ui/icons.js

../assets/icons/background.svg in ./node_modules/quill/ui/icons.js

../assets/icons/align-justify.svg in ./node_modules/quill/ui/icons.js
  ...

The paths theme correct. I totally don't know whats wrong here.

Thanks for your help :-)

Body:
If your issue concerns Laravel Mix: on GitHub there is a discussion about the problem in Mix itself, and a solution involving modifying your webpack.mix.js file as follows:

mix.extend('quill', webpackConfig => {
    const { rules } = webpackConfig.module;

    // 1. Exclude quill's SVG icons from existing rules
    rules.filter(rule => /svg/.test(rule.test.toString()))
        .forEach(rule => rule.exclude = /quill/);

    // 2. Instead, use html-loader for quill's SVG icons
    rules.unshift({
        test: /\.svg$/,
        include: [path.resolve('./node_modules/quill/assets')],
        loaders: [{ loader: 'html-loader', options: { minimize: true } }]
    });

    // 3. Don't exclude quill from babel-loader rule
    rules.filter(rule => rule.exclude && rule.exclude.toString() === "/(node_modules|bower_components)/")
        .forEach(rule => rule.exclude = /node_modules\/(?!(quill)\/).*/);
});

// …

mix.js(/* ... */)
   .quill()


问:
Firestore add method does not work properly when I am offline
If I run the following line of code when my device is offline, The card will be added to local cache. But the application never goes to the next line.

```<code>const data = await firebase.firestore().collection('cards').add(card);
console.log(data) // this line never get executed!
</code>```

答:
Write methods (such as add()) return a promise that fulfills once the write operation has been completed (or rejected) on the server. Since you're not connected to the server, that never happens and thus your await will stay blocked.

Note that you don't need to await for the local write operation, as the write to the local cache happens synchronously. So as soon as the add(...) call returns (and doesn't raise an exception), you can be sure that the write was completed to the local cache. Hence, you should only use await if you need to know that the write was also handled by the server, in which case the behavior you see is exactly what you'll want.

Body:
If I run the following line of code when my device is offline, The card will be added to local cache. But the application never goes to the next line.

const data = await firebase.firestore().collection('cards').add(card);
console.log(data) // this line never get executed!


问:
Best Open source gui tool for Mongodb-3.4
I am using :

```<code> Ubuntu 16.04 LTS
 Mongodb 3.4
</code>```

From Mongodb 3.4 Site https://docs.mongodb.com/manual/core/views/ there are views supported in Mongodb 3.4, and for admin tools link https://docs.mongodb.com/ecosystem/tools/administration-interfaces/#id2 . I am using latest version of RoboMongo, but I have not seen UI managing views

Please lemme know what could be suitable open source admin UI tools for managing (Create, View, Delete) views for a collection in Mongodb, and Admin UI tools for administering cluster health.

Regards

Kris

答:
You can try this :

MongoDB_Admin

Written in NodeJS and electron

Body:
I am using :

 Ubuntu 16.04 LTS
 Mongodb 3.4

From Mongodb 3.4 Site https://docs.mongodb.com/manual/core/views/ there are views supported in Mongodb 3.4, and for admin tools link https://docs.mongodb.com/ecosystem/tools/administration-interfaces/#id2 . I am using latest version of RoboMongo, but I have not seen UI managing views

Please lemme know what could be suitable open source admin UI tools for managing (Create, View, Delete) views for a collection in Mongodb, and Admin UI tools for administering cluster health.

Regards

Kris


问:
syntax error near unexpected token `(' when defining function in bash profile
```<code>gac() {
        git add .
        git commit -m "$1"
}
</code>```

This function is in my bash profile, and it raises an error when I try to source the file.

```<code>$ source ~/.bashrc
bash: /home/sahandz/.bashrc: line 176: syntax error near unexpected token `('
bash: /home/sahandz/.bashrc: line 176: `gac() {'
</code>```

I can't figure out why. I have another function that looks like this and doesn't raise any error:

```<code>abcToTestDir() {
        folderName=${1%_*}
        testFolderPath="$testfilespath$folderName"
        abcFilePath="$abcpath$folderName/$1"
        testFilePath="$testFolderPath/$1"

        mkdir -p $testFolderPath
        cp $abcFilePath $testFilePath
}
</code>```

What is wrong with my function definition?

答:
This can happen if gac is already an alias. For example on my machine:

$ type ls
ls is aliased to `ls --color=auto'
$ ls(){ true; }
bash: syntax error near unexpected token `('
```

Body:
gac() {
        git add .
        git commit -m "$1"
}

This function is in my bash profile, and it raises an error when I try to source the file.

$ source ~/.bashrc
bash: /home/sahandz/.bashrc: line 176: syntax error near unexpected token `('
bash: /home/sahandz/.bashrc: line 176: `gac() {'

I can't figure out why. I have another function that looks like this and doesn't raise any error:

abcToTestDir() {
        folderName=${1%_*}
        testFolderPath="$testfilespath$folderName"
        abcFilePath="$abcpath$folderName/$1"
        testFilePath="$testFolderPath/$1"

        mkdir -p $testFolderPath
        cp $abcFilePath $testFilePath
}

What is wrong with my function definition?


问:
How to fix 'APK is using permissions that require a privacy policy: (android.permission.CAMERA)' error in play console
I'm setting my flutter app to upload on play console but it shows error-
"Your APK or Android App Bundle is using permissions that require a privacy policy: (android.permission.CAMERA)."
  Even though I am not using permission for camera in my manifest file.

main/manifest file-

```<code><!-- io.flutter.app.FlutterApplication is an android.app.Application that
     calls FlutterMain.startInitialization(this); in its onCreate method.
     In most cases you can leave this as-is, but you if you want to provide
     additional functionality it is fine to subclass or reimplement
     FlutterApplication and put your custom class here. -->

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
    android:name="io.flutter.app.FlutterApplication"
    android:label="Motive Booster"
    android:icon="@mipmap/ic_launcher">
    <activity
        android:name=".MainActivity"
        android:launchMode="singleTop"
        android:theme="@style/LaunchTheme"
        android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
        android:hardwareAccelerated="true"
        android:windowSoftInputMode="adjustResize">
        <!-- This keeps the window background of the activity showing
             until Flutter renders its first frame. It can be removed if
             there is no splash screen (such as the default splash screen
             defined in @style/LaunchTheme). -->
        <meta-data
            android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
            android:value="true" />
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
</application>
</code>```

How can I solve this issue?

答:
One of your dependencies must be bringing the camera permission.

To remove it, you can add this to your manifest:

<manifest ... xmlns:tools="http://schemas.android.com/tools">
    ...
    <uses-permission android:name="android.permission.CAMERA" tools:node="remove"/>
    ...
</manifest>
```

Body:
I'm setting my flutter app to upload on play console but it shows error-
"Your APK or Android App Bundle is using permissions that require a privacy policy: (android.permission.CAMERA)."
  Even though I am not using permission for camera in my manifest file.

main/manifest file-

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
    android:name="io.flutter.app.FlutterApplication"
    android:label="Motive Booster"
    android:icon="@mipmap/ic_launcher">
    <activity
        android:name=".MainActivity"
        android:launchMode="singleTop"
        android:theme="@style/LaunchTheme"
        android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
        android:hardwareAccelerated="true"
        android:windowSoftInputMode="adjustResize">

        <meta-data
            android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
            android:value="true" />
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
</application>

How can I solve this issue?


问:
GNU make: how prevent '-include file.ext' from executing a rule the target of which is 'file.ext'?
Just to review the terminology, this is the structure of a makefile 'rule':

```<code>target:   dependencies ...
          commands
          ...
</code>```

This is the makefile I've written:

```<code>CC = mpicc
SHAREDLIB = libfmd.so
CFLAGS = -fPIC -Wall -Wno-unused-result -O3 -fopenmp
LFLAGS = -lm -fopenmp -lgsl -lgslcblas

OBJS = $(patsubst %.c,%.o,$(wildcard *.c))

.PHONY: all shared clean
all: shared
shared: $(SHAREDLIB)
$(SHAREDLIB): depend.mk $(OBJS)
    $(CC) $(OBJS) -shared -o $@ $(LFLAGS)
depend.mk: *.c *.h
    $(CC) -MM *.c > depend.mk
-include depend.mk
clean:
    rm -f *.o libfmd.so depend.mk
</code>```

When the folder is clean, and I enter make clean, the following lines are shown:

```<code>mpicc -MM *.c > depend.mk
rm -f *.o libfmd.so depend.mk
</code>```

It seems to me that -include depend.mk in addition to including depend.mk, executes the rule that depend.mk is its target. I'd like to stop this behavior.

答:
```<code>depend.mk: *.c *.h
    $(CC) -MM *.c > depend.mk
</code>```

<s>FYI, this is wrong, as make doesn't support shell wildcards in a rule string. Although on a recipe line that could work as it gets expanded by the shell itself.</s>

I'd like to stop this behavior

depend.mk is a prerequisite of the default target, so it is a target anyway.

Also, preprocessing into depend.mk is slow for large projects, so it totally makes sense either to switch to manually written dependencies, or use a recommended way to generate them, as @MadScientist suggested.

Body:
Just to review the terminology, this is the structure of a makefile 'rule':

target:   dependencies ...
          commands
          ...

This is the makefile I've written:

CC = mpicc
SHAREDLIB = libfmd.so
CFLAGS = -fPIC -Wall -Wno-unused-result -O3 -fopenmp
LFLAGS = -lm -fopenmp -lgsl -lgslcblas

OBJS = $(patsubst %.c,%.o,$(wildcard *.c))

.PHONY: all shared clean
all: shared
shared: $(SHAREDLIB)
$(SHAREDLIB): depend.mk $(OBJS)
    $(CC) $(OBJS) -shared -o $@ $(LFLAGS)
depend.mk: *.c *.h
    $(CC) -MM *.c > depend.mk
-include depend.mk
clean:
    rm -f *.o libfmd.so depend.mk

When the folder is clean, and I enter make clean, the following lines are shown:

mpicc -MM *.c > depend.mk
rm -f *.o libfmd.so depend.mk

It seems to me that -include depend.mk in addition to including depend.mk, executes the rule that depend.mk is its target. I'd like to stop this behavior.

Body:
depend.mk: *.c *.h
    $(CC) -MM *.c > depend.mk

<s>FYI, this is wrong, as make doesn't support shell wildcards in a rule string. Although on a recipe line that could work as it gets expanded by the shell itself.</s>

I'd like to stop this behavior

depend.mk is a prerequisite of the default target, so it is a target anyway.

Also, preprocessing into depend.mk is slow for large projects, so it totally makes sense either to switch to manually written dependencies, or use a recommended way to generate them, as @MadScientist suggested.


问:
How to update Camunda DMN table at runtime?
I have a DMN table created with a few rules and deployed to Camunda.

How do we update DMN tables programmatically at run-time and add a new rule when it is already deployed?

答:
When you change the dmn table but keep the decision-key, a deployment will create a new revision of the table.
So yes, you can update dmn tables at runtime.

You can do so by either using the REST or the java API.

The java api relies on the RepositoryService#createDeployment Builder. The concrete implementation depends on where your files are stored, and how you read them. Here are some examples.

```<code> Deployment deployment = repositoryService.createDeployment()
      .addString(resourceName, instanceAsString)
      .deploy();
</code>```

Body:
When you change the dmn table but keep the decision-key, a deployment will create a new revision of the table.
So yes, you can update dmn tables at runtime.

You can do so by either using the REST or the java API.

The java api relies on the RepositoryService#createDeployment Builder. The concrete implementation depends on where your files are stored, and how you read them. Here are some examples.

 Deployment deployment = repositoryService.createDeployment()
      .addString(resourceName, instanceAsString)
      .deploy();


问:
Subtract month/year to get years
```<code>data = data.frame("start"= c("1/2000","8/2004","99/9999"),
                  "stop"=c("1/2001","2/2007","09/2010"),
                  "WANTYEARS"= c(1,2.5,NA))
</code>```

I have date in month/year format and want to subtract to get the years.

My attempt of simple data$stop - data$start did not yield the desired results. THank you.

答:
The yearmon class represents months and years as years and fraction of a year.

Using data shown in the Note at the end:

```<code>library(zoo)

transform(data, diff = as.yearmon(stop, "%m/%Y") - as.yearmon(start, "%m/%Y"))
</code>```

giving:

```<code>    start    stop diff
1  1/2000  1/2001  1.0
2  8/2004  2/2007  2.5
3 99/9999 09/2010   NA
</code>```

Note

```<code>data = data.frame(start= c("1/2000", "8/2004", "99/9999"),
                  stop = c("1/2001", "2/2007", "09/2010"))
</code>```

Title: Subtract month/year to get years

Body:
data = data.frame("start"= c("1/2000","8/2004","99/9999"),
                  "stop"=c("1/2001","2/2007","09/2010"),
                  "WANTYEARS"= c(1,2.5,NA))

I have date in month/year format and want to subtract to get the years.

My attempt of simple data$stop - data$start did not yield the desired results. THank you.

Body:
The yearmon class represents months and years as years and fraction of a year.

Using data shown in the Note at the end:

library(zoo)

transform(data, diff = as.yearmon(stop, "%m/%Y") - as.yearmon(start, "%m/%Y"))

giving:

    start    stop diff
1  1/2000  1/2001  1.0
2  8/2004  2/2007  2.5
3 99/9999 09/2010   NA

Note

data = data.frame(start= c("1/2000", "8/2004", "99/9999"),
                  stop = c("1/2001", "2/2007", "09/2010"))


问:
Truffle Test - How To Show Errors Only
How does one suppress all compilation warnings (not errors) when running truffle test? Using the --quiet parameter does not seem to work.

```<code>Truffle v5.0.0 (core: 5.0.0)
Node v10.15.3
</code>```

答:
You can't suppress warnings, no such functionality yet in Truffle.

However, you can filter the output. I'm going to show an example using grep.

```<b>~/your_project_dir$</b> truffle test | grep 'Error'```

This will show only the lines which contain the word "Error".

Title: Truffle Test - How To Show Errors Only

Body:
How does one suppress all compilation warnings (not errors) when running truffle test? Using the --quiet parameter does not seem to work.

Truffle v5.0.0 (core: 5.0.0)
Node v10.15.3

Body:
You can't suppress warnings, no such functionality yet in Truffle.

However, you can filter the output. I'm going to show an example using grep.

~/your_project_dir$ truffle test | grep 'Error'

This will show only the lines which contain the word "Error".


问:
File not found in Jenkins pipeline script
I'm trying to have a pipeline script currently running on our Jenkins master, execute on a remote Jenkins node. But I'm getting a strange FileNotFound exception.

The most basic version of the pipeline I've been able to reproduce the issue with is this:

node("remoteNode") {
env.SERVICE_VERSIONS_FILE = pwd() + '/service_versions.csv'
stage('Read file') {
  git credentialsId: '***', url: '***'
  sh "cat $env.SERVICE_VERSIONS_FILE"
  new File(env.SERVICE_VERSIONS_FILE).each { line ->
    echo "$line"
   }
  }
}
```
<p>Which results in:</p>
```>java.io.FileNotFoundException: /home/***/workspace/DeploymentPipelines/test-deployer/service_versions.csv
> (No such file or directory)   at java.io.FileInputStream.open0(Native
> Method)   at java.io.FileInputStream.open(FileInputStream.java:195)   at
> java.io.FileInputStream.<init>(FileInputStream.java:138)  at
> groovy.util.CharsetToolkit.<init>(CharsetToolkit.java:71)     at
> org.codehaus.groovy.runtime.ResourceGroovyMethods.newReader(ResourceGroovyMethods.java:1572)
>   at
> org.codehaus.groovy.runtime.ResourceGroovyMethods.readLines(ResourceGroovyMethods.java:533)
>   at
> org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.asCollection(DefaultTypeTransformation.java:461)
>   at
> org.codehaus.groovy.runtime.DefaultGroovyMethods.iterator(DefaultGroovyMethods.java:15955)
>   at org.codehaus.groovy.runtime.dgm$367.doMethodInvoke(Unknown Source)
>   at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
>   at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
>   at
> org.codehaus.groovy.runtime.InvokerHelper.invokePojoMethod(InvokerHelper.java:913)
>   at
> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:904)
>   at
> org.codehaus.groovy.runtime.InvokerHelper.asIterator(InvokerHelper.java:573)
>   at org.codehaus.groovy.runtime.InvokerHelper$asIterator.call(Unknown
> Source)   at
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
>   at
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
>   at
> com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20)
>   at
> com.cloudbees.groovy.cps.CpsDefaultGroovyMethods.each(CpsDefaultGroovyMethods:1890)
>   at WorkflowScript.run(WorkflowScript:8)     at
> ___cps.transform___(Native Method)    at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:57)
>   at
> com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109)
>   at
> com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82)
>   at sun.reflect.GeneratedMethodAccessor324.invoke(Unknown Source)    at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>   at java.lang.reflect.Method.invoke(Method.java:498)     at
> com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
>   at
> com.cloudbees.groovy.cps.impl.LocalVariableBlock$LocalVariable.get(LocalVariableBlock.java:39)
>   at
> com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30)
>   at
> com.cloudbees.groovy.cps.impl.LocalVariableBlock.evalLValue(LocalVariableBlock.java:28)
>   at
> com.cloudbees.groovy.cps.LValueBlock$BlockImpl.eval(LValueBlock.java:55)
>   at com.cloudbees.groovy.cps.LValueBlock.eval(LValueBlock.java:16)   at
> com.cloudbees.groovy.cps.Next.step(Next.java:83)  at
> com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)     at
> com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)     at
> org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129)
>   at
> org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268)
>   at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
>   at
> org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:182)
>   at
> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:332)
>   at
> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$200(CpsThreadGroup.java:83)
>   at
> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:244)
>   at
> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:232)
>   at
> org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)
>   at java.util.concurrent.FutureTask.run(FutureTask.java:266)     at
> hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131)
>   at
> jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
>   at
> jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
>   at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
>   at java.util.concurrent.FutureTask.run(FutureTask.java:266)     at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
>   at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
>   at java.lang.Thread.run(Thread.java:748)   Finished: FAILURE
```

The sh "cat $env.SERVICE_VERSIONS_FILE" returns the correct results (i.e. - it prints the contents of the file).

The pipeline works fine when executed on the master. It feels like I might be missing something catastrophically simple? Or is it a bug?

答: I solved this error by providing a custom path of my Jenkinsfile.</p>

Body:
I'm trying to have a pipeline script currently running on our Jenkins master, execute on a remote Jenkins node. But I'm getting a strange FileNotFound exception.

The most basic version of the pipeline I've been able to reproduce the issue with is this:

node("remoteNode") {
env.SERVICE_VERSIONS_FILE = pwd() + '/service_versions.csv'
stage('Read file') {
  git credentialsId: '***', url: '***'
  sh "cat $env.SERVICE_VERSIONS_FILE"
  new File(env.SERVICE_VERSIONS_FILE).each { line ->
    echo "$line"
   }
  }
}

Which results in:

>java.io.FileNotFoundException: /home/***/workspace/DeploymentPipelines/test-deployer/service_versions.csv
> (No such file or directory)   at java.io.FileInputStream.open0(Native
> Method)   at java.io.FileInputStream.open(FileInputStream.java:195)   at
> java.io.FileInputStream.<init>(FileInputStream.java:138)  at
> groovy.util.CharsetToolkit.<init>(CharsetToolkit.java:71)     at
> org.codehaus.groovy.runtime.ResourceGroovyMethods.newReader(ResourceGroovyMethods.java:1572)
>   at
> org.codehaus.groovy.runtime.ResourceGroovyMethods.readLines(ResourceGroovyMethods.java:533)
>   at
> org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.asCollection(DefaultTypeTransformation.java:461)
>   at
> org.codehaus.groovy.runtime.DefaultGroovyMethods.iterator(DefaultGroovyMethods.java:15955)
>   at org.codehaus.groovy.runtime.dgm$367.doMethodInvoke(Unknown Source)
>   at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
>   at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
>   at
> org.codehaus.groovy.runtime.InvokerHelper.invokePojoMethod(InvokerHelper.java:913)
>   at
> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:904)
>   at
> org.codehaus.groovy.runtime.InvokerHelper.asIterator(InvokerHelper.java:573)
>   at org.codehaus.groovy.runtime.InvokerHelper$asIterator.call(Unknown
> Source)   at
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
>   at
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
>   at
> com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20)
>   at
> com.cloudbees.groovy.cps.CpsDefaultGroovyMethods.each(CpsDefaultGroovyMethods:1890)
>   at WorkflowScript.run(WorkflowScript:8)     at
> ___cps.transform___(Native Method)    at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:57)
>   at
> com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109)
>   at
> com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82)
>   at sun.reflect.GeneratedMethodAccessor324.invoke(Unknown Source)    at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>   at java.lang.reflect.Method.invoke(Method.java:498)     at
> com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
>   at
> com.cloudbees.groovy.cps.impl.LocalVariableBlock$LocalVariable.get(LocalVariableBlock.java:39)
>   at
> com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30)
>   at
> com.cloudbees.groovy.cps.impl.LocalVariableBlock.evalLValue(LocalVariableBlock.java:28)
>   at
> com.cloudbees.groovy.cps.LValueBlock$BlockImpl.eval(LValueBlock.java:55)
>   at com.cloudbees.groovy.cps.LValueBlock.eval(LValueBlock.java:16)   at
> com.cloudbees.groovy.cps.Next.step(Next.java:83)  at
> com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)     at
> com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)     at
> org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129)
>   at
> org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268)
>   at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
>   at
> org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:182)
>   at
> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:332)
>   at
> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$200(CpsThreadGroup.java:83)
>   at
> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:244)
>   at
> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:232)
>   at
> org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)
>   at java.util.concurrent.FutureTask.run(FutureTask.java:266)     at
> hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131)
>   at
> jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
>   at
> jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
>   at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
>   at java.util.concurrent.FutureTask.run(FutureTask.java:266)     at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
>   at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
>   at java.lang.Thread.run(Thread.java:748)   Finished: FAILURE

The sh "cat $env.SERVICE_VERSIONS_FILE" returns the correct results (i.e. - it prints the contents of the file).

The pipeline works fine when executed on the master. It feels like I might be missing something catastrophically simple? Or is it a bug?


问:
NuGet PackageReference not compatible with current framework version
I am working to move out NuGet references from using the packages.json format to PackageReferences. I have an issue with NuGet package compatibility: The package supports an older version of the .NET Framework.

This, using the packages.json format, works just fine.

```<code><?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="MarkdownDeep.NET-Signed" version="1.5" targetFramework="net461" />
</packages>

<Reference Include="MarkdownDeep, Version=1.5.5082.29984, Culture=neutral, PublicKeyToken=65640b2d9fe5ac0e, processorArchitecture=MSIL">
  <HintPath>..\..\packages\MarkdownDeep.NET-Signed.1.5\lib\.NetFramework 3.5\MarkdownDeep.dll</HintPath>
  <Private>True</Private>
</Reference>
</code>```

However, replacing this with a PackageReference instruction in the .csproj file results in the error below:

```<code><PackageReference Include="MarkdownDeep.NET-Signed">
  <Version>1.5</Version>
</PackageReference>
</code>```

"C:\Source\WebApp.csproj" (Restore target) (1) -> (Restore target) ->
  C:\Source\WebApp.csproj : error NU1202: Package
  MarkdownDeep.NET-Signed 1.5.0 is not compatible with net472
  (.NETFramework,Version=v4.7.2). Package MarkdownDeep.NET-Signed 1.5.0
  supports: netframework35 (.NetFramework 3.5,Version=v0.0)

Note that the current target framework in both cases is the same, v4.7.2.

Are there any additional instruction to add to the <PackageReference> node that will allow me to indicate that it is OK for this to target .NET Framework 3.5?

Note:
There's some good info in Package references (PackageReference) in project files, but it seems it only deals with TargetFramework as a variable to conditionally add references. I don't think I have a mix of .NET Framework versions to deal with - it's just v4.7.2 all the way.

答:
I've only been working on the NuGet team for a few months, so I don't consider myself an expert in all thing NuGet, but I would suggest that the MarkdownDeep.NET-Signed package might not be authored correctly.

From your sample you copied from the csproj using packages.config, you can see the package contains a lib\.NetFramework 3.5\ folder. However, NuGet packages usually use the short form lib\net35\. From a quick test of creating a console app, referencing the NuGet.Frameworks package and then using NuGetFramework.Parse(".NetFramework 3.5"), the resulting object has an "unsupported" framework. NuGet Package Explorer (available in the Microsoft Store) is a 3rd party app, so not guaranteed to work the same way that NuGet does in VS, but it also shows the .NetFramework 3.5 as "Unrecognized framework" lending further evidence that it could be an incorrectly authored package.

Given that the package does not appear to be correct, it is valid for NuGet to fail restore with PackageReference since NuGet is responsible for selecting assets from the package that are compatible with your project. I don't know why installing the package in a packages.config project works though.

If you're just looking for a .NET markdown parser, from what I can tell markdig is the most popular and still maintained package available on nuget.org.

Body:
I am working to move out NuGet references from using the packages.json format to PackageReferences. I have an issue with NuGet package compatibility: The package supports an older version of the .NET Framework.

This, using the packages.json format, works just fine.

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="MarkdownDeep.NET-Signed" version="1.5" targetFramework="net461" />
</packages>

<Reference Include="MarkdownDeep, Version=1.5.5082.29984, Culture=neutral, PublicKeyToken=65640b2d9fe5ac0e, processorArchitecture=MSIL">
  <HintPath>..\..\packages\MarkdownDeep.NET-Signed.1.5\lib\.NetFramework 3.5\MarkdownDeep.dll</HintPath>
  <Private>True</Private>
</Reference>

However, replacing this with a PackageReference instruction in the .csproj file results in the error below:

<PackageReference Include="MarkdownDeep.NET-Signed">
  <Version>1.5</Version>
</PackageReference>

"C:\Source\WebApp.csproj" (Restore target) (1) -> (Restore target) ->
  C:\Source\WebApp.csproj : error NU1202: Package
  MarkdownDeep.NET-Signed 1.5.0 is not compatible with net472
  (.NETFramework,Version=v4.7.2). Package MarkdownDeep.NET-Signed 1.5.0
  supports: netframework35 (.NetFramework 3.5,Version=v0.0)

Note that the current target framework in both cases is the same, v4.7.2.

Are there any additional instruction to add to the <PackageReference> node that will allow me to indicate that it is OK for this to target .NET Framework 3.5?

Note:
There's some good info in Package references (PackageReference) in project files, but it seems it only deals with TargetFramework as a variable to conditionally add references. I don't think I have a mix of .NET Framework versions to deal with - it's just v4.7.2 all the way.


问:
Showing Segmentation Fault when Attempting to Reverse a Linked List
I tried reversing a section of a singly Linked list using this code.

Here startOfSec is the pointer at the starting node of the section of the linked list which is to be reversed, and endofSec is the pointer to the last node of that section.

Now, with this code, I'm getting segmentation fault but if I replace endOfSec->next with NULL (I'm changing the value of the pointer, pointing to the last node of the section(which is to be reversed) of the original linked list, to NULL as well) in the while loop condition, it works perfectly!

```<code>void reverseList(ListNode* startOfSec, ListNode *endOfSec){

    ListNode *prev = NULL;
    ListNode *curr = startOfSec;
    ListNode *nxt;
    while(curr!=endOfSec->next){
        nxt = curr->next;
        curr->next = prev;
        prev = curr;
        curr = nxt;
    }
}

Callsite:
//code to get start and end pointers
reverseList(start, end);
</code>```

I expected my code to reverse the section of the list without the need of setting end->next pointer as NULL.

答:
There are a couple of problems with this code, some easier to fix than others. For this specific segmentation fault, a code walkthrough reveals the cause. Let's look at what happens with a simple example. (You should learn how to do this on your own, either by hand or using a debugger.)

```<code>start -> end -> NULL
</code>```

This is a list with two elements, one named "start" and the other "end". Meh, let's say "start" and "end" are also pointers to the nodes. It's a little ambiguous, but it should not cause problems this time. Now reverse the list.

```<code>reverseList(start, end);
</code>```

Before the first iteration of the loop in reverseList (i.e. after the initializations), your data looks like the following.

```<code>startOfSec == start
endOfSec == end;     endOfSec->next == NULL;
prev == NULL
curr == start
nxt == /* uninitialized */

start -> end -> NULL
</code>```

After the first iteration, the data has been updated.

```<code>startOfSec == start
endOfSec == end;     endOfSec->next == NULL;
prev == start
curr == end
nxt == end

start -> NULL
end -> NULL
</code>```

After the second iteration, the data has been updated.

```<code>startOfSec == start
endOfSec == end;     endOfSec->next == start;
prev == end
curr == NULL
nxt == NULL

end -> start -> NULL
</code>```

Congrats, the list has been reversed. Now all we have to do is exit the loop, so we would like curr to equal endOfSec->next. However, NULL is not equal to start, so we continue into a third iteration, and crash when we try to read curr->next (a.k.a. NULL->next).

Overall, you need to revise how you track the beginning and end of the section to reverse. The current crash comes about because you lose track of the end of the section. (Maybe check prev != endOfSec instead?) You will also have a problem if the end of the section is not the end of the list (the part of the list after the reversed section will be lost in limbo), but that is easy to fix by changing how prev is initialized. The biggest problem I see is when the beginning of the section is not the beginning of the list – changing a singly-linked list requires modifications to the node before the change (a.k.a. the node before startOfSec).

Body:
I tried reversing a section of a singly Linked list using this code.

Here startOfSec is the pointer at the starting node of the section of the linked list which is to be reversed, and endofSec is the pointer to the last node of that section.

Now, with this code, I'm getting segmentation fault but if I replace endOfSec->next with NULL (I'm changing the value of the pointer, pointing to the last node of the section(which is to be reversed) of the original linked list, to NULL as well) in the while loop condition, it works perfectly!

void reverseList(ListNode* startOfSec, ListNode *endOfSec){

    ListNode *prev = NULL;
    ListNode *curr = startOfSec;
    ListNode *nxt;
    while(curr!=endOfSec->next){
        nxt = curr->next;
        curr->next = prev;
        prev = curr;
        curr = nxt;
    }
}

Callsite:
//code to get start and end pointers
reverseList(start, end);

I expected my code to reverse the section of the list without the need of setting end->next pointer as NULL.

Body:
There are a couple of problems with this code, some easier to fix than others. For this specific segmentation fault, a code walkthrough reveals the cause. Let's look at what happens with a simple example. (You should learn how to do this on your own, either by hand or using a debugger.)

start -> end -> NULL

This is a list with two elements, one named "start" and the other "end". Meh, let's say "start" and "end" are also pointers to the nodes. It's a little ambiguous, but it should not cause problems this time. Now reverse the list.

reverseList(start, end);

Before the first iteration of the loop in reverseList (i.e. after the initializations), your data looks like the following.

startOfSec == start
endOfSec == end;     endOfSec->next == NULL;
prev == NULL
curr == start
nxt == /* uninitialized */

start -> end -> NULL

After the first iteration, the data has been updated.

startOfSec == start
endOfSec == end;     endOfSec->next == NULL;
prev == start
curr == end
nxt == end

start -> NULL
end -> NULL

After the second iteration, the data has been updated.

startOfSec == start
endOfSec == end;     endOfSec->next == start;
prev == end
curr == NULL
nxt == NULL

end -> start -> NULL

Congrats, the list has been reversed. Now all we have to do is exit the loop, so we would like curr to equal endOfSec->next. However, NULL is not equal to start, so we continue into a third iteration, and crash when we try to read curr->next (a.k.a. NULL->next).

Overall, you need to revise how you track the beginning and end of the section to reverse. The current crash comes about because you lose track of the end of the section. (Maybe check prev != endOfSec instead?) You will also have a problem if the end of the section is not the end of the list (the part of the list after the reversed section will be lost in limbo), but that is easy to fix by changing how prev is initialized. The biggest problem I see is when the beginning of the section is not the beginning of the list – changing a singly-linked list requires modifications to the node before the change (a.k.a. the node before startOfSec).


问:
MongoDB + Elasticsearch or only Elasticsearch?
We have a new project there for index a large amount of data and for provide real time. I have also complexe search with facets, full text, geospatial...

The first prototype is to index in MongoDB and next, into Elasticsearch, because I had read that Elasticsearch does not apply a checksum on stored files and the index can't be fully trusted.
But since last versions (in the version 1.5), there is now a checksum and I'm guessing if we can use Elasticsearch as primary data store ? And what is the benefit to use MongoDB in addition to Elasticsearch ?

I can't find up to date answer about thoses features in Elasticsearch

Thanks a lot

答:
I have recently developed a feature in my company,

we wanted to perform some searches and rank the result according to its relevance on multiple factors and conditions.

So in my application, we were already using MongoDB as Db,

So on ElasticSearch index, I exported some of the fields from MongoDB that I want to perform search and filters on.
So according to required conditions I prepared my mongo query and elasticsearch query also and performed the search. Then I filtered and sorted the result according to my need.
The whole flow will was designed in such a way that,
even if there is an error from ES, mongo will fetch the records.
If I get the result from ES then, mongo result will depend on ES result.
This is how I used mongo and ES in combination.

Also, don't forget to properly handle all updates, deletes and new record insertions.

And Just to Know, results for me were Really Good.


问:
My responsive navbar is not responsive on mobile devices(overflow problem?)
So i'm trying to build a responsive nav bar for a website, on Desktops it works great, however on mobile devices, no amount of me working with the overflow: hidden; will actually make the overflow go away.

When I originally started looking into this problem, I found a couple forums that said sometimes you need to assign "overflow: hidden;" to a more specific part of the html, so I tried that, but with no avail. My overflow is still all out in the open on mobile devices.

```<code>.mobile{
      display: none;
      cursor: pointer;
      overflow-x: hidden
  }

  .mobile div{
    width: 25px;
    height: 2px;
    background-color: #2d3436;
    margin: 5px;
    transition: all 0.3s ease;
  }

  @media screen and(max-width:1024px){
      .main-nav{
          width: 60%;
      }
  }

  @media screen and (max-width:786px){
      body{
          overflow: hidden;
      }
      .main-nav{
          position: absolute;
          right: 0px;
          height: 92vh;
          top: 8vh;
          background-color: white;
          display: flex;
          flex-direction: column;
          align-items: center;
          justify-content: center;
          width: 100%;
          transform: translateX(100%);
          transition: transform 0.5s ease-in;
        }
        .main-nav li {
            opacity: 0;
        }
        .mobile{
            display: block;
        }
    }
</code>```

To my knowledge(which granted isn't much) this should be a responsive navbar that has no overflow on mobile devices, I do have a link to the test website as well if you'd like to see it in action. I'm probably just missing something small, but I'm beat, I've been looking into this for hours. Any help is appreciated!

答:
Try adding this in the head tag of your HTML</p>

```<code><meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
</code>```

Body:
So i'm trying to build a responsive nav bar for a website, on Desktops it works great, however on mobile devices, no amount of me working with the overflow: hidden; will actually make the overflow go away.

When I originally started looking into this problem, I found a couple forums that said sometimes you need to assign "overflow: hidden;" to a more specific part of the html, so I tried that, but with no avail. My overflow is still all out in the open on mobile devices.

.mobile{
      display: none;
      cursor: pointer;
      overflow-x: hidden
  }

  .mobile div{
    width: 25px;
    height: 2px;
    background-color: #2d3436;
    margin: 5px;
    transition: all 0.3s ease;
  }

  @media screen and(max-width:1024px){
      .main-nav{
          width: 60%;
      }
  }

  @media screen and (max-width:786px){
      body{
          overflow: hidden;
      }
      .main-nav{
          position: absolute;
          right: 0px;
          height: 92vh;
          top: 8vh;
          background-color: white;
          display: flex;
          flex-direction: column;
          align-items: center;
          justify-content: center;
          width: 100%;
          transform: translateX(100%);
          transition: transform 0.5s ease-in;
        }
        .main-nav li {
            opacity: 0;
        }
        .mobile{
            display: block;
        }
    }

To my knowledge(which granted isn't much) this should be a responsive navbar that has no overflow on mobile devices, I do have a link to the test website as well if you'd like to see it in action. I'm probably just missing something small, but I'm beat, I've been looking into this for hours. Any help is appreciated!

Body:
Try adding this in the head tag of your HTML

<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">


问:
How to receive multicast data on a multihomed server's non-default interface
I have a linux server with two NICs (eth0 and eth1), and have set eth0 as default in "ip route."  Now I would like to receive multicast packets on eth1.  I have added "224.0.20.0/24 dev eth1  proto static scope link" to the routing table, and I connect as follows:

```<code>sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);

// port 12345, adress INADDR_ANY
bind(sock, &bind_addr, sizeof(bind_addr));

// multicast address 224.0.20.100, interface address 10.13.0.7 (=eth1)
setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, &imreq, sizeof(imreq));
</code>```

According to ip maddr it connects to that group on the right interface, and tshark -i eth1 shows that I am actually getting multicast packets.

However, I don't get any packets when calling recvfrom(sock).  If I set "ip route default" to eth1 (instead of eth0), I do get packets via recvfrom.  Is this an issue with my code or with my network setup, and what is the correct way of doing this?

(update) solution: caf hinted that this might be the same problem; indeed: after doing echo 0 > /proc/sys/net/ipv4/conf/eth1/rp_filter I can now receive multicast packets!

答: Try adding a netmask and specifying 10.13.0.7 as the gateway in your routing table entry.</p>

Body:
I have a linux server with two NICs (eth0 and eth1), and have set eth0 as default in "ip route."  Now I would like to receive multicast packets on eth1.  I have added "224.0.20.0/24 dev eth1  proto static scope link" to the routing table, and I connect as follows:

sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);

// port 12345, adress INADDR_ANY
bind(sock, &bind_addr, sizeof(bind_addr));

// multicast address 224.0.20.100, interface address 10.13.0.7 (=eth1)
setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, &imreq, sizeof(imreq));

According to ip maddr it connects to that group on the right interface, and tshark -i eth1 shows that I am actually getting multicast packets.

However, I don't get any packets when calling recvfrom(sock).  If I set "ip route default" to eth1 (instead of eth0), I do get packets via recvfrom.  Is this an issue with my code or with my network setup, and what is the correct way of doing this?

(update) solution: caf hinted that this might be the same problem; indeed: after doing echo 0 > /proc/sys/net/ipv4/conf/eth1/rp_filter I can now receive multicast packets!


问:
Finding differences in projections in R and projections in ArcMap
My current issue is creating an R program or function which creates a dataframe projection from latitude and longitude points to NAD-1983 2011 StatePlane Pennsylvania South FIPS - 3702 data.  Currently, I've hit a snag.  Here is the input data I've been using:

Latitude/Longitude:

```<code>-75.35843   40.12232
-75.36189   40.12347
-75.36404   40.12456
-75.37228   40.1287
-75.37835   40.13243
-75.38479   40.13835
-75.38961   40.14198
-75.39536   40.14724
-75.40018   40.15457
-75.40614   40.15849
-75.40939   40.16014
-75.41906   40.16572
-75.43034   40.17133
-75.43579   40.17576
</code>```

The current function I've been trying uses rgdal and sf functions.  I'm trying to do the following:

Define the data_x data projection in lat/long

Project the data to NAD-1983 2011 StatePlane Pennsylvania South FIPS - 3702 data

StatePlane info below:

```<code>NAD_1983_2011_StatePlane_Pennsylvania_South_FIPS_3702
WKID: 6564 Authority: EPSG

Projection: Lambert_Conformal_Conic
False_Easting: 600000.0
False_Northing: 0.0
Central_Meridian: -77.75
Standard_Parallel_1: 39.93333333333333
Standard_Parallel_2: 40.96666666666667
Latitude_Of_Origin: 39.33333333333334
Linear Unit: Meter (1.0)

Geographic Coordinate System: GCS_NAD_1983_2011
Angular Unit: Degree (0.0174532925199433)
Prime Meridian: Greenwich (0.0)
Datum: D_NAD_1983_2011
      Spheroid: GRS_1980
            Semimajor Axis: 6378137.0
            Semiminor Axis: 6356752.314140356
            Inverse Flattening: 298.257222101
</code>```

And here's the code I came up with

```<code>pckgs <- c("rgdal", "sf")
install.packages(pckgs)
library(rgdal)
library(sf)

project_coordinates <- function(df="data_x", x="Long", y="Lat"){
      # returns a dataframe with two new columns containing projected coordinates to NAD83
      ## df(str): dataframe to use
      ## x (str): name of column containing Longitude in degrees
      ## y (str): name of column containing Latitude in degrees
  df <- st_set_crs(df, "+proj=longlat +ellps=GRS80 +datum=NAD83")
  proj <- "+lat_1=39.93333333333333 +lat_2=40.96666666666667 +lat_0=39.33333333333334 +lon_0=-77.75 +x_0= 600000.0 +y_0=0 +k_0=lcc +ellps=GRS80 +datum=NAD83 +units=m no_defs"
  lat_long_proj <- project(as.matrix(cbind(df[x],df[y])),proj)
  df["Long_proj"] <-lat_long_proj[,1]
  df["Lat_proj"] <- lat_long_proj[,2]
  return(df)
}
</code>```

Here is an example of some of the results from what output I've found.

From R:

```<code>2637234.459 296472.2704
2636255.877 296864.8632
2635644.121 297245.5394
2633300.071 298690.992
2631566.848 300003.65
2629709.03  302111.1583
2628326.55  303396.9907
2626668.485 305269.5429
2625250.476 307902.9271
2623547.213 309286.1584
2622623.208 309862.9293
2619867.744 311823.4605
2616662.666 313783.4043
2615097.884 315356.6863
</code>```

And from ArcGIS:

```<code>103492.4449 778962.9451
103492.4652 778963.7957
103492.4652 778963.7957
103728.4336 778891.792
103785.0208 778469.1788
103675.0824 778236.0495
104262.4265 777852.7858
104271.2263 777849.1735
104276.7765 777849.042
104276.8168 777850.743
104277.9268 777850.7168
104279.057  777851.541
104279.057  777851.541
104280.1671 777851.5147
</code>```

While I haven't encountered any code-breaking errors, these results are an inconsistent factor of distance apart.  Is there a package I'm missing?  Am I missing a command or a step?

答:
AM having trouble running your code because if I pass a data frame it errors with

```<code>Error in UseMethod("st_crs<-") :
  no applicable method for 'st_crs<-' applied to an object of class "data.frame"
>
</code>```

I guess you must be reading it into a spatial data frame somehow. Also your target projection string seems broken. I'll show you how I'd do this:

First, with the data in a text file like this (which is long-lat):

```<code>-75.35843   40.12232
-75.36189   40.12347
-75.36404   40.12456
-75.37228   40.1287
</code>```

I'd read it in with:

```<code>> pts = read.table("latlong.txt",head=FALSE)
> head(pts)
         V1       V2
1 -75.35843 40.12232
2 -75.36189 40.12347
3 -75.36404 40.12456
4 -75.37228 40.12870
5 -75.37835 40.13243
6 -75.38479 40.13835
</code>```

Then use the sf package functions to make it into points with the EPSG:4326 coordinate system - the common GPS coordinates:

```<code>> pts2 = st_as_sf(pts, coords=c(1,2), crs=4326)
> pts2
Simple feature collection with 14 features and 0 fields
geometry type:  POINT
dimension:      XY
bbox:           xmin: -75.43579 ymin: 40.12232 xmax: -75.35843 ymax: 40.17576
epsg (SRID):    4326
proj4string:    +proj=longlat +datum=WGS84 +no_defs
First 10 features:
                     geometry
1  POINT (-75.35843 40.12232)
2  POINT (-75.36189 40.12347)
3  POINT (-75.36404 40.12456)
4   POINT (-75.37228 40.1287)
5  POINT (-75.37835 40.13243)
6  POINT (-75.38479 40.13835)
7  POINT (-75.38961 40.14198)
8  POINT (-75.39536 40.14724)
9  POINT (-75.40018 40.15457)
10 POINT (-75.40614 40.15849)
</code>```

Now I can transform to any other coordinate system. Your target appears to be EPSG:6564 (WKID: 6564 Authority: EPSG) (http://epsg.io/6564) although you also mention 3702 which is seems to be related to Wyoming...).

```<code>> st_transform(pts2, 6564)
Simple feature collection with 14 features and 0 fields
geometry type:  POINT
dimension:      XY
bbox:           xmin: 797083.4 ymin: 90364.93 xmax: 803830.7 ymax: 96120.91
epsg (SRID):    6564
proj4string:    +proj=lcc +lat_1=40.96666666666667 +lat_2=39.93333333333333 +lat_0=39.33333333333334 +lon_0=-77.75 +x_0=600000 +y_0=0 +ellps=GRS80 +units=m +no_defs
First 10 features:
                    geometry
1  POINT (803830.7 90364.93)
2  POINT (803532.4 90484.59)
3  POINT (803345.9 90600.62)
4   POINT (802631.5 91041.2)
5   POINT (802103.2 91441.3)
6  POINT (801536.9 92083.67)
7  POINT (801115.5 92475.59)
8  POINT (800610.2 93046.34)
9     POINT (800177.9 93849)
10 POINT (799658.8 94270.61)
>
</code>```

and those points don't match the ones you gave for either your R code or ARCGis, assuming the lat-longs you gave are supposed to be corresponding to the transformed X-Y coords you gave.

I'd be very confident in saying that the numbers I've given above are the EPSG:6564 coordinates of the EPSG:4326 lat-long coordinates in the source.

Also I managed to fix your broken projection string:

```<code>proj <- "+lat_1=39.93333333333333 +lat_2=40.96666666666667 +lat_0=39.33333333333334 +lon_0=-77.75 +x_0=600000.0 +y_0=0 +proj=lcc +ellps=GRS80 +datum=NAD83 +units=m"
</code>```

and that produces the same results as EPSG:6564.

Not being able to run your code and reproduce your results, I'm not sure where the problem lies, but my code is how I'd do this and I'm pretty confident its right.

Body:
My current issue is creating an R program or function which creates a dataframe projection from latitude and longitude points to NAD-1983 2011 StatePlane Pennsylvania South FIPS - 3702 data.  Currently, I've hit a snag.  Here is the input data I've been using:

Latitude/Longitude:

-75.35843   40.12232
-75.36189   40.12347
-75.36404   40.12456
-75.37228   40.1287
-75.37835   40.13243
-75.38479   40.13835
-75.38961   40.14198
-75.39536   40.14724
-75.40018   40.15457
-75.40614   40.15849
-75.40939   40.16014
-75.41906   40.16572
-75.43034   40.17133
-75.43579   40.17576

The current function I've been trying uses rgdal and sf functions.  I'm trying to do the following:

Define the data_x data projection in lat/long

Project the data to NAD-1983 2011 StatePlane Pennsylvania South FIPS - 3702 data

StatePlane info below:

NAD_1983_2011_StatePlane_Pennsylvania_South_FIPS_3702
WKID: 6564 Authority: EPSG

Projection: Lambert_Conformal_Conic
False_Easting: 600000.0
False_Northing: 0.0
Central_Meridian: -77.75
Standard_Parallel_1: 39.93333333333333
Standard_Parallel_2: 40.96666666666667
Latitude_Of_Origin: 39.33333333333334
Linear Unit: Meter (1.0)

Geographic Coordinate System: GCS_NAD_1983_2011
Angular Unit: Degree (0.0174532925199433)
Prime Meridian: Greenwich (0.0)
Datum: D_NAD_1983_2011
      Spheroid: GRS_1980
            Semimajor Axis: 6378137.0
            Semiminor Axis: 6356752.314140356
            Inverse Flattening: 298.257222101

And here's the code I came up with

pckgs <- c("rgdal", "sf")
install.packages(pckgs)
library(rgdal)
library(sf)

project_coordinates <- function(df="data_x", x="Long", y="Lat"){
      # returns a dataframe with two new columns containing projected coordinates to NAD83
      ## df(str): dataframe to use
      ## x (str): name of column containing Longitude in degrees
      ## y (str): name of column containing Latitude in degrees
  df <- st_set_crs(df, "+proj=longlat +ellps=GRS80 +datum=NAD83")
  proj <- "+lat_1=39.93333333333333 +lat_2=40.96666666666667 +lat_0=39.33333333333334 +lon_0=-77.75 +x_0= 600000.0 +y_0=0 +k_0=lcc +ellps=GRS80 +datum=NAD83 +units=m no_defs"
  lat_long_proj <- project(as.matrix(cbind(df[x],df[y])),proj)
  df["Long_proj"] <-lat_long_proj[,1]
  df["Lat_proj"] <- lat_long_proj[,2]
  return(df)
}

Here is an example of some of the results from what output I've found.

From R:

2637234.459 296472.2704
2636255.877 296864.8632
2635644.121 297245.5394
2633300.071 298690.992
2631566.848 300003.65
2629709.03  302111.1583
2628326.55  303396.9907
2626668.485 305269.5429
2625250.476 307902.9271
2623547.213 309286.1584
2622623.208 309862.9293
2619867.744 311823.4605
2616662.666 313783.4043
2615097.884 315356.6863

And from ArcGIS:

103492.4449 778962.9451
103492.4652 778963.7957
103492.4652 778963.7957
103728.4336 778891.792
103785.0208 778469.1788
103675.0824 778236.0495
104262.4265 777852.7858
104271.2263 777849.1735
104276.7765 777849.042
104276.8168 777850.743
104277.9268 777850.7168
104279.057  777851.541
104279.057  777851.541
104280.1671 777851.5147

While I haven't encountered any code-breaking errors, these results are an inconsistent factor of distance apart.  Is there a package I'm missing?  Am I missing a command or a step?

Body:
AM having trouble running your code because if I pass a data frame it errors with

Error in UseMethod("st_crs<-") :
  no applicable method for 'st_crs<-' applied to an object of class "data.frame"
>

I guess you must be reading it into a spatial data frame somehow. Also your target projection string seems broken. I'll show you how I'd do this:

First, with the data in a text file like this (which is long-lat):

-75.35843   40.12232
-75.36189   40.12347
-75.36404   40.12456
-75.37228   40.1287

I'd read it in with:

> pts = read.table("latlong.txt",head=FALSE)
> head(pts)
         V1       V2
1 -75.35843 40.12232
2 -75.36189 40.12347
3 -75.36404 40.12456
4 -75.37228 40.12870
5 -75.37835 40.13243
6 -75.38479 40.13835

Then use the sf package functions to make it into points with the EPSG:4326 coordinate system - the common GPS coordinates:

> pts2 = st_as_sf(pts, coords=c(1,2), crs=4326)
> pts2
Simple feature collection with 14 features and 0 fields
geometry type:  POINT
dimension:      XY
bbox:           xmin: -75.43579 ymin: 40.12232 xmax: -75.35843 ymax: 40.17576
epsg (SRID):    4326
proj4string:    +proj=longlat +datum=WGS84 +no_defs
First 10 features:
                     geometry
1  POINT (-75.35843 40.12232)
2  POINT (-75.36189 40.12347)
3  POINT (-75.36404 40.12456)
4   POINT (-75.37228 40.1287)
5  POINT (-75.37835 40.13243)
6  POINT (-75.38479 40.13835)
7  POINT (-75.38961 40.14198)
8  POINT (-75.39536 40.14724)
9  POINT (-75.40018 40.15457)
10 POINT (-75.40614 40.15849)

Now I can transform to any other coordinate system. Your target appears to be EPSG:6564 (WKID: 6564 Authority: EPSG) (http://epsg.io/6564) although you also mention 3702 which is seems to be related to Wyoming...).

> st_transform(pts2, 6564)
Simple feature collection with 14 features and 0 fields
geometry type:  POINT
dimension:      XY
bbox:           xmin: 797083.4 ymin: 90364.93 xmax: 803830.7 ymax: 96120.91
epsg (SRID):    6564
proj4string:    +proj=lcc +lat_1=40.96666666666667 +lat_2=39.93333333333333 +lat_0=39.33333333333334 +lon_0=-77.75 +x_0=600000 +y_0=0 +ellps=GRS80 +units=m +no_defs
First 10 features:
                    geometry
1  POINT (803830.7 90364.93)
2  POINT (803532.4 90484.59)
3  POINT (803345.9 90600.62)
4   POINT (802631.5 91041.2)
5   POINT (802103.2 91441.3)
6  POINT (801536.9 92083.67)
7  POINT (801115.5 92475.59)
8  POINT (800610.2 93046.34)
9     POINT (800177.9 93849)
10 POINT (799658.8 94270.61)
>

and those points don't match the ones you gave for either your R code or ARCGis, assuming the lat-longs you gave are supposed to be corresponding to the transformed X-Y coords you gave.

I'd be very confident in saying that the numbers I've given above are the EPSG:6564 coordinates of the EPSG:4326 lat-long coordinates in the source.

Also I managed to fix your broken projection string:

proj <- "+lat_1=39.93333333333333 +lat_2=40.96666666666667 +lat_0=39.33333333333334 +lon_0=-77.75 +x_0=600000.0 +y_0=0 +proj=lcc +ellps=GRS80 +datum=NAD83 +units=m"

and that produces the same results as EPSG:6564.

Not being able to run your code and reproduce your results, I'm not sure where the problem lies, but my code is how I'd do this and I'm pretty confident its right.


问:
using papa parse for big csv files
I am trying to load a file that has about 100k in lines and so far the browser has been crashing ( locally ). I looked on the internet and saw Papa Parse seems to handle large files. Now it is reduced down to about 3-4 minutes to load into the textarea. Once the file is loaded, I then want to do some more jQuery to do counts and things so the process is taking awhile. Is there a way to make the csv load faster? Am I using the program correctly?</p>

```<code><div id="tabs">
<ul>
  <li><a href="#tabs-4">Generate a Report</a></li>
</ul>
<div id="tabs-4">
  <h2>Generating a CSV report</h2>
  <h4>Input Data:</h4>
  <input id="myFile" type="file" name="files" value="Load File" />
  <button onclick="loadFileAsText()">Load Selected File</button>
  <form action="./" method="post">
  <textarea id="input3" style="height:150px;"></textarea>

  <input id="run3" type="button" value="Run" />
  <input id="runSplit" type="button" value="Run Split" />
  <input id="downloadLink" type="button" value="Download" />
  </form>
</div>
</div>

$(function () {
    $("#tabs").tabs();
});

var data = $('#input3').val();

function handleFileSelect(evt) {
    var file = evt.target.files[0];

Papa.parse(file, {
    header: true,
    dynamicTyping: true,
    complete: function (results) {
        data = results;
    }
});
}

$(document).ready(function () {

    $('#myFile').change(function(handleFileSelect){

    });
});

function loadFileAsText() {
    var fileToLoad = document.getElementById("myFile").files[0];

    var fileReader = new FileReader();
    fileReader.onload = function (fileLoadedEvent) {
        var textFromFileLoaded = fileLoadedEvent.target.result;
        document.getElementById("input3").value = textFromFileLoaded;
    };
    fileReader.readAsText(fileToLoad, "UTF-8");
}
</code>```

答:
As of v5, PapaParse has now baked in WebWorkers.

A simple example of invoking the worker within Papaparse is below

```<code>Papa.parse(bigFile, {
    worker: true,
    step: function(results) {
        console.log("Row:", results.data);
    }
});
</code>```

No need to re-implement if you have your own worker with PP, but for future projects, some may find it easier to use PapaParse's solution.

Title: using papa parse for big csv files

Body:
I am trying to load a file that has about 100k in lines and so far the browser has been crashing ( locally ). I looked on the internet and saw Papa Parse seems to handle large files. Now it is reduced down to about 3-4 minutes to load into the textarea. Once the file is loaded, I then want to do some more jQuery to do counts and things so the process is taking awhile. Is there a way to make the csv load faster? Am I using the program correctly?

Generate a Report

Generating a CSV report

Input Data:

  <input id="myFile" type="file" name="files" value="Load File" />
  <button onclick="loadFileAsText()">Load Selected File</button>
  <form action="./" method="post">
  <textarea id="input3" style="height:150px;"></textarea>

  <input id="run3" type="button" value="Run" />
  <input id="runSplit" type="button" value="Run Split" />
  <input id="downloadLink" type="button" value="Download" />
  </form>

$(function () {
    $("#tabs").tabs();
});

var data = $('#input3').val();

function handleFileSelect(evt) {
    var file = evt.target.files[0];

Papa.parse(file, {
    header: true,
    dynamicTyping: true,
    complete: function (results) {
        data = results;
    }
});
}

$(document).ready(function () {

    $('#myFile').change(function(handleFileSelect){

    });
});

function loadFileAsText() {
    var fileToLoad = document.getElementById("myFile").files[0];

    var fileReader = new FileReader();
    fileReader.onload = function (fileLoadedEvent) {
        var textFromFileLoaded = fileLoadedEvent.target.result;
        document.getElementById("input3").value = textFromFileLoaded;
    };
    fileReader.readAsText(fileToLoad, "UTF-8");
}

Body:
As of v5, PapaParse has now baked in WebWorkers.

A simple example of invoking the worker within Papaparse is below

Papa.parse(bigFile, {
    worker: true,
    step: function(results) {
        console.log("Row:", results.data);
    }
});

No need to re-implement if you have your own worker with PP, but for future projects, some may find it easier to use PapaParse's solution.


问:
How to update map markers based on an AsyncTask result
I have an asyncTask CommunicationThread which creates some Latitudes and Longitudes. I also have a map activity where I want to take the results of CommunicationThread update the marker based on these results. Here is the code of my map Activity.

```<code>public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {

private GoogleMap mMap;
private Thread2ThreadInfo connectionInfo;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);

    connectionInfo = SubscriberActivity.getConnInfo();
}

@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    Handler handler = new Handler(Looper.getMainLooper());
    handler.post(new Runnable() {
        Value currentPosition;
        @Override
        public void run() {
            while(true) {
                Log.e("start", "new thread");
                CommunicationThread communicationThread = new CommunicationThread();
                try {
                    currentPosition = communicationThread.execute(connectionInfo).get();
                    Log.e("start", currentPosition.toString());

                    LatLng templt = null;
                    double lat = currentPosition.getLatitude();
                    double lon = currentPosition.getLongtitude();
                    LatLng lt = new LatLng(lat, lon);

                    templt = lt;

                    MarkerOptions a = new MarkerOptions().position(lt).title(currentPosition.getBus().getBusLineId());
                    Marker m = mMap.addMarker(a);
                    mMap.moveCamera(CameraUpdateFactory.newLatLng(lt));
                    mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(templt, 13.0f));
                } catch (ExecutionException e) {
                    e.printStackTrace();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    });
}
}
</code>```

CommunicationThread works properly and the data (positions) are send to the map activity. I use an infinite loop to execute CommunicationThread tasks and when new positions are avaiable, fetch them. I alse use a handler in order to avoid issues with infinite loop inside the main thread. When I run it, the data are sent succesfuly (according to the logs produced inside the loop), but the map appears as follows:

When I run it without the infinite loop (just for one position) it runs properly.
Any other ideas?

答:
1. Missing or incorrect or disabled API key

Seems to be most often. I recommend to follow official documentation. If you finish all steps, issue persists and you're still unsure whether it could be the reason, clone official android samples, find the MapWithMarker sample (android-samples/tutorials/MapWithMarker) and test against it. If you run the sample and it shows the map correctly, try to exchange default API KEY for the one you own.

In such case make sure, you enabled it in Google API Console.

2. Missing Android GMS version meta-data tag

Your AndroidManifest.xml needs to define following metadata attribute:

```<code><meta-data android:name="com.google.android.gms.version"
      android:value="@integer/google_play_services_version" />
</code>```

See the answer here for more details and official documentation.

3. Missing user permissions

In older versions of Android SDK, you had to explicitly set certain user permissions to work with Google Maps API correctly, for example:

```<code><uses-permission
        android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</code>```

This is not the case anymore but I would recommend to visit official documentation to make sure you meet those version requirements.

4. Requirement for OpenGL ES version 2

In the past, there seemed to be requirement to specify following metadata attribute within AndroidManifest.xml

```<code><uses-feature
   android:glEsVersion="0x00020000"
   android:required="true"/>
</code>```

Body:
I have an asyncTask CommunicationThread which creates some Latitudes and Longitudes. I also have a map activity where I want to take the results of CommunicationThread update the marker based on these results. Here is the code of my map Activity.

public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {

private GoogleMap mMap;
private Thread2ThreadInfo connectionInfo;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);

    connectionInfo = SubscriberActivity.getConnInfo();
}

@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    Handler handler = new Handler(Looper.getMainLooper());
    handler.post(new Runnable() {
        Value currentPosition;
        @Override
        public void run() {
            while(true) {
                Log.e("start", "new thread");
                CommunicationThread communicationThread = new CommunicationThread();
                try {
                    currentPosition = communicationThread.execute(connectionInfo).get();
                    Log.e("start", currentPosition.toString());

                    LatLng templt = null;
                    double lat = currentPosition.getLatitude();
                    double lon = currentPosition.getLongtitude();
                    LatLng lt = new LatLng(lat, lon);

                    templt = lt;

                    MarkerOptions a = new MarkerOptions().position(lt).title(currentPosition.getBus().getBusLineId());
                    Marker m = mMap.addMarker(a);
                    mMap.moveCamera(CameraUpdateFactory.newLatLng(lt));
                    mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(templt, 13.0f));
                } catch (ExecutionException e) {
                    e.printStackTrace();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    });
}
}

CommunicationThread works properly and the data (positions) are send to the map activity. I use an infinite loop to execute CommunicationThread tasks and when new positions are avaiable, fetch them. I alse use a handler in order to avoid issues with infinite loop inside the main thread. When I run it, the data are sent succesfuly (according to the logs produced inside the loop), but the map appears as follows:

When I run it without the infinite loop (just for one position) it runs properly.
Any other ideas?

Body:
1. Missing or incorrect or disabled API key

Seems to be most often. I recommend to follow official documentation. If you finish all steps, issue persists and you're still unsure whether it could be the reason, clone official android samples, find the MapWithMarker sample (android-samples/tutorials/MapWithMarker) and test against it. If you run the sample and it shows the map correctly, try to exchange default API KEY for the one you own.

In such case make sure, you enabled it in Google API Console.

2. Missing Android GMS version meta-data tag

Your AndroidManifest.xml needs to define following metadata attribute:

<meta-data android:name="com.google.android.gms.version"
      android:value="@integer/google_play_services_version" />

See the answer here for more details and official documentation.

3. Missing user permissions

In older versions of Android SDK, you had to explicitly set certain user permissions to work with Google Maps API correctly, for example:

<uses-permission
        android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

This is not the case anymore but I would recommend to visit official documentation to make sure you meet those version requirements.

4. Requirement for OpenGL ES version 2

In the past, there seemed to be requirement to specify following metadata attribute within AndroidManifest.xml

<uses-feature
   android:glEsVersion="0x00020000"
   android:required="true"/>


问:
How to print my input in options 1 and 2 to option 3? Here is my code
I would like to have the inputs of options 1 and 2 be printed in option 3. I have a menu setup and the user chooses which number they want and then there are follow up questions after which team they choose.</p>

```<code>    if (choys == 1)
    {
        ch = new Scanner(System.in);
        System.out.println("Enter name: ");
        userBName = ch.nextLine();

        System.out.println("Enter age: ");
        userBAge = ch.nextInt();

        if(userBAge >=18 && userBAge <=21)
        {
            System.out.println("Congrats "+userBName+"! Welcome to the team.");
            bslot++;
        }
        else
        {
            System.out.println("Sorry "+userBName+". You are not qualified.");
        }

    }

    if (choys == 2)
    {
        System.out.println("Enter name: ");
        userVName = ch.nextLine();

        System.out.println("Enter age: ");
        userVAge = ch.nextInt();

        if(userVAge >=18 && userVAge <=21)
        {
            System.out.println("Congrats "+userVName+"! Welcome to the team.");
            vslot++;
        }
        else
        {
            System.out.println("Sorry "+userVName+". You are not qualified.");
        }
    }

    if (choys == 3)
    {
        System.out.println("Current number of recruits:\n");
        System.out.println("Basketball team: "+ userBName+"\n\n");
        System.out.println("Volleyball team: "+ userVName);
    }
    }
</code>```

答:
We can use 2 different ArrayList to store the usernames in Option 1 and 2.
Then print the same ArrayList in Option 3.</p>

```<code>List<String> vNames = new ArrayList();
List<String> bNames = new ArrayList();

if (choys == 1)
{
    ch = new Scanner(System.in);
    System.out.println("Enter name: ");
    userBName = ch.nextLine();

    System.out.println("Enter age: ");
    userBAge = ch.nextInt();

    if(userBAge >=18 && userBAge <=21)
    {
        System.out.println("Congrats "+userBName+"! Welcome to the team.");
        bslot++;
        bNames.add(userBName);
    }
 }

if (choys == 2)
{
    ch = new Scanner(System.in);
    System.out.println("Enter name: ");
    userVName = ch.nextLine();

    System.out.println("Enter age: ");
    userVAge = ch.nextInt();

    if(userVAge >=18 && userVAge <=21)
    {
        System.out.println("Congrats "+userVName+"! Welcome to the team.");
        vSlot++;
        vNames.add(userVName);
    }
 }
 if (choys == 3)
{
    System.out.println("Current number of recruits:\n");
    System.out.println("Basketball team: ");
    for(String name:bNames){
        System.out.println("Username : "+ name);
    }

}
</code>```

Body:
I would like to have the inputs of options 1 and 2 be printed in option 3. I have a menu setup and the user chooses which number they want and then there are follow up questions after which team they choose.

    if (choys == 1)
    {
        ch = new Scanner(System.in);
        System.out.println("Enter name: ");
        userBName = ch.nextLine();

        System.out.println("Enter age: ");
        userBAge = ch.nextInt();

        if(userBAge >=18 && userBAge <=21)
        {
            System.out.println("Congrats "+userBName+"! Welcome to the team.");
            bslot++;
        }
        else
        {
            System.out.println("Sorry "+userBName+". You are not qualified.");
        }

    }

    if (choys == 2)
    {
        System.out.println("Enter name: ");
        userVName = ch.nextLine();

        System.out.println("Enter age: ");
        userVAge = ch.nextInt();

        if(userVAge >=18 && userVAge <=21)
        {
            System.out.println("Congrats "+userVName+"! Welcome to the team.");
            vslot++;
        }
        else
        {
            System.out.println("Sorry "+userVName+". You are not qualified.");
        }
    }

    if (choys == 3)
    {
        System.out.println("Current number of recruits:\n");
        System.out.println("Basketball team: "+ userBName+"\n\n");
        System.out.println("Volleyball team: "+ userVName);
    }
    }

Body:
We can use 2 different ArrayList to store the usernames in Option 1 and 2.
Then print the same ArrayList in Option 3.

List<String> vNames = new ArrayList();
List<String> bNames = new ArrayList();

if (choys == 1)
{
    ch = new Scanner(System.in);
    System.out.println("Enter name: ");
    userBName = ch.nextLine();

    System.out.println("Enter age: ");
    userBAge = ch.nextInt();

    if(userBAge >=18 && userBAge <=21)
    {
        System.out.println("Congrats "+userBName+"! Welcome to the team.");
        bslot++;
        bNames.add(userBName);
    }
 }

if (choys == 2)
{
    ch = new Scanner(System.in);
    System.out.println("Enter name: ");
    userVName = ch.nextLine();

    System.out.println("Enter age: ");
    userVAge = ch.nextInt();

    if(userVAge >=18 && userVAge <=21)
    {
        System.out.println("Congrats "+userVName+"! Welcome to the team.");
        vSlot++;
        vNames.add(userVName);
    }
 }
 if (choys == 3)
{
    System.out.println("Current number of recruits:\n");
    System.out.println("Basketball team: ");
    for(String name:bNames){
        System.out.println("Username : "+ name);
    }

}