问:
Returning data frame entries based on max date and/or max values (COVID-19 data example)
```<code>df <- read.csv ('https://raw.githubusercontent.com/ulklc/covid19-timeseries/master/countryReport/raw/rawReport.csv',
                stringsAsFactors = FALSE)
</code>```

I found this code which finds countries that reported the highest number of deaths and recovered by region were found in this code.

```<code>    yesterday <- function() Sys.Date() - 1L
    yesterday()
    # [1] "if it doesn't work yesterday()-1  do it"

    library(tidyverse)
    death_df <- df %>%
    filter(as.Date(day) == yesterday()) %>%
    group_by(region) %>%
    filter(death == max(death)) %>%
    select(Date = day,
         countryName,
         region,
         death,
         recovered)

     recovered_df <- df %>%
     filter(as.Date(day) == yesterday()) %>%
    group_by(region) %>%
    filter(recovered == max(recovered)) %>%
    select(Date = day,
         countryName,
         region,
         death,
         recovered)

    full_df <- bind_rows(death_df, recovered_df)
</code>```

However, I need to find the countries that report the most death and recovered to the world in general.

Here is the output I am looking for:

```<code>date            countryName       death        recovered
2020/05/06       united State   **19580**        500
2020/05/06       İran             11500        **98567**
</code>```

Note that these values are not real.

The data set is updated daily. However, it may not have been updated for 1 -2 days. let's pay attention to this.

答:
The code below will select the record with the max daily death and max daily recovered for the max date in the data.

```<code>## call the dplyr library
library(dplyr)
## read the data into R
df <- read.csv ('https://raw.githubusercontent.com/ulklc/covid19-timeseries/master/countryReport/raw/rawReport.csv', stringsAsFactors = FALSE)
## determine the max date contained within the data
max.date <- df[which.max(as.Date(df$day)),"day"]
## copy the data to preserve original
df1 <- df
## filter the data to only entries from the max day
df1 <- filter(df1, as.Date(date, "%Y/%m/%d") == as.Date(max.date))
## determine the entry with the most deaths
max.deaths <- df1[which.max(df1$death),]
## format the number of deaths as given in the example
max.deaths$death <- paste0("**",max.deaths$death,"**")
## determine the entry with the most recovered
max.recovered <- df1[which.max(df1$recovered),]
## format the number recovered to match the format of the example
max.recovered$recovered <- paste0("**",max.recovered$recovered,"**")
## create a data frame containing our max death and max recovered entries
max.records <- rbind(max.deaths, max.recovered)
## attach a column with the max date which corresponds to the date of the entries selected
max.records$date <- max.date
## organize the data as shown in the example
max.records <- select(max.records, c("day","countryName","death","recovered"))
</code>```

And this code will calculate aggregate (or total) deaths as totalDeaths and aggregate recovered as totalRecovered for each country.  It then returns the record with the max totalDeath and max totalRecovered with the max date within the data.

```<code>## call the dplyr library
library(dplyr)
## read the data into R
df <- read.csv ('https://raw.githubusercontent.com/ulklc/covid19-timeseries/master/countryReport/raw/rawReport.csv', stringsAsFactors = FALSE)
## determine the max date contained within the data
max.date <- df[which.max(as.Date(df$day)),"day"]
## copy the data to preserve the original
df1 <- df
## group the data by countries
df1 <- group_by(df1, countryName)
## sum the death and recovered of each country
df1 <- summarise(df1, totalDeaths = sum(death), totalRecovered = sum(recovered))
## ungroup your data to avoid errors
df1 <- ungroup(df1)
## determine country with most total deaths reported
max.deaths <- df1[which.max(df1$totalDeaths),]
## format death numbers to match example
max.deaths$totalDeaths <- paste0("**",max.deaths$totalDeaths,"**")
## determine country with most total recovered reported
max.recovered <- df1[which.max(df1$totalRecovered),]
## format recovered numbers to match example
max.recovered$totalRecovered <- paste0("**",max.recovered$totalRecovered,"**")
## create a data frame containing our max entries
max.records <- rbind(max.deaths, max.recovered)
## attach a column with the max date which corresponds to the most current date the data reports
max.records$date <- max.date
## organize the data as shown in the example
max.records <- select(max.records, c("day","countryName","death","recovered"))
</code>```

Note: both methods rely upon the dplyr R package.  dplyr can be installed by running install.packages(dplyr) in R or RStudio.

I hope this helps!

Body:
df <- read.csv ('https://raw.githubusercontent.com/ulklc/covid19-timeseries/master/countryReport/raw/rawReport.csv',
                stringsAsFactors = FALSE)

I found this code which finds countries that reported the highest number of deaths and recovered by region were found in this code.

    yesterday <- function() Sys.Date() - 1L
    yesterday()
    # [1] "if it doesn't work yesterday()-1  do it"

    library(tidyverse)
    death_df <- df %>%
    filter(as.Date(day) == yesterday()) %>%
    group_by(region) %>%
    filter(death == max(death)) %>%
    select(Date = day,
         countryName,
         region,
         death,
         recovered)

     recovered_df <- df %>%
     filter(as.Date(day) == yesterday()) %>%
    group_by(region) %>%
    filter(recovered == max(recovered)) %>%
    select(Date = day,
         countryName,
         region,
         death,
         recovered)

    full_df <- bind_rows(death_df, recovered_df)

However, I need to find the countries that report the most death and recovered to the world in general.

Here is the output I am looking for:

date            countryName       death        recovered
2020/05/06       united State   **19580**        500
2020/05/06       İran             11500        **98567**

Note that these values are not real.

The data set is updated daily. However, it may not have been updated for 1 -2 days. let's pay attention to this.

Body:
The code below will select the record with the max daily death and max daily recovered for the max date in the data.

## call the dplyr library
library(dplyr)
## read the data into R
df <- read.csv ('https://raw.githubusercontent.com/ulklc/covid19-timeseries/master/countryReport/raw/rawReport.csv', stringsAsFactors = FALSE)
## determine the max date contained within the data
max.date <- df[which.max(as.Date(df$day)),"day"]
## copy the data to preserve original
df1 <- df
## filter the data to only entries from the max day
df1 <- filter(df1, as.Date(date, "%Y/%m/%d") == as.Date(max.date))
## determine the entry with the most deaths
max.deaths <- df1[which.max(df1$death),]
## format the number of deaths as given in the example
max.deaths$death <- paste0("**",max.deaths$death,"**")
## determine the entry with the most recovered
max.recovered <- df1[which.max(df1$recovered),]
## format the number recovered to match the format of the example
max.recovered$recovered <- paste0("**",max.recovered$recovered,"**")
## create a data frame containing our max death and max recovered entries
max.records <- rbind(max.deaths, max.recovered)
## attach a column with the max date which corresponds to the date of the entries selected
max.records$date <- max.date
## organize the data as shown in the example
max.records <- select(max.records, c("day","countryName","death","recovered"))

And this code will calculate aggregate (or total) deaths as totalDeaths and aggregate recovered as totalRecovered for each country.  It then returns the record with the max totalDeath and max totalRecovered with the max date within the data.

## call the dplyr library
library(dplyr)
## read the data into R
df <- read.csv ('https://raw.githubusercontent.com/ulklc/covid19-timeseries/master/countryReport/raw/rawReport.csv', stringsAsFactors = FALSE)
## determine the max date contained within the data
max.date <- df[which.max(as.Date(df$day)),"day"]
## copy the data to preserve the original
df1 <- df
## group the data by countries
df1 <- group_by(df1, countryName)
## sum the death and recovered of each country
df1 <- summarise(df1, totalDeaths = sum(death), totalRecovered = sum(recovered))
## ungroup your data to avoid errors
df1 <- ungroup(df1)
## determine country with most total deaths reported
max.deaths <- df1[which.max(df1$totalDeaths),]
## format death numbers to match example
max.deaths$totalDeaths <- paste0("**",max.deaths$totalDeaths,"**")
## determine country with most total recovered reported
max.recovered <- df1[which.max(df1$totalRecovered),]
## format recovered numbers to match example
max.recovered$totalRecovered <- paste0("**",max.recovered$totalRecovered,"**")
## create a data frame containing our max entries
max.records <- rbind(max.deaths, max.recovered)
## attach a column with the max date which corresponds to the most current date the data reports
max.records$date <- max.date
## organize the data as shown in the example
max.records <- select(max.records, c("day","countryName","death","recovered"))

Note: both methods rely upon the dplyr R package.  dplyr can be installed by running install.packages(dplyr) in R or RStudio.

I hope this helps!


来源: stackexchange

问:
Maven Increment property which is number inside the pom.xml
I want to change pom.xml property

So Build Number Maven Plugin not solve my problem because its based on other file (buidnumber.properties)

Given In pom.xml I have property my.number

```<code><properties>
    <my.number>125</my.number>
</properties>
</code>```

When I run some maven plugin goal

Than In pom.xml I have incremented my.number property by one:

```<code><properties>
    <my.number>126</my.number>
</properties>
</code>```

So what need to be done is to Increment value of property my.value by 1 each time I call maven goal. Is it possible to achieve that by some plugin?

答:
This will change your pom.xml accordingly:</p>

```<code>mvn versions:set-property -Dproperty=my.number -DnewVersion=126
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I want to change pom.xml property

So Build Number Maven Plugin not solve my problem because its based on other file (buidnumber.properties)

Given In pom.xml I have property my.number

<properties>
    <my.number>125</my.number>
</properties>

When I run some maven plugin goal

Than In pom.xml I have incremented my.number property by one:

<properties>
    <my.number>126</my.number>
</properties>

So what need to be done is to Increment value of property my.value by 1 each time I call maven goal. Is it possible to achieve that by some plugin?

Body:
This will change your pom.xml accordingly:

mvn versions:set-property -Dproperty=my.number -DnewVersion=126

ContentLicense: CC BY-SA 4.0


问:
Is there a library that allows checking if a 24-hour time is valid?
I am trying to check if a given time is valid, using any of python's multiple datetime libraries. This given time would be in 24hr format, and examples of valid inputs are 2359, 0000, 1330, while examples of invalid inputs would be 2400, 2360, 2500.

May I ask if there is a better way to check the validity of the input, without parsing through the strings to check individually?

Preferably using python libraries, if possible

If there are no such libraries, may I instead ask how this should be done in regex?

答:
Why do you need a library? You could do it with bare Python code:</p>

```<code>STRTIME = "2317"

if (0 <= int(STRTIME[:2]) < 24 and 0 <= int(STRTIME[2:]) < 60):
   print("Valid")
</code>```

Body:
Why do you need a library? You could do it with bare Python code:

STRTIME = "2317"

if (0 <= int(STRTIME[:2]) < 24 and 0 <= int(STRTIME[2:]) < 60):
   print("Valid")


问:
Read the Docs local install: Celery ValueError: signal only works in main thread
I have a local readthedocs install and get a ValueError exception when trying to import a project. I'm on release 5.1.0, running python 3.6 on Debian buster with celery 4.1.1 (from the requirements files).

From the debug.log:

```<code>[19/May/2020 23:31:11] celery.app.trace:124[24]: INFO Task readthedocs.projects.tasks.send_notifications[39551573-cfe1-46c1-b7e2-28bde20fd962] succeeded in 0.005342413205653429s: None
[19/May/2020 23:31:11] celery.app.trace:124[24]: INFO Task readthedocs.oauth.tasks.attach_webhook[119bed10-cacc-450c-bd51-822e96faffd7] succeeded in 0.016763793770223856s: False
[19/May/2020 23:31:11] celery.app.trace:249[24]: ERROR Task readthedocs.projects.tasks.update_docs_task[b6c22791-f1c6-4ddb-b64a-68d141580c30] raised unexpected: ValueError('signal only works in main thread',)
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/celery/app/trace.py", line 375, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/readthedocs.org/readthedocs/projects/tasks.py", line 448, in update_docs_task
    signal.signal(signal.SIGTERM, sigterm_received)
  File "/usr/local/lib/python3.6/signal.py", line 47, in signal
    handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread
</code>```

I'm using manage.py runserver to run readthedocs, so I tried the --noreload option which has no effect, and the --nothreading option, which causes pages to hang forever.

答:
In order to get a local installation working you need to run a celery worker, which I wasn't doing before (and is not in the readthedocs docs). I'm using docker compose, and ran a separate service called celery that uses the same image as the main readthedocs service (custom docker image that installs django and readthedocs).

```<code>celery -A readthedocs.worker worker -E -l info -Q celery,web
</code>```

Additionally, I have these settings in my Django config:

```<code>BROKER_URL = os.getenv('REDIS_URL')
CELERY_RESULT_BACKEND = os.getenv('REDIS_URL')
CELERY_ALWAYS_EAGER = False
</code>```

I have a simple redis service in my compose config:

```<code>redis:
  image: redis
</code>```

I then have REDIS_URL=redis://redis:6379/0 as an environment variable on my readthedocs and celery services.

Somewhat unrelated but I also stopped using python manage.py runserver and replaced it with uwsgi for production.

```<code>uwsgi \
    --http :80 \
    --wsgi-file readthedocs/wsgi.py \
    --static-map /static=./static \
    --master --processes 4 --threads 2
</code>```

Body:
I have a local readthedocs install and get a ValueError exception when trying to import a project. I'm on release 5.1.0, running python 3.6 on Debian buster with celery 4.1.1 (from the requirements files).

From the debug.log:

[19/May/2020 23:31:11] celery.app.trace:124[24]: INFO Task readthedocs.projects.tasks.send_notifications[39551573-cfe1-46c1-b7e2-28bde20fd962] succeeded in 0.005342413205653429s: None
[19/May/2020 23:31:11] celery.app.trace:124[24]: INFO Task readthedocs.oauth.tasks.attach_webhook[119bed10-cacc-450c-bd51-822e96faffd7] succeeded in 0.016763793770223856s: False
[19/May/2020 23:31:11] celery.app.trace:249[24]: ERROR Task readthedocs.projects.tasks.update_docs_task[b6c22791-f1c6-4ddb-b64a-68d141580c30] raised unexpected: ValueError('signal only works in main thread',)
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/celery/app/trace.py", line 375, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/readthedocs.org/readthedocs/projects/tasks.py", line 448, in update_docs_task
    signal.signal(signal.SIGTERM, sigterm_received)
  File "/usr/local/lib/python3.6/signal.py", line 47, in signal
    handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread

I'm using manage.py runserver to run readthedocs, so I tried the --noreload option which has no effect, and the --nothreading option, which causes pages to hang forever.

Body:
In order to get a local installation working you need to run a celery worker, which I wasn't doing before (and is not in the readthedocs docs). I'm using docker compose, and ran a separate service called celery that uses the same image as the main readthedocs service (custom docker image that installs django and readthedocs).

celery -A readthedocs.worker worker -E -l info -Q celery,web

Additionally, I have these settings in my Django config:

BROKER_URL = os.getenv('REDIS_URL')
CELERY_RESULT_BACKEND = os.getenv('REDIS_URL')
CELERY_ALWAYS_EAGER = False

I have a simple redis service in my compose config:

redis:
  image: redis

I then have REDIS_URL=redis://redis:6379/0 as an environment variable on my readthedocs and celery services.

Somewhat unrelated but I also stopped using python manage.py runserver and replaced it with uwsgi for production.

uwsgi \
    --http :80 \
    --wsgi-file readthedocs/wsgi.py \
    --static-map /static=./static \
    --master --processes 4 --threads 2


问:
Private Google Access for cross project bucket access
Does Google private access allow access to Google Storage bucket available in a different project (cross-project access)? We would like to access the Google bucket without an external IP attached to the machine (and possibly without NAT as the dataset we have is huge).</p>

答: Google private access allows access to the Cloud Storage service (as a whole). Which buckets and objects you can access from there depends on the permissions given to the calling code. From example, if you call Cloud Storage with the Compute Engine's default service account credentials, you'll be able to access buckets and objects that allow access to that service account, whichever project they're in.</p>


问:
Adjustable row heights with bootstrap 4
I'm using bootstrap columns to display expanding cards.  When one expands though, it pushes the whole row underneath it down.

Unexpanded:

Currently how it behaves expanded:

How I'd like it to behave:

I've been reading about flexbox, but I cant find any good examples of the desired behavior, while maintaining responsive design.

Currently the code is along the lines of

```<code><div class="row">
    <div class="col-xl-4 col-lg-5 col-12">
        expanding content...
    </div>
    .
    .
    .
    <div class="col-xl-4 col-lg-5 col-12">
        expanding content...
    </div>
</div>
</code>```

答:
When overriding css values while working with bootstrap try using

```<code>!important
</code>```

For example:

```<code>row {
    height: 150px !important;
}
</code>```

Title: Adjustable row heights with bootstrap 4

Body:
I'm using bootstrap columns to display expanding cards.  When one expands though, it pushes the whole row underneath it down.

Unexpanded:

Currently how it behaves expanded:

How I'd like it to behave:

I've been reading about flexbox, but I cant find any good examples of the desired behavior, while maintaining responsive design.

Currently the code is along the lines of

        expanding content...

    .
    .
    .

        expanding content...

Body:
When overriding css values while working with bootstrap try using

!important

For example:

row {
    height: 150px !important;
}


问:
Spoof $_SERVER['HTTPS'] on local wamp-server for testing
Is it possible to configure my local setup (running Wampserver) so that my PHP application thinks HTTPS is enabled locally?  The application requires HTTPS (by checking $_SERVER['HTTPS']) before doing stuff, but I don't want to go through the hassle of a full HTTPS setup locally.  Thanks.

Edit:  I should mention this isn't an application I wrote, just one I am tasked with maintaining.  This check is performed in many places (50-100) around the server.

答:
Shouldn't be too hard. Even though it is a superglobal, you can still redefine it like any other variable. Do this at the top of your code, and when it gets to the check, it should still recognize it as true.</p>

```<code>$_SERVER['HTTPS'] = true;
</code>```

Body:
Shouldn't be too hard. Even though it is a superglobal, you can still redefine it like any other variable. Do this at the top of your code, and when it gets to the check, it should still recognize it as true.

$_SERVER['HTTPS'] = true;


问:
After Chrome version 83 release, file download in modal dialog doesn't work
I use Google Apps Script to make download Spreadsheet data quickly.

Since several days before, download function doesn't work suddenly.
Some of my coworkers who can use the function use chrome version 81.0.4044.138（Official Build）
and who cannot use the function , chrome version 83.0.4103.61（Official Build）

(right-click and [save as] works fortunately)

I want to know what should I do to make one-click download function active again.

Script is as follows.

```<code>/**
 * Adds a custom menu
 *
 * @param {Object} e The event parameter for a simple onOpen trigger.
 */
function onOpen(e) {
  SpreadsheetApp.getUi()
      .createMenu('Custom')
      .addItem('Download as XLSX', 'downloadXLS_GUI')
      .addToUi();
}

/**
 * Display a modal dialog with a single download link.
 *
 * From: http://stackoverflow.com/a/37336778/1677912
 */
function downloadXLS_GUI() {
  // Get current spreadsheet's ID, place in download URL
  var ssID = SpreadsheetApp.getActive().getId();
  var URL = 'https://docs.google.com/spreadsheets/d/'+ssID+'/export?format=xlsx';

  // Display a modal dialog box with download link.
  var htmlOutput = HtmlService
                  .createHtmlOutput('<a href="'+URL+'">Click to download</a>')
                  .setSandboxMode(HtmlService.SandboxMode.IFRAME)
                  .setWidth(800)
                  .setHeight(600);
  SpreadsheetApp.getUi().showModalDialog(htmlOutput, 'Download XLS');
}

</code>```

答:
Problem

Cannot download a file via link in modal dialog

Reason

The ability to do so is deprecated since Chrome 83 (hence the issue). Modal dialogs are sandbox environments, therefore your script stopped working. If you open the developer tools (press f12), you will see a warning:

Download is disallowed. The frame initiating or instantiating the download is sandboxed, but the flag ‘allow-downloads’ is not set. See https://www.chromestatus.com/feature/5706745674465280 for more details.

Adding a download attribute to the link mitigates that part, but you will encounter the second warning:

Resource interpreted as Document but transferred with MIME type application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

What to do

As of now, there is an open issue regarding the matter, and it is promised that the allow-downloads flag will be added to HtmlService.XFrameOptionsMode.ALLOWALL - you can add the option to modal dialog via setXFrameOptionsMode and look for the updates.

Body:
I use Google Apps Script to make download Spreadsheet data quickly.

Since several days before, download function doesn't work suddenly.
Some of my coworkers who can use the function use chrome version 81.0.4044.138（Official Build）
and who cannot use the function , chrome version 83.0.4103.61（Official Build）

(right-click and [save as] works fortunately)

I want to know what should I do to make one-click download function active again.

Script is as follows.

/**
 * Adds a custom menu
 *
 * @param {Object} e The event parameter for a simple onOpen trigger.
 */
function onOpen(e) {
  SpreadsheetApp.getUi()
      .createMenu('Custom')
      .addItem('Download as XLSX', 'downloadXLS_GUI')
      .addToUi();
}

/**
 * Display a modal dialog with a single download link.
 *
 * From: http://stackoverflow.com/a/37336778/1677912
 */
function downloadXLS_GUI() {
  // Get current spreadsheet's ID, place in download URL
  var ssID = SpreadsheetApp.getActive().getId();
  var URL = 'https://docs.google.com/spreadsheets/d/'+ssID+'/export?format=xlsx';

  // Display a modal dialog box with download link.
  var htmlOutput = HtmlService
                  .createHtmlOutput('Click to download')
                  .setSandboxMode(HtmlService.SandboxMode.IFRAME)
                  .setWidth(800)
                  .setHeight(600);
  SpreadsheetApp.getUi().showModalDialog(htmlOutput, 'Download XLS');
}


问:
Dockerized Python Project - Best way to manage dependencies: Dockerfile or requirements.txt
What is the best practice for handling dependencies of a dockerized python project? Would I declare all of them in the Dockerfile or in the requirements.txt?</p>

答:
You can define your dependencies in a requirements.txt file, then install them with Docker:

```<code>RUN pip install -r requirements.txt
</code>```

Body:
You can define your dependencies in a requirements.txt file, then install them with Docker:

RUN pip install -r requirements.txt


问:
How do I extract data from nested XML using JAVA DOM?
I have an xml document that has multiple . I am able to get the  and account details (,, etc. I am having difficulty getting things like card_type, year, month, first_six, etc.

There are 200 transactions within this document, hence the loop.

```<code>  <transaction href="https://test.com" type="cc">
    <source>subscription</source>
    <created_at type="datetime">2014-03-06T20:59:03Z</created_at>
    <details>
      <account>
        <account_code>234234234</account_code>
        <first_name>asdadad</first_name>
        <last_name>asdadasd3433</last_name>
        <company nil="nil"></company>
        <email>test@gmail.com</email>
        <billing_info type="credit_card">
          <first_name>asdasdasd</first_name>
          <last_name>asdasdasd23434</last_name>
          <address1 nil="nil"></address1>
          <address2 nil="nil"></address2>
          <city nil="nil"></city>
          <state nil="nil"></state>
          <zip nil="nil"></zip>
          <country nil="nil"></country>
          <phone nil="nil"></phone>
          <vat_number nil="nil"></vat_number>
          <card_type>Visa</card_type>
          <year type="integer">2039</year>
          <month type="integer">6</month>
          <first_six>111111</first_six>
          <last_four>9999</last_four>
        </billing_info>
      </account>
    </details>
    <a name="refund" href="https://test.com/refund" method="delete"/>
  </transaction>
</code>```

I get this error when trying my code:

```<code>java.lang.NullPointerException
        at test.test.getTransactions(test.java:288)
        at test.test.main(test.java:53)
</code>```

Here's what I'm trying:

```<code>try {
  NodeList nList2 = eElement.getElementsByTagName("details");
  Node nNode2 = nList2.item(0);
  Element eElement2 = (Element) nNode2;

  //get some other info in try catch blocks here (removed for reading)

  try {
    System.out.println("attempting billing info");
    NodeList nList3 = eElement2.getElementsByTagName("billing_info");
    Node nNode3 = nList3.item(0);
    Element eElement3 = (Element) nNode3;
    System.out.println("attempting credit_year");
    System.out.println("credit_year: " + eElement3.getElementsByTagName("credit_year").item(0).getTextContent());
  } catch (Exception ex) {
    ex.printStackTrace();
  }

}
</code>```

答: You are doing eElement3.getElementsByTagName("credit_year") but you don't have credit_year in your xml. it is only 'year' not 'credit_year' in the xml. So try doing eElement3.getElementsByTagName("year").

Body:
I have an xml document that has multiple . I am able to get the  and account details (,, etc. I am having difficulty getting things like card_type, year, month, first_six, etc.

There are 200 transactions within this document, hence the loop.

  <transaction href="https://test.com" type="cc">
    <source>subscription</source>
    <created_at type="datetime">2014-03-06T20:59:03Z</created_at>

      <account>
        <account_code>234234234</account_code>
        <first_name>asdadad</first_name>
        <last_name>asdadasd3433</last_name>
        <company nil="nil"></company>
        <email>test@gmail.com</email>
        <billing_info type="credit_card">
          <first_name>asdasdasd</first_name>
          <last_name>asdasdasd23434</last_name>
          <address1 nil="nil"></address1>
          <address2 nil="nil"></address2>
          <city nil="nil"></city>
          <state nil="nil"></state>
          <zip nil="nil"></zip>
          <country nil="nil"></country>
          <phone nil="nil"></phone>
          <vat_number nil="nil"></vat_number>
          <card_type>Visa</card_type>
          <year type="integer">2039</year>
          <month type="integer">6</month>
          <first_six>111111</first_six>
          <last_four>9999</last_four>
        </billing_info>
      </account>

  </transaction>

I get this error when trying my code:

java.lang.NullPointerException
        at test.test.getTransactions(test.java:288)
        at test.test.main(test.java:53)

Here's what I'm trying:

try {
  NodeList nList2 = eElement.getElementsByTagName("details");
  Node nNode2 = nList2.item(0);
  Element eElement2 = (Element) nNode2;

  //get some other info in try catch blocks here (removed for reading)

  try {
    System.out.println("attempting billing info");
    NodeList nList3 = eElement2.getElementsByTagName("billing_info");
    Node nNode3 = nList3.item(0);
    Element eElement3 = (Element) nNode3;
    System.out.println("attempting credit_year");
    System.out.println("credit_year: " + eElement3.getElementsByTagName("credit_year").item(0).getTextContent());
  } catch (Exception ex) {
    ex.printStackTrace();
  }

}


问:
how to create a dynamic container in flutter according to image
I am trying to develop an app which has a container which contains a network image now I want that size of the container to adjust according to the size or image like if the image is in portrait the container height should set accordingly and if the image is in landscape it can adjust accordingly </p>

答:
Just wrap a Container around your Image widget.

I put you an exemple on this codepen:
https://codepen.io/blkkkbvsik/pen/MWKWwwN


问:
How to save value to chrome storage without button?
Need to save input's value of type text to chrome.storage.sync.set without uses ok button.

```<code><input id="titleUserTab" type="text">
<input id="urlUserTab" type="text">
</code>```

Problem

Event change of text element triggers by lost it focus. In this case, problem is need to button ok in order to lost focus.

Event input of text element triggers by each keyboard's button. Problem is limits of chrome.storage.sync:

MAX_WRITE_OPERATIONS_PER_HOUR = 1800 The maximum number of set, remove, or clear operations that can be
  performed each hour.

MAX_WRITE_OPERATIONS_PER_MINUTE = 120 The maximum number of set, remove, or clear operations that can be
  performed each minute.

Description

My solution

In order to remove button ok, use the input event.

And to save the values, I added an interval and deleted the handler before the trigger time.

What do you think about this case? Maybe you have your own solution? Thanks for any help.

```<code>// onload page
function restoreUserTabContext(data) {
    titleUserTab.value = data.title;
    urlUserTab.value = data.url;

    titleUserTab.addEventListener('input', onInputUserTabContext);
    urlUserTab.addEventListener('input', onInputUserTabContext);
}

// handler
function onInputUserTabContext() {
    titleUserTab.removeEventListener('input', onInputUserTabContext);
    urlUserTab.removeEventListener('input', onInputUserTabContext);

    setTimeout(function () {
        let data = {
            title: titleUserTab.value,
            url: urlUserTab.value,
        };

        titleUserTab.addEventListener('input', onInputUserTabContext);
        urlUserTab.addEventListener('input', onInputUserTabContext);

        saveOption('dataUserTab', data);
    }, 4000);
}

function saveOption(key, value) {
    option = {};
    option[key] = value;

    chrome.storage.sync.set(option, function () {
        if (chrome.runtime.lastError) {
            console.error(chrome.runtime.lastError.message);
        }
    });
}
</code>```

答:
The idea sounds good, but you could instead use "setInterval" along with a "previous value" variable:

var oldData = null;
setInterval(
  ()=>{
    var data = {
      title: titleUserTab.value,
      url: urlUserTab.value,
    };
    if (data!=oldData) {
      saveOption('dataUserTab', data);
    }
    oldData=data
  },
4000);
```

Body:
Need to save input's value of type text to chrome.storage.sync.set without uses ok button.

<input id="titleUserTab" type="text">
<input id="urlUserTab" type="text">

Problem

Event change of text element triggers by lost it focus. In this case, problem is need to button ok in order to lost focus.

Event input of text element triggers by each keyboard's button. Problem is limits of chrome.storage.sync:

MAX_WRITE_OPERATIONS_PER_HOUR = 1800 The maximum number of set, remove, or clear operations that can be
  performed each hour.

MAX_WRITE_OPERATIONS_PER_MINUTE = 120 The maximum number of set, remove, or clear operations that can be
  performed each minute.

Description

My solution

In order to remove button ok, use the input event.

And to save the values, I added an interval and deleted the handler before the trigger time.

What do you think about this case? Maybe you have your own solution? Thanks for any help.

// onload page
function restoreUserTabContext(data) {
    titleUserTab.value = data.title;
    urlUserTab.value = data.url;

    titleUserTab.addEventListener('input', onInputUserTabContext);
    urlUserTab.addEventListener('input', onInputUserTabContext);
}

// handler
function onInputUserTabContext() {
    titleUserTab.removeEventListener('input', onInputUserTabContext);
    urlUserTab.removeEventListener('input', onInputUserTabContext);

    setTimeout(function () {
        let data = {
            title: titleUserTab.value,
            url: urlUserTab.value,
        };

        titleUserTab.addEventListener('input', onInputUserTabContext);
        urlUserTab.addEventListener('input', onInputUserTabContext);

        saveOption('dataUserTab', data);
    }, 4000);
}

function saveOption(key, value) {
    option = {};
    option[key] = value;

    chrome.storage.sync.set(option, function () {
        if (chrome.runtime.lastError) {
            console.error(chrome.runtime.lastError.message);
        }
    });
}


问:
Upgrading running application on Android
Is Android system supposed to restart an application when it's upgraded while it's running?

When we upgrade our application (by opening the .apk from SD card) and the application is running, the existing process stays around and the upgrade does not take effect until we "force close" the application from application manager. However it is likely that the application is in some weird state and may not respond to some intents it should. So I want to know whether the application would be restarted if we fix that particular broken state or whether we need to handle the upgrade ourselves.

Note, that I know (or at least have some ideas) how to detect the upgrade programmatically. What I want to know is whether I am supposed to or whether there is some other mechanism that should do it if the application is in a sane state.

答:
Is Android system supposed to restart an application when it's upgraded while it's running?

I dont know what should be the expected behaviour. But I know that it does not restart the app. So I have a BroadcastReceiver waiting for the ACTION_PACKAGE_REPLACED intent and then handle the app restart accordingly.


问:
When is neccesary sanitizerBypassSecurityUrl
I have an ionic app in which i preview images in base64 using [src]="sanitizer.bypassSecurityTrustUrl(myBase64Photo), is neccesary there to preview because i had a warning, but im not sure if it is necessary after the image is stored in firebase and I retrieve it and load it, the thing is that if i do: , in the network i see multiple calls to firebase even if i click anyware in my home page where this images are loaded (BUT EVENT IF I DONT CLICK THEM). So I exceed the quota if i keep the bypass there.
Thanks in advance</p>

答:
Whenever you are using dynamic link binding like so:

```<code><a href="{{ some_dynamic_link }}">
</code>```

Regardless of where the resource is located you will see the warning unless you sanitize URL. This is in-built to prevent XSS type of attacks: when attackers explore HTML code and are able to inject malicious code to the DOM. An attacker can potentially change the URL resource to a script resource so it can collect data from our app or any other malicious act that they desire. Angular by default will block unsafe URLs (dynamic URLs) – protecting you from making unaware mistakes.

Best practice for sanitization is to perform it within so called pure pipes, then resource requests can be cached and you won't see excessive requests.

Body:
Whenever you are using dynamic link binding like so:

<a href="{{ some_dynamic_link }}">

Regardless of where the resource is located you will see the warning unless you sanitize URL. This is in-built to prevent XSS type of attacks: when attackers explore HTML code and are able to inject malicious code to the DOM. An attacker can potentially change the URL resource to a script resource so it can collect data from our app or any other malicious act that they desire. Angular by default will block unsafe URLs (dynamic URLs) – protecting you from making unaware mistakes.

Best practice for sanitization is to perform it within so called pure pipes, then resource requests can be cached and you won't see excessive requests.


问:
What is causing asynchronous changes of permissions after usage of chmod in backticks in perl
TL;DR - Go down to the UPDATE for a toy example.  The following was my original question before I was able to reproduce the issue in a small example, edited for clarity.

I do not understand what is going on here.  I was pulling my hair out trying to figure out why a test I'd written in perl kept failing.

I was testing a function that turns off logging when an open of an output log file failed so that output to STDERR would not be suppressed.  To test that it works, I created a file on the fly and chmod it to be unwritable.  The resulting run of the code should print an open error along with all other STDERR to the STDERR output.  I was doing the chmod in backticks before running my test.

However, what was happening was the logfile kept getting written to without error - so the test was failing.  I started doing sanity checks by printing the output of ls -halF in various places to see where the permission change was happening.  The initial chmod seemed to be working:

```<code>`echo > file.log;chmod 444 file.log;ls -halF file.log`
</code>```

A subsequent ls -halF file.log after some other setup confirmed the intended permissions, but a very early line of code in my run of the actual test code said that the owner had write permission!

I eventually discovered a fix to the problem - by using the perl chmod() method instead of chmod in backticks, which makes me think there's some asynchronous stuff going on - and that made no sense to me.

I ended up trying that because in my numerous tests, I would occassionally see a test randomly succeed.  So I wrote a quick loop to perform the same test over and over - and discovered that it randomly succeeds maybe 30% of the time!  That's what made me think there may be some sort of asynchronicity to this issue, which I could not explain because I thought that backticks essentially waited for the process to complete since it returns the output - so what is going on here?  I don't understand it.

For completeness - the actual test command is done in backticks too - it runs an independent script.

In my update below, I show a different case, but it demonstrates the randomness of the permissions states...

UPDATE

OK.  This is a small self-contained example that demonstrates the problem.  Pay attention to the different output of the second line in each case...

deleteme1.pl

```<code>#!/usr/bin/perl
print(`echo '' > deleteme.log;chmod 444 deleteme.log`);
print("1: ",`ls -l deleteme.log`);
`chmod 777 deleteme.log;rm -f deleteme.log`;
</code>```

deleteme2.pl

```<code>#!/usr/bin/perl
print(`echo '' > deleteme.log;chmod 444 deleteme.log`);
print("2: ",`ls -l deleteme.log`);
chmod 0777, "deleteme.log";
unlink("deleteme.log");
</code>```

Now observe the output of this repeating loop:

```<code>tcsh> foreach f ( `seq 1 30` )
perl deleteme1.pl
perl deleteme2.pl
end
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -rw-r--r--@ 1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -rw-r--r--@ 1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--@ 1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--@ 1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -rw-r--r--@ 1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--@ 1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--@ 1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--@ 1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
</code>```

Note that the owner permission differences are always from deleteme1.pl.  I think that the @ indicates extended attributes on macOS.  That may have something to do with it, but there are cases where xattr is there, but no permission differences...

And I also suspect that the problem might possibly have something to do with this:

```<code>>ls -1 t | wc -l
   46391
</code>```

So something's happening asynchronously - what the hell is it?!  Could it have something to do with SIP or csr(util)?

UPDATE 2

Here's an example truer to my specific case.

deleteme3.pl

This one represents my fix:

```<code>#!/usr/bin/perl
open(TLG,">deleteme.log");
print TLG '';
close(TLG);
chmod 0444, "deleteme.log";
if(open(TEST,">deleteme.log"))
  {print "3 opened\n"}
else
  {print "3 unable to open\n"}
chmod 0777, "deleteme.log";
unlink("deleteme.log");
</code>```

deleteme4.pl

This one demonstrates the original problem.

```<code>#!/usr/bin/perl
`echo '' > deleteme.log;chmod 444 deleteme.log`;
if(open(TEST,">deleteme.log"))
  {print "4 opened\n"}
else
  {print "4 unable to open\n"}
chmod 0777, "deleteme.log";
unlink("deleteme.log");
</code>```

I looped on these 2, as above:

```<code>tcsh>foreach f ( `seq 1 1000` )
perl deleteme3.pl
perl deleteme4.pl
end
</code>```

In the 1000 tries, 3 unable to open was always output for deleteme3.pl.  deleteme4.pl outputs 4 opened 4 times, and the rest are 4 unable to open.

Obviously, this doesn't demonstrate the frequency I was seeing where most of the time, my permissions showed owner-writable, but my guess is I was hitting some sort of sweet spot where something was mucking with my file permissions.

I would love to see if someone can reproduce these results on any platform, but I'm on macOS Sierra (10.12.6) running the system perl version 5.18.2.

答:
I figured out the culprit for the asynchronous permissions changes.  I was missing a critical piece of information in my question: the directory in which I was working was in Dropbox(!).  I was unaware that dropbox ever modifies the permissions of files, but apparently it does.

With the Dropbox app running:

```<code>tcsh>foreach f ( `seq 1 50` )
foreach? perl deleteme1.pl
foreach? perl deleteme2.pl
foreach? end
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -rw-r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -rw-r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -rw-r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -rw-r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -rw-r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -rw-r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -rw-r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -rw-r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -rw-r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
</code>```

After quitting Dropbox (still in the dropbox directory):

```<code>>foreach f ( `seq 1 50` )
foreach? perl deleteme1.pl
foreach? perl deleteme2.pl
foreach? end
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
</code>```

I discovered this because I was suspecting that SIP was the culprit.  I rebooted in recovery mode and disabled SIP with csrutil disable.  After rebooting, I ran the test loop and saw the same behavior of randomly changing permissions, but while that was running, I got a dialog from dropbox saying "Dropbox need to change permissions for the Folder /Users/robleach/Dropbox".  I clicked OK and re-ran the loop and the random permissions issue was not evident.

I rebooted in recovery to re-enable SIP and rebooted again (with SIP active) just to confirm SIP was not involved.  I re-ran the loop and again saw the random permissions issue.  I then quit dropbox and re-ran the loop.  The results are above.

I openly admit that I lacked the knowledge for it to even occur to me to realize that the dropbox aspect of this issue would be critical to answering this question.^  And I admit that I have my development project in Dropbox out of laziness - so I don't have to remember to commit/pull unfinished changes between performing work on 2 different computers.  But I've had this specific project in dropbox for years and never ran into any issues until now (test #757, i.e. 756 tests performed as expected).  So it hadn't even occurred to me that Dropbox could be a factor in this issue.  I was unaware the sync made active changes to the files on the source device (i.e. where the file was created).

^ Cross-reference: https://meta.stackexchange.com/questions/348841/stack-mechanisms-are-evolving-toward-an-ideal-that-hampers-collaborative-problem

Body:
TL;DR - Go down to the UPDATE for a toy example.  The following was my original question before I was able to reproduce the issue in a small example, edited for clarity.

I do not understand what is going on here.  I was pulling my hair out trying to figure out why a test I'd written in perl kept failing.

I was testing a function that turns off logging when an open of an output log file failed so that output to STDERR would not be suppressed.  To test that it works, I created a file on the fly and chmod it to be unwritable.  The resulting run of the code should print an open error along with all other STDERR to the STDERR output.  I was doing the chmod in backticks before running my test.

However, what was happening was the logfile kept getting written to without error - so the test was failing.  I started doing sanity checks by printing the output of ls -halF in various places to see where the permission change was happening.  The initial chmod seemed to be working:

`echo > file.log;chmod 444 file.log;ls -halF file.log`

A subsequent ls -halF file.log after some other setup confirmed the intended permissions, but a very early line of code in my run of the actual test code said that the owner had write permission!

I eventually discovered a fix to the problem - by using the perl chmod() method instead of chmod in backticks, which makes me think there's some asynchronous stuff going on - and that made no sense to me.

I ended up trying that because in my numerous tests, I would occassionally see a test randomly succeed.  So I wrote a quick loop to perform the same test over and over - and discovered that it randomly succeeds maybe 30% of the time!  That's what made me think there may be some sort of asynchronicity to this issue, which I could not explain because I thought that backticks essentially waited for the process to complete since it returns the output - so what is going on here?  I don't understand it.

For completeness - the actual test command is done in backticks too - it runs an independent script.

In my update below, I show a different case, but it demonstrates the randomness of the permissions states...

UPDATE

OK.  This is a small self-contained example that demonstrates the problem.  Pay attention to the different output of the second line in each case...

deleteme1.pl

#!/usr/bin/perl
print(`echo '' > deleteme.log;chmod 444 deleteme.log`);
print("1: ",`ls -l deleteme.log`);
`chmod 777 deleteme.log;rm -f deleteme.log`;

deleteme2.pl

#!/usr/bin/perl
print(`echo '' > deleteme.log;chmod 444 deleteme.log`);
print("2: ",`ls -l deleteme.log`);
chmod 0777, "deleteme.log";
unlink("deleteme.log");

Now observe the output of this repeating loop:

tcsh> foreach f ( `seq 1 30` )
perl deleteme1.pl
perl deleteme2.pl
end
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -rw-r--r--@ 1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -rw-r--r--@ 1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--@ 1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--@ 1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -rw-r--r--@ 1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--@ 1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--@ 1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--@ 1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
1: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log
2: -r--r--r--  1 robleach  staff  1 May 31 21:01 deleteme.log

Note that the owner permission differences are always from deleteme1.pl.  I think that the @ indicates extended attributes on macOS.  That may have something to do with it, but there are cases where xattr is there, but no permission differences...

And I also suspect that the problem might possibly have something to do with this:

>ls -1 t | wc -l
   46391

So something's happening asynchronously - what the hell is it?!  Could it have something to do with SIP or csr(util)?

UPDATE 2

Here's an example truer to my specific case.

deleteme3.pl

This one represents my fix:

#!/usr/bin/perl
open(TLG,">deleteme.log");
print TLG '';
close(TLG);
chmod 0444, "deleteme.log";
if(open(TEST,">deleteme.log"))
  {print "3 opened\n"}
else
  {print "3 unable to open\n"}
chmod 0777, "deleteme.log";
unlink("deleteme.log");

deleteme4.pl

This one demonstrates the original problem.

#!/usr/bin/perl
`echo '' > deleteme.log;chmod 444 deleteme.log`;
if(open(TEST,">deleteme.log"))
  {print "4 opened\n"}
else
  {print "4 unable to open\n"}
chmod 0777, "deleteme.log";
unlink("deleteme.log");

I looped on these 2, as above:

tcsh>foreach f ( `seq 1 1000` )
perl deleteme3.pl
perl deleteme4.pl
end

In the 1000 tries, 3 unable to open was always output for deleteme3.pl.  deleteme4.pl outputs 4 opened 4 times, and the rest are 4 unable to open.

Obviously, this doesn't demonstrate the frequency I was seeing where most of the time, my permissions showed owner-writable, but my guess is I was hitting some sort of sweet spot where something was mucking with my file permissions.

I would love to see if someone can reproduce these results on any platform, but I'm on macOS Sierra (10.12.6) running the system perl version 5.18.2.

Body:
I figured out the culprit for the asynchronous permissions changes.  I was missing a critical piece of information in my question: the directory in which I was working was in Dropbox(!).  I was unaware that dropbox ever modifies the permissions of files, but apparently it does.

With the Dropbox app running:

tcsh>foreach f ( `seq 1 50` )
foreach? perl deleteme1.pl
foreach? perl deleteme2.pl
foreach? end
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -rw-r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -rw-r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -rw-r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -rw-r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -rw-r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -rw-r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -rw-r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -rw-r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -rw-r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log
1: -r--r--r--@ 1 robleach  staff  1 Jun  2 12:09 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:09 deleteme.log

After quitting Dropbox (still in the dropbox directory):

>foreach f ( `seq 1 50` )
foreach? perl deleteme1.pl
foreach? perl deleteme2.pl
foreach? end
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
1: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log
2: -r--r--r--  1 robleach  staff  1 Jun  2 12:11 deleteme.log

I discovered this because I was suspecting that SIP was the culprit.  I rebooted in recovery mode and disabled SIP with csrutil disable.  After rebooting, I ran the test loop and saw the same behavior of randomly changing permissions, but while that was running, I got a dialog from dropbox saying "Dropbox need to change permissions for the Folder /Users/robleach/Dropbox".  I clicked OK and re-ran the loop and the random permissions issue was not evident.

I rebooted in recovery to re-enable SIP and rebooted again (with SIP active) just to confirm SIP was not involved.  I re-ran the loop and again saw the random permissions issue.  I then quit dropbox and re-ran the loop.  The results are above.

I openly admit that I lacked the knowledge for it to even occur to me to realize that the dropbox aspect of this issue would be critical to answering this question.^  And I admit that I have my development project in Dropbox out of laziness - so I don't have to remember to commit/pull unfinished changes between performing work on 2 different computers.  But I've had this specific project in dropbox for years and never ran into any issues until now (test #757, i.e. 756 tests performed as expected).  So it hadn't even occurred to me that Dropbox could be a factor in this issue.  I was unaware the sync made active changes to the files on the source device (i.e. where the file was created).

^ Cross-reference: https://meta.stackexchange.com/questions/348841/stack-mechanisms-are-evolving-toward-an-ideal-that-hampers-collaborative-problem


问:
Accessing foreign keys from the Django template
This is my models.py:

```<code>class dateEvent(models.Model):

    event = models.ForeignKey('Event', on_delete=models.CASCADE)
    start_date_time = models.DateTimeField(auto_now=False, auto_now_add=False)

class Event(models.Model):

    title = models.CharField(max_length=50)
</code>```

view.py:

```<code>def events_list_view(request):
    events = dateEvent.objects.all()

    context = {
        'dateEvents': dateEvents,
    }

    return render(request, 'events/events_list.html', context)
</code>```

template:

```<code>{% for event in dateEvents %}
    <tr>
      <td>{{ dateEvent.start_date_time }}</td>
      <td><a href="{% url 'event-detail' id=? %}">{{ dateEvent }}</a></td> # I want the event id here
      <td>{{ dateEvent.venue_event }}</td>

{% endfor %}
</code>```

How can I get the Event id which is linked to that dateEvent in my template? Using dateEvent.event_set doesn't seem to work.

答:
I think following can solve the problem :
 dataEvent.event.id
Let me know if that worked.

Body:
This is my models.py:

class dateEvent(models.Model):

    event = models.ForeignKey('Event', on_delete=models.CASCADE)
    start_date_time = models.DateTimeField(auto_now=False, auto_now_add=False)

class Event(models.Model):

    title = models.CharField(max_length=50)

view.py:

def events_list_view(request):
    events = dateEvent.objects.all()

    context = {
        'dateEvents': dateEvents,
    }

    return render(request, 'events/events_list.html', context)

template:

{% for event in dateEvents %}

      {{ dateEvent.start_date_time }}
      {{ dateEvent }}	 # I want the event id here
      {{ dateEvent.venue_event }}

{% endfor %}

How can I get the Event id which is linked to that dateEvent in my template? Using dateEvent.event_set doesn't seem to work.


问:
How to read a text file line by line define a count function using groovy script engine in jmeter
I have a text file contains 45 lines. I need to read the text file line by line based on the counter increment function.

Example: If we read the first line of a line then it prints count value is 1 and so on...

please provide me some good examples.

答:
new File('/path/to/your/file').readLines().get(0) - returns the first line of the file

new File('/path/to/your/file').readLines().get(1) - returns the second line of the file

etc.

If you need to access the JMeter variable defined by the Counter configuration element - use vars shorthand for JMeterVariables class instance like:

```<code>new File('/path/to/your/file').readLines().get(vars.get('your_counter_variable') as int))
</code>```

More information:

Groovy File.readLines() function

Apache Groovy - Why and How You Should Use It

Body:
new File('/path/to/your/file').readLines().get(0) - returns the first line of the file

new File('/path/to/your/file').readLines().get(1) - returns the second line of the file

etc.

If you need to access the JMeter variable defined by the Counter configuration element - use vars shorthand for JMeterVariables class instance like:

new File('/path/to/your/file').readLines().get(vars.get('your_counter_variable') as int))

More information:

Groovy File.readLines() function

Apache Groovy - Why and How You Should Use It


问: Reduce the impact of third-party code (zendesk)

答:
I came across this issue recently and made this hack using a function for loading the zendesk script only when you reached certain point of the doc. I know is kind of dirty but it works:

```<code><script defer type="text/javascript">
    (function($, win) {
        $.fn.inViewport = function(cb) {
            return this.each(function(i,el){
                function visPx(){
                    var H = $(this).height(),
                    r = el.getBoundingClientRect(), t=r.top, b=r.bottom;
                    return cb.call(el, Math.max(0, t>0? H-t : (b<H?b:H)));
                }  visPx();
                $(win).on("resize scroll", visPx);
            });
        };
    }(jQuery, window));

$('#trigger_div').inViewport(function(px){
    if(px) {

    //zopim code

    }
});
</code>```

Body:
I came across this issue recently and made this hack using a function for loading the zendesk script only when you reached certain point of the doc. I know is kind of dirty but it works:

<script defer type="text/javascript">
    (function($, win) {
        $.fn.inViewport = function(cb) {
            return this.each(function(i,el){
                function visPx(){
                    var H = $(this).height(),
                    r = el.getBoundingClientRect(), t=r.top, b=r.bottom;
                    return cb.call(el, Math.max(0, t>0? H-t : (b<H?b:H)));
                }  visPx();
                $(win).on("resize scroll", visPx);
            });
        };
    }(jQuery, window));

$('#trigger_div').inViewport(function(px){
    if(px) {

    //zopim code

    }
});


答:
You can mock up this variable in your init file by adding:</p>

```<code>$_SERVER['HTTPS'] = true;
</code>```

Title: Spoof $_SERVER['HTTPS'] on local wamp-server for testing

Body:
Is it possible to configure my local setup (running Wampserver) so that my PHP application thinks HTTPS is enabled locally?  The application requires HTTPS (by checking $_SERVER['HTTPS']) before doing stuff, but I don't want to go through the hassle of a full HTTPS setup locally.  Thanks.

Edit:  I should mention this isn't an application I wrote, just one I am tasked with maintaining.  This check is performed in many places (50-100) around the server.

Body:
You can mock up this variable in your init file by adding:

$_SERVER['HTTPS'] = true;


问:
default snapshot location for velero
I want to use velero with my azure Kubernetes cluster to backup cluster data and persistent volumes.

Like doc says I have annotated the pods and even backup job shows 4 snapshots successful.

I managed to take the backup for the cluster and I can see it in my azure storage account. the problem is I see only gz files and one json file in my storage accounts velero designated container. Shouldn't I see a file equivalent to my PVs ?(which is about 10GB)

答:
This in fact is the correct setup. You should see only json files and gziped files in the backup folder within valero container. </p>

<p>These files have pointers to actual snapshots in azure. look for the snapshots within resource group you specified during backup. There should be snapshots corresponding to PVC size. </p>

Title: default snapshot location for velero

Body:
This in fact is the correct setup. You should see only json files and gziped files in the backup folder within valero container.

These files have pointers to actual snapshots in azure. look for the snapshots within resource group you specified during backup. There should be snapshots corresponding to PVC size.


问:
Changing clang to compile in C11 or higher?
I'm following a tutorial on learning C. I'm currently using a Mac with clang 11.0.3. It is in C99 by default (I'm getting the error: warning: implicit declaration of function 'of' is invalid in C99
      [-Wimplicit-function-declaration].)
I'm using xcode 11.5.

How do I update/change the default of clang to C11 or higher?

答:
You can look up the documentation with man clang on your system or online on the Clang website (https://clang.org → “Getting started” → “User's Manual” link on the left).

clang supports the -std option, which changes what language mode clang uses. The supported modes for C are c89, gnu89, c99, gnu99, c11, gnu11, c17, gnu17, c2x, gnu2x, and various aliases for those modes. If no -std option is specified, clang defaults to gnu17 mode.

Note that since you're seeing C99 as the language version, your IDE is likely passing a -std option already. I don't know where to control compiler options in Xcode but Setting C compile flags in xcode might help.

The Clang documentation is not always complete or clear. Many features of Clang mimic GCC, and GCC often has better documentation. The section on C dialect options in the GCC manual has more information about -std and its values. You need to be careful because Clang doesn't always work exactly like GCC, but the GCC documentation is often helpful as long as you remember that it may not always apply to Clang.

None of this will help you anyway because switching from C99 to C11 wouldn't fix this particular error. Implicit function declarations are a deprecated feature in C89 which was made invalid in C99, and of is not a new keyword in C11, so either your code is bad-style C89 or more likely there's a typo and of should not be a function name.


问:
Selenium: how to extract all images from a website (including ones from javascript and css)
I need to extract all images from a website using Selenium. This should include all images of any extension (png, jpg, svg, etc) from html, css and javascript. This means that a simple extraction of all the  elements will not be sufficient (e.g. any image loaded from css style will be missed):

images = driver.find_elements_by_tag_name('img')  # not sufficient
```

Is there anything smarter to do instead of downloading and parsing every css and javascript script required in the website and using regex to look for image files?

It would be ideal if there is a way to just look for the downloaded resources after the page load, something similar to the network tab in chrome dev tools:

Any idea?

答:
The answer is originally taken from How to access Network panel on google chrome developer tools with selenium?. I just updated a little bit. </p>

```<code>resources = driver.execute_script("return window.performance.getEntriesByType('resource');")
for resource in resources:
    if resource['initiatorType'] == 'img': # check for other types if needed
        print(resource['name']) # this is the original link of the file
</code>```

Body:
I need to extract all images from a website using Selenium. This should include all images of any extension (png, jpg, svg, etc) from html, css and javascript. This means that a simple extraction of all the  elements will not be sufficient (e.g. any image loaded from css style will be missed):

images = driver.find_elements_by_tag_name('img')  # not sufficient

Is there anything smarter to do instead of downloading and parsing every css and javascript script required in the website and using regex to look for image files?

It would be ideal if there is a way to just look for the downloaded resources after the page load, something similar to the network tab in chrome dev tools:

Any idea?

Body:
The answer is originally taken from How to access Network panel on google chrome developer tools with selenium?. I just updated a little bit.

resources = driver.execute_script("return window.performance.getEntriesByType('resource');")
for resource in resources:
    if resource['initiatorType'] == 'img': # check for other types if needed
        print(resource['name']) # this is the original link of the file


问:
How do Typescript interface scope is working ? How to make interfaces global?
I'm a new user of Typescript and Deno and I don't really understand how the interfaces scope are working.

I have a tree layer application :

The first layer (App.ts) is my application, this is where the core logic part of my application is. This part can be any file that need to refer to the second layer (API.ts).

The second layer (API.ts) is the entry point where I can communicate with any distant API (like Facebook, stripe, Google API)

The third layer is a bunch of .ts file. The second layer (API.ts) can communicate with each of them. Every file handles a very precise part of a particular API. I have for example one FB_page.ts to handle the part of the Facebook API responsible for pages, another file STRP_Subscription that handle the part of the Stripe API responsible for subscriptions, etc.

My problem is

I have a lot of interfaces to handle every type of parameter, every error and every response an API call can input or output. And I need these interfaces in every layer of my application.

It would be very cool if I can put interfaces of a particular API part inside the file that is responsible for it. For example, if I need several interfaces for the Facebook page API, I would like to put then inside the FB_page.ts file.

But it's tedious to have to import the FB_page.ts file if I need them in the first layer of my application App.ts like this :
import {IPost, IPost_Error, IPost_Response} from '../lib/FB_page.ts';

So I put them inside .d.ts files, but they seem not to be global either ?

How can I have access to my interfaces without having to import them everywhere in my application ?

Thank you for your help.

答:
Almost everything in Deno is a module. If you provide a non-module/script with global types, it won't be found. Also, Deno cannot deal with .d.ts file extension, except for a few places with compiler hints.

What you can do

Rename the files containing the interfaces to .ts.

Put global types in a module (file with import/export)

Make sure to import this module, so Deno CLI can find it when compiling

Note, that  deno uses its own integrated TS compiler different from the one of your IDE (VS Code and others). So an IDE showing no type error doesn't mean, that deno run or deno cache can compile sources.

Example code

```<code>// Put following code inside one of your used modules
declare global {
  interface IPost {
    foo: string;
  }
}

// IPost will be available globally without import
const post: IPost = { foo: "bar" }
</code>```

If you want to separate the global types from your other code, you could use a side-effect import:

```<code>import "./lib/global.ts";
const post: IPost = { foo: "bar" };
</code>```
global.ts:
```<code>export {}; // use some export to mark file as module
declare global {
  interface IPost {
    foo: string
  }
}
</code>```

Body:
Almost everything in Deno is a module. If you provide a non-module/script with global types, it won't be found. Also, Deno cannot deal with .d.ts file extension, except for a few places with compiler hints.

What you can do

Rename the files containing the interfaces to .ts.

Put global types in a module (file with import/export)

Make sure to import this module, so Deno CLI can find it when compiling

Note, that  deno uses its own integrated TS compiler different from the one of your IDE (VS Code and others). So an IDE showing no type error doesn't mean, that deno run or deno cache can compile sources.

Example code

// Put following code inside one of your used modules
declare global {
  interface IPost {
    foo: string;
  }
}

// IPost will be available globally without import
const post: IPost = { foo: "bar" }

If you want to separate the global types from your other code, you could use a side-effect import:

import "./lib/global.ts";
const post: IPost = { foo: "bar" };

global.ts:

export {}; // use some export to mark file as module
declare global {
  interface IPost {
    foo: string
  }
}