问:
SSIS Deployment to Azure SQL Server, System.Net.Http.Formatting could not be found
I'm working on a project to setup a Visual Studio SSIS API package to deploy to our Azure SQL Server. It's supposed to grab data from TalentAPI and store it in our Sql Server tables through a SSIS to be executed by our SQL Server on a schedule.

This project was built with target SQL Server being 2019. Then I had to change it to SQL Server 2017 to allow it to work on Microsoft SQL Azure.

SSIS project was deployed using SSIS in SQL Server from Visual Studio 2019.

A script component source is used to make the call to TalentAPI to retrieve the data.

There is an error associated with a SSIS script component, about the System.Net.Http.Formatting could not be found when executing the package in Azure SQL Server. That so far, I've been unable to resolve.

Current Error:
Load Users data from TalentLMS to Onshore SQL DB:Error: System.IO.FileNotFoundException: Could not load file or assembly
'System.Net.Http.Formatting, Version=5.2.9.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.
The system cannot find the file specified.
File name: 'System.Net.Http.Formatting, Version=5.2.9.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
at Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.HandleUserException(Exception e)
at Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.PreExecute()
at Microsoft.SqlServer.Dts.Pipeline.ManagedComponentHost.HostPreExecute(IDTSManagedComponentWrapper100 wrapper)

Specs:
Visual Studio 2019,
SSIS Project target SQL Server 2017 currently,
System.Net.Http.Formatting 5.2.9.0,
Microsoft SQL Azure (RTM) - 12.0.2000.8   Oct 18 2022 13:24:45

Since the Microsoft SQL Azure (RTM) - 12.0.2000.8 is rented on an instance, I'm unable to determine which version of .NET is needed to match up.

Any thoughts?

Tried so far:
Clearing out the NuGet cache, clean solution, restoring Nuget packages, and build.

Setting the System.Net.Http.Formatting Copy Local attribute to True to try to copy the System.Net.Http.Formatting to SQL server when deployed.


来源: stackexchange

问:
Represent current speed and direction on a leaflet map
I'm trying to represent sea current speed and direction on a leaflet map, I found a plugin that represents it in an animated way like this example:

https://onaci.github.io/leaflet-velocity/

but what I want to achieve is something else, I want to represent it using arrows just like they did here:

https://thredds.socib.es/lw4nc2/?m=radar
or this
https://apps.socib.es/Leaflet.TimeDimension/examples/example3.html

so if anyone can give me a hint on how to achieve it, it will be very nice.

My personal effort result in the use of leaflet-arrowheads plugin to achieve it but I will need a lot of customization.

ContentLicense: CC BY-SA 4.0


问:
react navigation touchable previous screen when stack pop
When screen change, like use navigation.goBack(), cant touch button in previous screen umount upper screen, it looks like delay user interaction.

I want interact directly, before unmount upper screen when disappear animation.
Anything help?

under code is some example.

Navigator

function MyStack() {
  return (
    <Stack.Navigator
      screenOptions={{
        cardStyleInterpolator: CardStyleInterpolators.forModalPresentationIOS,
      }}>
      <Stack.Screen name="home" component={Home} />
      <Stack.Screen name="upper" component={Upper} />
    </Stack.Navigator>
  );
}
```
<p><strong>Upper</strong></p>
<pre class="lang-js prettyprint-override"><code>const Upper = () => {
  const navigation = useNavigation();
  const goBack = () => {
    console.log('back click');
    navigation.goBack();
  };

  useEffect(() => {
    console.log('upper render');
    return () => console.log('upper unmount');
  }, []);

  return (
    <View style={styles.container}>
      <Text>Upper</Text>
      <Button onPress={goBack} title="goBack" />
    </View>
  );
};

export default Upper;

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
});
</code>```

Home.tsx

const Home = () => {
  const navigation = useNavigation();
  const goUpper = () => {
    console.log('goupper click');
    navigation.navigate('upper');
  };

  useEffect(() => {
    console.log('home render');
    return () => console.log('home unmount');
  }, []);

  return (
    <View style={styles.container}>
      <Text>Home</Text>
      <Button title="goUpper" onPress={goUpper} />
    </View>
  );
};

export default Home;

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
});

```

enter image description here

real my company project, it work android, i dont know why...

Body:
When screen change, like use navigation.goBack(), cant touch button in previous screen umount upper screen, it looks like delay user interaction.

I want interact directly, before unmount upper screen when disappear animation.
Anything help?

under code is some example.

Navigator

function MyStack() {
  return (
    <Stack.Navigator
      screenOptions={{
        cardStyleInterpolator: CardStyleInterpolators.forModalPresentationIOS,
      }}>
      <Stack.Screen name="home" component={Home} />
      <Stack.Screen name="upper" component={Upper} />
    </Stack.Navigator>
  );
}

Upper

const Upper = () => {
  const navigation = useNavigation();
  const goBack = () => {
    console.log('back click');
    navigation.goBack();
  };

  useEffect(() => {
    console.log('upper render');
    return () => console.log('upper unmount');
  }, []);

  return (
    <View style={styles.container}>
      <Text>Upper</Text>
      <Button onPress={goBack} title="goBack" />
    </View>
  );
};

export default Upper;

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
});

Home.tsx

const Home = () => {
  const navigation = useNavigation();
  const goUpper = () => {
    console.log('goupper click');
    navigation.navigate('upper');
  };

  useEffect(() => {
    console.log('home render');
    return () => console.log('home unmount');
  }, []);

  return (
    <View style={styles.container}>
      <Text>Home</Text>
      <Button title="goUpper" onPress={goUpper} />
    </View>
  );
};

export default Home;

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
});

enter image description here

real my company project, it work android, i dont know why...


问:
JS/AngualarJS/Jquery/CSS Minimize Maximize Window
I am trying to understand how to make my current 'modal' code allow for a minimize and maximize button where the modal would minimize to the bottom of the screen when clicking the - button and in the little rectangle at the bottom allow for clicking the + button to bring it back.

Basically I want it to work the same as a browser where you minimize things to the bottom of the desktop, but in this case our application.

HTML

```<code><button id="phq_btn" ng-click="openModalBtn('phq_modal','modal-overlay')">PHQ Open Modal</button>

<div id="modal-overlay">

          <!--PHQ Modal-->
          <div id="phq_modal" class="modal">
            <!-- PHQ Modal content -->
            <div class="modal-content">
              <!--Allow Scroll-->
              <div class="modal-scroll">
                <!--Allow Dragging of Header-->
                <div class="modal-header">
              <div layout ="row" class="titleHolder" style ="height: 25px; width: 100%" >
                <div layout="column" flex="33">PHQ-9</div>
                <div layout="column" style="color: rgb(255, 255, 255)" layout-align="end end" flex="100"><span ng-click="closeModalBtn('phq_modal','modal-overlay')" style="margin-bottom:7px" class="close">×</span></div>
              </div>
            </div>

CONTENT GOES HERE.

          </div>
              </div>
              </div>
</div>

</code>```

CSS

```<code>/* The Modal (background) */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 999; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    z-index: 999;
    /*
    background-color: rgb(0,0,0); /* Fallback color
    background-color: rgba(0,0,0,0.4); /* Black w/ opacity
    */

  }

  /* Modal Content/Box */
  .modal-content {
    padding: 10px;
    background-color: #fefefe;
    margin: 5% auto; /* 15% from the top and centered */
    border: 1px solid #888;
    border-radius: 10px;
    height: 70%;
    width: 80%; /* Could be more or less, depending on screen size */
    pointer-events:all;
    z-index: 999;
  }

    /* Modal Scroll Content*/
.modal-scroll {
    overflow-y: scroll !important;
    background-color: #fefefe;
    height: 100%;
    width: 100%;
    pointer-events:all;
    }

    .modal-header{
    cursor: pointer;
    }

  /* The Close Button */
  .close {
    color: #f7f3f3;
    float: right;
    font-size: 28px;
    font-weight: 600;
    cursor: pointer;
    height: 15px;
    width: 20px;
    text-align: right;
    pointer-events:all;
  }

  .close:hover,
  .close:focus {
    color: white;
    text-decoration: none;
    cursor: pointer;
  }

  .modal-overlay-on {
    z-index: 1000;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.5);
    transition: opacity 200ms;
    opacity: 1;
    pointer-events: none;
    cursor: default;
  }

</code>```

JS

```<code>//Open Modal
$scope.openModalBtn = function(modal,overlay){
eval(modal + '.style.display = "block"');
eval("$('#" + overlay + "').addClass('modal-overlay-on')");
};

//Close Modal
$scope.closeModalBtn = function(modal,overlay){
eval(modal + '.style.display = "none"');
eval("$('#" + overlay + "').removeClass('modal-overlay-on')");
};

//Drag Modal
$(".modal").draggable({
    handle: ".modal-header"
});

//Disable Click outside of Modal
window.onclick = function(event) {
    if (event.target == phq_modal) {
    phq_modal.style.display = "none";
    }
};
</code>```

Body:
I am trying to understand how to make my current 'modal' code allow for a minimize and maximize button where the modal would minimize to the bottom of the screen when clicking the - button and in the little rectangle at the bottom allow for clicking the + button to bring it back.

Basically I want it to work the same as a browser where you minimize things to the bottom of the desktop, but in this case our application.

HTML

<button id="phq_btn" ng-click="openModalBtn('phq_modal','modal-overlay')">PHQ Open Modal</button>

PHQ-9

×

CONTENT GOES HERE.

CSS

/* The Modal (background) */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 999; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    z-index: 999;
    /*
    background-color: rgb(0,0,0); /* Fallback color
    background-color: rgba(0,0,0,0.4); /* Black w/ opacity
    */

  }

  /* Modal Content/Box */
  .modal-content {
    padding: 10px;
    background-color: #fefefe;
    margin: 5% auto; /* 15% from the top and centered */
    border: 1px solid #888;
    border-radius: 10px;
    height: 70%;
    width: 80%; /* Could be more or less, depending on screen size */
    pointer-events:all;
    z-index: 999;
  }

    /* Modal Scroll Content*/
.modal-scroll {
    overflow-y: scroll !important;
    background-color: #fefefe;
    height: 100%;
    width: 100%;
    pointer-events:all;
    }

    .modal-header{
    cursor: pointer;
    }

  /* The Close Button */
  .close {
    color: #f7f3f3;
    float: right;
    font-size: 28px;
    font-weight: 600;
    cursor: pointer;
    height: 15px;
    width: 20px;
    text-align: right;
    pointer-events:all;
  }

  .close:hover,
  .close:focus {
    color: white;
    text-decoration: none;
    cursor: pointer;
  }

  .modal-overlay-on {
    z-index: 1000;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.5);
    transition: opacity 200ms;
    opacity: 1;
    pointer-events: none;
    cursor: default;
  }

JS

//Open Modal
$scope.openModalBtn = function(modal,overlay){
eval(modal + '.style.display = "block"');
eval("$('#" + overlay + "').addClass('modal-overlay-on')");
};

//Close Modal
$scope.closeModalBtn = function(modal,overlay){
eval(modal + '.style.display = "none"');
eval("$('#" + overlay + "').removeClass('modal-overlay-on')");
};

//Drag Modal
$(".modal").draggable({
    handle: ".modal-header"
});

//Disable Click outside of Modal
window.onclick = function(event) {
    if (event.target == phq_modal) {
    phq_modal.style.display = "none";
    }
};


问:
error while using os.popen() to read command-line output
I wrote a python program script1.py. Its general logic flow is as follows:

```<code>while(true)
    if(hasTask)
        print('task flow info print')
</code>```

Then I wrote another python script called monitor.py, using os.popen() to monitor the console output of script1. py, and after obtaining specific information, sent a message to the Redis channel：

```<code>redis_key = "command"
cmd = "python script1.py"
pool = redis.ConnectionPool(host="127.0.0.1")
r = redis.Redis(connection_pool=pool)

with os.popen(cmd,"r") as stream:
    while True:
        buf = stream.readline().strip()
        if re.match("target",buf) is not None:

        message = stream.readline().strip()

        command_info["command"] = message

        r.publish(redis_key, json.dumps(command_info))
</code>```

In the beginning, the monitor can correctly read the script output and send messages to Redis. The problem is that after some time, this combination does not seem to work properly, and no messages are sent to Redis. Why does this happen?

Is the file object returned by popen is too large? or how can I deal with it, need your help.

Body:
I wrote a python program script1.py. Its general logic flow is as follows:

while(true)
    if(hasTask)
        print('task flow info print')

Then I wrote another python script called monitor.py, using os.popen() to monitor the console output of script1. py, and after obtaining specific information, sent a message to the Redis channel：

redis_key = "command"
cmd = "python script1.py"
pool = redis.ConnectionPool(host="127.0.0.1")
r = redis.Redis(connection_pool=pool)

with os.popen(cmd,"r") as stream:
    while True:
        buf = stream.readline().strip()
        if re.match("target",buf) is not None:

        message = stream.readline().strip()

        command_info["command"] = message

        r.publish(redis_key, json.dumps(command_info))

In the beginning, the monitor can correctly read the script output and send messages to Redis. The problem is that after some time, this combination does not seem to work properly, and no messages are sent to Redis. Why does this happen?

Is the file object returned by popen is too large? or how can I deal with it, need your help.


问:
Send Mail using MS graph api with size greater than 3MB by create upload session
```<code>POST https://graph.microsoft.com/v1.0/me/messages/**AAMkADI5MAAIT3drCAAA**/attachments/createUploadSession
Content-type: application/json

{
  "AttachmentItem": {
    "attachmentType": "file",
    "name": "flower",
    "size": 3483322
  }
}

Please tell what is this id 'AAMkADI5MAAIT3drCAAA' value in the above post request link, from where to extract that.

Documentation provided for sending mail with size more than 3/4mb is not clear for some one like as I am new to ms graph. It would be good if it has some real-time examples.
If possible, can someone please guide me on this and share if any coding related to the same. I am trying to develop in python.
This would be very helpful.
</code>```
```<code>my code is once token generated----->
def verify_access_token_and_send_mail(access_token):

    headers = {
        'Authorization': 'Bearer ' + access_token
    }

    file_path = 'notes.txt'
    file_name = os.path.basename(file_path)

    print(file_name)

    # if not os.path.exits(file_path):
    #     #raise Exception(f'{file_name} is not found.')
    print('if statement done')
    with open(file_path, 'rb') as upload:
        media_content = upload.read()

    request_body = {
        "AttachmentItem": {
            "attachmentType": "file",
            "name": file_name,
            "size": 3483322
        }
    }

</code>```

GRAPH_ENDPOINT = 'https://graph.microsoft.com/v1.`

```<code>response = requests.post(
    GRAPH_ENDPOINT + f'/me/messages/AAMkADI5MAAIT3drCAAA=/attachments/createUploadSession',
</code>```
```<code>
</code>```

Send Mail using MS graph api with size greater than 3MB by create upload sessionSend Mail using MS graph api with size greater than 3MB by create upload sessionSend Mail using MS graph api with size greater than 3MB by create upload session

Body:
POST https://graph.microsoft.com/v1.0/me/messages/**AAMkADI5MAAIT3drCAAA**/attachments/createUploadSession
Content-type: application/json

{
  "AttachmentItem": {
    "attachmentType": "file",
    "name": "flower",
    "size": 3483322
  }
}

Please tell what is this id 'AAMkADI5MAAIT3drCAAA' value in the above post request link, from where to extract that.

Documentation provided for sending mail with size more than 3/4mb is not clear for some one like as I am new to ms graph. It would be good if it has some real-time examples.
If possible, can someone please guide me on this and share if any coding related to the same. I am trying to develop in python.
This would be very helpful.

my code is once token generated----->
def verify_access_token_and_send_mail(access_token):

    headers = {
        'Authorization': 'Bearer ' + access_token
    }

    file_path = 'notes.txt'
    file_name = os.path.basename(file_path)

    print(file_name)

    # if not os.path.exits(file_path):
    #     #raise Exception(f'{file_name} is not found.')
    print('if statement done')
    with open(file_path, 'rb') as upload:
        media_content = upload.read()

    request_body = {
        "AttachmentItem": {
            "attachmentType": "file",
            "name": file_name,
            "size": 3483322
        }
    }

GRAPH_ENDPOINT = 'https://graph.microsoft.com/v1.`

response = requests.post(
    GRAPH_ENDPOINT + f'/me/messages/AAMkADI5MAAIT3drCAAA=/attachments/createUploadSession',

Send Mail using MS graph api with size greater than 3MB by create upload sessionSend Mail using MS graph api with size greater than 3MB by create upload sessionSend Mail using MS graph api with size greater than 3MB by create upload session


问:
MeteorJs - MongoDb: How to get the number of elements in a mongo pool
I search to get the number of elements in a mongo pool to display a graph on our internal monitoring tools, our source code is a JavaScript code with MeteorJs framework.

Today I loop on

```<code>MongoInternals.defaultRemoteCollectionDriver()
  .mongo.db.s.client.topology.s
  .servers.s.pool[Symbol(waitQueue)]
</code>```

and I get _tail or _head keys to display the information.

When I try to update mongodb server, this feature doesn’t work anymore, I try to use this command MongoInternals.defaultRemoteCollectionDriver().mongo.db.command({ connPoolStats: 1 }, callback) and loop on hosts key but the inuse or available values are always constant.

Is there an API to get the number of element into a mongo pool please ?

Thanks.

Ygles

Body:
I search to get the number of elements in a mongo pool to display a graph on our internal monitoring tools, our source code is a JavaScript code with MeteorJs framework.

Today I loop on

MongoInternals.defaultRemoteCollectionDriver()
  .mongo.db.s.client.topology.s
  .servers.s.pool[Symbol(waitQueue)]

and I get _tail or _head keys to display the information.

When I try to update mongodb server, this feature doesn’t work anymore, I try to use this command MongoInternals.defaultRemoteCollectionDriver().mongo.db.command({ connPoolStats: 1 }, callback) and loop on hosts key but the inuse or available values are always constant.

Is there an API to get the number of element into a mongo pool please ?

Thanks.

Ygles


问:
my app doesn't scroll down smoothly, something wrong with my xml
I am building a meal app for training purposes, in my home fragment I show the user a random app, then a recycler view with popular meals beneath, then after than another recycler view that show a list of meals that each belong to a different category. when the app is running the user suppose to scroll down easily to the bottom viewing the last recycler view with a grid layout.  maybe something wrong with my xml file ?</p>
```<code><?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">

    <data>
        <variable
            name="viewModel"
            type="com.example.easyfood2.viewModel.EFViewModel" />
    </data>

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".HomeFragment">

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fillViewport="true">

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_margin="25dp">

                <LinearLayout
                    android:id="@+id/linear_header"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="3"
                        android:text="Home"
                        android:textColor="#F12345"
                        android:textSize="32sp"
                        android:textStyle="bold" />

                    <ImageView
                        android:layout_width="40dp"
                        android:layout_height="match_parent"
                        android:src="@drawable/ic_search" />

                </LinearLayout>

                <TextView
                    android:id="@+id/tv_what_to_eat"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="What would you like to eat?"
                    android:textColor="@color/black"
                    android:textSize="24sp"
                    android:textStyle="bold"
                    app:layout_constraintStart_toStartOf="@+id/linear_header"
                    app:layout_constraintTop_toBottomOf="@+id/linear_header" />

                <androidx.cardview.widget.CardView
                    android:id="@+id/card_random_meal"
                    android:layout_width="match_parent"
                    android:layout_height="200dp"
                    android:layout_marginTop="24dp"
                    app:cardCornerRadius="12dp"
                    app:cardUseCompatPadding="true"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/tv_what_to_eat">

                    <ImageView
                        android:id="@+id/img_random_meal"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:background="#DF6161"
                        android:scaleType="centerCrop"
                        app:imageUrl="@{viewModel.randomMeal.meals.get(0).strMealThumb}" />

                </androidx.cardview.widget.CardView>

                <TextView
                    android:id="@+id/tv_over_popular_Items"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="popular Items"
                    android:textColor="@color/black"
                    android:textSize="24sp"
                    android:textStyle="bold"
                    app:layout_constraintTop_toBottomOf="@+id/card_random_meal" />

                <androidx.recyclerview.widget.RecyclerView
                    android:id="@+id/rc_popular_meals"
                    android:layout_width="match_parent"
                    android:layout_height="120dp"
                    android:layout_marginTop="10dp"
                    android:orientation="horizontal"
                    app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
                    app:layout_constraintStart_toStartOf="@+id/tv_over_popular_Items"
                    app:layout_constraintTop_toBottomOf="@+id/tv_over_popular_Items"
                    app:listData="@{viewModel.mealsByCategory.meals}" />

                <TextView
                    android:id="@+id/tv_categories"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="12dp"
                    android:text="Categories"
                    android:textColor="@color/black"
                    android:textSize="24sp"
                    android:textStyle="bold"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/rc_popular_meals" />

                <androidx.cardview.widget.CardView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:cardCornerRadius="12dp"
                    app:cardUseCompatPadding="true"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/tv_categories">

                    <androidx.recyclerview.widget.RecyclerView
                        android:id="@+id/rec_view_categories"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:scrollbars="none"
                        app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
                        app:listDataCategory="@{viewModel.categoryList.categories}"
                        app:spanCount="3" />
                </androidx.cardview.widget.CardView>

            </androidx.constraintlayout.widget.ConstraintLayout>
        </ScrollView>

    </androidx.constraintlayout.widget.ConstraintLayout>
</layout>
</code>```

Body:
I am building a meal app for training purposes, in my home fragment I show the user a random app, then a recycler view with popular meals beneath, then after than another recycler view that show a list of meals that each belong to a different category. when the app is running the user suppose to scroll down easily to the bottom viewing the last recycler view with a grid layout.  maybe something wrong with my xml file ?

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">

    <data>
        <variable
            name="viewModel"
            type="com.example.easyfood2.viewModel.EFViewModel" />
    </data>

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".HomeFragment">

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fillViewport="true">

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_margin="25dp">

                <LinearLayout
                    android:id="@+id/linear_header"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="3"
                        android:text="Home"
                        android:textColor="#F12345"
                        android:textSize="32sp"
                        android:textStyle="bold" />

                    <ImageView
                        android:layout_width="40dp"
                        android:layout_height="match_parent"
                        android:src="@drawable/ic_search" />

                </LinearLayout>

                <TextView
                    android:id="@+id/tv_what_to_eat"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="What would you like to eat?"
                    android:textColor="@color/black"
                    android:textSize="24sp"
                    android:textStyle="bold"
                    app:layout_constraintStart_toStartOf="@+id/linear_header"
                    app:layout_constraintTop_toBottomOf="@+id/linear_header" />

                <androidx.cardview.widget.CardView
                    android:id="@+id/card_random_meal"
                    android:layout_width="match_parent"
                    android:layout_height="200dp"
                    android:layout_marginTop="24dp"
                    app:cardCornerRadius="12dp"
                    app:cardUseCompatPadding="true"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/tv_what_to_eat">

                    <ImageView
                        android:id="@+id/img_random_meal"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:background="#DF6161"
                        android:scaleType="centerCrop"
                        app:imageUrl="@{viewModel.randomMeal.meals.get(0).strMealThumb}" />

                </androidx.cardview.widget.CardView>

                <TextView
                    android:id="@+id/tv_over_popular_Items"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="popular Items"
                    android:textColor="@color/black"
                    android:textSize="24sp"
                    android:textStyle="bold"
                    app:layout_constraintTop_toBottomOf="@+id/card_random_meal" />

                <androidx.recyclerview.widget.RecyclerView
                    android:id="@+id/rc_popular_meals"
                    android:layout_width="match_parent"
                    android:layout_height="120dp"
                    android:layout_marginTop="10dp"
                    android:orientation="horizontal"
                    app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
                    app:layout_constraintStart_toStartOf="@+id/tv_over_popular_Items"
                    app:layout_constraintTop_toBottomOf="@+id/tv_over_popular_Items"
                    app:listData="@{viewModel.mealsByCategory.meals}" />

                <TextView
                    android:id="@+id/tv_categories"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="12dp"
                    android:text="Categories"
                    android:textColor="@color/black"
                    android:textSize="24sp"
                    android:textStyle="bold"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/rc_popular_meals" />

                <androidx.cardview.widget.CardView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:cardCornerRadius="12dp"
                    app:cardUseCompatPadding="true"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/tv_categories">

                    <androidx.recyclerview.widget.RecyclerView
                        android:id="@+id/rec_view_categories"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:scrollbars="none"
                        app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
                        app:listDataCategory="@{viewModel.categoryList.categories}"
                        app:spanCount="3" />
                </androidx.cardview.widget.CardView>

            </androidx.constraintlayout.widget.ConstraintLayout>
        </ScrollView>

    </androidx.constraintlayout.widget.ConstraintLayout>
</layout>


问:
Hide PyCharm external libraries
How do I hide PyCharm external libraries tab, I've tried many ways, but nothing worked. There is no option to hide it.
There is an option to hide Scratches and Consoles but not the External Libraries, it's annoying because every time I create a new file, it shows all the files and folders in that tab

I tried going to the setting but didn't find anything.

Title: Hide PyCharm external libraries


问:
Detect if interrupt 1 has happened before or after executing a certain instruction in TASM
I need to check if an interrupt (int 1) has occurred before executing the IMUL instruction.

I have this code fragment and now I need to check whether INT 1 was called before IMUL function or after and print some sort of messages after. This code was given as an example and now I need to supplement it.  It sets TF, which raises interrupt 3 after every instruction.

```<code>.model small

.stack 100h

.data
PranNe  db "Not IMUL", 13, 10, "$"

.code
Start:
MOV ax, @data
MOV ds, ax

MOV ax, 0
MOV es, ax      ;write 0 to es because the interrupt vector table is in the segment whose start address is 00000

PUSH    es:[4]
PUSH    es:[6]

MOV word ptr es:[4], offset ApdorokPertr    ;record the offset of the interrupt handling procedure from the start of the code segment in the interrupt vector table
MOV es:[6], cs              ;write the segment of the interrupt handling procedure into the interrupt vector table

PUSHF
PUSHF
POP ax
OR ax, 0100h        ; TF=1
PUSH ax
POPF
NOP
;*************************************************************
;This command will be handled by the interrupt handler
MOV al,00h
MOV cl,01h
IMUL cl
;*************************************************************

POPF
;Since then TF was equal to 0, we knock down TF in this way
POP es:[6]
POP es:[4]

MOV ah, 4Ch
MOV al, 0
INT 21h

PROC ApdorokPertr
;put register values on the stack
PUSH    ax
PUSH    bx
PUSH    dx
PUSH    bp
PUSH    es
PUSH    ds

MOV ax, @data
MOV ds, ax

;In the DL register, we write the operation code of the command before which the INT was called
MOV bp, sp
ADD bp, 12
MOV bx, [bp]
MOV es, [bp+2]
MOV dl, [es:bx]     ;extract the first byte located at the return address - command OPK

;check if INT was called before the IMUL command here
MOV al, dl

;here I dont know how to check if its IMUL command or not
;if it is I need to display a warning and all information about the instruction:
;address, code, mnemonic, operands.

;If INT was not called before the IMUL command, then we output a message
MOV ah, 9
MOV dx, offset PranNe
INT 21h
JMP endd

;reset the register values and exit the interrupt handler
endd:
POP ds
POP es
POP bp
POP dx
POP bx
POP ax
IRET

ApdorokPertr ENDP

END Start
</code>```

I have to check it with IMUL's bulk code, but I have no idea how to do that... Can someone help me out?

Body:
I need to check if an interrupt (int 1) has occurred before executing the IMUL instruction.

I have this code fragment and now I need to check whether INT 1 was called before IMUL function or after and print some sort of messages after. This code was given as an example and now I need to supplement it.  It sets TF, which raises interrupt 3 after every instruction.

.model small

.stack 100h

.data
PranNe  db "Not IMUL", 13, 10, "$"

.code
Start:
MOV ax, @data
MOV ds, ax

MOV ax, 0
MOV es, ax      ;write 0 to es because the interrupt vector table is in the segment whose start address is 00000

PUSH    es:[4]
PUSH    es:[6]

MOV word ptr es:[4], offset ApdorokPertr    ;record the offset of the interrupt handling procedure from the start of the code segment in the interrupt vector table
MOV es:[6], cs              ;write the segment of the interrupt handling procedure into the interrupt vector table

PUSHF
PUSHF
POP ax
OR ax, 0100h        ; TF=1
PUSH ax
POPF
NOP
;*************************************************************
;This command will be handled by the interrupt handler
MOV al,00h
MOV cl,01h
IMUL cl
;*************************************************************

POPF
;Since then TF was equal to 0, we knock down TF in this way
POP es:[6]
POP es:[4]

MOV ah, 4Ch
MOV al, 0
INT 21h

PROC ApdorokPertr
;put register values on the stack
PUSH    ax
PUSH    bx
PUSH    dx
PUSH    bp
PUSH    es
PUSH    ds

MOV ax, @data
MOV ds, ax

;In the DL register, we write the operation code of the command before which the INT was called
MOV bp, sp
ADD bp, 12
MOV bx, [bp]
MOV es, [bp+2]
MOV dl, [es:bx]     ;extract the first byte located at the return address - command OPK

;check if INT was called before the IMUL command here
MOV al, dl

;here I dont know how to check if its IMUL command or not
;if it is I need to display a warning and all information about the instruction:
;address, code, mnemonic, operands.

;If INT was not called before the IMUL command, then we output a message
MOV ah, 9
MOV dx, offset PranNe
INT 21h
JMP endd

;reset the register values and exit the interrupt handler
endd:
POP ds
POP es
POP bp
POP dx
POP bx
POP ax
IRET

ApdorokPertr ENDP

END Start

I have to check it with IMUL's bulk code, but I have no idea how to do that... Can someone help me out?


问:
Google games api. How to get list of games which user played?
Is it possible to get a list of games which user played using Google play games services and get some stats from them like XP and achievements(with WEB API)?

I didn't find any info in documentation but have seen some sites which display the achievements like -> https://www.exophase.com .
I understand that this question was already asked in 2017 but still no info. I tried web-api and i need only answers about web-api.
Please hepl me


问:
How to send an event via gtag to a specific gtag code in GA4 when using multiple gtag codes
In my project I am using two different gtag codes and sending my events to each of them (one for a client, and one for our own tracking). The problem is, because of this, each time an event is sent it registers as 2 events at once for each separate analytics report, despite the event only being sent once for each separate gtag code. Here is the script tag I'm importing in the head of my html:

```<code>    <script async src="https://www.googletagmanager.com/gtag/js?id=G-CLIENT-GTAG"></script>
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-OUR-GTAG"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());
      gtag('config', 'G-CLIENT-GTAG');
      gtag('config', 'G-OUR-GTAG');
    </script>
</code>```

Here's where we send the events to each gtag at the same time:

```<code>        analyticsService.sendGaEvent(
          this[$clientGtag],
          eventData,
          this.sku,
        );
        analyticsService.sendGaEvent(
          this[$ourGtag],
          eventData,
          this.sku,
        );
</code>```

Then in our sendGaEvent function, we create our trackers and send the events:

```<code>public sendGaEvent(gTag: string, eventData: AnalyticsEvents, sku: string)
{
     const ga4Instance = this[$analyticsMap].get(gTag);
     const ga4ProductData = this[$ga4AnalyticsUniqueEventMap].get(sku);
     const ga4Tracker = ga4Instance!.tracker;
     this[$ga4AnalyticsUniqueEventMap].set(gTag, eventData);
     gtag('event', eventData.event_action,
     {
       'event_action': eventData.event_action,
       'event_category': eventData.event_category,
       'event_label': eventData.event_label,
       'value': eventData.value
     });
}
</code>```

So even though it's sending it to a different gtag each time analyticsService.sendGaEvent is called, it still registers as 2 events on each analytics report. I believe this is somehow due to us calling gtag('event',...) once for each gtag code, but not explicitly passing in the gtag code to the gtag('event',...) function, so it may just be sending the events to every gtag code initialized in the script tag of our  by default. Is there some way to call gtag('event',...) using a specific gtag code only? Or some other way to work around this?

Body:
In my project I am using two different gtag codes and sending my events to each of them (one for a client, and one for our own tracking). The problem is, because of this, each time an event is sent it registers as 2 events at once for each separate analytics report, despite the event only being sent once for each separate gtag code. Here is the script tag I'm importing in the head of my html:

Here's where we send the events to each gtag at the same time:

        analyticsService.sendGaEvent(
          this[$clientGtag],
          eventData,
          this.sku,
        );
        analyticsService.sendGaEvent(
          this[$ourGtag],
          eventData,
          this.sku,
        );

Then in our sendGaEvent function, we create our trackers and send the events:

public sendGaEvent(gTag: string, eventData: AnalyticsEvents, sku: string)
{
     const ga4Instance = this[$analyticsMap].get(gTag);
     const ga4ProductData = this[$ga4AnalyticsUniqueEventMap].get(sku);
     const ga4Tracker = ga4Instance!.tracker;
     this[$ga4AnalyticsUniqueEventMap].set(gTag, eventData);
     gtag('event', eventData.event_action,
     {
       'event_action': eventData.event_action,
       'event_category': eventData.event_category,
       'event_label': eventData.event_label,
       'value': eventData.value
     });
}

So even though it's sending it to a different gtag each time analyticsService.sendGaEvent is called, it still registers as 2 events on each analytics report. I believe this is somehow due to us calling gtag('event',...) once for each gtag code, but not explicitly passing in the gtag code to the gtag('event',...) function, so it may just be sending the events to every gtag code initialized in the script tag of our  by default. Is there some way to call gtag('event',...) using a specific gtag code only? Or some other way to work around this?


问:
nx affected and linting of monoreop
I want to run ESLint in our monorepo using nx affected so that it only lints the projects that have changed or are indirectly affected by changes.

This basically works

nx affected --target=lint
```
<p>However, I also want to create test reports (readable by CircleCI). The following will run but each project will overwrite <code>reports/js-lint-results.xml</code>, so the last project "wins" and other results are lost.</p>
<pre class="lang-sh prettyprint-override"><code>nx affected --target=lint -- --format junit --output-file reports/js-lint-results.xml
</code>```

How should I proceed?

Title: nx affected and linting of monoreop

Body:
I want to run ESLint in our monorepo using nx affected so that it only lints the projects that have changed or are indirectly affected by changes.

This basically works

nx affected --target=lint

However, I also want to create test reports (readable by CircleCI). The following will run but each project will overwrite reports/js-lint-results.xml, so the last project "wins" and other results are lost.

nx affected --target=lint -- --format junit --output-file reports/js-lint-results.xml

How should I proceed?


问:
Fish Final Character output is colored
In Fish, final character (exclamation mark) from a hello world program is highlighted when I accidentally used cd to go to the directory again.

Clearing seems to reset this behaviour, but cd starts it again. Also occurred upon exiting and reopening shell. Why does this happen?

Title: Fish Final Character output is colored


问:
React Native: .hprof file exceeds GitHub's 100MB file size limit
I'm trying to push my React Native app to GitHub, and I'm getting several errors like the following:

```<code>remote: error: File android/java_pid1566.hprof is 667.24 MB; this exceeds GitHub's file size limit of 100.00 MB
</code>```

I looked at this answer and it suggested running git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch android/java_pid1566.hprof', then adding a *.hprof line to .gitignore, then redoing git add, git commit, and git push. However, I still got the same error.

Does anyone know how I can approach this?

Body:
I'm trying to push my React Native app to GitHub, and I'm getting several errors like the following:

remote: error: File android/java_pid1566.hprof is 667.24 MB; this exceeds GitHub's file size limit of 100.00 MB

I looked at this answer and it suggested running git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch android/java_pid1566.hprof', then adding a *.hprof line to .gitignore, then redoing git add, git commit, and git push. However, I still got the same error.

Does anyone know how I can approach this?


问:
GetExternalLoginInfoAsync().Result.Email is null with outlook account
im calling to HttpContext.GetOwinContext().Authentication.GetExternalLoginInfoAsync() when i try to login with office365 account and in the respone Result.Email give me the email.

However, if i login with outlook (or hotmail) account, the response Result.Email is null.

```<code>var authenticationManager = HttpContext.GetOwinContext().Authentication;
var loginInfo =authenticationManager.GetExternalLoginInfoAsync().Result;
if (loginInfo == null)
{
   return RedireccionarInicio();
}
</code>```

Why?

Thanks

code

Body:
im calling to HttpContext.GetOwinContext().Authentication.GetExternalLoginInfoAsync() when i try to login with office365 account and in the respone Result.Email give me the email.

However, if i login with outlook (or hotmail) account, the response Result.Email is null.

var authenticationManager = HttpContext.GetOwinContext().Authentication;
var loginInfo =authenticationManager.GetExternalLoginInfoAsync().Result;
if (loginInfo == null)
{
   return RedireccionarInicio();
}

Why?

Thanks

code


问:
ModuleNotFoundError: No module named 'graphene_django' error when integrating GraphQL into the project
I got ModuleNotFoundError: No module named 'graphene_django' error after I added 'graphene_django' in settings.py and run the python manage.py runserver command.
I installed django, graphene-django using pip but no use.
I tried with virtual env and with out too, got the same issue.

I followed the below article to build GraphQL and I got issue from Integrating Graphql into the project steps:
pip install graphene-django
added graphene_django to INSTALLED_APPS in your settings.py file
added endpoint steps in ecommerce/urls.py file
created schema, in the products/ directory with a file name schema.py
and run python manage.py runserver to test GraphQL API

see the output(python manage.py runserver) and error info:

```<code>Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/threading.py", line 973, in _bootstrap_inner
    self.run()
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/threading.py", line 910, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/kalyan.avasarala/Library/Python/3.9/lib/python/site-packages/django/utils/autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "/Users/kalyan.avasarala/Library/Python/3.9/lib/python/site-packages/django/core/management/commands/runserver.py", line 125, in inner_run
    autoreload.raise_last_exception()
  File "/Users/kalyan.avasarala/Library/Python/3.9/lib/python/site-packages/django/utils/autoreload.py", line 87, in raise_last_exception
    raise _exception[1]
  File "/Users/kalyan.avasarala/Library/Python/3.9/lib/python/site-packages/django/core/management/__init__.py", line 398, in execute
    autoreload.check_errors(django.setup)()
  File "/Users/kalyan.avasarala/Library/Python/3.9/lib/python/site-packages/django/utils/autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "/Users/kalyan.avasarala/Library/Python/3.9/lib/python/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Users/kalyan.avasarala/Library/Python/3.9/lib/python/site-packages/django/apps/registry.py", line 91, in populate
    app_config = AppConfig.create(entry)
  File "/Users/kalyan.avasarala/Library/Python/3.9/lib/python/site-packages/django/apps/config.py", line 193, in create
    import_module(entry)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
**ModuleNotFoundError: No module named 'graphene-django'**
</code>```

see the version details:
ecommerce % pip list

Package         Version

aniso8601       9.0.1
asgiref         3.5.2
Django          4.1.4
graphene        3.2.1
graphene-django 3.0.0
graphql-core    3.2.3
graphql-relay   3.2.0
pip             22.3.1
promise         2.3
setuptools      65.6.3
six             1.16.0
sqlparse        0.4.3
text-unidecode  1.3
wheel           0.38.4

I tried all the steps in the virtual environment (env). I tried creating same steps after I deleted e-commerce folder but not use and I tried to install django, graphene-django without virtual env too but no use.

Its on Mac laptop.

please share me steps or solution for the above issue.Thanks

Body:
I got ModuleNotFoundError: No module named 'graphene_django' error after I added 'graphene_django' in settings.py and run the python manage.py runserver command.
I installed django, graphene-django using pip but no use.
I tried with virtual env and with out too, got the same issue.

I followed the below article to build GraphQL and I got issue from Integrating Graphql into the project steps:
pip install graphene-django
added graphene_django to INSTALLED_APPS in your settings.py file
added endpoint steps in ecommerce/urls.py file
created schema, in the products/ directory with a file name schema.py
and run python manage.py runserver to test GraphQL API

see the output(python manage.py runserver) and error info:

Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/threading.py", line 973, in _bootstrap_inner
    self.run()
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/threading.py", line 910, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/kalyan.avasarala/Library/Python/3.9/lib/python/site-packages/django/utils/autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "/Users/kalyan.avasarala/Library/Python/3.9/lib/python/site-packages/django/core/management/commands/runserver.py", line 125, in inner_run
    autoreload.raise_last_exception()
  File "/Users/kalyan.avasarala/Library/Python/3.9/lib/python/site-packages/django/utils/autoreload.py", line 87, in raise_last_exception
    raise _exception[1]
  File "/Users/kalyan.avasarala/Library/Python/3.9/lib/python/site-packages/django/core/management/__init__.py", line 398, in execute
    autoreload.check_errors(django.setup)()
  File "/Users/kalyan.avasarala/Library/Python/3.9/lib/python/site-packages/django/utils/autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "/Users/kalyan.avasarala/Library/Python/3.9/lib/python/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Users/kalyan.avasarala/Library/Python/3.9/lib/python/site-packages/django/apps/registry.py", line 91, in populate
    app_config = AppConfig.create(entry)
  File "/Users/kalyan.avasarala/Library/Python/3.9/lib/python/site-packages/django/apps/config.py", line 193, in create
    import_module(entry)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
**ModuleNotFoundError: No module named 'graphene-django'**

see the version details:
ecommerce % pip list

Package         Version

aniso8601       9.0.1
asgiref         3.5.2
Django          4.1.4
graphene        3.2.1
graphene-django 3.0.0
graphql-core    3.2.3
graphql-relay   3.2.0
pip             22.3.1
promise         2.3
setuptools      65.6.3
six             1.16.0
sqlparse        0.4.3
text-unidecode  1.3
wheel           0.38.4

I tried all the steps in the virtual environment (env). I tried creating same steps after I deleted e-commerce folder but not use and I tried to install django, graphene-django without virtual env too but no use.

Its on Mac laptop.

please share me steps or solution for the above issue.Thanks


问:
Belief propagation algorithm for boolean binary tree
I've been trying to learn how belief propagation works. Specifically whether it would work as a SAT solver. Some of my research suggests this is possible. However, I'm really struggling to understand whether it's the right tool for the job or whether my implementations are just incorrect. Unfortunately, most references are heavy on the mathematical formulas and I'm really rusty at reading those, so I feel like maybe I've missed something. And it seems like some references use different terminology or don't even mention things like conditional probability tables.

As a really simple example, I've been trying to solve this formula:

```<code>C = A or B
</code>```

Before doing belief propagation, I wrote out the truth table so I would know what to compare against:

A
B
C

0
0
0

0
1
1

1
0
1

1
1
1

From that, I think I can calculate the probabilities of everything which is what I've been using to compare against the results of the belief propagation algorithm. If I understand correctly, the probabilities are:

```<code>P(A=true | C=true) = 2/3
P(B=true | C=true) = 2/3
P(A=false | C=true) = 1/3
P(B=false | C=true) = 1/3
P(A=true | C=false) = 0
P(B=true | C=false) = 0
P(A=false | C=false) = 1
P(B=false | C=false) = 1
</code>```

For purposes of this example, I think choosing to solve for C=true is more interesting, so let's do that.

Here's the logic I've followed to use belief propagation:

Step 1: Set initial likelihoods.

All likelihoods of input variables are set to 1.0 for both false and true states since we don't know anything about their likelihood initially. In the arrays, the first number is for the false state, second is for true state.

```<code>Likelihood(A) = [1.0, 1.0]
Likelihood(B) = [1.0, 1.0]
</code>```

Step 2: Set initial priors.

My understanding is the only initial prior(s) are for the nodes that you know the value of already. In this case, since we want to solve for C=true:

```<code>Priors(C) = [0.0 1.0]
</code>```

Step 3: Define conditional probability tables.

Here I believe both A and B get their own probability tables. They both happen to look the same. I've written P(A|C) and P(B|C) because I've read this is the probability table of the variable given all it's parents.

A
C
P(A|C)

0
0
1.0

0
1
0.5

1
0
0.0

1
1
0.5

B
C
P(B|C)

0
0
1.0

0
1
0.5

1
0
0.0

1
1
0.5

Step 4: Send messages to parents.

Message from A to C:

```<code>[
  P(A=false|C=false) * Likelihood(A=false) + P(A=true|C=false) * Likelihood(A=true),
  P(A=false|C=true) * Likelihood(A=false) + P(A=true|C=true) * Likelihood(A=true),
]
= [1.0 * 1.0 + 0.0 * 1.0, 0.5 * 1.0 + 0.5 * 1.0]
= [1.0, 1.0]
</code>```

Message from B to C:

```<code>[
  P(B=false|C=false) * Likelihood(B=false) + P(B=true|C=false) * Likelihood(A=true),
  P(B=false|C=true) * Likelihood(B=false) + P(B=true|C=true) * Likelihood(A=true),
]
= [1.0 * 1.0 + 0.0 * 1.0, 0.5 * 1.0 + 0.5 * 1.0]
= [1.0, 1.0]
</code>```

Step 5: Send messages to children.

Message from C to A:

```<code>[
  Message from B to C(false) * Prior(C=false),
  Message from B to C(true) * Prior(C=true)
]
= [1.0 * 0.0, 1.0 * 1.0]
= [0.0, 1.0]
</code>```

Message from C to B:

```<code>[
  Message from A to C(false) * Prior(C=false),
  Message from A to C(true) * Prior(C=true)
]
= [1.0 * 0.0, 1.0 * 1.0]
= [0.0, 1.0]
</code>```

Step 6: Calculate beliefs.

```<code>Belief(A) = Likelihood(A) * Message from C to A
= [1.0 * 0.0, 1.0 * 1.0]
= [0.0, 1.0]
</code>```
```<code>Belief(B) = Likelihood(B) * Message from C to B
= [1.0 * 0.0, 1.0 * 1.0]
= [0.0, 1.0]
</code>```

At this point, my belief propagation algorithm says there's a 100% chance A is true and a 100% chance B is true, which doesn't match what I'm expecting. If I solve for C=false, I do get what I'm expecting.

Is there something wrong with the steps I took, or is this just not going to give me the answer I expect for some reason?

Body:
I've been trying to learn how belief propagation works. Specifically whether it would work as a SAT solver. Some of my research suggests this is possible. However, I'm really struggling to understand whether it's the right tool for the job or whether my implementations are just incorrect. Unfortunately, most references are heavy on the mathematical formulas and I'm really rusty at reading those, so I feel like maybe I've missed something. And it seems like some references use different terminology or don't even mention things like conditional probability tables.

As a really simple example, I've been trying to solve this formula:

C = A or B

Before doing belief propagation, I wrote out the truth table so I would know what to compare against:

A
B
C

0
0
0

0
1
1

1
0
1

1
1
1

From that, I think I can calculate the probabilities of everything which is what I've been using to compare against the results of the belief propagation algorithm. If I understand correctly, the probabilities are:

P(A=true | C=true) = 2/3
P(B=true | C=true) = 2/3
P(A=false | C=true) = 1/3
P(B=false | C=true) = 1/3
P(A=true | C=false) = 0
P(B=true | C=false) = 0
P(A=false | C=false) = 1
P(B=false | C=false) = 1

For purposes of this example, I think choosing to solve for C=true is more interesting, so let's do that.

Here's the logic I've followed to use belief propagation:

Step 1: Set initial likelihoods.

All likelihoods of input variables are set to 1.0 for both false and true states since we don't know anything about their likelihood initially. In the arrays, the first number is for the false state, second is for true state.

Likelihood(A) = [1.0, 1.0]
Likelihood(B) = [1.0, 1.0]

Step 2: Set initial priors.

My understanding is the only initial prior(s) are for the nodes that you know the value of already. In this case, since we want to solve for C=true:

Priors(C) = [0.0 1.0]

Step 3: Define conditional probability tables.

Here I believe both A and B get their own probability tables. They both happen to look the same. I've written P(A|C) and P(B|C) because I've read this is the probability table of the variable given all it's parents.

A
C
P(A|C)

0
0
1.0

0
1
0.5

1
0
0.0

1
1
0.5

B
C
P(B|C)

0
0
1.0

0
1
0.5

1
0
0.0

1
1
0.5

Step 4: Send messages to parents.

Message from A to C:

[
  P(A=false|C=false) * Likelihood(A=false) + P(A=true|C=false) * Likelihood(A=true),
  P(A=false|C=true) * Likelihood(A=false) + P(A=true|C=true) * Likelihood(A=true),
]
= [1.0 * 1.0 + 0.0 * 1.0, 0.5 * 1.0 + 0.5 * 1.0]
= [1.0, 1.0]

Message from B to C:

[
  P(B=false|C=false) * Likelihood(B=false) + P(B=true|C=false) * Likelihood(A=true),
  P(B=false|C=true) * Likelihood(B=false) + P(B=true|C=true) * Likelihood(A=true),
]
= [1.0 * 1.0 + 0.0 * 1.0, 0.5 * 1.0 + 0.5 * 1.0]
= [1.0, 1.0]

Step 5: Send messages to children.

Message from C to A:

[
  Message from B to C(false) * Prior(C=false),
  Message from B to C(true) * Prior(C=true)
]
= [1.0 * 0.0, 1.0 * 1.0]
= [0.0, 1.0]

Message from C to B:

[
  Message from A to C(false) * Prior(C=false),
  Message from A to C(true) * Prior(C=true)
]
= [1.0 * 0.0, 1.0 * 1.0]
= [0.0, 1.0]

Step 6: Calculate beliefs.

Belief(A) = Likelihood(A) * Message from C to A
= [1.0 * 0.0, 1.0 * 1.0]
= [0.0, 1.0]

Belief(B) = Likelihood(B) * Message from C to B
= [1.0 * 0.0, 1.0 * 1.0]
= [0.0, 1.0]

At this point, my belief propagation algorithm says there's a 100% chance A is true and a 100% chance B is true, which doesn't match what I'm expecting. If I solve for C=false, I do get what I'm expecting.

Is there something wrong with the steps I took, or is this just not going to give me the answer I expect for some reason?


问:
Access to fetch at 'https://externalDomain.com' from origin 'https://test.com' has been blocked by CORS policy
I don't really know if this problem is related to Magento or not, I tell you the error:

I am trying to make a fetch call to an external domain and I get the CORS error and it blocks my resources.

I have tried different solutions:

Add the headers to the fetch call.

Add the headers to the nginx.conf file.

Install a module to enable cors. https://github.com/graycoreio/magento2-cors

But no solution has worked for me and I'm running out of ideas.

Here is the error:

```<code>Access to fetch at 'https://test.cetelem.es/eCommerceCalculadora/cetelem/getEcommerceCalculadoraSlider.htm?cantidad=5000.00&codCentro=PRUEBAS&listadoMeses=&codPromocion=&material=' from origin 'https://test.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
</code>```

This is my code:

```<code>var data = {
            cantidad : cantidad,
            codCentro : codCentro,
            listadoMeses : listadoMesesCalculadora,
            codPromocion : codPromocionCalculadora,
            material: materialCalc
        };
        var urlGetEcommerceCalculadoraSlider = server+"/eCommerceCalculadora/cetelem/getEcommerceCalculadoraSlider.htm?cantidad=" + data.cantidad + "&codCentro=" + data.codCentro + "&listadoMeses=" + data.listadoMeses + "&codPromocion=" + data.codPromocion + "&material=" + data.material;

        fetch(urlGetEcommerceCalculadoraSlider, {
            headers: {
                "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
            },
            method: 'GET',
            async : true
        }).then(response => {
            if (response.ok) {
                return response.text();
            } else {
                console.log("GET request failed", response);
            }
        }).then(data => {

            data = data.replace('cetelem(','');
            data = data.slice(0, -1);
            data = JSON.parse(data);

        }).catch(function (error) {
            console.log(error);
            typeof window.dispatchMessages !== "undefined" && window.dispatchMessages(
                [{
                    type: "error",
                    text: error
                }], 5000
            );
        });
</code>```

Body:
I don't really know if this problem is related to Magento or not, I tell you the error:

I am trying to make a fetch call to an external domain and I get the CORS error and it blocks my resources.

I have tried different solutions:

Add the headers to the fetch call.

Add the headers to the nginx.conf file.

Install a module to enable cors. https://github.com/graycoreio/magento2-cors

But no solution has worked for me and I'm running out of ideas.

Here is the error:

Access to fetch at 'https://test.cetelem.es/eCommerceCalculadora/cetelem/getEcommerceCalculadoraSlider.htm?cantidad=5000.00&codCentro=PRUEBAS&listadoMeses=&codPromocion=&material=' from origin 'https://test.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

This is my code:

var data = {
            cantidad : cantidad,
            codCentro : codCentro,
            listadoMeses : listadoMesesCalculadora,
            codPromocion : codPromocionCalculadora,
            material: materialCalc
        };
        var urlGetEcommerceCalculadoraSlider = server+"/eCommerceCalculadora/cetelem/getEcommerceCalculadoraSlider.htm?cantidad=" + data.cantidad + "&codCentro=" + data.codCentro + "&listadoMeses=" + data.listadoMeses + "&codPromocion=" + data.codPromocion + "&material=" + data.material;

        fetch(urlGetEcommerceCalculadoraSlider, {
            headers: {
                "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
            },
            method: 'GET',
            async : true
        }).then(response => {
            if (response.ok) {
                return response.text();
            } else {
                console.log("GET request failed", response);
            }
        }).then(data => {

            data = data.replace('cetelem(','');
            data = data.slice(0, -1);
            data = JSON.parse(data);

        }).catch(function (error) {
            console.log(error);
            typeof window.dispatchMessages !== "undefined" && window.dispatchMessages(
                [{
                    type: "error",
                    text: error
                }], 5000
            );
        });


问:
Issue with large file upload using readAsDataURL and FileReader object when uploading a file with 700MB+ size
We are experiencing an error when trying to upload a large file using an HTML input uploader in Firefox. The file upload process is working properly in Chrome, but we are encountering issues when using Firefox. We have included a sample for reference and request assistance in resolving this problem. Please let us know if you have any suggestions for a solution.

sample :

```<code>    <html>

    <body>
        <input type="file" id="upload">
        <button id="button">flie upload</button>
    </body>
    <script>
        document.getElementById('button').addEventListener("click", function () {
            //debugger;
            var file = document.getElementById('upload').files;
            check(file[0]);

        })

        function check(file) {
            return new Promise(function (resolve, reject) {
                var fileReader = new FileReader();
                fileReader.readAsDataURL(file);
                fileReader.onload = function () {
                    return resolve(fileReader.result);
                };
                fileReader.onerror = function (error) {
                    return reject(error);
                };
            });
        }
    </script>

    </html>
</code>```

I need to upload file without console error.

Body:
We are experiencing an error when trying to upload a large file using an HTML input uploader in Firefox. The file upload process is working properly in Chrome, but we are encountering issues when using Firefox. We have included a sample for reference and request assistance in resolving this problem. Please let us know if you have any suggestions for a solution.

sample :

        <input type="file" id="upload">
        <button id="button">flie upload</button>

I need to upload file without console error.


问:
how can I add multiple images using faker in Factory Laravel 9
Please help, how can I add multiple url of images to the database using faker in Factory

```<code>public function definition()
{
    return array(
        'title' => $this->faker->colorName,
        'file_url' => $this->faker->imageUrl(748, 500),
    );
}
</code>```

I didn't find a solution

Body:
Please help, how can I add multiple url of images to the database using faker in Factory

public function definition()
{
    return array(
        'title' => $this->faker->colorName,
        'file_url' => $this->faker->imageUrl(748, 500),
    );
}

I didn't find a solution


问:
Why am I getting a broken token response?
I am creating a login system using discord oauth.

During development, I succeeded in logging in from oauth and getting a code, but I ran into a problem where I couldn't get a token afterwards.

I tried with the following code

const params = new URLSearchParams();
params.append('client_id', client_id);
params.append('client_secret', client_secret);
params.append('grant_type', 'authorization_code');
params.append('code', code);
params.append('redirect_uri', 'http://localhost/callback');

const token = await axios.post('https://discord.com/api/v10/oauth2/token', params);
console.log(token.data);
```
<p>and got the following output</p>
```V�@6���\���
u���%�%O~��F&��J�|_'*��d2ý��(��Q�2�ۊK�K1�
���l�6��'�W��@����Qtd�|�      M�>.�X
```

same request in hoppscotch

Things I've tried:

Content-Type: application/json -> discord api didn't allow it

responseEncoding: 'utf8' option -> same output

How can I get unbroken output?

Axios: 1.2.0

Body:
I am creating a login system using discord oauth.

During development, I succeeded in logging in from oauth and getting a code, but I ran into a problem where I couldn't get a token afterwards.

I tried with the following code

const params = new URLSearchParams();
params.append('client_id', client_id);
params.append('client_secret', client_secret);
params.append('grant_type', 'authorization_code');
params.append('code', code);
params.append('redirect_uri', 'http://localhost/callback');

const token = await axios.post('https://discord.com/api/v10/oauth2/token', params);
console.log(token.data);

and got the following output

V�@6���\���
u���%�%O~��F&��J�|_'*��d2ý��(��Q�2�ۊK�K1�
���l�6��'�W��@����Qtd�|�      M�>.�X

same request in hoppscotch

Things I've tried:

Content-Type: application/json -> discord api didn't allow it

responseEncoding: 'utf8' option -> same output

How can I get unbroken output?

Axios: 1.2.0


问:
Memory Use Errors on Importing many products into WooCommerce
I have developed a WordPress plugin that integrates with WooCommerce.  Among other features, it facilitates importing of products from an external database.  There seems to be a threshold of around 900 where fewer products work without issue, but more than that crash with an out-of-memory error.  When I see an error in debug.log it points to the 'random' function that pushed the memory over the edge and is of little help.

Some of the directions I have tried:

Made sure I am using the latest versions of WordPress and WooCommerce and PHP 8

I am working with Scheduled Actions to decouple this process from page loads.

I tried adding wp_suspend_cache_addition(true) without a noticeable difference, thinking that maybe WordPress/WooCommerce are storing product data in a memory cache that I do not need.

I have added memory monitoring debugging code but have learned little other than the memory used slowly increases until the crash.

My main limitation is that this needs to work within a plugin for WordPress/WooCommerce so I can not assume to have access to the server itself.  In addition, I would like to refrain from direct database insertion and use WP/WC functions for the obvious reasons.

How do WordPress and WooCommerce handle these sort of imports of data?  What memory management do they employ?  It looks to me like WooCommerce ultimately calls wp_update_post() or wp_insert_post() and those functions ultimately call $wpdb->update() or $wpdb->insert() which do the actual database insertions, and it doesn't seem like there is any caching going on there.

Another place for a memory leak might be a check if the product already exists in the database.  I set that up using WP_Query, and found that by using get_posts() I think I can reduce the memory used by some.  But the issue still persists.

EDIT:
It seems that if I run the process in batches/paging from within PHP using Scheduled Actions, I get the same results.  However if I run the batches from JS via AJAX, it looks like it processes all the products correctly. This means I can run an import from the browser, but not automated from the backend.

EDIT2:
Here is some of the code I'm running.  I have edited it down as much as I could to keep it simple without loosing any of the important things.  (A lot of error checking/reporting is gone, and some variables replaced with strings to make things simpler without loosing context)  If there is something missing or unclear, please let me know.

```<code>    function my_update_product_listings() {

    //Returns an array of Simple Products, Products with Variations and Variations
    $products = my_apiCall( "GET", "API/URL/Sanitized/For/StackOverflow" );

    if ( is_wp_error( $products ) ) {
        return array( 'message' => "Product Update Error" );
    }

    //Update/insert products
    //Return the number of inserts and updates and IDs of errors
    $updated = my_update_products( $products );

    //Remove Variable Products and error products
    //We only update Price and Inventory on Simple Products or Variations
    $end_products = my_only_end_products($products, $updated);

    //Run Price update and Inventory update functions on End Products
    do_action( 'post_update_end_products_actions_filter', $end_products);

    return "complete";
}

function my_single_products( $products ) {
    if ( !$updated ) {
        $updated = array('new' => 0, 'existing' => 0, 'errors' => array());
    }

    foreach ( $products as $prod ) {

        $prod_sku = $prod['sku'];
        $parent = $prod['parent'];
        $object_term  = $parent ? 'variable' : 'simple';

        $variation = $prod['parent_sku'] && !$parent;

        try {
            $existing = my_is_already_product( $prod_sku, $variation );
        } catch ( Exception $e ) {
            $updated["errors"][] = $prod_sku;
            continue;
        }

        $meta_input = array(
            '_visibility'   => 'visible',
            '_manage_stock' => 'yes',
            '_backorders'   => 'no',
            '_downloadable' => 'no',
            '_featured'     => 'no',
            '_virutal'      => 'no',
            '_sku'          => $prod_sku,
        );

        if ( $parent ) {
            $meta_input['_manage_stock'] = "no";
        }

        $post_info = array(
            'post_type'  => "product",
            'meta_input' => $meta_input,
            'post_title' => $prod['description'];
        );

        if ( $existing ) {
            $post_info['ID'] = $existing;

            $post_id = wp_update_post( $post_info, true );
        } else {
            $post_info['post_status'] = 'draft';
            $post_info['post_name']   = "p_" . $prod_sku;

            $post_id = wp_insert_post( $post_info, true );
        }

        if ( is_wp_error( $post_id ) ) {
            $updated['errors'][] = $prod_sku;
        } else {
            wp_set_object_terms( $post_id, $object_term, 'product_type' );
            $product    = wc_get_product( $post_id );
            $attributes = array();
            foreach ( $prod as $key => $value ) {
                //Attributes from database are fields that begin with 'SPEC' followed by a number
                if ( str_starts_with( $key, "SPEC" ) && $value != null ) {
                    $attributes['pa_' . strtolower( $key )] = array(
                        'name'       => 'pa_' . strtolower( $key ),
                        'value'      => strtolower( urldecode( $value ) ),
                        'is_visible' => 1
                    );
                }
            }
            if ( $attributes ) {
                $product->update_meta_data( '_product_attributes', $attributes );
            }

            if ( $existing ) {
                $updated['existing']++;
            } else {
                $updated['new']++;
            }

            $product->update_meta_data( 'my_custom_synced_meta_field', 1 );
            $product->save();
        }
    }

    return $updated;
}

function my_is_already_product( $sku, $variation ) {
    $meta_query = array(
        'relation' => 'AND',
        array(
            'key'   => '_sku',
            'value' => $sku
        ),
        array(
            'key'   => 'my_custom_synced_meta_field',
            'value' => 1
        )
    );

    $gotten_posts = get_posts(array(
        'post_type'   => $variation ? 'product_variation' : 'product',
        'post_status' => 'any',
        'meta_query'  => $meta_query
    ));

    if ( count($gotten_posts) === 0 ) {
        return false;
    } else if ( count($gotten_posts) === 1 ) {
        return $gotten_posts[0]->ID;
    } else if ( count($gotten_posts) > 1 ) {
        throw new Exception( "Multiple products found with same SKU: ". $sku );
    }
}

function my_update_product_price( $products_prices ) {
    $price_list      = get_option( "my_price_list" );
    $sale_price_list = get_option( "my_sale_price_list" );

    $priceField = 'price';

    foreach ( $products_prices as $prices ) {
        if ( !isset( $prices['prices'] ) ) {
            continue;
        }
        $product = my_get_product_by_SKU( $prices['sku'] );
        if ( $product ) {
            foreach ( $prices['prices'] as $pricePoint ) {
                if ( $pricePoint['priceList'] === $price_list ) {
                    $product->set_regular_price( $pricePoint['price'] );
                }
                if ( $pricePoint['priceList'] === $sale_price_list ) {
                    $product->set_sale_price( $pricePoint['price'] );
                }
            }
            $product->save();
        }
    }
}

function my_get_product_by_SKU( $sku, $variable = false ) {
    try {
        $id = my_is_already_product( $sku );
        if ( $id ) {
            if ( $variable ) {
                $product = new WC_Product_Variable( $id );
            } else {
                $product = new WC_Product( $id );
            }
        } else {
            $id = my_is_already_product( $sku, true );
            if ( $id ) {
                $product = new WC_Product_Variation( $id );
            } else {
                return false;
            }
        }

        return $product;
    } catch ( Exception $e ) {
        error_log( "Get Product by SKU Error: " . $e->getMessage() );
        return false;
    }
}
</code>```

Body:
I have developed a WordPress plugin that integrates with WooCommerce.  Among other features, it facilitates importing of products from an external database.  There seems to be a threshold of around 900 where fewer products work without issue, but more than that crash with an out-of-memory error.  When I see an error in debug.log it points to the 'random' function that pushed the memory over the edge and is of little help.

Some of the directions I have tried:

Made sure I am using the latest versions of WordPress and WooCommerce and PHP 8

I am working with Scheduled Actions to decouple this process from page loads.

I tried adding wp_suspend_cache_addition(true) without a noticeable difference, thinking that maybe WordPress/WooCommerce are storing product data in a memory cache that I do not need.

I have added memory monitoring debugging code but have learned little other than the memory used slowly increases until the crash.

My main limitation is that this needs to work within a plugin for WordPress/WooCommerce so I can not assume to have access to the server itself.  In addition, I would like to refrain from direct database insertion and use WP/WC functions for the obvious reasons.

How do WordPress and WooCommerce handle these sort of imports of data?  What memory management do they employ?  It looks to me like WooCommerce ultimately calls wp_update_post() or wp_insert_post() and those functions ultimately call $wpdb->update() or $wpdb->insert() which do the actual database insertions, and it doesn't seem like there is any caching going on there.

Another place for a memory leak might be a check if the product already exists in the database.  I set that up using WP_Query, and found that by using get_posts() I think I can reduce the memory used by some.  But the issue still persists.

EDIT:
It seems that if I run the process in batches/paging from within PHP using Scheduled Actions, I get the same results.  However if I run the batches from JS via AJAX, it looks like it processes all the products correctly. This means I can run an import from the browser, but not automated from the backend.

EDIT2:
Here is some of the code I'm running.  I have edited it down as much as I could to keep it simple without loosing any of the important things.  (A lot of error checking/reporting is gone, and some variables replaced with strings to make things simpler without loosing context)  If there is something missing or unclear, please let me know.

    function my_update_product_listings() {

    //Returns an array of Simple Products, Products with Variations and Variations
    $products = my_apiCall( "GET", "API/URL/Sanitized/For/StackOverflow" );

    if ( is_wp_error( $products ) ) {
        return array( 'message' => "Product Update Error" );
    }

    //Update/insert products
    //Return the number of inserts and updates and IDs of errors
    $updated = my_update_products( $products );

    //Remove Variable Products and error products
    //We only update Price and Inventory on Simple Products or Variations
    $end_products = my_only_end_products($products, $updated);

    //Run Price update and Inventory update functions on End Products
    do_action( 'post_update_end_products_actions_filter', $end_products);

    return "complete";
}

function my_single_products( $products ) {
    if ( !$updated ) {
        $updated = array('new' => 0, 'existing' => 0, 'errors' => array());
    }

    foreach ( $products as $prod ) {

        $prod_sku = $prod['sku'];
        $parent = $prod['parent'];
        $object_term  = $parent ? 'variable' : 'simple';

        $variation = $prod['parent_sku'] && !$parent;

        try {
            $existing = my_is_already_product( $prod_sku, $variation );
        } catch ( Exception $e ) {
            $updated["errors"][] = $prod_sku;
            continue;
        }

        $meta_input = array(
            '_visibility'   => 'visible',
            '_manage_stock' => 'yes',
            '_backorders'   => 'no',
            '_downloadable' => 'no',
            '_featured'     => 'no',
            '_virutal'      => 'no',
            '_sku'          => $prod_sku,
        );

        if ( $parent ) {
            $meta_input['_manage_stock'] = "no";
        }

        $post_info = array(
            'post_type'  => "product",
            'meta_input' => $meta_input,
            'post_title' => $prod['description'];
        );

        if ( $existing ) {
            $post_info['ID'] = $existing;

            $post_id = wp_update_post( $post_info, true );
        } else {
            $post_info['post_status'] = 'draft';
            $post_info['post_name']   = "p_" . $prod_sku;

            $post_id = wp_insert_post( $post_info, true );
        }

        if ( is_wp_error( $post_id ) ) {
            $updated['errors'][] = $prod_sku;
        } else {
            wp_set_object_terms( $post_id, $object_term, 'product_type' );
            $product    = wc_get_product( $post_id );
            $attributes = array();
            foreach ( $prod as $key => $value ) {
                //Attributes from database are fields that begin with 'SPEC' followed by a number
                if ( str_starts_with( $key, "SPEC" ) && $value != null ) {
                    $attributes['pa_' . strtolower( $key )] = array(
                        'name'       => 'pa_' . strtolower( $key ),
                        'value'      => strtolower( urldecode( $value ) ),
                        'is_visible' => 1
                    );
                }
            }
            if ( $attributes ) {
                $product->update_meta_data( '_product_attributes', $attributes );
            }

            if ( $existing ) {
                $updated['existing']++;
            } else {
                $updated['new']++;
            }

            $product->update_meta_data( 'my_custom_synced_meta_field', 1 );
            $product->save();
        }
    }

    return $updated;
}

function my_is_already_product( $sku, $variation ) {
    $meta_query = array(
        'relation' => 'AND',
        array(
            'key'   => '_sku',
            'value' => $sku
        ),
        array(
            'key'   => 'my_custom_synced_meta_field',
            'value' => 1
        )
    );

    $gotten_posts = get_posts(array(
        'post_type'   => $variation ? 'product_variation' : 'product',
        'post_status' => 'any',
        'meta_query'  => $meta_query
    ));

    if ( count($gotten_posts) === 0 ) {
        return false;
    } else if ( count($gotten_posts) === 1 ) {
        return $gotten_posts[0]->ID;
    } else if ( count($gotten_posts) > 1 ) {
        throw new Exception( "Multiple products found with same SKU: ". $sku );
    }
}

function my_update_product_price( $products_prices ) {
    $price_list      = get_option( "my_price_list" );
    $sale_price_list = get_option( "my_sale_price_list" );

    $priceField = 'price';

    foreach ( $products_prices as $prices ) {
        if ( !isset( $prices['prices'] ) ) {
            continue;
        }
        $product = my_get_product_by_SKU( $prices['sku'] );
        if ( $product ) {
            foreach ( $prices['prices'] as $pricePoint ) {
                if ( $pricePoint['priceList'] === $price_list ) {
                    $product->set_regular_price( $pricePoint['price'] );
                }
                if ( $pricePoint['priceList'] === $sale_price_list ) {
                    $product->set_sale_price( $pricePoint['price'] );
                }
            }
            $product->save();
        }
    }
}

function my_get_product_by_SKU( $sku, $variable = false ) {
    try {
        $id = my_is_already_product( $sku );
        if ( $id ) {
            if ( $variable ) {
                $product = new WC_Product_Variable( $id );
            } else {
                $product = new WC_Product( $id );
            }
        } else {
            $id = my_is_already_product( $sku, true );
            if ( $id ) {
                $product = new WC_Product_Variation( $id );
            } else {
                return false;
            }
        }

        return $product;
    } catch ( Exception $e ) {
        error_log( "Get Product by SKU Error: " . $e->getMessage() );
        return false;
    }
}


问:
How to implement recuring tasks with Google Pub/Sub and persistent task queue
I have a project where I am scrapping web pages. A user can add which web pages to scrape, and how often and remove them if necessary. Would it be ideal to have a messenger queue where the tasks (with functionality to scrape the page) are repeated every X period? Also, I want to be able to remove the repeated task if the user doesn't want to scrape the page anymore. Another question is should the task queue be persistent so we don't lose track of when to execute tasks.
I am having trouble choosing which technologies would suit me best. I am also using Google Cloud so it would be nice to keep everything there

Google Pub/Sub, but how can I schedule a repeated task and be able to remove them from the queue?

Using Celery beat and RabbitMQ

Thanks!


问:
Yii v1.1 redirects to 404 nginx
My Yii 1.1 app redirects to site.com/login and gets error 404. Yii app hasn't any problems, it's an old app which I want to install on my server. The problem has to be with nginx configuration with mod_rewrite because pretty urls are not processed as they should.

Here i my default.conf:

```<code>server {
 include snippets/phpmyadmin.conf;
 listen   80 default_server;
    charset UTF-8;

        # SSL configuration
        #
        # listen 443 ssl default_server;
        # listen [::]:443 ssl default_server;
        #
        # Note: You should disable gzip for SSL traffic.
        # See: https://bugs.debian.org/773332
        #
        # Read up on ssl_ciphers to ensure a secure configuration.
        # See: https://bugs.debian.org/765782
        #
        # Self signed certs generated by the ssl-cert package
        # Don't use them in a production server!
        #
        # include snippets/snakeoil.conf;

        root /home/fornex/tmp_7offers/public/;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.php;

        server_name localhost;

          client_max_body_size  30m;

  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  include fastcgi_params;
  fastcgi_read_timeout 60;
  fastcgi_send_timeout 60;

        location /public {
                root /home/fornex/tmp_7offers/public/;
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                error_log  /var/log/nginx/error-01.log;
                index index.php index.html index.htm;
                # proxy_pass http://localhost:8080;
                # proxy_http_version 1.1;
                # proxy_set_header Upgrade $http_upgrade;
                # proxy_set_header Connection 'upgrade';
                # proxy_set_header Host $host;
                # proxy_cache_bypass $http_upgrade;

                if (!-e $request_filename){
                   rewrite ^/(.*) /index.php?r=$1 last;
                 }

        }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
location ~ \.php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    include snippets/fastcgi-php.conf;
    include fastcgi_params;
    # With php-fpm (or other unix sockets):
    fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;

    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    fastcgi_param  PATH_INFO        $fastcgi_path_info;

        if ($request_uri ~ ^/(login)) {
            error_page      404     =301 @redirect;
        }
    # With php-cgi (or other tcp sockets):
     #fastcgi_pass 127.0.0.1:9000;
}
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #       deny all;
        #}
}
</code>```

How can I enable mod_rewrite so pretty urls will processed as they should?

Title: Yii v1.1 redirects to 404 nginx

Body:
My Yii 1.1 app redirects to site.com/login and gets error 404. Yii app hasn't any problems, it's an old app which I want to install on my server. The problem has to be with nginx configuration with mod_rewrite because pretty urls are not processed as they should.

Here i my default.conf:

server {
 include snippets/phpmyadmin.conf;
 listen   80 default_server;
    charset UTF-8;

        # SSL configuration
        #
        # listen 443 ssl default_server;
        # listen [::]:443 ssl default_server;
        #
        # Note: You should disable gzip for SSL traffic.
        # See: https://bugs.debian.org/773332
        #
        # Read up on ssl_ciphers to ensure a secure configuration.
        # See: https://bugs.debian.org/765782
        #
        # Self signed certs generated by the ssl-cert package
        # Don't use them in a production server!
        #
        # include snippets/snakeoil.conf;

        root /home/fornex/tmp_7offers/public/;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.php;

        server_name localhost;

          client_max_body_size  30m;

  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  include fastcgi_params;
  fastcgi_read_timeout 60;
  fastcgi_send_timeout 60;

        location /public {
                root /home/fornex/tmp_7offers/public/;
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                error_log  /var/log/nginx/error-01.log;
                index index.php index.html index.htm;
                # proxy_pass http://localhost:8080;
                # proxy_http_version 1.1;
                # proxy_set_header Upgrade $http_upgrade;
                # proxy_set_header Connection 'upgrade';
                # proxy_set_header Host $host;
                # proxy_cache_bypass $http_upgrade;

                if (!-e $request_filename){
                   rewrite ^/(.*) /index.php?r=$1 last;
                 }

        }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
location ~ \.php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    include snippets/fastcgi-php.conf;
    include fastcgi_params;
    # With php-fpm (or other unix sockets):
    fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;

    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    fastcgi_param  PATH_INFO        $fastcgi_path_info;

        if ($request_uri ~ ^/(login)) {
            error_page      404     =301 @redirect;
        }
    # With php-cgi (or other tcp sockets):
     #fastcgi_pass 127.0.0.1:9000;
}
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #       deny all;
        #}
}

How can I enable mod_rewrite so pretty urls will processed as they should?


问:
Why container does not start automatically in Test?
I have the following class

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK)
@RunWith(SpringRunner.class)
@Testcontainers
@ContextConfiguration(initializers = OperationCodeRepositoryTest.DockerDatasourceInitializer.class)
public class OperationCodeRepositoryTest {

    @Container
    private static MSSQLServerContainer<?> container = new MSSQLServerContainer<>(
            "mcr.microsoft.com/mssql/server:2019-latest").acceptLicense()
            .withInitScript("database/init.sql");

    @Autowired
    private OperationCodeRepository repository;

    public static class DockerDatasourceInitializer
            implements ApplicationContextInitializer<ConfigurableApplicationContext> {
        @Override
        public void initialize(ConfigurableApplicationContext applicationContext) {
            TestPropertySourceUtils.addInlinedPropertiesToEnvironment(
                    applicationContext, "spring.datasource.url=" + container.getJdbcUrl(),
                    "spring.datasource.username=" + container.getUsername(),
                    "spring.datasource.password=" + container.getPassword());
        }
    }

}

// SOme tests hre

```
<p>Whenever I try to run my tests,I get the following error :</p>
<p><code>java.lang.IllegalStateException: Mapped port can only be obtained after the container is started</code></p>
<p>I thought that having the <code>@Container</code> would be enough to start the container.
The only option for me is to manually start the container by calling the <code>start</code> method in <code>@BeforeClass</code></p>
<p>Ex :</p>
<pre class="lang-java prettyprint-override"><code>    @BeforeClass
    public static void init() {
        try{
            container.start();
        } catch(Exception e){
            e.printStackTrace();
        }

    }
</code>```

What am I doing wrong ?
THanks

Body:
I have the following class

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK)
@RunWith(SpringRunner.class)
@Testcontainers
@ContextConfiguration(initializers = OperationCodeRepositoryTest.DockerDatasourceInitializer.class)
public class OperationCodeRepositoryTest {

    @Container
    private static MSSQLServerContainer<?> container = new MSSQLServerContainer<>(
            "mcr.microsoft.com/mssql/server:2019-latest").acceptLicense()
            .withInitScript("database/init.sql");

    @Autowired
    private OperationCodeRepository repository;

    public static class DockerDatasourceInitializer
            implements ApplicationContextInitializer<ConfigurableApplicationContext> {
        @Override
        public void initialize(ConfigurableApplicationContext applicationContext) {
            TestPropertySourceUtils.addInlinedPropertiesToEnvironment(
                    applicationContext, "spring.datasource.url=" + container.getJdbcUrl(),
                    "spring.datasource.username=" + container.getUsername(),
                    "spring.datasource.password=" + container.getPassword());
        }
    }

}

// SOme tests hre

Whenever I try to run my tests,I get the following error :

java.lang.IllegalStateException: Mapped port can only be obtained after the container is started

I thought that having the @Container would be enough to start the container.
The only option for me is to manually start the container by calling the start method in @BeforeClass

Ex :

    @BeforeClass
    public static void init() {
        try{
            container.start();
        } catch(Exception e){
            e.printStackTrace();
        }

    }

What am I doing wrong ?
THanks


问:
Connect Salesforce to Postman
In the quick connection test, there's no response since I could not send any request through the "GET Limit" collection. I can't authenticate with Salesforce.

I tried installing the Postman Desktop Agent but it didn't work.

Title: Connect Salesforce to Postman