答:
Yeah, I've seen this before, coming from the Windows Explorer process. It's harmless, but basically what's happening is the client is trying to send non HTTP traffic through a HTTPS proxy tunnel, and because it's not legal HTTPS traffic, you get the weird parsing errors as shown in your screenshot.

Sadly, I don't remember my findings about what specific Windows feature causes this. See the wnpconnmanager.cpp remark at https://github.com/cvandeplas/plaso/blob/master/test_data/skydriveerr.log, maybe this is from the Windows Notification Service?

Title: Unknown https call from my computer

Body:
I captured weird call history from Fiddler.

The call repeatedly occurred.

I searched it with several keywords, but there were no clues.

Anyone know about this?

CNT https://1 CON 216
    Context: 67bc
    Last-Msg-Id: 0

------------------------------------------------------------------

CNT https://1 CON 231
Context: 6402
Last-Msg-Id: 159d428c446a5b3e

------------------------------------------------------------------

CNT https://1 CON 216
Context: 61ce
Last-Msg-Id: 0

------------------------------------------------------------------

CNT https://1 CON 231
Context: 5dc2
Last-Msg-Id: 159d428c446a5b3e

------------------------------------------------------------------

CNT https://1 CON 216
Context: 5be6
Last-Msg-Id: 0

------------------------------------------------------------------

CNT https://1 CON 231
Context: 581c
Last-Msg-Id: 159d428c446a5b3e

------------------------------------------------------------------

CNT https://1 CON 216
Context: 5642
Last-Msg-Id: 0

------------------------------------------------------------------

CNT https://1 CON 231
Context: 52bd
Last-Msg-Id: 159d428c446a5b3e

------------------------------------------------------------------

CNT https://1 CON 216
Context: 5156
Last-Msg-Id: 0

------------------------------------------------------------------

CNT https://1 CON 231
Context: 4da3
Last-Msg-Id: 159d428c446a5b3e

------------------------------------------------------------------

CNT https://1 CON 216
Context: 4cce
Last-Msg-Id: 0

------------------------------------------------------------------

CNT https://1 CON 231
Context: 4912
Last-Msg-Id: 159d428c446a5b3e

------------------------------------------------------------------

CNT https://1 CON 216
Context: 48c3
Last-Msg-Id: 0

------------------------------------------------------------------

CNT https://1 CON 231
Context: 4510
Last-Msg-Id: 159d428c446a5b3e

------------------------------------------------------------------

CNT https://1 CON 216
Context: 44f3
Last-Msg-Id: 0

------------------------------------------------------------------

CNT https://1 CON 231
Context: 4171
Last-Msg-Id: 159d428c446a5b3e

------------------------------------------------------------------

CNT https://1 CON 216
Context: 4164
Last-Msg-Id: 0

------------------------------------------------------------------

CNT https://1 CON 231
Context: 3e64
Last-Msg-Id: 159d428c446a5b3e

------------------------------------------------------------------

CNT https://1 CON 216
Context: 3e5e
Last-Msg-Id: 0

------------------------------------------------------------------

CNT https://1 CON 231
Context: 3bee
Last-Msg-Id: 159d428c446a5b3e

------------------------------------------------------------------

CNT https://1 CON 216
Context: 3bee
Last-Msg-Id: 0

------------------------------------------------------------------

CNT https://1 CON 231
Context: 39e7
Last-Msg-Id: 159d428c446a5b3e

------------------------------------------------------------------

CNT https://1 CON 216
Context: 39e7
Last-Msg-Id: 0

------------------------------------------------------------------

CNT https://1 CON 216
Context: 39dd
Last-Msg-Id: 0

------------------------------------------------------------------

CNT https://1 CON 231
Context: 39dd
Last-Msg-Id: 159d428c446a5b3e

------------------------------------------------------------------


来源: stackexchange

问:
Collecting information on where user clicks inside the app
I have created an iOS app using Swift to be used for a research project.
This app will pretty much only run on one specific device (iPhone7) and be used while the interviewer asks the user some question and the user uses the app to perform some tasks.

I would like to collect some statistics when the app is being used.
More precisely, I want to understand where the user actually clicks inside the app! I want to improve the User Interface and could use this data to see what buttons are being used and what buttons are not used.

I did some googling and came across some tools that pretty much claim to have this functionality, such as Appsee, UXCAM and Google Analytics.

I was wondering if there are any open source/free alternativ (SDK) to these paid solutions or should I start making something on my own from scratch.

The phone runs the app is also not connected to internet so the options above are not really suitable for my needs.

答:
The free version of Google Analytics has a Mobile SDK, but it's in the process of being phased out in favor of a recent Google acquisition: Firebase.

https://firebase.google.com/features/analytics/

If you need this level of tracking for a research project, the free version of Firebase is more than likely to meet your needs.

ContentLicense: CC BY-SA 3.0


问:
Javascript - Open a given URL in a new tab by clicking a button
I would like to have a button that redirects to a given URL and opens in a new tab. How can this be done?</p>

答:
My preferred method has the advantage of no JavaScript embedded in your markup:

CSS

```<code>a {
  color: inherit;
  text-decoration: none;
}
</code>```

HTML

```<code><a href="http://example.com" target="_blank"><input type="button" value="Link-button"></a>
</code>```

Body:
My preferred method has the advantage of no JavaScript embedded in your markup:

CSS

a {
  color: inherit;
  text-decoration: none;
}

HTML

<a href="http://example.com" target="_blank"><input type="button" value="Link-button"></a>

ContentLicense: CC BY-SA 4.0


问:
LINQ - double grouping with elements counting
As example I have the following list of PlanesLogRow objects

```<code>public class PlanesLogRow
{
    public DateTime ArriveDate;
    public string Origin;
    public string Destination;
}
</code>```

Need to get list of all of airports (Origin + Destination).Distinct()

Need to calc for every airport "arrived to airport" and "left from the airport" counts.

I need to create by one LINQ string tuple like <airport, AsOriginCount(arrivedToCount), AsDestinationCount(LeftFromCount)>

To get list of all of airports isn't a problem, but not sure how this can be done in case of such double grouping by different parameters

答:
If you have list of planes you can project each plane object into two anonymous objects - one for destination, and one for origin. Then group these anonymous objects by airport and calculate totals:

```<code>planes.SelectMany(p => new[] {
         new { Airport = p.origin, IsOrigin = true },
         new { Airport = p.destination, IsOrigin = false }
       })
       .GroupBy(x => x.Airport)
       .Select(g => new {
           Airport = g.Key,
           AsOriginCount = g.Count(x => x.IsOrigin),
           AsDestinationCount = g.Count(x => !x.IsOrigin)
       })
</code>```

For given planes:

```<code>var planes = new List<Plane> {
    new Plane { Origin = "Minsk", Destination = "London" },
    new Plane { Origin = "Barcelona", Destination = "Minsk" },
    new Plane { Origin = "Rome", Destination = "Minsk" },
    new Plane { Origin = "Barcelona", Destination = "London" },
    new Plane { Origin = "London", Destination = "Rome" },
};
</code>```

Output will be:

```<code>[
  { "Airport": "Minsk", "AsOriginCount": 1, "AsDestinationCount": 2 },
  { "Airport": "London", "AsOriginCount": 1, "AsDestinationCount": 2 },
  { "Airport": "Barcelona", "AsOriginCount": 2, "AsDestinationCount": 0 },
  { "Airport": "Rome", "AsOriginCount": 1, "AsDestinationCount": 1 }
]
</code>```

Update: This query will work with Entity Framework. Generated SQL will be big and scary.

Body:
As example I have the following list of PlanesLogRow objects

public class PlanesLogRow
{
    public DateTime ArriveDate;
    public string Origin;
    public string Destination;
}

Need to get list of all of airports (Origin + Destination).Distinct()

Need to calc for every airport "arrived to airport" and "left from the airport" counts.

I need to create by one LINQ string tuple like <airport, AsOriginCount(arrivedToCount), AsDestinationCount(LeftFromCount)>

To get list of all of airports isn't a problem, but not sure how this can be done in case of such double grouping by different parameters

Body:
If you have list of planes you can project each plane object into two anonymous objects - one for destination, and one for origin. Then group these anonymous objects by airport and calculate totals:

planes.SelectMany(p => new[] {
         new { Airport = p.origin, IsOrigin = true },
         new { Airport = p.destination, IsOrigin = false }
       })
       .GroupBy(x => x.Airport)
       .Select(g => new {
           Airport = g.Key,
           AsOriginCount = g.Count(x => x.IsOrigin),
           AsDestinationCount = g.Count(x => !x.IsOrigin)
       })

For given planes:

var planes = new List<Plane> {
    new Plane { Origin = "Minsk", Destination = "London" },
    new Plane { Origin = "Barcelona", Destination = "Minsk" },
    new Plane { Origin = "Rome", Destination = "Minsk" },
    new Plane { Origin = "Barcelona", Destination = "London" },
    new Plane { Origin = "London", Destination = "Rome" },
};

Output will be:

[
  { "Airport": "Minsk", "AsOriginCount": 1, "AsDestinationCount": 2 },
  { "Airport": "London", "AsOriginCount": 1, "AsDestinationCount": 2 },
  { "Airport": "Barcelona", "AsOriginCount": 2, "AsDestinationCount": 0 },
  { "Airport": "Rome", "AsOriginCount": 1, "AsDestinationCount": 1 }
]

Update: This query will work with Entity Framework. Generated SQL will be big and scary.


问:
How to debug the entry-point of fork-exec process in GDB?
I have a C linux application (A) that spawns another process (P) when it is started. When I want to debug P I start A as usual and I connect with ddd/gdb to P.

Problems appear when I want to debug the entry-point (start of main) of P. If I follow the usual approach when I connect the debugger to P is already to late. The solution I've found was to insert a sleep at the begining of the main of P so I have time to connect with gdb but this is not a very elegant solution.

I've also tried using asm("int $3") but it doesn't seems to work.

Do you have any idea how I could solve this problem? (preferably without altering the code of A or P)

答:
exec part with file + break main

The fork was part was explained at: https://stackoverflow.com/a/377295/895245

Now for the exec:

a.c:

```<code>#include <unistd.h>

int main(void) {
    execl("./b", "./b", "ab", "cd", (char*)NULL);
    return 1;
}
</code>```

b.c:

```<code>#include <stdio.h>

int main(int argc, char **argv ) {
    printf("%s\n", argv[0]);
    printf("%s\n", argv[1]);
}
</code>```

Then:

```<code>gcc -g a.c -o a
gcc -g b.c -o b
gdb -nh -q a
</code>```

Now on the interactive session:

```<code>Reading symbols from a...done.
(gdb) start
Temporary breakpoint 1 at 0x4004ea: file a.c, line 4.
Starting program: /home/ciro/test/gdb-exec/a

Temporary breakpoint 1, main () at a.c:4
4           execl("./b", "./b", "ab", "cd", (char*)NULL);
(gdb) file b
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
Load new symbol table from "b"? (y or n) y
Reading symbols from b...done.
(gdb) b main
Breakpoint 2 at 0x4004f5: file b.c, line 4.
(gdb) n

Breakpoint 2, main (argc=0, argv=0x7fffffffa570) at b.c:4
4               printf("%s\n", argv[1]);
(gdb) n
process 4877 is executing new program: /home/ciro/test/gdb-exec/b

Breakpoint 2, main (argc=3, argv=0x7fffffffa598) at b.c:4
4               printf("%s\n", argv[1]);
(gdb) n
ab
5               printf("%s\n", argv[2]);
(gdb) n
cd
6       }
(gdb)
</code>```

You just have to make sure that you go up to the exec before running file, possibly with a b execl, since after that you will be using symbols from the new file.

Tested in Ubuntu 14.04, gdb 7.7.1.

OwnerDisplayName: Ionut Anghelcovici

Body:
exec part with file + break main

The fork was part was explained at: https://stackoverflow.com/a/377295/895245

Now for the exec:

a.c:

#include <unistd.h>

int main(void) {
    execl("./b", "./b", "ab", "cd", (char*)NULL);
    return 1;
}

b.c:

#include <stdio.h>

int main(int argc, char **argv ) {
    printf("%s\n", argv[0]);
    printf("%s\n", argv[1]);
}

Then:

gcc -g a.c -o a
gcc -g b.c -o b
gdb -nh -q a

Now on the interactive session:

Reading symbols from a...done.
(gdb) start
Temporary breakpoint 1 at 0x4004ea: file a.c, line 4.
Starting program: /home/ciro/test/gdb-exec/a

Temporary breakpoint 1, main () at a.c:4
4           execl("./b", "./b", "ab", "cd", (char*)NULL);
(gdb) file b
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
Load new symbol table from "b"? (y or n) y
Reading symbols from b...done.
(gdb) b main
Breakpoint 2 at 0x4004f5: file b.c, line 4.
(gdb) n

Breakpoint 2, main (argc=0, argv=0x7fffffffa570) at b.c:4
4               printf("%s\n", argv[1]);
(gdb) n
process 4877 is executing new program: /home/ciro/test/gdb-exec/b

Breakpoint 2, main (argc=3, argv=0x7fffffffa598) at b.c:4
4               printf("%s\n", argv[1]);
(gdb) n
ab
5               printf("%s\n", argv[2]);
(gdb) n
cd
6       }
(gdb)

You just have to make sure that you go up to the exec before running file, possibly with a b execl, since after that you will be using symbols from the new file.

Tested in Ubuntu 14.04, gdb 7.7.1.


问:
Can i compile a c++ file within a c++ file execution without any extra programs or installations?
I was reading on Clang and Ch (c++ interpreters), but its not clear for me, is it possible to run a newly generated .cpp file without any installations? Because i need to run the final program on any pc...

ps. if yes, does anyone have a good example, where a .cpp file is being executed within c++ code?

答:
As far as I know, it is impossible, because compilation process of a CPP file is like this-

Preprocessing: the preprocessor takes a C++ source code file and deals with the #includes, #defines and other preprocessor directives. The output of this step is a "pure" C++ file without pre-processor directives.

Compilation: the compiler takes the pre-processor's output and produces an object file from it.

Linking: the linker takes the object files produced by the compiler and produces either a library or an executable file.

So, there should be intermediate files and executable files.

More can be found here-

https://stackoverflow.com/a/6264256/7725220


问:
Adding JavaScript to my Carousel
I don't know much about JavaScript, so how could I add some to get my carousel slides change every couple seconds? Do I need to change anything with my CSS or HTML to get it to work? Anything helps, thanks.

  .carousel {
      border-style:solid;
      border-width:1px;
      border-color:rgba(0, 0, 0, 0.05);
      box-shadow: 0px 1px 6px rgba(0, 0, 0, 0.1);
      widht:100%;
      height:250px;
  }

  .carousel-inner {
      position: relative;
      overflow: hidden;
      width: 100%;
      height:250px;
  }

  .carousel-open:checked + .carousel-item {
      position: absolute;
      opacity: 100;
      background-color:white;
      width:100%;
      height:250px;
  }

  .carousel-item {
      position: absolute;
      opacity: 0;
      padding-top:10px;
      text-align:center;
  }

  .carousel-control {
      background: rgba(0, 0, 0, 0);
      border-radius: 50%;
      color:#008c6c;
      cursor: pointer;
      display: none;
      font-size: 30px;
      height: 40px;
      line-height: 35px;
      position: absolute;
      top: 50%;
      -webkit-transform: translate(0, -50%);
      cursor: pointer;
      -ms-transform: translate(0, -50%);
      transform: translate(0, -50%);
      text-align: center;
      width: 40px;
      z-index: 10;
  }

  .carousel-control.prev {
      left: 2%;
  }

  .carousel-control.next {
      right: 2%;
  }

  .carousel-control:hover {
      background: rgba(0, 0, 0, 0.05);
      color: #008c6c;
  }

  #carousel-1:checked ~ .control-1,
  #carousel-2:checked ~ .control-2,
  #carousel-3:checked ~ .control-3,
  #carousel-4:checked ~ .control-4{
      display: block;
  }

  .carousel-indicators {
      margin: 0;
      padding: 0;
      position: absolute;
      bottom: 2px;
      left: 0;
      right: 0;
      text-align: center;
  }

  .carousel-indicators li {
      display: inline-block;
      margin: 0 5px;
  }

  .carousel-bullet {
      color: rgba(0, 0, 0, 0.05);
      cursor: pointer;
      font-size: 25px;
  }

  .carousel-bullet:hover {
      color: rgba(0, 0, 0, 0.1);
  }

  .HRConnectImage
  {width:375px;
  padding-top:50px;
  display:inline-block;}

  #carousel-1:checked ~ .control-1 ~ .carousel-indicators li:nth-child(1) .carousel-bullet,
  #carousel-2:checked ~ .control-2 ~ .carousel-indicators li:nth-child(2) .carousel-bullet,
  #carousel-3:checked ~ .control-3 ~ .carousel-indicators li:nth-child(3) .carousel-bullet,
  #carousel-4:checked ~ .control-4 ~ .carousel-indicators li:nth-child(4) .carousel-bullet{
      color: #008c6c;
  }

  #title {
      width: 100%;
      position: absolute;
      padding: 0px;
      margin: 0px auto;
      text-align: center;
      font-size: 27px;
      color: rgba(255, 255, 255, 1);
      font-family: 'Open Sans', sans-serif;
      z-index: 9999;
      text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.33), -1px 0px 2px rgba(255, 255, 255, 0);
  }

  ul
  {margin-left:40px;
  margin-right:60px;
  text-align:left;}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link href="http://wearenorthwest.northwest.ca/departments/humanresources/hr-connect-two/Documents/HRHome.css" rel="stylesheet"/>

  <div class="carousel">
     <div class="carousel-inner">
        <input name="carousel" class="carousel-open" id="carousel-1" aria-hidden="true" type="radio" hidden="true" Checked/>
        <div class="carousel-item">
  <h1>Slide 1</h1>
  <br/>
           <ul>
      <li>Content.</li>
    </ul>
        </div>
        <input name="carousel" class="carousel-open" id="carousel-2" aria-hidden="true" type="radio" hidden="true"/>
        <div class="carousel-item">
           <h1>Slide 2</h1>
  <br/>
           <ul>
      <li>Content.</li>
    </ul>
        </div>
        <input name="carousel" class="carousel-open" id="carousel-3" aria-hidden="true" type="radio" hidden="true"/>
        <div class="carousel-item">
           <h1>Slide 3</h1>
  <br/>
           <ul>
      <li>Content.</li>

    </ul>
        </div>
        <input name="carousel" class="carousel-open" id="carousel-4" aria-hidden="true" type="radio" hidden="true"/>
        <div class="carousel-item">
           <h1>Slide 4</h1>
  <br/>
           <ul>
      <li> Content.</li>

    </ul>
        </div>
        <label class="carousel-control prev control-1" for="carousel-4">‹</label>
        <label class="carousel-control next control-1" for="carousel-2">›</label>
        <label class="carousel-control prev control-2" for="carousel-1">‹</label>
        <label class="carousel-control next control-2" for="carousel-3">›</label>
        <label class="carousel-control prev control-3" for="carousel-2">‹</label>
        <label class="carousel-control next control-3" for="carousel-4">›</label>
        <label class="carousel-control prev control-4" for="carousel-3">‹</label>
        <label class="carousel-control next control-4" for="carousel-1">›</label>
        <ol class="carousel-indicators">
           <li>
              <label class="carousel-bullet" for="carousel-1">•</label> </li>
           <li>
              <label class="carousel-bullet" for="carousel-2">•</label> </li>
           <li>
              <label class="carousel-bullet" for="carousel-3">•</label> </li>
           <li>
              <label class="carousel-bullet" for="carousel-4">•</label> </li>
        </ol>
     </div>
  </div></code>```

答:
You can define a setInterval that alters the checked attribute of your checkboxes. Just modify the seconds variable to change the speed.

var carouselOpen = document.getElementsByClassName('carousel-open'),
    count = 1,
    seconds = 1;

function showSlide(el) {
  el.checked = true;
}

var interval = setInterval(function() {
  count = count % carouselOpen.length;
  showSlide(carouselOpen[count]);
  count++;
}, seconds*1000)```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.carousel {
      border-style:solid;
      border-width:1px;
      border-color:rgba(0, 0, 0, 0.05);
      box-shadow: 0px 1px 6px rgba(0, 0, 0, 0.1);
      widht:100%;
      height:250px;
  }

  .carousel-inner {
      position: relative;
      overflow: hidden;
      width: 100%;
      height:250px;
  }

  .carousel-open:checked + .carousel-item {
      position: absolute;
      opacity: 100;
      background-color:white;
      width:100%;
      height:250px;
  }

  .carousel-item {
      position: absolute;
      opacity: 0;
      padding-top:10px;
      text-align:center;
  }

  .carousel-control {
      background: rgba(0, 0, 0, 0);
      border-radius: 50%;
      color:#008c6c;
      cursor: pointer;
      display: none;
      font-size: 30px;
      height: 40px;
      line-height: 35px;
      position: absolute;
      top: 50%;
      -webkit-transform: translate(0, -50%);
      cursor: pointer;
      -ms-transform: translate(0, -50%);
      transform: translate(0, -50%);
      text-align: center;
      width: 40px;
      z-index: 10;
  }

  .carousel-control.prev {
      left: 2%;
  }

  .carousel-control.next {
      right: 2%;
  }

  .carousel-control:hover {
      background: rgba(0, 0, 0, 0.05);
      color: #008c6c;
  }

  #carousel-1:checked ~ .control-1,
  #carousel-2:checked ~ .control-2,
  #carousel-3:checked ~ .control-3,
  #carousel-4:checked ~ .control-4{
      display: block;
  }

  .carousel-indicators {
      margin: 0;
      padding: 0;
      position: absolute;
      bottom: 2px;
      left: 0;
      right: 0;
      text-align: center;
  }

  .carousel-indicators li {
      display: inline-block;
      margin: 0 5px;
  }

  .carousel-bullet {
      color: rgba(0, 0, 0, 0.05);
      cursor: pointer;
      font-size: 25px;
  }

  .carousel-bullet:hover {
      color: rgba(0, 0, 0, 0.1);
  }

  .HRConnectImage
  {width:375px;
  padding-top:50px;
  display:inline-block;}

  #carousel-1:checked ~ .control-1 ~ .carousel-indicators li:nth-child(1) .carousel-bullet,
  #carousel-2:checked ~ .control-2 ~ .carousel-indicators li:nth-child(2) .carousel-bullet,
  #carousel-3:checked ~ .control-3 ~ .carousel-indicators li:nth-child(3) .carousel-bullet,
  #carousel-4:checked ~ .control-4 ~ .carousel-indicators li:nth-child(4) .carousel-bullet{
      color: #008c6c;
  }

  #title {
      width: 100%;
      position: absolute;
      padding: 0px;
      margin: 0px auto;
      text-align: center;
      font-size: 27px;
      color: rgba(255, 255, 255, 1);
      font-family: 'Open Sans', sans-serif;
      z-index: 9999;
      text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.33), -1px 0px 2px rgba(255, 255, 255, 0);
  }

  ul
  {margin-left:40px;
  margin-right:60px;
  text-align:left;}</code>```

<link href="http://wearenorthwest.northwest.ca/departments/humanresources/hr-connect-two/Documents/HRHome.css" rel="stylesheet" />

    <input name="carousel" class="carousel-open" id="carousel-1" aria-hidden="true" type="radio" hidden="true" Checked/>

Slide 1

Content.

    <input name="carousel" class="carousel-open" id="carousel-2" aria-hidden="true" type="radio" hidden="true" />

Slide 2

Content.

    <input name="carousel" class="carousel-open" id="carousel-3" aria-hidden="true" type="radio" hidden="true" />

Slide 3

Content.

    <input name="carousel" class="carousel-open" id="carousel-4" aria-hidden="true" type="radio" hidden="true" />

Slide 4

 Content.

    ‹
    ›
    ‹
    ›
    ‹
    ›
    ‹
    ›

        •

        •

        •

        •

```

Title: Adding JavaScript to my Carousel

Body:
I don't know much about JavaScript, so how could I add some to get my carousel slides change every couple seconds? Do I need to change anything with my CSS or HTML to get it to work? Anything helps, thanks.

  .carousel {
      border-style:solid;
      border-width:1px;
      border-color:rgba(0, 0, 0, 0.05);
      box-shadow: 0px 1px 6px rgba(0, 0, 0, 0.1);
      widht:100%;
      height:250px;
  }

  .carousel-inner {
      position: relative;
      overflow: hidden;
      width: 100%;
      height:250px;
  }

  .carousel-open:checked + .carousel-item {
      position: absolute;
      opacity: 100;
      background-color:white;
      width:100%;
      height:250px;
  }

  .carousel-item {
      position: absolute;
      opacity: 0;
      padding-top:10px;
      text-align:center;
  }

  .carousel-control {
      background: rgba(0, 0, 0, 0);
      border-radius: 50%;
      color:#008c6c;
      cursor: pointer;
      display: none;
      font-size: 30px;
      height: 40px;
      line-height: 35px;
      position: absolute;
      top: 50%;
      -webkit-transform: translate(0, -50%);
      cursor: pointer;
      -ms-transform: translate(0, -50%);
      transform: translate(0, -50%);
      text-align: center;
      width: 40px;
      z-index: 10;
  }

  .carousel-control.prev {
      left: 2%;
  }

  .carousel-control.next {
      right: 2%;
  }

  .carousel-control:hover {
      background: rgba(0, 0, 0, 0.05);
      color: #008c6c;
  }

  #carousel-1:checked ~ .control-1,
  #carousel-2:checked ~ .control-2,
  #carousel-3:checked ~ .control-3,
  #carousel-4:checked ~ .control-4{
      display: block;
  }

  .carousel-indicators {
      margin: 0;
      padding: 0;
      position: absolute;
      bottom: 2px;
      left: 0;
      right: 0;
      text-align: center;
  }

  .carousel-indicators li {
      display: inline-block;
      margin: 0 5px;
  }

  .carousel-bullet {
      color: rgba(0, 0, 0, 0.05);
      cursor: pointer;
      font-size: 25px;
  }

  .carousel-bullet:hover {
      color: rgba(0, 0, 0, 0.1);
  }

  .HRConnectImage
  {width:375px;
  padding-top:50px;
  display:inline-block;}

  #carousel-1:checked ~ .control-1 ~ .carousel-indicators li:nth-child(1) .carousel-bullet,
  #carousel-2:checked ~ .control-2 ~ .carousel-indicators li:nth-child(2) .carousel-bullet,
  #carousel-3:checked ~ .control-3 ~ .carousel-indicators li:nth-child(3) .carousel-bullet,
  #carousel-4:checked ~ .control-4 ~ .carousel-indicators li:nth-child(4) .carousel-bullet{
      color: #008c6c;
  }

  #title {
      width: 100%;
      position: absolute;
      padding: 0px;
      margin: 0px auto;
      text-align: center;
      font-size: 27px;
      color: rgba(255, 255, 255, 1);
      font-family: 'Open Sans', sans-serif;
      z-index: 9999;
      text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.33), -1px 0px 2px rgba(255, 255, 255, 0);
  }

  ul
  {margin-left:40px;
  margin-right:60px;
  text-align:left;}

<link href="http://wearenorthwest.northwest.ca/departments/humanresources/hr-connect-two/Documents/HRHome.css" rel="stylesheet"/>

        <input name="carousel" class="carousel-open" id="carousel-1" aria-hidden="true" type="radio" hidden="true" Checked/>

Slide 1

Content.

        <input name="carousel" class="carousel-open" id="carousel-2" aria-hidden="true" type="radio" hidden="true"/>

Slide 2

Content.

        <input name="carousel" class="carousel-open" id="carousel-3" aria-hidden="true" type="radio" hidden="true"/>

Slide 3

Content.

        <input name="carousel" class="carousel-open" id="carousel-4" aria-hidden="true" type="radio" hidden="true"/>

Slide 4

 Content.

        ‹
        ›
        ‹
        ›
        ‹
        ›
        ‹
        ›

              •

              •

              •

              •

Body:
You can define a setInterval that alters the checked attribute of your checkboxes. Just modify the seconds variable to change the speed.

var carouselOpen = document.getElementsByClassName('carousel-open'),
    count = 1,
    seconds = 1;

function showSlide(el) {
  el.checked = true;
}

var interval = setInterval(function() {
  count = count % carouselOpen.length;
  showSlide(carouselOpen[count]);
  count++;
}, seconds*1000)

.carousel {
      border-style:solid;
      border-width:1px;
      border-color:rgba(0, 0, 0, 0.05);
      box-shadow: 0px 1px 6px rgba(0, 0, 0, 0.1);
      widht:100%;
      height:250px;
  }

  .carousel-inner {
      position: relative;
      overflow: hidden;
      width: 100%;
      height:250px;
  }

  .carousel-open:checked + .carousel-item {
      position: absolute;
      opacity: 100;
      background-color:white;
      width:100%;
      height:250px;
  }

  .carousel-item {
      position: absolute;
      opacity: 0;
      padding-top:10px;
      text-align:center;
  }

  .carousel-control {
      background: rgba(0, 0, 0, 0);
      border-radius: 50%;
      color:#008c6c;
      cursor: pointer;
      display: none;
      font-size: 30px;
      height: 40px;
      line-height: 35px;
      position: absolute;
      top: 50%;
      -webkit-transform: translate(0, -50%);
      cursor: pointer;
      -ms-transform: translate(0, -50%);
      transform: translate(0, -50%);
      text-align: center;
      width: 40px;
      z-index: 10;
  }

  .carousel-control.prev {
      left: 2%;
  }

  .carousel-control.next {
      right: 2%;
  }

  .carousel-control:hover {
      background: rgba(0, 0, 0, 0.05);
      color: #008c6c;
  }

  #carousel-1:checked ~ .control-1,
  #carousel-2:checked ~ .control-2,
  #carousel-3:checked ~ .control-3,
  #carousel-4:checked ~ .control-4{
      display: block;
  }

  .carousel-indicators {
      margin: 0;
      padding: 0;
      position: absolute;
      bottom: 2px;
      left: 0;
      right: 0;
      text-align: center;
  }

  .carousel-indicators li {
      display: inline-block;
      margin: 0 5px;
  }

  .carousel-bullet {
      color: rgba(0, 0, 0, 0.05);
      cursor: pointer;
      font-size: 25px;
  }

  .carousel-bullet:hover {
      color: rgba(0, 0, 0, 0.1);
  }

  .HRConnectImage
  {width:375px;
  padding-top:50px;
  display:inline-block;}

  #carousel-1:checked ~ .control-1 ~ .carousel-indicators li:nth-child(1) .carousel-bullet,
  #carousel-2:checked ~ .control-2 ~ .carousel-indicators li:nth-child(2) .carousel-bullet,
  #carousel-3:checked ~ .control-3 ~ .carousel-indicators li:nth-child(3) .carousel-bullet,
  #carousel-4:checked ~ .control-4 ~ .carousel-indicators li:nth-child(4) .carousel-bullet{
      color: #008c6c;
  }

  #title {
      width: 100%;
      position: absolute;
      padding: 0px;
      margin: 0px auto;
      text-align: center;
      font-size: 27px;
      color: rgba(255, 255, 255, 1);
      font-family: 'Open Sans', sans-serif;
      z-index: 9999;
      text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.33), -1px 0px 2px rgba(255, 255, 255, 0);
  }

  ul
  {margin-left:40px;
  margin-right:60px;
  text-align:left;}

<link href="http://wearenorthwest.northwest.ca/departments/humanresources/hr-connect-two/Documents/HRHome.css" rel="stylesheet" />

<div class="carousel">
  <div class="carousel-inner">
    <input name="carousel" class="carousel-open" id="carousel-1" aria-hidden="true" type="radio" hidden="true" Checked/>
    <div class="carousel-item">
      <h1>Slide 1</h1>
      <br/>
      <ul>
        <li>Content.</li>
      </ul>
    </div>
    <input name="carousel" class="carousel-open" id="carousel-2" aria-hidden="true" type="radio" hidden="true" />
    <div class="carousel-item">
      <h1>Slide 2</h1>
      <br/>
      <ul>
        <li>Content.</li>
      </ul>
    </div>
    <input name="carousel" class="carousel-open" id="carousel-3" aria-hidden="true" type="radio" hidden="true" />
    <div class="carousel-item">
      <h1>Slide 3</h1>
      <br/>
      <ul>
        <li>Content.</li>

      </ul>
    </div>
    <input name="carousel" class="carousel-open" id="carousel-4" aria-hidden="true" type="radio" hidden="true" />
    <div class="carousel-item">
      <h1>Slide 4</h1>
      <br/>
      <ul>
        <li> Content.</li>

      </ul>
    </div>
    <label class="carousel-control prev control-1" for="carousel-4">‹</label>
    <label class="carousel-control next control-1" for="carousel-2">›</label>
    <label class="carousel-control prev control-2" for="carousel-1">‹</label>
    <label class="carousel-control next control-2" for="carousel-3">›</label>
    <label class="carousel-control prev control-3" for="carousel-2">‹</label>
    <label class="carousel-control next control-3" for="carousel-4">›</label>
    <label class="carousel-control prev control-4" for="carousel-3">‹</label>
    <label class="carousel-control next control-4" for="carousel-1">›</label>
    <ol class="carousel-indicators">
      <li>
        <label class="carousel-bullet" for="carousel-1">•</label> </li>
      <li>
        <label class="carousel-bullet" for="carousel-2">•</label> </li>
      <li>
        <label class="carousel-bullet" for="carousel-3">•</label> </li>
      <li>
        <label class="carousel-bullet" for="carousel-4">•</label> </li>
    </ol>
  </div>
</div>


问:
processing this string with php
I have a text string that looks like this

```<code>var1=red&var2=green&var3=blue&var4=magenta
</code>```

How can manipulate this string isolate the value of var2 which in this case is green

答: Use the php function parse_str() to convert it to an array.</p>

ContentLicense: CC BY-SA 2.5

Title: processing this string with php

Body:
I have a text string that looks like this

var1=red&var2=green&var3=blue&var4=magenta

How can manipulate this string isolate the value of var2 which in this case is green


问:
How can I iterate on a Jekyll /Liquid collection items by batch of 3?
I have a base HTML structure where I display 3 items per row. In order to properly separate them, I use 2 borders (first/second second/third) like in the following schema:

```<code>ITEM1 | ITEM2 | ITEM3
</code>```

defined using SASS as follows:

```<code>         .middle {
                position: relative;
                z-index: 1;

                &:before {
                    content: '';
                    width: 32px;
                    height: 100%;
                    position: absolute;
                    left: -24px;
                    top: 0;
                    display: block;
                    z-index: -1;
                    box-shadow: 32px 0 0 0 #fff, 0 -32px 0 0 #fff, 0 32px 0 0 #fff, 32px 32px 0 0 #fff, 32px -32px 0 0 #fff, 0 0 32px 0 rgba(0, 0, 0, 0.15);
                }

                &:after {
                    content: '';
                    width: 32px;
                    height: 100%;
                    position: absolute;
                    right: -24px;
                    top: 0;
                    display: block;
                    z-index: -1;
                    box-shadow: -32px 0 0 0 #fff, 0 -32px 0 0 #fff, 0 32px 0 0 #fff, -32px 32px 0 0 #fff, -32px -32px 0 0 #fff, 0 0 32px 0 rgba(0, 0, 0, 0.15);
                }
            }
</code>```

I would like to distinguish between these 3 row items when I iterate on a Jekyll collection. To rephrase, iterate on items 3 by 3.
 it
I just started looking into Jekyll a couple hours ago and I could see that filters are available, but I have no idea of how to achieve this in a standard collection iteration like the following:

```<code>{% for item in array %}
    {{ item }}
{% endfor %}
</code>```

https://gist.github.com/smutnyleszek/9803727

答:
To be able to group items in a row while iterating we use the modulo filter:

Divides an output by a number and returns the remainder.

Then we can identify each iteration and more specifically, which of the three items we are processing by doing forloop.index | modulo: 3:

If the remainder is 1, is the first item in the row, if is 2 then it is the second one, if it is 0 it would be the third one. for example iterating through the array site.posts

```<code>{% for post in site.posts %}
{% assign mod = forloop.index | modulo: 3 %}
{{ mod }}:{{post.title}}
{% if mod == 1 %}
<div>first item</div>
{% elsif mod == 2 %}
<div class="middle">second item</div>
{% else %}
<div>third item</div>
<hr>
{% endif %}
<br>
{% endfor %}
</code>```

Note that based on your code I've applied the middle css class to the second item.

This would output:

```<code> 1:First post title
first item

2:Second post title
second item

0:Third post title
third item

-----------------

1:Fourth post title
first item
</code>```

Body:
I have a base HTML structure where I display 3 items per row. In order to properly separate them, I use 2 borders (first/second second/third) like in the following schema:

ITEM1 | ITEM2 | ITEM3

defined using SASS as follows:

         .middle {
                position: relative;
                z-index: 1;

                &:before {
                    content: '';
                    width: 32px;
                    height: 100%;
                    position: absolute;
                    left: -24px;
                    top: 0;
                    display: block;
                    z-index: -1;
                    box-shadow: 32px 0 0 0 #fff, 0 -32px 0 0 #fff, 0 32px 0 0 #fff, 32px 32px 0 0 #fff, 32px -32px 0 0 #fff, 0 0 32px 0 rgba(0, 0, 0, 0.15);
                }

                &:after {
                    content: '';
                    width: 32px;
                    height: 100%;
                    position: absolute;
                    right: -24px;
                    top: 0;
                    display: block;
                    z-index: -1;
                    box-shadow: -32px 0 0 0 #fff, 0 -32px 0 0 #fff, 0 32px 0 0 #fff, -32px 32px 0 0 #fff, -32px -32px 0 0 #fff, 0 0 32px 0 rgba(0, 0, 0, 0.15);
                }
            }

I would like to distinguish between these 3 row items when I iterate on a Jekyll collection. To rephrase, iterate on items 3 by 3.
 it
I just started looking into Jekyll a couple hours ago and I could see that filters are available, but I have no idea of how to achieve this in a standard collection iteration like the following:

{% for item in array %}
    {{ item }}
{% endfor %}

https://gist.github.com/smutnyleszek/9803727

Body:
To be able to group items in a row while iterating we use the modulo filter:

Divides an output by a number and returns the remainder.

Then we can identify each iteration and more specifically, which of the three items we are processing by doing forloop.index | modulo: 3:

If the remainder is 1, is the first item in the row, if is 2 then it is the second one, if it is 0 it would be the third one. for example iterating through the array site.posts

{% for post in site.posts %}
{% assign mod = forloop.index | modulo: 3 %}
{{ mod }}:{{post.title}}
{% if mod == 1 %}
<div>first item</div>
{% elsif mod == 2 %}
<div class="middle">second item</div>
{% else %}
<div>third item</div>
<hr>
{% endif %}
<br>
{% endfor %}

Note that based on your code I've applied the middle css class to the second item.

This would output:

 1:First post title
first item

2:Second post title
second item

0:Third post title
third item

-----------------

1:Fourth post title
first item


问:
.net native out of memory when compiling application with Syncfusion Controls
My application uses Syncfusion UWP chart control and EF7 Core RC2, with VS2015 preview 2.

I can compile the application fine with just the EF7 Core, but as soon as I add a reference to Syncfusion, I end up with very long compile times that end with ".net native out of memory" exception.

Syncfusion reference does not cause this effect in a different, very simple app.
Has anyone encountered this problem before and is it possible for this to be caused by my csProj settings?

答:
Yup. It's Syncfusion or maybe Microsoft, but don't just drag and drop a control from the Syncfusion toolbox onto your UWP app and try to compile it as .NET Native code. It will add a reference to the entire SDK, which will never finish compiling before running out of memory.

You can test this by trying to compile their sample browser as .NET Native if the spirit moves you.


问:
Setting up a 2-Column Grid Bootstrap
Hello I am trying to develop an alternating two column grid layout with bootstrap, where there would be one image on the lefthand size of the screen, then reverse down the web page until the end user reaches the footer.

I would thought to achieve this using the div row col order and going by using the floats, it has worked for the first row but when it came to developing the secondary row it did not help. I do not know if it is the floats that throwing it out of whack of I literally have to much going on in my code in general. Can someone review for me please? The blank divs are the image's as well.

/* CSS Document */

/* FONT FAMILY */

body{

 font-family: 'Montserrat', sans-serif;
}

p {

 font-family: 'Montserrat', Gotham, Helvetica Neue, Helvetica, Arial, "sans-serif";
 font-weight: 200;
 letter-spacing: 0.65px;
 line-height: 25px;
 text-align: center;
 color: white;
}

.lead {
 text-transform: uppercase;
}

h2 {
 margin-bottom: 1em;
 font-weight: 500;
 letter-spacing: 1.275px;
 font-size: 30px;
 color:  #cf6766;

}

h3 {
 margin-bottom: 1em;
 font-weight: 500;
 letter-spacing: 0.1em;
 font-size: 21px;
 color:  #cf6766;

}

/**************** NAVIGATION STYLING ****************/

.navbar,.navbar-default {

 background-color: #30415d;
 padding: 20px;
 color: white;
 margin: 0 auto;

}

.navbar.navbar-default li a {
 color: white;
 text-align: center;
 margin: 0 auto;

}

.navbar.navbar-default li a:hover{
 background-color: white;
 color: #031424;
 font-weight: bold;
}

.navbar.navbar-default li {
 font-weight: 300;
 letter-spacing: 0.10em;
 text-transform: uppercase;
 font-size: 12px;
}

.navbar-brand img {
 width: 85%;
 }

.navbar-brand a {

 padding: 20px;
 margin-top: -40px;
}

a.navbar-brand {
 margin-top: -20px;
 padding-right: 20px;
 padding-left: 20px;
 width: 85%;

}

.navbar-default {
 border: none;
}
/*img.wrap {
 float:right;
}*/

/**************HOME PAGE **********/

/* blockquote {

 background-color: #8eaebd;

 color: white;
 padding: 50px;
 margin-top: -50px;
 width: 100%;
 letter-spacing: 1.5;
 line-height: 1.5;
 text-align: center justify;
 font-size: 36px;
 margin-bottom: 50px;
 font-style: italic;
 font-weight: 400;

} */

.quote {
 font-size: 16px;
 text-align: right;
 font-weight: 300;
 letter-spacing: 2px;
}

.jumbotron {
 background:linear-gradient(#cf6766, transparent 100%),

  url(../img/DSC00154.jpg) no-repeat center;
 background-size: cover;
 height: 768px;
 margin-top: 0px;
 padding-top: 0px;
 display: table;
 width: 100%;

}

.jumbotron h1 {
 color: white;
 text-align: center;

}

#jumbotron-inner  {
 display: table-cell;
 vertical-align: middle;

}

#jumbotron-inner p {
 text-align: center;
}

.senior {

 background-color: #30415d;
 width: 50%;
 height: 500px;
 color:white;
 padding: 50px;

 letter-spacing: 1.5;
 line-height: 1.5;
 text-align: center justify;
 font-size: 16px;
 margin-bottom: 50px;
 float: left;
}

.get-involved {
 background-color: #8eaebd;
 color:white;
 padding: 50px;
 margin-top: -50px;
 width: 100%;
 letter-spacing: 1.5;
 line-height: 1.5;
 text-align: center justify;
 font-size: 16px;
 margin-bottom: 50px;
 float: right;
}

.get-inolved-img {

 background-image: url(../img/grandmother-child.jpg);
 background-position: center;
 background-size: cover;
 background-repeat: no-repeat;
 width: 100%;
 height: 500px;
 float: left;
}

.newMentor{
 background: url(../img/grandparents.jpg);
 background-position: center;
 background-size: cover;
 background-repeat: no-repeat;
 max-width:1000px 100%;
 height:500px;
 float: right;
}

.dontations {
 background-color: #30415d;
 color:white;
 padding: 50px;
 margin-top: -50px;
 width: 100%;
 letter-spacing: 1.5;
 line-height: 1.5;
 text-align: center justify;
 font-size: 16px;
 margin-bottom: 50px;
}

.btn-lg {

 background-color: #cf6766;
}

.btn-lg  {

 color: white;
 font-weight:200;
}

 .btn-lg a:hover  {
 color: #8eaebd;

}

/**************about PAGE **********/

#williams {
 width: 40%;
 height: 50%;
 margin-right: 25px;
 margin-bottom: 5px;
}

#goals {

 background-color: pink;
 padding: 20px;
}

#youth  {
 background-image: url(../img/youth-2.jpg);
 background-repeat:no-repeat;
 background-size: cover;
 background-position: center;
 width: 100%;
 height: 1000px;
}

#mentor {

    background-image: url(../img/youth-1.jpg);
    width: 100%;
    height: 500px;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    color: black;

}

#mentor h1 {
    color: rgba(0, 44, 44, 1);
}

#textarea {
   display: block;
}

textarea {

    display: block;
}

#community {

    background-image: url(../img/youth-3.jpg);
    width: 100%;
    height: 500px;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    color: black;

}

/***************************** FOOTER *****************************/

.copy {
 color: #cf6766;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>New Mentoring - 50- Home </title>

<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Montserrat:200,300,400,500,600" rel="stylesheet">
<link href="css/styles.css" rel="stylesheet">

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    </head>

<body>
<nav class="navbar navbar-default">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#defaultNavbar1"><span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button>

        <img src="img/logo.png" class="img-responsive"></div>
         <!-- Collect the nav links, forms, and other content for toggling -->
       <div class="collapse navbar-collapse" id="defaultNavbar1">
         <ul class="nav navbar-nav pull-right">
           <li class="active">Home<span class="sr-only">(current)</span></li>
           <li> About</li>
           <li>Saving the Youth</li>
           <li> Mentoring Tips</li>
      <li class="dropdown">Community <span class="caret"></span>
      <!-- DropDown Menu Here -->
     <ul class="dropdown-menu" role="menu">
      <li> Stories of Wisdom</li>
      <li> Guest Book</li>
      <li>Donate</li>
     </ul><!--community dropdown menu-->
     </li><!-- end of comunnity dropdown li & ul -->
            <li> Contact</li>
         </ul> <!-- end of navbar left -->
      </div> <!-- /.navbar-collapse -->
  </div> <!-- /.container-fluid -->
</nav> <!-- END OF FULL NAVIGATION BAR -->

<div class="jumbotron">
 <div class="container" id="jumbotron-inner">
    <h1>New Mentoring.com</h1>
     <p class="lead">Where our youth gain wisdom and leadership.</p>
      <p>Learn more</p>
 </div><!-- end of container & jumbtron inner -->
</div><!--jumbotron-->

<!-- BLOCKQUOTE-->
<blockquote>
 <p>"Let your age make the difference in your community."</p>

  <span class="pull-right quote">- Delece Williams</span>
</blockquote>

<div class="container-fluid">
  <div class="row">
   <div class="col-sm-6 senior">
  <h2>What is a New Mentoring?</h2>
 <p>The Middle Aged Generation that's considered to be between 30 to 80 whose living healthier, while inspiring youth to engage in healthier life-style choices and those helping to bridge the gap between the traditional values of seniors and the technical appetites of today's youth with wisdom keys. </p>
 </div>

  <div class="col-sm-6 newMentor">

  </div><!-- img div-->
 </div><!--row-->
  <div class="row">
   <div class="col-sm-6 get-involved">
    <h2>How to Get Involved?</h2>

<p>We would love for you to get involved and its simple.  Just be willing to share your time and /or stories, experience, wisdom and expertise to a young person to help them make better and healthier lifestyle choices for the success of a better path throughout life.  You can do that by joining our online conversations or hosting a community forum near you.</p>

 </div>

   <div class="col-sm-6 get-inolved-img">

   </div><!-- background img-->
</div><!--row-->
 <!--col-md-12->
  </div>
  <hr>
  <div class="row">
    <div class="text-justify col-sm-6">
    <h3>Stories of Wisdom</h3>
   Share words of wisdom on how you break barriers to get young people to listen. Connect with our online family and help us to inspire others here. </div>

 <div class="text-justify col-sm-6">
    <h3>Guest Book</h3>
   Thank you for visiting I Am The New 50 Campaign. Stop by and sign our guest book and be a part of our community. Tell us how we’ve inspired you to help youth  here. </div>
</div><!-- end of row div-->

    <div class="col-md-6 dontations">
      <h2>Dontations for Kidz Korna</h2>
       <p>Women &amps; Men T-Shirts are Available for Campaign Fundraising Initiatives</p>
        <div class="row">

     <div class="col-md-3">

           <img src="..." alt="...">

    </div>

       <div class="col-md-3">

           <img src="..." alt="...">

    </div>

       <div class="col-md-3">

           <img src="..." alt="...">

    </div>

        <div class="col-md-3">

           <img src="..." alt="...">

    </div>

    <p>Price:$20.00 <br>
     <br>
      Click here to order now </p>
        </div>
   </div>
 </div>
</div>

 <footer>
  <div class="row">
    <div class="text-center col-md-6 col-md-offset-3">

    <p class="copy">Copyright © 2017 · All Rights Reserved · New Mentoring · Chicago, IL.</p>
    </div>
  </div>
 </footer>

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="js/jquery-1.11.3.min.js"></script>

<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.js"></script>
</body>
</html></code>```

答:
I think you're describing a layout where it's like a checkerboard style. If so you can use offsets on every second div and clear the divs.

http://www.bootply.com/IMtdYhv7bs

HTML:

```<code><div class="col-md-6"></div>
<div class="col-md-6 col-md-offset-6"></div>
<div class="col-md-6"></div>
<div class="col-md-6 col-md-offset-6"></div>
<div class="col-md-6"></div>
<div class="col-md-6 col-md-offset-6"></div>
</code>```

CSS:

```<code>.col-md-6 {background-color:red; height:100px; clear:both;}
</code>```

Title: Setting up a 2-Column Grid Bootstrap

Body:
Hello I am trying to develop an alternating two column grid layout with bootstrap, where there would be one image on the lefthand size of the screen, then reverse down the web page until the end user reaches the footer.

I would thought to achieve this using the div row col order and going by using the floats, it has worked for the first row but when it came to developing the secondary row it did not help. I do not know if it is the floats that throwing it out of whack of I literally have to much going on in my code in general. Can someone review for me please? The blank divs are the image's as well.

/* CSS Document */

/* FONT FAMILY */

body{

 font-family: 'Montserrat', sans-serif;
}

p {

 font-family: 'Montserrat', Gotham, Helvetica Neue, Helvetica, Arial, "sans-serif";
 font-weight: 200;
 letter-spacing: 0.65px;
 line-height: 25px;
 text-align: center;
 color: white;
}

.lead {
 text-transform: uppercase;
}

h2 {
 margin-bottom: 1em;
 font-weight: 500;
 letter-spacing: 1.275px;
 font-size: 30px;
 color:  #cf6766;

}

h3 {
 margin-bottom: 1em;
 font-weight: 500;
 letter-spacing: 0.1em;
 font-size: 21px;
 color:  #cf6766;

}

/**************** NAVIGATION STYLING ****************/

.navbar,.navbar-default {

 background-color: #30415d;
 padding: 20px;
 color: white;
 margin: 0 auto;

}

.navbar.navbar-default li a {
 color: white;
 text-align: center;
 margin: 0 auto;

}

.navbar.navbar-default li a:hover{
 background-color: white;
 color: #031424;
 font-weight: bold;
}

.navbar.navbar-default li {
 font-weight: 300;
 letter-spacing: 0.10em;
 text-transform: uppercase;
 font-size: 12px;
}

.navbar-brand img {
 width: 85%;
 }

.navbar-brand a {

 padding: 20px;
 margin-top: -40px;
}

a.navbar-brand {
 margin-top: -20px;
 padding-right: 20px;
 padding-left: 20px;
 width: 85%;

}

.navbar-default {
 border: none;
}
/*img.wrap {
 float:right;
}*/

/**************HOME PAGE **********/

/* blockquote {

 background-color: #8eaebd;

 color: white;
 padding: 50px;
 margin-top: -50px;
 width: 100%;
 letter-spacing: 1.5;
 line-height: 1.5;
 text-align: center justify;
 font-size: 36px;
 margin-bottom: 50px;
 font-style: italic;
 font-weight: 400;

} */

.quote {
 font-size: 16px;
 text-align: right;
 font-weight: 300;
 letter-spacing: 2px;
}

.jumbotron {
 background:linear-gradient(#cf6766, transparent 100%),

  url(../img/DSC00154.jpg) no-repeat center;
 background-size: cover;
 height: 768px;
 margin-top: 0px;
 padding-top: 0px;
 display: table;
 width: 100%;

}

.jumbotron h1 {
 color: white;
 text-align: center;

}

#jumbotron-inner  {
 display: table-cell;
 vertical-align: middle;

}

#jumbotron-inner p {
 text-align: center;
}

.senior {

 background-color: #30415d;
 width: 50%;
 height: 500px;
 color:white;
 padding: 50px;

 letter-spacing: 1.5;
 line-height: 1.5;
 text-align: center justify;
 font-size: 16px;
 margin-bottom: 50px;
 float: left;
}

.get-involved {
 background-color: #8eaebd;
 color:white;
 padding: 50px;
 margin-top: -50px;
 width: 100%;
 letter-spacing: 1.5;
 line-height: 1.5;
 text-align: center justify;
 font-size: 16px;
 margin-bottom: 50px;
 float: right;
}

.get-inolved-img {

 background-image: url(../img/grandmother-child.jpg);
 background-position: center;
 background-size: cover;
 background-repeat: no-repeat;
 width: 100%;
 height: 500px;
 float: left;
}

.newMentor{
 background: url(../img/grandparents.jpg);
 background-position: center;
 background-size: cover;
 background-repeat: no-repeat;
 max-width:1000px 100%;
 height:500px;
 float: right;
}

.dontations {
 background-color: #30415d;
 color:white;
 padding: 50px;
 margin-top: -50px;
 width: 100%;
 letter-spacing: 1.5;
 line-height: 1.5;
 text-align: center justify;
 font-size: 16px;
 margin-bottom: 50px;
}

.btn-lg {

 background-color: #cf6766;
}

.btn-lg  {

 color: white;
 font-weight:200;
}

 .btn-lg a:hover  {
 color: #8eaebd;

}

/**************about PAGE **********/

#williams {
 width: 40%;
 height: 50%;
 margin-right: 25px;
 margin-bottom: 5px;
}

#goals {

 background-color: pink;
 padding: 20px;
}

#youth  {
 background-image: url(../img/youth-2.jpg);
 background-repeat:no-repeat;
 background-size: cover;
 background-position: center;
 width: 100%;
 height: 1000px;
}

#mentor {

    background-image: url(../img/youth-1.jpg);
    width: 100%;
    height: 500px;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    color: black;

}

#mentor h1 {
    color: rgba(0, 44, 44, 1);
}

#textarea {
   display: block;
}

textarea {

    display: block;
}

#community {

    background-image: url(../img/youth-3.jpg);
    width: 100%;
    height: 500px;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    color: black;

}

/***************************** FOOTER *****************************/

.copy {
 color: #cf6766;
}

<!DOCTYPE html>

<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>New Mentoring - 50- Home </title>

<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Montserrat:200,300,400,500,600" rel="stylesheet">
<link href="css/styles.css" rel="stylesheet">

      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#defaultNavbar1">Toggle navigation</button>

Home(current)

 About

Saving the Youth

 Mentoring Tips

Community

 Stories of Wisdom

 Guest Book

Donate

 Contact

New Mentoring.com

Where our youth gain wisdom and leadership.

Learn more

"Let your age make the difference in your community."

  - Delece Williams

What is a New Mentoring?

The Middle Aged Generation that's considered to be between 30 to 80 whose living healthier, while inspiring youth to engage in healthier life-style choices and those helping to bridge the gap between the traditional values of seniors and the technical appetites of today's youth with wisdom keys.

How to Get Involved?

We would love for you to get involved and its simple.  Just be willing to share your time and /or stories, experience, wisdom and expertise to a young person to help them make better and healthier lifestyle choices for the success of a better path throughout life.  You can do that by joining our online conversations or hosting a community forum near you.

Dontations for Kidz Korna

Women &amps; Men T-Shirts are Available for Campaign Fundraising Initiatives

Price:$20.00

      Click here to order now

Copyright © 2017 · All Rights Reserved · New Mentoring · Chicago, IL.

Body:
I think you're describing a layout where it's like a checkerboard style. If so you can use offsets on every second div and clear the divs.

http://www.bootply.com/IMtdYhv7bs

HTML:

<div class="col-md-6"></div>
<div class="col-md-6 col-md-offset-6"></div>
<div class="col-md-6"></div>
<div class="col-md-6 col-md-offset-6"></div>
<div class="col-md-6"></div>
<div class="col-md-6 col-md-offset-6"></div>

CSS:

.col-md-6 {background-color:red; height:100px; clear:both;}


问:
accessing Doubleclick Campaign Manager data through Google Analytics API
I am attempting to bring Doubleclick Campaign Manager dimensions through the GA API and am getting the following error message -
"Restricted dimension(s): (DCM dimensions I entered in the query string) can only be queried under certain conditions. For details see https://developers.google.com/analytics/devguides/reporting/core/dimsmets.

There is no guidance on that referencing site. Has anyone run into and solved this - or is it an auth restriction (shouldn't be: I have admin rights to the property).
thanks

答: If your property is not Google Analytics 360 you cannot query any of the metrics of the DCM. Take a look again here beside each metrics explanation there is the (Analytics 360 only). That is the only thing I can think if you also have admin rights on the property. Also check if you are authenticated with the correct account in any API or Query Explorer you are using</p>


问:
How do I add gestureHandling: 'cooperative' to gmaps for rails?
How do I add gestureHandling: 'cooperative' to the map using gmaps for rails?

答:
Have you tried the JS Methods section of the docs?

Something like this should work:

```<code>var handler = Gmaps.build('Google');
handler.buildMap({
    internal: { id: 'map' },
    provider: {
      gestureHandling: 'cooperative'
    }
  },
  function(){ }
);
</code>```

Body:
Have you tried the JS Methods section of the docs?

Something like this should work:

var handler = Gmaps.build('Google');
handler.buildMap({
    internal: { id: 'map' },
    provider: {
      gestureHandling: 'cooperative'
    }
  },
  function(){ }
);


问:
React, javascript object, if key value exists render an element
How do I check to see if a javascript object item has a key and render an element if it does exist.

This is my javascript object which is then parsed through and each item is made into a bootstrap list item.  Under items.title = Groups, there is an additional key "dropdown": "true" which is the element I would like to create a dropdown menu for.

```<code>var linksNav = {
    items: [
        {
            "type": "heading",
            "title": "News",
            "href": "#",
            "target": "_self"
        },
        {
            "type": "link",
            "title": "People",
            "href": "#",
            "target": "_self"
        },
        {
            "type": "link",
            "title": "Events",
            "href": "#",
            "target": "_self"
        },
        {
            "type": "link",
            "title": "Groups",
            "href": "#",
            "target": "_self",
            "dropdown": "true"
        },
        {
            "type": "heading",
            "title": "Capabilities",
            "href": "#",
            "target": "_self"
        },
        {
            "type": "link",
            "title": "Initiatives",
            "href": "#",
            "target": "_self"
        },
        {
            "type": "link",
            "title": "Who we are",
            "href": "#",
            "target": "_blank"
        },
    ]
}
</code>```

And this is my code (that doesn't work) to try to conditionally render a dropdown (the <NavSub /> tag) if that key exists for that menu item.
The result I get is my dropdown menu for each of my list items is
Nothing
.  Everything else shows up as normal, so I figure there's something wrong with my conditional statement.

```<code>render: function() {
  let dropdownMenu;
  if (this.props.dropdown=="true") {
    dropdownMenu = (<Navsub />)
  } else {
     dropdownMenu = (<div>Nothing</div>)
  }
  return (
    <li className={this.props.title + ' nav-items'}>
      <a href={this.props.href} target={this.props.target} className={this.state.color + ' dropdown-toggle'} onClick={this.onClick} data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">{this.props.title}</a>

      //I want to conditionall render this dropdown menu
      <ul className="dropdown-menu fade">
        {dropdownMenu}
      </ul>

    </li>
  );
}
</code>```

答:
If "dropdown" may not be present in your props, you should use JavaScript's in operator. Also, avoid using == as it can lead to weird results due to silent type conversions.

```<code>if ('dropdown' in this.props && this.props.dropdown === 'true') {
  //show dropdown
} else {
  //don't show dropdown
}
</code>```

The previous snippet works because JavaScript's if short-circuits.

Having said that, given that you're getting a div containing Nothing in each dropdown, it's likely your components are not receiving the props they're supposed to. You should check what props each component is getting.

Body:
How do I check to see if a javascript object item has a key and render an element if it does exist.

This is my javascript object which is then parsed through and each item is made into a bootstrap list item.  Under items.title = Groups, there is an additional key "dropdown": "true" which is the element I would like to create a dropdown menu for.

var linksNav = {
    items: [
        {
            "type": "heading",
            "title": "News",
            "href": "#",
            "target": "_self"
        },
        {
            "type": "link",
            "title": "People",
            "href": "#",
            "target": "_self"
        },
        {
            "type": "link",
            "title": "Events",
            "href": "#",
            "target": "_self"
        },
        {
            "type": "link",
            "title": "Groups",
            "href": "#",
            "target": "_self",
            "dropdown": "true"
        },
        {
            "type": "heading",
            "title": "Capabilities",
            "href": "#",
            "target": "_self"
        },
        {
            "type": "link",
            "title": "Initiatives",
            "href": "#",
            "target": "_self"
        },
        {
            "type": "link",
            "title": "Who we are",
            "href": "#",
            "target": "_blank"
        },
    ]
}

And this is my code (that doesn't work) to try to conditionally render a dropdown (the <NavSub /> tag) if that key exists for that menu item.
The result I get is my dropdown menu for each of my list items is
Nothing
.  Everything else shows up as normal, so I figure there's something wrong with my conditional statement.

render: function() {
  let dropdownMenu;
  if (this.props.dropdown=="true") {
    dropdownMenu = (<Navsub />)
  } else {
     dropdownMenu = (
Nothing
)
  }
  return (

      {this.props.title}

      //I want to conditionall render this dropdown menu

        {dropdownMenu}

  );
}

Body:
If "dropdown" may not be present in your props, you should use JavaScript's in operator. Also, avoid using == as it can lead to weird results due to silent type conversions.

if ('dropdown' in this.props && this.props.dropdown === 'true') {
  //show dropdown
} else {
  //don't show dropdown
}

The previous snippet works because JavaScript's if short-circuits.

Having said that, given that you're getting a div containing Nothing in each dropdown, it's likely your components are not receiving the props they're supposed to. You should check what props each component is getting.


问:
qsort() function in c used to compare an array of strings
I am trying to recreate the Linux command ls in C. I have the program working (going through a list of directories passed in as command line arguments, and pushing all the contents to an array of strings).

Now I'm trying to implement the quicksort flag for the command (e.g. ls -s /dev), which should print out all the contents in a lexicographical order. The problem is that the qsort() method in stdlib.h only "sorts" one element (basically swaps the first and the last element in the array) for my program.

I have no idea what's wrong, as all my pointers are properly set up as well. I'm adding the relevant snippet codes below, please let me know if something catches your eye that has been escaping mine for two days.

Compare function for qsort:

```<code>int normalCompare (const void *stringOne, const void *stringTwo) {
   return strcmp((const char *)stringOne, (const char *)stringTwo);
}
</code>```

Actual function call:

```<code>void execute_ls(char **directoryList, Flags flags) {

   //Create a buffer for directories' file names
   char **fileNamesList;
   fileNamesList = malloc(MAX_FILES * sizeof (*fileNamesList));
   int fileBufferCurrentPointer = 0;

   //Fill the buffer out by calling execute_ls_one_dir on all the directories
   int i = 0;
   while(directoryList[i] != NULL) {
      execute_ls_one_dir(directoryList[i], fileNamesList, &fileBufferCurrentPointer);
      i++;
   }
   fileNamesList[fileBufferCurrentPointer] = NULL;

   //Process the array
   if(flags.s == 1) {
       qsort(fileNamesList, fileBufferCurrentPointer, sizeof (char *), normalCompare);
   }
   else if(flags.r == 1) {
       qsort(fileNamesList, fileBufferCurrentPointer, sizeof (char *), reverseCompare);
   }

   //Print to user
   for(i = 0; i < fileBufferCurrentPointer; i++) {
       if(((*fileNamesList[i] == '.') && (flags.a == 1)) || (*fileNamesList[i] != '.')) {
        printf("%s\n", fileNamesList[i]);
       }
   }

   //Deallocate fileNamesList
   for(i = 0; i < MAX_FILES; i++) {
       free(fileNamesList[i]);
   }
   free(fileNamesList);
}
</code>```

Updating the fileBufferCurrentPointer:

```<code>while((oneDirEntryPtr = readdir(currentDirPtr)) != NULL) {

    // Push the file name onto the fileNamesList array
    fileNamesList[*fileBufferCurrentPointer] = malloc(MAX_LEN_NAME * sizeof (char));
    strcpy(fileNamesList[*fileBufferCurrentPointer], oneDirEntryPtr->d_name);
    *fileBufferCurrentPointer += 1;
}
</code>```

I'm confused as to why qsort is only working once (technically isn't even passing through the array once instead of recursively multiple times to complete the algorithm).

答:
you've made a common mistake in thinking the comparison function is taking two elements from your array - it's actually taking two pointers to elements in your array so you should call strcmp like this</p>

```<code>int normalCompare (const void *stringOne, const void *stringTwo) {
   return strcmp(*(const char **)stringOne, *(const char **)stringTwo);
}
</code>```

Body:
I am trying to recreate the Linux command ls in C. I have the program working (going through a list of directories passed in as command line arguments, and pushing all the contents to an array of strings).

Now I'm trying to implement the quicksort flag for the command (e.g. ls -s /dev), which should print out all the contents in a lexicographical order. The problem is that the qsort() method in stdlib.h only "sorts" one element (basically swaps the first and the last element in the array) for my program.

I have no idea what's wrong, as all my pointers are properly set up as well. I'm adding the relevant snippet codes below, please let me know if something catches your eye that has been escaping mine for two days.

Compare function for qsort:

int normalCompare (const void *stringOne, const void *stringTwo) {
   return strcmp((const char *)stringOne, (const char *)stringTwo);
}

Actual function call:

void execute_ls(char **directoryList, Flags flags) {

   //Create a buffer for directories' file names
   char **fileNamesList;
   fileNamesList = malloc(MAX_FILES * sizeof (*fileNamesList));
   int fileBufferCurrentPointer = 0;

   //Fill the buffer out by calling execute_ls_one_dir on all the directories
   int i = 0;
   while(directoryList[i] != NULL) {
      execute_ls_one_dir(directoryList[i], fileNamesList, &fileBufferCurrentPointer);
      i++;
   }
   fileNamesList[fileBufferCurrentPointer] = NULL;

   //Process the array
   if(flags.s == 1) {
       qsort(fileNamesList, fileBufferCurrentPointer, sizeof (char *), normalCompare);
   }
   else if(flags.r == 1) {
       qsort(fileNamesList, fileBufferCurrentPointer, sizeof (char *), reverseCompare);
   }

   //Print to user
   for(i = 0; i < fileBufferCurrentPointer; i++) {
       if(((*fileNamesList[i] == '.') && (flags.a == 1)) || (*fileNamesList[i] != '.')) {
        printf("%s\n", fileNamesList[i]);
       }
   }

   //Deallocate fileNamesList
   for(i = 0; i < MAX_FILES; i++) {
       free(fileNamesList[i]);
   }
   free(fileNamesList);
}

Updating the fileBufferCurrentPointer:

while((oneDirEntryPtr = readdir(currentDirPtr)) != NULL) {

    // Push the file name onto the fileNamesList array
    fileNamesList[*fileBufferCurrentPointer] = malloc(MAX_LEN_NAME * sizeof (char));
    strcpy(fileNamesList[*fileBufferCurrentPointer], oneDirEntryPtr->d_name);
    *fileBufferCurrentPointer += 1;
}

I'm confused as to why qsort is only working once (technically isn't even passing through the array once instead of recursively multiple times to complete the algorithm).

Body:
you've made a common mistake in thinking the comparison function is taking two elements from your array - it's actually taking two pointers to elements in your array so you should call strcmp like this

int normalCompare (const void *stringOne, const void *stringTwo) {
   return strcmp(*(const char **)stringOne, *(const char **)stringTwo);
}


问:
Can I create an <a> tag to open the Inspect Element panel?
Just wondering if this can be done simply in html. If so, how?</p>

```<code><a href="inspectElement">Check out my code!</a>
</code>```

答: Inspect Element is part of the browser, so no.</p>

Body:
Just wondering if this can be done simply in html. If so, how?

Check out my code!


问:
converting HttpWebRequest from Synchronous to Asynchronous code
I need to convert this code from sync to async code but every attempt so far has been dismal. Would anyone have a solution?

```<code> var http = (HttpWebRequest)WebRequest.Create(Connection.GetUri(path).Uri);
 http.Accept = "application/json";
 http.ContentType = "application/json";
 http.Method = "POST";

 var parsedContent = JsonConvert.SerializeObject(value);
 var encoding = new ASCIIEncoding();
 var bytes = encoding.GetBytes(parsedContent);

 var newStream = http.GetRequestStream();
 newStream.Write(bytes, 0, bytes.Length);
 newStream.Close();

 var response = http.GetResponse();

 var stream = response.GetResponseStream();

 var sr = new StreamReader(stream);

 return JsonConvert.DeserializeObject<TReturnType>(sr.ReadToEnd());
</code>```

for context, the problem is that i cannot use the System.Net.Http assembly but need Async support
.
The above code has been ported from the following due to disability to use the above mentioned assembly. Connection.Client is type HttpClient.

```<code>var response = await Connection.Client.PostAsync(
   Connection.GetUri("/transaction/announce").Uri,
   new StringContent(JsonConvert.SerializeObject(Rpa).ToString(),
       Encoding.UTF8,
       "application/json"));

return JsonConvert.DeserializeObject<NemAnnounceResponse.Response>(
    await response.Content.ReadAsStringAsync());
</code>```

答:
HttpWebRequest doesn't provide modern task-based asynchronous way to get response. But it allows you to make asynchronous call using old APM pattern. See BeginGetResponse method.

Fortunately you can easily convert old-fashioned APM to task-based using helper methods like Task.Factory.FromAsync. Eventually you should get smth like this:

```<code>public static Task<WebResponse> GetResponseAsync()
{
    var http = (HttpWebRequest)WebRequest.Create(Connection.GetUri(path).Uri);
    http.Accept = "application/json";
    http.ContentType = "application/json";
    http.Method = "POST";

    var parsedContent = JsonConvert.SerializeObject(value);
    var encoding = new ASCIIEncoding();
    var bytes = encoding.GetBytes(parsedContent);

    var newStream = http.GetRequestStream();
    newStream.Write(bytes, 0, bytes.Length);
    newStream.Close();

    Task<WebResponse> task = Task.Factory.FromAsync(
        http.BeginGetResponse,
        asyncResult => http.EndGetResponse(asyncResult),
        (object)null);

    return task;
}
</code>```

And even call it using await like var response = await GetResponseAsync(); and then proceed with response.

Body:
I need to convert this code from sync to async code but every attempt so far has been dismal. Would anyone have a solution?

 var http = (HttpWebRequest)WebRequest.Create(Connection.GetUri(path).Uri);
 http.Accept = "application/json";
 http.ContentType = "application/json";
 http.Method = "POST";

 var parsedContent = JsonConvert.SerializeObject(value);
 var encoding = new ASCIIEncoding();
 var bytes = encoding.GetBytes(parsedContent);

 var newStream = http.GetRequestStream();
 newStream.Write(bytes, 0, bytes.Length);
 newStream.Close();

 var response = http.GetResponse();

 var stream = response.GetResponseStream();

 var sr = new StreamReader(stream);

 return JsonConvert.DeserializeObject<TReturnType>(sr.ReadToEnd());

for context, the problem is that i cannot use the System.Net.Http assembly but need Async support
.
The above code has been ported from the following due to disability to use the above mentioned assembly. Connection.Client is type HttpClient.

var response = await Connection.Client.PostAsync(
   Connection.GetUri("/transaction/announce").Uri,
   new StringContent(JsonConvert.SerializeObject(Rpa).ToString(),
       Encoding.UTF8,
       "application/json"));

return JsonConvert.DeserializeObject<NemAnnounceResponse.Response>(
    await response.Content.ReadAsStringAsync());

Body:
HttpWebRequest doesn't provide modern task-based asynchronous way to get response. But it allows you to make asynchronous call using old APM pattern. See BeginGetResponse method.

Fortunately you can easily convert old-fashioned APM to task-based using helper methods like Task.Factory.FromAsync. Eventually you should get smth like this:

public static Task<WebResponse> GetResponseAsync()
{
    var http = (HttpWebRequest)WebRequest.Create(Connection.GetUri(path).Uri);
    http.Accept = "application/json";
    http.ContentType = "application/json";
    http.Method = "POST";

    var parsedContent = JsonConvert.SerializeObject(value);
    var encoding = new ASCIIEncoding();
    var bytes = encoding.GetBytes(parsedContent);

    var newStream = http.GetRequestStream();
    newStream.Write(bytes, 0, bytes.Length);
    newStream.Close();

    Task<WebResponse> task = Task.Factory.FromAsync(
        http.BeginGetResponse,
        asyncResult => http.EndGetResponse(asyncResult),
        (object)null);

    return task;
}

And even call it using await like var response = await GetResponseAsync(); and then proceed with response.


问:
Error handling with Observables in Angular 2
I'm trying to pass any errors that might occur in an HTTP request to a common logging service from all my services:

```<code>import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/catch';

constructor(logger: LoggerService) { }

doSomething(): Observable<any> {
    return this.http
        .post('/foo/bar', {})
        .catch(this.notifyErrors);
}

protected notifyErrors(error: any): Observable<any> {
    this.logger.log(error);

    return Observable.throw(error);
}
</code>```

Unfortunately, inside the notifyErrors method, this is lost. I've tried defining this as a fat arrow, but i get type errors from the TS compiler. I've used the exact syntax in the Observable documentation.

答:
I have not run your code, but if you want to access this, you may have to pass it in. </p>

```<code>import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/catch';

constructor(logger: LoggerService) { }

doSomething(): Observable<any> {
    return this.http
        .post('/foo/bar', {})
        .catch(err => {
            this.notifyErrors(err, this);
        });
}

protected notifyErrors(error, that): Observable<any> {
    that.logger.log(error);
    return Observable.throw(error);
}
</code>```

Body:
I'm trying to pass any errors that might occur in an HTTP request to a common logging service from all my services:

import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/catch';

constructor(logger: LoggerService) { }

doSomething(): Observable<any> {
    return this.http
        .post('/foo/bar', {})
        .catch(this.notifyErrors);
}

protected notifyErrors(error: any): Observable<any> {
    this.logger.log(error);

    return Observable.throw(error);
}

Unfortunately, inside the notifyErrors method, this is lost. I've tried defining this as a fat arrow, but i get type errors from the TS compiler. I've used the exact syntax in the Observable documentation.

Body:
I have not run your code, but if you want to access this, you may have to pass it in.

import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/catch';

constructor(logger: LoggerService) { }

doSomething(): Observable<any> {
    return this.http
        .post('/foo/bar', {})
        .catch(err => {
            this.notifyErrors(err, this);
        });
}

protected notifyErrors(error, that): Observable<any> {
    that.logger.log(error);
    return Observable.throw(error);
}


问:
C++ containers, covariance and template
I have some issues to find a relevant solution to my problem.
I have to return some data from a class, and the type of data kind of depends on the class.
My first solution was this :

```<code>class Base
{
    virtual QVector<Data*> getData() const = 0;
};

class Derived : public Base
{
   virtual QVector<DerviedData*> getData() const = 0;
};
</code>```

But I know this is impossible, even if DerivedData extends Data, because of invalid covariant return types.

So I came up with another idea which implies template. What I did is I turned the Base class into a template class :

```<code>template<class T>
class Base
{
    virtual QVector<T*> getData() const = 0;
}
</code>```

And then I could write a Derivedconstructor like that :

```<code>Derived::Derived() : Base<DerivedData>() {}
</code>```

But know I have another problem. Suppose that I write another class, which has a method taking any Base class in parameters.

```<code>void Foo::doSomething(Base* b) {
    b->getData();
}
</code>```

This does not compile and says

invalid use of template-name 'Base' without an argument list

which I understand perfectly.

Supposing that my code will look like that :

```<code>DerivedClass1 d1;
DerivedClass2 d2;
DerivedClass3 d3;

this->doSomething(&d1);
this->doSomething(&d2);
this->doSomething(&d3);
</code>```

What are my solutions here ? May I do something like "templating" the method doSomething ?

```<code>this->doSomething<DerivedData>(&d1);
</code>```

With a protoype like

```<code>template<class T>
void doSomething(Base<T>* b);
</code>```

Is that possible ? Is that a good way of thinking ?
Coming from Java, I used to resolve such problems by using wildcards

```<code>abstract List<? extends Data> getData();
</code>```

But I heard there is stricly speaking no such things in C++ (more or less simulable with such things as  std::is_base_of).

Thank you for your time.

答: You can let Derived::getData() return QVector<Data*>. When you need to use it, find out if the pointers in QVector is to Data or DerivedData, using dynamic_cast or similar method.

Title: C++ containers, covariance and template

Body:
I have some issues to find a relevant solution to my problem.
I have to return some data from a class, and the type of data kind of depends on the class.
My first solution was this :

class Base
{
    virtual QVector<Data*> getData() const = 0;
};

class Derived : public Base
{
   virtual QVector<DerviedData*> getData() const = 0;
};

But I know this is impossible, even if DerivedData extends Data, because of invalid covariant return types.

So I came up with another idea which implies template. What I did is I turned the Base class into a template class :

template<class T>
class Base
{
    virtual QVector<T*> getData() const = 0;
}

And then I could write a Derivedconstructor like that :

Derived::Derived() : Base<DerivedData>() {}

But know I have another problem. Suppose that I write another class, which has a method taking any Base class in parameters.

void Foo::doSomething(Base* b) {
    b->getData();
}

This does not compile and says

invalid use of template-name 'Base' without an argument list

which I understand perfectly.

Supposing that my code will look like that :

DerivedClass1 d1;
DerivedClass2 d2;
DerivedClass3 d3;

this->doSomething(&d1);
this->doSomething(&d2);
this->doSomething(&d3);

What are my solutions here ? May I do something like "templating" the method doSomething ?

this->doSomething<DerivedData>(&d1);

With a protoype like

template<class T>
void doSomething(Base<T>* b);

Is that possible ? Is that a good way of thinking ?
Coming from Java, I used to resolve such problems by using wildcards

abstract List<? extends Data> getData();

But I heard there is stricly speaking no such things in C++ (more or less simulable with such things as  std::is_base_of).

Thank you for your time.


问:
Patternlab twig includes with params
I am using the node version of patternlab with twig as template engine. I am using twig because my codebase is written in twig - so using mustache it not an option.

I simple try to include an pattern:

```<code><button type="button" class="btn {{ buttonClass }}">{{ cta }}</button>
</code>```

in an other pattern with:

```<code>{% include "base-button" with {'buttonClass': 'btn-primary btn-xs'} %}
</code>```

This does not work. The pattern is included but the variable buttonClass is not set.

Any Ideas?

答:
This seems to be an issue with the twig integration in this repo https://github.com/pattern-lab/patternengine-node-twig.

There are other issues with twig core features described here: https://github.com/pattern-lab/patternlab-node/issues/554

I finally decided to switch to the php/twig edition and the same twig-patterns are working as expected. If anybody have to use the node edition, i recommend to use mustache.

Title: Patternlab twig includes with params

Body:
I am using the node version of patternlab with twig as template engine. I am using twig because my codebase is written in twig - so using mustache it not an option.

I simple try to include an pattern:

<button type="button" class="btn {{ buttonClass }}">{{ cta }}</button>

in an other pattern with:

{% include "base-button" with {'buttonClass': 'btn-primary btn-xs'} %}

This does not work. The pattern is included but the variable buttonClass is not set.

Any Ideas?


问:
jQuery detect mousedown inside an element and then mouseup outside the element
I have something similar to a drawing canvas, and I capture it's state on mouseup for undo purposes. The canvas isn't full screen, so you can draw with a brush and release outside the canvas. Something like this:

```<code>$("#element").mousedown(function(){
  $(document).mouseup(function(){
    //do something
  });
});
</code>```

But this doesn't work of course. A plain $(document).mouseup doesn't work either, because I have many other UI elements and it saves the state each time you click on a UI element.

Any ideas?

答:
```<code>var isDown = false;

$("#element").mousedown(function(){
    isDown = true;
});

$(document).mouseup(function(){
    if(isDown){
        //do something
        isDown = false;
    }
});
</code>```

For the sake of simplicity I put isDown in the global namespace. In production you would probably want to isolate the scope of that variable.

Body:
I have something similar to a drawing canvas, and I capture it's state on mouseup for undo purposes. The canvas isn't full screen, so you can draw with a brush and release outside the canvas. Something like this:

$("#element").mousedown(function(){
  $(document).mouseup(function(){
    //do something
  });
});

But this doesn't work of course. A plain $(document).mouseup doesn't work either, because I have many other UI elements and it saves the state each time you click on a UI element.

Any ideas?

Body:
var isDown = false;

$("#element").mousedown(function(){
    isDown = true;
});

$(document).mouseup(function(){
    if(isDown){
        //do something
        isDown = false;
    }
});

For the sake of simplicity I put isDown in the global namespace. In production you would probably want to isolate the scope of that variable.


问:
tchar.h on linux
I am trying to write cross platform i18n C++ code. Since most linux system prefer to use UTF-8 as the character encoding, I thought that I should use string on linux and wstring on Windows. Is tchar.h available on linux? What is an equivalent replacement on for tchar.h on Linux?</p>

答:
To build my Windows centric source I was able to use the tchar.h file from Cygwin's found in the cygwin\usr\include\w32api folder.

I am actually building using Android NDK.
For my purposes I made a copy of tchar.h and patched it.

```<code>//#include <crtdefs.h>

#define _CRTIMP

//#define _strninc(_pc,_sz) (((_pc)+(_sz)))
//  _CRTIMP size_t __cdecl __strncnt(const char *_Str,size_t _Cnt);
</code>```

Title: tchar.h on linux

Body:
To build my Windows centric source I was able to use the tchar.h file from Cygwin's found in the cygwin\usr\include\w32api folder.

I am actually building using Android NDK.
For my purposes I made a copy of tchar.h and patched it.

//#include <crtdefs.h>

#define _CRTIMP

//#define _strninc(_pc,_sz) (((_pc)+(_sz)))
//  _CRTIMP size_t __cdecl __strncnt(const char *_Str,size_t _Cnt);


问:
Form validation not working with Bootstrap validator
I am using Bootstrap validator to ensure all fields are filled when submitting a form. But my validator is not working as expected!

Here is the JSFiddle: http://jsfiddle.net/3v3011e0/

If you play with it and submit the form with all fields empty, and change one of them to not empty, then all fields become green. This should not happen. It should only be green for the field that is working properly. As seen in this picture, username and password are empty but show up as green. Also the icon only shows for username. How do I fix this?

HTML

```<code><form action="#" method="POST" id="myForm">
  <div class="form-group">

    <input id="userField" type="text" name="username" placeholder="Enter user name" class="form-control" />

    <input id="password" type="password" name="password" placeholder="Choose a password" class="form-control" />

    <select id="myPicker" name="num" class="selectpicker form-control">
      <option value="" selected="selected">Select number</option>
      <option value="1">1</option>
      <option value="2">2</option>
    </select>
  </div>

  <div class="text-center">
    <button type="submit" class="btn btn-primary">submit</button>
  </div>
</form>
</code>```

Javascript

```<code>$(document).ready(function() {
  $('#myForm').bootstrapValidator({
    feedbackIcons: {
      valid: 'glyphicon glyphicon-ok',
      invalid: 'glyphicon glyphicon-remove',
      validating: 'glyphicon glyphicon-refresh'
    },
    fields: {
      username: {
        validators: {
          notEmpty: {
            message: 'The username is required and cannot be empty'
          }
        }
      },
      password: {
        validators: {
          notEmpty: {
            message: 'The password is required and cannot be empty'
          }
        }
      },
      num: {
        validators: {
          notEmpty: {
            message: 'Number is required and cannot be empty'
          }
        }
      }
    }
  });
});
</code>```

答:
I know this is an old question but I was working with the old version of this plugin, bootstrapValidator as it came with a theme I was using, SmartAdmin.

First, there are two versions of this plugin.

formvalidation.io (paid version), bootstrapValidator (free version, up until .5.2?)

Anyways they are different and the documentation is different so make sure you are using the docs for the correct one.

The problem this user is having is the HTML markup is incorrect. Each field must be separated with class ".form-group", when using default initialization of the plugin.

```<code><div class="form-group">
    <input id="userField" type="text" name="username" placeholder="Enter user name" class="form-control" />
</div>
<div class="form-group">
    <input id="password" type="password" name="password" placeholder="Choose a password" class="form-control" />
</div>
<div class="form-group">
    <select id="myPicker" name="num" class="selectpicker form-control">
        <option value="" selected="selected">Select number</option>
        <option value="1">1</option>
        <option value="2">2</option>
    </select>
</div>
</code>```

http://jsfiddle.net/3v3011e0/7/

If this is not possible, try emulating the initialization of the complex form example.
http://bootstrapvalidator.votintsev.ru/examples/complex-form/

Body:
I am using Bootstrap validator to ensure all fields are filled when submitting a form. But my validator is not working as expected!

Here is the JSFiddle: http://jsfiddle.net/3v3011e0/

If you play with it and submit the form with all fields empty, and change one of them to not empty, then all fields become green. This should not happen. It should only be green for the field that is working properly. As seen in this picture, username and password are empty but show up as green. Also the icon only shows for username. How do I fix this?

HTML

<form action="#" method="POST" id="myForm">

    <input id="userField" type="text" name="username" placeholder="Enter user name" class="form-control" />

    <input id="password" type="password" name="password" placeholder="Choose a password" class="form-control" />

    <select id="myPicker" name="num" class="selectpicker form-control">
      <option value="" selected="selected">Select number</option>
      <option value="1">1</option>
      <option value="2">2</option>
    </select>

    <button type="submit" class="btn btn-primary">submit</button>

</form>

Javascript

$(document).ready(function() {
  $('#myForm').bootstrapValidator({
    feedbackIcons: {
      valid: 'glyphicon glyphicon-ok',
      invalid: 'glyphicon glyphicon-remove',
      validating: 'glyphicon glyphicon-refresh'
    },
    fields: {
      username: {
        validators: {
          notEmpty: {
            message: 'The username is required and cannot be empty'
          }
        }
      },
      password: {
        validators: {
          notEmpty: {
            message: 'The password is required and cannot be empty'
          }
        }
      },
      num: {
        validators: {
          notEmpty: {
            message: 'Number is required and cannot be empty'
          }
        }
      }
    }
  });
});

Body:
I know this is an old question but I was working with the old version of this plugin, bootstrapValidator as it came with a theme I was using, SmartAdmin.

First, there are two versions of this plugin.

formvalidation.io (paid version), bootstrapValidator (free version, up until .5.2?)

Anyways they are different and the documentation is different so make sure you are using the docs for the correct one.

The problem this user is having is the HTML markup is incorrect. Each field must be separated with class ".form-group", when using default initialization of the plugin.

<div class="form-group">
    <input id="userField" type="text" name="username" placeholder="Enter user name" class="form-control" />
</div>
<div class="form-group">
    <input id="password" type="password" name="password" placeholder="Choose a password" class="form-control" />
</div>
<div class="form-group">
    <select id="myPicker" name="num" class="selectpicker form-control">
        <option value="" selected="selected">Select number</option>
        <option value="1">1</option>
        <option value="2">2</option>
    </select>
</div>

http://jsfiddle.net/3v3011e0/7/

If this is not possible, try emulating the initialization of the complex form example.
http://bootstrapvalidator.votintsev.ru/examples/complex-form/


问:
Name "shape" does not exist in the current context
Doing an inheritance test program specifically to root out problems such as these.

The classes themselves aren't important, the problem is in the Main.

I tried "Shape shape = null" before the if statements but having "Circle shape" etc in the if statements threw errors.

Main:

```<code>    string shapeType = "";
    double side = 0;
    while (true)
    {
      Console.WriteLine("What type of shape? - (cir/tri/sqr");
      shapeType = Console.ReadLine();
      Console.WriteLine("How long are the sides, or the radius?");
      side = Convert.ToDouble(Console.ReadLine());
      if (shapeType == "cir")
      {
        Circle shape = new Circle();
      }
      else if (shapeType == "tri")
      {
        Triangle shape = new Triangle();
      }
      else
      {
        Square shape = new Square();
      }

      // Code interacting with shapes.
    }
</code>```

答:
You're declaring the shapes within the if blocks, which means that after that block ends it's unavailable.

You need to declare it before, and as a Shape:

```<code>Shape shape = null;

if (shapeType == "cir")
{
    shape = new Circle();
}
else if (shapeType == "tri")
{
    shape = new Triangle();
}
else
{
    shape = new Square();
}

// … etc
</code>```

Body:
Doing an inheritance test program specifically to root out problems such as these.

The classes themselves aren't important, the problem is in the Main.

I tried "Shape shape = null" before the if statements but having "Circle shape" etc in the if statements threw errors.

Main:

    string shapeType = "";
    double side = 0;
    while (true)
    {
      Console.WriteLine("What type of shape? - (cir/tri/sqr");
      shapeType = Console.ReadLine();
      Console.WriteLine("How long are the sides, or the radius?");
      side = Convert.ToDouble(Console.ReadLine());
      if (shapeType == "cir")
      {
        Circle shape = new Circle();
      }
      else if (shapeType == "tri")
      {
        Triangle shape = new Triangle();
      }
      else
      {
        Square shape = new Square();
      }

      // Code interacting with shapes.
    }

Body:
You're declaring the shapes within the if blocks, which means that after that block ends it's unavailable.

You need to declare it before, and as a Shape:

Shape shape = null;

if (shapeType == "cir")
{
    shape = new Circle();
}
else if (shapeType == "tri")
{
    shape = new Triangle();
}
else
{
    shape = new Square();
}

// … etc