问:
Flutter Failure : Build
I have an Flutter project and facing a problem when trying to run it, i was running my application from flutter 1 and it works just fine, then im trying to migrate it to flutter 3 and when im trying to run the app it show an error, here is the debug console :

Launching lib\main.dart on sdk gphone x86 in debug mode...
lib\main.dart:1

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.

Where: Build file 'C:\Users\USERS\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\device_info_plus-8.0.0\android\build.gradle'
line: 25

What went wrong: A problem occurred evaluating project ':device_info_plus'.

org/gradle/api/services/BuildService

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

2: Task failed with an exception.

Where: Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line:
477

What went wrong: A problem occurred configuring project ':device_info_plus'.

Failed to notify project evaluation listener.
Cannot invoke method substring() on null object
compileSdkVersion is not specified.

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

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

BUILD FAILED in 2s Exception: Gradle task assembleDebug failed with
exit code 1 Exited (sigterm)

here is my app/build.gradle

```<code>def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
    compileSdkVersion 30

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.appname"
        minSdkVersion 18
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        manifestPlaceholders = [
                'appAuthRedirectScheme': 'io.identityserver.demo'
        ]
    }
    signingConfigs {
       release {
           keyAlias keystoreProperties['keyAlias']
           keyPassword keystoreProperties['keyPassword']
           storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
           storePassword keystoreProperties['storePassword']
       }
    }
    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            // signingConfig signingConfigs.debug
            signingConfig signingConfigs.release
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
</code>```

here is my android/build.gradle

```<code>buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
</code>```

here is my gradle-wrapper.properties

```<code>#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
</code>```

and here is my flutter doctor -v

[√] Flutter (Channel dev, 3.4.0-17.2.pre, on Microsoft Windows
[Version 10.0.22621.963], locale en-ID)
• Flutter version 3.4.0-17.2.pre on channel dev at C:\src\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision d6260f127f (3 months ago), 2022-09-21 13:33:49 -0500
• Engine revision 3950c6140a
• Dart version 2.19.0 (build 2.19.0-146.2.beta)
• DevTools version 2.16.0

[√] Android toolchain - develop for Android devices (Android SDK
version 33.0.1)
• Android SDK at C:\Users\USERS\AppData\Local\Android\sdk
• Platform android-33, build-tools 33.0.1
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
• All Android licenses accepted.

[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2022
17.4.1)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.4.33110.190
• Windows 10 SDK version 10.0.22000.0

[√] Android Studio (version 2021.3)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[√] VS Code (version 1.74.1)
• VS Code at C:\Users\USERS\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.54.0

[√] Connected device (3 available)
• Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.22621.963]
• Chrome (web)      • chrome  • web-javascript • Google Chrome 107.0.5304.88
• Edge (web)        • edge    • web-javascript • Microsoft Edge 107.0.1418.62

[√] HTTP Host Availability
• All required HTTP hosts are available

• No issues found!

so far what i have tried is upgrade all of my pubspec.yaml to current version, changing the compileSdkVersion, changing the build:gradle: and the gradle-all.zip into another version and i keep facing another different error so im just back to this version again to avoid further error, anyone had a solution for this? thank you!, sorry im still fairly new to this language and still looking for a solution myself thanks again!.

Title: Flutter Failure : Build

Body:
I have an Flutter project and facing a problem when trying to run it, i was running my application from flutter 1 and it works just fine, then im trying to migrate it to flutter 3 and when im trying to run the app it show an error, here is the debug console :

Launching lib\main.dart on sdk gphone x86 in debug mode...
lib\main.dart:1

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.

Where: Build file 'C:\Users\USERS\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\device_info_plus-8.0.0\android\build.gradle'
line: 25

What went wrong: A problem occurred evaluating project ':device_info_plus'.

org/gradle/api/services/BuildService

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

2: Task failed with an exception.

Where: Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line:
477

What went wrong: A problem occurred configuring project ':device_info_plus'.

Failed to notify project evaluation listener.
Cannot invoke method substring() on null object
compileSdkVersion is not specified.

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

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

BUILD FAILED in 2s Exception: Gradle task assembleDebug failed with
exit code 1 Exited (sigterm)

here is my app/build.gradle

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
    compileSdkVersion 30

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.appname"
        minSdkVersion 18
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        manifestPlaceholders = [
                'appAuthRedirectScheme': 'io.identityserver.demo'
        ]
    }
    signingConfigs {
       release {
           keyAlias keystoreProperties['keyAlias']
           keyPassword keystoreProperties['keyPassword']
           storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
           storePassword keystoreProperties['storePassword']
       }
    }
    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            // signingConfig signingConfigs.debug
            signingConfig signingConfigs.release
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

here is my android/build.gradle

buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

here is my gradle-wrapper.properties

#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip

and here is my flutter doctor -v

[√] Flutter (Channel dev, 3.4.0-17.2.pre, on Microsoft Windows
[Version 10.0.22621.963], locale en-ID)
• Flutter version 3.4.0-17.2.pre on channel dev at C:\src\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision d6260f127f (3 months ago), 2022-09-21 13:33:49 -0500
• Engine revision 3950c6140a
• Dart version 2.19.0 (build 2.19.0-146.2.beta)
• DevTools version 2.16.0

[√] Android toolchain - develop for Android devices (Android SDK
version 33.0.1)
• Android SDK at C:\Users\USERS\AppData\Local\Android\sdk
• Platform android-33, build-tools 33.0.1
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
• All Android licenses accepted.

[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2022
17.4.1)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.4.33110.190
• Windows 10 SDK version 10.0.22000.0

[√] Android Studio (version 2021.3)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[√] VS Code (version 1.74.1)
• VS Code at C:\Users\USERS\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.54.0

[√] Connected device (3 available)
• Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.22621.963]
• Chrome (web)      • chrome  • web-javascript • Google Chrome 107.0.5304.88
• Edge (web)        • edge    • web-javascript • Microsoft Edge 107.0.1418.62

[√] HTTP Host Availability
• All required HTTP hosts are available

• No issues found!

so far what i have tried is upgrade all of my pubspec.yaml to current version, changing the compileSdkVersion, changing the build:gradle: and the gradle-all.zip into another version and i keep facing another different error so im just back to this version again to avoid further error, anyone had a solution for this? thank you!, sorry im still fairly new to this language and still looking for a solution myself thanks again!.


来源: stackexchange

问:
Run only specific stage
I have 4 stages. But one stage is independent. I just want to run it by ever week. I could not find any information about running a single stage.</p>

ContentLicense: CC BY-SA 4.0

Title: Run only specific stage


问:
Is there a pre-processor variable indicating QNX SDP 6/7 difference?
We have some code originally developed for QNX SDP 6.6 that we are porting to QNX SDP 7.0 (7.1 does not yet have the board support packages we need).

As part of the porting effort, we are finding things that have been removed in 7.1, such as getprio() to retrieve the process priority. Now I know what that need to be replaced with but, in the interest of minimal impact to the code base, I went looking for a pre-processor variable to indicate whether I'm compiling with SDP 7.0 or something earlier.

That way, I could simply use #ifdef to select which code to compile, along the lines of __STDC_VERSION__ to figure out which ISO iteration applies.

However, I can't find anything in the QNX docs that seem relevant. I found __QNX__ and __QNXNTO__ which together let me figure out whether it's non-QNX, QNX 4, or QNX Neutrino, but nothing that appears to detect a difference between QNX 6 and 7.

Is there such a beast available?


问:
File is not getting deleted?
This line is showing true but  still not getting deleted from storage

```<code>fun delete(file: File  ,context: Context , pagesNO : List<Int> ,name : String ) {

    val d0 = file.delete()

    Log.i(TAG, "is deleted ${d0}")
    //    return
}

</code>```

I want to delete the file to external storage.

Title: File is not getting deleted?

Body:
This line is showing true but  still not getting deleted from storage

fun delete(file: File  ,context: Context , pagesNO : List<Int> ,name : String ) {

    val d0 = file.delete()

    Log.i(TAG, "is deleted ${d0}")
    //    return
}

I want to delete the file to external storage.


问:
detect markerCluster for leaflet is done recalculating
I would like to detect when my clusters for markerCluster have changed. zoomend and animationend do not seem to work.


问:
How can trigger the new announcement be created in google classroom?
I read the apps script and can’t find the  classroomtriggerbuilder.
I want to know, are there have any method can trigger the new announcement be created?

I consider a method like below.
I will save the announcements in google sheet,and set timer to check google classroom’s announcements length equal to google sheet or not.

But I don’t know are there have any other way to achieve it too.
Please help me!!


问:
local storage loses property when submit a form
I'm working on a toDo project with local storage. When i try do update the local storage it works perfectly. But after pressing the submit button and the page is reloading the data gets lost. I'm trying to update the name and the description. To update the name works fine, but the description doesn't. I don't get the problem. Between update the property and reloading the page the code didn't do anything.

I'm starting to despair ;)

```<code>function _editProjectHeader() {
    addProjectContainer.style.visibility = 'visible';

    projectNameContainer.value = _getActiveProject().getName();
    projectDescriptionContainer.value = _getActiveProject().getDescription();

    addProjectBtnSmallWindow.addEventListener('click', () => {
        _getActiveProject().setName(projectNameContainer.value); // Works fine
        _getActiveProject().setDescription(projectDescriptionContainer.value); // works fine to before update the page
        console.log(projectList);
        console.log(localStorage); // Here the data is stored in localstorage
    })
}
</code>```

Now after reloading the page, first I do a console log localstorage and the property didn't stored in it. How is that possible?

Get the active project from project list. The list stores all projects with name and description

```<code>function _getActiveProject() {
    const amountOfProjects = Object.keys(projectList).length;
    for (let i = 0; i <= amountOfProjects; i++) {
        if (projectList.getSingleProjects(i).isActive() == true) {
            return projectList.getSingleProjects(i)
        }
    }
}
</code>```

My project class

```<code>import { toDate, isToday, isThisWeek, subDays } from 'date-fns'
import { projectList } from '../index';

export class Projects {
    constructor(name) {
        this.name = name;
        this.tasks = {};
        this.active = false;
        this.description = '';
    }

    setName(name) {
        this.name = name;
        projectList.safeToProjectList(this);
    }

    setActiveTrue() {
        this.active = true;
        projectList.safeToProjectList(this);
    }

    isActive() {
        return this.active ? true : false;
    }

    getName() {
        return this.name;
    }

    setDescription(decription) {
        this.description = decription;
        projectList.safeToProjectList(this);
    }

    getDescription() {
        return this.description;
    }

    addTaskToList(task) {
        this.tasks[task.name] = task;
    }

    getTasks() {
        return this.tasks;
    }

    getTasksToday() {
        return this.tasks.filter((task) => {
          const taskDate = new Date(task.getDateFormatted())
          return isToday(toDate(taskDate))
        })
    }

    getTasksThisWeek() {
        return this.tasks.filter((task) => {
          const taskDate = new Date(task.getDateFormatted())
          return isThisWeek(subDays(toDate(taskDate), 1))
        })
    }

    updateLocalStorage() {

    }

}
</code>```

And my project list class where I store my projects

```<code>import { Projects } from "./project";
import { Tasks } from "./tasks";

export class ProjectList {
    constructor() {
        if (localStorage.getItem('list') != null) {
            this.projectList = JSON.parse(localStorage.getItem('list'));
            console.log('loading existing data');
        } else {
            this.projectList = {};
            localStorage.setItem('list', JSON.stringify(projectList));
            console.log('setting new data');
        }
    }

    safeToProjectList(project) {
        this.projectList[project.getName()] = project;
        localStorage.setItem('list', JSON.stringify(this.projectList));
    }

    deleteProjectFromList(project) {
        delete this.projectList[project]
        localStorage.setItem('list', JSON.stringify(this.projectList))
    }

    loadProjectList() {
       this.projectList = JSON.parse(localStorage.getItem('list'))
    }

    updateTodayTasks() {
        const today = new Projects('inbox');
        const amountOfProjects = Object.keys(this.projectList).length - 1;
        for (let i = 0; i <= amountOfProjects; i++) {
            const tasks = [Object.values(this.projectList)[i]][0].getTasksToday()
            if (tasks.length > 0) {
                today.addTaskToList(tasks);
            }
        }
        return today;
    }

    updateWeekTasks() {
        const thisWeek = new Projects('thisWeek');
        const amountOfProjects = Object.keys(this.projectList).length - 1;
        for (let i = 0; i <= amountOfProjects; i++) {
            const tasks = [Object.values(this.projectList)[i]][0].getTasksThisWeek()
            if (tasks.length > 0) {
                thisWeek.addTaskToList(tasks);
            }
        }
        return thisWeek;
    }

    updateInboxTasks() {
        const inbox = new Projects('thisWeek');
        const amountOfProjects = Object.keys(this.projectList).length - 1;
        for (let i = 0; i <= amountOfProjects; i++) {
            const tasks = [Object.values(this.projectList)[i]][0].getTasks();
            if (tasks.length > 0) {
                inbox.addTaskToList(tasks);
            }
        }
        return inbox;
    }

    getNameFromProjects() {
        const nameArray = [];
        const amountOfProjects = Object.keys(this.projectList).length - 1;
        for (let i = 0; i <= amountOfProjects; i++) {
            const name = [Object.values(this.projectList)[i]][0].getName();
            nameArray.push(name);
        }
        return nameArray
    }

    setProjectsActiveFalse() {
        const amountOfProjects = Object.keys(this.projectList).length - 1;
        for (let i = 0; i <= amountOfProjects; i++) {
            [Object.values(this.projectList)[i]][0].active = false;
        }
        //Local storage
        this.safeCurrentProject();
    }

    getSingleProjects(i) {
        //Build here new Project
        let project = new Projects([Object.values(this.projectList)[i]][0].name);

        //Set active bool
        if ([Object.values(this.projectList)[i]][0].active ==  true) {
            project.setActiveTrue();
        };

        //Add description
        project.setDescription([Object.values(this.projectList)[i]][0].description);

        //Add tasks
        const tasks = [Object.values(this.projectList)[i]][0].tasks;
        const newTasks = Object.values(tasks).length - 1
        if (newTasks > 0) {
            // const amountOfProjects = Object.keys(this.projectList).length - 1;
            for (let x = 0; x <= newTasks; x++) {
                //Filter data from tasks
                //Add new task
                const taskName = [Object.values(tasks)[x]][0].name;
                const taskDate = [Object.values(tasks)[x]][0].dueDate;
                const taskPriority = [Object.values(tasks)[x]][0].priority;
                const taskProject = [Object.values(tasks)[x]][0].project;
                const taskComplete = [Object.values(tasks)[x]][0].complete;

                const task = new Tasks(taskName, taskDate, taskPriority, taskProject, taskComplete);
                project.addTaskToList(task);
            }
        }
        return project;
    }

    safeCurrentProject() {
        localStorage.setItem('list', JSON.stringify(this.projectList));
    }

}
</code>```

The whole code
https://github.com/SandyWezzy/toDo_list

Thanks in advance :)

Body:
I'm working on a toDo project with local storage. When i try do update the local storage it works perfectly. But after pressing the submit button and the page is reloading the data gets lost. I'm trying to update the name and the description. To update the name works fine, but the description doesn't. I don't get the problem. Between update the property and reloading the page the code didn't do anything.

I'm starting to despair ;)

function _editProjectHeader() {
    addProjectContainer.style.visibility = 'visible';

    projectNameContainer.value = _getActiveProject().getName();
    projectDescriptionContainer.value = _getActiveProject().getDescription();

    addProjectBtnSmallWindow.addEventListener('click', () => {
        _getActiveProject().setName(projectNameContainer.value); // Works fine
        _getActiveProject().setDescription(projectDescriptionContainer.value); // works fine to before update the page
        console.log(projectList);
        console.log(localStorage); // Here the data is stored in localstorage
    })
}

Now after reloading the page, first I do a console log localstorage and the property didn't stored in it. How is that possible?

Get the active project from project list. The list stores all projects with name and description

function _getActiveProject() {
    const amountOfProjects = Object.keys(projectList).length;
    for (let i = 0; i <= amountOfProjects; i++) {
        if (projectList.getSingleProjects(i).isActive() == true) {
            return projectList.getSingleProjects(i)
        }
    }
}

My project class

import { toDate, isToday, isThisWeek, subDays } from 'date-fns'
import { projectList } from '../index';

export class Projects {
    constructor(name) {
        this.name = name;
        this.tasks = {};
        this.active = false;
        this.description = '';
    }

    setName(name) {
        this.name = name;
        projectList.safeToProjectList(this);
    }

    setActiveTrue() {
        this.active = true;
        projectList.safeToProjectList(this);
    }

    isActive() {
        return this.active ? true : false;
    }

    getName() {
        return this.name;
    }

    setDescription(decription) {
        this.description = decription;
        projectList.safeToProjectList(this);
    }

    getDescription() {
        return this.description;
    }

    addTaskToList(task) {
        this.tasks[task.name] = task;
    }

    getTasks() {
        return this.tasks;
    }

    getTasksToday() {
        return this.tasks.filter((task) => {
          const taskDate = new Date(task.getDateFormatted())
          return isToday(toDate(taskDate))
        })
    }

    getTasksThisWeek() {
        return this.tasks.filter((task) => {
          const taskDate = new Date(task.getDateFormatted())
          return isThisWeek(subDays(toDate(taskDate), 1))
        })
    }

    updateLocalStorage() {

    }

}

And my project list class where I store my projects

import { Projects } from "./project";
import { Tasks } from "./tasks";

export class ProjectList {
    constructor() {
        if (localStorage.getItem('list') != null) {
            this.projectList = JSON.parse(localStorage.getItem('list'));
            console.log('loading existing data');
        } else {
            this.projectList = {};
            localStorage.setItem('list', JSON.stringify(projectList));
            console.log('setting new data');
        }
    }

    safeToProjectList(project) {
        this.projectList[project.getName()] = project;
        localStorage.setItem('list', JSON.stringify(this.projectList));
    }

    deleteProjectFromList(project) {
        delete this.projectList[project]
        localStorage.setItem('list', JSON.stringify(this.projectList))
    }

    loadProjectList() {
       this.projectList = JSON.parse(localStorage.getItem('list'))
    }

    updateTodayTasks() {
        const today = new Projects('inbox');
        const amountOfProjects = Object.keys(this.projectList).length - 1;
        for (let i = 0; i <= amountOfProjects; i++) {
            const tasks = [Object.values(this.projectList)[i]][0].getTasksToday()
            if (tasks.length > 0) {
                today.addTaskToList(tasks);
            }
        }
        return today;
    }

    updateWeekTasks() {
        const thisWeek = new Projects('thisWeek');
        const amountOfProjects = Object.keys(this.projectList).length - 1;
        for (let i = 0; i <= amountOfProjects; i++) {
            const tasks = [Object.values(this.projectList)[i]][0].getTasksThisWeek()
            if (tasks.length > 0) {
                thisWeek.addTaskToList(tasks);
            }
        }
        return thisWeek;
    }

    updateInboxTasks() {
        const inbox = new Projects('thisWeek');
        const amountOfProjects = Object.keys(this.projectList).length - 1;
        for (let i = 0; i <= amountOfProjects; i++) {
            const tasks = [Object.values(this.projectList)[i]][0].getTasks();
            if (tasks.length > 0) {
                inbox.addTaskToList(tasks);
            }
        }
        return inbox;
    }

    getNameFromProjects() {
        const nameArray = [];
        const amountOfProjects = Object.keys(this.projectList).length - 1;
        for (let i = 0; i <= amountOfProjects; i++) {
            const name = [Object.values(this.projectList)[i]][0].getName();
            nameArray.push(name);
        }
        return nameArray
    }

    setProjectsActiveFalse() {
        const amountOfProjects = Object.keys(this.projectList).length - 1;
        for (let i = 0; i <= amountOfProjects; i++) {
            [Object.values(this.projectList)[i]][0].active = false;
        }
        //Local storage
        this.safeCurrentProject();
    }

    getSingleProjects(i) {
        //Build here new Project
        let project = new Projects([Object.values(this.projectList)[i]][0].name);

        //Set active bool
        if ([Object.values(this.projectList)[i]][0].active ==  true) {
            project.setActiveTrue();
        };

        //Add description
        project.setDescription([Object.values(this.projectList)[i]][0].description);

        //Add tasks
        const tasks = [Object.values(this.projectList)[i]][0].tasks;
        const newTasks = Object.values(tasks).length - 1
        if (newTasks > 0) {
            // const amountOfProjects = Object.keys(this.projectList).length - 1;
            for (let x = 0; x <= newTasks; x++) {
                //Filter data from tasks
                //Add new task
                const taskName = [Object.values(tasks)[x]][0].name;
                const taskDate = [Object.values(tasks)[x]][0].dueDate;
                const taskPriority = [Object.values(tasks)[x]][0].priority;
                const taskProject = [Object.values(tasks)[x]][0].project;
                const taskComplete = [Object.values(tasks)[x]][0].complete;

                const task = new Tasks(taskName, taskDate, taskPriority, taskProject, taskComplete);
                project.addTaskToList(task);
            }
        }
        return project;
    }

    safeCurrentProject() {
        localStorage.setItem('list', JSON.stringify(this.projectList));
    }

}

The whole code
https://github.com/SandyWezzy/toDo_list

Thanks in advance :)


问:
A.I. of crochet patterns- counting stitches and rows
I'm trying to create an AI model that will count stitches and rows in crochet pictures. I am not exactly sure how to approach this problem so I would like to get reccomendations of how and where to start. I dont have a lot of knowledge about AIs but am willing to learn. I want to code this AI using pycharm.

I did research and realised there is no already made data I can use or any models like this that work. So does this mean I need to manually create files of crochet pictures and where each stitch is located?
Thanks in advance.


问:
android-studio vpn service
i`ve despair about disconnect any vpn app

is there possible to disconnect any vpn app with android studio?

im still try and got the stuck to continue this code

I am very grateful for the help provided

sorry about the broken english:D

```<code></code>```
```<code>public class MainActivity extends AppCompatActivity {

    Button mulai, hentikan;
    TextView textstatus;

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

        mulai = findViewById(R.id.mulai);
        hentikan = findViewById(R.id.hentikan);
        textstatus = findViewById(R.id.status);

        mulai.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
               Context context = MainActivity.this;
               ConnectivityManager cManager = (ConnectivityManager) context.getSystemService(context.CONNECTIVITY_SERVICE);
                Network activenet = null;
                if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
                    activenet = cManager.getActiveNetwork();
                }
                NetworkCapabilities netCaps = cManager.getNetworkCapabilities(activenet);
               boolean vpn = netCaps.hasTransport(NetworkCapabilities.TRANSPORT_VPN);
                if (vpn){

                    textstatus.setText("vpn sedang berjalan");
                }else{
                    textstatus.setText("tidak ada vpn yang berjalan");
                }

            }
        });
        hentikan.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (textstatus.getText().toString().equals("vpn sedang berjalan")) {
                    checkvpn();

                    Toast.makeText(MainActivity.this, "vpn dihentikan", Toast.LENGTH_SHORT).show();

                    Toast.makeText(MainActivity.this, "sangat error pada saat hentikan vpn", Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(MainActivity.this, "error pada saat hentikan vpn", Toast.LENGTH_SHORT).show();
                }
            }
        });
    }

    private void checkvpn() {
        Context context = MainActivity.this;
        VpnManager vpn = (VpnManager) getSystemService()
    }
}
</code>```

Title: android-studio vpn service

Body:
i`ve despair about disconnect any vpn app

is there possible to disconnect any vpn app with android studio?

im still try and got the stuck to continue this code

I am very grateful for the help provided

sorry about the broken english:D

public class MainActivity extends AppCompatActivity {

    Button mulai, hentikan;
    TextView textstatus;

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

        mulai = findViewById(R.id.mulai);
        hentikan = findViewById(R.id.hentikan);
        textstatus = findViewById(R.id.status);

        mulai.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
               Context context = MainActivity.this;
               ConnectivityManager cManager = (ConnectivityManager) context.getSystemService(context.CONNECTIVITY_SERVICE);
                Network activenet = null;
                if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
                    activenet = cManager.getActiveNetwork();
                }
                NetworkCapabilities netCaps = cManager.getNetworkCapabilities(activenet);
               boolean vpn = netCaps.hasTransport(NetworkCapabilities.TRANSPORT_VPN);
                if (vpn){

                    textstatus.setText("vpn sedang berjalan");
                }else{
                    textstatus.setText("tidak ada vpn yang berjalan");
                }

            }
        });
        hentikan.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (textstatus.getText().toString().equals("vpn sedang berjalan")) {
                    checkvpn();

                    Toast.makeText(MainActivity.this, "vpn dihentikan", Toast.LENGTH_SHORT).show();

                    Toast.makeText(MainActivity.this, "sangat error pada saat hentikan vpn", Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(MainActivity.this, "error pada saat hentikan vpn", Toast.LENGTH_SHORT).show();
                }
            }
        });
    }

    private void checkvpn() {
        Context context = MainActivity.this;
        VpnManager vpn = (VpnManager) getSystemService()
    }
}


问:
Keras: How to continue training with weights in Keras?
I would like to continue a training (whose job was killed) from last saved weights. I am using tensorflow 2.0, and every documentation I see concern the function load_model(). However, as I only got the weights, I need to use load_weights(), but I do not know what to do next with the loaded weights.

Thank you for your help.


问:
Despite creating Workflows, Logic App Workflow listing is empty
I created a Workflow in Logic App, but the workflow listing in my Logic App keeps showing empty most of the times (though some times it does show my created workflows).

I've tried force-refreshing the page multiple times. Didn't work.

When I tried to open the workflow in Designer using its URL from browser history, it showed me an "unexpected error":

Switched from Firefox to Edge: didn't make any difference.

The overview of the workflow:

Yet the list of workflows is empty:

There are a bunch of messages in the activity log of the Logic App that I'm unsure what to make of:

I'm brand new to Logic Apps, so can't figure out what's going on.


问:
how to change label font, bounding box color and thickness with custom yolov5
I need to change the label font and bounding box color, in the inference

i have assigned a variable for torch hub model and pass it to running the inference but coudnt change the bounding box color and and text font

```<code>model = torch.hub.load('ultralytics/yolov5', 'custom', path=r'C:\Users\rohin\Desktop\NewData\yolo training\last.pt', force_reload=True)
cap = cv2.VideoCapture(0)
while cap.isOpened():
    ret, frame = cap.read()

    # Make detections
    results = model(frame)

    cv2.imshow('YOLO', np.squeeze(results.render()))

    if cv2.waitKey(10) & 0xFF == ord('q'):
        break
cap.release()
cv2.destroyAllWindows()

</code>```

Body:
I need to change the label font and bounding box color, in the inference

i have assigned a variable for torch hub model and pass it to running the inference but coudnt change the bounding box color and and text font

model = torch.hub.load('ultralytics/yolov5', 'custom', path=r'C:\Users\rohin\Desktop\NewData\yolo training\last.pt', force_reload=True)
cap = cv2.VideoCapture(0)
while cap.isOpened():
    ret, frame = cap.read()

    # Make detections
    results = model(frame)

    cv2.imshow('YOLO', np.squeeze(results.render()))

    if cv2.waitKey(10) & 0xFF == ord('q'):
        break
cap.release()
cv2.destroyAllWindows()


问:
Mongodb, Realm-cli: “Unknown system error -86”
As a personal project, I wanted to build an offline first app with Mondodb's realm, but I am not getting very far at all. The documentation suggests to install the realm CLI (npm install -g mongodb-realm-cli), but I am unable to run it. I get this error anytime I try running the realm-cli, no matter the input:

```<code>~ realm-cli -v
node:internal/child_process:413
    throw errnoException(err, 'spawn');
    ^

Error: spawn Unknown system error -86
    at ChildProcess.spawn (node:internal/child_process:413:11)
    at spawn (node:child_process:700:9)
    at Object.<anonymous> (/usr/local/lib/node_modules/mongodb-realm-cli/wrapper.js:22:22)
    at Module._compile (node:internal/modules/cjs/loader:1099:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47 {
  errno: -86,
  code: 'Unknown system error -86',
  syscall: 'spawn'
}

Node.js v17.9.0
</code>```

I saw that there was one other ticket open about the same case:

https://stackoverflow.com/questions/72157854/unable-to-run-realm-cli-on-mac-m1-return-nodeinternal-child-process

Just like that user, I am also using an M1 mac, but his solution was to freshly setup his macbook again. My macbook however is on a completely fresh install, and yet I experience this problem anyway.

I cannot find any other cases about this online.

Is this an M1 specific issue? Any idea how I can fix this?

I have tried uninstalling and re-installing the package with different npm versions through nvm, but I had no success with any version I tried.

Body:
As a personal project, I wanted to build an offline first app with Mondodb's realm, but I am not getting very far at all. The documentation suggests to install the realm CLI (npm install -g mongodb-realm-cli), but I am unable to run it. I get this error anytime I try running the realm-cli, no matter the input:

~ realm-cli -v
node:internal/child_process:413
    throw errnoException(err, 'spawn');
    ^

Error: spawn Unknown system error -86
    at ChildProcess.spawn (node:internal/child_process:413:11)
    at spawn (node:child_process:700:9)
    at Object.<anonymous> (/usr/local/lib/node_modules/mongodb-realm-cli/wrapper.js:22:22)
    at Module._compile (node:internal/modules/cjs/loader:1099:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47 {
  errno: -86,
  code: 'Unknown system error -86',
  syscall: 'spawn'
}

Node.js v17.9.0

I saw that there was one other ticket open about the same case:

https://stackoverflow.com/questions/72157854/unable-to-run-realm-cli-on-mac-m1-return-nodeinternal-child-process

Just like that user, I am also using an M1 mac, but his solution was to freshly setup his macbook again. My macbook however is on a completely fresh install, and yet I experience this problem anyway.

I cannot find any other cases about this online.

Is this an M1 specific issue? Any idea how I can fix this?

I have tried uninstalling and re-installing the package with different npm versions through nvm, but I had no success with any version I tried.


问:
how do i solve AttributeError: 'float' object has no attribute 'encode'

this is the code

```<code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

plt.style.use('ggplot')

import nltk

df = pd.read_csv('/kaggle/input/starbucks-review-play-store/starbucksEN.csv',sep=",", encoding="utf-8")
df = df.head(70000)

ax = df\['Score'\].value_counts().sort_index() \
.plot(kind='bar',
title='Count of Reviews by Stars',
figsize=(10, 5))
ax.set_xlabel('Review Stars')
plt.show()

from nltk.sentiment import SentimentIntensityAnalyzer
from tqdm.notebook import tqdm

sia = SentimentIntensityAnalyzer()

res = {}
for i, row in tqdm(df.iterrows(), total=len(df)):
text = row\['Text'\]
myid = row\['Id'\]
res\[myid\] = sia.polarity_scores(text)

</code>```

this is what show up

```<code>AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_27/744249663.py in \<module\>
3     text = row\['Text'\]
4     myid = row\['Id'\]
\----\> 5     res\[myid\] = sia.polarity_scores(text)

/opt/conda/lib/python3.7/site-packages/nltk/sentiment/vader.py in polarity_scores(self, text)
360         # text, words_and_emoticons, is_cap_diff = self.preprocess(text)
361         sentitext = SentiText(
\--\> 362             text, self.constants.PUNC_LIST, self.constants.REGEX_REMOVE_PUNCTUATION
363         )
364         sentiments = \[\]

/opt/conda/lib/python3.7/site-packages/nltk/sentiment/vader.py in __init__(self, text, punc_list, regex_remove_punctuation)
268     def __init__(self, text, punc_list, regex_remove_punctuation):
269         if not isinstance(text, str):
\--\> 270             text = str(text.encode("utf-8"))
271         self.text = text
272         self.PUNC_LIST = punc_list

AttributeError: 'float' object has no attribute 'encode'

</code>```

i'm trying to do sentiment analysis by wathing this video on youtube. here is the link to his kaggle notebook  https://www.kaggle.com/code/robikscube/sentiment-analysis-python-youtube-tutorial/notebook
i don't know what is wrong. how do i fix this?

Body:
this is the code

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

plt.style.use('ggplot')

import nltk

df = pd.read_csv('/kaggle/input/starbucks-review-play-store/starbucksEN.csv',sep=",", encoding="utf-8")
df = df.head(70000)

ax = df\['Score'\].value_counts().sort_index() \
.plot(kind='bar',
title='Count of Reviews by Stars',
figsize=(10, 5))
ax.set_xlabel('Review Stars')
plt.show()

from nltk.sentiment import SentimentIntensityAnalyzer
from tqdm.notebook import tqdm

sia = SentimentIntensityAnalyzer()

res = {}
for i, row in tqdm(df.iterrows(), total=len(df)):
text = row\['Text'\]
myid = row\['Id'\]
res\[myid\] = sia.polarity_scores(text)

this is what show up

AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_27/744249663.py in \<module\>
3     text = row\['Text'\]
4     myid = row\['Id'\]
\----\> 5     res\[myid\] = sia.polarity_scores(text)

/opt/conda/lib/python3.7/site-packages/nltk/sentiment/vader.py in polarity_scores(self, text)
360         # text, words_and_emoticons, is_cap_diff = self.preprocess(text)
361         sentitext = SentiText(
\--\> 362             text, self.constants.PUNC_LIST, self.constants.REGEX_REMOVE_PUNCTUATION
363         )
364         sentiments = \[\]

/opt/conda/lib/python3.7/site-packages/nltk/sentiment/vader.py in __init__(self, text, punc_list, regex_remove_punctuation)
268     def __init__(self, text, punc_list, regex_remove_punctuation):
269         if not isinstance(text, str):
\--\> 270             text = str(text.encode("utf-8"))
271         self.text = text
272         self.PUNC_LIST = punc_list

AttributeError: 'float' object has no attribute 'encode'

i'm trying to do sentiment analysis by wathing this video on youtube. here is the link to his kaggle notebook  https://www.kaggle.com/code/robikscube/sentiment-analysis-python-youtube-tutorial/notebook
i don't know what is wrong. how do i fix this?


问:
Browser Back behaviour and how to reload the page on back-navigation cross-browser
I have a situation where I need to fully reload a page, when a user navigates back to that page (using Browser "back" controls, "swipe right" trackpads or Keyboard controls).

Initially, I noticed that browsers (by default) do not handle the "go back" action the same.
Safari and Brave do not reload the page once navigated back. Chrome reloads it.

So for example, if you where to put this code on your page:

```<code>jQuery(document).ready(function() {
  console.log('document ready');
});
</code>```

... then in Safari and Brave you would not see any logged message, you would however in Chrome.

Then, in order to force the page reload whenever the user "goes back", I attempted something like this:

```<code>jQuery(window).on('pageshow', function ( event ) {

  var historyTraversal = event.persisted ||
                         ( typeof window.performance != "undefined" &&
                              window.performance.navigation.type === 2 );
  if ( historyTraversal ) {

    // Handle page restore.
    window.location.reload();

  } else {
    // nothing for now.
  }

});
</code>```

Now interestingly this works in Safari and Chrome (I would have expected it to fail in Safari), but, it still does not reload the page in Brave. Brave just seems to "cache" the previous page and does literally not reload anything in it.

Is there a cross-browser compatible way to force-reload the page when the user navigates back using Browser Controls, swipe actions, or keyboard commands?

I am aware that the better thing do do would be asking "Why do you even want to alter browser default behaviour", however in this case, I need to refresh data from the server, and cannot rely on eventually cached values when the user navigates back.

Can someone shed light into:

why are the browsers actually not performing the back navigation the same way

what is the best and most reliable way to refresh the page, when it is navigated back to

Thank you.

Body:
I have a situation where I need to fully reload a page, when a user navigates back to that page (using Browser "back" controls, "swipe right" trackpads or Keyboard controls).

Initially, I noticed that browsers (by default) do not handle the "go back" action the same.
Safari and Brave do not reload the page once navigated back. Chrome reloads it.

So for example, if you where to put this code on your page:

jQuery(document).ready(function() {
  console.log('document ready');
});

... then in Safari and Brave you would not see any logged message, you would however in Chrome.

Then, in order to force the page reload whenever the user "goes back", I attempted something like this:

jQuery(window).on('pageshow', function ( event ) {

  var historyTraversal = event.persisted ||
                         ( typeof window.performance != "undefined" &&
                              window.performance.navigation.type === 2 );
  if ( historyTraversal ) {

    // Handle page restore.
    window.location.reload();

  } else {
    // nothing for now.
  }

});

Now interestingly this works in Safari and Chrome (I would have expected it to fail in Safari), but, it still does not reload the page in Brave. Brave just seems to "cache" the previous page and does literally not reload anything in it.

Is there a cross-browser compatible way to force-reload the page when the user navigates back using Browser Controls, swipe actions, or keyboard commands?

I am aware that the better thing do do would be asking "Why do you even want to alter browser default behaviour", however in this case, I need to refresh data from the server, and cannot rely on eventually cached values when the user navigates back.

Can someone shed light into:

why are the browsers actually not performing the back navigation the same way

what is the best and most reliable way to refresh the page, when it is navigated back to

Thank you.


问:
C doubly linked list
I am trying to implement (BST) with doubly linked list in C with loops.  but something I couldn't understand why one could is work as expected and the other is not.

look at first code which is working well.

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

typedef struct Node {
  int data;
  struct Node* left;
  struct Node* right;
} Node;

typedef struct BST {
  Node* root;
}BST;

Node * createNode(int value) {
  Node * a= (Node* )malloc(sizeof(Node));
  a->left = NULL;
  a->right = NULL;
  a->data = value;
  return a;
}
void printBST(Node * bst) {
  if(bst == NULL) {return; }
  printf("%d ", bst->data);
  printBST(bst->left);
  printBST(bst->right);
}

Node* createRandomBST(size_t len){
  if(len == 0) {return NULL;}

  Node* tempBST = createNode(rand()%200);

  printf("   root: %d \n",  tempBST->data);

  Node* ptr_1;
  Node  *ptr_2;
  ptr_1 = tempBST;
  ptr_2 = tempBST;

  for(int  i = 0; i < len; i++) {
    int value = i*i+22;
    tempBST = ptr_1;
    while (1)
    {

      if(value >= tempBST->data) {

        if(tempBST->right == NULL) {
          tempBST->right = createNode(value);
          printf("right-I: %d, value:%d \n", i, tempBST->data);
          break;
        }
        tempBST = tempBST ->right;

      }else {

        if(tempBST->left == NULL) {
          tempBST->left = createNode(value);
          printf("left-I: %d, value:%d \n", i, value);
          break;
        }
        tempBST= tempBST->left;
      }
    }

  }
return ptr_2;
}
</code>```

Second  code which isn't working as expected.

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

typedef struct Node {
  int data;
  struct Node* left;
  struct Node* right;
} Node;

typedef struct BST {
  Node* root;
}BST;

Node * createNode(int value) {
  Node * a= (Node* )malloc(sizeof(Node));
  a->left = NULL;
  a->right = NULL;
  a->data = value;
  return a;
}
void printBST(Node * bst) {
  if(bst == NULL) {return; }
  printf("%d ", bst->data);
  printBST(bst->left);
  printBST(bst->right);
}

Node* createRandomBST(size_t len){
  if(len == 0) {return NULL;}

  Node* tempBST = createNode(rand()%200); //start by creating root node.

  printf("   root: %d \n",  tempBST->data); // print the root node

  Node* ptr_1;
  Node  *ptr_2;
  ptr_1 = tempBST; // ptr_1 and ptr_2 are copy of the root node.
  ptr_2 = tempBST;

  for(int  i = 0; i < len; i++) {  // start the loop -- tempBST , ptr_1 and ptr_2 are all pointing to the root node
    int value = i*i+22;    //the value needed to be inserted.
    tempBST = ptr_1;  // every time  need to insert a node it will  start from the root node.

    while (1)  //loop until insertion is happend
    {

      if(value >= tempBST->data) {   //if the value greater than the root->data then go right
         tempBST = tempBST ->right;  // now tempBST is pointing to tempBST->right not the root
        if(tempBST == NULL) {       //if tempBST is null then the insertion will happened else loop with tempBST-> as the root..
          tempBST = createNode(value);     //if tempBST->right is empty insert the node.
          printf("right-I: %d, value:%d \n", i, tempBST->data);
          break; break;
        }
      }else { //if the value greater than the root->data then go left

          tempBST = tempBST ->left; // now tempBST is pointing to tempBST->left not the root
          if(tempBST == NULL) {
          tempBST = createNode(value); //if tempBST->left is null then the insertion will happened else loop with tempBST-> as the root..
          printf("left-I: %d, value:%d \n", i, value);
          break;
        }

      }
    }
  }
return ptr_2;  //return  a pointer the root;
}

int main() {
  Node* tem;
  tem = createRandomBST(20);
  printf("%d ", tem->data);
  printBST(tem);

}
</code>```

I tried to debug it with GDB I couldn't understand the problem.
in the first code the printBST() print all the nodes but in the second one only the root is being printed

Title: C doubly linked list

Body:
I am trying to implement (BST) with doubly linked list in C with loops.  but something I couldn't understand why one could is work as expected and the other is not.

look at first code which is working well.

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

typedef struct Node {
  int data;
  struct Node* left;
  struct Node* right;
} Node;

typedef struct BST {
  Node* root;
}BST;

Node * createNode(int value) {
  Node * a= (Node* )malloc(sizeof(Node));
  a->left = NULL;
  a->right = NULL;
  a->data = value;
  return a;
}
void printBST(Node * bst) {
  if(bst == NULL) {return; }
  printf("%d ", bst->data);
  printBST(bst->left);
  printBST(bst->right);
}

Node* createRandomBST(size_t len){
  if(len == 0) {return NULL;}

  Node* tempBST = createNode(rand()%200);

  printf("   root: %d \n",  tempBST->data);

  Node* ptr_1;
  Node  *ptr_2;
  ptr_1 = tempBST;
  ptr_2 = tempBST;

  for(int  i = 0; i < len; i++) {
    int value = i*i+22;
    tempBST = ptr_1;
    while (1)
    {

      if(value >= tempBST->data) {

        if(tempBST->right == NULL) {
          tempBST->right = createNode(value);
          printf("right-I: %d, value:%d \n", i, tempBST->data);
          break;
        }
        tempBST = tempBST ->right;

      }else {

        if(tempBST->left == NULL) {
          tempBST->left = createNode(value);
          printf("left-I: %d, value:%d \n", i, value);
          break;
        }
        tempBST= tempBST->left;
      }
    }

  }
return ptr_2;
}

Second  code which isn't working as expected.

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

typedef struct Node {
  int data;
  struct Node* left;
  struct Node* right;
} Node;

typedef struct BST {
  Node* root;
}BST;

Node * createNode(int value) {
  Node * a= (Node* )malloc(sizeof(Node));
  a->left = NULL;
  a->right = NULL;
  a->data = value;
  return a;
}
void printBST(Node * bst) {
  if(bst == NULL) {return; }
  printf("%d ", bst->data);
  printBST(bst->left);
  printBST(bst->right);
}

Node* createRandomBST(size_t len){
  if(len == 0) {return NULL;}

  Node* tempBST = createNode(rand()%200); //start by creating root node.

  printf("   root: %d \n",  tempBST->data); // print the root node

  Node* ptr_1;
  Node  *ptr_2;
  ptr_1 = tempBST; // ptr_1 and ptr_2 are copy of the root node.
  ptr_2 = tempBST;

  for(int  i = 0; i < len; i++) {  // start the loop -- tempBST , ptr_1 and ptr_2 are all pointing to the root node
    int value = i*i+22;    //the value needed to be inserted.
    tempBST = ptr_1;  // every time  need to insert a node it will  start from the root node.

    while (1)  //loop until insertion is happend
    {

      if(value >= tempBST->data) {   //if the value greater than the root->data then go right
         tempBST = tempBST ->right;  // now tempBST is pointing to tempBST->right not the root
        if(tempBST == NULL) {       //if tempBST is null then the insertion will happened else loop with tempBST-> as the root..
          tempBST = createNode(value);     //if tempBST->right is empty insert the node.
          printf("right-I: %d, value:%d \n", i, tempBST->data);
          break; break;
        }
      }else { //if the value greater than the root->data then go left

          tempBST = tempBST ->left; // now tempBST is pointing to tempBST->left not the root
          if(tempBST == NULL) {
          tempBST = createNode(value); //if tempBST->left is null then the insertion will happened else loop with tempBST-> as the root..
          printf("left-I: %d, value:%d \n", i, value);
          break;
        }

      }
    }
  }
return ptr_2;  //return  a pointer the root;
}

int main() {
  Node* tem;
  tem = createRandomBST(20);
  printf("%d ", tem->data);
  printBST(tem);

}

I tried to debug it with GDB I couldn't understand the problem.
in the first code the printBST() print all the nodes but in the second one only the root is being printed


问:
GA4 Item Name Duplicate Values
Hi guys need your expert help. I have a client who sells membership. With each membership client also sell a supplementary membership (optional) which a user can purchase along with the primary. The problem is that in GA4, supplementary membership values are not showing up as unique. How can I fix this?

See attached screenshot

I am expecting unique values for each membership.

Title: GA4 Item Name Duplicate Values


问:
How do I convert a timestamp to a specific time zone in R?
I know similar questions have been asked already, but I haven't been able to get my answer from them. So here we go:

I have a dataset with timestamps that relate to the usage of a website (for example, person X started using Facebook at time x on day x.). The data is from the US, which covers different time zones. I have a state id (Basically, a state number (for example, Oklahoma = 37) and a time zone column (for example "US/Central"). I'd like to create a column with all timestamps converted to one time zone (for example, US Central, but it's irrelevant which one). how can I do that?

The timestamp is in this format: "2018-10-09 22:56:34"

Grateful for any hints.


问:
How to find distinct values between 2 MongoDB collections
I have 2 MongoDb collections.

collection A looks like this and contain of 463M docs

```<code>{
   _id: ObjectId("...")
   phone: "12345"
},
{
   _id: ObjectId("...")
   phone: "12346"
},
{
   _id: ObjectId("...")
   phone: "12347"
}
</code>```

collection B looks like this and contain 475M docs

```<code>{
   _id: ObjectId("...")
   phone: "12346"
},
{
   _id: ObjectId("...")
   phone: "12347"
},
{
   _id: ObjectId("...")
   phone: "12348"
}
</code>```

Now I want to create a C collection which contains only unique records from Both collections A and B. which will look like this.

```<code>{
   _id: ObjectId("...")
   phone: "12345"
},
{
   _id: ObjectId("...")
   phone: "12346"
},
{
   _id: ObjectId("...")
   phone: "12347"
},
{
   _id: ObjectId("...")
   phone: "12348"
}
</code>```

I did search and try multiple solutions.

using Pymongo with upsert flag true.

using mogodb lookup and distinct.

First solution which is using upsert flag works find but it is to much slow as my data volume is high I need to perform this task within an 1 or 2 hour.

So I need a suggestion how can I do it faster?

Body:
I have 2 MongoDb collections.

collection A looks like this and contain of 463M docs

{
   _id: ObjectId("...")
   phone: "12345"
},
{
   _id: ObjectId("...")
   phone: "12346"
},
{
   _id: ObjectId("...")
   phone: "12347"
}

collection B looks like this and contain 475M docs

{
   _id: ObjectId("...")
   phone: "12346"
},
{
   _id: ObjectId("...")
   phone: "12347"
},
{
   _id: ObjectId("...")
   phone: "12348"
}

Now I want to create a C collection which contains only unique records from Both collections A and B. which will look like this.

{
   _id: ObjectId("...")
   phone: "12345"
},
{
   _id: ObjectId("...")
   phone: "12346"
},
{
   _id: ObjectId("...")
   phone: "12347"
},
{
   _id: ObjectId("...")
   phone: "12348"
}

I did search and try multiple solutions.

using Pymongo with upsert flag true.

using mogodb lookup and distinct.

First solution which is using upsert flag works find but it is to much slow as my data volume is high I need to perform this task within an 1 or 2 hour.

So I need a suggestion how can I do it faster?


问:
RestAssured - Cookies are not set for redirected request
I need to set cookies for redirected request (they are sent from initial request) in RestAssured.
When I’m sending GET for my url - it responds with 302 status code and Set-Cookie header that needs to be set for redirected request. But these cookies are missed from redirected request and I’m getting an auth error.

It successfully works in Postman, but not in REST Assured. Here’s code sample:

```<code>        given()
                .spec(requestSpecWithToken)
                .redirects().follow(true)
                .config(RestAssured.config().httpClient(httpClientConfig().reuseHttpClientInstance()))
                .when()
                .get(myEndpoint)
                .then()
                .statusCode(200); // <— error 400 as no cookies

</code>```

Also I’ve tried without reuseHttpClientInstance - cookies still not set for redirected request.

Here’s example from http perspective:

```<code>Source Request: GET https://example1.com/url-with-redirect
Source Response: 302
Set-Cookie: CookieName1=CookieValue1; Path=/; SameSite=None; Secure
Set-Cookie: CookieName2=CookieValue2; Path=/
location: https://example2.org/target

Redirected Request: GET https://example2.org/target
Redirected Request Cookies: -
Redirected Response: 400
</code>```

So how can I set cookies for redirected request inside?

Update:

Logs:

```<code>Request method: GET
Request URI:    https://example1.com/url-with-redirect
Proxy:          <none>
Request params: <none>
Query params:   <none>
Form params:    <none>
Path params:    <none>
Headers:        Authorization=Bearer [..]
                Accept=*/*
                Connection=keep-alive
Cookies:        <none>
Multiparts:     <none>
Body:           <none>
[Fatal Error] :1:1: Content is not allowed in prolog.
[Fatal Error] :1:1: Content is not allowed in prolog.
HTTP/1.1 400 Authentication information is not given in the correct format.
Content-Length: 297
Content-Type: application/xml
Server: Microsoft-HTTPAPI/2.0
x-ms-request-id: [..]
Date: Tue, 20 Dec 2022 19:16:27 GMT

<?xml version="1.0" encoding="utf-8"?><Error><Code>InvalidAuthenticationInfo</Code><Message>Authentication information is not given in the correct format.
RequestId:[..]
Time:2022-12-20T19:16:27.9906229Z</Message></Error>
</code>```

Body:
I need to set cookies for redirected request (they are sent from initial request) in RestAssured.
When I’m sending GET for my url - it responds with 302 status code and Set-Cookie header that needs to be set for redirected request. But these cookies are missed from redirected request and I’m getting an auth error.

It successfully works in Postman, but not in REST Assured. Here’s code sample:

        given()
                .spec(requestSpecWithToken)
                .redirects().follow(true)
                .config(RestAssured.config().httpClient(httpClientConfig().reuseHttpClientInstance()))
                .when()
                .get(myEndpoint)
                .then()
                .statusCode(200); // <— error 400 as no cookies

Also I’ve tried without reuseHttpClientInstance - cookies still not set for redirected request.

Here’s example from http perspective:

Source Request: GET https://example1.com/url-with-redirect
Source Response: 302
Set-Cookie: CookieName1=CookieValue1; Path=/; SameSite=None; Secure
Set-Cookie: CookieName2=CookieValue2; Path=/
location: https://example2.org/target

Redirected Request: GET https://example2.org/target
Redirected Request Cookies: -
Redirected Response: 400

So how can I set cookies for redirected request inside?

Update:

Logs:

Request method: GET
Request URI:    https://example1.com/url-with-redirect
Proxy:          <none>
Request params: <none>
Query params:   <none>
Form params:    <none>
Path params:    <none>
Headers:        Authorization=Bearer [..]
                Accept=*/*
                Connection=keep-alive
Cookies:        <none>
Multiparts:     <none>
Body:           <none>
[Fatal Error] :1:1: Content is not allowed in prolog.
[Fatal Error] :1:1: Content is not allowed in prolog.
HTTP/1.1 400 Authentication information is not given in the correct format.
Content-Length: 297
Content-Type: application/xml
Server: Microsoft-HTTPAPI/2.0
x-ms-request-id: [..]
Date: Tue, 20 Dec 2022 19:16:27 GMT

<?xml version="1.0" encoding="utf-8"?><Error>InvalidAuthenticationInfo<Message>Authentication information is not given in the correct format.
RequestId:[..]
Time:2022-12-20T19:16:27.9906229Z</Message></Error>


问:
How to move select label if select has focus?
For my project I have a simple select element with TailwindCSS:

select:focus+label {
  transform: translateY(-24px);
  @apply text-sm;
  background-color: white;
}

select[value="none"]:not(:focus)+label {
  transform: translateY(0px);
  @apply text-base;
  background-color: transparent;
}

select:not([value="none"]):not(:focus)+label {
  transform: translateY(-24px);
  @apply text-sm;
  background-color: white;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><select name="role" id="role" class="w-full border-opacity-80 opacity-80 text-gray-light border border-gray-light rounded-md py-2 px-1 focus:outline-0 transition-all">
  <option value="none" selected disabled hidden></option>
  <option v-for="type in accountTypes" :key="type.type" class="opacity-100 text-gray-title hover:bg-green-500">
    {{ type.display }}
  </option>
</select>
<label for="role" class="absolute left-2 transition-all text-gray-light">Account type</label></code>```

What I'm trying to achieve:

When the user enters the page, the default option 'none' is selected. The label should be aligned at the same height as the select field (translateY 0)

When the select has focus, the label should shrink and animate up to the upper border of the selectarea (translateY -24px)

When the select has no focus and no option is selected, the label should go back to it's initial state (translateY 0px)

When the select has no focus but an option is selected, the label should remain small and at the upper area (translateY -24px)

Somehow, my current code always shrinks the label and places it at the top, no matter what conditions. What am I missing?

Body:
For my project I have a simple select element with TailwindCSS:

select:focus+label {
  transform: translateY(-24px);
  @apply text-sm;
  background-color: white;
}

select[value="none"]:not(:focus)+label {
  transform: translateY(0px);
  @apply text-base;
  background-color: transparent;
}

select:not([value="none"]):not(:focus)+label {
  transform: translateY(-24px);
  @apply text-sm;
  background-color: white;
}

<select name="role" id="role" class="w-full border-opacity-80 opacity-80 text-gray-light border border-gray-light rounded-md py-2 px-1 focus:outline-0 transition-all">
  <option value="none" selected disabled hidden></option>
  <option v-for="type in accountTypes" :key="type.type" class="opacity-100 text-gray-title hover:bg-green-500">
    {{ type.display }}
  </option>
</select>
Account type

What I'm trying to achieve:

When the user enters the page, the default option 'none' is selected. The label should be aligned at the same height as the select field (translateY 0)

When the select has focus, the label should shrink and animate up to the upper border of the selectarea (translateY -24px)

When the select has no focus and no option is selected, the label should go back to it's initial state (translateY 0px)

When the select has no focus but an option is selected, the label should remain small and at the upper area (translateY -24px)

Somehow, my current code always shrinks the label and places it at the top, no matter what conditions. What am I missing?


问:
Screenresolution is always 1280 x 720px
I have built an android app for a tv box which should support 4k-video/image playback. It's connected to a 4k-TV and in the device settings (HDMI-output mode) I have selected 4k/60fps in the HDMI-settings.

```<code>  WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
  Display display = wm.getDefaultDisplay();
</code>```

The display always gives me  1280 x 720px:

```<code>Display id 0: DisplayInfo{"Built-in Screen, displayId 0", uniqueId "local:0", app 1280 x 720, real 1280 x 720, largest app 1280 x 1248, smallest app 720 x 688, mode 1, defaultMode 1, modes [{id=1, width=1280, height=720, fps=60.000004}], colorMode 0, supportedColorModes [0], hdrCapabilities android.view.Display$HdrCapabilities@413e3a39, rotation 0, density 213 (213.0 x 213.0) dpi, layerStack 0, appVsyncOff 1000000, presDeadline 16666666, type BUILT_IN, address {port=0}, state ON, FLAG_SECURE, FLAG_SUPPORTS_PROTECTED_BUFFERS, removeMode 0}, DisplayMetrics{density=1.3312501, width=1280, height=720, scaledDensity=1.3312501, xdpi=213.0, ydpi=213.0}, isValid=true
</code>```

Only if I change the resolution via adb

```<code>wm size 4096x2160
</code>```

I get a different resolution (2560x1440 max).

But changing the resolution in the settings does have an effect - if I go to 480p I can't read anything on the screen.

Whats happening here?

Title: Screenresolution is always 1280 x 720px

Body:
I have built an android app for a tv box which should support 4k-video/image playback. It's connected to a 4k-TV and in the device settings (HDMI-output mode) I have selected 4k/60fps in the HDMI-settings.

  WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
  Display display = wm.getDefaultDisplay();

The display always gives me  1280 x 720px:

Display id 0: DisplayInfo{"Built-in Screen, displayId 0", uniqueId "local:0", app 1280 x 720, real 1280 x 720, largest app 1280 x 1248, smallest app 720 x 688, mode 1, defaultMode 1, modes [{id=1, width=1280, height=720, fps=60.000004}], colorMode 0, supportedColorModes [0], hdrCapabilities android.view.Display$HdrCapabilities@413e3a39, rotation 0, density 213 (213.0 x 213.0) dpi, layerStack 0, appVsyncOff 1000000, presDeadline 16666666, type BUILT_IN, address {port=0}, state ON, FLAG_SECURE, FLAG_SUPPORTS_PROTECTED_BUFFERS, removeMode 0}, DisplayMetrics{density=1.3312501, width=1280, height=720, scaledDensity=1.3312501, xdpi=213.0, ydpi=213.0}, isValid=true

Only if I change the resolution via adb

wm size 4096x2160

I get a different resolution (2560x1440 max).

But changing the resolution in the settings does have an effect - if I go to 480p I can't read anything on the screen.

Whats happening here?


问:
How to make quantized tflite support tf.pow function?
Because the original tf.pow function cannot be quatilized. So I want to adjust the implementation method of the pow function so that tflite can support the pow function.

The original method of Pow function is

```<code>Po = Pi ^ gamma
</code>```

changed to

```<code>ln (Po) = gamma * ln (Pi)
</code>```

so,

```<code>Po = exp ^ ( gamma * ln (Pi) )
</code>```

In this way, the power function can be replaced by exp function and ln function.
Because Taylor expansion only needs multiplication and addition to calculate exp function and ln function, tflite provides multiplication and addition.

I just need the range 0~1. The range of Taylor expansion of ln function (at x=1) is as follows:

I need all ranges less than 0. So I tried the exponential function of taylor expenditure in the subsection, as follows:

I also tried linear approximation of exponential function.

I still can't speed up the model with both methods.

Can anyone help me?

quantized tflite support function list:
https://github.com/tensorflow/tensorflow/tree/f9bdcd6d9c714fc5dde232ba3b8b0a5128a07516/tensorflow/lite/delegates/hexagon

Body:
Because the original tf.pow function cannot be quatilized. So I want to adjust the implementation method of the pow function so that tflite can support the pow function.

The original method of Pow function is

Po = Pi ^ gamma

changed to

ln (Po) = gamma * ln (Pi)

so,

Po = exp ^ ( gamma * ln (Pi) )

In this way, the power function can be replaced by exp function and ln function.
Because Taylor expansion only needs multiplication and addition to calculate exp function and ln function, tflite provides multiplication and addition.

I just need the range 0~1. The range of Taylor expansion of ln function (at x=1) is as follows:

I need all ranges less than 0. So I tried the exponential function of taylor expenditure in the subsection, as follows:

I also tried linear approximation of exponential function.

I still can't speed up the model with both methods.

Can anyone help me?

quantized tflite support function list:
https://github.com/tensorflow/tensorflow/tree/f9bdcd6d9c714fc5dde232ba3b8b0a5128a07516/tensorflow/lite/delegates/hexagon


问:
How to run 2 parallel processes in C?
I try to run 2 parallel processes
i have a global variable x = 0
process A: increase global variable x by 1
process B: print x

I followed this example How to run two child processes simultaneously in C?
but i always end up printing zeros

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

int main()
{
    int x = 0;
    int i;
    pid_t child1, child2;

    if (!(child1 = fork()))
    {
        // first childi
        while(1)
        {
            x = x + 1;
        }
    }
    else if (!(child2 = fork()))
    {
        // second child
        while(1)
        {
            printf("%d", x);
        }
    }
    else
    {
        // parent
        wait(&child1);
        wait(&child2);
    }

    return 0;
}
</code>```

Title: How to run 2 parallel processes in C?

Body:
I try to run 2 parallel processes
i have a global variable x = 0
process A: increase global variable x by 1
process B: print x

I followed this example How to run two child processes simultaneously in C?
but i always end up printing zeros

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

int main()
{
    int x = 0;
    int i;
    pid_t child1, child2;

    if (!(child1 = fork()))
    {
        // first childi
        while(1)
        {
            x = x + 1;
        }
    }
    else if (!(child2 = fork()))
    {
        // second child
        while(1)
        {
            printf("%d", x);
        }
    }
    else
    {
        // parent
        wait(&child1);
        wait(&child2);
    }

    return 0;
}