问:
Warning message:In read.table(file = file, header = header, sep = sep, quote = quote, : incomplete final line found by readTableHeader on 'hola.csv'
Problem: in R I get Warning message:

In read.table(file = file, header = header, sep = sep, quote = quote,  :  incomplete final line found by readTableHeader on 'hola.csv'

To simplify I created a basic table in excel and I have saved it in all the .csv formats it offers (comma separated values, csv UTF8, MS2 csv etc) and the error persists in all of them. I'm working in mac 10.15 catalina, Excel version 16.29.1 (2019).

I changed the language of my laptop from Spain to Uk, selecting , for groups and . for decimals, as some people here suggested it may be due to some countries languages by default using semicolon instead of commas for csv. After this, as expected, csv are indeed created separated by commas, but I still get the warning.

As suggested, if I open the file in textedit and click enter at the end, saving it afterwards, R works perfectly and the error disappears, but it does not seem practical/efficient to do that every single time I want to open a csv. On the other hand it remains a mystery to me why working colleagues using mac UK configuration do not get this error (neither do I when I open csv they have created on their laptops).

Can it be the Excel version? Should I ignore the warning? (the table looks fine when opening it). thanks!

```<code>aq2<-read.csv("hola.csv")
</code>```

答: That is a warning message generated because R's read.table expects the final line to include an end of line character (either  or ). It's almost always an unnecessary warning. Many programs including Excel, will create files like that.</p>

Body:
Problem: in R I get Warning message:

In read.table(file = file, header = header, sep = sep, quote = quote,  :  incomplete final line found by readTableHeader on 'hola.csv'

To simplify I created a basic table in excel and I have saved it in all the .csv formats it offers (comma separated values, csv UTF8, MS2 csv etc) and the error persists in all of them. I'm working in mac 10.15 catalina, Excel version 16.29.1 (2019).

I changed the language of my laptop from Spain to Uk, selecting , for groups and . for decimals, as some people here suggested it may be due to some countries languages by default using semicolon instead of commas for csv. After this, as expected, csv are indeed created separated by commas, but I still get the warning.

As suggested, if I open the file in textedit and click enter at the end, saving it afterwards, R works perfectly and the error disappears, but it does not seem practical/efficient to do that every single time I want to open a csv. On the other hand it remains a mystery to me why working colleagues using mac UK configuration do not get this error (neither do I when I open csv they have created on their laptops).

Can it be the Excel version? Should I ignore the warning? (the table looks fine when opening it). thanks!

aq2<-read.csv("hola.csv")


来源: stackexchange

问:
The server time zone value 'AEST' is unrecognized or represents more than one time zone
I'm trying to setup a simple hibernate application, when I run it I get a stack trace full of errors.

I have the following maven dependencies in my pom.xml file:

```<code><dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>5.2.0.Final</version>
    </dependency>
    <!-- http://mvnrepository.com/artifact/mysql/mysql-connector-java -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>6.0.2</version>
    </dependency>
</code>```

And the mysql version I'm running locally is:

```<code>5.7.9, for osx10.11 (x86_64)
</code>```

I'm running, what seems, a very simple method, and still getting errors:

```<code>// create session factory
SessionFactory factory = new Configuration()
            .configure("hibernate.cfg.xml")
            .addAnnotatedClass(Model.class)
            .buildSessionFactory();

// create session
Session session = factory.getCurrentSession();

Model newModel = new Model("....", "...", "...");

// start a transaction
session.beginTransaction();

// save the student object
System.out.println("Saving the model...");
session.save(newModel);
</code>```

After the above is executed, I get a long stack trace...The System.out.println doesn't print either...So the connection just doesn't seem to be connecting.

```<code>INFO: HHH000115: Hibernate connection pool size: 1 (min=1)
Thu Jun 09 17:36:28 EST 2016 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Exception in thread "main" org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:244)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:208)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:51)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:217)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.handleTypes(MetadataBuildingProcess.java:352)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:111)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:83)
    at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:418)
    at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:87)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:691)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:723)
    at com.parkingapi.tests.Test.main(Test.java:17)
Caused by: org.hibernate.exception.JDBCConnectionException: Error calling Driver#connect
    at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator$1$1.convert(BasicConnectionCreator.java:105)
    at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.convertSqlException(BasicConnectionCreator.java:123)
    at org.hibernate.engine.jdbc.connections.internal.DriverConnectionCreator.makeConnection(DriverConnectionCreator.java:41)
    at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.createConnection(BasicConnectionCreator.java:58)
    at org.hibernate.engine.jdbc.connections.internal.PooledConnections.addConnections(PooledConnections.java:106)
    at org.hibernate.engine.jdbc.connections.internal.PooledConnections.<init>(PooledConnections.java:40)
    at org.hibernate.engine.jdbc.connections.internal.PooledConnections.<init>(PooledConnections.java:19)
    at org.hibernate.engine.jdbc.connections.internal.PooledConnections$Builder.build(PooledConnections.java:138)
    at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.buildPool(DriverManagerConnectionProviderImpl.java:110)
    at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:74)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:217)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.buildJdbcConnectionAccess(JdbcEnvironmentInitiator.java:145)
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:66)
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:234)
    ... 14 more
Caused by: java.sql.SQLException: The server time zone value 'AEST' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:695)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:663)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:653)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:638)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:606)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:624)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:620)
    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:68)
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:1683)
    at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:656)
    at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:349)
    at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:221)
    at org.hibernate.engine.jdbc.connections.internal.DriverConnectionCreator.makeConnection(DriverConnectionCreator.java:38)
    ... 29 more
Caused by: com.mysql.cj.core.exceptions.InvalidConnectionAttributeException: The server time zone value 'AEST' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
    at com.mysql.cj.core.exceptions.ExceptionFactory.createException(ExceptionFactory.java:54)
    at com.mysql.cj.core.exceptions.ExceptionFactory.createException(ExceptionFactory.java:73)
    at com.mysql.cj.jdbc.util.TimeUtil.getCanonicalTimezone(TimeUtil.java:118)
    at com.mysql.cj.mysqla.MysqlaSession.configureTimezone(MysqlaSession.java:308)
    at com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:2474)
    at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:1817)
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:1673)
    ... 33 more
</code>```

I'm focused on this error here:

The server time zone value 'AEST' is unrecognized or represents more
  than one time zone. You must configure either the server or JDBC
  driver (via the serverTimezone configuration property) to use a more
  specifc time zone value if you want to utilize time zone support.

I'm unsure how I fix it?

Edit:

Printing out the Timezone (System.out.println(TimeZone.getDefault());) prints the following details:

sun.util.calendar.ZoneInfo[id="Australia/Melbourne",offset=36000000,dstSavings=3600000,useDaylight=true,transitions=142,lastRule=java.util.SimpleTimeZone[id=Australia/Melbourne,offset=36000000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=9,startDay=1,startDayOfWeek=1,startTime=7200000,startTimeMode=1,endMode=3,endMonth=3,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=1]]

Edit:

So I looked at the question which was flagged, and tried to change my connection string, but it's still throwing the same stack trace. Below is my new connection url. As you can see I changed the serverTimezone to that of the printed Timezone.getDefault()

```<code>jdbc:mysql://localhost:3306/parking_hib?useLegacyDatetimeCode=false;serverTimezone=Australia/Melbourne;useSSL=false;
</code>```

答: I had a similar issue, i was using  mysql-connector-java 8.0.15 (latest), but for some reaon it was still giving me a timezone error, i changed it for  mysql-connector-java 8.0.13 and that just did it. Hope thats be usefull.</p>

ContentLicense: CC BY-SA 3.0

Body:
I'm trying to setup a simple hibernate application, when I run it I get a stack trace full of errors.

I have the following maven dependencies in my pom.xml file:

<dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>5.2.0.Final</version>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>6.0.2</version>
    </dependency>

And the mysql version I'm running locally is:

5.7.9, for osx10.11 (x86_64)

I'm running, what seems, a very simple method, and still getting errors:

// create session factory
SessionFactory factory = new Configuration()
            .configure("hibernate.cfg.xml")
            .addAnnotatedClass(Model.class)
            .buildSessionFactory();

// create session
Session session = factory.getCurrentSession();

Model newModel = new Model("....", "...", "...");

// start a transaction
session.beginTransaction();

// save the student object
System.out.println("Saving the model...");
session.save(newModel);

After the above is executed, I get a long stack trace...The System.out.println doesn't print either...So the connection just doesn't seem to be connecting.

INFO: HHH000115: Hibernate connection pool size: 1 (min=1)
Thu Jun 09 17:36:28 EST 2016 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Exception in thread "main" org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:244)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:208)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:51)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:217)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.handleTypes(MetadataBuildingProcess.java:352)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:111)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:83)
    at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:418)
    at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:87)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:691)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:723)
    at com.parkingapi.tests.Test.main(Test.java:17)
Caused by: org.hibernate.exception.JDBCConnectionException: Error calling Driver#connect
    at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator$1$1.convert(BasicConnectionCreator.java:105)
    at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.convertSqlException(BasicConnectionCreator.java:123)
    at org.hibernate.engine.jdbc.connections.internal.DriverConnectionCreator.makeConnection(DriverConnectionCreator.java:41)
    at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.createConnection(BasicConnectionCreator.java:58)
    at org.hibernate.engine.jdbc.connections.internal.PooledConnections.addConnections(PooledConnections.java:106)
    at org.hibernate.engine.jdbc.connections.internal.PooledConnections.<init>(PooledConnections.java:40)
    at org.hibernate.engine.jdbc.connections.internal.PooledConnections.<init>(PooledConnections.java:19)
    at org.hibernate.engine.jdbc.connections.internal.PooledConnections$Builder.build(PooledConnections.java:138)
    at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.buildPool(DriverManagerConnectionProviderImpl.java:110)
    at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:74)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:217)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.buildJdbcConnectionAccess(JdbcEnvironmentInitiator.java:145)
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:66)
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:234)
    ... 14 more
Caused by: java.sql.SQLException: The server time zone value 'AEST' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:695)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:663)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:653)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:638)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:606)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:624)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:620)
    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:68)
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:1683)
    at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:656)
    at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:349)
    at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:221)
    at org.hibernate.engine.jdbc.connections.internal.DriverConnectionCreator.makeConnection(DriverConnectionCreator.java:38)
    ... 29 more
Caused by: com.mysql.cj.core.exceptions.InvalidConnectionAttributeException: The server time zone value 'AEST' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
    at com.mysql.cj.core.exceptions.ExceptionFactory.createException(ExceptionFactory.java:54)
    at com.mysql.cj.core.exceptions.ExceptionFactory.createException(ExceptionFactory.java:73)
    at com.mysql.cj.jdbc.util.TimeUtil.getCanonicalTimezone(TimeUtil.java:118)
    at com.mysql.cj.mysqla.MysqlaSession.configureTimezone(MysqlaSession.java:308)
    at com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:2474)
    at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:1817)
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:1673)
    ... 33 more

I'm focused on this error here:

The server time zone value 'AEST' is unrecognized or represents more
  than one time zone. You must configure either the server or JDBC
  driver (via the serverTimezone configuration property) to use a more
  specifc time zone value if you want to utilize time zone support.

I'm unsure how I fix it?

Edit:

Printing out the Timezone (System.out.println(TimeZone.getDefault());) prints the following details:

sun.util.calendar.ZoneInfo[id="Australia/Melbourne",offset=36000000,dstSavings=3600000,useDaylight=true,transitions=142,lastRule=java.util.SimpleTimeZone[id=Australia/Melbourne,offset=36000000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=9,startDay=1,startDayOfWeek=1,startTime=7200000,startTimeMode=1,endMode=3,endMonth=3,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=1]]

Edit:

So I looked at the question which was flagged, and tried to change my connection string, but it's still throwing the same stack trace. Below is my new connection url. As you can see I changed the serverTimezone to that of the printed Timezone.getDefault()

jdbc:mysql://localhost:3306/parking_hib?useLegacyDatetimeCode=false;serverTimezone=Australia/Melbourne;useSSL=false;

ContentLicense: CC BY-SA 4.0


问:
Downloading from Sharepoint Document Library
Goal: Download documents from a Sharepoint 2010 Document Library using C#

I've searched and found many questions/resources regarding how to download documents to a local disk from a Sharepoint Document Library. I've so far been unable to successfully implement a solution.

For the sake of discussion, my document library is located at the following link:
http://server.domain.com/sites/CompanyLocation/dprtmnts/DepartmentName/MyLibraryName/Forms/AllItems.aspx

Within this document library are two folders, each containing a number of documents. I desire to retrieve a list of these documents (in each folder) and have the ability to download/open a document on command.

Things I've tried:

The linked post from this comment: https://sharepoint.stackexchange.com/a/105923

The linked post (https://stackoverflow.com/a/21056425/2480558) offers a solution for both downloading and uploading. I only need to download, so I tried that. This solution gives me a Microsoft.SharePoint.Client.ServerObjectNullReferenceException. There are no instructions on what the url, listTitle, or listItemId need to be, so I'm probably doing something wrong... it doesn't appear to be getting any files.

I also tried the first blog post on that answer that points to using a package from bendsoft. Apparently that package is a paid package, and it's quite expensive.. I can't go that route.

Another answer: https://stackoverflow.com/a/53733630/2480558

This gives me the following exception: (actual server edited out of exception)

```<code>Microsoft.SharePoint.Client.ClientRequestException: 'The IDCRL response header from server 'http://server.domain.com/' is not valid. The response header value is 'NTLM'. The response status code is 'Unauthorized'.
</code>```

This solution: https://stackoverflow.com/a/15602003/2480558

Honestly, I don't even remember why that one didn't work.

If anyone has something that might help me get on the right path... I'm not familiar with making web requests and web authorization, or anything of that nature.

答:
If you use the example that you found at https://stackoverflow.com/a/53733630/2480558, but you have to adapt it for your local SharePoint server, since that code is logging in to SharePoint Online.

In the public void Connect() definition, replace the line

clientContext.Credentials = new SharePointOnlineCredentials(UserName, securePassword);

with this instead:

clientContext.Credentials = new NetworkCredential(UserName, securePassword, "putYourADDomainNameHere");

Body:
Goal: Download documents from a Sharepoint 2010 Document Library using C#

I've searched and found many questions/resources regarding how to download documents to a local disk from a Sharepoint Document Library. I've so far been unable to successfully implement a solution.

For the sake of discussion, my document library is located at the following link:
http://server.domain.com/sites/CompanyLocation/dprtmnts/DepartmentName/MyLibraryName/Forms/AllItems.aspx

Within this document library are two folders, each containing a number of documents. I desire to retrieve a list of these documents (in each folder) and have the ability to download/open a document on command.

Things I've tried:

The linked post from this comment: https://sharepoint.stackexchange.com/a/105923

The linked post (https://stackoverflow.com/a/21056425/2480558) offers a solution for both downloading and uploading. I only need to download, so I tried that. This solution gives me a Microsoft.SharePoint.Client.ServerObjectNullReferenceException. There are no instructions on what the url, listTitle, or listItemId need to be, so I'm probably doing something wrong... it doesn't appear to be getting any files.

I also tried the first blog post on that answer that points to using a package from bendsoft. Apparently that package is a paid package, and it's quite expensive.. I can't go that route.

Another answer: https://stackoverflow.com/a/53733630/2480558

This gives me the following exception: (actual server edited out of exception)

Microsoft.SharePoint.Client.ClientRequestException: 'The IDCRL response header from server 'http://server.domain.com/' is not valid. The response header value is 'NTLM'. The response status code is 'Unauthorized'.

This solution: https://stackoverflow.com/a/15602003/2480558

Honestly, I don't even remember why that one didn't work.

If anyone has something that might help me get on the right path... I'm not familiar with making web requests and web authorization, or anything of that nature.


问:
Using multiple refs on a single React element
I'm using the useHover() react hook defined in this recipe. The hook returns a ref and a boolean indicating whether the user is currently hovering over element identified by this ref. It can be used like this...

```<code>function App() {
  const [hoverRef, isHovered] = useHover();

  return (
    <div ref={hoverRef}>
      {isHovered ? 'Hovering' : 'Not Hovering'}
    </div>
  );
}
</code>```

Now let's say that I want to use another (hypothetical) hook called useDrag which returns a ref and a boolean indicating whether the user is dragging the current element around the page. I want to use this on the same element as before like this...

```<code>function App() {
  const [hoverRef, isHovered] = useHover();
  const [dragRef, isDragging] = useDrag();

  return (
    <div ref={[hoverRef, dragRef]}>
      {isHovered ? 'Hovering' : 'Not Hovering'}
      {isDragging ? 'Dragging' : 'Not Dragging'}
    </div>
  );
}
</code>```

This won't work because the ref prop can only accept a single reference object, not a list like in the example above.

How can I approach this problem so I can use multiple hooks like this on the same element? I found a package that looks like it might be what I'm looking for, but I'm not sure if I'm missing something.

答:
A React ref is really nothing but a container for some mutable data, stored as the current property. See the React docs for more details.

```<code>{
  current: ... // my ref content
}
</code>```

Considering this, you should be able to sort this out by hand:

```<code>function App() {
  const myRef = useRef(null);

  const [hoverRef, isHovered] = useHover();
  const [dragRef, isDragging] = useDrag();

  useEffect(function() {
    hoverRef.current = myRef.current;
    dragRef.current = myRef.current;
  }, [myRef.current]);

  return (
    <div ref={myRef}>
      {isHovered ? 'Hovering' : 'Not Hovering'}
      {isDragging ? 'Dragging' : 'Not Dragging'}
    </div>
  );
}
</code>```

Body:
I'm using the useHover() react hook defined in this recipe. The hook returns a ref and a boolean indicating whether the user is currently hovering over element identified by this ref. It can be used like this...

function App() {
  const [hoverRef, isHovered] = useHover();

  return (

      {isHovered ? 'Hovering' : 'Not Hovering'}

  );
}

Now let's say that I want to use another (hypothetical) hook called useDrag which returns a ref and a boolean indicating whether the user is dragging the current element around the page. I want to use this on the same element as before like this...

function App() {
  const [hoverRef, isHovered] = useHover();
  const [dragRef, isDragging] = useDrag();

  return (

      {isHovered ? 'Hovering' : 'Not Hovering'}
      {isDragging ? 'Dragging' : 'Not Dragging'}

  );
}

This won't work because the ref prop can only accept a single reference object, not a list like in the example above.

How can I approach this problem so I can use multiple hooks like this on the same element? I found a package that looks like it might be what I'm looking for, but I'm not sure if I'm missing something.

Body:
A React ref is really nothing but a container for some mutable data, stored as the current property. See the React docs for more details.

{
  current: ... // my ref content
}

Considering this, you should be able to sort this out by hand:

function App() {
  const myRef = useRef(null);

  const [hoverRef, isHovered] = useHover();
  const [dragRef, isDragging] = useDrag();

  useEffect(function() {
    hoverRef.current = myRef.current;
    dragRef.current = myRef.current;
  }, [myRef.current]);

  return (
    <div ref={myRef}>
      {isHovered ? 'Hovering' : 'Not Hovering'}
      {isDragging ? 'Dragging' : 'Not Dragging'}
    </div>
  );
}


问:
Batch writes to Cosmos DB from Databricks
Can someone let me know what asterics ** achieves when writing to Cosmos DB from Databrick.

```<code># Write configuration
writeConfig = {
    "Endpoint": "https://doctorwho.documents.azure.com:443/",
    "Masterkey": "YOUR-KEY-HERE",
    "Database": "DepartureDelays",
    "Collection": "flights_fromsea",
    "Upsert": "true"
}

# Write to Cosmos DB from the flights DataFrame
flights.write.format("com.microsoft.azure.cosmosdb.spark").options(
    **writeConfig).save()
</code>```

Thanks

答:
This is simply to allow you to pass multiple arguments directly using a list, tuple or a dictionary in your case.

So rather than you say:

```<code>flights.write.format("com.microsoft.azure.cosmosdb.spark")\
             .option("Endpoint", "https://doctorwho.documents.azure.com:443/")\
             .option("Upsert", "true")\
             .option("Masterkey", "YOUR-KEY-HERE")\
             ...etc
</code>```

You simply have all your arguments in a dictionary and then pass it like the following

```<code>flights.write.format("com.microsoft.azure.cosmosdb.spark").options(
    **yourdict).save()
</code>```

Body:
Can someone let me know what asterics ** achieves when writing to Cosmos DB from Databrick.

# Write configuration
writeConfig = {
    "Endpoint": "https://doctorwho.documents.azure.com:443/",
    "Masterkey": "YOUR-KEY-HERE",
    "Database": "DepartureDelays",
    "Collection": "flights_fromsea",
    "Upsert": "true"
}

# Write to Cosmos DB from the flights DataFrame
flights.write.format("com.microsoft.azure.cosmosdb.spark").options(
    **writeConfig).save()

Thanks

Body:
This is simply to allow you to pass multiple arguments directly using a list, tuple or a dictionary in your case.

So rather than you say:

flights.write.format("com.microsoft.azure.cosmosdb.spark")\
             .option("Endpoint", "https://doctorwho.documents.azure.com:443/")\
             .option("Upsert", "true")\
             .option("Masterkey", "YOUR-KEY-HERE")\
             ...etc

You simply have all your arguments in a dictionary and then pass it like the following

flights.write.format("com.microsoft.azure.cosmosdb.spark").options(
    **yourdict).save()


问:
Reading data out of an ADC (MCP3001) with python (SPI)
I try to read some data from an ADC with python, but unfortunatly it doesn't work. I hope someone has a hint for me, because my script creates only chaos-data. But I don't see the mistake with the bits...

I've updated the script below as I'm reading 16 bits and cut of the first and the last 3 bits. I need the 10 middle bits for the data - if I understand the datasheet correctly...

Datasheet MCP3001: (Page 15) http://ww1.microchip.com/downloads/en/DeviceDoc/21293C.pdf

```<code>import time
import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)

HIGH = True
LOW  = False

def readAnalogData(SCLKPin, MOSIPin, MISOPin, CSPin):
    GPIO.output(CSPin,   HIGH)
    GPIO.output(CSPin,   LOW)
    GPIO.output(SCLKPin, LOW)

    adcvalue = 0
    for i in range(16):
        GPIO.output(SCLKPin, HIGH)
        GPIO.output(SCLKPin, LOW)
        adcvalue <<= 1
        if(GPIO.input(MISOPin)):
            adcvalue |= 0x01
    adcvalue >>= 3
    adcvalue &= 0x3ff
    time.sleep(0.5)

    return adcvalue

SCLK        = 11 # Serial-Clock
MOSI        = 10 # Master-Out-Slave-In
MISO        = 9 # Master-In-Slave-Out
CS          = 17 # Chip-Select

GPIO.setup(SCLK, GPIO.OUT)
GPIO.setup(MOSI, GPIO.OUT)
GPIO.setup(MISO, GPIO.IN)
GPIO.setup(CS,   GPIO.OUT)

while True:
    print readAnalogData(SCLK, MOSI, MISO, CS)
</code>```

答:
This works.  Basically the previous answer but tweaked and tested.</p>

```<code>import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)

def ReadMCP3001():
    GPIO.setup(11, GPIO.OUT)
    GPIO.setup(7, GPIO.OUT)
    GPIO.setup(9, GPIO.IN)
    GPIO.output(11, False)  # CLK low
    GPIO.output(7, False)   # /CS low
    adcvalue = 0
    for i in range(13):
        GPIO.output(11, True)
        GPIO.output(11, False)
        adcvalue <<= 1
        if(GPIO.input(9)):
            adcvalue |= 0x001
    GPIO.output(7, True)    # /CS high
    adcvalue &= 0x3ff
    return adcvalue
</code>```

Body:
I try to read some data from an ADC with python, but unfortunatly it doesn't work. I hope someone has a hint for me, because my script creates only chaos-data. But I don't see the mistake with the bits...

I've updated the script below as I'm reading 16 bits and cut of the first and the last 3 bits. I need the 10 middle bits for the data - if I understand the datasheet correctly...

Datasheet MCP3001: (Page 15) http://ww1.microchip.com/downloads/en/DeviceDoc/21293C.pdf

import time
import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)

HIGH = True
LOW  = False

def readAnalogData(SCLKPin, MOSIPin, MISOPin, CSPin):
    GPIO.output(CSPin,   HIGH)
    GPIO.output(CSPin,   LOW)
    GPIO.output(SCLKPin, LOW)

    adcvalue = 0
    for i in range(16):
        GPIO.output(SCLKPin, HIGH)
        GPIO.output(SCLKPin, LOW)
        adcvalue <<= 1
        if(GPIO.input(MISOPin)):
            adcvalue |= 0x01
    adcvalue >>= 3
    adcvalue &= 0x3ff
    time.sleep(0.5)

    return adcvalue

SCLK        = 11 # Serial-Clock
MOSI        = 10 # Master-Out-Slave-In
MISO        = 9 # Master-In-Slave-Out
CS          = 17 # Chip-Select

GPIO.setup(SCLK, GPIO.OUT)
GPIO.setup(MOSI, GPIO.OUT)
GPIO.setup(MISO, GPIO.IN)
GPIO.setup(CS,   GPIO.OUT)

while True:
    print readAnalogData(SCLK, MOSI, MISO, CS)

Body:
This works.  Basically the previous answer but tweaked and tested.

import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)

def ReadMCP3001():
    GPIO.setup(11, GPIO.OUT)
    GPIO.setup(7, GPIO.OUT)
    GPIO.setup(9, GPIO.IN)
    GPIO.output(11, False)  # CLK low
    GPIO.output(7, False)   # /CS low
    adcvalue = 0
    for i in range(13):
        GPIO.output(11, True)
        GPIO.output(11, False)
        adcvalue <<= 1
        if(GPIO.input(9)):
            adcvalue |= 0x001
    GPIO.output(7, True)    # /CS high
    adcvalue &= 0x3ff
    return adcvalue


问:
Mamp won't start apache (Windows 10)
I've installed MAMP Pro on my Windows 10 Computer this week, and it worked fine until today. I've restarted my computer and immediately started MAMP Pro - this caused the MySQL server to start, but not Apache. Then, I restarted MAMP and no server was running, I've checked if any other Services were running on the MAMP port but there were none. I also changed the Ports in MAMP but it wasn't working either.

Why might this be happening?

Here are the Apache logs:

```<code>[Sat Oct 21 04:46:43 2017] [warn] pid file C:/MAMP/bin/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?

[Sat Oct 21 04:46:43 2017] [notice] Digest: generating secret for digest authentication ...

[Sat Oct 21 04:46:43 2017] [notice] Digest: done

[Sat Oct 21 04:46:44 2017] [notice] Apache/2.2.31 (Win32) DAV/2 mod_ssl/2.2.31 OpenSSL/1.0.2e mod_fcgid/2.3.9 mod_wsgi/3.4 Python/2.7.6 PHP/7.1.5

mod_perl/2.0.8 Perl/v5.16.3 configured -- resuming normal operations

[Sat Oct 21 04:46:44 2017] [notice] Server built: May  6 2016 10:19:53

[Sat Oct 21 04:46:44 2017] [notice] Parent: Created child process 5348

[Sat Oct 21 04:46:45 2017] [notice] Digest: generating secret for digest authentication ...

[Sat Oct 21 04:46:45 2017] [notice] Digest: done

[Sat Oct 21 04:46:46 2017] [notice] Child 5348: Child process is running

[Sat Oct 21 04:46:46 2017] [notice] Child 5348: Acquired the start mutex.

[Sat Oct 21 04:46:46 2017] [notice] Child 5348: Starting 64 worker threads.

[Sat Oct 21 04:46:46 2017] [notice] Child 5348: Starting thread to listen on port 443.

[Sat Oct 21 04:46:46 2017] [notice] Child 5348: Starting thread to listen on port 443.

[Sat Oct 21 04:46:46 2017] [notice] Child 5348: Starting thread to listen on port 80.
</code>```

答:
I had this same problem, and the only thing that worked for me to get the Apache server started again was to change the PHP version to 7.2.14 in the Preferences area of MAMP:

MAMP > Preferences... > PHP > Standard Version > 7.2.14

Note: After I was able to get the Apache server started again, I tried to change the PHP version back to 7.3.7, but this broke the Apache server startup process again. The green dot would wink on, and then off. So I am leaving MAMP with PHP version 7.2.14 for now (since the version of PHP doesn't matter to me as long as it is 7.x and not 5.6.x).

Title: Mamp won't start apache (Windows 10)

Body:
I've installed MAMP Pro on my Windows 10 Computer this week, and it worked fine until today. I've restarted my computer and immediately started MAMP Pro - this caused the MySQL server to start, but not Apache. Then, I restarted MAMP and no server was running, I've checked if any other Services were running on the MAMP port but there were none. I also changed the Ports in MAMP but it wasn't working either.

Why might this be happening?

Here are the Apache logs:

[Sat Oct 21 04:46:43 2017] [warn] pid file C:/MAMP/bin/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?

[Sat Oct 21 04:46:43 2017] [notice] Digest: generating secret for digest authentication ...

[Sat Oct 21 04:46:43 2017] [notice] Digest: done

[Sat Oct 21 04:46:44 2017] [notice] Apache/2.2.31 (Win32) DAV/2 mod_ssl/2.2.31 OpenSSL/1.0.2e mod_fcgid/2.3.9 mod_wsgi/3.4 Python/2.7.6 PHP/7.1.5

mod_perl/2.0.8 Perl/v5.16.3 configured -- resuming normal operations

[Sat Oct 21 04:46:44 2017] [notice] Server built: May  6 2016 10:19:53

[Sat Oct 21 04:46:44 2017] [notice] Parent: Created child process 5348

[Sat Oct 21 04:46:45 2017] [notice] Digest: generating secret for digest authentication ...

[Sat Oct 21 04:46:45 2017] [notice] Digest: done

[Sat Oct 21 04:46:46 2017] [notice] Child 5348: Child process is running

[Sat Oct 21 04:46:46 2017] [notice] Child 5348: Acquired the start mutex.

[Sat Oct 21 04:46:46 2017] [notice] Child 5348: Starting 64 worker threads.

[Sat Oct 21 04:46:46 2017] [notice] Child 5348: Starting thread to listen on port 443.

[Sat Oct 21 04:46:46 2017] [notice] Child 5348: Starting thread to listen on port 443.

[Sat Oct 21 04:46:46 2017] [notice] Child 5348: Starting thread to listen on port 80.


问:
Object creation order with class having containment of other objects
```<code>#include "iostream"
using namespace std;
class C
{
    public:
    C() { cout << "C's Constructor Called " << endl;  }
};

class A
{
    public:
    A() { cout << "A's Constructor Called " << endl;  }
    A(int) {  cout << "A's int Constructor Called " << endl;  }
};

class B
{
    public:
    A a;
    B() { cout << "B's Constructor Called " << endl; }
    B(int i) : a(i) { cout << "B's int Constructor Called " << endl; }
    C c;
};

int main()
{
    B b1(1);
    return 0;
}
</code>```

Output:

    A's int Constructor Called

    C's Constructor Called

    B's int Constructor Called

Question :

Why output does not contain "A's Constructor Called"

According to me i thought Output would be like below :

    A's Constructor Called

    C's Constructor Called

    B's int Constructor Called

Wondering why A a does not lead to constructor A() being called but only A(int) because of a(i)

答:
Simply because you have initialized it in B's constructor-initializer-list via A's constructor that takes an integer.

```<code>B(int i) : a(i) { cout << "B's int Constructor Called " << endl; }
</code>```

You can get "A's constructor called" if you called it or didn't initialize it then it is default-intialized:

```<code>B(int i) : a() { cout << "B's int Constructor Called " << endl; } // a is value-initialized which is here the same as default-initialized.
</code>```

Body:
#include "iostream"
using namespace std;
class C
{
    public:
    C() { cout << "C's Constructor Called " << endl;  }
};

class A
{
    public:
    A() { cout << "A's Constructor Called " << endl;  }
    A(int) {  cout << "A's int Constructor Called " << endl;  }
};

class B
{
    public:
    A a;
    B() { cout << "B's Constructor Called " << endl; }
    B(int i) : a(i) { cout << "B's int Constructor Called " << endl; }
    C c;
};

int main()
{
    B b1(1);
    return 0;
}

Output:

    A's int Constructor Called

    C's Constructor Called

    B's int Constructor Called

Question :

Why output does not contain "A's Constructor Called"

According to me i thought Output would be like below :

    A's Constructor Called

    C's Constructor Called

    B's int Constructor Called

Wondering why A a does not lead to constructor A() being called but only A(int) because of a(i)

Body:
Simply because you have initialized it in B's constructor-initializer-list via A's constructor that takes an integer.

B(int i) : a(i) { cout << "B's int Constructor Called " << endl; }

You can get "A's constructor called" if you called it or didn't initialize it then it is default-intialized:

B(int i) : a() { cout << "B's int Constructor Called " << endl; } // a is value-initialized which is here the same as default-initialized.


问:
Can we Bring two Dataset at a time and compare it
i have a ResultSet method public ResultSet getItemPurchase(String Pid) which return a Data from a  database table. similarly i have another method public Resultset getItemSale(String sid). i have called them using a function ResultSet rs1 = getItemPurchase(Pid); and next function is ResultSet rs2 = getItemSale(Pid);

i want to do as following.

```<code> 1. while(rs1.next)
 2. {
 3. rs1.getString("Item");
 4.      if(rs1.getString("price")==rs2.getString("price")
 5.        {
 6.          //some code here
 7.        }
 8.      else{
 9. rs1.getDate("Purchase Date");}
 10. rs2.getString("CustomerName");
 11. }
</code>```

can anybody please help me on this

答:
I would suggest you to write two domain objects, Plain Java objects like:

```<code>public class ItemPurchase{
    private String price;

    //setter/getter for price

    private String purchaseDate;
    //setter/getter for purchaseDate
}
public class ItemSale{
  private String price;

    //setter/getter for price

    private String customerName;
    //setter/getter for customerName
}
</code>```

Now create a list of objects while iterating each resultset like:

```<code>public List createListOfItemPurchased(ResultSet rs){
 List<ItemPurchase> purchaseList=new ArrayList<ItemPurchase>();
 while(rs.next()){
   ItemPurchase purchaseObject=new ItemPurchase();
   purchaseObject.setPrice(rs.getString("price"));
 //fill all required data in it
  purchaseList.add(purchaseObject);
 }
  return purchaseList;
}
</code>```

Same way populate the salesObjects and then create a method to filter out your results like:

```<code>filter(List purchaseList, List salesList){
  for(ItemPurchase purchaseObj:purchaseList){
    //process the objects according to your requirement
  }
}
</code>```

Body:
i have a ResultSet method public ResultSet getItemPurchase(String Pid) which return a Data from a  database table. similarly i have another method public Resultset getItemSale(String sid). i have called them using a function ResultSet rs1 = getItemPurchase(Pid); and next function is ResultSet rs2 = getItemSale(Pid);

i want to do as following.

 1. while(rs1.next)
 2. {
 3. rs1.getString("Item");
 4.      if(rs1.getString("price")==rs2.getString("price")
 5.        {
 6.          //some code here
 7.        }
 8.      else{
 9. rs1.getDate("Purchase Date");}
 10. rs2.getString("CustomerName");
 11. }

can anybody please help me on this

Body:
I would suggest you to write two domain objects, Plain Java objects like:

public class ItemPurchase{
    private String price;

    //setter/getter for price

    private String purchaseDate;
    //setter/getter for purchaseDate
}
public class ItemSale{
  private String price;

    //setter/getter for price

    private String customerName;
    //setter/getter for customerName
}

Now create a list of objects while iterating each resultset like:

public List createListOfItemPurchased(ResultSet rs){
 List<ItemPurchase> purchaseList=new ArrayList<ItemPurchase>();
 while(rs.next()){
   ItemPurchase purchaseObject=new ItemPurchase();
   purchaseObject.setPrice(rs.getString("price"));
 //fill all required data in it
  purchaseList.add(purchaseObject);
 }
  return purchaseList;
}

Same way populate the salesObjects and then create a method to filter out your results like:

filter(List purchaseList, List salesList){
  for(ItemPurchase purchaseObj:purchaseList){
    //process the objects according to your requirement
  }
}


问:
how can i make a dropdown in this sidebar when clicking?
I'm stuck right now on how I can make a drop-down menu in the sidebar, so when I click on it I should show or hide a submenu

Text

答:
The idea is to add a class to hide and show elements

sidebar.js

```<code>import React, { Fragment } from "react";
import "./style.css";

class sidebar extends React.Component {
  state = {
    isOpen: false,
  };

  toggleClass = (e) => {
    e.preventDefault();
    this.setState((prevState) => ({isOpen: !prevState.isOpen}));
  };

  render() {
    return (
      <div class="sidenav ">
        <a href="/">Retour a l'acceuil</a>
        <a href="/" onClick={this.toggleClass}>
          <span
            class="iconify hamburger"
            data-inline="false"
            data-icon="ic:round-menu"
          />
          Liste des élèves
          <span
            class="iconify down"
            data-inline="false"
            data-icon="bx:bxs-down-arrow"
          />
          </a>
        <div className={this.state.isOpen ? 'show': 'hide'} >
        <a href="/">
          <span
            class="iconify"
            data-inline="false"
            data-icon="ic:baseline-keyboard-arrow-right"
          />
          Item1
        </a>
        <a href="/">
          <span
            class="iconify"
            data-inline="false"
            data-icon="ic:baseline-keyboard-arrow-right"
          />
          Item2
        </a>
        <a href="/">
          <span
            class="iconify"
            data-inline="false"
            data-icon="ic:baseline-keyboard-arrow-right"
          />
          Item3
        </a>
        </div>

        <a href="/">Abscences</a>
        <a href="/">Inscription au concours</a>
        <a href="/">Résultat</a>
        <a href="/">Messagerie</a>
      </div>
    );
  }
}
export default sidebar;
</code>```

style.css

```<code>...
.hide {
  display: none;
}

.show {
  display: block;
}

</code>```

Body:
The idea is to add a class to hide and show elements

sidebar.js

import React, { Fragment } from "react";
import "./style.css";

class sidebar extends React.Component {
  state = {
    isOpen: false,
  };

  toggleClass = (e) => {
    e.preventDefault();
    this.setState((prevState) => ({isOpen: !prevState.isOpen}));
  };

  render() {
    return (
      <div class="sidenav ">
        <a href="/">Retour a l'acceuil</a>
        <a href="/" onClick={this.toggleClass}>
          <span
            class="iconify hamburger"
            data-inline="false"
            data-icon="ic:round-menu"
          />
          Liste des élèves
          <span
            class="iconify down"
            data-inline="false"
            data-icon="bx:bxs-down-arrow"
          />
          </a>
        <div className={this.state.isOpen ? 'show': 'hide'} >
        <a href="/">
          <span
            class="iconify"
            data-inline="false"
            data-icon="ic:baseline-keyboard-arrow-right"
          />
          Item1
        </a>
        <a href="/">
          <span
            class="iconify"
            data-inline="false"
            data-icon="ic:baseline-keyboard-arrow-right"
          />
          Item2
        </a>
        <a href="/">
          <span
            class="iconify"
            data-inline="false"
            data-icon="ic:baseline-keyboard-arrow-right"
          />
          Item3
        </a>
        </div>

        <a href="/">Abscences</a>
        <a href="/">Inscription au concours</a>
        <a href="/">Résultat</a>
        <a href="/">Messagerie</a>
      </div>
    );
  }
}
export default sidebar;

style.css

...
.hide {
  display: none;
}

.show {
  display: block;
}


问:
Excel VBA, Sort Dates via list
I am trying to sort a list of Sales Orders (on a pivot table) and filter to find the entries that are scheduled to ship on a holiday (a list of ~12 dates).

Considering this pivot table is Dynamic, but the list of dates is not, is there a way to apply these filters via a VBA macro, so i do not have to do so manually?

I have tried using the Macro recorder, but it just sets all of the existing dates to

actual list came up much, much, larger

```<code>With ActiveSheet.PivotTables("SalesOrders").PivotFields("Due Date")
    .PivotItems("2/28/2019").Visible = False
    .PivotItems("5/22/2019").Visible = False
    .PivotItems("7/17/2019").Visible = False
    .PivotItems("7/18/2019").Visible = False
    .PivotItems("8/7/2019").Visible = False
    .PivotItems("8/16/2019").Visible = False
    .PivotItems("8/19/2019").Visible = False
    .PivotItems("8/22/2019").Visible = False
    .PivotItems("8/28/2019").Visible = False
    .PivotItems("8/29/2019").Visible = False
    .PivotItems("8/30/2019").Visible = False
</code>```

```<code>End With
With ActiveSheet.PivotTables("SalesOrders").PivotFields("Due Date")
     .PivotItems("5/25/2020").Visible = True
     .PivotItems("7/3/2020").Visible = True
     .PivotItems("7/6/2020").Visible = True
End With
</code>```

This doesn't really work, because the dates will change...
I'm not really sure how to progress, any help would be welcome.

答: If you can add a new column to your data, you won't need to use VBA, you can get this incorporated in your pivot table. Add a new sheet that contains only the dates of the holidays in one column and True in the second column. Then add a new column to your Sales Order data and in that column use the Vlookup function to see if the date in your Sales Orders date is found in the list of holidays. You can add this new column to your pivot table as a filter. The screen shot below shows an example.

Title: Excel VBA, Sort Dates via list

Body:
I am trying to sort a list of Sales Orders (on a pivot table) and filter to find the entries that are scheduled to ship on a holiday (a list of ~12 dates).

Considering this pivot table is Dynamic, but the list of dates is not, is there a way to apply these filters via a VBA macro, so i do not have to do so manually?

I have tried using the Macro recorder, but it just sets all of the existing dates to

actual list came up much, much, larger

With ActiveSheet.PivotTables("SalesOrders").PivotFields("Due Date")
    .PivotItems("2/28/2019").Visible = False
    .PivotItems("5/22/2019").Visible = False
    .PivotItems("7/17/2019").Visible = False
    .PivotItems("7/18/2019").Visible = False
    .PivotItems("8/7/2019").Visible = False
    .PivotItems("8/16/2019").Visible = False
    .PivotItems("8/19/2019").Visible = False
    .PivotItems("8/22/2019").Visible = False
    .PivotItems("8/28/2019").Visible = False
    .PivotItems("8/29/2019").Visible = False
    .PivotItems("8/30/2019").Visible = False

End With
With ActiveSheet.PivotTables("SalesOrders").PivotFields("Due Date")
     .PivotItems("5/25/2020").Visible = True
     .PivotItems("7/3/2020").Visible = True
     .PivotItems("7/6/2020").Visible = True
End With

This doesn't really work, because the dates will change...
I'm not really sure how to progress, any help would be welcome.


问:
Switch chekcbox SHOW / HIDE two DIV elements using Vanilla Javascript
I have two Form Groups, both are inside a DIV element.
Fist one have an id="personaFisicaFormGroup"

Second one have an id="personaMoralFormGroup"

personaFisicaFormGroup is display: block; as default

personaMoralFormGroup is display: none; as default

When user click the checkbox I want to inverse the display.

personaFisicaFormGroup set to display: none;

personaMoralFormGroup set to display: blcok;

If user click again I want to switch values block and none (indeterminate times).

EDIT:
I just chaged my Javascript to:

```<code>onOffSwitch.addEventListener('change', e => {
    if(personaMoralFormGroup.style.display == 'none') {
        personaMoralFormGroup.style.display = 'block';
        personaFisicaFormGroup.style.display = 'none';
    } else {
        personaMoralFormGroup.style.display = 'none';
        personaFisicaFormGroup.style.display = 'block';
    }
});
</code>```

This works, but at the second switch click.

Here is my code:

const onOffSwitch = document.getElementById('onOffSwitch');
const personaFisicaFormGroup = document.getElementById('personaFisicaFormGroup');
const personaMoralFormGroup = document.getElementById('personaMoralFormGroup');

onOffSwitch.addEventListener('change', e => {
    if(e.target.checked){
        personaMoralFormGroup.style.display = 'block';
    } else {
        personaFisicaFormGroup.style.display = 'none';
    }
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.nuevo-ingreso-form__group {
    border: 1px solid var(--clr-grey-borders);
    border-radius: 5px;
    margin-bottom: 20px;
    background-color: rgb(255, 255, 255);
    width: 300px;
}
#personaMoralFormGroup {
    display: none;
}
.nuevo-ingreso-form__group:hover {
    box-shadow: 0 7px 16px 0 rgba(0,0,0,.2), 0 1px 3px 0 rgba(0,0,0,.1);
    transition: box-shadow .3s ease-out,-webkit-box-shadow .3s ease-out;
}

.nuevo-ingreso-form__group-header {
    padding: 25px 40px 10px;
    display: flex;
    align-items: center;
    font-size: 18px;
}
.nuevo-ingreso-form__group-header h3 {
    margin-left: 20px;
}
.nuevo-ingreso-form__field-wrapper {
    padding: 0px 40px;
    padding-top: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.nuevo-ingreso-form__field-wrapper:last-child {
    padding-bottom: 50px;

}
.nuevo-ingreso-form__input-label {
    font-size: 13px;
    font-weight: 800;
    color: grey;
    padding: 5px 5px 5px 0;
    display: block;
    width: 40%;
    text-align: right;
}
.nuevo-ingreso-form__input-container {
    border: 1px solid grey;
    height: 100%;
    border-radius: 5px;
    flex-grow: 1;
    margin-left: 20px;
}
.nuevo-ingreso-form__input-field {
    margin: 0;
    background-color: transparent;
    border: none;
    width: 100%;
    font-size: 16px;
}

.onoffswitch {
    position: relative; width: 172px;
    -webkit-user-select:none; -moz-user-select:none; -ms-user-select: none;
    margin: 0 auto;
}
.onoffswitch-checkbox {
    display: none;
}
.onoffswitch-label {
    display: block; overflow: hidden; cursor: pointer;
    border: 2px solid #FFFFFF; border-radius: 50px;
}
.onoffswitch-inner {
    display: block; width: 200%; margin-left: -100%;
    transition: margin 0.3s ease-in 0s;
}
.onoffswitch-inner:before, .onoffswitch-inner:after {
    display: block; float: left; width: 50%; height: 35px; padding: 0; line-height: 35px;
    font-size: 15px; color: white; font-family: Trebuchet, Arial, sans-serif; font-weight: bold;
    box-sizing: border-box;
}
.onoffswitch-inner:before {
    content: "Persona Física";
    padding-left: 19px;
    background-color: #E0E0E0; color: #5C5C5C;
}
.onoffswitch-inner:after {
    content: "Persona Moral";
    padding-right: 19px;
    background-color: #636363; color: #FFFFFF;
    text-align: right;
}
.onoffswitch-switch {
    display: block; width: 18px; margin: 8.5px;
    background: #FFFFFF;
    position: absolute; top: 0; bottom: 0;
    right: 133px;
    border: 2px solid #FFFFFF; border-radius: 50px;
    transition: all 0.3s ease-in 0s;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner {
    margin-left: 0;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
    right: 0px;
}</code>```

    <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="onOffSwitch">

Persona Fisica

        NOMBRE

            <input id="clienteNombreORazonSocial" class="nuevo-ingreso-form__input-field" type="text">

        APELLIDO PATERNO

            <input id="clientePaterno" class="nuevo-ingreso-form__input-field" type="text">

        APELLIDO MATERNO

            <input id="clienteMaterno" class="nuevo-ingreso-form__input-field" type="text">

Persona Moral

        RAZÓN SOCIAL

            <input id="clienteNombreORazonSocial" class="nuevo-ingreso-form__input-field" type="text">

        RFC

            <input id="clienteRFC" class="nuevo-ingreso-form__input-field" type="text">

        EMAIL

            <input id="clienteEmail" class="nuevo-ingreso-form__input-field" type="text">

```

答:
Whenever hiding and showing elements I prefer to use an explicit class for this. It is easier to add and remove the class with the added bonus of I don't have to worry about if the element isn't display:block by default.

This would result in the following for you. Things to note: I've removed display:none based on Id and we're using classList.toggle to add and remove the class

const onOffSwitch = document.getElementById('onOffSwitch');
const personaFisicaFormGroup = document.getElementById('personaFisicaFormGroup');
const personaMoralFormGroup = document.getElementById('personaMoralFormGroup');

onOffSwitch.addEventListener('change', e => {
    personaFisicaFormGroup.classList.toggle("hidden", e.target.checked);
    personaMoralFormGroup.classList.toggle("hidden", !e.target.checked);
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.hidden {display:none;}

.nuevo-ingreso-form__group {
    border: 1px solid var(--clr-grey-borders);
    border-radius: 5px;
    margin-bottom: 20px;
    background-color: rgb(255, 255, 255);
    width: 300px;
}

.nuevo-ingreso-form__group:hover {
    box-shadow: 0 7px 16px 0 rgba(0,0,0,.2), 0 1px 3px 0 rgba(0,0,0,.1);
    transition: box-shadow .3s ease-out,-webkit-box-shadow .3s ease-out;
}

.nuevo-ingreso-form__group-header {
    padding: 25px 40px 10px;
    display: flex;
    align-items: center;
    font-size: 18px;
}
.nuevo-ingreso-form__group-header h3 {
    margin-left: 20px;
}
.nuevo-ingreso-form__field-wrapper {
    padding: 0px 40px;
    padding-top: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.nuevo-ingreso-form__field-wrapper:last-child {
    padding-bottom: 50px;

}
.nuevo-ingreso-form__input-label {
    font-size: 13px;
    font-weight: 800;
    color: grey;
    padding: 5px 5px 5px 0;
    display: block;
    width: 40%;
    text-align: right;
}
.nuevo-ingreso-form__input-container {
    border: 1px solid grey;
    height: 100%;
    border-radius: 5px;
    flex-grow: 1;
    margin-left: 20px;
}
.nuevo-ingreso-form__input-field {
    margin: 0;
    background-color: transparent;
    border: none;
    width: 100%;
    font-size: 16px;
}

.onoffswitch {
    position: relative; width: 172px;
    -webkit-user-select:none; -moz-user-select:none; -ms-user-select: none;
    margin: 0 auto;
}
.onoffswitch-checkbox {
    display: none;
}
.onoffswitch-label {
    display: block; overflow: hidden; cursor: pointer;
    border: 2px solid #FFFFFF; border-radius: 50px;
}
.onoffswitch-inner {
    display: block; width: 200%; margin-left: -100%;
    transition: margin 0.3s ease-in 0s;
}
.onoffswitch-inner:before, .onoffswitch-inner:after {
    display: block; float: left; width: 50%; height: 35px; padding: 0; line-height: 35px;
    font-size: 15px; color: white; font-family: Trebuchet, Arial, sans-serif; font-weight: bold;
    box-sizing: border-box;
}
.onoffswitch-inner:before {
    content: "Persona Física";
    padding-left: 19px;
    background-color: #E0E0E0; color: #5C5C5C;
}
.onoffswitch-inner:after {
    content: "Persona Moral";
    padding-right: 19px;
    background-color: #636363; color: #FFFFFF;
    text-align: right;
}
.onoffswitch-switch {
    display: block; width: 18px; margin: 8.5px;
    background: #FFFFFF;
    position: absolute; top: 0; bottom: 0;
    right: 133px;
    border: 2px solid #FFFFFF; border-radius: 50px;
    transition: all 0.3s ease-in 0s;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner {
    margin-left: 0;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
    right: 0px;
}</code>```

    <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="onOffSwitch">

Persona Fisica

        NOMBRE

            <input id="clienteNombreORazonSocial" class="nuevo-ingreso-form__input-field" type="text">

        APELLIDO PATERNO

            <input id="clientePaterno" class="nuevo-ingreso-form__input-field" type="text">

        APELLIDO MATERNO

            <input id="clienteMaterno" class="nuevo-ingreso-form__input-field" type="text">

Persona Moral

        RAZÓN SOCIAL

            <input id="clienteNombreORazonSocial" class="nuevo-ingreso-form__input-field" type="text">

        RFC

            <input id="clienteRFC" class="nuevo-ingreso-form__input-field" type="text">

        EMAIL

            <input id="clienteEmail" class="nuevo-ingreso-form__input-field" type="text">

```

Body:
I have two Form Groups, both are inside a DIV element.
Fist one have an id="personaFisicaFormGroup"

Second one have an id="personaMoralFormGroup"

personaFisicaFormGroup is display: block; as default

personaMoralFormGroup is display: none; as default

When user click the checkbox I want to inverse the display.

personaFisicaFormGroup set to display: none;

personaMoralFormGroup set to display: blcok;

If user click again I want to switch values block and none (indeterminate times).

EDIT:
I just chaged my Javascript to:

onOffSwitch.addEventListener('change', e => {
    if(personaMoralFormGroup.style.display == 'none') {
        personaMoralFormGroup.style.display = 'block';
        personaFisicaFormGroup.style.display = 'none';
    } else {
        personaMoralFormGroup.style.display = 'none';
        personaFisicaFormGroup.style.display = 'block';
    }
});

This works, but at the second switch click.

Here is my code:

const onOffSwitch = document.getElementById('onOffSwitch');
const personaFisicaFormGroup = document.getElementById('personaFisicaFormGroup');
const personaMoralFormGroup = document.getElementById('personaMoralFormGroup');

onOffSwitch.addEventListener('change', e => {
    if(e.target.checked){
        personaMoralFormGroup.style.display = 'block';
    } else {
        personaFisicaFormGroup.style.display = 'none';
    }
});

.nuevo-ingreso-form__group {
    border: 1px solid var(--clr-grey-borders);
    border-radius: 5px;
    margin-bottom: 20px;
    background-color: rgb(255, 255, 255);
    width: 300px;
}
#personaMoralFormGroup {
    display: none;
}
.nuevo-ingreso-form__group:hover {
    box-shadow: 0 7px 16px 0 rgba(0,0,0,.2), 0 1px 3px 0 rgba(0,0,0,.1);
    transition: box-shadow .3s ease-out,-webkit-box-shadow .3s ease-out;
}

.nuevo-ingreso-form__group-header {
    padding: 25px 40px 10px;
    display: flex;
    align-items: center;
    font-size: 18px;
}
.nuevo-ingreso-form__group-header h3 {
    margin-left: 20px;
}
.nuevo-ingreso-form__field-wrapper {
    padding: 0px 40px;
    padding-top: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.nuevo-ingreso-form__field-wrapper:last-child {
    padding-bottom: 50px;

}
.nuevo-ingreso-form__input-label {
    font-size: 13px;
    font-weight: 800;
    color: grey;
    padding: 5px 5px 5px 0;
    display: block;
    width: 40%;
    text-align: right;
}
.nuevo-ingreso-form__input-container {
    border: 1px solid grey;
    height: 100%;
    border-radius: 5px;
    flex-grow: 1;
    margin-left: 20px;
}
.nuevo-ingreso-form__input-field {
    margin: 0;
    background-color: transparent;
    border: none;
    width: 100%;
    font-size: 16px;
}

.onoffswitch {
    position: relative; width: 172px;
    -webkit-user-select:none; -moz-user-select:none; -ms-user-select: none;
    margin: 0 auto;
}
.onoffswitch-checkbox {
    display: none;
}
.onoffswitch-label {
    display: block; overflow: hidden; cursor: pointer;
    border: 2px solid #FFFFFF; border-radius: 50px;
}
.onoffswitch-inner {
    display: block; width: 200%; margin-left: -100%;
    transition: margin 0.3s ease-in 0s;
}
.onoffswitch-inner:before, .onoffswitch-inner:after {
    display: block; float: left; width: 50%; height: 35px; padding: 0; line-height: 35px;
    font-size: 15px; color: white; font-family: Trebuchet, Arial, sans-serif; font-weight: bold;
    box-sizing: border-box;
}
.onoffswitch-inner:before {
    content: "Persona Física";
    padding-left: 19px;
    background-color: #E0E0E0; color: #5C5C5C;
}
.onoffswitch-inner:after {
    content: "Persona Moral";
    padding-right: 19px;
    background-color: #636363; color: #FFFFFF;
    text-align: right;
}
.onoffswitch-switch {
    display: block; width: 18px; margin: 8.5px;
    background: #FFFFFF;
    position: absolute; top: 0; bottom: 0;
    right: 133px;
    border: 2px solid #FFFFFF; border-radius: 50px;
    transition: all 0.3s ease-in 0s;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner {
    margin-left: 0;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
    right: 0px;
}

    <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="onOffSwitch">

Persona Fisica

        NOMBRE

            <input id="clienteNombreORazonSocial" class="nuevo-ingreso-form__input-field" type="text">

        APELLIDO PATERNO

            <input id="clientePaterno" class="nuevo-ingreso-form__input-field" type="text">

        APELLIDO MATERNO

            <input id="clienteMaterno" class="nuevo-ingreso-form__input-field" type="text">

Persona Moral

        RAZÓN SOCIAL

            <input id="clienteNombreORazonSocial" class="nuevo-ingreso-form__input-field" type="text">

        RFC

            <input id="clienteRFC" class="nuevo-ingreso-form__input-field" type="text">

        EMAIL

            <input id="clienteEmail" class="nuevo-ingreso-form__input-field" type="text">

Body:
Whenever hiding and showing elements I prefer to use an explicit class for this. It is easier to add and remove the class with the added bonus of I don't have to worry about if the element isn't display:block by default.

This would result in the following for you. Things to note: I've removed display:none based on Id and we're using classList.toggle to add and remove the class

const onOffSwitch = document.getElementById('onOffSwitch');
const personaFisicaFormGroup = document.getElementById('personaFisicaFormGroup');
const personaMoralFormGroup = document.getElementById('personaMoralFormGroup');

onOffSwitch.addEventListener('change', e => {
    personaFisicaFormGroup.classList.toggle("hidden", e.target.checked);
    personaMoralFormGroup.classList.toggle("hidden", !e.target.checked);
});

.hidden {display:none;}

.nuevo-ingreso-form__group {
    border: 1px solid var(--clr-grey-borders);
    border-radius: 5px;
    margin-bottom: 20px;
    background-color: rgb(255, 255, 255);
    width: 300px;
}

.nuevo-ingreso-form__group:hover {
    box-shadow: 0 7px 16px 0 rgba(0,0,0,.2), 0 1px 3px 0 rgba(0,0,0,.1);
    transition: box-shadow .3s ease-out,-webkit-box-shadow .3s ease-out;
}

.nuevo-ingreso-form__group-header {
    padding: 25px 40px 10px;
    display: flex;
    align-items: center;
    font-size: 18px;
}
.nuevo-ingreso-form__group-header h3 {
    margin-left: 20px;
}
.nuevo-ingreso-form__field-wrapper {
    padding: 0px 40px;
    padding-top: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.nuevo-ingreso-form__field-wrapper:last-child {
    padding-bottom: 50px;

}
.nuevo-ingreso-form__input-label {
    font-size: 13px;
    font-weight: 800;
    color: grey;
    padding: 5px 5px 5px 0;
    display: block;
    width: 40%;
    text-align: right;
}
.nuevo-ingreso-form__input-container {
    border: 1px solid grey;
    height: 100%;
    border-radius: 5px;
    flex-grow: 1;
    margin-left: 20px;
}
.nuevo-ingreso-form__input-field {
    margin: 0;
    background-color: transparent;
    border: none;
    width: 100%;
    font-size: 16px;
}

.onoffswitch {
    position: relative; width: 172px;
    -webkit-user-select:none; -moz-user-select:none; -ms-user-select: none;
    margin: 0 auto;
}
.onoffswitch-checkbox {
    display: none;
}
.onoffswitch-label {
    display: block; overflow: hidden; cursor: pointer;
    border: 2px solid #FFFFFF; border-radius: 50px;
}
.onoffswitch-inner {
    display: block; width: 200%; margin-left: -100%;
    transition: margin 0.3s ease-in 0s;
}
.onoffswitch-inner:before, .onoffswitch-inner:after {
    display: block; float: left; width: 50%; height: 35px; padding: 0; line-height: 35px;
    font-size: 15px; color: white; font-family: Trebuchet, Arial, sans-serif; font-weight: bold;
    box-sizing: border-box;
}
.onoffswitch-inner:before {
    content: "Persona Física";
    padding-left: 19px;
    background-color: #E0E0E0; color: #5C5C5C;
}
.onoffswitch-inner:after {
    content: "Persona Moral";
    padding-right: 19px;
    background-color: #636363; color: #FFFFFF;
    text-align: right;
}
.onoffswitch-switch {
    display: block; width: 18px; margin: 8.5px;
    background: #FFFFFF;
    position: absolute; top: 0; bottom: 0;
    right: 133px;
    border: 2px solid #FFFFFF; border-radius: 50px;
    transition: all 0.3s ease-in 0s;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner {
    margin-left: 0;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
    right: 0px;
}

<div class="onoffswitch">
    <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="onOffSwitch">
    <label class="onoffswitch-label" for="onOffSwitch">
        <span class="onoffswitch-inner"></span>
        <span class="onoffswitch-switch"></span>
    </label>
</div>

<!-- DATOS GENERALES - PERSONA FISICA -->
<div id="personaFisicaFormGroup" class="nuevo-ingreso-form__group">
    <div class="nuevo-ingreso-form__group-header">
        <h3>Persona Fisica</h3>
    </div>
    <div class="nuevo-ingreso-form__field-wrapper">
        <label class="nuevo-ingreso-form__input-label" for="">NOMBRE</label>
        <div class="nuevo-ingreso-form__input-container">
            <input id="clienteNombreORazonSocial" class="nuevo-ingreso-form__input-field" type="text">
        </div>
    </div>
    <div class="nuevo-ingreso-form__field-wrapper">
        <label class="nuevo-ingreso-form__input-label" for="">APELLIDO PATERNO</label>
        <div class="nuevo-ingreso-form__input-container">
            <input id="clientePaterno" class="nuevo-ingreso-form__input-field" type="text">
        </div>
    </div>
    <div class="nuevo-ingreso-form__field-wrapper">
        <label class="nuevo-ingreso-form__input-label" for="">APELLIDO MATERNO</label>
        <div class="nuevo-ingreso-form__input-container">
            <input id="clienteMaterno" class="nuevo-ingreso-form__input-field" type="text">
        </div>
    </div>
</div>

 <!-- PERSONA MORAL -->
<div id="personaMoralFormGroup" class="nuevo-ingreso-form__group hidden">
    <div class="nuevo-ingreso-form__group-header">
        <i class="fa fa-id-card"></i>
        <h3>Persona Moral</h3>
    </div>
    <div class="nuevo-ingreso-form__field-wrapper">
        <label class="nuevo-ingreso-form__input-label" for="">RAZÓN SOCIAL</label>
        <div class="nuevo-ingreso-form__input-container">
            <input id="clienteNombreORazonSocial" class="nuevo-ingreso-form__input-field" type="text">
        </div>
    </div>
    <div class="nuevo-ingreso-form__field-wrapper">
        <label class="nuevo-ingreso-form__input-label" for="">RFC</label>
        <div class="nuevo-ingreso-form__input-container">
            <input id="clienteRFC" class="nuevo-ingreso-form__input-field" type="text">
        </div>
    </div>
    <div class="nuevo-ingreso-form__field-wrapper">
        <label class="nuevo-ingreso-form__input-label" for="">EMAIL</label>
        <div class="nuevo-ingreso-form__input-container">
            <input id="clienteEmail" class="nuevo-ingreso-form__input-field" type="text">
        </div>
    </div>
</div>


问:
The 'componentDidMount' lifecycle method does not update the state
I have a component called DiscardPile that's receive in your props (props.cards) an array of objects like this:

```<code>{key: 'key', 'type', suit: 'suit', label: 'label', flipped: 'fliped, draggable: 'draggable', currentOrder: 0}
</code>```

Well, the component DiscardPile is shown bellow:

```<code>import React, { Component } from 'react';
import $ from 'jquery';
import 'jquery-ui/ui/core';
import 'jquery-ui/ui/widgets/droppable';

import './DiscardPile.scss';

import Card from '../Card/Card';
export default class DiscardPile extends Component {

    constructor(props) {
        super(props);
        this.state = {
            currentCards: []
        }
    }

    componentDidMount() {
        let currentCards = [...this.props.cards];
        for(let i = 0; i < currentCards.length; i++) {
            currentCards[i].currentOrder = i;
        }
        this.setState({currentCards: currentCards});
    }

    render() {
        return (
            <div id="discard-pile" className="discard-pile">
                {this.state.currentCards.map(card =>(
                    <Card key={card.key} type={card.type} suit={card.suit} label={card.label} flipped={card.flipped} draggable={card.draggable} currentOrder={card.currentOrder}></Card>
                ))}
            </div>
        )
    }

}
</code>```

The 'componentDidMount' should update the currentOrder attribute of the object and render the cards list again, but this is not happening. In fact, the list being rendered empty.
What could I do to fix this?

(Sorry for my bad english)

--UPDATE--

The DiscardPile component is called by the KlondikeTable component, shown bellow:

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

import './KlondikeTable.scss';

import Card from './../../generalComponents/Card/Card';
import DiscardPile from '../../generalComponents/DiscardPile/DiscardPile';
import FlippedPile from '../../generalComponents/FlippedPile/FlippedPile';
import SuitsPile from '../../generalComponents/SuitsPile/SuitsPile';
import CardsColumn from '../../generalComponents/CardsColumn/CardsColumn';

export default class KlondikeTable extends Component {

    constructor(props) {
        super(props);
        this.state = {
            cards: [],
            initialDistribution: {
                discardPile: [],
                flippedPile: [],
                cardsPile1: [],
                cardsPile2: [],
                cardsPile3: [],
                cardsPile4: [],
                cardsPile5: [],
                cardsPile6: [],
                cardsPile7: [],
            },
            currentDistribution: null
        }
        this.generateCards = this.generateCards.bind(this);
        this.shuffleCards = this.shuffleCards.bind(this);
    }

    componentDidMount() {
        this.generateCards();
    }

    generateCards() {
        let cards = [];
        let types = ["K","Q","J","10","9","8","7","6","5","4","3","2","A"];
        let suits = ["spades", "clubs", "diamonds", "hearts"];
        for(let i = 0; i < suits.length; i++) {
            for(let j = 0; j < types.length; j++) {
                cards.push(
                    {key: types[j] + "-" + suits[i] + "-0", type: types[j], suit: suits[i], label: "0", flipped: false, draggable: true, currentOrder: 0}
                )
            }
        }
        this.setState(state => ({...state, cards: cards}), () => {
            this.shuffleCards();
        });
    }

    shuffleCards() {
        let amount = 52;
        let numbersArray = [];
        let cards = [...this.state.cards];
        let initialDistribution = {...this.state.initialDistribution};
        for(let i = 0; i < 52; i++) {
            numbersArray.push(i);
        }
        for(let i = 0; i < 24; i++) {
            let randomNumber = Math.floor(Math.random() * amount);
            let removedElement = cards.splice(randomNumber, 1)[0];
            initialDistribution.discardPile.push(removedElement);
            amount--;
        }
        for(let i = 0; i < 28; i++) {
            let randomNumber = Math.floor(Math.random() * amount);
            let removedElement = cards.splice(randomNumber, 1)[0];
            if(i < 1) {
                initialDistribution.cardsPile1.push(removedElement);
            }else if(i < 3) {
                initialDistribution.cardsPile2.push(removedElement);
            }else if(i < 6) {
                initialDistribution.cardsPile3.push(removedElement);
            }else if(i < 10) {
                initialDistribution.cardsPile4.push(removedElement);
            }else if(i < 15) {
                initialDistribution.cardsPile5.push(removedElement);
            }else if(i < 21) {
                initialDistribution.cardsPile6.push(removedElement);
            }else if(i >= 21) {
                initialDistribution.cardsPile7.push(removedElement);
            }
            amount--;
        }
        this.setState({initialDistribution: initialDistribution, currentDistribution: initialDistribution});
    }

    render() {
        return (
            <div className="klondike-table">
                <DiscardPile cards={this.state.initialDistribution.discardPile}></DiscardPile>
                <FlippedPile cards={this.state.initialDistribution.flippedPile}></FlippedPile>
                <div className="suits-piles-container">
                    <SuitsPile></SuitsPile>
                    <SuitsPile></SuitsPile>
                    <SuitsPile></SuitsPile>
                    <SuitsPile></SuitsPile>
                </div>
                <CardsColumn cards={this.state.initialDistribution.cardsPile1}></CardsColumn>
                <CardsColumn cards={this.state.initialDistribution.cardsPile2}></CardsColumn>
                <CardsColumn cards={this.state.initialDistribution.cardsPile3}></CardsColumn>
                <CardsColumn cards={this.state.initialDistribution.cardsPile4}></CardsColumn>
                <CardsColumn cards={this.state.initialDistribution.cardsPile5}></CardsColumn>
                <CardsColumn cards={this.state.initialDistribution.cardsPile6}></CardsColumn>
                <CardsColumn cards={this.state.initialDistribution.cardsPile7}></CardsColumn>
            </div>
        )
    }

}
</code>```

答:
First of all, you do not need to have a currentCards state element. Think of it this way if you need your state element to be always updated with your props element content you might be thinking it wrong. Moreover, if your state element is just going to be a slight variation of the element you are receiving in props then you definitely don't need it.
Your code isn't working because on the first render your component is receiving an empty array, thus setting an empty currentCards array and never changing it.

Just use

```<code>render() {
    return (
        <div id="discard-pile" className="discard-pile">
            {this.props.cards.map((card, currentOrder)=>(
                <Card key={card.key} type={card.type} suit={card.suit} label={card.label} flipped={card.flipped} draggable={card.draggable} currentOrder={currentOrder}></Card>
            ))}
        </div>
    )
}`
</code>```

to achieve the expected behavior.

If what you want is to have only the initial version of props.cards on your state you might want to use componentDidUpdate or even shouldComponentUpdate with a well defined set of rules to avoid performance damage or infinitely re-rendering.

Body:
I have a component called DiscardPile that's receive in your props (props.cards) an array of objects like this:

{key: 'key', 'type', suit: 'suit', label: 'label', flipped: 'fliped, draggable: 'draggable', currentOrder: 0}

Well, the component DiscardPile is shown bellow:

import React, { Component } from 'react';
import $ from 'jquery';
import 'jquery-ui/ui/core';
import 'jquery-ui/ui/widgets/droppable';

import './DiscardPile.scss';

import Card from '../Card/Card';
export default class DiscardPile extends Component {

    constructor(props) {
        super(props);
        this.state = {
            currentCards: []
        }
    }

    componentDidMount() {
        let currentCards = [...this.props.cards];
        for(let i = 0; i < currentCards.length; i++) {
            currentCards[i].currentOrder = i;
        }
        this.setState({currentCards: currentCards});
    }

    render() {
        return (

                {this.state.currentCards.map(card =>(
                    <Card key={card.key} type={card.type} suit={card.suit} label={card.label} flipped={card.flipped} draggable={card.draggable} currentOrder={card.currentOrder}></Card>
                ))}

        )
    }

}

The 'componentDidMount' should update the currentOrder attribute of the object and render the cards list again, but this is not happening. In fact, the list being rendered empty.
What could I do to fix this?

(Sorry for my bad english)

--UPDATE--

The DiscardPile component is called by the KlondikeTable component, shown bellow:

import React, { Component } from 'react';

import './KlondikeTable.scss';

import Card from './../../generalComponents/Card/Card';
import DiscardPile from '../../generalComponents/DiscardPile/DiscardPile';
import FlippedPile from '../../generalComponents/FlippedPile/FlippedPile';
import SuitsPile from '../../generalComponents/SuitsPile/SuitsPile';
import CardsColumn from '../../generalComponents/CardsColumn/CardsColumn';

export default class KlondikeTable extends Component {

    constructor(props) {
        super(props);
        this.state = {
            cards: [],
            initialDistribution: {
                discardPile: [],
                flippedPile: [],
                cardsPile1: [],
                cardsPile2: [],
                cardsPile3: [],
                cardsPile4: [],
                cardsPile5: [],
                cardsPile6: [],
                cardsPile7: [],
            },
            currentDistribution: null
        }
        this.generateCards = this.generateCards.bind(this);
        this.shuffleCards = this.shuffleCards.bind(this);
    }

    componentDidMount() {
        this.generateCards();
    }

    generateCards() {
        let cards = [];
        let types = ["K","Q","J","10","9","8","7","6","5","4","3","2","A"];
        let suits = ["spades", "clubs", "diamonds", "hearts"];
        for(let i = 0; i < suits.length; i++) {
            for(let j = 0; j < types.length; j++) {
                cards.push(
                    {key: types[j] + "-" + suits[i] + "-0", type: types[j], suit: suits[i], label: "0", flipped: false, draggable: true, currentOrder: 0}
                )
            }
        }
        this.setState(state => ({...state, cards: cards}), () => {
            this.shuffleCards();
        });
    }

    shuffleCards() {
        let amount = 52;
        let numbersArray = [];
        let cards = [...this.state.cards];
        let initialDistribution = {...this.state.initialDistribution};
        for(let i = 0; i < 52; i++) {
            numbersArray.push(i);
        }
        for(let i = 0; i < 24; i++) {
            let randomNumber = Math.floor(Math.random() * amount);
            let removedElement = cards.splice(randomNumber, 1)[0];
            initialDistribution.discardPile.push(removedElement);
            amount--;
        }
        for(let i = 0; i < 28; i++) {
            let randomNumber = Math.floor(Math.random() * amount);
            let removedElement = cards.splice(randomNumber, 1)[0];
            if(i < 1) {
                initialDistribution.cardsPile1.push(removedElement);
            }else if(i < 3) {
                initialDistribution.cardsPile2.push(removedElement);
            }else if(i < 6) {
                initialDistribution.cardsPile3.push(removedElement);
            }else if(i < 10) {
                initialDistribution.cardsPile4.push(removedElement);
            }else if(i < 15) {
                initialDistribution.cardsPile5.push(removedElement);
            }else if(i < 21) {
                initialDistribution.cardsPile6.push(removedElement);
            }else if(i >= 21) {
                initialDistribution.cardsPile7.push(removedElement);
            }
            amount--;
        }
        this.setState({initialDistribution: initialDistribution, currentDistribution: initialDistribution});
    }

    render() {
        return (

                <DiscardPile cards={this.state.initialDistribution.discardPile}></DiscardPile>
                <FlippedPile cards={this.state.initialDistribution.flippedPile}></FlippedPile>

                    <SuitsPile></SuitsPile>
                    <SuitsPile></SuitsPile>
                    <SuitsPile></SuitsPile>
                    <SuitsPile></SuitsPile>

                <CardsColumn cards={this.state.initialDistribution.cardsPile1}></CardsColumn>
                <CardsColumn cards={this.state.initialDistribution.cardsPile2}></CardsColumn>
                <CardsColumn cards={this.state.initialDistribution.cardsPile3}></CardsColumn>
                <CardsColumn cards={this.state.initialDistribution.cardsPile4}></CardsColumn>
                <CardsColumn cards={this.state.initialDistribution.cardsPile5}></CardsColumn>
                <CardsColumn cards={this.state.initialDistribution.cardsPile6}></CardsColumn>
                <CardsColumn cards={this.state.initialDistribution.cardsPile7}></CardsColumn>

        )
    }

}

Body:
First of all, you do not need to have a currentCards state element. Think of it this way if you need your state element to be always updated with your props element content you might be thinking it wrong. Moreover, if your state element is just going to be a slight variation of the element you are receiving in props then you definitely don't need it.
Your code isn't working because on the first render your component is receiving an empty array, thus setting an empty currentCards array and never changing it.

Just use

render() {
    return (
        <div id="discard-pile" className="discard-pile">
            {this.props.cards.map((card, currentOrder)=>(
                <Card key={card.key} type={card.type} suit={card.suit} label={card.label} flipped={card.flipped} draggable={card.draggable} currentOrder={currentOrder}></Card>
            ))}
        </div>
    )
}`

to achieve the expected behavior.

If what you want is to have only the initial version of props.cards on your state you might want to use componentDidUpdate or even shouldComponentUpdate with a well defined set of rules to avoid performance damage or infinitely re-rendering.


问:
how can i see the current location on google map ,using obj c
hii every one

how to see the current location in google map using obj c can any buddy suggest me some good tutorial for the same

thanx in advance

答:
CLLocationCoordinate2D location =
        [[[mapview userLocation] location] coordinate];

NSLog(@"Location found from Map: %f %f",
        location.latitude,location.longitude);


问:
Many kubernetes secrets vs many keys in one k8s secret
Imagine a complex deployment with many dependencies that needs to connect to lots of things, and where the secrets is only used this current namespace with this one complex deployment.

Would you recommend having many secrets:

certificates.yaml

redis-password.yaml

gcp-credentials.yaml

etc....

Or one secret for the deployment with lots of keys:

```<code>apiVersion: v1
kind: Secret
metadata:
  name: all-the-secrets
data:
  redis-password: asdfa
  certificate-key: asdfadf
  certificatee-crt: adfadf
  ...
</code>```

The secrets will be used as environment variables:

```<code>name: redis-password
valueFrom:
  secretKeyRef:
    name: secret-name
    key: key-name

</code>```

And why is one better than the other?

Ps. They will all be encrypted with kubeseal

答:
For a complex deployment that needs many secrets, check cert-manager on kubernetes. Cert-manager creates and manages per-app certificates, keys and secrets for multiple applications and these secrets can be mounted inside pods.

Cert-manager also ties into a variety of sources such as Let’s Encrypt, HashiCorp Vault, Venafi, a simple signing key pair, or self signed. More info is in:

cert-manager docs

cert-manager on GitHub

Body:
Imagine a complex deployment with many dependencies that needs to connect to lots of things, and where the secrets is only used this current namespace with this one complex deployment.

Would you recommend having many secrets:

certificates.yaml

redis-password.yaml

gcp-credentials.yaml

etc....

Or one secret for the deployment with lots of keys:

apiVersion: v1
kind: Secret
metadata:
  name: all-the-secrets
data:
  redis-password: asdfa
  certificate-key: asdfadf
  certificatee-crt: adfadf
  ...

The secrets will be used as environment variables:

name: redis-password
valueFrom:
  secretKeyRef:
    name: secret-name
    key: key-name

And why is one better than the other?

Ps. They will all be encrypted with kubeseal


问:
Assert.fail equivalent using hamcrest
I use JUnit for Assert.fail but I do not know what is the Hamcrest equivalent. Does anyone know?

答:
Depending on how your test is structured, I found this more natural using the not(anything()) Matchers.</p>

```<code>@Test(expected = MyException.class)
public void runMyTestHere() {

    ...

    MyObj result = myService.getThing(id);
    assertThat("Exception should have been thrown.", result, is(not(anything())));
}
</code>```

Title: Assert.fail equivalent using hamcrest

Body:
Depending on how your test is structured, I found this more natural using the not(anything()) Matchers.

@Test(expected = MyException.class)
public void runMyTestHere() {

    ...

    MyObj result = myService.getThing(id);
    assertThat("Exception should have been thrown.", result, is(not(anything())));
}


问:
Extract a word from multiline string
I have a multiline string from which I have to extract a word.

Sample String:

```<code>`Locale LANG set to the following: "en"
Scheduled for (Exp) 02/12/20 (#4662) on CSC2CXN00002555.  Batchman LIVES.  Limit: 80, Fence: 0, Audit Level: 1`
</code>```

I have to extract only the word CSC2CXN00002555. I tried using regex_search ansible module

```<code>{{ input_string | regex_search('on(.*).  Batchman', multiline=True) }}
</code>```

But I'm getting the whole pattern as output:

```<code>{
"msg": "on CSC2CXN00002555.  Batchman"
}
</code>```

Is there a way to achieve this?

答:
You should use regex_replace if you want to return only a smaller part of your regex.

You can handle the multiline by splitting on newline.

```<code>---
- hosts: localhost
  gather_facts: no

  vars:
    input_string: |
        Locale LANG set to the following: "en"
        Scheduled for (Exp) 02/12/20 (#4662) on CSC2CXN00002555.  Batchman LIVES.  Limit: 80, Fence: 0, Audit Level: 1

  tasks:

    - name: "it will return 'CSC2CXN00002555'"
      debug:
        msg: "{{ input_string.split('\n') | regex_replace('^.+ on (\\w+)\\.  Batchman .+', '\\1') }}"
</code>```

And for a better understanding of regexes, play with regex101.

Explanation of the regex here: https://regex101.com/r/4RqNb4/1

Title: Extract a word from multiline string

Body:
I have a multiline string from which I have to extract a word.

Sample String:

`Locale LANG set to the following: "en"
Scheduled for (Exp) 02/12/20 (#4662) on CSC2CXN00002555.  Batchman LIVES.  Limit: 80, Fence: 0, Audit Level: 1`

I have to extract only the word CSC2CXN00002555. I tried using regex_search ansible module

{{ input_string | regex_search('on(.*).  Batchman', multiline=True) }}

But I'm getting the whole pattern as output:

{
"msg": "on CSC2CXN00002555.  Batchman"
}

Is there a way to achieve this?

Body:
You should use regex_replace if you want to return only a smaller part of your regex.

You can handle the multiline by splitting on newline.

---
- hosts: localhost
  gather_facts: no

  vars:
    input_string: |
        Locale LANG set to the following: "en"
        Scheduled for (Exp) 02/12/20 (#4662) on CSC2CXN00002555.  Batchman LIVES.  Limit: 80, Fence: 0, Audit Level: 1

  tasks:

    - name: "it will return 'CSC2CXN00002555'"
      debug:
        msg: "{{ input_string.split('\n') | regex_replace('^.+ on (\\w+)\\.  Batchman .+', '\\1') }}"

And for a better understanding of regexes, play with regex101.

Explanation of the regex here: https://regex101.com/r/4RqNb4/1


问:
python word frequencies for dictionary with values and key
I am a first-time learner of python, I understand how to use word frequencies to count the number of each unique variable of a list, like this

```<code>sentence = ['hello', 'people', 'are', 'the', 'most', 'common', 'word', 'people', 'use', 'for', 'language ', 'learning']

words_freq ={} #dictionary for the counts
for word in sentence:
    if word not in words_freq:

        words_freq[word] =1
    else:

        words_freq[word] +=1

print (words_freq)
</code>```

however, I wonder how could a word frequencies do on the dictionary by using a double for loop?

for example, I have a dictionary like this

```<code>Food = {
2015: ["Apple", "Milk", "Cookie", "Banana", "Orange" ],
2016: ["Potato", "Orange", "Chocolate", "Milk", "Mango"],
2017: ["Fish", "Potato", "Orange", "Mango", "Banana"],
2018: ["Beef", "Pork", "Fish", "Apple", "Cookie"],
2019: ["Pork", "Orange", "Apple", "Mango", "Chocolate"]
}
</code>```

how to do a word frequencies/count and print something like this? Or store the highest value in list form ?
apple : 3
milk : 2
orange : 3
..
..
..

答:
defaultdict would be pretty elegant for your use case
it create a default dictionary for a given type for int - the default value is 0 for int value, it enable you to write less code

https://docs.python.org/3.3/library/collections.html#collections.defaultdict

from collections import defaultdict

```<code>def get_freq(food_dict: dict) -> dict:
    freq = defaultdict(int)
    for year, lst in food_dict.items():
        for elem in lst:
            freq[elem] += 1
    return freq
</code>```

Body:
I am a first-time learner of python, I understand how to use word frequencies to count the number of each unique variable of a list, like this

sentence = ['hello', 'people', 'are', 'the', 'most', 'common', 'word', 'people', 'use', 'for', 'language ', 'learning']

words_freq ={} #dictionary for the counts
for word in sentence:
    if word not in words_freq:

        words_freq[word] =1
    else:

        words_freq[word] +=1

print (words_freq)

however, I wonder how could a word frequencies do on the dictionary by using a double for loop?

for example, I have a dictionary like this

Food = {
2015: ["Apple", "Milk", "Cookie", "Banana", "Orange" ],
2016: ["Potato", "Orange", "Chocolate", "Milk", "Mango"],
2017: ["Fish", "Potato", "Orange", "Mango", "Banana"],
2018: ["Beef", "Pork", "Fish", "Apple", "Cookie"],
2019: ["Pork", "Orange", "Apple", "Mango", "Chocolate"]
}

how to do a word frequencies/count and print something like this? Or store the highest value in list form ?
apple : 3
milk : 2
orange : 3
..
..
..

Body:
defaultdict would be pretty elegant for your use case
it create a default dictionary for a given type for int - the default value is 0 for int value, it enable you to write less code

https://docs.python.org/3.3/library/collections.html#collections.defaultdict

from collections import defaultdict

def get_freq(food_dict: dict) -> dict:
    freq = defaultdict(int)
    for year, lst in food_dict.items():
        for elem in lst:
            freq[elem] += 1
    return freq