问:
Angular4/MEAN does not render data on the template
I am learning MEAN stack with Angular4 and got stuck up with a problem.I use a service to get the data from the node.js and it is subscribed by app.component.
Logging the result displays  the right output however, on rendering it on the template doesn't works.There is no warnings or any other errors but data is not displayed on the template.

Here is the Service

```<code>import { Injectable } from '@angular/core';
import { Http,Headers,RequestOptions } from '@angular/http';
import 'rxjs/add/operator/map';

@Injectable()
export class DataserviceService {
    result:any;
    constructor(private http:Http) { }
    getusers()
       {
           return this.http.get('/users').map( result => this.result = result.json());
       }
    }
</code>```

App.component.ts

```<code>import { Component } from '@angular/core';
import { DataserviceService } from './dataservice.service';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
    users : Array<any> = [];
    constructor(private dataserv : DataserviceService)
     {
        this.dataserv.getusers().subscribe(function(result)
         {
            this.users = result;
            console.log(result);//result is rightly displayed on the console.
        });
    }
}
</code>```

and here is the template

```<code><div *ngIf="users">
  <h2>Results </h2>
  <ul>
    <li *ngFor="let user of users">{{ user.name }}</li>
  </ul>
</div>
</code>```

答:
Your users array is empty when template is rendered. You should read something about change detection, and change detection strategy, zones, ... But if you use rXjs Subject/BehaviorSubject and observable data would be rendered, component:

```<code>import {BehaviorSubject} from 'rxjs/BehaviorSubject';
import { Observable} from 'rxjs/Observable';
import { Component } from '@angular/core';
import { DataserviceService } from './dataservice.service';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
    private usersSubj = new BehaviorSubject<Array<any>>([]);
    users : Observable<Array<any>> = this.usersSubj.Observable();
    constructor(private dataserv : DataserviceService)
     {
        this.dataserv.getusers().subscribe(function(result)
         {
            this.usersSubj.next(result);
            console.log(result);//result is rightly displayed on the console.
        });
    }
}
</code>```

and template:

```<code><div *ngIf="users">
  <h2>Results </h2>
  <ul>
    <li *ngFor="let user of users | async">{{ user.name }}</li>
  </ul>
</div>
</code>```

Your service could also return observable, so you could subscribe users to service directy, ...

Body:
I am learning MEAN stack with Angular4 and got stuck up with a problem.I use a service to get the data from the node.js and it is subscribed by app.component.
Logging the result displays  the right output however, on rendering it on the template doesn't works.There is no warnings or any other errors but data is not displayed on the template.

Here is the Service

import { Injectable } from '@angular/core';
import { Http,Headers,RequestOptions } from '@angular/http';
import 'rxjs/add/operator/map';

@Injectable()
export class DataserviceService {
    result:any;
    constructor(private http:Http) { }
    getusers()
       {
           return this.http.get('/users').map( result => this.result = result.json());
       }
    }

App.component.ts

import { Component } from '@angular/core';
import { DataserviceService } from './dataservice.service';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
    users : Array<any> = [];
    constructor(private dataserv : DataserviceService)
     {
        this.dataserv.getusers().subscribe(function(result)
         {
            this.users = result;
            console.log(result);//result is rightly displayed on the console.
        });
    }
}

and here is the template

Results

{{ user.name }}

Body:
Your users array is empty when template is rendered. You should read something about change detection, and change detection strategy, zones, ... But if you use rXjs Subject/BehaviorSubject and observable data would be rendered, component:

import {BehaviorSubject} from 'rxjs/BehaviorSubject';
import { Observable} from 'rxjs/Observable';
import { Component } from '@angular/core';
import { DataserviceService } from './dataservice.service';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
    private usersSubj = new BehaviorSubject<Array<any>>([]);
    users : Observable<Array<any>> = this.usersSubj.Observable();
    constructor(private dataserv : DataserviceService)
     {
        this.dataserv.getusers().subscribe(function(result)
         {
            this.usersSubj.next(result);
            console.log(result);//result is rightly displayed on the console.
        });
    }
}

and template:

<div *ngIf="users">
  <h2>Results </h2>
  <ul>
    <li *ngFor="let user of users | async">{{ user.name }}</li>
  </ul>
</div>

Your service could also return observable, so you could subscribe users to service directy, ...


来源: stackexchange

问:
spring boot starter graphql not working
I recently started working with graphql and found it very intriguing. Since most of my rest apps were in java, I decided to do a quick setup using the provided spring boot starter project by the graphql-java team. It comes with graph-iql autoconf spring setup, which makes it easier to query /graphql endpoint.

After spending a few good hours on the project setup in IDEA, I was able to run the graphql-sample-app. But I think my servlet is still not enabled, and only the graphiql endpoint is running, as the default query is returning 404.

This is application.yml:

```<code>spring:
      application:
               name: graphql-todo-app
server:
      port: 9000

graphql:
      spring-graphql-common:
               clientMutationIdName: clientMutationId
               injectClientMutationId: true
               allowEmptyClientMutationId: false
               mutationInputArgumentName: input
               outputObjectNamePrefix: Payload
               inputObjectNamePrefix: Input
               schemaMutationObjectName: Mutation
      servlet:
             mapping: /graphql
             enabled: true
             corsEnabled: true

graphiql:
    mapping: /graphiql
    enabled: true
</code>```

This is what my build.gradle file looks like:

```<code>buildscript {
    repositories {
        maven { url "https://plugins.gradle.org/m2/" }
        maven { url 'http://repo.spring.io/plugins-release' }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.2.RELEASE")
        classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6"
    }
}

apply plugin: 'java'
apply plugin: 'org.springframework.boot'

repositories {
    jcenter()
    mavenCentral()
}

dependencies{
//    compile(project(":graphql-spring-boot-starter"))
//    compile(project(":graphiql-spring-boot-starter"))
    compile 'com.graphql-java:graphql-spring-boot-starter:3.6.0'

    // to embed GraphiQL tool
    compile 'com.graphql-java:graphiql-spring-boot-starter:3.6.0'

    compile "com.embedler.moon.graphql:spring-graphql-common:$LIB_SPRING_GRAPHQL_COMMON_VER"

    compile("org.springframework.boot:spring-boot-starter-web")
    compile("org.springframework.boot:spring-boot-starter-actuator")

    testCompile("org.springframework.boot:spring-boot-starter-test")
}

jar.enabled = true
uploadArchives.enabled = false
bintrayUpload.enabled = false
</code>```

After running gradle build, I run the generated jar file from the terminal. This is what I get on localhost:

答:
I had the same issue using Spring boot 2.0.0 (M6). Switching back to 1.5.8.RELEASE solved the problem. They're working on the issue, it will be released as soon as there is a non milestone release for Spring boot 2.x

https://github.com/graphql-java/graphql-spring-boot/issues/40

https://github.com/graphql-java/graphql-spring-boot/pull/36

ContentLicense: CC BY-SA 3.0

Title: spring boot starter graphql not working

Body:
I recently started working with graphql and found it very intriguing. Since most of my rest apps were in java, I decided to do a quick setup using the provided spring boot starter project by the graphql-java team. It comes with graph-iql autoconf spring setup, which makes it easier to query /graphql endpoint.

After spending a few good hours on the project setup in IDEA, I was able to run the graphql-sample-app. But I think my servlet is still not enabled, and only the graphiql endpoint is running, as the default query is returning 404.

This is application.yml:

spring:
      application:
               name: graphql-todo-app
server:
      port: 9000

graphql:
      spring-graphql-common:
               clientMutationIdName: clientMutationId
               injectClientMutationId: true
               allowEmptyClientMutationId: false
               mutationInputArgumentName: input
               outputObjectNamePrefix: Payload
               inputObjectNamePrefix: Input
               schemaMutationObjectName: Mutation
      servlet:
             mapping: /graphql
             enabled: true
             corsEnabled: true

graphiql:
    mapping: /graphiql
    enabled: true

This is what my build.gradle file looks like:

buildscript {
    repositories {
        maven { url "https://plugins.gradle.org/m2/" }
        maven { url 'http://repo.spring.io/plugins-release' }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.2.RELEASE")
        classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6"
    }
}

apply plugin: 'java'
apply plugin: 'org.springframework.boot'

repositories {
    jcenter()
    mavenCentral()
}

dependencies{
//    compile(project(":graphql-spring-boot-starter"))
//    compile(project(":graphiql-spring-boot-starter"))
    compile 'com.graphql-java:graphql-spring-boot-starter:3.6.0'

    // to embed GraphiQL tool
    compile 'com.graphql-java:graphiql-spring-boot-starter:3.6.0'

    compile "com.embedler.moon.graphql:spring-graphql-common:$LIB_SPRING_GRAPHQL_COMMON_VER"

    compile("org.springframework.boot:spring-boot-starter-web")
    compile("org.springframework.boot:spring-boot-starter-actuator")

    testCompile("org.springframework.boot:spring-boot-starter-test")
}

jar.enabled = true
uploadArchives.enabled = false
bintrayUpload.enabled = false

After running gradle build, I run the generated jar file from the terminal. This is what I get on localhost:


问:
Bash script to automate Git pull
I want to automatically pull from Git. For some reasons it is not possible to automate the password thing in the server I am using. So it needs to be done by a Bash file. Now my Bash coding is not that good. Then it is possible to enter the passphrase for the SSH key. But I have really no clue what to do...

#!/bin/bash
cd . public_html/auto_deploy/foldername && git fetch --all && git checkout --force "origin/master"

The above is not working... And then it needs to enter the passphrase, and I have no idea what to do then... How can I do this?

答:
Fortunately and according to the core Git documentation, you can use the following command to save your credentials for later on use - instead of typing it each time when prompted.

```<code>git config credential.helper store
</code>```

Using this helper will store your passwords unencrypted on disk,
protected only by filesystem permissions. This command stores credentials indefinitely on disk for use by future Git programs.

You probably don’t want to invoke this command directly; it is meant
to be used as a credential helper by other parts of git

Interesting to check: Git Credentials

ContentLicense: CC BY-SA 4.0

Title: Bash script to automate Git pull

Body:
Fortunately and according to the core Git documentation, you can use the following command to save your credentials for later on use - instead of typing it each time when prompted.

git config credential.helper store

Using this helper will store your passwords unencrypted on disk,
protected only by filesystem permissions. This command stores credentials indefinitely on disk for use by future Git programs.

You probably don’t want to invoke this command directly; it is meant
to be used as a credential helper by other parts of git

Interesting to check: Git Credentials


问:
Applying compression on multipage TIFF
I have the following code which takes a List of WIA.ImageFile and creates a multipage TIFF from those files:

```<code>Function MakeTiff(images As List(Of Object))
    Const wiaFormatTIFF = "{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}"
    Dim ip = AutomationFactory.CreateObject("WIA.ImageProcess")
    Dim frameFilterID = ip.FilterInfos("Frame").FilterID
    For i = 2 To images.Count
        ip.Filters.Add(frameFilterID)
        ip.Filters(i - 1).Properties("ImageFile") = images(i - 1)
    Next
    ip.Filters.Add(ip.FilterInfos("Convert").FilterID)
    ip.Filters(ip.Filters.Count).Properties("FormatID") = wiaFormatTIFF
    Return ip.Apply(images(0))
End Function
</code>```

How can I compress the resulting TIFF file (assuming it's not compressed already)?

答:
I'm using wia 2.0 settings:

```<code>.Properties("6146").Value = 1    '4 is Black-white,gray is 2, color 1
.Properties("6147").Value = 200  'dots per inch/horizontal
.Properties("6148").Value = 200  'dots per inch/vertical
.Properties("4107").Value = 5    '0 = NONE, JPG = 5, PNG = 8 *WiaCompressionMode
</code>```

Its works in VB.net and VBA, compress arround 98%

Title: Applying compression on multipage TIFF

Body:
I have the following code which takes a List of WIA.ImageFile and creates a multipage TIFF from those files:

Function MakeTiff(images As List(Of Object))
    Const wiaFormatTIFF = "{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}"
    Dim ip = AutomationFactory.CreateObject("WIA.ImageProcess")
    Dim frameFilterID = ip.FilterInfos("Frame").FilterID
    For i = 2 To images.Count
        ip.Filters.Add(frameFilterID)
        ip.Filters(i - 1).Properties("ImageFile") = images(i - 1)
    Next
    ip.Filters.Add(ip.FilterInfos("Convert").FilterID)
    ip.Filters(ip.Filters.Count).Properties("FormatID") = wiaFormatTIFF
    Return ip.Apply(images(0))
End Function

How can I compress the resulting TIFF file (assuming it's not compressed already)?

Body:
I'm using wia 2.0 settings:

.Properties("6146").Value = 1    '4 is Black-white,gray is 2, color 1
.Properties("6147").Value = 200  'dots per inch/horizontal
.Properties("6148").Value = 200  'dots per inch/vertical
.Properties("4107").Value = 5    '0 = NONE, JPG = 5, PNG = 8 *WiaCompressionMode

Its works in VB.net and VBA, compress arround 98%


问:
Excel rounding down to a specific number
I need a help with Excel. Can't figure out the formula for a number to round down to 10010.
There is a column which calculates numbers and I want when the result is over 10010, to round it down and display it. Else to show 0.

Thanks!

答:
if you would like to change the number (cell A1) to 10010 if it is greater than or equal to 10010, and if it is blank or less than 10010 set it to 0 this formula would work for you.

```<code>=IF(A1>=10010,10010,0)
</code>```

In response to your comment if in cell B1 you put the formula:

```<code> =MIN(IF(A1:A20>10010,A1:A20))
</code>```

...and make sure you press CTRL-SHIFT-ENTER instead of just ENTER when coming out of formula. This will turn it into an array formula and will return you next largest value to 10010 from you range A1:A20.

In cell C1 can then just put:

```<code> =B1-10010
</code>```

Hope this helps.

Body:
if you would like to change the number (cell A1) to 10010 if it is greater than or equal to 10010, and if it is blank or less than 10010 set it to 0 this formula would work for you.

=IF(A1>=10010,10010,0)

In response to your comment if in cell B1 you put the formula:

 =MIN(IF(A1:A20>10010,A1:A20))

...and make sure you press CTRL-SHIFT-ENTER instead of just ENTER when coming out of formula. This will turn it into an array formula and will return you next largest value to 10010 from you range A1:A20.

In cell C1 can then just put:

 =B1-10010

Hope this helps.


问:
Parameterise settings.json of Function app for publish
For a Proof of Concept, I would like to publish an Azure Function from Visual studio to Azure with a different connectionString value. But I can't figure out how.

In the FunctionApp there is a local.settings.json file. I have added a connectionString to my local database.

local.settings.json file:

```<code>{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "",
    "AzureWebJobsDashboard": ""
  },
  "ConnectionStrings": {
    "DefaultConnection": "Data Source=.\;Initial Catalog=declapp;Integrated Security=False;User ID=*****;Password=*****;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"
  }
}
</code>```

I can publish this FunctionApp to Azure with the generated publish profile but I have a database in Azure which is used by the deployed FunctionApp. The first time I had to add the connectionString to the FunctionApp in the Azure Portal. But also when the connectionString needs to be altered, I can only do it in the Azure Portal.

I would like to know how I can add/alter the connectionString in the publishing part as below. How can I achieve this?

```<code>{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "",
    "AzureWebJobsDashboard": ""
  },
  "ConnectionStrings": {
    "DefaultConnection": "<Azure sql connectionstring>"
  }
}
</code>```

Just to be clear: I know it`s a bad practice to have (production) values in source control, but it's for a simple Proof of Concept and I don't want to define a CI/CD pipeline just for this.

答:
local.settings.json is only intended for local development. In Azure, the values will be taken from App Settings of your Function App.

You can set this settings e.g. via the portal, Azure CLI (example), ARM templates (example), or func CLI from local.app.settings (func azure functionapp publish MyApp --publish-settings-only).

Body:
For a Proof of Concept, I would like to publish an Azure Function from Visual studio to Azure with a different connectionString value. But I can't figure out how.

In the FunctionApp there is a local.settings.json file. I have added a connectionString to my local database.

local.settings.json file:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "",
    "AzureWebJobsDashboard": ""
  },
  "ConnectionStrings": {
    "DefaultConnection": "Data Source=.\;Initial Catalog=declapp;Integrated Security=False;User ID=*****;Password=*****;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"
  }
}

I can publish this FunctionApp to Azure with the generated publish profile but I have a database in Azure which is used by the deployed FunctionApp. The first time I had to add the connectionString to the FunctionApp in the Azure Portal. But also when the connectionString needs to be altered, I can only do it in the Azure Portal.

I would like to know how I can add/alter the connectionString in the publishing part as below. How can I achieve this?

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "",
    "AzureWebJobsDashboard": ""
  },
  "ConnectionStrings": {
    "DefaultConnection": "<Azure sql connectionstring>"
  }
}

Just to be clear: I know it`s a bad practice to have (production) values in source control, but it's for a simple Proof of Concept and I don't want to define a CI/CD pipeline just for this.


答:
SVG animation

<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="30%" height="30%" viewBox="0 0 47.4 47.7" style="enable-background:new 0 0 47.4 47.7;" xml:space="preserve">

<defs>
<linearGradient id="grad" x1="0%" y1="0%" x2="0%" y2="100%" >

            <stop offset="0%" stop-color="#33363D"/>
            <stop offset="100%" stop-color="#5B5D5A"/>
</lineargradient>
</defs>
<rect width="100%" height="100%" fill="url(#grad)"/>

<path id="circle" class="st0" stroke-dashoffset="138" stroke-dasharray="138" d="M23.7,45.8c12.1,0,22-9.9,22-22c0-12.1-9.9-22-22-22c-12.1,0-22,9.9-22,22C1.7,35.9,11.6,45.8,23.7,45.8z">
<animate id="an_circle" attributeName="stroke-dashoffset" values="138;0" dur="2s" fill="freeze" />
</path>
    <g stroke-width="0.5">
       <path id="trap" class="st1" stroke-dashoffset="60" stroke-dasharray="60" style="fill:none; stroke:#FEC558;" d="M14.1,17.9 14.1,20.2 14.1,22.2 14.1,23.4 14.1,24.7 14.1,27.6 32.7,35.2 32.7,32.5 32.7,30.7  32.7,29.7 32.7,28.5 32.7,25.2z">
        <animate id="an_trap" attributeName="stroke-dashoffset" values="60;0" dur="1s" fill="freeze" />
        <animate id="fill_trap" attributeName="fill" values="#33363D;#FEC558"  begin="an_circle.end" dur="1s" fill="freeze" />
     </path>
        <path id="triangle" class="st1" stroke-dashoffset="35" stroke-dasharray="35" style="fill:none; stroke:#FEC558;"  d="M19.2,18.7 24.3,20.6 27.5,21.9 27.5,21.2 27.5,19.4 27.5,17.5 27.5,16.3 27.5,15.2 27.5,12.5 15.5,17.2 19.2,18.7">

        <animate id="an_triangle" attributeName="stroke-dashoffset" begin="an_trap.end" values="35;0" dur="1s" fill="freeze" />
          <animate id="fill_triangle" attributeName="fill" values="#33363D;#FEC558"  begin="fill_trap.end-0.5s" dur="1s" fill="freeze" />
      </path>
    </g>
</svg>```
</div>
</div>
</p>
<ul>
<li>Determine the length of objects using JS</li>
</ul>
```
```
<p><strong>Path length:</strong></p>
<p>for circle - <code>138px</code></p>
<p>for trapezium - <code>60px</code></p>
<p>for triangle - <code>35px</code></p>
<ul>
<li>Command for drawing animation of objects</li>
</ul>
```<animate id="an_circle" attributeName="stroke-dashoffset"
   values="138;0" dur="2s" fill="freeze" />
```
```  <animate id="an_trap" attributeName="stroke-dashoffset"
     values="60;0" dur="1s" fill="freeze" />
```
```<animate id="an_triangle" attributeName="stroke-dashoffset"
   begin="an_trap.end" values="35;0" dur="1s" fill="freeze" />
```
<ul>
<li>The animation of drawing a triangle will begin when the animation of
drawing of a trapezoid</li>
</ul>
<p><code>begin="an_trap.end"</code></p>
<ul>
<li>Animation fill color trapezium will begin when the animation is
finished drawing a circle</li>
</ul>
```<animate id="fill_trap" attributeName="fill" values="#33363D;#FEC558"
    begin="an_circle.end" dur="1s" fill="freeze" />
```
<ul>
<li>An animation of the color filling of the triangle will begin when the
fill animation of the trapezium ends</li>
</ul>
```    <animate id="fill_triangle" attributeName="fill" values="#33363D;#FEC558"
       begin="fill_trap.end-0.5s" dur="1s" fill="freeze" />
```

Title: Animate SVG with CSS: first the stroke, then the fill

Body:
I'm completely new to animating SVGs with CSS (from what I've been reading, JS might also be needed to get the total path length) and need to achieve the following effect: http://gph.is/2iZZ3Hw

<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
 viewBox="0 0 47.4 47.7" style="enable-background:new 0 0 47.4 47.7;" xml:space="preserve">

<path class="st0" d="M23.7,45.8c12.1,0,22-9.9,22-22c0-12.1-9.9-22-22-22c-12.1,0-22,9.9-22,22C1.7,35.9,11.6,45.8,23.7,45.8z"/>
    <g>
        <polygon class="st1" points="14.1,17.9 14.1,20.2 14.1,22.2 14.1,23.4 14.1,24.7 14.1,27.6 32.7,35.2 32.7,32.5 32.7,30.7
    32.7,29.7 32.7,28.5 32.7,25.2   "/>
        <polygon class="st1" points="19.2,18.7 24.3,20.6 27.5,21.9 27.5,21.2 27.5,19.4 27.5,17.5 27.5,16.3 27.5,15.2 27.5,12.5
    15.5,17.2 19.2,18.7     "/>
    </g>
</svg>

Body:
SVG animation

<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="30%" height="30%" viewBox="0 0 47.4 47.7" style="enable-background:new 0 0 47.4 47.7;" xml:space="preserve">
<style type="text/css">
    .st0{fill-rule:evenodd;clip-rule:evenodd;fill:none;stroke:#FEC558;stroke-width:0.5;stroke-miterlimit:22.9256;}
    .st1{fill:#FFC656;}
</style>
<defs>
<linearGradient id="grad" x1="0%" y1="0%" x2="0%" y2="100%" >

            <stop offset="0%" stop-color="#33363D"/>
            <stop offset="100%" stop-color="#5B5D5A"/>
</lineargradient>
</defs>
<rect width="100%" height="100%" fill="url(#grad)"/>

<path id="circle" class="st0" stroke-dashoffset="138" stroke-dasharray="138" d="M23.7,45.8c12.1,0,22-9.9,22-22c0-12.1-9.9-22-22-22c-12.1,0-22,9.9-22,22C1.7,35.9,11.6,45.8,23.7,45.8z">
<animate id="an_circle" attributeName="stroke-dashoffset" values="138;0" dur="2s" fill="freeze" />
</path>
    <g stroke-width="0.5">
       <path id="trap" class="st1" stroke-dashoffset="60" stroke-dasharray="60" style="fill:none; stroke:#FEC558;" d="M14.1,17.9 14.1,20.2 14.1,22.2 14.1,23.4 14.1,24.7 14.1,27.6 32.7,35.2 32.7,32.5 32.7,30.7  32.7,29.7 32.7,28.5 32.7,25.2z">
        <animate id="an_trap" attributeName="stroke-dashoffset" values="60;0" dur="1s" fill="freeze" />
        <animate id="fill_trap" attributeName="fill" values="#33363D;#FEC558"  begin="an_circle.end" dur="1s" fill="freeze" />
     </path>
        <path id="triangle" class="st1" stroke-dashoffset="35" stroke-dasharray="35" style="fill:none; stroke:#FEC558;"  d="M19.2,18.7 24.3,20.6 27.5,21.9 27.5,21.2 27.5,19.4 27.5,17.5 27.5,16.3 27.5,15.2 27.5,12.5 15.5,17.2 19.2,18.7">

        <animate id="an_triangle" attributeName="stroke-dashoffset" begin="an_trap.end" values="35;0" dur="1s" fill="freeze" />
          <animate id="fill_triangle" attributeName="fill" values="#33363D;#FEC558"  begin="fill_trap.end-0.5s" dur="1s" fill="freeze" />
      </path>
    </g>
</svg>

Determine the length of objects using JS

    <script>
             function TotalLength(){
              var path = document.querySelector('#circle');
            var len = Math.round(path.getTotalLength() );
            alert("path length - " + len);
            };
      </script>

Path length:

for circle - 138px

for trapezium - 60px

for triangle - 35px

Command for drawing animation of objects

<animate id="an_circle" attributeName="stroke-dashoffset"
   values="138;0" dur="2s" fill="freeze" />

  <animate id="an_trap" attributeName="stroke-dashoffset"
     values="60;0" dur="1s" fill="freeze" />

<animate id="an_triangle" attributeName="stroke-dashoffset"
   begin="an_trap.end" values="35;0" dur="1s" fill="freeze" />

The animation of drawing a triangle will begin when the animation of
drawing of a trapezoid

begin="an_trap.end"

Animation fill color trapezium will begin when the animation is
finished drawing a circle

<animate id="fill_trap" attributeName="fill" values="#33363D;#FEC558"
    begin="an_circle.end" dur="1s" fill="freeze" />

An animation of the color filling of the triangle will begin when the
fill animation of the trapezium ends

    <animate id="fill_triangle" attributeName="fill" values="#33363D;#FEC558"
       begin="fill_trap.end-0.5s" dur="1s" fill="freeze" />


问:
Can a app detect if it's installed as "External Testing" via TestFlight
I would like the Internal Testing and External Testing users on TestFlight to goto different API servers when they first run the app.  I'm wondering if it's possible for the app to detect if it was installed as "Internal Testing" or "External Testing" app from TestFlight.

If this is not possible my next option was to build a separate app to send to Testflight that would use a different API server on startup.  But this is more complicated.

The reason behind doing this is I only want external testers to see real data from the server.  And not the bogus test data we have been submitting while developing the app.

答:
As far as I know it is not possible to detect internal vs external testers running your application.

But you don't have to build two different applications. I have similar requirements than you: I have a special menu in the application settings where internal testers may tweak several aspects of the application, like for example the server they are connecting to, so they can test the application without messing with production data, or buying content in a controlled environment. I don't want those settings to be available to external testers, so I do the following:

I create two different build configurations, one for internal testers (e.g. ReleaseInternal), and other for the rest (Release)

I define a preprocessor macro / Swift flag in the internal tester build configuration (e.g. INTERNAL_TESTING)

I use the preprocessor macro / Swift flag to activate / deactivate certain sections of code or functionalities

I create two different schemas, each one using the corresponding build configuration, so you just have to switch the schema to build the appropriate version of the application

And finally, I automate the release of the application using fastlane, with a flag indicating whether I want to release the application to internal or external testers, so I don't make a mistake and release the wrong version to the wrong people


问:
Integrate existing cassandra data to elassandra
Is there any way to intigrate existing cassandra cluster link with the elassandra running instance.We have lot's of data in the existing cassandra cluster and when we intigrate my application with elassandra its work well but my existing data is not there to use.</p>

答:
I had a similar error with it. The problem was at the time to configuration of elissandra.

have you use: nodetool rebuild <source-datacenter-name>?


问:
get only string after matching pattern and exclude everything else
I would like to get string which comes after matching pattern and exclude everything else. For example say,

```<code>Nov 17 21:52:06 web01-san roundcube: <he1v330n> User dxxssjksdfd [121.177.26.200]; \
Message for undisclosed-recipients:, stanpiatt@yahoo.com
Nov 17 21:48:26 web01-san roundcube: <fqu8k29l> User cxcnjdfdssd [121.177.26.200]; \
Message for undisclosed-recipients:, stanpiatt@yahoo.com
</code>```

So I would like to get ONLY string after pattern User and exclude everything else, so output should be

```<code>User dxxssjksdfd
User cxcnjdfdssd
</code>```

I've tried grep -Po 'User\K[^\s]*' but it doesn't give what I want. How can I do that ?

答:
```<code>$ cat infile
Nov 17 21:52:06 web01-san roundcube: <he1v330n> User dxxssjksdfd [121.177.26.200]; \
Message for undisclosed-recipients:, stanpiatt@yahoo.com
Nov 17 21:48:26 web01-san roundcube: <fqu8k29l> User cxcnjdfdssd [121.177.26.200]; \
Message for undisclosed-recipients:, stanpiatt@yahoo.com
</code>```

Using grep

```<code>$ grep -Po 'User [^\s]*'  infile
User dxxssjksdfd
User cxcnjdfdssd
</code>```

Using awk

```<code>$ awk  'match($0,/User [^ ]*/){ print substr($0, RSTART,RLENGTH)}'  infile
User dxxssjksdfd
User cxcnjdfdssd
</code>```

Using GNU awk

```<code>$ awk  'match($0,/User [^ ]*/,arr){ print arr[0]}'  infile
User dxxssjksdfd
User cxcnjdfdssd
</code>```

Explanation:

/User [^\s]*/

User matches the characters User literally (case sensitive)

Match a single character not present in the list below [^\s]*

* Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)

\s matches any whitespace character (equal to [\r\n\t\f\v ])

Body:
I would like to get string which comes after matching pattern and exclude everything else. For example say,

Nov 17 21:52:06 web01-san roundcube: <he1v330n> User dxxssjksdfd [121.177.26.200]; \
Message for undisclosed-recipients:, stanpiatt@yahoo.com
Nov 17 21:48:26 web01-san roundcube: <fqu8k29l> User cxcnjdfdssd [121.177.26.200]; \
Message for undisclosed-recipients:, stanpiatt@yahoo.com

So I would like to get ONLY string after pattern User and exclude everything else, so output should be

User dxxssjksdfd
User cxcnjdfdssd

I've tried grep -Po 'User\K[^\s]*' but it doesn't give what I want. How can I do that ?

Body:
$ cat infile
Nov 17 21:52:06 web01-san roundcube: <he1v330n> User dxxssjksdfd [121.177.26.200]; \
Message for undisclosed-recipients:, stanpiatt@yahoo.com
Nov 17 21:48:26 web01-san roundcube: <fqu8k29l> User cxcnjdfdssd [121.177.26.200]; \
Message for undisclosed-recipients:, stanpiatt@yahoo.com

Using grep

$ grep -Po 'User [^\s]*'  infile
User dxxssjksdfd
User cxcnjdfdssd

Using awk

$ awk  'match($0,/User [^ ]*/){ print substr($0, RSTART,RLENGTH)}'  infile
User dxxssjksdfd
User cxcnjdfdssd

Using GNU awk

$ awk  'match($0,/User [^ ]*/,arr){ print arr[0]}'  infile
User dxxssjksdfd
User cxcnjdfdssd

Explanation:

/User [^\s]*/

User matches the characters User literally (case sensitive)

Match a single character not present in the list below [^\s]*

* Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)

\s matches any whitespace character (equal to [\r\n\t\f\v ])


问:
Why datetime in MATLAB is giving weird result?
I am trying to convert datenum values from double array. But conversion is leading to weird values in 'year'.

e.g.

     t(1)=23823.1076388889;
      d=datetime(t,'ConvertFrom','datenum');
      d(1) = '22-Mar-0065 02:35:00'

What am I doing wrong?

Thanks for your help.

答:
23823.1076388889 is being interpreted as either a Julian date or a Proleptic Gregorian date with the decimal part being the proportion elapsed in that day.

23823 is a day within the 65th year.

If you want to use a different scale, then use an additive constant. For example, to recover Excel-style dates after Feb 1900, you would need to add 2415019.


问:
Aggregate strings in Azure SQL Data Warehouse
Is there a way to aggregate strings in Azure SQL Data Warehouse similar to the string_agg function in SQL Server?

I have records with strings that I want to concatenate into a single string.

SELECT string_agg(string_col, ',') FROM table1

https://learn.microsoft.com/en-us/sql/t-sql/functions/string-agg-transact-sql

答:
Update Jan 2019: As at Jan 2019 STRING_SPLIT is available in SQL Data Warehouse as per here.

Update Jul 2019: As at Jul 2019 STRING_AGG is available in SQL Data Warehouse as per here.

Azure SQL Data Warehouse is an MPP system designed to hold billions of records and terabytes of data, so as a first port of call you should strongly consider if it's the right place to do string manipulation.  It's also kind of expensive depending on what DWU you are running at.  Have a read through this anti-patterns article.

Azure SQL Data Warehouse Workload Patterns and Anti-Patterns
https://blogs.msdn.microsoft.com/sqlcat/2017/09/05/azure-sql-data-warehouse-workload-patterns-and-anti-patterns/

If you really need to do this in your warehouse then I did do a recent example specifically for Azure SQL Data Warehouse using a procedural approach:

Does Azure SQL Data Warehouse have a way to split strings?


问:
MongoDB with Node.js can't find one other collections
I've done two collections before "article" and "news" and it all works...
If i want to do other collection mongo cant find it

```<code>var mongoose = require('mongoose');

var calendarSchema = mongoose.Schema({
name:{
    type: String,
    required: true
},
create_date:{
    type: Date,
    default: Date.now
}
});

var Calendar = module.exports = mongoose.model('calendar',calendarSchema);

module.exports.getCalendar = function(callback, limit){
Calendar.find(callback).limit(limit);

}
});
</code>```

Calendar.find() returns empty array.
if i change mongoose.model to " news" it works

答:
You can also check with commands if you don't have robomongo,</p>

```<code> >mongo
//Mongodb
    >show dbs
//It shows the database
    >use yourdbname
//type your db name
    >show collections
//It shows all collections what you have done so far
</code>```

Body:
I've done two collections before "article" and "news" and it all works...
If i want to do other collection mongo cant find it

var mongoose = require('mongoose');

var calendarSchema = mongoose.Schema({
name:{
    type: String,
    required: true
},
create_date:{
    type: Date,
    default: Date.now
}
});

var Calendar = module.exports = mongoose.model('calendar',calendarSchema);

module.exports.getCalendar = function(callback, limit){
Calendar.find(callback).limit(limit);

}
});

Calendar.find() returns empty array.
if i change mongoose.model to " news" it works

Body:
You can also check with commands if you don't have robomongo,

 >mongo
//Mongodb
    >show dbs
//It shows the database
    >use yourdbname
//type your db name
    >show collections
//It shows all collections what you have done so far


问:
How to use HTML and CSS as a Java application GUI?
I want to design new Git client with a clean GUI.

Is it possible to use the power of HTML, CSS and JavaScript in a java application?

I would like to use Java + JGit for models, Java for controllers and HTML + CSS + JavaScript for views.

I don't want a client-server model. I would like to integrate Java and HTML nicely. A DOM event would fire events directly to a Java controller. This way it would be possible to create rich offline application.

答:
JavaFX 2.2 brought this functionality  to providing a user interface component (GUI) that has web view and full browsing functionality.

For more details, see  Adding HTML Content to JavaFX Applications.


问:
Html to Excel. How to export html to excel via JS with utf-8?
I have spent a lot of time on stackoverflow and other internet resources to find an answer for this question. But i couldn't convert solutions into my current code( it is very important). So i have the code below:

var data_type = 'data:application/vnd.ms-excel/charset=UTF-8';
var tables_divs_sum_html = '

';
var table_divs = document.getElementsByClassName('calculate--container')

for (let i=0;i<table_divs.length;i++)
{
    if (i === table_divs.length - 1)
    {
        tables_divs_sum_html += table_divs[i].outerHTML + '

';
    }
    else
    {
        tables_divs_sum_html += table_divs[i].outerHTML + '	';
    }
}

var table_html = tables_divs_sum_html.replace(/ /g, '%20');
var a = document.createElement('a');

a.href = data_type + ', ' + table_html
a.download = `Report_for_${this.props.match.params.month}_${this.props.match.params.year}` + '.xls';
a.click();```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="calculate--container">
    <h5 style="color: skyblue;">
    </h5>

    <div class="calculate--table">
        <table>
            <tbody>
                <tr>
                    <th style="border-top-color: skyblue; border-left-color: skyblue; border-right-color: skyblue; color: skyblue;">

                        <span>
                            <span>
                                July
                            </span>

                            2017
                        </span>

                        <span>
                            <br>

                            <span>
                                Equality period
                            </span>

                            (4)
                        </span>
                    </th>

                    <th colspan="3" style="border-top-color: whitesmoke; border-left-color: whitesmoke; border-right-color: whitesmoke;">
                        Laborable, de 6 AM a 6 PM
                    </th>

                    <th colspan="3" style="border-top-color: whitesmoke; border-left-color: whitesmoke; border-right-color: whitesmoke;">
                        Fin de semana, de 6 AM a 6 PM
                    </th>
                </tr>

                <tr>
                    <th>
                        Sensors
                    </th>

                    <th>
                        <span>
                            ATT
                        </span>
                    </th>

                    <th>
                        <span>
                            ATT SLA
                        </span>
                    </th>

                    <th>
                        <span>
                            ATT MI
                        </span>
                    </th>

                    <th>
                        <span>
                            ATT
                        </span>
                    </th>

                    <th>
                        <span>
                            ATT SLA
                        </span>
                    </th>

                    <th>
                        <span>
                            ATT MI
                        </span>
                    </th>
                </tr>

                <tr>
                    <td>
                        Salvador Orozco Loreto s/n
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>
                </tr>

                <tr>
                    <td>
                        Chapala - Guadalajara & Oleoducto
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>
                </tr>

                <tr>
                    <td>
                        Calz. Jesús González Gallo 655
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>
                </tr>

                <tr>
                    <td>
                        Av. Niños Héroes 642
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>
                </tr>

                <tr>
                    <td>
                        1006 - Niños Héroes 1092
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>
                </tr>

                <tr>
                    <td>
                        Av San Rafael 403
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>
                </tr>

                <tr>
                    <td>
                        Glorieta del Charro
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>
                </tr>

                <tr>
                    <td>
                        1085 - Av del Chamizal 389-333
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>
                </tr>

                <tr>
                    <td>
                        1004 - Felipe Angeles 391
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>
                </tr>

                <tr>
                    <td>
                        1007 - Artesanos 1078
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>
                </tr>

                <tr>
                    <td>
                        1007 - Artesanos 1078
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>

                    <td style="background-color: white; color: black;">
                        -
                    </td>
                </tr>

                <tr>
                    <th>
                        <span>
                            Route
                        </span>
                    </th>

                    <th style="background-color: white; color: black;">
                        -
                    </th>

                    <th style="color: black;">
                        -
                    </th>

                    <th style="background-color: white; color: black;">
                        -
                    </th>

                    <th style="background-color: white; color: black;">
                        -
                    </th>

                    <th style="color: black;">
                        -
                    </th>

                    <th style="background-color: white; color: black;">
                        -
                    </th>
                </tr>

                <tr class="stupid-height">
                </tr>

                <tr>
                    <th style="border-top-color: whitesmoke; border-left-color: whitesmoke;">
                        <nbsp></nbsp>
                    </th>

                    <th>
                        <span>
                            AV
                        </span>
                    </th>

                    <th>
                        <span>
                            SLA
                        </span>
                    </th>

                    <th>
                        <span>
                            MI
                        </span>
                    </th>

                    <th>
                        <span>
                            AV
                        </span>
                    </th>

                    <th>
                        <span>
                            SLA
                        </span>
                    </th>

                    <th>
                        <span>
                            MI
                        </span>
                    </th>
                </tr>

                <tr>
                    <th>
                        <span>
                            Average pass frequency
                        </span>
                    </th>

                    <th style="background-color: white; color: black;">
                        -
                    </th>

                    <th style="color: black;">
                        -
                    </th>

                    <th style="background-color: white; color: black;">
                        -
                    </th>

                    <th style="background-color: white; color: black;">
                        -
                    </th>

                    <th style="color: black;">
                        -
                    </th>

                    <th style="background-color: white; color: black;">
                        -
                    </th>
                </tr>

                <tr>
                    <th>
                        <span>
                            Number of buses
                        </span>
                    </th>

                    <th style="background-color: white; color: black;">
                        -
                    </th>

                    <th style="color: black;">
                        -
                    </th>

                    <th style="background-color: white; color: black;">
                        -
                    </th>

                    <th style="background-color: white; color: black;">
                        -
                    </th>

                    <th style="color: black;">
                        -
                    </th>

                    <th style="background-color: white; color: black;">
                        -
                    </th>
                </tr>

                <tr class="stupid-height">
                </tr>
            </tbody>
        </table>
    </div>
</div></code>```

The javascript is starting after clicking the button on page.But

答:
I hope this meets your requirement;

window.open('data:application/vnd.ms-excel,' + $('#tableToBeExported').html());```
<pre class="snippet-code-html lang-html prettyprint-override"><code><table id="tableToBeExported">
  <tbody>
    <tr>
      <th style="border-top-color: skyblue; border-left-color: skyblue; border-right-color: skyblue; color: skyblue;"> <span><span>July</span> 2017</span><span><br> <span> Equality period</span>(4)</span>
      </th>
      <th colspan="3" style="border-top-color: whitesmoke; border-left-color: whitesmoke; border-right-color: whitesmoke;">Laborable, de 6 AM a 6 PM</th>
      <th colspan="3" style="border-top-color: whitesmoke; border-left-color: whitesmoke; border-right-color: whitesmoke;">Fin de semana, de 6 AM a 6 PM</th>
    </tr>
    <tr>
          <th>Sensors</th>
          <th><span>ATT</span></th>
          <th><span>ATT SLA</span></th>
          <th><span>ATT MI</span></th>
          <th><span>ATT</span></th>
          <th><span>ATT SLA</span></th>
          <th><span>ATT MI</span></th>
        </tr>
        <tr>
          <td> Salvador Orozco Loreto s/n</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
        </tr>
        <tr>
          <td>Chapala - Guadalajara & Oleoducto</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
        </tr>
        <tr>
          <td>Calz. Jesús González Gallo 655</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
        </tr>
        <tr>
          <td>Av. Niños Héroes 642</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
        </tr>
        <tr>
          <td>1006 - Niños Héroes 1092</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
        </tr>
        <tr>
          <td>Av San Rafael 403</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
        </tr>
        <tr>
          <td>Glorieta del Charro</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
        </tr>
        <tr>
          <td>1085 - Av del Chamizal 389-333</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
        </tr>
        <tr>
          <td>1004 - Felipe Angeles 391</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
        </tr>
        <tr>
          <td>1007 - Artesanos 1078</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
        </tr>
        <tr>
          <td>1007 - Artesanos 1078</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
        </tr>
        <tr>
          <th><span>Route</span></th>
          <th style="background-color: white; color: black;">-</th>
          <th style="color: black;">-</th>
          <th style="background-color: white; color: black;">-</th>
          <th style="background-color: white; color: black;">-</th>
          <th style="color: black;">-</th>
          <th style="background-color: white; color: black;">-</th>
        </tr>
        </tr>
        <tr>
          <th><span>Average pass frequency</span></th>
          <th style="background-color: white; color: black;">-</th>
          <th style="color: black;">-</th>
          <th style="background-color: white; color: black;">-</th>
          <th style="background-color: white; color: black;">-</th>
          <th style="color: black;">-</th>
          <th style="background-color: white; color: black;">-</th>
        </tr>
        <tr>
          <th><span>Number of buses</span></th>
          <th style="background-color: white; color: black;">-</th>
          <th style="color: black;">-</th>
          <th style="background-color: white; color: black;">-</th>
          <th style="background-color: white; color: black;">-</th>
          <th style="color: black;">-</th>
          <th style="background-color: white; color: black;">-</th>
        </tr>
        <tr class="stupid-height"></tr>
 </tbody>
</table></code>```

Body:
I have spent a lot of time on stackoverflow and other internet resources to find an answer for this question. But i couldn't convert solutions into my current code( it is very important). So i have the code below:

var data_type = 'data:application/vnd.ms-excel/charset=UTF-8';
var tables_divs_sum_html = '

';
var table_divs = document.getElementsByClassName('calculate--container')

for (let i=0;i<table_divs.length;i++)
{
    if (i === table_divs.length - 1)
    {
        tables_divs_sum_html += table_divs[i].outerHTML + '

';
    }
    else
    {
        tables_divs_sum_html += table_divs[i].outerHTML + '	';
    }
}

var table_html = tables_divs_sum_html.replace(/ /g, '%20');
var a = document.createElement('a');

a.href = data_type + ', ' + table_html
a.download = `Report_for_${this.props.match.params.month}_${this.props.match.params.year}` + '.xls';
a.click();

                                July

                            2017

                                Equality period

                            (4)

                        Laborable, de 6 AM a 6 PM

                        Fin de semana, de 6 AM a 6 PM

                        Sensors

                            ATT

                            ATT SLA

                            ATT MI

                            ATT

                            ATT SLA

                            ATT MI

                        Salvador Orozco Loreto s/n

                        -

                        -

                        -

                        -

                        -

                        -

                        Chapala - Guadalajara & Oleoducto

                        -

                        -

                        -

                        -

                        -

                        -

                        Calz. Jesús González Gallo 655

                        -

                        -

                        -

                        -

                        -

                        -

                        Av. Niños Héroes 642

                        -

                        -

                        -

                        -

                        -

                        -

                        1006 - Niños Héroes 1092

                        -

                        -

                        -

                        -

                        -

                        -

                        Av San Rafael 403

                        -

                        -

                        -

                        -

                        -

                        -

                        Glorieta del Charro

                        -

                        -

                        -

                        -

                        -

                        -

                        1085 - Av del Chamizal 389-333

                        -

                        -

                        -

                        -

                        -

                        -

                        1004 - Felipe Angeles 391

                        -

                        -

                        -

                        -

                        -

                        -

                        1007 - Artesanos 1078

                        -

                        -

                        -

                        -

                        -

                        -

                        1007 - Artesanos 1078

                        -

                        -

                        -

                        -

                        -

                        -

                            Route

                        -

                        -

                        -

                        -

                        -

                        -

                        <nbsp></nbsp>

                            AV

                            SLA

                            MI

                            AV

                            SLA

                            MI

                            Average pass frequency

                        -

                        -

                        -

                        -

                        -

                        -

                            Number of buses

                        -

                        -

                        -

                        -

                        -

                        -

The javascript is starting after clicking the button on page.But

Body:
I hope this meets your requirement;

window.open('data:application/vnd.ms-excel,' + $('#tableToBeExported').html());

<table id="tableToBeExported">
  <tbody>
    <tr>
      <th style="border-top-color: skyblue; border-left-color: skyblue; border-right-color: skyblue; color: skyblue;">&nbsp;<span><span>July</span>&nbsp;2017</span><span><br> <span> Equality period</span>(4)</span>
      </th>
      <th colspan="3" style="border-top-color: whitesmoke; border-left-color: whitesmoke; border-right-color: whitesmoke;">Laborable, de 6 AM a 6 PM</th>
      <th colspan="3" style="border-top-color: whitesmoke; border-left-color: whitesmoke; border-right-color: whitesmoke;">Fin de semana, de 6 AM a 6 PM</th>
    </tr>
    <tr>
          <th>Sensors</th>
          <th><span>ATT</span></th>
          <th><span>ATT SLA</span></th>
          <th><span>ATT MI</span></th>
          <th><span>ATT</span></th>
          <th><span>ATT SLA</span></th>
          <th><span>ATT MI</span></th>
        </tr>
        <tr>
          <td> Salvador Orozco Loreto s/n</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
        </tr>
        <tr>
          <td>Chapala - Guadalajara &amp; Oleoducto</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
        </tr>
        <tr>
          <td>Calz. Jesús González Gallo 655</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
        </tr>
        <tr>
          <td>Av. Niños Héroes 642</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
        </tr>
        <tr>
          <td>1006 - Niños Héroes 1092</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
        </tr>
        <tr>
          <td>Av San Rafael 403</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
        </tr>
        <tr>
          <td>Glorieta del Charro</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
        </tr>
        <tr>
          <td>1085 - Av del Chamizal 389-333</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
        </tr>
        <tr>
          <td>1004 - Felipe Angeles 391</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
        </tr>
        <tr>
          <td>1007 - Artesanos 1078</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
        </tr>
        <tr>
          <td>1007 - Artesanos 1078</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
          <td style="background-color: white; color: black;">-</td>
        </tr>
        <tr>
          <th><span>Route</span></th>
          <th style="background-color: white; color: black;">-</th>
          <th style="color: black;">-</th>
          <th style="background-color: white; color: black;">-</th>
          <th style="background-color: white; color: black;">-</th>
          <th style="color: black;">-</th>
          <th style="background-color: white; color: black;">-</th>
        </tr>
        </tr>
        <tr>
          <th><span>Average pass frequency</span></th>
          <th style="background-color: white; color: black;">-</th>
          <th style="color: black;">-</th>
          <th style="background-color: white; color: black;">-</th>
          <th style="background-color: white; color: black;">-</th>
          <th style="color: black;">-</th>
          <th style="background-color: white; color: black;">-</th>
        </tr>
        <tr>
          <th><span>Number of buses</span></th>
          <th style="background-color: white; color: black;">-</th>
          <th style="color: black;">-</th>
          <th style="background-color: white; color: black;">-</th>
          <th style="background-color: white; color: black;">-</th>
          <th style="color: black;">-</th>
          <th style="background-color: white; color: black;">-</th>
        </tr>
        <tr class="stupid-height"></tr>
 </tbody>
</table>


问:
Activity is resetting values
I have an activity that sum distance according user walks. The problem is when app goes to background and after something around 50 minutes I resume activity, values start again.
I have tried too many things to solve this problem without success.

Does someone have any idea?

Thanks

答:
You can always use sharedPreference to save progress or similar value

```<code>//initialize

SharedPreferences pref = getApplicationContext().getSharedPreferences("MyPref", MODE_PRIVATE);
    Editor editor = pref.edit();

  //To save values
    editor.putBoolean("key_name1", true);           // Saving boolean - true/false
        editor.putInt("key_name2", "int value");        // Saving integer
        editor.putFloat("key_name3", "float value");    // Saving float
        editor.putLong("key_name4", "long value");      // Saving long
        editor.putString("key_name5", "string value");  // Saving string
        editor.commit(); // commit changes

//and to get values
 pref.getBoolean("key_name1", null);         // getting boolean
    pref.getInt("key_name2", null);             // getting Integer
    pref.getFloat("key_name3", null);           // getting Float
    pref.getLong("key_name4", null);            // getting Long
    pref.getString("key_name5", null);          // getting String
</code>```

example is taken from here.

Title: Activity is resetting values

Body:
You can always use sharedPreference to save progress or similar value

//initialize

SharedPreferences pref = getApplicationContext().getSharedPreferences("MyPref", MODE_PRIVATE);
    Editor editor = pref.edit();

  //To save values
    editor.putBoolean("key_name1", true);           // Saving boolean - true/false
        editor.putInt("key_name2", "int value");        // Saving integer
        editor.putFloat("key_name3", "float value");    // Saving float
        editor.putLong("key_name4", "long value");      // Saving long
        editor.putString("key_name5", "string value");  // Saving string
        editor.commit(); // commit changes

//and to get values
 pref.getBoolean("key_name1", null);         // getting boolean
    pref.getInt("key_name2", null);             // getting Integer
    pref.getFloat("key_name3", null);           // getting Float
    pref.getLong("key_name4", null);            // getting Long
    pref.getString("key_name5", null);          // getting String

example is taken from here.


问:
Issues with session in Codeigniter3 framework
My website works properly in localhost, however, it sometimes give this error when I open it in live https://wtf.az/test . Where can be the problem?

答:
You need to change the session settings in config.php.

Kindly comment out below lines:

//$config['sess_save_path'] = NULL;

//$config['sess_save_path'] = sys_get_temp_dir();

And add a new line.

$config['sess_save_path'] = BASEPATH . 'cache/';


问:
Qt: How to adjust QGraphicsItem to dynamicaly change size
I've this problem for several days. I have created QGraphicsItem and I want to stretch/adjust it's size to size of my QGraphicsView. I was using paint() method, but got with it problems with updating. Now I've used boundingRect() but it uses fixed size. When I set too big size it expand my scene and scrollbars are appearing. Is there way to adjust size of item to size of View?

EDIT: I want only adjust height of my object.

Here's some code:

Header of my Item:

```<code>#ifndef POINTER_H
#define POINTER_H
#include <QObject>
#include <QColor>
#include <QRect>
#include <QGraphicsLineItem>
#include <QPainter>
#include <QGraphicsSceneMouseEvent>

class Pointer : public QGraphicsLineItem
{
public:
    Pointer();
    void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget);
    QRectF boundingRect() const;
    int position;
    void changePosition(int x);

};

#endif // TRACKPOINTER_H
</code>```

Implementation of my Item:

```<code>#include "pointer.h"

Pointer::Pointer()
{
    //this->setFlag(QGraphicsLineItem::ItemIsMovable);
    //setFlag(QGraphicsLineItem::ItemIsFocusable);
    //setFocus();

}

void Pointer::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{

    QPen pen(Qt::red);
    painter->setPen(pen);
    painter->setBrush(QColor(77,77,77));
    painter->drawLine(0,0,0,2000);

}

QRectF Pointer::boundingRect() const
{
    return QRectF(0,0,2,600);
}

void Pointer::changePosition(int x)
{
    //position = x;
    setPos(x,0);
    update();
}
</code>```

And my Window:

```<code>Window::Window(Timers *timer, TrackPointer *tp)
{
Timeline = new QGraphicsScene(this);
TimelineView = new QGraphicsView(Timeline);
TimelineView->setAlignment(Qt::AlignTop|Qt::AlignLeft);

QVBoxLayout *timeLineLayout = new QVBoxLayout;
timeLineLayout->addWidget(TimelineView);

Pointer *pointer = new Pointer;
Timeline->addItem(pointer);
}
</code>```

I have also problems with my scene: When my object moves somewhere away - it expand scene. Later when I bring my object back to it's starting position scene still is expanded and I have scrollbars to scroll my view around the scene. Is there way to decrease scene size using my object?

答:
look into :QGraphicsView::fitInView

http://doc.qt.io/qt-4.8/qgraphicsview.html#fitInView

```<code>QPixmap *pixMap= new QPixmap();;
QGraphicsScene *scene=new QGraphicsScene();;
pixMap->loadFromData(jpegData);
scene->clear();
pixMapItem = scene->addPixmap(*pixMap);
ui->graphicsView->fitInView(scene->sceneRect(), Qt::KeepAspectRatio);
ui->graphicsView->show();
ui->graphicsView->viewport()->update();
</code>```

Body:
I've this problem for several days. I have created QGraphicsItem and I want to stretch/adjust it's size to size of my QGraphicsView. I was using paint() method, but got with it problems with updating. Now I've used boundingRect() but it uses fixed size. When I set too big size it expand my scene and scrollbars are appearing. Is there way to adjust size of item to size of View?

EDIT: I want only adjust height of my object.

Here's some code:

Header of my Item:

#ifndef POINTER_H
#define POINTER_H
#include <QObject>
#include <QColor>
#include <QRect>
#include <QGraphicsLineItem>
#include <QPainter>
#include <QGraphicsSceneMouseEvent>

class Pointer : public QGraphicsLineItem
{
public:
    Pointer();
    void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget);
    QRectF boundingRect() const;
    int position;
    void changePosition(int x);

};

#endif // TRACKPOINTER_H

Implementation of my Item:

#include "pointer.h"

Pointer::Pointer()
{
    //this->setFlag(QGraphicsLineItem::ItemIsMovable);
    //setFlag(QGraphicsLineItem::ItemIsFocusable);
    //setFocus();

}

void Pointer::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{

    QPen pen(Qt::red);
    painter->setPen(pen);
    painter->setBrush(QColor(77,77,77));
    painter->drawLine(0,0,0,2000);

}

QRectF Pointer::boundingRect() const
{
    return QRectF(0,0,2,600);
}

void Pointer::changePosition(int x)
{
    //position = x;
    setPos(x,0);
    update();
}

And my Window:

Window::Window(Timers *timer, TrackPointer *tp)
{
Timeline = new QGraphicsScene(this);
TimelineView = new QGraphicsView(Timeline);
TimelineView->setAlignment(Qt::AlignTop|Qt::AlignLeft);

QVBoxLayout *timeLineLayout = new QVBoxLayout;
timeLineLayout->addWidget(TimelineView);

Pointer *pointer = new Pointer;
Timeline->addItem(pointer);
}

I have also problems with my scene: When my object moves somewhere away - it expand scene. Later when I bring my object back to it's starting position scene still is expanded and I have scrollbars to scroll my view around the scene. Is there way to decrease scene size using my object?

Body:
look into :QGraphicsView::fitInView

http://doc.qt.io/qt-4.8/qgraphicsview.html#fitInView

QPixmap *pixMap= new QPixmap();;
QGraphicsScene *scene=new QGraphicsScene();;
pixMap->loadFromData(jpegData);
scene->clear();
pixMapItem = scene->addPixmap(*pixMap);
ui->graphicsView->fitInView(scene->sceneRect(), Qt::KeepAspectRatio);
ui->graphicsView->show();
ui->graphicsView->viewport()->update();


问:
How to implement google maps in my iPhone application
I am totally confused with google maps and maps of iPhone...

i have read that iPhone uses google maps.....and also spent some time on it....

But it never display the items like  location pictures, balloons etc.

EDIT

THIS is photo for of browser

and following is same place for iPhone maps

second one did not show the annotation added by people.....
(this is what i was asking for ballons or other pictures which people adds to location  on oogle maps)

I want to display all those in my application....

what should i do...

if you suggests implement Google maps API, then please suggest a working link...or provide some sample code if possible.....if anybody has done it...then please mail me at yogeshkumau@gmail.com

waiting for answer......

答: Apple has a special agreement with Google to use their maps on their platform. The internet is packed with examples of usage of MKMapView along with annotations (pins, there're no baloons on iPhone).</p>

ContentLicense: CC BY-SA 2.5


问:
Convert image to pdf php
I am using csxi to make scanning for documnets as image, but I have to upload pdf files to server. How can I convert image to PDF in php ? or is there any way to make csxi scan documents as PDF not image</p>

答:
If you have ImageMagick installed on your machine you could use the ImageMagick bindings for PHP to execute some simple PHP code to do this task:

```<code>$im=new Imagick('my.png');
$im->setImageFormat('pdf');
$im->writeImage('my.pdf');
</code>```

Alternatively if you don't have ImageMagick available you could use a commercial API such as Zamzar which supports image to PDF conversion via PHP (more info in the docs).

Code to use this would be:

```<code><?php
// Build request
$endpoint = "https://api.zamzar.com/v1/jobs";
$apiKey = "YOUR_API_KEY";
$sourceFilePath = "my.png";
$targetFormat = "pdf";

$sourceFile = curl_file_create($sourceFilePath);
$postData = array(
  "source_file" => $sourceFile,
  "target_format" => $targetFormat
);

// Send request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $endpoint);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $apiKey . ":");
$body = curl_exec($ch);
curl_close($ch);

// Process response (with link to converted files)
$response = json_decode($body, true);
print_r($response);
?>
</code>```

Title: Convert image to pdf php

Body:
If you have ImageMagick installed on your machine you could use the ImageMagick bindings for PHP to execute some simple PHP code to do this task:

$im=new Imagick('my.png');
$im->setImageFormat('pdf');
$im->writeImage('my.pdf');

Alternatively if you don't have ImageMagick available you could use a commercial API such as Zamzar which supports image to PDF conversion via PHP (more info in the docs).

Code to use this would be:

<?php
// Build request
$endpoint = "https://api.zamzar.com/v1/jobs";
$apiKey = "YOUR_API_KEY";
$sourceFilePath = "my.png";
$targetFormat = "pdf";

$sourceFile = curl_file_create($sourceFilePath);
$postData = array(
  "source_file" => $sourceFile,
  "target_format" => $targetFormat
);

// Send request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $endpoint);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $apiKey . ":");
$body = curl_exec($ch);
curl_close($ch);

// Process response (with link to converted files)
$response = json_decode($body, true);
print_r($response);
?>


问:
create a one page PDF from two PDFs using PDFBOX
I have a small (quarter inch) one page PDF I created with PDFBOX with text (A). I want to put that small one page PDF (A) on the top of an existing PDF page (B), preserving the existing content of the PDF page (B). In the end, I will have a one page PDF, representing the small PDF on top(A), and the existing PDF intact  making up the rest (B).  How can I accomplish this with PDFBOX?</p>

答:
To join two pages one atop the other onto one target page, you can make use of the PDFBox LayerUtility for importing pages as form XObjects in a fashion similar to PDFBox SuperimposePage example, e.g. with this helper method:

```<code>void join(PDDocument target, PDDocument topSource, PDDocument bottomSource) throws IOException {
    LayerUtility layerUtility = new LayerUtility(target);
    PDFormXObject topForm = layerUtility.importPageAsForm(topSource, 0);
    PDFormXObject bottomForm = layerUtility.importPageAsForm(bottomSource, 0);

    float height = topForm.getBBox().getHeight() + bottomForm.getBBox().getHeight();
    float width, topMargin, bottomMargin;
    if (topForm.getBBox().getWidth() > bottomForm.getBBox().getWidth()) {
        width = topForm.getBBox().getWidth();
        topMargin = 0;
        bottomMargin = (topForm.getBBox().getWidth() - bottomForm.getBBox().getWidth()) / 2;
    } else {
        width = bottomForm.getBBox().getWidth();
        topMargin = (bottomForm.getBBox().getWidth() - topForm.getBBox().getWidth()) / 2;
        bottomMargin = 0;
    }

    PDPage targetPage = new PDPage(new PDRectangle(width, height));
    target.addPage(targetPage);

    PDPageContentStream contentStream = new PDPageContentStream(target, targetPage);
    if (bottomMargin != 0)
        contentStream.transform(Matrix.getTranslateInstance(bottomMargin, 0));
    contentStream.drawForm(bottomForm);
    contentStream.transform(Matrix.getTranslateInstance(topMargin - bottomMargin, bottomForm.getBBox().getHeight()));
    contentStream.drawForm(topForm);
    contentStream.close();
}
</code>```

(JoinPages method join)

You use it like this:

```<code>try (   PDDocument document = new PDDocument();
        PDDocument top = ...;
        PDDocument bottom = ...) {
    join(document, top, bottom);
    document.save("joinedPage.pdf");
}
</code>```

(JoinPages test testJoinSmallAndBig)

The result looks like this:

Body:
To join two pages one atop the other onto one target page, you can make use of the PDFBox LayerUtility for importing pages as form XObjects in a fashion similar to PDFBox SuperimposePage example, e.g. with this helper method:

void join(PDDocument target, PDDocument topSource, PDDocument bottomSource) throws IOException {
    LayerUtility layerUtility = new LayerUtility(target);
    PDFormXObject topForm = layerUtility.importPageAsForm(topSource, 0);
    PDFormXObject bottomForm = layerUtility.importPageAsForm(bottomSource, 0);

    float height = topForm.getBBox().getHeight() + bottomForm.getBBox().getHeight();
    float width, topMargin, bottomMargin;
    if (topForm.getBBox().getWidth() > bottomForm.getBBox().getWidth()) {
        width = topForm.getBBox().getWidth();
        topMargin = 0;
        bottomMargin = (topForm.getBBox().getWidth() - bottomForm.getBBox().getWidth()) / 2;
    } else {
        width = bottomForm.getBBox().getWidth();
        topMargin = (bottomForm.getBBox().getWidth() - topForm.getBBox().getWidth()) / 2;
        bottomMargin = 0;
    }

    PDPage targetPage = new PDPage(new PDRectangle(width, height));
    target.addPage(targetPage);

    PDPageContentStream contentStream = new PDPageContentStream(target, targetPage);
    if (bottomMargin != 0)
        contentStream.transform(Matrix.getTranslateInstance(bottomMargin, 0));
    contentStream.drawForm(bottomForm);
    contentStream.transform(Matrix.getTranslateInstance(topMargin - bottomMargin, bottomForm.getBBox().getHeight()));
    contentStream.drawForm(topForm);
    contentStream.close();
}

(JoinPages method join)

You use it like this:

try (   PDDocument document = new PDDocument();
        PDDocument top = ...;
        PDDocument bottom = ...) {
    join(document, top, bottom);
    document.save("joinedPage.pdf");
}

(JoinPages test testJoinSmallAndBig)

The result looks like this:


问:
Change Clauses Order Prolog [Database Manipulation]
I have do implement a rule invert(+PredicateSymbol, +Arity) that reverses the order of the predicates PredicateSymbol/Arity on the data base.

For example:

before:

```<code>vote(john, ['A'-7, 'B'-9, 'C'-6]).
vote(jack, ['A'-8, 'B'-8, 'C'-7]).
vote(peter, ['C'-4, 'D'-7, 'E'-3]).
vote(harry, ['A'-7, 'C'-6]).
vote(richard, ['A'-10, 'D'-10, 'F'-9]).

| ?- invert(vote,2).
yes
</code>```

after:

```<code>vote(richard, ['A'-10, 'D'-10, 'F'-9]).
vote(harry, ['A'-7, 'C'-6]).
vote(peter, ['C'-4, 'D'-7, 'E'-3]).
vote(jack, ['A'-8, 'B'-8, 'C'-7]).
vote(john, ['A'-7, 'B'-9, 'C'-6]).
</code>```

I have no clue how to do this since it must invert any clause with its given arity...

答:
There are two solutions to this problem.

1)

As long as your predicate is dynamic AND composed by simple facts (no head :- body clauses), this works:

```<code>reverse(F/A) :-
    functor(Pred,F,A),
    retract(Pred),
    asserta(Pred),
    fail.
reverse(_).
</code>```

For example:

```<code>?- reverse(vote/2).
true.

?- vote(X,_).
X = richard ;
X = harry ;
X = peter ;
X = jack ;
X = john.
</code>```

2)

If your intention is to get predicate solutions in reverse order, this works for ANY predicate with a finite number of solutions:

```<code>revaux([_|Rest],Next) :-
    revaux(Rest,Next).
revaux([X|_],X).

reverse_order(Pred) :-
    copy_term(Pred,QueryPred),
    findall(QueryPred,QueryPred,AllSols),
    !,
    revaux(AllSols,Pred).
</code>```

For example:

```<code>?- vote(X,_).
X = john ;
X = jack ;
X = peter ;
X = harry ;
X = richard.

?- reverse_order(vote(X,_)).
X = richard ;
X = harry ;
X = peter ;
X = jack ;
X = john.
</code>```

Body:
I have do implement a rule invert(+PredicateSymbol, +Arity) that reverses the order of the predicates PredicateSymbol/Arity on the data base.

For example:

before:

vote(john, ['A'-7, 'B'-9, 'C'-6]).
vote(jack, ['A'-8, 'B'-8, 'C'-7]).
vote(peter, ['C'-4, 'D'-7, 'E'-3]).
vote(harry, ['A'-7, 'C'-6]).
vote(richard, ['A'-10, 'D'-10, 'F'-9]).

| ?- invert(vote,2).
yes

after:

vote(richard, ['A'-10, 'D'-10, 'F'-9]).
vote(harry, ['A'-7, 'C'-6]).
vote(peter, ['C'-4, 'D'-7, 'E'-3]).
vote(jack, ['A'-8, 'B'-8, 'C'-7]).
vote(john, ['A'-7, 'B'-9, 'C'-6]).

I have no clue how to do this since it must invert any clause with its given arity...

Body:
There are two solutions to this problem.

1)

As long as your predicate is dynamic AND composed by simple facts (no head :- body clauses), this works:

reverse(F/A) :-
    functor(Pred,F,A),
    retract(Pred),
    asserta(Pred),
    fail.
reverse(_).

For example:

?- reverse(vote/2).
true.

?- vote(X,_).
X = richard ;
X = harry ;
X = peter ;
X = jack ;
X = john.

2)

If your intention is to get predicate solutions in reverse order, this works for ANY predicate with a finite number of solutions:

revaux([_|Rest],Next) :-
    revaux(Rest,Next).
revaux([X|_],X).

reverse_order(Pred) :-
    copy_term(Pred,QueryPred),
    findall(QueryPred,QueryPred,AllSols),
    !,
    revaux(AllSols,Pred).

For example:

?- vote(X,_).
X = john ;
X = jack ;
X = peter ;
X = harry ;
X = richard.

?- reverse_order(vote(X,_)).
X = richard ;
X = harry ;
X = peter ;
X = jack ;
X = john.


问:
How to convert TXT file with various columns to file a with delimiter "," using python?
I have the following ORIGINAL.TXT file:

```<code>"TRACE: A"
"FORMAT: WOW"

"Frequency" "Data 1"    "Data 2"
1   1   2
1   6   0

"Frequency" "Data 1"    "Data 2"
1   5   0
1   6   0
</code>```

In order to run python script, I have to first open .TXT file in LibreOffice, then save and close it, to create EXPECTED.TXT file with a delimiter=',', as shown below:

```<code>"TRACE: A",,
"FORMAT: WOW",,
,,
"Frequency","Data 1","Data 2"
1,5,0
1,5,0

"Frequency","Data 1","Data Trace Imag"
1,5,0
1,5,0
</code>```

Now I can use the following code to plot the graphs:

```<code>import numpy as np
from pylab import *

fileName = 'EXPECTED.TXT';

traceAdata= np.genfromtxt(fileName, delimiter=',')[3:5].T;

x = traceAdata[0]*1e-6;
A = traceAdata[1];

plot(x,A);
savefig(fileName + '.png');
</code>```

I have tried to use different delimiters in the original TXT file such as: ' ', None, '\t', but none of them worked, and I had following error:

```<code>Line #5 (got 3 columns instead of 1)
</code>```

Is there any other way to convert original TXT file to the file with needed delimiter using python?

UPD: Current Solution, thank you @lxop.

```<code>import numpy as np
from pylab import *

fileName = 'C2.TXT';

traceAdata= np.genfromtxt(fileName, skip_header=21,skip_footer = 334).T;

x = traceAdata[0]*1e-6;
A = traceAdata[1];

plot(x,A);
savefig('traceAdata.png');

traceBdata= np.genfromtxt(fileName, skip_header=337).T;
x = traceBdata[0]*1e-6;
B = traceBdata[1];

plot(x,B);
savefig('traceBdata.png');
</code>```

答:
You can load the space separated file directly, without converting, with a script like

```<code>import numpy as np
from pylab import *

fileName = '11.TXT';

traceAdata= np.genfromtxt(fileName, skip_header=4).T;

x = traceAdata[0]*1e-6;
A = traceAdata[1];

plot(x,A);
savefig(fileName + '.png');
</code>```

In particular not the use of skip_header to skip over the lines that don't have data. Also, if you explicitly specify delimiter=' ' then genfromtxt will treat each space as a delimiter and try to get values between the individual space characters, so just leave that argument out.

If you really want to convert it to a CSV first, then you should look at a parsing library, since it will need to handle quoting etc.

Body:
I have the following ORIGINAL.TXT file:

"TRACE: A"
"FORMAT: WOW"

"Frequency" "Data 1"    "Data 2"
1   1   2
1   6   0

"Frequency" "Data 1"    "Data 2"
1   5   0
1   6   0

In order to run python script, I have to first open .TXT file in LibreOffice, then save and close it, to create EXPECTED.TXT file with a delimiter=',', as shown below:

"TRACE: A",,
"FORMAT: WOW",,
,,
"Frequency","Data 1","Data 2"
1,5,0
1,5,0

"Frequency","Data 1","Data Trace Imag"
1,5,0
1,5,0

Now I can use the following code to plot the graphs:

import numpy as np
from pylab import *

fileName = 'EXPECTED.TXT';

traceAdata= np.genfromtxt(fileName, delimiter=',')[3:5].T;

x = traceAdata[0]*1e-6;
A = traceAdata[1];

plot(x,A);
savefig(fileName + '.png');

I have tried to use different delimiters in the original TXT file such as: ' ', None, '\t', but none of them worked, and I had following error:

Line #5 (got 3 columns instead of 1)

Is there any other way to convert original TXT file to the file with needed delimiter using python?

UPD: Current Solution, thank you @lxop.

import numpy as np
from pylab import *

fileName = 'C2.TXT';

traceAdata= np.genfromtxt(fileName, skip_header=21,skip_footer = 334).T;

x = traceAdata[0]*1e-6;
A = traceAdata[1];

plot(x,A);
savefig('traceAdata.png');

traceBdata= np.genfromtxt(fileName, skip_header=337).T;
x = traceBdata[0]*1e-6;
B = traceBdata[1];

plot(x,B);
savefig('traceBdata.png');

Body:
You can load the space separated file directly, without converting, with a script like

import numpy as np
from pylab import *

fileName = '11.TXT';

traceAdata= np.genfromtxt(fileName, skip_header=4).T;

x = traceAdata[0]*1e-6;
A = traceAdata[1];

plot(x,A);
savefig(fileName + '.png');

In particular not the use of skip_header to skip over the lines that don't have data. Also, if you explicitly specify delimiter=' ' then genfromtxt will treat each space as a delimiter and try to get values between the individual space characters, so just leave that argument out.

If you really want to convert it to a CSV first, then you should look at a parsing library, since it will need to handle quoting etc.