问:
Woocommerce: Trying to limit search fuctionality to only allow search by SKU, or if done by name or description, only show items that begin w/ "TM1"
I am trying to create a function in WordPress/WooCommerce that will allow you to search for any product by SKU and pull that item directly (visibility is set to only show in search), but if you want to search by name, title, or description, I want it only to pull items in which the SKU starts with "TM1". After TM1, there are additional characters and hyphens.

Example:
I have three products below, but different SKUs depending on the maker. The customer doesn't care about the maker unless they know the SKU, but I don't want them to have so many options they can't decide.

Snickers Bar - SKU: TM1-Any-Maker-123

Snickers Bar - SKU: Mars-Co-Candy

Snickers Bar - SKU: Knock-off-candy

Kit Kat - SKU: TM1-Any-Maker-345

Kit Kat - SKU: Real-Maker-1

Kit Kat - SKU: Fake-Maker-74

Doritos Bag - SKU: TM1-123-Frito

Doritos Bag - SKU: Frito-Lay-9813

Doritos Bag - SKU: Store-Brand-Sucks

When someone searches by SKU, I want them to see that SKU. If someone Searches for Doritos, though, I only want to show the one that starts with TM1.

I have tried the code below and it still pulls all the records with the same name when searching by name.

```<code>`add_filter( 'woocommerce_product_data_store_cpt_get_products_query', 'limit_wc_product_search', 10, 2 );

function limit_wc_product_search( $query, $query_vars ) {
    global $wpdb;
    $sku_meta_lookup_table = $wpdb->prefix . 'wc_product_meta_lookup';

    if ( ! empty( $query_vars['search'] ) ) {
        $search_term = $query_vars['search'];

        if ( is_sku( $search_term ) ) {
            // Limit search to a single product if searching by SKU
            $query['where'] .= $wpdb->prepare( " AND {$wpdb->posts}.ID IN (SELECT product_id FROM {$sku_meta_lookup_table} WHERE sku = %s)", $search_term );
        } else {
            // Limit search to products with names containing the search term and SKUs starting with "TM1" if searching by name
            $query['join'] .= " INNER JOIN {$sku_meta_lookup_table} ON {$wpdb->posts}.ID = {$sku_meta_lookup_table}.product_id";
            $query['where'] .= $wpdb->prepare( " AND {$sku_meta_lookup_table}.sku LIKE %s AND {$wpdb->posts}.post_title LIKE %s", 'TM1%', '%' . $wpdb->esc_like( $search_term ) . '%' );
        }
    }

    return $query;
}

function is_sku( $string ) {
    // Check if string is a valid SKU format (e.g. "TM1-12345")
    return preg_match( '/^[A-Z]{2}[0-9]+$/', $string );
}
</code>```

`

Body:
I am trying to create a function in WordPress/WooCommerce that will allow you to search for any product by SKU and pull that item directly (visibility is set to only show in search), but if you want to search by name, title, or description, I want it only to pull items in which the SKU starts with "TM1". After TM1, there are additional characters and hyphens.

Example:
I have three products below, but different SKUs depending on the maker. The customer doesn't care about the maker unless they know the SKU, but I don't want them to have so many options they can't decide.

Snickers Bar - SKU: TM1-Any-Maker-123

Snickers Bar - SKU: Mars-Co-Candy

Snickers Bar - SKU: Knock-off-candy

Kit Kat - SKU: TM1-Any-Maker-345

Kit Kat - SKU: Real-Maker-1

Kit Kat - SKU: Fake-Maker-74

Doritos Bag - SKU: TM1-123-Frito

Doritos Bag - SKU: Frito-Lay-9813

Doritos Bag - SKU: Store-Brand-Sucks

When someone searches by SKU, I want them to see that SKU. If someone Searches for Doritos, though, I only want to show the one that starts with TM1.

I have tried the code below and it still pulls all the records with the same name when searching by name.

`add_filter( 'woocommerce_product_data_store_cpt_get_products_query', 'limit_wc_product_search', 10, 2 );

function limit_wc_product_search( $query, $query_vars ) {
    global $wpdb;
    $sku_meta_lookup_table = $wpdb->prefix . 'wc_product_meta_lookup';

    if ( ! empty( $query_vars['search'] ) ) {
        $search_term = $query_vars['search'];

        if ( is_sku( $search_term ) ) {
            // Limit search to a single product if searching by SKU
            $query['where'] .= $wpdb->prepare( " AND {$wpdb->posts}.ID IN (SELECT product_id FROM {$sku_meta_lookup_table} WHERE sku = %s)", $search_term );
        } else {
            // Limit search to products with names containing the search term and SKUs starting with "TM1" if searching by name
            $query['join'] .= " INNER JOIN {$sku_meta_lookup_table} ON {$wpdb->posts}.ID = {$sku_meta_lookup_table}.product_id";
            $query['where'] .= $wpdb->prepare( " AND {$sku_meta_lookup_table}.sku LIKE %s AND {$wpdb->posts}.post_title LIKE %s", 'TM1%', '%' . $wpdb->esc_like( $search_term ) . '%' );
        }
    }

    return $query;
}

function is_sku( $string ) {
    // Check if string is a valid SKU format (e.g. "TM1-12345")
    return preg_match( '/^[A-Z]{2}[0-9]+$/', $string );
}

`


来源: stackexchange

问:
How to resize pictures to create a picture gallery on a website using html and css
I want to create an image gallery for my website but it seems like the pictures can’t be resize

Tried reseizing it on both html and css codes but it’s not working

ContentLicense: CC BY-SA 4.0


问:
Matplotlib interactive mode in Kaggle
Is there any way to run a notebook in interactive mode in Kaggle?
In this notebook, I'm getting errors with the get_window_extent method, and the images don't show correctly.</p>

Title: Matplotlib interactive mode in Kaggle


问:
Horizontal flatlist issue
I have a view with 2 flatlist, one vertical is working perfectly while the horizontal one doesn't, I can see one card only and it won't move. I searched through the known issues and most of the times is a missing flex-1 but not here.
Any idea? Some Tailwind CSS in it, if it needs clarification please tell me. Thanks

```<code>const Home = () => {

  const renderItem = useCallback(
    ({ item, onpress }) => <VideoListItem onpress={onpress} item={item} />,
    []
  );

 return (
    <>
      <SafeAreaView className="flex-1">
         <KeyboardAvoidingView
          behavior={Platform.OS === "ios" ? "height" : undefined}
          keyboardVerticalOffset={100}
        >
          <View
            className="flex flex-row mx-6 my-2 px-3 py-3 justify-between items-center  "
            style={styles.searchContainer}
          >
            <Image
              className="rounded-full"
              style={{ width: scale(30), height: scale(30) }}
              source={require("../assets/mlucas.jpg")}
            />
            <Ionicons
              name="search-outline"
              size={scale(25)}
              color="px-2 bg-black border"
            />
          </View>
        </KeyboardAvoidingView>

        <Text className="text-xl px-6 my-3"> Dernières vidéos</Text>
        <View style={{ flex: 1 }} className="px-6 mb-3">
          {data && (
            <>
              <FlatList
                horizontal={true}
                data={data}
                renderItem={renderItem}
                keyExtractor={(item) => item.title}
              />
            </>
          )}
        </View>
        <Text className="text-xl px-6 my-3"> Toutes nos vidéos</Text>
        <View style={{ flex: 1 }} className="px-6">
          {data && (
            <FlatList
              showsVerticalScrollIndicator={false}
              data={data}
              renderItem={renderItem}
              keyExtractor={(item) => item.title}
            />
          )}
        </View>
      </SafeAreaView>
    </>
</code>```

and simplified VideoItems

```<code>const VideoListItem = ({ item, onpress }) => {

  return (
    <Pressable className=' bg-gray-200 border my-2 rounded-2xl' onPress={openVideoPage} style={styles.videoCard}>

    <View >
      <Image style={styles.thumbnail} className="rounded-t-2xl" source={{ uri: item.url_image  || "" }} />
          </View>

        <View style={styles.titleRow}>

      <View style={styles.midleContainer}>
        <Text className='text-black'style={styles.title}>{item.title}</Text>
        <Text style={styles.subtitle}>
          {item.User?.name || "No name"}
        </Text>
      </View>

    </View>
  </Pressable>
  )
}
</code>```

Title: Horizontal flatlist issue

Body:
I have a view with 2 flatlist, one vertical is working perfectly while the horizontal one doesn't, I can see one card only and it won't move. I searched through the known issues and most of the times is a missing flex-1 but not here.
Any idea? Some Tailwind CSS in it, if it needs clarification please tell me. Thanks

const Home = () => {

  const renderItem = useCallback(
    ({ item, onpress }) => <VideoListItem onpress={onpress} item={item} />,
    []
  );

 return (
    <>
      <SafeAreaView className="flex-1">
         <KeyboardAvoidingView
          behavior={Platform.OS === "ios" ? "height" : undefined}
          keyboardVerticalOffset={100}
        >
          <View
            className="flex flex-row mx-6 my-2 px-3 py-3 justify-between items-center  "
            style={styles.searchContainer}
          >
            <Image
              className="rounded-full"
              style={{ width: scale(30), height: scale(30) }}
              source={require("../assets/mlucas.jpg")}
            />
            <Ionicons
              name="search-outline"
              size={scale(25)}
              color="px-2 bg-black border"
            />
          </View>
        </KeyboardAvoidingView>

        <Text className="text-xl px-6 my-3"> Dernières vidéos</Text>
        <View style={{ flex: 1 }} className="px-6 mb-3">
          {data && (
            <>
              <FlatList
                horizontal={true}
                data={data}
                renderItem={renderItem}
                keyExtractor={(item) => item.title}
              />
            </>
          )}
        </View>
        <Text className="text-xl px-6 my-3"> Toutes nos vidéos</Text>
        <View style={{ flex: 1 }} className="px-6">
          {data && (
            <FlatList
              showsVerticalScrollIndicator={false}
              data={data}
              renderItem={renderItem}
              keyExtractor={(item) => item.title}
            />
          )}
        </View>
      </SafeAreaView>
    </>

and simplified VideoItems

const VideoListItem = ({ item, onpress }) => {

  return (
    <Pressable className=' bg-gray-200 border my-2 rounded-2xl' onPress={openVideoPage} style={styles.videoCard}>

    <View >
      <Image style={styles.thumbnail} className="rounded-t-2xl" source={{ uri: item.url_image  || "" }} />
          </View>

        <View style={styles.titleRow}>

      <View style={styles.midleContainer}>
        <Text className='text-black'style={styles.title}>{item.title}</Text>
        <Text style={styles.subtitle}>
          {item.User?.name || "No name"}
        </Text>
      </View>

    </View>
  </Pressable>
  )
}


问:
How do I supress error related to build constraints in syscall/js?
I'm writing a WASM program using Golang. Import of syscall/js causes build constraints exclude all go files... error by static check. The program builds just fine with right flags: GOOS=js GOARCH=wasm go build -o frontend/calc.wasm internal/calc/calc.go

However, static check ceases to work until this one error is fixed. How can I suppress this error while keeping import of syscall/js?

Project structure:

```<code>frontend // files that will be served on the web, compiled .wasm file will go there
internal
  L calc // a directory of a program that will be compiled into WASM
      L calc.go
      L ...
main.go // a file server
go.mod
go.sum
</code>```

Body:
I'm writing a WASM program using Golang. Import of syscall/js causes build constraints exclude all go files... error by static check. The program builds just fine with right flags: GOOS=js GOARCH=wasm go build -o frontend/calc.wasm internal/calc/calc.go

However, static check ceases to work until this one error is fixed. How can I suppress this error while keeping import of syscall/js?

Project structure:

frontend // files that will be served on the web, compiled .wasm file will go there
internal
  L calc // a directory of a program that will be compiled into WASM
      L calc.go
      L ...
main.go // a file server
go.mod
go.sum


问:
Godot: Can you change how a node moves along a path?
I am trying to make a game where you command a crew of people, and the movement system is that if you click on an area, the crew moves there. Is there any way to not have the node (the crew) follow the path I made in the order that I put down the points? Because the way they move right now is by following a Path2D.

I have put down Area2D nodes where when the crew overlaps them, they stop moving along the path. But I cannot figure out how to get the crew to move along the path not in the order that I placed down the points.


问:
I have problem with multi companies flow when confirm order Odoo 15
I have a multi companies flow where Purchase Order from Company A will create Sale Order for Company B, I am trying to automatically confirm that Sale Order. Each Company has different flow when confirm Sale Order.

I am running the code with OdooBot because I need access to both Companies, but when confirm Sale Order for company B, it always trigger the flow of confirming order of company A, I dont know why.

If I choose both companies on the top right multi-company widget and then confirm the SO, the same problem happens.

If I only choose company B on the top right multi-company widget and then confirm the SO, it will work fine.

How am I gonna simulate this behavior by code? I tried with_company and with_context(allowed_company_ids), nothing worked

so_res.with_company(so_res.company_id).action_confirm()
It still triggers the flow of company A


问:
Issue building app after upgrading from RN 0.68 to 0.70
In the process of upgrading my app from RN v0.68 to RN v0.70 , I ran the npx react-native upgrade command and then start following this guide to finish things up and now my builds start failing after upgrade.
This is the output of my gradlew clean and I get the same error on building app for debug.

```<code>FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Build file 'E:\GitHub\app\android\app\build.gradle' line: 99

* What went wrong:
A problem occurred evaluating project ':app'.
> Cannot invoke method getAbsolutePath() on null object

* 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.
-----------
* What went wrong:
A problem occurred configuring project ':app'.
> compileSdkVersion is not specified. Please add it to build.gradle

* 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 9s
5 actionable tasks: 5 up-to-date
</code>```

this is my app/build.gradle

```<code>apply plugin: "com.android.application"
apply plugin: 'com.google.gms.google-services'
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"

import com.android.build.OutputFile
import org.apache.tools.ant.taskdefs.condition.Os

def projectRoot = rootDir.getAbsoluteFile().getParentFile().getAbsolutePath()

project.ext.react = [
    entryFile: ["node", "-e", "require('expo/scripts/resolveAppEntry')", projectRoot, "android"].execute(null, rootDir).text.trim(),
    enableHermes: true,
    cliPath: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/cli.js",
    hermesCommand: new File(["node", "--print", "require.resolve('hermes-engine/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/%OS-BIN%/hermesc",
    composeSourceMapsPath: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/scripts/compose-source-maps.js",
]

apply from: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), "../react.gradle")
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
def enableSeparateBuildPerCPUArchitecture = false

def enableProguardInReleaseBuilds =true

def jscFlavor = 'org.webkit:android-jsc:+'

def enableHermes = project.ext.react.get("enableHermes", false);
def reactNativeArchitectures() {
    def value = project.getProperties().get("reactNativeArchitectures")
    return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}

android {
    ndkVersion rootProject.ext.ndkVersion

    compileSdkVersion rootProject.ext.compileSdkVersion

    flavorDimensions "default"

    productFlavors {
        dev {
            applicationIdSuffix ".dev"
        }
        prod {
        }
        qa {
            applicationIdSuffix ".qa"
        }
        demo{
            applicationIdSuffix ".demo"
        }
    }

    defaultConfig {
        applicationId "com.employeeapp"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 202212301
        versionName "2022.12.30"
        buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()

        if (isNewArchitectureEnabled()) {
            externalNativeBuild {
                cmake {
                    arguments "-DPROJECT_BUILD_DIR=$buildDir",
                        "-DREACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid",
                        "-DREACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build",
                        "-DNODE_MODULES_DIR=$rootDir/../node_modules",
                        "-DANDROID_STL=c++_shared"
                }
            }
            if (!enableSeparateBuildPerCPUArchitecture) {
                ndk {
                    abiFilters (*reactNativeArchitectures())
                    // abiFilters "armeabi-v7a","x86"
                }
            }
        }
    }

    if (isNewArchitectureEnabled()) {
        externalNativeBuild {
            cmake {
                path "$projectDir/src/main/jni/CMakeLists.txt"
            }
        }
        def reactAndroidProjectDir = project(':ReactAndroid').projectDir
        def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) {
            dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck")
            from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
            into("$buildDir/react-ndk/exported")
        }
        def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy) {
            dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck")
            from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
            into("$buildDir/react-ndk/exported")
        }
        afterEvaluate {
            preDebugBuild.dependsOn(packageReactNdkDebugLibs)
            preReleaseBuild.dependsOn(packageReactNdkReleaseLibs)
            configureCMakeRelWithDebInfo.dependsOn(preReleaseBuild)
            configureCMakeDebug.dependsOn(preDebugBuild)
            reactNativeArchitectures().each { architecture ->
                tasks.findByName("configureCMakeDebug[${architecture}]")?.configure {
                    dependsOn("preDebugBuild")
                }
                tasks.findByName("configureCMakeRelWithDebInfo[${architecture}]")?.configure {
                    dependsOn("preReleaseBuild")
                }
            }
        }
    }

    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include (*reactNativeArchitectures())
        }
    }
    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword project.env.get("DEBUG_STORE_PASSWORD")
            keyAlias project.env.get("DEBUG_KEY_ALIAS")
            keyPassword project.env.get("DEBUG_KEY_PASSWORD")
        }
        release {
            storeFile file('unipe.keystore')
            storePassword project.env.get("STORE_PASSWORD")
            keyAlias project.env.get("KEY_ALIAS")
            keyPassword project.env.get("KEY_PASSWORD")
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            signingConfig signingConfigs.release
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }

    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }

        }
    }
}
["pickFirsts", "excludes", "merges", "doNotStrip"].each { prop ->
    def options = (findProperty("android.packagingOptions.$prop") ?: "").split(",");
    for (i in 0..<options.size()) options[i] = options[i].trim();
    options -= ""

    if (options.length > 0) {
        println "android.packagingOptions.$prop += $options ($options.length)"
        options.each {
            android.packagingOptions[prop] += it
        }
    }
}

dependencies {
    def appCenterSdkVersion = '4.1.0'
    implementation "com.microsoft.appcenter:appcenter-distribute:${appCenterSdkVersion}"
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation 'androidx.work:work-runtime-ktx:2.8.0-alpha01'
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation project(':react-native-splash-screen')
    implementation 'com.facebook.fresco:fresco:2.0.0'
    implementation 'com.facebook.fresco:animated-gif:2.6.0'
     implementation 'com.google.firebase:firebase-analytics:17.3.0'
implementation project(':react-native-push-notification')

    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
    debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.fbjni'
    }
    debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.flipper'
        exclude group:'com.squareup.okhttp3', module:'okhttp'
    }
    debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.flipper'
    }

    if (enableHermes) {
       implementation("com.facebook.react:hermes-engine:+") {
            exclude group:'com.facebook.fbjni'
        }
    } else {
        implementation jscFlavor
    }
}

if (isNewArchitectureEnabled()) {
    configurations.all {
        resolutionStrategy.dependencySubstitution {
            substitute(module("com.facebook.react:react-native"))
                    .using(project(":ReactAndroid"))
                    .because("On New Architecture we're building React Native from source")
            substitute(module("com.facebook.react:hermes-engine"))
                    .using(project(":ReactAndroid:hermes-engine"))
                    .because("On New Architecture we're building Hermes from source")
        }
    }
}

task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.implementation
    into 'libs'
}

apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json')"].execute(null, rootDir).text.trim(), "../native_modules.gradle");
applyNativeModulesAppBuildGradle(project)

def isNewArchitectureEnabled() {
    return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
}

</code>```

Was upgrading from RN v0.68 to RN v0.70 and had to make some manual code changes for the update , post update the app fails to build. Tried this solution to no avail.

Body:
In the process of upgrading my app from RN v0.68 to RN v0.70 , I ran the npx react-native upgrade command and then start following this guide to finish things up and now my builds start failing after upgrade.
This is the output of my gradlew clean and I get the same error on building app for debug.

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Build file 'E:\GitHub\app\android\app\build.gradle' line: 99

* What went wrong:
A problem occurred evaluating project ':app'.
> Cannot invoke method getAbsolutePath() on null object

* 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.
-----------
* What went wrong:
A problem occurred configuring project ':app'.
> compileSdkVersion is not specified. Please add it to build.gradle

* 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 9s
5 actionable tasks: 5 up-to-date

this is my app/build.gradle

apply plugin: "com.android.application"
apply plugin: 'com.google.gms.google-services'
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"

import com.android.build.OutputFile
import org.apache.tools.ant.taskdefs.condition.Os

def projectRoot = rootDir.getAbsoluteFile().getParentFile().getAbsolutePath()

project.ext.react = [
    entryFile: ["node", "-e", "require('expo/scripts/resolveAppEntry')", projectRoot, "android"].execute(null, rootDir).text.trim(),
    enableHermes: true,
    cliPath: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/cli.js",
    hermesCommand: new File(["node", "--print", "require.resolve('hermes-engine/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/%OS-BIN%/hermesc",
    composeSourceMapsPath: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/scripts/compose-source-maps.js",
]

apply from: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), "../react.gradle")
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
def enableSeparateBuildPerCPUArchitecture = false

def enableProguardInReleaseBuilds =true

def jscFlavor = 'org.webkit:android-jsc:+'

def enableHermes = project.ext.react.get("enableHermes", false);
def reactNativeArchitectures() {
    def value = project.getProperties().get("reactNativeArchitectures")
    return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}

android {
    ndkVersion rootProject.ext.ndkVersion

    compileSdkVersion rootProject.ext.compileSdkVersion

    flavorDimensions "default"

    productFlavors {
        dev {
            applicationIdSuffix ".dev"
        }
        prod {
        }
        qa {
            applicationIdSuffix ".qa"
        }
        demo{
            applicationIdSuffix ".demo"
        }
    }

    defaultConfig {
        applicationId "com.employeeapp"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 202212301
        versionName "2022.12.30"
        buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()

        if (isNewArchitectureEnabled()) {
            externalNativeBuild {
                cmake {
                    arguments "-DPROJECT_BUILD_DIR=$buildDir",
                        "-DREACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid",
                        "-DREACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build",
                        "-DNODE_MODULES_DIR=$rootDir/../node_modules",
                        "-DANDROID_STL=c++_shared"
                }
            }
            if (!enableSeparateBuildPerCPUArchitecture) {
                ndk {
                    abiFilters (*reactNativeArchitectures())
                    // abiFilters "armeabi-v7a","x86"
                }
            }
        }
    }

    if (isNewArchitectureEnabled()) {
        externalNativeBuild {
            cmake {
                path "$projectDir/src/main/jni/CMakeLists.txt"
            }
        }
        def reactAndroidProjectDir = project(':ReactAndroid').projectDir
        def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) {
            dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck")
            from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
            into("$buildDir/react-ndk/exported")
        }
        def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy) {
            dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck")
            from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
            into("$buildDir/react-ndk/exported")
        }
        afterEvaluate {
            preDebugBuild.dependsOn(packageReactNdkDebugLibs)
            preReleaseBuild.dependsOn(packageReactNdkReleaseLibs)
            configureCMakeRelWithDebInfo.dependsOn(preReleaseBuild)
            configureCMakeDebug.dependsOn(preDebugBuild)
            reactNativeArchitectures().each { architecture ->
                tasks.findByName("configureCMakeDebug[${architecture}]")?.configure {
                    dependsOn("preDebugBuild")
                }
                tasks.findByName("configureCMakeRelWithDebInfo[${architecture}]")?.configure {
                    dependsOn("preReleaseBuild")
                }
            }
        }
    }

    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include (*reactNativeArchitectures())
        }
    }
    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword project.env.get("DEBUG_STORE_PASSWORD")
            keyAlias project.env.get("DEBUG_KEY_ALIAS")
            keyPassword project.env.get("DEBUG_KEY_PASSWORD")
        }
        release {
            storeFile file('unipe.keystore')
            storePassword project.env.get("STORE_PASSWORD")
            keyAlias project.env.get("KEY_ALIAS")
            keyPassword project.env.get("KEY_PASSWORD")
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            signingConfig signingConfigs.release
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }

    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }

        }
    }
}
["pickFirsts", "excludes", "merges", "doNotStrip"].each { prop ->
    def options = (findProperty("android.packagingOptions.$prop") ?: "").split(",");
    for (i in 0..<options.size()) options[i] = options[i].trim();
    options -= ""

    if (options.length > 0) {
        println "android.packagingOptions.$prop += $options ($options.length)"
        options.each {
            android.packagingOptions[prop] += it
        }
    }
}

dependencies {
    def appCenterSdkVersion = '4.1.0'
    implementation "com.microsoft.appcenter:appcenter-distribute:${appCenterSdkVersion}"
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation 'androidx.work:work-runtime-ktx:2.8.0-alpha01'
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation project(':react-native-splash-screen')
    implementation 'com.facebook.fresco:fresco:2.0.0'
    implementation 'com.facebook.fresco:animated-gif:2.6.0'
     implementation 'com.google.firebase:firebase-analytics:17.3.0'
implementation project(':react-native-push-notification')

    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
    debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.fbjni'
    }
    debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.flipper'
        exclude group:'com.squareup.okhttp3', module:'okhttp'
    }
    debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.flipper'
    }

    if (enableHermes) {
       implementation("com.facebook.react:hermes-engine:+") {
            exclude group:'com.facebook.fbjni'
        }
    } else {
        implementation jscFlavor
    }
}

if (isNewArchitectureEnabled()) {
    configurations.all {
        resolutionStrategy.dependencySubstitution {
            substitute(module("com.facebook.react:react-native"))
                    .using(project(":ReactAndroid"))
                    .because("On New Architecture we're building React Native from source")
            substitute(module("com.facebook.react:hermes-engine"))
                    .using(project(":ReactAndroid:hermes-engine"))
                    .because("On New Architecture we're building Hermes from source")
        }
    }
}

task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.implementation
    into 'libs'
}

apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json')"].execute(null, rootDir).text.trim(), "../native_modules.gradle");
applyNativeModulesAppBuildGradle(project)

def isNewArchitectureEnabled() {
    return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
}

Was upgrading from RN v0.68 to RN v0.70 and had to make some manual code changes for the update , post update the app fails to build. Tried this solution to no avail.


问:
JAVA XWPFDocument script gives java.lang.Error
I am sorry, I am absolutely new to JAVA and no (until now) nothing about JAVA, and only little to coding. I wanted to learn simple document creation with the XWPFDocument Library. I got a sample code from https://www.geeksforgeeks.org/java-program-to-write-a-paragraph-in-a-word-document/ but the code does not work.
I am also sorry for not being able to format the code as a code. I made spaces with my hand, but not everywhere. I know it's horrible, but I don't know how to do to properly.  A have a brand new Mac and a microsoft keyboard which drives me crazy + I also do not know how to do it the advice strg + k

I get the error:

```<code>    at GFG.main(docgen_V0.1.java:17)
</code>```

js@MacBook-Pro-von-Jonathan ~ %  /usr/bin/env /Library/Java/JavaVirtualMachines/jdk-19.jdk/Contents/Home/bin/java --enable-preview -XX:+Show
CodeDetailsInExceptionMessages -cp /private/var/folders/fq/f_v1db_d17qc749gnnmrbch00000gn/T/vscodesws_2d1b0/jdt_ws/jdt.ls-java-project/bin G
FG
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
XWPFDocument cannot be resolved to a type
XWPFDocument cannot be resolved to a type
XWPFParagraph cannot be resolved to a type
XWPFRun cannot be resolved to a type
XWPFRun cannot be resolved to a type
XWPFRun cannot be resolved to a type

The Code is:

```<code>    public class docgen_V0.2 {
        // Java Programming to Write a paragraph in a Word Document

    // Importing required packages
    import java.io.File;
    import java.io.FileOutputStream;
    import org.apache.poi.xwpf.usermodel.XWPFDocument;
    import org.apache.poi.xwpf.usermodel.XWPFParagraph;
    import org.apache.poi.xwpf.usermodel.XWPFRun;

    public class GFG {

        // Main driver method
        public static void main(String[] args) throws Exception
        {

            // Create a blank document
            XWPFDocument xwpfdocument = new XWPFDocument();

            // Create a blank file at C:
            File file = new File("/Users/Shared/Arbeit/Codes/Speachdoc/addParagraph.docx");

            // Create a file output stream connection
            FileOutputStream ostream
                = new FileOutputStream(file);

            /* Create a new paragraph using the document */

            // CreateParagraph() method is used
            // to instantiate a new paragraph
            XWPFParagraph para = xwpfdocument.createParagraph();

            // CreateRun method appends a new run to the
            // paragraph created
            XWPFRun xwpfrun = para.createRun();

            // SetText sets the text to the run
            // created using XWPF run
            xwpfrun.setText(
                "Geeks for Geeks is a computer science portal which aims "
                + "to provide all in one platform for learning and "
                + "practicing.We can learn multiple programming languages here. ");

            // Write content set using XWPF classes available
            xwpfdocument.write(ostream);

            // Close connection
            ostream.close();
    }
    }

    }
</code>```

I just tried to run it. I expect to create a document with a little paragraph that says:
" Geeks for Geeks is a computer science portal which aims to provide all in one platform for learning and practicing.We can learn multiple programming languages here."

Body:
I am sorry, I am absolutely new to JAVA and no (until now) nothing about JAVA, and only little to coding. I wanted to learn simple document creation with the XWPFDocument Library. I got a sample code from https://www.geeksforgeeks.org/java-program-to-write-a-paragraph-in-a-word-document/ but the code does not work.
I am also sorry for not being able to format the code as a code. I made spaces with my hand, but not everywhere. I know it's horrible, but I don't know how to do to properly.  A have a brand new Mac and a microsoft keyboard which drives me crazy + I also do not know how to do it the advice strg + k

I get the error:

    at GFG.main(docgen_V0.1.java:17)

js@MacBook-Pro-von-Jonathan ~ %  /usr/bin/env /Library/Java/JavaVirtualMachines/jdk-19.jdk/Contents/Home/bin/java --enable-preview -XX:+Show
CodeDetailsInExceptionMessages -cp /private/var/folders/fq/f_v1db_d17qc749gnnmrbch00000gn/T/vscodesws_2d1b0/jdt_ws/jdt.ls-java-project/bin G
FG
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
XWPFDocument cannot be resolved to a type
XWPFDocument cannot be resolved to a type
XWPFParagraph cannot be resolved to a type
XWPFRun cannot be resolved to a type
XWPFRun cannot be resolved to a type
XWPFRun cannot be resolved to a type

The Code is:

    public class docgen_V0.2 {
        // Java Programming to Write a paragraph in a Word Document

    // Importing required packages
    import java.io.File;
    import java.io.FileOutputStream;
    import org.apache.poi.xwpf.usermodel.XWPFDocument;
    import org.apache.poi.xwpf.usermodel.XWPFParagraph;
    import org.apache.poi.xwpf.usermodel.XWPFRun;

    public class GFG {

        // Main driver method
        public static void main(String[] args) throws Exception
        {

            // Create a blank document
            XWPFDocument xwpfdocument = new XWPFDocument();

            // Create a blank file at C:
            File file = new File("/Users/Shared/Arbeit/Codes/Speachdoc/addParagraph.docx");

            // Create a file output stream connection
            FileOutputStream ostream
                = new FileOutputStream(file);

            /* Create a new paragraph using the document */

            // CreateParagraph() method is used
            // to instantiate a new paragraph
            XWPFParagraph para = xwpfdocument.createParagraph();

            // CreateRun method appends a new run to the
            // paragraph created
            XWPFRun xwpfrun = para.createRun();

            // SetText sets the text to the run
            // created using XWPF run
            xwpfrun.setText(
                "Geeks for Geeks is a computer science portal which aims "
                + "to provide all in one platform for learning and "
                + "practicing.We can learn multiple programming languages here. ");

            // Write content set using XWPF classes available
            xwpfdocument.write(ostream);

            // Close connection
            ostream.close();
    }
    }

    }

I just tried to run it. I expect to create a document with a little paragraph that says:
" Geeks for Geeks is a computer science portal which aims to provide all in one platform for learning and practicing.We can learn multiple programming languages here."


问:
How to abstract over higher-kind with F-bounded polymorphism in Scala3? The same definition works in Scala2
Assuming that several objects in Scala share an identical definition of nested generic class or trait H, with only 1 Peer type defined using F-bounded polymorphism:

```<code>object Example {

  trait P {

    type H[Peer <: H[Peer]]
  }

  object P1 extends P {
    trait H[Peer <: H[Peer]]
  }
  object P2 extends P {
    trait H[Peer <: H[Peer]]
  }

//  object KO extends P1.HH
}

</code>```

This compiles with absolutely no problem in Scala 2.13.10. But on Scala 3.2.1 it causes the following error:

```<code>....scala:25:20: Cyclic reference involving type H
one error found
</code>```

What may have caused this definition to violate the underlying type calculus? Can the type system still regard as GADT-friendly if such definition can't be supported?

Body:
Assuming that several objects in Scala share an identical definition of nested generic class or trait H, with only 1 Peer type defined using F-bounded polymorphism:

object Example {

  trait P {

    type H[Peer <: H[Peer]]
  }

  object P1 extends P {
    trait H[Peer <: H[Peer]]
  }
  object P2 extends P {
    trait H[Peer <: H[Peer]]
  }

//  object KO extends P1.HH
}

This compiles with absolutely no problem in Scala 2.13.10. But on Scala 3.2.1 it causes the following error:

....scala:25:20: Cyclic reference involving type H
one error found

What may have caused this definition to violate the underlying type calculus? Can the type system still regard as GADT-friendly if such definition can't be supported?


问:
Efficiently loading/importing a big dataset that is in a non-standard format into R
The code used in this question comes from the script entitled "LASSO code (Version for Antony) in my GitHub Repository for this research project.

I am trying to load each of the 260,000 csv file-formatted datasets (each of which is 189 KB) into my RStudio environment/WorkSpace sequentially using the following code:

```<code># load all necessary packages using only 1 command/line
library_list <- c(library(plyr),library(dplyr),library(tidyverse),
                  library(readr),library(stringi),library(purrr),
                  library(stats),library(leaps),library(lars),
                  library(elasticnet),library(data.table),library(parallel),
                  library(microbenchmark))

# these 2 lines together create a simple character list of
# all the file names in the file folder of datasets you created
folderpath <- "C:/Users/Spencer/Documents/EER Project/datasets folder"
filepaths_list <- list.files(path = folderpath, full.names = TRUE,
                             recursive = TRUE)
# reformat the names of each of the csv file formatted datasets
DS_names_list <- basename(filepaths_list)
DS_names_list <- tools::file_path_sans_ext(DS_names_list)

# sort both of the list of file names so that they are in the proper order
my_order = DS_names_list |>
  # split apart the numbers, convert them to numeric
  strsplit(split = "-", fixed = TRUE) |>  unlist() |> as.numeric() |>
  # get them in a data frame
  matrix(nrow = length(DS_names_list), byrow = TRUE) |> as.data.frame() |>
  # get the appropriate ordering to sort the data frame
  do.call(order, args = _)

DS_names_list = DS_names_list[my_order]
filepaths_list = filepaths_list[my_order]

# this line reads all of the data in each of the csv files
# using the name of each store in the list we just created
CL1 <- makeCluster(detectCores() - 1L)
clusterExport(CL1, c('filepaths_list'))
system.time( datasets <- parLapply(CL1, filepaths_list, fread) )
stopCluster(CL1)
</code>```

Note: this 'datasets folder' is 46.6 GB.
I calculated that it should take around 36ish hours to finish based on loading a 1000 dataset folder using the same script before hand. However, around 25 hours into the process (or before), when I woke up on Thursday morning, my laptop had frozen. I waited all afternoon and tried everything to resuscitate it, but it was frozen solid.

Is there any syntactic error I made in my code here? My laptop is only several months old, with a 11th Gen Intel(R) Core(TM) i5-1155G7 @ 2.50GHz processor, two fully compatible 16 GB ram sticks for a total of 32 gb of RAM, and also, a fast after market 1 tb SSD, so I don't see why my laptop shouldn't be able to pull this off so long as I am patient enough to wait.

p.s.
I tried the same operation several days earlier with all lines of code the same except the actual command to load the file folder in, that time it was the following:

```<code>CL <- makeCluster(detectCores() - 1L)
clusterExport(CL, c('filepaths_list'))
system.time( datasets <- lapply(filepaths_list, read.csv) )
</code>```

However, after around 56 hours in of waiting, I realized I made a mistake but forgetting to do the following instead:

```<code>system.time( datasets <- parLapply(CL, filepaths_list, read.csv) )
</code>```

Or preferably, read_csv instead, so I cancelled that operation, but my laptop did not freeze that time.

Body:
The code used in this question comes from the script entitled "LASSO code (Version for Antony) in my GitHub Repository for this research project.

I am trying to load each of the 260,000 csv file-formatted datasets (each of which is 189 KB) into my RStudio environment/WorkSpace sequentially using the following code:

# load all necessary packages using only 1 command/line
library_list <- c(library(plyr),library(dplyr),library(tidyverse),
                  library(readr),library(stringi),library(purrr),
                  library(stats),library(leaps),library(lars),
                  library(elasticnet),library(data.table),library(parallel),
                  library(microbenchmark))

# these 2 lines together create a simple character list of
# all the file names in the file folder of datasets you created
folderpath <- "C:/Users/Spencer/Documents/EER Project/datasets folder"
filepaths_list <- list.files(path = folderpath, full.names = TRUE,
                             recursive = TRUE)
# reformat the names of each of the csv file formatted datasets
DS_names_list <- basename(filepaths_list)
DS_names_list <- tools::file_path_sans_ext(DS_names_list)

# sort both of the list of file names so that they are in the proper order
my_order = DS_names_list |>
  # split apart the numbers, convert them to numeric
  strsplit(split = "-", fixed = TRUE) |>  unlist() |> as.numeric() |>
  # get them in a data frame
  matrix(nrow = length(DS_names_list), byrow = TRUE) |> as.data.frame() |>
  # get the appropriate ordering to sort the data frame
  do.call(order, args = _)

DS_names_list = DS_names_list[my_order]
filepaths_list = filepaths_list[my_order]

# this line reads all of the data in each of the csv files
# using the name of each store in the list we just created
CL1 <- makeCluster(detectCores() - 1L)
clusterExport(CL1, c('filepaths_list'))
system.time( datasets <- parLapply(CL1, filepaths_list, fread) )
stopCluster(CL1)

Note: this 'datasets folder' is 46.6 GB.
I calculated that it should take around 36ish hours to finish based on loading a 1000 dataset folder using the same script before hand. However, around 25 hours into the process (or before), when I woke up on Thursday morning, my laptop had frozen. I waited all afternoon and tried everything to resuscitate it, but it was frozen solid.

Is there any syntactic error I made in my code here? My laptop is only several months old, with a 11th Gen Intel(R) Core(TM) i5-1155G7 @ 2.50GHz processor, two fully compatible 16 GB ram sticks for a total of 32 gb of RAM, and also, a fast after market 1 tb SSD, so I don't see why my laptop shouldn't be able to pull this off so long as I am patient enough to wait.

p.s.
I tried the same operation several days earlier with all lines of code the same except the actual command to load the file folder in, that time it was the following:

CL <- makeCluster(detectCores() - 1L)
clusterExport(CL, c('filepaths_list'))
system.time( datasets <- lapply(filepaths_list, read.csv) )

However, after around 56 hours in of waiting, I realized I made a mistake but forgetting to do the following instead:

system.time( datasets <- parLapply(CL, filepaths_list, read.csv) )

Or preferably, read_csv instead, so I cancelled that operation, but my laptop did not freeze that time.


问:
How to call in the google books API in django?
The books are being displayed but when i click on the link it does not lead to the google books.co.in webpage where the book is stored, it displays that the page is not found.

my views.py

```<code>def books(request):
    if request.method == "POST":
        form=DashboardForm(request.POST)
        text=request.POST['text']
        url="https://www.googleapis.com/books/v1/volumes?q="+text
        r = requests.get(url)
        answer = r.json()
        result_list = []
        for i in range(10):
            result_dict = {
                'title':answer['items'][i]['volumeInfo']['title'],
                'subtitle':answer['items'][i]['volumeInfo'].get('subtitle'),
                'description':answer['items'][i]['volumeInfo'].get('description'),
                'count':answer['items'][i]['volumeInfo'].get('pageCount'),
                'categories':answer['items'][i]['volumeInfo'].get('categories'),
                'rating':answer['items'][i]['volumeInfo'].get('pageRating'),
                'thumbnail':answer['items'][i]['volumeInfo'].get('imageLinks').get('thumbnail'),
                'preview':answer['items'][i]['volumeInfo'].get('previewLinks')

            }
            result_list.append(result_dict)
            context={
                'form' : form,
                'results' :result_list
            }
        return render(request,'dashboard/books.html',context)
    else:
        form=DashboardForm()
    context={'form' : form}
    return render(request,'dashboard/books.html',context)

</code>```

my books.html template

```<code>{% extends 'dashboard/base.html' %}
{% load static %}
{% block content %}

<section class='text-center container'>
    <h2><b>SEARCH FOR BOOKS </b></h2>
    <p>Enter the search query to obtain your desired book</p><b></b>
    <form action="" method="post">
        {% csrf_token %}
        {{form}}
        <input class="btn btn-danger" type="submit" value="Submit">
    </form><br>

    {% for result in results %}
    <a href="{{result.preview}}" target="_blank">
        <div class="card">
            <div class="card-header">
                <div class="row">
                    <div class="col-md-3">
                        <img class="img-fluid" src="{{result.thumbnail}}" alt="">

                    </div>
                    <div class="col-md-9">
                        <h3 class="p-0 m-0">{{result.title}}</h3>
                        <b>
                            <u>
                                <h5 class="p-0 m-0">{{result.subtitle}}</h5>
                            </u>
                        </b>
                        {% if result.description %}
                            <h6 class="p-0 m-1">{{result.description}}</h6>
                        {% endif %}

                        <b>

                        {% if result.categories %}
                            <h6 class="ml-0 mt-3">Category:
                                {% for category in result.categories %}
                                    {{category}}
                                {% endfor %}
                            </h6>
                        {% endif %}

                        {% if result.count %}
                            <h6 class="ml-0 mt-1">Pages: {{result.count}}</h6>
                        {% endif %}

                        {% if result.rating %}
                            <h6 class="ml-0 mt-1">Rating:{{result.rating}}</h6>
                        {% endif %}
                        </b>
                    </div>
                </div>
            </div>
        </div>
    </a>
    {% endfor %}
    <br>
</section>

{% endblock content %}
</code>```

I have installed and imported requests and want to redirect to google books page when i click on the book.
enter image description here

Body:
The books are being displayed but when i click on the link it does not lead to the google books.co.in webpage where the book is stored, it displays that the page is not found.

my views.py

def books(request):
    if request.method == "POST":
        form=DashboardForm(request.POST)
        text=request.POST['text']
        url="https://www.googleapis.com/books/v1/volumes?q="+text
        r = requests.get(url)
        answer = r.json()
        result_list = []
        for i in range(10):
            result_dict = {
                'title':answer['items'][i]['volumeInfo']['title'],
                'subtitle':answer['items'][i]['volumeInfo'].get('subtitle'),
                'description':answer['items'][i]['volumeInfo'].get('description'),
                'count':answer['items'][i]['volumeInfo'].get('pageCount'),
                'categories':answer['items'][i]['volumeInfo'].get('categories'),
                'rating':answer['items'][i]['volumeInfo'].get('pageRating'),
                'thumbnail':answer['items'][i]['volumeInfo'].get('imageLinks').get('thumbnail'),
                'preview':answer['items'][i]['volumeInfo'].get('previewLinks')

            }
            result_list.append(result_dict)
            context={
                'form' : form,
                'results' :result_list
            }
        return render(request,'dashboard/books.html',context)
    else:
        form=DashboardForm()
    context={'form' : form}
    return render(request,'dashboard/books.html',context)

my books.html template

{% extends 'dashboard/base.html' %}
{% load static %}
{% block content %}

SEARCH FOR BOOKS

Enter the search query to obtain your desired book

    <form action="" method="post">
        {% csrf_token %}
        {{form}}
        <input class="btn btn-danger" type="submit" value="Submit">
    </form>

    {% for result in results %}

{{result.title}}

{{result.subtitle}}

                        {% if result.description %}

{{result.description}}

                        {% endif %}

                        {% if result.categories %}

Category:
                                {% for category in result.categories %}
                                    {{category}}
                                {% endfor %}

                        {% endif %}

                        {% if result.count %}

Pages: {{result.count}}

                        {% endif %}

                        {% if result.rating %}

Rating:{{result.rating}}

                        {% endif %}

    {% endfor %}

{% endblock content %}

I have installed and imported requests and want to redirect to google books page when i click on the book.
enter image description here


问:
Module Federations / Angular, how share assets folder between different repositories?
There a way to share assets folder in a shell repository to another repository without using a monorepository?</p>


问:
Is floating point add symmetric?
Is it the case that, for any floats a and b, a + b will always == b + a?

Title: Is floating point add symmetric?


问:
OAuth2 configuration with authorization code grant type for use with and without scheduled
I created oauth2 configuration with grant type - authorization code and it works for regular queries called from the browser window.

```<code>@Bean("lm")
    WebClient webClient(OAuth2AuthorizedClientManager authorizedClientManager) {

        ServletOAuth2AuthorizedClientExchangeFilterFunction filter = new ServletOAuth2AuthorizedClientExchangeFilterFunction(
                authorizedClientManager);
        filter.setDefaultClientRegistrationId("lm");
        return WebClient.builder().apply(filter.oauth2Configuration()).build();
    }

@Bean
    public OAuth2AuthorizedClientManager authorizedClientManager(
            ClientRegistrationRepository clientRegistrationRepository,
            OAuth2AuthorizedClientRepository authorizedClientRepository) {

        OAuth2AuthorizedClientProvider authorizedClientProvider = OAuth2AuthorizedClientProviderBuilder.builder()
                .authorizationCode()
                .refreshToken()
                .build();

        DefaultOAuth2AuthorizedClientManager authorizedClientManager = new DefaultOAuth2AuthorizedClientManager(
                clientRegistrationRepository, authorizedClientRepository);
        authorizedClientManager.setAuthorizedClientProvider(authorizedClientProvider);

        return authorizedClientManager;
    }
</code>```

After starting the browser and entering the link, it redirects me to a page where I have to click "grant permissions" from the user account, each subsequent query works using the token and the refresh token.
However, I have one function that should be called every minute, I wanted to use scheduled(fixedRate = 60000) for this, but I get the error servletRequest cannot be null.

I tried to use AuthorizedClientServiceOAuth2AuthorizedClientManager and AuthorizedClientServiceReactiveOAuth2AuthorizedClientManager in several different ways, but none of the ones provided on the internet work.
Could someone help me create a configuration that would work for regular queries via the browser and those via scheduled (will such queries via scheduled also use the refresh token?

Body:
I created oauth2 configuration with grant type - authorization code and it works for regular queries called from the browser window.

@Bean("lm")
    WebClient webClient(OAuth2AuthorizedClientManager authorizedClientManager) {

        ServletOAuth2AuthorizedClientExchangeFilterFunction filter = new ServletOAuth2AuthorizedClientExchangeFilterFunction(
                authorizedClientManager);
        filter.setDefaultClientRegistrationId("lm");
        return WebClient.builder().apply(filter.oauth2Configuration()).build();
    }

@Bean
    public OAuth2AuthorizedClientManager authorizedClientManager(
            ClientRegistrationRepository clientRegistrationRepository,
            OAuth2AuthorizedClientRepository authorizedClientRepository) {

        OAuth2AuthorizedClientProvider authorizedClientProvider = OAuth2AuthorizedClientProviderBuilder.builder()
                .authorizationCode()
                .refreshToken()
                .build();

        DefaultOAuth2AuthorizedClientManager authorizedClientManager = new DefaultOAuth2AuthorizedClientManager(
                clientRegistrationRepository, authorizedClientRepository);
        authorizedClientManager.setAuthorizedClientProvider(authorizedClientProvider);

        return authorizedClientManager;
    }

After starting the browser and entering the link, it redirects me to a page where I have to click "grant permissions" from the user account, each subsequent query works using the token and the refresh token.
However, I have one function that should be called every minute, I wanted to use scheduled(fixedRate = 60000) for this, but I get the error servletRequest cannot be null.

I tried to use AuthorizedClientServiceOAuth2AuthorizedClientManager and AuthorizedClientServiceReactiveOAuth2AuthorizedClientManager in several different ways, but none of the ones provided on the internet work.
Could someone help me create a configuration that would work for regular queries via the browser and those via scheduled (will such queries via scheduled also use the refresh token?


问:
Why do I get "error[E0308]: mismatched types" when the function pointer types match exactly
I've got a scenario where I want to pass a function pointer (or closure) that takes a mutable reference to a struct, as a way of letting the caller initialize that struct for me.

The (very simplified) code looks like this:

use std::future::Future;

struct Data {
    value: u32
}

async fn initialize(data: &mut Data) {
    // ... do some async work ...
    data.value = 1;
}

fn do_work<Fut>(init: fn(&mut Data) -> Fut)
where
    Fut: Future<Output = ()>,
{
    pollster::block_on(async {
        let mut data = Data { value:0 };
        init(&mut data).await;
        // ... do other stuff with `data`
    })
}

fn main() {
    do_work(initialize);
}
```
<p>And I get the compiler error:</p>
```error[E0308]: mismatched types
  --> src/main.rs:29:13
   |
29 |     do_work(initialize);
   |     ------- ^^^^^^^^^^ one type is more general than the other
   |     |
   |     arguments to this function are incorrect
   |
   = note: expected fn pointer `for<'a> fn(&'a mut Data) -> _`
                 found fn item `for<'a> fn(&'a mut Data) -> impl Future<Output = ()> {initialize}`
note: function defined here
  --> src/main.rs:17:4
   |
17 | fn do_work<Fut>(init: fn(&mut Data) -> Fut)
   |    ^^^^^^^      --------------------------

For more information about this error, try `rustc --explain E0308`.
error: could not compile `playground` due to previous error
```

but I can not find where I've gone wrong. I'm suspecting there's something whacky happening with Higher-Ranked Trait Bounds since there's a for<'a> in there, but I can't figure out why it's not correct.

Playground link.

If I don't make initialize async, it works just as expected. Maybe there's something going on with Future<Output = ()>?

Edit:

A similar question is "Expected fn item, found a different fn item" when working with function pointers, but as @PitaJ pointed out this is not the same thing as in this case I've got a fn item and a fn pointer and not two fn items, and here there's a generic function output.

Body:
I've got a scenario where I want to pass a function pointer (or closure) that takes a mutable reference to a struct, as a way of letting the caller initialize that struct for me.

The (very simplified) code looks like this:

use std::future::Future;

struct Data {
    value: u32
}

async fn initialize(data: &mut Data) {
    // ... do some async work ...
    data.value = 1;
}

fn do_work<Fut>(init: fn(&mut Data) -> Fut)
where
    Fut: Future<Output = ()>,
{
    pollster::block_on(async {
        let mut data = Data { value:0 };
        init(&mut data).await;
        // ... do other stuff with `data`
    })
}

fn main() {
    do_work(initialize);
}

And I get the compiler error:

error[E0308]: mismatched types
  --> src/main.rs:29:13
   |
29 |     do_work(initialize);
   |     ------- ^^^^^^^^^^ one type is more general than the other
   |     |
   |     arguments to this function are incorrect
   |
   = note: expected fn pointer `for<'a> fn(&'a mut Data) -> _`
                 found fn item `for<'a> fn(&'a mut Data) -> impl Future<Output = ()> {initialize}`
note: function defined here
  --> src/main.rs:17:4
   |
17 | fn do_work<Fut>(init: fn(&mut Data) -> Fut)
   |    ^^^^^^^      --------------------------

For more information about this error, try `rustc --explain E0308`.
error: could not compile `playground` due to previous error

but I can not find where I've gone wrong. I'm suspecting there's something whacky happening with Higher-Ranked Trait Bounds since there's a for<'a> in there, but I can't figure out why it's not correct.

Playground link.

If I don't make initialize async, it works just as expected. Maybe there's something going on with Future<Output = ()>?

Edit:

A similar question is "Expected fn item, found a different fn item" when working with function pointers, but as @PitaJ pointed out this is not the same thing as in this case I've got a fn item and a fn pointer and not two fn items, and here there's a generic function output.


问:
Plotting a function with 2 variables and a 3D graph in r
I want to plot B_h vs. z_par and rot_ang. B_h is a function of these two variables and it is returned by the function.This is my code:

```<code>N=15
L=3.83
I=1
xh_top=0.101
yh_top=0.328
xh_bot=0.101
yh_bot=0.603
z0=2.126

Bh_func <- function(z_par,Rot_ang){
  Rot =Matrix(c(cos(Rot_ang),0, sin(Rot_ang),0,1,0,
                -sin(Rot_ang),0,cos(Rot_ang)), nrow=3,byrow=T)
  Old_h_top <- Matrix(c(xh_top,yh_top,z0),ncol=1)
  Old_h_bot <- Matrix(c(xh_bot,yh_bot,z0),ncol=1)
  new_h_top <- Rot %*% Old_h_top
  new_h_bot <- Rot %*% Old_h_bot
  #print(new_h_top)
  #print(new_h_bot)
  xh_top_new <- new_h_top[1,1]
  yh_top_new <- new_h_top[2,1]
  z_par <- new_h_top[3,1]
  xh_bot_new <- new_h_bot[1,1]
  yh_bot_new <- new_h_bot[2,1]
  rh_top= sqrt(xh_top_new^2+yh_top_new^2)
  rh_bot= sqrt(xh_bot_new^2+yh_bot_new^2)
  B_h= ((N*I)*cos(Rot_ang)*((((L-z_par)*(yh_top_new))/((rh_top)^2*sqrt(rh_top^2+(L-z_par)^2)))+
                              (((z_par)*(yh_top_new))/((rh_top)^2*sqrt(rh_top^2+(z_par)^2)))))-
    ((N*I)*cos(Rot_ang)*((((L-z_par)*(yh_bot_new))/((rh_bot)^2*sqrt(rh_bot^2+(L-z_par)^2)))+
                              (((z_par)*(yh_bot_new))/((rh_bot)^2*sqrt(rh_bot^2+(z_par)^2)))))
  return(B_h)
}
#I <- c(0.4,0.6,1)
z_par <- seq(from=0, to=3.83, by=0.01)
Rot_ang <- seq(from=0, to=pi/2, by=0.01)

#create z_par-values
Bh <- outer(z_par, Rot_ang, Bh_func)
plot3d(z_par, Rot_ang, Bh)
#plot_ly() %>% add_surface(x = ~z_par, y = ~Rot_ang, z = ~Bh, opacity=5)
</code>```

But it is not working.

Body:
I want to plot B_h vs. z_par and rot_ang. B_h is a function of these two variables and it is returned by the function.This is my code:

N=15
L=3.83
I=1
xh_top=0.101
yh_top=0.328
xh_bot=0.101
yh_bot=0.603
z0=2.126

Bh_func <- function(z_par,Rot_ang){
  Rot =Matrix(c(cos(Rot_ang),0, sin(Rot_ang),0,1,0,
                -sin(Rot_ang),0,cos(Rot_ang)), nrow=3,byrow=T)
  Old_h_top <- Matrix(c(xh_top,yh_top,z0),ncol=1)
  Old_h_bot <- Matrix(c(xh_bot,yh_bot,z0),ncol=1)
  new_h_top <- Rot %*% Old_h_top
  new_h_bot <- Rot %*% Old_h_bot
  #print(new_h_top)
  #print(new_h_bot)
  xh_top_new <- new_h_top[1,1]
  yh_top_new <- new_h_top[2,1]
  z_par <- new_h_top[3,1]
  xh_bot_new <- new_h_bot[1,1]
  yh_bot_new <- new_h_bot[2,1]
  rh_top= sqrt(xh_top_new^2+yh_top_new^2)
  rh_bot= sqrt(xh_bot_new^2+yh_bot_new^2)
  B_h= ((N*I)*cos(Rot_ang)*((((L-z_par)*(yh_top_new))/((rh_top)^2*sqrt(rh_top^2+(L-z_par)^2)))+
                              (((z_par)*(yh_top_new))/((rh_top)^2*sqrt(rh_top^2+(z_par)^2)))))-
    ((N*I)*cos(Rot_ang)*((((L-z_par)*(yh_bot_new))/((rh_bot)^2*sqrt(rh_bot^2+(L-z_par)^2)))+
                              (((z_par)*(yh_bot_new))/((rh_bot)^2*sqrt(rh_bot^2+(z_par)^2)))))
  return(B_h)
}
#I <- c(0.4,0.6,1)
z_par <- seq(from=0, to=3.83, by=0.01)
Rot_ang <- seq(from=0, to=pi/2, by=0.01)

#create z_par-values
Bh <- outer(z_par, Rot_ang, Bh_func)
plot3d(z_par, Rot_ang, Bh)
#plot_ly() %>% add_surface(x = ~z_par, y = ~Rot_ang, z = ~Bh, opacity=5)

But it is not working.


问:
How can i insert the inline_keyboard with php ? my code not insert the keyboard with msg
```<code>$txt = $data;
if ($telegram == "on"){
    $keyboard = json_encode([
        "inline_keyboard" => [
            [
                [
                    "text" => "Button 1",
                    "callback_data" => "1"
                ],
                [
                    "text" => "Button 2",
                    "callback_data" => "2"
                ]
            ]
        ]
    ]);
    $send = ['chat_id'=>$chat_id,'text'=>$txt];
    $website_telegram = "https://api.telegram.org/bot{$bot_url}&reply_markup={$keyboard}";
    $ch = curl_init($website_telegram . '/sendMessage');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, ($send));
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    $result = curl_exec($ch);
    curl_close($ch);
}
</code>```

my code not insert the keyboard with msg, on my but display just the message without keyboard

Body:
$txt = $data;
if ($telegram == "on"){
    $keyboard = json_encode([
        "inline_keyboard" => [
            [
                [
                    "text" => "Button 1",
                    "callback_data" => "1"
                ],
                [
                    "text" => "Button 2",
                    "callback_data" => "2"
                ]
            ]
        ]
    ]);
    $send = ['chat_id'=>$chat_id,'text'=>$txt];
    $website_telegram = "https://api.telegram.org/bot{$bot_url}&reply_markup={$keyboard}";
    $ch = curl_init($website_telegram . '/sendMessage');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, ($send));
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    $result = curl_exec($ch);
    curl_close($ch);
}

my code not insert the keyboard with msg, on my but display just the message without keyboard


问:
Gitlab: How to get the commit IDs of a submodule and all of its tags?
I'm using the following command to get the tags in each of the submodules:

```<code>git submodule foreach git tag --sort=-taggerdate -l
</code>```

What I'm trying to do now is to also get the commit IDs, of both the submodule and all the tags listed inside that submodule.

Body:
I'm using the following command to get the tags in each of the submodules:

git submodule foreach git tag --sort=-taggerdate -l

What I'm trying to do now is to also get the commit IDs, of both the submodule and all the tags listed inside that submodule.


问:
Why tkinter still remains responsive when input() (which is blocking) is called in a handler?
When the following code is run from terminal, it shows a tkinter frame with three buttons. The test button simply prints "testing". The sleep() button calls sleep in the button's callback and makes the UI non-responsive (expected) for the duration of sleep. The input() button calls Python's input() function and just echoes the text entered. What is surprising to me is that while the input() function when called by itself is a blocking function, it still keeps the UI responsive (moving window, resizing window, clicking test button etc.)

```<code>import tkinter as tk
import time

btn_input = None

def cb_input():
    global btn_input
    btn_input.config(state="disabled")
    print("Enter text to echo")
    while True:
        cmd = input()
        print(">> " + cmd)

root = tk.Tk()
root.geometry("200x100")
btn_input = tk.Button(root, text = "input()", command = cb_input)
btn_input.pack()
tk.Button(root, text = "test", command = lambda: print("testing")).pack()
tk.Button(root, text = "sleep()", command = lambda : time.sleep(5)).pack()

root.mainloop()
</code>```

I tried replacing root.mainloop() with the following codeblock

```<code>### root.mainloop()
count = 0
while True:
    print(count)
    count += 1
    root.update()
</code>```

As you would expect, it continuously prints incremental count. When you click "input()" button, the printing of the count variable stops, which leads me to believe that root.update() is not being called anymore, but the UI still remains responsive.

I ran strace on it and saw something like the following (truncated).

```<code>futex(0x562fbdacf5c0, FUTEX_WAIT_PRIVATE, 0, NULL) = 0
futex(0x7fd15b3372e0, FUTEX_WAKE_PRIVATE, 1) = 0
recvmsg(4, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\7\4|\1\256e\250\218\5\0\0\16\0`\4\r\0`\4'\1\265\3\222\0\2\0\0\0\0\2"..., iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 96
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fd168e24b80}, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fd168e24b80}, 8) = 0
poll([{fd=4, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=4, revents=POLLOUT}])
writev(4, [{iov_base="\177\0\1\0", iov_len=4}, {iov_base=NULL, iov_len=0}, {iov_base="", iov_len=0}], 3) = 4
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fd168e24b80}, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fd168e24b80}, 8) = 0
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
write(6, "\0", 1)                       = 1
futex(0x7fd15b3372e0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7fd15b3372e0, FUTEX_WAKE_PRIVATE, 1) = 0
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
write(6, "\0", 1)                       = 1
futex(0x7fd15b3372e0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x562fbdacf5c0, FUTEX_WAIT_PRIVATE, 0, NULL) = 0
futex(0x7fd15b3372e0, FUTEX_WAKE_PRIVATE, 1) = 0
recvmsg(4, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\6\0}\1\266e\250\218\5\0\0\r\0`\4\0\0\0\0&\1\265\3\221\0\2\0\0\0\1\0", iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 32
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fd168e24b80}, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fd168e24b80}, 8) = 0
poll([{fd=4, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=4, revents=POLLOUT}])
writev(4, [{iov_base="\177\0\1\0", iov_len=4}, {iov_base=NULL, iov_len=0}, {iov_base="", iov_len=0}], 3) = 4
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fd168e24b80}, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fd168e24b80}, 8) = 0
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
write(6, "\0", 1)                       = 1
futex(0x7fd15b3372e0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7fd15b3372e0, FUTEX_WAKE_PRIVATE, 1) = 0
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
write(6, "\0", 1)                       = 1
futex(0x7fd15b3372e0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x562fbdacf5c0, FUTEX_WAIT_PRIVATE, 0, NULL) = 0
futex(0x7fd15b3372e0, FUTEX_WAKE_PRIVATE, 1) = 0
recvmsg(4, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\6\0~\1\276e\250\218\5\0\0\r\0`\4\0\0\0\0!\1\265\3\214\0\2\0\0\0\1\0", iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 32
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fd168e24b80}, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fd168e24b80}, 8) = 0
poll([{fd=4, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=4, revents=POLLOUT}])
writev(4, [{iov_base="\177\0\1\0", iov_len=4}, {iov_base=NULL, iov_len=0}, {iov_base="", iov_len=0}], 3) = 4
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fd168e24b80}, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fd168e24b80}, 8) = 0
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
write(6, "\0", 1)                       = 1
futex(0x7fd15b3372e0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7fd15b3372e0, FUTEX_WAKE_PRIVATE, 1) = 0
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
write(6, "\0", 1)                       = 1
futex(0x7fd15b3372e0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x562fbdacf5c0, FUTEX_WAIT_PRIVATE, 0, NULL) = 0
futex(0x7fd15b3372e0, FUTEX_WAKE_PRIVATE, 1) = 0
recvmsg(4, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\6\0\177\1\305e\250\218\5\0\0\r\0`\4\0\0\0\0\35\1\266\3\210\0\3\0\0\0\1\0", iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 32
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fd168e24b80}, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fd168e24b80}, 8) = 0
poll([{fd=4, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=4, revents=POLLOUT}])
writev(4, [{iov_base="\177\0\1\0", iov_len=4}, {iov_base=NULL, iov_len=0}, {iov_base="", iov_len=0}], 3) = 4
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fd168e24b80}, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fd168e24b80}, 8) = 0
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
write(6, "\0", 1)                       = 1
futex(0x7fd15b3372e0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7fd15b3372e0, FUTEX_WAKE_PRIVATE, 1) = 0
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
</code>```

Hoping to learn from smarter and more experienced developers to make sense of this behavior.

Body:
When the following code is run from terminal, it shows a tkinter frame with three buttons. The test button simply prints "testing". The sleep() button calls sleep in the button's callback and makes the UI non-responsive (expected) for the duration of sleep. The input() button calls Python's input() function and just echoes the text entered. What is surprising to me is that while the input() function when called by itself is a blocking function, it still keeps the UI responsive (moving window, resizing window, clicking test button etc.)

import tkinter as tk
import time

btn_input = None

def cb_input():
    global btn_input
    btn_input.config(state="disabled")
    print("Enter text to echo")
    while True:
        cmd = input()
        print(">> " + cmd)

root = tk.Tk()
root.geometry("200x100")
btn_input = tk.Button(root, text = "input()", command = cb_input)
btn_input.pack()
tk.Button(root, text = "test", command = lambda: print("testing")).pack()
tk.Button(root, text = "sleep()", command = lambda : time.sleep(5)).pack()

root.mainloop()

I tried replacing root.mainloop() with the following codeblock

### root.mainloop()
count = 0
while True:
    print(count)
    count += 1
    root.update()

As you would expect, it continuously prints incremental count. When you click "input()" button, the printing of the count variable stops, which leads me to believe that root.update() is not being called anymore, but the UI still remains responsive.

I ran strace on it and saw something like the following (truncated).

futex(0x562fbdacf5c0, FUTEX_WAIT_PRIVATE, 0, NULL) = 0
futex(0x7fd15b3372e0, FUTEX_WAKE_PRIVATE, 1) = 0
recvmsg(4, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\7\4|\1\256e\250\218\5\0\0\16\0`\4\r\0`\4'\1\265\3\222\0\2\0\0\0\0\2"..., iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 96
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fd168e24b80}, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fd168e24b80}, 8) = 0
poll([{fd=4, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=4, revents=POLLOUT}])
writev(4, [{iov_base="\177\0\1\0", iov_len=4}, {iov_base=NULL, iov_len=0}, {iov_base="", iov_len=0}], 3) = 4
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fd168e24b80}, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fd168e24b80}, 8) = 0
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
write(6, "\0", 1)                       = 1
futex(0x7fd15b3372e0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7fd15b3372e0, FUTEX_WAKE_PRIVATE, 1) = 0
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
write(6, "\0", 1)                       = 1
futex(0x7fd15b3372e0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x562fbdacf5c0, FUTEX_WAIT_PRIVATE, 0, NULL) = 0
futex(0x7fd15b3372e0, FUTEX_WAKE_PRIVATE, 1) = 0
recvmsg(4, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\6\0}\1\266e\250\218\5\0\0\r\0`\4\0\0\0\0&\1\265\3\221\0\2\0\0\0\1\0", iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 32
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fd168e24b80}, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fd168e24b80}, 8) = 0
poll([{fd=4, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=4, revents=POLLOUT}])
writev(4, [{iov_base="\177\0\1\0", iov_len=4}, {iov_base=NULL, iov_len=0}, {iov_base="", iov_len=0}], 3) = 4
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fd168e24b80}, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fd168e24b80}, 8) = 0
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
write(6, "\0", 1)                       = 1
futex(0x7fd15b3372e0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7fd15b3372e0, FUTEX_WAKE_PRIVATE, 1) = 0
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
write(6, "\0", 1)                       = 1
futex(0x7fd15b3372e0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x562fbdacf5c0, FUTEX_WAIT_PRIVATE, 0, NULL) = 0
futex(0x7fd15b3372e0, FUTEX_WAKE_PRIVATE, 1) = 0
recvmsg(4, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\6\0~\1\276e\250\218\5\0\0\r\0`\4\0\0\0\0!\1\265\3\214\0\2\0\0\0\1\0", iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 32
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fd168e24b80}, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fd168e24b80}, 8) = 0
poll([{fd=4, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=4, revents=POLLOUT}])
writev(4, [{iov_base="\177\0\1\0", iov_len=4}, {iov_base=NULL, iov_len=0}, {iov_base="", iov_len=0}], 3) = 4
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fd168e24b80}, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fd168e24b80}, 8) = 0
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
write(6, "\0", 1)                       = 1
futex(0x7fd15b3372e0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7fd15b3372e0, FUTEX_WAKE_PRIVATE, 1) = 0
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
write(6, "\0", 1)                       = 1
futex(0x7fd15b3372e0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x562fbdacf5c0, FUTEX_WAIT_PRIVATE, 0, NULL) = 0
futex(0x7fd15b3372e0, FUTEX_WAKE_PRIVATE, 1) = 0
recvmsg(4, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\6\0\177\1\305e\250\218\5\0\0\r\0`\4\0\0\0\0\35\1\266\3\210\0\3\0\0\0\1\0", iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 32
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fd168e24b80}, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fd168e24b80}, 8) = 0
poll([{fd=4, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=4, revents=POLLOUT}])
writev(4, [{iov_base="\177\0\1\0", iov_len=4}, {iov_base=NULL, iov_len=0}, {iov_base="", iov_len=0}], 3) = 4
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fd168e24b80}, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fd168e24b80}, 8) = 0
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
write(6, "\0", 1)                       = 1
futex(0x7fd15b3372e0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7fd15b3372e0, FUTEX_WAKE_PRIVATE, 1) = 0
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(4, {msg_namelen=0}, 0)          = -1 EAGAIN (Resource temporarily unavailable)

Hoping to learn from smarter and more experienced developers to make sense of this behavior.