text:
Q: Spring Boot on Google Cloud SQL - org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set When I run my program in localhost connecting remotely to Google Cloud SQL (MySQL), it works. All the necessary IAM permission are in place once the program is deployed in the Google App Engine, it causes the error:
org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set. Logs Below:

Caused by: org.hibernate.HibernateException: Access to
  DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
    at
  org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:100)
  ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]     at
  org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:54)
  ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]     at
  org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:137)
  ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]     at
  org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35)
  ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]     at
  org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88)
  ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]     at
  org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:254)
  ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]     ... 41 common
  frames omitted

POM File:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 <modelVersion>4.0.0</modelVersion>

 <groupId>com.myapi</groupId>
 <artifactId>myapi</artifactId>
 <version>0.0.1-SNAPSHOT</version>
 <packaging>jar</packaging>

 <name>myapi</name>
 <description>My API</description>

 <parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>1.5.9.RELEASE</version>
  <relativePath/> <!-- lookup parent from repository -->
 </parent>

 <properties>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  <java.version>1.8</java.version>

  <INSTANCE_CONNECTION_NAME>myapi:asia-south1:myapidb</INSTANCE_CONNECTION_NAME>
  <user>root</user>
  <password>complicated password</password>
  <database>myapidb</database>
 </properties>

 <dependencies>
  <dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-web</artifactId>
  </dependency>

  <dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-test</artifactId>
   <scope>test</scope>
  </dependency>

  <dependency>
   <groupId>org.springframework.security.oauth</groupId>
   <artifactId>spring-security-oauth2</artifactId>
   <version>2.2.1.RELEASE</version>
  </dependency>

  <dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-data-jpa</artifactId>
  </dependency>

  <!--<dependency>
   <groupId>mysql</groupId>
   <artifactId>mysql-connector-java</artifactId>
   <scope>runtime</scope>
   <!–<version>8.0.8-dmr</version>–>
  </dependency>-->

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

  <dependency>
   <groupId>org.springframework.security</groupId>
   <artifactId>spring-security-jwt</artifactId>
  </dependency>

  <!--<dependency>
   <groupId>com.google.cloud.sql</groupId>
   <artifactId>mysql-socket-factory-connector-j-6</artifactId>
   <version>1.0.4</version>
  </dependency>-->
  <dependency>
   <groupId>com.google.cloud.sql</groupId>
   <artifactId>mysql-socket-factory</artifactId>
   <version>1.0.4</version>
  </dependency>

  <!--<dependency>
   <groupId>com.google.appengine</groupId>
   <artifactId>appengine-maven-plugin</artifactId>
   <version>1.9.63</version>
  </dependency>-->

  <dependency>
   <groupId>com.google.cloud.tools</groupId>
   <artifactId>appengine-maven-plugin</artifactId>
   <version>1.3.2</version>
  </dependency>

  <!--<dependency>
   <groupId>com.google.cloud.sql</groupId>
   <artifactId>mysql-socket-factory</artifactId>
   <!–<version>1.0.4</version>–>
   <version>1.0.5</version>
  </dependency>-->

  <dependency>
   <groupId>com.google.guava</groupId>
   <artifactId>guava</artifactId>
   <version>23.6-jre</version>
  </dependency>

  <!--<dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-jdbc</artifactId>
  </dependency>-->

  <dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-jdbc</artifactId>
  </dependency>

  <!--dependency>
   <groupId>org.springframework.cloud</groupId>
   <artifactId>spring-cloud-gcp-starter-sql</artifactId>
   <version>1.0.0.M1</version>
  </dependency>-->

  <dependency>
   <groupId>com.fasterxml.jackson.datatype</groupId>
   <artifactId>jackson-datatype-jsr310</artifactId>
  </dependency>

  <dependency>
   <groupId>com.fasterxml.jackson.module</groupId>
   <artifactId>jackson-module-parameter-names</artifactId>
  </dependency>
  <dependency>
   <groupId>com.fasterxml.jackson.datatype</groupId>
   <artifactId>jackson-datatype-jdk8</artifactId>
  </dependency>

  <dependency>
   <groupId>org.springframework.data</groupId>
   <artifactId>spring-data-jpa</artifactId>
  </dependency>

  <!--<dependency>
   <groupId>org.springframework.cloud</groupId>
   <artifactId>spring-cloud-gcp</artifactId>
   <version>1.0.0.M2</version>
  </dependency>-->

 </dependencies>

 <!--<repositories>
  <repository>
   <id>spring-milestones</id>
   <name>Spring Milestones</name>
   <url>https://repo.spring.io/libs-milestone</url>
   <snapshots>
    <enabled>false</enabled>
   </snapshots>
  </repository>
 </repositories>-->
 <!--<repositories>
  <repository>
   <id>spring-milestones</id>
   <name>Spring Milestones</name>
   <url>https://repo.spring.io/milestone</url>
   <snapshots>
    <enabled>false</enabled>
   </snapshots>
  </repository>
 </repositories>-->
 <build>
  <plugins>
   <plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
   </plugin>
  </plugins>
 </build>

</project>

A: I have not myself worked with Spring Boot and Cloud SQL, but according to some external sources like [A] or [B], you should have a file called application.properties in the directory src/main/resources of your application, and there, you should set some spring properties like:
database=mysql
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://google/<DB_NAME>?cloudSqlInstance=<INSTANCE_CONNECTION_NAME>&socketFactory=com.google.cloud.sql.mysql.SocketFactory
spring.datasource.username=<USERNAME>
spring.datasource.password=<PASSWORD>

Make sure that you are setting the names properly in this application.properties file, and also in the pom.xml file.

*

*A - Community Tutorial on how to run Spring Boot with Cloud SQL on
GAE Flexible

*B - Guide on how to connect to Cloud SQL using Spring

A: Your JDBC connection string is probably incorrect for App Engine, and Hibernate is unable to figure out the dialect automatically. Note that the connection string for connecting locally is different than when running on App Engine. See docs.
  <system-properties>
    <property name="cloudsql" value="jdbc:google:mysql://${INSTANCE_CONNECTION_NAME}/${database}?user=${user}&password=${password}" />
    <property name="cloudsql-local" value="jdbc:mysql://google/${database}?useSSL=false&cloudSqlInstance=${INSTANCE_CONNECTION_NAME}&socketFactory=com.google.cloud.sql.mysql.SocketFactory&user=${user}&password=${password}" />
  </system-properties>

Also, since you are using Spring Boot, you might want to consider using Spring Cloud GCP for connecting to Cloud SQL, which has support for automatically detecting App Engine and generating the correct connection string.

A: For me it was nothing to do with the hibernate setup.
In the stackdriver's log there was a clear error message to enable the Cloud SQL Admin API:
java.lang.RuntimeException: The Google Cloud SQL API is not enabled for project [<project>]. Please use the Google Developers Console to enable it: https://console.cloud.google.com/apis/api/sqladmin/overview?project=<project>

A similar error message (as in OP's post) happens when the JDBC URL is wrong and your app can't connect to the Cloud SQL database.

A: Add in your pom.xml:
<dependency>
    <groupId>com.google.cloud.sql</groupId>
    <artifactId>mysql-socket-factory-connector-j-8</artifactId>
    <version>1.0.15</version>
</dependency>

jdbc:mysql:///<DATABASE_NAME>?cloudSqlInstance=<INSTANCE_CONNECTION_NAME>&socketFactory=com.google.cloud.sql.mysql.SocketFactory&useSSL=false&user=<USER_NAME>&password=<USER_PASSWORD>

spring:
    data:
        rest:
            base-path: /api
    datasource:
        driver-class-name: com.mysql.cj.jdbc.Driver

For the driver use this new one: com.mysql.cj.jdbc.Driver ,
about the SocketFactory, it gets your instances IP address base on the provided cloudSqlInstance


text:
Q: Should the use of the INTENT keyword speed the code up? This question is based on an answer to the post Fortran intent(inout) versus omitting intent, namely the one by user Vladimyr, @Vladimyr.
He says that "<...> Fortran copies that data into a contiguous section of memory, and passes the new address to the routine. Upon returning, the data is copied back into its original location. By specifying INTENT, the compiler can know to skip one of the copying operations."
I did not know this at all, I thought Fortran passes by reference exactly as C.
The first question is, why would Fortran do so, what is the rationale behind this choice?
As a second point, I put this behaviour to the test. If I understood correctly, use of INTENT(IN) would save the time spent in copying back the data to th original location, as the compiler is sure the data has not been changed.
I tried this little piece of code
function funco(inp) result(j)
  !!  integer, dimension(:), intent (in) :: inp
  integer, dimension(:):: inp
    integer, dimension(SIZE(inp)) :: j ! output
    j = 0.0       !! clear whole vector
    N = size(inp)
    DO i = 1, N
      j(i) = inp(i)
   END DO
end function

program main
    implicit none

interface
    function funco(inp) result(j)
  !!  integer, dimension(:), intent (in) :: inp
    integer, dimension(:) :: inp
    integer, dimension(SIZE(inp)) :: j ! output
    end function
   end interface

    integer, dimension(3000) :: inp , j
 !!   integer, dimension(3000) :: funco
    integer :: cr, cm , c1, c2,  m
    real :: rate, t1, t2

! Initialize the system_clock
  CALL system_clock(count_rate=cr)
  CALL system_clock(count_max=cm)
CALL CPU_TIME(t1)
  rate = REAL(cr)
  WRITE(*,*) "system_clock rate ",rate

    inp = 2
DO m = 1,1000000
     j = funco(inp) + 1
END DO

    CALL SYSTEM_CLOCK(c2)

 CALL CPU_TIME(t2)
WRITE(*,*) "system_clock : ",(c2 - c1)/rate
  WRITE(*,*) "cpu_time     : ",(t2-t1)
end program

The function copies an array, and in the main body this is repeated many times.
According to the claim above, the time spent in copying back the array should somehow show up.
system_clock rate    1000.00000
 system_clock :    2068.07910
 cpu_time     :    9.70935345

but the results are pretty much the same independently from whether INTENT is use or not.
Could anybody share some light on these two points, why does Fortran performs an additional copy (which seems ineffective at first, efficiency-wise) instead of passing by reference, and does really INTENT save the time of a copying operation?

A: The answer you are referring to speaks about passing some specific type of subsection, not of the whole array. In that case a temporary copy might be necessary, depending on the function. Your function uses and assumed shape array and a temporary array will not be necessary even if you try quite hard.
An example of what the author (it wasn't me) might have had in mind is
module functions
  implicit none
contains

  function fun(a, n) result(res)
    real :: res
    ! note the explicit shape !!!
    integer, intent(in) :: n
    real, intent(in) :: a(n, n)
    integer :: i, j

    do j = 1, n
      do i = 1, n
        res = res + a(i,j) *i + j
      end do
    end do
  end function
end module

program main
  use functions

  implicit none

  real, allocatable :: array(:,:)
  real :: x, t1, t2
  integer :: fulln

  fulln = 400

  allocate(array(1:fulln,1:fulln))

  call random_number(array)

  call cpu_time(t1)

  x = fun(array(::2,::2),(fulln/2))

  call cpu_time(t2)

  print *,x

  print *, t2-t1

end program

This program is somewhat faster with intent(in) when compared to intent(inout) in Gfortran (not so much in Intel).  However, it is even much faster with an assumed shape array a(:,:). Then no copy is performed.
I am also getting some strange uninitialized accesses in gfortran when running without runtime checks. I do not understand why.
Of course this is a contrived example and there are real cases in production programs where array copies are made and then intent(in) can make a difference.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Query a postgres database for the SQL which generates the tables We want to replicate our local test DB automatically, given the structure of the production DB, on the fly / on demand.
What would be nice, would be to query the prod DB and retrieve the SQL that generates the tables/views and then run that SQL against a cleaned out local DB.
Or perhaps there is a better way to replicate a production DB on a local machine?
What is the best way to do this?

A: If I understood your question correct, you need to copy DB schema. You can use pg_dump with --schema-only parameter to do this. It'll only dump schema of the database, and you can import it locally.
$ pg_dump mydb --schema-only > mydb-schema.sql


text:
Q: Trying to remember a book where a young man refuses to upload his mind digitally A young man lives in an abandoned town where almost everyone has uploaded their mind into a network (which I think was based on crystals somehow?) so that they can live forever in peace and prosperity. His parents left him as a kid to join the network and left him in the care of a manufactured creature, which I believe was lizard/dinosaur like in appearance because that what the man liked as a kid. He occasionally visits his parents, who are always worried because they want him to "live" forever as they do, and they end up secretly creating a woman for him to fall in love with so that he will want to join them.  Turns out that they did this by smushing together copies of his grandmother from a bunch of different times in her life. Apparently someone does this often, because I know the woman has a conversation with another being created the same way, who's basically enslaved
I have no idea when it was published, it could have even been in the last few years.  I think the cover was mostly white? Any help would be much appreciated

A: This seems very close to Circuit of Heaven, and it has a sequel.
From Circuit of Heaven:

Plot Summary-
  In the future, most of the Earth's population have abandoned their bodies and permanently uploaded their personalities to "the Bin": a vast network of silicon crystals that supports a perfect, peaceful, deathless virtual society. Only the creeps, the crazies, the religious fundamentalists, and a few righteous rebels remain behind. One of these last is 21-year-old Nemo, forsaken by his parents' quest for cyber-utopia. Nemo is determined to live, age, and die in the bleak hell that the Earth has become rather than sacrifice his soul to a technological purgatory. But all of Nemo's hard-won convictions are shaken when, on a visit to the Bin, he meets his soul mate, a beautiful woman newly arrived in the virtual paradise who is struggling to recall her mysterious, dreamlike past.


text:
Q: Find next table when click in a div I need get id or class from next table, for example, when I click in any div in blue square, get id or class from the table of red square.
If I use this:
$('div').click(function() {
    console.log($(this).next().find('table').attr('id));
});

But doesn't work!

HTML CODE

    Status ::

Todos

Pendiente

En Atención

Concluido

Cerrado
 | Acciones ::

Para visualizar los detalles del ticket, presione sobre la fila deseada.

            #TKMA
            CLIENTE
            EMPRESA
            ING. ASIGNADO
            FECHA CREACIÓN
            OBSERVACIONES
            STATUS

A: next() only gets you to the next sibling, which in this case is the next blue
.
You have to go up the tree to the
 that is sibling to the
 containing the
.
In your example, the following should work.
Fiddle
$('#statusServ').children().click(function(){
    console.log(
        $(this)             // div that was clicked
            .parent().parent()       // #statusServ
            .find('table')         // #rBuscarServicio_wrapper
            .prop('id')     // 'rBuscarServicio'
    );
});

NOTE:
Generally it is best to use prop() instead of attr()
prop() vs attr()

A: $('div.colorstatus').click(function() {
  console.log($(this).closest('div.buscar').find('table').attr('id'));
});

EDIT (alternative for HTML provided at bottom of post):
$('div.colorstatus').click(function() {
  console.log($(this).parent('div').siblings('table').attr('id'));
});


text:
Q: COMponents mscomctl.ocx, mscomct2.ocx, mswinsck.ocx: set off Kill-Bit programmatically On Windows 7, the COMponents listed in the title seem by default to have the "killbit" set to COMPAT_EVIL_DONT_LOAD (compare MSDN), that is, their Compatibility Flags in HKLM\SW\IE\ActiveX Compatibility\{<CLSID>}\ seem to be set to that value by default:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\ActiveX Compatibility\{B09DE715-87C1-11D1-8BE3-0000F8754DA1}]
"Compatibility Flags"=dword:00000400

When I set the value to 0 (that's what Nirsoft's ActiveX Compatibility Manager does when "activating" a COMponent), everything works fine.
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\ActiveX Compatibility\{B09DE715-87C1-11D1-8BE3-0000F8754DA1}]
"Compatibility Flags"=dword:00000000

But this is just a GUI solution for one workstation. To deploy our software, I need a safe and stable procedure (script or tool) to ship with our software, that not only sets the "killbit" to 0 or deletes the registry entry (which procedure should be preferred?), but checks the situation before and does nothing if nothing is necessary. Preferably, the solution would just be passed over a file name or a list of files and proceeds everything else necessary on its own.
This is the point where the bigger questions begin:

*

*Regarding COM objects, the registry is queried by CLSID, not by ocx file name (that is the InProcServer32 entry in the Windows registry) nor by (VersionIndependent)ProgID (HKLM\Software\Classes\CLSID\{<CLSID>}\). Do you know a method, i.e., a batch / (PowerShell) script / tool / whatever to query the CLSIDs related to an ocx file or at least the ProgID radical?

*I understand the CLSID is constant in Windows 2000 up to 7?

*SlayOCX.vbs seems to be a low level approach that, called as a group policy as described in SlayOCX.vbs and here, could work as a network-wide solution. But: It's a vbs, switched off in some environments. Furthermore, I will end up with quite a list of CLSIDs to be checked by this script. Wrapped e.g. in a batch I will probably not be able to have it deployed by the customers' admins in the described way, but rather by logon script or runonce key in the registry or something -- not very elegant. So what would you suggest? I'd prefer a solution (a tool, a new group policy in 7 I don't know yet, a more sophisticated script with less dependency on system and security configuration issues, ...) that makes the first informational questions superfluous.

A: You want to expose your clients knowingly to security vulnerabilities? I am not a lawyer, but...
According to this post, the files mentioned are "Supported Runtime Files to Distribute with Your Application", you just need to update to the latest version.
Another post details the necessary steps (probably for an older update, but still it should get you started):   Clickety

A: CLSID Registry Scanner (COM/ActiveX)
is my answer to my own question. It's working for now, that's important for me now. It would be a moot discussion if it was not better to rewrite or at least refurbish the program, or both independently, and get rid of old hats. Would be moot because I do not make our budget decisions.

A: With the exception of the Treeview replacement code or API calls can be found for most usages of these OCXs.  Apparently there was some German commented API code available for purchase years ago for the treeview.   All these OCXs are is a wrapper for the API calls anyhow.
See the Calendar Tips page at my website
The mswinsck is a bit trickier and I don't have a URL for that one.  However I'm sure there is VB6 code that can be found that will work quite nicely in VBA.
Blog posting - An older version of MSCOMM32.OCX has had the "kill bit" flag set.  Although you don't mention this one.


text:
Q: Foreign Key with multiple Inherited Classes EF Core 2.0 Code First I have 2 classes (A & B), both inherit from my Base class.
My Side Class has a BaseId and a Base field.
I'm working with Code First and Table per Concrete Class (TPC)
I'm trying to create Foreign keys to connect the Side table with my A & B table. When i create only one relation with fluent api it works fine. But when i add the second one, the new migration drop the FKs from A and create a new one for B. Why i can't create 2 relations?
public class Base
{
    public int    Id   { get; set; }
    public string Name { get; set; }
}

public class A : Base
{
    public string StringA { get; set; }
}

public class B : Base
{
    public string StringA { get; set; }
}

public class Side
{
    public int Id { get; set; }
    public int BaseId { get; set; }
    public Base Base { get; set; }
}

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    modelBuilder.Entity<Side>().HasOne(s => (A) s.Base);
    modelBuilder.Entity<Side>().HasOne(s => (B) s.Base);
}

A: Hopefully you already got this figured out, but as previously mentioned table TPC isn't supported!  You can use TPH.
To do TPH just do the following:
modelBuilder.Entity<Side>.ToTable("Sides")
            .HasDiscriminator<SideType>("SideType")
            .HasValue<A>(SideType.BASE_A)
            .HasValue<B>(SideType.BASE_A);

 public enum SideType {
    BASE_A = 100,
    BASE_B = 500
 }


text:
Q: Travel Mode (walking, cycling, driving) Segmentation of GPS data in R I work with GPS data (1 hz). I calculated the walking speed (meters per second) out of the coordinates information.
Now I have to classify the typ of the travel mode: Is it by foot, by bycicle, by car.
Here is an example of the data structure:
    userId  DateTime            lon         lat         speedms
1   01001   2018-05-08 17:05:21 8.551420    47.41114    1.0978790
2   01001   2018-05-08 17:05:22 8.551431    47.41115    1.5707432
3   01001   2018-05-08 17:05:23 8.551439    47.41116    1.0745824
4   01001   2018-05-08 17:05:24 8.551447    47.41116    1.1682027
5   01001   2018-05-08 17:05:25 8.551452    47.41118    1.3859502
6   01001   2018-05-08 17:05:26 8.551457    47.41118    0.9657960
7   01001   2018-05-08 17:05:27 8.551461    47.41119    1.2591893
8   01001   2018-05-08 17:05:28 8.551461    47.41121    2.0004471
9   01001   2018-05-08 17:05:29 8.551462    47.41123    2.2239989
10  01001   2018-05-08 17:05:30 8.551484    47.41124    1.6928664
11  01001   2018-05-08 17:05:31 8.551496    47.41126    *2.8167094*
12  01001   2018-05-08 17:05:32 8.551533    47.41124    *3.7848781*
13  01001   2018-05-08 17:05:33 8.551529    47.41123    0.4496923
14  01001   2018-05-08 17:05:34 8.551530    47.41125    1.2248210
15  01001   2018-05-08 17:05:35 8.551530    47.41125    0.3334079
16  01001   2018-05-08 17:05:36 8.551528    47.41126    1.3421395
17  01001   2018-05-08 17:05:37 8.551525    47.41127    0.6000021
18  01001   2018-05-08 17:05:38 8.551523    47.41128    1.1215550
19  01001   2018-05-08 17:05:39 8.551518    47.41128    1.1736288
20  01001   2018-05-08 17:05:40 8.551492    47.41132    *4.3563280*
21  01001   2018-05-08 17:05:41 8.551474    47.41135    *3.6000119*
22  01001   2018-05-08 17:05:42 8.551478    47.41135    0.3017647
23  01001   2018-05-08 17:05:43 8.551493    47.41133    2.2022842
24  01001   2018-05-08 17:05:44 8.551494    47.41133    0.5607775
25  01001   2018-05-08 17:05:45 8.551480    47.41134    1.3805747
26  01001   2018-05-08 17:05:46 8.551476    47.41131    2.9052493
27  01001   2018-05-08 17:05:47 8.551471    47.41130    1.3859500
28  01001   2018-05-08 17:05:48 8.551461    47.41130    0.8248025
29  01001   2018-05-08 17:05:49 8.551460    47.41128    2.1129303

This is only a subset of the data. I have over 20 million observations and no pre-classification of "trips" or whatever is made.
So, the person in the subset is walking. But there are some outliers (marked with the stars) because of the noise of the GPS device.
I can classify the GPS obverservations with the statement:
gps$movement <- ifelse(gps$speedms <=2.7, "walking", "not walking")

This is really "quick and dirty"... But it works for over 70% of the data. Now, I d'like to increase the classification success.
I think about a function, that compares pre and post observations and if (for example) the mean of the last 50 observations is lower than 2.7, it would classify the outlier also to walking.
Of course, the subset is shown only for the walking part. I have to do this also for driving, cycling.
Also the moment when a person walks first and then starts cycling is definitely challenging.
Thanks for your help!
PS: or is there even a specific r package? (I found the "trip" package, but there you need the GPS data already with a trip segmentation...)

My solution:
df <- df %>%
  mutate(rollingAvg_60 = rollapply(speedms, 60, mean, fill=NA, align='center'))


text:
Q: Get Dynamic Tabular from Website data using Selenium & Beautiful Soup from selenium import webdriver
from bs4 import BeautifulSoup
path = 'C:/Program Files/Google/Chrome/Application/ChromeDriver'
driver = webdriver.Chrome(executable_path = path)
driver.get("https://www1.nseindia.com/products/content/equities/equities/oi_spurts.htm")
soup = BeautifulSoup(driver.page_source,"lxml")
for items in soup.select('#profile table.table tr'):
    data = [item.get_text(strip=True) for item in items.select("th,td")]
    print(data)

I am trying to get a dynamic tabular data from website using selenium and chrome driver. Need some help in getting data as right now i am getting empty dataframe.

A: You're one request away from getting that table. It comes in as a plain JSON so all you need is requests.
For example:
import requests
from tabulate import tabulate

headers = {
    "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:82.0) Gecko/20100101 Firefox/82.0",
    "X-Requested-With": "XMLHttpRequest",
}
url = "https://www1.nseindia.com/live_market/dynaContent/live_analysis/oi_spurts/topPositiveOIChangeData.json"
response = requests.get(url, headers=headers).json()
print(tabulate(response["data"], headers="keys", showindex=False, tablefmt="pretty"))

Output:
+------------+-----------+-----------+----------+--------------+-------------+-----------------+------------+------+-----------+-------------+--------------+----------+
|   symbol   | latestOI  |  prevOI   | oiChange | percOIchange |   volume    |  valueInLakhs   | underlying | isFO |  FUTVAL   |   OPTVAL    |    TOTVAL    |  OPVAL   |
+------------+-----------+-----------+----------+--------------+-------------+-----------------+------------+------+-----------+-------------+--------------+----------+
| JINDALSTEL |   9,098   |   6,211   |  2,887   |    46.48     |   16,723    |   2,00,623.71   |   235.05   |  0   | 1,111.20  |   895.00    |   2,006.20   |  19.53   |
|  INFRATEL  |   9,707   |   6,987   |  2,720   |    38.93     |   57,630    |   3,40,222.56   |   221.70   |  0   | 1,111.91  |  2,290.29   |   3,402.20   |  65.60   |
|    GAIL    |   9,270   |   6,793   |  2,477   |    36.46     |   22,653    |   1,37,091.48   |   97.60    |  0   |  430.14   |   940.80    |   1,370.94   |  20.17   |
| BAJAJFINSV |  24,693   |  18,452   |  6,241   |    33.82     |  1,01,363   |  10,56,613.81   |  8,548.80  |  0   | 3,050.60  |  7,515.50   |  10,566.10   |  136.56  |
| BANKNIFTY  | 8,99,992  | 6,73,712  | 2,26,280 |    33.59     | 1,37,75,584 | 10,04,67,151.05 | 29,236.00  |  1   | 30,772.13 | 9,73,899.33 | 10,04,671.46 | 8,435.93 |
| ADANIPORTS |  34,066   |  26,191   |  7,875   |    30.07     |   39,050    |   3,72,251.30   |   375.95   |  0   | 2,629.21  |  1,093.32   |   3,722.53   |  14.28   |
|   TITAN    |  16,910   |  13,234   |  3,676   |    27.78     |   76,457    |   7,83,224.88   |  1,362.05  |  0   | 1,876.69  |  5,955.54   |   7,832.23   |  88.77   |
| AMARAJABAT |   2,376   |   1,913   |   463    |    24.20     |    8,709    |    76,247.76    |   862.00   |  0   |  205.81   |   556.65    |    762.46    |   6.49   |
|   INDIGO   |  11,782   |   9,593   |  2,189   |    22.82     |   38,356    |   3,23,486.48   |  1,675.35  |  0   | 1,419.05  |  1,815.81   |   3,234.86   |  31.15   |
| TATASTEEL  |  44,455   |  36,295   |  8,160   |    22.48     |   84,064    |   7,67,276.96   |   531.55   |  0   | 3,171.72  |  4,501.05   |   7,672.77   |  87.21   |
| TATAPOWER  |  11,705   |   9,598   |  2,107   |    21.95     |    7,330    |    58,594.30    |   58.10    |  0   |  365.53   |   220.41    |    585.94    |   3.56   |
| AUROPHARMA |  34,318   |  28,559   |  5,759   |    20.17     |   26,876    |   1,47,356.23   |   833.05   |  0   |  800.34   |   673.24    |   1,473.58   |  10.00   |
|    HDFC    | 1,27,756  | 1,06,830  |  20,926  |    19.59     |   77,486    |   5,51,136.78   |  2,329.00  |  0   | 2,666.28  |  2,845.07   |   5,511.35   |  31.63   |
and so on ..


text:
Q: upgrade to macOS Sierra breaks vim On the bash command line, in Terminal, I edit unicode text files in vim, often 1MB per file. This is command line vim, not not mvim or gvim.
One of my Macs runs OS X El Capitan 10.11.6. Two others, I have upgraded to OS X Sierra 10.12.5.
All computers have exactly the same .vimrc file (12655 abbreviations) and I vim-edit the same size of files on both computers.
Before the upgrade, vim performed on all Macs with no perceptible difference: "iab"s were reliably substituted in real time as I typed them, exactly as I specify in my .vimrc file.
But now on the upgraded (Sierra) machines, frequently my "iab" abbreviations are not converted to the proper value.  If I re-save the file I'm editing,  :w, then the "iab" substitution works again.
On the El Capitan machine, performance is as before.
I never experienced these problems with vim before upgrading to Sierra.
Has anyone experienced this? Is there a fix? What causes this?
Incidentally, the alpine command-line, text-based email client also has problems on the machines that were upgraded to Sierra.  Something in the unix shell seems to have been broken by the macos upgrade.


text:
Q: How can I align HTML elements printed in a loop? I'm printing a loop dynamically in a col-3. Each column contains 4 HTML elements.

*

*An Image

*A Title

*Some text content

*A button

Is it possible to make each elements top, line up with each other regardless of how many lines the element on top is?

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>

Title1

Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim pellentesque felis.

Title2

Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim pellentesque felis.

Title3

Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim pellentesque felis.

Title
 4

Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim pellentesque felis.

A: Personally, I would split the content into various rows, and put the columns inside those rows:

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />

Title1

Title2

Title3

Title
 4

Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim pellentesque felis.

Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim pellentesque felis.

Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim pellentesque felis.

Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim pellentesque felis.

A: One option is to separate your
 and
 into separate rows. That allows them to all be aligned horizontally.

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />

Title1

Title2

Title3

Title
 4

Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim pellentesque felis.

Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim pellentesque felis.

Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim pellentesque felis.

Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim pellentesque felis.


text:
Q: How to correct the code such that the loop stops when there is a data match We have new entries being pulled into a Google sheet daily using XML (Sheet 1). We are using the code below to pull these entries into a separate Google sheet for end users (Sheet 2). The end users can then edit the data. We are trying to compare the ID numbers in Sheet 1 and Sheet 2. Each time we run the code, ID numbers from Sheet 1 that do not have a match in Sheet 2 should be added to Sheet 2. If the ID number in Sheet 1 already exists in Sheet 2, that ID number should be skipped. It isn't skipping the matches. Instead it is adding everything to Sheet 2 every time we run the code and Sheet 2 now contains duplicates.

  for(var i = 1; i < slateDT.length; i ++) {
    var bannerid = slateDT[i][0];
    var match = "No Match";
    var j = 1;

    while(j < gradingDT.length && match == "No Match") {
      var matchID = gradingDT[j][1].trim();

      if(bannerid.trim() != matchID){
        j++;
      } else {
        match = "Match";
      }
    }

    if(match == "No Match"){
      additions.push(moveColumns(slateDT[i]));
    }
  }
    if(additions.length > 0) {
    gradingSS.getRange(gradingDT.length + 1, 2, additions.length, additions[0].length).setValues(additions);

     gradingDT = getDataValues(gradingSS.getName());
    var sortRng = gradingSS.getRange(2, 1, gradingDT.length, gradingDT[0].length);
    sortRng.sort(3);
  }

function moveColumns(studentRow) {
studentRow.splice(17, 3);

var v = checkDefined(studentRow.splice(20, 1));
  studentRow.splice(10, 0, v.join());

 v = checkDefined(studentRow.splice(18, 1));
  studentRow.splice(13, 0, v.join());

  v = checkDefined(studentRow.splice(20));
  studentRow.splice(14, 0, v.join());

  return studentRow;
}

A: Ok, I'm assuming that your weird moveColumns function does what you want and that the column numbers mismatch per my question above. Replace your for loop with this:
for (var i = 0; i < slateDT.length; i++) {
    var oldID = slateDT[i][0].trim();
    var matchID = 0;
    for (var j = 1; j < gradingDT.length; j++) {
        var newID = gradingDT[j][1].trim();
        if (oldID == newID) {
            matchID = j;
            break; //ends the j loop when it meets the match
        }
    } //for [j] loop
    if (matchID == 0) {
        additions.push(moveColumns(slateDT[i]));
        Logger.log("No match was found for " + i);
    } else {
        Logger.log("A match was found for " + i + " at " + j);
    }
} //for [i] loop

This is very similar to what you are trying to do with the while loop but without managing to never increment J under certain circumstances.
Once you are sure it is working comment out the two logger lines for performance.


text:
Q: How to avoid page reload when i select dropdown list ?? and also how to get selected values php I am stuck with small problem.
    when i change my drop down list the page is getting reloaded.
    Can any one  help me .
    This code is used to retrieve userid, based on userid get all the application id form drop down and populate it into dropdown list.
    If i select value in drop down  i am storing selected value
    Here is my code.
<?php
    $selected = " ";
    function get_options($select) {
        global $wpdb;
        $user_ID = get_current_user_id();

        echo $user_ID;

        $sql = $wpdb->get_col("select Application_ID from wp3_cteTest where $user_ID = userid");
        echo $sql;

        //print_r($keysql);

        $options = "";
        while (list($k, $v) = each($sql)) {
            if ($select == $v) {
                $options.='<option value="' . $v . '" selected>' . $v . '</option>';
            } else {
                $options.='<option value="' . $v . '">' . $v . '</option>';
            }
        }
        return $options;
    }

    if (isset($_POST['applications'])) {
        $selected = $_POST['applications'];
        echo $selected;
    }
?>

<html>
    <head>
    </head>
    <body>
        <form action="" method="POST">
            <?php $default_state = 'please Select your id'; ?>
            <select name="applications" onchange=this.form.submit()>
                <option value=' ' ><?php echo $default_state ?></option>
                <?php echo get_options($selected) ?>
            </select>
        </form>
    </body>
</html>

I Tried removing form, if i remove form drop down doesn't work, I wont get selected value.
    Then what is wrong??
    Thanks in advance!

A: You've got onchange=this.form.submit() in your select tag, so when you change the option selected javascript is submitting the form.
Just change...
<select name="applications" onchange=this.form.submit()>

...to...
<select name="applications">

A: So if you just need the selected id without submit the form then replace this line:
<select name="applications" onchange=this.form.submit()>

with this :
<select name="applications" onchange="getval(this)">

and Add little script :
<script type="text/javascript">
    function getval(sel) {
       alert(sel.value);
    }
</script>


text:
Q: Display base64 image from url to objectUrl There is a base64 image in the db and I need to fetch the image and store its localhost url into a variable. I need to use the fetch function because the image is authenticated. I am not sure if I have to use blob() or arraybuffer() or text() in the response.
fetch(url, {
method: 'GET',
  headers: {
    Authorization: '',
    'Content-Type': 'application/octet-stream'
  }
})
.then(response => response.blob())
.then(data => {
    const fileUrl = URL.createObjectUrl(data);
    console.log(fileUrl);
})

Apparently the database should return the base64 string. My plan is to create a blob then create an object url from it and store it. When I visit that object url, the page is black with nothing on it. The blob size is 16 too. What does that mean? Is the base64 string in the data?


text:
Q: How to negate some users while retrieving users from Google Apps I can apply the filter to get the specific users while retrieving all the users based on givenName, familyName and email attributes. But the requirement is to apply the filter such that it excludes some users while retrieving all the users e.g i don't want users which has givenName=admin*. I know that we can do post processing locally once all the users has been returned by Google API but it may have performance impact to exclude the unwanted users locally.
Is there any way to pass the filter to google APIs so that it return the all the users excluding the unwanted users?


text:
Q: How can I delay a jquery or CSS3 animation to start once the object is in view I want to use this animated graph as seen here
But it lives below the fold and I want it to only animate once it is in view.
I tried using the code provided here, which looks like it would do the trick:
Load (Lazy Loading) a Div whenever the DIV gets visible for the first time
Along with other similar posts but have had no success.
some help would be much appreciated. the barebones of the code can be seen here
Thanks.
Neil

A: I think the problem with this lazyLoad() function is that it uses the offset().top of the element to determine if the element is in the view of the window.
The problem though, is if your element display property is set to none, the offset method will return 0, which will fire the event when the page loads, thus making your animation start on page load.
Since your animation probably uses the display property to control the visiblitiy of the animation, you are probably getting a 0 value from the offset method.
Give this a try, put this in the lasyLoad() function just after it calls the offset method (about line 13) and see what the offset value is when the page loads
console.log("offset top " + ot + " height: " + ob);

Enter that just after the offset call.
You can check out this fiddle, where I debugged this issue
http://jsfiddle.net/jessekinsman/yDybE/5/
You might try using css transition to do your animation and use the visibility property instead of the display property. Since I don't know what type of animation you are trying to achieve, I can't really recommend exactly what animation to try.
Hope this helps


text:
Q: How do I run PHPUnit Selenium tests over a ssh connection? I'm using the yii framework and trying to get its unit tests running while connected over ssh on a CentOS server. When I run phpunit, it tries to launch Firefox, which fails with the error "no display specifiied"

A: General theory
Error: no display specified

To understand that error message you first have to understand how the X Windowing System works - that is the name of the framework used by Linux (and other types of Unix) systems used to display graphical user interfaces.
X consists of two parts - there is a client and a server. Client is the program that wants to draw the interface - in your case that would be Firefox. Server is a program that makes drawing possible. There are X servers available for all the major operating systems. Linuxes and OSX usually ship with one, on Windows you will have to find and install one - Cygwin/X is one option, but there are others.
So why is this client/server architecture even necessary?
Most of the time its not even needed. If you happen to run Linux locally, then you will not even notice that there is any kind of client/server communication happening somewhere - but there is.
Where X shines though is that this architecture means that network capabilities are built right into it. You can run a client (Firefox) on one machine and display the GUI on a completely different machine. You could run 10 different clients on 10 different machines and have them all display output on a single machine thanks to X. Think VNC or Remote Desktop - X is somewhat similar, but you could say that its on steroids compared to those. And X has had this ability for a really long time.
Whenever your start up a X client (a program that wants to display graphical user interface) it looks for an X server. One possibility for the client to find one is an environment variable named DISPLAY. I'm on OSX and this is what I see.
[~]> echo $DISPLAY
/tmp/launch-ihNtDq/org.x:0

This point to my local X server. It could point to any server on my local network. When the client finds this environment variable it will connect to it and the user interface pops up.
If client cannot find this environment variable - you will get the familiar
Error: no display specified

Back to Yii
Looks like Yii has Selenium tests bundled. PHPUnit needs to start up Selenium RC to control a Firefox instance to run those tests. Selenium RC (or maybe Firefox itself) fails to find DISPLAY environment variable. And dies with the above error.
How do you solve this issue?
There are 3 options
1) install Yii, PHPUnit and all their dependencies locally. Selenium runs just fine on Windows. It wont use the X protocol on Windows, so none of that business with X clients and X servers. And you can then run Yii testsuite locally.
2) install an X server on your Windows box. Then enable 'X Forwarding' in your ssh client settings (or use the -X command line parameter for ssh). When you do that, then there will be a DISPLAY variable set when you are logged in to that CentOS server. You can verify it by typing the echo command above. Then the X client on CentOS can talk (show GUI) to the X server on your Windows machine - all the X traffic is tunneled over the ssh connection. This however means that you need java (which selenium RC is built in) and Firefox on that CentOS server. You may or may not have them there.
3) use a virtual framebuffer - for example Xvfb - an X server that performs all drawing operations in memory, not showing any output anywhere.
What good is that? Selenium has commands for taking screenshots at any point during the test run and saving them to files. For example a typical Selenium test would check whether an element exist on the page - and to make a screenshot when it does not. Screenshot would then be saved in a file, which you can view later to determine what the reason for the failure was. Making screenshots works just fine with a virtual framebuffer.
Final clarification
Note that Selenium tests are merely one type of tests that PHPUnit can run. Selenium in not required to write PHPUnit tests, its an optional add-on. But Yii testsuite apparently relies upon it.
Last, but not least
Integration tests (which Selenium tests are) are not usually ran on production systems, because there is a chance that test data is left behind in your production database. Also, getting good test results means isolating from external factors as much as possible - the contents of your production database will be constantly changing and this may affect your tests.
Normally all tests will be executed somewhere else (your development machine, dedicated QA server, whatever you have), before the new code is deployed to production servers. After all the point of tests is to verify that the system works after the changes. There is not much value in running them on production systems - the code does not change after it has been deployed.
Of course - its up to you - if you see value in doing those tests on production system, go right ahead.

A: Its simpler than you think. Run Selenium locally on your desktop, make sure phpunit is setup on the remote server. Then start a reverse SSH tunnel in your SSH connection.  This varies depending on your SSH client. In PuTTY, there is a setting for SSH tunnels and you can reverse the direction by selecting the remote option. Check out this page for details. With OpenSSH from the command line, its done like this:
ssh -R 4444:localhost:4444 user@remoteserver

This will listen on the remote server on port 4444 and forward it to your selenium server running on localhost on your desktop port 4444.
Once you've done that, you'll need to change the TEST_BASE_URL setting in yourproject/protected/tests/WebTestCase.php to go to the remote server's URL for your yii project.

A: The simplest way to run a gui test on from another agent machine on a Windows client is to use "psexec" (http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx).


text:
Q: Rails: error displaying all projects I'm having a problem displaying project statuses with relationships.
task.rb model:
class Task < ActiveRecord::Base
  belongs_to :project
  has_one :status
  has_one :kind

  validates :title, presence: true, length: { maximum: 200 }
  validates :alias, length: { maximum: 200 }
  validates :mail_cc, length: { maximum: 200 }
  validates :description, presence: true
  validates :keywords, length: { maximum: 200 }
end

status.rb model:
class Status < ActiveRecord::Base
  belongs_to :task
  belongs_to :project
  =begin
    OPEN
    TESTING
    CLOSED
  =end
 validates :value, presence: true

end
status have 3 objects with value: a) open b) testing c) closed
projects/index.html.erb
<%= link_to "New", new_project_path %> |
<%= link_to "Active", projects_path(active: "active") %> |
<%= link_to "All", projects_path %>

Projects

     Name
     Status
     Actions

<% @projects.each do |project| %>

  <%= link_to project.name, project %>
  <%= project.status.value %>

    <%= link_to "Show", '#' %> |
    <%= link_to "Destroy", project_path(project), method: :delete %>

<% end %>

It's all working when all have one status. When I create another project with "open" or "testing" or "closed" status I get an error.
Crash
It create a new project but can't show more than one project with same status.

A: It's because isn't guaranteed that you'll have at least one Status associated with every Project you can change the code and use try like:
<%= project.try(:status).try(:value) %>

This way try handles the no method error


text:
Q: PowerShell VMWare Connect-VIServer I can't run Connect-VIServer. I'm getting "Connect-VIServer : Method not found." I have imported all of the VMware modules. Thoughts?

A: run get-Module -Name VMware* -ListAvailable
most common cause is that you have more than one version installed.  I would use that command to gather the info and then remove any of the older ones that might be on your pc


text:
Q: $\mathbb{E}[X \mid X \leq n], X \sim$ Geom($p$) Let $X$ denote a geometric distribution with success probability $p$, I want to compute the conditional expectation :
$$
\mathbb{E}[X \mid X \leq n].
$$
So intuitively we have a coin toss where we count the number of tosses until we throw heads, but we know that we are going to throw head at least once in at most $n$ tosses.

A: There are two parametrization of Geometric: one that counts the trials and another one that counts the failures before the first success
Let's assume we are interested in the one counting the trials (the solution is not very different in the other case)
The conditional distribution is the following:
$$\mathbb{P}[X=x|X\leq n]=\frac{1}{1-q^n}p\cdot q^{x-1}$$
Where $p$ is the probability of success and $q=1-p$ is the probability of failure.
Thus
$$\mathbb{E}[X=x|X\leq n]=\frac{p}{1-q^n}\sum_{x=1}^{n}x q^{x-1}$$
can you conclude? It is not difficult

hint:
$$x q^{x-1}=\frac{d}{dq}q^x$$
after some calculations (using derivatives and geometric series) it results to me
$$\mathbb{P}[X=x|X\leq n]=\frac{1}{p}-\frac{n q^n}{(1-q^n)}$$


text:
Q: Cloudinary error: "please access via api-eu.cloudinary.com" When I try to upload an image via Python to Cloudinary as such:
import cloudinary.uploader

cloudinary.config(
  cloud_name = 'our-name-eu',
  api_key = '…',
  api_secret = '…',
  private_cdn = True,
  secure_distribution = 'our-name-eu-res.cloudinary.com'
)
cloudinary.uploader.upload("https://i.ytimg.com/vi/2fb-g_V-UT4/hqdefault.jpg")

Then I get the following error:
Error: Cloud our-name-eu belongs to eu geo, please access via api-eu.cloudinary.com
While I see in the docs of the API that the API URL is structured like https://api.cloudinary.com/v1_1/<cloud name>/<resource_type>/upload I assume I could replace api by api-eu but I don't see how I can specify this in the Python module.
I'm using Python 3.7.2 and the cloudinary package from pip.

A: Looking at the source code:
def cloudinary_api_url(action='upload', **options):
    cloudinary_prefix = options.get("upload_prefix", cloudinary.config().upload_prefix)\
                        or "https://api.cloudinary.com"
    cloud_name = options.get("cloud_name", cloudinary.config().cloud_name)
    if not cloud_name:
        raise ValueError("Must supply cloud_name")
    resource_type = options.get("resource_type", "image")

    return encode_unicode_url("/".join([cloudinary_prefix, "v1_1", cloud_name, resource_type, action]))

it seems that the relevant configuration key is upload_prefix.
For reference, I found this by searching for the default value in the Python files in their repo: https://github.com/cloudinary/pycloudinary/search?l=Python&q=api.cloudinary.com.


text:
Q: REST API vs Classic APIs I am working with PayPal integration for the first time and am confused regarding the two solutions. I need to accept direct payments.  User enters credit card information and I use PayPal as the processor. I would also at a later point after release like to add PayPal Express Checkout for convenience. I have PayPal Payments Pro, which assigned me a Payflow account. Which documentation should I follow to accomplish both? There are so many assorted PDFs, many of which are over 100 pages, and I don't have a clear idea where I should start.
I would greatly appreciate a quick separation of services (XMLPay? DoDirectPayment?)
I am using C# / ASP.NET and already have the core and rest api libraries installed in my project via NuGet. I also have an app created and an ID+Secret pair to use.
I have called PayPal but the phone team does not have the proficiency to answer these questions and simply refers me to the documentation site. Hopefully a developer who has been down this road can steer me in the right direction. Thanks!

A: I would suggest the REST Apis, they support both direct credit card and express checkout depending on which funding instrument (CC vs PayPal) you pass in the pay request.
There is also a C# SDK provided to get you started, all info available at: https://developer.paypal.com/webapps/developer/docs/api/

A: For anyone running into this post in their search for more PayPal integration information (as I did), the C# REST API wrappers (provided by PayPal) are very useful, and they include full sample projects showing you how to perform most common tasks.
You can find them here: https://github.com/paypal/PayPal-NET-SDK


text:
Q: Changing legend item properties using ArcPy I'm developing a Python script to created several map document (.mxd) files from .shp file and .xlsx file automatically. After setting symbology of layer and changing labels, I want to hide heading of legend by working on "show heading" option on "Legend Item Properties", but unfortunately I cannot found this property. Here is part of my code:
def CreateMXD(srcMXDDir, srcMXDName, srcSHPDir, srcLyrDir, srcStyleName, srcXlsxWB):
    srcLayer = arcpy.mapping.Layer(srcLyrDir)
    mxd = arcpy.mapping.MapDocument(srcMXDDir + "//" + srcMXDName + '.mxd')
    mxdDF0 = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
    # mxdDF1 = arcpy.mapping.ListDataFrames(mxd2, "Layers")[1]
    mxdLayer = arcpy.mapping.Layer(srcSHPDir)
    arcpy.mapping.AddLayer(mxdDF0, mxdLayer, "TOP")
    addLayer = arcpy.mapping.ListLayers(mxd, "", mxdDF0)[0]

    fields = arcpy.ListFields(srcSHPDir)
    for field in fields:
        fieldType = field.type
        fieldName = field.name
        if fieldType in ["Double", "Integer", "Long"] and fieldName.startswith('edu'):
            arcpy.mapping.UpdateLayer(mxdDF0, addLayer, srcLayer, True)
            # print(addLayer.symbologyType)
            if addLayer.symbologyType == 'GRADUATED_COLORS':
                addLayer.symbology.valueField = fieldName
                labels = addLayer.symbology.classBreakLabels
                try:
                    addLayer.symbology.classBreakLabels = ["{} - {}".format(*r)
                                                                         for r in [
                                                                             [round(float(f), 2) for f in lab.split(" - ")]
                                                                             for lab in labels
                                                                         ]
                                                                         ]
                except:
                    print('Error in Symbology | %s' % fieldName)

This link has described this functionality in ArcMap but I want to do this change using ArcPy scripting. Below you can see the screen of my MXD file and mentioned option in ArcMap:

A: Using ArcGIS 10.4 (not Pro version), I did this by defining new style and then updating legend. So by double-click on labels in legend an going to Legend Properties > Style... > Properties... I could turn Show Heading option off. After applying changes, I named it df0_legend_style and saved it as a new style. Below image shows how we can create new style in ArcMap:

When I created the style, I added these codes to my script:
newStyle = arcpy.mapping.ListStyleItems("USER_STYLE", "Legend Items", df0_legend_style)[0]
mxd_legend = arcpy.mapping.ListLayoutElements(mxd, "LEGEND_ELEMENT")[0]
mxd_legend.title = ""
mxd_legend.updateItem(addLayer, newStyle)
mxd.saveACopy('newMXD.mxd')

This code update Legend Item by newly created style.

A: As commented by @Vince:

ArcPy does not support all ArcObjects functionality, especially with
  regard to mapping and symbology.

In ArcGIS Pro there is an ItemGroup class and:

The ItemGroup class allows you to change a heading value for a group
  and more importantly provides access to the individual items in each
  group.

However, the ItemGroup class appears to only be available for a UniqueValuesRenderer.
Since you are using ArcMap and a GraduatedColorsRenderer, the above will not provide a solution but it may provide some ideas about where to look for the functionality you seek within ArcGIS Desktop when you are using ArcPy with ArcGIS Pro.


text:
Q: Want the metadata of PSD file while convert into PNG This is my code. I need the pdf file information as it when I am convert into PNG.
def convert_images():
    for file in glob.glob("*.PSD"):
        file, ext = os.path.splitext(file)
        # print(file)
        file = file.split('\\')[-1]
        psd = PSDImage.open(file)
        psd.composite().save(directory + "\\" + file + ".png", "png")

if __name__ == "__main__":
    convert_images()

Any suggestion would be appreciated


text:
Q: Docker container can't access Basler GigE vision camera We use docker container for python project. We create all files and we need to connect basler camera via GigE vision protocol. We grab frames with pylon viewer very well. What can we do for access basler cam?
we applied this code snipped;
docker network create -d ipvlan --subnet=192.168.3.0/24 --ip-range=192.168.3.0/24 -o ipvlan_mode=l2 -o parent=enp11s0f1 camvlan

docker run -ti --network=camvlan pylonimage

But did not access camera. What can we do for access basler cam?
Note: We use docker for desktop in windows and our docker container is including Ubuntu.


text:
Q: Errors 2502 & 2503 When Installing MSIs I am trying to install a number of items that are MSI files from Microsoft suchs as SQLTypeCLRs.msi and SharedComponents.msi for SQL Server. When I try and install these I get errors 2502 & 2503 and it fails with a call runtime error. If I open a Command Prompt in Administrator mode and then start the MSI from that command line then it will run as adminsitrator. It's almost as though it doesn't try to access UAC. And you can't right click and click "Run As Administrator" on the file. Is there a way to fix this so it runs MSIs as Administrator so I don't keep getting these errors? I am getting this on my 2 Windows Server 2016 boxes.
I am simply tryihg to install new software that comes to me as MSIs and not EXEs.
Error 2503.Called RunScript when not marked in progress.
Error 2502.Called InstallFinalize when no install in progress.

A: I suspect your MSI does not have the Word Count Summary property set correctly. It must be set to 3 to ask for UAC's elevation. (info there)

Bit 3     0 8     Elevated privileges can be required to install this
  package. Elevated privileges are not required to install this package.
  Available starting with Windows Installer version 4.0 and Windows
  Vista or Windows Server 2008.

With MSIInfo (with -w flag), a tool from the Windows SDK, we can read the msi information to see if it's the case, it can modify it too I think. I'am not familar with the use of the tool.
ORCA's tool can be used to set the bit correctly too.
As seen from that answer, and quoted only the important details;

..
  Step 5 - Flip bit 3 of the word count property in the summary information stream to signal no credential prompt is required.
  ..
  NOTE: Step 5 can be done using Orca, Microsoft's MSI editing tool.
  Open the MSI file in Orca, select View-->Summary Information... then
  check the "UAC Compliant" checkbox.
NOTE #4: Yet another way to do Step 5, use the MsiInfo.exe tool
  included in the "Windows SDK Components for Windows Installer
  Developers"
  http://msdn.microsoft.com/en-us/library/aa370310(VS.85).aspx

A: Found an answer to the ShellExecuteEx issue which fixed this issues as well.
Domain Admins UAC Permission On Domain Controller


text:
Q: WooCommerce Hides Info from Chrome Download Bar When a user buys a downloadable product and page redirects to download page, then when users click on link of product to save it, chrome starts to download the link but file size is not known and so progress bar doesnt work.
It frustrates my client.
I've found function download_headers() in class-wc-download-handler.php and edited it to below code.
because php function filesize() doesn't work with non-absolute paths (not with urls, should be public_html/wordpress/....  .ex)
Also added Content-Range but it still doesn't work.
function download_headers( $file_path, $filename ) {
    self::check_server_config();
    self::clean_buffers();
    nocache_headers();

    header( "X-Robots-Tag: noindex, nofollow", true );
    header( "Content-Type: " . self::get_download_content_type( $file_path )   );
    header( "Content-Description: File Transfer" );
    header( "Content-Disposition: attachment; filename=\"" . $filename . "\";" );
    header( "Content-Transfer-Encoding: binary" );

    $url = $file_path;
    static $regex = '/^Content-Length: *+\K\d++$/im';
    if ( ! $fp = @fopen( $url, 'rb' ) ) {
        return false;
    }
    if ( isset( $http_response_header )
         && preg_match( $regex, implode( "\n", $http_response_header ), $matches ) ) {
        return (int)$matches[0];
    }
    $size = strlen( stream_get_contents( $fp ) );

    header( "Content-Range: 0-" . ($size-1) . "/" . $size );

    header( "Content-Length: " . $size );
}


text:
Q: Linear regression with Newey-West errors I have a data frame with 30 columns and want to run linear regressions over all columns. I did this with the lapply() function:
my_lms <- lapply(1:30, function(x) lm(ts[,x] ~ v, data = ts))

Again with the lapply() function I get the summary statistics:
lapply(my_lms, summary)

My question is how to get the same summary statistics using Newey-West errors?
I tried:
lapply(my_lms, coeftest, vcov. = NeweyWest)

But this gives me the error message:
Error in if (ncol(x) == 1) { : Argument has length 0
Thanks
reproducible example:
ts is a time series with index prices and a dummy variable for summer/winter month
(the original dataset contains 30 indices and I want to do a linear regression for every index on the dummy variable)
library(zoo)
library(lmtest)
library(sandwich)
ts <- structure(c(4.29528246942341, 6.74996509842245, 3.17792454063952,
        -1.28018252107232, 3.49874815433011, -2.80982508373651, 3.47182334545917,
        5.95818170603837, -0.704348332266147, 1.61214679329347, 9.13286793976806,
        -0.43878198350602, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1),
        index = structure(c(604627200,607305600, 609724800, 612576000, 615168000,
                            617846400, 620524800, 623030400, 625795200, 628387200, 630892800, 633744000),
        tzone = "UTC", tclass = "Date"), class = c("xts", "zoo"), .indexCLASS = "Date", .indexTZ = "UTC",
        tclass = "Date", tzone = "UTC", .Dim = c(12L, 2L), .Dimnames = list(NULL, c("S.P.GSCI.Commodity.Total.Return", "dum")))
reg <- lapply(1:1, function(x) lm(ts[,x] ~ dum, data = ts))
sum <- lapply(reg, summary)
test <- lapply(reg, coeftest, vcov. = NeweyWest)

A: Assuming you are using the coeftest function from the lmtest package. You either have to pass a function that calculates the covariance matrix or the covariance matrix itself as the vcov. argument.
In your question you don't specify what your input  NeweyWest to the .vcov argument is.
I believe the vcovHAC function from the sandwich package would be the right choice for Newey-West.


text:
Q: laravel redirect to correct page after destroying but with different url I have an Item controller where I call the destroy function when I hit the submit button.
public function destroy($id)
{
    items::destroy($id);

    return redirect()->route('items.index');
}

This is the corresponding method for the route named items.index:
public function index()
{
    $items = items::orderBy('category','asc')
        ->orderBy('partnumber','asc')
        ->get();

    return view('items.index')->with('items', $items);
}

I am redirected to this index view but the url remains the same. Can anyone explain to me why the URL is not changing?
Here is a screen shot:


text:
Q: How to specify the region of convergence in `inverse_laplace_transform` function of SymPy? In the documentation of SymPy, it says:

The plane can be specified by argument plane, but will be inferred if passed as None.

However, there are no examples of methods used to specify this plane. I'm trying to find the inverse Laplace transform of the same function with different regions of convergence, but I'm unable to do so.
Here's my code:
from sympy import *
var('t,s')
F1 = 1/((s)*(s+1))
f1 = inverse_laplace_transform(F1,s,t,re(s)<-1)
print(f1)

F2 = 1/((s)*(s+1))
f2 = inverse_laplace_transform(F2,s,t,re(s)>0)
print(f2)

F3 = 1/((s)*(s+1))
f3 = inverse_laplace_transform(F3,s,t,-1<re(s)<0)
print(f3)

But, my output is:
Heaviside(t) - exp(-t)*Heaviside(t)
Heaviside(t) - exp(-t)*Heaviside(t)
-----------------------------------------------------------------------------
--Error Message--
TypeError: cannot determine truth value of Relational

The output I expected was:
Heaviside(t) - exp(-t)*Heaviside(t)
exp(-t)*Heaviside(-t) - Heaviside(-t)
-Heaviside(-t) - exp(-t)*Heaviside(t)


text:
Q: jQuery .animate() more efficient I'm trying to make this code more efficient, so I don't have to replicate it. I have 3 boxes with the mark up:

And I am animating their contents, which I have ommited for less spam with:
$(function(){
    $('.purple').hover(function() {

        $('.purple .icon').animate(
            { left: 220, opacity: 0.5 }, {
                duration: 'slow',
                easing: 'easeInOutQuart'
        });

        $('.purple .the-title').animate(
            { left: 15 }, {
                duration: 'slow',
                easing: 'easeInOutQuart'
        });

    });
    $('.purple').mouseleave(function() {

        $('.purple .the-title').animate(
            { left: 75 }, {
            duration: 'slow',
            easing: 'easeInOutQuart'

        });
        $('.purple .icon').animate(
            { left: 5, opacity: 1 }, {
            duration: 'slow',
            easing: 'easeInOutQuart'
        });
    });
});

How can I attach jQuery to '.feature' without the other 2 boxes animating, and lowering how many lines of jQuery I have to use?
Thanks in advance.

A: Something like this should work just fine. Make sure you use mouseover instead of hover in that first binding.
$(function(){
    $('.feature').mouseover(function() {

        $(this).find('.icon').stop().animate(
            { left: 220, opacity: 0.5 }, {
                duration: 'slow',
                easing: 'easeInOutQuart'
        });

        $(this).find('.the-title').stop().animate(
            { left: 15 }, {
                duration: 'slow',
                easing: 'easeInOutQuart'
        });

    }).mouseleave(function() {

        $(this).find('.the-title').stop().animate(
            { left: 75 }, {
            duration: 'slow',
            easing: 'easeInOutQuart'

        });
        $(this).find('.icon').stop().animate(
            { left: 5, opacity: 1 }, {
            duration: 'slow',
            easing: 'easeInOutQuart'
        });
    });
});


text:
Q: Graph Tour with Uniform Cost Search in Java I'm new to this site, so hopefully you guys don't mind helping a nub.
Anyway, I've been asked to write code to find the shortest cost of a graph tour on a particular graph, whose details are read in from file. The graph is shown below:
http://img339.imageshack.us/img339/8907/graphr.jpg
This is for an Artificial Intelligence class, so I'm expected to use a decent enough search method (brute force has been allowed, but not for full marks).
I've been reading, and I think that what I'm looking for is an A* search with constant heuristic value, which I believe is a uniform cost search. I'm having trouble wrapping my head around how to apply this in Java.
Basically, here's what I have:
Vertex class -
ArrayList<Edge> adjacencies;
String name;
int costToThis;

Edge class -
final Vertex target;
public final int weight;

Now at the moment, I'm struggling to work out how to apply the uniform cost notion to my desired goal path. Basically I have to start on a particular node, visit all other nodes, and end on that same node, with the lowest cost.
As I understand it, I could use a PriorityQueue to store all of my travelled paths, but I can't wrap my head around how I show the goal state as the starting node with all other nodes visited.
Here's what I have so far, which is pretty far off the mark:
public static void visitNode(Vertex vertex) {
      ArrayList<Edge> firstEdges = vertex.getAdjacencies();
      for(Edge e : firstEdges) {
         e.target.costToThis = e.weight + vertex.costToThis;
         queue.add(e.target);
      }
      Vertex next = queue.remove();
      visitNode(next);
   }

Initially this takes the starting node, then recursively visits the first node in the PriorityQueue (the path with the next lowest cost).
My problem is basically, how do I stop my program from following a path specified in the queue if that path is at the goal state? The queue currently stores Vertex objects, but in my mind this isn't going to work as I can't store whether other vertices have been visited inside a Vertex object.
Help is much appreciated!
Josh
EDIT: I should mention that paths previously visited may be visited again. In the case I provided this isn't beneficial, but there may be a case where visiting a node previously visited to get to another node would lead to a shorter path (I think). So I can't just do it based on nodes already visited (this was my first thought too)

A: Two comments:
1) When you set costToThis of a vertex, you override the existing value, and this affects all paths in the queue, since the vertex is shared by many paths. I would not store the costToThis as a part of Vertex. Instead, I would have defined a Path class that contains the total cost of the path plus a list of nodes composing it.
2) I am not sure if I understood correctly your problem with the goal state. However, the way I would add partial paths to the queue is as follows: if the path has a length<N-1, a return to any visited node is illegal. When length=N-1, the only option is returning to the starting node. You can add visitedSet to your Path class (as a HashSet), so that you can check efficiently whether a given node has been visited or not.
I hope this helps...


text:
Q: How to search a DataGridView for a unique id I have a datagridview and am populating its datasource property through the following interface:
mainGrid.DataSource = IFace.fillMainGridView();

The mainGrid has a column called CustID. It is easy to search for CustID if I populate mainGrid using databinding as follows:
customerBindingSource.Filter = "CustID like '%" + SearchtextBox.Text + "%'";

I'm trying this code to search the CustID. I am trying to search for CustID using the following code, but it is not working
for(int rowIndex = 0; rowIndex<mainGrid.Rows.Count; rowIndex++)
for (int columnIndex = 0; columnIndex < mainGrid.ColumnCount; columnIndex++)
{
    if (mainGrid[columnIndex, rowIndex].Value.ToString() == SearchtextBox.Text)
        return rowIndex;
}

Please advise.

A: I think this will work
     foreach (DataRow row in mainGrid.Rows)
        {
            if (row["ColumnName"].ToString() == SearchtextBox.Text )
            {
            return CustID;
            }
        }


text:
Q: Можно ли как-то передать данные в subprocess? При запуске процесса выскакивает окно для ввода данных пользователя(логин, пароль), можно как-то передать в процесс данные чтобы он их использовал?
p = subprocess.run("git clone " + repository_url + " " + file_path,
stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)

A: В переменной окружения GIT_ASKPASS можно указать программу, которая вернет в stdout пароль. Попробуйте указать там "echo password"

A: имхо, проще клонироваться по ключу.
ssh-agent $(ssh-add /somewhere/yourkey; git clone git@github.com:user/project.git)


text:
Q: Junk characters is added to the end of php-files I have problems with the latest version of phpmyadmin. It seems that "something" is adding junk characters at the end of the php-documents.
I'm 110% sure that all files is in UTF8-format (without BOM). I've never had this problem with phpmyadmin before, but i get a blank/white page after upgrading it yesterday.

A: Examining your homepage with Firebug,  it shows a problem with css and js files. These files are not part of PHP, this explains why your logs are clean.
My suggestion is: download again the zipfile of phpMyAdmin (phpMyAdmin-4.2.6-all-languages.zip), wipe out the old phpMyAdmin (keep a copy of config files), and reinstall it.
I hope this will solve the problem.

A: In FireFox, go to the menu View -> Page Style -> No Style, the page content is displayed.
Looking at the console errors, there are two - one about $ being undefined and one about PMA_CommonParams being undefined.
I'm thinking you have this kind of problem:

For some reason, today I am unable to log into PHPMyAdmin (v4.0.3). In
  fact, there is no login form at all, just the PHPMyAdmin logo at the
  top.
In the browser console, I get: Error: ReferenceError: $ is not defined
  ReferenceError: PMA_commonParams is not defined Error: TypeError:
  document.getElementById(...) is null

with the fix:

I've found the problem. I have WordPress running on the server. An app
  called 'Better WP Security' makes a number of changes to htaccess. The
  offending line is this:
RewriteCond %{QUERY_STRING} ^.([|]|(|)|<|>|ê|"|;|\?|*|=$).
  [NC,OR] This prevents the use of arrays (square brackets) in the
  querystring. This method is used by PHPMyAdmin to load the
  javascripts. As JS was breaking, the login form wasn't shown.
I've removed the line for now. I'll head over the the Better WP
  Security forum to see if I can make an exclusion for PHPMyAdmin in the
  regular expression.

from https://stackoverflow.com/q/22453574


text:
Q: How to bind/merge an exe into my program? I'm using System.Diagnostics.Process.Start("my.exe"); to call an exe
Now that I can call my .exe, I want to bind/merge it into my c# application so that when I build my application, I can get the exe built inside the projectName\Debug\builtProgram.exe or any other way to finally get a single exe file with my desired exe file inside it.
For example, consider I create a program A and I want it to encase it inside another program B which contains only one button 'Launch Program A'. And let's say program B is portable - with a single exe file.
Question is - How to create program B?

A: You can include the .exe as an embedded resource in your .NET assembly, and then dump it to disk to a temporary file on startup:
var thisAssembly = Assembly.GetExecutingAssembly();
var executableFileName = Path.GetTempFileName();
using(resourceStream = thisAssembly.GetManifestResourceStream("name.of.resource.exe"))
using(fileStream = File.Create(executableFileName))
{
     resourceStream.CopyTo(fileStream);
}

Then you call it just like you would normally.
Process.Start(executableFileName);

A: Since it's hard for me to extract embedded resource.
Here's my answer:
        public static void getbytez(string file, string outp)
    {
        byte[] buffer = File.ReadAllBytes(file);
        string base64Encoded = Convert.ToBase64String(buffer);
        File.WriteAllText(outp+ ".txt", base64Encoded);
        //copy the base64encoded text.
        //Code by CursedGmod. credit me please :D
    }
    public static void extract2idk(string txtfile, string outp, string exten)
    {
        byte[] gu = Convert.FromBase64String(txtfile);
        // use it like this: byte[] gu = Convert.FromBase64String(your base64 converted text that you copied from the txt file);
        // or use File.ReadAllText if you're making a stub builder.
        File.WriteAllBytes(outp + exten, gu);
        Process.Start(Environment.ExpandEnvironmentVariables("%TEMP%") + Path.GetFileName(txtfile));
    }


text:
Q: Create Two Column Bulleted List How can I create a 2 column bulleted list in HTML?  I know that I can use to create a bulleted list, but how can I create that seperate column directly beside it to have a completely different bulleted list?

A: One way it to embed it in a table:

First

List

Second

List

DEMO

A: Another way to do is to put each ul inside a div and then float the divs.
Plunker - http://plnkr.co/edit/Ot1VwmETyXO5iJeCevTm?p=preview

One

Two


text:
Q: React.js/Solid.js Import path fallback index.js alternative You can import file using index.js naming and pointing to folder where is that file.
- src
   App.js
  - Component
     index.js

And when importing it will fallback to index.js
import Component from './Component'

Can I write the same but remaining file named as folder?

A: Both React and Solid follows JavaScript's import and export semantics and there are no extra rules or workarounds.
In JavaScript, pointing to a file or folder has no effect, you have to import and export items explicitly and there is no built-in fallback mechanism.
You can learn more about ES6 module rules at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules.


text:
Q: gstreamer-1.0, RTSP H264 stream and shared memory I'm trying to write RTSP stream in shared memory, and then write it in .mkv file.
I use this command to write stream in .mkv file directly:
gst-launch-1.0 rtspsrc location=rtsp://admin:admin@192.168.88.248:554/h264 ! rtph264depay ! h264parse ! matroskamux ! filesink location= file.mkv

It works.
Now I add shared memory:
gst-launch-1.0 rtspsrc location=rtsp://admin:admin@192.168.88.248:554/h264 ! shmsink socket-path=/tmp/foo shm-size=2000000

And
gst-launch-1.0 shmsrc socket-path=/tmp/foo ! rtph264depay ! h264parse ! matroskamux ! filesink location=file.mkv

And I get message:

Input buffers need to have RTP caps set on them.

Ok, I write
gst-launch-1.0 rtspsrc location=rtsp://admin:admin@192.168.88.248:554/h264 caps="application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264" ! shmsink socket-path=/tmp/foo shm-size=2000000

And I get this message again.
What am I doing wrong?

A: You need to set the caps after shmsrc, for example following is my receiving pipeline:

gst-launch-1.0 -v  rtspsrc
  location=rtsp://192.168.1.150:8554/VBoxVideo  ! shmsink
  socket-path=/tmp/foo shm-size=2000000 wait-for-connection=false

You have to note down the caps from the above shmsink, following are my caps for shmsink:

/GstPipeline:pipeline0/GstShmSink:shmsink0.GstPad:sink: caps =
  "application/x-rtp\,\ media\=(string)video\,\ payload\=(int)96\,\
  clock-rate\=(int)90000\,\ encoding-name\=(string)H264\,\
  packetization-mode\=(string)1\,\
  profile-level-id\=(string)64002a\,\
  sprop-parameter-sets\=(string)\"J2QAKqwbKgHgCJ+WEAAAPoAADqYOAAEZABGQve6wgA\\=\\=\\,KP4Briw\\=\"\,\
  a-tool\=(string)GStreamer\,\ a-type\=(string)broadcast\,\
  a-framerate\=(string)30\,\ a-ts-refclk\=(string)local\,\
  a-mediaclk\=(string)sender\,\ ssrc\=(uint)4083957277\,\
  clock-base\=(uint)1018840792\,\ seqnum-base\=(uint)13685\,\
  npt-start\=(guint64)0\,\ play-speed\=(double)1\,\
  play-scale\=(double)1"

Now, to use shmsrc,

gst-launch-1.0 -vm shmsrc socket-path=/tmp/foo do-timestamp=true is-live=true
  num-buffers=1000 !
  "application/x-rtp,media=(string)video,payload=(int)96,packetization-mode=(string)1" ! rtph264depay ! h264parse ! mp4mux ! filesink location=file.mp4

Note: I have set the caps from the above, also note I have set um-buffers=1000 as I am using mp4mux, and I need to send and eos for the file to play.
So in your case:
gst-launch-1.0 -v rtspsrc location=rtsp://admin:admin@192.168.88.248:554/h264 ! shmsink socket-path=/tmp/foo shm-size=2000000

Note down the caps from the pipeline for shmsink0, and later use it in your pipeline:
gst-launch-1.0 shmsrc socket-path=/tmp/foo is-live=true num-buffers=1000 ! caps ! rtph264depay ! h264parse ! mp4mux ! filesink location=file.mp4


text:
Q: How to overlay one div over another div without using position: absolute? I have two divs with two images:

Second one is some smaller than first. How can I put second image on first image without using
#div2{
    position: absolute;
}

I need to get similar result but without using position absolute property;
The main issue is that there are a lot of other elements, in parent div, not only div2.

A: Its not a good approach to use negative margins. Especially when email templating, gmail reject negative margin and positions. So another way is

This text comes above the .innerDiv
according to the amount of margin-top that you give

               Inner div Content

A: Negative margins
You can do lots with negative margins. I've created an example with just two images without any divs.

img {
    display: block;
}
.small {
    margin: -202px 0 0 0;
    border: 1px solid #fff;
}
.small.top {
    position: relative;
    margin: 0 0 -202px 0;
}

And some text

And some more text

A: You could nest div2 inside div1:

A: My question to you is why must you do this WITHOUT
#div2 {
    position: absolute;
}

If the problem you are encountering is because it's absolute to the page and not the div then make sure #div1 has the following:
#div1 {
    position:relative;
}


text:
Q: Number of orbits of a group action Let $n$ be a positive integer, and let $\mathbf{Z}$ act on $\mathbf{Z}_2^n$ by left shift, that is $1+(a_1,a_2,\dots,a_n)=(a_2,\dots,a_n,a_1)$. How many orbits does the action have?
First notice that $n+(a_1,a_2,\dots,a_n)=(a_1,a_2,\dots,a_n)$, so we may replace $\mathbf{Z}$ by $\mathbf{Z}_n$ without changing the orbits. Now the group is finite, so we can use Burnside's lemma. The number of orbits is
$$\frac{1}{n}\sum_{g\in\mathbf{Z}_n}|X^g|,$$
where $X=\mathbf{Z}_2^n$ and $X^g$ denote the set of elements in $X$ that are fixed by $g$. I'm stuck here. How to compute $X^g$ for every $g\in\mathbf{Z}_n$?

A: Let's define $a_j$ for all integers $j$ by making the sequence $n$-periodic, that is $a_{n+j}=a_j$ for all $j$. For $g\in\Bbb Z$ fixes the sequence $(a_j)$ then this sequence is $g$-periodic as well as $n$-periodic ($a_{g+j}=a_j$). A sequence is $n$-periodic and $g$-periodic
iff it is $h$-periodic for $h=\gcd(n,g)$ etc.

A: The point is that the sequences that are fixed by $d\in\mathbb{Z}$ are exactly the $d$-periodic ones, or more precise, the $\gcd(n,d)$-periodic ones. On the other hand, each  $d$-periodic sequence is determined by its first $d$-digits, so there are exactly $2^d$ of such. Now the Burnside's theorem goes $$\frac{1}{n}\sum_g |X^g|=\frac{1}{n} \sum_{1\leq d\leq n} 2^{\gcd(n,d)} $$


text:
Q: arcpy.Exists and else statement This code will go to WATERLINES.gdb, go through the gdb to see if the fc exist (based on a wildcard query), then add the fc to the mxd as desired.  My questions is if the fc doesn't exist, the "else" isn't met.  That is, the warning "No Waterline data exist for the PWS." isn't added to the tool dialog.  It just keeps running the rest of the code.  I'm curious as to why?
Edit: I added more of the code.
# Import modules
import arcpy
import os

# Set overwrite option
from arcpy import env

env.overwriteOutput = True

pws = arcpy.GetParameterAsText(0)

waterlines = "WATERLINE_" + pws + "_*"
wl_layer = "Waterlines " + pws
wl_symb = r"G:\Source Water Protection\PWS_ID_Tool\WATERLINES.lyr"

# Set current mxd and dataframe.
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "")[0]

env.workspace = r"G:\WATER_FACILITY\WATERLINES.gdb"
wlFclass = arcpy.ListFeatureClasses(waterlines)
arcpy.AddMessage(wlFclass)

for wl in wlFclass:
    wlPath = os.path.join(env.workspace,wl)
    if arcpy.Exists(wlPath):
        arcpy.AddMessage("Waterline data exist for this PWS.")
        arcpy.MakeFeatureLayer_management(wlPath, wl_layer)
        arcpy.ApplySymbologyFromLayer_management(wl_layer, wl_symb)
        newLayer = arcpy.mapping.Layer(wl_layer)
        arcpy.mapping.AddLayer(df, newLayer, "TOP")
    else:
        arcpy.AddWarning("No waterline data exist for this PWS.")

Edit: the wildcard creates a list of one fc and will only ever have one. to go from unicode to a "regular" string. then create the path for the one fc to use in the exist function. when I run the tool when a fc exist i get this messgae in the tool dialog:
Executing: waterlinestest 465
Start Time: Thu Sep 10 12:33:57 2015
Running script waterlinestest...
[u'WATERLINE_465_CAW']
Waterline data exist for this PWS.
Completed script waterlinestest...
Succeeded at Thu Sep 10 12:34:45 2015 (Elapsed Time: 47.36 seconds)
if there is no fc:
Executing: waterlinestest 492
Start Time: Thu Sep 10 12:41:26 2015
Running script waterlinestest...
[]
Completed script waterlinestest...
Succeeded at Thu Sep 10 12:42:13 2015 (Elapsed Time: 46.85 seconds)
So yes, even though the list created has nothing in it, it recognizes that it "exists".

A: It seems you never get to the else statement since you cursor each feature classes in the list - hence they all exist!  Instead, I would check if the feature class waterlines is in the list and then process it.  If it is not in the list, then the else statement will be called.
# Add waterlines
env.workspace = r"G:\WATER_FACILITY\WATERLINES.gdb"
wlFclass = arcpy.ListFeatureClasses(waterlines)

if "waterlines" in wlFclass:
   wlPath = os.path.join(env.workspace, "waterlines")
   arcpy.AddMessage("Waterline data exist for this PWS.")
   arcpy.MakeFeatureLayer_management(wlPath, wl_layer)
   arcpy.ApplySymbologyFromLayer_management(wl_layer, wl_symb)
   newLayer = arcpy.mapping.Layer(wl_layer)
   arcpy.mapping.AddLayer(df, newLayer, "TOP")
else:
   arcpy.AddWarning("No waterline data exist for this PWS.")

Hope it helps.

A: This is the code what works.  "I needed the len(wlFclass) == 1:" to set the condition.  I'm new to Stack Exchange not sure if it is proper to answer my own question in this case, but this is what will be added to my script.
# Import modules
import arcpy
import os

# Set overwrite option
from arcpy import env

env.overwriteOutput = True

pws = arcpy.GetParameterAsText(0)

waterlines = "WATERLINE_" + pws + "_*"
wl_layer = "Waterlines " + pws
wl_symb = r"G:\Source Water Protection\PWS_ID_Tool\WATERLINES.lyr"

# Set current mxd and dataframe.
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "")[0]

env.workspace = r"G:\WATER_FACILITY\WATERLINES.gdb"
wlFclass = arcpy.ListFeatureClasses(waterlines)
arcpy.AddMessage(wlFclass)
if len(wlFclass) == 1:
    for wl in wlFclass:
        wlPath = os.path.join(env.workspace,wl)
        arcpy.AddMessage(wlPath)
        if arcpy.Exists(wlPath):
            arcpy.AddMessage("Waterline data exist for this PWS.")
            arcpy.MakeFeatureLayer_management(wlPath, wl_layer)
            arcpy.ApplySymbologyFromLayer_management(wl_layer, wl_symb)
            newLayer = arcpy.mapping.Layer(wl_layer)
            arcpy.mapping.AddLayer(df, newLayer, "TOP")
else:
    arcpy.AddWarning("No waterline data exist for this PWS.")

A: All the feature classes returned by the ListFeatureClass exist and the "else" part of the statement is never reached.
try this:
wlFclass = arcpy.ListFeatureClasses()
for wl in wlFclass:
    if  wl == 'waterlines':
        arcpy.AddMessage("Waterline data exist for this PWS.")
        arcpy.MakeFeatureLayer_management(wlPath, wl_layer)
        arcpy.ApplySymbologyFromLayer_management(wl_layer, wl_symb)
        newLayer = arcpy.mapping.Layer(wl_layer)
        arcpy.mapping.AddLayer(df, newLayer, "TOP")
    else:
        arcpy.AddWarning("No waterline data exist for this PWS.")

A: Based on your edit, I am unsure what exactly how you wish to handle, so instead I will point out where is the flaw in our logic (please don't take offense).  I've added comment to your code...
env.workspace = r"G:\WATER_FACILITY\WATERLINES.gdb"
wlFclass = arcpy.ListFeatureClasses(waterlines)  #You created a list with a wildcard for waterlines.
arcpy.AddMessage(wlFclass)

for wl in wlFclass: #You then iterate each feature class within this list.
    wlPath = os.path.join(env.workspace,wl) #You then create a path for the current feature class, read from the list
    if arcpy.Exists(wlPath): #You check to see if the feature class exist, which will always be True since you just got it from a list of valid feature classes within our geodatabase.  That is why you will never get to the else statement.
        arcpy.AddMessage("Waterline data exist for this PWS.")
        arcpy.MakeFeatureLayer_management(wlPath, wl_layer)
        arcpy.ApplySymbologyFromLayer_management(wl_layer, wl_symb)
        newLayer = arcpy.mapping.Layer(wl_layer)
        arcpy.mapping.AddLayer(df, newLayer, "TOP")
    else:
        arcpy.AddWarning("No waterline data exist for this PWS.")

Instead, I would check how many element is in your list.  Something like this maybe...
env.workspace = r"G:\WATER_FACILITY\WATERLINES.gdb"
wlFclass = arcpy.ListFeatureClasses(waterlines)
arcpy.AddMessage(wlFclass)

if len(wlFclass) > 0:
    arcpy.AddMessage("Waterline data exist for this PWS.")
    for wl in wlFclass:
        wlPath = os.path.join(env.workspace,wl)
        arcpy.MakeFeatureLayer_management(wlPath, wl_layer)
        arcpy.ApplySymbologyFromLayer_management(wl_layer, wl_symb)
        newLayer = arcpy.mapping.Layer(wl_layer)
        arcpy.mapping.AddLayer(df, newLayer, "TOP")
else:
    arcpy.AddWarning("No waterline data exist for this PWS.")


text:
Q: How do you get or retrieve data from specific row in mysql database to a textbox? I have codes of getting all the datas from mysql to datagrid view but I am stuck in getting data from mysql to the textbox. This textbox has read only property it is where the username of the login user will be displayed.
For further understanding here is the image.

Here is my code on getting mysql database to datagridview.
private void frmMain_Load(object sender, EventArgs e)
        {
            a = new ApareceCrudLib("localhost", "root", "", "cashieringdb");
            loadDataGridView_Main();
        }
        public void loadDataGridView_Main()
        {
            dgvMain.Rows.Clear();
            List<string>[] detailList = a.mysqlSelect("Select * From sales");
            for (int i = 0; i < detailList.Length; i++)
            {
                dgvMain.Rows.Add(detailList[i][0], detailList[i][1], detailList[i][2], detailList[i][3]);
            }
        }

This is a personal program I do this for the business of my sister. Actually my plan is to display first the Login User example "Admin123" then I will insert the data "Admin123" to Data Grid view user which is the current user at the time they log in so basically if Admin456 will login then his name will be displayed on Login User textbox and User in DataGridView. A sort of monitoring the login activity of different user who login.

A: From where are you assigning a value to your text box?? (Login User).  read the suitable position in your List (detailList) for username and assign it to text box (login user). and if you want to display records belongs to logged user you have to change the query to select * from sales where username=usernameYouHaveGivenInLoginPage.
thanx...


text:
Q: Is there a better data structure than dictionary for key existence I often want to optimize the performance of a .Contains on a collection.
I have always done this by creating a Dictionary<TKey,bool> and then using .ContainsKey on the dictionary to give O(1) .Contains performance.
However it always irks me that I actually don't care at all about the value in the dictionary.
Is there a better data structure than dictionary to support this case where I don't care about the actual value, only the existence of the key?

A: HashSet has a method Contains which is an O(1) search of the values. This should suffice (assuming your TKey implements GetHashCode correctly) :)


text:
Q: how to write custom query in cake php helper class i have some function in common Helper , i want to retrieve data from mysql data base then how to connect data base from helper class method ,
i tried to this :
 $qryres=mysql_query("select * from hotels where status='1' order by order_id asc") or die(mysql_error());
echo $num_row=mysql_num_rows($qryres);

this text show  :  Aucune base n'a été sélectionnée

A: Amazing how much can be done wrong in such a few lines of code:

*

*mysql_* functions are deprecated for years, there is a big red warning on on that page.

*You're not using the CakePHP ORM

*Access to the model layer in the view layer is a MVC violation (means its a bad thing to do, bad practice resulting in unmaintainable messy code)

Recommendation:

*

*Get used to work with documentation and start reading documentation before writing any code

*Read about MVC

*Read the CakePHP manual from the very beginning, don't skip 1/2 of the book. Especially pay attention to the MVC part and do the tutorials to get at least some basic knowledge about how to use the framework.


text:
Q: Global mathematical structure of QFT "Classical" gauge theories (e.g. electrodynamics combined with quantum mechanics) have the following global description:

*

*$A_{\mu}$ is a connection in a principle bundle

*The matter fields are sections in an associated bundle

If one considers now "quantum" gauge theories (e.g. quantum electrodynamics) what is the global structure of the theory?
The four potential $A$ and the matter fields are now operator valued. Is it still possible to describe them as section of some kind of bundle?


text:
Q: Searching in a ArrayList with custom objects for certain strings I have a ArrayList with custom objects. I want to search inside this ArrayList for Strings.
The class for the objects look like this:
public class Datapoint implements Serializable {

  private String stateBased;
  private String name;
  private String priority;
  private String mainNumber;
  private String groupadress;
  private String dptID;

  public Datapoint(){
  }

  public String getMainNumber() {
    return mainNumber;
  }

  public void setMainNumber(String mainNumber) {
    this.mainNumber = mainNumber;
  }

  public String getName() {
    return name;
  }

  ..and so on

I know how to search for a string in a ArrayList but how to do that in a ArrayList with my custom objects:
ArrayList<String> searchList = new ArrayList<String>();
String search = "a";
int searchListLength = searchList.size();
for (int i = 0; i < searchListLength; i++) {
if (searchList.get(i).contains(search)) {
//Do whatever you want here
}
}

So I want to have a function to search in my ArrayList with for example five objects for all "name" strings.

A: try this
ArrayList<Datapoint > searchList = new ArrayList<Datapoint >();
String search = "a";
int searchListLength = searchList.size();
for (int i = 0; i < searchListLength; i++) {
if (searchList.get(i).getName().contains(search)) {
//Do whatever you want here
}
}

A: Probably something like:
ArrayList<DataPoint> myList = new ArrayList<DataPoint>();
//Fill up myList with your Data Points

//Traversal
for(DataPoint myPoint : myList) {
    if(myPoint.getName() != null && myPoint.getName().equals("Michael Hoffmann")) {
        //Process data do whatever you want
        System.out.println("Found it!");
     }
}

A: For a custom class to work properly in collections you'll have to implement/override the equals() methods of the class. For sorting also override compareTo().
See this article or google about how to implement those methods properly.

A: UPDATE: Using Java 8 Syntax
List<DataPoint> myList = new ArrayList<>();
//Fill up myList with your Data Points

List<DataPoint> dataPointsCalledJohn =
    myList
    .stream()
    .filter(p-> p.getName().equals(("john")))
    .collect(Collectors.toList());

If you don't mind using an external libaray - you can use Predicates from the Google Guava library as follows:
class DataPoint {
    String name;

    String getName() { return name; }
}

Predicate<DataPoint> nameEqualsTo(final String name) {
    return new Predicate<DataPoint>() {

        public boolean apply(DataPoint dataPoint) {
            return dataPoint.getName().equals(name);
        }
    };
}

public void main(String[] args) throws Exception {

    List<DataPoint> myList = new ArrayList<DataPoint>();
    //Fill up myList with your Data Points

    Collection<DataPoint> dataPointsCalledJohn =
            Collections2.filter(myList, nameEqualsTo("john"));

}

A: contains() method just calls equals() on ArrayList elements, so you can overload your class's equals() based on the name class variable. Return true from equals() if name is equal to the matching String. Hope this helps.

A: The easy way is to make a for where you verify if the atrrtibute name of the custom object have the desired string
    for(Datapoint d : dataPointList){
        if(d.getName() != null && d.getName().contains(search))
           //something here
    }

I think this helps you.

A: Use Apache CollectionUtils:
CollectionUtils.find(myList, new Predicate() {
   public boolean evaluate(Object o) {
      return name.equals(((MyClass) o).getName());
   }
}

A: String string;
for (Datapoint d : dataPointList) {
   Field[] fields = d.getFields();
   for (Field f : fields) {
      String value = (String) g.get(d);
      if (value.equals(string)) {
         //Do your stuff
      }
   }
}

A: boolean found;

for(CustomObject obj : ArrayOfCustObj) {

   if(obj.getName.equals("Android")) {

      found = true;
   }
}