问:
How do I use Gitlab variables with SonarQube.Scanner.MSBuild.exe inside of a gitlab-ci.yml
When i try to use SonarQube.Scanner.MSBuild.exe with switches like:

```<code>SonarQube.Scanner.MSBuild.exe /k:%CI_COMMIT_REF_NAME% /n:%CI_COMMIT_REF_NAME%
</code>```

The log dump gives me problems for having %CI_COMMIT_REF_NAME%. It's as if they don't exist or that they can't be found.

I also see this line at the end of the file:

```<code>'GitLab Commit Issue Publisher' skipped because one of the required properties is missing
</code>```

Here is my SonarQube.Analysis.xml file

```<code><SonarQubeAnalysisProperties  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.sonarsource.com/msbuild/integration/2015/1">
 <!-- The sonarqube server address -->
  <Property Name="sonar.host.url">http://server.com:1234</Property>

      <Property Name="sonar.sourceEncoding">UTF-8</Property>

      <!-- I have no idea if anything below this line works -->
    <!--   <Property Name="sonar.projectName">Master</Property>  Should be set in job of the gitlab yml
      <Property Name="sonar.projectKey">Master</Property> Should be set in job of the gitlab yml -->
      <Property Name="sonar.exclusions">folder\**</Property>
      <Property Name="sonar.sources">.</Property>
      <Property Name="sonar.verbose">true</Property>
     <!--  <Property Name="sonar.scanner.dumpToFile">somethingWentWrong.txt</Property> -->
      <Property Name="sonar.analysis.mode">issues</Property>

      <!--
    this is only for forced authentication. the group "everyone" on the server has execute permission so you don't need to fill this out.
      <Property Name="sonar.login"></Property>
      <Property Name="sonar.password"></Property>
      -->

    </SonarQubeAnalysisProperties>
</code>```

here is the command sequence I use to call SonarQube.Scanner.MSbuild.exe in the gitlab-ci.yml job:

```<code> - SonarQube.Scanner.MSBuild.exe begin /k:doesthiswork /n:doesthiswork
 - MSBuild.exe /t:Rebuild directory\Solution.sln
 - SonarQube.Scanner.MSBuild.exe end
</code>```

What do I not understand about using Gitlab predfined variables in SonarQube.Scanner.MSBuild.exe calls inside of Gitlab-ci.yml?

gitlab variables: https://docs.gitlab.com/ee/ci/variables/#predefined-variables-environment-variables

答:
Gitlab and sonarqube variables can be used; but they can't be referenced from inside gitlab-ci.yml.

In gitlab-ci.yml make a call to a batch script such as:

```<code>   - cmd.exe /c callMyBatch.bat
</code>```

....inside of callMyBatch.bat

```<code>SonarQube.Scanner.MSBuild.exe begin /k:%GITLABORENVIRONMENTVAR%
MSBuild.exe /t:Rebuild directory\Solution.sln
SonarQube.Scanner.MSBuild.exe end
</code>```

Body:
When i try to use SonarQube.Scanner.MSBuild.exe with switches like:

SonarQube.Scanner.MSBuild.exe /k:%CI_COMMIT_REF_NAME% /n:%CI_COMMIT_REF_NAME%

The log dump gives me problems for having %CI_COMMIT_REF_NAME%. It's as if they don't exist or that they can't be found.

I also see this line at the end of the file:

'GitLab Commit Issue Publisher' skipped because one of the required properties is missing

Here is my SonarQube.Analysis.xml file

<SonarQubeAnalysisProperties  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.sonarsource.com/msbuild/integration/2015/1">

  <Property Name="sonar.host.url">http://server.com:1234</Property>

      <Property Name="sonar.sourceEncoding">UTF-8</Property>

      <Property Name="sonar.exclusions">folder\**</Property>
      <Property Name="sonar.sources">.</Property>
      <Property Name="sonar.verbose">true</Property>

      <Property Name="sonar.analysis.mode">issues</Property>

    </SonarQubeAnalysisProperties>

here is the command sequence I use to call SonarQube.Scanner.MSbuild.exe in the gitlab-ci.yml job:

 - SonarQube.Scanner.MSBuild.exe begin /k:doesthiswork /n:doesthiswork
 - MSBuild.exe /t:Rebuild directory\Solution.sln
 - SonarQube.Scanner.MSBuild.exe end

What do I not understand about using Gitlab predfined variables in SonarQube.Scanner.MSBuild.exe calls inside of Gitlab-ci.yml?

gitlab variables: https://docs.gitlab.com/ee/ci/variables/#predefined-variables-environment-variables

Body:
Gitlab and sonarqube variables can be used; but they can't be referenced from inside gitlab-ci.yml.

In gitlab-ci.yml make a call to a batch script such as:

   - cmd.exe /c callMyBatch.bat

....inside of callMyBatch.bat

SonarQube.Scanner.MSBuild.exe begin /k:%GITLABORENVIRONMENTVAR%
MSBuild.exe /t:Rebuild directory\Solution.sln
SonarQube.Scanner.MSBuild.exe end


来源: stackexchange

问:
Outlook Calendar Sync Issue 80070005
I have a SharePoint 2013 calendar that needs unique permissions on it, allowing people who have NOT been granted access to the parent site access to this calendar.  I've broken inheritance on this calendar and granted Read permissions on the calendar to these non site members.  They are able to browse the calendar via Internet Explorer, but if they click the Connect to Outlook button in SharePoint, Outlook prompts for a username/password that can never authenticate.  The calendar is added to Outlook, but any attempts to sync results in an error message:

'Task SharePoint reported error (0x80070005): You do not have permission to view theis SharePoint List... HTTP 401'

I've tried the conventional wisdom of deleting the calendar from Outlook and adding again, but always get the same result.  The only thing that seems to fix the issue is to add the external user to the calendar's parent site as part of the members group.  This gives that external user access to other content in the parent site we want to restrict, so this is not an option.

Any suggestions on how to resolve this issue?

Tks

答: In order to Sync a SharePoint list or library to Outlook, the user must have Collaborate permissions for the library or list (2nd paragraph).</p>

ContentLicense: CC BY-SA 3.0

Title: Outlook Calendar Sync Issue 80070005


问:
Angular 2 Input time doesnt return seconds
```<code><input class="form-control" type="time" step="1" [(ngModel)]="dateField"  min="00:00:00" max="23:59:59">
</code>```

Thats my code for this input. the problem is after change a time (for example to 07:00:00) the variable into ngModel have only a 07:00. So the problem occur when the seconds are 00 only. Is that possible to return full time with hours,minutes and seconds always not only in case when seconds are higher than 0?

答:
When you get the dateField use this code to get seconds too:

```<code>this.dateField = this.dateField && this.dateField.length === 5 ? this.dateField + ":00" : this.dateField;
</code>```

It appends :00 if string length is 5 eg: 07:00 turns into 07:00:00.

Body:
<input class="form-control" type="time" step="1" [(ngModel)]="dateField"  min="00:00:00" max="23:59:59">

Thats my code for this input. the problem is after change a time (for example to 07:00:00) the variable into ngModel have only a 07:00. So the problem occur when the seconds are 00 only. Is that possible to return full time with hours,minutes and seconds always not only in case when seconds are higher than 0?

Body:
When you get the dateField use this code to get seconds too:

this.dateField = this.dateField && this.dateField.length === 5 ? this.dateField + ":00" : this.dateField;

It appends :00 if string length is 5 eg: 07:00 turns into 07:00:00.


问:
How do I delete a line from the table in index page when I press the delete button without deleting it from the database
How do I delete a line from the table in index page when I press the delete button without deleting it from the database.
i'm using asp.net mvc5 with visual studio 2017 and sql server 2016.

```<code>// GET: Information/Delete/5
    public ActionResult Delete(int? id)
    {
        if (id == null)
        {
            return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        }
        Information information = db.Informations.Find(id);
        if (information == null)
        {
            return HttpNotFound();
        }
        return View(information);
    }

    // POST: Information/Delete/5
    [HttpPost, ActionName("Delete")]
    [ValidateAntiForgeryToken]
    public ActionResult DeleteConfirmed(int id)
    {
        Information information = db.Informations.Find(id);
        db.Informations.Remove(information);
        db.SaveChanges();
        return RedirectToAction("Index");
    }

    protected override void Dispose(bool disposing)
    {
        if (disposing)
        {
            db.Dispose();
        }
        base.Dispose(disposing);
    }
}
</code>```

}

this code delete the selected row from database. i want to delete it just from index page.
Please could anyone give me any hint.

答:
You can just use the jquery remove() method to remove that row..
Just you have something to target that row i.e. id or a class </p>

<p>$('#ID').remove();
OR
$('.CLASSNAME').remove();</p>

Body:
How do I delete a line from the table in index page when I press the delete button without deleting it from the database.
i'm using asp.net mvc5 with visual studio 2017 and sql server 2016.

// GET: Information/Delete/5
    public ActionResult Delete(int? id)
    {
        if (id == null)
        {
            return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        }
        Information information = db.Informations.Find(id);
        if (information == null)
        {
            return HttpNotFound();
        }
        return View(information);
    }

    // POST: Information/Delete/5
    [HttpPost, ActionName("Delete")]
    [ValidateAntiForgeryToken]
    public ActionResult DeleteConfirmed(int id)
    {
        Information information = db.Informations.Find(id);
        db.Informations.Remove(information);
        db.SaveChanges();
        return RedirectToAction("Index");
    }

    protected override void Dispose(bool disposing)
    {
        if (disposing)
        {
            db.Dispose();
        }
        base.Dispose(disposing);
    }
}

}

this code delete the selected row from database. i want to delete it just from index page.
Please could anyone give me any hint.

Body:
You can just use the jquery remove() method to remove that row..
Just you have something to target that row i.e. id or a class

$('#ID').remove();
OR
$('.CLASSNAME').remove();


问:
Passing ID Of Dynamic Javascript HTML
I'm trying to pass the element itself, or id. How can I make this work?

```<code>onclick="addYes(this)"
</code>```

```<code>for (var i = 0; i < data.length; i++) {
  tempTable+= '<tr>'+
    '<td  class="cust-data-row"style="height:40px;width:40%;">'+
    data[i].service+
    '</td>'+
    '</td>'+
    '<td  class="cust-data-row-yes" style="height:40px;width:10%;  id="rec_btn_yes_' +i+'"  onclick="addYes(this)" >'+
    'Yes'+
    '</td>'+
    '</tr>';
}

function addYes(button){
  //shows nothing:
  alert(button.id);
  //not working:
  document.getElementById(button.id).addClass("clicked_yes");
  //unrecognized method:
  button.addClass("clicked_yes");
}
</code>```

答:
Just small change in addClass() code and everything works fine:-

Working snippet:-

function addYes(button){
  alert(button.id);
  $("#"+button.id).addClass("clicked_yes");
}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.clicked_yes{
  color:red;
  font-size:20px;
}</code>```

<button id="abc" onclick="addYes(this)">click pls!</button>```

Title: Passing ID Of Dynamic Javascript HTML

Body:
I'm trying to pass the element itself, or id. How can I make this work?

onclick="addYes(this)"

for (var i = 0; i < data.length; i++) {
  tempTable+= '
'+
    ''+
    data[i].service+
    '	'+
    '	'+
    ''+
    'Yes'+
    '	'+
    '
';
}

function addYes(button){
  //shows nothing:
  alert(button.id);
  //not working:
  document.getElementById(button.id).addClass("clicked_yes");
  //unrecognized method:
  button.addClass("clicked_yes");
}

Body:
Just small change in addClass() code and everything works fine:-

Working snippet:-

function addYes(button){
  alert(button.id);
  $("#"+button.id).addClass("clicked_yes");
}

.clicked_yes{
  color:red;
  font-size:20px;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button id="abc" onclick="addYes(this)">click pls!</button>


问:
Meaning of __in , __out, __in_opt
What is the meaning of these keywords used before variables in a
 function parameters?

__in

__out

__in_opt

答:
As answered by Nercolis, these are SAL annotation attributes. However, these aren't just internal or just for API documentation. The real purpose is for Code Analysis. When you build the project with /analyze compiler option (Project Properties, Code Analysis -> General), these play important role in finding the coding issues.

For example, if a particular pointer argument says __in then it must not be passed a null pointer. The function will not check for null and may cause SEH. __in_opt argument may be null. When compiler finds some issue, it reports it as a warning. See this article.

Title: Meaning of __in , __out, __in_opt


问:
How do ligature icons work in Material Icons?
Using Material Icons, a plus icon can be added as follows:

```<code><i class="material-icons">add</i>
</code>```

The text add is no longer visible. Why does this happen and where does the plus icon come from? I know it's defined in the font file, but how?

If it's due to the word add linked with the plus icon in the font file, then why doesn't the following work in Bootstrap, with its Glyphicons?

```<code><span style="font-family: 'Glyphicons Halflings'">\20ac</span>
</code>```

答:
Material Icons. It is possible in a font to define special glyphs for combinations of characters. An example in English is the glyph æ, which is a combination of a and e. This is called a ligature. Other examples are special renderings of ff, ft and tt. Instead of drawing an f followed by another one, the two glyphs are drawn as a single connected glyph: f f versus ff. What the designers of the Material Icons set did is (ab)using this system to make it easy to use icons.

Let's take a step back for a moment. You'll notice in the usage of the add icon that it is possible to include it by directly using a character code that is mapped, in the font, to the correct icon.

```<code><i class="material-icons"></i>
</code>```

This refers to Unicode character U+E145, which falls in one of the Private Use Area blocks of the Unicode specification. This means that no character is usually assigned to this position and every font designer is free to put any glyph they want at that position. Google chose to put the add icon at that spot. Thus, this character, with font family Material Icons, will render as a nice icon.

In addition to that, they created a ligature in their font family that says that the combination of characters add should be rendered as the same glyph. When browsers support ligatures in their font rendering engine, this will result in the same output as using &#xE145 would.

Google documents this very briefly as well.

In a nutshell: both  (U+E145) and the string add will render as  when using Material Icons.

<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
      rel="stylesheet">
As character: .

As ligature: add.```
</div>
</div>
</p>
<hr />
<p><strong>Boostrap and Glyphicons.</strong> The Glyphicons font does not define ligatures, but referencing the correct characters definitely does work. This is exactly what Bootstrap does, by setting (for the plus icon from Glyphicons) <code>content: "\002b";</code>. This sets the content of the <code>span</code> it is applied on to the character represented by the escaped code point U+002B, which is the plus sign. The <code>Glyphicons Halflings</code> font family renders this as some sort of icon, just like <code>Material Icons</code>. The only difference is that the icon is represented by a different character.</p>
<p>Why does using <code>\002B</code> in a <code>span</code> not work, you ask? That's because escaping a Unicode character in CSS is different than in HTML. In HTML, you'd use <code>+</code> instead (or <code>€</code> to get the example you have in your question). You can read more about escaping here.</p>
<p>Thus, + (U+002B) renders as <img src="https://i.stack.imgur.com/X1hrD.png" alt="plus" /> and € (U+20AC) renders as <img src="https://i.stack.imgur.com/DftI3.png" alt="Euro sign" /> when using the <code>Glyphicons Halflings</code> font family. You'll notice that for the Glyphicons, they chose to use characters resembling the icons, whereas Material Icons use special, reserved characters.</p>
<p><div class="snippet" data-lang="js" data-hide="true" data-console="false" data-babel="false">
<div class="snippet-code snippet-currently-hidden">
<pre class="snippet-code-html lang-html prettyprint-override"><code><link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<span style="font-family: 'Glyphicons Halflings'">+ €</span></code>```

Body:
Using Material Icons, a plus icon can be added as follows:

add

The text add is no longer visible. Why does this happen and where does the plus icon come from? I know it's defined in the font file, but how?

If it's due to the word add linked with the plus icon in the font file, then why doesn't the following work in Bootstrap, with its Glyphicons?

\20ac

Body:
Material Icons. It is possible in a font to define special glyphs for combinations of characters. An example in English is the glyph æ, which is a combination of a and e. This is called a ligature. Other examples are special renderings of ff, ft and tt. Instead of drawing an f followed by another one, the two glyphs are drawn as a single connected glyph: f f versus ff. What the designers of the Material Icons set did is (ab)using this system to make it easy to use icons.

Let's take a step back for a moment. You'll notice in the usage of the add icon that it is possible to include it by directly using a character code that is mapped, in the font, to the correct icon.

<i class="material-icons">&#xE145;</i>

This refers to Unicode character U+E145, which falls in one of the Private Use Area blocks of the Unicode specification. This means that no character is usually assigned to this position and every font designer is free to put any glyph they want at that position. Google chose to put the add icon at that spot. Thus, this character, with font family Material Icons, will render as a nice icon.

In addition to that, they created a ligature in their font family that says that the combination of characters add should be rendered as the same glyph. When browsers support ligatures in their font rendering engine, this will result in the same output as using &#xE145 would.

Google documents this very briefly as well.

In a nutshell: both  (U+E145) and the string add will render as  when using Material Icons.

<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
      rel="stylesheet">
As character: <span class="material-icons">&#xE145;</span>.<br>
As ligature: <span class="material-icons">add</span>.

Boostrap and Glyphicons. The Glyphicons font does not define ligatures, but referencing the correct characters definitely does work. This is exactly what Bootstrap does, by setting (for the plus icon from Glyphicons) content: "\002b";. This sets the content of the span it is applied on to the character represented by the escaped code point U+002B, which is the plus sign. The Glyphicons Halflings font family renders this as some sort of icon, just like Material Icons. The only difference is that the icon is represented by a different character.

Why does using \002B in a span not work, you ask? That's because escaping a Unicode character in CSS is different than in HTML. In HTML, you'd use &#x002B; instead (or &#x20AC; to get the example you have in your question). You can read more about escaping here.

Thus, + (U+002B) renders as  and € (U+20AC) renders as  when using the Glyphicons Halflings font family. You'll notice that for the Glyphicons, they chose to use characters resembling the icons, whereas Material Icons use special, reserved characters.

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<span style="font-family: 'Glyphicons Halflings'">&#x002B; &#x20AC;</span>

ContentLicense: CC BY-SA 4.0


问:
Git change branch historically
When I look at my repository network on https://github.com/user/repo/network, the graph of my repo looks like this:

Shown:

```<code>       ------------ A2 (branch a)
      |
A0 -- A1 -- B0 (branch b)
      |
       ------------------ C0 -- C1 (branch c)
</code>```

Though the graph structure is correct, it looks like branch a originated from branch b. This effect is extra strong because [A0-A1-B0] all have the same color whereas [A2] is colored differently and so is [C0-C1].

Expected:

```<code>       ----- B0 (branch b)
      |
A0 -- A1 ---------- A2 (branch a)
      |
       ------------------ C0 -- C1 (branch c)
</code>```

I am wondering if this is just a displaying "issue" or wether or not this is somehow actually encoded into the git history.

I did some rebasing (private repo) to make the graph look nicer when I accidentally committed to the wrong branch.

Is there a way to assign A0 and A1 to branch a historically to make the graph look like expected? Or should I just not worry about this issue?

答:
This is not an issue.

In git, there is no notion of "this is a root branch" vs "this is a fork", branch a, branch b and branch c are stored in completely symmetrical ways.

The order in which the branches are drawn (blind guess : alphabetical order) and the fact that the common history is on the same horizontal line as branch b (blind guess : the common history was drawn in the middle) relies purely on the drawing library, and does not reflect any information stored in the repo.

Title: Git change branch historically

Body:
When I look at my repository network on https://github.com/user/repo/network, the graph of my repo looks like this:

Shown:

       ------------ A2 (branch a)
      |
A0 -- A1 -- B0 (branch b)
      |
       ------------------ C0 -- C1 (branch c)

Though the graph structure is correct, it looks like branch a originated from branch b. This effect is extra strong because [A0-A1-B0] all have the same color whereas [A2] is colored differently and so is [C0-C1].

Expected:

       ----- B0 (branch b)
      |
A0 -- A1 ---------- A2 (branch a)
      |
       ------------------ C0 -- C1 (branch c)

I am wondering if this is just a displaying "issue" or wether or not this is somehow actually encoded into the git history.

I did some rebasing (private repo) to make the graph look nicer when I accidentally committed to the wrong branch.

Is there a way to assign A0 and A1 to branch a historically to make the graph look like expected? Or should I just not worry about this issue?


问:
Getting amount of active trips via postgresql loop
I am searching for a way to get the amount of active trips in a GTFS feed for each minute of a day through a postgresql query.

For every trip I have the start and endtimes (in seconds) in a denormalized table. It looks something like this:

The query to give me trips that are active for a given timeframe (e.g. here 43000 to 43600 seconds) looks like this:

SELECT
COUNT(trips.trip_id)
FROM denormalized_trips AS trips

LEFT JOIN gtfs_calendar_dates AS calendar_dates
ON calendar_dates.service_id = trips.service_id
AND calendar_dates.agency_key = trips.agency_key
AND date = '2017-07-03'
AND exception_type = 1

INNER JOIN gtfs_calendar AS calendar
  ON trips.service_id = calendar.service_id
  AND calendar.agency_key = trips.agency_key
  AND calendar.wednesday = 1

WHERE (
  trip_start_time BETWEEN 46800 AND 47100
  AND '2017-07-03' BETWEEN calendar.start_date AND calendar.end_date
)
AND NOT EXISTS (
  SELECT 0
  FROM gtfs_calendar_dates AS date_exceptions
  WHERE date = '2017-07-03'
  AND date_exceptions.agency_key = trips.agency_key
  AND date_exceptions.service_id = calendar.service_id
  AND exception_type = 2
);
```

<p>This will result in 12 trips that will start between 13:00pm and 13:05pm.</p>

<p>Now I want to do that for the whole day. I want to get the amount of trips that get active in an interval of e.g. 1 minute or maybe more like 5 minutes.
I tried it with a loop but this seems to just give me 1 result back.
Here is what I came up with for now:</p>

<pre class="lang-sql prettyprint-override"><code>CREATE OR REPLACE FUNCTION get_active_trips(n int)
RETURNS INTEGER AS
$BODY$
DECLARE
 count INTEGER;
BEGIN
  FOR counter IN 43130..50000 BY 60 LOOP
    SELECT
    COUNT(trips.trip_id)
    INTO count
    FROM denormalized_trips AS trips

    LEFT JOIN gtfs_calendar_dates AS calendar_dates
    ON calendar_dates.service_id = trips.service_id
    AND calendar_dates.agency_key = trips.agency_key
    AND date = '2017-07-03'
    AND exception_type = 1

    INNER JOIN gtfs_calendar AS calendar
      ON trips.service_id = calendar.service_id
      AND calendar.agency_key = trips.agency_key
      AND calendar.wednesday = 1

    WHERE (
      trip_start_time BETWEEN counter AND counter + 60
      AND '2017-07-03' BETWEEN calendar.start_date AND calendar.end_date
    )
    AND NOT EXISTS (
      SELECT 0
      FROM gtfs_calendar_dates AS date_exceptions
      WHERE date = '2017-07-03'
      AND date_exceptions.agency_key = trips.agency_key
      AND date_exceptions.service_id = calendar.service_id
      AND exception_type = 2
    );
  END LOOP;
  RETURN count;
END;
$BODY$ LANGUAGE plpgsql STABLE;
</code>```

The result of calling SELECT get_active_trips(1);

Now I would like to get something like a table or an array of results back instead of just 1 entry. How would I do that?

Any help is highly appreciated.

答:
Create type like below

```<code>drop type if exists get_active_trips_out;
create type get_active_trips_out as
(
   Count int
);
</code>```

use that table type while returning the data from the function like below

```<code>CREATE OR REPLACE FUNCTION get_active_trips(n int)
RETURNS setof get_active_trips_out AS
$BODY$
DECLARE
 count INTEGER;
r get_active_trips_out%rowtype;
BEGIN
 create temp table tmp_count
(
  Count int
)on commit drop;
  FOR counter IN 43130..50000 BY 60 LOOP
    Insert into tmp_count
    SELECT
    COUNT(trips.trip_id)
    FROM denormalized_trips AS trips

    LEFT JOIN gtfs_calendar_dates AS calendar_dates
    ON calendar_dates.service_id = trips.service_id
    AND calendar_dates.agency_key = trips.agency_key
    AND date = '2017-07-03'
    AND exception_type = 1

    INNER JOIN gtfs_calendar AS calendar
      ON trips.service_id = calendar.service_id
      AND calendar.agency_key = trips.agency_key
      AND calendar.wednesday = 1

    WHERE (
      trip_start_time BETWEEN counter AND counter + 60
      AND '2017-07-03' BETWEEN calendar.start_date AND calendar.end_date
    )
    AND NOT EXISTS (
      SELECT 0
      FROM gtfs_calendar_dates AS date_exceptions
      WHERE date = '2017-07-03'
      AND date_exceptions.agency_key = trips.agency_key
      AND date_exceptions.service_id = calendar.service_id
      AND exception_type = 2
    );
  END LOOP;
 for r in
 Select * from tmp_count
 loop
 return next r
 end loop;
END;
</code>```

Body:
I am searching for a way to get the amount of active trips in a GTFS feed for each minute of a day through a postgresql query.

For every trip I have the start and endtimes (in seconds) in a denormalized table. It looks something like this:

The query to give me trips that are active for a given timeframe (e.g. here 43000 to 43600 seconds) looks like this:

SELECT
COUNT(trips.trip_id)
FROM denormalized_trips AS trips

LEFT JOIN gtfs_calendar_dates AS calendar_dates
ON calendar_dates.service_id = trips.service_id
AND calendar_dates.agency_key = trips.agency_key
AND date = '2017-07-03'
AND exception_type = 1

INNER JOIN gtfs_calendar AS calendar
  ON trips.service_id = calendar.service_id
  AND calendar.agency_key = trips.agency_key
  AND calendar.wednesday = 1

WHERE (
  trip_start_time BETWEEN 46800 AND 47100
  AND '2017-07-03' BETWEEN calendar.start_date AND calendar.end_date
)
AND NOT EXISTS (
  SELECT 0
  FROM gtfs_calendar_dates AS date_exceptions
  WHERE date = '2017-07-03'
  AND date_exceptions.agency_key = trips.agency_key
  AND date_exceptions.service_id = calendar.service_id
  AND exception_type = 2
);

This will result in 12 trips that will start between 13:00pm and 13:05pm.

Now I want to do that for the whole day. I want to get the amount of trips that get active in an interval of e.g. 1 minute or maybe more like 5 minutes.
I tried it with a loop but this seems to just give me 1 result back.
Here is what I came up with for now:

CREATE OR REPLACE FUNCTION get_active_trips(n int)
RETURNS INTEGER AS
$BODY$
DECLARE
 count INTEGER;
BEGIN
  FOR counter IN 43130..50000 BY 60 LOOP
    SELECT
    COUNT(trips.trip_id)
    INTO count
    FROM denormalized_trips AS trips

    LEFT JOIN gtfs_calendar_dates AS calendar_dates
    ON calendar_dates.service_id = trips.service_id
    AND calendar_dates.agency_key = trips.agency_key
    AND date = '2017-07-03'
    AND exception_type = 1

    INNER JOIN gtfs_calendar AS calendar
      ON trips.service_id = calendar.service_id
      AND calendar.agency_key = trips.agency_key
      AND calendar.wednesday = 1

    WHERE (
      trip_start_time BETWEEN counter AND counter + 60
      AND '2017-07-03' BETWEEN calendar.start_date AND calendar.end_date
    )
    AND NOT EXISTS (
      SELECT 0
      FROM gtfs_calendar_dates AS date_exceptions
      WHERE date = '2017-07-03'
      AND date_exceptions.agency_key = trips.agency_key
      AND date_exceptions.service_id = calendar.service_id
      AND exception_type = 2
    );
  END LOOP;
  RETURN count;
END;
$BODY$ LANGUAGE plpgsql STABLE;

The result of calling SELECT get_active_trips(1);

Now I would like to get something like a table or an array of results back instead of just 1 entry. How would I do that?

Any help is highly appreciated.

Body:
Create type like below

drop type if exists get_active_trips_out;
create type get_active_trips_out as
(
   Count int
);

use that table type while returning the data from the function like below

CREATE OR REPLACE FUNCTION get_active_trips(n int)
RETURNS setof get_active_trips_out AS
$BODY$
DECLARE
 count INTEGER;
r get_active_trips_out%rowtype;
BEGIN
 create temp table tmp_count
(
  Count int
)on commit drop;
  FOR counter IN 43130..50000 BY 60 LOOP
    Insert into tmp_count
    SELECT
    COUNT(trips.trip_id)
    FROM denormalized_trips AS trips

    LEFT JOIN gtfs_calendar_dates AS calendar_dates
    ON calendar_dates.service_id = trips.service_id
    AND calendar_dates.agency_key = trips.agency_key
    AND date = '2017-07-03'
    AND exception_type = 1

    INNER JOIN gtfs_calendar AS calendar
      ON trips.service_id = calendar.service_id
      AND calendar.agency_key = trips.agency_key
      AND calendar.wednesday = 1

    WHERE (
      trip_start_time BETWEEN counter AND counter + 60
      AND '2017-07-03' BETWEEN calendar.start_date AND calendar.end_date
    )
    AND NOT EXISTS (
      SELECT 0
      FROM gtfs_calendar_dates AS date_exceptions
      WHERE date = '2017-07-03'
      AND date_exceptions.agency_key = trips.agency_key
      AND date_exceptions.service_id = calendar.service_id
      AND exception_type = 2
    );
  END LOOP;
 for r in
 Select * from tmp_count
 loop
 return next r
 end loop;
END;


答:
With JQuery you can do as follow:

$("#Your_button").click(function(){
  $(this).addClass("clicked_yes");
})```

Title: Passing ID Of Dynamic Javascript HTML


问:
install gsuit market place app using API
Query 1 :

I have published my app in Gsuit Market place,what I want any admin can install my app by mine platform ie if he can install app (mine published) without going Gsuit marketplace.

So is there any Gsuit API for the same by using it we can install app on the behalf of him (Admin who wants to install App).

Query 2 :

This there any API why which we can fetch all the users those installed my published app.

答:
Query 1

This feature doesn't exist yet, not even mentioned in Control user installation of Marketplace apps.

Query 2

Don't think there is. Even Google Analytics API only show daily active users and not the specific users themselves.


问:
object oriented php code Error
```<code>// connection.php file

<?php

class Connection{

   private $host;
   private $username;
   private $password;
   private $database;

   public function __construct($host,$username,$password,$database)
   {
     try{
     $conn = new PDO("mysql:host=".$host.";dbname=".$database, $username, $password);
     $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     return $conn;
     }catch(PDOException $e)
     {
        return $e->getMessage();
     }
   }

}

?>

// user.php

<?php

class Users extends Connection{

  private $username;
  private $email;
  private $password;

  public function __construct($username,$email,$password){

    $this->username=$username;
    $this->email=$email;
    $this->password=$password;

  }

  public function addUser(){
    $conn = new Connection("localhost","root","","userdata");
    echo "database connection established";
    die();
    $sql = $conn->prepare("INSERT INTO information (UserName, Email, Password) VALUES (?, ?, ?)");
    $conn->bind_param("sss", $username, $email, $password);
    $username=this->username;
    $password=this->password;
    $email=this->email;
    $sql->execute();

    echo "New records created successfully";

    $sql->close();
    $conn->close();

  }
}

?>

process.php

<?php

include('lib/connection.php');

if(isset($_POST['username']) && isset($_POST['email']) && isset($_POST['password']))
{
  $user = new User("Gautam","gautam@mail.com","123456");
  $user->addUser();
}

?>
</code>```

So the Problem when i try to execute the process.php file the records are not added to the database.So i have created connection class separately where i have written the logic for database connection then i inherited that class to the users where i added the users to the database then i called the object of user class in process.php but records are not added to the database.Please clarify what is the problem associated with it.

答:
first of all use $this instead of this in your class and second you call wrong class name User, It is Users, please modify and try, should work.

```<code>$user = new Users("Gautam","gautam@mail.com","123456");
</code>```

And in your adduser function of class Users

```<code>$username=$this->username;
$password=$this->password;
$email=$this->email;
</code>```

change as above and it should work..

Title: object oriented php code Error

Body:
// connection.php file

<?php

class Connection{

   private $host;
   private $username;
   private $password;
   private $database;

   public function __construct($host,$username,$password,$database)
   {
     try{
     $conn = new PDO("mysql:host=".$host.";dbname=".$database, $username, $password);
     $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     return $conn;
     }catch(PDOException $e)
     {
        return $e->getMessage();
     }
   }

}

?>

// user.php

<?php

class Users extends Connection{

  private $username;
  private $email;
  private $password;

  public function __construct($username,$email,$password){

    $this->username=$username;
    $this->email=$email;
    $this->password=$password;

  }

  public function addUser(){
    $conn = new Connection("localhost","root","","userdata");
    echo "database connection established";
    die();
    $sql = $conn->prepare("INSERT INTO information (UserName, Email, Password) VALUES (?, ?, ?)");
    $conn->bind_param("sss", $username, $email, $password);
    $username=this->username;
    $password=this->password;
    $email=this->email;
    $sql->execute();

    echo "New records created successfully";

    $sql->close();
    $conn->close();

  }
}

?>

process.php

<?php

include('lib/connection.php');

if(isset($_POST['username']) && isset($_POST['email']) && isset($_POST['password']))
{
  $user = new User("Gautam","gautam@mail.com","123456");
  $user->addUser();
}

?>

So the Problem when i try to execute the process.php file the records are not added to the database.So i have created connection class separately where i have written the logic for database connection then i inherited that class to the users where i added the users to the database then i called the object of user class in process.php but records are not added to the database.Please clarify what is the problem associated with it.

Body:
first of all use $this instead of this in your class and second you call wrong class name User, It is Users, please modify and try, should work.

$user = new Users("Gautam","gautam@mail.com","123456");

And in your adduser function of class Users

$username=$this->username;
$password=$this->password;
$email=$this->email;

change as above and it should work..


问:
Webpack - React Router V4 - code splitting duplicate modules in async chunks
The main problem is while code splitting with react-routerV4 and then webpack 2, I have modules that are in several chunks that I can't get to the main one.

My configuration is as follow :

Webpack 2.2.1

React-route 4.1.1

I'm using the code splitting as in the react-router v4 documentation

Basically, I don't use the import, but on the route configuration I have : something like this :

```<code>import loadHome from 'bundle-loader?lazy&name=home-chunk!./pages/market/Home';
[
  {
    path: url1,
    component: props => <Bundle load={loadHome}>{Home => <Home {...props} />}</Bundle>,
    exact: true,
  },
  // other routes
  ]
</code>```

This works totally fine with the code splitting and I get a bundle for each route and another bundle for the node_modules that I can later split.

My problem is, I have one node_module (react-slick) that is in several bundles. So I want to get it out in the main bundle.

My webpack configuration is :

```<code>module.exports = {
  entry: [
    'whatwg-fetch',
    './src/scripts/index.js',
  ],
  output: {
    path: path.resolve(__dirname, 'src/build'),
    publicPath: '/build/',
    chunkFilename: "[name].js?[hash]",
    filename: '[name].js',
  },
  plugins: [
    new BundleAnalyzerPlugin(),
    new webpack.DefinePlugin({
      'process.env': {
        'NODE_ENV': '"production"'
      }
    }),
    new webpack.optimize.CommonsChunkPlugin({
      name: ['4_node-modules'],
      minChunks(module) {
       const context = module.context;
       return context && context.indexOf('node_modules') >= 0;
      },
    }),
    new webpack.optimize.CommonsChunkPlugin({
      name: ['3_react'],
      chunks: ['4_node-modules'],
      minChunks(module) {
        return module.context && /.*\/react.*/.test(module.context);
      },
    }),
    new webpack.optimize.CommonsChunkPlugin({
        children: true,
        minChunks: 2,
    }),
    new ExtractTextPlugin({
      filename: '[name].css',
      allChunks: true,
    }),
    new HtmlWebpackPlugin({
      filename: '../index.prod.html',
      template: 'src/template.index.prod.html',
      inject: false,
      hash: true,
    }),
  ],
};
</code>```

According to the documentation, this should do the trick :

```<code>new webpack.optimize.CommonsChunkPlugin({
    children: true,
    minChunks: 2,
}),
</code>```

But nothing happens, I still have "react-slick" in 3 of my bundles.

Does anyone have an hint of what's going on ?

Any help is appreciated :) Thank you !

答:
And I finally got the solution ;)

I let this so it might help someone.

The answer is :
Not specifying chunk doesn't apparently target all the chunks but only the last one created.

So let's say with react-router V4 we've created 2 async chunks 'home-chunk' and 'welcome-chunk'.
The way to get the common chunks out of it is to add in the webpack config file (in the pluggins):

```<code>new webpack.optimize.CommonsChunkPlugin( {
  name : 'common',
  chunks : ['home-chunk', 'welcome-chunk'],
  minChunks : 2,
}),
</code>```

This will check if there is common modules in the async chunks and if so, put them in the common chunk.

Body:
The main problem is while code splitting with react-routerV4 and then webpack 2, I have modules that are in several chunks that I can't get to the main one.

My configuration is as follow :

Webpack 2.2.1

React-route 4.1.1

I'm using the code splitting as in the react-router v4 documentation

Basically, I don't use the import, but on the route configuration I have : something like this :

import loadHome from 'bundle-loader?lazy&name=home-chunk!./pages/market/Home';
[
  {
    path: url1,
    component: props => <Bundle load={loadHome}>{Home => <Home {...props} />}</Bundle>,
    exact: true,
  },
  // other routes
  ]

This works totally fine with the code splitting and I get a bundle for each route and another bundle for the node_modules that I can later split.

My problem is, I have one node_module (react-slick) that is in several bundles. So I want to get it out in the main bundle.

My webpack configuration is :

module.exports = {
  entry: [
    'whatwg-fetch',
    './src/scripts/index.js',
  ],
  output: {
    path: path.resolve(__dirname, 'src/build'),
    publicPath: '/build/',
    chunkFilename: "[name].js?[hash]",
    filename: '[name].js',
  },
  plugins: [
    new BundleAnalyzerPlugin(),
    new webpack.DefinePlugin({
      'process.env': {
        'NODE_ENV': '"production"'
      }
    }),
    new webpack.optimize.CommonsChunkPlugin({
      name: ['4_node-modules'],
      minChunks(module) {
       const context = module.context;
       return context && context.indexOf('node_modules') >= 0;
      },
    }),
    new webpack.optimize.CommonsChunkPlugin({
      name: ['3_react'],
      chunks: ['4_node-modules'],
      minChunks(module) {
        return module.context && /.*\/react.*/.test(module.context);
      },
    }),
    new webpack.optimize.CommonsChunkPlugin({
        children: true,
        minChunks: 2,
    }),
    new ExtractTextPlugin({
      filename: '[name].css',
      allChunks: true,
    }),
    new HtmlWebpackPlugin({
      filename: '../index.prod.html',
      template: 'src/template.index.prod.html',
      inject: false,
      hash: true,
    }),
  ],
};

According to the documentation, this should do the trick :

new webpack.optimize.CommonsChunkPlugin({
    children: true,
    minChunks: 2,
}),

But nothing happens, I still have "react-slick" in 3 of my bundles.

Does anyone have an hint of what's going on ?

Any help is appreciated :) Thank you !

Body:
And I finally got the solution ;)

I let this so it might help someone.

The answer is :
Not specifying chunk doesn't apparently target all the chunks but only the last one created.

So let's say with react-router V4 we've created 2 async chunks 'home-chunk' and 'welcome-chunk'.
The way to get the common chunks out of it is to add in the webpack config file (in the pluggins):

new webpack.optimize.CommonsChunkPlugin( {
  name : 'common',
  chunks : ['home-chunk', 'welcome-chunk'],
  minChunks : 2,
}),

This will check if there is common modules in the async chunks and if so, put them in the common chunk.


问:
Repeat same action with function and apply familly
I'm new on R (and I use R-studio) and I have to analyze a big data frame (60 variables for 10 000 observations). My data frame had a column name specie with lot of different animals species in there. The goal of my work it's to have results of 8 differents species, so I have to work on there separately.
I start with building different subset (like I learn in school) and with awesome packages(special thanks to dplyr & tdyr). But now I have to repeat many identical (or nearly identical) actions on each of the 8 species, so I spent much time to copy/paste and when I make a mistake I must verify and change mistakes on thousands of lines.
Then I try to learn about loops et apply family functions. But I can't do something good.

There is an exemple of an action I do on a specie with the traditional way (organize data):

```<code>espece_td_a <- subset(BDD, BDD$espece == "espece A" & BDD$placette =="TOTAL")%>%
  select(code_site,passage,adulte)%>%
  spread(passage, adulte)
  espece_td_a <- full_join(B.irene_td_a, BDD_P3_TOT_site)
  espece_td_a <- replace(espece_td_a, is.na(espece_td_a),0)
  espece_td_a$P1[B.irene_td_a$P1>0]<-1
  espece_td_a$P2[B.irene_td_a$P2>0]<-1
  espece_td_a$P3[B.irene_td_a$P3>0]<-1
  write.csv(espece_td_a, file = "espece_td_a.csv")
</code>```

BDD is my data frame.

BDD_P3_TOT_site is vector (or data frame with 1 columns and many rows ?) built with BDD

This "traditional way" work for me, but I must do something like that so many times! And it takes a lot of time...

Then I tried to "apply" this with function :

```<code>f <- function(x)
{
  select(code_site, passage, adulte)%>%
    spread(x, x$passage, x$adulte)%>%
    full_join(x, BDD_P3_TOT_site) -> x
  x <- replace(x, is.na(x),0)
  x$P1[x$P1>0]<-1
  x$P2[x$P2>0]<-1
  x$P3[x$P3>0]<-1
}
</code>```

I wish apply this function to my dataset with lapply (with my 8 species in list):

```<code>l <- c("espece_a","espece_b","espece_c")

lapply(l,f(x))
</code>```

Problems :

I know that is a wrong formulation for lapply if I want take my species into BDD.

the function doesn't want work:
I already made 8 subsets (for each of my interest species)
In my global environment: espece_a; espece_b...

Then I wanted to put my subset one by one into my function:

```<code>> f(espece_a)
</code>```

Error in select_(.data, .dots = lazyeval::lazy_dots(...)) :          Show Traceback
       object 'code_site' not found                                          Rerun with Debug

I wish that my table appears in my Globlal env with a name that make me able to recognize it (ex: "espece_td_a")

答:
I solve the function problem :

```<code>f <- function(X){
  X <- select(X, code_site, passage, adulte)%>%
   spread(passage, adulte)
  X <- full_join(X, BDD_P3_TOT_site)
  X <- replace(X, is.na(X),0)
  X$P1[X$P1>0]<-1
  X$P2[X$P2>0]<-1
  X$P3[X$P3>0]<-1
  X <- return(X)
    }
</code>```

test <- f(espece_a)

Body:
I'm new on R (and I use R-studio) and I have to analyze a big data frame (60 variables for 10 000 observations). My data frame had a column name specie with lot of different animals species in there. The goal of my work it's to have results of 8 differents species, so I have to work on there separately.
I start with building different subset (like I learn in school) and with awesome packages(special thanks to dplyr & tdyr). But now I have to repeat many identical (or nearly identical) actions on each of the 8 species, so I spent much time to copy/paste and when I make a mistake I must verify and change mistakes on thousands of lines.
Then I try to learn about loops et apply family functions. But I can't do something good.

There is an exemple of an action I do on a specie with the traditional way (organize data):

espece_td_a <- subset(BDD, BDD$espece == "espece A" & BDD$placette =="TOTAL")%>%
  select(code_site,passage,adulte)%>%
  spread(passage, adulte)
  espece_td_a <- full_join(B.irene_td_a, BDD_P3_TOT_site)
  espece_td_a <- replace(espece_td_a, is.na(espece_td_a),0)
  espece_td_a$P1[B.irene_td_a$P1>0]<-1
  espece_td_a$P2[B.irene_td_a$P2>0]<-1
  espece_td_a$P3[B.irene_td_a$P3>0]<-1
  write.csv(espece_td_a, file = "espece_td_a.csv")

BDD is my data frame.

BDD_P3_TOT_site is vector (or data frame with 1 columns and many rows ?) built with BDD

This "traditional way" work for me, but I must do something like that so many times! And it takes a lot of time...

Then I tried to "apply" this with function :

f <- function(x)
{
  select(code_site, passage, adulte)%>%
    spread(x, x$passage, x$adulte)%>%
    full_join(x, BDD_P3_TOT_site) -> x
  x <- replace(x, is.na(x),0)
  x$P1[x$P1>0]<-1
  x$P2[x$P2>0]<-1
  x$P3[x$P3>0]<-1
}

I wish apply this function to my dataset with lapply (with my 8 species in list):

l <- c("espece_a","espece_b","espece_c")

lapply(l,f(x))

Problems :

I know that is a wrong formulation for lapply if I want take my species into BDD.

the function doesn't want work:
I already made 8 subsets (for each of my interest species)
In my global environment: espece_a; espece_b...

Then I wanted to put my subset one by one into my function:

> f(espece_a)

Error in select_(.data, .dots = lazyeval::lazy_dots(...)) :          Show Traceback
       object 'code_site' not found                                          Rerun with Debug

I wish that my table appears in my Globlal env with a name that make me able to recognize it (ex: "espece_td_a")

Body:
I solve the function problem :

f <- function(X){
  X <- select(X, code_site, passage, adulte)%>%
   spread(passage, adulte)
  X <- full_join(X, BDD_P3_TOT_site)
  X <- replace(X, is.na(X),0)
  X$P1[X$P1>0]<-1
  X$P2[X$P2>0]<-1
  X$P3[X$P3>0]<-1
  X <- return(X)
    }

test <- f(espece_a)


问:
Linux batch rename files, with string manipulation
I have a series of folders that having this naming convention:

DD / MM / YYYY - Name

eg:

01 / 05 / 2015 - test folder

I want to convert the format for easier reading as the name is more important than the date.

I would like the output to be

Name DD-MM-YYY

for i in *; do mv "$i" ...

So how do I in the terminal, or through a .sh (bash):

replace / (\s\/\s) with -?

move the DD-MM-YYYY to the back?

remove the - (\s\-\s)?

答:
```<code> awk -F/ '{ split($3,bits,"-");var=$1"-"$2"-"bits[1];print gensub(" ","","g",bits[2])" "gensub(" ","","g",var) }'
</code>```

Here we are splitting the data using "/" and then further split the 3rd piece of data with "-" (using the split function) We then remove the spaces where needed using the gensub function.

Body:
 awk -F/ '{ split($3,bits,"-");var=$1"-"$2"-"bits[1];print gensub(" ","","g",bits[2])" "gensub(" ","","g",var) }'

Here we are splitting the data using "/" and then further split the 3rd piece of data with "-" (using the split function) We then remove the spaces where needed using the gensub function.


问:
Is there any easy way to determine what factors are contributing to the size of an HTML element?
For example I have a situation where I have something like this (contrived) example:

```<code><div id="outer" style="margin: auto>
    <div id="inner1" style="float: left">content</div>
    <div id="inner2" style="float: left">content</div>
    <div id="inner3" style="float: left">content</div>
    <br style="clear: both"/>
</div>
</code>```

where there are no widths set on any elements, and what I want is #inner1, #inner2 and #inner3 to appear next to each other horizontally inside #outer but what is happening is that #inner1 and #inner2 are appearing next to each other and then #inner3 is wrapping on to the next line.

In the actual page where this is happening there is a lot more going on, but I have inspected all of the elements very carefully with Firebug and do not understand why the #inner3 element is not appearing on the same line as #inner1 and #inner2 and causing #outer to get wider.

So, my question is: Is there any way to determine why the browser is sizing #outer the way it is, or why it is choosing to wrap #inner3 even though there is plenty of room to put it on the previous "line"?  Baring specific solutions to this problem, what tips or techniques do you hardcore HTML/CSS/Web UI guys have for a poor back end developer who has found himself working on the front end?

答:
So I found the answer in my specific case -- there was a div much further up in the DOM that had specific left/right margins set which compressed it and everything in it.

But the   heart of the question is really how can you easily debug this sort of issue?  What would be perfect in this case for example would be something in Firebug that, when hovering over an element's size in the layout panel would display a tool tip that says something like "width constrained by outer element X; height constrained by style Z on element Q" or "width contributed to by inner elements A, B and C".

I wish I had the time to write something like this, although I suspect it would be difficult (if not impossible) to get that information out of Firefox's rendering engine.

OwnerDisplayName: John

Body:
For example I have a situation where I have something like this (contrived) example:

content

content

content

where there are no widths set on any elements, and what I want is #inner1, #inner2 and #inner3 to appear next to each other horizontally inside #outer but what is happening is that #inner1 and #inner2 are appearing next to each other and then #inner3 is wrapping on to the next line.

In the actual page where this is happening there is a lot more going on, but I have inspected all of the elements very carefully with Firebug and do not understand why the #inner3 element is not appearing on the same line as #inner1 and #inner2 and causing #outer to get wider.

So, my question is: Is there any way to determine why the browser is sizing #outer the way it is, or why it is choosing to wrap #inner3 even though there is plenty of room to put it on the previous "line"?  Baring specific solutions to this problem, what tips or techniques do you hardcore HTML/CSS/Web UI guys have for a poor back end developer who has found himself working on the front end?

LastEditorDisplayName: Chris

ContentLicense: CC BY-SA 2.5


问:
How to display a day from the Date
Using SQL Server 2005

Table1

```<code>Date

19-12-2009
20-12-2010
.....
</code>```

Date Column datatype is DATETIME.

Expected Output

```<code>Monday
Tuesday
</code>```

How to make a query for getting the day...

答:
Here is the reference for DateName which will assist you

http://msdn.microsoft.com/en-us/library/ms174395.aspx

If you want a numerical Reference like Sunday = 1, Saturday = 7, then use DatePart

http://msdn.microsoft.com/en-us/library/ms174420.aspx

This is what you want

```<code>DateName(dw, [Date])
</code>```

Title: How to display a day from the Date

Body:
Using SQL Server 2005

Table1

Date

19-12-2009
20-12-2010
.....

Date Column datatype is DATETIME.

Expected Output

Monday
Tuesday

How to make a query for getting the day...

Body:
Here is the reference for DateName which will assist you

http://msdn.microsoft.com/en-us/library/ms174395.aspx

If you want a numerical Reference like Sunday = 1, Saturday = 7, then use DatePart

http://msdn.microsoft.com/en-us/library/ms174420.aspx

This is what you want

DateName(dw, [Date])


问:
Why is my Interceptor not working?
I have two different projects: A and B.

B contains one Interceptor that I'd like to use in project A and, in the future, projects C and D.

I'm using jboss-javaee-6.0 version 3.0.3.Final in both projects (this means, CDI version 1.0).

Project B (does not contain beans.xml):

```<code>@InterceptorBinding
@Target({TYPE, METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface PerformanceLog {
}

@Interceptor
@PerformanceLog
public class LoggingInterceptor {
    private static final Logger LOG = LoggerFactory.getLogger(LoggingInterceptor.class);

    @AroundInvoke
    public Object logMethodEntry(InvocationContext ctx) throws Exception {
        LOG.debug("Entered method (" + ctx.getMethod().getName() + ") of class (" + ctx.getMethod().getClass() + ").");
    }
}
</code>```

Project A (contains beans.xml):

beans.xml (declares Interceptor in order to activate it):

```<code><?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">

<interceptors>
    <class>commons.utils.logging.performanceInterceptor.LoggingInterceptor</class>
</interceptors>
</beans>
</code>```

MyControllerC:

```<code>@Named
@RequestScoped
public class MyControllerC implements Serializable {
     ...

    @PerformanceLog
    public void init() {
       //do some BD access here
    }
}
</code>```

When I deploy the application I get the error

```<code>weblogic.management.DeploymentException: org.jboss.weld.exceptions.DeploymentException: WELD-001417 Enabled interceptor class <class>commons.utils.logging.performanceInterceptor.LoggingInterceptor    </class> in file:/D:/projectos/myProject/target/myProject/WEB-INF/beans.xml@7 is neither annotated @Interceptor nor registered through a portable extension:org.jboss.weld.exceptions.DeploymentException:WELD-001417 Enabled interceptor class <class>commons.utils.logging.performanceInterceptor.LoggingInterceptor</class> in file:/D:/projectos/myProject/target/myProject/WEB-INF/beans.xml@7 is neither annotated @Interceptor nor registered through a portable extension
at org.jboss.weld.bootstrap.Validator.validateEnabledInterceptorClasses(Validator.java:503)
at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:373)
at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:379)
at com.oracle.injection.provider.weld.WeldInjectionContainer.start(WeldInjectionContainer.java:110)
at com.oracle.injection.integration.CDIAppDeploymentExtension.initCdi(CDIAppDeploymentExtension.java:76)
</code>```

My first tought was that because the Interceptor is inside a jar that's in project A lib, it was not visible. I upgraded to java-ee 7 version 1.0.3.Final and CDI 1.1 so that I could use the tag @Priority in LoggingInterceptor. The error disappeared, however it did not work (nothing was written to log). So I got back to java-ee 6 version 3.0.3.Final and CDI 1.0.

I'm guessing that maybe I cannot find the Interceptor because the path in beans.xml is not the correct one in the jar (it is inside \WEB-INF\lib\loggings-1.2.jar\commons\utils\logging\performanceInterceptor).

Does anyone have an idea of what might be wrong?

答:
1) In your beans.xml add the tag bean-discovery-mode as in the example above:

```<code><beans
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
                           http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
    version="1.1"
    bean-discovery-mode="all">
    <interceptors>
        <class>YOUR_CLASS__FROM_THE_JAR</class>
    </interceptors>
</beans>
</code>```

2) In the jar which contains the interceptor add inside src/main/resources a folder called META-INF and inside a beans.xml file without the <interceptors> tag.

That worked for me.

Also, try creating a standalone container(I recommend WELD) in a class with the method main and test your interceptor.

Title: Why is my Interceptor not working?

Body:
I have two different projects: A and B.

B contains one Interceptor that I'd like to use in project A and, in the future, projects C and D.

I'm using jboss-javaee-6.0 version 3.0.3.Final in both projects (this means, CDI version 1.0).

Project B (does not contain beans.xml):

@InterceptorBinding
@Target({TYPE, METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface PerformanceLog {
}

@Interceptor
@PerformanceLog
public class LoggingInterceptor {
    private static final Logger LOG = LoggerFactory.getLogger(LoggingInterceptor.class);

    @AroundInvoke
    public Object logMethodEntry(InvocationContext ctx) throws Exception {
        LOG.debug("Entered method (" + ctx.getMethod().getName() + ") of class (" + ctx.getMethod().getClass() + ").");
    }
}

Project A (contains beans.xml):

beans.xml (declares Interceptor in order to activate it):

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">

<interceptors>
    <class>commons.utils.logging.performanceInterceptor.LoggingInterceptor</class>
</interceptors>
</beans>

MyControllerC:

@Named
@RequestScoped
public class MyControllerC implements Serializable {
     ...

    @PerformanceLog
    public void init() {
       //do some BD access here
    }
}

When I deploy the application I get the error

weblogic.management.DeploymentException: org.jboss.weld.exceptions.DeploymentException: WELD-001417 Enabled interceptor class <class>commons.utils.logging.performanceInterceptor.LoggingInterceptor    </class> in file:/D:/projectos/myProject/target/myProject/WEB-INF/beans.xml@7 is neither annotated @Interceptor nor registered through a portable extension:org.jboss.weld.exceptions.DeploymentException:WELD-001417 Enabled interceptor class <class>commons.utils.logging.performanceInterceptor.LoggingInterceptor</class> in file:/D:/projectos/myProject/target/myProject/WEB-INF/beans.xml@7 is neither annotated @Interceptor nor registered through a portable extension
at org.jboss.weld.bootstrap.Validator.validateEnabledInterceptorClasses(Validator.java:503)
at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:373)
at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:379)
at com.oracle.injection.provider.weld.WeldInjectionContainer.start(WeldInjectionContainer.java:110)
at com.oracle.injection.integration.CDIAppDeploymentExtension.initCdi(CDIAppDeploymentExtension.java:76)

My first tought was that because the Interceptor is inside a jar that's in project A lib, it was not visible. I upgraded to java-ee 7 version 1.0.3.Final and CDI 1.1 so that I could use the tag @Priority in LoggingInterceptor. The error disappeared, however it did not work (nothing was written to log). So I got back to java-ee 6 version 3.0.3.Final and CDI 1.0.

I'm guessing that maybe I cannot find the Interceptor because the path in beans.xml is not the correct one in the jar (it is inside \WEB-INF\lib\loggings-1.2.jar\commons\utils\logging\performanceInterceptor).

Does anyone have an idea of what might be wrong?

Body:
1) In your beans.xml add the tag bean-discovery-mode as in the example above:

<beans
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
                           http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
    version="1.1"
    bean-discovery-mode="all">
    <interceptors>
        <class>YOUR_CLASS__FROM_THE_JAR</class>
    </interceptors>
</beans>

2) In the jar which contains the interceptor add inside src/main/resources a folder called META-INF and inside a beans.xml file without the <interceptors> tag.

That worked for me.

Also, try creating a standalone container(I recommend WELD) in a class with the method main and test your interceptor.


答:
first of all

```<code>document.getElementById(button.id)
</code>```

will gives you button which is already you have.

second you should apss your element to jquery to use thats addClass method

```<code>$(button).addClass("someclass");
</code>```

Title: Passing ID Of Dynamic Javascript HTML

Body:
I'm trying to pass the element itself, or id. How can I make this work?

onclick="addYes(this)"

for (var i = 0; i < data.length; i++) {
  tempTable+= '
'+
    ''+
    data[i].service+
    '	'+
    '	'+
    ''+
    'Yes'+
    '	'+
    '
';
}

function addYes(button){
  //shows nothing:
  alert(button.id);
  //not working:
  document.getElementById(button.id).addClass("clicked_yes");
  //unrecognized method:
  button.addClass("clicked_yes");
}

Body:
first of all

document.getElementById(button.id)

will gives you button which is already you have.

second you should apss your element to jquery to use thats addClass method

$(button).addClass("someclass");


问:
Pentaho | Centos
I am working in Pentaho Data Integretion.
We have developed the transformations and Job in spoon.
We want to move our code on server and server is Centos.

In Centos, we are getting errors while installing UI of Pentaho. We are able to install kitchen on Centos.

Can we run our transformations and job directly with Kitchen?
If yes, how?

Waiting for reply.

答:
You can try to use Carte on centos.
http://wiki.pentaho.com/display/EAI/Carte+User+Documentation

So you start carte server and run your jobs and transformations at this carte server.

Title: Pentaho | Centos


问:
How to hide a tweet from TimeLine in Twitter API
I am working on TwitterKit in iOS SDK. I am showing TimeLine tweets for a user in tableview cell.

User want to delete a tweet posted by others from his/her time line but I am getting following error

```<code>Twitter API error : You may not delete another user's status. (code 183)
</code>```

On search I found following link

Link saying 'The authenticating user must be the author of the specified status'

Can anyone suggest how to remove a tweet posted by others from user timeline. Is there any API to hide the tweets from TimeLine?

Please suggest.

答: There is no way for a user to delete the Tweet(s) of another user. You would have to implement some custom view handling to remove table cells from the timeline.</p>

Body:
I am working on TwitterKit in iOS SDK. I am showing TimeLine tweets for a user in tableview cell.

User want to delete a tweet posted by others from his/her time line but I am getting following error

Twitter API error : You may not delete another user's status. (code 183)

On search I found following link

Link saying 'The authenticating user must be the author of the specified status'

Can anyone suggest how to remove a tweet posted by others from user timeline. Is there any API to hide the tweets from TimeLine?

Please suggest.


问:
how do i include BSP library in a c++ program?
im trying to compile c++ parellel program using BSPlib , on a platfrom that has bsp compile ( bsp++). Nevertheless , it doesnt seem to recognize any of the bsp functions.

what should i do in order to include / import/ tell the compiler that im using bsp?

include bsplib? bsplib.h ?

thanks

答:
```<code>#include "bsplib.h"
</code>```

then add bsplib to the link library list.

Body:
#include "bsplib.h"

then add bsplib to the link library list.


问:
Pandas Columns Operations with List
I have a pandas dataframe with two columns, the first one with just a single date ('action_date') and the second one with a list of dates ('verification_date'). I am trying to calculate the time difference between the date in 'action_date' and each of the dates in the list in the corresponding 'verification_date' column, and then fill the df new columns with the number of dates in verification_date that have a difference of either over or under 360 days.

Here is my code:

```<code>df = pd.DataFrame()
df['action_date'] = ['2017-01-01', '2017-01-01', '2017-01-03']
df['action_date'] = pd.to_datetime(df['action_date'], format="%Y-%m-%d")
df['verification_date'] = ['2016-01-01', '2015-01-08', '2017-01-01']
df['verification_date'] = pd.to_datetime(df['verification_date'], format="%Y-%m-%d")
df['user_name'] = ['abc', 'wdt', 'sdf']
df.index = df.action_date
df = df.groupby(pd.TimeGrouper(freq='2D'))['verification_date'].apply(list).reset_index()

def make_columns(df):
    df = df
    for i in range(len(df)):
        over_360 = []
        under_360 = []
        for w in [(df['action_date'][i]-x).days for x in df['verification_date'][i]]:
            if w > 360:
                over_360.append(w)
            else:
                under_360.append(w)
        df['over_360'] = len(over_360)
        df['under_360'] = len(under_360)
return df

make_columns(df)
</code>```

This kinda works EXCEPT the df has the same values for each row, which is not true as the dates are different. For example, in the first row of the dataframe, there IS a difference of over 360 days between the action_date and both of the items in the list in the verification_date column, so the over_360 column should be populated with 2. However, it is empty and instead the under_360 column is populated with 1, which is accurate only for the second row in 'action_date'.

I have a feeling I'm just messing up the looping but am really stuck. Thanks for all help!

答:
you might want to try this:

```<code>df['over_360'] = df.apply(lambda x: sum([((x['action_date'] - i).days >360) for i in x['verification_date']]) , axis=1)
df['under_360'] = df.apply(lambda x: sum([((x['action_date'] - i).days <360) for i in x['verification_date']]) , axis=1)
</code>```

I believe it should be a bit faster.
You didn't specify what to do if == 360, so you can just change > or < into >= or <=.

Title: Pandas Columns Operations with List

Body:
I have a pandas dataframe with two columns, the first one with just a single date ('action_date') and the second one with a list of dates ('verification_date'). I am trying to calculate the time difference between the date in 'action_date' and each of the dates in the list in the corresponding 'verification_date' column, and then fill the df new columns with the number of dates in verification_date that have a difference of either over or under 360 days.

Here is my code:

df = pd.DataFrame()
df['action_date'] = ['2017-01-01', '2017-01-01', '2017-01-03']
df['action_date'] = pd.to_datetime(df['action_date'], format="%Y-%m-%d")
df['verification_date'] = ['2016-01-01', '2015-01-08', '2017-01-01']
df['verification_date'] = pd.to_datetime(df['verification_date'], format="%Y-%m-%d")
df['user_name'] = ['abc', 'wdt', 'sdf']
df.index = df.action_date
df = df.groupby(pd.TimeGrouper(freq='2D'))['verification_date'].apply(list).reset_index()

def make_columns(df):
    df = df
    for i in range(len(df)):
        over_360 = []
        under_360 = []
        for w in [(df['action_date'][i]-x).days for x in df['verification_date'][i]]:
            if w > 360:
                over_360.append(w)
            else:
                under_360.append(w)
        df['over_360'] = len(over_360)
        df['under_360'] = len(under_360)
return df

make_columns(df)

This kinda works EXCEPT the df has the same values for each row, which is not true as the dates are different. For example, in the first row of the dataframe, there IS a difference of over 360 days between the action_date and both of the items in the list in the verification_date column, so the over_360 column should be populated with 2. However, it is empty and instead the under_360 column is populated with 1, which is accurate only for the second row in 'action_date'.

I have a feeling I'm just messing up the looping but am really stuck. Thanks for all help!

Body:
you might want to try this:

df['over_360'] = df.apply(lambda x: sum([((x['action_date'] - i).days >360) for i in x['verification_date']]) , axis=1)
df['under_360'] = df.apply(lambda x: sum([((x['action_date'] - i).days <360) for i in x['verification_date']]) , axis=1)

I believe it should be a bit faster.
You didn't specify what to do if == 360, so you can just change > or < into >= or <=.


问:
How to implement anonymous comparator inside stream API, more precisely sorted()?
I have a Doctor class and collection of objects of class Doctor (cd),
each doctor has a collection of patients inside, and i need to sort doctors by number of patients and return collection of Strings with their names and number of patients, so this is my code:

```<code>    Collection <String> output;
    output = cd.stream()
               .sorted(new Comparator<Doctor>(){
                    @Override
                    public int compare(Doctor d1, Doctor d2){
                    return d1.getPatients().size()-d2.getPatients().size();}})
            .map(String.format("%d : %s %s", d->d.getPatients().size, d.getName, d.getSurname))
            .collect(Collectors.toList());
</code>```

So my question is whether the code above is correct and can it be done better without implementaion of Comparable interface? Also could you help me with String.format part of the code, something is wrong there.

Thanks

Edit1 Sorry for uncertainty regarding String.format() the Eclipse says:

d cannot be resolved to a variable

答:
There is a handy comparing method in Comparator to save you having to manually write comparators.

You can use it like this:

```<code>output = cd.stream()
           .sorted(Comparator.comparing(d -> d.getPatients().size()))
...
</code>```

As Holger points out, since you are comparing an int, you might prefer to use comparingInt in place of comparing.

For the formatting part, map expects a function (which is what d -> ... means), and the arguments to format should just be values, not functions.

So you can do your formatting using:

```<code>           .map(d -> String.format("%d : %s %s", d.getPatients().size(), d.getName(), d.getSurname()))
</code>```

Body:
I have a Doctor class and collection of objects of class Doctor (cd),
each doctor has a collection of patients inside, and i need to sort doctors by number of patients and return collection of Strings with their names and number of patients, so this is my code:

    Collection <String> output;
    output = cd.stream()
               .sorted(new Comparator<Doctor>(){
                    @Override
                    public int compare(Doctor d1, Doctor d2){
                    return d1.getPatients().size()-d2.getPatients().size();}})
            .map(String.format("%d : %s %s", d->d.getPatients().size, d.getName, d.getSurname))
            .collect(Collectors.toList());

So my question is whether the code above is correct and can it be done better without implementaion of Comparable interface? Also could you help me with String.format part of the code, something is wrong there.

Thanks

Edit1 Sorry for uncertainty regarding String.format() the Eclipse says:

d cannot be resolved to a variable

Body:
There is a handy comparing method in Comparator to save you having to manually write comparators.

You can use it like this:

output = cd.stream()
           .sorted(Comparator.comparing(d -> d.getPatients().size()))
...

As Holger points out, since you are comparing an int, you might prefer to use comparingInt in place of comparing.

For the formatting part, map expects a function (which is what d -> ... means), and the arguments to format should just be values, not functions.

So you can do your formatting using:

           .map(d -> String.format("%d : %s %s", d.getPatients().size(), d.getName(), d.getSurname()))


问:
osmdroid Polygon - adding a new point in a triangle
I can make a polygon using the singleTapConfirmedHelper(). But I still have a problem. How do I remove the line(blue arrow) when adding a fourth point(red circle). The line does not disappear after I add the fourth point. I hope I explained it well. Thank you.

```<code>    @Override
    public boolean singleTapConfirmedHelper(GeoPoint p) {

    Polygon circle = new Polygon();
    circle.setPoints(Polygon.pointsAsCircle(p, 2.0));
    circle.setFillColor(0x12121212);
    circle.setStrokeColor(Color.RED);
    circle.setStrokeWidth(2);
    map.getOverlays().add(circle);
    circle.setInfoWindow(new
    BasicInfoWindow(org.osmdroid.bonuspack.R.layout.bonuspack_bubble,
    map));
    circle.setTitle("Centered on " + p.getLatitude() + "," +
    p.getLongitude());

    List<GeoPoint> pts = new ArrayList<>();
    pts.add(new GeoPoint(p.getLatitude(), p.getLongitude()));

    Polygon polygon = new Polygon(ctx);
    polygon.setTitle("This is a polygon");
    polygon.setSubDescription(Polygon.class.getCanonicalName());
    polygon.setFillColor(0x12121212);
    polygon.setVisible(true);
    polygon.setStrokeColor(Color.BLACK);
    polygon.setStrokeWidth(4);
    polygon.setInfoWindow(new
    BasicInfoWindow(R.layout.bonuspack_bubble, map));
    polygon.setPoints(pts);
    map.getOverlays().add(polygon);

    map.invalidate();

    return true;
}
</code>```

答:
You are drawing new polygon for each point added and you are not removing old ones. So theMapView will draw them all one over another. You should remove previously drawn polygon from list of overlays before calling map.invalidate().</p>

```<code>Polygon polygon = new Polygon(ctx);
polygon.setTitle("This is a polygon");
polygon.setSubDescription(Polygon.class.getCanonicalName());
polygon.setFillColor(0x12121212);
polygon.setVisible(true);
polygon.setStrokeColor(Color.BLACK);
polygon.setStrokeWidth(4);
polygon.setInfoWindow(new
BasicInfoWindow(R.layout.bonuspack_bubble, map));
polygon.setPoints(pts);
map.getOverlays().add(polygon);
if (oldPolygon != null) {
   map.getOverlays().remove(oldPolygon);
}
oldPolygon = polygon;

map.invalidate();
</code>```

Body:
I can make a polygon using the singleTapConfirmedHelper(). But I still have a problem. How do I remove the line(blue arrow) when adding a fourth point(red circle). The line does not disappear after I add the fourth point. I hope I explained it well. Thank you.

    @Override
    public boolean singleTapConfirmedHelper(GeoPoint p) {

    Polygon circle = new Polygon();
    circle.setPoints(Polygon.pointsAsCircle(p, 2.0));
    circle.setFillColor(0x12121212);
    circle.setStrokeColor(Color.RED);
    circle.setStrokeWidth(2);
    map.getOverlays().add(circle);
    circle.setInfoWindow(new
    BasicInfoWindow(org.osmdroid.bonuspack.R.layout.bonuspack_bubble,
    map));
    circle.setTitle("Centered on " + p.getLatitude() + "," +
    p.getLongitude());

    List<GeoPoint> pts = new ArrayList<>();
    pts.add(new GeoPoint(p.getLatitude(), p.getLongitude()));

    Polygon polygon = new Polygon(ctx);
    polygon.setTitle("This is a polygon");
    polygon.setSubDescription(Polygon.class.getCanonicalName());
    polygon.setFillColor(0x12121212);
    polygon.setVisible(true);
    polygon.setStrokeColor(Color.BLACK);
    polygon.setStrokeWidth(4);
    polygon.setInfoWindow(new
    BasicInfoWindow(R.layout.bonuspack_bubble, map));
    polygon.setPoints(pts);
    map.getOverlays().add(polygon);

    map.invalidate();

    return true;
}

Body:
You are drawing new polygon for each point added and you are not removing old ones. So theMapView will draw them all one over another. You should remove previously drawn polygon from list of overlays before calling map.invalidate().

Polygon polygon = new Polygon(ctx);
polygon.setTitle("This is a polygon");
polygon.setSubDescription(Polygon.class.getCanonicalName());
polygon.setFillColor(0x12121212);
polygon.setVisible(true);
polygon.setStrokeColor(Color.BLACK);
polygon.setStrokeWidth(4);
polygon.setInfoWindow(new
BasicInfoWindow(R.layout.bonuspack_bubble, map));
polygon.setPoints(pts);
map.getOverlays().add(polygon);
if (oldPolygon != null) {
   map.getOverlays().remove(oldPolygon);
}
oldPolygon = polygon;

map.invalidate();


问:
Having hard time to start GCE VM with GPU in us-east-1
We are having problem to start a simple GCE VM with GPU in us-central-1. I am wondering if anyone experience the same thing. The error we got is below:

Instance 'instance-group-2-vc37' creation failed: The resource 'projects/xxxxx-xxxx-858/zones/us-central1-a/acceleratorTypes/nvidia-tesla-k80' was not found (when acting as 'xxxxxxx@cloudservices.gserviceaccount.com')

Thanks

答:
GCE doesn't offer GPUs in us-central1. The docs list which regions GPUs are available in.

Cloud ML Engine is a separate product and not what you are using here.


问:
How do you log an int on Android?
I'm logging this:

```<code>Log.d(getClass().getName(), "BLA BLA BLA");
</code>```

How can I show an int value? What is the equivalent of C's %d?

答:
or you could use

```<code>Integer.toString(intVar);
</code>```

Assuming intVar is an Integer and not the primitive int.

Title: How do you log an int on Android?

Body:
I'm logging this:

Log.d(getClass().getName(), "BLA BLA BLA");

How can I show an int value? What is the equivalent of C's %d?

Body:
or you could use

Integer.toString(intVar);

Assuming intVar is an Integer and not the primitive int.


问:
ExcelVBA issues with IF else statement
i am new to excel VBA
i am currently working on a mapping using excel vba. the concept is if i click on cell c6 it colors the various cell boxes applicable to it same goes to cell C7. Both C6 and C7 have a common cell mapping which is cell E6 But now i noticed that when i click on Cell C6, this cell E6 doesnt show case its colour but when i click on C7 the colour on this cell E6 shows the color which means my C7 if else statement has overriden the C6 on that common cell E6 please how can i fix this so that when i click on them individually they return the color shows.
Below is my code:    </p>

```<code>Sub AccessControl1()
Range("C6").Interior.Color = RGB(255, 255, 0)
Range("D13").Interior.Color = RGB(154, 205, 50)

Range("E6").Interior.Color = RGB(154, 205, 50)

Range("F6").Interior.Color = RGB(154, 205, 50)
Range("AC6").Interior.Color = RGB(154, 205, 50)
Range("BH6").Interior.Color = RGB(154, 205, 50)
Range("DL7").Interior.Color = RGB(154, 205, 50)
Range("DF9").Interior.Color = RGB(154, 205, 50)
Range("DF6").Interior.Color = RGB(255, 20, 147)
Range("DA7").Interior.Color = RGB(255, 20, 147)
Range("DB23").Interior.Color = RGB(255, 20, 147)
Range("DF212").Interior.Color = RGB(255, 20, 147)
Range("DA215").Interior.Color = RGB(255, 20, 147)

End Sub
Sub AccessControl2()
Range("C6").Interior.Color = RGB(255, 255, 255)
Range("D13").Interior.Color = RGB(255, 255, 255)

Range("E6").Interior.Color = RGB(255, 255, 255)

Range("F6").Interior.Color = RGB(255, 255, 255)
Range("AC6").Interior.Color = RGB(255, 255, 255)
Range("BH6").Interior.Color = RGB(255, 255, 255)
Range("DL7").Interior.Color = RGB(255, 255, 255)
Range("DF9").Interior.Color = RGB(255, 255, 255)
Range("DF6").Interior.Color = RGB(255, 255, 255)
Range("DA7").Interior.Color = RGB(255, 255, 255)
Range("DB23").Interior.Color = RGB(255, 255, 255)
Range("DF212").Interior.Color = RGB(255, 255, 255)
Range("DA215").Interior.Color = RGB(255, 255, 255)
End Sub
Sub AccountManagement1()
Range("C7").Interior.Color = RGB(255, 255, 0)

Range("E6").Interior.Color = RGB(154, 205, 50)

Range("AE13").Interior.Color = RGB(154, 205, 50)
Range("AF6").Interior.Color = RGB(154, 205, 50)
Range("AG13").Interior.Color = RGB(154, 205, 50)
Range("AI6").Interior.Color = RGB(154, 205, 50)
Range("AJ13").Interior.Color = RGB(154, 205, 50)
Range("DA189").Interior.Color = RGB(255, 20, 147)
Range("DC195").Interior.Color = RGB(255, 20, 147)
Range("DA192").Interior.Color = RGB(255, 20, 147)
End Sub
Sub AccountManagement2()
Range("C7").Interior.Color = RGB(255, 255, 255)

Range("AE13").Interior.Color = RGB(255, 255, 255)
Range("AF6").Interior.Color = RGB(255, 255, 255)

Range("E6").Interior.Color = RGB(255, 255, 255)

Range("AG13").Interior.Color = RGB(255, 255, 255)
Range("AI6").Interior.Color = RGB(255, 255, 255)
Range("AJ13").Interior.Color = RGB(255, 255, 255)
Range("DA189").Interior.Color = RGB(255, 255, 255)
Range("DC195").Interior.Color = RGB(255, 255, 255)
Range("DA192").Interior.Color = RGB(255, 255, 255)
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Target.Address = "$C$6" Then
    Call AccessControl1
Else
    Call AccessControl2
End If
If Target.Address = "$C$7" Then
    Call AccountManagement1
Else
    Call AccountManagement2
End If
End Sub
</code>```

答:
As per the comment

on clicking Cell C6 Call AccessControl1 alone should be executed and when Cell C7 is clicked you want Call AccessControl2 followed by AccountManagement1 to be execute. Am I right? – Yes

Change your Worksheet_SelectionChange to the following:

```<code>Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
    If Target.Address = "$C$6" Then
        Call AccessControl1
    ElseIf Target.Address = "$C$7" Then
        Call AccessControl2
        Call AccountManagement1
    End If
End Sub
</code>```

Title: ExcelVBA issues with IF else statement

Body:
i am new to excel VBA
i am currently working on a mapping using excel vba. the concept is if i click on cell c6 it colors the various cell boxes applicable to it same goes to cell C7. Both C6 and C7 have a common cell mapping which is cell E6 But now i noticed that when i click on Cell C6, this cell E6 doesnt show case its colour but when i click on C7 the colour on this cell E6 shows the color which means my C7 if else statement has overriden the C6 on that common cell E6 please how can i fix this so that when i click on them individually they return the color shows.
Below is my code:

Sub AccessControl1()
Range("C6").Interior.Color = RGB(255, 255, 0)
Range("D13").Interior.Color = RGB(154, 205, 50)

Range("E6").Interior.Color = RGB(154, 205, 50)

Range("F6").Interior.Color = RGB(154, 205, 50)
Range("AC6").Interior.Color = RGB(154, 205, 50)
Range("BH6").Interior.Color = RGB(154, 205, 50)
Range("DL7").Interior.Color = RGB(154, 205, 50)
Range("DF9").Interior.Color = RGB(154, 205, 50)
Range("DF6").Interior.Color = RGB(255, 20, 147)
Range("DA7").Interior.Color = RGB(255, 20, 147)
Range("DB23").Interior.Color = RGB(255, 20, 147)
Range("DF212").Interior.Color = RGB(255, 20, 147)
Range("DA215").Interior.Color = RGB(255, 20, 147)

End Sub
Sub AccessControl2()
Range("C6").Interior.Color = RGB(255, 255, 255)
Range("D13").Interior.Color = RGB(255, 255, 255)

Range("E6").Interior.Color = RGB(255, 255, 255)

Range("F6").Interior.Color = RGB(255, 255, 255)
Range("AC6").Interior.Color = RGB(255, 255, 255)
Range("BH6").Interior.Color = RGB(255, 255, 255)
Range("DL7").Interior.Color = RGB(255, 255, 255)
Range("DF9").Interior.Color = RGB(255, 255, 255)
Range("DF6").Interior.Color = RGB(255, 255, 255)
Range("DA7").Interior.Color = RGB(255, 255, 255)
Range("DB23").Interior.Color = RGB(255, 255, 255)
Range("DF212").Interior.Color = RGB(255, 255, 255)
Range("DA215").Interior.Color = RGB(255, 255, 255)
End Sub
Sub AccountManagement1()
Range("C7").Interior.Color = RGB(255, 255, 0)

Range("E6").Interior.Color = RGB(154, 205, 50)

Range("AE13").Interior.Color = RGB(154, 205, 50)
Range("AF6").Interior.Color = RGB(154, 205, 50)
Range("AG13").Interior.Color = RGB(154, 205, 50)
Range("AI6").Interior.Color = RGB(154, 205, 50)
Range("AJ13").Interior.Color = RGB(154, 205, 50)
Range("DA189").Interior.Color = RGB(255, 20, 147)
Range("DC195").Interior.Color = RGB(255, 20, 147)
Range("DA192").Interior.Color = RGB(255, 20, 147)
End Sub
Sub AccountManagement2()
Range("C7").Interior.Color = RGB(255, 255, 255)

Range("AE13").Interior.Color = RGB(255, 255, 255)
Range("AF6").Interior.Color = RGB(255, 255, 255)

Range("E6").Interior.Color = RGB(255, 255, 255)

Range("AG13").Interior.Color = RGB(255, 255, 255)
Range("AI6").Interior.Color = RGB(255, 255, 255)
Range("AJ13").Interior.Color = RGB(255, 255, 255)
Range("DA189").Interior.Color = RGB(255, 255, 255)
Range("DC195").Interior.Color = RGB(255, 255, 255)
Range("DA192").Interior.Color = RGB(255, 255, 255)
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Target.Address = "$C$6" Then
    Call AccessControl1
Else
    Call AccessControl2
End If
If Target.Address = "$C$7" Then
    Call AccountManagement1
Else
    Call AccountManagement2
End If
End Sub

Body:
As per the comment

on clicking Cell C6 Call AccessControl1 alone should be executed and when Cell C7 is clicked you want Call AccessControl2 followed by AccountManagement1 to be execute. Am I right? – Yes

Change your Worksheet_SelectionChange to the following:

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
    If Target.Address = "$C$6" Then
        Call AccessControl1
    ElseIf Target.Address = "$C$7" Then
        Call AccessControl2
        Call AccountManagement1
    End If
End Sub


问:
python matplotlib: how to move the scale to the other side of the axis?
I have this weird thing with the scale of the axis showing out of the figure like:

And what I want to have:

How can I move the scale to the other side of the axis?

```<code>x=range(len(ticks))
plt.plot(x,phase1,'r^-',label='$\Delta \phi(U1,I1)$')
plt.plot(x,phase2,'go-',label='$\Delta \phi(U2,I2)$')
plt.plot(x,phase3,'b*-',label='$\Delta \phi(U3,I3)$')
plt.xticks(x,ticks,rotation=45)
plt.xlabel('Messung')
plt.ylabel('$\Delta \phi [^\circ]$')
plt.legend()
plt.show()
</code>```

答:
The tick_params of your axis can be used to control axes label and ticks location. Set direction to in so that they point into the graph.

And here is a great example if you want different y-axis ranges and colours too.

```<code>from matplotlib import pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111)
ax.tick_params(direction='in', length=6, width=2, colors='r', right=True, labelright='on')

plt.show()
</code>```

Body:
I have this weird thing with the scale of the axis showing out of the figure like:

And what I want to have:

How can I move the scale to the other side of the axis?

x=range(len(ticks))
plt.plot(x,phase1,'r^-',label='$\Delta \phi(U1,I1)$')
plt.plot(x,phase2,'go-',label='$\Delta \phi(U2,I2)$')
plt.plot(x,phase3,'b*-',label='$\Delta \phi(U3,I3)$')
plt.xticks(x,ticks,rotation=45)
plt.xlabel('Messung')
plt.ylabel('$\Delta \phi [^\circ]$')
plt.legend()
plt.show()

Body:
The tick_params of your axis can be used to control axes label and ticks location. Set direction to in so that they point into the graph.

And here is a great example if you want different y-axis ranges and colours too.

from matplotlib import pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111)
ax.tick_params(direction='in', length=6, width=2, colors='r', right=True, labelright='on')

plt.show()


问:
Website is not secure. Can it be fixed without https?
I have made a website for a small local company and on that website, there's a log-in-page so the staff can edit the content. The problem is that Google Chrome says the log-in-page isn't secure. I have tried searching for solutions, but everybody just says that I just make the website https. Are there other ways to do it? The company doesn't have the budget to pay for https.</p>

答:
You have enabled SSL on Your webserver. If you use Apache check this</p>

```<code>sudo a2dismod ssl
service apache2 restart
</code>```

Body:
You have enabled SSL on Your webserver. If you use Apache check this

sudo a2dismod ssl
service apache2 restart


问:
calculate md5 of image loaded in java webdriver
I want calculate md5 of images that loaded in webdriver in java.
webdriver is Firefox.

```<code>import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.JavascriptExecutor;

String script = "var imgElement = document.querySelector('div.mtl:nth-child(2) > div:nth-child(1) > img:nth-child(1))'; *** return md5 of image *** ";
String url = "http://www.facebook.com";

WebDriver webDriver = new FirefoxDriver();
driver.get(url);
JavascriptExecutor js = (JavascriptExecutor) driver;
Stgin md5 = (String) js.executeScript(script);
</code>```

in this code, what must replace with :

*** return md5 of image ***

答:
```<code>public void getImageMD5(){
    driver.get("https://www.blognone.com/");
    WebElement img = driver.findElement(By.cssSelector("img"));
    String imgUrl = img.getAttribute("src").trim();
    String script = "var callback = arguments[arguments.length - 1];"
                + "function _arrayBufferToBase64( buffer ) {"
                + "    var binary = '';"
                + "    var bytes = new Uint8Array( buffer );"
                + "    var len = bytes.byteLength;"
                + "    for (var i = 0; i < len; i++) {"
                + "        binary += String.fromCharCode( bytes[ i ] );"
                + "    }"
                + "    return window.btoa( binary );"
                + "}"
                + " fetch(' " + imgUrl + " ',{cache:'force-cache'})."
                + "then((response)=>{return response.arrayBuffer()})."
                + "then((response)=>{return _arrayBufferToBase64(response)})."
                + "then((response)=>{callback(response)});";
    driver.manage().timeouts().setScriptTimeout(15, TimeUnit.SECONDS);
    Object response = ((JavascriptExecutor) driver).executeAsyncScript(script, imgUrl);
            byte[] data = Base64.getDecoder().decode((String) response);
    MessageDigest md = MessageDigest.getInstance("MD5");
    byte[] hash = md.digest(data);

    StringBuilder sb = new StringBuilder(2 * hash.length);
    for (byte b : hash) {
        sb.append(String.format("%02x", b & 0xff));
    }

    String digest = sb.toString();
    System.out.println("MD5 of Image : " + digest);
}
</code>```

Body:
I want calculate md5 of images that loaded in webdriver in java.
webdriver is Firefox.

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.JavascriptExecutor;

String script = "var imgElement = document.querySelector('div.mtl:nth-child(2) > div:nth-child(1) > img:nth-child(1))'; *** return md5 of image *** ";
String url = "http://www.facebook.com";

WebDriver webDriver = new FirefoxDriver();
driver.get(url);
JavascriptExecutor js = (JavascriptExecutor) driver;
Stgin md5 = (String) js.executeScript(script);

in this code, what must replace with :

*** return md5 of image ***


问:
Can't hold session values
I have written a code for a login page and user page. When the user provides the correct username and password, my code creates a session variable rid and then redirects the user to user page.

But I am facing a weird problem, the session variable remains in the login page but when the code redirects to user page is says Notice: Undefined variable: _SESSION in /var/www/Avatar/test1.php on line 6.

Just to check if session is working properly I tries to output $_SESSION['rid'] on both the pages, it displays the rid on the login page, but on the user page I get the above error.

So I have created two sample pages test.php and test1.php. I am creating a session variable in test.php and then trying to display in in test1.php.

test.php :

```<code><?php
     $result=session_start();
     $_SESSION["Searock"]="Searock";
     echo $result;
     echo $_SESSION["Searock"];
?>
<html>
     <body>
          <a href="test1.php">next</a>
     </body>
</html>
</code>```

Output :

1 Searock next

test1.php :

```<code><?php
    echo $_SESSION["Searock"];
?>
</code>```

Output :

Notice: Undefined variable: _SESSION
  in /var/www/Avatar/test1.php on line 2

I don't know whether the problem is in my code or is it in PHP enviroment variables.

Heres a screen shot of phpinfo.

Can someone point me in a right direction ?

Thanks.

答:
In your test1.php file, you are missing session_start():

```<code><?php
    session_start();
    echo $_SESSION["Searock"];
?>
</code>```

You will need to have session_start() on top on any file you are using session related functions.

Title: Can't hold session values

Body:
I have written a code for a login page and user page. When the user provides the correct username and password, my code creates a session variable rid and then redirects the user to user page.

But I am facing a weird problem, the session variable remains in the login page but when the code redirects to user page is says Notice: Undefined variable: _SESSION in /var/www/Avatar/test1.php on line 6.

Just to check if session is working properly I tries to output $_SESSION['rid'] on both the pages, it displays the rid on the login page, but on the user page I get the above error.

So I have created two sample pages test.php and test1.php. I am creating a session variable in test.php and then trying to display in in test1.php.

test.php :

<?php
     $result=session_start();
     $_SESSION["Searock"]="Searock";
     echo $result;
     echo $_SESSION["Searock"];
?>

          next

Output :

1 Searock next

test1.php :

<?php
    echo $_SESSION["Searock"];
?>

Output :

Notice: Undefined variable: _SESSION
  in /var/www/Avatar/test1.php on line 2

I don't know whether the problem is in my code or is it in PHP enviroment variables.

Heres a screen shot of phpinfo.

Can someone point me in a right direction ?

Thanks.

Body:
In your test1.php file, you are missing session_start():

<?php
    session_start();
    echo $_SESSION["Searock"];
?>

You will need to have session_start() on top on any file you are using session related functions.


问:
Indexing across multiple intervals
I am trying to extract the n-th element from a set of multiple intervals. I am currently dealing with genome sequences. Assume we have a gene with a gap in the middle. The position of this gene within the whole DNA is:

```<code>gene = [100,110], [130,140]
# representing the lists [100,101,...,109] and [130, 131,...,139]
# the gene spans over these entries of the DNA, so it looks like -gene-gap-gene-
</code>```

Now, for a position within the gene (e.g. 10th position), I want to find the corresponding position on the whole DNA (which would be 109 in this example).
The function should do the following:

```<code>function(gene, 9)
> 109
function(gene, 10)
> 130
</code>```

My approach is to explicitly generate the two sequences, concatenate them and take the n-th element of this list. However, for large lists (as they happen to occur), this is very inefficient.

Can anyone think of a simple way?

Thanks in advance!

答:
your function can be provided both lists and you can find which list you should be indexing and where using the size of the lists

so if you do function(gene, 10) and function(gene, 11)

10 <= len(List1) but 11 > len(list1) so you know you need to access the second list in the case of 11, and the right element is 11 - len(list1) -1 which is index 0 but for the second list.

Title: Indexing across multiple intervals

Body:
I am trying to extract the n-th element from a set of multiple intervals. I am currently dealing with genome sequences. Assume we have a gene with a gap in the middle. The position of this gene within the whole DNA is:

gene = [100,110], [130,140]
# representing the lists [100,101,...,109] and [130, 131,...,139]
# the gene spans over these entries of the DNA, so it looks like -gene-gap-gene-

Now, for a position within the gene (e.g. 10th position), I want to find the corresponding position on the whole DNA (which would be 109 in this example).
The function should do the following:

function(gene, 9)
> 109
function(gene, 10)
> 130

My approach is to explicitly generate the two sequences, concatenate them and take the n-th element of this list. However, for large lists (as they happen to occur), this is very inefficient.

Can anyone think of a simple way?

Thanks in advance!