问:
Laravel 5.4 - Installing Passport
I'm trying to install passport on my Laravel 5.4 project with the help of the Laravel Documentation. But when i'm at this stage :

php artisan passport:install

I have this error :

```<code>[Illuminate\Database\QueryException]
  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'lpo.oauth_clients' doesn't exist (SQL: insert into `oa
  uth_clients` (`user_id`, `name`, `secret`, `redirect`, `personal_access_client`, `password_client`, `revoked`, `upd
  ated_at`, `created_at`) values (, Laravel Personal Access Client, ruEzLmQYSK5RhfzSximBKoupaXaMcRSR4CvXET0o, http://
  localhost, 1, 0, 0, 2017-07-06 08:26:25, 2017-07-06 08:26:25))

  [PDOException]
  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'lpo.oauth_clients' doesn't exist
</code>```

And i should have something like this if it succeed :

```<code>Encryption keys generated successfully.
Personal access client created successfully.
Client ID: 1
Client Secret: OUA4IhQj1t3kDRuWZ6N7DQb9h1N3ccXpQw9HS2iz
Password grant client created successfully.
Client ID: 2
Client Secret: oGhkm0EPSjqxJBMkaWNZ6lIuuZoby4ev787yW6cO
</code>```

I did php artisan migrate before and i had 2 new table : users and migrations.

Thanks for your help

答:
Most likely you skipped one or two of the following steps:

Next, register the Passport service provider in the providers array of your config/app.php configuration file:

```<code>Laravel\Passport\PassportServiceProvider::class,
</code>```

The Passport service provider registers its own database migration directory with the framework, so you should migrate your database after registering the provider. The Passport migrations will create the tables your application needs to store clients and access tokens:

```<code>php artisan migrate
</code>```

Only after that can you run

```<code>php artisan passport:install
</code>```

Title: Laravel 5.4 - Installing Passport

Body:
I'm trying to install passport on my Laravel 5.4 project with the help of the Laravel Documentation. But when i'm at this stage :

php artisan passport:install

I have this error :

[Illuminate\Database\QueryException]
  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'lpo.oauth_clients' doesn't exist (SQL: insert into `oa
  uth_clients` (`user_id`, `name`, `secret`, `redirect`, `personal_access_client`, `password_client`, `revoked`, `upd
  ated_at`, `created_at`) values (, Laravel Personal Access Client, ruEzLmQYSK5RhfzSximBKoupaXaMcRSR4CvXET0o, http://
  localhost, 1, 0, 0, 2017-07-06 08:26:25, 2017-07-06 08:26:25))

  [PDOException]
  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'lpo.oauth_clients' doesn't exist

And i should have something like this if it succeed :

Encryption keys generated successfully.
Personal access client created successfully.
Client ID: 1
Client Secret: OUA4IhQj1t3kDRuWZ6N7DQb9h1N3ccXpQw9HS2iz
Password grant client created successfully.
Client ID: 2
Client Secret: oGhkm0EPSjqxJBMkaWNZ6lIuuZoby4ev787yW6cO

I did php artisan migrate before and i had 2 new table : users and migrations.

Thanks for your help

Body:
Most likely you skipped one or two of the following steps:

Next, register the Passport service provider in the providers array of your config/app.php configuration file:

Laravel\Passport\PassportServiceProvider::class,

The Passport service provider registers its own database migration directory with the framework, so you should migrate your database after registering the provider. The Passport migrations will create the tables your application needs to store clients and access tokens:

php artisan migrate

Only after that can you run

php artisan passport:install


来源: stackexchange

问:
How to get HttpServletRequest before controller method
I am developing a Spring application and I am authenticating user in HandlerInterceptorAdapter's prehandle() method and if user authenticated I am setting request attribute like this:

```<code>@Override
public boolean preHandle(HttpServletRequest request,
                         HttpServletResponse response,
                         Object handler) throws Exception {

    request.setAttribute("isAuthenticated",true);
    request.setAttribute("user",user);
}
</code>```

if user not authenticated I am setting like this

```<code>@Override
public boolean preHandle(HttpServletRequest request,
                         HttpServletResponse response,
                         Object handler) throws Exception {

    request.setAttribute("isAuthenticated",false);
    request.setAttribute("user",null);
}
</code>```

and then later in controller method I am retrieving user with HttpServletRequest like this:

```<code>@GetMapping(value = "/user", produces = "application/json")
public Object getUserByToken(HttpServletRequest request) {

    if((Boolean) request.getAttribute("isAuthenticated")) {
        return request.getAttribute("user");
    }

    return ResponseEntity.status(UNAUTHORIZED).body("unauthorized");
}
</code>```

The problem is I need to receive HttpServletRequest in each controller method to check if user authenticated.

What I want is that a method that is called before controller method and inside the controller class, so that I can set user in one place and get from all other controller methods

答:
Write a base controller this way:

```<code>public class BaseController {

    @ModelAttribute("user")
    public User getUser(HttpServletRequest request) {
        return (User)request.getAttribute("user");
    }
}
</code>```

Extend all you controllers from BaseController.

```<code>@RequestMapping(value = "/user", produces = "application/json")
public Object getUserByToken(@ModelAttribute("user") User user) {
   // play with user object
}
</code>```

I have shown you the example for user, similarly do for authentication flag.

ContentLicense: CC BY-SA 3.0

Body:
I am developing a Spring application and I am authenticating user in HandlerInterceptorAdapter's prehandle() method and if user authenticated I am setting request attribute like this:

@Override
public boolean preHandle(HttpServletRequest request,
                         HttpServletResponse response,
                         Object handler) throws Exception {

    request.setAttribute("isAuthenticated",true);
    request.setAttribute("user",user);
}

if user not authenticated I am setting like this

@Override
public boolean preHandle(HttpServletRequest request,
                         HttpServletResponse response,
                         Object handler) throws Exception {

    request.setAttribute("isAuthenticated",false);
    request.setAttribute("user",null);
}

and then later in controller method I am retrieving user with HttpServletRequest like this:

@GetMapping(value = "/user", produces = "application/json")
public Object getUserByToken(HttpServletRequest request) {

    if((Boolean) request.getAttribute("isAuthenticated")) {
        return request.getAttribute("user");
    }

    return ResponseEntity.status(UNAUTHORIZED).body("unauthorized");
}

The problem is I need to receive HttpServletRequest in each controller method to check if user authenticated.

What I want is that a method that is called before controller method and inside the controller class, so that I can set user in one place and get from all other controller methods

Body:
Write a base controller this way:

public class BaseController {

    @ModelAttribute("user")
    public User getUser(HttpServletRequest request) {
        return (User)request.getAttribute("user");
    }
}

Extend all you controllers from BaseController.

@RequestMapping(value = "/user", produces = "application/json")
public Object getUserByToken(@ModelAttribute("user") User user) {
   // play with user object
}

I have shown you the example for user, similarly do for authentication flag.


问:
Python regex matching problem
I have been parsing a GraphViz file for a specific identifer using Regex. Here is the typical content from this file:

```<code>node10 [label="second-messenger-mediated signaling\nGO:0019932", fontname=Courier, ...];

node11 [label="inositol phosphate-mediated signaling\nGO:0048016", fontname=Courier, ...];

node12 [label="activation of phospholipase C activity by G-protein coupled receptor protein signaling pathway coupled to IP3 second messenger\n\

GO:0007200", fontname=Courier, ...];

node13 [label="G-protein coupled receptor protein signaling pathway\nGO:0007186", fontname=Courier, ...];

node14 [label="activation of phospholipase C activity\nGO:0007202", fontname=Courier, ...];

node15 [label="elevation of cytosolic calcium ion concentration involved in G-protein signaling coupled to IP3 second messenger\nGO:0051482", fontname=Courier, pos="798,1162", width="9.56", height="0.50"];
</code>```

Since I am only interested in the nodeid, label and the GO identifier I have used the following regex to match each line:

```<code>(node\d*)\s\[label=\"([\w\s-]*).*(GO:\d*)
</code>```

I know that it's neither terribly elegant nor very efficient but it got the job done except for the line with node12. I have tried using re.DOTALL and re.MULTILINE but to no avail.

Can anyone help me spot the missing piece of the puzzle to make the regex also work with node12 ?

**EDIT:

Here [1] is a link to the file that contains one of those lines.

[1] http://amigo.geneontology.org/cgi-bin/amigo/term-details.cgi?session_id=7924amigo1292519756&term=GO:0051482&format=dot

答: Is the \ after the first line of node12 escaping the line ending?

ContentLicense: CC BY-SA 2.5

Title: Python regex matching problem

Body:
I have been parsing a GraphViz file for a specific identifer using Regex. Here is the typical content from this file:

node10 [label="second-messenger-mediated signaling\nGO:0019932", fontname=Courier, ...];

node11 [label="inositol phosphate-mediated signaling\nGO:0048016", fontname=Courier, ...];

node12 [label="activation of phospholipase C activity by G-protein coupled receptor protein signaling pathway coupled to IP3 second messenger\n\

GO:0007200", fontname=Courier, ...];

node13 [label="G-protein coupled receptor protein signaling pathway\nGO:0007186", fontname=Courier, ...];

node14 [label="activation of phospholipase C activity\nGO:0007202", fontname=Courier, ...];

node15 [label="elevation of cytosolic calcium ion concentration involved in G-protein signaling coupled to IP3 second messenger\nGO:0051482", fontname=Courier, pos="798,1162", width="9.56", height="0.50"];

Since I am only interested in the nodeid, label and the GO identifier I have used the following regex to match each line:

(node\d*)\s\[label=\"([\w\s-]*).*(GO:\d*)

I know that it's neither terribly elegant nor very efficient but it got the job done except for the line with node12. I have tried using re.DOTALL and re.MULTILINE but to no avail.

Can anyone help me spot the missing piece of the puzzle to make the regex also work with node12 ?

**EDIT:

Here [1] is a link to the file that contains one of those lines.

[1] http://amigo.geneontology.org/cgi-bin/amigo/term-details.cgi?session_id=7924amigo1292519756&term=GO:0051482&format=dot


问:
How could i make a div with rounded borders and make the fa icons inside it centered?
So i want a div with rounded borders (to make a circle) and inside that i want my fa icons which would be aligned to the middle.

So basically i want a Circle containing an fa icon in the middle just to make it simple.

.normal-page {
  padding-top: 30px;
}

body .normal-page {
  z-index: 998;
  position: relative;
  padding-bottom: 10px;
  background: url(../images/tpbg.jpg) top center no-repeat #141416;
  border: 1px solid #000;
  border-top: 0;
  min-height: 500px;
}

.container {
  padding-right: 15px;
  padding-left: 15px;
  margin-right: auto;
  margin-left: auto;
}

.vote-container {
  text-align: center;
  padding-left: 30px;
  padding-right: 30px;
  color: #fff;
}

.vote-fa {
  color: #ff8800;
  margin-bottom: 20px;
}

.vote-container a {
  cursor: pointer;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link href="https://netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="normal-page">
  <div class="container">
    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
      <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
        <div class="vote-container">
          <i class="fa fa-handshake-o fa-3x vote-fa" aria-hidden="true"></i>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eu risus vitae metus rhoncus tincidunt eu a lorem.</p><br>
          Click here to vote!
        </div>
      </div>
      <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
        <div class="vote-container">
          <i class="fa fa-superpowers fa-3x vote-fa" aria-hidden="true"></i>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eu risus vitae metus rhoncus tincidunt eu a lorem.</p><br>
          Click here to vote!
        </div>
      </div>
      <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
        <div class="vote-container">
          <i class="fa fa-superpowers fa-3x vote-fa" aria-hidden="true"></i>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eu risus vitae metus rhoncus tincidunt eu a lorem.</p><br>
          Click here to vote!
        </div>
      </div>
      <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
        <div class="vote-container">
          <i class="fa fa-superpowers fa-3x vote-fa" aria-hidden="true"></i>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eu risus vitae metus rhoncus tincidunt eu a lorem.</p><br>
          Click here to vote!
        </div>
      </div>
    </div>
  </div>
</div></code>```

答:
You need to fix width and height and use text-align:center and line-height to center it, and to make the rounded border you need to add border-radius:50%;

note: line-height needs to be equal to height to center it vertically

See working example:

.normal-page {
  padding-top: 30px;
}

body .normal-page {
  z-index: 998;
  position: relative;
  padding-bottom: 10px;
  background: url(../images/tpbg.jpg) top center no-repeat #141416;
  border: 1px solid #000;
  border-top: 0;
  min-height: 500px;
}

.container {
  padding-right: 15px;
  padding-left: 15px;
  margin-right: auto;
  margin-left: auto;
}

.vote-container {
  text-align: center;
  padding-left: 30px;
  padding-right: 30px;
  color: #fff;
}

i.vote-fa {
  color: #ff8800;
  margin-bottom: 20px;
  background: #861515;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  text-align: center;
  line-height: 80px;
  border:1px solid #ff8800;
}

.vote-container a {
  cursor: pointer;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link href="https://netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="normal-page">
  <div class="container">
    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
      <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
        <div class="vote-container">
          <i class="fa fa-handshake-o fa-3x vote-fa" aria-hidden="true"></i>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eu risus vitae metus rhoncus tincidunt eu a lorem.</p><br>
          Click here to vote!
        </div>
      </div>
      <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
        <div class="vote-container">
          <i class="fa fa-superpowers fa-3x vote-fa" aria-hidden="true"></i>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eu risus vitae metus rhoncus tincidunt eu a lorem.</p><br>
          Click here to vote!
        </div>
      </div>
      <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
        <div class="vote-container">
          <i class="fa fa-superpowers fa-3x vote-fa" aria-hidden="true"></i>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eu risus vitae metus rhoncus tincidunt eu a lorem.</p><br>
          Click here to vote!
        </div>
      </div>
      <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
        <div class="vote-container">
          <i class="fa fa-superpowers fa-3x vote-fa" aria-hidden="true"></i>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eu risus vitae metus rhoncus tincidunt eu a lorem.</p><br>
          Click here to vote!
        </div>
      </div>
    </div>
  </div>
</div></code>```

Body:
So i want a div with rounded borders (to make a circle) and inside that i want my fa icons which would be aligned to the middle.

So basically i want a Circle containing an fa icon in the middle just to make it simple.

.normal-page {
  padding-top: 30px;
}

body .normal-page {
  z-index: 998;
  position: relative;
  padding-bottom: 10px;
  background: url(../images/tpbg.jpg) top center no-repeat #141416;
  border: 1px solid #000;
  border-top: 0;
  min-height: 500px;
}

.container {
  padding-right: 15px;
  padding-left: 15px;
  margin-right: auto;
  margin-left: auto;
}

.vote-container {
  text-align: center;
  padding-left: 30px;
  padding-right: 30px;
  color: #fff;
}

.vote-fa {
  color: #ff8800;
  margin-bottom: 20px;
}

.vote-container a {
  cursor: pointer;
}

<link href="https://netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eu risus vitae metus rhoncus tincidunt eu a lorem.

          Click here to vote!

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eu risus vitae metus rhoncus tincidunt eu a lorem.

          Click here to vote!

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eu risus vitae metus rhoncus tincidunt eu a lorem.

          Click here to vote!

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eu risus vitae metus rhoncus tincidunt eu a lorem.

          Click here to vote!

Body:
You need to fix width and height and use text-align:center and line-height to center it, and to make the rounded border you need to add border-radius:50%;

note: line-height needs to be equal to height to center it vertically

See working example:

.normal-page {
  padding-top: 30px;
}

body .normal-page {
  z-index: 998;
  position: relative;
  padding-bottom: 10px;
  background: url(../images/tpbg.jpg) top center no-repeat #141416;
  border: 1px solid #000;
  border-top: 0;
  min-height: 500px;
}

.container {
  padding-right: 15px;
  padding-left: 15px;
  margin-right: auto;
  margin-left: auto;
}

.vote-container {
  text-align: center;
  padding-left: 30px;
  padding-right: 30px;
  color: #fff;
}

i.vote-fa {
  color: #ff8800;
  margin-bottom: 20px;
  background: #861515;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  text-align: center;
  line-height: 80px;
  border:1px solid #ff8800;
}

.vote-container a {
  cursor: pointer;
}

<link href="https://netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="normal-page">
  <div class="container">
    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
      <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
        <div class="vote-container">
          <i class="fa fa-handshake-o fa-3x vote-fa" aria-hidden="true"></i>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eu risus vitae metus rhoncus tincidunt eu a lorem.</p><br>
          <a href="#">Click here to vote!</a>
        </div>
      </div>
      <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
        <div class="vote-container">
          <i class="fa fa-superpowers fa-3x vote-fa" aria-hidden="true"></i>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eu risus vitae metus rhoncus tincidunt eu a lorem.</p><br>
          <a href="#">Click here to vote!</a>
        </div>
      </div>
      <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
        <div class="vote-container">
          <i class="fa fa-superpowers fa-3x vote-fa" aria-hidden="true"></i>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eu risus vitae metus rhoncus tincidunt eu a lorem.</p><br>
          <a href="#">Click here to vote!</a>
        </div>
      </div>
      <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
        <div class="vote-container">
          <i class="fa fa-superpowers fa-3x vote-fa" aria-hidden="true"></i>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eu risus vitae metus rhoncus tincidunt eu a lorem.</p><br>
          <a href="#">Click here to vote!</a>
        </div>
      </div>
    </div>
  </div>
</div>


问:
snakemake - output one only file from multiple input files in one rule
I'm using snakemake for the first time in order to build a basic pipeline using cutadapt, bwa and GATK (trimming ; mapping ; calling). I would like to run this pipeline on every fastq file contained in a directory, without having to specify their name or whatever in the snakefile or in the config file. I would like to succeed in doing this.

The first two steps (cutadapt and bwa / trimming and mapping) are running fine, but I'm encountering some problems with GATK.

First, I have to generate g.vcf files from bam files. I'm doing this using these rules:

configfile: "config.yaml"

import os
import glob

rule all:
    input:
        "merge_calling.g.vcf"

rule cutadapt:
    input:
        read="data/Raw_reads/{sample}_R1_{run}.fastq.gz",
        read2="data/Raw_reads/{sample}_R2_{run}.fastq.gz"
    output:
        R1=temp("trimmed_reads/{sample}_R1_{run}.fastq.gz"),
        R2=temp("trimmed_reads/{sample}_R2_{run}.fastq.gz")
    threads:
        10
    shell:
        "cutadapt -q {config[Cutadapt][Quality_value]} -m {config[Cutadapt][min_length]} -a {config[Cutadapt][forward_adapter]} -A  {config[Cutadapt][reverse_adapter]} -o {output.R1} -p '{output.R2}' {input.read} {input.read2}"

rule bwa_map:
    input:
        genome="data/genome.fasta",
        read=expand("trimmed_reads/{{sample}}_{pair}_{{run}}.fastq.gz", pair=["R1", "R2"])
    output:
        temp("mapped_bam/{sample}_{run}.bam")
    threads:
        10
    params:
        rg="@RG\\tID:{sample}\\tPL:ILLUMINA\\tSM:{sample}"
    shell:
        "bwa mem -t 2 -R '{params.rg}' {input.genome} {input.read} | samtools view -Sb - > {output}"

rule picard_sort:
    input:
        "mapped_bam/{sample}.bam"
    output:
        "sorted_reads/{sample}.bam"
    shell:
        "java -Xmx4g -jar /home/alexandre/picard-tools/picard.jar SortSam I={input} O={output} SO=coordinate VALIDATION_STRINGENCY=SILENT"

rule picard_rmdup:
    input:
        bam="sorted_reads/{sample}.bam"
    output:
        "rmduped_reads/{sample}.bam",
        "picard_stats/{sample}.bam"
    params:
        reads="rmduped_reads/{sample}.bam",
        stats="picard_stats/{sample}.bam",
    shell:
        "java -jar -Xmx2g /home/alexandre/picard-tools/picard.jar MarkDuplicates "
        "I={input.bam} "
        "O='{params.reads}' "
        "VALIDATION_STRINGENCY=SILENT "
        "MAX_FILE_HANDLES_FOR_READ_ENDS_MAP=1000 "
        "REMOVE_DUPLICATES=TRUE "
        "M='{params.stats}'"

rule samtools_index:
    input:
        "rmduped_reads/{sample}.bam"
    output:
        "rmduped_reads/{sample}.bam.bai"
    shell:
        "samtools index {input}"

rule GATK_raw_calling:
    input:
        bam="rmduped_reads/{sample}.bam",
        bai="rmduped_reads/{sample}.bam.bai",
        genome="data/genome.fasta"
    output:
        "Raw_calling/{sample}.g.vcf",
    shell:
        "java -Xmx4g -jar /home/alexandre/GenomeAnalysisTK-3.7/GenomeAnalysisTK.jar -ploidy 2 --emitRefConfidence GVCF -T HaplotypeCaller -R {input.genome} -I {input.bam} --genotyping_mode DISCOVERY -o {output}"
```

<p>These rules work fine. For example, if I have the files :
    Cla001d_S281_L001_R1_001.fastq.gz
    Cla001d_S281_L001_R2_001.fastq.gz</p>

<p>I can create one bam file (<code>Cla001d_S281_L001_001.bam</code>) and from that bam file create a GVCF file (<code>Cla001d_S281_L001_001.g.vcf</code>). I have a lot of sample like this one, and I need to create one GVCF file for each, and then merge these GVCF files into one file. The problem is that I'm unable to give the list of the file to merge to the following rule:</p>

<pre class="lang-python prettyprint-override"><code>rule GATK_merge:
    input:
        ???
    output:
        "merge_calling.g.vcf"
    shell:
        "java -Xmx4g -jar /home/alexandre/GenomeAnalysisTK-3.7/GenomeAnalysisTK.jar "
        "-T CombineGVCFs "
        "-R data/genome.fasta "
        "--variant {input} "
        "-o {output}"
</code>```

I tried several things in order to do that, but cannot succeed. The problem is the link between the two rules (GATK_raw_calling and GATK_merge that is supposed to merge the output of GATK_raw_calling). I can't output one single file if I'm specifying the output of GATK_raw_calling as the input of the following rule (Wildcards in input files cannot be determined from output files), and  I'm unable to make a link between the two rules if I'm not specifying these files as an input...

Is there a way to succeed in doing that? The difficulty is that I'm not defining a list of names or whatever, I think.

Thanks you in advance for your help.

答:
You can try to generate a list of sample IDs using glob_wildcards on the initial fastq.gz files:

sample_ids, run_ids = glob_wildcards("data/Raw_reads/{sample}_R1_{run}.fastq.gz")
```

<p>Then, you can use this to <code>expand</code> the input of <code>GATK_merge</code>:</p>

<pre class="lang-python prettyprint-override"><code>rule GATK_merge:
    input:
        expand("Raw_calling/{sample}_{run}.g.vcf",
               sample=sample_ids, run=run_ids)
</code>```

If the same run ID always come with the same sample ID, you will need to zip instead of expanding, in order to avoid non-existing combinations:

rule GATK_merge:
    input:
        ["Raw_calling/{sample}_{run}.g.vcf".format(
            sample=sample_id,
            run=run_id) for sample_id, run_id in zip(sample_ids, run_ids)]
```

Body:
I'm using snakemake for the first time in order to build a basic pipeline using cutadapt, bwa and GATK (trimming ; mapping ; calling). I would like to run this pipeline on every fastq file contained in a directory, without having to specify their name or whatever in the snakefile or in the config file. I would like to succeed in doing this.

The first two steps (cutadapt and bwa / trimming and mapping) are running fine, but I'm encountering some problems with GATK.

First, I have to generate g.vcf files from bam files. I'm doing this using these rules:

configfile: "config.yaml"

import os
import glob

rule all:
    input:
        "merge_calling.g.vcf"

rule cutadapt:
    input:
        read="data/Raw_reads/{sample}_R1_{run}.fastq.gz",
        read2="data/Raw_reads/{sample}_R2_{run}.fastq.gz"
    output:
        R1=temp("trimmed_reads/{sample}_R1_{run}.fastq.gz"),
        R2=temp("trimmed_reads/{sample}_R2_{run}.fastq.gz")
    threads:
        10
    shell:
        "cutadapt -q {config[Cutadapt][Quality_value]} -m {config[Cutadapt][min_length]} -a {config[Cutadapt][forward_adapter]} -A  {config[Cutadapt][reverse_adapter]} -o {output.R1} -p '{output.R2}' {input.read} {input.read2}"

rule bwa_map:
    input:
        genome="data/genome.fasta",
        read=expand("trimmed_reads/{{sample}}_{pair}_{{run}}.fastq.gz", pair=["R1", "R2"])
    output:
        temp("mapped_bam/{sample}_{run}.bam")
    threads:
        10
    params:
        rg="@RG\\tID:{sample}\\tPL:ILLUMINA\\tSM:{sample}"
    shell:
        "bwa mem -t 2 -R '{params.rg}' {input.genome} {input.read} | samtools view -Sb - > {output}"

rule picard_sort:
    input:
        "mapped_bam/{sample}.bam"
    output:
        "sorted_reads/{sample}.bam"
    shell:
        "java -Xmx4g -jar /home/alexandre/picard-tools/picard.jar SortSam I={input} O={output} SO=coordinate VALIDATION_STRINGENCY=SILENT"

rule picard_rmdup:
    input:
        bam="sorted_reads/{sample}.bam"
    output:
        "rmduped_reads/{sample}.bam",
        "picard_stats/{sample}.bam"
    params:
        reads="rmduped_reads/{sample}.bam",
        stats="picard_stats/{sample}.bam",
    shell:
        "java -jar -Xmx2g /home/alexandre/picard-tools/picard.jar MarkDuplicates "
        "I={input.bam} "
        "O='{params.reads}' "
        "VALIDATION_STRINGENCY=SILENT "
        "MAX_FILE_HANDLES_FOR_READ_ENDS_MAP=1000 "
        "REMOVE_DUPLICATES=TRUE "
        "M='{params.stats}'"

rule samtools_index:
    input:
        "rmduped_reads/{sample}.bam"
    output:
        "rmduped_reads/{sample}.bam.bai"
    shell:
        "samtools index {input}"

rule GATK_raw_calling:
    input:
        bam="rmduped_reads/{sample}.bam",
        bai="rmduped_reads/{sample}.bam.bai",
        genome="data/genome.fasta"
    output:
        "Raw_calling/{sample}.g.vcf",
    shell:
        "java -Xmx4g -jar /home/alexandre/GenomeAnalysisTK-3.7/GenomeAnalysisTK.jar -ploidy 2 --emitRefConfidence GVCF -T HaplotypeCaller -R {input.genome} -I {input.bam} --genotyping_mode DISCOVERY -o {output}"

These rules work fine. For example, if I have the files :
    Cla001d_S281_L001_R1_001.fastq.gz
    Cla001d_S281_L001_R2_001.fastq.gz

I can create one bam file (Cla001d_S281_L001_001.bam) and from that bam file create a GVCF file (Cla001d_S281_L001_001.g.vcf). I have a lot of sample like this one, and I need to create one GVCF file for each, and then merge these GVCF files into one file. The problem is that I'm unable to give the list of the file to merge to the following rule:

rule GATK_merge:
    input:
        ???
    output:
        "merge_calling.g.vcf"
    shell:
        "java -Xmx4g -jar /home/alexandre/GenomeAnalysisTK-3.7/GenomeAnalysisTK.jar "
        "-T CombineGVCFs "
        "-R data/genome.fasta "
        "--variant {input} "
        "-o {output}"

I tried several things in order to do that, but cannot succeed. The problem is the link between the two rules (GATK_raw_calling and GATK_merge that is supposed to merge the output of GATK_raw_calling). I can't output one single file if I'm specifying the output of GATK_raw_calling as the input of the following rule (Wildcards in input files cannot be determined from output files), and  I'm unable to make a link between the two rules if I'm not specifying these files as an input...

Is there a way to succeed in doing that? The difficulty is that I'm not defining a list of names or whatever, I think.

Thanks you in advance for your help.

Body:
You can try to generate a list of sample IDs using glob_wildcards on the initial fastq.gz files:

sample_ids, run_ids = glob_wildcards("data/Raw_reads/{sample}_R1_{run}.fastq.gz")

Then, you can use this to expand the input of GATK_merge:

rule GATK_merge:
    input:
        expand("Raw_calling/{sample}_{run}.g.vcf",
               sample=sample_ids, run=run_ids)

If the same run ID always come with the same sample ID, you will need to zip instead of expanding, in order to avoid non-existing combinations:

rule GATK_merge:
    input:
        ["Raw_calling/{sample}_{run}.g.vcf".format(
            sample=sample_id,
            run=run_id) for sample_id, run_id in zip(sample_ids, run_ids)]


问:
How to add date time values in csv from json using python?
I am trying to convert a nested json with multiple arrays and object jsons into CSV file using python. I tried many methods somehow i got the csvfile with only 1 array. I want to print the many filters which has unique values inside , so i am not able to print the 2nd arrays with cost, my sample json as below :

SAMPLE JSON:

```<code>     {
    "breakdown":[
     {
     "filter":"tags",
     "cost":5517.734,
     "values":[
        {
           "count":13,
           "subvalues":[
              {
                 "count":1,
                 "subvalue":"BizOps-VM-20",
                 "cost":227.576
                  {
                 "count":4,
                 "subvalue":"<nulltagvalue>",
                 "cost":70.358
              },
                 "subvalues":[
              {
                 "count":2,
                 "subvalue":"cb",
                 "cost":4.584
              }
           ],
           "cost":4.584,
           "value":"TagNewForTestw"
           }
           ]
           },
             {
        "filter":"account",
        "cost":2954.905,
        "values":[
        {
           "count":86,
           "cost":1613.508,
           "value":"628455167342"
         },]
         },
       "time":[
        {
        "cost":112.793,
       "time":"2017-05-16"
       },
      {
      "cost":112.748,
     "time":"2017-05-17"
        },
        {
       "cost":112.739,
       "time":"2017-05-18"
       },
      ]
</code>```

now here i have time array where time and cost is in json i want this to print in csv using python code , but when trying to print i am getting ###### format in place of time values. and one more thing is that i am getting repeated time values printed even after the end of array time.

My python code :

```<code>      import json
      import csv
      import time
      f = open('cost_drilldown_data.json')
      data = json.load(f)
      s=csv.writer(open('cd13old.csv','w'))
      s.writerow(["filter","cost","value","cost","subvalue","cost"])
      i=0
      for breakdown in data['breakdown']:
           for values in breakdown['values']:
              if 'subvalues' in values:
                  for subvalues in values['subvalues']:
                      for time in data['time']:
                        s.writerow([breakdown['filter'],breakdown["cost"],
                       values['value'],values['cost'],subvalues["subvalue"],
                       subvalues["cost"],time['time'],time['cost']])
              else :
      s.writerow([breakdown['filter'],"","",values['value'],values['cost']])
</code>```

The output is :

```<code>filter,cost,value,cost,subvalue,cost,time,cost
</code>```

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-16,112.793

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-17,112.748

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-18,112.739

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-19,107.165

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-20,89.988

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-21,88.773

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-22,96.591

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-23,104.809

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-24,104.471

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-25,104.472

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-26,103.536

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-27,83.205

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-28,83.103

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-29,83.111

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-30,84.555

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-31,86.986

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-06-01,103.024

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-06-02,100.905

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-06-03,102.062

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-06-04,105.243

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-06-05,105.134

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-06-06,111.764

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-06-07,107.455

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-06-08,107.62

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-06-09,107.61

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-06-10,102.53

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-06-11,102.282

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-06-12,105.52

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-06-13,93.617

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-06-14,41.094

tags,5517.734,Name,462.62,,70.358,2017-05-16,112.793

tags,5517.734,Name,462.62,,70.358,2017-05-17,112.748

tags,5517.734,Name,462.62,,70.358,2017-05-18,112.739

its printing the values again and again , i tried using iteration but not abe to get stop the repition of values. So anybody can help or guide me here i am stuck

THE EXPECTED OUT PUT IS :

filter,cost,value,cost,subvalue,cost,time,cost

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-16,112.793
tags,5517.734,Name,462.62,,70.358,2017-05-16,112.793
tags,5517.734,Name,462.62,BizOps01,60.188,2017-06-10,102.53

答:
```<code>with open('cd13old.csv','w') as csvfile:
    s=csv.writer(csvfile)
    s.writerow(["filter","cost","value","cost","subvalue","cost"])
    for breakdown in data['breakdown']:
        for values in breakdown['values']:
            if 'subvalues' in values:
                for subvalues in values['subvalues']:
                    s.writerow([breakdown['filter'],values['value'],values['cost'],subvalues["subvalue"],subvalues["cost"]])
            else:
                s.writerow([breakdown['filter'],values['value'],values['cost'],"",""])
</code>```

Body:
I am trying to convert a nested json with multiple arrays and object jsons into CSV file using python. I tried many methods somehow i got the csvfile with only 1 array. I want to print the many filters which has unique values inside , so i am not able to print the 2nd arrays with cost, my sample json as below :

SAMPLE JSON:

     {
    "breakdown":[
     {
     "filter":"tags",
     "cost":5517.734,
     "values":[
        {
           "count":13,
           "subvalues":[
              {
                 "count":1,
                 "subvalue":"BizOps-VM-20",
                 "cost":227.576
                  {
                 "count":4,
                 "subvalue":"<nulltagvalue>",
                 "cost":70.358
              },
                 "subvalues":[
              {
                 "count":2,
                 "subvalue":"cb",
                 "cost":4.584
              }
           ],
           "cost":4.584,
           "value":"TagNewForTestw"
           }
           ]
           },
             {
        "filter":"account",
        "cost":2954.905,
        "values":[
        {
           "count":86,
           "cost":1613.508,
           "value":"628455167342"
         },]
         },
       "time":[
        {
        "cost":112.793,
       "time":"2017-05-16"
       },
      {
      "cost":112.748,
     "time":"2017-05-17"
        },
        {
       "cost":112.739,
       "time":"2017-05-18"
       },
      ]

now here i have time array where time and cost is in json i want this to print in csv using python code , but when trying to print i am getting ###### format in place of time values. and one more thing is that i am getting repeated time values printed even after the end of array time.

My python code :

      import json
      import csv
      import time
      f = open('cost_drilldown_data.json')
      data = json.load(f)
      s=csv.writer(open('cd13old.csv','w'))
      s.writerow(["filter","cost","value","cost","subvalue","cost"])
      i=0
      for breakdown in data['breakdown']:
           for values in breakdown['values']:
              if 'subvalues' in values:
                  for subvalues in values['subvalues']:
                      for time in data['time']:
                        s.writerow([breakdown['filter'],breakdown["cost"],
                       values['value'],values['cost'],subvalues["subvalue"],
                       subvalues["cost"],time['time'],time['cost']])
              else :
      s.writerow([breakdown['filter'],"","",values['value'],values['cost']])

The output is :

filter,cost,value,cost,subvalue,cost,time,cost

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-16,112.793

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-17,112.748

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-18,112.739

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-19,107.165

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-20,89.988

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-21,88.773

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-22,96.591

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-23,104.809

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-24,104.471

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-25,104.472

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-26,103.536

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-27,83.205

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-28,83.103

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-29,83.111

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-30,84.555

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-31,86.986

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-06-01,103.024

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-06-02,100.905

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-06-03,102.062

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-06-04,105.243

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-06-05,105.134

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-06-06,111.764

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-06-07,107.455

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-06-08,107.62

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-06-09,107.61

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-06-10,102.53

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-06-11,102.282

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-06-12,105.52

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-06-13,93.617

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-06-14,41.094

tags,5517.734,Name,462.62,,70.358,2017-05-16,112.793

tags,5517.734,Name,462.62,,70.358,2017-05-17,112.748

tags,5517.734,Name,462.62,,70.358,2017-05-18,112.739

its printing the values again and again , i tried using iteration but not abe to get stop the repition of values. So anybody can help or guide me here i am stuck

THE EXPECTED OUT PUT IS :

filter,cost,value,cost,subvalue,cost,time,cost

tags,5517.734,Name,462.62,BizOps-VM-20,227.576,2017-05-16,112.793
tags,5517.734,Name,462.62,,70.358,2017-05-16,112.793
tags,5517.734,Name,462.62,BizOps01,60.188,2017-06-10,102.53


问:
Make bottom borders in line according to the lowest content
I'm developing my homepage using HTML, CSS, JSP and JavaScript, about musical instrument sale and communication of people.

Currently, I'm implementing a site-map for my site's menu configuration chart using div, ul, li and h tags. I would like to create bottom borders under the lowermost submenu items (last li tags) like in the picture below (see the blue indications). They should have bottom borders in line, adjusted to the lowermost (last) li tag.

How can I achieve my goal? This is what I have so far:

#sitemap_menu_container {
  width: 980px;
  height: 200px;
  border: 1px solid violet;
}

.sitemap_menu {
  width: 150px;
  height: 180px;
  float: left;
  margin-left: 5px;
  margin-right: 5px;
  margin-bottom: 5px;
  border-bottom: 1px solid #cbcbcb;
}

.sitemap_menu_header1 {
  font-size: 15pt;
  font-family: Arial;
  padding-bottom: 7px;
  border-bottom: 1px solid #cbcbcb;
}

.sitemap_menu_header2 {
  font-size: 15pt;
  font-family: Arial;
  color: red;
  padding-bottom: 7px;
  border-bottom: 1px solid #cbcbcb;
}

.sitemap_menu ul li {
  list-style: none;
  font-size: 11pt;
  font-family: Arial;
  background: url(../images/bullet1.png)no-repeat 0px 50%;
  padding-left: 10px;
  margin-left: 10px;
  cursor: pointer;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="sitemap_menu_container">
  <div class="sitemap_menu">
    <h2 class="sitemap_menu_header1">About</h2>
    <ul>
      <li>P&G introduce</li>
      <li>P&G history</li>
      <li>location</li>
    </ul>
  </div>
  <div class="sitemap_menu">
    <h2 class="sitemap_menu_header2">Piano goods</h2>
    <ul>
      <li>All kind of piano</li>
      <li>Upright</li>
      <li>Grand</li>
      <li>Electronics</li>
      <li>Synthesizer</li>
      <li>Management Tools</li>
    </ul>
  </div>
  <div class="sitemap_menu">
    <h2 class="sitemap_menu_header1">Guitar goods</h2>
    <ul>
      <li>Acoustic</li>
      <li>Classic</li>
      <li>Electrics</li>
      <li>Ukulele</li>
      <li>Management Tools</li>
    </ul>
  </div>
  <div class="sitemap_menu">
    <h2 class="sitemap_menu_header2">Community</h2>
    <ul>
      <li>Free Board</li>
      <li>Reviews</li>
      <li>Gallery Board</li>
    </ul>
  </div>
  <div class="sitemap_menu">
    <h2 class="sitemap_menu_header1">Event</h2>
    <ul>
      <li>Ongoing Event</li>
      <li>Announcement</li>
    </ul>
  </div>
  <div class="sitemap_menu">
    <h2 class="sitemap_menu_header2">Help you</h2>
    <ul>
      <li>Guide</li>
      <li>Notice</li>
      <li>FAQ</li>
      <li>Q&A</li>
      <li>Sitemap</li>
    </ul>
  </div>
</div></code>```

答:
Just add the below css to give border-bottom to the last
 of your sub-menu

```<code>.sitemap_menu ul li:last-child{border-bottom:1px solid #000;}
</code>```

Body:
I'm developing my homepage using HTML, CSS, JSP and JavaScript, about musical instrument sale and communication of people.

Currently, I'm implementing a site-map for my site's menu configuration chart using div, ul, li and h tags. I would like to create bottom borders under the lowermost submenu items (last li tags) like in the picture below (see the blue indications). They should have bottom borders in line, adjusted to the lowermost (last) li tag.

How can I achieve my goal? This is what I have so far:

#sitemap_menu_container {
  width: 980px;
  height: 200px;
  border: 1px solid violet;
}

.sitemap_menu {
  width: 150px;
  height: 180px;
  float: left;
  margin-left: 5px;
  margin-right: 5px;
  margin-bottom: 5px;
  border-bottom: 1px solid #cbcbcb;
}

.sitemap_menu_header1 {
  font-size: 15pt;
  font-family: Arial;
  padding-bottom: 7px;
  border-bottom: 1px solid #cbcbcb;
}

.sitemap_menu_header2 {
  font-size: 15pt;
  font-family: Arial;
  color: red;
  padding-bottom: 7px;
  border-bottom: 1px solid #cbcbcb;
}

.sitemap_menu ul li {
  list-style: none;
  font-size: 11pt;
  font-family: Arial;
  background: url(../images/bullet1.png)no-repeat 0px 50%;
  padding-left: 10px;
  margin-left: 10px;
  cursor: pointer;
}

About

P&G introduce

P&G history

location

Piano goods

All kind of piano

Upright

Grand

Electronics

Synthesizer

Management Tools

Guitar goods

Acoustic

Classic

Electrics

Ukulele

Management Tools

Community

Free Board

Reviews

Gallery Board

Event

Ongoing Event

Announcement

Help you

Guide

Notice

FAQ

Q&A

Sitemap

Body:
Just add the below css to give border-bottom to the last <li> of your sub-menu

.sitemap_menu ul li:last-child{border-bottom:1px solid #000;}


问:
Clearing all cookies with JavaScript
How do you delete all the cookies for the current domain using JavaScript?</p>

答:
Jquery:

```<code>var cookies = $.cookie();
for(var cookie in cookies) {
$.removeCookie(cookie);
}
</code>```

vanilla JS

```<code>function clearListCookies()
{
 var cookies = document.cookie.split(";");
 for (var i = 0; i < cookies.length; i++)
  {
    var spcook =  cookies[i].split("=");
    deleteCookie(spcook[0]);
  }
  function deleteCookie(cookiename)
   {
    var d = new Date();
    d.setDate(d.getDate() - 1);
    var expires = ";expires="+d;
    var name=cookiename;
    //alert(name);
    var value="";
    document.cookie = name + "=" + value + expires + "; path=/acc/html";
}
window.location = ""; // TO REFRESH THE PAGE
}
</code>```

OwnerDisplayName: polarbear

Title: Clearing all cookies with JavaScript

Body:
Jquery:

var cookies = $.cookie();
for(var cookie in cookies) {
$.removeCookie(cookie);
}

vanilla JS

function clearListCookies()
{
 var cookies = document.cookie.split(";");
 for (var i = 0; i < cookies.length; i++)
  {
    var spcook =  cookies[i].split("=");
    deleteCookie(spcook[0]);
  }
  function deleteCookie(cookiename)
   {
    var d = new Date();
    d.setDate(d.getDate() - 1);
    var expires = ";expires="+d;
    var name=cookiename;
    //alert(name);
    var value="";
    document.cookie = name + "=" + value + expires + "; path=/acc/html";
}
window.location = ""; // TO REFRESH THE PAGE
}


问:
Select an element with it's background color is not working in jQuery
Please check my code. The  condition for checking the background color are not working.

https://jsfiddle.net/oL7tdL22/1/

$(function(){

$(".testing").each(function(){
   if($(this).css("background-color")=="rgb(255,193,0)"){
     alert("found");
   }
   else{
     alert("not found");
   }
  });

});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<div class="parent">
<div class="testing"  style="background-color:rgb(255,193,0)">
Test
</div>
</div>

<div class="parent">
<div class="testing"  style="background-color:rgb(220, 4, 81)">
Test
</div>
</div>

<div class="parent">
<div class="testing"  style="background-color:rgb(0, 186, 76)">
Test
</div>
</div></code>```

When we are alert background color, it's working. But we cannot match the colors.

答:
you need to give a space after each comma in rgb color code like rgb(255, 193, 0). Then it works.

$(function(){

$(".testing").each(function(){
   if($(this).css("background-color")=="rgb(255, 193, 0)"){
     alert("found");
   }
   else{
     alert("not found");
   }
  });

});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<div class="parent">
<div class="testing"  style="background-color:rgb(255,193,0)">
Test
</div>
</div>

<div class="parent">
<div class="testing"  style="background-color:rgb(220, 4, 81)">
Test
</div>
</div>

<div class="parent">
<div class="testing"  style="background-color:rgb(0, 186, 76)">
Test
</div>
</div></code>```

Body:
Please check my code. The  condition for checking the background color are not working.

https://jsfiddle.net/oL7tdL22/1/

$(function(){

$(".testing").each(function(){
   if($(this).css("background-color")=="rgb(255,193,0)"){
     alert("found");
   }
   else{
     alert("not found");
   }
  });

});

Test

Test

Test

When we are alert background color, it's working. But we cannot match the colors.

Body:
you need to give a space after each comma in rgb color code like rgb(255, 193, 0). Then it works.

$(function(){

$(".testing").each(function(){
   if($(this).css("background-color")=="rgb(255, 193, 0)"){
     alert("found");
   }
   else{
     alert("not found");
   }
  });

});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<div class="parent">
<div class="testing"  style="background-color:rgb(255,193,0)">
Test
</div>
</div>

<div class="parent">
<div class="testing"  style="background-color:rgb(220, 4, 81)">
Test
</div>
</div>

<div class="parent">
<div class="testing"  style="background-color:rgb(0, 186, 76)">
Test
</div>
</div>


问:
Pass address from one Vc to another
I'm trying to pass the address I get from the map into my other Viewcontroller and keep the same settings (i.e switch is still on)  The mapVC is named MapViewController and the tableVC is named AddTaskTableViewController.

答:
For your first question, you need to pass the data in prepareForSegue method, like this in your MapViewController

```<code>override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if let destinationViewController = segue.destination as? AddTaskTableViewController{
        destinationViewController.address = self.address// Get address from map and stored here
    }
}
</code>```

For your second question about setting, you need to save setting into UseDefaults and whenever your view controller is loaded, set value from UserDefault. Here are example code

```<code>UserDefaults.standard.set("address", forKey: "address")

UserDefaults.standard.string(forKey: "address")
</code>```

Title: Pass address from one Vc to another

Body:
For your first question, you need to pass the data in prepareForSegue method, like this in your MapViewController

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if let destinationViewController = segue.destination as? AddTaskTableViewController{
        destinationViewController.address = self.address// Get address from map and stored here
    }
}

For your second question about setting, you need to save setting into UseDefaults and whenever your view controller is loaded, set value from UserDefault. Here are example code

UserDefaults.standard.set("address", forKey: "address")

UserDefaults.standard.string(forKey: "address")


问:
run stop tomcat task if test task fails in gradle project
I am working on a gradle project. I have written few tests for it.
In build.gradle, I have written three tasks for it: tomcatStart, tomcatEnd and test.
Inside test task, i am executing tomcatStart in doFirst and tomcatStop in doLast.
It all works fine if there is no test failure.
But if a test fails, the tomcat keeps on running.

I want to know if there is any way, i can stop tomcat even if test task fails.

答:
Try to use finalizebBy property of the test task. It's well described in the official documentation. According to it:

Finalizer tasks are useful in situations where the build creates a resource that has to be cleaned up regardless of the build failing or succeeding. An example of such a resource is a web container that is started before an integration test task and which should be always shut down, even if some of the tests fail.

And here is an example from the docs:

```<code>task taskX {
    doLast {
        println 'taskX'
        throw new RuntimeException()
    }
}
task taskY {
    doLast {
        println 'taskY'
    }
}

taskX.finalizedBy taskY
</code>```

Body:
Try to use finalizebBy property of the test task. It's well described in the official documentation. According to it:

Finalizer tasks are useful in situations where the build creates a resource that has to be cleaned up regardless of the build failing or succeeding. An example of such a resource is a web container that is started before an integration test task and which should be always shut down, even if some of the tests fail.

And here is an example from the docs:

task taskX {
    doLast {
        println 'taskX'
        throw new RuntimeException()
    }
}
task taskY {
    doLast {
        println 'taskY'
    }
}

taskX.finalizedBy taskY


问:
How many users is too much when using session variables?
I'm currently using session variables as a cache to cut down the calls to the database.

I'm wondering at about how many concurrent users does this stop working at? 1,000, 10,000 ....100,000??? Also will iis start flaking out at a certain load? And are there
any alternatives?

I know it depends on how much data I'm storing per user, but I want to hear from other peoples experiences.

I do have it setup so that when the code tries to access a timed out session that it reloads from the database.

I'm currently using iis6 but I could easily use iis7 if it handles sessions better.

Edit: Yes I'm using application variables for non user specific data.

答: You should probably be looking at Memcached if you're getting to this point.</p>

OwnerDisplayName: Donny V

LastEditorDisplayName: Donny V

OwnerDisplayName: Diodeus


问:
Good Database Solutions for small-medium Traffic Sites and Silverlight
What are some good database solutions that support Silverlight and are solid for a small-medium traffic website

Easy to use/Manage is a very strong plus

edit: Forgot to mention that the database needs to be very smartphone-friendly, it needs to be able to work with devices on iOS, Android, and Windows Phone 7

答:
It depends on what you term small-medium. I would say SQL Server Express should suit your needs.

It is free, but your database size cannot be more than 10 GB. It also limits the resources that can be used from the server.

http://www.microsoft.com/express/Database/Default.aspx


问:
Call and stop a rest service with an interval of time
I need to make a rest call every x interval seconds (3000 ms) to consult the status of a webservice until i have the wanted result or until 12 times (for example) or when I receive the status expected:

function myFunction() {
    var i=0;
    var _onSuccess = function(response) {
        if (response.status=== 'READY' || i >= 12) {
            clearInterval(x);
            if(response.status !== 'READY') {
                $location.path('/errorView');
            }
        }
    }
    var x = setInterval(function () {
       $rest.getSomething(_onSuccess)
    }, 3000);
}
```

<p>I have another function that calls myFunction with a timeout because if I dont receive the expected result after 32 seconds i want to cancel stop rest call and go to an error view.</p>

```function myFunction2() {
    myFunction();
    $timeout(function () {
        $location.path('/routeWhenStatusReady');
    }, 32000);
}
```

Is there any way to improve this? I want to finish timeout myFunction2 if the Ready status is ok in 16 seconds for example and not to wait 32 seconds...

Thank you!

答:
You could set the $timeout in a variable:

var myTimeout = $timeout

and finish it with:

$timeout.cancel(myTimeout);

Body:
I need to make a rest call every x interval seconds (3000 ms) to consult the status of a webservice until i have the wanted result or until 12 times (for example) or when I receive the status expected:

function myFunction() {
    var i=0;
    var _onSuccess = function(response) {
        if (response.status=== 'READY' || i >= 12) {
            clearInterval(x);
            if(response.status !== 'READY') {
                $location.path('/errorView');
            }
        }
    }
    var x = setInterval(function () {
       $rest.getSomething(_onSuccess)
    }, 3000);
}

I have another function that calls myFunction with a timeout because if I dont receive the expected result after 32 seconds i want to cancel stop rest call and go to an error view.

function myFunction2() {
    myFunction();
    $timeout(function () {
        $location.path('/routeWhenStatusReady');
    }, 32000);
}

Is there any way to improve this? I want to finish timeout myFunction2 if the Ready status is ok in 16 seconds for example and not to wait 32 seconds...

Thank you!


问:
PHP imap_open wont connect
Trying to use the PHP function imap_open to connect to my gmail account, here is the code:

```<code>$mailboxpath = "{imap.gmail.com:993/imap/ssl}INBOX";
$username = "email@gmail.com";
$password = "password";

$imap = imap_open($mailboxpath, $username, $password);
</code>```

I am receiving the following error:

```<code>Warning: imap_open() [function.imap-open]: Couldn't open stream {imap.gmail.com:993/imap/ssl}INBOX in /websites/123reg/LinuxPackage22/sf/pa/ys/sfpayslips.info/public_html/test/index.php on line 6
</code>```

Not using XAMPP

答:
Try using a different form of account like Outlook for example. Also try this:
{mail.domain.com:143/notls}INBOX.

Title: PHP imap_open wont connect

Body:
Trying to use the PHP function imap_open to connect to my gmail account, here is the code:

$mailboxpath = "{imap.gmail.com:993/imap/ssl}INBOX";
$username = "email@gmail.com";
$password = "password";

$imap = imap_open($mailboxpath, $username, $password);

I am receiving the following error:

Warning: imap_open() [function.imap-open]: Couldn't open stream {imap.gmail.com:993/imap/ssl}INBOX in /websites/123reg/LinuxPackage22/sf/pa/ys/sfpayslips.info/public_html/test/index.php on line 6

Not using XAMPP


答:
You can use
 instead, just adjust the height of the columns

#sitemap_menu_container {
  width: 980px;
  height: 200px;
  border: 1px solid violet;
}

.sitemap_menu {
  width: 150px;
  height: 180px;
  float: left;
  margin-left: 5px;
  margin-right: 5px;
  margin-bottom: 5px;
}

.sitemap_menu_header1 {
  font-size: 15pt;
  font-family: Arial;
  padding-bottom: 7px;
  border-bottom: 1px solid #cbcbcb;
}

.sitemap_menu_header2 {
  font-size: 15pt;
  font-family: Arial;
  color: red;
  padding-bottom: 7px;
  border-bottom: 1px solid #cbcbcb;
}

.sitemap_menu ul li {
  list-style: none;
  font-size: 11pt;
  font-family: Arial;
  background: url(../images/bullet1.png)no-repeat 0px 50%;
  padding-left: 10px;
  margin-left: 10px;
  cursor: pointer;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="sitemap_menu_container">
  <div class="sitemap_menu">
    <h2 class="sitemap_menu_header1">About</h2>
    <ul>
      <li>P&G introduce</li>
      <li>P&G history</li>
      <li>location</li>
    </ul>
    <hr>
  </div>
  <div class="sitemap_menu">
    <h2 class="sitemap_menu_header2">Piano goods</h2>
    <ul>
      <li>All kind of piano</li>
      <li>Upright</li>
      <li>Grand</li>
      <li>Electronics</li>
      <li>Synthesizer</li>
      <li>Management Tools</li>
    </ul>
    <hr>
  </div>
  <div class="sitemap_menu">
    <h2 class="sitemap_menu_header1">Guitar goods</h2>
    <ul>
      <li>Acoustic</li>
      <li>Classic</li>
      <li>Electrics</li>
      <li>Ukulele</li>
      <li>Management Tools</li>
    </ul>
    <hr>
  </div>
  <div class="sitemap_menu">
    <h2 class="sitemap_menu_header2">Community</h2>
    <ul>
      <li>Free Board</li>
      <li>Reviews</li>
      <li>Gallery Board</li>
    </ul>
    <hr>
  </div>
  <div class="sitemap_menu">
    <h2 class="sitemap_menu_header1">Event</h2>
    <ul>
      <li>Ongoing Event</li>
      <li>Announcement</li>
    </ul>
    <hr>
  </div>
  <div class="sitemap_menu">
    <h2 class="sitemap_menu_header2">Help you</h2>
    <ul>
      <li>Guide</li>
      <li>Notice</li>
      <li>FAQ</li>
      <li>Q&A</li>
      <li>Sitemap</li>
    </ul>
    <hr>
  </div>
</div></code>```

Title: Make bottom borders in line according to the lowest content

Body:
You can use <hr> instead, just adjust the height of the columns

#sitemap_menu_container {
  width: 980px;
  height: 200px;
  border: 1px solid violet;
}

.sitemap_menu {
  width: 150px;
  height: 180px;
  float: left;
  margin-left: 5px;
  margin-right: 5px;
  margin-bottom: 5px;
}

.sitemap_menu_header1 {
  font-size: 15pt;
  font-family: Arial;
  padding-bottom: 7px;
  border-bottom: 1px solid #cbcbcb;
}

.sitemap_menu_header2 {
  font-size: 15pt;
  font-family: Arial;
  color: red;
  padding-bottom: 7px;
  border-bottom: 1px solid #cbcbcb;
}

.sitemap_menu ul li {
  list-style: none;
  font-size: 11pt;
  font-family: Arial;
  background: url(../images/bullet1.png)no-repeat 0px 50%;
  padding-left: 10px;
  margin-left: 10px;
  cursor: pointer;
}

<div id="sitemap_menu_container">
  <div class="sitemap_menu">
    <h2 class="sitemap_menu_header1">About</h2>
    <ul>
      <li>P&G introduce</li>
      <li>P&G history</li>
      <li>location</li>
    </ul>
    <hr>
  </div>
  <div class="sitemap_menu">
    <h2 class="sitemap_menu_header2">Piano goods</h2>
    <ul>
      <li>All kind of piano</li>
      <li>Upright</li>
      <li>Grand</li>
      <li>Electronics</li>
      <li>Synthesizer</li>
      <li>Management Tools</li>
    </ul>
    <hr>
  </div>
  <div class="sitemap_menu">
    <h2 class="sitemap_menu_header1">Guitar goods</h2>
    <ul>
      <li>Acoustic</li>
      <li>Classic</li>
      <li>Electrics</li>
      <li>Ukulele</li>
      <li>Management Tools</li>
    </ul>
    <hr>
  </div>
  <div class="sitemap_menu">
    <h2 class="sitemap_menu_header2">Community</h2>
    <ul>
      <li>Free Board</li>
      <li>Reviews</li>
      <li>Gallery Board</li>
    </ul>
    <hr>
  </div>
  <div class="sitemap_menu">
    <h2 class="sitemap_menu_header1">Event</h2>
    <ul>
      <li>Ongoing Event</li>
      <li>Announcement</li>
    </ul>
    <hr>
  </div>
  <div class="sitemap_menu">
    <h2 class="sitemap_menu_header2">Help you</h2>
    <ul>
      <li>Guide</li>
      <li>Notice</li>
      <li>FAQ</li>
      <li>Q&A</li>
      <li>Sitemap</li>
    </ul>
    <hr>
  </div>
</div>


问:
DateTime.ParseExact returns wrong date for the 'dd/MM/yyyy h:mm tt' format
I need to convert datetime from MM/dd/yyyy h:mm:ss tt format to the dd/MM/yyyy h:mm:ss tt

My code

```<code> var date = ((DateTime)model.WorkshopDate).ToString("dd/MM/yyyy h:mm:ss tt");

 var resultDate = DateTime.ParseExact(date, "dd/MM/yyyy h:mm:ss tt", CultureInfo.InvariantCulture);
</code>```

In result date = 25/12/2017 12:00:00 AM

But resultDate = 12/25/2017 12:00:00 AM .

How can i parse it right?

答:
You don't need to convert it to a String and back to a DateTime. The resulting DateTime object should have the same Date. You just need to convert it when you want to display it somewhere:

```<code>((DateTime)model.WorkshopDate).ToString("dd/MM/yyyy h:mm:ss tt");
</code>```

Body:
I need to convert datetime from MM/dd/yyyy h:mm:ss tt format to the dd/MM/yyyy h:mm:ss tt

My code

 var date = ((DateTime)model.WorkshopDate).ToString("dd/MM/yyyy h:mm:ss tt");

 var resultDate = DateTime.ParseExact(date, "dd/MM/yyyy h:mm:ss tt", CultureInfo.InvariantCulture);

In result date = 25/12/2017 12:00:00 AM

But resultDate = 12/25/2017 12:00:00 AM .

How can i parse it right?

Body:
You don't need to convert it to a String and back to a DateTime. The resulting DateTime object should have the same Date. You just need to convert it when you want to display it somewhere:

((DateTime)model.WorkshopDate).ToString("dd/MM/yyyy h:mm:ss tt");


问:
MS Access SQL: Troubles combining UNION ALL with a LEFT JOIN
I have created a query in MS Access to simulate a FULL OUTER JOIN and combine the results that looks something like the following:

```<code>SELECT NZ(estimates.employee_id, actuals.employee_id) AS employee_id
, NZ(estimates.a_date, actuals.a_date) AS a_date
, estimates.estimated_hours
, actuals.actual_hours
FROM (SELECT *
      FROM estimates
      LEFT JOIN actuals ON estimates.employee_id = actuals.employee_id
         AND estimates.a_date = actuals.a_date
      UNION ALL
      SELECT *
      FROM estimates
      RIGHT JOIN actuals ON estimates.employee_id = actuals.employee_id
         AND estimates.a_date = actuals.a_date
      WHERE estimates.employee_id IS NULL
         OR estimates.a_date IS NULL) AS qFullJoinEstimatesActuals
</code>```

I have saved this query as an object (let's call it qEstimatesAndActuals).  My objective is to LEFT JOIN qEstimatesAndActuals with another table.  Something like the following:

```<code>SELECT *
FROM qJoinedTable
LEFT JOIN (SELECT *
           FROM labor_rates) AS rates
ON qJoinedTable.employee_id = rates.employee_id
   AND qJoinedTable.a_date BETWEEN rates.begin_date AND rates.end_date
</code>```

MS Access accepts the syntax and runs the query, but it omits results that are clearly within the result set.  Wondering if the date format was somehow lost, I placed a FORMAT around the begin_date and end_date to force them to be interpreted as Short Dates.  Oddly, this produced a different result set, but it still omitted result that it shouldn't have.

I am wondering if the queries are performed in such a way that you can't LEFT JOIN the result set of a UNION ALL.  Does anyone have any thoughts/ideas on this?  Is there a better way of accomplishing the end goal?

答:
You can find exactly how to do this here.

You're missing an INNER JOIN.... UNION ALL step.

Body:
I have created a query in MS Access to simulate a FULL OUTER JOIN and combine the results that looks something like the following:

SELECT NZ(estimates.employee_id, actuals.employee_id) AS employee_id
, NZ(estimates.a_date, actuals.a_date) AS a_date
, estimates.estimated_hours
, actuals.actual_hours
FROM (SELECT *
      FROM estimates
      LEFT JOIN actuals ON estimates.employee_id = actuals.employee_id
         AND estimates.a_date = actuals.a_date
      UNION ALL
      SELECT *
      FROM estimates
      RIGHT JOIN actuals ON estimates.employee_id = actuals.employee_id
         AND estimates.a_date = actuals.a_date
      WHERE estimates.employee_id IS NULL
         OR estimates.a_date IS NULL) AS qFullJoinEstimatesActuals

I have saved this query as an object (let's call it qEstimatesAndActuals).  My objective is to LEFT JOIN qEstimatesAndActuals with another table.  Something like the following:

SELECT *
FROM qJoinedTable
LEFT JOIN (SELECT *
           FROM labor_rates) AS rates
ON qJoinedTable.employee_id = rates.employee_id
   AND qJoinedTable.a_date BETWEEN rates.begin_date AND rates.end_date

MS Access accepts the syntax and runs the query, but it omits results that are clearly within the result set.  Wondering if the date format was somehow lost, I placed a FORMAT around the begin_date and end_date to force them to be interpreted as Short Dates.  Oddly, this produced a different result set, but it still omitted result that it shouldn't have.

I am wondering if the queries are performed in such a way that you can't LEFT JOIN the result set of a UNION ALL.  Does anyone have any thoughts/ideas on this?  Is there a better way of accomplishing the end goal?


问:
VB.net GROUP By Date ignore time
Currently trying to group by date but ignoring the time thats presented it as my dgv groups it by the time aswell, i've looked around and am struggling to adapt to work. This is the original code that works but groups by date/time.

```<code>Dim sql2
    Try

        connect()
        sql2 = "SELECT r_datetime, SUM(r_quantity) FROM [r_repair] WHERE r_location = 'CNV' AND r_line =('" & computer_line & "') AND r_datetime >= @startdata2 AND r_datetime < @enddata2 AND r_area = 'DPMO(T)' GROUP BY r_datetime"
        Dim adapter2 As New SqlDataAdapter(sql2, con)

        With adapter2.SelectCommand.Parameters
            .Clear()

            .Add("@startdata2", SqlDbType.DateTime).Value = monthly_from.Value
            .Add("@enddata2", SqlDbType.DateTime).Value = monthly_to.Value.AddDays(1)
        End With

        Dim table_stencil As New DataTable()
        table_stencil.Locale = System.Globalization.CultureInfo.InvariantCulture
        adapter2.Fill(table_stencil)
        Me.bs_m_t.DataSource = table_stencil

        dgv_m_t.DataSource = bs_m_t

        disconnect()

        dgv_m_t.RowHeadersWidth = "28"

        dgv_m_t.Columns(0).HeaderText = "Date:"
        dgv_m_t.Columns(1).HeaderText = "Quantity:"

        dgv_m_t.EnableHeadersVisualStyles = False

    Catch ex As System.Exception
    End Try
</code>```

Any idea's?

Cheers,
Pete

答: Use CONVERT(DATE, r_datetime). The date datatype doesn't have a time component.

Title: VB.net GROUP By Date ignore time

Body:
Currently trying to group by date but ignoring the time thats presented it as my dgv groups it by the time aswell, i've looked around and am struggling to adapt to work. This is the original code that works but groups by date/time.

Dim sql2
    Try

        connect()
        sql2 = "SELECT r_datetime, SUM(r_quantity) FROM [r_repair] WHERE r_location = 'CNV' AND r_line =('" & computer_line & "') AND r_datetime >= @startdata2 AND r_datetime < @enddata2 AND r_area = 'DPMO(T)' GROUP BY r_datetime"
        Dim adapter2 As New SqlDataAdapter(sql2, con)

        With adapter2.SelectCommand.Parameters
            .Clear()

            .Add("@startdata2", SqlDbType.DateTime).Value = monthly_from.Value
            .Add("@enddata2", SqlDbType.DateTime).Value = monthly_to.Value.AddDays(1)
        End With

        Dim table_stencil As New DataTable()
        table_stencil.Locale = System.Globalization.CultureInfo.InvariantCulture
        adapter2.Fill(table_stencil)
        Me.bs_m_t.DataSource = table_stencil

        dgv_m_t.DataSource = bs_m_t

        disconnect()

        dgv_m_t.RowHeadersWidth = "28"

        dgv_m_t.Columns(0).HeaderText = "Date:"
        dgv_m_t.Columns(1).HeaderText = "Quantity:"

        dgv_m_t.EnableHeadersVisualStyles = False

    Catch ex As System.Exception
    End Try

Any idea's?

Cheers,
Pete


问:
Swisscom Appcloud S3 Connection reset by peer
We have a Django Webservice that uses Swisscom AppCloud's S3 solution. So far we had no problems, but without changing anything on the application we are experiencing ConnectionError: ('Connection aborted.', error(104, 'Connection reset by peer')) errors when we are trying to upload files. We are using boto3 1.4.4.

Edit:

The error occures after somwhere between 10 and 30s. When I try from my local development machine it works.

```<code>from django.conf import settings
from boto3 import session
from botocore.exceptions import ClientError

class S3Client(object):

    def __init__(self):
        s3_session = session.Session()

        self.s3_client = s3_session.client(
            service_name='s3',
            aws_access_key_id=settings.AWS_ACCESS_KEY,
            aws_secret_access_key=settings.AWS_SECRET_ACCESS_KEY,
            endpoint_url=settings.S3_ENDPOINT,
        )

    .
    .
    .

    def add_file(self, bucket, fileobj, file_name):
        self.s3_client.upload_fileobj(fileobj, bucket, file_name)

        url = self.s3_client.generate_presigned_url(
            ClientMethod='get_object',
            Params={
                'Bucket': bucket,
                'Key': file_name
            },
            ExpiresIn=60*24*356*10  # signed for 10 years. Should be enough..
        )

        url, signature = self._split_signed_url(url)

        return url, signature, file_name
</code>```

Could this be a version problem or anything else on our side?

Edit:
Made some tests with s3cmd: I can list the buckets I have access to but for all other commands like listing all objects or just listing the objects in a bucket I get a Retrying failed request: / ([Errno 54] Connection reset by peer)

答:
After some investigation I found the error:

Swisscom's implementation of S3 is somehow not up-to-date with Amazon's. To solve the problem I had to downgrade botocore from 1.5.78 to 1.5.62.

Body:
We have a Django Webservice that uses Swisscom AppCloud's S3 solution. So far we had no problems, but without changing anything on the application we are experiencing ConnectionError: ('Connection aborted.', error(104, 'Connection reset by peer')) errors when we are trying to upload files. We are using boto3 1.4.4.

Edit:

The error occures after somwhere between 10 and 30s. When I try from my local development machine it works.

from django.conf import settings
from boto3 import session
from botocore.exceptions import ClientError

class S3Client(object):

    def __init__(self):
        s3_session = session.Session()

        self.s3_client = s3_session.client(
            service_name='s3',
            aws_access_key_id=settings.AWS_ACCESS_KEY,
            aws_secret_access_key=settings.AWS_SECRET_ACCESS_KEY,
            endpoint_url=settings.S3_ENDPOINT,
        )

    .
    .
    .

    def add_file(self, bucket, fileobj, file_name):
        self.s3_client.upload_fileobj(fileobj, bucket, file_name)

        url = self.s3_client.generate_presigned_url(
            ClientMethod='get_object',
            Params={
                'Bucket': bucket,
                'Key': file_name
            },
            ExpiresIn=60*24*356*10  # signed for 10 years. Should be enough..
        )

        url, signature = self._split_signed_url(url)

        return url, signature, file_name

Could this be a version problem or anything else on our side?

Edit:
Made some tests with s3cmd: I can list the buckets I have access to but for all other commands like listing all objects or just listing the objects in a bucket I get a Retrying failed request: / ([Errno 54] Connection reset by peer)


问:
Plot an imshow graph with axes limits beyond the end of the data sets
I have a 2d matrix which corresponds to time (columns) and height (rows). I've managed to get it to plot using imshow just fine (with time on the x axis and height on the y axis), however I will be plotting a number of days, some of which will not have 24hrs worth of data. For the days with less than 24hrs of data, I would still like them to plot on a 24hr time axis with the data plotting starting from their start time on the x axis.

I have tried plotting this on pcolormesh which didn't resolve the problem, and also to plot a plt.plot over the top with all the time values and height values of nan.

I also tried changing the extent to a time base, based off 24/(the difference in time steps), but that didn't have an affect either. Below is the code I am using as well as a sample data set to show the format of my data;

```<code>time = [0.01649999991059303, 0.02584999985992908]
rdata = [-600.020751953125, -570.04150390625, -540.062255859375, -510.0830078125, -480.1037902832031, -450.1245422363281, -420.1452941894531, -390.1660461425781, -360.1867980957031, -330.2075500488281]
intensity = [[-37.32464981079102, -38.3233528137207], [-37.70231628417969, -38.05134201049805], [-38.27889251708984, -38.82979583740234], [-28.01022720336914, -27.68825912475586], [-8.408446311950684, -8.440451622009277], [-8.749446868896484, -8.750232696533203], [-9.431790351867676, -9.41820240020752], [-10.09048461914062, -10.23848724365234], [-10.84317588806152, -10.84869194030762], [-11.61933135986328, -11.67543029785156]]

t_start = time[0]
t_end = time[-1]
r_start = rdata[0]
r_end = rdata[-1]

fig = plt.figure(figsize=[8,5])
X,Y = meshgrid(time,rdata)
#plt.pcolormesh(X,Y, intensity, norm=None)
plt.imshow(intensity,aspect='auto',origin='lower',extent=[t_start,t_end,r_start,r_end])
plt.colorbar()
plt.show()
</code>```

Any help with this would be greatly appreciated!

答:
can't you simply change the range of X values shown on the x-axis?

```<code>plt.xlim([0,0.035])
</code>```

Body:
I have a 2d matrix which corresponds to time (columns) and height (rows). I've managed to get it to plot using imshow just fine (with time on the x axis and height on the y axis), however I will be plotting a number of days, some of which will not have 24hrs worth of data. For the days with less than 24hrs of data, I would still like them to plot on a 24hr time axis with the data plotting starting from their start time on the x axis.

I have tried plotting this on pcolormesh which didn't resolve the problem, and also to plot a plt.plot over the top with all the time values and height values of nan.

I also tried changing the extent to a time base, based off 24/(the difference in time steps), but that didn't have an affect either. Below is the code I am using as well as a sample data set to show the format of my data;

time = [0.01649999991059303, 0.02584999985992908]
rdata = [-600.020751953125, -570.04150390625, -540.062255859375, -510.0830078125, -480.1037902832031, -450.1245422363281, -420.1452941894531, -390.1660461425781, -360.1867980957031, -330.2075500488281]
intensity = [[-37.32464981079102, -38.3233528137207], [-37.70231628417969, -38.05134201049805], [-38.27889251708984, -38.82979583740234], [-28.01022720336914, -27.68825912475586], [-8.408446311950684, -8.440451622009277], [-8.749446868896484, -8.750232696533203], [-9.431790351867676, -9.41820240020752], [-10.09048461914062, -10.23848724365234], [-10.84317588806152, -10.84869194030762], [-11.61933135986328, -11.67543029785156]]

t_start = time[0]
t_end = time[-1]
r_start = rdata[0]
r_end = rdata[-1]

fig = plt.figure(figsize=[8,5])
X,Y = meshgrid(time,rdata)
#plt.pcolormesh(X,Y, intensity, norm=None)
plt.imshow(intensity,aspect='auto',origin='lower',extent=[t_start,t_end,r_start,r_end])
plt.colorbar()
plt.show()

Any help with this would be greatly appreciated!

Body:
can't you simply change the range of X values shown on the x-axis?

plt.xlim([0,0.035])


问:
On-Behalf-Of Azure Mobile backend - MS Graph
Another attempt to ask a different question surrounding my month long problem:

I'm now trying to initiate the "On-Behalf-Of" flow to get a MS Graph token when users login with a Microsoft Account. As documented here:
https://learn.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-protocols-oauth-on-behalf-of

On the client, users log in with a server-flow:

```<code>var user = await MobileService.LoginAsync(MobileServiceAuthenticationProvider.MicrosoftAccount);
</code>```

On the .NET backend, I am trying to retrieve the MS Graph token:

```<code>string clientId = "id-shown-in-app-registration-portal";
string clientSecret = "secret-shown-in-app-registration-portal";
IEnumerable<string> msIdTokenOut = null;
Request.Headers.TryGetValues("x-ms-token-microsoftaccount-access-token", out msIdTokenOut);
string msIdToken = msIdTokenOut.FirstOrDefault();
AuthenticationContext authContext = new AuthenticationContext("https://login.microsoftonline.com/common/oauth2/v2.0");
UserAssertion assertion = new UserAssertion(msIdToken);
ClientCredential cred = new ClientCredential(clientId, clientSecret);
AuthenticationResult authResult = await authContext.AcquireTokenAsync("https://graph.microsoft.com/", cred, assertion);
</code>```

I get the following error:
aadsts50027: invalid jwt token. token format not valid.

I've tried every possible combination, from using server-flow to login, using MSAL for client-flow (which doesn't authenticate against App Services with the retrieved token). This has been driving me crazy for over a month. I can't believe how many hoops I have jumped through to get 2 Microsoft products working together. If anyone can steer me towards a solution I would be beyond grateful.

答:
Here is a workaround, I suggest you could enable the mobile server custom authentication by using MSAL returned access token.

More details, you could refer to below steps:

Firstly, you could create a login page which will use MSAL login with the microsoft account. It will return the access token.

Then you could send the request with the access token to the mobile service backend to ask for authentication.

Notice: The logic in the backend which used to check the access token is right, you need achieve by yourself. You could decode the access jwt token to get the aud value. If this value is as same as the client id that means the user have the permission to access mobile backend data.

Then you could use jwt token to get the user information from graph api. After get the user information, you could set the user information value to claims to generate the auth token(using this method AppServiceLoginHandler.CreateToken[Add Microsoft.Azure.Mobile.Server.Login NuGet package]). By using this token the mobile client user could access the mobile backend.

The access token like this:

More details, you could refer to this article to know how to enable custom auth in mobile backend.

Body:
Another attempt to ask a different question surrounding my month long problem:

I'm now trying to initiate the "On-Behalf-Of" flow to get a MS Graph token when users login with a Microsoft Account. As documented here:
https://learn.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-protocols-oauth-on-behalf-of

On the client, users log in with a server-flow:

var user = await MobileService.LoginAsync(MobileServiceAuthenticationProvider.MicrosoftAccount);

On the .NET backend, I am trying to retrieve the MS Graph token:

string clientId = "id-shown-in-app-registration-portal";
string clientSecret = "secret-shown-in-app-registration-portal";
IEnumerable<string> msIdTokenOut = null;
Request.Headers.TryGetValues("x-ms-token-microsoftaccount-access-token", out msIdTokenOut);
string msIdToken = msIdTokenOut.FirstOrDefault();
AuthenticationContext authContext = new AuthenticationContext("https://login.microsoftonline.com/common/oauth2/v2.0");
UserAssertion assertion = new UserAssertion(msIdToken);
ClientCredential cred = new ClientCredential(clientId, clientSecret);
AuthenticationResult authResult = await authContext.AcquireTokenAsync("https://graph.microsoft.com/", cred, assertion);

I get the following error:
aadsts50027: invalid jwt token. token format not valid.

I've tried every possible combination, from using server-flow to login, using MSAL for client-flow (which doesn't authenticate against App Services with the retrieved token). This has been driving me crazy for over a month. I can't believe how many hoops I have jumped through to get 2 Microsoft products working together. If anyone can steer me towards a solution I would be beyond grateful.


问:
vba kill a file using a variable
I have written code which stores the original file which is opened, as the variable fileName and this is used to save a new version of the file with a slightly different name. I have written the code to kill the original file but its not behaving quite as it should.

I am getting file not found on the kill line.

```<code> 'Deletes the original copy
  Kill "S:\MERIT OUTPUTS FOLDER\MSI Recruitment Limited\" & fileName &
  ".txt"

   Sub BACSConversion()

   Dim MyNewBook As String
   Dim MySaveFile As String
   Dim fileToOpen As Variant
   Dim fileName As String
   Dim sheetName As String
   Dim rCopy As Range

  'Turn off display alerts
   Application.DisplayAlerts = False
  'Turn off screen updates
   Application.ScreenUpdating = False

   'Ensures that the file open directory is always the same
   ChDir "S:\MERIT OUTPUTS FOLDER\MSI Recruitment Limited\"

  'Opens the folder to location to select txt file
   fileToOpen = Application.GetOpenFilename("Text Files (*.txt), *.txt")
    If fileToOpen <> False Then
    Workbooks.OpenText fileName:=fileToOpen, _
    DataType:=xlDelimited, Tab:=True
    End If
'Creates the file name based on txt file name
fileName = Mid(fileToOpen, InStrRev(fileToOpen, "\") + 1)
'Creates the sheet name based on the active txt file
sheetName = Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4)

  'Rename the original text file
   ActiveWorkbook.SaveAs ("S:\MERIT OUTPUTS FOLDER\MSI Recruitment
   Limited\"
   & "DNU_" & fileName & ".txt")

'Save active file as...
 ActiveWorkbook.SaveAs ("S:\MERIT OUTPUTS FOLDER\MSI Recruitment
 Limited\BACS File Original\" & _
   fileName & ".CSV"), FileFormat:=xlCSV

 'Selects all data in column A and copies to clipboard
   Set rCopy = Range("A1", Range("A1").End(xlDown))

 'Open the original document where the BACS file is located
  Workbooks.Open "S:\Accounts (New)\Management Information
 (Analysis)\Phil
  Hanmore - Analysis\bacs conversation calc.xlsx"
 'Selects the worksheet called "Original"
  Sheets("Original").Range("A:A").ClearContents

  'Paste selected values from previous sheet
    rCopy.Copy
   Sheets("Original").Range("A1").PasteSpecial Paste:=xlPasteValues

  'Selects appropriate worksheet - Non-MyPayFINAL
   Sheets("Non-MyPay FINAL").Select

  'Selects all data in column A and copies to clipboard
   Range("A1", Range("A1").End(xlDown)).Select
   Selection.Copy

'Add a new workbook
  Workbooks.Add
 'Paste selected values from previous sheet
  Selection.PasteSpecial Paste:=xlPasteValues

 'Build SaveAs file name (for CSV file)
  MySaveFile = Format(Now(), "DDMMYYYY") & "NonMyPayFINAL" & ".CSV"
 'Save template file as...(for CSV file)
  ActiveWorkbook.SaveAs ("S:\MERIT OUTPUTS FOLDER\MSI Recruitment
  Limited\"
  & MySaveFile), FileFormat:=xlCSV

  'Build SaveAs file name (for Txt file)
  MySaveFile = Format(Now(), "DDMMYYYY") & "NonMyPayFINAL" & ".Txt"
 'Save template file as...(for Txt file)
  ActiveWorkbook.SaveAs ("S:\MERIT OUTPUTS FOLDER\MSI Recruitment
  Limited\"
  & MySaveFile), FileFormat:=xlTextWindows

  'Close the new saved file
   ActiveWorkbook.Close

  'Selects appropriate worksheet - MyPayFINAL
   Sheets("MyPay FINAL").Select

  'Selects all data in column A and copies to clipboard
   Range("A1", Range("A1").End(xlDown)).Select
   Selection.Copy

  'Add a new workbook
   Workbooks.Add
   'Paste selected values from previous sheet
   Selection.PasteSpecial Paste:=xlPasteValues

   'Build SaveAs file name (for CSV file)
    MySaveFile = Format(Now(), "DDMMYYYY") & "MyPayFINAL" & ".CSV"
  'Save template file as...(for CSV file)
   ActiveWorkbook.SaveAs ("S:\MERIT OUTPUTS FOLDER\MSI Recruitment
   Limited\"
  & MySaveFile), FileFormat:=xlCSV

   'Build SaveAs file name (for Txt file)
   MySaveFile = Format(Now(), "DDMMYYYY") & "MyPayFINAL" & ".Txt"
   'Save template file as...(for Txt file)
   ActiveWorkbook.SaveAs ("S:\MERIT OUTPUTS FOLDER\MSI Recruitment
    Limited\"
   & MySaveFile), FileFormat:=xlTextWindows

  'Close the new saved file
   ActiveWorkbook.Close
  'Close original source workbook (template)
   Workbooks("bacs conversation calc").Close
  'Close final workbook
   ActiveWorkbook.Close savechanges:=True
  'Deletes the original copy
   Kill "S:\MERIT OUTPUTS FOLDER\MSI Recruitment Limited\" & fileName &
  ".txt"

  'Displays message box
  MsgBox "Your file has been processed successfully!", vbExclamation

  'Turn on display alerts
  Application.DisplayAlerts = True
 'Turn on screen updates
  Application.ScreenUpdating = True

  End Sub
</code>```

答: With the help of @ainwood, I have realized that the answer really was quite simple. Where I was using filename Variable this meant that the file could not be found - using fileToOpen solved the problem completely.

Title: vba kill a file using a variable

Body:
I have written code which stores the original file which is opened, as the variable fileName and this is used to save a new version of the file with a slightly different name. I have written the code to kill the original file but its not behaving quite as it should.

I am getting file not found on the kill line.

 'Deletes the original copy
  Kill "S:\MERIT OUTPUTS FOLDER\MSI Recruitment Limited\" & fileName &
  ".txt"

   Sub BACSConversion()

   Dim MyNewBook As String
   Dim MySaveFile As String
   Dim fileToOpen As Variant
   Dim fileName As String
   Dim sheetName As String
   Dim rCopy As Range

  'Turn off display alerts
   Application.DisplayAlerts = False
  'Turn off screen updates
   Application.ScreenUpdating = False

   'Ensures that the file open directory is always the same
   ChDir "S:\MERIT OUTPUTS FOLDER\MSI Recruitment Limited\"

  'Opens the folder to location to select txt file
   fileToOpen = Application.GetOpenFilename("Text Files (*.txt), *.txt")
    If fileToOpen <> False Then
    Workbooks.OpenText fileName:=fileToOpen, _
    DataType:=xlDelimited, Tab:=True
    End If
'Creates the file name based on txt file name
fileName = Mid(fileToOpen, InStrRev(fileToOpen, "\") + 1)
'Creates the sheet name based on the active txt file
sheetName = Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4)

  'Rename the original text file
   ActiveWorkbook.SaveAs ("S:\MERIT OUTPUTS FOLDER\MSI Recruitment
   Limited\"
   & "DNU_" & fileName & ".txt")

'Save active file as...
 ActiveWorkbook.SaveAs ("S:\MERIT OUTPUTS FOLDER\MSI Recruitment
 Limited\BACS File Original\" & _
   fileName & ".CSV"), FileFormat:=xlCSV

 'Selects all data in column A and copies to clipboard
   Set rCopy = Range("A1", Range("A1").End(xlDown))

 'Open the original document where the BACS file is located
  Workbooks.Open "S:\Accounts (New)\Management Information
 (Analysis)\Phil
  Hanmore - Analysis\bacs conversation calc.xlsx"
 'Selects the worksheet called "Original"
  Sheets("Original").Range("A:A").ClearContents

  'Paste selected values from previous sheet
    rCopy.Copy
   Sheets("Original").Range("A1").PasteSpecial Paste:=xlPasteValues

  'Selects appropriate worksheet - Non-MyPayFINAL
   Sheets("Non-MyPay FINAL").Select

  'Selects all data in column A and copies to clipboard
   Range("A1", Range("A1").End(xlDown)).Select
   Selection.Copy

'Add a new workbook
  Workbooks.Add
 'Paste selected values from previous sheet
  Selection.PasteSpecial Paste:=xlPasteValues

 'Build SaveAs file name (for CSV file)
  MySaveFile = Format(Now(), "DDMMYYYY") & "NonMyPayFINAL" & ".CSV"
 'Save template file as...(for CSV file)
  ActiveWorkbook.SaveAs ("S:\MERIT OUTPUTS FOLDER\MSI Recruitment
  Limited\"
  & MySaveFile), FileFormat:=xlCSV

  'Build SaveAs file name (for Txt file)
  MySaveFile = Format(Now(), "DDMMYYYY") & "NonMyPayFINAL" & ".Txt"
 'Save template file as...(for Txt file)
  ActiveWorkbook.SaveAs ("S:\MERIT OUTPUTS FOLDER\MSI Recruitment
  Limited\"
  & MySaveFile), FileFormat:=xlTextWindows

  'Close the new saved file
   ActiveWorkbook.Close

  'Selects appropriate worksheet - MyPayFINAL
   Sheets("MyPay FINAL").Select

  'Selects all data in column A and copies to clipboard
   Range("A1", Range("A1").End(xlDown)).Select
   Selection.Copy

  'Add a new workbook
   Workbooks.Add
   'Paste selected values from previous sheet
   Selection.PasteSpecial Paste:=xlPasteValues

   'Build SaveAs file name (for CSV file)
    MySaveFile = Format(Now(), "DDMMYYYY") & "MyPayFINAL" & ".CSV"
  'Save template file as...(for CSV file)
   ActiveWorkbook.SaveAs ("S:\MERIT OUTPUTS FOLDER\MSI Recruitment
   Limited\"
  & MySaveFile), FileFormat:=xlCSV

   'Build SaveAs file name (for Txt file)
   MySaveFile = Format(Now(), "DDMMYYYY") & "MyPayFINAL" & ".Txt"
   'Save template file as...(for Txt file)
   ActiveWorkbook.SaveAs ("S:\MERIT OUTPUTS FOLDER\MSI Recruitment
    Limited\"
   & MySaveFile), FileFormat:=xlTextWindows

  'Close the new saved file
   ActiveWorkbook.Close
  'Close original source workbook (template)
   Workbooks("bacs conversation calc").Close
  'Close final workbook
   ActiveWorkbook.Close savechanges:=True
  'Deletes the original copy
   Kill "S:\MERIT OUTPUTS FOLDER\MSI Recruitment Limited\" & fileName &
  ".txt"

  'Displays message box
  MsgBox "Your file has been processed successfully!", vbExclamation

  'Turn on display alerts
  Application.DisplayAlerts = True
 'Turn on screen updates
  Application.ScreenUpdating = True

  End Sub


答:
Store the $timeout timer in a global scope which can be accessed by myFunction. And cancel the timer when you reach your desired result.

```<code>var timer=null;

function myFunction(){
var i=0;
    var _onSuccess = function(response){
        if (response.status=== 'READY' || i >= 12) {
            clearInterval(x);
            if(timer){
              $timeout.cancel(timer);
            }
            if(response.status !== 'READY'){
                $location.path('/errorView');
            }
        }
    }
var x = setInterval(function () {
            $rest.getSomething(_onSuccess)
        }, 3000);
}

function myFunction2(){
      myFunction();
      timer = $timeout(function () {
        $location.path('/routeWhenStatusReady');
      }, 32000);
   }
</code>```

Title: Call and stop a rest service with an interval of time

Body:
Store the $timeout timer in a global scope which can be accessed by myFunction. And cancel the timer when you reach your desired result.

var timer=null;

function myFunction(){
var i=0;
    var _onSuccess = function(response){
        if (response.status=== 'READY' || i >= 12) {
            clearInterval(x);
            if(timer){
              $timeout.cancel(timer);
            }
            if(response.status !== 'READY'){
                $location.path('/errorView');
            }
        }
    }
var x = setInterval(function () {
            $rest.getSomething(_onSuccess)
        }, 3000);
}

function myFunction2(){
      myFunction();
      timer = $timeout(function () {
        $location.path('/routeWhenStatusReady');
      }, 32000);
   }


问:
Cannot resolve symbol newRequestQueue - Volley
I have this bit of code in the MainActivity file:

RequestQueue queue = new Volley.newRequestQueue(this);
```
<p>and for some reason the <code>newRequestQueue</code> part is red and when I hover over it I get</p>
<pre class="lang-none prettyprint-override"><code>Cannot resolve symbol 'newRequestQueue'
</code>```

How can I solve this ?

答: you just have to remove the new and it will be solved

ContentLicense: CC BY-SA 4.0

Body:
I have this bit of code in the MainActivity file:

RequestQueue queue = new Volley.newRequestQueue(this);

and for some reason the newRequestQueue part is red and when I hover over it I get

Cannot resolve symbol 'newRequestQueue'

How can I solve this ?


问:
Integration Birt parameters with HTML
I working on my Bachelor Thesis and i have a question.
It is possible that Birt will be generate form with parameters on my HTML page from .rptdesign?
I found that i can put the code to my html like there
but this not working.
Maybe somebody know, where i can find examples?</p>

答: Consider using the JavaScript or REST API. Check the documentation for examples of using the API with parameters in JSON format. </p>

Title: Integration Birt parameters with HTML


问:
wolframalpha result stopiteration
I getting an error for my below code:

```<code>import wolframalpha

ask = input("Question:- ")
app_id = "E82747-Y2LGY6EKH3"

client = wolframalpha.Client(app_id)

res = client.query(ask)

answer = next(res.results).text

print (answer)
</code>```

Error I am getting:

```<code>**Traceback (most recent call last):   File "test.py", line 8, in <module>
    answer = next(res.results).text StopIteration
**
</code>```

What am I doing Wrong?

答:
I've just run your code (with the question "temperature of the sun") and it seems to work fine, giving me an answer of 5772 K.

StopIteration is raised when there are no more items in the iterable (res.results). What question did you ask, and are you sure it gave an answer?

Try printing res.results before the call to next to check what it returned.

Title: wolframalpha result stopiteration

Body:
I getting an error for my below code:

import wolframalpha

ask = input("Question:- ")
app_id = "E82747-Y2LGY6EKH3"

client = wolframalpha.Client(app_id)

res = client.query(ask)

answer = next(res.results).text

print (answer)

Error I am getting:

**Traceback (most recent call last):   File "test.py", line 8, in <module>
    answer = next(res.results).text StopIteration
**

What am I doing Wrong?