问:
How to create dynamic time intervals in SQL Snowflake?
I am writing a query that should recognize the dates when different budgets associated to one account were totally consumed. My start date is 1/12 so my task is to create a cumulative sum of the expenses that the account made for its first budget, then when the cumulative sum reach the budget, I should store the date when it happened, and the use that date as my new START DATE to compute the expenses of the same account but for the second budget, and so on. It seems for me difficult to create this dynamic interval was on the result of the previous budget. Do you have any idea of how I could I manage this problem?

What I Tried

```<code>

WITH TRM_INTERVAL AS
    (
    SELECT
    Country,
    replace(Account_ID, '-', '') AS fixed_accountid,
    TO_DATE(Date) AS CONVERTED_DATE,
    TO_DATE(CAST(CONVERTED_DATE AS VARCHAR), 'YYYY-DD-MM') AS CONVERTED_DATE_FORMAT,
    TRM2,
    TRM1,
    TOTAL_ARS_IN_ACCOUNT,
    row_number()
    over (partition by Account_ID, Country order by CONVERTED_DATE_FORMAT) AS ROW_NUMBER,
    lag(TOTAL_ARS_IN_ACCOUNT)
    over (partition by Account_ID, Country order by CONVERTED_DATE_FORMAT) AS PREVIOUS_ARS_BUCKET,
    lead(CONVERTED_DATE_FORMAT)
    over (partition by Account_ID, Country order by CONVERTED_DATE_FORMAT) AS NEXT_DATE
    FROM CONECTOR
),

--DETAIL
DETAIL AS (

    SELECT TI.COUNTRY, TI.fixed_accountid, TI.PREVIOUS_ARS_BUCKET, TI.TOTAL_ARS_IN_ACCOUNT, TI.ROW_NUMBER, GO.EVENT_DATE, SUM(CASE WHEN GO.CURRENCY_ORIGINAL = 'ARS' THEN GO.FINAL_CAC * 160 END) AS ARS_SPEND,

    SUM(ARS_SPEND) OVER(PARTITION BY TI.fixed_accountid, TI.COUNTRY, TI.TOTAL_ARS_IN_ACCOUNT ORDER BY GO.EVENT_DATE ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS CUMULATIVE_ARS_SPEND

    FROM TABLE1 AS GO
    JOIN CONECTOR AS TI
    ON GO.ACCOUNT_ID = TI.fixed_accountid AND GO.COUNTRY = TI.COUNTRY
    WHERE GO.EVENT_DATE >= '2022-12-1'
    GROUP BY 1,2,3,4,5,6

),

--ACUMULADO
LOGIC AS (

    SELECT *,
    CUMULATIVE_ARS_SPEND / TOTAL_ARS_IN_ACCOUNT AS CUMULATIVE_ARS_SPEND_PERCENTAGE,
    --COMO VALIDAR CON EL TI TOTAL ARS CORRESPONDIENTE
    CASE WHEN CUMULATIVE_ARS_SPEND_PERCENTAGE >=0.686 AND EVENT_DATE <> CURRENT_DATE() THEN 'FLAG' END AS FLAGS

    FROM DETAIL

)
</code>```

I have 3 subqueries. To sum up, I create the cumulative sum of the expenses related to each account but I could not create the dynamic intervals. The dates start from 12/1/2022.

What actually resulted

You see 3 budgets as example. All of them are associated with a single account. I start with the budget 500,000, you see that I made the cumulative sum until it reach 100%. but then for the second budget 30,000,000 the dates and the expenses are repeated. The same dates were applied 1/12, 1/13, 1/14 and 1/15. The idea is that if the first budget was totally consumed on 1/15 as you can see, the query should compute the expenses for the second budget since one day later 1/16 until that second budget is as well totally consumed and so on.

```<code>FECHA   BUDGET      SPEND_DAILY     CUMULATIVE   % ACUMM
01/12/2022  500000    100000        100000       20.00%
01/13/2022  500000    150000        250000       50.00%
01/14/2022  500000    200000        450000       90.00%
01/15/2022  500000    50000         500000       100.00%
01/12/2022  30000000  100000        100000         0.33%
01/13/2022  30000000  150000        250000         0.83%
01/14/2022  30000000  200000        450000         1.50%
01/15/2022  30000000  50000         500000         1.67%
01/12/2022  4000000   100000        100000        2.50%
01/13/2022  4000000   150000        250000        6.25%
01/14/2022  4000000   200000        450000        11.25%
01/15/2022  4000000   50000         500000        12.50%
</code>```

What I expected to happen
The desire output should be these table, where the first budget is totally consumed one day, and on the next day, the expenses compute is updated and now the cumulative sum is applied to the second budget.

```<code>FECHA       BUDGET  GASTO DIARIO    GASTO ACUMM % ACUMM
01/12/2022  500000     100000            100000   20.00%
01/13/2022  500000     150000            250000   50.00%
01/14/2022  500000     200000            450000   90.00%
01/15/2022  500000     50000             500000   100.00%
01/16/2022  30000000    100000           100000     0.33%
01/17/2022  30000000    200000           300000     1.00%
01/18/2022  30000000    500000           800000     2.67%
01/19/2022  30000000    300000           1100000    3.67%
01/20/2022  30000000    150000           1250000    4.17%
01/21/2022  30000000    20000000         21250000   70.83%
01/22/2022  30000000    10000000         31250000   104.17%
</code>```

Body:
I am writing a query that should recognize the dates when different budgets associated to one account were totally consumed. My start date is 1/12 so my task is to create a cumulative sum of the expenses that the account made for its first budget, then when the cumulative sum reach the budget, I should store the date when it happened, and the use that date as my new START DATE to compute the expenses of the same account but for the second budget, and so on. It seems for me difficult to create this dynamic interval was on the result of the previous budget. Do you have any idea of how I could I manage this problem?

What I Tried

WITH TRM_INTERVAL AS
    (
    SELECT
    Country,
    replace(Account_ID, '-', '') AS fixed_accountid,
    TO_DATE(Date) AS CONVERTED_DATE,
    TO_DATE(CAST(CONVERTED_DATE AS VARCHAR), 'YYYY-DD-MM') AS CONVERTED_DATE_FORMAT,
    TRM2,
    TRM1,
    TOTAL_ARS_IN_ACCOUNT,
    row_number()
    over (partition by Account_ID, Country order by CONVERTED_DATE_FORMAT) AS ROW_NUMBER,
    lag(TOTAL_ARS_IN_ACCOUNT)
    over (partition by Account_ID, Country order by CONVERTED_DATE_FORMAT) AS PREVIOUS_ARS_BUCKET,
    lead(CONVERTED_DATE_FORMAT)
    over (partition by Account_ID, Country order by CONVERTED_DATE_FORMAT) AS NEXT_DATE
    FROM CONECTOR
),

--DETAIL
DETAIL AS (

    SELECT TI.COUNTRY, TI.fixed_accountid, TI.PREVIOUS_ARS_BUCKET, TI.TOTAL_ARS_IN_ACCOUNT, TI.ROW_NUMBER, GO.EVENT_DATE, SUM(CASE WHEN GO.CURRENCY_ORIGINAL = 'ARS' THEN GO.FINAL_CAC * 160 END) AS ARS_SPEND,

    SUM(ARS_SPEND) OVER(PARTITION BY TI.fixed_accountid, TI.COUNTRY, TI.TOTAL_ARS_IN_ACCOUNT ORDER BY GO.EVENT_DATE ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS CUMULATIVE_ARS_SPEND

    FROM TABLE1 AS GO
    JOIN CONECTOR AS TI
    ON GO.ACCOUNT_ID = TI.fixed_accountid AND GO.COUNTRY = TI.COUNTRY
    WHERE GO.EVENT_DATE >= '2022-12-1'
    GROUP BY 1,2,3,4,5,6

),

--ACUMULADO
LOGIC AS (

    SELECT *,
    CUMULATIVE_ARS_SPEND / TOTAL_ARS_IN_ACCOUNT AS CUMULATIVE_ARS_SPEND_PERCENTAGE,
    --COMO VALIDAR CON EL TI TOTAL ARS CORRESPONDIENTE
    CASE WHEN CUMULATIVE_ARS_SPEND_PERCENTAGE >=0.686 AND EVENT_DATE <> CURRENT_DATE() THEN 'FLAG' END AS FLAGS

    FROM DETAIL

)

I have 3 subqueries. To sum up, I create the cumulative sum of the expenses related to each account but I could not create the dynamic intervals. The dates start from 12/1/2022.

What actually resulted

You see 3 budgets as example. All of them are associated with a single account. I start with the budget 500,000, you see that I made the cumulative sum until it reach 100%. but then for the second budget 30,000,000 the dates and the expenses are repeated. The same dates were applied 1/12, 1/13, 1/14 and 1/15. The idea is that if the first budget was totally consumed on 1/15 as you can see, the query should compute the expenses for the second budget since one day later 1/16 until that second budget is as well totally consumed and so on.

FECHA   BUDGET      SPEND_DAILY     CUMULATIVE   % ACUMM
01/12/2022  500000    100000        100000       20.00%
01/13/2022  500000    150000        250000       50.00%
01/14/2022  500000    200000        450000       90.00%
01/15/2022  500000    50000         500000       100.00%
01/12/2022  30000000  100000        100000         0.33%
01/13/2022  30000000  150000        250000         0.83%
01/14/2022  30000000  200000        450000         1.50%
01/15/2022  30000000  50000         500000         1.67%
01/12/2022  4000000   100000        100000        2.50%
01/13/2022  4000000   150000        250000        6.25%
01/14/2022  4000000   200000        450000        11.25%
01/15/2022  4000000   50000         500000        12.50%

What I expected to happen
The desire output should be these table, where the first budget is totally consumed one day, and on the next day, the expenses compute is updated and now the cumulative sum is applied to the second budget.

FECHA       BUDGET  GASTO DIARIO    GASTO ACUMM % ACUMM
01/12/2022  500000     100000            100000   20.00%
01/13/2022  500000     150000            250000   50.00%
01/14/2022  500000     200000            450000   90.00%
01/15/2022  500000     50000             500000   100.00%
01/16/2022  30000000    100000           100000     0.33%
01/17/2022  30000000    200000           300000     1.00%
01/18/2022  30000000    500000           800000     2.67%
01/19/2022  30000000    300000           1100000    3.67%
01/20/2022  30000000    150000           1250000    4.17%
01/21/2022  30000000    20000000         21250000   70.83%
01/22/2022  30000000    10000000         31250000   104.17%


来源: stackexchange

问:
Spark how to process Kafka streaming consumer when the program is crashed
I wrote a program using Spark 3.3.1 to consume Kafka data. My Client asked me two questions:

Before the checkpoint was saved into S3 bucket, the client was crashed. Next time, the client was rebooted, there was duplicated data.

Or, when the checkpoint was saved into S3 bucket, before the dat was sinked into S3 bucket, the client was crashed. Next time, the client was rebooted, the data was lost.

I don't sure whether this situations will take places.

I didn't find the answer from the official documents.

if len(partition_cols) == 0:
    df.selectExpr("CAST(value AS STRING)") \
     .select(from_json("value", schema_def, {"mode": "FAILFAST"}).alias("data")) \
     .select("data.*") \
     .selectExpr(*select_expr) \
     .writeStream.trigger(processingTime='5 minute') \
     .format('parquet') \
     .outputMode('append') \
     .option('path', f"s3a://{bucket}/{prefix}") \
     .option('checkpointLocation', f"s3a://{config_bucket}/{glue_db}/{glue_table}/checkpoint/") \
     .start() \
     .awaitTermination()
else:
    df.selectExpr("CAST(value AS STRING)") \
     .select(from_json("value", schema_def, {"mode": "FAILFAST"}).alias("data")) \
     .select("data.*") \
     .selectExpr(*select_expr) \
     .writeStream.trigger(processingTime='5 minute') \
     .format('parquet') \
     .partitionBy(','.join(partition_cols)) \
     .outputMode('append') \
     .option('path', f"s3a://{bucket}/{prefix}") \
     .option('checkpointLocation', f"s3a://{config_bucket}/{glue_db}/{glue_table}/checkpoint/") \
     .start() \
     .awaitTermination()
```

ContentLicense: CC BY-SA 4.0


问:
RVest html_nodes() not returning second table on webpage
I am trying to scrape data from football reference using this code:

```<code>season<-2020
team<-"nwe"
html<-paste("https://www.pro-football-reference.com/teams/",team,"/",season,"_roster.htm", sep="")
x<-read_csv(html)
table <- "table#roster"

html %>%
  read_html() %>%
  html_nodes(table) %>%
  html_table()

</code>```

Running this code gives me an empty list. My intention is to scrape the second table on the page. Scraping the first table works regardless of which method I use, but getting the second one is impossible. I am getting really annoyed because there is no logical reason for this to be happening.

IF I replaced
table <- "table#roster"
with
table <-"table#starters"
then the code effectively reads in the first table from the website.

Body:
I am trying to scrape data from football reference using this code:

season<-2020
team<-"nwe"
html<-paste("https://www.pro-football-reference.com/teams/",team,"/",season,"_roster.htm", sep="")
x<-read_csv(html)
table <- "table#roster"

html %>%
  read_html() %>%
  html_nodes(table) %>%
  html_table()

Running this code gives me an empty list. My intention is to scrape the second table on the page. Scraping the first table works regardless of which method I use, but getting the second one is impossible. I am getting really annoyed because there is no logical reason for this to be happening.

IF I replaced
table <- "table#roster"
with
table <-"table#starters"
then the code effectively reads in the first table from the website.


问:
How to know when user is about to leave app?
I am currently working on locking my app with face id/touch id when user moves away from the app.
I would like to cover the app with my splash screen when user is about to close the app. The "issue" right now is that onPause is called when the app is fully closed which means that users can see what the app looks like when going to the "open apps gallery" or whatever to call it. I would like to fire some function to show my launch screen before the app is fully paused.
Does this make sense? How can I do this?</p>


问:
Why does the accuracy fluctuate widely after using batch normalization
I'm training a model which includes batch normalization layer, but i noticed that the accuracy can fluctuate widely (from 55% to 31% in just one epoch), both train accuracy and test accuracy, so i think it's not caused by overfitting.

This is my accuracy over epoch

This is joint graph

This is my model architecture

```<code>    return nn.Sequential(
        nn.Conv2d(3,64,kernel_size=7,stride=2,padding=3),
        nn.BatchNorm2d(64,momentum=momentum),
        nn.ReLU(),
        nn.MaxPool2d(kernel_size=3,stride=2,padding=1),
        Residual(64, 64),
        Residual(64, 64),
        Residual(64, 128, use_1x1=True, stride=2),
        Residual(128, 128),
        Residual(128, 256, use_1x1=True, stride=2),
        Residual(256, 256),
        Residual(256, 512, use_1x1=True, stride=2),
        Residual(512, 512),
        nn.AdaptiveAvgPool2d((1, 1)),
        nn.Flatten(),
        nn.Linear(512, 176)
    ).to(device)
</code>```
```<code>class Residual(nn.Module):
    def __init__(self,input_channel,output_channel,use_1x1=False,stride=1):
        super().__init__()
        self.conv1=nn.Conv2d(input_channel,output_channel,kernel_size=3,padding=1,stride=stride)
        self.conv2=nn.Conv2d(output_channel,output_channel,kernel_size=3,padding=1)
        self.bn1=nn.BatchNorm2d(output_channel,momentum=momentum)
        self.bn2=nn.BatchNorm2d(output_channel,momentum=momentum)

        if use_1x1:
            self.conv3=nn.Conv2d(input_channel,output_channel,kernel_size=1,stride=stride)
        else:
            self.conv3=None

    def forward(self,X):
        Y=F.relu(self.bn1(self.conv1(X)))
        Y=self.bn2(self.conv2(Y))
        if self.conv3 is not None:
            X=self.conv3(X)
        Y += X
        return F.relu(Y)
</code>```

But magically, if i don't call model.eval() in the accuracy evaluation function, which keeps the running_mean and running_var updating, the accuracy won't fluctuate
Furthermore, if i go through the training set after each epoch, as is shown in the code below

```<code>    for epoch in range(epochs):
        net.train()
        for X, y in train_iter:
            optimizer.zero_grad()
            y_hat = net(X)
            l = loss(y_hat, y)
            l.backward()
            optimizer.step()

        for X,y in train_iter:
            net(X)

        eval_accuracy()
</code>```

the accuracy doesn't fluctuate, too

I've tried to change the momentum, but it doesn't work
Now i'm totally confused, i don't have any idea why the accuracy fluctuates and why the method above works

Body:
I'm training a model which includes batch normalization layer, but i noticed that the accuracy can fluctuate widely (from 55% to 31% in just one epoch), both train accuracy and test accuracy, so i think it's not caused by overfitting.

This is my accuracy over epoch

This is joint graph

This is my model architecture

    return nn.Sequential(
        nn.Conv2d(3,64,kernel_size=7,stride=2,padding=3),
        nn.BatchNorm2d(64,momentum=momentum),
        nn.ReLU(),
        nn.MaxPool2d(kernel_size=3,stride=2,padding=1),
        Residual(64, 64),
        Residual(64, 64),
        Residual(64, 128, use_1x1=True, stride=2),
        Residual(128, 128),
        Residual(128, 256, use_1x1=True, stride=2),
        Residual(256, 256),
        Residual(256, 512, use_1x1=True, stride=2),
        Residual(512, 512),
        nn.AdaptiveAvgPool2d((1, 1)),
        nn.Flatten(),
        nn.Linear(512, 176)
    ).to(device)

class Residual(nn.Module):
    def __init__(self,input_channel,output_channel,use_1x1=False,stride=1):
        super().__init__()
        self.conv1=nn.Conv2d(input_channel,output_channel,kernel_size=3,padding=1,stride=stride)
        self.conv2=nn.Conv2d(output_channel,output_channel,kernel_size=3,padding=1)
        self.bn1=nn.BatchNorm2d(output_channel,momentum=momentum)
        self.bn2=nn.BatchNorm2d(output_channel,momentum=momentum)

        if use_1x1:
            self.conv3=nn.Conv2d(input_channel,output_channel,kernel_size=1,stride=stride)
        else:
            self.conv3=None

    def forward(self,X):
        Y=F.relu(self.bn1(self.conv1(X)))
        Y=self.bn2(self.conv2(Y))
        if self.conv3 is not None:
            X=self.conv3(X)
        Y += X
        return F.relu(Y)

But magically, if i don't call model.eval() in the accuracy evaluation function, which keeps the running_mean and running_var updating, the accuracy won't fluctuate
Furthermore, if i go through the training set after each epoch, as is shown in the code below

    for epoch in range(epochs):
        net.train()
        for X, y in train_iter:
            optimizer.zero_grad()
            y_hat = net(X)
            l = loss(y_hat, y)
            l.backward()
            optimizer.step()

        for X,y in train_iter:
            net(X)

        eval_accuracy()

the accuracy doesn't fluctuate, too

I've tried to change the momentum, but it doesn't work
Now i'm totally confused, i don't have any idea why the accuracy fluctuates and why the method above works


问:
Can I call data-bs-target after response data is true?
'My vue code like this :'

```<code><teleport to="body">
  <div v-show="success" id="msgModal" class="modal fade" tabindex="-1">
    <div class="modal-dialog modal-dialog-centered modal-dialog-scrollable">
      <div class="modal-content">
        <div class="modal-header bg-light">
          <h5 class="modal-title">applyed successed!</h5>
          <button type="button" data-bs-dismiss="modal" aria-label="Close">
            <font-awesome-icon icon="times" />
          </button>
        </div
      </div>
    </div>
  </div>
</teleport>

<script>
   function callBackEndFunc(){

   if(condition){
     api.apiMethod1({})
         .then(() => {
          alert("success!");
         //want to call  data-bs-target="#msgModal"
       });
   }
}
</script>
</code>```

When callBackEndFunc was called and after ajax success
want to want to call  data-bs-target="#msgModal" to show div message in #msgModal.

Can anyone give me some advisor how to solve this problem?

Body:
'My vue code like this :'

<teleport to="body">

applyed successed!

          <button type="button" data-bs-dismiss="modal" aria-label="Close">

          </button>
        </div

</teleport>

When callBackEndFunc was called and after ajax success
want to want to call  data-bs-target="#msgModal" to show div message in #msgModal.

Can anyone give me some advisor how to solve this problem?


问:
How to send encrypted Devise OmniAuth credentials
I have a Next.js app that runs on localhost:3001 and a Rails API server that runs on localhost:3000

I am able to initiate the OAuth flow. The callback gets handled by my Rails app and creates a User instance with an email and encrypted password.

I have tried sharing a cookie across all subdomains, but this does not work because two different ports are considered two different domains.

I considered sending the encrypted password as a URL param, but this could be seen clearly in plain text.


问:
Does MongoDB store keys of repetetive entries every time? Best way to store thousands of data-rows that are always accessed together
I am planning to create a Collection of "users" in MongoDB consisting of documents like this:

```<code>{
    "name": "Example",
    "age": 100,
    "data": [
        {
            "key1": value1,
            "key2": value2,
            "key3": value3
        },
        {
            "key1": value1,
            "key2": value2,
            "key3": value3
        },
        {
            "key1": value1,
            "key2": value2,
            "key3": value3
        }
    ]
}
</code>```

with the "data"-array containing tens of thousands of entries. All entries have the same structure with identical keys. Does MongoDB really store the Strings I use as keys for every single element in the array? As the values are small numbers, the repetetive keys would consume more storage space than the values.

I am uncertain whether to use a schemafull oder schemaless db for this. The elements in "data" are added one by one (1 every second) and in series (no random writes). If I want to do something with the "data", I always need all data-entries of a user at the same time. If I would use a schemafull database, I would have a giant table with the entries of "data" associating them with a userId. It feels a bit wrong to write thousands of entries in individual rows and always accessing them together. Is there a good way to basically do a relation-free schemaful table inside of MongoDB documents? Or a schemaful database to store thousands of entries grouped together?

Do you have ideas or suggestions?

Body:
I am planning to create a Collection of "users" in MongoDB consisting of documents like this:

{
    "name": "Example",
    "age": 100,
    "data": [
        {
            "key1": value1,
            "key2": value2,
            "key3": value3
        },
        {
            "key1": value1,
            "key2": value2,
            "key3": value3
        },
        {
            "key1": value1,
            "key2": value2,
            "key3": value3
        }
    ]
}

with the "data"-array containing tens of thousands of entries. All entries have the same structure with identical keys. Does MongoDB really store the Strings I use as keys for every single element in the array? As the values are small numbers, the repetetive keys would consume more storage space than the values.

I am uncertain whether to use a schemafull oder schemaless db for this. The elements in "data" are added one by one (1 every second) and in series (no random writes). If I want to do something with the "data", I always need all data-entries of a user at the same time. If I would use a schemafull database, I would have a giant table with the entries of "data" associating them with a userId. It feels a bit wrong to write thousands of entries in individual rows and always accessing them together. Is there a good way to basically do a relation-free schemaful table inside of MongoDB documents? Or a schemaful database to store thousands of entries grouped together?

Do you have ideas or suggestions?


问:
How to correctly parse Json Objects from text Stream delimited by new lines
I have written some code to read JSON objects from a stream returned from a fetch API. However, I am unable to successfully parse out the JSON objects successfully. I want return the JSON objects from the chunks in a array and feed the results to a transformer that will apply some custom transformation the the final JSON. However, I am unable to deal with the partial chunks that result from the chunks after splitting the chunks into new lines. My main problem is I don't know how the chunking format looks from the data returned in the stream. I have written some code which does not work entirely. I am looking for some help to get it parsing out all the JSON objects.  Here is my code that attempts to do that. First, I wrote an async iterator that works fine. Next, i use that to split the chunks into new lines

             function streamAsyncIterator(stream) {
                const reader = stream.pipeThrough(new TextDecoderStream()).getReader();

                return {
                  next() {
                  return reader.read();
                },

               return() {
                 reader.releaseLock();
                 return {};
               },
              [Symbol.asyncIterator]() {
              return this;
             }
           };
          }

```
<p>Next, I use the iterator to to get new lines to convert to JSON objects; Here is that code, which partially works:</p>
<pre class="lang-js prettyprint-override"><code>
                   const fetchProductsStream = async () => {
                     const body = {
                        searchRange: ['fragrance', 'perfumery', 'cologne'],
                        exclusionCategory: ['discounted']
                     }
                     let time1 = performance.now();

                     const response = await fetch('/products/stream', {
                       method: 'POST',
                        body: JSON.stringify(body)
                      });
                     let chunkCount = 0;
                     let remaining = "";
                     let currentChunk = "";
                     let totalItems = 0;

                    for await (const chunk of streamAsyncIterator(response.body)) {
                      let items = [];
                      try{
                        currentChunk = chunk;
                        let lastIndex;
                        if(remaining.trim().length > 1){
                          currentChunk = remaining + chunk;
                       }
                      currentChunk.split(/\r?\n/).forEach((line, index) => {
                         try{
                           items.push(JSON.parse(line));
                           console.log(`Pushed line ${line} to items array`);
                           lastIndex = index;
                         }catch(err){
                           console.error(`Error is ${err}`);
                         }
                       })
                           totalItems += items.length;
                           remaining = "";

                           let i = currentChunk.indexOf(lastIndex);
                           if(i != -1){
                            remaining = currentChunk.substring(lastIndex);
                           }
                           items = [];

                         }catch(error){
                          console.log(error);
                        }
                        chunkCount++;
                      }

                        let time2 = performance.now();
                        console.log(`Total number of items is ${totalItems}`);
                        console.log(`Total number of chunks :: ${chunkCount} in time
                         ${(time2 - time1)/1000} seconds`)
                   }

</code>```

Here is what a sample looks like

"{"productId":"1671","category":"fragrance","categoryId":1WW23,"productName":"Paco Rabane","productClass":"M","warehouseCode":"1242","alternateName":"ALT_ELL332"}\n{"productId":"1671","category":"fragrance","categoryId":1WW23,"productName":"Paco Rabane","productClass":"M","warehouseCode":"1242","alternateName":"ALT_ELL332"}\n{"productId":"1671","category":"fragrance","categoryId":1WW23,"productName":"Paco Rabane","productClass":"M","warehouseCode":"1242","alternateName":"ALT_ELL332","category":{"desc":"1654 Cologne Perfume","code":"221","feature":"1","salesCode":"S2237"}\n{"productId":"1671","category":"fragrance","categoryId":1WW23,"productName":"Paco Rabane","productClass":"M","warehouseCode":"1242","alternateName":"ALT_ELL332"}"

```<code>This is my attempt, which does not work perfectly, since there are some json objects that are not correctly parsed. Most of them are, so I'd appreciate some help in getting it to work perfectly. If there is a better way to do it, I will also be grateful for that solution.
</code>```

Body:
I have written some code to read JSON objects from a stream returned from a fetch API. However, I am unable to successfully parse out the JSON objects successfully. I want return the JSON objects from the chunks in a array and feed the results to a transformer that will apply some custom transformation the the final JSON. However, I am unable to deal with the partial chunks that result from the chunks after splitting the chunks into new lines. My main problem is I don't know how the chunking format looks from the data returned in the stream. I have written some code which does not work entirely. I am looking for some help to get it parsing out all the JSON objects.  Here is my code that attempts to do that. First, I wrote an async iterator that works fine. Next, i use that to split the chunks into new lines

             function streamAsyncIterator(stream) {
                const reader = stream.pipeThrough(new TextDecoderStream()).getReader();

                return {
                  next() {
                  return reader.read();
                },

               return() {
                 reader.releaseLock();
                 return {};
               },
              [Symbol.asyncIterator]() {
              return this;
             }
           };
          }

Next, I use the iterator to to get new lines to convert to JSON objects; Here is that code, which partially works:

                   const fetchProductsStream = async () => {
                     const body = {
                        searchRange: ['fragrance', 'perfumery', 'cologne'],
                        exclusionCategory: ['discounted']
                     }
                     let time1 = performance.now();

                     const response = await fetch('/products/stream', {
                       method: 'POST',
                        body: JSON.stringify(body)
                      });
                     let chunkCount = 0;
                     let remaining = "";
                     let currentChunk = "";
                     let totalItems = 0;

                    for await (const chunk of streamAsyncIterator(response.body)) {
                      let items = [];
                      try{
                        currentChunk = chunk;
                        let lastIndex;
                        if(remaining.trim().length > 1){
                          currentChunk = remaining + chunk;
                       }
                      currentChunk.split(/\r?\n/).forEach((line, index) => {
                         try{
                           items.push(JSON.parse(line));
                           console.log(`Pushed line ${line} to items array`);
                           lastIndex = index;
                         }catch(err){
                           console.error(`Error is ${err}`);
                         }
                       })
                           totalItems += items.length;
                           remaining = "";

                           let i = currentChunk.indexOf(lastIndex);
                           if(i != -1){
                            remaining = currentChunk.substring(lastIndex);
                           }
                           items = [];

                         }catch(error){
                          console.log(error);
                        }
                        chunkCount++;
                      }

                        let time2 = performance.now();
                        console.log(`Total number of items is ${totalItems}`);
                        console.log(`Total number of chunks :: ${chunkCount} in time
                         ${(time2 - time1)/1000} seconds`)
                   }

Here is what a sample looks like

"{"productId":"1671","category":"fragrance","categoryId":1WW23,"productName":"Paco Rabane","productClass":"M","warehouseCode":"1242","alternateName":"ALT_ELL332"}\n{"productId":"1671","category":"fragrance","categoryId":1WW23,"productName":"Paco Rabane","productClass":"M","warehouseCode":"1242","alternateName":"ALT_ELL332"}\n{"productId":"1671","category":"fragrance","categoryId":1WW23,"productName":"Paco Rabane","productClass":"M","warehouseCode":"1242","alternateName":"ALT_ELL332","category":{"desc":"1654 Cologne Perfume","code":"221","feature":"1","salesCode":"S2237"}\n{"productId":"1671","category":"fragrance","categoryId":1WW23,"productName":"Paco Rabane","productClass":"M","warehouseCode":"1242","alternateName":"ALT_ELL332"}"

This is my attempt, which does not work perfectly, since there are some json objects that are not correctly parsed. Most of them are, so I'd appreciate some help in getting it to work perfectly. If there is a better way to do it, I will also be grateful for that solution.


问:
how do I add code to react-syntax-highlighter tag from a different component
I have a React component called "UploadButton" that allows a user to select and upload a ZIP file. When the file is uploaded, the component extracts a specific JSON file from the ZIP and converts it into a string. I need to find a way to display this JSON string data in a SyntaxHighlighter component, but when I try to use the append or prepend methods to add the data to the SyntaxHighlighter, the JSON is displayed as plain text without any syntax highlighting or markup. How can I properly display the JSON string data in the SyntaxHighlighter component with proper syntax highlighting and markup applied?

here is some of my code.

```<code>return (
   <div className="App">

      <SideNav></SideNav>
      <TopBar className="home_content"></TopBar>

      <div className="Panels">
        <div className="jsonPanel">
          <SyntaxHighlighter id="jsonText" language="JSON" style={docco}>

          </SyntaxHighlighter>
        </div>
        <div className="infopanel">
          details
        </div>
      </div>
    </div>
  );
}
</code>```

and here is the function that is call from UploadButton to add the code value.

```<code>const appendflowData = (data) => {

    alert("file uploaded ")

    $("#jsonText").prepend(JSON.stringify(data,undefined,4))

}
</code>```

Body:
I have a React component called "UploadButton" that allows a user to select and upload a ZIP file. When the file is uploaded, the component extracts a specific JSON file from the ZIP and converts it into a string. I need to find a way to display this JSON string data in a SyntaxHighlighter component, but when I try to use the append or prepend methods to add the data to the SyntaxHighlighter, the JSON is displayed as plain text without any syntax highlighting or markup. How can I properly display the JSON string data in the SyntaxHighlighter component with proper syntax highlighting and markup applied?

here is some of my code.

return (

      <SideNav></SideNav>
      <TopBar className="home_content"></TopBar>

          <SyntaxHighlighter id="jsonText" language="JSON" style={docco}>

          </SyntaxHighlighter>

          details

  );
}

and here is the function that is call from UploadButton to add the code value.

const appendflowData = (data) => {

    alert("file uploaded ")

    $("#jsonText").prepend(JSON.stringify(data,undefined,4))

}


问:
MongoDB query is slow on first view runs, but then dramatically speeds up afterwards
My MongoDB Atlas collection has 1 million documents and about 10 indexes.

I have a query that has arbitrary filter conditions.

I notice that sometimes whenever I create a new set of filter conditions it runs really slowly in the first 4 or 5 runs, taking about 16 seconds to return. But then afterwards, it speeds up dramatically and only take about 1 or 2 seconds to return.

What explains?


问:
Cupy DLL load failed
I am trying to use cupy to speed up some background numpy operations in my python code but when attempting to import cupy I am told that the DLL load failed, importError: DLL load failed.

I am fairly inexperienced when it comes to handling things like this so any help would be greatly appreciated. The entire error message and trace is copied below:

when I tried pip install cupy-cuda112, cupy import is working but pytorch import is not working.

```<code>Error loading "C:\Users\CT1\miniconda3\envs\DentiumRIP\lib\site-packages\torch\lib\cublas64_11.dll" or one of its dependencies.
</code>```

And, when I do conda install pytorch torchvision torchaudio cudatoolkit=11.2 -c pytorch -c conda-forge, the cupy import doesn't work.

please tell me how to fix it..

```<code>Failed to import CuPy.

If you installed CuPy via wheels (cupy-cudaXXX or cupy-rocm-X-X), make sure that the package matches with the version of CUDA or ROCm installed.

On Linux, you may need to set LD_LIBRARY_PATH environment variable depending on how you installed CUDA/ROCm.
On Windows, try setting CUDA_PATH environment variable.

Check the Installation Guide for details:
  https://docs.cupy.dev/en/latest/install.html

Original error:
  ImportError: DLL load failed: 지정된 프로시저를 찾을 수 없습니다.
</code>```

Title: Cupy DLL load failed

Body:
I am trying to use cupy to speed up some background numpy operations in my python code but when attempting to import cupy I am told that the DLL load failed, importError: DLL load failed.

I am fairly inexperienced when it comes to handling things like this so any help would be greatly appreciated. The entire error message and trace is copied below:

when I tried pip install cupy-cuda112, cupy import is working but pytorch import is not working.

Error loading "C:\Users\CT1\miniconda3\envs\DentiumRIP\lib\site-packages\torch\lib\cublas64_11.dll" or one of its dependencies.

And, when I do conda install pytorch torchvision torchaudio cudatoolkit=11.2 -c pytorch -c conda-forge, the cupy import doesn't work.

please tell me how to fix it..

Failed to import CuPy.

If you installed CuPy via wheels (cupy-cudaXXX or cupy-rocm-X-X), make sure that the package matches with the version of CUDA or ROCm installed.

On Linux, you may need to set LD_LIBRARY_PATH environment variable depending on how you installed CUDA/ROCm.
On Windows, try setting CUDA_PATH environment variable.

Check the Installation Guide for details:
  https://docs.cupy.dev/en/latest/install.html

Original error:
  ImportError: DLL load failed: 지정된 프로시저를 찾을 수 없습니다.


问:
dotnet ef database update not creating tables from existing migrations in EF Core and .NET 6
I'm trying to add tables via my existing migrations so I can work on this locally on another machine.

I'm running the dotnet ef database update command in the terminal, but it doesn't create any of the tables - it only gets as far as:

```<code>Build started...
Build succeeded.
info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
      Entity Framework Core 6.0.7 initialized 'PingContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer:6.0.7' with options: None
</code>```

and that's the end of the command. It doesn't create the tables at all.

Any ideas?

Body:
I'm trying to add tables via my existing migrations so I can work on this locally on another machine.

I'm running the dotnet ef database update command in the terminal, but it doesn't create any of the tables - it only gets as far as:

Build started...
Build succeeded.
info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
      Entity Framework Core 6.0.7 initialized 'PingContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer:6.0.7' with options: None

and that's the end of the command. It doesn't create the tables at all.

Any ideas?


问:
Looking for file in javascripts folder but now is javascript folder in Rails 7 jsbundling-rails
I'm getting the error GET http://localhost:3000/javascripts/olLocationMap.js net::ERR_ABORTED 404 (Not Found)

The file is in javascript and does load however.

What is telling Rails to look in /javascripts and how do I get rid of it? I have enough errors already! javascripts appears no where in my application code.


问:
Error: Chunks are uploading as empty strings
I have WP and whenever I try to uplod 2-7GB mp4 video file I get that error...

enter image description here


问:
Why is the response sometimes passing through and sometimes not when using requests httpx in python?
I am trying to scrape this website items, however when I used httpx or even requests sometimes it passes and gets the response sometimes it doesn't. It seems random, that's why I tried doing a rerun of the failed items to get the results. However this does not seem to work 100% of all the time. Is there something that I am not doing right? Can somebody help?

Below is a sample of the web I am scraping, if it does not show any errors you can loop it to scrape the same thing twice.

Here's my current code:

```<code>urllist=['https://www.blibli.com/backend/product-detail/products/ps--RAM-70107-16912/_summary?defaultItemSku=RAM-70107-16912-00001&pickupPointCode=PP-3239816&cnc=false',
'https://www.blibli.com/backend/product-detail/products/ps--RAM-70107-04124/_summary?defaultItemSku=RAM-70107-04124-00001&pickupPointCode=PP-3239816&cnc=false',
'https://www.blibli.com/backend/product-detail/products/ps--RAM-70107-19598/_summary?defaultItemSku=RAM-70107-19598-00001&pickupPointCode=PP-3239816&cnc=false',
'https://www.blibli.com/backend/product-detail/products/ps--RAM-70107-01115/_summary?defaultItemSku=RAM-70107-01115-00001&pickupPointCode=PP-3206709&cnc=false',
'https://www.blibli.com/backend/product-detail/products/ps--RAM-70107-02620/_summary?defaultItemSku=RAM-70107-02620-00001&pickupPointCode=PP-3239816&cnc=false',
'https://www.blibli.com/backend/product-detail/products/ps--RAM-70107-17552/_summary?defaultItemSku=RAM-70107-17552-00001&pickupPointCode=PP-3023611&cnc=false',
'https://www.blibli.com/backend/product-detail/products/ps--RAM-70107-08377/_summary?defaultItemSku=RAM-70107-08377-00001&pickupPointCode=PP-3239816&cnc=false',
'https://www.blibli.com/backend/product-detail/products/ps--RAM-70107-03274/_summary?defaultItemSku=RAM-70107-03274-00001&pickupPointCode=PP-3069769&cnc=false',
'https://www.blibli.com/backend/product-detail/products/ps--RAM-70107-04345/_summary?defaultItemSku=RAM-70107-04345-00001&pickupPointCode=PP-3239816&cnc=false',
'https://www.blibli.com/backend/product-detail/products/ps--RAM-70107-01030/_summary?defaultItemSku=RAM-70107-01030-00001&pickupPointCode=PP-3239816&cnc=false',
'https://www.blibli.com/backend/product-detail/products/ps--RAM-70107-01534/_summary?defaultItemSku=RAM-70107-01534-00001&pickupPointCode=PP-3239816&cnc=false']

rancherrors=pd.DataFrame()
ranchdf=pd.DataFrame()
    for url in urllist:
     try:
            ua = UserAgent()
            USER_AGENT = ua.random
            headers={
                "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
                "accept-encoding": "gzip, deflate, br",
                "accept-language": "id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7",
                "cache-control": "max-age=0",
                "sec-ch-ua": 'Chromium";v="106", "Google Chrome";v="106", "Not;A=Brand";v="99',
                "sec-ch-ua-platform": "Windows",
                "sec-fetch-dest": "document",
                "sec-fetch-mode": "navigate",
                "sec-fetch-site": "none",
                'X-Forwarded-For': f'{random_ip}',
                "user-agent" : f"{USER_AGENT}",
                'referer':'https://www.blibli.com/'
                }
            response =httpx.get(url,headers=headers)

        try:
            price=str(response.json()['data']['price']['listed']).replace(".0","")
            discount=str(response.json()['data']['price']['totalDiscount'])
        except:
            price="0"
            discount="0"
        try:
            unit=str(response.json()['data']['uniqueSellingPoint']).replace("• ","")
        except:
            unit=""

        dat={
            'product_name':response.json()['data']['name'],
            'normal_price':price,
            'discount':discount,
            'competitor_id':response.json()['data']['ean'],
            'url':input,
            'unit':unit,
            'astro_id':id,
            'date_key':today,
            'web':'ranch market'
            }
        dat=pd.DataFrame([dat])
        ranchdf=ranchdf.append(dat)
        sleep(randint(2,5))
    except Exception as e:
        datum={
            'id':id,
            'url':url
        }
        datum=pd.DataFrame([datum])
        rancherrors=rancherrors.append(datum)
        print(f'{url} error {e}')
</code>```

Body:
I am trying to scrape this website items, however when I used httpx or even requests sometimes it passes and gets the response sometimes it doesn't. It seems random, that's why I tried doing a rerun of the failed items to get the results. However this does not seem to work 100% of all the time. Is there something that I am not doing right? Can somebody help?

Below is a sample of the web I am scraping, if it does not show any errors you can loop it to scrape the same thing twice.

Here's my current code:

urllist=['https://www.blibli.com/backend/product-detail/products/ps--RAM-70107-16912/_summary?defaultItemSku=RAM-70107-16912-00001&pickupPointCode=PP-3239816&cnc=false',
'https://www.blibli.com/backend/product-detail/products/ps--RAM-70107-04124/_summary?defaultItemSku=RAM-70107-04124-00001&pickupPointCode=PP-3239816&cnc=false',
'https://www.blibli.com/backend/product-detail/products/ps--RAM-70107-19598/_summary?defaultItemSku=RAM-70107-19598-00001&pickupPointCode=PP-3239816&cnc=false',
'https://www.blibli.com/backend/product-detail/products/ps--RAM-70107-01115/_summary?defaultItemSku=RAM-70107-01115-00001&pickupPointCode=PP-3206709&cnc=false',
'https://www.blibli.com/backend/product-detail/products/ps--RAM-70107-02620/_summary?defaultItemSku=RAM-70107-02620-00001&pickupPointCode=PP-3239816&cnc=false',
'https://www.blibli.com/backend/product-detail/products/ps--RAM-70107-17552/_summary?defaultItemSku=RAM-70107-17552-00001&pickupPointCode=PP-3023611&cnc=false',
'https://www.blibli.com/backend/product-detail/products/ps--RAM-70107-08377/_summary?defaultItemSku=RAM-70107-08377-00001&pickupPointCode=PP-3239816&cnc=false',
'https://www.blibli.com/backend/product-detail/products/ps--RAM-70107-03274/_summary?defaultItemSku=RAM-70107-03274-00001&pickupPointCode=PP-3069769&cnc=false',
'https://www.blibli.com/backend/product-detail/products/ps--RAM-70107-04345/_summary?defaultItemSku=RAM-70107-04345-00001&pickupPointCode=PP-3239816&cnc=false',
'https://www.blibli.com/backend/product-detail/products/ps--RAM-70107-01030/_summary?defaultItemSku=RAM-70107-01030-00001&pickupPointCode=PP-3239816&cnc=false',
'https://www.blibli.com/backend/product-detail/products/ps--RAM-70107-01534/_summary?defaultItemSku=RAM-70107-01534-00001&pickupPointCode=PP-3239816&cnc=false']

rancherrors=pd.DataFrame()
ranchdf=pd.DataFrame()
    for url in urllist:
     try:
            ua = UserAgent()
            USER_AGENT = ua.random
            headers={
                "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
                "accept-encoding": "gzip, deflate, br",
                "accept-language": "id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7",
                "cache-control": "max-age=0",
                "sec-ch-ua": 'Chromium";v="106", "Google Chrome";v="106", "Not;A=Brand";v="99',
                "sec-ch-ua-platform": "Windows",
                "sec-fetch-dest": "document",
                "sec-fetch-mode": "navigate",
                "sec-fetch-site": "none",
                'X-Forwarded-For': f'{random_ip}',
                "user-agent" : f"{USER_AGENT}",
                'referer':'https://www.blibli.com/'
                }
            response =httpx.get(url,headers=headers)

        try:
            price=str(response.json()['data']['price']['listed']).replace(".0","")
            discount=str(response.json()['data']['price']['totalDiscount'])
        except:
            price="0"
            discount="0"
        try:
            unit=str(response.json()['data']['uniqueSellingPoint']).replace("• ","")
        except:
            unit=""

        dat={
            'product_name':response.json()['data']['name'],
            'normal_price':price,
            'discount':discount,
            'competitor_id':response.json()['data']['ean'],
            'url':input,
            'unit':unit,
            'astro_id':id,
            'date_key':today,
            'web':'ranch market'
            }
        dat=pd.DataFrame([dat])
        ranchdf=ranchdf.append(dat)
        sleep(randint(2,5))
    except Exception as e:
        datum={
            'id':id,
            'url':url
        }
        datum=pd.DataFrame([datum])
        rancherrors=rancherrors.append(datum)
        print(f'{url} error {e}')


问:
error encountered while pip installing SPAMS
While doing pip install SPAMS, I encountered the following error:

```<code>(base) C:\Users\Foram>pip install spams
Collecting spams
  Using cached spams-2.6.5.4.tar.gz (2.0 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: Pillow>=6.0 in c:\users\foram\anaconda3\lib\site-packages (from spams) (8.0.1)
Requirement already satisfied: scipy>=1.0 in c:\users\foram\appdata\roaming\python\python38\site-packages (from spams) (1.4.1)
Requirement already satisfied: numpy>=1.12 in c:\users\foram\anaconda3\lib\site-packages (from spams) (1.21.2)
Building wheels for collected packages: spams
  Building wheel for spams (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for spams (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [29 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-cpython-38
      creating build\lib.win-amd64-cpython-38\spams_wrap
      copying spams_wrap\spams_wrap.py -> build\lib.win-amd64-cpython-38\spams_wrap
      copying spams_wrap\__init__.py -> build\lib.win-amd64-cpython-38\spams_wrap
      creating build\lib.win-amd64-cpython-38\spams
      copying spams\spams.py -> build\lib.win-amd64-cpython-38\spams
      copying spams\__init__.py -> build\lib.win-amd64-cpython-38\spams
      creating build\lib.win-amd64-cpython-38\spams\tests
      copying spams\tests\run.py -> build\lib.win-amd64-cpython-38\spams\tests
      copying spams\tests\test_decomp.py -> build\lib.win-amd64-cpython-38\spams\tests
      copying spams\tests\test_dictLearn.py -> build\lib.win-amd64-cpython-38\spams\tests
      copying spams\tests\test_linalg.py -> build\lib.win-amd64-cpython-38\spams\tests
      copying spams\tests\test_prox.py -> build\lib.win-amd64-cpython-38\spams\tests
      copying spams\tests\test_spams.py -> build\lib.win-amd64-cpython-38\spams\tests
      copying spams\tests\test_utils.py -> build\lib.win-amd64-cpython-38\spams\tests
      copying spams\tests\__init__.py -> build\lib.win-amd64-cpython-38\spams\tests
      creating build\lib.win-amd64-cpython-38\spams\data
      copying spams\data\boat.png -> build\lib.win-amd64-cpython-38\spams\data
      copying spams\data\lena.png -> build\lib.win-amd64-cpython-38\spams\data
      copying spams\version -> build\lib.win-amd64-cpython-38\spams
      running build_ext
      cl : Command line error D8021 : invalid numeric argument '/Wunused-variable'
      C:\Users\Foram\AppData\Local\Temp\pip-build-env-t_3qg0ji\overlay\Lib\site-packages\setuptools\_distutils\_msvccompiler.py:539: UserWarning: Fallback spawn triggered. Please update distutils monkeypatch.
        warnings.warn("Fallback spawn triggered. Please update distutils monkeypatch.")
      error: Command "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\bin\HostX86\x64\cl.exe /c /nologo /O2 /W3 /GL /DNDEBUG /MD -Ispams_wrap -Ispams_wrap\linalg -Ispams_wrap\prox -Ispams_wrap\decomp -Ispams_wrap\dictLearn -IC:\Users\Foram\AppData\Local\Temp\pip-build-env-t_3qg0ji\overlay\Lib\site-packages\numpy\core\include -Ic:\users\foram\anaconda3\include -Ic:\users\foram\anaconda3\include -Ic:\users\foram\anaconda3\include -Ic:\users\foram\anaconda3\Include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\include -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt /EHsc /Tpspams_wrap/spams_wrap.cpp /Fobuild\temp.win-amd64-cpython-38\Release\spams_wrap\spams_wrap.obj -DNDEBUG -DUSE_BLAS_LIB -std=c++11 -fPIC -Wunused-variable -Wno-uninitialized -m64" failed with exit status 2
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for spams
Failed to build spams
ERROR: Could not build wheels for spams, which is required to install pyproject.toml-based projects
</code>```

I tried searching solutions for the following:

Command line error D8021 : invalid numeric argument '/Wunused-variable'

Fallback spawn triggered. Please update distutils monkeypatch.

Could not build wheels for spams, which is required to install pyproject.toml-based projects

However, I could not find any clear solution. It would be great, if I could get some help.
Specs for my system is
Windows-10 64 bit
Python 3.8.5

Body:
While doing pip install SPAMS, I encountered the following error:

(base) C:\Users\Foram>pip install spams
Collecting spams
  Using cached spams-2.6.5.4.tar.gz (2.0 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: Pillow>=6.0 in c:\users\foram\anaconda3\lib\site-packages (from spams) (8.0.1)
Requirement already satisfied: scipy>=1.0 in c:\users\foram\appdata\roaming\python\python38\site-packages (from spams) (1.4.1)
Requirement already satisfied: numpy>=1.12 in c:\users\foram\anaconda3\lib\site-packages (from spams) (1.21.2)
Building wheels for collected packages: spams
  Building wheel for spams (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for spams (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [29 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-cpython-38
      creating build\lib.win-amd64-cpython-38\spams_wrap
      copying spams_wrap\spams_wrap.py -> build\lib.win-amd64-cpython-38\spams_wrap
      copying spams_wrap\__init__.py -> build\lib.win-amd64-cpython-38\spams_wrap
      creating build\lib.win-amd64-cpython-38\spams
      copying spams\spams.py -> build\lib.win-amd64-cpython-38\spams
      copying spams\__init__.py -> build\lib.win-amd64-cpython-38\spams
      creating build\lib.win-amd64-cpython-38\spams\tests
      copying spams\tests\run.py -> build\lib.win-amd64-cpython-38\spams\tests
      copying spams\tests\test_decomp.py -> build\lib.win-amd64-cpython-38\spams\tests
      copying spams\tests\test_dictLearn.py -> build\lib.win-amd64-cpython-38\spams\tests
      copying spams\tests\test_linalg.py -> build\lib.win-amd64-cpython-38\spams\tests
      copying spams\tests\test_prox.py -> build\lib.win-amd64-cpython-38\spams\tests
      copying spams\tests\test_spams.py -> build\lib.win-amd64-cpython-38\spams\tests
      copying spams\tests\test_utils.py -> build\lib.win-amd64-cpython-38\spams\tests
      copying spams\tests\__init__.py -> build\lib.win-amd64-cpython-38\spams\tests
      creating build\lib.win-amd64-cpython-38\spams\data
      copying spams\data\boat.png -> build\lib.win-amd64-cpython-38\spams\data
      copying spams\data\lena.png -> build\lib.win-amd64-cpython-38\spams\data
      copying spams\version -> build\lib.win-amd64-cpython-38\spams
      running build_ext
      cl : Command line error D8021 : invalid numeric argument '/Wunused-variable'
      C:\Users\Foram\AppData\Local\Temp\pip-build-env-t_3qg0ji\overlay\Lib\site-packages\setuptools\_distutils\_msvccompiler.py:539: UserWarning: Fallback spawn triggered. Please update distutils monkeypatch.
        warnings.warn("Fallback spawn triggered. Please update distutils monkeypatch.")
      error: Command "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\bin\HostX86\x64\cl.exe /c /nologo /O2 /W3 /GL /DNDEBUG /MD -Ispams_wrap -Ispams_wrap\linalg -Ispams_wrap\prox -Ispams_wrap\decomp -Ispams_wrap\dictLearn -IC:\Users\Foram\AppData\Local\Temp\pip-build-env-t_3qg0ji\overlay\Lib\site-packages\numpy\core\include -Ic:\users\foram\anaconda3\include -Ic:\users\foram\anaconda3\include -Ic:\users\foram\anaconda3\include -Ic:\users\foram\anaconda3\Include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\include -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt /EHsc /Tpspams_wrap/spams_wrap.cpp /Fobuild\temp.win-amd64-cpython-38\Release\spams_wrap\spams_wrap.obj -DNDEBUG -DUSE_BLAS_LIB -std=c++11 -fPIC -Wunused-variable -Wno-uninitialized -m64" failed with exit status 2
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for spams
Failed to build spams
ERROR: Could not build wheels for spams, which is required to install pyproject.toml-based projects

I tried searching solutions for the following:

Command line error D8021 : invalid numeric argument '/Wunused-variable'

Fallback spawn triggered. Please update distutils monkeypatch.

Could not build wheels for spams, which is required to install pyproject.toml-based projects

However, I could not find any clear solution. It would be great, if I could get some help.
Specs for my system is
Windows-10 64 bit
Python 3.8.5


问:
Does Connection Pool Insert Rows to DB randomly or in a sequence?
I am implementing the connection pool in Python using psycopg2.pool. And my aim is to insert all the data frame like 100 rows into DB, would like to know if using DB connection pool, the rows inserted will be in random order or they will be inserted by sequence since I am iterating each row in data frame? Or to say if it can insert rows into DB some kind of simultaneously or it just can reduce the time between opening and closing each time running the query by using the connection pool, the running sequence actually not be affected?

Thanks


问:
The commit message pane of WebStorm is unable to edit
WebStorm 2021.1.3 on Windows.

I've tried to modify the setting params.


问:
Write different Unicode characters while CapsLock is active, by pressing key combination
I am trying to rewrite my formerly hotkey script to bash, so I can use it on Linux.

I am trying to do infinite while loop which check whether CapsLock is active or not.
If it is, the same key combination produces uppercase letter, if it is not, it produces the same letter, but lowercase.

```<code>#!/bin/bash

while :
do
read -n 1 a

if [[ 'CapsLock is active' ]]
then
  case $a in
    \033A*)     echo -e '\u00C5';; # Å
    \033E*)     echo -e '\u00C6';; # Æ
    \033O*)     echo -e '\u00D8';; # Ø
    \033U*)     echo -e '\u016E';; # Ů
   esac
else
  case $a in
    \033a*)     echo -e '\u00E5';; # å
    \033e*)     echo -e '\u00E6';; # æ
    \033o*)     echo -e '\u00F8';; # ø
    \033u*)     echo -e '\u016F';; # ů
   esac
fi
done
</code>```

I have two problems:

I don´t know how to write "when CapsLock is active, do this..."

How to write individual cases for each key combination (while pressing Alt+A (CapsLock active), write Å in text files, Alt+a -  write å, etc.)

And before you ask, yes, I did check if similar question/s has been posted and tried to find answers by myself. This is as far as I got.

Body:
I am trying to rewrite my formerly hotkey script to bash, so I can use it on Linux.

I am trying to do infinite while loop which check whether CapsLock is active or not.
If it is, the same key combination produces uppercase letter, if it is not, it produces the same letter, but lowercase.

#!/bin/bash

while :
do
read -n 1 a

if [[ 'CapsLock is active' ]]
then
  case $a in
    \033A*)     echo -e '\u00C5';; # Å
    \033E*)     echo -e '\u00C6';; # Æ
    \033O*)     echo -e '\u00D8';; # Ø
    \033U*)     echo -e '\u016E';; # Ů
   esac
else
  case $a in
    \033a*)     echo -e '\u00E5';; # å
    \033e*)     echo -e '\u00E6';; # æ
    \033o*)     echo -e '\u00F8';; # ø
    \033u*)     echo -e '\u016F';; # ů
   esac
fi
done

I have two problems:

I don´t know how to write "when CapsLock is active, do this..."

How to write individual cases for each key combination (while pressing Alt+A (CapsLock active), write Å in text files, Alt+a -  write å, etc.)

And before you ask, yes, I did check if similar question/s has been posted and tried to find answers by myself. This is as far as I got.


问:
Vagrant Up or init commands not working anymore

I have been learning to use vagrant recently, everything was going fine but now none of my vagrant commands work and gives me the same above error. I started having this error when I was learning vagrant provisioning


问:
Equivalent of xpath/xquery as to xml for css?
I want to search for content in a CSS file. The XPath/XQuery language is convenient for searching content in XML. How can I find an equivalent so that complex searches in CSS are easy?</p>


问:
Does the private blockchain have to follow client-server model when considering BFT?
I'm a newbie, currently interested in data security & integrity.

I'm quite new to blockchain and distributed system theories, and suffering from some unclear doubts/questions on the fault-tolerant consensus.

May I ask for your kind advice on my dull thoughts regarding on the blockchain's true objective?

It would be a great help for me to step forward on understading better concept of consensus.

Here's the summary of what I understand (please correct me if I'm wrong)

In a synchronous network model, it is assumed that one can guarantee the message being delivered within a certain amount of time.
In an asynchronous network model, there is no certain guarantee on the message delivery.

In a design perspective, it is easier & more efficient to design a system based on the synchronous model.
Even the quorum size requirement can be reduced - synchronous model needs only f+1 votes while asynchronous model needs 2f+1 votes on the consensus.
(This is because that the synchronous model can eliminate the possiblity of message dropout (up to f), while the async model needs to consider both message dropout & possibly malicious messages.)

But in a distributed system based on multiple nodes, it is normally impossible to guarantee the message delivery since there is no central manager who can monitor all nodes whether each receives the message or not.
That is why most of the blockchain-oriented distributed ledgers (non-currency) are based on the asynchronous consensus schemes such as PBFT (Castro, Liskov 99).

In a private blockchain scenario, I believe that the main & final purpose of the consensus is to let all nodes hold a chain of blocks, where each block has a certain amount of agreements (i.e. more than f signatures).

So, based on the facts above, I got curious whether the fault-tolerance model only stands for the standard "client-server" environment.

What happens if we give up the client-server model, and let the client supersede peers' broadcast communications? (For a scenario where the client has enough computation power but is just short on storage, so it wants to manage multiple (but few, e.g. 3) replicas to store data via transactions)

To be more specific with a simple example (an authenticated environment with PKI):

Each replica only performs a "block creation (+signing)" and "block finalization (verifying signatures)" logic, and there may exist some malicious replicas (up to f) which try to spread different outputs, which is not originated from the client's transaction.

Let the client (a "data owner/manager" would be a more suitable term now...) visit all replicas, and it handles each replica as below:

Enforce that all replicas work as a synchronized state machine; assure all 3 replicas are synced up (check the latest block of each, and supplement the lagged ones)

Sets a callback (with a timeout) for each replica to guarantee the message delivery

Send a transaction to all replicas, and receive the block (with a signature) generated from the corresponding transaction (assume that the block contains only one transaction)

If more than f signatures (from replicas) for the same block message are collected, deliver the collected signatures to all replicas and order them to finalize the block.

If we do as above, instead of replicas making consensus on their own (i.e. no view-changes), can we still say that the system suffices a BFT model?

It seems that byzantine replicas cannot breach safety, since the client (and honest replicas) will only order/accept block finalization when the block comes with more than f signatures.

The concern is the liveness - can we say that the liveness still holds, since the system can continue (not a client-server model anymore, but the "system" goes on) because the client will ignore the faulty replica response and order honest replicas to finalize?

This curiosity is just stuck in my head, and it's blocking me from clearly understanding why the private blockchain systems need asynchronous consensus process among peers themselves.

(since they already trust the client transactions, and participants are designated by PKI & signatures)

Could anyone be kind and inform that whether my dominant-client example can still suffice the BFT, or something would go wrong?

Thank you so much!


问:
How to merge two databases with the same tables and table columns but different database records?
I'm currently using Redmine Docker Image version 5.0.2 with Amazon RDS MySQL8.0.2 version,

when my Redmine was down, the only available database backup I had was from two weeks ago, however, after two days, I was able to get a much more recent database backup.

but now, Redmine is up and still currently being used, thus data are encoded but still missing data.

How can I merge those two databases, one from the old backup being used and another much more recent but not currently being used?


问:
Get search terms keywords from traffic source of video using Youtube Data Api v3
I want to get search keywords from traffic source of video using Youtube Data Api.

I can already view 8-10 on the Dashboard, but most of the time, the video is in 1000 views and although I see 7-8, the api returns empty or only takes one. how can i solve this problem? I will be glad if you help.


问:
Including React Components (Using React.Lazy or Next.JS Dynamic Import) that are bundled separately

I am building a Next.JS site that includes a bunch of modules that act as "mini-wizard" like experiences that allow people to learn about various topics. These modules though aren't just text though and include a lot of functionality and some api calls to my backend. I would like to maintain these separately and have them sit in something like an S3 bucket and then have the main next.js site (Deployed through AWS Amplify currently, but might switch to Vercel) dynamically import them.

So I'm wondering if it is possible to dynamically import a js file from a S3 bucket that is separate from the bundled Next.JS application? I know that is super vague statement and also makes no sense when you think about it technically, but I want to implement something where I can push code updates to one of these modules without having to redeploy the entire site and also prevent the site from becoming massive as we have 100s or 1000s of these modules. I looked at some of the micro-frontends documentation and it doesn't quite seem to solve this problem since I would like to include these components and provide them data utilizing useContext so they can function and interact with data that lives inside the main site.

I haven't had much success so far in trying any approach, but this is somewhat the implementation would look like in code:

```<code>import dynamic from 'next/dynamic';
import { useContext, createContext, useState } from 'react';

const RemoteLearningModule = dynamic(() => import('https://s3_bucket_domain.com/modules/module_123.js'), {
  loading: () => 'Loading...',
})

export default function ModuleDisplayer() {
  const ModuleContext = createContext();
  const [exampleData, setExampleData] = useState("test data");

  return (
    <div className="ModuleWrapper">
      <ModuleContext.Provider value={exampleData}>
        <RemoteLearningModule contextComponent={ModuleContext} />
      </ModuleContext.Provider>
    </div>
  );
}

</code>```

The line that doesn't work, and I have no solution for, is:

```<code>import('https://s3_bucket_domain.com/modules/module_123.js')
</code>```

So this is kind of the exact spot where I am wondering if the idea of remote importing modules, like this, is even remotely possible. Thanks for any input you can add or any existing resources I may have not looked at!

Body:
I am building a Next.JS site that includes a bunch of modules that act as "mini-wizard" like experiences that allow people to learn about various topics. These modules though aren't just text though and include a lot of functionality and some api calls to my backend. I would like to maintain these separately and have them sit in something like an S3 bucket and then have the main next.js site (Deployed through AWS Amplify currently, but might switch to Vercel) dynamically import them.

So I'm wondering if it is possible to dynamically import a js file from a S3 bucket that is separate from the bundled Next.JS application? I know that is super vague statement and also makes no sense when you think about it technically, but I want to implement something where I can push code updates to one of these modules without having to redeploy the entire site and also prevent the site from becoming massive as we have 100s or 1000s of these modules. I looked at some of the micro-frontends documentation and it doesn't quite seem to solve this problem since I would like to include these components and provide them data utilizing useContext so they can function and interact with data that lives inside the main site.

I haven't had much success so far in trying any approach, but this is somewhat the implementation would look like in code:

import dynamic from 'next/dynamic';
import { useContext, createContext, useState } from 'react';

const RemoteLearningModule = dynamic(() => import('https://s3_bucket_domain.com/modules/module_123.js'), {
  loading: () => 'Loading...',
})

export default function ModuleDisplayer() {
  const ModuleContext = createContext();
  const [exampleData, setExampleData] = useState("test data");

  return (

      <ModuleContext.Provider value={exampleData}>
        <RemoteLearningModule contextComponent={ModuleContext} />
      </ModuleContext.Provider>

  );
}

The line that doesn't work, and I have no solution for, is:

import('https://s3_bucket_domain.com/modules/module_123.js')

So this is kind of the exact spot where I am wondering if the idea of remote importing modules, like this, is even remotely possible. Thanks for any input you can add or any existing resources I may have not looked at!


问:
Find Rank of a Variable in my Dataframe within For Loop
I understand how to add a new column that shows the Rank of the number, but I am looking to change this to show the rank of a variable in that column...

list_of_values = [1,14,125,23,12]
df['price'] contains all 500 of my prices, and I'd like to see how 1 compares to these 500 or how 125 ranks (ties should reflect the minimum (e.g. if there are two values of price=1, the ranking should be 500/500 for both))


问:
Why Rich-Results doesn't catch generate structured data with javascript
Generate structured data with javascript. But structured data testing tool doesn't catch any data.

Why Rich-Results doesn't catch generate structured data with javascript.

Google Doc Said:

Google can read JSON-LD data when it is dynamically injected into the page's contents, such as by JavaScript code or embedded widgets in your content management system.

from this doc
and how to do reference here.

But Testing tool doesn't catch the data.

Test Page:
Page A, Page B

Page's JSON-LD data is correct, I copy to Testing tool, it can found.

Web page is build by Next.js^10.2.3.
I used server-side render structured-data before.
Encountered page large than 1M, can't load page.
So I changed it to client-side dynamically injected into the page's contents.

```<code>import React from 'react';
import Head from 'next/head';
import { map, keys } from 'ramda';

function SeoSchema({ schema }: { schema: Object }) {
  // client side render only
  if (!process.browser) return null;

  return (
    <Head>
      {/* schema */}
      {map((key) => (
        schema[key] && (
          <script
            type="application/ld+json"
            key={`schema-${key}`}
            // eslint-disable-next-line
            dangerouslySetInnerHTML={{ __html: JSON.stringify(schema[key]) }}
          />
        )
      ), keys(schema))}
    </Head>
  );
}

export default SeoSchema;
</code>```

What I'm missing?
If there no answer, I will change back to server-side render structured-data.

Body:
Generate structured data with javascript. But structured data testing tool doesn't catch any data.

Why Rich-Results doesn't catch generate structured data with javascript.

Google Doc Said:

Google can read JSON-LD data when it is dynamically injected into the page's contents, such as by JavaScript code or embedded widgets in your content management system.

from this doc
and how to do reference here.

But Testing tool doesn't catch the data.

Test Page:
Page A, Page B

Page's JSON-LD data is correct, I copy to Testing tool, it can found.

Web page is build by Next.js^10.2.3.
I used server-side render structured-data before.
Encountered page large than 1M, can't load page.
So I changed it to client-side dynamically injected into the page's contents.

import React from 'react';
import Head from 'next/head';
import { map, keys } from 'ramda';

function SeoSchema({ schema }: { schema: Object }) {
  // client side render only
  if (!process.browser) return null;

  return (

      {/* schema */}
      {map((key) => (
        schema[key] && (


问:
I was devoloping a program which stores passwords in a CSV file but its heavily insecure , how can I store passwords more securely
I really wanted to harden my program as it is a prototype to create active directroy users however I was looking for advice as storing passcodes in a CSV file seems insecure yet my script relies on it as I have another powershell script which generates the AD users. Is there a way I can still encrypt the CSV file and add onto it and read it

```<code>import csv
import subprocess, sys
from password_generator import password_generator
def header():
    headerList = ['Name', 'username', 'passcode', 'Title', ]

    # open CSV file and assign header
    with open("users.csv", 'w', newline='') as file:
        dd = csv.DictWriter(file, delimiter=',',
                            fieldnames=headerList)
        dd.writeheader()

def add_user():
    infile = open("users.csv", "a")
    Name = str((input('enter your full name:')))
    username = str((input('enter your username:')))
    passcode = password_generator()
    Title = str((input('enter your job title:')))

    data1 = f"\n{username},{passcode},{Name},{Title}"
    data = data1.strip()  # strips white space
    infile.write(data + "\n")  # appends to new line
    print('record added succesfully !')
    infile.close()

def gen_user():
    p = subprocess.Popen(["powershell.exe",
                          "C:\\Users\\Administrator\\Desktop\\AD_Users.ps1"],
                         stdout=sys.stdout)
    p.communicate()

def main():
    print('Welcome to AD_USERS creation')
    print('********************************************************'
          ' **  \n'
          ' **  Please choose one of the options below:\n'
          ' **  [a] to add new AD user record\n'
          ' **  [h] to initialze headers\n'
          ' **  [G] to generate users \n'
          ' **  [q] to quit \n'
          ' ********************************************************\n')
    choice = input('pick:')
    while True:
        if choice == "a":
            add_user()
            break
        elif choice == "h":
            header()
            break
        elif choice == "G":
            gen_user()
            break
        elif choice == "q":
            break

        else:
            print('Invalid choice!')

main()  # calls all the code
</code>```

Powershell script

```<code>Import-Module ActiveDirectory
$ADUsers = Import-Csv C:\users.csv
foreach ($User in $ADUsers) {
    $Name = $User.Name
    $username = $User.username
    $password = $User.passcode
    $Title=$User.Title
    New-ADUser -Name $Name -SamAccountName $username -AccountPassword (ConvertTo-secureString $password -AsPlainText -Force) -Title $Title
    Enable-AdAccount -Identity $username
    }
</code>```

Body:
I really wanted to harden my program as it is a prototype to create active directroy users however I was looking for advice as storing passcodes in a CSV file seems insecure yet my script relies on it as I have another powershell script which generates the AD users. Is there a way I can still encrypt the CSV file and add onto it and read it

import csv
import subprocess, sys
from password_generator import password_generator
def header():
    headerList = ['Name', 'username', 'passcode', 'Title', ]

    # open CSV file and assign header
    with open("users.csv", 'w', newline='') as file:
        dd = csv.DictWriter(file, delimiter=',',
                            fieldnames=headerList)
        dd.writeheader()

def add_user():
    infile = open("users.csv", "a")
    Name = str((input('enter your full name:')))
    username = str((input('enter your username:')))
    passcode = password_generator()
    Title = str((input('enter your job title:')))

    data1 = f"\n{username},{passcode},{Name},{Title}"
    data = data1.strip()  # strips white space
    infile.write(data + "\n")  # appends to new line
    print('record added succesfully !')
    infile.close()

def gen_user():
    p = subprocess.Popen(["powershell.exe",
                          "C:\\Users\\Administrator\\Desktop\\AD_Users.ps1"],
                         stdout=sys.stdout)
    p.communicate()

def main():
    print('Welcome to AD_USERS creation')
    print('********************************************************'
          ' **  \n'
          ' **  Please choose one of the options below:\n'
          ' **  [a] to add new AD user record\n'
          ' **  [h] to initialze headers\n'
          ' **  [G] to generate users \n'
          ' **  [q] to quit \n'
          ' ********************************************************\n')
    choice = input('pick:')
    while True:
        if choice == "a":
            add_user()
            break
        elif choice == "h":
            header()
            break
        elif choice == "G":
            gen_user()
            break
        elif choice == "q":
            break

        else:
            print('Invalid choice!')

main()  # calls all the code

Powershell script

Import-Module ActiveDirectory
$ADUsers = Import-Csv C:\users.csv
foreach ($User in $ADUsers) {
    $Name = $User.Name
    $username = $User.username
    $password = $User.passcode
    $Title=$User.Title
    New-ADUser -Name $Name -SamAccountName $username -AccountPassword (ConvertTo-secureString $password -AsPlainText -Force) -Title $Title
    Enable-AdAccount -Identity $username
    }


问:
I have successfully installed code runner extension in my VS Code. but play button is not showing only in my c extension files
I have successfully installed code runner extension in my VS Code. It is showing and running in other  program files, but in my c extension file play button is not visible

enter image description here


问:
Spring boot application deployed via Kubernetes can't connect to external MySQL
I tried my Spring boot application deploy to Kubernetes, but spring boot can't connect to external MySQL.
MySQL is running on AWS RDS and i tried ExternalName service to connect external MySQL.

this is my configs.

```<code># mysql.yml

apiVersion: v1
kind: Service
metadata:
  name: mysql
spec:
  type: ExternalName
  externalName: mysql.ap-northeast-2.rds.amazonaws.com
  ports:
    - port: 3306
</code>```
```<code># app-dev.yml

apiVersion: v1
kind: Service
metadata:
  name: app-dev
spec:
  type: NodePort
  ports:
  - nodePort: 30000
    port: 80
    protocol: TCP
    targetPort: 8080
  selector:
    app: app-dev
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: app-dev
  labels:
    app: app-dev
spec:
  replicas: 1
  selector:
    matchLabels:
      app: app-dev
  template:
    metadata:
      labels:
        app: app-dev
    spec:
      containers:
      - name: app-dev
        image: registry.ap-northeast-2.compute.amazonaws.com:5000/app/app-dev:1
        env:
        - name: SPRING_PROFILES_ACTIVE
          value: dev
        - name: SPRING_DATASOURCE_URL
          # I tried mysql.default, default.mysql, mysql.default.svc.cluster.local.
          value: jdbc:mysql://mysql.default:3306/db?serverTimezone=UTC&characterEncoding=UTF-8
        imagePullPolicy: Always
        ports:
        - containerPort: 8080
      nodeSelector:
        app: app-dev
</code>```

and this is error log

```<code>The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174)
    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64)
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:836)
    at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456)
    at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
    at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:197)
    at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
    at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:358)
    at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206)
    at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:477)
    at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:560)
    at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
    at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
    at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:158)
    at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:116)
    at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79)
    ... 60 common frames omitted
Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105)
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151)
    at com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:167)
    at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:91)
    at com.mysql.cj.NativeSession.connect(NativeSession.java:144)
    at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:956)
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:826)
    ... 73 common frames omitted
Caused by: java.net.UnknownHostException: mysql.default: Name or service not known
    at java.base/java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
    at java.base/java.net.InetAddress$PlatformNameService.lookupAllHostAddr(InetAddress.java:932)
    at java.base/java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1517)
    at java.base/java.net.InetAddress$NameServiceAddresses.get(InetAddress.java:851)
    at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1507)
    at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1366)
    at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1300)
    at com.mysql.cj.protocol.StandardSocketFactory.connect(StandardSocketFactory.java:132)
    at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:65)
    ... 76 common frames omitted
</code>```
```<code># kubectl -n default describe service mysql
Name:              mysql
Namespace:         default
Labels:            <none>
Annotations:       <none>
Selector:          <none>
Type:              ExternalName
IP Families:       <none>
IP:
IPs:               <none>
External Name:     mysql.ap-northeast-2.rds.amazonaws.com
Port:              <unset>  3306/TCP
TargetPort:        3306/TCP
Endpoints:         <none>
Session Affinity:  None
Events:            <none>
</code>```

is there anything missing?
please help me.

thank you. and sorry for my bad english :)

Body:
I tried my Spring boot application deploy to Kubernetes, but spring boot can't connect to external MySQL.
MySQL is running on AWS RDS and i tried ExternalName service to connect external MySQL.

this is my configs.

# mysql.yml

apiVersion: v1
kind: Service
metadata:
  name: mysql
spec:
  type: ExternalName
  externalName: mysql.ap-northeast-2.rds.amazonaws.com
  ports:
    - port: 3306

# app-dev.yml

apiVersion: v1
kind: Service
metadata:
  name: app-dev
spec:
  type: NodePort
  ports:
  - nodePort: 30000
    port: 80
    protocol: TCP
    targetPort: 8080
  selector:
    app: app-dev
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: app-dev
  labels:
    app: app-dev
spec:
  replicas: 1
  selector:
    matchLabels:
      app: app-dev
  template:
    metadata:
      labels:
        app: app-dev
    spec:
      containers:
      - name: app-dev
        image: registry.ap-northeast-2.compute.amazonaws.com:5000/app/app-dev:1
        env:
        - name: SPRING_PROFILES_ACTIVE
          value: dev
        - name: SPRING_DATASOURCE_URL
          # I tried mysql.default, default.mysql, mysql.default.svc.cluster.local.
          value: jdbc:mysql://mysql.default:3306/db?serverTimezone=UTC&characterEncoding=UTF-8
        imagePullPolicy: Always
        ports:
        - containerPort: 8080
      nodeSelector:
        app: app-dev

and this is error log

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174)
    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64)
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:836)
    at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456)
    at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
    at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:197)
    at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
    at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:358)
    at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206)
    at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:477)
    at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:560)
    at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
    at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
    at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:158)
    at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:116)
    at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79)
    ... 60 common frames omitted
Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105)
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151)
    at com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:167)
    at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:91)
    at com.mysql.cj.NativeSession.connect(NativeSession.java:144)
    at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:956)
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:826)
    ... 73 common frames omitted
Caused by: java.net.UnknownHostException: mysql.default: Name or service not known
    at java.base/java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
    at java.base/java.net.InetAddress$PlatformNameService.lookupAllHostAddr(InetAddress.java:932)
    at java.base/java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1517)
    at java.base/java.net.InetAddress$NameServiceAddresses.get(InetAddress.java:851)
    at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1507)
    at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1366)
    at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1300)
    at com.mysql.cj.protocol.StandardSocketFactory.connect(StandardSocketFactory.java:132)
    at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:65)
    ... 76 common frames omitted

# kubectl -n default describe service mysql
Name:              mysql
Namespace:         default
Labels:            <none>
Annotations:       <none>
Selector:          <none>
Type:              ExternalName
IP Families:       <none>
IP:
IPs:               <none>
External Name:     mysql.ap-northeast-2.rds.amazonaws.com
Port:              <unset>  3306/TCP
TargetPort:        3306/TCP
Endpoints:         <none>
Session Affinity:  None
Events:            <none>

is there anything missing?
please help me.

thank you. and sorry for my bad english :)