问:
Flutter got No issues found but still can not get the packages after create project
Flutter got No issues found but still can not get the packages after create project with the "Got TLS error trying to find package cupertino_icons at https://pub.dartlang.org." error

I tried these:

Flutter app behind corporate firewall throws TLS error during packages get

Network Connection Proxies in Dart Editor

flutter -v doctor -v

```<code>[  +15 ms] executing: [Q:\Developer\flutter\] git rev-parse --abbrev-ref --symbolic @{u}
[ +722 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[   +2 ms] origin/stable
[        ] executing: [Q:\Developer\flutter\] git rev-parse --abbrev-ref HEAD
[ +612 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[   +1 ms] stable
[        ] executing: [Q:\Developer\flutter\] git ls-remote --get-url origin
[ +741 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[        ] executing: [Q:\Developer\flutter\] git log -n 1 --pretty=format:%H
[ +659 ms] Exit code 0 from: git log -n 1 --pretty=format:%H
[   +1 ms] 8661d8aecd626f7f57ccbcb735553edc05a2e713
[        ] executing: [Q:\Developer\flutter\] git log -n 1 --pretty=format:%ar
[ +675 ms] Exit code 0 from: git log -n 1 --pretty=format:%ar
[        ] 7 weeks ago
[        ] executing: [Q:\Developer\flutter\] git describe --match v*.*.* --first-parent --long --tags
[ +672 ms] Exit code 0 from: git describe --match v*.*.* --first-parent --long --tags
[   +1 ms] v1.2.1-0-g8661d8aec
[+3410 ms] java -version
[ +174 ms] [√] Flutter (Channel stable, v1.2.1, on Microsoft Windows [Version 10.0.16299.847], locale tr-TR)
[   +3 ms]     • Flutter version 1.2.1 at Q:\Developer\flutter
[   +1 ms]     • Framework revision 8661d8aecd (7 weeks ago), 2019-02-14 19:19:53 -0800
[        ]     • Engine revision 3757390fa4
[        ]     • Dart version 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)
\[   +2 ms] executing: C:\Users\Kafeduran.NTD_EBI\AppData\Local\Android\sdk\platform-tools\adb devices -l
[ +458 ms] Exit code 0 from: C:\Users\Kafeduran.NTD_EBI\AppData\Local\Android\sdk\platform-tools\adb devices -l
[   +1 ms] List of devices attached
           ad78615b               device product:gemini model:MI_5 device:gemini transport_id:1
[  +13 ms] C:\Users\Kafeduran.NTD_EBI\AppData\Local\Android\sdk\platform-tools\adb -s ad78615b shell getprop           |[ +551 ms] executing: C:\Users\Kafeduran.NTD_EBI\AppData\Local\Android\sdk\tools\bin\sdkmanager --licenses
[  +53 ms] ro.hardware = qcom                                                                                [+56173 ms] [√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[   +1 ms]     • Android SDK at C:\Users\Kafeduran.NTD_EBI\AppData\Local\Android\sdk
[   +1 ms]     • Android NDK location not configured (optional; useful for native profiling support)
[        ]     • Platform android-28, build-tools 28.0.3
[        ]     • Java binary at: Q:\Developer\android-studio\jre\bin\java
[        ]     • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
[        ]     • All Android licenses accepted.
[   +1 ms] [√] Android Studio (version 3.3)
[        ]     • Android Studio at Q:\Developer\android-studio
[        ]     • Flutter plugin version 34.0.1
[        ]     • Dart plugin version 182.5215
[        ]     • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
[        ] [√] IntelliJ IDEA Ultimate Edition (version 2019.1)
[        ]     • IntelliJ at Q:\Developer\editors
[        ]     • Flutter plugin version 34.0.4
[        ]     • Dart plugin version 191.6183.87
[   +1 ms] [√] VS Code, 64-bit edition (version 1.32.3)
[        ]     • VS Code at C:\Program Files\Microsoft VS Code
[        ]     • Flutter extension version 2.25.0
[        ] [√] Proxy Configuration
[        ]     • HTTP_PROXY is set
[        ]     • NO_PROXY is localhost,127.0.0.1
[        ]     • NO_PROXY contains 127.0.0.1
[        ]     • NO_PROXY contains localhost
[        ] [√] Connected device (1 available)
[        ]     • MI 5 • ad78615b • android-arm64 • Android 8.0.0 (API 26)
[        ] • No issues found!
[   +7 ms] "flutter doctor" took 60.205ms.
[        ] "flutter doctor" took 60.205ms.
</code>```

flutter -v create -v rad

```<code>[  +18 ms] executing: [Q:\Developer\flutter\] git rev-parse --abbrev-ref --symbolic @{u}
[ +703 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[   +2 ms] origin/stable
[        ] executing: [Q:\Developer\flutter\] git rev-parse --abbrev-ref HEAD
[ +626 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[   +1 ms] stable
[        ] executing: [Q:\Developer\flutter\] git ls-remote --get-url origin
[ +617 ms] Exit code 0 from: git ls-remote --get-url origin
[   +1 ms] https://github.com/flutter/flutter.git
[   +1 ms] executing: [Q:\Developer\flutter\] git log -n 1 --pretty=format:%H
[ +647 ms] Exit code 0 from: git log -n 1 --pretty=format:%H
[        ] 8661d8aecd626f7f57ccbcb735553edc05a2e713
[        ] executing: [Q:\Developer\flutter\] git log -n 1 --pretty=format:%ar
[ +646 ms] Exit code 0 from: git log -n 1 --pretty=format:%ar
[        ] 7 weeks ago
[   +1 ms] executing: [Q:\Developer\flutter\] git describe --match v*.*.* --first-parent --long --tags
[ +668 ms] Exit code 0 from: git describe --match v*.*.* --first-parent --long --tags
[   +1 ms] v1.2.1-0-g8661d8aec
[+1033 ms] Creating project rad...
[  +95 ms]   rad\.gitignore (created)
[  +12 ms]   rad\.idea\libraries\Dart_SDK.xml (created)
[  +11 ms]   rad\.idea\libraries\Flutter_for_Android.xml (created)
[   +4 ms]   rad\.idea\libraries\KotlinJavaRuntime.xml (created)
[   +4 ms]   rad\.idea\modules.xml (created)
[   +6 ms]   rad\.idea\runConfigurations\main_dart.xml (created)
[   +5 ms]   rad\.idea\workspace.xml (created)
[   +4 ms]   rad\.metadata (created)
[   +4 ms]   rad\android\app\build.gradle (created)
[   +8 ms]   rad\android\app\src\main\java\com\example\rad\MainActivity.java (created)
[  +19 ms]   rad\android\build.gradle (created)
[   +7 ms]   rad\android\rad_android.iml (created)
[   +6 ms]   rad\android\app\src\debug\AndroidManifest.xml (created)
[   +7 ms]   rad\android\app\src\main\AndroidManifest.xml (created)
[   +6 ms]   rad\android\app\src\main\res\drawable\launch_background.xml (created)
[  +11 ms]   rad\android\app\src\main\res\mipmap-hdpi\ic_launcher.png (created)
[   +9 ms]   rad\android\app\src\main\res\mipmap-mdpi\ic_launcher.png (created)
[  +10 ms]   rad\android\app\src\main\res\mipmap-xhdpi\ic_launcher.png (created)
[   +9 ms]   rad\android\app\src\main\res\mipmap-xxhdpi\ic_launcher.png (created)
[   +8 ms]   rad\android\app\src\main\res\mipmap-xxxhdpi\ic_launcher.png (created)
[  +10 ms]   rad\android\app\src\main\res\values\styles.xml (created)
[   +9 ms]   rad\android\app\src\profile\AndroidManifest.xml (created)
[   +9 ms]   rad\android\gradle\wrapper\gradle-wrapper.properties (created)
[   +8 ms]   rad\android\gradle.properties (created)
[   +4 ms]   rad\android\settings.gradle (created)
[   +4 ms]   rad\ios\Runner\AppDelegate.h (created)
[   +7 ms]   rad\ios\Runner\AppDelegate.m (created)
[   +4 ms]   rad\ios\Runner\main.m (created)
[   +4 ms]   rad\ios\Runner.xcodeproj\project.pbxproj (created)
[  +15 ms]   rad\ios\Runner.xcodeproj\xcshareddata\xcschemes\Runner.xcscheme (created)
[  +10 ms]   rad\ios\Flutter\AppFrameworkInfo.plist (created)
[   +8 ms]   rad\ios\Flutter\Debug.xcconfig (created)
[   +4 ms]   rad\ios\Flutter\Release.xcconfig (created)
[   +6 ms]   rad\ios\Runner\Assets.xcassets\AppIcon.appiconset\Contents.json (created)
[   +9 ms]   rad\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-1024x1024@1x.png (created)
[   +4 ms]   rad\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-20x20@1x.png (created)
[   +4 ms]   rad\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-20x20@2x.png (created)
[   +4 ms]   rad\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-20x20@3x.png (created)
[   +5 ms]   rad\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-29x29@1x.png (created)
[   +4 ms]   rad\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-29x29@2x.png (created)
[   +3 ms]   rad\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-29x29@3x.png (created)
[   +4 ms]   rad\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-40x40@1x.png (created)
[   +3 ms]   rad\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-40x40@2x.png (created)
[   +4 ms]   rad\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-40x40@3x.png (created)
[   +4 ms]   rad\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-60x60@2x.png (created)
[   +4 ms]   rad\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-60x60@3x.png (created)
[   +3 ms]   rad\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-76x76@1x.png (created)
[   +3 ms]   rad\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-76x76@2x.png (created)
[   +4 ms]   rad\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-83.5x83.5@2x.png (created)
[   +7 ms]   rad\ios\Runner\Assets.xcassets\LaunchImage.imageset\Contents.json (created)
[   +6 ms]   rad\ios\Runner\Assets.xcassets\LaunchImage.imageset\LaunchImage.png (created)
[   +5 ms]   rad\ios\Runner\Assets.xcassets\LaunchImage.imageset\LaunchImage@2x.png (created)
[   +3 ms]   rad\ios\Runner\Assets.xcassets\LaunchImage.imageset\LaunchImage@3x.png (created)
[   +3 ms]   rad\ios\Runner\Assets.xcassets\LaunchImage.imageset\README.md (created)
[   +6 ms]   rad\ios\Runner\Base.lproj\LaunchScreen.storyboard (created)
[   +6 ms]   rad\ios\Runner\Base.lproj\Main.storyboard (created)
[   +4 ms]   rad\ios\Runner\Info.plist (created)
[   +6 ms]   rad\ios\Runner.xcodeproj\project.xcworkspace\contents.xcworkspacedata (created)
[   +6 ms]   rad\ios\Runner.xcodeproj\xcshareddata\xcschemes\Runner.xcscheme (existing - skipped)
[   +2 ms]   rad\ios\Runner.xcworkspace\contents.xcworkspacedata (created)
[  +10 ms]   rad\lib\main.dart (created)
[   +8 ms]   rad\rad.iml (created)
[  +12 ms]   rad\pubspec.yaml (created)
[  +10 ms]   rad\README.md (created)
[   +9 ms]   rad\test\widget_test.dart (created)
[ +103 ms] Running "flutter packages get" in rad...
[   +5 ms] Using Q:\Developer\flutter\.pub-cache for the pub cache.
[   +2 ms] executing: [Q:\workspace\projects\rad\] Q:\Developer\flutter\bin\cache\dart-sdk\bin\pub.bat
--verbosity=warning --verbose get --no-precompile
[+66695 ms] Got TLS error trying to find package cupertino_icons at https://pub.dartlang.org.
[  +27 ms] pub get failed (69) -- attempting retry 1 in 1 second...
[+1019 ms] Using Q:\Developer\flutter\.pub-cache for the pub cache.
[   +2 ms] executing: [Q:\workspace\projects\rad\] Q:\Developer\flutter\bin\cache\dart-sdk\bin\pub.bat
--verbosity=warning --verbose get --no-precompile
[+68239 ms] Got TLS error trying to find package cupertino_icons at https://pub.dartlang.org.
[  +29 ms] pub get failed (69) -- attempting retry 2 in 2 seconds...
[+2012 ms] Using Q:\Developer\flutter\.pub-cache for the pub cache.
[   +2 ms] executing: [Q:\workspace\projects\rad\] Q:\Developer\flutter\bin\cache\dart-sdk\bin\pub.bat
--verbosity=warning --verbose get --no-precompile
[+66594 ms] Got TLS error trying to find package cupertino_icons at https://pub.dartlang.org.
[  +28 ms] pub get failed (69) -- attempting retry 3 in 4 seconds...
[+4008 ms] Using Q:\Developer\flutter\.pub-cache for the pub cache.
[   +3 ms] executing: [Q:\workspace\projects\rad\]
</code>```

Getting this error:
"Got TLS error trying to find package cupertino_icons at https://pub.dartlang.org."

It can not get packages. Do you have any idea what can I try to get rid of?

答: The issue seems that your Flutter project is unable to download packages. You should try uninstalling and reinstalling Flutter again and see if it works, similar to what has been suggested on this thread. It's possible that there's some components that you're using that were corrupted after an upgrade.</p>

Body:
Flutter got No issues found but still can not get the packages after create project with the "Got TLS error trying to find package cupertino_icons at https://pub.dartlang.org." error

I tried these:

Flutter app behind corporate firewall throws TLS error during packages get

Network Connection Proxies in Dart Editor

flutter -v doctor -v

[  +15 ms] executing: [Q:\Developer\flutter\] git rev-parse --abbrev-ref --symbolic @{u}
[ +722 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[   +2 ms] origin/stable
[        ] executing: [Q:\Developer\flutter\] git rev-parse --abbrev-ref HEAD
[ +612 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[   +1 ms] stable
[        ] executing: [Q:\Developer\flutter\] git ls-remote --get-url origin
[ +741 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[        ] executing: [Q:\Developer\flutter\] git log -n 1 --pretty=format:%H
[ +659 ms] Exit code 0 from: git log -n 1 --pretty=format:%H
[   +1 ms] 8661d8aecd626f7f57ccbcb735553edc05a2e713
[        ] executing: [Q:\Developer\flutter\] git log -n 1 --pretty=format:%ar
[ +675 ms] Exit code 0 from: git log -n 1 --pretty=format:%ar
[        ] 7 weeks ago
[        ] executing: [Q:\Developer\flutter\] git describe --match v*.*.* --first-parent --long --tags
[ +672 ms] Exit code 0 from: git describe --match v*.*.* --first-parent --long --tags
[   +1 ms] v1.2.1-0-g8661d8aec
[+3410 ms] java -version
[ +174 ms] [√] Flutter (Channel stable, v1.2.1, on Microsoft Windows [Version 10.0.16299.847], locale tr-TR)
[   +3 ms]     • Flutter version 1.2.1 at Q:\Developer\flutter
[   +1 ms]     • Framework revision 8661d8aecd (7 weeks ago), 2019-02-14 19:19:53 -0800
[        ]     • Engine revision 3757390fa4
[        ]     • Dart version 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)
\[   +2 ms] executing: C:\Users\Kafeduran.NTD_EBI\AppData\Local\Android\sdk\platform-tools\adb devices -l
[ +458 ms] Exit code 0 from: C:\Users\Kafeduran.NTD_EBI\AppData\Local\Android\sdk\platform-tools\adb devices -l
[   +1 ms] List of devices attached
           ad78615b               device product:gemini model:MI_5 device:gemini transport_id:1
[  +13 ms] C:\Users\Kafeduran.NTD_EBI\AppData\Local\Android\sdk\platform-tools\adb -s ad78615b shell getprop           |[ +551 ms] executing: C:\Users\Kafeduran.NTD_EBI\AppData\Local\Android\sdk\tools\bin\sdkmanager --licenses
[  +53 ms] ro.hardware = qcom                                                                                [+56173 ms] [√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[   +1 ms]     • Android SDK at C:\Users\Kafeduran.NTD_EBI\AppData\Local\Android\sdk
[   +1 ms]     • Android NDK location not configured (optional; useful for native profiling support)
[        ]     • Platform android-28, build-tools 28.0.3
[        ]     • Java binary at: Q:\Developer\android-studio\jre\bin\java
[        ]     • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
[        ]     • All Android licenses accepted.
[   +1 ms] [√] Android Studio (version 3.3)
[        ]     • Android Studio at Q:\Developer\android-studio
[        ]     • Flutter plugin version 34.0.1
[        ]     • Dart plugin version 182.5215
[        ]     • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
[        ] [√] IntelliJ IDEA Ultimate Edition (version 2019.1)
[        ]     • IntelliJ at Q:\Developer\editors
[        ]     • Flutter plugin version 34.0.4
[        ]     • Dart plugin version 191.6183.87
[   +1 ms] [√] VS Code, 64-bit edition (version 1.32.3)
[        ]     • VS Code at C:\Program Files\Microsoft VS Code
[        ]     • Flutter extension version 2.25.0
[        ] [√] Proxy Configuration
[        ]     • HTTP_PROXY is set
[        ]     • NO_PROXY is localhost,127.0.0.1
[        ]     • NO_PROXY contains 127.0.0.1
[        ]     • NO_PROXY contains localhost
[        ] [√] Connected device (1 available)
[        ]     • MI 5 • ad78615b • android-arm64 • Android 8.0.0 (API 26)
[        ] • No issues found!
[   +7 ms] "flutter doctor" took 60.205ms.
[        ] "flutter doctor" took 60.205ms.

flutter -v create -v rad

[  +18 ms] executing: [Q:\Developer\flutter\] git rev-parse --abbrev-ref --symbolic @{u}
[ +703 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[   +2 ms] origin/stable
[        ] executing: [Q:\Developer\flutter\] git rev-parse --abbrev-ref HEAD
[ +626 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[   +1 ms] stable
[        ] executing: [Q:\Developer\flutter\] git ls-remote --get-url origin
[ +617 ms] Exit code 0 from: git ls-remote --get-url origin
[   +1 ms] https://github.com/flutter/flutter.git
[   +1 ms] executing: [Q:\Developer\flutter\] git log -n 1 --pretty=format:%H
[ +647 ms] Exit code 0 from: git log -n 1 --pretty=format:%H
[        ] 8661d8aecd626f7f57ccbcb735553edc05a2e713
[        ] executing: [Q:\Developer\flutter\] git log -n 1 --pretty=format:%ar
[ +646 ms] Exit code 0 from: git log -n 1 --pretty=format:%ar
[        ] 7 weeks ago
[   +1 ms] executing: [Q:\Developer\flutter\] git describe --match v*.*.* --first-parent --long --tags
[ +668 ms] Exit code 0 from: git describe --match v*.*.* --first-parent --long --tags
[   +1 ms] v1.2.1-0-g8661d8aec
[+1033 ms] Creating project rad...
[  +95 ms]   rad\.gitignore (created)
[  +12 ms]   rad\.idea\libraries\Dart_SDK.xml (created)
[  +11 ms]   rad\.idea\libraries\Flutter_for_Android.xml (created)
[   +4 ms]   rad\.idea\libraries\KotlinJavaRuntime.xml (created)
[   +4 ms]   rad\.idea\modules.xml (created)
[   +6 ms]   rad\.idea\runConfigurations\main_dart.xml (created)
[   +5 ms]   rad\.idea\workspace.xml (created)
[   +4 ms]   rad\.metadata (created)
[   +4 ms]   rad\android\app\build.gradle (created)
[   +8 ms]   rad\android\app\src\main\java\com\example\rad\MainActivity.java (created)
[  +19 ms]   rad\android\build.gradle (created)
[   +7 ms]   rad\android\rad_android.iml (created)
[   +6 ms]   rad\android\app\src\debug\AndroidManifest.xml (created)
[   +7 ms]   rad\android\app\src\main\AndroidManifest.xml (created)
[   +6 ms]   rad\android\app\src\main\res\drawable\launch_background.xml (created)
[  +11 ms]   rad\android\app\src\main\res\mipmap-hdpi\ic_launcher.png (created)
[   +9 ms]   rad\android\app\src\main\res\mipmap-mdpi\ic_launcher.png (created)
[  +10 ms]   rad\android\app\src\main\res\mipmap-xhdpi\ic_launcher.png (created)
[   +9 ms]   rad\android\app\src\main\res\mipmap-xxhdpi\ic_launcher.png (created)
[   +8 ms]   rad\android\app\src\main\res\mipmap-xxxhdpi\ic_launcher.png (created)
[  +10 ms]   rad\android\app\src\main\res\values\styles.xml (created)
[   +9 ms]   rad\android\app\src\profile\AndroidManifest.xml (created)
[   +9 ms]   rad\android\gradle\wrapper\gradle-wrapper.properties (created)
[   +8 ms]   rad\android\gradle.properties (created)
[   +4 ms]   rad\android\settings.gradle (created)
[   +4 ms]   rad\ios\Runner\AppDelegate.h (created)
[   +7 ms]   rad\ios\Runner\AppDelegate.m (created)
[   +4 ms]   rad\ios\Runner\main.m (created)
[   +4 ms]   rad\ios\Runner.xcodeproj\project.pbxproj (created)
[  +15 ms]   rad\ios\Runner.xcodeproj\xcshareddata\xcschemes\Runner.xcscheme (created)
[  +10 ms]   rad\ios\Flutter\AppFrameworkInfo.plist (created)
[   +8 ms]   rad\ios\Flutter\Debug.xcconfig (created)
[   +4 ms]   rad\ios\Flutter\Release.xcconfig (created)
[   +6 ms]   rad\ios\Runner\Assets.xcassets\AppIcon.appiconset\Contents.json (created)
[   +9 ms]   rad\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-1024x1024@1x.png (created)
[   +4 ms]   rad\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-20x20@1x.png (created)
[   +4 ms]   rad\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-20x20@2x.png (created)
[   +4 ms]   rad\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-20x20@3x.png (created)
[   +5 ms]   rad\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-29x29@1x.png (created)
[   +4 ms]   rad\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-29x29@2x.png (created)
[   +3 ms]   rad\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-29x29@3x.png (created)
[   +4 ms]   rad\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-40x40@1x.png (created)
[   +3 ms]   rad\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-40x40@2x.png (created)
[   +4 ms]   rad\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-40x40@3x.png (created)
[   +4 ms]   rad\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-60x60@2x.png (created)
[   +4 ms]   rad\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-60x60@3x.png (created)
[   +3 ms]   rad\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-76x76@1x.png (created)
[   +3 ms]   rad\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-76x76@2x.png (created)
[   +4 ms]   rad\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-83.5x83.5@2x.png (created)
[   +7 ms]   rad\ios\Runner\Assets.xcassets\LaunchImage.imageset\Contents.json (created)
[   +6 ms]   rad\ios\Runner\Assets.xcassets\LaunchImage.imageset\LaunchImage.png (created)
[   +5 ms]   rad\ios\Runner\Assets.xcassets\LaunchImage.imageset\LaunchImage@2x.png (created)
[   +3 ms]   rad\ios\Runner\Assets.xcassets\LaunchImage.imageset\LaunchImage@3x.png (created)
[   +3 ms]   rad\ios\Runner\Assets.xcassets\LaunchImage.imageset\README.md (created)
[   +6 ms]   rad\ios\Runner\Base.lproj\LaunchScreen.storyboard (created)
[   +6 ms]   rad\ios\Runner\Base.lproj\Main.storyboard (created)
[   +4 ms]   rad\ios\Runner\Info.plist (created)
[   +6 ms]   rad\ios\Runner.xcodeproj\project.xcworkspace\contents.xcworkspacedata (created)
[   +6 ms]   rad\ios\Runner.xcodeproj\xcshareddata\xcschemes\Runner.xcscheme (existing - skipped)
[   +2 ms]   rad\ios\Runner.xcworkspace\contents.xcworkspacedata (created)
[  +10 ms]   rad\lib\main.dart (created)
[   +8 ms]   rad\rad.iml (created)
[  +12 ms]   rad\pubspec.yaml (created)
[  +10 ms]   rad\README.md (created)
[   +9 ms]   rad\test\widget_test.dart (created)
[ +103 ms] Running "flutter packages get" in rad...
[   +5 ms] Using Q:\Developer\flutter\.pub-cache for the pub cache.
[   +2 ms] executing: [Q:\workspace\projects\rad\] Q:\Developer\flutter\bin\cache\dart-sdk\bin\pub.bat
--verbosity=warning --verbose get --no-precompile
[+66695 ms] Got TLS error trying to find package cupertino_icons at https://pub.dartlang.org.
[  +27 ms] pub get failed (69) -- attempting retry 1 in 1 second...
[+1019 ms] Using Q:\Developer\flutter\.pub-cache for the pub cache.
[   +2 ms] executing: [Q:\workspace\projects\rad\] Q:\Developer\flutter\bin\cache\dart-sdk\bin\pub.bat
--verbosity=warning --verbose get --no-precompile
[+68239 ms] Got TLS error trying to find package cupertino_icons at https://pub.dartlang.org.
[  +29 ms] pub get failed (69) -- attempting retry 2 in 2 seconds...
[+2012 ms] Using Q:\Developer\flutter\.pub-cache for the pub cache.
[   +2 ms] executing: [Q:\workspace\projects\rad\] Q:\Developer\flutter\bin\cache\dart-sdk\bin\pub.bat
--verbosity=warning --verbose get --no-precompile
[+66594 ms] Got TLS error trying to find package cupertino_icons at https://pub.dartlang.org.
[  +28 ms] pub get failed (69) -- attempting retry 3 in 4 seconds...
[+4008 ms] Using Q:\Developer\flutter\.pub-cache for the pub cache.
[   +3 ms] executing: [Q:\workspace\projects\rad\]

Getting this error:
"Got TLS error trying to find package cupertino_icons at https://pub.dartlang.org."

It can not get packages. Do you have any idea what can I try to get rid of?


来源: stackexchange

问:
regeneratorRuntime is not defined - onnxruntime-web-bundler
I tried to replicate the example found here: https://github.com/microsoft/onnxruntime-inference-examples/tree/main/js/quick-start_onnxruntime-web-bundler:

```<code>import * as React from 'react';

import ort from 'onnxruntime-web'
import regeneratorRuntime from 'regenerator-runtime'

function App_F() {

  // https://github.com/microsoft/onnxruntime-inference-examples/blob/main/js/quick-start_onnxruntime-web-bundler/main.js

  const onnxFunct = async () => {
    try {
      // create a new session and load the specific model

      // the model in this example contains a single MatMul node
      // it has 2 inputs: 'a'(float32, 3x4) and 'b'(float32, 4x3)
      // it has 1 output: 'c'(float32, 3x3)
      const session = await ort.InferenceSession.create('../../assets/onnx/model.onnx');

      //const dataA =  Float32Array.from([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])
      //const dataB = Float32Array.from([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120])
      //const tensorA = new ort.Tensor('float32', dataA, [3, 4])
      //const tensorB = new ort.Tensor('float32', dataB, [4, 3])

      // prepare feeds. use model input names as keys
      //const feeds = { a: tensorA, b: tensorB }

      // feed inputs and run
      //const results = await session.run(feeds)

      // read from results
      //const dataC = results.c.data
      //console.log(`data of result rensor 'c': ${dataC}`)

    } catch (e) {
      console.log(`failed to inference ONNX model: ${e}. `)
    }
  }

  return (
    <div className='container'>
      <h1 className='heading'>
          F
      </h1>

    </div>
  );
}

export default App_F;
</code>```

In webpack.config.js :

```<code>      new CopyPlugin({
        patterns: [
          {
            from: path.resolve(__dirname, "./node_modules/onnxruntime-web/dist/*.wasm"),
            to: path.resolve(__dirname, "[name][ext]")
          },
          {
            from: path.resolve(__dirname, "./src/assets/onnx"),
            to: path.resolve(__dirname, "./dist/assets/onnx")
          }
</code>```

As suggested here: regeneratorRuntime is not defined in TypeScript run in web

I tried to convert "target": "ESNext" ---> "target": "es5"  in tsconfig.json:

tsconfig.json :

```<code>{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "lib": ["dom", "es2015", "ESNext"],
    "outDir": "dist",
    //"jsx": "react",
    "jsx": "react-jsx",
    "baseUrl": "./src",
    "paths": {
      "@sections/*": ["app/sections/*"],
      "@app/*": ["app/*"]
    },
    "strict": true,
    "sourceMap": true,
    "skipLibCheck": true,
    "noImplicitAny": false,
    "noImplicitThis": false,
    "moduleResolution": "node",
    "esModuleInterop": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "resolveJsonModule": true,
    "allowJs": true
  },
  "include": ["src/**/*"],
  "exclude": [
    "src/index.js",
    "dist",
  ]
}
</code>```

But I get this error message : regeneratorRuntime is not defined

How to solve the problem?

答:
I solved the issue following the indications found here:Uncaught ReferenceError: regeneratorRuntime is not defined in React

I added in package.json :

```<code>"browserslist": [
  "last 2 Chrome versions"
]
</code>```

Now I get another error : failed to inference ONNX model: TypeError: Cannot read properties of undefined (reading 'InferenceSession') , but that's a different issue

ContentLicense: CC BY-SA 4.0

Body:
I tried to replicate the example found here: https://github.com/microsoft/onnxruntime-inference-examples/tree/main/js/quick-start_onnxruntime-web-bundler:

import * as React from 'react';

import ort from 'onnxruntime-web'
import regeneratorRuntime from 'regenerator-runtime'

function App_F() {

  // https://github.com/microsoft/onnxruntime-inference-examples/blob/main/js/quick-start_onnxruntime-web-bundler/main.js

  const onnxFunct = async () => {
    try {
      // create a new session and load the specific model

      // the model in this example contains a single MatMul node
      // it has 2 inputs: 'a'(float32, 3x4) and 'b'(float32, 4x3)
      // it has 1 output: 'c'(float32, 3x3)
      const session = await ort.InferenceSession.create('../../assets/onnx/model.onnx');

      //const dataA =  Float32Array.from([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])
      //const dataB = Float32Array.from([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120])
      //const tensorA = new ort.Tensor('float32', dataA, [3, 4])
      //const tensorB = new ort.Tensor('float32', dataB, [4, 3])

      // prepare feeds. use model input names as keys
      //const feeds = { a: tensorA, b: tensorB }

      // feed inputs and run
      //const results = await session.run(feeds)

      // read from results
      //const dataC = results.c.data
      //console.log(`data of result rensor 'c': ${dataC}`)

    } catch (e) {
      console.log(`failed to inference ONNX model: ${e}. `)
    }
  }

  return (

          F

  );
}

export default App_F;

In webpack.config.js :

      new CopyPlugin({
        patterns: [
          {
            from: path.resolve(__dirname, "./node_modules/onnxruntime-web/dist/*.wasm"),
            to: path.resolve(__dirname, "[name][ext]")
          },
          {
            from: path.resolve(__dirname, "./src/assets/onnx"),
            to: path.resolve(__dirname, "./dist/assets/onnx")
          }

As suggested here: regeneratorRuntime is not defined in TypeScript run in web

I tried to convert "target": "ESNext" ---> "target": "es5"  in tsconfig.json:

tsconfig.json :

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "lib": ["dom", "es2015", "ESNext"],
    "outDir": "dist",
    //"jsx": "react",
    "jsx": "react-jsx",
    "baseUrl": "./src",
    "paths": {
      "@sections/*": ["app/sections/*"],
      "@app/*": ["app/*"]
    },
    "strict": true,
    "sourceMap": true,
    "skipLibCheck": true,
    "noImplicitAny": false,
    "noImplicitThis": false,
    "moduleResolution": "node",
    "esModuleInterop": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "resolveJsonModule": true,
    "allowJs": true
  },
  "include": ["src/**/*"],
  "exclude": [
    "src/index.js",
    "dist",
  ]
}

But I get this error message : regeneratorRuntime is not defined

How to solve the problem?

Body:
I solved the issue following the indications found here:Uncaught ReferenceError: regeneratorRuntime is not defined in React

I added in package.json :

"browserslist": [
  "last 2 Chrome versions"
]

Now I get another error : failed to inference ONNX model: TypeError: Cannot read properties of undefined (reading 'InferenceSession') , but that's a different issue


问:
Can I Use Task.CompletedTask to Detect if Virtual Method was Overridden?
I have an asp.net core web application with an abstract class with a virtual method that child classes may or may not override. I want to execute different logic based on whether it was overridden or not and was wondering if the below check is a good idea or not:

```<code>public abstract class BaseClass
{
    public async Task DoSomethingAsync()
    {
        var task = OverrideMe();
        bool wasOverridden = task != Task.CompletedTask;
        await task;

        if (wasOverridden)
        {
            //Virtual method was overridden
        }
        else
        {
            //Virtual method was not overridden
        }
    }

    protected virtual Task OverrideMe()
    {
        return Task.CompletedTask;
    }
}
</code>```

I realize that if the child class returns Task.CompletedTask it would still look like it wasn't overridden. But if we ignore that fact, would this check work? What I'm most concerned about is the Id field of the task. Would that change and maybe cause the equality comparison to fail? When I test my code above it works but what if there are other async tasks running in parallel etc?

答:
First, I recommend re-addressing the design. If possible, a base class should not change behavior when a derived class overrides a method. Perhaps the base type should define a property of an interface type that the derived type could choose set or leave null. Bottom line is that "detecting whether an override exists" is a huge red flag from a design perspective.

That said, I have done it once in my (almost) 25 years of programming. My ConnectedProperties library has a validation check to attempt to ensure correct usage; connected properties only work for types treated as reference types, so it checks if the type overrides Equals as a heuristic for "type treated as a value type".

If you must use this questionable design, then reflection is the only real way to go; find the methods on that type hierarchy matching the name and parameters of OverrideMe and then check to see whether their base definitions are the OverrideMe from the base type.

Body:
I have an asp.net core web application with an abstract class with a virtual method that child classes may or may not override. I want to execute different logic based on whether it was overridden or not and was wondering if the below check is a good idea or not:

public abstract class BaseClass
{
    public async Task DoSomethingAsync()
    {
        var task = OverrideMe();
        bool wasOverridden = task != Task.CompletedTask;
        await task;

        if (wasOverridden)
        {
            //Virtual method was overridden
        }
        else
        {
            //Virtual method was not overridden
        }
    }

    protected virtual Task OverrideMe()
    {
        return Task.CompletedTask;
    }
}

I realize that if the child class returns Task.CompletedTask it would still look like it wasn't overridden. But if we ignore that fact, would this check work? What I'm most concerned about is the Id field of the task. Would that change and maybe cause the equality comparison to fail? When I test my code above it works but what if there are other async tasks running in parallel etc?


问:
How to get storage information of the EFI partition?
How can I get the size and current usage of the EFI partition on a disk?

I see that I can use the following command to at least the size of the partition, but I haven't found anything about how to get the current utilization:

get-partition |Where-Object{ $_.GptType -eq "{c12a7328-f81f-11d2-ba4b-00a0c93ec93b}"} |Select Size

答:
As @JeroenMostert mentioned in the comments, this will work well:

```<code>Get-Volume -UniqueId "\\?\Volume$(((Get-Partition).Where{$_.GptType -eq '{c12a7328-f81f-11d2-ba4b-00a0c93ec93b}'}.Guid))\" | Select-Object Size, SizeRemaining
</code>```

The GPT type is the GUID of the EFI partition on Windows, as seen here. This Unique ID is then passed into Get-Volume and will allow one to pull back the size & utilization information.

Body:
As @JeroenMostert mentioned in the comments, this will work well:

Get-Volume -UniqueId "\\?\Volume$(((Get-Partition).Where{$_.GptType -eq '{c12a7328-f81f-11d2-ba4b-00a0c93ec93b}'}.Guid))\" | Select-Object Size, SizeRemaining

The GPT type is the GUID of the EFI partition on Windows, as seen here. This Unique ID is then passed into Get-Volume and will allow one to pull back the size & utilization information.


问:
Rest API design: Managing access to sub-entities
Note: I realize that this is close to being off-topic for being opinion-based, but I am hoping that there is some accepted best practice to handle this that I just don't know about.

My problem is the following: I need to design a Rest API for a program where users can create their own projects, and each project contains files that can only be seen by users that have access. I am stuck with how to design the "List all files of a project" query.

Standard Rest API practice would suggest two endpoints, like:

```<code>`GET /projects`     # List all projects
`POST /projects`    # Create new project
`GET /projects/id`  # Get specific project
etc.
</code>```

and the same for the files of a project.

However, there should never be a reason to list all files - only the files of a single project. To make it more complicated, access management needs to be a thing, users should never see files that are in projects they don't have access to.

I can see multiple ways to handle that:

So the obvious way is to implement the GET function, optionally with a filter. However, this isn't optimal, since if the user doesn't set a filter, it would have to crawl through all projects, check for each project whether the user has access, and then list all files the user has access to:

GET /files?project=test1

I could also make the files command a subcommand of the projects command - e.g.

GET /projects/#id/files

However, I have the feeling this isn't too restful, since it doesn't expose entities directly?

Is there any concencus on which should usually be implemented? Is it okay to "force" users to set a parameter in the first one? Or is there a third alternative that solves what I am looking for? Happy about any literature recommendations on how to design this as well.

答:
Standard Rest API practice would suggest two endpoints

No, it wouldn't.  REST practice would suggest figuring out the resources in your resource model.

Think "documents": I should be able to retrieve (GET) a document that describes all of the files in the project.  Great!  This document should only be accessible when the request authorization matches some access control list.  Also good.

Maybe there should also be a document for each user, so they can see a list of all of the projects they have access to, where that document includes links to the "all of the files in the project" documents.  And of course that document should also be subject to access control.

Note that "documents" here might be text, or media files, or scripts, or CSS, or pretty much any kind of information that you can transmit over the network.  We can gloss the details, because "uniform interface" means that we manage them all the same way.

In other words, we're just designing a "web site" filled with interlinked documents, with access control.

Each document is going to need a unique identifier.  That identifier can be anything we want: /5393d5b0-0517-4c13-a821-c6578cb97668 is fine.  Because it can be anything we want, we have extra degrees of freedom.

For example, we might design our identifiers such that the document whose identifiers begin with /users/12345 are only accessible by requests with authorization headers that match user 12345, and that all documents whose identifiers begin with /projects/12345 are only accessible by requests with authorization headers that match any of the users that have access to that specific project, and so on.

In other words, it is completely acceptable to choose resource identifier spellings that make your implementation easier.

(Note: in an ideal world, you would have "cool" identifiers that are implementation agnostic, so that they still work even if you change the underlying implementation details of your server.)

I have the feeling this isn't too restful, since it doesn't expose entities directly?

It's fine.  Resource models and entity models are different things; we shouldn't expect them to always match one to one.

Body:
Note: I realize that this is close to being off-topic for being opinion-based, but I am hoping that there is some accepted best practice to handle this that I just don't know about.

My problem is the following: I need to design a Rest API for a program where users can create their own projects, and each project contains files that can only be seen by users that have access. I am stuck with how to design the "List all files of a project" query.

Standard Rest API practice would suggest two endpoints, like:

`GET /projects`     # List all projects
`POST /projects`    # Create new project
`GET /projects/id`  # Get specific project
etc.

and the same for the files of a project.

However, there should never be a reason to list all files - only the files of a single project. To make it more complicated, access management needs to be a thing, users should never see files that are in projects they don't have access to.

I can see multiple ways to handle that:

So the obvious way is to implement the GET function, optionally with a filter. However, this isn't optimal, since if the user doesn't set a filter, it would have to crawl through all projects, check for each project whether the user has access, and then list all files the user has access to:

GET /files?project=test1

I could also make the files command a subcommand of the projects command - e.g.

GET /projects/#id/files

However, I have the feeling this isn't too restful, since it doesn't expose entities directly?

Is there any concencus on which should usually be implemented? Is it okay to "force" users to set a parameter in the first one? Or is there a third alternative that solves what I am looking for? Happy about any literature recommendations on how to design this as well.


问:
CorruptedCacheException: Corrupted IndexBlock 298298 found in cache '/Users/macuser/.gradle/caches/journal-1/file-access.bin'
My android projects runs and my app works but I keep getting these errors.
Can anyone explain what is happening and how I can solve it?

org.gradle.cache.internal.btree.CorruptedCacheException: Corrupted IndexBlock 298298 found in cache '/Users/macuser/.gradle/caches/journal-1/file-access.bin'.
  org.gradle.cache.internal.btree.CorruptedCacheException: Corrupted IndexBlock 272355 found in cache '/Users/macuser/.gradle/caches/journal-1/file-access.bin'.

  org.gradle.cache.internal.btree.CorruptedCacheException: Corrupted IndexBlock 256346 found in cache '/Users/macuser/.gradle/caches/journal-1/file-access.bin'.

  org.gradle.cache.internal.btree.CorruptedCacheException: Corrupted IndexBlock 285739 found in cache '/Users/macuser/.gradle/caches/journal-1/file-access.bin'.

  org.gradle.cache.internal.btree.CorruptedCacheException: Corrupted IndexBlock 272355 found in cache '/Users/macuser/.gradle/caches/journal-1/file-access.bin'.

  org.gradle.cache.internal.btree.CorruptedCacheException: Corrupted IndexBlock 298298 found in cache '/Users/macuser/.gradle/caches/journal-1/file-access.bin'.

  org.gradle.cache.internal.btree.CorruptedCacheException: Corrupted IndexBlock 272355 found in cache '/Users/macuser/.gradle/caches/journal-1/file-access.bin'.

  org.gradle.cache.internal.btree.CorruptedCacheException: Corrupted IndexBlock 256346 found in cache '/Users/macuser/.gradle/caches/journal-1/file-access.bin'.

  org.gradle.cache.internal.btree.CorruptedCacheException: Corrupted IndexBlock 272355 found in cache '/Users/macuser/.gradle/caches/journal-1/file-access.bin'.

  org.gradle.cache.internal.btree.CorruptedCacheException: Corrupted IndexBlock 256346 found in cache '/Users/macuser/.gradle/caches/journal-1/file-access.bin'.

  org.gradle.cache.internal.btree.CorruptedCacheException: Corrupted IndexBlock 298298 found in cache '/Users/macuser/.gradle/caches/journal-1/file-access.bin'.

  org.gradle.cache.internal.btree.CorruptedCacheException: Corrupted IndexBlock 256346 found in cache '/Users/macuser/.gradle/caches/journal-1/file-access.bin'.

  org.gradle.cache.internal.btree.CorruptedCacheException: Corrupted IndexBlock 298298 found in cache '/Users/macuser/.gradle/caches/journal-1/file-access.bin'.

  org.gradle.cache.internal.btree.CorruptedCacheException: Corrupted IndexBlock 238437 found in cache '/Users/macuser/.gradle/caches/journal-1/file-access.bin'.

  org.gradle.cache.internal.btree.CorruptedCacheException: Corrupted IndexBlock 298298 found in cache '/Users/macuser/.gradle/caches/journal-1/file-access.bin'.

答:
In Windows There are two ways but this one worked for me.. hope it works out for you

First way:

-C:\Users.gradle\caches\journal-1 Delete all the files

-Restart Android studio.

-Rebuild your project


问:
Multiple custom fields stored as meta_keys, how to connect with the post?
I recently posted a question about connecting two queries to omit elements found in a second:

MYSQL - How to join two queries to omit elements found in the second query (or perhaps any better solution?)

Now I am wondering how to look at a number of meta_keys and their corresponding values to achieve something else.

I am essentially building an event system with custom fields, simplified, an event will have:

Start Date

End Date

Ongoing (Yes or No)

These are stored as

```<code>-----------
wp_postmeta
-----------
meta_key
meta_value
post_id
</code>```

e.g.

```<code>-----------
wp_postmeta
-----------
Start Date
2011-07-30
10

-----------
wp_postmeta
-----------
End Date
2011-08-30
10

-----------
wp_postmeta
-----------
Ongoing
Yes
10
</code>```

My confusion lies in trying to look at multiple wp_postmeta entries and connecting them with the appropriate post.

For example, I want to find the posts that:

Start Date > Today

End Date > Today

Ongoing = Yes

Building upon the previous question, I am trying this query:

```<code>SELECT * FROM wp_posts, wp_postmeta
WHERE wp_posts.ID = wp_postmeta.post_id

AND wp_posts.ID IN (
SELECT post_id FROM wp_postmeta
WHERE wp_postmeta.meta_key = 'Start Date'
AND wp_postmeta.meta_value > NOW())

AND wp_posts.ID IN (
SELECT post_id FROM wp_postmeta
WHERE wp_postmeta.meta_key = 'Ongoing'
AND wp_postmeta.meta_value = 'Yes')

AND wp_posts.ID IN (
SELECT post_id FROM wp_postmeta
WHERE wp_postmeta.meta_key = 'End Date'
AND wp_postmeta.meta_value > NOW())
</code>```

Which is not really working.

I feel like there must be a way to find all the related meta_keys and join their values to the post table, so it can be more easily accessed. For example, is it possible to find the meta_value for 'Start Date' and join it to the wp_posts with a column title start_date_value or something like that?

Or how should I be approaching this problem instead?

Using the answer from @karevn, I came up with the following code which works exactly as I want:

```<code>$query = array(
        'category_name' => 'event',
        'meta_query' => array(
            'relation' => 'AND',
            array(
                'key' => 'Start Date',
                'value' => $today,
                'compare' => '>'
            ),
            array(
                'key' => 'End Date',
                'value' => $today,
                'compare' => '>'
            ),
            array(
                'key' => 'Ongoing',
                'value' => 'Yes',
                'compare' => '='
            ),
        )
    );
</code>```

I think this is a pretty powerful feature of wordpress.

答:
Not sure why you have multiple rows. If you provide a sample of tables' data and sample results that the query produces, it would help. The query seems correct.

Note: The implicit JOIN syntax you use, with WHERE:

```<code>    FROM wp_posts, wp_postmeta
WHERE wp_posts.ID = wp_postmeta.post_id
</code>```

is not best practice. It's better to use the explicit JOIN:

```<code>    FROM wp_posts
      JOIN wp_postmeta
        ON wp_posts.ID = wp_postmeta.post_id
</code>```

Warning: something IN (SELECT x FROM y) does not result in the best query plan in MySQL. So, you better rewrite it (for efficiency) as:

```<code>SELECT *
FROM wp_posts
  JOIN wp_postmeta
    ON wp_posts.ID = wp_postmeta.post_id

WHERE EXISTS (
  SELECT *
  FROM wp_postmeta
  WHERE wp_postmeta.post_id = wp_posts.ID
  AND wp_postmeta.meta_key = 'Start Date'
  AND wp_postmeta.meta_value > NOW())

AND EXISTS (
  SELECT *
  FROM wp_postmeta
  WHERE wp_postmeta.post_id = wp_posts.ID
  AND wp_postmeta.meta_key = 'Ongoing'
  AND wp_postmeta.meta_value = 'Yes')

AND EXISTS (
  SELECT *
  FROM wp_postmeta
  WHERE wp_postmeta.post_id = wp_posts.ID
  AND wp_postmeta.meta_key = 'End Date'
  AND wp_postmeta.meta_value > NOW())
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I recently posted a question about connecting two queries to omit elements found in a second:

MYSQL - How to join two queries to omit elements found in the second query (or perhaps any better solution?)

Now I am wondering how to look at a number of meta_keys and their corresponding values to achieve something else.

I am essentially building an event system with custom fields, simplified, an event will have:

Start Date

End Date

Ongoing (Yes or No)

These are stored as

-----------
wp_postmeta
-----------
meta_key
meta_value
post_id

e.g.

-----------
wp_postmeta
-----------
Start Date
2011-07-30
10

-----------
wp_postmeta
-----------
End Date
2011-08-30
10

-----------
wp_postmeta
-----------
Ongoing
Yes
10

My confusion lies in trying to look at multiple wp_postmeta entries and connecting them with the appropriate post.

For example, I want to find the posts that:

Start Date > Today

End Date > Today

Ongoing = Yes

Building upon the previous question, I am trying this query:

SELECT * FROM wp_posts, wp_postmeta
WHERE wp_posts.ID = wp_postmeta.post_id

AND wp_posts.ID IN (
SELECT post_id FROM wp_postmeta
WHERE wp_postmeta.meta_key = 'Start Date'
AND wp_postmeta.meta_value > NOW())

AND wp_posts.ID IN (
SELECT post_id FROM wp_postmeta
WHERE wp_postmeta.meta_key = 'Ongoing'
AND wp_postmeta.meta_value = 'Yes')

AND wp_posts.ID IN (
SELECT post_id FROM wp_postmeta
WHERE wp_postmeta.meta_key = 'End Date'
AND wp_postmeta.meta_value > NOW())

Which is not really working.

I feel like there must be a way to find all the related meta_keys and join their values to the post table, so it can be more easily accessed. For example, is it possible to find the meta_value for 'Start Date' and join it to the wp_posts with a column title start_date_value or something like that?

Or how should I be approaching this problem instead?

Using the answer from @karevn, I came up with the following code which works exactly as I want:

$query = array(
        'category_name' => 'event',
        'meta_query' => array(
            'relation' => 'AND',
            array(
                'key' => 'Start Date',
                'value' => $today,
                'compare' => '>'
            ),
            array(
                'key' => 'End Date',
                'value' => $today,
                'compare' => '>'
            ),
            array(
                'key' => 'Ongoing',
                'value' => 'Yes',
                'compare' => '='
            ),
        )
    );

I think this is a pretty powerful feature of wordpress.

Body:
Not sure why you have multiple rows. If you provide a sample of tables' data and sample results that the query produces, it would help. The query seems correct.

Note: The implicit JOIN syntax you use, with WHERE:

    FROM wp_posts, wp_postmeta
WHERE wp_posts.ID = wp_postmeta.post_id

is not best practice. It's better to use the explicit JOIN:

    FROM wp_posts
      JOIN wp_postmeta
        ON wp_posts.ID = wp_postmeta.post_id

Warning: something IN (SELECT x FROM y) does not result in the best query plan in MySQL. So, you better rewrite it (for efficiency) as:

SELECT *
FROM wp_posts
  JOIN wp_postmeta
    ON wp_posts.ID = wp_postmeta.post_id

WHERE EXISTS (
  SELECT *
  FROM wp_postmeta
  WHERE wp_postmeta.post_id = wp_posts.ID
  AND wp_postmeta.meta_key = 'Start Date'
  AND wp_postmeta.meta_value > NOW())

AND EXISTS (
  SELECT *
  FROM wp_postmeta
  WHERE wp_postmeta.post_id = wp_posts.ID
  AND wp_postmeta.meta_key = 'Ongoing'
  AND wp_postmeta.meta_value = 'Yes')

AND EXISTS (
  SELECT *
  FROM wp_postmeta
  WHERE wp_postmeta.post_id = wp_posts.ID
  AND wp_postmeta.meta_key = 'End Date'
  AND wp_postmeta.meta_value > NOW())


问:
Having trouble with Terraform and AWS Storage Gateway disks
I am using Terraform with AWS and have been able to create an AWS Storage Gateway file gateway using the aws_storagegateway_gateway resource.

The gateway will create and the status will be 'online' however there is not a cache disk added yet in the console which is normal as it has to be done after the gateway is created. The VM does have a disk and it is available to add in the console and doing so in the console works perfectly.

However, I am trying to add the disk with Terraform once the gateway is created and cannot seem to get the code to work, or quite possibly don't understand how to get it to work.

Trying to use the aws_storagegateway_cache resource but I get an error on the disk_id and do not know how to get it to return from the code of the gateway creation.

Might someone have a working example of how to get the cache disk to add with Terraform once the gateway is created or know how to get the disk_id so I can add it?

Adding code

```<code>provider "aws" {
  access_key = "${var.access-key}"
  secret_key = "${var.secret-key}"
  token      = "${var.token}"
  region     = "${var.region}"
}

resource "aws_storagegateway_gateway" "hmsgw" {
  gateway_ip_address = "${var.gateway-ip-address}"
  gateway_name       = "${var.gateway-name}"
  gateway_timezone   = "${var.gateway-timezone}"
  gateway_type       = "${var.gateway-type}"

  smb_active_directory_settings {
    domain_name = "${var.domain-name}"
    username    = "${var.username}"
    password    = "${var.password}"
  }

}

resource "aws_storagegateway_cache" "sgwdisk" {
  disk_id     = "SCSI"
  gateway_arn = "${aws_storagegateway_gateway.hmsgw.arn}"
}

output "gatewayid" {
  value = "${aws_storagegateway_gateway.hmsgw.arn}"
}
</code>```

The error I get is:

aws_storagegateway_cache.sgwdisk: error adding Storage Gateway cache: InvalidGatewayRequestException: The specified disk does not exist.
    status code: 400, request id: fda602fd-a47e-11e8-a1f4-b383e2e2e2f6

I have attempted to hard code the disk_id like above or use a variable. On the variable I don't know if it is returned or exists so that could be the issue, new to this.

答:
This would work also:</p>
```<code>variable "disk_path" {
  default = "/dev/sdb"
}

provider "aws" {
  alias  = "primary"
  access_key = var.access-key
  secret_key = var.secret-key
  token      = var.token
  region     = var.region
}

resource "aws_storagegateway_gateway" "hmsgw" {
  gateway_ip_address = var.gateway-ip-address
  gateway_name       = var.gateway-name
  gateway_timezone   = var.gateway-timezone
  gateway_type       = var.gateway-type

  smb_active_directory_settings {
    domain_name = var.domain-name
    username    = var.username
    password    = var.password
  }
}

data "aws_storagegateway_local_disk" "sgw_disk" {
  disk_path   = var.disk_path
  gateway_arn = aws_storagegateway_gateway.hmsgw.arn
  provider    = aws.primary
}

resource "aws_storagegateway_cache" "sgw_cache" {
  disk_id     = data.aws_storagegateway_local_disk.sgw_disk.id
  gateway_arn = aws_storagegateway_gateway.hmsgw.arn
  provider    = aws.primary
}
</code>```

Body:
I am using Terraform with AWS and have been able to create an AWS Storage Gateway file gateway using the aws_storagegateway_gateway resource.

The gateway will create and the status will be 'online' however there is not a cache disk added yet in the console which is normal as it has to be done after the gateway is created. The VM does have a disk and it is available to add in the console and doing so in the console works perfectly.

However, I am trying to add the disk with Terraform once the gateway is created and cannot seem to get the code to work, or quite possibly don't understand how to get it to work.

Trying to use the aws_storagegateway_cache resource but I get an error on the disk_id and do not know how to get it to return from the code of the gateway creation.

Might someone have a working example of how to get the cache disk to add with Terraform once the gateway is created or know how to get the disk_id so I can add it?

Adding code

provider "aws" {
  access_key = "${var.access-key}"
  secret_key = "${var.secret-key}"
  token      = "${var.token}"
  region     = "${var.region}"
}

resource "aws_storagegateway_gateway" "hmsgw" {
  gateway_ip_address = "${var.gateway-ip-address}"
  gateway_name       = "${var.gateway-name}"
  gateway_timezone   = "${var.gateway-timezone}"
  gateway_type       = "${var.gateway-type}"

  smb_active_directory_settings {
    domain_name = "${var.domain-name}"
    username    = "${var.username}"
    password    = "${var.password}"
  }

}

resource "aws_storagegateway_cache" "sgwdisk" {
  disk_id     = "SCSI"
  gateway_arn = "${aws_storagegateway_gateway.hmsgw.arn}"
}

output "gatewayid" {
  value = "${aws_storagegateway_gateway.hmsgw.arn}"
}

The error I get is:

aws_storagegateway_cache.sgwdisk: error adding Storage Gateway cache: InvalidGatewayRequestException: The specified disk does not exist.
    status code: 400, request id: fda602fd-a47e-11e8-a1f4-b383e2e2e2f6

I have attempted to hard code the disk_id like above or use a variable. On the variable I don't know if it is returned or exists so that could be the issue, new to this.

Body:
This would work also:

variable "disk_path" {
  default = "/dev/sdb"
}

provider "aws" {
  alias  = "primary"
  access_key = var.access-key
  secret_key = var.secret-key
  token      = var.token
  region     = var.region
}

resource "aws_storagegateway_gateway" "hmsgw" {
  gateway_ip_address = var.gateway-ip-address
  gateway_name       = var.gateway-name
  gateway_timezone   = var.gateway-timezone
  gateway_type       = var.gateway-type

  smb_active_directory_settings {
    domain_name = var.domain-name
    username    = var.username
    password    = var.password
  }
}

data "aws_storagegateway_local_disk" "sgw_disk" {
  disk_path   = var.disk_path
  gateway_arn = aws_storagegateway_gateway.hmsgw.arn
  provider    = aws.primary
}

resource "aws_storagegateway_cache" "sgw_cache" {
  disk_id     = data.aws_storagegateway_local_disk.sgw_disk.id
  gateway_arn = aws_storagegateway_gateway.hmsgw.arn
  provider    = aws.primary
}


问:
Laravel calendar of absences problem with displaying in table
I wanted to create team calendar of absences. Each user can define more than one absence in specific month.

Then I want to print it for each in table like this (example for 10 days):

```<code>Day   | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
-----------------------------------------------|
User1 | o | o | x | x | x | x | o | o | o | x  |
-----------------------------------------------|
User2 | x | o | o | o | x | x | o | x | o | x  |
-----------------------------------------------|
</code>```

Where the "o" is for normal day and "x" is defined as absence.

I got Users table and Absences table:

```<code>Users
id | name

Absences
id | user_id | start | end
</code>```

I get the current month day value and iterate through all Users and then through the days in blade like that:

```<code>@foreach ($users as $user )
   <tr>
      <td> {{ $user->name }} </td>
   @if($user->absences != null)
      @foreach($days as $day)
         @foreach ($user->absences as $absence)
           @if($day >= $absence->start->format('d') && $day <= $absence->end->format('d'))
              <td style="background: red"> x </td>
           @else
              <td style="background: blue"> o </td>
           @endif
         @endforeach
       @endforeach
    @endif
  </tr>
@endforeach
</code>```

The problem is that, If user have more than one absence defined, the days in his column are doubled and whole table is being crashed. When User has only 1 absence, it works OK.

Do you have any idea how do achieve that easier?

答:
Your problem lies in @foreach ($user->absences as $absence) loop. You're checking all the absences for one day.

Instead, you should use a function to get all the absense days of users. I think keeping such functionality in controller is a better idea.

```<code>$users = $users->map(function ($user) {
    $user['absenseDays'] = $user->absences->reduce(function ($carry, $item) {
        return [...$carry, ...range($item['start'], $item['end'])];
    }, []);
    return $user;
});
</code>```

This should create a new entry of absenseDays on each user, and the values should be an array of absense days. Let's say a user has 2 records 5-8 and 12-14, absenseDays should be [5,6,7,8,12,13,14].

In blade you need only:

```<code>@if (in_array($day, $user->absenseDays))
    <td style="background: red"> x </td>
@else
    <td style="background: blue"> o </td>
@endif
</code>```

I wrote the function here directly. So it might not work, or can be a better way to produce the same output. But I can say that for sure, producing absenseDays array is the best approach that I can come up with.

Body:
I wanted to create team calendar of absences. Each user can define more than one absence in specific month.

Then I want to print it for each in table like this (example for 10 days):

Day   | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
-----------------------------------------------|
User1 | o | o | x | x | x | x | o | o | o | x  |
-----------------------------------------------|
User2 | x | o | o | o | x | x | o | x | o | x  |
-----------------------------------------------|

Where the "o" is for normal day and "x" is defined as absence.

I got Users table and Absences table:

Users
id | name

Absences
id | user_id | start | end

I get the current month day value and iterate through all Users and then through the days in blade like that:

@foreach ($users as $user )

       {{ $user->name }}
   @if($user->absences != null)
      @foreach($days as $day)
         @foreach ($user->absences as $absence)
           @if($day >= $absence->start->format('d') && $day <= $absence->end->format('d'))
               x
           @else
               o
           @endif
         @endforeach
       @endforeach
    @endif

@endforeach

The problem is that, If user have more than one absence defined, the days in his column are doubled and whole table is being crashed. When User has only 1 absence, it works OK.

Do you have any idea how do achieve that easier?

Body:
Your problem lies in @foreach ($user->absences as $absence) loop. You're checking all the absences for one day.

Instead, you should use a function to get all the absense days of users. I think keeping such functionality in controller is a better idea.

$users = $users->map(function ($user) {
    $user['absenseDays'] = $user->absences->reduce(function ($carry, $item) {
        return [...$carry, ...range($item['start'], $item['end'])];
    }, []);
    return $user;
});

This should create a new entry of absenseDays on each user, and the values should be an array of absense days. Let's say a user has 2 records 5-8 and 12-14, absenseDays should be [5,6,7,8,12,13,14].

In blade you need only:

@if (in_array($day, $user->absenseDays))
    <td style="background: red"> x </td>
@else
    <td style="background: blue"> o </td>
@endif

I wrote the function here directly. So it might not work, or can be a better way to produce the same output. But I can say that for sure, producing absenseDays array is the best approach that I can come up with.


问:
calculate sum of squares with rows above
I have a dataset that looks like this:

```<code>Value         Type       X_sq
-1.975767     Weather
-0.540979     Fruits
-2.359127     Fruits
-2.815604     Corona
-0.929755     Weather
</code>```

I want to iterate through each row and calculate a sum of squares value for each row above (only if the Type matches). I want to put this value in the X.sq column.

So for example, in the first row, there's nothing above. So only (-1.975767 x -1.975767). In the second row, there's no FRUITS row above it, so it will just be -0.540979 x -0.540979. However, in the third row, when we scan all previous rows, we should find that FRUITS is already there. So we should get the last's FRUIT's  .....  X_sq value and calculate a new sum of squares.

```<code>Value         Type       X_sq
-1.975767     Weather   -1.975767 * -1.975767    = x
-0.540979     Fruits    -0.540979 * -0.540979    = y
-2.359127     Fruits    y + ( -2.359127 x -2.359127)
-2.815604     Corona    -2.815604 * -2.815604
-0.929755     Weather   x + (-0.929755 * -0.929755)
</code>```

What would be an efficient way to do this?

```<code>def updateSS(X_sq, X_new):
    return X_sq + X_new**2
</code>```

EDIT:

```<code>----> 1 df['sumOfSquares'] = df['avg_country_tone'].pow(2).groupby(['themes', 'suppliers_country']).cumsum()

File /usr/local/Cellar/ipython/8.0.1/libexec/lib/python3.10/site-packages/pandas/core/series.py:1929, in Series.groupby(self, by, axis, level, as_index, sort, group_keys, squeeze, observed, dropna)
   1925 axis = self._get_axis_number(axis)
   1927 # error: Argument "squeeze" to "SeriesGroupBy" has incompatible type
   1928 # "Union[bool, NoDefault]"; expected "bool"
-> 1929 return SeriesGroupBy(
   1930     obj=self,
   1931     keys=by,
   1932     axis=axis,
   1933     level=level,
   1934     as_index=as_index,
   1935     sort=sort,
   1936     group_keys=group_keys,
   1937     squeeze=squeeze,  # type: ignore[arg-type]
   1938     observed=observed,
   1939     dropna=dropna,
   1940 )

File /usr/local/Cellar/ipython/8.0.1/libexec/lib/python3.10/site-packages/pandas/core/groupby/groupby.py:882, in GroupBy.__init__(self, obj, keys, axis, level, grouper, exclusions, selection, as_index, sort, group_keys, squeeze, observed, mutated, dropna)
    879 if grouper is None:
    880     from pandas.core.groupby.grouper import get_grouper
--> 882     grouper, exclusions, obj = get_grouper(
    883         obj,
    884         keys,
    885         axis=axis,
    886         level=level,
    887         sort=sort,
    888         observed=observed,
    889         mutated=self.mutated,
    890         dropna=self.dropna,
    891     )
    893 self.obj = obj
    894 self.axis = obj._get_axis_number(axis)

File /usr/local/Cellar/ipython/8.0.1/libexec/lib/python3.10/site-packages/pandas/core/groupby/grouper.py:882, in get_grouper(obj, key, axis, level, sort, observed, mutated, validate, dropna)
    880         in_axis, level, gpr = False, gpr, None
    881     else:
--> 882         raise KeyError(gpr)
    883 elif isinstance(gpr, Grouper) and gpr.key is not None:
    884     # Add key to exclusions
    885     exclusions.add(gpr.key)

KeyError: 'themes'
even though themes is there. Themes = type
</code>```

答:
You first build an id for consecutive rows with same type

```<code>groupid = (df['Type'] != df['Type'].shift()).cumsum()
</code>```

You can then group the dataframe on it and again use cumsum on each group:

```<code>df['X_sq'] = df.groupby(groupid)['Value'].transform(lambda x: (x*x).cumsum())
</code>```

You should get as expected:

```<code>      Value     Type      X_sq
0 -1.975767  Weather  3.903655
1 -0.540979   Fruits  0.292658
2 -2.359127   Fruits  5.858138
3 -2.815604   Corona  7.927626
4 -0.929755  Weather  0.864444
</code>```

Body:
I have a dataset that looks like this:

Value         Type       X_sq
-1.975767     Weather
-0.540979     Fruits
-2.359127     Fruits
-2.815604     Corona
-0.929755     Weather

I want to iterate through each row and calculate a sum of squares value for each row above (only if the Type matches). I want to put this value in the X.sq column.

So for example, in the first row, there's nothing above. So only (-1.975767 x -1.975767). In the second row, there's no FRUITS row above it, so it will just be -0.540979 x -0.540979. However, in the third row, when we scan all previous rows, we should find that FRUITS is already there. So we should get the last's FRUIT's  .....  X_sq value and calculate a new sum of squares.

Value         Type       X_sq
-1.975767     Weather   -1.975767 * -1.975767    = x
-0.540979     Fruits    -0.540979 * -0.540979    = y
-2.359127     Fruits    y + ( -2.359127 x -2.359127)
-2.815604     Corona    -2.815604 * -2.815604
-0.929755     Weather   x + (-0.929755 * -0.929755)

What would be an efficient way to do this?

def updateSS(X_sq, X_new):
    return X_sq + X_new**2

EDIT:

----> 1 df['sumOfSquares'] = df['avg_country_tone'].pow(2).groupby(['themes', 'suppliers_country']).cumsum()

File /usr/local/Cellar/ipython/8.0.1/libexec/lib/python3.10/site-packages/pandas/core/series.py:1929, in Series.groupby(self, by, axis, level, as_index, sort, group_keys, squeeze, observed, dropna)
   1925 axis = self._get_axis_number(axis)
   1927 # error: Argument "squeeze" to "SeriesGroupBy" has incompatible type
   1928 # "Union[bool, NoDefault]"; expected "bool"
-> 1929 return SeriesGroupBy(
   1930     obj=self,
   1931     keys=by,
   1932     axis=axis,
   1933     level=level,
   1934     as_index=as_index,
   1935     sort=sort,
   1936     group_keys=group_keys,
   1937     squeeze=squeeze,  # type: ignore[arg-type]
   1938     observed=observed,
   1939     dropna=dropna,
   1940 )

File /usr/local/Cellar/ipython/8.0.1/libexec/lib/python3.10/site-packages/pandas/core/groupby/groupby.py:882, in GroupBy.__init__(self, obj, keys, axis, level, grouper, exclusions, selection, as_index, sort, group_keys, squeeze, observed, mutated, dropna)
    879 if grouper is None:
    880     from pandas.core.groupby.grouper import get_grouper
--> 882     grouper, exclusions, obj = get_grouper(
    883         obj,
    884         keys,
    885         axis=axis,
    886         level=level,
    887         sort=sort,
    888         observed=observed,
    889         mutated=self.mutated,
    890         dropna=self.dropna,
    891     )
    893 self.obj = obj
    894 self.axis = obj._get_axis_number(axis)

File /usr/local/Cellar/ipython/8.0.1/libexec/lib/python3.10/site-packages/pandas/core/groupby/grouper.py:882, in get_grouper(obj, key, axis, level, sort, observed, mutated, validate, dropna)
    880         in_axis, level, gpr = False, gpr, None
    881     else:
--> 882         raise KeyError(gpr)
    883 elif isinstance(gpr, Grouper) and gpr.key is not None:
    884     # Add key to exclusions
    885     exclusions.add(gpr.key)

KeyError: 'themes'
even though themes is there. Themes = type

Body:
You first build an id for consecutive rows with same type

groupid = (df['Type'] != df['Type'].shift()).cumsum()

You can then group the dataframe on it and again use cumsum on each group:

df['X_sq'] = df.groupby(groupid)['Value'].transform(lambda x: (x*x).cumsum())

You should get as expected:

      Value     Type      X_sq
0 -1.975767  Weather  3.903655
1 -0.540979   Fruits  0.292658
2 -2.359127   Fruits  5.858138
3 -2.815604   Corona  7.927626
4 -0.929755  Weather  0.864444


问:
Flow emits different values when collecting it multiple times
I created a Flow from which I emit data. When I collect this flow twice, there are 2 different sets of data emitted from the same variable instead of emitting the same values to both collectors.

I have a simple Flow that I created myself. The text will be logged twice a second

```<code>    val demoFlow: Flow<String> = flow {
        while (true) {
            val text = "Flow ${(0..100).random()}"
            Log.d("TAG", text)
            emit(text)
            delay(1000)
        }
    }
</code>```

In my viewModel I have a simple function that gets the previous Flow

```<code>fun getSimpleFlow() = FlowRepository.demoFlow
</code>```

And in my Fragment I collect and display my Flow

```<code>        lifecycleScope.launch {
            repeatOnLifecycle(Lifecycle.State.STARTED) {
                launch {
                    viewModel.getSimpleFlow().collect {
                        binding.tv1.text = it
                    }
                }
                launch {
                    viewModel.getSimpleFlow().collect {
                        binding.tv2.text = it
                    }
                }
            }
        }
</code>```

If I transform the Flow to a StateFlow or a SharedFlow, I no longer have this problem.
I don't understand how or why this happens since I'm using the same 'demoFlow' variable.
Is there a way to get the same values from 'demoFlow' without converting to a StateFlow or a SharedFlow?

答:
Regular Flows are cold, this behaviour is by design.

The demoFlow is the same, so you have the same Flow instance. However, collecting the flow multiple times actually runs the body inside the flow { ... } definition every time from the start. Each independent collection has its own variable i etc.

Using a StateFlow or a SharedFlow allows to share the source of the flow between multiple collectors. If you use shareIn or stateIn on some source flow, that source flow is only collected once, and the items collected from this source flow are shared and sent to every collector of the resulting state/shared flow. This is why it behaves differently.

In short, reusing a Flow instance is not sufficient to share the collection. You need to use flow types that are specifically designed for this.

Body:
I created a Flow from which I emit data. When I collect this flow twice, there are 2 different sets of data emitted from the same variable instead of emitting the same values to both collectors.

I have a simple Flow that I created myself. The text will be logged twice a second

    val demoFlow: Flow<String> = flow {
        while (true) {
            val text = "Flow ${(0..100).random()}"
            Log.d("TAG", text)
            emit(text)
            delay(1000)
        }
    }

In my viewModel I have a simple function that gets the previous Flow

fun getSimpleFlow() = FlowRepository.demoFlow

And in my Fragment I collect and display my Flow

        lifecycleScope.launch {
            repeatOnLifecycle(Lifecycle.State.STARTED) {
                launch {
                    viewModel.getSimpleFlow().collect {
                        binding.tv1.text = it
                    }
                }
                launch {
                    viewModel.getSimpleFlow().collect {
                        binding.tv2.text = it
                    }
                }
            }
        }

If I transform the Flow to a StateFlow or a SharedFlow, I no longer have this problem.
I don't understand how or why this happens since I'm using the same 'demoFlow' variable.
Is there a way to get the same values from 'demoFlow' without converting to a StateFlow or a SharedFlow?


问:
C++ and STL refresher course
I know C and C++ quite well. I know in much detail about pointers and well versed with pointer arithmetic and worked on Win32 API and a bit of MFC as well in my university days. In my previous job, I had no chance to look on these matters and worked in some other domain. Now what I want is a crash or refresher course in:

C++

STL

I do not want to go through 500+ pages of books because I know C#, Java, Ruby, Python and even x86 Assembly as well. What I want is to cover advanced and dark corners of C++ and intermediate STL.

Can anyone point out good links about it?
I know about Google! ;-)
But an intelligent human recommendation is something else yet Google has not implemented.

答:
Read STL - C++ feeds on stackoverflow =)

comp.lang.c++

comp.lang.c++.moderated news groups

Herb Sutter's "Guru of the week" - http://gotw.ca/gotw/index.htm

Start learn boost (boost.org), it will be good way to refresh c++ and stl.

C++ Coding Standards : 101 Rules, Guidelines, and Best Practices (C++ in Depth Series) - small and easy for reading in subway book. It helps you refresh your knowledges.

Other books from "C++ in Depth Series" nice too.

OwnerDisplayName: Mohsin Hijazee

Title: C++ and STL refresher course

LastEditorDisplayName: Ferruccio

OwnerDisplayName: bb

ContentLicense: CC BY-SA 2.5

LastEditorDisplayName: bb


问:
I cannot scrape anything with BeautifulSoup
Im using BeautifulSoup to scrape some web contents.

Im learning with this example code,but I always get a "None" response.

Code:

```<code>import urllib2
from BeautifulSoup import BeautifulSoup

soup = BeautifulSoup(urllib2.urlopen('http://www.velocidadcuchara.com/2011/08/helado-platano-light.html').read())

post = soup.find('div', attrs={'id': 'topmenucontainer'})

print post
</code>```

Any idea what Im doing wrong ?

Thanks!!

答:
Something weird with your HTML. BeautifulSoup tries its best, but sometimes it just can't parse it.

Try moving the first <link> element inside the , that might help.

Body:
Im using BeautifulSoup to scrape some web contents.

Im learning with this example code,but I always get a "None" response.

Code:

import urllib2
from BeautifulSoup import BeautifulSoup

soup = BeautifulSoup(urllib2.urlopen('http://www.velocidadcuchara.com/2011/08/helado-platano-light.html').read())

post = soup.find('div', attrs={'id': 'topmenucontainer'})

print post

Any idea what Im doing wrong ?

Thanks!!

Body:
Something weird with your HTML. BeautifulSoup tries its best, but sometimes it just can't parse it.

Try moving the first <link> element inside the <head>, that might help.


问:
exception in android 12
For me, when using the method (chain.proceed (request)), there is a problem which is the following error.

My error happens in Android 12

I use retrofit

```<code>class CustomInterceptor implements Interceptor {
    @NonNull
    @Override
    public Response intercept(Chain chain) throws IOException {
        Request request = chain.request ();
        return chain.proceed (request);
    }
}
</code>```

Exception

```<code>Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
</code>```

答:
I had the same problem today. The root problem was not okHttp / Retrofit, but Gander, a Http inspection library that I use in my app. The library is not maintained anymore, which means they do not support Android 12. I guess I'll have to switch to Chucker or some other alternative.

If you would provide the full stacktrace we could see, which library is really causing your problem. Removing or updating that library might help you.

See also the issue in the OkHttp GitHub repo: https://github.com/square/okhttp/issues/7034. The developers of OkHttp / Retrofit ensure in their response, that the two libraries are not the problem.

Title: exception in android 12

Body:
For me, when using the method (chain.proceed (request)), there is a problem which is the following error.

My error happens in Android 12

I use retrofit

class CustomInterceptor implements Interceptor {
    @NonNull
    @Override
    public Response intercept(Chain chain) throws IOException {
        Request request = chain.request ();
        return chain.proceed (request);
    }
}

Exception

Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.


问:
Asp.net core web api kestrel - https working but http does not
I'm following along Microsoft's tutorial on Asp.net core web api (https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-web-api?view=aspnetcore-5.0&tabs=visual-studio).

I'm trying to configure Kestrel and I've added this to appsettings.json

```<code>{
  "Kestrel": {
    "Endpoints": {
      "Http": {
        "Url": "http://localhost:5000"
      },
      "Https": {
        "Url": "https://localhost:5001"
      }
    }
  }
}
</code>```

When I start the app now, https works fine, but the http connection does not work. I get "site can't be reached error".

Can someone explain why this is? If I remove the Kestrel configuration, both http and https work fine.

答:
Looks like this was an issue with Chrome, not with Kestrel.

I had changed the port to 6000 and Chrome was not letting it go through as it had marked it as an unsafe port.

Postman and curl worked fine, so I was able to look through Chrome dev tools to troubleshoot.

Body:
I'm following along Microsoft's tutorial on Asp.net core web api (https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-web-api?view=aspnetcore-5.0&tabs=visual-studio).

I'm trying to configure Kestrel and I've added this to appsettings.json

{
  "Kestrel": {
    "Endpoints": {
      "Http": {
        "Url": "http://localhost:5000"
      },
      "Https": {
        "Url": "https://localhost:5001"
      }
    }
  }
}

When I start the app now, https works fine, but the http connection does not work. I get "site can't be reached error".

Can someone explain why this is? If I remove the Kestrel configuration, both http and https work fine.


问:
SQL Frequency Count resetting for each year
I want to count the frequency of occurrences of a variable based on the order of the date - which I can do. But I want the frequency count to reset for each year- I can't get it to reset.

The table looks like the below but I've manually added the Frequency:

```<code>Date / Variable / Year / Frequency
2019-01-01 / blue / 2019 / 1
2019-01-15 / blue / 2019 / 2
2019-01-01 / red / 2019 / 1
2019-04-01 / blue / 2019 / 3
2019-06-01 / red / 2019 / 2
2020-01-01 / blue / 2020 / 1
2020-04-01 / red / 2020 / 1
2020-01-21 / blue / 2020 / 2
2020-06-01 / blue / 2020 / 3
2020-08-01 / red / 2020 / 2
2021-01-21 / blue / 2021 / 1
2021-02-21 / red / 2021 / 1
</code>```

This how I did the original count but this ignores the reset for each year:

```<code>UPDATE A
SET A.Frequency =
(SELECT COUNT(*) FROM #TableB B
WHERE B.Date <= A.Date
AND B.Variable = A.Variable)
FROM #TableA A
</code>```

I've tried adding in WHERE clauses i.e.

```<code>WHERE A.Date BETWEEN '2019-01-01' AND '2019-12-31'
</code>```

And adding in a year column and limiting that way i.e.

```<code>UPDATE A
SET A.Frequency =
(SELECT COUNT(*) FROM #TableB B
WHERE B.Date <= A.Date
AND B.Variable = A.Variable
AND B.Year = '2020')
FROM #TableA A
</code>```

Any tips would be greatly appreciated! Thanks

答:
You can do this with row_number()

DBFiddle

```<code>select a.[date],
       a.variable,
       a.year,
       row_number() over (partition by a.variable, a.year order by [date]) AS frequency
from   tableA a
order by a.id
</code>```

result

```<code>date        variable    year    frequency
2019-01-01  blue        2019    1
2019-01-15  blue        2019    2
2019-01-01  red         2019    1
2019-04-01  blue        2019    3
2019-06-01  red         2019    2
2020-01-01  blue        2020    1
2020-04-01  red         2020    1
2020-01-21  blue        2020    2
2020-06-01  blue        2020    3
2020-08-01  red         2020    2
</code>```

EDIT

How to use this in an update:

```<code>update aa
set    aa.frequency = aaa.frequency
from   tableA aa
  inner join ( select a.[date], a.variable, a.year,
                      row_number() over (partition by a.variable, a.year order by [date]) AS frequency
               from   tableA a
             ) aaa on aa.[date] = aaa.[date]
                  and aa.variable = aaa.variable
                  and aa.year = aaa.year
</code>```

See this DBFiddle

Body:
I want to count the frequency of occurrences of a variable based on the order of the date - which I can do. But I want the frequency count to reset for each year- I can't get it to reset.

The table looks like the below but I've manually added the Frequency:

Date / Variable / Year / Frequency
2019-01-01 / blue / 2019 / 1
2019-01-15 / blue / 2019 / 2
2019-01-01 / red / 2019 / 1
2019-04-01 / blue / 2019 / 3
2019-06-01 / red / 2019 / 2
2020-01-01 / blue / 2020 / 1
2020-04-01 / red / 2020 / 1
2020-01-21 / blue / 2020 / 2
2020-06-01 / blue / 2020 / 3
2020-08-01 / red / 2020 / 2
2021-01-21 / blue / 2021 / 1
2021-02-21 / red / 2021 / 1

This how I did the original count but this ignores the reset for each year:

UPDATE A
SET A.Frequency =
(SELECT COUNT(*) FROM #TableB B
WHERE B.Date <= A.Date
AND B.Variable = A.Variable)
FROM #TableA A

I've tried adding in WHERE clauses i.e.

WHERE A.Date BETWEEN '2019-01-01' AND '2019-12-31'

And adding in a year column and limiting that way i.e.

UPDATE A
SET A.Frequency =
(SELECT COUNT(*) FROM #TableB B
WHERE B.Date <= A.Date
AND B.Variable = A.Variable
AND B.Year = '2020')
FROM #TableA A

Any tips would be greatly appreciated! Thanks

Body:
You can do this with row_number()

DBFiddle

select a.[date],
       a.variable,
       a.year,
       row_number() over (partition by a.variable, a.year order by [date]) AS frequency
from   tableA a
order by a.id

result

date        variable    year    frequency
2019-01-01  blue        2019    1
2019-01-15  blue        2019    2
2019-01-01  red         2019    1
2019-04-01  blue        2019    3
2019-06-01  red         2019    2
2020-01-01  blue        2020    1
2020-04-01  red         2020    1
2020-01-21  blue        2020    2
2020-06-01  blue        2020    3
2020-08-01  red         2020    2

EDIT

How to use this in an update:

update aa
set    aa.frequency = aaa.frequency
from   tableA aa
  inner join ( select a.[date], a.variable, a.year,
                      row_number() over (partition by a.variable, a.year order by [date]) AS frequency
               from   tableA a
             ) aaa on aa.[date] = aaa.[date]
                  and aa.variable = aaa.variable
                  and aa.year = aaa.year

See this DBFiddle


问:
Class 'Spatie\YamlFrontMatter\YamlFrontMatter' not found
I need help. I installed Yaml-front-matter via composer, everything was good. But if I use this class in my project, I get this very strange error. Why laravel doesn't see this class?
I do not find a solution with google.

I tried commands: php artisan optimize: clear, composer dump-autoload
but they don't help.

Thanks in advance.

screen to show the problem

答:
Replace this

```<code>$document = YamlFrontMatter::parseFile(resource_path('posts/my-fourth-post.html');
</code>```

with this

```<code>$document = \Spatie\YamlFrontMatter\YamlFrontMatter::parseFile(resource_path('posts/my-fourth-post.html');
</code>```

It works.

Source: https://laracasts.com/discuss/channels/laravel/class-yamlfrontmatter-not-found-laravel-docker-composer

Body:
Replace this

$document = YamlFrontMatter::parseFile(resource_path('posts/my-fourth-post.html');

with this

$document = \Spatie\YamlFrontMatter\YamlFrontMatter::parseFile(resource_path('posts/my-fourth-post.html');

It works.

Source: https://laracasts.com/discuss/channels/laravel/class-yamlfrontmatter-not-found-laravel-docker-composer


问:
Export DataGridView to Excel File
Can you say me, how can i save the contents of DataGridView to Exel File with the Formatting cells Backcolor/Forecolor? I have DGV like this:

And when I try to Export Data to Excel I get the data, but without Forecolor, I have tried a several of ways, but it does not work! Beforehand Thank you!

```<code>private void btnExport_Click(object sender, EventArgs e)
    {

        SaveFileDialog sfd = new SaveFileDialog();
        sfd.Filter = "Excel Documents (*.xls)|*.xls";
        sfd.FileName = "export.xls";
        if (sfd.ShowDialog() == DialogResult.OK)
        {
            //ToCsV(dataGridView1, @"c:\export.xls");
            ToCsV1(dataGridView1, sfd.FileName);
        }
}

private void ToCsV1(DataGridView dGV, string filename)
    {
        string stOutput = "";
        // Export titles:
        string sHeaders = "";

        for (int j = 0; j < dGV.Columns.Count; j++)
            sHeaders = sHeaders.ToString() + Convert.ToString(dGV.Columns[j].HeaderText) + "\t";
        stOutput += sHeaders + "\r\n";
        // Export data.
        for (int i = 0; i < dGV.RowCount - 1; i++)
        {
            string stLine = "";
            for (int j = 0; j < dGV.Rows[i].Cells.Count; j++)
                stLine = stLine.ToString() + Convert.ToString(dGV.Rows[i].Cells[j].Value) + "\t";
            stOutput += stLine + "\r\n";
        }
        Encoding utf16 = Encoding.GetEncoding(1254);
        byte[] output = utf16.GetBytes(stOutput);
        FileStream fs = new FileStream(filename, FileMode.Create);
        BinaryWriter bw = new BinaryWriter(fs);
        bw.Write(output, 0, output.Length); //write the encoded file
        bw.Flush();
        bw.Close();
        fs.Close();
    }
</code>```

答: Here is an example using GemBox.Spreadsheet component to work with Excel files and cell formatting.

Title: Export DataGridView to Excel File

Body:
Can you say me, how can i save the contents of DataGridView to Exel File with the Formatting cells Backcolor/Forecolor? I have DGV like this:

And when I try to Export Data to Excel I get the data, but without Forecolor, I have tried a several of ways, but it does not work! Beforehand Thank you!

private void btnExport_Click(object sender, EventArgs e)
    {

        SaveFileDialog sfd = new SaveFileDialog();
        sfd.Filter = "Excel Documents (*.xls)|*.xls";
        sfd.FileName = "export.xls";
        if (sfd.ShowDialog() == DialogResult.OK)
        {
            //ToCsV(dataGridView1, @"c:\export.xls");
            ToCsV1(dataGridView1, sfd.FileName);
        }
}

private void ToCsV1(DataGridView dGV, string filename)
    {
        string stOutput = "";
        // Export titles:
        string sHeaders = "";

        for (int j = 0; j < dGV.Columns.Count; j++)
            sHeaders = sHeaders.ToString() + Convert.ToString(dGV.Columns[j].HeaderText) + "\t";
        stOutput += sHeaders + "\r\n";
        // Export data.
        for (int i = 0; i < dGV.RowCount - 1; i++)
        {
            string stLine = "";
            for (int j = 0; j < dGV.Rows[i].Cells.Count; j++)
                stLine = stLine.ToString() + Convert.ToString(dGV.Rows[i].Cells[j].Value) + "\t";
            stOutput += stLine + "\r\n";
        }
        Encoding utf16 = Encoding.GetEncoding(1254);
        byte[] output = utf16.GetBytes(stOutput);
        FileStream fs = new FileStream(filename, FileMode.Create);
        BinaryWriter bw = new BinaryWriter(fs);
        bw.Write(output, 0, output.Length); //write the encoded file
        bw.Flush();
        bw.Close();
        fs.Close();
    }


问:
Update map value in nested struct in pyspark
I have a table with dates and comments.

```<code>dob        | comment
---------------------------
1960-12-01 | this is useful

</code>```

And I want a new column with this type:

```<code>value_type = T.StructType(
    [
       T.StructField("extra",T.MapType(T.StringType(), T.StringType(), True), True),
       T.StructField("date", T.StringType(), True),
       T.StructField("from_date", T.StringType(), True),
       T.StructField("to_date", T.StringType(), True),
       T.StructField("value", T.StringType(), True),
    ]
)
</code>```

I need to:

put the df.date into the date field of the struct and

put the df.comment into the extra map of the struct

thanks to blackbishop I figured out how to do the first part here - and i tried to use .withField() to update the map but it throws an error:

I tried:

```<code>(df
.withColumn("new_col",
            F.struct(*[F.lit(None).cast(f.dataType).alias(f.name)
                       for f in value_type.fields]))
.withColumn("new_col", (F.col("new_col")
                         .withField("date", F.col("dob"))
                         .withField("extra.value", F.col("comment")))))
</code>```

But I get the following error:

```<code>AnalysisException: cannot resolve 'update_fields(update_fields(new_col, WithField(dob), WithField(dob)).extra, WithField(dob))' due to data type mismatch: struct argument should be struct type, got: map<string,string>;
</code>```

I am confused as per why it would not work with the map inside the struct?

Thanks :)

答:
I figured it out!

```<code>(df
.withColumn("new_col",
            F.struct(*[F.lit(None).cast(f.dataType).alias(f.name)
                       for f in value_type.fields]))
.withColumn("new_col", (F.col("new_col")
                         .withField("date", F.col("dob"))
                         .withField("extra",
                                    F.create_map(F.lit("my_key"), F.col("comment")))))

</code>```

The problem was that I was not actually passing a map to a map type!

Body:
I have a table with dates and comments.

dob        | comment
---------------------------
1960-12-01 | this is useful

And I want a new column with this type:

value_type = T.StructType(
    [
       T.StructField("extra",T.MapType(T.StringType(), T.StringType(), True), True),
       T.StructField("date", T.StringType(), True),
       T.StructField("from_date", T.StringType(), True),
       T.StructField("to_date", T.StringType(), True),
       T.StructField("value", T.StringType(), True),
    ]
)

I need to:

put the df.date into the date field of the struct and

put the df.comment into the extra map of the struct

thanks to blackbishop I figured out how to do the first part here - and i tried to use .withField() to update the map but it throws an error:

I tried:

(df
.withColumn("new_col",
            F.struct(*[F.lit(None).cast(f.dataType).alias(f.name)
                       for f in value_type.fields]))
.withColumn("new_col", (F.col("new_col")
                         .withField("date", F.col("dob"))
                         .withField("extra.value", F.col("comment")))))

But I get the following error:

AnalysisException: cannot resolve 'update_fields(update_fields(new_col, WithField(dob), WithField(dob)).extra, WithField(dob))' due to data type mismatch: struct argument should be struct type, got: map<string,string>;

I am confused as per why it would not work with the map inside the struct?

Thanks :)

Body:
I figured it out!

(df
.withColumn("new_col",
            F.struct(*[F.lit(None).cast(f.dataType).alias(f.name)
                       for f in value_type.fields]))
.withColumn("new_col", (F.col("new_col")
                         .withField("date", F.col("dob"))
                         .withField("extra",
                                    F.create_map(F.lit("my_key"), F.col("comment")))))

The problem was that I was not actually passing a map to a map type!


问:
WebRTC issue with File transfer in production application
Hello I am developing a WebRTC based file transfer application.I have deployed the application online using Heroku. But there seems to be a problem with file transfer specifically at the the receiving end which I have been unable to figure out. The file is transferred and received successfully when done on localhost but there is a problem with file reception when done in production. The browser used is Google Chrome if that's any help.

Here is the File reception code:

```<code>function dataChannelStateChanged() {
    if (dataChannel.readyState === 'open') {
        console.log("Data Channel open");
        dataChannel.onmessage = receiveDataChannelMessage;
    }
}

function receiveDataChannel(event) {
    console.log("Receiving a data channel");
    dataChannel = event.channel;
    dataChannel.onmessage = receiveDataChannelMessage;
}

function receiveDataChannelMessage(event) {
    console.log("From DataChannel: " + event.data);
    if (fileTransferring) {
        //Now here is the file handling code:
        fileBuffer.push(event.data);
        fileSize += event.data.byteLength;
        fileProgress.value = fileSize;

        //Provide link to downloadable file when complete
        if (fileSize === receivedFileSize) {
            var received = new window.Blob(fileBuffer);
            fileBuffer = [];

            downloadLink.href = URL.createObjectURL(received);
            downloadLink.download = receivedFileName;
            downloadLink.appendChild(document.createTextNode(receivedFileName + "(" + fileSize + ") bytes"));
            fileTransferring = false;

            //Also put the file in the text chat area
            var linkTag = document.createElement('a');
            linkTag.href = URL.createObjectURL(received);
            linkTag.download = receivedFileName;
            linkTag.appendChild(document.createTextNode(receivedFileName));
            var div = document.createElement('div');
            div.className = 'message-out';
            div.appendChild(linkTag);
            messageHolder.appendChild(div);
        }
    }
    else {
        appendChatMessage(event.data, 'message-out');
    }
}
</code>```

The following image shows the problem i'm encountering when receiving the file:

Any guidance would be much appreciated.

答:
WEBRTC is based on UDP, it means there is no guarantee that your sequence of data transfers "in order" or successfully

use "webSocket" or a simple "http request" instead.

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

UPDATE: see the first comment

Body:
Hello I am developing a WebRTC based file transfer application.I have deployed the application online using Heroku. But there seems to be a problem with file transfer specifically at the the receiving end which I have been unable to figure out. The file is transferred and received successfully when done on localhost but there is a problem with file reception when done in production. The browser used is Google Chrome if that's any help.

Here is the File reception code:

function dataChannelStateChanged() {
    if (dataChannel.readyState === 'open') {
        console.log("Data Channel open");
        dataChannel.onmessage = receiveDataChannelMessage;
    }
}

function receiveDataChannel(event) {
    console.log("Receiving a data channel");
    dataChannel = event.channel;
    dataChannel.onmessage = receiveDataChannelMessage;
}

function receiveDataChannelMessage(event) {
    console.log("From DataChannel: " + event.data);
    if (fileTransferring) {
        //Now here is the file handling code:
        fileBuffer.push(event.data);
        fileSize += event.data.byteLength;
        fileProgress.value = fileSize;

        //Provide link to downloadable file when complete
        if (fileSize === receivedFileSize) {
            var received = new window.Blob(fileBuffer);
            fileBuffer = [];

            downloadLink.href = URL.createObjectURL(received);
            downloadLink.download = receivedFileName;
            downloadLink.appendChild(document.createTextNode(receivedFileName + "(" + fileSize + ") bytes"));
            fileTransferring = false;

            //Also put the file in the text chat area
            var linkTag = document.createElement('a');
            linkTag.href = URL.createObjectURL(received);
            linkTag.download = receivedFileName;
            linkTag.appendChild(document.createTextNode(receivedFileName));
            var div = document.createElement('div');
            div.className = 'message-out';
            div.appendChild(linkTag);
            messageHolder.appendChild(div);
        }
    }
    else {
        appendChatMessage(event.data, 'message-out');
    }
}

The following image shows the problem i'm encountering when receiving the file:

Any guidance would be much appreciated.