问:
How to fix bootstrap Error in angular ? What is going wrong
I am not sure why I am getting following error.

```<code>ERROR in node_modules/@ng-bootstrap/ng-bootstrap/accordion/accordion.d.ts(118,34): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/accordion/accordion.d.ts(118,40): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker-service.d.ts(27,44): error TS1144: '{' or ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker-service.d.ts(28,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker-service.d.ts(29,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker-service.d.ts(30,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker-service.d.ts(31,1): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(13,20): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(13,21): error TS1003: Identifier expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(13,37): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(13,74): error TS1005: '(' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(14,24): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(14,25): error TS1003: Identifier expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(14,41): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(14,51): error TS1005: '(' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/hebrew/ngb-calendar-hebrew.d.ts(14,34): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/hebrew/ngb-calendar-hebrew.d.ts(14,41): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/hijri/ngb-calendar-hijri.d.ts(25,34): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/hijri/ngb-calendar-hijri.d.ts(25,41): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/jalali/ngb-calendar-persian.d.ts(10,34): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/jalali/ngb-calendar-persian.d.ts(10,41): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/ngb-calendar.d.ts(54,43): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/ngb-calendar.d.ts(54,50): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/ngb-calendar.d.ts(71,34): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/ngb-calendar.d.ts(71,41): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/highlight.d.ts(27,29): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/highlight.d.ts(27,35): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(79,69): error TS1005: '>' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(79,72): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(79,74): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(79,75): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(95,55): error TS1005: '(' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(119,58): error TS1005: '(' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(122,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(123,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,28): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,58): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,76): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,105): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,126): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,162): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,196): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,224): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,239): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,256): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,270): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,295): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,330): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(125,15): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(125,21): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(126,18): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(126,24): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(127,24): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(127,46): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(127,52): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(128,25): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(128,37): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(128,43): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(129,21): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(129,27): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(129,33): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(130,32): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(130,42): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(130,48): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(134,19): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(134,25): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(138,18): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(139,17): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(139,23): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(140,24): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(140,40): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(140,46): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(141,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(142,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(143,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(144,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(145,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(146,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(147,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(148,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(149,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(150,1): error TS1128: Declaration or statement expected.
node_modules/@ngrx/store/src/models.d.ts(7,39): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(7,67): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(7,76): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(7,79): error TS1109: Expression expected.
node_modules/@ngrx/store/src/models.d.ts(7,95): error TS1005: '(' expected.
node_modules/@ngrx/store/src/models.d.ts(8,12): error TS1005: ',' expected.
node_modules/@ngrx/store/src/models.d.ts(9,3): error TS1005: ',' expected.
node_modules/@ngrx/store/src/models.d.ts(9,10): error TS1005: ')' expected.
node_modules/@ngrx/store/src/models.d.ts(37,58): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(37,98): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(39,3): error TS1128: Declaration or statement expected.
node_modules/@ngrx/store/src/models.d.ts(45,85): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(45,125): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(47,3): error TS1128: Declaration or statement expected.
node_modules/@ngrx/store/src/models.d.ts(47,64): error TS1005: '(' expected.
node_modules/@ngrx/store/src/models.d.ts(48,59): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(48,99): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(50,3): error TS1128: Declaration or statement expected.
node_modules/@ngrx/store/src/models.d.ts(59,43): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(59,67): error TS1005: ',' expected.
node_modules/@ngrx/store/src/tokens.d.ts(20,83): error TS1005: '>' expected.
node_modules/@ngrx/store/src/tokens.d.ts(20,126): error TS1109: Expression expected.
node_modules/@ngrx/store/src/tokens.d.ts(24,69): error TS1005: '>' expected.
node_modules/@ngrx/store/src/tokens.d.ts(24,112): error TS1109: Expression expected.
node_modules/@ngrx/store/src/tokens.d.ts(29,79): error TS1005: '>' expected.
node_modules/@ngrx/store/src/tokens.d.ts(29,120): error TS1109: Expression expected.
</code>```

Below is my angular.json

```<code>{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "AllowMeClientAngular": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "app",
      "schematics": {
        "@schematics/angular:component": {
          "styleext": "scss"
        }
      },
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/AllowMeClientAngular",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.app.json",
            "assets": [
              "src/favicon.ico",
              "src/assets"

            ],
            "styles": [
              "node_modules/nouislider/distribute/nouislider.min.css",
              "node_modules/angular-calendar/scss/angular-calendar.scss",
              "node_modules/dragula/dist/dragula.css",
              "node_modules/ngx-toastr/toastr.css",
              "node_modules/videogular2/fonts/videogular.css",
              "node_modules/@swimlane/ngx-datatable/release/index.css",
              "node_modules/@swimlane/ngx-datatable/release/assets/icons.css",
              "node_modules/sweetalert2/dist/sweetalert2.min.css",
              "src/assets/css/prism.min.css",
              "src/assets/css/wizard.css",
              "src/assets/css/quill.snow.css",
              "src/assets/css/quill.bubble.css",
              "src/assets/css/hopscotch.css",
              "src/assets/css/demo.css",
              "src/assets/sass/app.scss",
              "src/styles.scss"
            ],
            "scripts": [
              "node_modules/jquery/dist/jquery.min.js",
              "src/assets/vendor/pace/pace.min.js",
              "src/assets/js/perfect-scrollbar.jquery.min.js"
            ]
          },
          "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
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "AllowMeClientAngular:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "AllowMeClientAngular:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "AllowMeClientAngular: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": [

            ],
            "scripts": [
              "node_modules/jquery/dist/jquery.min.js",
              "src/assets/vendor/pace/pace.min.js",
              "src/assets/js/perfect-scrollbar.jquery.min.js"
            ],
            "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/**"
            ]
          }
        }
      }
    },
    "AllowMeClientAngular-e2e": {
      "root": "e2e/",
      "projectType": "application",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "e2e/protractor.conf.js",
            "devServerTarget": "AllowMeClientAngular:serve"
          },
          "configurations": {
            "production": {
              "devServerTarget": "AllowMeClientAngular:serve:production"
            }
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": "e2e/tsconfig.e2e.json",
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    }
  },
  "defaultProject": "AllowMeClientAngular"
}
</code>```

Below is package.json

```<code>{
  "name": "allow-me-client-angular",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@agm/core": "^1.1.0",
    "@angular/animations": "^6.0.3",
    "@angular/cdk": "^6.4.0",
    "@angular/common": "^6.0.3",
    "@angular/compiler": "^6.0.3",
    "@angular/core": "^6.0.3",
    "@angular/forms": "^6.0.3",
    "@angular/http": "^6.0.3",
    "@angular/material": "^6.4.0",
    "@angular/platform-browser": "^6.0.3",
    "@angular/platform-browser-dynamic": "^6.0.3",
    "@angular/router": "^6.0.3",
    "@material/form-field": "^0.37.1",
    "@ng-bootstrap/ng-bootstrap": "^5.3.0",
    "@ngrx/store": "^8.6.0",
    "@ngx-translate/core": "^12.1.1",
    "@ngx-translate/http-loader": "^4.0.0",
    "@swimlane/ngx-datatable": "^16.0.3",
    "angular-calendar": "^0.28.2",
    "bootstrap": "^4.4.1",
    "core-js": "^2.5.4",
    "jquery": "^3.4.1",
    "ng-chartist": "^4.1.0",
    "ng-pick-datetime": "^6.0.10",
    "ng2-dragula": "^2.1.1",
    "ng2-smart-table": "^1.5.0",
    "ngx-bootstrap": "^3.0.1",
    "ngx-password-toggle": "^1.0.3",
    "ngx-show-hide-password": "^1.2.4",
    "ngx-toastr": "^12.0.0",
    "ngx-webstorage": "^2.0.1",
    "node-sass": "^4.13.1",
    "nouislider": "^14.1.1",
    "rxjs": "^6.0.0",
    "sweetalert2": "^9.7.2",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular/compiler-cli": "^6.0.3",
    "@angular-devkit/build-angular": "~0.6.8",
    "typescript": "~2.7.2",
    "@angular/cli": "~6.0.8",
    "@angular/language-service": "^6.0.3",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.2.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~1.7.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.0",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.3.0",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1"
  }
}
</code>```

Can someone just explain what this error mean so that I can look for some solution. The issue is I not able to figure out what is exact issue.

答:
"@ng-bootstrap/ng-bootstrap": "^4.2.2",
    "bootstrap": "^4.5.0",

Both bootstrap and ng-bootstrap version should same, it works for me

Body:
I am not sure why I am getting following error.

ERROR in node_modules/@ng-bootstrap/ng-bootstrap/accordion/accordion.d.ts(118,34): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/accordion/accordion.d.ts(118,40): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker-service.d.ts(27,44): error TS1144: '{' or ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker-service.d.ts(28,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker-service.d.ts(29,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker-service.d.ts(30,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker-service.d.ts(31,1): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(13,20): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(13,21): error TS1003: Identifier expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(13,37): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(13,74): error TS1005: '(' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(14,24): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(14,25): error TS1003: Identifier expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(14,41): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(14,51): error TS1005: '(' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/hebrew/ngb-calendar-hebrew.d.ts(14,34): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/hebrew/ngb-calendar-hebrew.d.ts(14,41): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/hijri/ngb-calendar-hijri.d.ts(25,34): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/hijri/ngb-calendar-hijri.d.ts(25,41): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/jalali/ngb-calendar-persian.d.ts(10,34): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/jalali/ngb-calendar-persian.d.ts(10,41): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/ngb-calendar.d.ts(54,43): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/ngb-calendar.d.ts(54,50): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/ngb-calendar.d.ts(71,34): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/ngb-calendar.d.ts(71,41): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/highlight.d.ts(27,29): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/highlight.d.ts(27,35): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(79,69): error TS1005: '>' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(79,72): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(79,74): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(79,75): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(95,55): error TS1005: '(' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(119,58): error TS1005: '(' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(122,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(123,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,28): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,58): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,76): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,105): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,126): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,162): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,196): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,224): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,239): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,256): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,270): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,295): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(124,330): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(125,15): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(125,21): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(126,18): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(126,24): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(127,24): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(127,46): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(127,52): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(128,25): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(128,37): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(128,43): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(129,21): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(129,27): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(129,33): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(130,32): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(130,42): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(130,48): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(134,19): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(134,25): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(138,18): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(139,17): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(139,23): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(140,24): error TS1005: ',' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(140,40): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(140,46): error TS1109: Expression expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(141,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(142,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(143,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(144,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(145,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(146,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(147,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(148,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(149,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(150,1): error TS1128: Declaration or statement expected.
node_modules/@ngrx/store/src/models.d.ts(7,39): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(7,67): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(7,76): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(7,79): error TS1109: Expression expected.
node_modules/@ngrx/store/src/models.d.ts(7,95): error TS1005: '(' expected.
node_modules/@ngrx/store/src/models.d.ts(8,12): error TS1005: ',' expected.
node_modules/@ngrx/store/src/models.d.ts(9,3): error TS1005: ',' expected.
node_modules/@ngrx/store/src/models.d.ts(9,10): error TS1005: ')' expected.
node_modules/@ngrx/store/src/models.d.ts(37,58): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(37,98): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(39,3): error TS1128: Declaration or statement expected.
node_modules/@ngrx/store/src/models.d.ts(45,85): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(45,125): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(47,3): error TS1128: Declaration or statement expected.
node_modules/@ngrx/store/src/models.d.ts(47,64): error TS1005: '(' expected.
node_modules/@ngrx/store/src/models.d.ts(48,59): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(48,99): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(50,3): error TS1128: Declaration or statement expected.
node_modules/@ngrx/store/src/models.d.ts(59,43): error TS1005: ';' expected.
node_modules/@ngrx/store/src/models.d.ts(59,67): error TS1005: ',' expected.
node_modules/@ngrx/store/src/tokens.d.ts(20,83): error TS1005: '>' expected.
node_modules/@ngrx/store/src/tokens.d.ts(20,126): error TS1109: Expression expected.
node_modules/@ngrx/store/src/tokens.d.ts(24,69): error TS1005: '>' expected.
node_modules/@ngrx/store/src/tokens.d.ts(24,112): error TS1109: Expression expected.
node_modules/@ngrx/store/src/tokens.d.ts(29,79): error TS1005: '>' expected.
node_modules/@ngrx/store/src/tokens.d.ts(29,120): error TS1109: Expression expected.

Below is my angular.json

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "AllowMeClientAngular": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "app",
      "schematics": {
        "@schematics/angular:component": {
          "styleext": "scss"
        }
      },
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/AllowMeClientAngular",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.app.json",
            "assets": [
              "src/favicon.ico",
              "src/assets"

            ],
            "styles": [
              "node_modules/nouislider/distribute/nouislider.min.css",
              "node_modules/angular-calendar/scss/angular-calendar.scss",
              "node_modules/dragula/dist/dragula.css",
              "node_modules/ngx-toastr/toastr.css",
              "node_modules/videogular2/fonts/videogular.css",
              "node_modules/@swimlane/ngx-datatable/release/index.css",
              "node_modules/@swimlane/ngx-datatable/release/assets/icons.css",
              "node_modules/sweetalert2/dist/sweetalert2.min.css",
              "src/assets/css/prism.min.css",
              "src/assets/css/wizard.css",
              "src/assets/css/quill.snow.css",
              "src/assets/css/quill.bubble.css",
              "src/assets/css/hopscotch.css",
              "src/assets/css/demo.css",
              "src/assets/sass/app.scss",
              "src/styles.scss"
            ],
            "scripts": [
              "node_modules/jquery/dist/jquery.min.js",
              "src/assets/vendor/pace/pace.min.js",
              "src/assets/js/perfect-scrollbar.jquery.min.js"
            ]
          },
          "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
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "AllowMeClientAngular:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "AllowMeClientAngular:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "AllowMeClientAngular: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": [

            ],
            "scripts": [
              "node_modules/jquery/dist/jquery.min.js",
              "src/assets/vendor/pace/pace.min.js",
              "src/assets/js/perfect-scrollbar.jquery.min.js"
            ],
            "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/**"
            ]
          }
        }
      }
    },
    "AllowMeClientAngular-e2e": {
      "root": "e2e/",
      "projectType": "application",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "e2e/protractor.conf.js",
            "devServerTarget": "AllowMeClientAngular:serve"
          },
          "configurations": {
            "production": {
              "devServerTarget": "AllowMeClientAngular:serve:production"
            }
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": "e2e/tsconfig.e2e.json",
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    }
  },
  "defaultProject": "AllowMeClientAngular"
}

Below is package.json

{
  "name": "allow-me-client-angular",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@agm/core": "^1.1.0",
    "@angular/animations": "^6.0.3",
    "@angular/cdk": "^6.4.0",
    "@angular/common": "^6.0.3",
    "@angular/compiler": "^6.0.3",
    "@angular/core": "^6.0.3",
    "@angular/forms": "^6.0.3",
    "@angular/http": "^6.0.3",
    "@angular/material": "^6.4.0",
    "@angular/platform-browser": "^6.0.3",
    "@angular/platform-browser-dynamic": "^6.0.3",
    "@angular/router": "^6.0.3",
    "@material/form-field": "^0.37.1",
    "@ng-bootstrap/ng-bootstrap": "^5.3.0",
    "@ngrx/store": "^8.6.0",
    "@ngx-translate/core": "^12.1.1",
    "@ngx-translate/http-loader": "^4.0.0",
    "@swimlane/ngx-datatable": "^16.0.3",
    "angular-calendar": "^0.28.2",
    "bootstrap": "^4.4.1",
    "core-js": "^2.5.4",
    "jquery": "^3.4.1",
    "ng-chartist": "^4.1.0",
    "ng-pick-datetime": "^6.0.10",
    "ng2-dragula": "^2.1.1",
    "ng2-smart-table": "^1.5.0",
    "ngx-bootstrap": "^3.0.1",
    "ngx-password-toggle": "^1.0.3",
    "ngx-show-hide-password": "^1.2.4",
    "ngx-toastr": "^12.0.0",
    "ngx-webstorage": "^2.0.1",
    "node-sass": "^4.13.1",
    "nouislider": "^14.1.1",
    "rxjs": "^6.0.0",
    "sweetalert2": "^9.7.2",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular/compiler-cli": "^6.0.3",
    "@angular-devkit/build-angular": "~0.6.8",
    "typescript": "~2.7.2",
    "@angular/cli": "~6.0.8",
    "@angular/language-service": "^6.0.3",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.2.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~1.7.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.0",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.3.0",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1"
  }
}

Can someone just explain what this error mean so that I can look for some solution. The issue is I not able to figure out what is exact issue.


来源: stackexchange

问:
Runtime Error '91 when saving email attachments
We use a shared Outlook email box and we need to save some of the attachments from that email.

I need the macro to:

Allow user to select multiple emails and save all the attachments in the selection

Allow the user to select what folder to save the attachments in (it will be different every time)

Add the ReceivedTime to the file name as we get some email attachments with the same name but they are always received on different days

Not alter the original email (don't delete the attachment or add a note to the email)

I have combined different lines from macros I found.

On both lines with "***" I get

"Runtime error 91: "object variable or With block variable not set"

I remove the dateFormat and SaveAs and still get the runtime error on the SaveAs line.

Sub saveAttachment()
    Dim objOL As Outlook.Application
    Dim objMsg As Outlook.MailItem
    Dim objAtt As Outlook.Attachment
    Dim objSel As Outlook.Selection
    Dim lngCount As Long
    Dim sFolder As String
    Dim dateFormat As String

    dateFormat = Format(objMsg.ReceivedTime, "yyyy-mm-dd")  '***

    Dim xlObj As Excel.Application
    Set xlObj = New Excel.Application
    ' Open the select folder prompt
    With xlObj.FileDialog(msoFileDialogFolderPicker)
        If .Show = -1 Then ' if OK is pressed
            sFolder = .SelectedItems(1)
        ElseIf .Show = 0 Then
            MsgBox "Failed to select folder to save attachements to"
        Exit Sub
        End If
    End With
    xlObj.Quit
    Set xlObj = Nothing
    Set objOL = CreateObject("Outlook.Application")
    Set objSelection = objOL.ActiveExplorer.Selection
    For Each objMsg In objSelection
        Set objAttachments = objMsg.Attachments
        lngCount = objAttachments.Count
        If lngCount > 0 Then
            objAtt.SaveAsFile sFolder & "\" & objAtt.FileName & dateFormat '***
        Else
            MsgBox "No attachements selected"
        End If
    Next
End Sub
```

We are utilizing Office365.

答:
First of all, you need to place the Format method inside the loop where the mail item is accessible and instantiated. Then you need to make sure the file path is valid and no forbidden symbols are used in the file name.

```<code>Set objOL = CreateObject("Outlook.Application")
Set objSelection = objOL.ActiveExplorer.Selection
For Each objMsg In objSelection
    Set objAttachments = objMsg.Attachments
    lngCount = objAttachments.Count
    If lngCount > 0 Then
      dateFormat = Format(objMsg.ReceivedTime, "yyyy-mm-dd")
      objAtt.SaveAsFile sFolder & "\" & objAtt.FileName & dateFormat
    Else
      MsgBox "No attachements selected"
    End If
Next
</code>```

You may find the Getting started with VBA in Office article helpful.

ContentLicense: CC BY-SA 4.0

Body:
We use a shared Outlook email box and we need to save some of the attachments from that email.

I need the macro to:

Allow user to select multiple emails and save all the attachments in the selection

Allow the user to select what folder to save the attachments in (it will be different every time)

Add the ReceivedTime to the file name as we get some email attachments with the same name but they are always received on different days

Not alter the original email (don't delete the attachment or add a note to the email)

I have combined different lines from macros I found.

On both lines with "***" I get

"Runtime error 91: "object variable or With block variable not set"

I remove the dateFormat and SaveAs and still get the runtime error on the SaveAs line.

Sub saveAttachment()
    Dim objOL As Outlook.Application
    Dim objMsg As Outlook.MailItem
    Dim objAtt As Outlook.Attachment
    Dim objSel As Outlook.Selection
    Dim lngCount As Long
    Dim sFolder As String
    Dim dateFormat As String

    dateFormat = Format(objMsg.ReceivedTime, "yyyy-mm-dd")  '***

    Dim xlObj As Excel.Application
    Set xlObj = New Excel.Application
    ' Open the select folder prompt
    With xlObj.FileDialog(msoFileDialogFolderPicker)
        If .Show = -1 Then ' if OK is pressed
            sFolder = .SelectedItems(1)
        ElseIf .Show = 0 Then
            MsgBox "Failed to select folder to save attachements to"
        Exit Sub
        End If
    End With
    xlObj.Quit
    Set xlObj = Nothing
    Set objOL = CreateObject("Outlook.Application")
    Set objSelection = objOL.ActiveExplorer.Selection
    For Each objMsg In objSelection
        Set objAttachments = objMsg.Attachments
        lngCount = objAttachments.Count
        If lngCount > 0 Then
            objAtt.SaveAsFile sFolder & "\" & objAtt.FileName & dateFormat '***
        Else
            MsgBox "No attachements selected"
        End If
    Next
End Sub

We are utilizing Office365.

Body:
First of all, you need to place the Format method inside the loop where the mail item is accessible and instantiated. Then you need to make sure the file path is valid and no forbidden symbols are used in the file name.

Set objOL = CreateObject("Outlook.Application")
Set objSelection = objOL.ActiveExplorer.Selection
For Each objMsg In objSelection
    Set objAttachments = objMsg.Attachments
    lngCount = objAttachments.Count
    If lngCount > 0 Then
      dateFormat = Format(objMsg.ReceivedTime, "yyyy-mm-dd")
      objAtt.SaveAsFile sFolder & "\" & objAtt.FileName & dateFormat
    Else
      MsgBox "No attachements selected"
    End If
Next

You may find the Getting started with VBA in Office article helpful.


问:
Retrieve inactive clients by LINQ
I have a problem with my code. I want to retrieve all the inactive clients(that have no orders) from last week.
This is my information from database.
information in database picture
Below is my code in LINQ, but it does not return anything.

```<code>DateTime daysBeforeToday = DateTime.Today.AddDays(-7);
var queryCount = context.Orders.Select(x=>x.ID).Count();
var query = (from o in context.Orders
where o.OrderDate >= daysBeforeToday
select new { CustomerName = o.CustomerName, ID = o.ID } into Customers
group Customers by Customers.CustomerName into pg
where queryCount == 0
select pg.Key);
return query.ToList();
</code>```

Please advice. Thank you

UPDATE

I found this SQL statement that works:

```<code>SELECT CustomerName, MAX(OrderDate) as LastOrderDate
FROM Orders
GROUP By CustomerName
having MAX(OrderDate) < dateAdd(day,-7, GetDate())
</code>```

but when I convert in LINQ it fails. What I did wrong?

```<code>DateTime daysBeforeToday = DateTime.Today.AddDays(-7);
var queryMax = context.Orders.Select(x=>x.OrderDate).Max();

var query = (from o in context.Orders
            select new { CustomerName = o.CustomerName, Date = o.OrderDate } into Customers
            group Customers by Customers.CustomerName into pg
            where queryMax < daysBeforeToday
            select pg.Key);

return query.ToList();
</code>```

答:
Like the comment, The Max should be calculated for each grouped customer, like the following code:

```<code>DateTime daysBeforeToday = DateTime.Today.AddDays(-7);

var query = (from o in context.Orders
            group o by o.CustomerName into pg
            where pg.Max(x => x.OrderDate) < daysBeforeToday
            select pg.Key);

return query.ToList();
</code>```

I hope you find this helpful.

Title: Retrieve inactive clients by LINQ

Body:
I have a problem with my code. I want to retrieve all the inactive clients(that have no orders) from last week.
This is my information from database.
information in database picture
Below is my code in LINQ, but it does not return anything.

DateTime daysBeforeToday = DateTime.Today.AddDays(-7);
var queryCount = context.Orders.Select(x=>x.ID).Count();
var query = (from o in context.Orders
where o.OrderDate >= daysBeforeToday
select new { CustomerName = o.CustomerName, ID = o.ID } into Customers
group Customers by Customers.CustomerName into pg
where queryCount == 0
select pg.Key);
return query.ToList();

Please advice. Thank you

UPDATE

I found this SQL statement that works:

SELECT CustomerName, MAX(OrderDate) as LastOrderDate
FROM Orders
GROUP By CustomerName
having MAX(OrderDate) < dateAdd(day,-7, GetDate())

but when I convert in LINQ it fails. What I did wrong?

DateTime daysBeforeToday = DateTime.Today.AddDays(-7);
var queryMax = context.Orders.Select(x=>x.OrderDate).Max();

var query = (from o in context.Orders
            select new { CustomerName = o.CustomerName, Date = o.OrderDate } into Customers
            group Customers by Customers.CustomerName into pg
            where queryMax < daysBeforeToday
            select pg.Key);

return query.ToList();

Body:
Like the comment, The Max should be calculated for each grouped customer, like the following code:

DateTime daysBeforeToday = DateTime.Today.AddDays(-7);

var query = (from o in context.Orders
            group o by o.CustomerName into pg
            where pg.Max(x => x.OrderDate) < daysBeforeToday
            select pg.Key);

return query.ToList();

I hope you find this helpful.


问:
Microsoft flow return JSON wrong format
Currently I have this:

Which is the output I want so just 1 as output

But the next step is parse JSON which results in this output:

How can I make that the parse JSON also returns 1 as output without the rest of the text?

答: In the step after "Parse JSON", you'll be able to select "id" in your "Dynamic content" and that will be just "1"</p>

Title: Microsoft flow return JSON wrong format


问:
Prevent inverted Flatlist from scrolling to bottom when new items are added
I am building a chat app, using an inverted Flatlist. I add new items to the top of the list when onEndReached is called and everything works fine.

The problem is that if add items to the bottom, it instantly scrolls to the bottom of the list. That means that the user has to scroll back up to read the messages that were just added (which is terrible).

I tried to call scrollToOffset in onContentSizeChange, but this has a one-second delay where the scroll jumps back and forth.

How can I have the list behave the same way when I add items to the top AND to the bottom, by keeping the same messages on screen instead of showing the new ones?

答:
Here I am adding a new item on top and bottom in an inverted Flatlist.

I hope you can compare your requirements with the provided sample code :)

Full Code:

import React, {Component} from 'react';
import {
  SafeAreaView,
  View,
  FlatList,
  StyleSheet,
  Text,
  Button,
  Platform,
  UIManager,
  LayoutAnimation,
} from 'react-native';

if (Platform.OS === 'android') {
  if (UIManager.setLayoutAnimationEnabledExperimental) {
    UIManager.setLayoutAnimationEnabledExperimental(true);
  }
}

const getRandomColor = () => {
  var letters = '0123456789ABCDEF';
  var color = '#';
  for (var i = 0; i < 6; i++) {
    color += letters[Math.floor(Math.random() * 16)];
  }
  return color;
};

const DATA = [
  getRandomColor(),
  getRandomColor(),
  getRandomColor(),
  getRandomColor(),
  getRandomColor(),
];

export default class App extends Component {
  scrollValue = 0;
  append = true;

  state = {
    data: DATA,
  };

  addItem = (top) => {
    const {data} = this.state;
    let newData;
    LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
    if (top) {
      newData = [...data, getRandomColor()];
      this.setState({data: newData});
    } else {
      newData = [getRandomColor(), ...data];
      this.setState({data: newData});
    }
  };

  shouldComponentUpdate() {
    return this.scrollValue === 0 || this.append;
  }

  onScrollBeginDrag = () => {
    this.append = true;
    LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
    this.setState({});
  };

  render() {
    const {data} = this.state;
    return (
      <SafeAreaView style={styles.container}>
        <Button title="ADD ON TOP" onPress={() => this.addItem(true)} />
        <FlatList
          data={data}
          onScrollBeginDrag={this.onScrollBeginDrag}
          renderItem={({item}) => <Item item={item} />}
          keyExtractor={(item) => item}
          inverted
          onScroll={(e) => {
            this.append = false;
            this.scrollValue = e.nativeEvent.contentOffset.y;
          }}
        />
        <Button title="ADD ON BOTTOM" onPress={() => this.addItem(false)} />
      </SafeAreaView>
    );
  }
}

function Item({item}) {
  return (
    <View style={[styles.item, {backgroundColor: item}]}>
      <Text style={styles.title}>{item}</Text>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
  item: {
    backgroundColor: '#f9c2ff',
    padding: 20,
    height: 100,
  },
  title: {
    fontSize: 32,
  },
});

```


问:
Sum values in a list of lists of dictionaries using common key-value pairs
How do I sum duplicate elements in a list of lists of dictionaries?

Sample list:

```<code>data = [
        [
            {'user': 1, 'rating': 0},
            {'user': 2, 'rating': 10},
            {'user': 1, 'rating': 20},
            {'user': 3, 'rating': 10}
        ],
        [
            {'user': 4, 'rating': 4},
            {'user': 2, 'rating': 80},
            {'user': 1, 'rating': 20},
            {'user': 1, 'rating': 10}
        ],
    ]
</code>```

Expected output:

```<code>op = [
        [
            {'user': 1, 'rating': 20},
            {'user': 2, 'rating': 10},
            {'user': 3, 'rating': 10}
        ],
        [
            {'user': 4, 'rating': 4},
            {'user': 2, 'rating': 80},
            {'user': 1, 'rating': 30},
        ],
    ]
</code>```

答:
With pandas:

```<code>>>> import pandas as pd
>>> [pd.DataFrame(dicts).groupby('user', as_index=False, sort=False).sum().to_dict(orient='records') for dicts in data]
[[{'user': 1, 'rating': 20},
  {'user': 2, 'rating': 10},
  {'user': 3, 'rating': 10}],
 [{'user': 4, 'rating': 4},
  {'user': 2, 'rating': 80},
  {'user': 1, 'rating': 30}]]
</code>```

Body:
How do I sum duplicate elements in a list of lists of dictionaries?

Sample list:

data = [
        [
            {'user': 1, 'rating': 0},
            {'user': 2, 'rating': 10},
            {'user': 1, 'rating': 20},
            {'user': 3, 'rating': 10}
        ],
        [
            {'user': 4, 'rating': 4},
            {'user': 2, 'rating': 80},
            {'user': 1, 'rating': 20},
            {'user': 1, 'rating': 10}
        ],
    ]

Expected output:

op = [
        [
            {'user': 1, 'rating': 20},
            {'user': 2, 'rating': 10},
            {'user': 3, 'rating': 10}
        ],
        [
            {'user': 4, 'rating': 4},
            {'user': 2, 'rating': 80},
            {'user': 1, 'rating': 30},
        ],
    ]

Body:
With pandas:

>>> import pandas as pd
>>> [pd.DataFrame(dicts).groupby('user', as_index=False, sort=False).sum().to_dict(orient='records') for dicts in data]
[[{'user': 1, 'rating': 20},
  {'user': 2, 'rating': 10},
  {'user': 3, 'rating': 10}],
 [{'user': 4, 'rating': 4},
  {'user': 2, 'rating': 80},
  {'user': 1, 'rating': 30}]]


问:
C / Getting line string from text file and storing them in array/pointer
I want to get all lines from the text file and store them in my char** pointer (array of strings). The problem is that when I try to set indices for pointer's strings, the program assigns the last scanned sentence for all indices.

```<code>#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_LINE 10000

int main()
{
    FILE *fp = NULL;
    char line[MAX_LINE];
    char** lines = (char**) malloc(10000*200*sizeof(char));

    int count = 0;

    fp = fopen("test.txt","r");

    while(fgets(line,10000,fp)) {
      lines[count] = line;
      count++;
    }

    fclose(fp);

    for(int i =0; i<2000;i++){
      printf("%s",lines[i]);
    }

    return 0;
}

</code>```

lets assume test.txt is like this:

```<code>Alice was beginning to get very tired of sitting by her sister on the
bank, and of having nothing to do: once or twice she had peeped into the
book her sister was reading, but it had no pictures or conversations in
it, and what is the use of a book, thought Alice without pictures or
conversations?
</code>```

When I print like this, every time I get the last sentence (in this case conversations? ) in my text file. However, I want to set every scanned sentence from the text file to the different index in my char**. For example, I want to set like this:

```<code>lines[0] gives "Alice was beginning to get very tired of sitting by her sister on the"
lines[1] gives "bank, and of having nothing to do: once or twice she had peeped into the"
and so on.
</code>```

答:
strdup resolve the issue, free resources as said by Adrian when finished.

```<code>int main()
{
   FILE *fp = NULL;
   char line[MAX_LINE];
   char** lines = (char**) malloc(10000*200*sizeof(char));

   int count = 0;

   fp = fopen("test.txt","r");

   while(fgets(line,10000,fp)) {
      lines[count] = strdup(line);
      count++;
   }

   fclose(fp);

   for(int i =0; i<count;i++){
      printf("%s",lines[i]);
   }

   for (int i = 0; i < count; ++i) free(lines[i]);
   free(lines);

   return 0;
}
</code>```

If you are looking for better performance look at my repo (https://github.com/PatrizioColomba/strvect)

Body:
I want to get all lines from the text file and store them in my char** pointer (array of strings). The problem is that when I try to set indices for pointer's strings, the program assigns the last scanned sentence for all indices.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_LINE 10000

int main()
{
    FILE *fp = NULL;
    char line[MAX_LINE];
    char** lines = (char**) malloc(10000*200*sizeof(char));

    int count = 0;

    fp = fopen("test.txt","r");

    while(fgets(line,10000,fp)) {
      lines[count] = line;
      count++;
    }

    fclose(fp);

    for(int i =0; i<2000;i++){
      printf("%s",lines[i]);
    }

    return 0;
}

lets assume test.txt is like this:

Alice was beginning to get very tired of sitting by her sister on the
bank, and of having nothing to do: once or twice she had peeped into the
book her sister was reading, but it had no pictures or conversations in
it, and what is the use of a book, thought Alice without pictures or
conversations?

When I print like this, every time I get the last sentence (in this case conversations? ) in my text file. However, I want to set every scanned sentence from the text file to the different index in my char**. For example, I want to set like this:

lines[0] gives "Alice was beginning to get very tired of sitting by her sister on the"
lines[1] gives "bank, and of having nothing to do: once or twice she had peeped into the"
and so on.

Body:
strdup resolve the issue, free resources as said by Adrian when finished.

int main()
{
   FILE *fp = NULL;
   char line[MAX_LINE];
   char** lines = (char**) malloc(10000*200*sizeof(char));

   int count = 0;

   fp = fopen("test.txt","r");

   while(fgets(line,10000,fp)) {
      lines[count] = strdup(line);
      count++;
   }

   fclose(fp);

   for(int i =0; i<count;i++){
      printf("%s",lines[i]);
   }

   for (int i = 0; i < count; ++i) free(lines[i]);
   free(lines);

   return 0;
}

If you are looking for better performance look at my repo (https://github.com/PatrizioColomba/strvect)


问:
node-rsa decryption doesn't work
I tried to implement rsa public key system.
the server was implemented with node-js and using node-rsa library to encrypt/decrypt rsa.

and the client was implemented with java.

in authentification part, the client(java) encrypt client's id and password with the public key of the server, and post to server with http post.

so server could receive them perfectly, but in node-rsa decrypt function, nothing occurs and http request denied with 500

client code below

```<code>public static boolean REQ_AUTH(String user_id, String user_pw )
{
    InputStreamReader ret = null;
    try
    {
        JSONObject obj = new JSONObject();
        obj.put("user_id", "waps12b");
        obj.put("user_pw", "password");

        String cipher = VoteUtility.EncryptRSA(obj.toString());
        ret = PostHTTP(API_URL.AUTH, "cipher=" + cipher);
        JSONParser parser = new JSONParser();
        JSONObject json = (JSONObject)parser.parse(ret);
        ret.close();

        String result = (String)json.get(JSON_KEY.Result);
        if(result.equals("FALSE"))
            return false;

        VoteUtility.Setting((String)json.get(JSON_KEY.Kp));
        RN = (String)json.get(JSON_KEY.RN);
        return true;
    }catch(Exception ex)
    {
        ex.printStackTrace();
    }
    return false;
}
</code>```

server code below

```<code>router.all('/auth', function(req, res){
    var cipher = req.body.cipher;
    console.log('[cipher] : ' + cipher);

    var buf = new Buffer(cipher,'hex');
    console.log('[buf] : ' + buf.toString('hex'));

    var decrypted = key.decrypt(buf);
    console.log('[plain] : ' + decrypted);
}
</code>```

and server log below

```<code>[cipher] : 46641844ffffff8d18ffffffb6ffffff8d6fffffffcf37ffffffd3ffffffa520721407ffffffbf7810ffffffc87d7925ffffffae16ffffffc9620f356872ffffff892828ffffffb533ffffffb324ffffffffffffffeefffffffa6b78ffffff8effffffb1ffffffb3ffffffdd681affffffae405d105affffff9626ffffff85fffffff8ffffffc9fffffff22c69ffffffa87efffffff8ffffffe64e082fffffffd247500f176dffffffedffffffcc6c5affffffc712ffffff9136ffffffbe26672b206cffffffa56dffffffa4ffffff85ffffffc0ffffffff0b6936fffffffb61ffffff8a0f3effffff8effffff965d5851ffffffaeffffff9dffffffb1417c57ffffffbfffffffee5affffff80ffffff9bffffffac0bffffff9cffffffaf6377327d
[buf] : 46641844ffffff8d18ffffffb6ffffff8d6fffffffcf37ffffffd3ffffffa520721407ffffffbf7810ffffffc87d7925ffffffae16ffffffc9620f356872ffffff892828ffffffb533ffffffb324ffffffffffffffeefffffffa6b78ffffff8effffffb1ffffffb3ffffffdd681affffffae405d105affffff9626ffffff85fffffff8ffffffc9fffffff22c69ffffffa87efffffff8ffffffe64e082fffffffd247500f176dffffffedffffffcc6c5affffffc712ffffff9136ffffffbe26672b206cffffffa56dffffffa4ffffff85ffffffc0ffffffff0b6936fffffffb61ffffff8a0f3effffff8effffff965d5851ffffffaeffffff9dffffffb1417c57ffffffbfffffffee5affffff80ffffff9bffffffac0bffffff9cffffffaf6377327d
POST /api/auth 500 421.025 ms - 1158
</code>```

how can i fix it?

答:
try it in node js    </p>

```<code>const NodeRSA   = require('node-rsa');
const key       = new NodeRSA('-----BEGIN RSA PRIVATE KEY-----PRIVATE_key-----
END RSA PRIVATE KEY-----");
const text = 'helo or array';
const encrypted = key.encrypt(text, 'base64');
console.log('encrypted: ', encrypted);
</code>```

ContentLicense: CC BY-SA 3.0

Title: node-rsa decryption doesn't work

Body:
I tried to implement rsa public key system.
the server was implemented with node-js and using node-rsa library to encrypt/decrypt rsa.

and the client was implemented with java.

in authentification part, the client(java) encrypt client's id and password with the public key of the server, and post to server with http post.

so server could receive them perfectly, but in node-rsa decrypt function, nothing occurs and http request denied with 500

client code below

public static boolean REQ_AUTH(String user_id, String user_pw )
{
    InputStreamReader ret = null;
    try
    {
        JSONObject obj = new JSONObject();
        obj.put("user_id", "waps12b");
        obj.put("user_pw", "password");

        String cipher = VoteUtility.EncryptRSA(obj.toString());
        ret = PostHTTP(API_URL.AUTH, "cipher=" + cipher);
        JSONParser parser = new JSONParser();
        JSONObject json = (JSONObject)parser.parse(ret);
        ret.close();

        String result = (String)json.get(JSON_KEY.Result);
        if(result.equals("FALSE"))
            return false;

        VoteUtility.Setting((String)json.get(JSON_KEY.Kp));
        RN = (String)json.get(JSON_KEY.RN);
        return true;
    }catch(Exception ex)
    {
        ex.printStackTrace();
    }
    return false;
}

server code below

router.all('/auth', function(req, res){
    var cipher = req.body.cipher;
    console.log('[cipher] : ' + cipher);

    var buf = new Buffer(cipher,'hex');
    console.log('[buf] : ' + buf.toString('hex'));

    var decrypted = key.decrypt(buf);
    console.log('[plain] : ' + decrypted);
}

and server log below

[cipher] : 46641844ffffff8d18ffffffb6ffffff8d6fffffffcf37ffffffd3ffffffa520721407ffffffbf7810ffffffc87d7925ffffffae16ffffffc9620f356872ffffff892828ffffffb533ffffffb324ffffffffffffffeefffffffa6b78ffffff8effffffb1ffffffb3ffffffdd681affffffae405d105affffff9626ffffff85fffffff8ffffffc9fffffff22c69ffffffa87efffffff8ffffffe64e082fffffffd247500f176dffffffedffffffcc6c5affffffc712ffffff9136ffffffbe26672b206cffffffa56dffffffa4ffffff85ffffffc0ffffffff0b6936fffffffb61ffffff8a0f3effffff8effffff965d5851ffffffaeffffff9dffffffb1417c57ffffffbfffffffee5affffff80ffffff9bffffffac0bffffff9cffffffaf6377327d
[buf] : 46641844ffffff8d18ffffffb6ffffff8d6fffffffcf37ffffffd3ffffffa520721407ffffffbf7810ffffffc87d7925ffffffae16ffffffc9620f356872ffffff892828ffffffb533ffffffb324ffffffffffffffeefffffffa6b78ffffff8effffffb1ffffffb3ffffffdd681affffffae405d105affffff9626ffffff85fffffff8ffffffc9fffffff22c69ffffffa87efffffff8ffffffe64e082fffffffd247500f176dffffffedffffffcc6c5affffffc712ffffff9136ffffffbe26672b206cffffffa56dffffffa4ffffff85ffffffc0ffffffff0b6936fffffffb61ffffff8a0f3effffff8effffff965d5851ffffffaeffffff9dffffffb1417c57ffffffbfffffffee5affffff80ffffff9bffffffac0bffffff9cffffffaf6377327d
POST /api/auth 500 421.025 ms - 1158

how can i fix it?

Body:
try it in node js

const NodeRSA   = require('node-rsa');
const key       = new NodeRSA('-----BEGIN RSA PRIVATE KEY-----PRIVATE_key-----
END RSA PRIVATE KEY-----");
const text = 'helo or array';
const encrypted = key.encrypt(text, 'base64');
console.log('encrypted: ', encrypted);


问:
Jquery $(this) node and its use
I am trying to understand some jquery code that uses a $(this) node.  What is it used for and when can it be used?

```<code>$("li").hover(border, noBorder);
function border()
{
    $(this).css("border", "1px solid black");
}
</code>```

答: $(this) just wraps whatever this refers to in a jQuery object.  It's commonly used in callbacks to refer to the element that fired the event, amongst other things.

Title: Jquery $(this) node and its use

Body:
I am trying to understand some jquery code that uses a $(this) node.  What is it used for and when can it be used?

$("li").hover(border, noBorder);
function border()
{
    $(this).css("border", "1px solid black");
}


问:
RecyclerView not appearing
Hi I just set up this RecyclerView and can't find what's wrong. Thanks in advance. I'm sure the RecyclerView is showing up though their is a faint shade on the main activity screen where I can pull down and pull up. I think the problem may revolve around this part of my line activity:

```<code>    getSupportActionBar().setTitle(null);
    recyclerView = (RecyclerView) findViewById(R.id.line_list);
    adapter=new MyAdapter(getApplicationContext(),getData());
    recyclerView.setAdapter(adapter);
    recyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
</code>```

Activity code;

```<code>import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;

import java.util.ArrayList;
import java.util.List;

public class Lines extends AppCompatActivity {

private RecyclerView recyclerView;
private MyAdapter adapter;

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

    Toolbar myToolbar = (Toolbar) findViewById(R.id.toolbar_top);
    setSupportActionBar(myToolbar);
    getSupportActionBar().setTitle(null);
    recyclerView = (RecyclerView) findViewById(R.id.line_list);
    adapter=new MyAdapter(getApplicationContext(),getData());
    recyclerView.setAdapter(adapter);
    recyclerView.setLayoutManager(new     LinearLayoutManager(getApplicationContext()));

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main_item, menu);
    return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int i = item.getItemId();
    switch (i) {
        case R.id.action_search:
            Intent s = new Intent(this, SearchActivity.class);
            startActivity(s);
            return true;

        case R.id.action_add:
            Intent a = new Intent(this, AddLine.class);
            startActivity(a);
            return true;

        case R.id.action_wheel:
            Intent w = new Intent(this, Settings.class);
            startActivity(w);
            return true;

    }
    return super.onOptionsItemSelected(item);
}

public static  List<Information> getData(){

    List<Information> data=new ArrayList<>();

    int[] icons={R.drawable.ic_place_black_24dp,R.drawable.ic_place_black_24dp2,
            R.drawable.ic_place_black_24dp3};

    String[] titles={"Homework","Birthday","Index"};

    for(int i=0;i<titles.length && i<icons.length;i++){

        Information current=new Information();

        current.iconId=icons[i];

        current.title=titles[i];

        data.add(current);

    }
    return data;
}

}
</code>```

.xml code:

```<code><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".Lines">

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar_top"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#000000"
    android:minHeight="?attr/actionBarSize">

    <TextView
        android:id="@+id/toolbar_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="LINES"
        android:textColor="#ffffff"
        android:textSize="25sp" />
</android.support.v7.widget.Toolbar>

<android.support.v7.widget.RecyclerView
    android:id="@+id/line_list"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

</android.support.v7.widget.RecyclerView>

</LinearLayout>
</code>```

Row elements definitions Activity code:

```<code>package com.example.patri.index01;

public class Information {

int iconId;

String title;

}
</code>```

Adapter Activity code:

```<code>import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.Collections;
import java.util.List;

public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> {
private LayoutInflater inflater;
List<Information> data= Collections.emptyList();
public MyAdapter(Context context, List<Information> data){
    inflater=LayoutInflater.from(context);
    this.data=data;

}
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

    View view=inflater.inflate(R.layout.custom_row, parent,false);
    MyViewHolder holder=new MyViewHolder(view);
    return holder;
}

@Override
public void onBindViewHolder(MyViewHolder holder, int position) {

    Information current=data.get(position);

    holder.title.setText(current.title);
    holder.icon.setImageResource(current.iconId);

}

@Override
public int getItemCount() {
    return 0;
}

class MyViewHolder extends RecyclerView.ViewHolder{
    TextView title;

    ImageView icon;

    public MyViewHolder(View itemView) {

        super(itemView);

        title= (TextView)itemView.findViewById(R.id.listText);

        icon= (ImageView) itemView.findViewById(R.id.listIcon);

    }
}
}
</code>```

Row .xml code:

```<code><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
    android:id="@+id/listIcon"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/ic_place_black_24dp"
    android:padding="8dp"/>
<TextView
    android:id="@+id/listText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Dummy text"
    android:padding="8dp"
    android:textColor="#000000"/>
</LinearLayout>
</code>```

答: Set the layout_height of the linearlayout in row.xml to wrap_content instead of match_parent. That is why it fills the whole screen.</p>

Title: RecyclerView not appearing

Body:
Hi I just set up this RecyclerView and can't find what's wrong. Thanks in advance. I'm sure the RecyclerView is showing up though their is a faint shade on the main activity screen where I can pull down and pull up. I think the problem may revolve around this part of my line activity:

    getSupportActionBar().setTitle(null);
    recyclerView = (RecyclerView) findViewById(R.id.line_list);
    adapter=new MyAdapter(getApplicationContext(),getData());
    recyclerView.setAdapter(adapter);
    recyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));

Activity code;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;

import java.util.ArrayList;
import java.util.List;

public class Lines extends AppCompatActivity {

private RecyclerView recyclerView;
private MyAdapter adapter;

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

    Toolbar myToolbar = (Toolbar) findViewById(R.id.toolbar_top);
    setSupportActionBar(myToolbar);
    getSupportActionBar().setTitle(null);
    recyclerView = (RecyclerView) findViewById(R.id.line_list);
    adapter=new MyAdapter(getApplicationContext(),getData());
    recyclerView.setAdapter(adapter);
    recyclerView.setLayoutManager(new     LinearLayoutManager(getApplicationContext()));

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main_item, menu);
    return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int i = item.getItemId();
    switch (i) {
        case R.id.action_search:
            Intent s = new Intent(this, SearchActivity.class);
            startActivity(s);
            return true;

        case R.id.action_add:
            Intent a = new Intent(this, AddLine.class);
            startActivity(a);
            return true;

        case R.id.action_wheel:
            Intent w = new Intent(this, Settings.class);
            startActivity(w);
            return true;

    }
    return super.onOptionsItemSelected(item);
}

public static  List<Information> getData(){

    List<Information> data=new ArrayList<>();

    int[] icons={R.drawable.ic_place_black_24dp,R.drawable.ic_place_black_24dp2,
            R.drawable.ic_place_black_24dp3};

    String[] titles={"Homework","Birthday","Index"};

    for(int i=0;i<titles.length && i<icons.length;i++){

        Information current=new Information();

        current.iconId=icons[i];

        current.title=titles[i];

        data.add(current);

    }
    return data;
}

}

.xml code:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".Lines">

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar_top"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#000000"
    android:minHeight="?attr/actionBarSize">

    <TextView
        android:id="@+id/toolbar_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="LINES"
        android:textColor="#ffffff"
        android:textSize="25sp" />
</android.support.v7.widget.Toolbar>

<android.support.v7.widget.RecyclerView
    android:id="@+id/line_list"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

</android.support.v7.widget.RecyclerView>

</LinearLayout>

Row elements definitions Activity code:

package com.example.patri.index01;

public class Information {

int iconId;

String title;

}

Adapter Activity code:

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.Collections;
import java.util.List;

public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> {
private LayoutInflater inflater;
List<Information> data= Collections.emptyList();
public MyAdapter(Context context, List<Information> data){
    inflater=LayoutInflater.from(context);
    this.data=data;

}
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

    View view=inflater.inflate(R.layout.custom_row, parent,false);
    MyViewHolder holder=new MyViewHolder(view);
    return holder;
}

@Override
public void onBindViewHolder(MyViewHolder holder, int position) {

    Information current=data.get(position);

    holder.title.setText(current.title);
    holder.icon.setImageResource(current.iconId);

}

@Override
public int getItemCount() {
    return 0;
}

class MyViewHolder extends RecyclerView.ViewHolder{
    TextView title;

    ImageView icon;

    public MyViewHolder(View itemView) {

        super(itemView);

        title= (TextView)itemView.findViewById(R.id.listText);

        icon= (ImageView) itemView.findViewById(R.id.listIcon);

    }
}
}

Row .xml code:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
    android:id="@+id/listIcon"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/ic_place_black_24dp"
    android:padding="8dp"/>
<TextView
    android:id="@+id/listText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Dummy text"
    android:padding="8dp"
    android:textColor="#000000"/>
</LinearLayout>


问:
Typescript enumeration instance type
This must be something extremelly simple but couldn't find the words to search here on stackoverflow.

Basically I would like to be able to typehint a variable being of an enumeration type. Something like this:

```<code>enum RecurringEventDeleteOptions {
  THIS_EVENT = 1,
  THIS_AND_FUTURE_EVENTS = 2,
  ALL_EVENTS = 3,
}

const foo: RecurringEventDeleteOptions = RecurringEventDeleteOptions;
</code>```

I get an error from the variable foo (Type 'typeof RecurringEventDeleteOptions' is not assignable to type 'RecurringEventDeleteOptions')

Is there a way to tell that foo will be of type RecurringEventDeleteOptions?

playground

Why? Because I have a VueJS template that will have to access these options. An example:

```<code><template>
  <div> {{ foo.THIS_EVENT }} </div>
</template>

<script lang="ts">

@Component
export default class FooClass extends Vue {
  public foo = RecurringEventDeleteOptions;
}
</script>
</code>```

答:
You should assign one concrete value of the enum to that variable, for example:

```<code>const a: RecurringEventDeleteOptions = RecurringEventDeleteOptions.THIS_EVENT;
</code>```

Playground Link

Title: Typescript enumeration instance type

Body:
This must be something extremelly simple but couldn't find the words to search here on stackoverflow.

Basically I would like to be able to typehint a variable being of an enumeration type. Something like this:

enum RecurringEventDeleteOptions {
  THIS_EVENT = 1,
  THIS_AND_FUTURE_EVENTS = 2,
  ALL_EVENTS = 3,
}

const foo: RecurringEventDeleteOptions = RecurringEventDeleteOptions;

I get an error from the variable foo (Type 'typeof RecurringEventDeleteOptions' is not assignable to type 'RecurringEventDeleteOptions')

Is there a way to tell that foo will be of type RecurringEventDeleteOptions?

playground

Why? Because I have a VueJS template that will have to access these options. An example:

<template>

 {{ foo.THIS_EVENT }}

</template>

Body:
You should assign one concrete value of the enum to that variable, for example:

const a: RecurringEventDeleteOptions = RecurringEventDeleteOptions.THIS_EVENT;

Playground Link


问:
Redirect to a script that uses /dev/tty
I am writing a git hook that might require human input. According to this answer one has to use exec < /dev/tty in that script. This does the job, but now there is no possibility to redirect the standard output to that hook (for test purposes). I guess the problem can be narrowed down to a question: how to send a message to /dev/tty in such a way that another process will read it? Not sure if this is even possible.

Here is the minimum reproducible example:

# file: target.sh

exec < /dev/tty # we want to use /dev/tty
read -p  "Type a message: " message
echo "The message ${message}"

```

<p>I tried several solutions like this:</p>

<pre class="lang-sh prettyprint-override"><code>echo -e "foo\n"| tee /dev/tty | source target.sh
</code>```

And it actually prints the message in the console after the read prompt, but the message variable remains unset. Is there any way to fix it?

答:
You can use expect to achieve the result:

```<code>#!/bin/bash

expect << EOF
spawn bash target.sh
expect {
    "Type a message: " {send "foo\r"; interact}
}
EOF
</code>```

Title: Redirect to a script that uses /dev/tty

Body:
I am writing a git hook that might require human input. According to this answer one has to use exec < /dev/tty in that script. This does the job, but now there is no possibility to redirect the standard output to that hook (for test purposes). I guess the problem can be narrowed down to a question: how to send a message to /dev/tty in such a way that another process will read it? Not sure if this is even possible.

Here is the minimum reproducible example:

# file: target.sh

exec < /dev/tty # we want to use /dev/tty
read -p  "Type a message: " message
echo "The message ${message}"

I tried several solutions like this:

echo -e "foo\n"| tee /dev/tty | source target.sh

And it actually prints the message in the console after the read prompt, but the message variable remains unset. Is there any way to fix it?

Body:
You can use expect to achieve the result:

#!/bin/bash

expect << EOF
spawn bash target.sh
expect {
    "Type a message: " {send "foo\r"; interact}
}
EOF


问:
Scheme Function to remove one list's items from another
I'm trying to create a scheme function which given two lists L1 and L2, will remove any items present in L2 from L1.

I have a small start, but I don't know exactly what else to do.

```<code>(define (remove L1 L2)
(((null? L2) L1))
</code>```

答:
You can simply use SRFI 1's lset-difference:

```<code>(lset-difference = '(1 2 3 4 5) '(3 4 5 5 6))
; => (1 2)
</code>```

The =, in my example, is the comparison function. If your lists contain strings, say, instead of numbers, then you should use string=? in place of =.

Body:
I'm trying to create a scheme function which given two lists L1 and L2, will remove any items present in L2 from L1.

I have a small start, but I don't know exactly what else to do.

(define (remove L1 L2)
(((null? L2) L1))

Body:
You can simply use SRFI 1's lset-difference:

(lset-difference = '(1 2 3 4 5) '(3 4 5 5 6))
; => (1 2)

The =, in my example, is the comparison function. If your lists contain strings, say, instead of numbers, then you should use string=? in place of =.


问:
select query in laravel
I have created a my application in laravel.my sql query is working fine.I'm bit struck with laravel query

```<code>select a.type from chart_table a left join color_codes b on a.type=b.type_id group by a.type
</code>```

For the above query tried as

```<code>DB::table('chart_table')
    ->leftjoin('color_codes','color_codes.type_id','=','chart_table.type')
    ->whereIn('chart_table.user_name',$filter_username_details)
    ->orderBy('color_codes.id', 'asc')
    ->groupBy('chart_table.type')
    ->pluck('chart_table.type')
    ->toArray();
</code>```

I'm getting the error as

```<code>SQLSTATE[42803]: Grouping error: 7 ERROR:  column "color_codes.id" must appear in the GROUP BY clause or be used in an aggregate function<br />
LINE 1: ...le"."type" group by "chart_table"."type" order by "color_cod..
</code>```

What I did wrong in my query

答:
A small change you will need to do in your project database.php

```<code>Go to config/database.php inside connections => mysql => [ 'strict': false ]
</code>```

And your will query will become something like this

```<code>DB::table('chart_table as a')
->select('a.type')
->leftJoin('color_codes as b','b.type_id','=','a.type')
->whereIn('a.user_name',$filter_username_details)
->orderBy('b.id', 'asc')
->groupBy('a.type')
->get()
->toArray();
</code>```

Title: select query in laravel

Body:
I have created a my application in laravel.my sql query is working fine.I'm bit struck with laravel query

select a.type from chart_table a left join color_codes b on a.type=b.type_id group by a.type

For the above query tried as

DB::table('chart_table')
    ->leftjoin('color_codes','color_codes.type_id','=','chart_table.type')
    ->whereIn('chart_table.user_name',$filter_username_details)
    ->orderBy('color_codes.id', 'asc')
    ->groupBy('chart_table.type')
    ->pluck('chart_table.type')
    ->toArray();

I'm getting the error as

SQLSTATE[42803]: Grouping error: 7 ERROR:  column "color_codes.id" must appear in the GROUP BY clause or be used in an aggregate function

LINE 1: ...le"."type" group by "chart_table"."type" order by "color_cod..

What I did wrong in my query

Body:
A small change you will need to do in your project database.php

Go to config/database.php inside connections => mysql => [ 'strict': false ]

And your will query will become something like this

DB::table('chart_table as a')
->select('a.type')
->leftJoin('color_codes as b','b.type_id','=','a.type')
->whereIn('a.user_name',$filter_username_details)
->orderBy('b.id', 'asc')
->groupBy('a.type')
->get()
->toArray();


答:
```<code>import pprint
data = [
        [
            {'user': 1, 'rating': 0},
            {'user': 2, 'rating': 10},
            {'user': 1, 'rating': 20},
            {'user': 3, 'rating': 10}
        ],
        [
            {'user': 4, 'rating': 4},
            {'user': 2, 'rating': 80},
            {'user': 1, 'rating': 20},
            {'user': 1, 'rating': 10}
        ],
    ]

def find(user, l):
    for i, d in enumerate(l):
        if user == d['user']:
            return i
    return -1

data_sum = []

for l in data:
    list_sum = []
    for d in l:
        idx = find(d['user'], list_sum)
        if idx == -1:
            list_sum.append(d)
        else:
            list_sum[idx]['rating'] += d['rating']
    data_sum.append(list_sum)

pprint.pprint(data_sum)
</code>```

Title: Sum values in a list of lists of dictionaries using common key-value pairs


问:
flutter build apk --release command not work
```<code>TYSONs-MacBook-Air:chats jeshurun$ flutter build apk --release
You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64.
 If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
To generate an app bundle, run:
    flutter build appbundle --target-platform android-arm,android-arm64,android-x64
    Learn more on: https://developer.android.com/guide/app-bundle
To split the APKs per ABI, run:
    flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
    Learn more on:  https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
 Plugin project :firebase_core_web not found. Please update settings.gradle.
 Plugin project :cloud_firestore_web not found. Please update settings.gradle.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':device_info:verifyReleaseResources'.
> A failure occurred while executing
com.android.build.gradle.internal.tasks.Workers$ActionFacade
> 1 exception was raised by workers:
 com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
 /Users/jeshurun/.gradle/caches/transforms-2/files-2.1/8caf43a43008a17794fe6e0dd5ac61b7/core-1.1.0/res/values/values.xml:142:5-173:25: AAPT: error: resource android:attr/fontVariationSettings not found.

 /Users/jeshurun/.gradle/caches/transforms-2/files-2.1/8caf43a43008a17794fe6e0dd5ac61b7/core-1.1.0/res/values/values.xml:142:5-173:25: AAPT: error: resource android:attr/ttcIndex not found.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 14s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done                      15.6s
The built failed likely due to AndroidX incompatibilities in a plugin.
The tool is about to try using Jetfier to solve the incompatibility.
Building plugin agora_rtc_engine...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done                    1.7s

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':compileReleaseAidl'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/Users/jeshurun/flutter/.pub-cache/hosted/pub.dartlang.org/agora_rtc_engine-1.0.12/android/local.properties'.
</code>```

Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

Get more help at https://help.gradle.org

BUILD FAILED in 1s

The plugin agora_rtc_engine could not be built due to the issue above.

答:
First, flutter build apk by default uses argument --release.

Next, May be you are using AndroidX packages within your app but your app not migrated to use AndroidX. To ensure that:

In an app or module project, the file android/gradle.properties or .android/gradle.properties must contain:

```<code>android.useAndroidX=true
android.enableJetifier=true
</code>```

Or else maybe because your compileSdkVersion is lower than 28,

Try setting compileSdkVersion 28 or 29 to app/build.gradle. If this not solved your problem may be one of your plugin is the problem. Ofcourse you can edit your plugin build gradle but I do not recommend that.

First, Try upgrading packages that are not updated. If not upgarded those packages, you can follow below by opening flutter root android directory in android studio.

Steps:

Go to External libraries

Locate the library that raised the issue

Open it's app/build.gradle

Update the compileSdkVersion to 28 or 29

Also you can cloned the packages that causes the problem and do aboves and push it to github and in the pubspec.yaml, access from github like below:

```<code>dependencies:
  #...
  repo_name:
    git:
      url: git://github.com/your_github/repo_name.git
</code>```

If none of them worked, worth trying below options :D,

Flutter clean / Deleted build folder

Deleted pubspec.lock, .packages, .flutter-plugins

Flutter pub cache repair

Ensured compileSdkVersion is 28 in app/build.gradle

finally, try Deleting flutter/.pub-cache

Body:
TYSONs-MacBook-Air:chats jeshurun$ flutter build apk --release
You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64.
 If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
To generate an app bundle, run:
    flutter build appbundle --target-platform android-arm,android-arm64,android-x64
    Learn more on: https://developer.android.com/guide/app-bundle
To split the APKs per ABI, run:
    flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
    Learn more on:  https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
 Plugin project :firebase_core_web not found. Please update settings.gradle.
 Plugin project :cloud_firestore_web not found. Please update settings.gradle.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':device_info:verifyReleaseResources'.
> A failure occurred while executing
com.android.build.gradle.internal.tasks.Workers$ActionFacade
> 1 exception was raised by workers:
 com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
 /Users/jeshurun/.gradle/caches/transforms-2/files-2.1/8caf43a43008a17794fe6e0dd5ac61b7/core-1.1.0/res/values/values.xml:142:5-173:25: AAPT: error: resource android:attr/fontVariationSettings not found.

 /Users/jeshurun/.gradle/caches/transforms-2/files-2.1/8caf43a43008a17794fe6e0dd5ac61b7/core-1.1.0/res/values/values.xml:142:5-173:25: AAPT: error: resource android:attr/ttcIndex not found.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 14s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done                      15.6s
The built failed likely due to AndroidX incompatibilities in a plugin.
The tool is about to try using Jetfier to solve the incompatibility.
Building plugin agora_rtc_engine...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done                    1.7s

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':compileReleaseAidl'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/Users/jeshurun/flutter/.pub-cache/hosted/pub.dartlang.org/agora_rtc_engine-1.0.12/android/local.properties'.

Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

Get more help at https://help.gradle.org

BUILD FAILED in 1s

The plugin agora_rtc_engine could not be built due to the issue above.

Body:
First, flutter build apk by default uses argument --release.

Next, May be you are using AndroidX packages within your app but your app not migrated to use AndroidX. To ensure that:

In an app or module project, the file android/gradle.properties or .android/gradle.properties must contain:

android.useAndroidX=true
android.enableJetifier=true

Or else maybe because your compileSdkVersion is lower than 28,

Try setting compileSdkVersion 28 or 29 to app/build.gradle. If this not solved your problem may be one of your plugin is the problem. Ofcourse you can edit your plugin build gradle but I do not recommend that.

First, Try upgrading packages that are not updated. If not upgarded those packages, you can follow below by opening flutter root android directory in android studio.

Steps:

Go to External libraries

Locate the library that raised the issue

Open it's app/build.gradle

Update the compileSdkVersion to 28 or 29

Also you can cloned the packages that causes the problem and do aboves and push it to github and in the pubspec.yaml, access from github like below:

dependencies:
  #...
  repo_name:
    git:
      url: git://github.com/your_github/repo_name.git

If none of them worked, worth trying below options :D,

Flutter clean / Deleted build folder

Deleted pubspec.lock, .packages, .flutter-plugins

Flutter pub cache repair

Ensured compileSdkVersion is 28 in app/build.gradle

finally, try Deleting flutter/.pub-cache