问:
RangeError (index): Invalid value: Not in inclusive range 0..12: 13 during flutter null-safety migration
I'm following this guide to migrate my flutter project to null safety.

At step 2 when issuing the command

```<code>$ dart migrate
</code>```

Also I'm wondering if it's normal that there are no issues found during project analysis:

```<code>Migrating /home/chrei/code/insight_me

See https://dart.dev/go/null-safety-migration for a migration guide.

Analyzing project...
[---/]No analysis issues found.
</code>```

Below I get an error during Compiling instrumentation information:

```<code>Generating migration suggestions...
[---]

Compiling instrumentation information...
[----------------------------------------------------------\]
RangeError (index): Invalid value: Not in inclusive range 0..12: 13
    #0      List.[] (dart:core-patch/array.dart:268:52)
    #1      BestPracticesVerifier._targetKindsFor (package:analyzer/src/error/best_practices_verifier.dart:1582:38)
    #2      BestPracticesVerifier.visitAnnotation (package:analyzer/src/error/best_practices_verifier.dart:250:17)
    #3      AnnotationImpl.accept (package:analyzer/src/dart/ast/ast.dart:280:49)
    #4      NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:7611:20)
    #5      AnnotatedNodeImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:148:17)
    #6      ClassDeclarationImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:1559:11)
    #7      RecursiveAstVisitor.visitClassDeclaration (package:analyzer/dart/ast/visitor.dart:707:10)
    #8      BestPracticesVerifier.visitClassDeclaration (package:analyzer/src/error/best_practices_verifier.dart:320:13)
    #9      ClassDeclarationImpl.accept (package:analyzer/src/dart/ast/ast.dart:1536:49)
    #10     NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:7611:20)
    #11     CompilationUnitImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:2141:21)
    #12     RecursiveAstVisitor.visitCompilationUnit (package:analyzer/dart/ast/visitor.dart:731:10)
    #13     CompilationUnitImpl.accept (package:analyzer/src/dart/ast/ast.dart:2134:49)
    #14     LibraryAnalyzer._computeHints (package:analyzer/src/dart/analysis/library_analyzer.dart:281:10)
    #15     LibraryAnalyzer.analyzeSync.<anonymous closure> (package:analyzer/src/dart/analysis/library_analyzer.dart:167:9)
    #16     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:397:8)
    #17     LibraryAnalyzer.analyzeSync (package:analyzer/src/dart/analysis/library_analyzer.dart:166:13)
    #18     LibraryAnalyzer.analyze (package:analyzer/src/dart/analysis/library_analyzer.dart:107:12)
    #19     AnalysisDriver._computeResolvedLibrary2.<anonymous closure> (package:analyzer/src/dart/analysis/driver.dart:1416:65)
    #20     PerformanceLog.run (package:analyzer/src/dart/analysis/performance_logger.dart:32:15)
    #21     AnalysisDriver._computeResolvedLibrary2 (package:analyzer/src/dart/analysis/driver.dart:1402:20)
    #22     AnalysisDriver._computeResolvedLibrary.<anonymous closure> (package:analyzer/src/dart/analysis/driver.dart:1395:15)
    #23     _rootRun (dart:async/zone.dart:1354:13)
    #24     _CustomZone.run (dart:async/zone.dart:1258:19)
    #25     _runZoned (dart:async/zone.dart:1788:10)
    #26     runZoned (dart:async/zone.dart:1710:10)
    #27     NullSafetyUnderstandingFlag.enableNullSafetyTypes (package:analyzer/dart/element/null_safety_understanding_flag.dart:42:12)
    #28     AnalysisDriver._computeResolvedLibrary (package:analyzer/src/dart/analysis/driver.dart:1394:40)
    #29     AnalysisDriver.performWork (package:analyzer/src/dart/analysis/driver.dart:964:22)
    #30     AnalysisDriverScheduler._run (package:analyzer/src/dart/analysis/driver.dart:2018:24)
    <asynchronous suspension>
</code>```

Dart version:

```<code>Dart SDK version: 2.12.4 (stable) (Unknown timestamp) on "linux_x64"
</code>```

SDK constraints:

```<code>environment:
  sdk: ">=2.6.0 <3.0.0"
</code>```

Flutter Doctor summary (to see all details, run flutter doctor -v):

```<code>[✓] Flutter (Channel beta, 2.6.0-5.2.pre, on Ubuntu 21.04 5.11.0-36-generic, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Android Studio (version 4.2)
[✓] Android Studio (version 2020.3)
[✓] Connected device (1 available)
! Doctor found issues in 1 category.
</code>```

Any help is appreciated!

答:
Updating the Dart SDK to the latest version solves it.

This issue was discussed and solved here https://github.com/dart-lang/sdk/issues/46183

Body:
I'm following this guide to migrate my flutter project to null safety.

At step 2 when issuing the command

$ dart migrate

Also I'm wondering if it's normal that there are no issues found during project analysis:

Migrating /home/chrei/code/insight_me

See https://dart.dev/go/null-safety-migration for a migration guide.

Analyzing project...
[---/]No analysis issues found.

Below I get an error during Compiling instrumentation information:

Generating migration suggestions...
[---]

Compiling instrumentation information...
[----------------------------------------------------------\]
RangeError (index): Invalid value: Not in inclusive range 0..12: 13
    #0      List.[] (dart:core-patch/array.dart:268:52)
    #1      BestPracticesVerifier._targetKindsFor (package:analyzer/src/error/best_practices_verifier.dart:1582:38)
    #2      BestPracticesVerifier.visitAnnotation (package:analyzer/src/error/best_practices_verifier.dart:250:17)
    #3      AnnotationImpl.accept (package:analyzer/src/dart/ast/ast.dart:280:49)
    #4      NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:7611:20)
    #5      AnnotatedNodeImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:148:17)
    #6      ClassDeclarationImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:1559:11)
    #7      RecursiveAstVisitor.visitClassDeclaration (package:analyzer/dart/ast/visitor.dart:707:10)
    #8      BestPracticesVerifier.visitClassDeclaration (package:analyzer/src/error/best_practices_verifier.dart:320:13)
    #9      ClassDeclarationImpl.accept (package:analyzer/src/dart/ast/ast.dart:1536:49)
    #10     NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:7611:20)
    #11     CompilationUnitImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:2141:21)
    #12     RecursiveAstVisitor.visitCompilationUnit (package:analyzer/dart/ast/visitor.dart:731:10)
    #13     CompilationUnitImpl.accept (package:analyzer/src/dart/ast/ast.dart:2134:49)
    #14     LibraryAnalyzer._computeHints (package:analyzer/src/dart/analysis/library_analyzer.dart:281:10)
    #15     LibraryAnalyzer.analyzeSync.<anonymous closure> (package:analyzer/src/dart/analysis/library_analyzer.dart:167:9)
    #16     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:397:8)
    #17     LibraryAnalyzer.analyzeSync (package:analyzer/src/dart/analysis/library_analyzer.dart:166:13)
    #18     LibraryAnalyzer.analyze (package:analyzer/src/dart/analysis/library_analyzer.dart:107:12)
    #19     AnalysisDriver._computeResolvedLibrary2.<anonymous closure> (package:analyzer/src/dart/analysis/driver.dart:1416:65)
    #20     PerformanceLog.run (package:analyzer/src/dart/analysis/performance_logger.dart:32:15)
    #21     AnalysisDriver._computeResolvedLibrary2 (package:analyzer/src/dart/analysis/driver.dart:1402:20)
    #22     AnalysisDriver._computeResolvedLibrary.<anonymous closure> (package:analyzer/src/dart/analysis/driver.dart:1395:15)
    #23     _rootRun (dart:async/zone.dart:1354:13)
    #24     _CustomZone.run (dart:async/zone.dart:1258:19)
    #25     _runZoned (dart:async/zone.dart:1788:10)
    #26     runZoned (dart:async/zone.dart:1710:10)
    #27     NullSafetyUnderstandingFlag.enableNullSafetyTypes (package:analyzer/dart/element/null_safety_understanding_flag.dart:42:12)
    #28     AnalysisDriver._computeResolvedLibrary (package:analyzer/src/dart/analysis/driver.dart:1394:40)
    #29     AnalysisDriver.performWork (package:analyzer/src/dart/analysis/driver.dart:964:22)
    #30     AnalysisDriverScheduler._run (package:analyzer/src/dart/analysis/driver.dart:2018:24)
    <asynchronous suspension>

Dart version:

Dart SDK version: 2.12.4 (stable) (Unknown timestamp) on "linux_x64"

SDK constraints:

environment:
  sdk: ">=2.6.0 <3.0.0"

Flutter Doctor summary (to see all details, run flutter doctor -v):

[✓] Flutter (Channel beta, 2.6.0-5.2.pre, on Ubuntu 21.04 5.11.0-36-generic, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Android Studio (version 4.2)
[✓] Android Studio (version 2020.3)
[✓] Connected device (1 available)
! Doctor found issues in 1 category.

Any help is appreciated!


来源: stackexchange

问:
Elementary OS - LibreOffice/OpenOffice conflict, Dpkg error (unmet dependencies) - stuck in a loop
I have been looking at multiple pages for a few hours now but still no luck in solving this. I installed OpenOffice then tried to install LibreOffice-Draw through the app-center but encountered a problem (the file didn't install and kept cutting out). I went into the terminal and was met with these errors after trying to use apt-get with anything:

```<code>You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies.
 libreoffice-core : Depends: libreoffice-common (> 1:5.1.6~rc2) but it is not going to be installed
 libreoffice-style-galaxy : Depends: libreoffice-common (= 1:5.1.6~rc2-0ubuntu1~xenial1) but it is not going to be installed
 libreoffice-style-human : Depends: libreoffice-common (= 1:5.1.6~rc2-0ubuntu1~xenial1) but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
</code>```

Running that and trying to install libreoffice-common results in:

```<code>Preparing to unpack .../libreoffice-common_1%3a5.1.6~rc2-0ubuntu1~xenial1_all.deb ...
Unpacking libreoffice-common (1:5.1.6~rc2-0ubuntu1~xenial1) ...
dpkg: error processing archive /var/cache/apt/archives/libreoffice-common_1%3a5.1.6~rc2-0ubuntu1~xenial1_all.deb (--unpack):
 trying to overwrite '/usr/bin/soffice', which is also in package openoffice-debian-menus 4.1.3-9783
rmdir: failed to remove '/var/lib/libreoffice/share/prereg/': No such file or directory
rmdir: failed to remove '/var/lib/libreoffice/share/': No such file or directory
rmdir: failed to remove '/var/lib/libreoffice/program/': No such file or directory
rmdir: failed to remove '/var/lib/libreoffice': No such file or directory
rmdir: failed to remove '/var/lib/libreoffice': No such file or directory
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for shared-mime-info (1.5-2ubuntu0.1) ...
Unknown media type in type 'all/all'
Unknown media type in type 'all/allfiles'
Processing triggers for desktop-file-utils (0.22-1ubuntu5.1+elementary2~ubuntu0.4.1) ...
Processing triggers for bamfdaemon (0.5.3~bzr0+16.04.20160824-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for gnome-menus (3.13.3-6ubuntu3.1) ...
Processing triggers for mime-support (3.59ubuntu1) ...
Processing triggers for hicolor-icon-theme (0.15-0ubuntu1) ...
Processing triggers for gnome-icon-theme (3.12.0-1ubuntu3) ...
Errors were encountered while processing:
 /var/cache/apt/archives/libreoffice-common_1%3a5.1.6~rc2-0ubuntu1~xenial1_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
```
```

<p>Trying to purge OpenOffice -</p>

```Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'openoffice.org-debian-menus' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-fr-fr' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-thesaurus-de-ch' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-hyphenation-en-ca' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-hyphenation-en-us' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-updatedicts' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-kde' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-common' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-an' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-ca' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-eo' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-es' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-eu' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-fo' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-gl' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-nb' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-nn' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-nr' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-ns' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-ss' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-st' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-tl' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-tn' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-uz' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-ve' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-xh' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-zu' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-hunspell' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-hyphenation-en' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-hyphenation-fi' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-hyphenation-ga' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-hyphenation-hr' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-hyphenation-id' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-calc' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-writer' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-hyphenation-lt' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-hyphenation-pl' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-hyphenation-ru' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-ure' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-thesaurus-de' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-thesaurus-it' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-thesaurus-pl' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-bundled' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-base' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-en-us' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-core' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-dev-doc' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-dmaths' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-de-at' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-de-ch' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-de-de' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-unbundled' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-hyphenation' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-thesaurus-en-au' for glob 'openoffice.org-*'
Package 'openoffice.org-thesaurus-it' is not installed, so not removed
Note, selecting 'dictionaries-common' instead of 'openoffice.org-updatedicts'
Package 'openoffice.org-hunspell' is not installed, so not removed
Package 'openoffice.org-core' is not installed, so not removed
Note, selecting 'hunspell-an' instead of 'openoffice.org-spellcheck-an'
Note, selecting 'hunspell-ca' instead of 'openoffice.org-spellcheck-ca'
Package 'openoffice.org-spellcheck-en-us' is not installed, so not removed
Note, selecting 'hunspell-eu' instead of 'openoffice.org-spellcheck-eu'
Note, selecting 'hunspell-gl-es' instead of 'openoffice.org-spellcheck-gl'
Note, selecting 'hunspell-uz' instead of 'openoffice.org-spellcheck-uz'
Package 'openoffice.org-writer' is not installed, so not removed
Note, selecting 'hyphen-en-us' instead of 'openoffice.org-hyphenation-en-us'
Note, selecting 'hyphen-en-us' instead of 'openoffice.org-hyphenation-en'
Package 'openoffice.org-hyphenation-hr' is not installed, so not removed
Note, selecting 'hyphen-pl' instead of 'openoffice.org-hyphenation-pl'
Note, selecting 'hyphen-ru' instead of 'openoffice.org-hyphenation-ru'
Package 'openoffice.org-base' is not installed, so not removed
Package 'openoffice.org-common' is not installed, so not removed
Package 'openoffice.org-dev-doc' is not installed, so not removed
Note, selecting 'myspell-eo' instead of 'openoffice.org-spellcheck-eo'
Note, selecting 'myspell-es' instead of 'openoffice.org-spellcheck-es'
Note, selecting 'myspell-fo' instead of 'openoffice.org-spellcheck-fo'
Note, selecting 'myspell-nb' instead of 'openoffice.org-spellcheck-nb'
Note, selecting 'myspell-nn' instead of 'openoffice.org-spellcheck-nn'
Note, selecting 'myspell-nr' instead of 'openoffice.org-spellcheck-nr'
Note, selecting 'myspell-ns' instead of 'openoffice.org-spellcheck-ns'
Note, selecting 'myspell-ss' instead of 'openoffice.org-spellcheck-ss'
Note, selecting 'myspell-st' instead of 'openoffice.org-spellcheck-st'
Note, selecting 'myspell-tn' instead of 'openoffice.org-spellcheck-tn'
Note, selecting 'myspell-ve' instead of 'openoffice.org-spellcheck-ve'
Note, selecting 'myspell-xh' instead of 'openoffice.org-spellcheck-xh'
Note, selecting 'myspell-zu' instead of 'openoffice.org-spellcheck-zu'
Note, selecting 'mythes-de' instead of 'openoffice.org-thesaurus-de'
Note, selecting 'mythes-de-ch' instead of 'openoffice.org-thesaurus-de-ch'
Note, selecting 'mythes-en-au' instead of 'openoffice.org-thesaurus-en-au'
Note, selecting 'mythes-pl' instead of 'openoffice.org-thesaurus-pl'
Note, selecting 'openoffice.org-hyphenation' instead of 'openoffice.org-hyphenation-en-ca'
Note, selecting 'openoffice.org-hyphenation' instead of 'openoffice.org-hyphenation-fi'
Note, selecting 'openoffice.org-hyphenation' instead of 'openoffice.org-hyphenation-ga'
Note, selecting 'openoffice.org-hyphenation' instead of 'openoffice.org-hyphenation-id'
Package 'openoffice.org-calc' is not installed, so not removed
Package 'openoffice.org-kde' is not installed, so not removed
Note, selecting 'myspell-fr-gut' instead of 'openoffice.org-spellcheck-fr-fr'
Note, selecting 'myspell-tl' instead of 'openoffice.org-spellcheck-tl'
Package 'openoffice.org-dmaths' is not installed, so not removed
Package 'openoffice.org-bundled' is not installed, so not removed
Package 'openoffice.org-ure' is not installed, so not removed
Package 'openoffice.org-debian-menus' is not installed, so not removed
Package 'openoffice.org-hyphenation' is not installed, so not removed
Package 'openoffice.org-hyphenation-lt' is not installed, so not removed
```

<p>Trying to purge LibreOffice results in a similar messsage telling me that nothing Libreoffice related is installed, however <code>sudo apt list --installed</code> has (along with openoffice):</p>

```libreoffice-core/xenial-updates,xenial-security,now 1:5.1.6~rc2-0ubuntu1~xenial1 amd64 [installed,automatic]
libreoffice-draw/xenial-updates,xenial-security,now 1:5.1.6~rc2-0ubuntu1~xenial1 amd64 [installed]
libreoffice-style-galaxy/xenial-updates,xenial-updates,xenial-security,xenial-security,now 1:5.1.6~rc2-0ubuntu1~xenial1 all [installed,auto-removable]
libreoffice-style-human/xenial-updates,xenial-updates,xenial-security,xenial-security,now 1:5.1.6~rc2-0ubuntu1~xenial1 all [installed,auto-removable]
```

The dpkg manager is completely bricked due to unmet dependencies, I can't purge anything as it says it can't find it and I can't install anything because of the conflict. I thought about removing the "soffice" directory that seems to be causing this mess but I don't know how wise that is.

I'm fairly new to Linux and I hope I've been comprehensive enough in showing the error reports.

答:
sudo dpkg -r --force-all openoffice-debian-menus
```
<p>removes all dependencies related to openoffice</p>
<p>next type</p>
<pre class="lang-sh prettyprint-override"><code>sudo apt-get install -f
</code>```

to resolves rependencies related to libreoffice

ContentLicense: CC BY-SA 3.0

Body:
I have been looking at multiple pages for a few hours now but still no luck in solving this. I installed OpenOffice then tried to install LibreOffice-Draw through the app-center but encountered a problem (the file didn't install and kept cutting out). I went into the terminal and was met with these errors after trying to use apt-get with anything:

You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies.
 libreoffice-core : Depends: libreoffice-common (> 1:5.1.6~rc2) but it is not going to be installed
 libreoffice-style-galaxy : Depends: libreoffice-common (= 1:5.1.6~rc2-0ubuntu1~xenial1) but it is not going to be installed
 libreoffice-style-human : Depends: libreoffice-common (= 1:5.1.6~rc2-0ubuntu1~xenial1) but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

Running that and trying to install libreoffice-common results in:

Preparing to unpack .../libreoffice-common_1%3a5.1.6~rc2-0ubuntu1~xenial1_all.deb ...
Unpacking libreoffice-common (1:5.1.6~rc2-0ubuntu1~xenial1) ...
dpkg: error processing archive /var/cache/apt/archives/libreoffice-common_1%3a5.1.6~rc2-0ubuntu1~xenial1_all.deb (--unpack):
 trying to overwrite '/usr/bin/soffice', which is also in package openoffice-debian-menus 4.1.3-9783
rmdir: failed to remove '/var/lib/libreoffice/share/prereg/': No such file or directory
rmdir: failed to remove '/var/lib/libreoffice/share/': No such file or directory
rmdir: failed to remove '/var/lib/libreoffice/program/': No such file or directory
rmdir: failed to remove '/var/lib/libreoffice': No such file or directory
rmdir: failed to remove '/var/lib/libreoffice': No such file or directory
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for shared-mime-info (1.5-2ubuntu0.1) ...
Unknown media type in type 'all/all'
Unknown media type in type 'all/allfiles'
Processing triggers for desktop-file-utils (0.22-1ubuntu5.1+elementary2~ubuntu0.4.1) ...
Processing triggers for bamfdaemon (0.5.3~bzr0+16.04.20160824-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for gnome-menus (3.13.3-6ubuntu3.1) ...
Processing triggers for mime-support (3.59ubuntu1) ...
Processing triggers for hicolor-icon-theme (0.15-0ubuntu1) ...
Processing triggers for gnome-icon-theme (3.12.0-1ubuntu3) ...
Errors were encountered while processing:
 /var/cache/apt/archives/libreoffice-common_1%3a5.1.6~rc2-0ubuntu1~xenial1_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
```

Trying to purge OpenOffice -

Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'openoffice.org-debian-menus' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-fr-fr' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-thesaurus-de-ch' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-hyphenation-en-ca' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-hyphenation-en-us' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-updatedicts' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-kde' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-common' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-an' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-ca' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-eo' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-es' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-eu' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-fo' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-gl' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-nb' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-nn' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-nr' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-ns' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-ss' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-st' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-tl' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-tn' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-uz' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-ve' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-xh' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-zu' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-hunspell' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-hyphenation-en' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-hyphenation-fi' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-hyphenation-ga' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-hyphenation-hr' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-hyphenation-id' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-calc' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-writer' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-hyphenation-lt' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-hyphenation-pl' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-hyphenation-ru' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-ure' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-thesaurus-de' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-thesaurus-it' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-thesaurus-pl' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-bundled' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-base' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-en-us' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-core' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-dev-doc' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-dmaths' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-de-at' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-de-ch' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-spellcheck-de-de' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-unbundled' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-hyphenation' for glob 'openoffice.org-*'
Note, selecting 'openoffice.org-thesaurus-en-au' for glob 'openoffice.org-*'
Package 'openoffice.org-thesaurus-it' is not installed, so not removed
Note, selecting 'dictionaries-common' instead of 'openoffice.org-updatedicts'
Package 'openoffice.org-hunspell' is not installed, so not removed
Package 'openoffice.org-core' is not installed, so not removed
Note, selecting 'hunspell-an' instead of 'openoffice.org-spellcheck-an'
Note, selecting 'hunspell-ca' instead of 'openoffice.org-spellcheck-ca'
Package 'openoffice.org-spellcheck-en-us' is not installed, so not removed
Note, selecting 'hunspell-eu' instead of 'openoffice.org-spellcheck-eu'
Note, selecting 'hunspell-gl-es' instead of 'openoffice.org-spellcheck-gl'
Note, selecting 'hunspell-uz' instead of 'openoffice.org-spellcheck-uz'
Package 'openoffice.org-writer' is not installed, so not removed
Note, selecting 'hyphen-en-us' instead of 'openoffice.org-hyphenation-en-us'
Note, selecting 'hyphen-en-us' instead of 'openoffice.org-hyphenation-en'
Package 'openoffice.org-hyphenation-hr' is not installed, so not removed
Note, selecting 'hyphen-pl' instead of 'openoffice.org-hyphenation-pl'
Note, selecting 'hyphen-ru' instead of 'openoffice.org-hyphenation-ru'
Package 'openoffice.org-base' is not installed, so not removed
Package 'openoffice.org-common' is not installed, so not removed
Package 'openoffice.org-dev-doc' is not installed, so not removed
Note, selecting 'myspell-eo' instead of 'openoffice.org-spellcheck-eo'
Note, selecting 'myspell-es' instead of 'openoffice.org-spellcheck-es'
Note, selecting 'myspell-fo' instead of 'openoffice.org-spellcheck-fo'
Note, selecting 'myspell-nb' instead of 'openoffice.org-spellcheck-nb'
Note, selecting 'myspell-nn' instead of 'openoffice.org-spellcheck-nn'
Note, selecting 'myspell-nr' instead of 'openoffice.org-spellcheck-nr'
Note, selecting 'myspell-ns' instead of 'openoffice.org-spellcheck-ns'
Note, selecting 'myspell-ss' instead of 'openoffice.org-spellcheck-ss'
Note, selecting 'myspell-st' instead of 'openoffice.org-spellcheck-st'
Note, selecting 'myspell-tn' instead of 'openoffice.org-spellcheck-tn'
Note, selecting 'myspell-ve' instead of 'openoffice.org-spellcheck-ve'
Note, selecting 'myspell-xh' instead of 'openoffice.org-spellcheck-xh'
Note, selecting 'myspell-zu' instead of 'openoffice.org-spellcheck-zu'
Note, selecting 'mythes-de' instead of 'openoffice.org-thesaurus-de'
Note, selecting 'mythes-de-ch' instead of 'openoffice.org-thesaurus-de-ch'
Note, selecting 'mythes-en-au' instead of 'openoffice.org-thesaurus-en-au'
Note, selecting 'mythes-pl' instead of 'openoffice.org-thesaurus-pl'
Note, selecting 'openoffice.org-hyphenation' instead of 'openoffice.org-hyphenation-en-ca'
Note, selecting 'openoffice.org-hyphenation' instead of 'openoffice.org-hyphenation-fi'
Note, selecting 'openoffice.org-hyphenation' instead of 'openoffice.org-hyphenation-ga'
Note, selecting 'openoffice.org-hyphenation' instead of 'openoffice.org-hyphenation-id'
Package 'openoffice.org-calc' is not installed, so not removed
Package 'openoffice.org-kde' is not installed, so not removed
Note, selecting 'myspell-fr-gut' instead of 'openoffice.org-spellcheck-fr-fr'
Note, selecting 'myspell-tl' instead of 'openoffice.org-spellcheck-tl'
Package 'openoffice.org-dmaths' is not installed, so not removed
Package 'openoffice.org-bundled' is not installed, so not removed
Package 'openoffice.org-ure' is not installed, so not removed
Package 'openoffice.org-debian-menus' is not installed, so not removed
Package 'openoffice.org-hyphenation' is not installed, so not removed
Package 'openoffice.org-hyphenation-lt' is not installed, so not removed

Trying to purge LibreOffice results in a similar messsage telling me that nothing Libreoffice related is installed, however sudo apt list --installed has (along with openoffice):

libreoffice-core/xenial-updates,xenial-security,now 1:5.1.6~rc2-0ubuntu1~xenial1 amd64 [installed,automatic]
libreoffice-draw/xenial-updates,xenial-security,now 1:5.1.6~rc2-0ubuntu1~xenial1 amd64 [installed]
libreoffice-style-galaxy/xenial-updates,xenial-updates,xenial-security,xenial-security,now 1:5.1.6~rc2-0ubuntu1~xenial1 all [installed,auto-removable]
libreoffice-style-human/xenial-updates,xenial-updates,xenial-security,xenial-security,now 1:5.1.6~rc2-0ubuntu1~xenial1 all [installed,auto-removable]

The dpkg manager is completely bricked due to unmet dependencies, I can't purge anything as it says it can't find it and I can't install anything because of the conflict. I thought about removing the "soffice" directory that seems to be causing this mess but I don't know how wise that is.

I'm fairly new to Linux and I hope I've been comprehensive enough in showing the error reports.

Body:
sudo dpkg -r --force-all openoffice-debian-menus

removes all dependencies related to openoffice

next type

sudo apt-get install -f

to resolves rependencies related to libreoffice

ContentLicense: CC BY-SA 4.0


问:
requireNativeComponent: "RNSScreenStackHeaderConfig" was not found in the UIManager when running android app
When running an application on android i get this error. It builds correctly but crashes with exception. I have installed React-native-screens, @React-native/navigation and the dependencies listed on https://reactnavigation.org/docs/getting-started/

com.facebook.react.common.JavascriptException: Invariant Violation: requireNativeComponent: "RNSScreenStackHeaderConfig" was not found in the UIManager.

```<code>This error is located at:
    in RNSScreenStackHeaderConfig
    in Unknown
    in RNSScreen
    in N
    in ForwardRef
    in y
    in E
    in RNSScreenStack
    in w
    in RNCSafeAreaProvider
    in Unknown
    in v
    in Unknown
    in Unknown
    in Unknown
    in ForwardRef
    in Unknown
    in ForwardRef
    in p
    in c
    in P
    in RCTView
    in View
    in RCTView
    in View
    in h, stack:
</code>```

It builds and runs on iOS fine but when running on android it crashes completely. Is there something I am overlooking here?

This is my Package json.

```<code>{
  "name": "<myprojectname>",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint .",
    "postinstall": "npx jetify",
    "android:bundle:debug": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/"
  },
  "dependencies": {
    "@react-native-community/async-storage": "^1.8.1",
    "@react-native-community/masked-view": "^0.1.11",
    "@react-navigation/native": "^6.0.2",
    "@react-navigation/native-stack": "^6.1.0",
    "@react-navigation/stack": "^6.0.7",
    "adbkit": "^2.11.1",
    "moment": "^2.24.0",
    "react": "16.9.0",
    "react-native": "0.63.0",
    "react-native-calendar-strip": "^1.4.1",
    "react-native-calendars": "^1.264.0",
    "react-native-firebase": "^5.6.0",
    "react-native-gesture-handler": "^1.10.3",
    "react-native-reanimated": "^2.2.0",
    "react-native-safe-area-context": "^3.3.1",
    "react-native-screens": "3.1.1",
    "react-native-snap-carousel": "^3.8.4",
    "react-native-vector-icons": "^6.6.0",
    "react-navigation": "^4.4.4",
    "react-navigation-stack": "^2.10.4",
    "react-redux": "^7.2.0",
    "redux": "^4.0.5"
  },
  "devDependencies": {
    "@babel/core": "^7.15.0",
    "babel-jest": "24.9.0",
    "eslint": "^6.5.1",
    "jest": "24.9.0",
    "jetifier": "^1.6.5",
    "metro-react-native-babel-preset": "^0.66.2",
    "react-test-renderer": "16.9.0"
  },
  "jest": {
    "preset": "react-native"
  }
}
</code>```

I dont really know how to solve this, have tried removing caches, restarting metro, deleting node modules and all "related" errors. This error even happens when I create a fresh project and try installing and using the navigation library.

This is my entrypoint, example copied from React-navigation snack.

```<code>import * as React from 'react';
import { View, Text } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { enableScreens } from 'react-native-screens';

enableScreens(true);
function HomeScreen() {
  return (
    <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
      <Text>Home Screen</Text>
    </View>
  );
}

function DetailsScreen() {
  return (
    <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
      <Text>Details Screen</Text>
    </View>
  );
}

const Stack = createNativeStackNavigator();

function AppTest() {
  return (
    <NavigationContainer>
      <Stack.Navigator
      screenOptions={{
        headerStyle: {
          backgroundColor: '#f4511e',
        },
        headerTintColor: '#fff',
        headerTitleStyle: {
          fontWeight: 'bold',
        },
      }}
      initialRouteName="Home">
        <Stack.Screen  options={{ title: 'My home' }} name="Home" component={HomeScreen} />
        <Stack.Screen  options={{ title: 'My home' }} name="Details" component={DetailsScreen} />
      </Stack.Navigator>
    </NavigationContainer>
  );
}

export default AppTest;
</code>```

Any suggestions?

答:
Solution have in documentation of reactnavigation doc

After install @react-navigation/native you have to install two dependency:

```<code>npm install react-native-screens react-native-safe-area-context
</code>```

it's mention library.

NB: react-native-screens package requires one additional configuration step to properly work on Android devices. Edit MainActivity.java file which is located in

android/app/src/main/java/<your package name>/MainActivity.java.

Add the following code to the body of MainActivity class:

```<code>@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(null);
}
</code>```

and make sure to add an import statement at the top of this file:

```<code>import android.os.Bundle;
</code>```

Body:
When running an application on android i get this error. It builds correctly but crashes with exception. I have installed React-native-screens, @React-native/navigation and the dependencies listed on https://reactnavigation.org/docs/getting-started/

com.facebook.react.common.JavascriptException: Invariant Violation: requireNativeComponent: "RNSScreenStackHeaderConfig" was not found in the UIManager.

This error is located at:
    in RNSScreenStackHeaderConfig
    in Unknown
    in RNSScreen
    in N
    in ForwardRef
    in y
    in E
    in RNSScreenStack
    in w
    in RNCSafeAreaProvider
    in Unknown
    in v
    in Unknown
    in Unknown
    in Unknown
    in ForwardRef
    in Unknown
    in ForwardRef
    in p
    in c
    in P
    in RCTView
    in View
    in RCTView
    in View
    in h, stack:

It builds and runs on iOS fine but when running on android it crashes completely. Is there something I am overlooking here?

This is my Package json.

{
  "name": "<myprojectname>",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint .",
    "postinstall": "npx jetify",
    "android:bundle:debug": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/"
  },
  "dependencies": {
    "@react-native-community/async-storage": "^1.8.1",
    "@react-native-community/masked-view": "^0.1.11",
    "@react-navigation/native": "^6.0.2",
    "@react-navigation/native-stack": "^6.1.0",
    "@react-navigation/stack": "^6.0.7",
    "adbkit": "^2.11.1",
    "moment": "^2.24.0",
    "react": "16.9.0",
    "react-native": "0.63.0",
    "react-native-calendar-strip": "^1.4.1",
    "react-native-calendars": "^1.264.0",
    "react-native-firebase": "^5.6.0",
    "react-native-gesture-handler": "^1.10.3",
    "react-native-reanimated": "^2.2.0",
    "react-native-safe-area-context": "^3.3.1",
    "react-native-screens": "3.1.1",
    "react-native-snap-carousel": "^3.8.4",
    "react-native-vector-icons": "^6.6.0",
    "react-navigation": "^4.4.4",
    "react-navigation-stack": "^2.10.4",
    "react-redux": "^7.2.0",
    "redux": "^4.0.5"
  },
  "devDependencies": {
    "@babel/core": "^7.15.0",
    "babel-jest": "24.9.0",
    "eslint": "^6.5.1",
    "jest": "24.9.0",
    "jetifier": "^1.6.5",
    "metro-react-native-babel-preset": "^0.66.2",
    "react-test-renderer": "16.9.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

I dont really know how to solve this, have tried removing caches, restarting metro, deleting node modules and all "related" errors. This error even happens when I create a fresh project and try installing and using the navigation library.

This is my entrypoint, example copied from React-navigation snack.

import * as React from 'react';
import { View, Text } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { enableScreens } from 'react-native-screens';

enableScreens(true);
function HomeScreen() {
  return (
    <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
      <Text>Home Screen</Text>
    </View>
  );
}

function DetailsScreen() {
  return (
    <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
      <Text>Details Screen</Text>
    </View>
  );
}

const Stack = createNativeStackNavigator();

function AppTest() {
  return (
    <NavigationContainer>
      <Stack.Navigator
      screenOptions={{
        headerStyle: {
          backgroundColor: '#f4511e',
        },
        headerTintColor: '#fff',
        headerTitleStyle: {
          fontWeight: 'bold',
        },
      }}
      initialRouteName="Home">
        <Stack.Screen  options={{ title: 'My home' }} name="Home" component={HomeScreen} />
        <Stack.Screen  options={{ title: 'My home' }} name="Details" component={DetailsScreen} />
      </Stack.Navigator>
    </NavigationContainer>
  );
}

export default AppTest;

Any suggestions?

Body:
Solution have in documentation of reactnavigation doc

After install @react-navigation/native you have to install two dependency:

npm install react-native-screens react-native-safe-area-context

it's mention library.

NB: react-native-screens package requires one additional configuration step to properly work on Android devices. Edit MainActivity.java file which is located in

android/app/src/main/java/<your package name>/MainActivity.java.

Add the following code to the body of MainActivity class:

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(null);
}

and make sure to add an import statement at the top of this file:

import android.os.Bundle;


问:
Visual studio 2019 “Unable to connect to web server 'IIS Express'”
I attempt to lunch my ASP.NET Core project in Microsoft Visual Studio 2019 and got this error: "Unable to connect to web server 'IIS Express'"

Visual Studio 2019 Version 16.9.5

.Net 5.0

答: I encountered the same issue , but after few seconds  i find out that there is a  duplicated sslport , the same sslport being registered for another running app , so when i run another app with the same setting i see this error , you have to change the sslport in the launchsetting.json


问:
How do I convert string to object type without using eval() in for loop?
class Testclass:

```<code>def change(self, obj):
    if(self.ball):
        self.ball=False
        obj.ball=True
</code>```

main():

```<code>A=Testclass()
B=Testclass()
seq=["AB", "BA", "AB"]
for val in seq:
    obj1, obj2=list(val)    #to split "AB" into A, B
    eval(obj1).change(eval(obj2))
</code>```

.change() method changes object's boolean value to the other object's value. Just for the test.

How can I avoid using eval in this loop? Without eval(), following error appears:
'str' object has no attribute 'change'

I'm using python 3.10

答:
Store the objects in a dict from their "name" to the instances (it's better to explicitly maintain such a mapping instead of falling to the trap of using locals() or globals()).

A = Testclass()
B = Testclass()

objects = {"A": A, "B": B}
seq = ["AB", "BA", "AB"]

for val in seq:
    obj1, obj2 = list(val)
    objects[obj1].change(objects[obj2])
```
<p>BTW, it's possible to unpack a string directly without <code>list</code>:</p>
<pre class="lang-py prettyprint-override"><code>ob1, obj2 = val
</code>```

Body:
class Testclass:

def change(self, obj):
    if(self.ball):
        self.ball=False
        obj.ball=True

main():

A=Testclass()
B=Testclass()
seq=["AB", "BA", "AB"]
for val in seq:
    obj1, obj2=list(val)    #to split "AB" into A, B
    eval(obj1).change(eval(obj2))

.change() method changes object's boolean value to the other object's value. Just for the test.

How can I avoid using eval in this loop? Without eval(), following error appears:
'str' object has no attribute 'change'

I'm using python 3.10

Body:
Store the objects in a dict from their "name" to the instances (it's better to explicitly maintain such a mapping instead of falling to the trap of using locals() or globals()).

A = Testclass()
B = Testclass()

objects = {"A": A, "B": B}
seq = ["AB", "BA", "AB"]

for val in seq:
    obj1, obj2 = list(val)
    objects[obj1].change(objects[obj2])

BTW, it's possible to unpack a string directly without list:

ob1, obj2 = val


问:
How to Solve this Exception
I am trying to create a Todo Application in Flutter with taking SQFLITE as Database.
I am adding a "Category" Property to my Tasks to Group them.
When importing Values of Categories stored in database and showing it in my add a task
view, I am using a dropdownmenubutton and all the categories are being shown as dropdownmenu Item.
The code is below

```<code>var _categories = <DropdownMenuItem>[];
_loadCategories() async {
var _categoryService = CategoryService();
var categories = await _categoryService.readCategories();
categories.forEach((category) {
  setState(() {
    _categories.add(DropdownMenuItem(
      child: Text(category['Name']),
      value: category['name'],
    ));
  });
});
</code>```

}

And the Code to Show these categories is

```<code>DropdownButtonFormField(
                value: _selectedValue,
                items: _categories,
                hint: Text("Category"),
                onChanged: (value) {
                  setState(() {
                    _selectedValue = value;
                  });
                },
              ),
</code>```

And the Error Message is this

Couldn't infer type parameter 'T'.

Tried to infer 'dynamic' for 'T' which doesn't work:
Parameter 'onChanged' declared as     'void Function(T?)?'
but argument is 'void Function(Object?)'.
The type 'dynamic' was inferred from:
Parameter 'value' declared as     'T?'
but argument is 'dynamic'.
Parameter 'items' declared as     'List<DropdownMenuItem>?'
but argument is 'List<DropdownMenuItem>'.

Consider passing explicit type argument(s) to the generic.

Can anyone help me?

答:
Try to add type of Value

```<code>DropdownButtonFormField<String?>()
</code>```

and also

```<code>var _categories = <DropdownMenuItem<String?>>[];
</code>```

Title: How to Solve this Exception

Body:
I am trying to create a Todo Application in Flutter with taking SQFLITE as Database.
I am adding a "Category" Property to my Tasks to Group them.
When importing Values of Categories stored in database and showing it in my add a task
view, I am using a dropdownmenubutton and all the categories are being shown as dropdownmenu Item.
The code is below

var _categories = <DropdownMenuItem>[];
_loadCategories() async {
var _categoryService = CategoryService();
var categories = await _categoryService.readCategories();
categories.forEach((category) {
  setState(() {
    _categories.add(DropdownMenuItem(
      child: Text(category['Name']),
      value: category['name'],
    ));
  });
});

}

And the Code to Show these categories is

DropdownButtonFormField(
                value: _selectedValue,
                items: _categories,
                hint: Text("Category"),
                onChanged: (value) {
                  setState(() {
                    _selectedValue = value;
                  });
                },
              ),

And the Error Message is this

Couldn't infer type parameter 'T'.

Tried to infer 'dynamic' for 'T' which doesn't work:
Parameter 'onChanged' declared as     'void Function(T?)?'
but argument is 'void Function(Object?)'.
The type 'dynamic' was inferred from:
Parameter 'value' declared as     'T?'
but argument is 'dynamic'.
Parameter 'items' declared as     'List<DropdownMenuItem>?'
but argument is 'List<DropdownMenuItem>'.

Consider passing explicit type argument(s) to the generic.

Can anyone help me?

Body:
Try to add type of Value

DropdownButtonFormField<String?>()

and also

var _categories = <DropdownMenuItem<String?>>[];


问:
Join range of row using arrayformula

I have a range of data on column A and B. In Column D , i have a reference for the shotID. I want to make a list for the artist involved for specific shotID.

In E2 i use this :

```<code>=JOIN( "," , FILTER($B$2:$B, $A$2:$A= D2))
</code>```

then copy down to E3,E4. It works as i expected, but i want to do it using array formula. So only use single formula in E2 and that doesn't work that simple :

```<code>=arrayformula( JOIN( "," , FILTER($B$2:$B, $A$2:$A= D2:D4)) )
</code>```

How can i do this ?

答:
You could also try:

```<code>={unique(A2:A),arrayformula(transpose(substitute(trim(query(if(A2:A<>transpose(unique(A2:A)),,B2:B),,9^9))," ",", ")))}
</code>```

Title: Join range of row using arrayformula

Body:
I have a range of data on column A and B. In Column D , i have a reference for the shotID. I want to make a list for the artist involved for specific shotID.

In E2 i use this :

=JOIN( "," , FILTER($B$2:$B, $A$2:$A= D2))

then copy down to E3,E4. It works as i expected, but i want to do it using array formula. So only use single formula in E2 and that doesn't work that simple :

=arrayformula( JOIN( "," , FILTER($B$2:$B, $A$2:$A= D2:D4)) )

How can i do this ?

Body:
You could also try:

={unique(A2:A),arrayformula(transpose(substitute(trim(query(if(A2:A<>transpose(unique(A2:A)),,B2:B),,9^9))," ",", ")))}


问:
Socket Server controller Android App, Socket error
So basically I want to create some kind of controller for my pc, where on pc, runs java socket server. The server is working, I have tried it. Also, Port Forwarding in the router is allright.  Source code is here :

```<code>import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;

public class Server {
    public static final String ANSI_RESET = "\u001B[0m";
    public static final String ANSI_GREEN = "\u001B[32m";
    public static final String ANSI_BOLD = "\033[1m";
    public static final String ANSI_RED = "\u001B[31m";

    public static void main(String[] args) throws IOException {

        // Creating server instance
        ServerSocket serverSocket = new ServerSocket(2000);
        Socket socket = serverSocket.accept();

        System.out.println(ANSI_GREEN + "Controller connected" + ANSI_RESET);

        // Input Output streams
        DataInputStream dataInputStream = new DataInputStream(socket.getInputStream());
        DataOutputStream dataOutputStream = new DataOutputStream(socket.getOutputStream());

        String command = "";

        do {

            command = dataInputStream.readUTF();

            switch (command.trim()){
                case "volume up":
                    Runtime.getRuntime().exec("cmd /c start src\\sk\\dzurik\\main\\volup.bat");
                    break;
                case "volume down":
                    Runtime.getRuntime().exec("cmd /c start src\\sk\\dzurik\\main\\voldown.bat");
                    break;
                default:
                    // Unknown command
                    break;
            }

        }while (!command.equals("stop"));

        socket.close();

        System.out.println(ANSI_RED + "Controller disconnected" + ANSI_RESET);

    }

}
</code>```

And it is supposed to interact with the android app, but I got an error and I can't quite figure out why is that so, here is the source code for ActivityMain :

```<code>import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;

public class MainActivity extends AppCompatActivity {
    private boolean connected;
    private DataOutputStream dataOutputStream;
    private Socket socket;

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

        // Pripájanie na server

        try {
            socket = new Socket("172.0.0.1",2000);
            dataOutputStream = new DataOutputStream(socket.getOutputStream());

        } catch (IOException e) {
            Toast.makeText(MainActivity.this, "Not Connected!",
                    Toast.LENGTH_LONG).show();
        }

        Button VolumeUp = (Button) findViewById(R.id.VolumeUpButton);
        VolumeUp.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try {
                    send("volume up");
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });

        Button VolumeDown = (Button) findViewById(R.id.VolumeDownButton);
        VolumeDown.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try {
                    send("volume down");
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });

        Button DisconnectButton = (Button) findViewById(R.id.DisconnectButton);
        DisconnectButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try {
                    send("stop");

                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });

    }

    public void send(String command) throws IOException {
        if (socket != null){
            dataOutputStream.writeUTF(command);
        }
        else Toast.makeText(MainActivity.this, "Socket is not defined",
                Toast.LENGTH_SHORT).show();
    }

    public void disconnect() throws IOException {
        if (socket != null){
            socket.close();
        }
        else Toast.makeText(MainActivity.this, "Socket is not defined",
                Toast.LENGTH_SHORT).show();
    }

}
</code>```

So if you could help me with it, I would be thankful, <3

答: Well the reason for that was silly. When I'm loading data from Stream it says nextLine which means the ending point is \n so I could never get that line because I haven't put it there.</p>

Body:
So basically I want to create some kind of controller for my pc, where on pc, runs java socket server. The server is working, I have tried it. Also, Port Forwarding in the router is allright.  Source code is here :

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;

public class Server {
    public static final String ANSI_RESET = "\u001B[0m";
    public static final String ANSI_GREEN = "\u001B[32m";
    public static final String ANSI_BOLD = "\033[1m";
    public static final String ANSI_RED = "\u001B[31m";

    public static void main(String[] args) throws IOException {

        // Creating server instance
        ServerSocket serverSocket = new ServerSocket(2000);
        Socket socket = serverSocket.accept();

        System.out.println(ANSI_GREEN + "Controller connected" + ANSI_RESET);

        // Input Output streams
        DataInputStream dataInputStream = new DataInputStream(socket.getInputStream());
        DataOutputStream dataOutputStream = new DataOutputStream(socket.getOutputStream());

        String command = "";

        do {

            command = dataInputStream.readUTF();

            switch (command.trim()){
                case "volume up":
                    Runtime.getRuntime().exec("cmd /c start src\\sk\\dzurik\\main\\volup.bat");
                    break;
                case "volume down":
                    Runtime.getRuntime().exec("cmd /c start src\\sk\\dzurik\\main\\voldown.bat");
                    break;
                default:
                    // Unknown command
                    break;
            }

        }while (!command.equals("stop"));

        socket.close();

        System.out.println(ANSI_RED + "Controller disconnected" + ANSI_RESET);

    }

}

And it is supposed to interact with the android app, but I got an error and I can't quite figure out why is that so, here is the source code for ActivityMain :

import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;

public class MainActivity extends AppCompatActivity {
    private boolean connected;
    private DataOutputStream dataOutputStream;
    private Socket socket;

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

        // Pripájanie na server

        try {
            socket = new Socket("172.0.0.1",2000);
            dataOutputStream = new DataOutputStream(socket.getOutputStream());

        } catch (IOException e) {
            Toast.makeText(MainActivity.this, "Not Connected!",
                    Toast.LENGTH_LONG).show();
        }

        Button VolumeUp = (Button) findViewById(R.id.VolumeUpButton);
        VolumeUp.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try {
                    send("volume up");
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });

        Button VolumeDown = (Button) findViewById(R.id.VolumeDownButton);
        VolumeDown.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try {
                    send("volume down");
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });

        Button DisconnectButton = (Button) findViewById(R.id.DisconnectButton);
        DisconnectButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try {
                    send("stop");

                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });

    }

    public void send(String command) throws IOException {
        if (socket != null){
            dataOutputStream.writeUTF(command);
        }
        else Toast.makeText(MainActivity.this, "Socket is not defined",
                Toast.LENGTH_SHORT).show();
    }

    public void disconnect() throws IOException {
        if (socket != null){
            socket.close();
        }
        else Toast.makeText(MainActivity.this, "Socket is not defined",
                Toast.LENGTH_SHORT).show();
    }

}

So if you could help me with it, I would be thankful, <3


问:
How to create an instance method based on this object data?
I have some data inside this variable and I want to know how could I write an method to give me the sum of the items price.

Model names and their associations:

```<code>Order
- belongs_to :customer
- has_many :item_orders
- has_many :items, :through => :item_orders
- accepts_nested_attributes_for :item_orders, :allow_destroy => true, :reject_if => lambda { |a| a['item_id'].blank? }

Item
- has_many :item_orders, :dependent => :destroy
- has_many :orders, :through => :item_orders
- accepts_nested_attributes_for :item_orders, :allow_destroy => true

ItemOrder
- belongs_to :item
- belongs_to :order
</code>```

doing:

```<code><%= debug @order.items %>

# returns me

- !ruby/object:Item
  attributes:
  id: 31
  title: Golden Ring 2
  price: 13445.0
  labour_cost: 500.0
  item_type_id: 10
  created_at: 2011-08-13 10:53:24.000000000Z
  updated_at: 2011-08-18 06:10:36.000000000Z
  photo: golden_ring.jpg
  changed_attributes: {}
  previously_changed: {}
  attributes_cache: {}
  marked_for_destruction: false
  destroyed: false
  readonly: false
  new_record: false
- !ruby/object:Item
 attributes:
  id: 32
  title: Special Pendant
  price: 171.67
  labour_cost: 120.0
  item_type_id: 20
  created_at: 2011-08-13 11:09:43.000000000Z
  updated_at: 2011-08-14 06:03:02.000000000Z
  photo: prd_194_48cd9b21771dd.jpg
  changed_attributes: {}
  previously_changed: {}
  attributes_cache: {}
  marked_for_destruction: false
  destroyed: false
  readonly: false
  new_record: false
</code>```

So, I want to write a method in the Order model class to make possible writes something like this on the view.

```<code> <%= @order.items.total_price %>
</code>```

The total_price method will sum all the item prices and multiply by the quantity that contains in @order.items.

My doubt is: from inside the method, how could I have access to the items collection to perform the sum operation.

```<code>def total_price
  self.item_order.each do |i| {
     result += i.quantity * i.items.price
  }
end
</code>```

EDIT: I totally forgot to mention that I have to consider the quantity also to make this math.

答:
I'm pretty sure you could just do;</p>

```<code>def total_price
  items.sum(:price)
end
</code>```

Body:
I have some data inside this variable and I want to know how could I write an method to give me the sum of the items price.

Model names and their associations:

Order
- belongs_to :customer
- has_many :item_orders
- has_many :items, :through => :item_orders
- accepts_nested_attributes_for :item_orders, :allow_destroy => true, :reject_if => lambda { |a| a['item_id'].blank? }

Item
- has_many :item_orders, :dependent => :destroy
- has_many :orders, :through => :item_orders
- accepts_nested_attributes_for :item_orders, :allow_destroy => true

ItemOrder
- belongs_to :item
- belongs_to :order

doing:

<%= debug @order.items %>

# returns me

- !ruby/object:Item
  attributes:
  id: 31
  title: Golden Ring 2
  price: 13445.0
  labour_cost: 500.0
  item_type_id: 10
  created_at: 2011-08-13 10:53:24.000000000Z
  updated_at: 2011-08-18 06:10:36.000000000Z
  photo: golden_ring.jpg
  changed_attributes: {}
  previously_changed: {}
  attributes_cache: {}
  marked_for_destruction: false
  destroyed: false
  readonly: false
  new_record: false
- !ruby/object:Item
 attributes:
  id: 32
  title: Special Pendant
  price: 171.67
  labour_cost: 120.0
  item_type_id: 20
  created_at: 2011-08-13 11:09:43.000000000Z
  updated_at: 2011-08-14 06:03:02.000000000Z
  photo: prd_194_48cd9b21771dd.jpg
  changed_attributes: {}
  previously_changed: {}
  attributes_cache: {}
  marked_for_destruction: false
  destroyed: false
  readonly: false
  new_record: false

So, I want to write a method in the Order model class to make possible writes something like this on the view.

 <%= @order.items.total_price %>

The total_price method will sum all the item prices and multiply by the quantity that contains in @order.items.

My doubt is: from inside the method, how could I have access to the items collection to perform the sum operation.

def total_price
  self.item_order.each do |i| {
     result += i.quantity * i.items.price
  }
end

EDIT: I totally forgot to mention that I have to consider the quantity also to make this math.

Body:
I'm pretty sure you could just do;

def total_price
  items.sum(:price)
end


问:
React Native release apk does not fetch data from local network
I created a react-native app, it is working fine.

If I generate a debug APK and install it on the devices, it works fine and fetches data from the local database as it should.

However, if generate gradlew assembleRelease the APK's are generated successfully, but when I install it on the devices it does not fetch data from the same network which it fetches from the same network if generate a debug APK.

Here is the URL of the repo https://github.com/sh4rif/react-native-restaurant-app.

答:
By default, iOS will block any request that's not encrypted using SSL. If you need to fetch from a cleartext URL (one that begins with http) you will first need to add an App Transport Security exception. If you know ahead of time what domains you will need access to, it is more secure to add exceptions only for those domains; if the domains are not known until runtime you can disable ATS completely. Note however that from January 2017, Apple's App Store review will require reasonable justification for disabling ATS. See Apple's documentation for more information.

On Android, as of API Level 28, clear text traffic is also blocked by default. This behaviour can be overridden by setting android:usesCleartextTraffic in the app manifest file.

Please refer to documentation


问:
Convert oracle date to another date format using php language
I am extracting date from the oracle database in this format: 31-DEC-68, then I use PHP to convert it to date like this: 'Y-m-d'. it's working fine for me for dates after 2000 otherwise it gives a wrong date for example this date :31-DEC-68 converted to 2068-12-31, it should be 1968-12-31.

this is a sample of my code:

```<code>$query = "select * from my_table";
$stid = oci_parse($connection, $query);
oci_execute($stid);
while (oci_fetch($stid)) {
    $dateVariable = oci_result($stid, 'date_field_from_oracle');
}
</code>```

Any help, please?

答:
it worked for me finally, I used:

```<code>TO_CHAR(date_field_from_oracle, 'dd-mm-yyyy')
</code>```

it gives the correct date format: 31-12-1968

Thanks a lot

Body:
I am extracting date from the oracle database in this format: 31-DEC-68, then I use PHP to convert it to date like this: 'Y-m-d'. it's working fine for me for dates after 2000 otherwise it gives a wrong date for example this date :31-DEC-68 converted to 2068-12-31, it should be 1968-12-31.

this is a sample of my code:

$query = "select * from my_table";
$stid = oci_parse($connection, $query);
oci_execute($stid);
while (oci_fetch($stid)) {
    $dateVariable = oci_result($stid, 'date_field_from_oracle');
}

Any help, please?

Body:
it worked for me finally, I used:

TO_CHAR(date_field_from_oracle, 'dd-mm-yyyy')

it gives the correct date format: 31-12-1968

Thanks a lot


问:
View javascript object model in real time
Are there tools or techniques (other than repeated console.log() calls) to view the javascript object model used in a web page in real time? eg something like:

```<code>    firstUser (User)
    -- userName Joe Bloggs (String)
    -- userEmail joe.bloggs@gmail.com (String)
    -- userSelections (Array)
    ----[1,2,4]

    secondUser (User)
    -- userName John Doe (String)
    -- userEmail jogn.doe@gmail.com (String)
    -- userSelections (Array)
    ----[1,2,3]
</code>```

I know this can be achieved using console.log(firstUser) and console.log(secondUser) but it would be useful to be able to display the entire data model so that I can see variables being altered in real time.

答:
The best approach is configure the logger package ( I really recommend pinojs ) and configure a "log level" strategy for your application, you can read more about here

But you also can do that:

console.log(JSON.stringefy(user))
```

Body:
Are there tools or techniques (other than repeated console.log() calls) to view the javascript object model used in a web page in real time? eg something like:

    firstUser (User)
    -- userName Joe Bloggs (String)
    -- userEmail joe.bloggs@gmail.com (String)
    -- userSelections (Array)
    ----[1,2,4]

    secondUser (User)
    -- userName John Doe (String)
    -- userEmail jogn.doe@gmail.com (String)
    -- userSelections (Array)
    ----[1,2,3]

I know this can be achieved using console.log(firstUser) and console.log(secondUser) but it would be useful to be able to display the entire data model so that I can see variables being altered in real time.


问:
FAB inside FrameLayout to be on top of fragments
In my layout I have a FrameLayout in which I intend to display different layouts depending on user input. I want to display a FloatingActionButton in all those layouts.

In order to not repeat the FloatingActionButton in all of them, I want to have it attached to the FrameLayout. The problem is that the button is not displayed correctly on top of the fragment layout. For example, the initial fragment displayed, has a GridView and the button is behind it.

activity_main.xml:

```<code><?xml version="1.0" encoding="utf-8"?>
<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="xeniasis.mymarket.MainActivity">

    <include
        android:id="@+id/toolbar"
        layout="@layout/toolbar" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:baselineAligned="false"
        android:orientation="horizontal"
        android:weightSum="4">

        <LinearLayout
            android:id="@+id/categories_layout"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:paddingRight="20dp">

            <ExpandableListView
                android:id="@+id/categories_listView"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />
        </LinearLayout>

        <FrameLayout
            android:id="@+id/mainPane"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="3">

            <android.support.design.widget.FloatingActionButton
                android:id="@+id/settings"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom|start"
                android:layout_margin="8dp"
                android:clickable="true"
                android:elevation="5dp"
                android:src="@android:drawable/ic_menu_search" />
        </FrameLayout>
    </LinearLayout>
</LinearLayout>
</code>```

and the fragment layout displayed programmatically:

```<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="xeniasis.mymarket.MainActivity">

        <android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/swipeRefreshContainer"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:paddingBottom="@dimen/activity_vertical_margin"
            android:paddingLeft="8dp"
            android:paddingRight="8dp"
            android:paddingTop="@dimen/activity_vertical_margin">

            <GridView
                android:id="@+id/productsGridview"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_alignParentLeft="true"
                android:layout_alignParentRight="true"
                android:layout_alignParentTop="true"
                android:numColumns="3"></GridView>

        </android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>
</code>```

The result:

答:
You can add the layout_gravity to the FAB, and then you can set it in any corner you want.

For Setting at right bottom:

```<code>android:layout_gravity="right|bottom"
</code>```

For Setting at left bottom:

```<code>android:layout_gravity="left|bottom"
</code>```

For Setting at left top:

```<code>android:layout_gravity="left|top"
</code>```

For Setting at right top:

```<code>android:layout_gravity="right|top"
</code>```

Body:
In my layout I have a FrameLayout in which I intend to display different layouts depending on user input. I want to display a FloatingActionButton in all those layouts.

In order to not repeat the FloatingActionButton in all of them, I want to have it attached to the FrameLayout. The problem is that the button is not displayed correctly on top of the fragment layout. For example, the initial fragment displayed, has a GridView and the button is behind it.

activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<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="xeniasis.mymarket.MainActivity">

    <include
        android:id="@+id/toolbar"
        layout="@layout/toolbar" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:baselineAligned="false"
        android:orientation="horizontal"
        android:weightSum="4">

        <LinearLayout
            android:id="@+id/categories_layout"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:paddingRight="20dp">

            <ExpandableListView
                android:id="@+id/categories_listView"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />
        </LinearLayout>

        <FrameLayout
            android:id="@+id/mainPane"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="3">

            <android.support.design.widget.FloatingActionButton
                android:id="@+id/settings"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom|start"
                android:layout_margin="8dp"
                android:clickable="true"
                android:elevation="5dp"
                android:src="@android:drawable/ic_menu_search" />
        </FrameLayout>
    </LinearLayout>
</LinearLayout>

and the fragment layout displayed programmatically:

<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="xeniasis.mymarket.MainActivity">

        <android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/swipeRefreshContainer"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:paddingBottom="@dimen/activity_vertical_margin"
            android:paddingLeft="8dp"
            android:paddingRight="8dp"
            android:paddingTop="@dimen/activity_vertical_margin">

            <GridView
                android:id="@+id/productsGridview"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_alignParentLeft="true"
                android:layout_alignParentRight="true"
                android:layout_alignParentTop="true"
                android:numColumns="3"></GridView>

        </android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>

The result:

Body:
You can add the layout_gravity to the FAB, and then you can set it in any corner you want.

For Setting at right bottom:

android:layout_gravity="right|bottom"

For Setting at left bottom:

android:layout_gravity="left|bottom"

For Setting at left top:

android:layout_gravity="left|top"

For Setting at right top:

android:layout_gravity="right|top"


问:
WebSocket and/or Request-Response
I'm creating a chat application, and one detail is that "acknowledgements" are crucial. I'll get to what that means. I'm trying to figure out what the best exchange protocol would be.

Scenario:
Alice sends Bob a message. Bob is offline, so the message is stored on the server. Bob connects to the server through a WebSocket connection. The server sends him messages that have been sent to him while he was away. This is where the problem arises. The WS API that's available for my app's ecosystem (Node.js, Nest.js specifically), has no pattern where it can wait for this message to be sent. The mechanism there seems to just be fire & forget. What if the payload is quite large and the connection drops while the message is being sent?

Now, I know socket.io has support for acknowledgements. But from what I've read, socket.io has some overhead and therefore less performance than optimal. Now whether that performance is something that I arguably need is another question, but I'm just trying to figure out how I can guarantee that the message has arrived on the other end. This means client-server and server-client directions. How can I await it? I know that one approach is to attach a unique ID to the socket event, and have the other side send you a confirmation that it received it. This is how socket.io does it if I'm not mistaken.
But my question there is how can I guarantee that the acknowledgement message was successfully sent? So then I'd need an "ack" for my "ack" and so on, so I'll always need one more acknowledgement so I don't know how that works.

What I though of as options is to use two REST endpoints to send and receive (or download) messages. You send when you send, but you receive when you receive a ping that there's messages for you to download. Now this could be done through a WebSocket connection where the server notifies the client about a new message and then the client can call this receive endpoint. This ping can also be done through a more managed solution like FCM. The pros with that approach are twofold:

First, I have the REST interface to use, which is a lot more practical

I have the Request-Response pattern to use, so I have a theoretical guarantee that things are arriving if I get a response

Now the problem with this approach is that there's a lot of overhead from opening a new HTTP connection every time I want to send or receive messages, if I'm not mistaken:

I have to wait for the initial request time to get to the server before I actually have to wait for the server to respond with messages. With the pure WebSockets case, I would theoretically then just wait for the response equivalent part there (?)

This wastes bandwidth as well.

So one more question, where can I find out which clients will actually re-use an existing HTTP connection like a WebSocket connection, if available and not create a new one? Do all clients do that? Is it only the browser? What about apps? Is it on the OS level?

So the final question is how do I solve this problem of "acknowledgements" and not waste time and bandwidth? Are any of my conclusion/questions wrong or uninformed, am I missing something?

Notes:

server is Node.js and client is Flutter

i know about the WAMP subprotocol, but for my ecosystem it doesn't have very reliable implementations

答:
I'm not sure what your exact requirements or performance need,
but I did a project that also need reliable communication between client and server using websocket, the simplest I could think of was build request-response mechanism on top of websocket, and then build your application data on top of that.

here's high level overview how I implemented it:

implement request-response message using transaction to identify which response belongs to which request.

clients will have map storing transaction, when you send the message request wait for server to send a message response with the same transaction or wait
until timeout.

client wants to send message to server and construct the request as follow

```<code>{
  "event": "sendMessage",
  "type": "request",
  "transaction": "<uuid/unique-value>",
  "data": "<your-application-data>"
}
</code>```

server parse the message and check that its a request with an event name sendMessage then call related function

server sends back response message to client

```<code>{
  "event": "sendMessage",
  "type": "response",
  "transaction": "<uuid/unique-value>", // same unique value as in request
  "data": "<your-application-data-result>"
}
</code>```

because client has mapping which transaction belongs to which request, it is possible to match which request this response belongs to, if matched then complete the transaction

Title: WebSocket and/or Request-Response

Body:
I'm not sure what your exact requirements or performance need,
but I did a project that also need reliable communication between client and server using websocket, the simplest I could think of was build request-response mechanism on top of websocket, and then build your application data on top of that.

here's high level overview how I implemented it:

implement request-response message using transaction to identify which response belongs to which request.

clients will have map storing transaction, when you send the message request wait for server to send a message response with the same transaction or wait
until timeout.

client wants to send message to server and construct the request as follow

{
  "event": "sendMessage",
  "type": "request",
  "transaction": "<uuid/unique-value>",
  "data": "<your-application-data>"
}

server parse the message and check that its a request with an event name sendMessage then call related function

server sends back response message to client

{
  "event": "sendMessage",
  "type": "response",
  "transaction": "<uuid/unique-value>", // same unique value as in request
  "data": "<your-application-data-result>"
}

because client has mapping which transaction belongs to which request, it is possible to match which request this response belongs to, if matched then complete the transaction


问:
How to get to postgres database at localhost from Django in Docker container
I have a django in a docker container that must access a postgres database at my localhost. The Dockerfile works fine when accessing the database residing at an external host, but it can't find the database at my host.

It is a well known problem and there is a lot of documentation, but it doesn't work in my case. This question resembles another question but it did not solve my problem. I actually describe the correct solution of this problem as @Zeitounator pointed out, but it still did not work. It was thanks @Zeitounator that I realised two parts of the problem must be solved: the docker side and the PostgreSQL side. I did not find that solution in any of the answers I read. I did however read about the same frustration: getting a solution that did not work.

It all focuses on which internet address I transmit to the HOST key in the database driver dictionary in the django settings.py:

```<code>print('***', os.environ['POSTGRES_DB'], os.environ['POSTGRES_USER'],
        os.environ['POSTGRES_HOST'], os.environ['POSTGRES_PORT'])

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2', # os.environ['ENGINE'],
        'NAME': 'demo',
        'USER': os.environ['POSTGRES_USER'],
        'PASSWORD': os.environ['POSTGRES_PASSWORD'],
        'HOST': os.environ['POSTGRES_HOST'],
    }
}
</code>```

And running the Dockerfile:

```<code>docker build -t dd .
docker run --name demo -p 8000:8000 --rm dd
</code>```

When POSTGRES_HOST points to my external server 192.168.178.100 it works great. When running python manage.py runserver it finds the host and the database. The server starts and waits for commands. When pointing to 127.0.0.1 it fails (which actually is great too: the container really isolates).

```<code>django.db.utils.OperationalError: could not connect to server: Connection refused
    Is the server running on host "127.0.0.1" and accepting
    TCP/IP connections on port 5432?
</code>```

But as I can connect to my server, I should be able to connect to the localhost IP and that fails just as well (I forgot to tell that the database really runs). When I use host.docker.internal it doesn't work either when running:

```<code>docker run --name demo -p 8000:8000 --rm --add-host host.docker.internal:host-gateway dd
</code>```

It replaces host.docker.internal by 172.17.0.1. The only solution that works so far is:

```<code># set POSTGRES_HOST at 127.0.0.1
docker run --name demo -p 8000:8000 --rm --network host dd
</code>```

but that seems something I don't want. As far as I understand the documentation it makes the full host stack available to the container which defeats the idea of a container in the first place. But second: it doesn't work in docker-compose, though I specify:

```<code>extra_hosts:
  - "host.docker.internal:host-gateway"
</code>```

network_mode: host leads to a compile error, docker-compose refuses to run.

Is there a way to access a service running on my PC from a docker running on my PC as well from Dockerfile as well as docker-compose and can be deployed as well?

using Ubuntu 21.04 (latest version), Docker version 20.10.7, build 20.10.7-0ubuntu5.1, postgresql v14. My Dockerfile:

```<code>FROM python:3

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

RUN mkdir /app

WORKDIR /app

COPY . .

RUN pip install -r requirements.txt

CMD ["python", "manage.py", "runserver", "127.0.0.1:8000"]
</code>```

答:
There are two parts in solving this problem: the docker part and the postgresql part as @Zeitounator pointed out. I was not aware of the postgres part. Thanks to his comment I could resolve this issue. And it works for Dockerfile as well as docker-compose where this Dockerfile is used.

One has to change two postgres configuration files, both are on /etc/postgresql/<version>/main:

postgresql.conf

Change the listen address. Initially it shows:

```<code>listen_addresses = 'localhost'      # what IP address(es) to listen on;
                    # comma-separated list of addresses;
                    # defaults to 'localhost'; use '*' for all
                    # (change requires restart)
</code>```

I changed 'localhost' to '*'. It can be more specific, in this case to the docker address, but as a Proof of Concept it worked.

pg_hba.conf

In my case host.docker.internal resolves to 172.17.0.1. This seems some default docker gateway address as I noticed in most discussion regarding this subject.
Add two lines at the very end of the file:

```<code>host    all             all              172.17.0.1/0                       md5
host    all             all              ::ffff:ac11:1/0                            md5
</code>```

Body:
I have a django in a docker container that must access a postgres database at my localhost. The Dockerfile works fine when accessing the database residing at an external host, but it can't find the database at my host.

It is a well known problem and there is a lot of documentation, but it doesn't work in my case. This question resembles another question but it did not solve my problem. I actually describe the correct solution of this problem as @Zeitounator pointed out, but it still did not work. It was thanks @Zeitounator that I realised two parts of the problem must be solved: the docker side and the PostgreSQL side. I did not find that solution in any of the answers I read. I did however read about the same frustration: getting a solution that did not work.

It all focuses on which internet address I transmit to the HOST key in the database driver dictionary in the django settings.py:

print('***', os.environ['POSTGRES_DB'], os.environ['POSTGRES_USER'],
        os.environ['POSTGRES_HOST'], os.environ['POSTGRES_PORT'])

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2', # os.environ['ENGINE'],
        'NAME': 'demo',
        'USER': os.environ['POSTGRES_USER'],
        'PASSWORD': os.environ['POSTGRES_PASSWORD'],
        'HOST': os.environ['POSTGRES_HOST'],
    }
}

And running the Dockerfile:

docker build -t dd .
docker run --name demo -p 8000:8000 --rm dd

When POSTGRES_HOST points to my external server 192.168.178.100 it works great. When running python manage.py runserver it finds the host and the database. The server starts and waits for commands. When pointing to 127.0.0.1 it fails (which actually is great too: the container really isolates).

django.db.utils.OperationalError: could not connect to server: Connection refused
    Is the server running on host "127.0.0.1" and accepting
    TCP/IP connections on port 5432?

But as I can connect to my server, I should be able to connect to the localhost IP and that fails just as well (I forgot to tell that the database really runs). When I use host.docker.internal it doesn't work either when running:

docker run --name demo -p 8000:8000 --rm --add-host host.docker.internal:host-gateway dd

It replaces host.docker.internal by 172.17.0.1. The only solution that works so far is:

# set POSTGRES_HOST at 127.0.0.1
docker run --name demo -p 8000:8000 --rm --network host dd

but that seems something I don't want. As far as I understand the documentation it makes the full host stack available to the container which defeats the idea of a container in the first place. But second: it doesn't work in docker-compose, though I specify:

extra_hosts:
  - "host.docker.internal:host-gateway"

network_mode: host leads to a compile error, docker-compose refuses to run.

Is there a way to access a service running on my PC from a docker running on my PC as well from Dockerfile as well as docker-compose and can be deployed as well?

using Ubuntu 21.04 (latest version), Docker version 20.10.7, build 20.10.7-0ubuntu5.1, postgresql v14. My Dockerfile:

FROM python:3

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

RUN mkdir /app

WORKDIR /app

COPY . .

RUN pip install -r requirements.txt

CMD ["python", "manage.py", "runserver", "127.0.0.1:8000"]

Body:
There are two parts in solving this problem: the docker part and the postgresql part as @Zeitounator pointed out. I was not aware of the postgres part. Thanks to his comment I could resolve this issue. And it works for Dockerfile as well as docker-compose where this Dockerfile is used.

One has to change two postgres configuration files, both are on /etc/postgresql/<version>/main:

postgresql.conf

Change the listen address. Initially it shows:

listen_addresses = 'localhost'      # what IP address(es) to listen on;
                    # comma-separated list of addresses;
                    # defaults to 'localhost'; use '*' for all
                    # (change requires restart)

I changed 'localhost' to '*'. It can be more specific, in this case to the docker address, but as a Proof of Concept it worked.

pg_hba.conf

In my case host.docker.internal resolves to 172.17.0.1. This seems some default docker gateway address as I noticed in most discussion regarding this subject.
Add two lines at the very end of the file:

host    all             all              172.17.0.1/0                       md5
host    all             all              ::ffff:ac11:1/0                            md5


问:
Why am I getting an error in C# when mixing explicit implementation and polymorphism?
I am getting this error:

type  Bar does not implement interface IFoo

From this code:

```<code>public interface IFoo
{
   void DoA();

   void DoB();
}

public class Foo:IFoo
{

    void IFoo.DoA()
    {

    }

    void IFoo.DoB()
    {

   }
}

public class Bar:Foo
{

     void IFoo.DoA()
      {
          base.doA();

      }

      void IFoo.DoB()
      {
          base.doB();

      }
  }
</code>```

I am using C# 2.0.

What am I doing wrong?

答:
```<code>public class Bar : Foo, IFoo
{
    // Your code
}
</code>```

OwnerDisplayName: Sasha

LastEditorDisplayName: Sasha

ContentLicense: CC BY-SA 2.5

Body:
I am getting this error:

type  Bar does not implement interface IFoo

From this code:

public interface IFoo
{
   void DoA();

   void DoB();
}

public class Foo:IFoo
{

    void IFoo.DoA()
    {

    }

    void IFoo.DoB()
    {

   }
}

public class Bar:Foo
{

     void IFoo.DoA()
      {
          base.doA();

      }

      void IFoo.DoB()
      {
          base.doB();

      }
  }

I am using C# 2.0.

What am I doing wrong?


问:
How is working the "Query cost" in the execution plan?
I am trying to increase one of my request performance.
My request is made of 10 different select .

The actual production query is taking 36sec to execute.

If I display the execution plan, for one select I have a query cost of 18%.

So I change a in clause (in this select) with an xml query (http://www.codeproject.com/KB/database/InClauseAndSQLServer.aspx).

The new query now takes 28 sec to execute, but sql server tells me that the above select has a query cost of 100%. And this is the only change I made. And there is no parallelism in any query.

PRODUCTION :
36sec, my select is 18% (the others are 10%).

NEW VERSION :
28sec, my select is 100% (the others are 0%).

Do you have any idea how sql server compute this "query cost" ? (I start to believe that it's random or something like that).

答:
Query cost is a unitless measure of a combination of CPU cycles, memory, and disk IO.

Very often you will see operators or plans with a higher cost but faster execution time.

Primarily this is due to the difference in speed of the above three components.  CPU and Memory are fairly quick, and also uncommon as bottlenecks.  If you can shift some pressure from the disk IO subsystem to the CPU, the query may show a higher cost but should execute substantially faster.

If you want to get more detailed information about the execution of your specific queries, you can use:

```<code>SET STATISTICS IO ON
SET STATISTICS TIME ON
</code>```

This will output detailed information about CPU cycles, plan creation, and page reads (both from disk and from memory) to the messages tab.

Body:
Query cost is a unitless measure of a combination of CPU cycles, memory, and disk IO.

Very often you will see operators or plans with a higher cost but faster execution time.

Primarily this is due to the difference in speed of the above three components.  CPU and Memory are fairly quick, and also uncommon as bottlenecks.  If you can shift some pressure from the disk IO subsystem to the CPU, the query may show a higher cost but should execute substantially faster.

If you want to get more detailed information about the execution of your specific queries, you can use:

SET STATISTICS IO ON
SET STATISTICS TIME ON

This will output detailed information about CPU cycles, plan creation, and page reads (both from disk and from memory) to the messages tab.


问:
How can I load and merge several .txt files in a memory efficient way in python?
I am trying to read several (>1000) .txt files (on average approx. 700 MB, delimited, header-less CSV, without commas or other separator) and merge them into one pandas dataframe (to next run an analysis on the entire dataset).

I am running this through SSH on a HPC server, on which I requested 50GB RAM, 1 node, 1 task-per-node (that was all just a wild guess, as I have never done this before).

So far, my idea was this:

```<code>li = []

for filename in all_files:
    df = pd.read_csv(filename, sep=None, header=0, engine='python')
    li.append(df)

df = pd.concat(li, axis=0, ignore_index=True)
</code>```

but after a few hours and having loaded the approx. 360th file the process gets killed and I get the error message:

numpy.core._exceptions.MemoryError: Unable to allocate 1.11 GiB for an array with shape (10, 14921599) and data type float64

Do you have any idea how to load and merge the data more memory efficient? (I assume just requesting more RAM still does not get me through the entire set of .txt files!?)

Also, I would like to save the resulting dataframe in a 'memory-efficient' way afterwards, do you know the best way/format (csv?) to do that?

Any help would be much appreciated!

答:
as you said you have so many files and it needs so much memory so I suggest loading and saving all of the files in a single file in appending mode (append data to the previously saved data) like this

for filename in all_files:
    df = pd.read_csv(filename, sep=None, header=0, engine='python')
    df.to_csv('./data.csv', header=None, index=None, mode='a')
```
<p>after saving all of the files in single file now you can read the single file as a dataframe like this:</p>
<pre class="lang-py prettyprint-override"><code>df = pd.read_csv('./data.csv',header=None,index_col=False)
</code>```

after that if you have any issues with reading this file because of memory you can use a reader like this:

chunksize = 10 ** 6
with pd.read_csv('./data.csv',header=None,index_col=False, chunksize=chunksize) as reader:
    for chunk in reader:
        # Do What you want
```

Body:
I am trying to read several (>1000) .txt files (on average approx. 700 MB, delimited, header-less CSV, without commas or other separator) and merge them into one pandas dataframe (to next run an analysis on the entire dataset).

I am running this through SSH on a HPC server, on which I requested 50GB RAM, 1 node, 1 task-per-node (that was all just a wild guess, as I have never done this before).

So far, my idea was this:

li = []

for filename in all_files:
    df = pd.read_csv(filename, sep=None, header=0, engine='python')
    li.append(df)

df = pd.concat(li, axis=0, ignore_index=True)

but after a few hours and having loaded the approx. 360th file the process gets killed and I get the error message:

numpy.core._exceptions.MemoryError: Unable to allocate 1.11 GiB for an array with shape (10, 14921599) and data type float64

Do you have any idea how to load and merge the data more memory efficient? (I assume just requesting more RAM still does not get me through the entire set of .txt files!?)

Also, I would like to save the resulting dataframe in a 'memory-efficient' way afterwards, do you know the best way/format (csv?) to do that?

Any help would be much appreciated!

Body:
as you said you have so many files and it needs so much memory so I suggest loading and saving all of the files in a single file in appending mode (append data to the previously saved data) like this

for filename in all_files:
    df = pd.read_csv(filename, sep=None, header=0, engine='python')
    df.to_csv('./data.csv', header=None, index=None, mode='a')

after saving all of the files in single file now you can read the single file as a dataframe like this:

df = pd.read_csv('./data.csv',header=None,index_col=False)

after that if you have any issues with reading this file because of memory you can use a reader like this:

chunksize = 10 ** 6
with pd.read_csv('./data.csv',header=None,index_col=False, chunksize=chunksize) as reader:
    for chunk in reader:
        # Do What you want