问:
Customize Infowindow : move arrow to the left not working on first click
I'm using the "5 ways to customize the Google Maps Infowindow"
( code here : https://codepen.io/Marnoto/pen/xboPmG )

When clicking for the first time on the marker, the window opens, but the arrow don't move to the left (this appens not all the time, but very often).

Starting the second click, it's positioning correctly, as written in the JS :

```<code>// Moves the arrow 76px to the left margin.
iwBackground.children(':nth-child(3)').attr('style', function(i,s){ return s + 'left: 76px !important;'});
</code>```

Here is a pic of the problem
capture

And here is a pic of how it works when the style property is correctly applied
capture 2

Is there a way to fix this ??

Thank you!

Edit : THIS IS THE CODE

HTML

```<code><body>
  <div id="map-canvas"/>
</body>
</code>```

CSS

```<code>#map-canvas {
    margin: 0;
    padding: 0;
    height: 400px;
    max-width: none;
}
#map-canvas img {
    max-width: none !important;
}
.gm-style-iw {
    width: 350px !important;
    top: 15px !important;
    left: 0px !important;
    background-color: #fff;
    box-shadow: 0 1px 6px rgba(178, 178, 178, 0.6);
    border: 1px solid rgba(72, 181, 233, 0.6);
    border-radius: 2px 2px 10px 10px;
}
#iw-container {
    margin-bottom: 10px;
}
#iw-container .iw-title {
    font-family: 'Open Sans Condensed', sans-serif;
    font-size: 22px;
    font-weight: 400;
    padding: 10px;
    background-color: #48b5e9;
    color: white;
    margin: 0;
    border-radius: 2px 2px 0 0;
}
#iw-container .iw-content {
    font-size: 13px;
    line-height: 18px;
    font-weight: 400;
    margin-right: 1px;
    padding: 15px 5px 20px 15px;
    max-height: 140px;
    overflow-y: auto;
    overflow-x: hidden;
}
.iw-content img {
    float: right;
    margin: 0 5px 5px 10px;
}
.iw-subTitle {
    font-size: 16px;
    font-weight: 700;
    padding: 5px 0;
}
.iw-bottom-gradient {
    position: absolute;
    width: 326px;
    height: 25px;
    bottom: 10px;
    right: 18px;
    background: linear-gradient(to bottom, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%);
    background: -webkit-linear-gradient(top, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%);
    background: -moz-linear-gradient(top, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%);
    background: -ms-linear-gradient(top, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%);
}
</code>```

JAVASCRIPT

```<code>/*
 * 5 ways to customize the Google Maps infowindow
 * 2015 - en.marnoto.com
 * http://en.marnoto.com/2014/09/5-formas-de-personalizar-infowindow.html
*/

// map center
var center = new google.maps.LatLng(40.589500, -8.683542);

// marker position
var factory = new google.maps.LatLng(40.589500, -8.683542);

function initialize() {
  var mapOptions = {
    center: center,
    zoom: 16,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };

  var map = new google.maps.Map(document.getElementById("map-canvas"),mapOptions);

  // InfoWindow content
  var content = '<div id="iw-container">' +
                    '<div class="iw-title">Porcelain Factory of Vista Alegre</div>' +
                    '<div class="iw-content">' +
                      '<div class="iw-subTitle">History</div>' +
                      '<img src="http://maps.marnoto.com/en/5wayscustomizeinfowindow/images/vistalegre.jpg" alt="Porcelain Factory of Vista Alegre" height="115" width="83">' +
                      '<p>Founded in 1824, the Porcelain Factory of Vista Alegre was the first industrial unit dedicated to porcelain production in Portugal. For the foundation and success of this risky industrial development was crucial the spirit of persistence of its founder, José Ferreira Pinto Basto. Leading figure in Portuguese society of the nineteenth century farm owner, daring dealer, wisely incorporated the liberal ideas of the century, having become "the first example of free enterprise" in Portugal.</p>' +
                      '<div class="iw-subTitle">Contacts</div>' +
                      '<p>VISTA ALEGRE ATLANTIS, SA<br>3830-292 Ílhavo - Portugal<br>'+
                      '<br>Phone. +351 234 320 600<br>e-mail: geral@vaa.pt<br>www: www.myvistaalegre.com</p>'+
                    '</div>' +
                    '<div class="iw-bottom-gradient"></div>' +
                  '</div>';

  // A new Info Window is created and set content
  var infowindow = new google.maps.InfoWindow({
    content: content,

    // Assign a maximum value for the width of the infowindow allows
    // greater control over the various content elements
    maxWidth: 350
  });

  // marker options
  var marker = new google.maps.Marker({
    position: factory,
    map: map,
    title:"Porcelain Factory of Vista Alegre"
  });

  // This event expects a click on a marker
  // When this event is fired the Info Window is opened.
  google.maps.event.addListener(marker, 'click', function() {
    infowindow.open(map,marker);
  });

  // Event that closes the Info Window with a click on the map
  google.maps.event.addListener(map, 'click', function() {
    infowindow.close();
  });

  // *
  // START INFOWINDOW CUSTOMIZE.
  // The google.maps.event.addListener() event expects
  // the creation of the infowindow HTML structure 'domready'
  // and before the opening of the infowindow, defined styles are applied.
  // *
  google.maps.event.addListener(infowindow, 'domready', function() {

    // Reference to the DIV that wraps the bottom of infowindow
    var iwOuter = $('.gm-style-iw');

    /* Since this div is in a position prior to .gm-div style-iw.
     * We use jQuery and create a iwBackground variable,
     * and took advantage of the existing reference .gm-style-iw for the previous div with .prev().
    */
    var iwBackground = iwOuter.prev();

    // Removes background shadow DIV
    iwBackground.children(':nth-child(2)').css({'display' : 'none'});

    // Removes white background DIV
    iwBackground.children(':nth-child(4)').css({'display' : 'none'});

    // Moves the infowindow 115px to the right.
    iwOuter.parent().parent().css({left: '115px'});

    // Moves the shadow of the arrow 76px to the left margin.
    iwBackground.children(':nth-child(1)').attr('style', function(i,s){ return s + 'left: 76px !important;'});

    // Moves the arrow 76px to the left margin.
    iwBackground.children(':nth-child(3)').attr('style', function(i,s){ return s + 'left: 76px !important;'});

    // Changes the desired tail shadow color.
    iwBackground.children(':nth-child(3)').find('div').children().css({'box-shadow': 'rgba(72, 181, 233, 0.6) 0px 1px 6px', 'z-index' : '1'});

    // Reference to the div that groups the close button elements.
    var iwCloseBtn = iwOuter.next();

    // Apply the desired effect to the close button
    iwCloseBtn.css({opacity: '1', right: '38px', top: '3px', border: '7px solid #48b5e9', 'border-radius': '13px', 'box-shadow': '0 0 5px #3990B9'});

    // If the content of infowindow not exceed the set maximum height, then the gradient is removed.
    if($('.iw-content').height() < 140){
      $('.iw-bottom-gradient').css({display: 'none'});
    }

    // The API automatically applies 0.7 opacity to the button after the mouseout event. This function reverses this event to the desired value.
    iwCloseBtn.mouseout(function(){
      $(this).css({opacity: '1'});
    });
  });
}
google.maps.event.addDomListener(window, 'load', initialize);
</code>```

答:
try the pixelOffset for the infowindow

for example: I moved my whole infowindow to the right of the marker:

```<code>var infowindow = new google.maps.InfoWindow({
    content: $marker.html(),
    pixelOffset: new google.maps.Size(175, 114),
    maxWidth: '290',
  });
</code>```

the pixelOffset equals half of my maxWidth and double the height of my marker icon

then I also changed this line:

```<code>// Moves the infowindow to the right.
    iwOuter.parent().parent().css({left: '0px', top: '0px'});
</code>```

so the top left corner will be aligned to the right of the marker icon and in the CSS:

```<code>.gm-style .gm-style-iw{
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  padding: 0 !important;
  overflow: visible !important;
}
</code>```

I also exchanged the arrow thingy - adding an additional div inside my marker-wrap, which has the following style:

```<code>.marker-arrow {
  position: absolute;
  left: -30px;
  top: 0;
  width: 30px;
  background: transparent;
  border-top: 12px solid transparent;
  border-right: 20px solid #ffffff;
  border-bottom: 12px solid transparent;
  height: 24px;
}
</code>```

in addition I changed the styles for the arrow, so it doesn't appear anywhere visibly:

```<code>// Moves the shadow of the arrow to the left.
iwBackground.children(':nth-child(1)').attr('style', function(i,s){ return s + 'left: 0px !important; top: 0px !important;'});

// Moves the arrow to the left.
iwBackground.children(':nth-child(3)').attr('style', function(i,s){ return s + 'left: 0px !important; top: 0px !important;'});

// Changes the desired tail shadow color.
iwBackground.children(':nth-child(3)').find('div').children().css({'box-shadow': 'unset', 'z-index' : '0', 'background' : 'transparent'});
</code>```

hope that helps ;-)

Body:
I'm using the "5 ways to customize the Google Maps Infowindow"
( code here : https://codepen.io/Marnoto/pen/xboPmG )

When clicking for the first time on the marker, the window opens, but the arrow don't move to the left (this appens not all the time, but very often).

Starting the second click, it's positioning correctly, as written in the JS :

// Moves the arrow 76px to the left margin.
iwBackground.children(':nth-child(3)').attr('style', function(i,s){ return s + 'left: 76px !important;'});

Here is a pic of the problem
capture

And here is a pic of how it works when the style property is correctly applied
capture 2

Is there a way to fix this ??

Thank you!

Edit : THIS IS THE CODE

HTML

CSS

#map-canvas {
    margin: 0;
    padding: 0;
    height: 400px;
    max-width: none;
}
#map-canvas img {
    max-width: none !important;
}
.gm-style-iw {
    width: 350px !important;
    top: 15px !important;
    left: 0px !important;
    background-color: #fff;
    box-shadow: 0 1px 6px rgba(178, 178, 178, 0.6);
    border: 1px solid rgba(72, 181, 233, 0.6);
    border-radius: 2px 2px 10px 10px;
}
#iw-container {
    margin-bottom: 10px;
}
#iw-container .iw-title {
    font-family: 'Open Sans Condensed', sans-serif;
    font-size: 22px;
    font-weight: 400;
    padding: 10px;
    background-color: #48b5e9;
    color: white;
    margin: 0;
    border-radius: 2px 2px 0 0;
}
#iw-container .iw-content {
    font-size: 13px;
    line-height: 18px;
    font-weight: 400;
    margin-right: 1px;
    padding: 15px 5px 20px 15px;
    max-height: 140px;
    overflow-y: auto;
    overflow-x: hidden;
}
.iw-content img {
    float: right;
    margin: 0 5px 5px 10px;
}
.iw-subTitle {
    font-size: 16px;
    font-weight: 700;
    padding: 5px 0;
}
.iw-bottom-gradient {
    position: absolute;
    width: 326px;
    height: 25px;
    bottom: 10px;
    right: 18px;
    background: linear-gradient(to bottom, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%);
    background: -webkit-linear-gradient(top, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%);
    background: -moz-linear-gradient(top, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%);
    background: -ms-linear-gradient(top, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%);
}

JAVASCRIPT

/*
 * 5 ways to customize the Google Maps infowindow
 * 2015 - en.marnoto.com
 * http://en.marnoto.com/2014/09/5-formas-de-personalizar-infowindow.html
*/

// map center
var center = new google.maps.LatLng(40.589500, -8.683542);

// marker position
var factory = new google.maps.LatLng(40.589500, -8.683542);

function initialize() {
  var mapOptions = {
    center: center,
    zoom: 16,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };

  var map = new google.maps.Map(document.getElementById("map-canvas"),mapOptions);

  // InfoWindow content
  var content = '
' +
                    '
Porcelain Factory of Vista Alegre
' +
                    '
' +
                      '
History
' +
                      '' +
                      '
Founded in 1824, the Porcelain Factory of Vista Alegre was the first industrial unit dedicated to porcelain production in Portugal. For the foundation and success of this risky industrial development was crucial the spirit of persistence of its founder, José Ferreira Pinto Basto. Leading figure in Portuguese society of the nineteenth century farm owner, daring dealer, wisely incorporated the liberal ideas of the century, having become "the first example of free enterprise" in Portugal.
' +
                      '
Contacts
' +
                      '
VISTA ALEGRE ATLANTIS, SA
3830-292 Ílhavo - Portugal
'+
                      '
Phone. +351 234 320 600
e-mail: geral@vaa.pt
www: www.myvistaalegre.com
'+
                    '
' +
                    '

' +
                  '
';

  // A new Info Window is created and set content
  var infowindow = new google.maps.InfoWindow({
    content: content,

    // Assign a maximum value for the width of the infowindow allows
    // greater control over the various content elements
    maxWidth: 350
  });

  // marker options
  var marker = new google.maps.Marker({
    position: factory,
    map: map,
    title:"Porcelain Factory of Vista Alegre"
  });

  // This event expects a click on a marker
  // When this event is fired the Info Window is opened.
  google.maps.event.addListener(marker, 'click', function() {
    infowindow.open(map,marker);
  });

  // Event that closes the Info Window with a click on the map
  google.maps.event.addListener(map, 'click', function() {
    infowindow.close();
  });

  // *
  // START INFOWINDOW CUSTOMIZE.
  // The google.maps.event.addListener() event expects
  // the creation of the infowindow HTML structure 'domready'
  // and before the opening of the infowindow, defined styles are applied.
  // *
  google.maps.event.addListener(infowindow, 'domready', function() {

    // Reference to the DIV that wraps the bottom of infowindow
    var iwOuter = $('.gm-style-iw');

    /* Since this div is in a position prior to .gm-div style-iw.
     * We use jQuery and create a iwBackground variable,
     * and took advantage of the existing reference .gm-style-iw for the previous div with .prev().
    */
    var iwBackground = iwOuter.prev();

    // Removes background shadow DIV
    iwBackground.children(':nth-child(2)').css({'display' : 'none'});

    // Removes white background DIV
    iwBackground.children(':nth-child(4)').css({'display' : 'none'});

    // Moves the infowindow 115px to the right.
    iwOuter.parent().parent().css({left: '115px'});

    // Moves the shadow of the arrow 76px to the left margin.
    iwBackground.children(':nth-child(1)').attr('style', function(i,s){ return s + 'left: 76px !important;'});

    // Moves the arrow 76px to the left margin.
    iwBackground.children(':nth-child(3)').attr('style', function(i,s){ return s + 'left: 76px !important;'});

    // Changes the desired tail shadow color.
    iwBackground.children(':nth-child(3)').find('div').children().css({'box-shadow': 'rgba(72, 181, 233, 0.6) 0px 1px 6px', 'z-index' : '1'});

    // Reference to the div that groups the close button elements.
    var iwCloseBtn = iwOuter.next();

    // Apply the desired effect to the close button
    iwCloseBtn.css({opacity: '1', right: '38px', top: '3px', border: '7px solid #48b5e9', 'border-radius': '13px', 'box-shadow': '0 0 5px #3990B9'});

    // If the content of infowindow not exceed the set maximum height, then the gradient is removed.
    if($('.iw-content').height() < 140){
      $('.iw-bottom-gradient').css({display: 'none'});
    }

    // The API automatically applies 0.7 opacity to the button after the mouseout event. This function reverses this event to the desired value.
    iwCloseBtn.mouseout(function(){
      $(this).css({opacity: '1'});
    });
  });
}
google.maps.event.addDomListener(window, 'load', initialize);

Body:
try the pixelOffset for the infowindow

for example: I moved my whole infowindow to the right of the marker:

var infowindow = new google.maps.InfoWindow({
    content: $marker.html(),
    pixelOffset: new google.maps.Size(175, 114),
    maxWidth: '290',
  });

the pixelOffset equals half of my maxWidth and double the height of my marker icon

then I also changed this line:

// Moves the infowindow to the right.
    iwOuter.parent().parent().css({left: '0px', top: '0px'});

so the top left corner will be aligned to the right of the marker icon and in the CSS:

.gm-style .gm-style-iw{
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  padding: 0 !important;
  overflow: visible !important;
}

I also exchanged the arrow thingy - adding an additional div inside my marker-wrap, which has the following style:

.marker-arrow {
  position: absolute;
  left: -30px;
  top: 0;
  width: 30px;
  background: transparent;
  border-top: 12px solid transparent;
  border-right: 20px solid #ffffff;
  border-bottom: 12px solid transparent;
  height: 24px;
}

in addition I changed the styles for the arrow, so it doesn't appear anywhere visibly:

// Moves the shadow of the arrow to the left.
iwBackground.children(':nth-child(1)').attr('style', function(i,s){ return s + 'left: 0px !important; top: 0px !important;'});

// Moves the arrow to the left.
iwBackground.children(':nth-child(3)').attr('style', function(i,s){ return s + 'left: 0px !important; top: 0px !important;'});

// Changes the desired tail shadow color.
iwBackground.children(':nth-child(3)').find('div').children().css({'box-shadow': 'unset', 'z-index' : '0', 'background' : 'transparent'});

hope that helps ;-)


来源: stackexchange

问:
Changing the stack size and LD_LIBRARY_PATH using a Makefile
I would like to be able to have a rule inside my makefile that a changes the stack size and that appends to LD_LIBRARY_FILE the current directory.
In the shell I can just do:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)

ulimit -s SOME_NUMBER

Is there way to make a rule inside a makefile that is equivalent to running this two commands and will update the environment variables after the makefile is run?

答:
No

A child process in bash cannot effect the environment of the calling shell (as @mpez pointed out).   This is done on purpose to avoid some security holes.   It's possible to export the commands to change the environment variable to a script, and run that script after you run make (which can be automated through another script), but make itself cannot effect the environment of the calling shell.

ContentLicense: CC BY-SA 3.0


问:
Serial Key in innosetup
Is possible to make a setup program with Inno setup which ask serial key for continue install the application?
Thanks</p>

答:
Password= in the [setup] section.
Drawback is that the setup can't use other bitmaps for the installer program</p>

ContentLicense: CC BY-SA 2.5

Title: Serial Key in innosetup


问:
can std::unique be used to determine if objects of a custom class have the same values?
I have a list of framerates and a list of associated screen resolutions. The problem is that I get loads of duplicates in my resoltuions list. Actually, I get loads of duplicates in the framerates list as well (thanks a lot, Windows!), but those are eliminated by a simple comparison when I sort through the raw list. I guess that I want to use std::algorithm to help me eliminate my duplicates, but I can't get it to work.

Code:

```<code>#include <algorithm>
#include <vector>
#include <iostream>

struct resolution {
    int w;
    int h;
};

int main(void) {

    std::vector<std::pair<int, std::vector<resolution>>> vec;
    for (int i = 0; i < 5; i++) {
        std::pair<int, std::vector<resolution>> p;
        p.first = i;
        for (int j = 0; j < 5; j++) {
            resolution res;
            res.w = j;
            res.h = j;
            p.second.push_back(res);
        }
        vec.push_back(p);
    }

    for (std::vector<std::pair<int, std::vector<resolution>>>::iterator it = vec.begin();
        it != vec.end();
        ++it) {
        it->second.erase(std::unique(it->second.begin(), it->second.end()), it->second.end());
    }

    for (std::vector<std::pair<int, std::vector<resolution>>>::iterator it1 = vec.begin();
        it1 != vec.end();
        ++it1) {
        for (std::vector<resolution>::iterator it2 = it1->second.begin();
            it2 != it1->second.end();
            ++it2) {
            std::cout << it1->first << ": " << it2->w << " x " << it2->h << std::endl;
        }
    }

    return 0;
}
</code>```

I get the following compiler errors from algorithm:

```<code>Error   C2672   'operator __surrogate_func': no matching overloaded function found  dummy_erase c:\program files (x86)\microsoft visual studio 14.0\vc\include\algorithm    1503
Error   C2893   Failed to specialize function template 'unknown-type std::equal_to<void>::operator ()(_Ty1 &&,_Ty2 &&) const'   dummy_erase c:\program files (x86)\microsoft visual studio 14.0\vc\include\algorithm    1503
Error   C2672   'operator __surrogate_func': no matching overloaded function found  dummy_erase c:\program files (x86)\microsoft visual studio 14.0\vc\include\algorithm    1506
Error   C2893   Failed to specialize function template 'unknown-type std::equal_to<void>::operator ()(_Ty1 &&,_Ty2 &&) const'   dummy_erase c:\program files (x86)\microsoft visual studio 14.0\vc\include\algorithm    1506
</code>```

I've not much experience with <algorithm> but I suspect the problem is that std::unique doesn't understand how to compare my resolution objects. If this is in fact the case, is there something I can add to my resolution class to make it nice for std::unique? Or, is there any other way to do this elegantly?

I could always just do it by hand with another pass on the list and some conditionals, but avoiding doing that kind of thing is exactly one reason to use C++ as opposed to C. If there is a trick to this, I'd love to know it.

答:
You have to add a comparator.

Try adding

```<code>bool operator == (resolution const & r1, resolution const & r2)
 { return (r1.w == r2.w) && (r1.h == r2.h); }
</code>```

You can write it inside the resolution body as a friend function

```<code>struct resolution {
    int w;
    int h;

    friend bool operator == (resolution const & r1, resolution const & r2)
     { return (r1.w == r2.w) && (r1.h == r2.h); }
};
</code>```

Body:
I have a list of framerates and a list of associated screen resolutions. The problem is that I get loads of duplicates in my resoltuions list. Actually, I get loads of duplicates in the framerates list as well (thanks a lot, Windows!), but those are eliminated by a simple comparison when I sort through the raw list. I guess that I want to use std::algorithm to help me eliminate my duplicates, but I can't get it to work.

Code:

#include <algorithm>
#include <vector>
#include <iostream>

struct resolution {
    int w;
    int h;
};

int main(void) {

    std::vector<std::pair<int, std::vector<resolution>>> vec;
    for (int i = 0; i < 5; i++) {
        std::pair<int, std::vector<resolution>> p;
        p.first = i;
        for (int j = 0; j < 5; j++) {
            resolution res;
            res.w = j;
            res.h = j;
            p.second.push_back(res);
        }
        vec.push_back(p);
    }

    for (std::vector<std::pair<int, std::vector<resolution>>>::iterator it = vec.begin();
        it != vec.end();
        ++it) {
        it->second.erase(std::unique(it->second.begin(), it->second.end()), it->second.end());
    }

    for (std::vector<std::pair<int, std::vector<resolution>>>::iterator it1 = vec.begin();
        it1 != vec.end();
        ++it1) {
        for (std::vector<resolution>::iterator it2 = it1->second.begin();
            it2 != it1->second.end();
            ++it2) {
            std::cout << it1->first << ": " << it2->w << " x " << it2->h << std::endl;
        }
    }

    return 0;
}

I get the following compiler errors from algorithm:

Error   C2672   'operator __surrogate_func': no matching overloaded function found  dummy_erase c:\program files (x86)\microsoft visual studio 14.0\vc\include\algorithm    1503
Error   C2893   Failed to specialize function template 'unknown-type std::equal_to<void>::operator ()(_Ty1 &&,_Ty2 &&) const'   dummy_erase c:\program files (x86)\microsoft visual studio 14.0\vc\include\algorithm    1503
Error   C2672   'operator __surrogate_func': no matching overloaded function found  dummy_erase c:\program files (x86)\microsoft visual studio 14.0\vc\include\algorithm    1506
Error   C2893   Failed to specialize function template 'unknown-type std::equal_to<void>::operator ()(_Ty1 &&,_Ty2 &&) const'   dummy_erase c:\program files (x86)\microsoft visual studio 14.0\vc\include\algorithm    1506

I've not much experience with <algorithm> but I suspect the problem is that std::unique doesn't understand how to compare my resolution objects. If this is in fact the case, is there something I can add to my resolution class to make it nice for std::unique? Or, is there any other way to do this elegantly?

I could always just do it by hand with another pass on the list and some conditionals, but avoiding doing that kind of thing is exactly one reason to use C++ as opposed to C. If there is a trick to this, I'd love to know it.

Body:
You have to add a comparator.

Try adding

bool operator == (resolution const & r1, resolution const & r2)
 { return (r1.w == r2.w) && (r1.h == r2.h); }

You can write it inside the resolution body as a friend function

struct resolution {
    int w;
    int h;

    friend bool operator == (resolution const & r1, resolution const & r2)
     { return (r1.w == r2.w) && (r1.h == r2.h); }
};


问:
Ionic dynamic component creation?
Is there a way using Ionic to dynamically create a component? For example, I have a few pages where a login prompt should be displayed. I have my component added to my module but don't know where I should go next in order to get this to display when certain events are called.

Any help as to where I should go now, I'm super confused on what I should do.

答:
Since you have the LoginPage added to your module. You can use Ionic built-in ModalController to popup your login page everywhere you need it.

Here is an example:

```<code>export class MyPage {
    constructor(public modalCtrl: ModalController) {
    }

    presentModal() {
        let modal = this.modalCtrl.create(LoginPage);
        modal.present();
    }
}
</code>```

Source: https://ionicframework.com/docs/components/#modals

Title: Ionic dynamic component creation?

Body:
Since you have the LoginPage added to your module. You can use Ionic built-in ModalController to popup your login page everywhere you need it.

Here is an example:

export class MyPage {
    constructor(public modalCtrl: ModalController) {
    }

    presentModal() {
        let modal = this.modalCtrl.create(LoginPage);
        modal.present();
    }
}

Source: https://ionicframework.com/docs/components/#modals


问:
How to create a dataview In Sharepoint with data from a join query?
I have 3 Lists in Sharepoint.

I want to create a dataview that is a join of 3 tables.

Table1 is joined with Table2 on FieldA
Table 2 is joined to Table3 on FieldB

Table1 has duplicate values in FieldA so I need to only return one value to join with Table2.

In Access my query looks like this:
SELECT DISTINCT WRK_InputWorkOrders.WorkOrder, Production1.[Part Number], Production1.[Work Order], Production1.Location, StationItems.Station, Production1.Description, Production1.Revision, WRK_InputWorkOrders.Status
FROM StationItems INNER JOIN (WRK_InputWorkOrders INNER JOIN Production1 ON WRK_InputWorkOrders.WorkOrder = Production1.[Work Order]) ON StationItems.Item = Production1.[Part Number]
WHERE (((WRK_InputWorkOrders.Status)<>"closed"));

Is there a way to write sql-like queries for dataviews?

I have Sharepoint Designer 2007 and Access.

The goal is to get a report that a user can view in Internet Explorer.
I have tried using this method. But it returns duplicate records
I found this suggestion. It suggests using an XPath Filter
not(@yourvalue = preceding-sibling::dfs:YourRepeatingRowName/@yourvalue)

But wasn't able to get it to work. I don't know what to enter as YourRepeatingRowName

I found this link. Does anyone know if it can be used to perform such a join?

答:
Microsoft has a video demo and a writeup that may be just what you want:

Display data from multiple sources in a single Data View
http://office.microsoft.com/en-us/sharepointdesigner/HA103511401033.aspx

With Microsoft Office SharePoint Designer 2007, you can link two or more data sources that contain related data and then create a single Data View that displays data from those linked data sources.

OwnerDisplayName: Tom Winter


问:
But these conflict with your requirements or minimum-stability

Hi, I'm getting this problem when I try to install SparkPost PHP Library:

Problem 1

- The requested package sparkpost/sparkpost No version set (parsed as 1.0.0) is satisfiable by sparkpost/sparkpost[No version set (parsed
as 1.0.0)] but these conflict with your requirements or
minimum-stability.

It appears when I try to execute this command:

composer require sparkpost/sparkpost

Full Console Output:

You are running Composer with SSL/TLS protection disabled.
Using version ^2.0 for sparkpost/sparkpost
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package sparkpost/sparkpost No version set (parsed as 1.0.0) is satisfiable by sparkpost/sparkpost[No version set (parsed as 1.0.0)] but these conflict with your requirements or minimum-stability.

Installation failed, reverting ./composer.json to its original content.
```
<p>Composer File:</p>
<pre class="lang-json prettyprint-override"><code>{
  "name": "sparkpost/sparkpost",
  "description": "Client library for interfacing with the SparkPost API.",
  "license": "Apache 2.0",
  "authors": [
    {
      "name": "SparkPost"
    }
  ],
  "minimum-stability": "stable",
  "scripts": {
    "post-install-cmd": "post-install.sh",
    "post-update-cmd": "post-install.sh",
    "test": "./vendor/bin/phpunit",
    "fix-style": "php-cs-fixer fix ."
  },
  "require": {
    "php": "^5.6 || ^7.0",
    "php-http/httplug": "^1.0",
    "php-http/message": "^1.0",
    "php-http/client-implementation": "^1.0",
    "php-http/discovery": "^1.0",
    "php-http/guzzle6-adapter": "^1.1",
    "guzzlehttp/guzzle": "^6.2"
  },
  "require-dev": {
    "phpunit/phpunit": "^4.8 || ^5.4",
    "mockery/mockery": "^0.9.4",
    "friendsofphp/php-cs-fixer": "^1.11",
    "nyholm/nsa": "^1.0",
    "satooshi/php-coveralls": "dev-master",
    "phpunit/phpcov": "2.*"
  },
  "autoload": {
    "psr-4": {
      "SparkPost\\": "lib/SparkPost"
    }
  },
  "autoload-dev": {
    "psr-4": {
      "SparkPost\\Test\\": "test/unit"
    }
  }
}
</code>```

Any solution?

PD: I've tried to set "minimum-stability": "stable" to "dev", but I have the same error

答:
If your project doesn't have version, you should specify require the development version, e.g.:

```<code>composer require sparkpost/sparkpost --dev
</code>```

or:

```<code>composer require sparkpost/sparkpost:dev-master
</code>```

You can specify the version in your composer.json, then create a tag for that release (git tag).

See also: How do i use Composer to install a package without a version (only master)

Body:
Hi, I'm getting this problem when I try to install SparkPost PHP Library:

Problem 1

- The requested package sparkpost/sparkpost No version set (parsed as 1.0.0) is satisfiable by sparkpost/sparkpost[No version set (parsed
as 1.0.0)] but these conflict with your requirements or
minimum-stability.

It appears when I try to execute this command:

composer require sparkpost/sparkpost

Full Console Output:

You are running Composer with SSL/TLS protection disabled.
Using version ^2.0 for sparkpost/sparkpost
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package sparkpost/sparkpost No version set (parsed as 1.0.0) is satisfiable by sparkpost/sparkpost[No version set (parsed as 1.0.0)] but these conflict with your requirements or minimum-stability.

Installation failed, reverting ./composer.json to its original content.

Composer File:

{
  "name": "sparkpost/sparkpost",
  "description": "Client library for interfacing with the SparkPost API.",
  "license": "Apache 2.0",
  "authors": [
    {
      "name": "SparkPost"
    }
  ],
  "minimum-stability": "stable",
  "scripts": {
    "post-install-cmd": "post-install.sh",
    "post-update-cmd": "post-install.sh",
    "test": "./vendor/bin/phpunit",
    "fix-style": "php-cs-fixer fix ."
  },
  "require": {
    "php": "^5.6 || ^7.0",
    "php-http/httplug": "^1.0",
    "php-http/message": "^1.0",
    "php-http/client-implementation": "^1.0",
    "php-http/discovery": "^1.0",
    "php-http/guzzle6-adapter": "^1.1",
    "guzzlehttp/guzzle": "^6.2"
  },
  "require-dev": {
    "phpunit/phpunit": "^4.8 || ^5.4",
    "mockery/mockery": "^0.9.4",
    "friendsofphp/php-cs-fixer": "^1.11",
    "nyholm/nsa": "^1.0",
    "satooshi/php-coveralls": "dev-master",
    "phpunit/phpcov": "2.*"
  },
  "autoload": {
    "psr-4": {
      "SparkPost\\": "lib/SparkPost"
    }
  },
  "autoload-dev": {
    "psr-4": {
      "SparkPost\\Test\\": "test/unit"
    }
  }
}

Any solution?

PD: I've tried to set "minimum-stability": "stable" to "dev", but I have the same error

Body:
If your project doesn't have version, you should specify require the development version, e.g.:

composer require sparkpost/sparkpost --dev

or:

composer require sparkpost/sparkpost:dev-master

You can specify the version in your composer.json, then create a tag for that release (git tag).

See also: How do i use Composer to install a package without a version (only master)


问:
second project not showing tests in test explorer
I have a solution with a test project in it, based on nUnit.  All of the tests I created show in the test explorer window, I can execute, etc.

I added another unit test project to the solution, created references exactly like the first project, same nUnit version, same Platform target (Any CPU), same code structure, etc., just for a different product.  But I added tests (with Test attribute) to that project and they don't show in the Test Explorer.

All of my tests in the original project still show but no tests in my new project show.

How do I get tests from multiple projects to show in the Test Explorer window?
Is the Test Explorer window tied to a specific project?

答: I spent a day trying to figure this out but once I posted the question, as luck would have it, I figured out the solution.  I changed the nUnit version back to 3.7.1.0 and it works - both projects now show tests in the Test Explorer window.  </p>


问:
how to create and call an object to be called within a method
In the below code, I iterate through the all the directories and any file with extension 'js' i add it to "files_" array.
what I want to do as well is, to create an object or a method "accumulateData" that will be update every time "files_.push" is called. so that, for every iteration, that
"files_.push" is called, "accumulateData" will contain the recent/updated contants of "files_.push" and the totalsize.

Moreover, I want the below method to return "accumulateData", so that after the method "getFiles" finish iterations i can call something like,

```<code>console.log(accumulateData.totalSize)
</code>```

please let me know how to achieve that

code:

```<code>function getFiles(dir, files_) {
    files_ = files_ || [];
    var files = fs.readdirSync(dir);

    for (var i in files) {
        var name = dir + '/' + files[i];
        if (fs.statSync(name).isDirectory()) {
            getFiles(name, files_);
        } else if (name.endsWith('js')) {
            //totalSize += fs.statSync(name).size;
            files_.push({ name: name, size: fs.statSync(name).size });
           /*accumulateData(files, totalSize)
           {
               files = files;
               totoalSize = totalSize;
           }*/
       }
    }
    return files_;
    //return accumulateData
}
</code>```

my attempts

```<code>let totalSize = 0;
let accumulatedData;
function getFiles(dir, files_) {
  files_ = files_ || [];
  const files = fs.readdirSync(dir);

  for (const i in files) {
    const name = dir + '/' + files[i];
    if (fs.statSync(name).isDirectory()) {
      getFiles(name, files_);
    } else if (name.endsWith('js')) {
      // files_.push(name);

      totalSize += fs.statSync(name).size;
      files_.push({ name: name, size: fs.statSync(name).size });
      // data(files, totalSize);

      accumulatedData = {
        files: files,
        totalSize: totalSize
      };
    }
  }
  return accumulatedData;
}

console.log(getFiles('/home/bakria/Projects/smartvehicle').totalSize);
</code>```

答:
You can use an object that contain both the array of files and the total size:

```<code>function getFiles(dir, obj) {
    obj = obj || { files: [], totalSize: 0 };                    // if no object is provided then initialize obj with an object that contains an empty array for files and 0 for totalSize
    var files = fs.readdirSync(dir);
    for(var i = 0; i < files.length; i++) {
        var name = dir + '/' + files[i];
        var stat = fs.statSync(name);                            // to minimize the calls to fs.statSync
        if (stat.isDirectory()) {
            getFiles(name, obj);                                 // pass obj to getFile (recursion)
        } else if (name.endsWith('js')) {
            obj.totalSize += stat.size;                          // add this file's size to obj.totalSize
            obj.files.push({ name: name, size: stat.size });     // push this file's object into obj.files
       }
    }
    return obj;                                                  // return obj
}
</code>```

The return will be like this:

```<code>var result = getFiles("some/dir");
</code>```

where result is:

```<code>{
    files: [/* an array of files */],
    totalSize: /* total size of the files */
}
</code>```

thus result.files will be the array of files, and result.totalSize will be the total size.

Body:
In the below code, I iterate through the all the directories and any file with extension 'js' i add it to "files_" array.
what I want to do as well is, to create an object or a method "accumulateData" that will be update every time "files_.push" is called. so that, for every iteration, that
"files_.push" is called, "accumulateData" will contain the recent/updated contants of "files_.push" and the totalsize.

Moreover, I want the below method to return "accumulateData", so that after the method "getFiles" finish iterations i can call something like,

console.log(accumulateData.totalSize)

please let me know how to achieve that

code:

function getFiles(dir, files_) {
    files_ = files_ || [];
    var files = fs.readdirSync(dir);

    for (var i in files) {
        var name = dir + '/' + files[i];
        if (fs.statSync(name).isDirectory()) {
            getFiles(name, files_);
        } else if (name.endsWith('js')) {
            //totalSize += fs.statSync(name).size;
            files_.push({ name: name, size: fs.statSync(name).size });
           /*accumulateData(files, totalSize)
           {
               files = files;
               totoalSize = totalSize;
           }*/
       }
    }
    return files_;
    //return accumulateData
}

my attempts

let totalSize = 0;
let accumulatedData;
function getFiles(dir, files_) {
  files_ = files_ || [];
  const files = fs.readdirSync(dir);

  for (const i in files) {
    const name = dir + '/' + files[i];
    if (fs.statSync(name).isDirectory()) {
      getFiles(name, files_);
    } else if (name.endsWith('js')) {
      // files_.push(name);

      totalSize += fs.statSync(name).size;
      files_.push({ name: name, size: fs.statSync(name).size });
      // data(files, totalSize);

      accumulatedData = {
        files: files,
        totalSize: totalSize
      };
    }
  }
  return accumulatedData;
}

console.log(getFiles('/home/bakria/Projects/smartvehicle').totalSize);

Body:
You can use an object that contain both the array of files and the total size:

function getFiles(dir, obj) {
    obj = obj || { files: [], totalSize: 0 };                    // if no object is provided then initialize obj with an object that contains an empty array for files and 0 for totalSize
    var files = fs.readdirSync(dir);
    for(var i = 0; i < files.length; i++) {
        var name = dir + '/' + files[i];
        var stat = fs.statSync(name);                            // to minimize the calls to fs.statSync
        if (stat.isDirectory()) {
            getFiles(name, obj);                                 // pass obj to getFile (recursion)
        } else if (name.endsWith('js')) {
            obj.totalSize += stat.size;                          // add this file's size to obj.totalSize
            obj.files.push({ name: name, size: stat.size });     // push this file's object into obj.files
       }
    }
    return obj;                                                  // return obj
}

The return will be like this:

var result = getFiles("some/dir");

where result is:

{
    files: [/* an array of files */],
    totalSize: /* total size of the files */
}

thus result.files will be the array of files, and result.totalSize will be the total size.


问:
re.sub with variables, whole string by itself only
Column 1 in my csv has the target_string (to be replaced) and column 2 is the context (text_column). I can't get it to only remove the string when it is stand alone. I have tried adding \b, but that doesn't work.

Text : "Foo, FOOBAR FOO FOOBAR FOO FOO FOOBAR."

```<code>string_column = col [1]
text_column = col [2]
string_replacement = "BAR"

text_column = re.sub(string_column, string_replacement, text_column, flags=re.IGNORECASE)
</code>```

What I get is : "BARBAR BAR BARBAR BAR BAR BARBAR."

What I need is: "FOOBAR BAR FOOBAR BAR BAR FOOBAR."

EDIT I don't think this is a duplicate of the linked question. Those responses wouldn't have helped me, and are far more complicated than the simple solution provided here.

答:
You (probably) need \b on both sides:

```<code>import re

string = "Foo, FOOBAR FOO FOOBAR FOO FOO FOOBAR."

your_string_here = "FOO"
string_column = r"\b{}\b".format(your_string_here)
string_replacement = "BAR"

string = re.sub(string_column, 'BAR', string)
print(string)
</code>```

This yields

```<code>Foo, FOOBAR BAR FOOBAR BAR BAR FOOBAR.
</code>```

Body:
Column 1 in my csv has the target_string (to be replaced) and column 2 is the context (text_column). I can't get it to only remove the string when it is stand alone. I have tried adding \b, but that doesn't work.

Text : "Foo, FOOBAR FOO FOOBAR FOO FOO FOOBAR."

string_column = col [1]
text_column = col [2]
string_replacement = "BAR"

text_column = re.sub(string_column, string_replacement, text_column, flags=re.IGNORECASE)

What I get is : "BARBAR BAR BARBAR BAR BAR BARBAR."

What I need is: "FOOBAR BAR FOOBAR BAR BAR FOOBAR."

EDIT I don't think this is a duplicate of the linked question. Those responses wouldn't have helped me, and are far more complicated than the simple solution provided here.

Body:
You (probably) need \b on both sides:

import re

string = "Foo, FOOBAR FOO FOOBAR FOO FOO FOOBAR."

your_string_here = "FOO"
string_column = r"\b{}\b".format(your_string_here)
string_replacement = "BAR"

string = re.sub(string_column, 'BAR', string)
print(string)

This yields

Foo, FOOBAR BAR FOOBAR BAR BAR FOOBAR.


问:
Post With C# WebClient Multiple Json Object
I want to send Post Request with C# WebClient with this Json Schema :

```<code> [
  {
    "id": "00000000-0000-0000-0000-000000000000",
    "points": [
      {
        "timestamp": "2017-12-04T16:07:44.562Z",
        "value": 0
      }
    ]
  }
]
</code>```

I've tried This :

```<code>public class RequestData
{
    public string id {get; set; }
    public points points { get; set; }
}

public class points
{
     public DateTime timestamp { get; set; }
     public float value { get; set; }
}
</code>```

My Program :

```<code>Random number = new Random();
var req = new RequestData();
req.id = "0e13d9c-571c-44f4-b796-7c40c0e20a1d";
req.points = new points { timestamp = DateTime.UtcNow, value =
number.Next(100, 99999) };

JsonSerializerSettings settings = new JsonSerializerSettings();
var data = JsonConvert.SerializeObject(req);

WebClient client = new WebClient();

client.Headers.Add(HttpRequestHeader.Authorization,
AquaAtuhorization.accessToken);

client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
client.UploadString ("http://localhost:8080/api/v1/data/writeNumericValues",
data  );
</code>```

And I always get Http 415 (Unsupported Media Type).

How could I format my C# Object as the restApi accepeted Format.

答:
Your Json class needs to be like this, see http://json2csharp.com/ or use paste as JSON from VS https://blog.codeinside.eu/2014/09/08/Visual-Studio-2013-Paste-Special-JSON-And-Xml/</p>

```<code>public class Point
{
  public DateTime timestamp { get; set; }
  public int value { get; set; }
}

public class RootObject
{
  public string id { get; set; }
  public List<Point> points { get; set; }
}`
</code>```

Body:
I want to send Post Request with C# WebClient with this Json Schema :

 [
  {
    "id": "00000000-0000-0000-0000-000000000000",
    "points": [
      {
        "timestamp": "2017-12-04T16:07:44.562Z",
        "value": 0
      }
    ]
  }
]

I've tried This :

public class RequestData
{
    public string id {get; set; }
    public points points { get; set; }
}

public class points
{
     public DateTime timestamp { get; set; }
     public float value { get; set; }
}

My Program :

Random number = new Random();
var req = new RequestData();
req.id = "0e13d9c-571c-44f4-b796-7c40c0e20a1d";
req.points = new points { timestamp = DateTime.UtcNow, value =
number.Next(100, 99999) };

JsonSerializerSettings settings = new JsonSerializerSettings();
var data = JsonConvert.SerializeObject(req);

WebClient client = new WebClient();

client.Headers.Add(HttpRequestHeader.Authorization,
AquaAtuhorization.accessToken);

client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
client.UploadString ("http://localhost:8080/api/v1/data/writeNumericValues",
data  );

And I always get Http 415 (Unsupported Media Type).

How could I format my C# Object as the restApi accepeted Format.

Body:
Your Json class needs to be like this, see http://json2csharp.com/ or use paste as JSON from VS https://blog.codeinside.eu/2014/09/08/Visual-Studio-2013-Paste-Special-JSON-And-Xml/

public class Point
{
  public DateTime timestamp { get; set; }
  public int value { get; set; }
}

public class RootObject
{
  public string id { get; set; }
  public List<Point> points { get; set; }
}`


问:
How to exit GUARD outside and inside a function - Swift
In the following code I am practicing the use of GUARD (Book: OReilly Learning Swift)

```<code>guard 2+2 == 4 else {
print("The universe makes no sense")
return // this is mandatory!
}
print("We can continue with our daily lives")
</code>```

Why do I get the following code error?

error: return invalid outside of a func

Or is GUARD only used within functions?

答:
If the condition in your guard statement is not met, the else branch has to exit the current scope. return can only be used inside functions, as the error message shows, but return is not the only way to exit scope.

You can use throw outside functions as well and if the guard statement is in a loop, you can also use break or continue.

return valid in functions:

```<code>func testGuard(){
    guard 2+2 == 4 else {
        print("The universe makes no sense")
        return // this is mandatory!
    }
    print("We can continue with our daily lives")
}
</code>```

throw valid outside of function as well:

```<code>guard 2+2 == 4 else { throw NSError() }
</code>```

break valid in loops:

```<code>for i in 1..<5 {
    guard i < 5 else {
        break
    }
}
</code>```

continue valid in loops:

```<code>for someObject in someArray {
    guard let someProperty = someObject.someOptionalProperty else {
        continue
    }
}
</code>```

Body:
In the following code I am practicing the use of GUARD (Book: OReilly Learning Swift)

guard 2+2 == 4 else {
print("The universe makes no sense")
return // this is mandatory!
}
print("We can continue with our daily lives")

Why do I get the following code error?

error: return invalid outside of a func

Or is GUARD only used within functions?

Body:
If the condition in your guard statement is not met, the else branch has to exit the current scope. return can only be used inside functions, as the error message shows, but return is not the only way to exit scope.

You can use throw outside functions as well and if the guard statement is in a loop, you can also use break or continue.

return valid in functions:

func testGuard(){
    guard 2+2 == 4 else {
        print("The universe makes no sense")
        return // this is mandatory!
    }
    print("We can continue with our daily lives")
}

throw valid outside of function as well:

guard 2+2 == 4 else { throw NSError() }

break valid in loops:

for i in 1..<5 {
    guard i < 5 else {
        break
    }
}

continue valid in loops:

for someObject in someArray {
    guard let someProperty = someObject.someOptionalProperty else {
        continue
    }
}

ContentLicense: CC BY-SA 4.0


问:
Alter css keyframe properties at runtime
I have a simple keyframe animation which grows a dot and transforms the background into blue. How can I dynamically alter this background color?

```<code>@keyframes growDot {
    100% {
        background-color: #23b7e5;
        -webkit-transform: scale3d(0.9, 0.9, 0.9);
        transform: scale3d(0.9, 0.9, 0.9);
    }
}
</code>```

Obviously, something like $('keyframes growDot').css("background-color", "#FF00B0"); is not working.

答:
You can't target/modify a CSS class with jQuery. You can, however, add a new class that overrides an existing class.

```<code>$("[your selector]").addClass("[class that overrides growDot");
</code>```

Having said that, this approach seems a bit off. As others have suggested, it would be best to change the background of the div itself, independent of the .growDot class.

Body:
I have a simple keyframe animation which grows a dot and transforms the background into blue. How can I dynamically alter this background color?

@keyframes growDot {
    100% {
        background-color: #23b7e5;
        -webkit-transform: scale3d(0.9, 0.9, 0.9);
        transform: scale3d(0.9, 0.9, 0.9);
    }
}

Obviously, something like $('keyframes growDot').css("background-color", "#FF00B0"); is not working.

Body:
You can't target/modify a CSS class with jQuery. You can, however, add a new class that overrides an existing class.

$("[your selector]").addClass("[class that overrides growDot");

Having said that, this approach seems a bit off. As others have suggested, it would be best to change the background of the div itself, independent of the .growDot class.


答: You should change the background of the div that is animated instead of changing the background of the keyframe. </p>

Title: Alter css keyframe properties at runtime


问:
Express with absolute file path?
I have a directory sitting in dropbox on a different drive. The path is something like:

T:\Dropbox\Me\Dropbox (Work)\Project - Foo\FILES

Yet the following gives me a Cannot Get / Error when I try to access http://localhost:4101:

```<code>const os = require('os');
const express = require('express');
const fs = require('fs');

const localPath = `T:\\Dropbox\\Me\\Dropbox (Work)\\Project - Foo\\FILES`

const app = express();
app.use(express.static(localPath))

app.listen(4101, () => console.log('Local CDN Started!'))
</code>```

Note that fs.existsSync(localPath) is true.

How can I set express to properly use the folder in this other directory/drive?

答:
Express does not generate a directory listing. But you can use plugin serve-index:

```<code>app.use('/ftp', express.static('public/ftp'), serveIndex('public/ftp', {'icons': true}))
</code>```

Title: Express with absolute file path?

Body:
I have a directory sitting in dropbox on a different drive. The path is something like:

T:\Dropbox\Me\Dropbox (Work)\Project - Foo\FILES

Yet the following gives me a Cannot Get / Error when I try to access http://localhost:4101:

const os = require('os');
const express = require('express');
const fs = require('fs');

const localPath = `T:\\Dropbox\\Me\\Dropbox (Work)\\Project - Foo\\FILES`

const app = express();
app.use(express.static(localPath))

app.listen(4101, () => console.log('Local CDN Started!'))

Note that fs.existsSync(localPath) is true.

How can I set express to properly use the folder in this other directory/drive?

Body:
Express does not generate a directory listing. But you can use plugin serve-index:

app.use('/ftp', express.static('public/ftp'), serveIndex('public/ftp', {'icons': true}))


问:
How to extract xip archive using command line?
I searched around how to extract XIP archive using command line with no luck so I am leaving my own solution, as a bash function, here.

I found my inspiration here.

答: open -W archive.xip will work better since it will then block until the archive has finished opening.


问:
What causes Google search to display a byline for a GitHub repo?
When I do a Google Search on certain GitHub repositories, I see a byline and a date on the third line (following the URL).  For example, the "by D Stark - 2016" line in the following screenshot.  What causes this information to be displayed and what is the root source of the information?

答:
The author at the top is decorated with itemprop="author" which I believe trigger this schema http://schema.org/author.

Edit: if you copy-paste the HTML into https://search.google.com/structured-data/testing-tool you'll be able to see everything that is parsed. Marking HTML elements is one way to do it, another one is to build special json elements that contain this data. Ref https://developers.google.com/search/docs/guides/intro-structured-data


问:
Data transfer over wifi from laptop to Android phone in java
actually I am a CS student and at the end we have to submit a final project. I have developed an idea of making an application, that can be used to transfer data from an android phone to a Windows system over the wifi (something like shareIt). I have studied, java, C, C++, but not really actually built a project with them. The above mentioned is going to be my first, hopefully. What i am really confused in is knowing where to start from. What should i study in java, since i want to build this app with the  java and in addition any other skill that i must master(topics that are to my interest). I have got a year from now to submit my project and I'm willing to spend enough time to master my work. If anyone among you good folks would be kind enough to direct me through. It might seem a lot to reply about, but it might be a big step in making someone good at programming. I really have got this idea and nothing else...Since java is so vast i really don't know where to start from and what to start with.</p>

答:
You should start with Socket:
https://docs.oracle.com/javase/tutorial/networking/sockets/clientServer.html

Android & PC will be the same, you can test your code on your PC first.

Note: On Android, you need to create a separate thread with UI to make the socket work.


问:
Database modeling software with non-binary file format?
Do you know a database modeling software whose the file format can safely be tracked by a VCS without always creating conflicts ? (i.e. a non-binary file format.) It would be great if the software worked on Linux and MacOS also.

It would be even better if the file format could be diffed easily.

Edit:

I am currently using MySQL Workbench and am satisfied with it, however its binary file format keeps creating conflicts in the VCS, and using it is a pain because of this.

答:
I use microOLAP for MySQL database design. It's a windows application unfortunately (I'm a Linux+Mac user mysql too), but it works like a charm. It generates XML out of the database schema, so it can safely be imported into any VCS.
Otherwise, you can try Dia on Linux as well. It's not as advanced as microOLAP, but it does have limited ER-diagram designing possibilities.</p>


问:
Google Cloud Pub/Sub node library error parsing
I'm trying to handle error responses returned from the Google Cloud Pub/Sub api using their node client library. From what I can see, if you use their REST API directly (ie. not through the client library) they return common HTTP error codes:

https://cloud.google.com/pubsub/docs/reference/error-codes

However, their client library returns RPC style errors that do not adhere to http status code conventions.

I have a worker that is processing these responses and is expecting responses to conform to standard http response conventions. Does anyone know if there is a way to intercept the actual HTTP response that the client is handling and extract a status code from it? Alternatively, is there documentation somewhere listing out the potential RPC errors the node client can return so I can set up a mapping from them to http codes?

Thanks!

答: FYI this got answered as a Github issue here: https://github.com/GoogleCloudPlatform/google-cloud-node/issues/2761#issuecomment-348358474</p>


问:
xxx.replace() not working properly
At the moment I'm getting code from this api - I'm trying to show list of vehicles in a user friendly way, aka the 'classname', and I've got that running right with the code below:

```<code>var vehicleList = data.vehicles.map(v => v.classname);
var content = vehicleList.join(", ");
document.getElementById("vehicle").textContent = content;
</code>```

However, I want to replace the names of the vehicles with more understandable ones, for example the API might say "B_Quadbike_01" when I really want it to just say "Quadbike" in my html. I've tried doing that with the code below:

```<code>content.replace(/B_Quadbike_01/ig, "Quadbike");
</code>```

However it's just not working - am I doing it right? You can see what I mean with the vehicle list over here how it just looks like a complete mess.

Title: xxx.replace() not working properly

Body:
At the moment I'm getting code from this api - I'm trying to show list of vehicles in a user friendly way, aka the 'classname', and I've got that running right with the code below:

var vehicleList = data.vehicles.map(v => v.classname);
var content = vehicleList.join(", ");
document.getElementById("vehicle").textContent = content;

However, I want to replace the names of the vehicles with more understandable ones, for example the API might say "B_Quadbike_01" when I really want it to just say "Quadbike" in my html. I've tried doing that with the code below:

content.replace(/B_Quadbike_01/ig, "Quadbike");

However it's just not working - am I doing it right? You can see what I mean with the vehicle list over here how it just looks like a complete mess.


问:
What jar's are required to enable Jersey RequestDispatcher in Dropwizard
I'm working through the article trying to put a layer of basic auditing functionality on top of an existing minimal Dropwizard project.

The article also contains an associated repository.

The gradle.build in that repo doesn't seem to have any extra dependencies besides core DW:

```<code>dependencies {
    compile(
            'io.dropwizard:dropwizard-core:' + dropwizardVersion
    )
    testCompile(
            'junit:junit:4.11',
            'org.hamcrest:hamcrest-core:1.3',
            'org.mockito:mockito-all:1.9.5',
            'org.unitils:unitils-core:3.4.2'
    )
}
</code>```

My build is in Maven and seemingly contains an equivalent list of dependencies:

```<code><dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.dropwizard</groupId>
                <artifactId>dropwizard-bom</artifactId>
                <version>${dropwizard.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>io.dropwizard</groupId>
            <artifactId>dropwizard-core</artifactId>
        </dependency>
    </dependencies>
</code>```

What's not recognized are the imports for the RequestDispatcher / HttpContext when I'm trying to build an equivalent to this:

IntelliJ IDEA seems to recognize these on the classpath:

however what's needed is the reference to com.sun.jersey.api.core.HttpContext instead.

Could someone please point me to what extra jar files I might be missing here, or perhaps some references to the working demoes of auditing functionality on top of DW.

Thank you in advance.

答:
That article is using an older Dropwizard version when it was still using Jersey 1.x. Since you are using a newer version that uses 2.x, the way to do it now is to use a ContainerRequestFilter. You can get the resource information by injecting ResourceInfo. In Jersey 1.x the RequestDispatcher was used as there was so such thing as a ResourceInfo at that time, so this was a way to get the resource class and resource method.

```<code>@Provider
public class AuditRequestFilter implements ContainerRequestFilter {

    @Context
    private ResourceInfo info;

    @Override
    public void filter(ContainerRequestContext requestContext) throws IOException {

        Class<?> resourceClass = info.getResourceClass();
        Method resourceMethod = info.getResourceMethod();
    }
}
</code>```

The just register the filter with Dropwizard

```<code>env.jersey().register(AuditRequestFilter.class);
</code>```

Edit

Looking again at the code you linked to, it's probably better to use a ContainerResponseFilter since you want to check the status code before auditing. Also, to get the remote address, you can inject HttpServletRequest. You can also get URI information from the UriInfo

```<code>@Provider
public class AuditRequestFilter implements ContainerResponseFilter {

    @Context
    private HttpServletRequest request;

    @Context
    private ResourceInfo info;

    @Override
    public void filter(ContainerRequestContext requestContext,
                       ContainerResponseContext responseContext) throws IOException {

        int status = responseContext.getStatus();
        String remoteAddr = request.getRemoteAddr();

        UriInfo uriInfo = requestContext.getUriInfo();

        Class<?> resourceClass = info.getResourceClass();
        Method resourceMethod = info.getResourceMethod();
    }
}
</code>```

See also:

Jersey docs for Filter and Interceptors

Body:
I'm working through the article trying to put a layer of basic auditing functionality on top of an existing minimal Dropwizard project.

The article also contains an associated repository.

The gradle.build in that repo doesn't seem to have any extra dependencies besides core DW:

dependencies {
    compile(
            'io.dropwizard:dropwizard-core:' + dropwizardVersion
    )
    testCompile(
            'junit:junit:4.11',
            'org.hamcrest:hamcrest-core:1.3',
            'org.mockito:mockito-all:1.9.5',
            'org.unitils:unitils-core:3.4.2'
    )
}

My build is in Maven and seemingly contains an equivalent list of dependencies:

<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.dropwizard</groupId>
                <artifactId>dropwizard-bom</artifactId>
                <version>${dropwizard.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>io.dropwizard</groupId>
            <artifactId>dropwizard-core</artifactId>
        </dependency>
    </dependencies>

What's not recognized are the imports for the RequestDispatcher / HttpContext when I'm trying to build an equivalent to this:

IntelliJ IDEA seems to recognize these on the classpath:

however what's needed is the reference to com.sun.jersey.api.core.HttpContext instead.

Could someone please point me to what extra jar files I might be missing here, or perhaps some references to the working demoes of auditing functionality on top of DW.

Thank you in advance.

Body:
That article is using an older Dropwizard version when it was still using Jersey 1.x. Since you are using a newer version that uses 2.x, the way to do it now is to use a ContainerRequestFilter. You can get the resource information by injecting ResourceInfo. In Jersey 1.x the RequestDispatcher was used as there was so such thing as a ResourceInfo at that time, so this was a way to get the resource class and resource method.

@Provider
public class AuditRequestFilter implements ContainerRequestFilter {

    @Context
    private ResourceInfo info;

    @Override
    public void filter(ContainerRequestContext requestContext) throws IOException {

        Class<?> resourceClass = info.getResourceClass();
        Method resourceMethod = info.getResourceMethod();
    }
}

The just register the filter with Dropwizard

env.jersey().register(AuditRequestFilter.class);

Edit

Looking again at the code you linked to, it's probably better to use a ContainerResponseFilter since you want to check the status code before auditing. Also, to get the remote address, you can inject HttpServletRequest. You can also get URI information from the UriInfo

@Provider
public class AuditRequestFilter implements ContainerResponseFilter {

    @Context
    private HttpServletRequest request;

    @Context
    private ResourceInfo info;

    @Override
    public void filter(ContainerRequestContext requestContext,
                       ContainerResponseContext responseContext) throws IOException {

        int status = responseContext.getStatus();
        String remoteAddr = request.getRemoteAddr();

        UriInfo uriInfo = requestContext.getUriInfo();

        Class<?> resourceClass = info.getResourceClass();
        Method resourceMethod = info.getResourceMethod();
    }
}

See also:

Jersey docs for Filter and Interceptors


问:
loop throgh all the data to search particular string
I want to loop throgh all the column of all the tables available in my database to check which column containts string "Kroki Homes".

I have approx. 56 tables in my database. So it is hard to check in all the columns of these 56 tables. is there any easy way to achieve this in sql server?

答:
You can create one procedure and can pass the string for search. I found this some where this might help you.</p>

```<code>CREATE PROC [dbo].[SearchDataFromAllTables] (@SearchStr NVARCHAR(100))
AS
BEGIN

    SET NOCOUNT ON;

    CREATE TABLE #Results
    (
        ColumnName NVARCHAR(370),
        ColumnValue NVARCHAR(3630)
    )

    DECLARE @TableName NVARCHAR(256)
          , @ColumnName NVARCHAR(128)
          , @SearchStr2 NVARCHAR(110)

    SET @TableName = ''
    SET @SearchStr2 = QUOTENAME('%' + @SearchStr + '%', '''')

    WHILE @TableName IS NOT NULL
    BEGIN
        SET @ColumnName = ''
        SET @TableName = (
                SELECT MIN(QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME))
                FROM INFORMATION_SCHEMA.TABLES
                WHERE TABLE_TYPE = 'BASE TABLE'
                    AND QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME) > @TableName
                    AND OBJECTPROPERTY(OBJECT_ID(QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME)), 'IsMSShipped') = 0
                )

        WHILE (@TableName IS NOT NULL)
            AND (@ColumnName IS NOT NULL)
        BEGIN
            SET @ColumnName = (
                    SELECT MIN(QUOTENAME(COLUMN_NAME))
                    FROM INFORMATION_SCHEMA.COLUMNS
                    WHERE TABLE_SCHEMA = PARSENAME(@TableName, 2)
                        AND TABLE_NAME = PARSENAME(@TableName, 1)
                        AND DATA_TYPE IN (
                            'char'
                            ,'varchar'
                            ,'nchar'
                            ,'nvarchar'
                            )
                        AND QUOTENAME(COLUMN_NAME) > @ColumnName
                    )

            IF @ColumnName IS NOT NULL
            BEGIN
                INSERT INTO #Results
                EXEC (
                        'SELECT ''' + @TableName + '.' + @ColumnName + ''', LEFT(' + @ColumnName + ', 3630)
                         FROM ' + @TableName + ' (NOLOCK) ' + ' WHERE ' + @ColumnName + ' LIKE ' + @SearchStr2
                     )
            END
        END
    END

    SELECT ColumnName, ColumnValue FROM #Results

END
</code>```

Body:
You can create one procedure and can pass the string for search. I found this some where this might help you.

CREATE PROC [dbo].[SearchDataFromAllTables] (@SearchStr NVARCHAR(100))
AS
BEGIN

    SET NOCOUNT ON;

    CREATE TABLE #Results
    (
        ColumnName NVARCHAR(370),
        ColumnValue NVARCHAR(3630)
    )

    DECLARE @TableName NVARCHAR(256)
          , @ColumnName NVARCHAR(128)
          , @SearchStr2 NVARCHAR(110)

    SET @TableName = ''
    SET @SearchStr2 = QUOTENAME('%' + @SearchStr + '%', '''')

    WHILE @TableName IS NOT NULL
    BEGIN
        SET @ColumnName = ''
        SET @TableName = (
                SELECT MIN(QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME))
                FROM INFORMATION_SCHEMA.TABLES
                WHERE TABLE_TYPE = 'BASE TABLE'
                    AND QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME) > @TableName
                    AND OBJECTPROPERTY(OBJECT_ID(QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME)), 'IsMSShipped') = 0
                )

        WHILE (@TableName IS NOT NULL)
            AND (@ColumnName IS NOT NULL)
        BEGIN
            SET @ColumnName = (
                    SELECT MIN(QUOTENAME(COLUMN_NAME))
                    FROM INFORMATION_SCHEMA.COLUMNS
                    WHERE TABLE_SCHEMA = PARSENAME(@TableName, 2)
                        AND TABLE_NAME = PARSENAME(@TableName, 1)
                        AND DATA_TYPE IN (
                            'char'
                            ,'varchar'
                            ,'nchar'
                            ,'nvarchar'
                            )
                        AND QUOTENAME(COLUMN_NAME) > @ColumnName
                    )

            IF @ColumnName IS NOT NULL
            BEGIN
                INSERT INTO #Results
                EXEC (
                        'SELECT ''' + @TableName + '.' + @ColumnName + ''', LEFT(' + @ColumnName + ', 3630)
                         FROM ' + @TableName + ' (NOLOCK) ' + ' WHERE ' + @ColumnName + ' LIKE ' + @SearchStr2
                     )
            END
        END
    END

    SELECT ColumnName, ColumnValue FROM #Results

END


Title: Overflowing of HTML table

Body:
tr {
width: 100%;
display: inline-table;
table-layout: fixed;
}

table{
 height:300px;
 display: -moz-groupbox;
}
tbody{
  overflow-y: scroll;
  height: 400px;
  min-width: 1034px;
  position: absolute;
}

Col 1	Col 2	Col 3

.1.	.1.	.1.

..	..	..

..	.sdfdsfqf.	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

..	..	..

I am trying to make a fixed header HTML table.
Scrollable table with fixed header in bootstrap  I referred this question. But I have some sort of problems. The tbody's width is larger than the thead. When I resize the page it becomes larger.

While resizing

Without resizing

Body:
You need put the class : table-responsive.

tr {
width: 100%;
display: inline-table;
table-layout: fixed;
}

table{
 height:300px;
 display: -moz-groupbox;
}
tbody{
  overflow-y: scroll;
  height: 400px;
  min-width: 1034px;
  position: absolute;
}

<table class="table table-striped table-responsive">
<thead><tr><th>Col 1</th><th>Col 2</th><th>Col 3</th></tr></thead>
<tbody>
  <tr><td>.1.</td><td>.1.</td><td>.1.</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>.sdfdsfqf.</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  <tr><td>..</td><td>..</td><td>..</td></tr>
  </tbody>
</table>


问:
generateDataKey error Signature expired on AWS KMS?
I am working with my client so I cloned git repo and built application which use AWS KMS to generate data key.

All is works well on live server but when I got failed on my local environment.

Here is code snippet and result of error.

```<code>const AWS = require('aws-sdk');
AWS.config.update({region:'eu-central-1'});
const kms = new AWS.KMS({ apiVersion: '2014-11-01' });

kms.generateDataKey({
 KeyId: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
 KeySpec: 'AES_256',
}).promise()
.catch(err => {
 console.error('generateDataKey error', err.message, err.stack);
 throw err;
})
.then(data => {
 console.log(data);
});
</code>```

Is there a way to fix this error?

"GenerateDataKey error Signature expired...."

答:
When you send a request signed using the AWS SigV4 protocol (to KMS or any other AWS service), the requests include a timestamp from when the signature was generated. The tolerance is 5 minutes. This mechanism is in place to make replay attacks harder (they essentially have a smaller window to be peformed). More information here.

Since the same request is working fine on your server, but failing locally, I think the clock on your local workspace is off by more than five minutes.

Body:
I am working with my client so I cloned git repo and built application which use AWS KMS to generate data key.

All is works well on live server but when I got failed on my local environment.

Here is code snippet and result of error.

const AWS = require('aws-sdk');
AWS.config.update({region:'eu-central-1'});
const kms = new AWS.KMS({ apiVersion: '2014-11-01' });

kms.generateDataKey({
 KeyId: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
 KeySpec: 'AES_256',
}).promise()
.catch(err => {
 console.error('generateDataKey error', err.message, err.stack);
 throw err;
})
.then(data => {
 console.log(data);
});

Is there a way to fix this error?

"GenerateDataKey error Signature expired...."


问:
Loop multiple variable to form one table
What would be the best method to loop multiple variables into one table? Each variable could have one or more data points. For example, I wish to create something like this:

The following code example is only placing each item in a row.

```<code><table class="table">
<% (@variable1 + @variable2 + @variable3).each do |data, v2, v3| %>
<tr>
    <% if data.is_a?(Variable1) %>
    <td><%= data.date %></td>
    <td><%= data.name %></td>
    <% elsif data.is_a?(Variable2) %>
    <td><%= data.date %></td>
    <td><%= data.name %></td>
    <% elsif data.is_a?(Variable3) %>
    <td><%= data.date %></td>
    <td><%= data.name %></td>
    <% end %>
</tr>
<% end %>
</table>
</code>```

答:
In this case, since you don't know how many records might be in each array, I would find out the greatest length of the arrays I have.

In your controller for this aciton could do something like:
@max_length = [@variable_1, @variable_2, @variable_3].map(&:size).max

*Note: this assumes those variables are always arrays, even if they only have a length of 1.

Then in your view file you could do this:

```<code><table class="table">
<% @max_length.times do |n| %>
  <tr>
    <td><%= @variable_1[n].try(:date) %></td>
    <td><%= @variable_1[n].try(:name) %></td>
    <td><%= @variable_2[n].try(:date) %></td>
    <td><%= @variable_2[n].try(:name) %></td>
    <td><%= @variable_3[n].try(:date) %></td>
    <td><%= @variable_3[n].try(:name) %></td>
  </tr>
<% end %>
</table>
</code>```

This way, for the third row, for example, in columns 1 and 3 in your example there will be no values, but values for the second column, which has a third record, will appear.

Body:
What would be the best method to loop multiple variables into one table? Each variable could have one or more data points. For example, I wish to create something like this:

The following code example is only placing each item in a row.

<% (@variable1 + @variable2 + @variable3).each do |data, v2, v3| %>

    <% if data.is_a?(Variable1) %>
    <%= data.date %>
    <%= data.name %>
    <% elsif data.is_a?(Variable2) %>
    <%= data.date %>
    <%= data.name %>
    <% elsif data.is_a?(Variable3) %>
    <%= data.date %>
    <%= data.name %>
    <% end %>

<% end %>

Body:
In this case, since you don't know how many records might be in each array, I would find out the greatest length of the arrays I have.

In your controller for this aciton could do something like:
@max_length = [@variable_1, @variable_2, @variable_3].map(&:size).max

*Note: this assumes those variables are always arrays, even if they only have a length of 1.

Then in your view file you could do this:

<table class="table">
<% @max_length.times do |n| %>
  <tr>
    <td><%= @variable_1[n].try(:date) %></td>
    <td><%= @variable_1[n].try(:name) %></td>
    <td><%= @variable_2[n].try(:date) %></td>
    <td><%= @variable_2[n].try(:name) %></td>
    <td><%= @variable_3[n].try(:date) %></td>
    <td><%= @variable_3[n].try(:name) %></td>
  </tr>
<% end %>
</table>

This way, for the third row, for example, in columns 1 and 3 in your example there will be no values, but values for the second column, which has a third record, will appear.


问:
Updating UI when a model property changes in an ObservableCollection?
I have a view that has a group of images I get from a web service
I receive them in a list of this class:

```<code> public class ImageModel
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string imageUrl { get; set; }
    }
</code>```

under each image I show an up-vote button, so I added another bool property to the model above:

```<code> public bool UpVoted { get; set; }
</code>```

the ListView that shows these images is bound to an ObservableCollection<ImageModel > , I want to change the voting icon through a converter that convert the value of UpVoted to the corresponding icon, when the user click the voting icon: a command execute this method:

```<code>    private void OnVoting(ImageModel image)
    {
        Images.Single(x => x.id == image.id).UpVoted = !image.UpVoted;
    }
</code>```

the problem is that the UI is not updated, and to make sure that I understood the problem I turned the model to a View model and made the required changes to the UpVoted property (I'm using MVVM light library)

```<code>bool upVoted;
        public bool UpVoted
        {
            get { return upVoted; }
            set
            {
                Set(ref upVoted, value);
            }
        }
</code>```

and it works now,
so I need to bind the UpVoted to the UI, so it's updated whenever it changed

答:
first
your model class must inherit from MvxNotifyPropertyChanged

```<code>public class ImageModel : MvxNotifyPropertyChanged
    {
        public int Id { get; set; }
        public string Name { get; set; }
        private bool upVoted ;
        public bool UpVoted
        {
            get { return upVoted ; }
            set { upVoted = value; RaisePropertyChanged(() => UpVoted ); }
        }
    }
</code>```

then with MvxValueConverter  you ready to go

Body:
I have a view that has a group of images I get from a web service
I receive them in a list of this class:

 public class ImageModel
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string imageUrl { get; set; }
    }

under each image I show an up-vote button, so I added another bool property to the model above:

 public bool UpVoted { get; set; }

the ListView that shows these images is bound to an ObservableCollection<ImageModel > , I want to change the voting icon through a converter that convert the value of UpVoted to the corresponding icon, when the user click the voting icon: a command execute this method:

    private void OnVoting(ImageModel image)
    {
        Images.Single(x => x.id == image.id).UpVoted = !image.UpVoted;
    }

the problem is that the UI is not updated, and to make sure that I understood the problem I turned the model to a View model and made the required changes to the UpVoted property (I'm using MVVM light library)

bool upVoted;
        public bool UpVoted
        {
            get { return upVoted; }
            set
            {
                Set(ref upVoted, value);
            }
        }

and it works now,
so I need to bind the UpVoted to the UI, so it's updated whenever it changed

Body:
first
your model class must inherit from MvxNotifyPropertyChanged

public class ImageModel : MvxNotifyPropertyChanged
    {
        public int Id { get; set; }
        public string Name { get; set; }
        private bool upVoted ;
        public bool UpVoted
        {
            get { return upVoted ; }
            set { upVoted = value; RaisePropertyChanged(() => UpVoted ); }
        }
    }

then with MvxValueConverter  you ready to go


问:
.NET hot deploy/undeploy of bundled code. How to? Which container?
We are new to the .NET world and have built a small C# application on top of Nancy

We are looking for a way to "package" the application code so that we can programmatically hot deploy and undeploy it on top of a minimal Nancy based container (or any other appropriate container you may suggest)

How do we do this in the .NET world ?

In the JVM world, one way to do it is to package a Web Application Resource (war) that is deployed on top of a servlet engine, typically Jetty or Tomcat. There are other solutions (micro-containers, using class loaders directly, etc..). We are looking of an equivalent .NET paradigm.

EDIT Dec 5

There seems to be solutions around building Assemblies and using methods such as Assembly.LoadFromString.

This still seems pretty manual and we are looking for a C# library/framework to help with loading/unloading

答: If you are on Windows/IIS you can use MSDeploy to update your web app without downtime. Be aware that it will not keep any in-memory state as it will spin up the new version in a new AppDomain while the old AppDomain will be unloaded.</p>


问:
SAS - How to run a array over multiple files
I have multiple files with the same naming conventions and same data format: Dsn1 to Dsn7.

At the moment I am running the following

```<code>data temp (drop=i); set Dsn1;
array S_(12) S_AUD--S_USD;
do i=1 to 12;
S_[i] = log(S_{i});
end;
</code>```

I have not been able to figure out how to do this for all files?

Any help appreciated

答:
It depends. You could create a macro and run it for each file. Or you can run it for all files at once and create a 'big' file.

```<code>data temp (drop=i);
     set Dsn1 - dsn7;
     array S_(12) S_AUD--S_USD;
     do i=1 to 12;
           S_[i] = log(S_{i});
     end;
run;
</code>```

Macro approach:

```<code>%macro loop (num_datasets=);
  %do i=1 %to &num_datasets;

 data temp&i. (drop=i);
 set Dsn&i;
 array S_(12) S_AUD--S_USD;
 do i=1 to 12;
       S_[i] = log(S_{i});
 end;
 run;

%end;

 %mend;

%loop(num_datasets=5);
</code>```

The macro appendix in the documentation has several examples of how this can work:

https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Appendix/ta-p/291716

Body:
I have multiple files with the same naming conventions and same data format: Dsn1 to Dsn7.

At the moment I am running the following

data temp (drop=i); set Dsn1;
array S_(12) S_AUD--S_USD;
do i=1 to 12;
S_[i] = log(S_{i});
end;

I have not been able to figure out how to do this for all files?

Any help appreciated

Body:
It depends. You could create a macro and run it for each file. Or you can run it for all files at once and create a 'big' file.

data temp (drop=i);
     set Dsn1 - dsn7;
     array S_(12) S_AUD--S_USD;
     do i=1 to 12;
           S_[i] = log(S_{i});
     end;
run;

Macro approach:

%macro loop (num_datasets=);
  %do i=1 %to &num_datasets;

 data temp&i. (drop=i);
 set Dsn&i;
 array S_(12) S_AUD--S_USD;
 do i=1 to 12;
       S_[i] = log(S_{i});
 end;
 run;

%end;

 %mend;

%loop(num_datasets=5);

The macro appendix in the documentation has several examples of how this can work:

https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Appendix/ta-p/291716


问:
Navigate through pages in a paginator using React
First I want to say this is my first question, sorry if it doesn't meet the standards of a quality one (whether it's too messy / badly organized or explained), I'm listening to all kinds of feedback. Also sorry if my english is not perfect, I'll try to be as understandable as possible.

So here is my problem : I'm implementing a React paginator, compatible with server-side content-range pagination. I want to navigate through pages, when there are too much of them.

A basic example without styling available here (EDIT : working, see answer) : https://codesandbox.io/s/w03lkpmy48

(I'm a React rookie, so the quality of my code is probably questionable.)

I created a function calculateNumberOfPages(itemsCount) (l.42) where itemsCount can be a huge number, e.g 7683, to return an int used to create the
s.

In the render, I call this function (l.48) to get the number, then I loop on it x times and push
s in an array (l.53 to 65).

However, when the itemsCount is huge, that can result in something like this : https://i.imgur.com/zea4QaD.png

which is why I put an ellipsis if the number of pages is above 10 :
https://i.imgur.com/7FstTlO.png

Now, the problem is that I want to navigate through pages, to get next pages (4 by 4). If I click on the 10th page, i should have 10 11 12 13 14 ... 16 (for example), and same when I click on the 10th page, in order to have previous pages.

But I'm logically stuck, and I quite need your help. Some comments in the code might point out what I want to do, but they might be as messy as my logic.

If you have other questions, I'm all ears. Thanks for reading my question !

答:
Okay so I had help from a friend in order to do this.

What was essentially missing in my code was a way to conserve the state of the current page, to compare it. So I added a currentPage property in the state.

Then I added some Javascript (with if/else, needs to be optimized and cleansed) to compare values of the
s and the current page.

And I change the values displayed in the render.

You can see all of it in the codesandbox in the question !

Body:
Okay so I had help from a friend in order to do this.

What was essentially missing in my code was a way to conserve the state of the current page, to compare it. So I added a currentPage property in the state.

Then I added some Javascript (with if/else, needs to be optimized and cleansed) to compare values of the <li>s and the current page.

And I change the values displayed in the render.

You can see all of it in the codesandbox in the question !


问:
Bottom Menu bar with submenu
Im using the BottomNavigationViewEx library to display a Bottom Menu Bar in my android app, the library works well and fixes many of the shortcomings of the standard BottomNavigationView.

The problem comes when as per requirements I need to show 7 options in the menu, with 4 options being the direct access to their respective functionality and a "More" option, that should show a submenu with 3 more options (similar to a toolbar with items with property showAsAction="never")

Since the library does not admit more than 5 items and does not support submenus either I've been trying to implement a solution to no avail. Is there a way to implement this or any other bottom menu library that I could use that implements submenus (or lets me extend it to create a submenu)?

答:
@Jeav148, you can take help from androidhive tab tutorial.
https://www.androidhive.info/2015/09/android-material-design-working-with-tabs/

From this tutorial you can check the scrollable tabs, so you'll be able to add tabs as much menu items you want.
Just you need to use the tablayout inside RelativeLayout with property AlignParentBottom = "true" to show the tabs at bottom.

Title: Bottom Menu bar with submenu


问:
Nice searchable select-box in jQuery
I'm just starting to use the jQuery framework.
I really like the look of SelectMenu plugin. But unfortunately I have quite large set of data, so going through them in selectbox is not possible.
So, I need to do some search in the dataset.

Does anybody know, whether there is any plugin that combines look of SelectMenu and features of Autocomplete in jQuery? Or is there any easy possibility to modify Autocomplete look (i.e. show multi-line records and format each line separately)?

Thanks for replies

答: From what I've done with the jquery-ui autocomplete module it is very easy to modify the look and feel of it. Just take a look at the methods and attributes on the demo page. If you don't necessarily like how the jquery-ui autocomplete works/is set up you could also look at this tutorial for simple list filter that you can also configure to what you want here: http://kilianvalkhof.com/2010/javascript/how-to-build-a-fast-simple-list-filter-with-jquery/</p>

Title: Nice searchable select-box in jQuery