问:
URL blocked: "Add all your app domains as valid OAuth redirect URIs" (with a Facebook Business App)
Trying to get Facebook Login to work with my next-auth / nextjs app.

It all works when I select a Consumer App and it's in Development Mode.

However, I want to use features of the App Type Business App. Business Apps in Facebook don't have Development Mode / Production Mode. Instead, everything is managed via access levels. The first 2 types in this list is what I am referring to:

Now, when I try it out with a Consumer App, things work fine. It does not work for me however when I use a Business App. I get the following error:

URL blocked This redirect failed because the redirect URI is not
white-listed in the app's client OAuth settings. Make sure that the
client and web OAuth logins are on and add all your app domains as
valid OAuth redirect URIs.

However, I cannot add the URL to valid OAuth redirect URIs, since Facebook tells me that localhost is automatically approved in development mode, so I doesn't allow me to add it. But this is weird, since there is no 'development mode' for business apps.

See these 2 images:

I found that a bit strange, so I deployed it to production and tested it - this works.

So Consumer App + localhost works, Business App + Localhost doesn't work, Business App + Production works.

Does anyone know what the problem is with localhost + business apps on facebook? I would really love to test things in development, and not have to push everything to production all the time.

答:
The only thing I can think of is trying to use shaHmac512 to encrypt and sign your token, digesting with hex

I do remember having to do this for auth from localhost

and to gain access to "long-lived" access tokens for facebook business/facebook for developers

```<code>const accessToken = process.env.FACEBOOK_ACCESS_TOKEN ?? "";
const secretKey = process.env.FACEBOOK_SECRET ?? "";

function signHmacSha512(key: string, secret: string) {
  key = accessToken;
  secret = secretKey;
  const hmac = crypto.createHmac("sha512", key);
  const signed = hmac.update(Buffer.from(secret, "utf-8")).digest("hex");
  return signed;
}

console.log(JSON.stringify(signHmacSha512(accessToken, secretKey), null, 2));
</code>```

no promises it will definitely work, I did this before they became meta in the past 9 months

might be worth checking out this thread though
Facebook login message: "URL Blocked: This redirect failed because the redirect URI is not whitelisted in the app’s Client OAuth Settings."

Body:
The only thing I can think of is trying to use shaHmac512 to encrypt and sign your token, digesting with hex

I do remember having to do this for auth from localhost

and to gain access to "long-lived" access tokens for facebook business/facebook for developers

const accessToken = process.env.FACEBOOK_ACCESS_TOKEN ?? "";
const secretKey = process.env.FACEBOOK_SECRET ?? "";

function signHmacSha512(key: string, secret: string) {
  key = accessToken;
  secret = secretKey;
  const hmac = crypto.createHmac("sha512", key);
  const signed = hmac.update(Buffer.from(secret, "utf-8")).digest("hex");
  return signed;
}

console.log(JSON.stringify(signHmacSha512(accessToken, secretKey), null, 2));

no promises it will definitely work, I did this before they became meta in the past 9 months

might be worth checking out this thread though
Facebook login message: "URL Blocked: This redirect failed because the redirect URI is not whitelisted in the app’s Client OAuth Settings."


来源: stackexchange

问:
Relate an architecture to a Data Warehouse System Architecture
Below you find from the company EC4U an architecture
for a a data warehouse system. (OBI stands for Oracle Business Intelligence).
And I want to relate this architecture to the data warehouse system reference architecture
(see the first image) Which parts of the EC4U architecture fulfill the task(s) of which
components of the reference architecture?

I tried this, below you can find my solution. Is it right? Is something missing?

Data Warehouse System Architecture

EC4U Architecture

Solution

```<code>Reference Architecture      |        EC4U Architecture
=========================================================================
Data Sources                |        OLTP Application Server (Operational Systems)
Data Warehouse              |        OLAP DWH
Staging Area                |        Database Server
Transformation              |        ETL Server
DW Manager                  |        Information Server
Repository                  |        Config Files, RPD, Catalog, Log Files
Metadata Manager            |        BI Server

</code>```

Definitions

Functional Components

Data Warehouse Manager: Central component, starts, monitors and controls all
processes from extraction of data from the sources to analysis.

Monitors: detect and report to the data warehouse manager updates in the data
sources that are relevant for the DW. There is usually one Monitor per data source.

Extractors: select and transport data from the sources to the Staging Area

Transformators: Before loading into the Basic Database, data must be transformed
into a homogeneous internal format to be comparable => unify, integrate, consolidate,
aggregate, and supplement extracted data in the Staging Area.

Loading Components: Load acquired and transformed data from the Staging Area
to the Basic Database and from there finally into the DW

Analysis Components: Provide analysis and presentation of data in the DW.

Metadata Manager: A database application that controls the metadata management
of the DWS. It provides an interface for read and write access to the repository
where the metadata are stored.

Data components

Data sources: Operational systems with detailed data some or all of which are fed
to the DW

Staging Area: intermediate storage area where data is transformed and integrated
for the DW. Not necessarily a database system.

Basic Database: A database system with integrated data from which the DW is
updated periodically. Unlike in the DW, the data in the Basic Database can be changed
and deleted. It contains the data that has changed since the last loading of the
DW. Not every DWS has a Basic Database.

Repository: contains the metadata of the DW (comparable to a data dictionary).
Information from the respective data dictionaries of the source databases is also
imported into the Repository.

Data Warehouse (DW): a database with historical data designed in a model suited
to analytic needs.

答:
Database server (RDBMS, OLTP, Excel,Files) is the Data Source.
ETL Server represents the gray area un the 1st diagram (Extraction, Transformation, Loading, Staging Arda, etc.)
DWH is the Data Warehouse.

Both diagram elements don't match with one-to-one correspondance.

ContentLicense: CC BY-SA 4.0

Body:
Below you find from the company EC4U an architecture
for a a data warehouse system. (OBI stands for Oracle Business Intelligence).
And I want to relate this architecture to the data warehouse system reference architecture
(see the first image) Which parts of the EC4U architecture fulfill the task(s) of which
components of the reference architecture?

I tried this, below you can find my solution. Is it right? Is something missing?

Data Warehouse System Architecture

EC4U Architecture

Solution

Reference Architecture      |        EC4U Architecture
=========================================================================
Data Sources                |        OLTP Application Server (Operational Systems)
Data Warehouse              |        OLAP DWH
Staging Area                |        Database Server
Transformation              |        ETL Server
DW Manager                  |        Information Server
Repository                  |        Config Files, RPD, Catalog, Log Files
Metadata Manager            |        BI Server

Definitions

Functional Components

Data Warehouse Manager: Central component, starts, monitors and controls all
processes from extraction of data from the sources to analysis.

Monitors: detect and report to the data warehouse manager updates in the data
sources that are relevant for the DW. There is usually one Monitor per data source.

Extractors: select and transport data from the sources to the Staging Area

Transformators: Before loading into the Basic Database, data must be transformed
into a homogeneous internal format to be comparable => unify, integrate, consolidate,
aggregate, and supplement extracted data in the Staging Area.

Loading Components: Load acquired and transformed data from the Staging Area
to the Basic Database and from there finally into the DW

Analysis Components: Provide analysis and presentation of data in the DW.

Metadata Manager: A database application that controls the metadata management
of the DWS. It provides an interface for read and write access to the repository
where the metadata are stored.

Data components

Data sources: Operational systems with detailed data some or all of which are fed
to the DW

Staging Area: intermediate storage area where data is transformed and integrated
for the DW. Not necessarily a database system.

Basic Database: A database system with integrated data from which the DW is
updated periodically. Unlike in the DW, the data in the Basic Database can be changed
and deleted. It contains the data that has changed since the last loading of the
DW. Not every DWS has a Basic Database.

Repository: contains the metadata of the DW (comparable to a data dictionary).
Information from the respective data dictionaries of the source databases is also
imported into the Repository.

Data Warehouse (DW): a database with historical data designed in a model suited
to analytic needs.


问:
How to extract dates based on months using regex
```<code>import re

pattern = ['[\d]{1,2} [ADFJMNOS]\w* [\d]{2,4}','\d{1,2}/\d{1,2}/\d{2,4}']

text = "He welcomed me on 12 Jan 2014 and there by 15 OF 16 cakes for the party. Next morning on 16/05/2022 he waked up. He attended on 16 Feb 1966"

for i in pattern:
    temp_list = re.findall(i,text)
    print(temp_list)

Required output:
['12 Jan 2014','16 Feb 1966']
['16/05/2022']
</code>```

The output is coming with 15 OF 16. Is there any solution to get only the dates with months

答:
My advice is to use re.findall with the regular expression

```<code>\b\d{2,4}(?: +|\/)\S+(?: +|\/)\d{2,4}\b|\b[a-z]+ +\d{1,2},? +\d{4}\b
</code>```

Demo

The link shows that for the following string (which I've broken into two parts for readability) the indicated strings are matched.

```<code>blah 12 Jan 2014 blah 15 OF 16 blah 16/05/2022 blah 16 Feb 1966
     ^^^^^^^^^^^      ^^^^^^^^      ^^^^^^^^^^      ^^^^^^^^^^^
blah 2017/8/21 blah Jan 12, 2014 blah January 12, 2014 blah cat 0 0000
     ^^^^^^^^^      ^^^^^^^^^^^^      ^^^^^^^^^^^^^^^^      ^^^^^^^^^^
</code>```

Notice that I added additional date formats to those included in the example.

This is not what you want? Of course it's not, but it's effectively impossible to catch all valid date strings and only valid date strings with a single regular expression, so it's best to initially capture all the strings that may represent valid dates, and then filter them further, as described below.

There is another consideration. You may want to convert all the date strings you collect to a common format, for presentational and/or computational, purposes.

For each possible date string you collect in the first step you can next use strptime to see if the string matches any format string from a list of format strings that you construct. For each format string, if the string being tested represents a valid date a time tuple is returned; else a ValueError is raised.

By way of illustration, the list of format strings would include "%d %b %Y", which parses "12 Jan 2014", and "%Y/%m/%d", which parses "2017/8/21".

Not only will that tell you which strings represent valid dates but you can then use strftime (same link as strptime) with the time tuple obtained with strptime to display the dates in a consistent format.

Body:
import re

pattern = ['[\d]{1,2} [ADFJMNOS]\w* [\d]{2,4}','\d{1,2}/\d{1,2}/\d{2,4}']

text = "He welcomed me on 12 Jan 2014 and there by 15 OF 16 cakes for the party. Next morning on 16/05/2022 he waked up. He attended on 16 Feb 1966"

for i in pattern:
    temp_list = re.findall(i,text)
    print(temp_list)

Required output:
['12 Jan 2014','16 Feb 1966']
['16/05/2022']

The output is coming with 15 OF 16. Is there any solution to get only the dates with months

Body:
My advice is to use re.findall with the regular expression

\b\d{2,4}(?: +|\/)\S+(?: +|\/)\d{2,4}\b|\b[a-z]+ +\d{1,2},? +\d{4}\b

Demo

The link shows that for the following string (which I've broken into two parts for readability) the indicated strings are matched.

blah 12 Jan 2014 blah 15 OF 16 blah 16/05/2022 blah 16 Feb 1966
     ^^^^^^^^^^^      ^^^^^^^^      ^^^^^^^^^^      ^^^^^^^^^^^
blah 2017/8/21 blah Jan 12, 2014 blah January 12, 2014 blah cat 0 0000
     ^^^^^^^^^      ^^^^^^^^^^^^      ^^^^^^^^^^^^^^^^      ^^^^^^^^^^

Notice that I added additional date formats to those included in the example.

This is not what you want? Of course it's not, but it's effectively impossible to catch all valid date strings and only valid date strings with a single regular expression, so it's best to initially capture all the strings that may represent valid dates, and then filter them further, as described below.

There is another consideration. You may want to convert all the date strings you collect to a common format, for presentational and/or computational, purposes.

For each possible date string you collect in the first step you can next use strptime to see if the string matches any format string from a list of format strings that you construct. For each format string, if the string being tested represents a valid date a time tuple is returned; else a ValueError is raised.

By way of illustration, the list of format strings would include "%d %b %Y", which parses "12 Jan 2014", and "%Y/%m/%d", which parses "2017/8/21".

Not only will that tell you which strings represent valid dates but you can then use strftime (same link as strptime) with the time tuple obtained with strptime to display the dates in a consistent format.


问:
Error compiling Git via Home Brew
Having problems compiling Git via Homebrew

Error: Failed executing: make prefix=/usr/local/Cellar/git/1.7.6 install

I've deleted and reinstall Homebrew and also reinstalled Xcode 3.2.6

System:
Mac OS X 10.6.8

Any ideas what is going on?

Updated:

Here's the tail end of error trace. Not sure where else to look. Hope this helps.

```<code>referenced  from :
 " _libiconv",      referenced _reencode_stringfrom:
_reencode_stringin  libgit.a(inutf8.o )libgit.a
( utf8.o )"
_libiconv_close " ," _libiconv_close",    referencedreferenced  from   _reencode_string infrom:
   :
  libgit.a_reencode_string(  in  utf8.o    libgit.a_reencode_string( utf8.oin)
libgit.a ()utf8.o)
   "  _libiconv_close " ,
  referenced    _reencode_string  from:in
  libgit.a( _reencode_string utf8.o )
ld in :   _reencode_string symbol(s) not found
 in libgit.a(utf8.o)
ld: symbol(slibgit.a) not( utf8.o)
found
     _reencode_string in libgit.a(utf8.o)
ld: symbol(s) not found
collect2: collect2: Undefinedld returned 1 exit status
symbols:
  "ld returned 1 exit status_libiconv_open"
, referenced from:
      _reencode_string in libgit.a(utf8.o)
  "_libiconvcollect2: ", referencedld returned 1 exit status
from:
      _reencode_string in libgit.a(utf8.o)
  "_libiconv_close", referenced from:
      _reencode_string in libgit.a(utf8.o)
      _reencode_string in libgit.a(utf8.o)

ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [git-daemon] Error 1
make: *** Waiting for unfinished jobs....
make: *** [git-fast-import] Error 1
make: *** [git-imap-send] Error 1
make: *** [git-shell] Error 1
==> Exit Status: 2
http://github.com/mxcl/homebrew/blob/master/Library/Formula/git.rb#L37
==> Environment
HOMEBREW_VERSION: 0.8
HEAD: 63da621a3fb430cb9ae757a09077890be8aa689e
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_REPOSITORY: /usr/local
HOMEBREW_LIBRARY_PATH: /usr/local/Library/Homebrew
Hardware: quad-core 64-bit arrandale
OS X: 10.6.8
Kernel Architecture: i386
Ruby: 1.8.7-174
/usr/bin/ruby => /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
Xcode: 3.2.6
GCC-4.0: build 5494
GCC-4.2: build 5666
LLVM: build 2335
MacPorts or Fink? false
X11 installed? true
==> Build Flags
CC: /usr/bin/cc => /usr/bin/gcc-4.2
CXX: /usr/bin/c++ => /usr/bin/c++-4.2
LD: /usr/bin/cc => /usr/bin/gcc-4.2
CFLAGS: -O3 -w -pipe
CXXFLAGS: -O3 -w -pipe
MAKEFLAGS: -j4
</code>```

Not sure if it's worth noting but the trace shows Ruby 1.8
while ruby -v gives a ruby 1.9.2p180

Okay I've updated the error trace.

答: The ld: symbol(s) not found occurs either when you don't have a needed library dependency installed, or its inclusion or that of an object file is missing from the compile line for some reason.  Without knowing what symbols are not found, it's impossible to help further.  You cut off just at the good part of the error message.  It's like getting to the last chapter of a mystery novel and finding it ripped out :-)

ContentLicense: CC BY-SA 3.0

Title: Error compiling Git via Home Brew

Body:
Having problems compiling Git via Homebrew

Error: Failed executing: make prefix=/usr/local/Cellar/git/1.7.6 install

I've deleted and reinstall Homebrew and also reinstalled Xcode 3.2.6

System:
Mac OS X 10.6.8

Any ideas what is going on?

Updated:

Here's the tail end of error trace. Not sure where else to look. Hope this helps.

referenced  from :
 " _libiconv",      referenced _reencode_stringfrom:
_reencode_stringin  libgit.a(inutf8.o )libgit.a
( utf8.o )"
_libiconv_close " ," _libiconv_close",    referencedreferenced  from   _reencode_string infrom:
   :
  libgit.a_reencode_string(  in  utf8.o    libgit.a_reencode_string( utf8.oin)
libgit.a ()utf8.o)
   "  _libiconv_close " ,
  referenced    _reencode_string  from:in
  libgit.a( _reencode_string utf8.o )
ld in :   _reencode_string symbol(s) not found
 in libgit.a(utf8.o)
ld: symbol(slibgit.a) not( utf8.o)
found
     _reencode_string in libgit.a(utf8.o)
ld: symbol(s) not found
collect2: collect2: Undefinedld returned 1 exit status
symbols:
  "ld returned 1 exit status_libiconv_open"
, referenced from:
      _reencode_string in libgit.a(utf8.o)
  "_libiconvcollect2: ", referencedld returned 1 exit status
from:
      _reencode_string in libgit.a(utf8.o)
  "_libiconv_close", referenced from:
      _reencode_string in libgit.a(utf8.o)
      _reencode_string in libgit.a(utf8.o)

ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [git-daemon] Error 1
make: *** Waiting for unfinished jobs....
make: *** [git-fast-import] Error 1
make: *** [git-imap-send] Error 1
make: *** [git-shell] Error 1
==> Exit Status: 2
http://github.com/mxcl/homebrew/blob/master/Library/Formula/git.rb#L37
==> Environment
HOMEBREW_VERSION: 0.8
HEAD: 63da621a3fb430cb9ae757a09077890be8aa689e
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_REPOSITORY: /usr/local
HOMEBREW_LIBRARY_PATH: /usr/local/Library/Homebrew
Hardware: quad-core 64-bit arrandale
OS X: 10.6.8
Kernel Architecture: i386
Ruby: 1.8.7-174
/usr/bin/ruby => /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
Xcode: 3.2.6
GCC-4.0: build 5494
GCC-4.2: build 5666
LLVM: build 2335
MacPorts or Fink? false
X11 installed? true
==> Build Flags
CC: /usr/bin/cc => /usr/bin/gcc-4.2
CXX: /usr/bin/c++ => /usr/bin/c++-4.2
LD: /usr/bin/cc => /usr/bin/gcc-4.2
CFLAGS: -O3 -w -pipe
CXXFLAGS: -O3 -w -pipe
MAKEFLAGS: -j4

Not sure if it's worth noting but the trace shows Ruby 1.8
while ruby -v gives a ruby 1.9.2p180

Okay I've updated the error trace.


问:
How to find the element of a toast message in chrome
I am trying to get the field address of a toast message but gets disappearing very fast. Is there a way to pause it.</p>

答:
Here's a trick that I use:

Prepare for the toast notification to appear

Open Chrome's Developer Tools

Navigate to the Sources tab

(Switch back to the site) trigger the toast notification

(Switch back to the Sources tab) click "Pause script execution"

The site should now be frozen, including the toast notification.

Try using the "element inspector" or navigate to the Elements tab and search (ctrl+f / cmd+f) for content found in the toast notification's message.


问:
RealityKit - Can I make a RealityKit Entity's material with SwiftUI View?
Is it possible to augment SwiftUI view in AR World? I need a SwiftUI button view inside AR world. Is it possible to make material of a RealityKit Entity with SwiftUI View?

How can I get clickable SwiftUI button inside AR World?

(Not as a z index over ARViewContainer)

答: As far as I know there is no way to put a SwiftUI button into AR as it requires a totally different rendering system. If you want, you could create an AR ModelEntity (that looks like a SwiftUI button) and assign it an action when the user taps on it.</p>


问:
List sections empty after adding .id()
I have a section for each element in array. I need to use ScrollViewReader so I need to add .id() to each row. However, when I add id, list rows become empty. It works fine without id modifier. See the image below:

Here's the sample project I have made that demonstrates this problem:

import SwiftUI
import PlaygroundSupport

struct Interval: Identifiable {
    var id = UUID()
    var index: Int
    var name : String {
        "Interval \(index)"
    }
}

struct ContentView: View {

    var intervals: [Interval] = (1...9).map { index in Interval(index: index) }

    var body: some View {
        List {
            ForEach(intervals, id: \.id) { interval in
                Section {
                    Text(interval.name)
                        //.id(interval.id) // try removing this comment
                }
            }
        }
    }

}

PlaygroundPage.current.setLiveView(ContentView())
```
<p>Some debugging that I have done:</p>
<p>Having only 1 section works, but I need one section for every element.</p>
<pre class="lang-swift prettyprint-override"><code>Section {
    ForEach(intervals, id: \.id) { interval in
        Text(interval.name)
            .id(interval.id)
    }
}
</code>```

Adding each section manually also works, but this can't be done as I have lots of section in my actual project.

Section {
    Text(intervals[0].name)
        .id(intervals[0].id)
}
Section {
    Text(intervals[1].name)
        .id(intervals[1].id)
}
```

Does anyone know how to fix this? Thanks.

答:
the following using a VStack works for me (on real devices):

```<code>var body: some View {
    List {
        ForEach(intervals) { interval in
            Section {
                VStack { // <-- here
                    Text(interval.name).id(interval.id)
                }
            }
        }
    }
}
</code>```

Title: List sections empty after adding .id()

Body:
I have a section for each element in array. I need to use ScrollViewReader so I need to add .id() to each row. However, when I add id, list rows become empty. It works fine without id modifier. See the image below:

Here's the sample project I have made that demonstrates this problem:

import SwiftUI
import PlaygroundSupport

struct Interval: Identifiable {
    var id = UUID()
    var index: Int
    var name : String {
        "Interval \(index)"
    }
}

struct ContentView: View {

    var intervals: [Interval] = (1...9).map { index in Interval(index: index) }

    var body: some View {
        List {
            ForEach(intervals, id: \.id) { interval in
                Section {
                    Text(interval.name)
                        //.id(interval.id) // try removing this comment
                }
            }
        }
    }

}

PlaygroundPage.current.setLiveView(ContentView())

Some debugging that I have done:

Having only 1 section works, but I need one section for every element.

Section {
    ForEach(intervals, id: \.id) { interval in
        Text(interval.name)
            .id(interval.id)
    }
}

Adding each section manually also works, but this can't be done as I have lots of section in my actual project.

Section {
    Text(intervals[0].name)
        .id(intervals[0].id)
}
Section {
    Text(intervals[1].name)
        .id(intervals[1].id)
}

Does anyone know how to fix this? Thanks.

Body:
the following using a VStack works for me (on real devices):

var body: some View {
    List {
        ForEach(intervals) { interval in
            Section {
                VStack { // <-- here
                    Text(interval.name).id(interval.id)
                }
            }
        }
    }
}


问:
VSCode: There is no Pip installer available in the selected environment
I'm trying to run the autopep8 linter on a Python file in VSCode.

I've followed the instructions here: https://code.visualstudio.com/docs/python/environments and selected my interpreter (⇧⌘P): /usr/local/bin/python

I then try to format my code, and VSCode says autopep8 isn't installed, and can be installed via Pip. However, when I try to install via Pip, it says There is no Pip installer available in the selected environment.

I then tried launching a terminal in the current environment by selecting Python: Create Terminal from the Command Palette.

The terminal opens fine, pip is present, and I'm even able to pip install autopep8 in the terminal that opened in VSCode, but when I try running the Format Document command I get the same errors that autopep8 and pip aren't available in the environment.

答:
Go in (ctrl + shift + p), then type Python: Select Interpreter,
then type  Python: Select Interpreter and then click on "Enter interpreter path"
Then click on "Find.. Browse your file. "
Then type Python in c drive search bar and click on latest version of python in case if you have multiple version of python. Enter and modify wait for sometimes to complete then close.
After that restart your vs code.
It worked for me it will work for you also.</p>


问:
Can Nant be used to deploy to different servers?
Can Nant be used to deploy an application to a different set of servers based on some type of property/parameter?

What I need NANT to do:
An environment is made up of 1 or more servers.
We have multiple environments (dev, qa, prod).
The package contains multiple web-site projects.

When NANT is asked to build for DEV, it needs to build the projects and setup the web.config up correctly to work in the DEV environment (connection strings, etc). In addition each web-site project needs to be deployed to the correct server for that environment.

In addition, can NANT be used to build all my projects once and then deploy it multiple times (deploy to Dev, QA, Prod environments?) (ie, the build and deploy are done at different times and once a build has been created, the deploy could be run on that build package multiple times)

答:
I have a similar NAnt solution in place and this is what works well form me. In the same build file, I define different targets for compiling and setting up the different config files for each environment. My deployment target takes uses 3 parameters: copy source, copy destination, config file.

The files are copied from source to destination. Then the specified config file (Web.config.dev, Web.config.qa, Web.config.production) are copied to the destination and renamed to Web.config.


问:
How would I go about getting a json file into javascipt?
I'm extremely new to javascript, so assume I know nothing.
I'm trying to import this json file into my website, and having issues getting it working.
Currently, I'm trying out jquery's $.getJSON() method, but it returns with this error code:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///C:/Users/edgib102/Documents/GitHub/First-Website/data.json. (Reason: CORS request not http).

I tried looking online about it but nothing useful came up, so here I am.
Any help at all would be much appreciated, I've been stuck on this for 2 days now and it's brought my progress to a standstill.

Github

答:
This issue is because of safety.
Because of a security reason you cannot import a Json file in to your code because it contains data that could have some effects on the websites.

Your error caused by :

```<code><script type="text/javascript" src="data.json"></script>
</code>```

You can use Jquery and ajax to import it.

Step1: use jquery CDN

```<code><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"> </script>
</code>```

Step2:

```<code>$.getJSON('dataenter code here.json', function(data) {
    //do stuff with your data here
});
</code>```

good luck :)

Body:
This issue is because of safety.
Because of a security reason you cannot import a Json file in to your code because it contains data that could have some effects on the websites.

Your error caused by :

<script type="text/javascript" src="data.json"></script>

You can use Jquery and ajax to import it.

Step1: use jquery CDN

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"> </script>

Step2:

$.getJSON('dataenter code here.json', function(data) {
    //do stuff with your data here
});

good luck :)


问:
Aquaresizer doesn't work
I'm trying to include the aquaresize script in my theme. I have added it to assets/components/aq_resize.php

And required it in functions.php

```<code>require_once( 'assets/components/aq_resize.php' );
</code>```

However, when I try to echo

```<code>aq_resize($img_url,$width);
</code>```

Nothing is shown on the page, I gave the variables $img_url a url and $width a number

When I make a console.log in assets/components/aq_resize.php I can see the log in my console.

Why doesn't my aq_resizer work?

The aqua resizer code can be found here: https://github.com/syamilmj/Aqua-Resizer/blob/master/aq_resizer.php

To test it I used a random image from google.

```<code><?php
 $img_url = 'http://joombig.com/demo-extensions1/images/gallery_slider/Swan_large.jpg';
 $width = 300;
 echo aq_resize($img_url,$width);
?>
</code>```

答: I have solved the problem by activating "gd" library for xampp. You simply have to install/activate gd library. Go to php.ini file and check if "extension=gd" starts with ";". If it starts with ";" simply remove it. Otherwise insert a new line extension=gd.

Title: Aquaresizer doesn't work

Body:
I'm trying to include the aquaresize script in my theme. I have added it to assets/components/aq_resize.php

And required it in functions.php

require_once( 'assets/components/aq_resize.php' );

However, when I try to echo

aq_resize($img_url,$width);

Nothing is shown on the page, I gave the variables $img_url a url and $width a number

When I make a console.log in assets/components/aq_resize.php I can see the log in my console.

Why doesn't my aq_resizer work?

The aqua resizer code can be found here: https://github.com/syamilmj/Aqua-Resizer/blob/master/aq_resizer.php

To test it I used a random image from google.

<?php
 $img_url = 'http://joombig.com/demo-extensions1/images/gallery_slider/Swan_large.jpg';
 $width = 300;
 echo aq_resize($img_url,$width);
?>


问:
Concatenate files using PowerShell
I am using PowerShell 3.

What is best practice for concatenating files?

```<code>file1.txt + file2.txt = file3.txt
</code>```

Does PowerShell provide a facility for performing this operation directly? Or do I need each file's contents be loaded into local variables?

答:
```<code>gc file1.txt, file2.txt > output.txt
</code>```

I think this is as short as it gets.

Title: Concatenate files using PowerShell

Body:
I am using PowerShell 3.

What is best practice for concatenating files?

file1.txt + file2.txt = file3.txt

Does PowerShell provide a facility for performing this operation directly? Or do I need each file's contents be loaded into local variables?

Body:
gc file1.txt, file2.txt > output.txt

I think this is as short as it gets.


问:
Using Null variables in conditions in T-Sql
Is there a way to use a variable in the following manner?

```<code>DECLARE @ID int;
SET @ID = NULL;
SELECT *
FROM Market market
WHERE market.ID IS @ID
</code>```

Or is there another way to do this?

Thanks.

答:
If you just want to determine if market.ID is null, you would do this

```<code>SELECT *
FROM Market market
WHERE market.ID IS NULL
</code>```

If you're testing to see if market.ID is null or some other value then try this

```<code>SELECT *
FROM Market market
WHERE market.ID IS NULL
  OR market.ID = @ID
</code>```

Body:
Is there a way to use a variable in the following manner?

DECLARE @ID int;
SET @ID = NULL;
SELECT *
FROM Market market
WHERE market.ID IS @ID

Or is there another way to do this?

Thanks.

Body:
If you just want to determine if market.ID is null, you would do this

SELECT *
FROM Market market
WHERE market.ID IS NULL

If you're testing to see if market.ID is null or some other value then try this

SELECT *
FROM Market market
WHERE market.ID IS NULL
  OR market.ID = @ID


问:
Program works on GCC 7.5 on PC but not on online compiler
I have the following program that compiles successfully on my machine using GCC 7.5.0 but when i try out the program here the program doesn't work.

```<code>class Foo
{
    friend void ::error() { }

};
int main()
{

    return 0;
}
</code>```

The error here says:

```<code>Compilation failed due to following error(s).

    3 |     friend void ::error() { }
      |                         ^
</code>```

My question what is the problem here and how can i solve it.

答:
The problem is that a qualified friend declaration cannot be a definition. In your example, since the name error is qualified(because it has ::) so the corresponding friend declaration cannot be a definition.

This seems to be a bug in GCC 7.5.0. For example, for gcc 7.5.0 the program works but for gcc 8.4.0 and higher it doesn't work.

One way to solve thiswould be to remove the body { } of the error function and make it a declaration by adding semicolon ; as shown below:

```<code>//forward declare function error()
void error();

class Foo
{
    friend void ::error();//removed the body { } . This is now a declaration and not a definition

};
int main()
{

    return 0;
}
//definition of function error
void error()
{

}
</code>```

Note you can also put the definition of function error() before the definition of class Foo as shown here.

Another way to solve this would be to remove the :: and make error an unqualified name as shown here

Body:
I have the following program that compiles successfully on my machine using GCC 7.5.0 but when i try out the program here the program doesn't work.

class Foo
{
    friend void ::error() { }

};
int main()
{

    return 0;
}

The error here says:

Compilation failed due to following error(s).

    3 |     friend void ::error() { }
      |                         ^

My question what is the problem here and how can i solve it.

Body:
The problem is that a qualified friend declaration cannot be a definition. In your example, since the name error is qualified(because it has ::) so the corresponding friend declaration cannot be a definition.

This seems to be a bug in GCC 7.5.0. For example, for gcc 7.5.0 the program works but for gcc 8.4.0 and higher it doesn't work.

One way to solve thiswould be to remove the body { } of the error function and make it a declaration by adding semicolon ; as shown below:

//forward declare function error()
void error();

class Foo
{
    friend void ::error();//removed the body { } . This is now a declaration and not a definition

};
int main()
{

    return 0;
}
//definition of function error
void error()
{

}

Note you can also put the definition of function error() before the definition of class Foo as shown here.

Another way to solve this would be to remove the :: and make error an unqualified name as shown here


问:
print outnum to the standard output stream sample input 5,10,6,8 sample output 4
Consider an array of non-zero positive integers inarr. Identify and print a number outnum based on the below logic:

· Across each of the possible ways in which integers in inarr can be sequentially arranged, identify the maximum absolute difference of adjacent values

o The last and the first integers are adjacent

· Print outnum, the minimum value across the maximum differences identified above

Input:

The first line represents the array inarr with its elements separated by ‘,’(comma)

Read the inputs from the standard input stream

Output:

Print outnum to the standard output stream

Sample Input    Sample Output   Explanation

5,10,6,8    4

For the given inarr, the maximum absolute difference of adjacent values for all the possible ways in which integers can be arranged is as below:

5,10,6,8:

5 - 10 =5  àabsolute maximum difference

10 - 6 = 4

6 - 8 =2

8 - 5 =3

Similarly, for other possible ways:

5,10,8,6 - absolute max diff = 5

5,6,8,10 - absolute max diff = 5

5,6,10,8 - absolute max diff = 4

5,8,6,10 - absolute max diff = 5

5,8,10,6 - absolute max diff = 4

10,5,6,8 - absolute max diff = 5

10,5,8,6 - absolute max diff = 5

10,6,5,8 - absolute max diff = 4

10,6,8,5 - absolute max diff = 5

10,8,6,5 - absolute max diff = 5

10,8,5,6 - absolute max diff = 4

6,5,10,8 - absolute max diff = 5

6,5,8,10 - absolute max diff = 4

6,8,5,10 - absolute max diff = 5

6,8,10,5 - absolute max diff = 5

6,10,5,8 - absolute max diff = 5

6,10,8,5 - absolute max diff = 4

8,5,6,10 - absolute max diff = 4

8,5,10,6 - absolute max diff = 5

8,6,5,10 - absolute max diff = 5

8,6,10,5 - absolute max diff = 5

8,10,5,6 - absolute max diff = 5

8,10,6,5 - absolute max diff = 4

The minimum value across the maximum differences is 4

答:
This might be useful for you</p>
```<code>def permutation(lst):
    if len(lst) == 0:
        return []
    if len(lst) == 1:
        return [lst]
    l = []
    for i in range(len(lst)):
       m = lst[i]
       remLst = lst[:i] + lst[i+1:]
       for p in permutation(remLst):
           l.append([m] + p)
    return l

data = [5,10,6,8]
got = []
for a in permutation(data):
    result = []
    for i in range(len(a)+1):
        if i > len(a)/2:
            result.append(abs(a[len(a)-1] - a[0]))
        else:
            result.append(abs(a[i] - a[i+1]))
    max_value = max(result)
    got.append(max_value)
print(list(set(sorted(got)))[0])
</code>```

Body:
This might be useful for you

def permutation(lst):
    if len(lst) == 0:
        return []
    if len(lst) == 1:
        return [lst]
    l = []
    for i in range(len(lst)):
       m = lst[i]
       remLst = lst[:i] + lst[i+1:]
       for p in permutation(remLst):
           l.append([m] + p)
    return l

data = [5,10,6,8]
got = []
for a in permutation(data):
    result = []
    for i in range(len(a)+1):
        if i > len(a)/2:
            result.append(abs(a[len(a)-1] - a[0]))
        else:
            result.append(abs(a[i] - a[i+1]))
    max_value = max(result)
    got.append(max_value)
print(list(set(sorted(got)))[0])


问:
Webpack Dev Server Config - contentBase not working in latest version
When I upgrade webpack to 4.0.0-beta.3 and run npx webpack serve I get this error:

```<code>[webpack-cli] Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
 - configuration has an unknown property 'contentBase'. These properties are valid:
   object { bonjour?, client?, compress?, devMiddleware?, firewall?, headers?, historyApiFallback?, host?, hot?, http2?, https?, liveReload?, onAfterSetupMiddleware?, onBeforeSetupMiddleware?, onListening?, open?, port?, proxy?, public?, setupExitSignals?, static?, transportMode?, watchFiles? }
</code>```

This is my webpack.config.js that works in 3.11.2:

```<code>const path = require('path');
const ArcGISPlugin = require("@arcgis/webpack-plugin");

module.exports = {
  mode: 'development',
  entry: {
      main: './app/main.js'
  },
  plugins: [
      new ArcGISPlugin()
  ],
  devServer: {
      contentBase: './'
  }
}
</code>```

my devDependencies from package.json:

```<code>  "devDependencies": {
    "@arcgis/webpack-plugin": "^4.18.0",
    "dojo-typings": "^1.11.11",
    "webpack-cli": "^4.7.2",
    "webpack-dev-server": "^4.0.0-beta.3"
</code>```

How do I need to update my config to get the latest version working? When I take out the dev server object, the server will run, but serve content out of ./public which doesn't exist.

I'm new to webpack, so I'm not yet familiar with the application, config, and requirements.

答:
```<code>  devServer: {
    static: {
      directory: path.join(__dirname, "public")
    },

    compress: true,
    port: 3010, // default 8000
  },
</code>```

Body:
When I upgrade webpack to 4.0.0-beta.3 and run npx webpack serve I get this error:

[webpack-cli] Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
 - configuration has an unknown property 'contentBase'. These properties are valid:
   object { bonjour?, client?, compress?, devMiddleware?, firewall?, headers?, historyApiFallback?, host?, hot?, http2?, https?, liveReload?, onAfterSetupMiddleware?, onBeforeSetupMiddleware?, onListening?, open?, port?, proxy?, public?, setupExitSignals?, static?, transportMode?, watchFiles? }

This is my webpack.config.js that works in 3.11.2:

const path = require('path');
const ArcGISPlugin = require("@arcgis/webpack-plugin");

module.exports = {
  mode: 'development',
  entry: {
      main: './app/main.js'
  },
  plugins: [
      new ArcGISPlugin()
  ],
  devServer: {
      contentBase: './'
  }
}

my devDependencies from package.json:

  "devDependencies": {
    "@arcgis/webpack-plugin": "^4.18.0",
    "dojo-typings": "^1.11.11",
    "webpack-cli": "^4.7.2",
    "webpack-dev-server": "^4.0.0-beta.3"

How do I need to update my config to get the latest version working? When I take out the dev server object, the server will run, but serve content out of ./public which doesn't exist.

I'm new to webpack, so I'm not yet familiar with the application, config, and requirements.


问:
cannot infer an appropriate lifetime for lifetime parameter '_ in function call due to conflicting requirements
i have a vector of a struct

 let list = vec![
        ListenerList {
            listener: Pattern {
                cmd: "sum"
            },
            handler: |listener, connection| Box::pin(simple_handler(listener, connection))
        }
    ];
```
<p>here is my struct</p>
<pre class="lang-rs prettyprint-override"><code>pub struct ListenerList<'a>{
    pub listener: Pattern<'a>,
    pub handler: fn(Subscription, &Connection) -> Pin<Box<dyn futures::Future<Output = ()>>>
}
</code>```

and here is my simple_handler function

async fn simple_handler(listener: Subscription, connection: &Connection){
    println!("work?")
}
```
<p>when i compile it i get this error</p>
```error[E0495]: cannot infer an appropriate lifetime for lifetime parameter '_ in function call due to conflicting requirements
  --> src/main.rs:19:54
   |
19 |             handler: |listener, connection| Box::pin(simple_handler(listener, connection))
   |                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |

```

答:
The problem is in the definition of the handler field of ListenerList, which has this type:

fn(Subscription, &Connection) -> Pin<Box<dyn futures::Future<Output = ()>>>
```
<p>Due to Rust's default trait object lifetime rules, it desugars to the trait object getting a <code>'static</code> bound, which we don't want:</p>
<pre class="lang-rust prettyprint-override"><code>fn(Subscription, &Connection) -> Pin<Box<dyn futures::Future<Output = ()> + 'static>>
</code>```

To fix this, specify the lifetime as '_:

fn(Subscription, &Connection) -> Pin<Box<dyn futures::Future<Output = ()> + '_>>
```

Body:
i have a vector of a struct

 let list = vec![
        ListenerList {
            listener: Pattern {
                cmd: "sum"
            },
            handler: |listener, connection| Box::pin(simple_handler(listener, connection))
        }
    ];

here is my struct

pub struct ListenerList<'a>{
    pub listener: Pattern<'a>,
    pub handler: fn(Subscription, &Connection) -> Pin<Box<dyn futures::Future<Output = ()>>>
}

and here is my simple_handler function

async fn simple_handler(listener: Subscription, connection: &Connection){
    println!("work?")
}

when i compile it i get this error

error[E0495]: cannot infer an appropriate lifetime for lifetime parameter '_ in function call due to conflicting requirements
  --> src/main.rs:19:54
   |
19 |             handler: |listener, connection| Box::pin(simple_handler(listener, connection))
   |                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |

Body:
The problem is in the definition of the handler field of ListenerList, which has this type:

fn(Subscription, &Connection) -> Pin<Box<dyn futures::Future<Output = ()>>>

Due to Rust's default trait object lifetime rules, it desugars to the trait object getting a 'static bound, which we don't want:

fn(Subscription, &Connection) -> Pin<Box<dyn futures::Future<Output = ()> + 'static>>

To fix this, specify the lifetime as '_:

fn(Subscription, &Connection) -> Pin<Box<dyn futures::Future<Output = ()> + '_>>


答:
```<code>package com.company;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        String [] str = bf.readLine().split(",");
        int arr[]  = new int[str.length+1];
        for (int i=0;i<str.length;i++){
            arr[i] = Integer.parseInt(str[i]);

        }
        for (int i=0;i< str.length;i++){
            int maxdif = 0;
            int diff =0;
            diff = arr[i] - arr[i+1];
            maxdif = diff;
            checkmax(Math.abs(diff));
            System.out.println(Math.abs(maxdif));

//      5,10,6,8

        }

    }
    public static int checkmax(int diff){
        int []num = new int[200];
        while (0<diff)
        System.out.println(num[]);
        return 0;

    }
}
</code>```

Title: print outnum to the standard output stream sample input 5,10,6,8 sample output 4

Body:
Consider an array of non-zero positive integers inarr. Identify and print a number outnum based on the below logic:

· Across each of the possible ways in which integers in inarr can be sequentially arranged, identify the maximum absolute difference of adjacent values

o The last and the first integers are adjacent

· Print outnum, the minimum value across the maximum differences identified above

Input:

The first line represents the array inarr with its elements separated by ‘,’(comma)

Read the inputs from the standard input stream

Output:

Print outnum to the standard output stream

Sample Input    Sample Output   Explanation

5,10,6,8    4

For the given inarr, the maximum absolute difference of adjacent values for all the possible ways in which integers can be arranged is as below:

5,10,6,8:

5 - 10 =5  àabsolute maximum difference

10 - 6 = 4

6 - 8 =2

8 - 5 =3

Similarly, for other possible ways:

5,10,8,6 - absolute max diff = 5

5,6,8,10 - absolute max diff = 5

5,6,10,8 - absolute max diff = 4

5,8,6,10 - absolute max diff = 5

5,8,10,6 - absolute max diff = 4

10,5,6,8 - absolute max diff = 5

10,5,8,6 - absolute max diff = 5

10,6,5,8 - absolute max diff = 4

10,6,8,5 - absolute max diff = 5

10,8,6,5 - absolute max diff = 5

10,8,5,6 - absolute max diff = 4

6,5,10,8 - absolute max diff = 5

6,5,8,10 - absolute max diff = 4

6,8,5,10 - absolute max diff = 5

6,8,10,5 - absolute max diff = 5

6,10,5,8 - absolute max diff = 5

6,10,8,5 - absolute max diff = 4

8,5,6,10 - absolute max diff = 4

8,5,10,6 - absolute max diff = 5

8,6,5,10 - absolute max diff = 5

8,6,10,5 - absolute max diff = 5

8,10,5,6 - absolute max diff = 5

8,10,6,5 - absolute max diff = 4

The minimum value across the maximum differences is 4


问:
Android Emulator stop working after update to 31.2.6 [M1/Apple Silicon]
After updating Android emulator to 31.2.6 today, emulator stop working. It says Connecting to the Emulator and process of qemu-system-aarch64 is become unresponsive

It worked well on previous version of emulator, which I downloaded with Arctic Fox, but can't rollback it

AS version: Bumblebee 2021.1.1 (downloaded it using Toolbox app)

macOS: Big Sur 11.6

答: how frustrating this is. My solution was to delete all (3) emulators and reinstall. I've only reinstalled one and I upped the APK level by one to Pixel3a XL API 31, up from 30. Emulator, at least initially, is working OK. The whole process has now taken a couple of hours.</p>


问:
Converting a pointer to int into a pointer to an array of int
I'm reading a book about the C language and it says

The assignment of an array name to a pointer to an array of ints, such as a, is implicitly converted into a pointer to the array’s first element, not a pointer to the whole array and it requires an explicit type conversion.

So the following code would give "Error: mismatched pointer types".

```<code>int(*arrPtr)[4] = NULL;
int a[4] = {7, 8, 9, 5};
arrPtr = a;
</code>```

We should change it to

```<code>arrPtr = (int(*)[4])a;
</code>```

My question is why it's required to do type casting when we can simply get the address of the whole array a using & operator.

```<code>arrPtr = &a;
</code>```

Is there any advantage in doing the cast? aren't they both the same?

答:
To clarify, here a is a pointer of type int* and points to the 0th element of the array.
arrPtr is a pointer that can point to an array of 4 integers.
So arrPtr and a are two different pointer types. And the compiler throws a warning if you try to assign a to arrPtr. But you can still do this assignment in C however it is not the way to do it.
Note that arrPtr = a & arrPtr = &a assigns the same memory address to arrPtr. But for &a the compiler doesn't show any warning.

See the below progarm output to get more clarity on this,

```<code>int main()
{
    int(*arrPtr)[4] = NULL;
    int(*arrPtrtemp)[4] = NULL;
    int *ptr;
    int a[4] = {7, 8, 9, 5};
    arrPtr = a;
    arrPtrtemp = &a;
    ptr = a;
    printf("arrPtr:%p\n", arrPtr);
    printf("arrPtrtemp:%p\n", arrPtrtemp);
    printf("ptr:%p\n", ptr);
    arrPtr++;
    arrPtrtemp++;
    ptr++;
    printf("arrPtr:%p\n", arrPtr);
    printf("arrPtrtemp:%p\n", arrPtrtemp);
    printf("ptr:%p\n", ptr);
    return 0;
}
</code>```

Will give the following output:

```<code>arrPtr:0x7ffc1bf19820
arrPtrtemp:0x7ffc1bf19820
ptr:0x7ffc1bf19820
arrPtr:0x7ffc1bf19830
arrPtrtemp:0x7ffc1bf19830
ptr:0x7ffc1bf19824
</code>```

Note that arrPtr & arrPtrtemp are same and works same irrespective of the compiler warning. The purpose of this typecasting arrPtr = (int(*)[4])a; is to convet int* to int(*)[4].
The main difference between int & int()[4]** comes in pointer arithmetic.
so if we assume the size of an integer is 4 bytes in our system, an operation like ptr++(an int* pointer) will increment the address by 4 bytes. And arrPtr++ (an int(*)[4] pointer) will increment the address by 16 bytes.

Edit:-
here a is a pointer of type int* and points to the 0th element of the array. Change to the following,

When using the array name a to assign the address of the 0th element of the array, the compiler checks the pointer type of a as int*. And by using & operator to get the address of array a, the compiler will treat the pointer type of &a as int (*)[4] in this case. And no warning will be displayed.

Body:
I'm reading a book about the C language and it says

The assignment of an array name to a pointer to an array of ints, such as a, is implicitly converted into a pointer to the array’s first element, not a pointer to the whole array and it requires an explicit type conversion.

So the following code would give "Error: mismatched pointer types".

int(*arrPtr)[4] = NULL;
int a[4] = {7, 8, 9, 5};
arrPtr = a;

We should change it to

arrPtr = (int(*)[4])a;

My question is why it's required to do type casting when we can simply get the address of the whole array a using & operator.

arrPtr = &a;

Is there any advantage in doing the cast? aren't they both the same?

Body:
To clarify, here a is a pointer of type int* and points to the 0th element of the array.
arrPtr is a pointer that can point to an array of 4 integers.
So arrPtr and a are two different pointer types. And the compiler throws a warning if you try to assign a to arrPtr. But you can still do this assignment in C however it is not the way to do it.
Note that arrPtr = a & arrPtr = &a assigns the same memory address to arrPtr. But for &a the compiler doesn't show any warning.

See the below progarm output to get more clarity on this,

int main()
{
    int(*arrPtr)[4] = NULL;
    int(*arrPtrtemp)[4] = NULL;
    int *ptr;
    int a[4] = {7, 8, 9, 5};
    arrPtr = a;
    arrPtrtemp = &a;
    ptr = a;
    printf("arrPtr:%p\n", arrPtr);
    printf("arrPtrtemp:%p\n", arrPtrtemp);
    printf("ptr:%p\n", ptr);
    arrPtr++;
    arrPtrtemp++;
    ptr++;
    printf("arrPtr:%p\n", arrPtr);
    printf("arrPtrtemp:%p\n", arrPtrtemp);
    printf("ptr:%p\n", ptr);
    return 0;
}

Will give the following output:

arrPtr:0x7ffc1bf19820
arrPtrtemp:0x7ffc1bf19820
ptr:0x7ffc1bf19820
arrPtr:0x7ffc1bf19830
arrPtrtemp:0x7ffc1bf19830
ptr:0x7ffc1bf19824

Note that arrPtr & arrPtrtemp are same and works same irrespective of the compiler warning. The purpose of this typecasting arrPtr = (int(*)[4])a; is to convet int* to int(*)[4].
The main difference between int & int()[4]** comes in pointer arithmetic.
so if we assume the size of an integer is 4 bytes in our system, an operation like ptr++(an int* pointer) will increment the address by 4 bytes. And arrPtr++ (an int(*)[4] pointer) will increment the address by 16 bytes.

Edit:-
here a is a pointer of type int* and points to the 0th element of the array. Change to the following,

When using the array name a to assign the address of the 0th element of the array, the compiler checks the pointer type of a as int*. And by using & operator to get the address of array a, the compiler will treat the pointer type of &a as int (*)[4] in this case. And no warning will be displayed.


问:
fatal error: google fonts in flutter throws error
i'm getting this error in flutter

```<code>../../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/google_fonts-2.3.0/lib/google_fonts.dart:142265:7: Error: No named parameter with the name 'displayLarge'.
      displayLarge:
      ^^^^^^^^^^^^
../../../snap/flutter/common/flutter/packages/flutter/lib/src/material/text_theme.dart:81:9: Context: Found this candidate, but the arguments don't match.
  const TextTheme({
        ^^^^^^^^^

</code>```

while running mobile application

some code snippets...

pubspec.yaml

```<code>dependencies:
  flutter:
    sdk: flutter
  http: ^0.13.4
  cupertino_icons: ^1.0.2
  google_fonts:
  get:
</code>```

code

```<code>     Padding(
              padding: const EdgeInsets.all(8.0),
              child: Text(
                'Details',
                style: GoogleFonts.pacifico(),
              ),
            )
</code>```

thank you in advance

答: i have updated flutter version to 2.10.0 & now it is working</p>

Body:
i'm getting this error in flutter

../../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/google_fonts-2.3.0/lib/google_fonts.dart:142265:7: Error: No named parameter with the name 'displayLarge'.
      displayLarge:
      ^^^^^^^^^^^^
../../../snap/flutter/common/flutter/packages/flutter/lib/src/material/text_theme.dart:81:9: Context: Found this candidate, but the arguments don't match.
  const TextTheme({
        ^^^^^^^^^

while running mobile application

some code snippets...

pubspec.yaml

dependencies:
  flutter:
    sdk: flutter
  http: ^0.13.4
  cupertino_icons: ^1.0.2
  google_fonts:
  get:

code

     Padding(
              padding: const EdgeInsets.all(8.0),
              child: Text(
                'Details',
                style: GoogleFonts.pacifico(),
              ),
            )

thank you in advance


问:
Importxml() returned "empty cells" or "formula parse error"
I tried Importhtml ("https://nepsealpha.com/investment-calandar/dividend","table",) and then Importxml("https://nepsealpha.com/investment-calandar/dividend",xpath). I found out xpath from "selectorgadget" extension of googlechrome, but still couldn't import it. It shows either "empty content" or formula parse error".

答:
You can retrieve quite all the informations this way

```<code>=importxml(url,"//div/@data-page")
</code>```

and then parse the json.

By script : =getData("https://nepsealpha.com/investment-calandar/dividend")

```<code>function getData(url) {
  var from='data-page="'
  var to='"></div></body>'
  var jsonString = UrlFetchApp.fetch(url).getContentText().split(from)[1].split(to)[0].replace(/"/g,'"')
  var json = JSON.parse(jsonString).props.today_prices_summary.top_volume
  var headers = Object.keys(json[0]);
  return  ([headers, ...json.map(obj => headers.map(header => obj[header]))]);
}
</code>```

edit

to update periodically, add this script

```<code>function update(){
  var chk = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0].getRange('A1')
  chk.setValue(!chk.getValue())
}
</code>```

put a trigger as you wish on the update function and change as follows

```<code>=getData("https://nepsealpha.com/investment-calandar/dividend",$A$1)
</code>```

Body:
You can retrieve quite all the informations this way

=importxml(url,"//div/@data-page")

and then parse the json.

By script : =getData("https://nepsealpha.com/investment-calandar/dividend")

function getData(url) {
  var from='data-page="'
  var to='"></div></body>'
  var jsonString = UrlFetchApp.fetch(url).getContentText().split(from)[1].split(to)[0].replace(/&quot;/g,'"')
  var json = JSON.parse(jsonString).props.today_prices_summary.top_volume
  var headers = Object.keys(json[0]);
  return  ([headers, ...json.map(obj => headers.map(header => obj[header]))]);
}

edit

to update periodically, add this script

function update(){
  var chk = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0].getRange('A1')
  chk.setValue(!chk.getValue())
}

put a trigger as you wish on the update function and change as follows

=getData("https://nepsealpha.com/investment-calandar/dividend",$A$1)


问:
how can I remove this one in beautifulsoup python
I want to get only the text save in the html below using bs and discard the text del. How can I do that?

```<code><div>
<span class="chk_box">
  <input id="subj5" name="subj" onclick="subjSel();" type="checkbox" value="5"/>
  <label for="subj5">
   SAVE1
  </label>
 </span>
 <span class="chk_box">
  <input id="subj6" name="subj" onclick="subjSel();" type="checkbox" value="6"/>
  <label for="subj6">
   SAVE2
  </label>
 </span>
 <span class="chk_box">
  <input disabled="" id="subj7" name="subj" onclick="subjSel();" type="checkbox" value="7"/>
  <label for="" subj7""="">
  DEL1
  </label>
 </span>
 <span class="chk_box">
  <input disabled="" id="subj8" name="subj" onclick="subjSel();" type="checkbox" value="8"/>
  <label for="subj78">
   DEL2
  </label>
 </span>
</div>
</code>```

答:
It looks like the discriminating feature is that the items you want to extract are missing disabled='' in input. So you could filter on that:

```<code>from bs4 import BeautifulSoup

html = '''<div>
<span class="chk_box">
  <input id="subj5" name="subj" onclick="subjSel();" type="checkbox" value="5"/>
  <label for="subj5">
   SAVE1
  </label>
 </span>
 <span class="chk_box">
  <input id="subj6" name="subj" onclick="subjSel();" type="checkbox" value="6"/>
  <label for="subj6">
   SAVE2
  </label>
 </span>
 <span class="chk_box">
  <input disabled="" id="subj7" name="subj" onclick="subjSel();" type="checkbox" value="7"/>
  <label for="" subj7""="">
  DEL1
  </label>
 </span>
 <span class="chk_box">
  <input disabled="" id="subj8" name="subj" onclick="subjSel();" type="checkbox" value="8"/>
  <label for="subj78">
   DEL2
  </label>
 </span>
</div>'''

soup = BeautifulSoup(html)
results = [i.find_next_sibling().get_text().strip() for i in soup.find_all('input', {'disabled':None})]
</code>```

Output:

```<code>['SAVE1', 'SAVE2']
</code>```

Body:
I want to get only the text save in the html below using bs and discard the text del. How can I do that?

  <input id="subj5" name="subj" onclick="subjSel();" type="checkbox" value="5"/>

   SAVE1

  <input id="subj6" name="subj" onclick="subjSel();" type="checkbox" value="6"/>

   SAVE2

  <input disabled="" id="subj7" name="subj" onclick="subjSel();" type="checkbox" value="7"/>

  DEL1

  <input disabled="" id="subj8" name="subj" onclick="subjSel();" type="checkbox" value="8"/>

   DEL2

Body:
It looks like the discriminating feature is that the items you want to extract are missing disabled='' in input. So you could filter on that:

from bs4 import BeautifulSoup

html = '''<div>
<span class="chk_box">
  <input id="subj5" name="subj" onclick="subjSel();" type="checkbox" value="5"/>
  <label for="subj5">
   SAVE1
  </label>
 </span>
 <span class="chk_box">
  <input id="subj6" name="subj" onclick="subjSel();" type="checkbox" value="6"/>
  <label for="subj6">
   SAVE2
  </label>
 </span>
 <span class="chk_box">
  <input disabled="" id="subj7" name="subj" onclick="subjSel();" type="checkbox" value="7"/>
  <label for="" subj7""="">
  DEL1
  </label>
 </span>
 <span class="chk_box">
  <input disabled="" id="subj8" name="subj" onclick="subjSel();" type="checkbox" value="8"/>
  <label for="subj78">
   DEL2
  </label>
 </span>
</div>'''

soup = BeautifulSoup(html)
results = [i.find_next_sibling().get_text().strip() for i in soup.find_all('input', {'disabled':None})]

Output:

['SAVE1', 'SAVE2']


问:
Make counter not be less than zero in React.js
Consider the following code :

```<code>import React, { Component } from 'react';

class Counter extends Component {
  state = { value: 5 };

  increment = () => {
    this.setState(prevState => ({
      value: prevState.value + 1
    }));
  };

  decrement = () => {
    this.setState(prevState => ({
      value: prevState.value - 1
    }));
  };

  render() {
    return (
      <div>
        {this.state.value}
        <button onClick={this.increment}>+</button>
        <button onClick={this.decrement}>-</button>
      </div>
    )
  }
}
</code>```

How can I make it so that whenever I click the Decrement button, the value will not be less than 0. The value's minimum will always be zero and not -1, -2 ,-3 ,-4 ...

答:
On Way Use Conditional (ternary) operator  in decrement  Function

```<code>     decrement = () => {
        this.setState(prevState => ({
          value: prevState.value ? prevState.value -1 : 0
        }));
      };
</code>```

Body:
Consider the following code :

import React, { Component } from 'react';

class Counter extends Component {
  state = { value: 5 };

  increment = () => {
    this.setState(prevState => ({
      value: prevState.value + 1
    }));
  };

  decrement = () => {
    this.setState(prevState => ({
      value: prevState.value - 1
    }));
  };

  render() {
    return (

        {this.state.value}
        <button onClick={this.increment}>+</button>
        <button onClick={this.decrement}>-</button>

    )
  }
}

How can I make it so that whenever I click the Decrement button, the value will not be less than 0. The value's minimum will always be zero and not -1, -2 ,-3 ,-4 ...

Body:
On Way Use Conditional (ternary) operator  in decrement  Function

     decrement = () => {
        this.setState(prevState => ({
          value: prevState.value ? prevState.value -1 : 0
        }));
      };


问:
Error creating VPC: UnauthorizedOperation
I am trying to create VPC by using terraform, I am using IAM user's secrate and access key for authentication.
But when trying to create VPC it is throwing "Error creating VPC: UnauthorizedOperation: You are not authorized to perform this operation. Encoded authorization failure message: <encode_message>"
When I decode this message then I got it's don't have permission to ec2:createVpc. But I have assign Administrator Access, ec2 full access and vpc full access to this user.
I am able to create any other resources by using this credentials.

Really appreciate your help. Thanks in advance.

答:
Your user may not have the necessary permissions to perform the action.

Try adding something like the following to your permissions:

```<code>{
    "Sid": "VisualEditor1",
    "Effect": "Allow",
    "Action": "ec2:DescribeVpcs",
    "Resource": "*"
},
{
    "Sid": "foo",
    "Effect": "Allow",
    "Action": [
        "ec2:CreateVpc",
        "ec2:DeleteVpc"
    ],
    "Resource": "*"
}
</code>```

Body:
Your user may not have the necessary permissions to perform the action.

Try adding something like the following to your permissions:

{
    "Sid": "VisualEditor1",
    "Effect": "Allow",
    "Action": "ec2:DescribeVpcs",
    "Resource": "*"
},
{
    "Sid": "foo",
    "Effect": "Allow",
    "Action": [
        "ec2:CreateVpc",
        "ec2:DeleteVpc"
    ],
    "Resource": "*"
}


问:
Is there a way to allocate an Objective-C NSArray with objects contained in a C-style macro?
What I'd like to do is something like this:

```<code>NSArray *someArray = [[NSArray alloc] initWithObjects: C_MACRO, nil];
</code>```

With the C_MACRO part being an outlying file that uses a #define to list some number of NSStrings, so when I need to change the string objects that populate the array I can conveniently do in one file. So far, it seems this is impossible. But then again, I'm a novice.

Anyone care to enlighten me?

答:
Why does it have to be a macro? The following works just as well:</p>

```<code>NSString *words[] = {@"Hello", @"World!"}; // this can be a global
...
NSArray *array = [NSArray arrayWithObjects:words count:sizeof(words)/sizeof(*words)];
</code>```

Body:
What I'd like to do is something like this:

NSArray *someArray = [[NSArray alloc] initWithObjects: C_MACRO, nil];

With the C_MACRO part being an outlying file that uses a #define to list some number of NSStrings, so when I need to change the string objects that populate the array I can conveniently do in one file. So far, it seems this is impossible. But then again, I'm a novice.

Anyone care to enlighten me?

Body:
Why does it have to be a macro? The following works just as well:

NSString *words[] = {@"Hello", @"World!"}; // this can be a global
...
NSArray *array = [NSArray arrayWithObjects:words count:sizeof(words)/sizeof(*words)];


问:
How to select between different child components, depending on code higher up?
Below is a component for a List/
 where there is a
 for each item in classesByName. Is there any way to decide between using the component <ClassItemAnchor /> and an alternative, say <ClassItemButton /> depending on code higher up (outside of <ClassList />)? Otherwise, I'd have to create a new
 component to have a different
 component?

```<code>import ClassItemAnchor from "./ClassItemAnchor"

const ClassList = ({ classesByName, getChat, searchName }) => {

    return (
        <ul className="chat-list">
            {classesByName.map((Class) => (
                <ClassItemAnchor
                    key={Class.id}
                    Class={Class}
                    searchName={searchName}
                    getChat={getChat}
                />
            ))}
        </ul>
    )
}

export default ClassList

</code>```

Thank you

答:
You can pass a prop named isAnchor (Boolean) from parent to conditionally render the ClassItemAnchor and ClassItemButton.

```<code>const ClassList = ({ classesByName, getChat, searchName, isAnchor = true }) => {
  return (
    <ul className="chat-list">
      {classesByName.map((Class) =>
        isAnchor ? (
          <ClassItemAnchor
            key={Class.id}
            Class={Class}
            searchName={searchName}
            getChat={getChat}
          />
        ) : (
          <ClassItemButton
            key={Class.id}
            Class={Class}
            searchName={searchName}
            getChat={getChat}
          />
        )
      )}
    </ul>
  );
};
</code>```

if isAnchor is true , it will render ClassItemAnchor else ClassItemButton

Usage

```<code><ClassList isAnchor={true}/>
</code>```

Body:
Below is a component for a List/
 where there is a
 for each item in classesByName. Is there any way to decide between using the component <ClassItemAnchor /> and an alternative, say <ClassItemButton /> depending on code higher up (outside of <ClassList />)? Otherwise, I'd have to create a new
 component to have a different
 component?

import ClassItemAnchor from "./ClassItemAnchor"

const ClassList = ({ classesByName, getChat, searchName }) => {

    return (

            {classesByName.map((Class) => (
                <ClassItemAnchor
                    key={Class.id}
                    Class={Class}
                    searchName={searchName}
                    getChat={getChat}
                />
            ))}

    )
}

export default ClassList

Thank you

Body:
You can pass a prop named isAnchor (Boolean) from parent to conditionally render the ClassItemAnchor and ClassItemButton.

const ClassList = ({ classesByName, getChat, searchName, isAnchor = true }) => {
  return (
    <ul className="chat-list">
      {classesByName.map((Class) =>
        isAnchor ? (
          <ClassItemAnchor
            key={Class.id}
            Class={Class}
            searchName={searchName}
            getChat={getChat}
          />
        ) : (
          <ClassItemButton
            key={Class.id}
            Class={Class}
            searchName={searchName}
            getChat={getChat}
          />
        )
      )}
    </ul>
  );
};

if isAnchor is true , it will render ClassItemAnchor else ClassItemButton

Usage

<ClassList isAnchor={true}/>


问:
How would I go about getting a json file into javascipt?
I'm extremely new to javascript, so assume I know nothing.
I'm trying to import this json file into my website, and having issues getting it working.
Currently, I'm trying out jquery's $.getJSON() method, but it returns with this error code:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///C:/Users/edgib102/Documents/GitHub/First-Website/data.json. (Reason: CORS request not http).

I tried looking online about it but nothing useful came up, so here I am.
Any help at all would be much appreciated, I've been stuck on this for 2 days now and it's brought my progress to a standstill.

Github

答:
You cannot import a JSON file in a script tag

You cannot AJAX a JSON file from file system - if you can upload the files to the same webserver (could be a locally run server), then you CAN AJAX it - NOTE the server needs to send correct CORS headers if the server has a different ORIGIN (for example port number)

Alternatively change the JSON file to a JS file:

```<code>const data = { "object-data": {
    your data
  }
};
</code>```

and then import it using

```<code><script src="data.js"></script>
</code>```

Body:
You cannot import a JSON file in a script tag

You cannot AJAX a JSON file from file system - if you can upload the files to the same webserver (could be a locally run server), then you CAN AJAX it - NOTE the server needs to send correct CORS headers if the server has a different ORIGIN (for example port number)

Alternatively change the JSON file to a JS file:

const data = { "object-data": {
    your data
  }
};

and then import it using

<script src="data.js"></script>


问:
How can I get all folders that contain the images using MediaStore?
I'm getting all images from the user gallery using this code:

```<code>String[] projection = {MediaStore.Images.Media.DATA};
Cursor cursor = MediaStore.Images.Media.query(requireContext().getContentResolver(), MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, null, MediaStore.Images.Media.DATE_ADDED + " desc");
while (cursor.moveToNext()) {
    list.add(cursor.getString(0));
}
</code>```

I want to ask how can I get all folders that contain the above images using MediaStore?

I googled before posting this question to avoid the duplicated questions but I did not find anything as I want, I found related questions but it is for Android 10 and above.

Thank you.

答:
I found all folders of images using this way

```<code>Cursor cursor = MediaStore.Images.Media.query(
        requireContext().getContentResolver(),
        MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
        new String[]{MediaStore.Images.Media.BUCKET_DISPLAY_NAME});

while (cursor.moveToNext()) {
    Log.w("G183", cursor.getString(0));
}
</code>```

You can handle all folders in your way and remove the duplicated folders.

But there is something very weird

MediaStore.Images.Media.BUCKET_DISPLAY_NAME Added in API level 29 but at the same time, it's working on API levels under 29. How?

I discovered the solution by this answer because if you noticed the answer posted in 2014 and android 10 released in 2020 so I said how he used MediaStore.Images.Media.BUCKET_DISPLAY_NAME in 2014 but this added in 2020!

Body:
I'm getting all images from the user gallery using this code:

String[] projection = {MediaStore.Images.Media.DATA};
Cursor cursor = MediaStore.Images.Media.query(requireContext().getContentResolver(), MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, null, MediaStore.Images.Media.DATE_ADDED + " desc");
while (cursor.moveToNext()) {
    list.add(cursor.getString(0));
}

I want to ask how can I get all folders that contain the above images using MediaStore?

I googled before posting this question to avoid the duplicated questions but I did not find anything as I want, I found related questions but it is for Android 10 and above.

Thank you.

Body:
I found all folders of images using this way

Cursor cursor = MediaStore.Images.Media.query(
        requireContext().getContentResolver(),
        MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
        new String[]{MediaStore.Images.Media.BUCKET_DISPLAY_NAME});

while (cursor.moveToNext()) {
    Log.w("G183", cursor.getString(0));
}

You can handle all folders in your way and remove the duplicated folders.

But there is something very weird

MediaStore.Images.Media.BUCKET_DISPLAY_NAME Added in API level 29 but at the same time, it's working on API levels under 29. How?

I discovered the solution by this answer because if you noticed the answer posted in 2014 and android 10 released in 2020 so I said how he used MediaStore.Images.Media.BUCKET_DISPLAY_NAME in 2014 but this added in 2020!


问:
Is there an enhanced interpreter toploop for OCaml?
Python has IPython.. does OCaml have anything similar?

I'd very much like to have command history, although other features would be nice too. I've read that I could get command history by running it in Emacs, but I don't use Emacs..

答: There's utop! It has autocompletion, is emacs compatible and so on.</p>

ContentLicense: CC BY-SA 2.5


问:
How to replace a character in the string only giving its index?
Im making hangman and i want to put the blank and if he give the correct letters i want to put the correct letter to its correct index blanks this is my code

```<code>guess = "code"
howmuch = len(guess)
times = "_" * howmuch
blank = times
print(blank)
answer = input("what letter: ")
if answer in guess:
    change = guess.index(answer)
    blank[change] = answer
    print(blank)
else:
    print("wrong")
</code>```

TypeError = "str" object does not support item assignment

Pls give me the solution of this ill just add this to my hangman file this is the only problem to make my hangman program

答:
One way to do this might be converting it to list and then joining the list. This can be done by:

```<code>a = 'Hello'
lst1 = []
for i in a: lst1.append(i) # or use lst1 = list(a) as suggested by @buran
# Code to replace here, use replace function
a = ''.join(lst1)
</code>```

This is just a sample

Another way is to break the string at that index and then concatenating the new character with the replaced string:

```<code>a = 'Hello'
index = 1
character_to_replace_with = 'a'
final_str = a[:index]+character_to_replace_with+a[index+1:]

</code>```

Body:
Im making hangman and i want to put the blank and if he give the correct letters i want to put the correct letter to its correct index blanks this is my code

guess = "code"
howmuch = len(guess)
times = "_" * howmuch
blank = times
print(blank)
answer = input("what letter: ")
if answer in guess:
    change = guess.index(answer)
    blank[change] = answer
    print(blank)
else:
    print("wrong")

TypeError = "str" object does not support item assignment

Pls give me the solution of this ill just add this to my hangman file this is the only problem to make my hangman program

Body:
One way to do this might be converting it to list and then joining the list. This can be done by:

a = 'Hello'
lst1 = []
for i in a: lst1.append(i) # or use lst1 = list(a) as suggested by @buran
# Code to replace here, use replace function
a = ''.join(lst1)

This is just a sample

Another way is to break the string at that index and then concatenating the new character with the replaced string:

a = 'Hello'
index = 1
character_to_replace_with = 'a'
final_str = a[:index]+character_to_replace_with+a[index+1:]


问:
Can multiple threads run in parallel (not context switching) in multi core processor
I have been reading that if there are say 2 threads and 2 cores , then each thread if allocated to different cores , they will be able to run concurrently or at the exact same time . Lets consider 2 threads T1 , T2 with run time of 10 sec each.

Let's consider Single core first :

If these 2 threads were to run in a single core, they would be running by context switching which will of course not be parallel execution but sequential, the thread scheduler will pick one and assign a slot to run. So in single-core, it can't be possible that T1 is running at 10:00:00, and T2 is also  running at 10:00:00 concurrently. So here run time of both threadsis 20sec

Now consider multi core:

Lets say T1 begins running on core 1 at 10:00:00 am
Then is it possible that T2 also starts to run on core 2 at exactly 10:00:00 am ?

If yes , this simply means that here the run time is halved - so total time taken to run both threads on multicore is 10 secs?
I highly doubt this but this is what I am reading , please clarify

答:
Yes, you are right, multiple cores can run threads simultaneously i.e parallel execution of multiple threads is possible if we have multiple cores.
So it may happen that in your case, T1 and T2 runs on the exact same time, depending on the scheduler.

In single core though, because it can only run single thread at a time, it has to stop processing the first thread to give chance to second thread, before giving chance to thread T2, it saves the state of T1 and switches over to T2 this in fact is Context switching.

You can check this by running a simple program of starting 2 or more threads and see if they prints the exact almost similar timestamp or not.


问:
SVN how to resolve new tree conflicts when file is added on two branches
When merging a couple of branches (using SVN 1.6.1) where a file has been added on both branches (and then worked on in those separate branches) I'm getting one of the new tree conflicts:

```<code>      C foo.txt
  >   local obstruction, incoming add upon merge
</code>```

I need the changes from both branches, but the tree conflict doesn't give me the usual .working, .merge-left & .merge-right files -- which is understandable due to the nature of the conflict. There are quite a few of these conflict, and ones where a delete of the same file has occurred on each branch, but they're simple to resolve.

How can I resolve this issue? The SVN redbean book (for 1.6) doesn't cover this situation.

答:
I just managed to wedge myself pretty thoroughly trying to follow user619330's advice above.  The situation was: (1): I had added some files while working on my initial branch, branch1; (2) I created a new branch, branch2 for further development, branching it off from the trunk and then merging in my changes from branch1 (3) A co-worker had copied my mods from branch1 to his own branch, added further mods, and then merged back to the trunk; (4) I now wanted to merge the latest changes from trunk into my current working branch, branch2.  This is with svn 1.6.17.

The merge had tree conflicts with the new files, and I wanted the new version from the trunk where they differed, so from a clean copy of branch2, I did an svn delete of the conflicting files, committed these branch2 changes (thus creating a temporary version of branch2 without the files in question), and then did my merge from the trunk.  I did this because I wanted the history to match the trunk version so that I wouldn't have more problems later when trying to merge back to trunk.  Merge went fine, I got the trunk version of the files, svn st shows all ok, and then I hit more tree conflicts while trying to commit the changes, between the delete I had done earlier and the add from the merge.  Did an svn resolve of the conflicts in favor of my working copy (which now had the trunk version of the files), and got it to commit.  All should be good, right?

Well, no.  An update of another copy of branch2 resulted in the old version of the files (pre-trunk merge).  So now I have two different working copies of branch2, supposedly updated to the same version, with two different versions of the files, and both insisting that they are fully up to date!  Checking out a clean copy of branch2 resulted in the old (pre-trunk) version of the files.  I manually update these to the trunk version and commit the changes, go back to my first working copy (from which I had submitted the trunk changes originally), try to update it, and now get a checksum error on the files in question.  Blow the directory in question away, get a new version via update, and finally I have what should be a good version of branch2 with the trunk changes.  I hope.  Caveat developer.

Body:
When merging a couple of branches (using SVN 1.6.1) where a file has been added on both branches (and then worked on in those separate branches) I'm getting one of the new tree conflicts:

      C foo.txt
  >   local obstruction, incoming add upon merge

I need the changes from both branches, but the tree conflict doesn't give me the usual .working, .merge-left & .merge-right files -- which is understandable due to the nature of the conflict. There are quite a few of these conflict, and ones where a delete of the same file has occurred on each branch, but they're simple to resolve.

How can I resolve this issue? The SVN redbean book (for 1.6) doesn't cover this situation.


问:
Why does my conda environment work on one VSCode window but NOT on the others?
I got an annoying issue triggered my obsession.

I am using vscode on Mac. I have a python conda env and I am normally using it.

For one vscode window, when I do the log check through 'Output' button, it looks good:

```<code>Experiment 'pythonaa' is active
Experiment 'pythonTensorboardExperiment' is active
Experiment 'pythonSurveyNotification' is active
Experiment 'PythonPyTorchProfiler' is active
Experiment 'pythonDeprecatePythonPath' is active
> conda info --json
> ~/anaconda3/envs/gnn/bin/python ~/.vscode/extensions/ms-python.python-2022.0.1786462952/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2022.0.1786462952/pythonFiles/interpreterInfo.py
> ~/anaconda3/bin/python ~/.vscode/extensions/ms-python.python-2022.0.1786462952/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2022.0.1786462952/pythonFiles/interpreterInfo.py
> ~/anaconda3/envs/crawler/bin/python ~/.vscode/extensions/ms-python.python-2022.0.1786462952/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2022.0.1786462952/pythonFiles/interpreterInfo.py
Python interpreter path: ~/anaconda3/envs/gnn/bin/python
> . ~/anaconda3/bin/activate && conda activate gnn && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode/extensions/ms-python.python-2022.0.1786462952/pythonFiles/printEnvVariables.py
Starting Pylance language server.
> ~/anaconda3/envs/gnn/bin/python ~/.vscode/extensions/ms-python.python-2022.0.1786462952/pythonFiles/linter.py -m pylint ./greedy.py
cwd: .
</code>```

but when I opened the other windows, I got

```<code>ERROR 2022-1-6 15:57:27.538]: getActivatedEnvironmentVariables [SyntaxError: Invalid regular expression: //[mypath]: Nothing to repeat
    at new RegExp (<anonymous>)
    at h ([mypath]/.vscode/extensions/ms-python.python-2022.0.1786462952/out/client/extension.js:104:312461)
    at d.getDisplayCommands ([mypath]/.vscode/extensions/ms-python.python-2022.0.1786462952/out/client/extension.js:104:312240)
    at d.logProcess ([mypath]/.vscode/extensions/ms-python.python-2022.0.1786462952/out/client/extension.js:104:311978)
    at s.emit (events.js:315:20)
    at shellExec ([mypath]/.vscode/extensions/ms-python.python-2022.0.1786462952/out/client/extension.js:52:33373)
    at P.getActivatedEnvironmentVariablesImpl ([mypath]/.vscode/extensions/ms-python.python-2022.0.1786462952/out/client/extension.js:85:118653)]
Starting Pylance language server.

Linter 'pylint' is not installed. Please install it or select another linter".
SyntaxError: Invalid regular expression: //[mypath]: Nothing to repeat
</code>```

I use [mypath] to alternate my local path.

Please enlighten me how to solve it. I am sure my conda env is rightly linked to my vscode.

答:
Similar question: Error message "Linter pylint is not installed"

You need to activate the conda environment manually on the second one if not triggered automatically.

Check this conda guide to get more clarity on such environments: https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html

Body:
I got an annoying issue triggered my obsession.

I am using vscode on Mac. I have a python conda env and I am normally using it.

For one vscode window, when I do the log check through 'Output' button, it looks good:

Experiment 'pythonaa' is active
Experiment 'pythonTensorboardExperiment' is active
Experiment 'pythonSurveyNotification' is active
Experiment 'PythonPyTorchProfiler' is active
Experiment 'pythonDeprecatePythonPath' is active
> conda info --json
> ~/anaconda3/envs/gnn/bin/python ~/.vscode/extensions/ms-python.python-2022.0.1786462952/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2022.0.1786462952/pythonFiles/interpreterInfo.py
> ~/anaconda3/bin/python ~/.vscode/extensions/ms-python.python-2022.0.1786462952/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2022.0.1786462952/pythonFiles/interpreterInfo.py
> ~/anaconda3/envs/crawler/bin/python ~/.vscode/extensions/ms-python.python-2022.0.1786462952/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2022.0.1786462952/pythonFiles/interpreterInfo.py
Python interpreter path: ~/anaconda3/envs/gnn/bin/python
> . ~/anaconda3/bin/activate && conda activate gnn && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode/extensions/ms-python.python-2022.0.1786462952/pythonFiles/printEnvVariables.py
Starting Pylance language server.
> ~/anaconda3/envs/gnn/bin/python ~/.vscode/extensions/ms-python.python-2022.0.1786462952/pythonFiles/linter.py -m pylint ./greedy.py
cwd: .

but when I opened the other windows, I got

ERROR 2022-1-6 15:57:27.538]: getActivatedEnvironmentVariables [SyntaxError: Invalid regular expression: //[mypath]: Nothing to repeat
    at new RegExp (<anonymous>)
    at h ([mypath]/.vscode/extensions/ms-python.python-2022.0.1786462952/out/client/extension.js:104:312461)
    at d.getDisplayCommands ([mypath]/.vscode/extensions/ms-python.python-2022.0.1786462952/out/client/extension.js:104:312240)
    at d.logProcess ([mypath]/.vscode/extensions/ms-python.python-2022.0.1786462952/out/client/extension.js:104:311978)
    at s.emit (events.js:315:20)
    at shellExec ([mypath]/.vscode/extensions/ms-python.python-2022.0.1786462952/out/client/extension.js:52:33373)
    at P.getActivatedEnvironmentVariablesImpl ([mypath]/.vscode/extensions/ms-python.python-2022.0.1786462952/out/client/extension.js:85:118653)]
Starting Pylance language server.

Linter 'pylint' is not installed. Please install it or select another linter".
SyntaxError: Invalid regular expression: //[mypath]: Nothing to repeat

I use [mypath] to alternate my local path.

Please enlighten me how to solve it. I am sure my conda env is rightly linked to my vscode.


问:
ImportError: No system module 'pywintypes' (pywintypes39.dll)
I was making a virtual assistant in python, but I see the following error.

```<code>ImportError: No system module 'pywintypes' (pywintypes39.dll)
</code>```

I am using Windows 10 and Python 3.9

Here is the code

```<code>import speech_recognition as sr
import pyttsx3
listner=sr.Recognizer()
engine=pyttsx3.init()
engine.say('Hello Vishal. I am Cisco')
engine.say('What do you want me to do?')
engine.runAndWait()
try:
    with sr.Microphone() as source:
            print('listening...')
            voice=listner.listen(source)
            command = listner.recognize_google(voice)
            command=command.lower()
            if "cisco" in command:
                 print(command)
except:
    print('Something went wrong')
</code>```

Also when I run this program The console prints this:

```<code>    enter code hraceback (most recent call last):
  File "C:\Users\visha\AppData\Roaming\Python\Python39\site-packages\pyttsx3\__init__.py", line 20, in init
    eng = _activeEngines[driverName]
  File "C:\Program Files (x86)\Python\lib\weakref.py", line 134, in __getitem__
    o = self.data[key]()
KeyError: None

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\visha\Documents\Python\Basic.py", line 4, in <module>
    engine=pyttsx3.init()
  File "C:\Users\visha\AppData\Roaming\Python\Python39\site-packages\pyttsx3\__init__.py", line 22, in init
    eng = Engine(driverName, debug)
  File "C:\Users\visha\AppData\Roaming\Python\Python39\site-packages\pyttsx3\engine.py", line 30, in __init__
    self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
  File "C:\Users\visha\AppData\Roaming\Python\Python39\site-packages\pyttsx3\driver.py", line 50, in __init__
    self._module = importlib.import_module(name)
  File "C:\Program Files (x86)\Python\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "C:\Users\visha\AppData\Roaming\Python\Python39\site-packages\pyttsx3\drivers\sapi5.py", line 10, in <module>
    import pythoncom
  File "C:\Users\visha\AppData\Roaming\Python\Python39\site-packages\pythoncom.py", line 2, in <module>
    import pywintypes
  File "C:\Users\visha\AppData\Roaming\Python\Python39\site-packages\win32\lib\pywintypes.py", line 105, in <module>
    __import_pywin32_system_module__("pywintypes", globals())
  File "C:\Users\visha\AppData\Roaming\Python\Python39\site-packages\win32\lib\pywintypes.py", line 87, in __import_pywin32_system_module__
    raise ImportError("No system module '%s' (%s)" % (modname, filename))
ImportError: No system module 'pywintypes' (pywintypes39.dll)
PS C:\Users\visha\Documents\Python> ere
</code>```

I am a beginner so I don't have much idea.
Thanks in advance for your help

答: C:\Users\lenevo\AppData\Roaming\Python\Python39\site-packages\win32\lib . Just copy  the two files 'pythoncom39.dll' and 'pywintypes39.dll' from the 'pywin32_system32' folder in the lib folder "C:\Users\lenevo\AppData\Roaming\Python\Python39\site-packages\win32\lib "</p>

Body:
I was making a virtual assistant in python, but I see the following error.

ImportError: No system module 'pywintypes' (pywintypes39.dll)

I am using Windows 10 and Python 3.9

Here is the code

import speech_recognition as sr
import pyttsx3
listner=sr.Recognizer()
engine=pyttsx3.init()
engine.say('Hello Vishal. I am Cisco')
engine.say('What do you want me to do?')
engine.runAndWait()
try:
    with sr.Microphone() as source:
            print('listening...')
            voice=listner.listen(source)
            command = listner.recognize_google(voice)
            command=command.lower()
            if "cisco" in command:
                 print(command)
except:
    print('Something went wrong')

Also when I run this program The console prints this:

    enter code hraceback (most recent call last):
  File "C:\Users\visha\AppData\Roaming\Python\Python39\site-packages\pyttsx3\__init__.py", line 20, in init
    eng = _activeEngines[driverName]
  File "C:\Program Files (x86)\Python\lib\weakref.py", line 134, in __getitem__
    o = self.data[key]()
KeyError: None

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\visha\Documents\Python\Basic.py", line 4, in <module>
    engine=pyttsx3.init()
  File "C:\Users\visha\AppData\Roaming\Python\Python39\site-packages\pyttsx3\__init__.py", line 22, in init
    eng = Engine(driverName, debug)
  File "C:\Users\visha\AppData\Roaming\Python\Python39\site-packages\pyttsx3\engine.py", line 30, in __init__
    self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
  File "C:\Users\visha\AppData\Roaming\Python\Python39\site-packages\pyttsx3\driver.py", line 50, in __init__
    self._module = importlib.import_module(name)
  File "C:\Program Files (x86)\Python\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "C:\Users\visha\AppData\Roaming\Python\Python39\site-packages\pyttsx3\drivers\sapi5.py", line 10, in <module>
    import pythoncom
  File "C:\Users\visha\AppData\Roaming\Python\Python39\site-packages\pythoncom.py", line 2, in <module>
    import pywintypes
  File "C:\Users\visha\AppData\Roaming\Python\Python39\site-packages\win32\lib\pywintypes.py", line 105, in <module>
    __import_pywin32_system_module__("pywintypes", globals())
  File "C:\Users\visha\AppData\Roaming\Python\Python39\site-packages\win32\lib\pywintypes.py", line 87, in __import_pywin32_system_module__
    raise ImportError("No system module '%s' (%s)" % (modname, filename))
ImportError: No system module 'pywintypes' (pywintypes39.dll)
PS C:\Users\visha\Documents\Python> ere

I am a beginner so I don't have much idea.
Thanks in advance for your help


问:
React - Module not found: Can't resolve 'react-loading-overlay' in 'F:\htdocs\....'
I want to implement react-loading-overlay in react for full page loaders.

Tried doing following things:

So I tried to install react-overlay-loading but it still shows me the error as above.

What's getting wrong here ? Any ideas ?

答:
You are missing a module which is called react-loading-overlay which you can get by installing the package by using the command:

npm i react-loading-overlay-ts

This should install the required package.