问:
Button set to visibility Gone is still clickable
In my activity I have a switch, which when checked creates an animation and a button appears on the screen. When the switch disabled the button disappears also with an animation. When the button disappears I set the visibility to gone and when it appears I set the visibility to visible.
The initial state of the button is gone and when I try to click the location it supposed to be nothing happens. When the buttons appears it becomes clickable. If I make it disappear again, it's still clickable. Why is that? I thought that setting visibility to gone prevents the button from being triggered. I know I can set the button to setEnabled(false), but I'm curious why the button is still clickable when I set it visibility to gone.

Here's my onCreate():

```<code> @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        handler = new Handler();
        show = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.show);
        hide = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.hide);
        ((SwitchCompat)findViewById(R.id.animation_switch)).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if(isChecked){
                    handler.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            ((AppCompatButton)findViewById(R.id.animated_button)).startAnimation(show);
                            ((AppCompatButton)findViewById(R.id.animated_button)).setVisibility(View.VISIBLE);
                        }
                    }, 3000);

                }else{
                    handler.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            ((AppCompatButton)findViewById(R.id.animated_button)).startAnimation(hide);
                            ((AppCompatButton)findViewById(R.id.animated_button)).setVisibility(View.GONE);
                        }
                    },3000);
                }
            }
        });

        ((AppCompatButton)findViewById(R.id.animated_button)).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(MainActivity.this, "Button Clicked", Toast.LENGTH_LONG).show();
            }
        });
</code>```

Here is the Layout:

```<code><?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="36dp"
        android:layout_marginTop="32dp"
        android:text="Animataion"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView" />

    <android.support.v7.widget.SwitchCompat
        android:id="@+id/animation_switch"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="32dp"
        android:layout_marginTop="24dp"
        android:checked="false"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/notification_switch" />

    <android.support.v7.widget.AppCompatButton
        android:id="@+id/animated_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="176dp"
        android:text="click me"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:visibility="gone"/>
</android.support.constraint.ConstraintLayout>
</code>```

Here's the show animation:

```<code><?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:fillAfter="true">
    <scale
    android:duration="450"
    android:fromXScale="0.0"
    android:fromYScale="0.0"
    android:toXScale="1.0"
    android:toYScale="1.0"
    android:pivotX="50%"
    android:pivotY="50%"
    />
</set>
</code>```

Here's the hide animation:

```<code><?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:fillAfter="true">
    <scale
    android:duration="300"
    android:fromXScale="1.0"
    android:fromYScale="1.0"
    android:toXScale="0.0"
    android:toYScale="0.0"
    android:pivotX="50%"
    android:pivotY="50%"
    />
</set>
</code>```

答:
If you set setVisibility(View.GONE) after the animation, then try clearing the animation on your views with clearAnimation() at the end of the animation

```<code>mview.clearAnimation()
</code>```

OR

this can also work while initializing your animation because there are some bugs with animations.

```<code>show = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.show);
hide = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.hide);
show.setFillAfter(false);
hide.setFillAfter(false);
</code>```

Body:
In my activity I have a switch, which when checked creates an animation and a button appears on the screen. When the switch disabled the button disappears also with an animation. When the button disappears I set the visibility to gone and when it appears I set the visibility to visible.
The initial state of the button is gone and when I try to click the location it supposed to be nothing happens. When the buttons appears it becomes clickable. If I make it disappear again, it's still clickable. Why is that? I thought that setting visibility to gone prevents the button from being triggered. I know I can set the button to setEnabled(false), but I'm curious why the button is still clickable when I set it visibility to gone.

Here's my onCreate():

 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        handler = new Handler();
        show = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.show);
        hide = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.hide);
        ((SwitchCompat)findViewById(R.id.animation_switch)).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if(isChecked){
                    handler.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            ((AppCompatButton)findViewById(R.id.animated_button)).startAnimation(show);
                            ((AppCompatButton)findViewById(R.id.animated_button)).setVisibility(View.VISIBLE);
                        }
                    }, 3000);

                }else{
                    handler.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            ((AppCompatButton)findViewById(R.id.animated_button)).startAnimation(hide);
                            ((AppCompatButton)findViewById(R.id.animated_button)).setVisibility(View.GONE);
                        }
                    },3000);
                }
            }
        });

        ((AppCompatButton)findViewById(R.id.animated_button)).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(MainActivity.this, "Button Clicked", Toast.LENGTH_LONG).show();
            }
        });

Here is the Layout:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="36dp"
        android:layout_marginTop="32dp"
        android:text="Animataion"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView" />

    <android.support.v7.widget.SwitchCompat
        android:id="@+id/animation_switch"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="32dp"
        android:layout_marginTop="24dp"
        android:checked="false"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/notification_switch" />

    <android.support.v7.widget.AppCompatButton
        android:id="@+id/animated_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="176dp"
        android:text="click me"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:visibility="gone"/>
</android.support.constraint.ConstraintLayout>

Here's the show animation:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:fillAfter="true">
    <scale
    android:duration="450"
    android:fromXScale="0.0"
    android:fromYScale="0.0"
    android:toXScale="1.0"
    android:toYScale="1.0"
    android:pivotX="50%"
    android:pivotY="50%"
    />
</set>

Here's the hide animation:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:fillAfter="true">
    <scale
    android:duration="300"
    android:fromXScale="1.0"
    android:fromYScale="1.0"
    android:toXScale="0.0"
    android:toYScale="0.0"
    android:pivotX="50%"
    android:pivotY="50%"
    />
</set>

Body:
If you set setVisibility(View.GONE) after the animation, then try clearing the animation on your views with clearAnimation() at the end of the animation

mview.clearAnimation()

OR

this can also work while initializing your animation because there are some bugs with animations.

show = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.show);
hide = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.hide);
show.setFillAfter(false);
hide.setFillAfter(false);


来源: stackexchange

问:
How can i change the options of my drawerNavigator in React Native before and after loged in
Before Login i have these options.

Home,
Free Services,
Signals,
Contact Us,
Login,
Signup

i want to  add more and also change some options after login

Home,
Free Services,
Paid Services,
Free Signals,
Paid Signals,
Contact us,
Logout

Please Resolve my issue how can i do this.

答:
When your react native app has authentication you should use SwitchNavigator.

Read this page from the react navigation documentation: https://reactnavigation.org/docs/en/auth-flow.html

Before login you use the 'Auth' stack and after login you use the 'App' stack. Each stack has its own navigator. The AuthLoadingScreen checks if the user is logged in and uses the appropriate stack.

ContentLicense: CC BY-SA 4.0


问:
Can't run Angular site because my angular.json file paths mismatch with what ng build creates
New to Angular and after running ng build I see all the files it created in the folder I defined.

In my Angular.json file I'm building to

"outputPath": "../DatingApp.API/wwwroot"

but the rest of the Angular.json file doesn't seem to match with the built files.

Meaning, all the files that were built in wwwroot don't seem to have the same folder structure that my Angular.json file needs/expects based on the paths in the file.

Here is what gets built, you can see it's a single folder with all files in it. And my angular.json file is looking for files in subfolders, ex. "src/..."

Why is there a mismatch and what's the propper way to fix this? Should I modify all the paths in the Angular.json file to point to the correct build files? Or is there some other mismatch from versions or something that can be corrected by updating a npm package for example.

Angular.json file

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "DataingApp-SPA": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "app",
      "schematics": {},
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "../DatingApp.API/wwwroot",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.app.json",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.css"
            ],
            "scripts": [
              "node_modules/alertifyjs/build/alertify.min.js"
            ],
            "es5BrowserSupport": true

          },
          "configurations": {
            "production": {
              "fileReplacements": [{
                "replace": "src/environments/environment.ts",
                "with": "src/environments/environment.prod.ts"
              }],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "budgets": [{
                "type": "initial",
                "maximumWarning": "2mb",
                "maximumError": "5mb"
              }]
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "DataingApp-SPA:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "DataingApp-SPA:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "DataingApp-SPA:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.spec.json",
            "karmaConfig": "src/karma.conf.js",
            "styles": [
              "src/styles.css"
            ],
            "scripts": [],
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ]
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "src/tsconfig.app.json",
              "src/tsconfig.spec.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    },
    "DataingApp-SPA-e2e": {
      "root": "e2e/",
      "projectType": "application",
      "prefix": "",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "e2e/protractor.conf.js",
            "devServerTarget": "DataingApp-SPA:serve"
          },
          "configurations": {
            "production": {
              "devServerTarget": "DataingApp-SPA:serve:production"
            }
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": "e2e/tsconfig.e2e.json",
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    }
  },
  "defaultProject": "DataingApp-SPA"
}```

答:
Your issue must be related to how you're hosting the files on your webserver seeing as the build doesn't fail.

The directory structure of your application is irrelevant to the final build, which will store everything in a single folder*.

During compilation Webpack changes any file references to support this.

Try building your application with ng build and serve it with something like http-server (which you can install globally with npm install http-server -g).

Then you can just type http-server DatingApp.API/wwwroot and it should start a webserver on localhost:8080.

*Any exceptions can be defined in your angular.json file under assets which lists folders and files that is added to the final build folder. By default it looks like

```<code>"assets": ["src/assets", "src/favicon.ico",],
</code>```

Body:
Your issue must be related to how you're hosting the files on your webserver seeing as the build doesn't fail.

The directory structure of your application is irrelevant to the final build, which will store everything in a single folder*.

During compilation Webpack changes any file references to support this.

Try building your application with ng build and serve it with something like http-server (which you can install globally with npm install http-server -g).

Then you can just type http-server DatingApp.API/wwwroot and it should start a webserver on localhost:8080.

*Any exceptions can be defined in your angular.json file under assets which lists folders and files that is added to the final build folder. By default it looks like

"assets": ["src/assets", "src/favicon.ico",],


问:
Sort from low to high the two dimensional int arrays according to the sum of arr[i]
I've got to a dead end in the homework working on sorting a integers two-dimensional array.

The instructions are to create a function that takes a two-dimensional int array
(not necessarily a matrix) and sort the Outer array according to the sum of the inner arrays. in other words, in the first index of the array should be the inner array with the lowest sum.

Example -
input - int[][] array = {{2, 4, 1,9,9,9,9}, {6, 8}, {7, 3, 6, 5, 1}};

output - array = {{6, 8}, {7, 3, 6, 5, 1}, {2, 4, 1,9,9,9,9}};

My logic so far is creating a new one dimensional array that will include the sum
of each of the inner arrays from the main array.
and work with the sorting according to it.

```<code>public static int[] arraysCalculator(int[][] arr) {
int[] sums = new int[arr.length];
int sum= 0;
for(int i = 0; i  < arr.length; i++)
{
    for(int j = 0; j < arr[i].length; j++)
    {
        sum += arr[i][j];
    }
    sums[i] = sum;
    sum = 0;
}
</code>```

答:
In addition to the other answers who did a great job explaining the theory and laying the ground work for solving your assignment, here is a full working example (with detailed documentation on what each thing does and why) that will hopefully be of some assistance:

```<code>/**
 * This method will sort the inner arrays of a given two dimensional array
 * from lowest to highest value according to the sum of it's elements.
 */
private static int[][] arrayCalc(int[][] arr)
{
    /*
     * We're working with a TreeMap here because this type
     * of map is allowed to have duplicate key entries
     */
    java.util.Map<Integer, Integer[]> map = new java.util.TreeMap<>();
    /*
     * This value represents the largest inner array
     * size found in 2d array passed as parameter
     */
    int largestSize = 0;
    for (int[] inner : arr) {
        /*
         * Convert the inner array to an array of Integer
         * objects so it can be placed inside a map
         */
        Integer[] integers = IntStream.of(inner).boxed().toArray(Integer[]::new);
        map.put(IntStream.of(inner).sum(), integers);
        /*
         * Check if this inner array has a larger value
         * then the largest array we processed so far
         */
        if (inner.length > largestSize) {
            largestSize = inner.length;
        }
    }

    int[][] result = new int[map.size()][largestSize];
    /*
     * Iterate over the map and copy it's values which are represented
     * as Integer arrays into inner arrays of our return value
     */
    java.util.Iterator<java.util.Map.Entry<Integer, Integer[]>> iter = map.entrySet().iterator();
    for (int i = 0; i < result.length && iter.hasNext(); i++)
    {
        java.util.Map.Entry<Integer, Integer[]> entry = iter.next();
        /*
         * We can just return our value as an array of Integer objects
         * but for the sake of this exercise we will convert it to a
         * primitive 2D int array so it's consistent with our method parameter
         */
        Integer[] integers = entry.getValue();
        result[i] = java.util.Arrays.stream(integers).mapToInt(Integer::intValue).toArray();
    }
    return result;
}

public static void main(String[] args)
{
    int[][] array = {{2, 4, 1,9,9,9,9}, {6, 8}, {7, 3, 6, 5, 1}};
    int[][] result = arrayCalc(array);

    for (int[] iResult : result) {
        System.out.println(Arrays.toString(iResult));
    }
}
</code>```

Output

```<code>[6, 8]
[7, 3, 6, 5, 1]
[2, 4, 1, 9, 9, 9, 9]
</code>```

Body:
I've got to a dead end in the homework working on sorting a integers two-dimensional array.

The instructions are to create a function that takes a two-dimensional int array
(not necessarily a matrix) and sort the Outer array according to the sum of the inner arrays. in other words, in the first index of the array should be the inner array with the lowest sum.

Example -
input - int[][] array = {{2, 4, 1,9,9,9,9}, {6, 8}, {7, 3, 6, 5, 1}};

output - array = {{6, 8}, {7, 3, 6, 5, 1}, {2, 4, 1,9,9,9,9}};

My logic so far is creating a new one dimensional array that will include the sum
of each of the inner arrays from the main array.
and work with the sorting according to it.

public static int[] arraysCalculator(int[][] arr) {
int[] sums = new int[arr.length];
int sum= 0;
for(int i = 0; i  < arr.length; i++)
{
    for(int j = 0; j < arr[i].length; j++)
    {
        sum += arr[i][j];
    }
    sums[i] = sum;
    sum = 0;
}

Body:
In addition to the other answers who did a great job explaining the theory and laying the ground work for solving your assignment, here is a full working example (with detailed documentation on what each thing does and why) that will hopefully be of some assistance:

/**
 * This method will sort the inner arrays of a given two dimensional array
 * from lowest to highest value according to the sum of it's elements.
 */
private static int[][] arrayCalc(int[][] arr)
{
    /*
     * We're working with a TreeMap here because this type
     * of map is allowed to have duplicate key entries
     */
    java.util.Map<Integer, Integer[]> map = new java.util.TreeMap<>();
    /*
     * This value represents the largest inner array
     * size found in 2d array passed as parameter
     */
    int largestSize = 0;
    for (int[] inner : arr) {
        /*
         * Convert the inner array to an array of Integer
         * objects so it can be placed inside a map
         */
        Integer[] integers = IntStream.of(inner).boxed().toArray(Integer[]::new);
        map.put(IntStream.of(inner).sum(), integers);
        /*
         * Check if this inner array has a larger value
         * then the largest array we processed so far
         */
        if (inner.length > largestSize) {
            largestSize = inner.length;
        }
    }

    int[][] result = new int[map.size()][largestSize];
    /*
     * Iterate over the map and copy it's values which are represented
     * as Integer arrays into inner arrays of our return value
     */
    java.util.Iterator<java.util.Map.Entry<Integer, Integer[]>> iter = map.entrySet().iterator();
    for (int i = 0; i < result.length && iter.hasNext(); i++)
    {
        java.util.Map.Entry<Integer, Integer[]> entry = iter.next();
        /*
         * We can just return our value as an array of Integer objects
         * but for the sake of this exercise we will convert it to a
         * primitive 2D int array so it's consistent with our method parameter
         */
        Integer[] integers = entry.getValue();
        result[i] = java.util.Arrays.stream(integers).mapToInt(Integer::intValue).toArray();
    }
    return result;
}

public static void main(String[] args)
{
    int[][] array = {{2, 4, 1,9,9,9,9}, {6, 8}, {7, 3, 6, 5, 1}};
    int[][] result = arrayCalc(array);

    for (int[] iResult : result) {
        System.out.println(Arrays.toString(iResult));
    }
}

Output

[6, 8]
[7, 3, 6, 5, 1]
[2, 4, 1, 9, 9, 9, 9]


答:
Those paths refer to files during development. When you build the code the compiler does a lot of magic. Your output in your dist directory is supposed to look like the one you showed in your picture.

Don't worry about the mismatch, this is how it supposed to be. Don't try to open the file locally since it requires a webserver to work correctly. Just use ng serve  --prod if you want to run your application in production mode.

Title: Can't run Angular site because my angular.json file paths mismatch with what ng build creates

Body:
New to Angular and after running ng build I see all the files it created in the folder I defined.

In my Angular.json file I'm building to

"outputPath": "../DatingApp.API/wwwroot"

but the rest of the Angular.json file doesn't seem to match with the built files.

Meaning, all the files that were built in wwwroot don't seem to have the same folder structure that my Angular.json file needs/expects based on the paths in the file.

Here is what gets built, you can see it's a single folder with all files in it. And my angular.json file is looking for files in subfolders, ex. "src/..."

Why is there a mismatch and what's the propper way to fix this? Should I modify all the paths in the Angular.json file to point to the correct build files? Or is there some other mismatch from versions or something that can be corrected by updating a npm package for example.

Angular.json file

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "DataingApp-SPA": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "app",
      "schematics": {},
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "../DatingApp.API/wwwroot",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.app.json",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.css"
            ],
            "scripts": [
              "node_modules/alertifyjs/build/alertify.min.js"
            ],
            "es5BrowserSupport": true

          },
          "configurations": {
            "production": {
              "fileReplacements": [{
                "replace": "src/environments/environment.ts",
                "with": "src/environments/environment.prod.ts"
              }],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "budgets": [{
                "type": "initial",
                "maximumWarning": "2mb",
                "maximumError": "5mb"
              }]
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "DataingApp-SPA:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "DataingApp-SPA:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "DataingApp-SPA:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.spec.json",
            "karmaConfig": "src/karma.conf.js",
            "styles": [
              "src/styles.css"
            ],
            "scripts": [],
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ]
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "src/tsconfig.app.json",
              "src/tsconfig.spec.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    },
    "DataingApp-SPA-e2e": {
      "root": "e2e/",
      "projectType": "application",
      "prefix": "",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "e2e/protractor.conf.js",
            "devServerTarget": "DataingApp-SPA:serve"
          },
          "configurations": {
            "production": {
              "devServerTarget": "DataingApp-SPA:serve:production"
            }
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": "e2e/tsconfig.e2e.json",
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    }
  },
  "defaultProject": "DataingApp-SPA"
}


问:
Processing large arrays in PowerShell
I am having a difficult time understanding the most efficient to process large datasets/arrays in PowerShell. I have arrays that have several million items that I need to process and group. This list is always different in size meaning it could be 3.5 million items or 10 million items.

Example: 3.5 million items they group by "4's" like the following:

Items 0,1,2,3 Group together 4,5,6,7 Group Together and so on.

I have tried processing the array using a single thread by looping through the list and assigning to a pscustomobject which works it just takes 45-50+ minutes to complete.

I have also attempted to break up the array into smaller arrays but that causes the process to run even longer.

$i=0
$d_array = @()
$item_array # Large dataset

While ($i -lt $item_array.length){

    $o = "Test"
    $oo = "Test"
    $n = $item_array[$i];$i++
    $id = $item_array[$i];$i++
    $ir = $item_array[$i];$i++
    $cs = $item_array[$i];$i++

    $items = [PSCustomObject]@{
        'field1' = $o
        'field2' = $oo
        'field3' = $n
        'field4' = $id
        'field5' = $ir
        'field6'= $cs
    }
    $d_array += $items

}
```

I would imagine if I applied a job scheduler that would allow me to run the multiple jobs would cut the process time down by a significant amount, but I wanted to get others takes on a quick effective way to tackle this.

答:
While rokumarus version is unsurpassed, here my try with my local measurements from js2010

Same $item_array = 1..100000 applied to all versions

```<code>> .\SO_56406847.ps1
measuring...BDups
measuring...LotPings
measuring...Theo
measuring...js2010
measuring...rokumaru
BDups    = 75,9949897 TotalSeconds
LotPings = 2,3663763 TotalSeconds
Theo     = 2,4469917 TotalSeconds
js2010   = 2,9198114 TotalSeconds
rokumaru = 0,0109287 TotalSeconds
</code>```

```<code>## Q:\Test\2019\06\01\SO_56406847.ps1
$i=0
$item_array = 1..100000  # Large dataset

'measuring...LotPings'
$LotPings = measure-command {
    $d_array = for($i=0;$i -lt $item_array.length;$i+=4){
        [PSCustomObject]@{
            'field1' = "Test"
            'field2' = "Test"
            'field3' = $item_array[$i]
            'field4' = $item_array[$i+1]
            'field5' = $item_array[$i+2]
            'field6' = $item_array[$i+3]
        }
    }
} # measure-command
</code>```

Title: Processing large arrays in PowerShell

Body:
I am having a difficult time understanding the most efficient to process large datasets/arrays in PowerShell. I have arrays that have several million items that I need to process and group. This list is always different in size meaning it could be 3.5 million items or 10 million items.

Example: 3.5 million items they group by "4's" like the following:

Items 0,1,2,3 Group together 4,5,6,7 Group Together and so on.

I have tried processing the array using a single thread by looping through the list and assigning to a pscustomobject which works it just takes 45-50+ minutes to complete.

I have also attempted to break up the array into smaller arrays but that causes the process to run even longer.

$i=0
$d_array = @()
$item_array # Large dataset

While ($i -lt $item_array.length){

    $o = "Test"
    $oo = "Test"
    $n = $item_array[$i];$i++
    $id = $item_array[$i];$i++
    $ir = $item_array[$i];$i++
    $cs = $item_array[$i];$i++

    $items = [PSCustomObject]@{
        'field1' = $o
        'field2' = $oo
        'field3' = $n
        'field4' = $id
        'field5' = $ir
        'field6'= $cs
    }
    $d_array += $items

}

I would imagine if I applied a job scheduler that would allow me to run the multiple jobs would cut the process time down by a significant amount, but I wanted to get others takes on a quick effective way to tackle this.

Body:
While rokumarus version is unsurpassed, here my try with my local measurements from js2010

Same $item_array = 1..100000 applied to all versions

> .\SO_56406847.ps1
measuring...BDups
measuring...LotPings
measuring...Theo
measuring...js2010
measuring...rokumaru
BDups    = 75,9949897 TotalSeconds
LotPings = 2,3663763 TotalSeconds
Theo     = 2,4469917 TotalSeconds
js2010   = 2,9198114 TotalSeconds
rokumaru = 0,0109287 TotalSeconds

## Q:\Test\2019\06\01\SO_56406847.ps1
$i=0
$item_array = 1..100000  # Large dataset

'measuring...LotPings'
$LotPings = measure-command {
    $d_array = for($i=0;$i -lt $item_array.length;$i+=4){
        [PSCustomObject]@{
            'field1' = "Test"
            'field2' = "Test"
            'field3' = $item_array[$i]
            'field4' = $item_array[$i+1]
            'field5' = $item_array[$i+2]
            'field6' = $item_array[$i+3]
        }
    }
} # measure-command


问:
Trouble trusting local HTTPs certificate in ASP.NET Core
I am following an online tutorial to create an ASP.NET Core Web application. I followed everything but had trouble with trusting the local HTTPS certificate.

When I first run the application, I got an error saying:
"the access control list (acl) structure is invalid"

I tried googling this error but couldn't find anything related to my ASP.NET application, after cleaning the solution I didn't get this error any longer.

But I was unable to run my application in browser using HTTPS as it always says:
"This site is not secure"

I tried to trust certificate using CMD using this command:

dotnet dev-certs https --trust

It should show me a prompt to trust the certificate but it says "there was an error trusting the HTTPS developer certificate" and the application runs in an unsafe mode on the browser.

Can someone please help me run my application with HTTPS on my local environment? Any help will be greatly appreciated. Thanks

答:
This seems to be a bug in ASP.NET Core 2.1:

what you need to do is go move your added certificates from your certificate manager.

go to start menu > Type "Win + R" type "certlm.msc", this will open your certificate manager.

go to Personal/Certificates

you will find a certificate named "localhost there.

Move that to "Trusted Root Certification Authorities/Certificates"

run the project again, and it should work.

Hope this helps.


问:
"Did you mean to run dotnet SDK commands? Please install dotnetsdk" in windows command prompt
I have just installed dot net core sdk and runtime (2.2.1) on my system viz. a Windows Server 2012R2.
I am trying to create a console app using the command prompt using

```<code>dotnet new console
</code>```

but it says

Did you mean to run dotnet SDK commands? Please install dotnetsdk

Is there any other configurations needed. The Environment path variable also contains the following folder C:\Program Files\dotnet.
I have not installed VS2017. Was trying to use VS Code

答:
In my case somehow I also had a C:\Program Files (x86)\dotnet with a runtime version there which was picked from Path instead of the SDK in C:\Program Files\dotnet

This was causing exactly the same error message + it was breaking solutions in Visual Studio (but not in Rider)

Body:
I have just installed dot net core sdk and runtime (2.2.1) on my system viz. a Windows Server 2012R2.
I am trying to create a console app using the command prompt using

dotnet new console

but it says

Did you mean to run dotnet SDK commands? Please install dotnetsdk

Is there any other configurations needed. The Environment path variable also contains the following folder C:\Program Files\dotnet.
I have not installed VS2017. Was trying to use VS Code


问:
Keyframes - gradient background is not animated
I am trying to animate background exchange using @keyframes. Background is radial gradient. Backgroud changes but it isn't animated.

#mydiv {
background: radial-gradient(circle at 90% 80%, #ff0000, #4d0019);
width: 100%;
height: 1246px;
position: relative;
overflow: hidden;
animation: background-gradient 5s;
animation-iteration-count: infinite;
backface-visibility: hidden;
animation-timing-function: ease-in-out;
}

@-webkit-keyframes background-gradient {
0% {background: radial-gradient(circle at 90% 80%, #ff0000, #4d0019);}
25% {background: radial-gradient(circle at 90% 80%, #993399, #4d0019);}
50% {background: radial-gradient(circle at 90% 80%, #3333cc, #4d0019);}
75% {background: radial-gradient(circle at 90% 80%, #00ffcc, #4d0019);}
100% {background: radial-gradient(circle at 90% 80%, #cc9900, #4d0019);}
}

@keyframes background-gradient {
0% {background: radial-gradient(circle at 90% 80%, #ff0000, #4d0019);}
25% {background: radial-gradient(circle at 90% 80%, #993399, #4d0019);}
50% {background: radial-gradient(circle at 90% 80%, #3333cc, #4d0019);}
75% {background: radial-gradient(circle at 90% 80%, #00ffcc, #4d0019);}
100% {background: radial-gradient(circle at 90% 80%, #cc9900, #4d0019);}
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="mydiv"></div></code>```

I tried with just solid colors and it works fine (e.g. background: red, background: yellow...).

I tried background-image instead of just background on my gradients, it doesn't help.

Do you have any advice or know solution how to animate exhange, so it is not just rapid exhange of colors but gradual exchange from one to another.

答:
Unfortunately, background gradients are not animatable

Luckily for you, your current desing doesn't need to animate the gradient, since the external color is constant.

Just make the gradient transparent, and set a solid changing color underneath

#mydiv {
  width: 100%;
  height: 600px;
  position: relative;
  overflow: hidden;
  animation: background-gradient 5s;
  animation-iteration-count: infinite;
  backface-visibility: hidden;
  animation-timing-function: ease-in-out;
  background-image: radial-gradient(circle at 90% 80%, transparent, #4d0019);
}

@keyframes background-gradient {
  0% {
    background-color: #ff0000;
  }
  25% {
    background-color: yellow;
  }
  50% {
    background-color: #3333cc;
  }
  75% {
    background-color: #00ffcc;
  }
  100% {
    background-color: #cc9900;
  }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="mydiv"></div></code>```

Body:
I am trying to animate background exchange using @keyframes. Background is radial gradient. Backgroud changes but it isn't animated.

#mydiv {
background: radial-gradient(circle at 90% 80%, #ff0000, #4d0019);
width: 100%;
height: 1246px;
position: relative;
overflow: hidden;
animation: background-gradient 5s;
animation-iteration-count: infinite;
backface-visibility: hidden;
animation-timing-function: ease-in-out;
}

@-webkit-keyframes background-gradient {
0% {background: radial-gradient(circle at 90% 80%, #ff0000, #4d0019);}
25% {background: radial-gradient(circle at 90% 80%, #993399, #4d0019);}
50% {background: radial-gradient(circle at 90% 80%, #3333cc, #4d0019);}
75% {background: radial-gradient(circle at 90% 80%, #00ffcc, #4d0019);}
100% {background: radial-gradient(circle at 90% 80%, #cc9900, #4d0019);}
}

@keyframes background-gradient {
0% {background: radial-gradient(circle at 90% 80%, #ff0000, #4d0019);}
25% {background: radial-gradient(circle at 90% 80%, #993399, #4d0019);}
50% {background: radial-gradient(circle at 90% 80%, #3333cc, #4d0019);}
75% {background: radial-gradient(circle at 90% 80%, #00ffcc, #4d0019);}
100% {background: radial-gradient(circle at 90% 80%, #cc9900, #4d0019);}
}

I tried with just solid colors and it works fine (e.g. background: red, background: yellow...).

I tried background-image instead of just background on my gradients, it doesn't help.

Do you have any advice or know solution how to animate exhange, so it is not just rapid exhange of colors but gradual exchange from one to another.

Body:
Unfortunately, background gradients are not animatable

Luckily for you, your current desing doesn't need to animate the gradient, since the external color is constant.

Just make the gradient transparent, and set a solid changing color underneath

#mydiv {
  width: 100%;
  height: 600px;
  position: relative;
  overflow: hidden;
  animation: background-gradient 5s;
  animation-iteration-count: infinite;
  backface-visibility: hidden;
  animation-timing-function: ease-in-out;
  background-image: radial-gradient(circle at 90% 80%, transparent, #4d0019);
}

@keyframes background-gradient {
  0% {
    background-color: #ff0000;
  }
  25% {
    background-color: yellow;
  }
  50% {
    background-color: #3333cc;
  }
  75% {
    background-color: #00ffcc;
  }
  100% {
    background-color: #cc9900;
  }
}

<div id="mydiv"></div>


问:
What does reset actually mean in Tensorflow 2 dataset?
I'm following tensorflow 2 Keras documentation. My model looks like this:

```<code>train_dataset = tf.data.Dataset.from_tensor_slices((np.array([_my_cus_func(i) for i in X_train]), y_train))
train_dataset = train_dataset.map(lambda vals,lab: _process_tensors(vals,lab), num_parallel_calls=4)
train_dataset = train_dataset.shuffle(buffer_size=10000)
train_dataset = train_dataset.batch(64,drop_remainder=True)
train_dataset = train_dataset.prefetch(1)
model=get_compiled_model()
model.fit(train_dataset, epochs=100)
</code>```

The documentation says

Note that the Dataset is reset at the end of each epoch, so it can be
  reused of the next epoch.

If you want to run training only on a specific number of batches from
  this Dataset, you can pass the steps_per_epoch argument, which
  specifies how many training steps the model should run using this
  Dataset before moving on to the next epoch.

If you do this, the dataset is not reset at the end of each epoch,
  instead we just keep drawing the next batches. The dataset will
  eventually run out of data (unless it is an infinitely-looping
  dataset).

What does the reset actually mean? Will tensorflow read data from tensor slices after every epoch? or it only reshuffles and runs map function? I want tensorflow to read data from numpy after epoch and run _my_cus_func. I can rather pass _my_cus_func on dataset map or apply api, but I'm more comfortable in doing this on python list or numpy array.

答:
In this context, reset means start iterating over dataset from scratch. In your particular case, code lacks repeat() function. So, if you specify steps_per_epoch parameter like this

```<code>model.fit(train_dataset, steps_per_epoch=N, epochs=100)
</code>```

It will iterate over the dataset for N steps, if N is less than actual number of examples, it will terminate training. If N is larger, it will finish one epoch, but still terminates when runs out of data . If you add repeat,

```<code>train_dataset = train_dataset.shuffle(buffer_size=10000).repeat()
</code>```

It will start new cycle over dataset when actual number of examples is reached, not when new epoch starts.

Body:
I'm following tensorflow 2 Keras documentation. My model looks like this:

train_dataset = tf.data.Dataset.from_tensor_slices((np.array([_my_cus_func(i) for i in X_train]), y_train))
train_dataset = train_dataset.map(lambda vals,lab: _process_tensors(vals,lab), num_parallel_calls=4)
train_dataset = train_dataset.shuffle(buffer_size=10000)
train_dataset = train_dataset.batch(64,drop_remainder=True)
train_dataset = train_dataset.prefetch(1)
model=get_compiled_model()
model.fit(train_dataset, epochs=100)

The documentation says

Note that the Dataset is reset at the end of each epoch, so it can be
  reused of the next epoch.

If you want to run training only on a specific number of batches from
  this Dataset, you can pass the steps_per_epoch argument, which
  specifies how many training steps the model should run using this
  Dataset before moving on to the next epoch.

If you do this, the dataset is not reset at the end of each epoch,
  instead we just keep drawing the next batches. The dataset will
  eventually run out of data (unless it is an infinitely-looping
  dataset).

What does the reset actually mean? Will tensorflow read data from tensor slices after every epoch? or it only reshuffles and runs map function? I want tensorflow to read data from numpy after epoch and run _my_cus_func. I can rather pass _my_cus_func on dataset map or apply api, but I'm more comfortable in doing this on python list or numpy array.

Body:
In this context, reset means start iterating over dataset from scratch. In your particular case, code lacks repeat() function. So, if you specify steps_per_epoch parameter like this

model.fit(train_dataset, steps_per_epoch=N, epochs=100)

It will iterate over the dataset for N steps, if N is less than actual number of examples, it will terminate training. If N is larger, it will finish one epoch, but still terminates when runs out of data . If you add repeat,

train_dataset = train_dataset.shuffle(buffer_size=10000).repeat()

It will start new cycle over dataset when actual number of examples is reached, not when new epoch starts.


问:
Build success, no errors but white screen
I have a react application generating with create-react-app that I would like to transform into a hybrid app thanks to cordova. I followed this tutorial for configuration. everything seems to be going well, the build is done as it should be and the app runs through the emulator but whether it's on android or iOS the only thing I see is a white screen

I initialized a new react app in that I configured to use with cordova, it works very well, I transposed this configuration to my existing app.
My app uses redux and react-router as a particular library.

I don't think it's a Policy issue.

builded index.html

<!doctype html>

  <meta charset="utf-8">
  <link rel="shortcut icon" href="./favicon.ico">
  <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no,shrink-to-fit=no">
  <meta name="HandheldFriendly" content="true" />
  <meta http-equiv="Content-Security-Policy"
    content="default-src *; style-src 'self' http://* 'unsafe-inline'; script-src 'self' http://* 'unsafe-inline' 'unsafe-eval'" />
  <meta name="format-detection" content="telephone=no">
  <meta name="msapplication-tap-highlight" content="no">
  <meta name="theme-color" content="#008000">
  <meta name="title" content="Lunchs du Bureau">
  <meta name="description" content="Partager votre repas avec vos collègues de bureau.">
  <meta name="keywords" content="lunch, repas, dejeuner">
  <meta property="og:url" content="https://staging.lunchsdubureau.com" />
  <meta property="og:image" content="lunch-seo.jpg" />
  <meta name="robots" content="index, nofollow">
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <meta name="language" content="French">
  <link rel="manifest" href="./manifest.json">

  <link rel="apple-touch-icon" sizes="180x180" href="apple-icon-180x180.png">
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" />
  <link href="https://fonts.googleapis.com/css?family=Yesteryear|Raleway:400,700|Material+Icons" rel="stylesheet" />
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
    integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  <link rel="stylesheet" charset="UTF-8"
    href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick.min.css" />
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick-theme.min.css" />

  <title>Lunchs du Bureau</title>
  <link href="./static/css/main.d76f0357.chunk.css" rel="stylesheet">

You need to enable JavaScript to run this app.

```

<p>config.xml</p>

<pre class="lang-xml prettyprint-override"><code><?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.hellocordova" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>HelloCordova</name>
    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>
    <author email="dev@cordova.apache.org" href="http://cordova.io">
        Apache Cordova Team
    </author>
    <content src="index.html" />
    <plugin name="cordova-plugin-whitelist" spec="1" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <platform name="android">
        <allow-intent href="market:*" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
</widget>
</code>```

答:
Add:

```<code>"homepage": "./"
</code>```

to your package.json.

Body:
I have a react application generating with create-react-app that I would like to transform into a hybrid app thanks to cordova. I followed this tutorial for configuration. everything seems to be going well, the build is done as it should be and the app runs through the emulator but whether it's on android or iOS the only thing I see is a white screen

I initialized a new react app in that I configured to use with cordova, it works very well, I transposed this configuration to my existing app.
My app uses redux and react-router as a particular library.

I don't think it's a Policy issue.

builded index.html

<!doctype html>

  <meta charset="utf-8">
  <link rel="shortcut icon" href="./favicon.ico">
  <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no,shrink-to-fit=no">
  <meta name="HandheldFriendly" content="true" />
  <meta http-equiv="Content-Security-Policy"
    content="default-src *; style-src 'self' http://* 'unsafe-inline'; script-src 'self' http://* 'unsafe-inline' 'unsafe-eval'" />
  <meta name="format-detection" content="telephone=no">
  <meta name="msapplication-tap-highlight" content="no">
  <meta name="theme-color" content="#008000">
  <meta name="title" content="Lunchs du Bureau">
  <meta name="description" content="Partager votre repas avec vos collègues de bureau.">
  <meta name="keywords" content="lunch, repas, dejeuner">
  <meta property="og:url" content="https://staging.lunchsdubureau.com" />
  <meta property="og:image" content="lunch-seo.jpg" />
  <meta name="robots" content="index, nofollow">
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <meta name="language" content="French">
  <link rel="manifest" href="./manifest.json">

  <link rel="apple-touch-icon" sizes="180x180" href="apple-icon-180x180.png">
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" />
  <link href="https://fonts.googleapis.com/css?family=Yesteryear|Raleway:400,700|Material+Icons" rel="stylesheet" />
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
    integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  <link rel="stylesheet" charset="UTF-8"
    href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick.min.css" />
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick-theme.min.css" />

  <title>Lunchs du Bureau</title>
  <link href="./static/css/main.d76f0357.chunk.css" rel="stylesheet">

You need to enable JavaScript to run this app.

config.xml

<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.hellocordova" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>HelloCordova</name>
    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>
    <author email="dev@cordova.apache.org" href="http://cordova.io">
        Apache Cordova Team
    </author>
    <content src="index.html" />
    <plugin name="cordova-plugin-whitelist" spec="1" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <platform name="android">
        <allow-intent href="market:*" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
</widget>

Body:
Add:

"homepage": "./"

to your package.json.


问:
vb.net Postgresql Database, using DataTable and display bitmap in Datagridview
I am using a Postgresql, and I would like to store a status value. These values should be of type integer (0 = OK, 1 = Not OK e.g.).
But I don't want to display these values as integer in my datagridview, I would like to display some small icons or bitmaps.

But how am I able to do this?
If I am using a DataColumn with Bitmap Type, I can't use the Integer type in my database.

This is how I fill my DataTable with the SQL data.
dtRecord is assigned to my DataGridview.

```<code>sda = New NpgsqlDataAdapter(pgCommand)
        sda.Fill(dtRecord)
</code>```

This was a test - but I can't insert the integer values from the SQL Database

```<code>Dim column1 As DataColumn = New DataColumn("Status")
    column1.DataType = GetType(Bitmap)
</code>```

Can someone give me any hints?

Thanks!

答:
This is a fully working sample of how to load an image from the disk based on a value in the grid and display that image. In addition to the code below, you will need to drop a DataGridView on to the form from the Designer

```<code>Public Class Form1
Public Sub New()

    ' This call is required by the designer.
    InitializeComponent()

    ' Add any initialization after the InitializeComponent() call.
    InitialiseGridView()

    InitialiseDataTable()

    DataGridView1.DataSource = RecordsDataTable
End Sub

Dim RecordsDataTable As DataTable

Private Sub InitialiseGridView()
    DataGridView1.AutoGenerateColumns = False
    AddHandler DataGridView1.CellFormatting, AddressOf DataGridView1_CellFormatting

    DataGridView1.Columns.Clear()
    Dim dgvImageColumn As New DataGridViewImageColumn()
    dgvImageColumn.Name = "dgvImageColumn"
    dgvImageColumn.DataPropertyName = "dgvImageColumn"
    dgvImageColumn.HeaderText = "Status"
    DataGridView1.Columns.Add(dgvImageColumn)

    Dim dgvTextColumn As New DataGridViewTextBoxColumn
    dgvTextColumn.Name = "dgvTextColumn"
    dgvTextColumn.DataPropertyName = "dgvTextColumn"
    dgvTextColumn.HeaderText = "Other Text"
    DataGridView1.Columns.Add(dgvTextColumn)
End Sub

Private Sub InitialiseDataTable()
    RecordsDataTable = New DataTable()

    RecordsDataTable.Columns.Add("dgvImageColumn", GetType(Integer))
    RecordsDataTable.Columns.Add("dgvTextColumn", GetType(String))

    RecordsDataTable.Rows.Add({1, "one"})
    RecordsDataTable.Rows.Add({0, "two"})
    RecordsDataTable.Rows.Add({1, "three"})
End Sub

Private Sub DataGridView1_CellFormatting(sender As Object, e As DataGridViewCellFormattingEventArgs)
    Dim thisDGV As DataGridView = DirectCast(sender, DataGridView)
    If (thisDGV.Columns(e.ColumnIndex).Name = "dgvImageColumn") Then
        Dim newImage As Image
        If (e.Value.ToString() = "0") Then
            newImage = Bitmap.FromFile("D:\Projects\Graphics\GreenDot.png")
        Else
            newImage = Bitmap.FromFile("D:\Projects\Graphics\RedDot.png")
        End If
        e.Value = newImage
        e.FormattingApplied = True
    End If
End Sub
End Class
</code>```

This will give you a DataGridView that looks like:

Body:
I am using a Postgresql, and I would like to store a status value. These values should be of type integer (0 = OK, 1 = Not OK e.g.).
But I don't want to display these values as integer in my datagridview, I would like to display some small icons or bitmaps.

But how am I able to do this?
If I am using a DataColumn with Bitmap Type, I can't use the Integer type in my database.

This is how I fill my DataTable with the SQL data.
dtRecord is assigned to my DataGridview.

sda = New NpgsqlDataAdapter(pgCommand)
        sda.Fill(dtRecord)

This was a test - but I can't insert the integer values from the SQL Database

Dim column1 As DataColumn = New DataColumn("Status")
    column1.DataType = GetType(Bitmap)

Can someone give me any hints?

Thanks!

Body:
This is a fully working sample of how to load an image from the disk based on a value in the grid and display that image. In addition to the code below, you will need to drop a DataGridView on to the form from the Designer

Public Class Form1
Public Sub New()

    ' This call is required by the designer.
    InitializeComponent()

    ' Add any initialization after the InitializeComponent() call.
    InitialiseGridView()

    InitialiseDataTable()

    DataGridView1.DataSource = RecordsDataTable
End Sub

Dim RecordsDataTable As DataTable

Private Sub InitialiseGridView()
    DataGridView1.AutoGenerateColumns = False
    AddHandler DataGridView1.CellFormatting, AddressOf DataGridView1_CellFormatting

    DataGridView1.Columns.Clear()
    Dim dgvImageColumn As New DataGridViewImageColumn()
    dgvImageColumn.Name = "dgvImageColumn"
    dgvImageColumn.DataPropertyName = "dgvImageColumn"
    dgvImageColumn.HeaderText = "Status"
    DataGridView1.Columns.Add(dgvImageColumn)

    Dim dgvTextColumn As New DataGridViewTextBoxColumn
    dgvTextColumn.Name = "dgvTextColumn"
    dgvTextColumn.DataPropertyName = "dgvTextColumn"
    dgvTextColumn.HeaderText = "Other Text"
    DataGridView1.Columns.Add(dgvTextColumn)
End Sub

Private Sub InitialiseDataTable()
    RecordsDataTable = New DataTable()

    RecordsDataTable.Columns.Add("dgvImageColumn", GetType(Integer))
    RecordsDataTable.Columns.Add("dgvTextColumn", GetType(String))

    RecordsDataTable.Rows.Add({1, "one"})
    RecordsDataTable.Rows.Add({0, "two"})
    RecordsDataTable.Rows.Add({1, "three"})
End Sub

Private Sub DataGridView1_CellFormatting(sender As Object, e As DataGridViewCellFormattingEventArgs)
    Dim thisDGV As DataGridView = DirectCast(sender, DataGridView)
    If (thisDGV.Columns(e.ColumnIndex).Name = "dgvImageColumn") Then
        Dim newImage As Image
        If (e.Value.ToString() = "0") Then
            newImage = Bitmap.FromFile("D:\Projects\Graphics\GreenDot.png")
        Else
            newImage = Bitmap.FromFile("D:\Projects\Graphics\RedDot.png")
        End If
        e.Value = newImage
        e.FormattingApplied = True
    End If
End Sub
End Class

This will give you a DataGridView that looks like:


问:
PHP mySQL - Can you return an associated array with a number index?
I have this method in my db class

```<code>public function query($queryString)
    {

      if (!$this->_connected) $this->_connectToDb(); //connect to database

      $results = mysql_query($queryString, $this->_dbLink) or trigger_error(mysql_error());

      return mysql_num_rows($results) > 0 ? mysql_fetch_assoc($results) : false;

    }
</code>```

This works great for queries that return 1 row, but how can I get an array returned something like this?

```<code>$array[0]['name'] = 'jim'
$array[0]['id'] =  120
$array[1]['name'] = 'judith'
$array[1]['ID'] = 121
</code>```

Now I know I could use a while loop to insert this data into the array like so, but I was wondering if PHP could do this with an internal function? I havn't been able to find on the docs what I'm after.

The reason I don't want to run the while within the method is because I am going to reiterate back over the array when it's returned, and I'd rather not run through the results twice (for performance reasons).

Is there a way to do this? Do I have a problem with my general query method design?

Thank you muchly!

答:
thanks for the ideas.  I have a function that returns an associative array from the sql (used in Moodle).

$results = get_records_sql($sql);

```<code>//to create a numerically indexed array:
$data = array();
foreach ($results as $row)
     {
           $data[] = $row;
     }
return $data;
</code>```

}

OwnerDisplayName: alex

ContentLicense: CC BY-SA 3.0

Body:
I have this method in my db class

public function query($queryString)
    {

      if (!$this->_connected) $this->_connectToDb(); //connect to database

      $results = mysql_query($queryString, $this->_dbLink) or trigger_error(mysql_error());

      return mysql_num_rows($results) > 0 ? mysql_fetch_assoc($results) : false;

    }

This works great for queries that return 1 row, but how can I get an array returned something like this?

$array[0]['name'] = 'jim'
$array[0]['id'] =  120
$array[1]['name'] = 'judith'
$array[1]['ID'] = 121

Now I know I could use a while loop to insert this data into the array like so, but I was wondering if PHP could do this with an internal function? I havn't been able to find on the docs what I'm after.

The reason I don't want to run the while within the method is because I am going to reiterate back over the array when it's returned, and I'd rather not run through the results twice (for performance reasons).

Is there a way to do this? Do I have a problem with my general query method design?

Thank you muchly!

Body:
thanks for the ideas.  I have a function that returns an associative array from the sql (used in Moodle).

$results = get_records_sql($sql);

//to create a numerically indexed array:
$data = array();
foreach ($results as $row)
     {
           $data[] = $row;
     }
return $data;

}

OwnerDisplayName: Tina

ContentLicense: CC BY-SA 2.5


问:
How to cope with 'readonly' and 'selected' attributes in WatiN 2.0 against IE9
I'm using WatiN for web testing, and am encountering issues caused by the fact that for the 'readonly' attribute of INPUT elements, WatiN is attempting to parse the value as a boolean, which as far as I can tell is incorrect, as the attribute should be written as follows:

<input readonly="readonly" />

When I try to access the TextField.Readonly property from WatiN at runtime, an error is thrown because WatiN attempts to parse 'readonly' as a boolean. I also encountered a similar issue with the 'selected' attribute of the <option> element.

I find it hard to believe that nobody else has encountered these basic scenarios using WatiN which makes me think I am missing something obvious. Is there a known way to work around these issues or is this a known issue with WatiN?

答: This issue has to do with IE9 showing a page in IE9mode differs greatly from how IE9 in IE8mode (and older versions of IE) behaves. These problems have been fixed in WatiN 2.1</p>


问:
How to add a crontab job to crontab using a bash script with date stamp?
here was the original question
How to add a crontab job to crontab using a bash script?

```<code> #!/bin/bash
cronjob="* * * * * /path/to/command"
(crontab -u userhere -l; echo "$cronjob" ) | crontab -u userhere -
</code>```

if I try to use command below bash is importing command and replacing (date +\%H_\%M-\%d.\%m.\%Y at the date and time of the import and I see imported command with fixed date stamp as..../mysql/21_18-27.05.2019_dbbackup.sql.gz

is there a way to keep date imported a formula?

```<code>cronjob="05 21 * * * /usr/bin/mysqldump -u mysqluserhere -pmysqlpassword DBname | gzip > /path/to/mysql/$(date +\%H_\%M-\%d.\%m.\%Y)_dbbackup.sql.gz" (crontab -u userhere -l; echo "$cronjob" ) | crontab -u userhere -
</code>```

Many thanks

答:
you can

a) escape the $ in the path, like this:

```<code>    /path/to/mysql/\$(date +\%H_\%M-\%d.\%m.\%Y)_dbbackup.sql.gz
</code>```

this way the "$(date..." will end up in the cron tab

b) put the whole command into a shellscript(file) and then just execute that file from the cronjob

Body:
here was the original question
How to add a crontab job to crontab using a bash script?

 #!/bin/bash
cronjob="* * * * * /path/to/command"
(crontab -u userhere -l; echo "$cronjob" ) | crontab -u userhere -

if I try to use command below bash is importing command and replacing (date +\%H_\%M-\%d.\%m.\%Y at the date and time of the import and I see imported command with fixed date stamp as..../mysql/21_18-27.05.2019_dbbackup.sql.gz

is there a way to keep date imported a formula?

cronjob="05 21 * * * /usr/bin/mysqldump -u mysqluserhere -pmysqlpassword DBname | gzip > /path/to/mysql/$(date +\%H_\%M-\%d.\%m.\%Y)_dbbackup.sql.gz" (crontab -u userhere -l; echo "$cronjob" ) | crontab -u userhere -

Many thanks

Body:
you can

a) escape the $ in the path, like this:

    /path/to/mysql/\$(date +\%H_\%M-\%d.\%m.\%Y)_dbbackup.sql.gz

this way the "$(date..." will end up in the cron tab

b) put the whole command into a shellscript(file) and then just execute that file from the cronjob


问:
How do I give my simple java program memory?
I am new to programming and I have a simple program I am working on for fun that keeps track of my money. For instance, I want it to record how much money is in my wallet. So I will give it some data, and it complies. However, when I rerun the program at a different time to add or subtract money from my wallet for example, it will revert back to 0 instead of saving the changes I made before.

I assume I have to make a txt file for this data to save to, and then have it read it every time I run the program?

```<code>//here is my wallet class
public class Wallet extends UserInterface{

    public String WalletName;
    public double WalletCash;

    public Wallet(String name) {
        this.WalletName = name;

    }

    public String addCashtoWallet(double income) {
        WalletCash += income;
        return "Added $" + income + "to " + this.WalletName;
    }

    public String removeCashfromWallet(double cost) {
        WalletCash -= cost;
        return "Removed $" + cost + "from " + this.WalletName;
    }

}
</code>```

The output when I add money to the wallet for example, will be
"Your wallet now has $64.0 would you like to do anything else"
However, when I run the program again, it will say 0, but I want it to display the 64 dollars I added before. How do I get it to save this data?

答:
You could use a file to keep your information and load the information at the startup.

https://stackabuse.com/reading-and-writing-files-in-java/

Or you can use a database to keep that information.

https://www.tutorialspoint.com/jdbc/jdbc-sample-code.htm

I advice you first to try to use a file, after that you could try using a database (e.g. MySQL, MariaDB, PostgreSQL)

Body:
I am new to programming and I have a simple program I am working on for fun that keeps track of my money. For instance, I want it to record how much money is in my wallet. So I will give it some data, and it complies. However, when I rerun the program at a different time to add or subtract money from my wallet for example, it will revert back to 0 instead of saving the changes I made before.

I assume I have to make a txt file for this data to save to, and then have it read it every time I run the program?

//here is my wallet class
public class Wallet extends UserInterface{

    public String WalletName;
    public double WalletCash;

    public Wallet(String name) {
        this.WalletName = name;

    }

    public String addCashtoWallet(double income) {
        WalletCash += income;
        return "Added $" + income + "to " + this.WalletName;
    }

    public String removeCashfromWallet(double cost) {
        WalletCash -= cost;
        return "Removed $" + cost + "from " + this.WalletName;
    }

}

The output when I add money to the wallet for example, will be
"Your wallet now has $64.0 would you like to do anything else"
However, when I run the program again, it will say 0, but I want it to display the 64 dollars I added before. How do I get it to save this data?


问:
How to exclude rows from a SQL fetch that have a related keyword through a many to many relationship
I have a MySQL database with a media table, and a keywords table, and a many-to-many relationship between media and keywords via a media_keywords join table.

I want to fetch all records from the media table where the following set of conditions match:

```<code>'description' is like 'dog' OR
'media.keywords' includes the id for the 'dog' keyword [100]
</code>```

And exclude from the found set any records where:

```<code>'description' is like 'cat' OR
'media.keywords' includes the id for the 'cat' keyword [400]
</code>```

And also exclude any row where:

```<code>'media.keywords' includes the id for the 'monochrome' keyword [500]
</code>```

I also want to return only distinct rows, so I'm using GROUP By 'media.id'

The SQL statement I have at the moment is as follows:

```<code>    SELECT DISTINCT
    `media`.`id`,`media`.`description`,
    `keywords`.`id` AS `keywords.id`,
    `keywords->media_keywords`.`id` AS `keywords.media_keywords.id`,
    `keywords->media_keywords`.`media_id` AS `keywords.media_keywords.media_id`,
    `keywords->media_keywords`.`keyword_id` AS `keywords.media_keywords.keyword_id`

    FROM database.media

    LEFT OUTER JOIN
    (
        `media_keywords` AS `keywords->media_keywords`

        INNER JOIN `keywords` AS `keywords`
        ON `keywords`.`id` = `keywords->media_keywords`.`keyword_id`
    )

    ON `media`.`id` = `keywords->media_keywords`.`media_id`

    WHERE
    (
            (`media`.`description` LIKE '%dog%' )

            OR `keywords`.`id` IN (100)
    )

    AND NOT
    (
            (`media`.`description` LIKE '%cat%' )

            OR `keywords`.`id` IN (400,500)
    )

    GROUP BY `media`.`id` ;
</code>```

This correctly fetches records where 'dog' is in the description or is a keyword, but ignores the exclusions completely.

Can anyone see what I'm doing wrong here?

答:
I don't work with mySQL much, but I would suggestion a different approach

Move the "DOG" condition inside the LEFT JOIN (so only get keywords
matching "DOG") and make it a JOIN.   Now you'll have a list of all
matches.

add a subquery in the WHERE clause

WHERE id not in (SELECT id FROM ... WHERE LIKE '%cat%')

Body:
I have a MySQL database with a media table, and a keywords table, and a many-to-many relationship between media and keywords via a media_keywords join table.

I want to fetch all records from the media table where the following set of conditions match:

'description' is like 'dog' OR
'media.keywords' includes the id for the 'dog' keyword [100]

And exclude from the found set any records where:

'description' is like 'cat' OR
'media.keywords' includes the id for the 'cat' keyword [400]

And also exclude any row where:

'media.keywords' includes the id for the 'monochrome' keyword [500]

I also want to return only distinct rows, so I'm using GROUP By 'media.id'

The SQL statement I have at the moment is as follows:

    SELECT DISTINCT
    `media`.`id`,`media`.`description`,
    `keywords`.`id` AS `keywords.id`,
    `keywords->media_keywords`.`id` AS `keywords.media_keywords.id`,
    `keywords->media_keywords`.`media_id` AS `keywords.media_keywords.media_id`,
    `keywords->media_keywords`.`keyword_id` AS `keywords.media_keywords.keyword_id`

    FROM database.media

    LEFT OUTER JOIN
    (
        `media_keywords` AS `keywords->media_keywords`

        INNER JOIN `keywords` AS `keywords`
        ON `keywords`.`id` = `keywords->media_keywords`.`keyword_id`
    )

    ON `media`.`id` = `keywords->media_keywords`.`media_id`

    WHERE
    (
            (`media`.`description` LIKE '%dog%' )

            OR `keywords`.`id` IN (100)
    )

    AND NOT
    (
            (`media`.`description` LIKE '%cat%' )

            OR `keywords`.`id` IN (400,500)
    )

    GROUP BY `media`.`id` ;

This correctly fetches records where 'dog' is in the description or is a keyword, but ignores the exclusions completely.

Can anyone see what I'm doing wrong here?


问:
MKOverlayRenderer function not being called?
```<code>import UIKit
import CoreData
import Foundation
import MapKit

struct Geoshape : Codable {
    let coordinates: [[Double]]
}
struct Field : Codable {
    let geo_shape: Geoshape
    let level_of_service: String
}
struct Record: Codable {
    let fields: Field
}

struct Verkeer: Codable{
    let records: Array<Record>
}

class ViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate{
    var managedContext:NSManagedObjectContext?
    var coordinaten: [[[Double]]] = []
    var levels: [String] = []

    @IBOutlet weak var myMap: MKMapView!

    let initialLocation = CLLocation(latitude: 50.841890,  longitude: 4.323475)

    override func viewDidLoad() {
        super.viewDidLoad()

        myMap.delegate = self
        centerMapOnLocation(location: initialLocation)

    }

    @IBAction func clickRefresh(_ sender: Any) {
        //Refresh -> array leegmaken en waardes opnieuw toevoegen in core data
        coordinaten = []
        levels = []

        guard let url = URL(string: "https://opendata.brussels.be/api/records/1.0/search/?dataset=traffic-volume&rows=70&facet=level_of_service") else { return }
        let session = URLSession.shared
        let task = session.dataTask(with: url){ (data, response, error) in
            if let response = response {
                print(response)
            }
         if let data = data {
            let traffic = try? JSONDecoder().decode(Verkeer.self, from: data)
            let test = traffic?.records
            for loop in test! {

                //Coördinaten
                //print(loop.fields.geo_shape.coordinates)
                self.coordinaten.append(loop.fields.geo_shape.coordinates)

                //Levels
                //print(loop.fields.level_of_service)
                self.levels.append(loop.fields.level_of_service)
            }
            var points = [MKMapPoint]()
            for x in 0..<self.coordinaten.count{
                for y in 0..<self.coordinaten[x].count{
                    print(self.coordinaten[x][y][0])
                    let p = MKMapPoint(CLLocationCoordinate2DMake(self.coordinaten[x][y][0], self.coordinaten[x][y][1]))
                    points.append(p)
                }
                let polyline = MKPolyline(points: points, count: points.count)

                self.myMap.addOverlay(polyline)

                points.removeAll()
                print(points.count)
            }

            }
        }
        task.resume()

    }

    let regionRadius: CLLocationDistance = 200
    func centerMapOnLocation(location: CLLocation) {
        let coordinateRegion = MKCoordinateRegion(center: location.coordinate,
                                                  latitudinalMeters: regionRadius, longitudinalMeters: regionRadius)
        myMap.setRegion(coordinateRegion, animated: true)

        //Add pin
        let pin: MKPointAnnotation = MKPointAnnotation()
        pin.coordinate = CLLocationCoordinate2DMake(initialLocation.coordinate.latitude, initialLocation.coordinate.longitude);
        pin.title = "Current location"
        myMap.addAnnotation(pin)
    }

    func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
        if overlay is MKPolyline {
            let lineView = MKPolylineRenderer(overlay: overlay)
            lineView.strokeColor = UIColor.red
            lineView.lineWidth = 10
            return lineView
        }
        return MKOverlayRenderer()
    }

}
</code>```

So I've been trying to show some coordinates on my map, but it does not seem to work. I get the coordinates from a json file and printing them is no problem but its the part where I try to add them to my map.. Anyone knows why this "func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer" is not being called? When I was searching online, the only thing I could find was to add the map delegate in viewDidLoad() function but that also does not work for me..

答:
It’s because your overlay is not visible because the latitude and longitude are backwards. Swap them and you’ll start to see your overlays:</p>

```<code>let coordinate = CLLocationCoordinate2DMake(self.coordinaten[x][y][1], self.coordinaten[x][y][0])
</code>```

Body:
import UIKit
import CoreData
import Foundation
import MapKit

struct Geoshape : Codable {
    let coordinates: [[Double]]
}
struct Field : Codable {
    let geo_shape: Geoshape
    let level_of_service: String
}
struct Record: Codable {
    let fields: Field
}

struct Verkeer: Codable{
    let records: Array<Record>
}

class ViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate{
    var managedContext:NSManagedObjectContext?
    var coordinaten: [[[Double]]] = []
    var levels: [String] = []

    @IBOutlet weak var myMap: MKMapView!

    let initialLocation = CLLocation(latitude: 50.841890,  longitude: 4.323475)

    override func viewDidLoad() {
        super.viewDidLoad()

        myMap.delegate = self
        centerMapOnLocation(location: initialLocation)

    }

    @IBAction func clickRefresh(_ sender: Any) {
        //Refresh -> array leegmaken en waardes opnieuw toevoegen in core data
        coordinaten = []
        levels = []

        guard let url = URL(string: "https://opendata.brussels.be/api/records/1.0/search/?dataset=traffic-volume&rows=70&facet=level_of_service") else { return }
        let session = URLSession.shared
        let task = session.dataTask(with: url){ (data, response, error) in
            if let response = response {
                print(response)
            }
         if let data = data {
            let traffic = try? JSONDecoder().decode(Verkeer.self, from: data)
            let test = traffic?.records
            for loop in test! {

                //Coördinaten
                //print(loop.fields.geo_shape.coordinates)
                self.coordinaten.append(loop.fields.geo_shape.coordinates)

                //Levels
                //print(loop.fields.level_of_service)
                self.levels.append(loop.fields.level_of_service)
            }
            var points = [MKMapPoint]()
            for x in 0..<self.coordinaten.count{
                for y in 0..<self.coordinaten[x].count{
                    print(self.coordinaten[x][y][0])
                    let p = MKMapPoint(CLLocationCoordinate2DMake(self.coordinaten[x][y][0], self.coordinaten[x][y][1]))
                    points.append(p)
                }
                let polyline = MKPolyline(points: points, count: points.count)

                self.myMap.addOverlay(polyline)

                points.removeAll()
                print(points.count)
            }

            }
        }
        task.resume()

    }

    let regionRadius: CLLocationDistance = 200
    func centerMapOnLocation(location: CLLocation) {
        let coordinateRegion = MKCoordinateRegion(center: location.coordinate,
                                                  latitudinalMeters: regionRadius, longitudinalMeters: regionRadius)
        myMap.setRegion(coordinateRegion, animated: true)

        //Add pin
        let pin: MKPointAnnotation = MKPointAnnotation()
        pin.coordinate = CLLocationCoordinate2DMake(initialLocation.coordinate.latitude, initialLocation.coordinate.longitude);
        pin.title = "Current location"
        myMap.addAnnotation(pin)
    }

    func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
        if overlay is MKPolyline {
            let lineView = MKPolylineRenderer(overlay: overlay)
            lineView.strokeColor = UIColor.red
            lineView.lineWidth = 10
            return lineView
        }
        return MKOverlayRenderer()
    }

}

So I've been trying to show some coordinates on my map, but it does not seem to work. I get the coordinates from a json file and printing them is no problem but its the part where I try to add them to my map.. Anyone knows why this "func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer" is not being called? When I was searching online, the only thing I could find was to add the map delegate in viewDidLoad() function but that also does not work for me..

Body:
It’s because your overlay is not visible because the latitude and longitude are backwards. Swap them and you’ll start to see your overlays:

let coordinate = CLLocationCoordinate2DMake(self.coordinaten[x][y][1], self.coordinaten[x][y][0])


问:
Can't save data into my Access 2007 database
I cannot save data in Access 2007. When I tried to click the Save button, I get the message

Syntax Error in Insert Into Statement.

What is the error in my code?

```<code>Private Sub Save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Save.Click
    If Len(Trim(TxtUserid.Text)) = 0 Then
        MessageBox.Show("Please enter Student No.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        TxtUserid.Focus()
        Exit Sub
    End If

    If Len(Trim(TxtUsername.Text)) = 0 Then
        MessageBox.Show("Please enter Username", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        TxtUsername.Focus()
        Exit Sub
    End If
    If Len(Trim(txtreenterpassword.Text)) = 0 Then
        MessageBox.Show("Please enter Password", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        txtreenterpassword.Focus()
        Exit Sub
    End If

    Try
        con = New OleDbConnection(cs)
        con.Open()
        Dim ct As String = "select Userid from Users where Userid=@find"

        cmd = New OleDbCommand(ct)
        cmd.Connection = con
        cmd.Parameters.Add(New OleDbParameter("@find", System.Data.OleDb.OleDbType.VarChar, 20, "Userid"))
        cmd.Parameters("@find").Value = TxtUserid.Text
        rdr = cmd.ExecuteReader()

        If rdr.Read Then
            MessageBox.Show("Student No. Already Exists", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)

            If Not rdr Is Nothing Then
                rdr.Close()
            End If
        Else
            con = New OleDbConnection(cs)
            con.Open()

            Dim ab As String = "insert into Users(Userid,USERNAME,USERTYPE,PASSWORD,FIRSTNAME,MI,LASTNAME,CONTACT,BIRTHDAY,Age) VALUES (@a1,@a2,@a3,@a4,@a5,@a6,@a7,@a8,@a9,@a10)"

            cmd = New OleDbCommand(ab)
            cmd.Connection = con
            cmd.Parameters.Add(New OleDbParameter("@a1", System.Data.OleDb.OleDbType.VarChar, 20, "Userid"))
            cmd.Parameters.Add(New OleDbParameter("@a2", System.Data.OleDb.OleDbType.VarChar, 100, "USERNAME"))
            cmd.Parameters.Add(New OleDbParameter("@a3", System.Data.OleDb.OleDbType.VarChar, 250, "USERTYPE"))
            cmd.Parameters.Add(New OleDbParameter("@a4", System.Data.OleDb.OleDbType.VarChar, 50, "PASSWORD"))
            cmd.Parameters.Add(New OleDbParameter("@a5", System.Data.OleDb.OleDbType.VarChar, 200, "FIRSTNAME"))
            cmd.Parameters.Add(New OleDbParameter("@a6", System.Data.OleDb.OleDbType.VarChar, 150, "MI"))
            cmd.Parameters.Add(New OleDbParameter("@a7", System.Data.OleDb.OleDbType.VarChar, 15, "LASTNAME"))
            cmd.Parameters.Add(New OleDbParameter("@a8", System.Data.OleDb.OleDbType.VarChar, 250, "CONTACT"))
            cmd.Parameters.Add(New OleDbParameter("@a9", System.Data.OleDb.OleDbType.VarChar, 15, "BIRTHDAY"))
            cmd.Parameters.Add(New OleDbParameter("@a10", System.Data.OleDb.OleDbType.VarChar, 250, "Age"))

            cmd.Parameters("@a1").Value = TxtUserid.Text
            cmd.Parameters("@a2").Value = TxtUsername.Text
            cmd.Parameters("@a3").Value = Cmbusertype.Text
            cmd.Parameters("@a4").Value = txtreenterpassword.Text
            cmd.Parameters("@a5").Value = TxtFirstname.Text
            cmd.Parameters("@a6").Value = txtMi.Text
            cmd.Parameters("@a7").Value = TxtLastname.Text
            cmd.Parameters("@a8").Value = TxtContact.Text
            cmd.Parameters("@a9").Value = DateTimePicker3.Text
            cmd.Parameters("@a10").Value = TxtAge.Text

            cmd.ExecuteReader()

            MessageBox.Show("Successfully Saved", "Issued Details", MessageBoxButtons.OK, MessageBoxIcon.Information)

            If con.State = ConnectionState.Open Then
                con.Close()
            End If
            con.Close()
        End If
    Catch ex As Exception
        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        con.Dispose()
    End Try
End Sub
</code>```

答:
why are you using:

```<code>cmd.ExecuteReader()
</code>```

could you try to use:

```<code>cmd.ExecuteNonQuery()
</code>```

Body:
I cannot save data in Access 2007. When I tried to click the Save button, I get the message

Syntax Error in Insert Into Statement.

What is the error in my code?

Private Sub Save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Save.Click
    If Len(Trim(TxtUserid.Text)) = 0 Then
        MessageBox.Show("Please enter Student No.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        TxtUserid.Focus()
        Exit Sub
    End If

    If Len(Trim(TxtUsername.Text)) = 0 Then
        MessageBox.Show("Please enter Username", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        TxtUsername.Focus()
        Exit Sub
    End If
    If Len(Trim(txtreenterpassword.Text)) = 0 Then
        MessageBox.Show("Please enter Password", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        txtreenterpassword.Focus()
        Exit Sub
    End If

    Try
        con = New OleDbConnection(cs)
        con.Open()
        Dim ct As String = "select Userid from Users where Userid=@find"

        cmd = New OleDbCommand(ct)
        cmd.Connection = con
        cmd.Parameters.Add(New OleDbParameter("@find", System.Data.OleDb.OleDbType.VarChar, 20, "Userid"))
        cmd.Parameters("@find").Value = TxtUserid.Text
        rdr = cmd.ExecuteReader()

        If rdr.Read Then
            MessageBox.Show("Student No. Already Exists", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)

            If Not rdr Is Nothing Then
                rdr.Close()
            End If
        Else
            con = New OleDbConnection(cs)
            con.Open()

            Dim ab As String = "insert into Users(Userid,USERNAME,USERTYPE,PASSWORD,FIRSTNAME,MI,LASTNAME,CONTACT,BIRTHDAY,Age) VALUES (@a1,@a2,@a3,@a4,@a5,@a6,@a7,@a8,@a9,@a10)"

            cmd = New OleDbCommand(ab)
            cmd.Connection = con
            cmd.Parameters.Add(New OleDbParameter("@a1", System.Data.OleDb.OleDbType.VarChar, 20, "Userid"))
            cmd.Parameters.Add(New OleDbParameter("@a2", System.Data.OleDb.OleDbType.VarChar, 100, "USERNAME"))
            cmd.Parameters.Add(New OleDbParameter("@a3", System.Data.OleDb.OleDbType.VarChar, 250, "USERTYPE"))
            cmd.Parameters.Add(New OleDbParameter("@a4", System.Data.OleDb.OleDbType.VarChar, 50, "PASSWORD"))
            cmd.Parameters.Add(New OleDbParameter("@a5", System.Data.OleDb.OleDbType.VarChar, 200, "FIRSTNAME"))
            cmd.Parameters.Add(New OleDbParameter("@a6", System.Data.OleDb.OleDbType.VarChar, 150, "MI"))
            cmd.Parameters.Add(New OleDbParameter("@a7", System.Data.OleDb.OleDbType.VarChar, 15, "LASTNAME"))
            cmd.Parameters.Add(New OleDbParameter("@a8", System.Data.OleDb.OleDbType.VarChar, 250, "CONTACT"))
            cmd.Parameters.Add(New OleDbParameter("@a9", System.Data.OleDb.OleDbType.VarChar, 15, "BIRTHDAY"))
            cmd.Parameters.Add(New OleDbParameter("@a10", System.Data.OleDb.OleDbType.VarChar, 250, "Age"))

            cmd.Parameters("@a1").Value = TxtUserid.Text
            cmd.Parameters("@a2").Value = TxtUsername.Text
            cmd.Parameters("@a3").Value = Cmbusertype.Text
            cmd.Parameters("@a4").Value = txtreenterpassword.Text
            cmd.Parameters("@a5").Value = TxtFirstname.Text
            cmd.Parameters("@a6").Value = txtMi.Text
            cmd.Parameters("@a7").Value = TxtLastname.Text
            cmd.Parameters("@a8").Value = TxtContact.Text
            cmd.Parameters("@a9").Value = DateTimePicker3.Text
            cmd.Parameters("@a10").Value = TxtAge.Text

            cmd.ExecuteReader()

            MessageBox.Show("Successfully Saved", "Issued Details", MessageBoxButtons.OK, MessageBoxIcon.Information)

            If con.State = ConnectionState.Open Then
                con.Close()
            End If
            con.Close()
        End If
    Catch ex As Exception
        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        con.Dispose()
    End Try
End Sub

Body:
why are you using:

cmd.ExecuteReader()

could you try to use:

cmd.ExecuteNonQuery()


问:
Node.js - process.exit AND append the entire console.log messages in a text file
I'm a noob to Puppeteer.
I'm using a script that login to a site. If username or password is wrong, I want to log the console message in a file AND exit with an error number. This number is important because it will be used in Excel VBA.
I use a file batch (Windows) to run the node.js script, and I use a function at the beginning the script to append the console message.

I run a batch file to run the script:

```<code>node C:\*my-path*\node-script.js
exit /b %errorlevel%
</code>```

I can see the message in the console, but in the log file there isn't the entire error message because process.exit(1) close the procedure before it.

This is the function to append the console.log messages:

```<code>fs.unlinkSync("./tmp/node-js.log");
console.log = function(msg) {
    fs.appendFile("./tmp/node-js.log", msg+'\r\n', 'ascii', function(err) {
        if(err) {
            return trueLog(err);
        }
    });
    trueLog(msg);
</code>```

And then, this is the code to login:

```<code>await page.goto('https://google-wrong.com/', {  //a wrong url to test
                waitUntil: 'networkidle2',
                timeout: 10000
}).catch(error => {
    throw (console.log('\r\n'+ 'JAVASCRIPT * Wrong Url ! * ' + error)), process.exit(1) });
</code>```

So, if I use browser.close() instead of process.exit(1) I can append the entire message but can't exit with an error code; this is my console.log:

```<code>> Open browser in memory... Done!
> Connect to google-wrong.com... Error!
> JAVASCRIPT * Wrong Url ! * Error: net::ERR_NAME_NOT_RESOLVED at https://google-wrong.com/
</code>```

And at the Dos prompt I see:

```<code>> exit /b 0
</code>```

If I use process.exit(1), I can see the "exit with error" number:

exit /b 1

...but I can't log the entire message:

```<code>> Open browser in memory... Done!
> Connect to google-wrong.com... Error
</code>```

Any ideas?
Thanks in advance, and sorry for my bad english, I hope I made myself clear.

答: I think you should use fs.appendFileSync in your console.log function, and no need for the throw keyword in the catch handler

Body:
I'm a noob to Puppeteer.
I'm using a script that login to a site. If username or password is wrong, I want to log the console message in a file AND exit with an error number. This number is important because it will be used in Excel VBA.
I use a file batch (Windows) to run the node.js script, and I use a function at the beginning the script to append the console message.

I run a batch file to run the script:

node C:\*my-path*\node-script.js
exit /b %errorlevel%

I can see the message in the console, but in the log file there isn't the entire error message because process.exit(1) close the procedure before it.

This is the function to append the console.log messages:

fs.unlinkSync("./tmp/node-js.log");
console.log = function(msg) {
    fs.appendFile("./tmp/node-js.log", msg+'\r\n', 'ascii', function(err) {
        if(err) {
            return trueLog(err);
        }
    });
    trueLog(msg);

And then, this is the code to login:

await page.goto('https://google-wrong.com/', {  //a wrong url to test
                waitUntil: 'networkidle2',
                timeout: 10000
}).catch(error => {
    throw (console.log('\r\n'+ 'JAVASCRIPT * Wrong Url ! * ' + error)), process.exit(1) });

So, if I use browser.close() instead of process.exit(1) I can append the entire message but can't exit with an error code; this is my console.log:

> Open browser in memory... Done!
> Connect to google-wrong.com... Error!
> JAVASCRIPT * Wrong Url ! * Error: net::ERR_NAME_NOT_RESOLVED at https://google-wrong.com/

And at the Dos prompt I see:

> exit /b 0

If I use process.exit(1), I can see the "exit with error" number:

exit /b 1

...but I can't log the entire message:

> Open browser in memory... Done!
> Connect to google-wrong.com... Error

Any ideas?
Thanks in advance, and sorry for my bad english, I hope I made myself clear.


问:
how to import the "django-sse" module?
I want to import the module Django-SSE in one of my projects, but it errors because it has subtraction sign.

I've tried to import the library like this import django-sse and import django_sse and I've tried from django_sse.views import BaseSseView but none of theme worked.

so i'll be appreciate if you help me to import it and tell me is there any documentation about it?

答:
thanks of those who paied attention.
I should dwnload the sse pkage beside the djagno_sse and then

from django_sse.views import BaseSseView
```

Title: how to import the "django-sse" module?


问:
How can I add shared variable to chakram?
I'am using chakram + mocha.
How can I use shared variables for all test?

For example, I would like to use variable API_PATH="http://example.com/v1/" in tests. And this variable could be changed during running test. So, my test looks like this.

```<code>var response = chakram.get(API_PATH + "products");
expect(response).to.have.status(200);
</code>```

As example, protractor has conf.js with parameter baseUrl. Running test looks like protractor conf.js --baseUrl http://example.com/

答:
For Example in config.js

```<code>module.exports = {
    "baseUrl": "http://example.com/",
    "googleUrl":  "http://www.google.com.tr/"
  };
</code>```

And use in javascript code:

```<code>let config = require('/config');

describle("test describle", () => {

   it("test", () => {
      chakram.get(config.baseUrl + "products");   //for example use
   })
})
</code>```

Body:
I'am using chakram + mocha.
How can I use shared variables for all test?

For example, I would like to use variable API_PATH="http://example.com/v1/" in tests. And this variable could be changed during running test. So, my test looks like this.

var response = chakram.get(API_PATH + "products");
expect(response).to.have.status(200);

As example, protractor has conf.js with parameter baseUrl. Running test looks like protractor conf.js --baseUrl http://example.com/

Body:
For Example in config.js

module.exports = {
    "baseUrl": "http://example.com/",
    "googleUrl":  "http://www.google.com.tr/"
  };

And use in javascript code:

let config = require('/config');

describle("test describle", () => {

   it("test", () => {
      chakram.get(config.baseUrl + "products");   //for example use
   })
})