问:
ReCaptcha not working properly on iPhone
I have a website with a simple contact form.  The validation is somewhat minimal because it doesn't go into a database; just an email.  The form works as such:

There are 5 fields - 4 of which are required.  The submit is disabled until the 4 fields are valid, and then you can submit it.  Then everything is validated on the server again, including the recaptcha (which is not validated by me client side).  The whole process is done with ajax, and there are multiple tests that must pass on the server side or 4** headers are returned, and the fail callback handler is called.

Everything works like gangbusters on Chrome on the desktop (I haven't tried other browsers, but I can't imagine why they'd be different), but on the iPhone the reCaptcha always validates even if I don't check the box for the test.

In other words:  I still have to fill out the four values correctly in order to submit, but if I don't check the box for the reCaptcha, the request still succeeds.

I can post some code if anyone thinks that would be helpful, but it appears that the problem is with the device and not with the code.  Does anyone have any insight into this?

Note:  The server side is PHP/Apache if this is helpful.

Update: 5/28/2015:

I'm still debugging this, but it seems like Mobile Safari is ignoring my response headers on my iPhone.  When I output  the response to the page what I get on Desktop for (data,status,xhr) is:

data: my response which at this point just says error or success -> error

status: error

xhr:  {'error',400,'error'}

On Mobile safari:

data: error

status: success

xhr:  {'error',200,'success'}

So - it seems like it's just ignoring my response headers.  I tried explicitly setting {"headers":{"cache-control":"no-cache"}} but to no avail.

Update: 6/3/2015

Per Request, here is the code.  This is almost certainly more than you need.  It has also become more obtuse because of the changes I've made to try and fix it.  Also note that, while it may appear that there are variables that haven't been defined, they (should) have been defined in other files.

The client side

```<code> $('#submit').on('click', function(e) {

    $(this).parents('form').find('input').each(function() {
        $(this).trigger('blur');
    })
    var $btn = $(this);
    $btn = $btn.button('loading');
    var dfr = $.Deferred();

    if ($(this).attr('disabled') || $(this).hasClass('disabled')) {

        e.preventDefault();
        e.stopImmediatePropagation();
        dfr.reject();
        return false;

    } else {

        var input = $('form').serializeArray();
        var obj = {},
            j;

        $.each(input, function(i, a) {

            if (a.name === 'person-name') {

                obj.name = a.value;

            } else if (a.name === 'company-name') {

                obj.company_name = a.value;

            } else {

                j = a.name.replace(/(g-)(.*)(-response)/g, '$2');
                obj[j] = a.value;

            }

        });

        obj.action = 'recaptcha-js';
        obj.remoteIp = rc.remoteiP;
        rc.data = obj;

        var request = $.ajax({

            url: rc.ajaxurl,
            type: 'post',
            data: obj,

            headers: {
                'cache-control': 'no-cache'
            }

        });

        var success = function(data) {

            $btn.data('loadingText', 'Success');
            $btn.button('reset');
            $('#submit').addClass('btn-success').removeClass('btn-default');
            $btn.button('loading');
            dfr.resolve(data);

        };
        var fail = function(data) {

            var reason = JSON.parse(data.responseText).reason;
            $btn.delay(1000).button('reset');
            switch (reason) {

                case 'Recaptcha Failed':
                case 'Recaptcha Not Checked':
                case 'One Or more validator fields not valid or not filled out':
                case 'One Or more validator fields is invalid':

                    // reset recaptcha

                    if ($('#submit').data('tries')) {

                        $('#submit').remove();
                        $('.g-recaptcha').parent().addBack().remove();

                        myPopover('Your request is invalid.  Please reload the page to try again.');

                    } else {

                        $('#submit').data('tries', 1);
                        grecaptcha.reset();

                        myPopover('One or more of your entries are invalid.  Please make corrections and try again.');
                    }

                    break;

                default:

                    // reset page
                    $('#submit').remove();
                    $('.g-recaptcha').remove();

                    myPopover('There was a problem with your request.  Please reload the page and try again.');

                    break;
            }
            dfr.reject(data);

        };

        request.done(success);
        request.fail(fail);

    }
</code>```

The Server:

```<code>function _send_email(){

$recaptcha=false;
/* * */
if(isset($_POST['recaptcha'])):

    $gRecaptchaResponse=$_POST['recaptcha'];
    $remoteIp=isset($_POST['remoteIp']) ? $_POST['remoteIp'] : false;

    /* ** */
    if(!$remoteIp):

        $response=array('status_code'=>'409','reason'=>'remoteIP not set');
        echo json_encode($response);
        http_response_code(409);

        exit();

    endif;
    /* ** */

    /* ** */
    if($gRecaptchaResponse==''):

        $response=array('status_code'=>'400','reason'=>'Recaptcha Failed');
        echo json_encode($response);
        http_response_code(400);
        exit();

    endif;
    /* ** */

    if($recaptcha=recaptcha_test($gRecaptchaResponse,$remoteIp)):

        $recaptcha=true;

    /* ** */
    else:

        $response=array('status_code'=>'400','reason'=>'Recaptcha Failed');
        echo json_encode($response);
        http_response_code(400);
        exit();

    endif;
    /* ** */

/* * */
else:

    $response=array('status_code'=>'400','reason'=>'Recaptcha Not Checked');
    echo json_encode($response);
    http_response_code(400);
    exit();

endif;
/* * */

/* * */
if($recaptcha==1):

    $name=isset($_POST['name']) ? $_POST['name'] : false;
    $company_name=isset($_POST['company_name']) ? $_POST['company_name'] : false;
    $phone=isset($_POST['phone']) ? $_POST['phone'] : false;
    $email=isset($_POST['email']) ? $_POST['email'] : false;

    /* ** */
    if(isset($_POST['questions'])):

        $questions=$_POST['questions']=='' ? 1 : $_POST['questions'];

        /* *** */

    if(!$questions=filter_var($questions,FILTER_SANITIZE_SPECIAL_CHARS)):

         $response=array('status_code'=>'400','reason'=>'$questions could not be sanitized');
         echo json_encode($response);
         http_response_code(400);
         exit();

        endif;
       /* *** */

    /* ** */
    else:

      $questions=true;

    endif;
    /* ** */

    /* ** */
    if( count( array_filter( array( $name,$company_name,$phone,$email ),"filter_false" ) ) !=4 ):

        $response=array('status_code'=>'400','reason'=>'One Or more validator fields not valid or not filled out');
        echo json_encode($response);
        http_response_code(400);
        exit();

    endif;
    /* ** */

    $company_name=filter_var($company_name,FILTER_SANITIZE_SPECIAL_CHARS);
    $name=filter_var($name,FILTER_SANITIZE_SPECIAL_CHARS);
    $phone=preg_replace('/[^0-9+-]/', '', $phone);
    $email=filter_var($email,FILTER_VALIDATE_EMAIL);

    /* ** */
    if($company_name && $recaptcha && $name && $phone && $email && $questions):

        $phone_str='Phone:  ' . $phone;
        $company_str='Company:   ' . $company_name;
        $email_str='Email String:  ' . $email;
        $name_str='Name:  '.$name;
        $questions=$questions==1 ? '' : $questions;
        $body="$name_str\r\n\r\n$company_str\r\n\r\n$email_str\r\n\r\n$phone_str\r\n\r\n____________________\r\n\r\n$questions";

        $mymail='fake@fake.com';
        $headers   = array();
        $headers[] = "MIME-Version: 1.0";
        $headers[] = "Content-type: text/plain; charset=\"utf-8\"";
        $headers[] = "From: $email";
        $headers[] = "X-Mailer: PHP/" . phpversion();

        /* *** */
        if(mail('$mymail', 'Information Request from: ' . $name,$body,implode("\r\n",$headers))):

            $response=array('status_code'=>'200','reason'=>'Sent !');
            echo json_encode($response);
            http_response_code(200);
            exit();

        /* *** */
        else:

            $response=array('status_code'=>'400','reason'=>'One Or more validator fields is invalid');
            echo json_encode($response);
            http_response_code(400);
            exit();

        endif;
        /* *** */

     endif;
    /* ** */

   endif;
  /* * */

     $response=array('status_code'=>'412','reason'=>'There was an unknown error');
     echo json_encode($response);
     http_response_code(412);
     exit();
 }

function recaptcha_test($gRecaptchaResponse,$remoteIp){

    $secret=$itsasecret; //removed for security;

    require TEMPLATE_DIR . '/includes/lib/recaptcha/src/autoload.php';
    $recaptcha = new \ReCaptcha\ReCaptcha($secret);
    $resp = $recaptcha->verify($gRecaptchaResponse, $remoteIp);

    if ($resp->isSuccess()) {
        return true;
            // verified!
    } else {
        $errors = $resp->getErrorCodes();
        return false;
    }
 }
</code>```

答:
Like that question iOS: Authentication using XMLHttpRequest - Handling 401 reponse the easiest way to solve that is disregard natural headers validation and, on the callback sucess, validate with some flag.

I've saw some cases like that and never smell good.

Body:
I have a website with a simple contact form.  The validation is somewhat minimal because it doesn't go into a database; just an email.  The form works as such:

There are 5 fields - 4 of which are required.  The submit is disabled until the 4 fields are valid, and then you can submit it.  Then everything is validated on the server again, including the recaptcha (which is not validated by me client side).  The whole process is done with ajax, and there are multiple tests that must pass on the server side or 4** headers are returned, and the fail callback handler is called.

Everything works like gangbusters on Chrome on the desktop (I haven't tried other browsers, but I can't imagine why they'd be different), but on the iPhone the reCaptcha always validates even if I don't check the box for the test.

In other words:  I still have to fill out the four values correctly in order to submit, but if I don't check the box for the reCaptcha, the request still succeeds.

I can post some code if anyone thinks that would be helpful, but it appears that the problem is with the device and not with the code.  Does anyone have any insight into this?

Note:  The server side is PHP/Apache if this is helpful.

Update: 5/28/2015:

I'm still debugging this, but it seems like Mobile Safari is ignoring my response headers on my iPhone.  When I output  the response to the page what I get on Desktop for (data,status,xhr) is:

data: my response which at this point just says error or success -> error

status: error

xhr:  {'error',400,'error'}

On Mobile safari:

data: error

status: success

xhr:  {'error',200,'success'}

So - it seems like it's just ignoring my response headers.  I tried explicitly setting {"headers":{"cache-control":"no-cache"}} but to no avail.

Update: 6/3/2015

Per Request, here is the code.  This is almost certainly more than you need.  It has also become more obtuse because of the changes I've made to try and fix it.  Also note that, while it may appear that there are variables that haven't been defined, they (should) have been defined in other files.

The client side

 $('#submit').on('click', function(e) {

    $(this).parents('form').find('input').each(function() {
        $(this).trigger('blur');
    })
    var $btn = $(this);
    $btn = $btn.button('loading');
    var dfr = $.Deferred();

    if ($(this).attr('disabled') || $(this).hasClass('disabled')) {

        e.preventDefault();
        e.stopImmediatePropagation();
        dfr.reject();
        return false;

    } else {

        var input = $('form').serializeArray();
        var obj = {},
            j;

        $.each(input, function(i, a) {

            if (a.name === 'person-name') {

                obj.name = a.value;

            } else if (a.name === 'company-name') {

                obj.company_name = a.value;

            } else {

                j = a.name.replace(/(g-)(.*)(-response)/g, '$2');
                obj[j] = a.value;

            }

        });

        obj.action = 'recaptcha-js';
        obj.remoteIp = rc.remoteiP;
        rc.data = obj;

        var request = $.ajax({

            url: rc.ajaxurl,
            type: 'post',
            data: obj,

            headers: {
                'cache-control': 'no-cache'
            }

        });

        var success = function(data) {

            $btn.data('loadingText', 'Success');
            $btn.button('reset');
            $('#submit').addClass('btn-success').removeClass('btn-default');
            $btn.button('loading');
            dfr.resolve(data);

        };
        var fail = function(data) {

            var reason = JSON.parse(data.responseText).reason;
            $btn.delay(1000).button('reset');
            switch (reason) {

                case 'Recaptcha Failed':
                case 'Recaptcha Not Checked':
                case 'One Or more validator fields not valid or not filled out':
                case 'One Or more validator fields is invalid':

                    // reset recaptcha

                    if ($('#submit').data('tries')) {

                        $('#submit').remove();
                        $('.g-recaptcha').parent().addBack().remove();

                        myPopover('Your request is invalid.  Please reload the page to try again.');

                    } else {

                        $('#submit').data('tries', 1);
                        grecaptcha.reset();

                        myPopover('One or more of your entries are invalid.  Please make corrections and try again.');
                    }

                    break;

                default:

                    // reset page
                    $('#submit').remove();
                    $('.g-recaptcha').remove();

                    myPopover('There was a problem with your request.  Please reload the page and try again.');

                    break;
            }
            dfr.reject(data);

        };

        request.done(success);
        request.fail(fail);

    }

The Server:

function _send_email(){

$recaptcha=false;
/* * */
if(isset($_POST['recaptcha'])):

    $gRecaptchaResponse=$_POST['recaptcha'];
    $remoteIp=isset($_POST['remoteIp']) ? $_POST['remoteIp'] : false;

    /* ** */
    if(!$remoteIp):

        $response=array('status_code'=>'409','reason'=>'remoteIP not set');
        echo json_encode($response);
        http_response_code(409);

        exit();

    endif;
    /* ** */

    /* ** */
    if($gRecaptchaResponse==''):

        $response=array('status_code'=>'400','reason'=>'Recaptcha Failed');
        echo json_encode($response);
        http_response_code(400);
        exit();

    endif;
    /* ** */

    if($recaptcha=recaptcha_test($gRecaptchaResponse,$remoteIp)):

        $recaptcha=true;

    /* ** */
    else:

        $response=array('status_code'=>'400','reason'=>'Recaptcha Failed');
        echo json_encode($response);
        http_response_code(400);
        exit();

    endif;
    /* ** */

/* * */
else:

    $response=array('status_code'=>'400','reason'=>'Recaptcha Not Checked');
    echo json_encode($response);
    http_response_code(400);
    exit();

endif;
/* * */

/* * */
if($recaptcha==1):

    $name=isset($_POST['name']) ? $_POST['name'] : false;
    $company_name=isset($_POST['company_name']) ? $_POST['company_name'] : false;
    $phone=isset($_POST['phone']) ? $_POST['phone'] : false;
    $email=isset($_POST['email']) ? $_POST['email'] : false;

    /* ** */
    if(isset($_POST['questions'])):

        $questions=$_POST['questions']=='' ? 1 : $_POST['questions'];

        /* *** */

    if(!$questions=filter_var($questions,FILTER_SANITIZE_SPECIAL_CHARS)):

         $response=array('status_code'=>'400','reason'=>'$questions could not be sanitized');
         echo json_encode($response);
         http_response_code(400);
         exit();

        endif;
       /* *** */

    /* ** */
    else:

      $questions=true;

    endif;
    /* ** */

    /* ** */
    if( count( array_filter( array( $name,$company_name,$phone,$email ),"filter_false" ) ) !=4 ):

        $response=array('status_code'=>'400','reason'=>'One Or more validator fields not valid or not filled out');
        echo json_encode($response);
        http_response_code(400);
        exit();

    endif;
    /* ** */

    $company_name=filter_var($company_name,FILTER_SANITIZE_SPECIAL_CHARS);
    $name=filter_var($name,FILTER_SANITIZE_SPECIAL_CHARS);
    $phone=preg_replace('/[^0-9+-]/', '', $phone);
    $email=filter_var($email,FILTER_VALIDATE_EMAIL);

    /* ** */
    if($company_name && $recaptcha && $name && $phone && $email && $questions):

        $phone_str='Phone:  ' . $phone;
        $company_str='Company:   ' . $company_name;
        $email_str='Email String:  ' . $email;
        $name_str='Name:  '.$name;
        $questions=$questions==1 ? '' : $questions;
        $body="$name_str\r\n\r\n$company_str\r\n\r\n$email_str\r\n\r\n$phone_str\r\n\r\n____________________\r\n\r\n$questions";

        $mymail='fake@fake.com';
        $headers   = array();
        $headers[] = "MIME-Version: 1.0";
        $headers[] = "Content-type: text/plain; charset=\"utf-8\"";
        $headers[] = "From: $email";
        $headers[] = "X-Mailer: PHP/" . phpversion();

        /* *** */
        if(mail('$mymail', 'Information Request from: ' . $name,$body,implode("\r\n",$headers))):

            $response=array('status_code'=>'200','reason'=>'Sent !');
            echo json_encode($response);
            http_response_code(200);
            exit();

        /* *** */
        else:

            $response=array('status_code'=>'400','reason'=>'One Or more validator fields is invalid');
            echo json_encode($response);
            http_response_code(400);
            exit();

        endif;
        /* *** */

     endif;
    /* ** */

   endif;
  /* * */

     $response=array('status_code'=>'412','reason'=>'There was an unknown error');
     echo json_encode($response);
     http_response_code(412);
     exit();
 }

function recaptcha_test($gRecaptchaResponse,$remoteIp){

    $secret=$itsasecret; //removed for security;

    require TEMPLATE_DIR . '/includes/lib/recaptcha/src/autoload.php';
    $recaptcha = new \ReCaptcha\ReCaptcha($secret);
    $resp = $recaptcha->verify($gRecaptchaResponse, $remoteIp);

    if ($resp->isSuccess()) {
        return true;
            // verified!
    } else {
        $errors = $resp->getErrorCodes();
        return false;
    }
 }


来源: stackexchange

问:
Why must I click twice to open and close my menu
Hello I got a situation which I do not understand quite well. I have the following setup:

 $(document).ready(function(){
  $('.menuBtn').on('click touch', function () {
  $(this).toggleClass('act');
   if($(this).hasClass('act')) {
    $('.mobileMenu').addClass('act');
    //$('body').addClass('positionfixed');
   }
   else {
    $('.mobileMenu').removeClass('act');
    //$('body').removeClass('positionfixed');
   }
 });
   });```
<pre class="snippet-code-css lang-css prettyprint-override"><code> .mobile-menu-button{
  display:block;
  position:fixed;
  top:20px;
  left:20px;
  z-index:99;
    background-color:#19b698;
    padding:5px 10px;
    color:#fff;
    font-family: Open Sans;
    font-weight:bold;
 }
 .mobile-menu-button i{
  font-size:26px;
  background-color:#00adee;
  padding:5px 10px;
  color:#fff;
 }
.mobileMenu {
  background-color: #fff !important;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  height: 100vh;
  width: 100vw;
  display: block;
  text-align: center;
  opacity: 0;
  -webkit-transition: all 500ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
  transition: all 500ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
  -webkit-transform: scale(0);
     transform: scale(0);
  overflow:hidden;
 }
 .mobileMenu img{
  max-width:90%;
  margin:0 auto;
  margin-top:20px;
  margin-bottom:10px;
  border-bottom:1px dotted #717274;
  padding-bottom:20px;
 }
 .mobileMenu.act {
  opacity: 1;
  -webkit-transform: scale(1);
     transform: scale(1);
 }
 .mobileMenu.act ul li {
  opacity: 1;
  -webkit-transform: translateX(0);
     transform: translateX(0);
  display:block !important;
 }
 .mobileMenu ul {
  display: block;
  vertical-align: middle;
 }
 .mobileMenu li {
  padding: 10px 0 !important;
  -webkit-transition: all 400ms 510ms;
  transition: all 400ms 510ms;
  opacity: 0;
 }
 .mobileMenu li:nth-child(odd) {
   -webkit-transform: translateX(30%);
     transform: translateX(30%);
 }
 .mobileMenu li:nth-child(even) {
   -webkit-transform: translateX(-30%);
     transform: translateX(-30%);
 }
 .mobileMenu li:last-child {
   -webkit-transform: none;
     transform: none;
 }
 .mobileMenu a {
   color: #00adee !important;
   display: inline-block;
   font-size: 18px;
 }
 .mobileMenu a.suBtn {
   color: #fff;
 }</code>```

Open

  Close

Home

Testimonials

Contact

```

Why should I press two times on the open / close button to open / close the menu?

Anyone any idea / fix?

答:
You have 2 .menuBtn.
You could simplify your code to something like this:

$(document).ready(function(){
  $('.menuBtn').on('click touch', function () {
    $('.mobileMenu').toggleClass('act');
    $(this).text($(this).text() === 'Open' ? 'Close' : 'Open')
 });
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.mobile-menu-button{
  display:block;
  position:fixed;
  top:20px;
  left:20px;
  z-index:101;
    background-color:#19b698;
    padding:5px 10px;
    color:#fff;
    font-family: Open Sans;
    font-weight:bold;
    cursor: pointer;
 }
 .mobile-menu-button i{
  font-size:26px;
  background-color:#00adee;
  padding:5px 10px;
  color:#fff;
 }
.mobileMenu {
  background-color: #fff !important;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  height: 100vh;
  width: 100vw;
  display: block;
  text-align: center;
  opacity: 0;
  -webkit-transition: all 500ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
  transition: all 500ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
  -webkit-transform: scale(0);
     transform: scale(0);
  overflow:hidden;
 }
 .mobileMenu img{
  max-width:90%;
  margin:0 auto;
  margin-top:20px;
  margin-bottom:10px;
  border-bottom:1px dotted #717274;
  padding-bottom:20px;
 }
 .mobileMenu.act {
  opacity: 1;
  -webkit-transform: scale(1);
     transform: scale(1);
 }
 .mobileMenu.act ul li {
  opacity: 1;
  -webkit-transform: translateX(0);
     transform: translateX(0);
  display:block !important;
 }
 .mobileMenu ul {
  display: block;
  vertical-align: middle;
 }
 .mobileMenu li {
  padding: 10px 0 !important;
  -webkit-transition: all 400ms 510ms;
  transition: all 400ms 510ms;
  opacity: 0;
 }
 .mobileMenu li:nth-child(odd) {
   -webkit-transform: translateX(30%);
     transform: translateX(30%);
 }
 .mobileMenu li:nth-child(even) {
   -webkit-transform: translateX(-30%);
     transform: translateX(-30%);
 }
 .mobileMenu li:last-child {
   -webkit-transform: none;
     transform: none;
 }
 .mobileMenu a {
   color: #00adee !important;
   display: inline-block;
   font-size: 18px;
 }
 .mobileMenu a.suBtn {
   color: #fff;
 }</code>```

Open

Home

Testimonials

Contact

```

ContentLicense: CC BY-SA 3.0

Body:
Hello I got a situation which I do not understand quite well. I have the following setup:

 $(document).ready(function(){
  $('.menuBtn').on('click touch', function () {
  $(this).toggleClass('act');
   if($(this).hasClass('act')) {
    $('.mobileMenu').addClass('act');
    //$('body').addClass('positionfixed');
   }
   else {
    $('.mobileMenu').removeClass('act');
    //$('body').removeClass('positionfixed');
   }
 });
   });

 .mobile-menu-button{
  display:block;
  position:fixed;
  top:20px;
  left:20px;
  z-index:99;
    background-color:#19b698;
    padding:5px 10px;
    color:#fff;
    font-family: Open Sans;
    font-weight:bold;
 }
 .mobile-menu-button i{
  font-size:26px;
  background-color:#00adee;
  padding:5px 10px;
  color:#fff;
 }
.mobileMenu {
  background-color: #fff !important;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  height: 100vh;
  width: 100vw;
  display: block;
  text-align: center;
  opacity: 0;
  -webkit-transition: all 500ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
  transition: all 500ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
  -webkit-transform: scale(0);
     transform: scale(0);
  overflow:hidden;
 }
 .mobileMenu img{
  max-width:90%;
  margin:0 auto;
  margin-top:20px;
  margin-bottom:10px;
  border-bottom:1px dotted #717274;
  padding-bottom:20px;
 }
 .mobileMenu.act {
  opacity: 1;
  -webkit-transform: scale(1);
     transform: scale(1);
 }
 .mobileMenu.act ul li {
  opacity: 1;
  -webkit-transform: translateX(0);
     transform: translateX(0);
  display:block !important;
 }
 .mobileMenu ul {
  display: block;
  vertical-align: middle;
 }
 .mobileMenu li {
  padding: 10px 0 !important;
  -webkit-transition: all 400ms 510ms;
  transition: all 400ms 510ms;
  opacity: 0;
 }
 .mobileMenu li:nth-child(odd) {
   -webkit-transform: translateX(30%);
     transform: translateX(30%);
 }
 .mobileMenu li:nth-child(even) {
   -webkit-transform: translateX(-30%);
     transform: translateX(-30%);
 }
 .mobileMenu li:last-child {
   -webkit-transform: none;
     transform: none;
 }
 .mobileMenu a {
   color: #00adee !important;
   display: inline-block;
   font-size: 18px;
 }
 .mobileMenu a.suBtn {
   color: #fff;
 }

Open

  Close

Home

Testimonials

Contact

Why should I press two times on the open / close button to open / close the menu?

Anyone any idea / fix?

Body:
You have 2 .menuBtn.
You could simplify your code to something like this:

$(document).ready(function(){
  $('.menuBtn').on('click touch', function () {
    $('.mobileMenu').toggleClass('act');
    $(this).text($(this).text() === 'Open' ? 'Close' : 'Open')
 });
});

.mobile-menu-button{
  display:block;
  position:fixed;
  top:20px;
  left:20px;
  z-index:101;
    background-color:#19b698;
    padding:5px 10px;
    color:#fff;
    font-family: Open Sans;
    font-weight:bold;
    cursor: pointer;
 }
 .mobile-menu-button i{
  font-size:26px;
  background-color:#00adee;
  padding:5px 10px;
  color:#fff;
 }
.mobileMenu {
  background-color: #fff !important;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  height: 100vh;
  width: 100vw;
  display: block;
  text-align: center;
  opacity: 0;
  -webkit-transition: all 500ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
  transition: all 500ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
  -webkit-transform: scale(0);
     transform: scale(0);
  overflow:hidden;
 }
 .mobileMenu img{
  max-width:90%;
  margin:0 auto;
  margin-top:20px;
  margin-bottom:10px;
  border-bottom:1px dotted #717274;
  padding-bottom:20px;
 }
 .mobileMenu.act {
  opacity: 1;
  -webkit-transform: scale(1);
     transform: scale(1);
 }
 .mobileMenu.act ul li {
  opacity: 1;
  -webkit-transform: translateX(0);
     transform: translateX(0);
  display:block !important;
 }
 .mobileMenu ul {
  display: block;
  vertical-align: middle;
 }
 .mobileMenu li {
  padding: 10px 0 !important;
  -webkit-transition: all 400ms 510ms;
  transition: all 400ms 510ms;
  opacity: 0;
 }
 .mobileMenu li:nth-child(odd) {
   -webkit-transform: translateX(30%);
     transform: translateX(30%);
 }
 .mobileMenu li:nth-child(even) {
   -webkit-transform: translateX(-30%);
     transform: translateX(-30%);
 }
 .mobileMenu li:last-child {
   -webkit-transform: none;
     transform: none;
 }
 .mobileMenu a {
   color: #00adee !important;
   display: inline-block;
   font-size: 18px;
 }
 .mobileMenu a.suBtn {
   color: #fff;
 }

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span class="mobile-menu-button menuBtn">Open</span>
  <nav class="mobileMenu">
  <ul>
    <li><a href="index.html">Home</a></li>
    <li><a href="testimonials.html">Testimonials</a></li>
    <li><a href="contact.html">Contact</a></li>
  </ul>
</nav>


问:
Get data from database with PHP
I have the following PHP code but it doesn't work:

```<code><?php
$pid = "test123";
$conn = mysql_connect('localhost', 'user', 'password');
mysql_select_db('database');
$result = mysql_query('SELECT name FROM my_table WHERE
channel=$pid', $conn);
$content = mysql_result($result, 0);
echo $content;
?>
</code>```

I just get a blank page...

Can someone pls help me?! Thank's!

答:
First, you should run away from using mysql_* functions, use mysqli_* instead.
That said, you should display the data, not the result object.

Example

```<code>while ($row = mysql_fetch_assoc($result)) {
      echo $row['column_name'];
}
</code>```

Still doesn't work? Use mysql_error() to view the mysql error message.

ContentLicense: CC BY-SA 4.0

Title: Get data from database with PHP

Body:
I have the following PHP code but it doesn't work:

<?php
$pid = "test123";
$conn = mysql_connect('localhost', 'user', 'password');
mysql_select_db('database');
$result = mysql_query('SELECT name FROM my_table WHERE
channel=$pid', $conn);
$content = mysql_result($result, 0);
echo $content;
?>

I just get a blank page...

Can someone pls help me?! Thank's!

Body:
First, you should run away from using mysql_* functions, use mysqli_* instead.
That said, you should display the data, not the result object.

Example

while ($row = mysql_fetch_assoc($result)) {
      echo $row['column_name'];
}

Still doesn't work? Use mysql_error() to view the mysql error message.


问:
Spring security issue with 404 error?
greetings all, i am using spring security 3.0.2, urlRewrite 3.1.0
, and i have a problem with spring security that i have a rule that all the pages in the app requires authentication except for some pages so my security.xml is:

```<code><http use-expressions="true" >
<intercept-url pattern="/" access="permitAll" />
<intercept-url pattern="/error"  filter="none" />
<intercept-url pattern="/**" access="isAuthenticated()" />
.
.
.</http>
</code>```

in the web.xml i have defined the error page

```<code><error-page>
   <error-code>404</error-code>
   <location>/p/error</location>
</error-page>
</code>```

and the issue is that if i am not a logged in user, and typed some url that doesn't exist in the app like app/notFoundUrl the spring security matched this page to the pattern /** which requires authentication, so the user is not redirected to the error page as expected, but redirected to the login page and after it, redirected to the error page

and i want that if the user typed a bad url if he's logged in or not, he's redirected to the error page directly.

i think that the problem is related to the web.xml, here's it:

```<code><?xml version="1.0" encoding="ISO-8859-1"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

    <!-- Beans in these files will makeup the configuration of the root web application context -->
    <!-- Bootstraps the root web application context before servlet initialization-->
    <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <!-- Deploys the 'projects' dispatcher servlet whose configuration resides in /WEB-INF/servlet-config.xml-->
    <servlet>
        <servlet-name>p</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>
            /WEB-INF/servlet-config.xml
            </param-value>
        </init-param>
    </servlet>

    <!-- Maps all /p URLs to the 'p' servlet -->
    <servlet-mapping>
        <servlet-name>p</servlet-name>
        <url-pattern>/p/*</url-pattern>
    </servlet-mapping>

   <error-page>
   <error-code>404</error-code>
   <location>/p/error</location>
   </error-page>

   <!-- force encoding on the requests -->
   <filter>
    <filter-name>encoding-filter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
      <param-name>encoding</param-name>
      <param-value>utf-8</param-value>
    </init-param>
    <init-param>
      <param-name>forceEncoding</param-name>
      <param-value>true</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>encoding-filter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
  </filter-mapping>

    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

   <filter>
    <filter-name>UrlRewriteFilter</filter-name>
    <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>

  </filter>
  <filter-mapping>
    <filter-name>UrlRewriteFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

    <!-- Security -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
      /WEB-INF/application-config.xml
      /WEB-INF/app-security.xml
      /WEB-INF/mvc-config.xml
    </param-value>
    </context-param>

    <session-config>
      <session-timeout>1</session-timeout>
    </session-config>

</web-app>
</code>```

any ideas how to solve this issue ?

答:
You have said:

i want that if the user typed a bad url if he's logged in or not, he's redirected to the error page directly

Spring security will intercept every request before it knows whether its url is valid or not, so a way to get it would be intercept all valid urls with some patterns, and add at the end a general pattern which could be accessed by anyone.

```<code><intercept-url pattern="/" access="permitAll" />
<intercept-url pattern="/validUrl1Pattern"  access="permitAll" />
<intercept-url pattern="/validUrl2Pattern"  access="permitAll" />
<intercept-url pattern="/validUrl2Pattern"  access="permitAll" />
...
<intercept-url pattern="/**" access="ROLE_ANONYMOUS" />
</code>```

The problem of this configuration is that is probably difficult to find patterns for all the valid urls if your application is complex.

ContentLicense: CC BY-SA 2.5

Title: Spring security issue with 404 error?

Body:
greetings all, i am using spring security 3.0.2, urlRewrite 3.1.0
, and i have a problem with spring security that i have a rule that all the pages in the app requires authentication except for some pages so my security.xml is:

<http use-expressions="true" >
<intercept-url pattern="/" access="permitAll" />
<intercept-url pattern="/error"  filter="none" />
<intercept-url pattern="/**" access="isAuthenticated()" />
.
.
.</http>

in the web.xml i have defined the error page

<error-page>
   <error-code>404</error-code>
   <location>/p/error</location>
</error-page>

and the issue is that if i am not a logged in user, and typed some url that doesn't exist in the app like app/notFoundUrl the spring security matched this page to the pattern /** which requires authentication, so the user is not redirected to the error page as expected, but redirected to the login page and after it, redirected to the error page

and i want that if the user typed a bad url if he's logged in or not, he's redirected to the error page directly.

i think that the problem is related to the web.xml, here's it:

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

    <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <servlet>
        <servlet-name>p</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>
            /WEB-INF/servlet-config.xml
            </param-value>
        </init-param>
    </servlet>

    <servlet-mapping>
        <servlet-name>p</servlet-name>
        <url-pattern>/p/*</url-pattern>
    </servlet-mapping>

   <error-page>
   <error-code>404</error-code>
   <location>/p/error</location>
   </error-page>

   <filter>
    <filter-name>encoding-filter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
      <param-name>encoding</param-name>
      <param-value>utf-8</param-value>
    </init-param>
    <init-param>
      <param-name>forceEncoding</param-name>
      <param-value>true</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>encoding-filter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
  </filter-mapping>

    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

   <filter>
    <filter-name>UrlRewriteFilter</filter-name>
    <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>

  </filter>
  <filter-mapping>
    <filter-name>UrlRewriteFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
      /WEB-INF/application-config.xml
      /WEB-INF/app-security.xml
      /WEB-INF/mvc-config.xml
    </param-value>
    </context-param>

    <session-config>
      <session-timeout>1</session-timeout>
    </session-config>

</web-app>

any ideas how to solve this issue ?

Body:
You have said:

i want that if the user typed a bad url if he's logged in or not, he's redirected to the error page directly

Spring security will intercept every request before it knows whether its url is valid or not, so a way to get it would be intercept all valid urls with some patterns, and add at the end a general pattern which could be accessed by anyone.

<intercept-url pattern="/" access="permitAll" />
<intercept-url pattern="/validUrl1Pattern"  access="permitAll" />
<intercept-url pattern="/validUrl2Pattern"  access="permitAll" />
<intercept-url pattern="/validUrl2Pattern"  access="permitAll" />
...
<intercept-url pattern="/**" access="ROLE_ANONYMOUS" />

The problem of this configuration is that is probably difficult to find patterns for all the valid urls if your application is complex.


问:
C# sql How to get specific column's data to datagrid
I want to get specific colums to show on my C# WPF DataGrid.

I used this code to get selected columns:

```<code>using (SqlConnection con = new SqlConnection(ConString))
{
    SqlCommand cmd = new SqlCommand("SELECT roll FROM cmt_7th", con);
    SqlDataAdapter sda = new SqlDataAdapter(cmd);
    DataTable dt = new DataTable("cmt_7th");
    sda.Fill(dt);
    MydataGrid_roll.ItemsSource = dt.DefaultView;
}
</code>```

But I want to show only those row which column data is empty .

Left image is output screen short and right image is sql table image on "Like this" link image

I want to get rows 5 to 10 and ignore 1 to 4 row where all columns are not null.

答:
According to your description, you want to get all row where name, department, phone are null. So, you have to apply condition in your sql. Please check this:

```<code>string ConString = ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(ConString))
{

    SqlCommand cmd = new SqlCommand("SELECT roll FROM cmt_7th WHERE name IS Null And department IS Null And phone IS Null", con);
    SqlDataAdapter sda = new SqlDataAdapter(cmd);
    DataTable dt = new DataTable("cmt_7th");
    sda.Fill(dt);
    MydataGrid_roll.ItemsSource = dt.DefaultView;

}
</code>```

Check this output of the SQL:

Body:
I want to get specific colums to show on my C# WPF DataGrid.

I used this code to get selected columns:

using (SqlConnection con = new SqlConnection(ConString))
{
    SqlCommand cmd = new SqlCommand("SELECT roll FROM cmt_7th", con);
    SqlDataAdapter sda = new SqlDataAdapter(cmd);
    DataTable dt = new DataTable("cmt_7th");
    sda.Fill(dt);
    MydataGrid_roll.ItemsSource = dt.DefaultView;
}

But I want to show only those row which column data is empty .

Left image is output screen short and right image is sql table image on "Like this" link image

I want to get rows 5 to 10 and ignore 1 to 4 row where all columns are not null.

Body:
According to your description, you want to get all row where name, department, phone are null. So, you have to apply condition in your sql. Please check this:

string ConString = ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(ConString))
{

    SqlCommand cmd = new SqlCommand("SELECT roll FROM cmt_7th WHERE name IS Null And department IS Null And phone IS Null", con);
    SqlDataAdapter sda = new SqlDataAdapter(cmd);
    DataTable dt = new DataTable("cmt_7th");
    sda.Fill(dt);
    MydataGrid_roll.ItemsSource = dt.DefaultView;

}

Check this output of the SQL:


问:
How to retrieve data in jquery from mvc list type of model
I have a class like below:

```<code>public class CustomBenefitCommittee
{
    public bool? IsChecked { get; set; }
    public bool PropertyError { get; set; }
}
</code>```

And I am using this class as a list type in MVC model like:

```<code>@model List<CustomBenefitCommittee>
</code>```

I want to retrieve data from this model in jQuery. I am trying right now as

```<code>@{
    var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
    var json = serializer.Serialize(Model);
}

var model = @Html.Raw(json);
if(model != null && @Html.Raw(json) != "undefined")
{
    $.each(model, function () {
        alert(model.PropertyError );
    });
}
</code>```

This is giving me undefind. Can someone help me out getting the values from this model.

答:
Make an method in you controller that returns model list (in json format) like:

```<code>public JsonResult LoadList()
{
   var modelList=new List<CustomBenefitCommittee>();
   modelList=   //get your list of model
   var jsonResult = Json(modelList, JsonRequestBehavior.AllowGet);
   return jsonResult;
}
</code>```

Now on View call this method throught jquery like:

```<code><script>
 $(document).ready(function() {
 $.getJSON('/"Controller Name"/"Action Name as "LoadList', function (data) {

 if (data.length == 0) {
 alert('No data');
 }
 else{
 $(data).each(function() {
 alert(this.PropertyError);
 });
 }

 });

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

Body:
I have a class like below:

public class CustomBenefitCommittee
{
    public bool? IsChecked { get; set; }
    public bool PropertyError { get; set; }
}

And I am using this class as a list type in MVC model like:

@model List<CustomBenefitCommittee>

I want to retrieve data from this model in jQuery. I am trying right now as

@{
    var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
    var json = serializer.Serialize(Model);
}

var model = @Html.Raw(json);
if(model != null && @Html.Raw(json) != "undefined")
{
    $.each(model, function () {
        alert(model.PropertyError );
    });
}

This is giving me undefind. Can someone help me out getting the values from this model.

Body:
Make an method in you controller that returns model list (in json format) like:

public JsonResult LoadList()
{
   var modelList=new List<CustomBenefitCommittee>();
   modelList=   //get your list of model
   var jsonResult = Json(modelList, JsonRequestBehavior.AllowGet);
   return jsonResult;
}

Now on View call this method throught jquery like:

<script>
 $(document).ready(function() {
 $.getJSON('/"Controller Name"/"Action Name as "LoadList', function (data) {

 if (data.length == 0) {
 alert('No data');
 }
 else{
 $(data).each(function() {
 alert(this.PropertyError);
 });
 }

 });

});
</script>


问:
JavaNNS can't find dll
I have problem with installing javanns. I get java.lang.Exception:

The system couldn't find the library SNNS_jkr JavaNNS couldn't start

I tried to do everything, what I have found in Google. Maybe somebody faced with same problem, and can help me?

答: I have solved my problem downgrading java version to 1.3 on my PC.</p>

Title: JavaNNS can't find dll


问:
cannot resolve method 'getFont(?)'
As the documentation states:

Android O lets you bundle fonts as resources by adding the font file
  in the res/font/ folder.

As a result:

You can retrieve fonts by using the getFont(int) method, where you
  need to pass the resource identifier of the font that you want to
  retrieve. This method returns a Typeface object. This encodes the
  first of the weight or style variants of your font, if it is a font
  family. You can then use the Typeface.create(typeface, style) method
  to retrieve specific styles.

Note: The TextView already does this for you.

Typeface typeface = getResources().getFont(R.font.myfont);
  textView.setTypeface(typeface);

Unfortunately when I am using the above code I get the following error:

```<code>cannot resolve method 'getFont(?)'
</code>```

Previously I used to do the following:

```<code>Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/myfont.ttf");
</code>```

But now when I try to create the fonts folder inside assets folder, it automatically jumps inside res folder.

I am using android studio 2.3. Thanks in advance for any help.

答:
Try something like this </p>

```<code>Typeface yourFont = Typeface.createFromAsset(getAssets(), "fonts/yourFont.ttf");
</code>```

Title: cannot resolve method 'getFont(?)'

Body:
As the documentation states:

Android O lets you bundle fonts as resources by adding the font file
  in the res/font/ folder.

As a result:

You can retrieve fonts by using the getFont(int) method, where you
  need to pass the resource identifier of the font that you want to
  retrieve. This method returns a Typeface object. This encodes the
  first of the weight or style variants of your font, if it is a font
  family. You can then use the Typeface.create(typeface, style) method
  to retrieve specific styles.

Note: The TextView already does this for you.

Typeface typeface = getResources().getFont(R.font.myfont);
  textView.setTypeface(typeface);

Unfortunately when I am using the above code I get the following error:

cannot resolve method 'getFont(?)'

Previously I used to do the following:

Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/myfont.ttf");

But now when I try to create the fonts folder inside assets folder, it automatically jumps inside res folder.

I am using android studio 2.3. Thanks in advance for any help.

Body:
Try something like this

Typeface yourFont = Typeface.createFromAsset(getAssets(), "fonts/yourFont.ttf");


问:
How to resize QPlainTextEdit widget when displayed
I have a QT GUI application, it has a vertical layout all the controls expand to fill the layout. If I add a QTextBox to the layout it has a fixed size (too big), I can change this in the designer or in code (in the MainWindow constructor)

```<code>    m_textEdit->setMaximumHeight(3 * RowHeight);
</code>```

but then it seems it is fixed permanently. I want to make it bigger when it has focus.

I have tried css

```<code>  m_textEdit->setStyleSheet("QPlainTextEdit:focus{max-height: 400px}");
</code>```

I have tried the resize function which is called in an action

```<code>  m_textEdit->resize(m_textEdit->width(), 3 * RowHeight);
</code>```

also doesn't resize once displayed.

I also thought that maybe I could put it in a splitter layout which would then be resizeable, but then the controls didn't expand with the window size.

Any ideas anyone?

答:
The way I did this in the end is to add a QLabel and a QTextEdit to the form, then I right click on form and layout->'break layout' (why, I don't know!), then I select both widgets and add them to a vertical splitter layout (by right clicking form and layout->'vertical splitter'). Then I right click on form and add a vertical layout which then sets the all important layout to the MainWidget and lets the controls scale with the window size (the red warning icon disappears from the mainwidget). To get the vertical proportions I want at startup I have to also add the following code

```<code>MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QList<int> sizes;
    sizes << 1000 <<  1;
    ui->splitter->setStretchFactor(0,1000);
    ui->splitter->setStretchFactor(1,1);
}
</code>```

I also have to set the size policy to expanding on the widgets (not sure this is required)

Body:
I have a QT GUI application, it has a vertical layout all the controls expand to fill the layout. If I add a QTextBox to the layout it has a fixed size (too big), I can change this in the designer or in code (in the MainWindow constructor)

    m_textEdit->setMaximumHeight(3 * RowHeight);

but then it seems it is fixed permanently. I want to make it bigger when it has focus.

I have tried css

  m_textEdit->setStyleSheet("QPlainTextEdit:focus{max-height: 400px}");

I have tried the resize function which is called in an action

  m_textEdit->resize(m_textEdit->width(), 3 * RowHeight);

also doesn't resize once displayed.

I also thought that maybe I could put it in a splitter layout which would then be resizeable, but then the controls didn't expand with the window size.

Any ideas anyone?

Body:
The way I did this in the end is to add a QLabel and a QTextEdit to the form, then I right click on form and layout->'break layout' (why, I don't know!), then I select both widgets and add them to a vertical splitter layout (by right clicking form and layout->'vertical splitter'). Then I right click on form and add a vertical layout which then sets the all important layout to the MainWidget and lets the controls scale with the window size (the red warning icon disappears from the mainwidget). To get the vertical proportions I want at startup I have to also add the following code

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QList<int> sizes;
    sizes << 1000 <<  1;
    ui->splitter->setStretchFactor(0,1000);
    ui->splitter->setStretchFactor(1,1);
}

I also have to set the size policy to expanding on the widgets (not sure this is required)


问:
How to change icon colors in android studio
I downloaded some icons from material.io but they only offer the icons in black.  I saw a youtube video where they use to allow you to choose the color.  Anyway, I am trying to change the colors of the icons to white.  I am not having any luck.  I tried to change the fill color in android studio  but it doesn't work.  Any assistance would be appreciated such as exact code and files to add the code to.  Thanks.</p>

答:
https://material.io/icons/ actually does let you download icons in white.

But, depending on what exactly you want to do, there are a few options. If you simply want white icons (and not to change them at runtime), you may find this plugin for Android Studio useful: https://github.com/konifar/android-material-design-icon-generator-plugin

It allows you to generate the material design icons right in Android Studio, in whatever color you want. Another alternative for downloading these icons in different colors is  https://materialdesignicons.com/.

If you do want to color the icons at runtime, try something like this:

```<code>imageView.setColorFilter(ContextCompat.getColor(context, android.R.color.white),
        PorterDuff.Mode.MULTIPLY);
</code>```

Body:
https://material.io/icons/ actually does let you download icons in white.

But, depending on what exactly you want to do, there are a few options. If you simply want white icons (and not to change them at runtime), you may find this plugin for Android Studio useful: https://github.com/konifar/android-material-design-icon-generator-plugin

It allows you to generate the material design icons right in Android Studio, in whatever color you want. Another alternative for downloading these icons in different colors is  https://materialdesignicons.com/.

If you do want to color the icons at runtime, try something like this:

imageView.setColorFilter(ContextCompat.getColor(context, android.R.color.white),
        PorterDuff.Mode.MULTIPLY);


问:
Combining two arrays
So i have 2 POSTs coming as arrays:

$ post1   Array ( [0] => Tipul1 [1] => tipul2 [2] => tipul3 )

$ post2   Array ( [0] => cant1 [1] => cant2 [2] => cant3 )

What I want to achieve is send these in a db(the query wont be a problem) in this format(the format is a problem and the way I concatenate the values):

```<code>Tipul 1 - cant1 | Tipul 2 - cant2 | Tipul 3 - cant3
</code>```

So , how can I combine those arrays and add the - between each value ?

Using

```<code>foreach ($tip as $tipq) {

    foreach ($cantitate as $cantitateq) {

        echo $tipq.''.$cantitateq. "<br>";

    }
}
</code>```

I would get this(it makes sense):
Tipul1cant1
Tipul1cant2
Tipul1cant3
tipul2cant1
tipul2cant2
tipul2cant3
tipul3cant1
tipul3cant2
tipul3cant3

答:
You have to iterate over the elements to combine them. Take a look at this simple three step example:

```<code><?php
$input = array_combine(
    ['Tipul1', 'Tipul2', 'Tipul3'],
    ['cant1', 'cant2', 'cant3']
);
$output = [];
array_walk($input, function($val, $key) use (&$output) {
    $output[] = $key . ' - ' . $val;
});
var_dump(implode(' | ', $output));
</code>```

The output obviously is:

string(48) "Tipul1 - cant1 | Tipul2 - cant2 | Tipul3 - cant3"

Title: Combining two arrays

Body:
So i have 2 POSTs coming as arrays:

$ post1   Array ( [0] => Tipul1 [1] => tipul2 [2] => tipul3 )

$ post2   Array ( [0] => cant1 [1] => cant2 [2] => cant3 )

What I want to achieve is send these in a db(the query wont be a problem) in this format(the format is a problem and the way I concatenate the values):

Tipul 1 - cant1 | Tipul 2 - cant2 | Tipul 3 - cant3

So , how can I combine those arrays and add the - between each value ?

Using

foreach ($tip as $tipq) {

    foreach ($cantitate as $cantitateq) {

        echo $tipq.''.$cantitateq. "
";

    }
}

I would get this(it makes sense):
Tipul1cant1
Tipul1cant2
Tipul1cant3
tipul2cant1
tipul2cant2
tipul2cant3
tipul3cant1
tipul3cant2
tipul3cant3

Body:
You have to iterate over the elements to combine them. Take a look at this simple three step example:

<?php
$input = array_combine(
    ['Tipul1', 'Tipul2', 'Tipul3'],
    ['cant1', 'cant2', 'cant3']
);
$output = [];
array_walk($input, function($val, $key) use (&$output) {
    $output[] = $key . ' - ' . $val;
});
var_dump(implode(' | ', $output));

The output obviously is:

string(48) "Tipul1 - cant1 | Tipul2 - cant2 | Tipul3 - cant3"


问:
Kubernetes - How to know which minions are hosting Pods
I have a 6 minion cluster and would like to know how many of these minions are actually hosting pods at any given time. Is there a specific command for that ? Right now Im using a very generic command.

```<code>kubectl get po | grep Running > RUNNING.txt
for i in `cat RUNNING.txt `; do kubectl describe po $i; done | grep "Started container with docker
</code>```

"

Any direct command to fetch the info I want ?

答:
This command will print all the nodes that have pods running on them:</p>

```<code>kubectl get pods -o jsonpath='{range .items[*]}{.spec.nodeName} {end}' | tr " " "\n" | sort | uniq
</code>```

Body:
I have a 6 minion cluster and would like to know how many of these minions are actually hosting pods at any given time. Is there a specific command for that ? Right now Im using a very generic command.

kubectl get po | grep Running > RUNNING.txt
for i in `cat RUNNING.txt `; do kubectl describe po $i; done | grep "Started container with docker

"

Any direct command to fetch the info I want ?

Body:
This command will print all the nodes that have pods running on them:

kubectl get pods -o jsonpath='{range .items[*]}{.spec.nodeName} {end}' | tr " " "\n" | sort | uniq


问:
Eclipse gluon new project does not finish
I use Eclipse 4.7 (Oxygen), portable version

Android Development Tools (no version ?), with SDK Manager => SDK Tools 25.5, Android 6 and 7 (API 23, 25), Android Support Repository, SDK Platform, SDK Platform-tools

Gluon plugin 2.4.0

E(fx)clipse 2.4.0

Gradle IdePack 3.8.x +1.0.x

SceneBuilder installed and configured in Eclipse

and (MarketPlace, Enide 2015)

new Gluon project begins well:

name and location (default)

Gluon Application Settings (default)

Name of view (default)
=> button finish appears active, but when pressing it, nothing happens. This window blocks here and no message. Only back button, close and cancel work.

I'v tried any combination of projects (Desktop, Mobile, single view, multiple, Fxml), and checkbox, but it doesnt change anything.

Have anyone encounter the same problem ?

Or is there any log to search for anywhere ?

thanks

答:
Firstly, sorry for my english.

I was having the same problem as the guillaume girod-vitouchkina. I could not create a new Gluon project. I was using Eclipse Neon.2 and update for Eclipse Neon.3 and the problem persisted. So I did what uBreckner recommended and it worked! I uinstall version 2.x of Buildships Gradle and install latest 1.x version.

Thanks guys,

Regards!


问:
Creating self-executable node.js server
I would like to create an executable bash file that will execute the command
node app.js - the goal is to have an executable file that can be opened on a local machine on which node is already installed and the executable is inside the project directory (It's an express.js app).

I'm trying to do it on a mac, I've written a .command file, made it executable and added the command.
Problem is, the process immediately closes, as the terminal seems to automatically add exit; after the last command.
I would like to do it on Windows machines also.

I don't need the entire app in an executable file, only the option to double click a file instead of opening the terminal and manually writing that simple command.

Any idea how to achieve this?

答: You gotta save node server.js as a .bat file , but you need to add pause to the last line. This will prevent the command prompt from exiting.

Title: Creating self-executable node.js server


问:
How to delete current buffer and reopen the next buffer in current window?
I would like to know is there any shortcuts or commands to switch buffer (delete current and reopen next buffer) in current window because sometimes I feel I opened too many buffers? And currently I use bufexplorer and fuzzyfinder.</p>

答:
Try this:</p>

```<code>function DelBufferAndNext()
    let s:old_bufnr = bufnr('%')
    bnext
    exec s:old_bufnr . 'bd'
    unlet s:old_bufnr
endfunction
command -nargs=0 BD call DelBufferAndNext()
</code>```

Body:
Try this:

function DelBufferAndNext()
    let s:old_bufnr = bufnr('%')
    bnext
    exec s:old_bufnr . 'bd'
    unlet s:old_bufnr
endfunction
command -nargs=0 BD call DelBufferAndNext()


问:
Form onsubmit="" with confirm window not working
On my site, it should be possible to delete specific data from the database, but you can only delete the data you created. If you look at some data, my php code checks, if the account your logged in with is the "creator-account" of the data. If yes, it will show you a button to delete the data.

```<code>if ($_SESSION['userID'] == $creatorID) {
  echo
    '<form onsubmit="return confirm("Do you really want to delete this entry?");" class="c-inline" action="delete.php" method="post">
      <input name="query" type="hidden" value ="'. $id .'"/>
      <button id="btnDelete" type="submit" class="btn btn-danger" name="button" title="Eintrag löschen">
        <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Löschen
      </button>
    </form>';
}
</code>```

The Problem is, when you press the button, it should ask you if you really want to delete the data, but it doesn't. The message doesn't show up and I instantly get redirected to delete.php.

Any ideas why my onsubmit="" gets ignored?

答:
Your issue is that you're using the quotes a bit wrong. Using double-quotes for the onsubmit attribute, and the function inside, that breaks the quotes. So your onsubmit only sees return confirm( (because after that comes a quote of the same kind which you opened that attribute with). Replace the inner doublequotes with singlequotes; but they have to be escaped (because you echo this string).

```<code><?php
if ($_SESSION['userID'] == $creatorID) {
  echo
    '<form onsubmit="return confirm(\'Do you really want to delete this entry?\');" class="c-inline" action="delete.php" method="post">
      <input name="query" type="hidden" value ="'. $id .'"/>
      <button id="btnDelete" type="submit" class="btn btn-danger" name="button" title="Eintrag löschen">
        <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Löschen
      </button>
    </form>';
}
</code>```

A more readable alternative would be to exit PHP mode, and output it as pure HTML. This way you can use singlequotes without having to escape them.

```<code><?php
if ($_SESSION['userID'] == $creatorID) {
  ?>
  <form onsubmit="return confirm('Do you really want to delete this entry?');" class="c-inline" action="delete.php" method="post">
      <input name="query" type="hidden" value ="<?= $id ?>"/>
      <button id="btnDelete" type="submit" class="btn btn-danger" name="button" title="Eintrag löschen">
        <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Löschen
      </button>
    </form>
    <?php
}
</code>```

Body:
On my site, it should be possible to delete specific data from the database, but you can only delete the data you created. If you look at some data, my php code checks, if the account your logged in with is the "creator-account" of the data. If yes, it will show you a button to delete the data.

if ($_SESSION['userID'] == $creatorID) {
  echo
    '<form onsubmit="return confirm("Do you really want to delete this entry?");" class="c-inline" action="delete.php" method="post">
      <input name="query" type="hidden" value ="'. $id .'"/>
      <button id="btnDelete" type="submit" class="btn btn-danger" name="button" title="Eintrag löschen">
         Löschen
      </button>
    </form>';
}

The Problem is, when you press the button, it should ask you if you really want to delete the data, but it doesn't. The message doesn't show up and I instantly get redirected to delete.php.

Any ideas why my onsubmit="" gets ignored?

Body:
Your issue is that you're using the quotes a bit wrong. Using double-quotes for the onsubmit attribute, and the function inside, that breaks the quotes. So your onsubmit only sees return confirm( (because after that comes a quote of the same kind which you opened that attribute with). Replace the inner doublequotes with singlequotes; but they have to be escaped (because you echo this string).

<?php
if ($_SESSION['userID'] == $creatorID) {
  echo
    '<form onsubmit="return confirm(\'Do you really want to delete this entry?\');" class="c-inline" action="delete.php" method="post">
      <input name="query" type="hidden" value ="'. $id .'"/>
      <button id="btnDelete" type="submit" class="btn btn-danger" name="button" title="Eintrag löschen">
        <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Löschen
      </button>
    </form>';
}

A more readable alternative would be to exit PHP mode, and output it as pure HTML. This way you can use singlequotes without having to escape them.

<?php
if ($_SESSION['userID'] == $creatorID) {
  ?>
  <form onsubmit="return confirm('Do you really want to delete this entry?');" class="c-inline" action="delete.php" method="post">
      <input name="query" type="hidden" value ="<?= $id ?>"/>
      <button id="btnDelete" type="submit" class="btn btn-danger" name="button" title="Eintrag löschen">
        <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Löschen
      </button>
    </form>
    <?php
}


问:
sending files via POST with AngularJS
I have a problem sending data via POST in angular,
my data include 2 files and some text field,
the problem is that the service doesn't receives any data.

this is my code:

```<code>var inputs = document.querySelectorAll( 'input[type="file"]' );

Array.prototype.forEach.call( inputs, function( input ){
    input.addEventListener( 'change', function( e ){
    if(this.id == "zipToUpload")
            $scope.zipToUpload = this.files[0];
        else
            $scope.imgToUpload = this.files[1];
    });
});

$scope.submit = function(){
    var getInput = {nome: $scope.app_name, zipToUpload: $scope.zipToUpload, imgToUpload: $scope.imgToUpload, url: $scope.app_url,
        secure: $scope.checkbox_pass, hide: $scope.checkbox_hide, beta: $scope.checkbox_beta, password: $scope.app_pass, location: "1" };

    var req = {
        method: 'POST',
        url: 'api/rest/app/insert_app.php',
        headers: {
            'Content-Type': undefined
        },
        data: getInput
    }

    $http(req)
    .then(function(result) {
            console.log(result);
    });
}
</code>```

答:
You can not directly upload file using model in angular. First you need a directive to bind files to the model.

```<code>   myApp.directive('fileModel', ['$parse', function ($parse) {
        return {
           restrict: 'A',
           link: function(scope, element, attrs) {
              var model = $parse(attrs.fileModel);
              var modelSetter = model.assign;

              element.bind('change', function(){
                 scope.$apply(function(){
                    modelSetter(scope, element[0].files[0]);
                 });
              });
           }
        };
     }]);
</code>```

And the input will be like :

```<code> <input type = "file" file-model = "myFile"/>
</code>```

And the you can send post request using form data

```<code>$scope.upload = funtion(){
  var fd = new FormData();
  fd.append('file', $scope.myFile);
  var req = {
    method: 'POST',
    url: 'api/rest/app/insert_app.php',
    headers: {
        'Content-Type': undefined
    },
    data: fd
   }

$http(req)
.then(function(result) {
        console.log(result);
});
}
</code>```

Title: sending files via POST with AngularJS

Body:
I have a problem sending data via POST in angular,
my data include 2 files and some text field,
the problem is that the service doesn't receives any data.

this is my code:

var inputs = document.querySelectorAll( 'input[type="file"]' );

Array.prototype.forEach.call( inputs, function( input ){
    input.addEventListener( 'change', function( e ){
    if(this.id == "zipToUpload")
            $scope.zipToUpload = this.files[0];
        else
            $scope.imgToUpload = this.files[1];
    });
});

$scope.submit = function(){
    var getInput = {nome: $scope.app_name, zipToUpload: $scope.zipToUpload, imgToUpload: $scope.imgToUpload, url: $scope.app_url,
        secure: $scope.checkbox_pass, hide: $scope.checkbox_hide, beta: $scope.checkbox_beta, password: $scope.app_pass, location: "1" };

    var req = {
        method: 'POST',
        url: 'api/rest/app/insert_app.php',
        headers: {
            'Content-Type': undefined
        },
        data: getInput
    }

    $http(req)
    .then(function(result) {
            console.log(result);
    });
}

Body:
You can not directly upload file using model in angular. First you need a directive to bind files to the model.

   myApp.directive('fileModel', ['$parse', function ($parse) {
        return {
           restrict: 'A',
           link: function(scope, element, attrs) {
              var model = $parse(attrs.fileModel);
              var modelSetter = model.assign;

              element.bind('change', function(){
                 scope.$apply(function(){
                    modelSetter(scope, element[0].files[0]);
                 });
              });
           }
        };
     }]);

And the input will be like :

 <input type = "file" file-model = "myFile"/>

And the you can send post request using form data

$scope.upload = funtion(){
  var fd = new FormData();
  fd.append('file', $scope.myFile);
  var req = {
    method: 'POST',
    url: 'api/rest/app/insert_app.php',
    headers: {
        'Content-Type': undefined
    },
    data: fd
   }

$http(req)
.then(function(result) {
        console.log(result);
});
}


问:
how to place validation for phone number in android,"starts with +"?
```<code> Pattern p = Pattern.compile("^\\+(?:[0-9] ?){6,14}[0-9]$");
          //Match the given string with the pattern
          Matcher m = p.matcher(numberstr);
          //check whether match is found
          boolean numberFound = m.matches();
</code>```

答:
1) If you want to validate a text field, so they can enter only phone numbers you need to put in XML

```<code>android:phoneNumber="true"
</code>```

2) Or if you want to validate a phone number make use of the Linkify class, and you can make use of the MatchFilter interface it provides to get the recognized phone numbers in the charsequence.

Body:
1) If you want to validate a text field, so they can enter only phone numbers you need to put in XML

android:phoneNumber="true"

2) Or if you want to validate a phone number make use of the Linkify class, and you can make use of the MatchFilter interface it provides to get the recognized phone numbers in the charsequence.


问:
Call Bundle Activator Before Injecting Entity Manager
I have a persistence bundle (has a Meta-Persistence), it also has an Activator class

when deployed into karaf, the container starts processing the persistence unit &mapping files etc, before calling the start method of the Activator

My question is : is there a way to alter this behavior ? having the container call the method first ?

Edit

The reason I need the activator to be called first:

I have some mapped entities that rely on jackson which itself relies on spring, what happens is, when hibernate is loading the entities, it arrives at a home-made class that blocks while no spring context is injected into it. So the bundle is forever on a starting state

So I though a possible solution would be to make use of the Activator to inject the spring context

Thank you

答:
The container (or more precisely Aries JPA) must start processing the persistence unit before the bundle is started.

The reason is that Aries JPA needs to do load time weaving in some cases. This kind of weaving must be done before classes to be weaved are loaded the first time by any bundle. So the only safe time to do this is directly after the bundle is resolved.


问:
Can JpaRepository take entity description from *.hbm.xml files?
I write application using hibernate, spring-boot-data-jpa and spring-boot-data-rest.

My entity classes are not contain any annotations, and all orm mapping placed in several hbm.xml files.

```<code>class MyEntity {
    Long id;
    String name;
}

interface MyRepository extends JpaRepository<MyEntity, Long> {
}
</code>```

Hibernate working fine, as well as all methods of JpaRepository like findOne. The problem that the rest interface provided by JpaRepository say

```<code>"PersistentEntity does not have an identifier property!".
</code>```

I found that adding @Id to MyEntity class solves the problem. However, I prefer define orm mapping in hbm.xml file, not using annotations.

How can I configure JpaRepository's to consider *.hbm.xml files?

答: I faced similar problem with JpaRepository using hbm files. JpaRepository  can accept hbm files if these are present in resource folder. In resources folder, create any folder say resources/hbm and move all hbm file to this folder. Now hbm files will be found by JpaRepository  and not an managed type error will be fixed.</p>

Body:
I write application using hibernate, spring-boot-data-jpa and spring-boot-data-rest.

My entity classes are not contain any annotations, and all orm mapping placed in several hbm.xml files.

class MyEntity {
    Long id;
    String name;
}

interface MyRepository extends JpaRepository<MyEntity, Long> {
}

Hibernate working fine, as well as all methods of JpaRepository like findOne. The problem that the rest interface provided by JpaRepository say

"PersistentEntity does not have an identifier property!".

I found that adding @Id to MyEntity class solves the problem. However, I prefer define orm mapping in hbm.xml file, not using annotations.

How can I configure JpaRepository's to consider *.hbm.xml files?


问:
Piwik: plugin's scripts load before widget
I am developing a new plugin. When I create jQuery events to bind them with html elements I get an error, it is because the script loads before my widget gets rendered. How can I solve this problem?

I already made a setInterval and stopped it when some element of my widget gets rendered, and all the functionality works great; the problem is that when I click again (on my widget's menu option), the widget reloads but the script stops working.

There must be a piwik way to solve this, but I can't find the solution.

Please, help.

Thank you very much.

答:
I'm not familiar with Piwik but you can use jQuery to check when elements and sub-elements have loaded.

Have a look at the jQuery load event.

An example given there:

```<code>$( ".widget" ).load(function() {
    // The widget is loaded so handler for .load() called.
});
</code>```

Body:
I'm not familiar with Piwik but you can use jQuery to check when elements and sub-elements have loaded.

Have a look at the jQuery load event.

An example given there:

$( ".widget" ).load(function() {
    // The widget is loaded so handler for .load() called.
});


问:
in SSMS, is there any way to preview table contents without writing a query?
Browsing table contents in SQL Server Management Studio (SSMS) doesn't seem as easy as it should be. In contrast to other client software I have used, I can't find a way to simply click on a table and view its top rows (i.e. preview it).

The closest is to right click and "SELECT Top 1000 Rows" but not only is that two clicks, more importantly it opens a new query tab. If I'm browsing a lot of tables, I end up needing to juggle a lot of unnecessary tabs.

Is there a better way?

答: Currently in SQL Server Management Studio there is no functionality like this built in. You are correct that the only way to view the data content is right click on the table name in Object Explorer and SELECT TOP 1000 ROWS. There are some 3rd party tools that might have a PREVIEW functionality but this is not in SSMS.


问:
Convert string[] to Int[] without losing leading zeros
Input:

```<code>string param = "1100,1110,0110,0001";
</code>```

Output:

```<code>int[] matrix = new[]
    {
              1,1,0,0,
              1,1,1,0,
              0,1,1,0,
              0,0,0,1
    };
</code>```

What I did?

First of all I splited string to string[].

```<code>string[] resultantArray = param.Split(',');
</code>```

Created one method, where I passed my string[].

```<code>var intArray = toIntArray(resultantArray);

static private int[] toIntArray(string[] strArray)
{
    int[] intArray = new int[strArray.Length];
    for (int i = 0; i < strArray.Length; i++)
    {
        intArray[i] = int.Parse(strArray[i]);
    }

    return intArray;
}
</code>```

Issue?

I tried many solutions of SO, but none of them helped me.

Ended up with array without leading zeroes.

答:
```<code>string[] s=param.split(',');
Char[] c;
foreach(string i in s){
 c+=i.ToCharArray()
}
int[] myintarray;
int j=0;
foreach(char i in c){
myintarray[j]=(int)i;
j++
}
</code>```

Body:
Input:

string param = "1100,1110,0110,0001";

Output:

int[] matrix = new[]
    {
              1,1,0,0,
              1,1,1,0,
              0,1,1,0,
              0,0,0,1
    };

What I did?

First of all I splited string to string[].

string[] resultantArray = param.Split(',');

Created one method, where I passed my string[].

var intArray = toIntArray(resultantArray);

static private int[] toIntArray(string[] strArray)
{
    int[] intArray = new int[strArray.Length];
    for (int i = 0; i < strArray.Length; i++)
    {
        intArray[i] = int.Parse(strArray[i]);
    }

    return intArray;
}

Issue?

I tried many solutions of SO, but none of them helped me.

Ended up with array without leading zeroes.


答:
You could also remove the commas and convert the result character-wise as follows using Linq.</p>

```<code>string param = "1100,1110,0110,0001";
int[] result = param.Replace(",", "").Select(c => (int)Char.GetNumericValue(c)).ToArray();
</code>```

Title: Convert string[] to Int[] without losing leading zeros

Body:
You could also remove the commas and convert the result character-wise as follows using Linq.

string param = "1100,1110,0110,0001";
int[] result = param.Replace(",", "").Select(c => (int)Char.GetNumericValue(c)).ToArray();


问:
Why print an object name is name of prototype.constructor rather than the name of constructor in nodejs?
```<code>function Foo () {
    console.log('Foo');
}

Foo.prototype.constructor = function Boo () {
    console.log('Boo');
}

console.log(new Foo());
</code>```

result in nodejs@v7.3.0

```<code>Foo
Boo {}
</code>```

result in chrome@57.0.2987.110

```<code>Foo
Foo {}
</code>```

I think the chrome look more reasonable, Because of its reaction is the name of the constructor. Which one is right?

答:
Why print an object name is name of prototype.constructor rather than the name of constructor in nodejs?

Because the nodejs console is implemented in the JS environment, and can only query val.constructor.name. In contrast, Chrome devtools are a debugger, and its console can access internal details of the instance.

Which one is right?

Both and neither. There is no standard console output format. Each implementation tries to be as useful as possible.

Body:
function Foo () {
    console.log('Foo');
}

Foo.prototype.constructor = function Boo () {
    console.log('Boo');
}

console.log(new Foo());

result in nodejs@v7.3.0

Foo
Boo {}

result in chrome@57.0.2987.110

Foo
Foo {}

I think the chrome look more reasonable, Because of its reaction is the name of the constructor. Which one is right?


问:
Bash split large file of 2 line chunks into smaller files
The file has millions of lines, arranged in 2 line blocks, where 1st line in each block is a header, marked with a > , followed by two lines of letter characters.

In linux and/or bash, how to split the file into smaller ones, preserving the 2block structure? Ideally, with some flexibility over how many are output, based on number of output files or the number of blocks per smaller file?

short example:

```<code>>k99_12
CCTTCTTCAATGCCAATACCCTCGAAGAATTGCACCGCCTCGAACAAACCACATGACACACCCACCGTCACTGGCTGACATTGCCGCACAACTTGAAGCCTATGACCCGCAGGCACTACCTGCCAATGAGGTCTTGAATTTTCTGGATCACTTGGTGACGCCAGTGCACGACTCAGAATCAGTCGACATCTTTGCAGCATTGGGCAGAGTCACTGCGCAA
>k99_27
ATCCAAGCCAGAGAATATGCCTACCCGCATCGCACCGCGATCTCGCAAATGTCGTGTAATCGCGCGGGTATCAACACCCTGAATGCCAATGATTCCTTGCTCAATCAATTCCGCCTCAAGATCATTTTGTGCGCGCCAATTTGATGTCAAAGAGGATGGGTTTCTAACAACAAACCCTGCCACCCAAATCTTTGATGACTCATTATCTAA
>k99_31
CCATTGCGCAAACGGACTGCCGGACACCAAGTGCACCTCGTGCGACAGACCATACTGGTCGTCATAAGAGAGTTCAGGGTTTTCGCGGTGGTCGGCCATGCCGTCCACATTGTGCACCTGCTGGTGCAGCGAACCGCCCATGGCCACATTGATTTCCTGGAAGCCACGGCAAATCCCCAGCAGGGGCACACCCTGCGCGACGCAGGCGCGTACCAAGGGCAAGGTCAGGCTGTCGCGGTGCGGATCCAGCGGCAGACGCGGA
>k99_35
AAAATTGAGTTTGAAGGAATTTCGCATTTCATCAAAAATCAACACGACGAGAGTGGTTCAACAACTATAAAACGTTGGGCAAAGGAATTTATGGACGAAATAAATTGTCCTGTTTGCGAAGGTTCACGATTAAAAAAAGAAGCTTTATTTTTCAAAATTAATGGAAAAAACATCACTGAATTATGCAATATGGATATTTCGGATGTCACGGCTTGGTTTTTGGAATTGAACACCCATTTATCAGATAAACAAAAGACTATAGCGACGGAGGTTATCAAGGAAATAAAAGATCGATTGGCCTTTTTAATGAATGTAGGTTTGGATTATTT
>k99_40
GAGGCCGGCGAAGGCGCGGTGATCGACGAGGAGGACGACGACGCTGGCGCGGGCGAGCGCGTCGGCGAGGGAAACGAGTTCCGCCCTGCCCTGCAGCGCTTTCGGCAAGGCGGTCACGTGCGGCTCGACGGCCAGGACCTTCAGGCCGGCGTCGGCGAGGTGCGCGGCGATCTCGACGGCGGGAGATTCACGGAGGTCGTCGACGTTCGCCTTGAAGGCGAGGCCGAGGCAGGCGACGGCGGCGCCAGAA
>k99_42
AGACCAAATCGCACGGCTAGCAGGATCAAAACGCAAGATGCGCGGGTCTCTTACTTCATCGCGCAGAGTAGGGCGCATCAGCGCGACTTTTTCGCGCACGTCATCGGCGCCTTTGCGGCCGTCTATGTTGAGGTCAAACTCAACCACCACCACCGACACGCCTTCATAACTGCGAGATGTGAGGGCATTGATACCGGCAATGGAATTGACTGCTTCTTCCACTTTTTTAGTCACCTCGCTCTCGACAATTTCAGGAGAGGCGCCTGGATATTCGGTGCTCACGACAACGACGGGCAAATCAATATTAGGAAACTGGTCGATCTTGAGGCGCTGATAAGAGAACAAGCCCAGCACCACAAAGGCAAGCATCACCATCGTTGCGAAGACGGGGTTTTTGAGGCTGACTTTGGTGA
>k99_75
AAAGGTAGCATTGAAGATTATACGCAGTTGTTTCAGGCAGCAGCACAAATTGCGAATGAATCGGCACATATGCAACTCGATATAGATGTCGAGGGATTCAACGAATTTGCTACGGCGGCGGACGACCTCAGTAAGTTATTCACTGGTTTCATTTTGAAGTTGGAGAATGTGAGTATCATCGACGATACTGTATTTTTGACTGCGGTGGCAAATGCTCTCTCGAAGATAAGCAATTTGTCGAAAGTGTTTGGTAAGTTCAAAGAAACTATATTGGGCACTTCGACAATTCGTTTGCCCAAATCCGCACATGATGCATCGGTTATACTGAAAGATGTGGTTGGGCAAATCAATTGTGCAATGACGTATATAAACCATTTTGTCGATTCGAGTGTTCCCGCACCAAGTGTTGCGGAATTATCGAAAGAAGAGAAGAATATAATCGACGCTGCGGTGACAACCATTCACAATTGGAATACATTGTGTGACCAAGGAGTTAGTATTGCCATGTCAAGCGACCCAGATATTCAATTTGTTAGTAATGCGAATCAATCGCT
>k99_76
TCGTAAGCTAACTAAATCAACTGAACAATCTATCACCAATAGTATGTAATCAGAAATCAACTTAAATCTCATATATTAATGAAAGTTTTATCAATTGTTGGAACAAGGCCGGAAATAATTAAGTTATCAAGAGTGTTTCATGAACTTGAAAAATATACTGAACACATTTTAGTACATACAGGTCAAAACTTTGATTATGAACTAAATGAAATATTTTTCAATGATCTTAAAATTAAGAAACCTGATTTTTTTTTAAATGTTGTTGGCGAATCTTTAGCTGATACTATTGCAAACATAATTTCCAAATCCGATAAAGTTCTAGAAAAAATAAAACCA
>k99_79
GATGTACTGGTACTCGTTGTAGGTCGTCGTCTTGCTACCTCTGCTGCTGTCGTTCGTGGCCTCGTTGCGGTGGTCGTAGTTGTTGTGGTCGCTCTCGCAGGCCCGCCGCTCAGAGCTTGGAACGAGTTCTTGGAGACGAAGTCTCCCAGCGTTGCGCCGCGAGGCGTCGGGCGAGGTCGAGCTGCGACCTTCGCCTGGACAAAGCCGTCCTGGACCAGAGAGATGTCCATCCGCTGCGGCGGCCCCTCTTCGACGCTCCTGACGGCGCCTGTCGTTGGCCTCTGCGGGCAGGCTCGGGAGGAGTGACCGGTCTTTTTGCAGATCCAGCACTTCCGGAGCTCCCGTGCGACCTCAGGCAGGGGGCACTTGATGGCGGCGTGCGACTCGCC
>k99_83
CCCGAACACAATCGCTTTAGTCGAGCGGGAAACGCGGTGGGATTATGCGGACCCAGCCTTTACGAACGGGATCGCGGAAGACTTCTCCATCGACCAGTCTACTCACTCGCTCTTCGGCGCCTCGAAGGTTGCCGCCGACGTTTTGGTGCAGGAATACGGCCGCTATTTTGGAATGCCTACTTGCGTGCTGCGCGGCGGCTGCCTCACCGGCCCGAATCACAGCGGCGTCCAG
>k99_90
GGCTGACGTACAAGATGCGCCGTCCGTGGTCACGCGGCACGCTGGGCGTGGTGTTCAACGCGTTGTATGCCGTCATGTTCCTGTTCACGATCACGGTGATCGCGTCGATTCTCCACTCGTTCGAGTTCAACGGGCTATCCATCTTCTTCTTCCTGTTCTTCCTGTCGCTCGTGACCTTCTTCGGCCTGAAGATTCGCAATACGCGCCGCGAGCTGATGGTGGTAGAGGCGCGCGTCGGCATCGTCGGCACGATCGCGGACATCCTGTTTCTCCCCATGATACGCGCCGGCCGCTGGGTCGCGCTCCGGGCGCCGCGGGCCATCGCCACGCGGCCGGTCCGGACCATTTCCATGATCCCGTACGGCCGAAGCACCTCGAGCAGACCGTCAATCTTGTCTTCCGTACCGGTGATCTCGATGATCAGCGAATCCACCGCCACGTCGATCACCCGCGCGCGGAACACCTCGGCGAGCTGCATGACGTGCGGCCTGGATTCCGCCGACGCGGCAAC
>k99_100
AAAATACAGGTCTTTCAATGATGAAAGAAATGGATGATGCAAAAAATCTCGTTGGAATTGATTATACGAAGCATTTTGCTGATTTGGTAGAGAAAGCAGATCCTTTTGGTTCTAAAGCAGCGTTTATGCCAATGAAAGTAATTACTGCTTTGGCTTTGTTTGGTGAAAACGGCTCAACGAAAGCATTGGAAAGCTCATTAAAAAGAGGTGGAAGTGAAGAAAATTTAAACGATCTTTATTTAAACAGAGTAGGTGAGTACAAATGGAATGGTAAAACCTGGATTAAAAATAAAGAAGTTAAAGATAAAATTATTTTACGCTTTCCATCTTCTAATGCTAAAACTGTAAATAACGCTTCTTATGAAATTTCATTTGTGAACTATGCTGGAGCAGGTTTGCCTGATGA
>k99_104
GGTTCCATACATGTAACGCCAGGAATAGTGGACAACATTTGGTGCATCAGTGCGCCACGACGAGCAAATGCCTCACGCATCATGTGCACCGCTGATAAATCACCACTGACTGCAGCAAGTGCTGCAACCTGTGACACGTTGGCAACGTTTGACGTGGCATGCGATTGGAAGTTTGTTGAAGCCTTCATGATGTCTTTCGGTCCA
>k99_108
CCGCAGCATCTGACCGAGATCGAAGGGGCGGCCGTAGGGGCGCCGGCTGCTGTGCTGGCGCGCTGGACGGCGGCGGGCATGGCGCCGGCAGTCGTCATCGGCGACGGCGCGTTGGCCTTCGAGTCCCTCCTCGCCGGAGAGGCCCGCGTGTGTGGCGCGCAGCCGCTCGCCGGGACAATCGGACGAATCGCGGCGATCCGCGCGGATCGGGGAGAAGCGGTGGAGCCACACGCCGTGCGCGCGCTGTACGTCCGGCGTTCTGACGCGGAGGTCGAGAGGGACCGTGCCCGCTGATTCGAATGGTGCGGCGCCCCTCGCGCTGACGGTCGATCTCTTGTCGTCACTCGACGAACTGGACGAGGTGATGGCGGTCGA
>k99_112
ATGTCGAGCGCCAGCATTAGCGGGCGGGCGGACAAGGATGTTGATGCGCGCTCAATCGCTTTGGTGAAAACCGGTGACGAAGAAGCCAGCGCTGGCCGCGTCGATAGCGCAATTGGCTGGTATGAAACTGCGCTCGCGGTCGACCCGCGCAACCGTGCCGCTTATGTCGCCATGGCGCGCGCCGTAAAATCCCAGGGGTTG
>k99_115
GCAGTGGATGCCATACCAGAAAAAGTCGGGATGGTGCGGCTCGAATTCGGCGGGCCCGATGGAGTAGACGGAGGTGATGTCACCGATCTTGGCGAACTTTGAGGCGAAGGTTTCAGGTGGATACCTAAGGGACGAAGAACTGAAGAGTGGGATTTTGTGTTCGCGGGCGAGGCGGACGATTTCGACGGCGTCTGTAAGAGAGCCGGCGAGGGGCTTGTCGATGAAGACGGGTTTTTTCGCGGCGAGGGTCTGGCGGAATTGTTCGAGGTGGGGGCGGCCGTCGACGCTTTCGATCAGA
>k99_117
CGTCTCTGAGCTTTTCAGCTTCCATCAACTTGGCTTTTCCTATGGCCGCACTGTCGGAAACAATCGCAATCGGCCCTAACCTGGCTCCCAAGCAAGCCATGTGCATCGCCACGTGCTCAGCGGCCCCGGACGAGATTCGATATCCCACCGGAATGGCGACCGCCATGGATCTGACACAAACCTTCCCGTCCTTTCGCCATACCGTCCGTCGCTTCGTACGTCGTCTGGTGTGGCGTCGCTGTCCTCCGTGGTGCTGTAGACGTTCTCGATGGGGTCGTCGCCCTGGAAGTACTGGAGGTGGCTGTAGTCGCGCGGGAC
>k99_121
ATGAGTACAACAGTCAGTCATAACTGCGTAAGGGGCACCTGTAAATCTAGCCAATGCATGTTCAAATTCTAGTATTTTCTCAAACATTTTCGCTCAAGTGATCTTGTTTAATTTCTCGCACTGGGCAATTTAGTAATTCTGCTATAGTATTTTTAACTGCTATTCTTTTATTATTCCAATTTCTTATTAGTATAGCACGTCGTCCAATTTCTTCCAAACTTAATTCTTCTTCGCAACCACTTTTTAATTCAGCTTCTAATGTCCAGATAGTATCATGTATTCTTTTGAGCTCATCAAAACACGTTTTAACAAGAGATAAATCGAATTGTGAAGTTTGATCTTGATACCAATTAAGTTCCTCTTGATTGCTGTGTGTCCGATCCCACTTAACTTCGGCTATGGCTAATCTATCAAATAGTTCAATTACTGGAAAGTGGTAACTCATAGATATAGTCCTTCAATTTTTTCTGGA
>k99_135
AAAAGACTGTTGGCTTCTCCCAAAAAATTTACTTAAAAAATAATATTCAGACAACAATTCTTGAAAGTGCTATGCTTTGAAAGTTGTGTTTTTTTTAATTATGGCCAAAGAAAAAACAATACACACAAAAAAAGTTTGAAACATGGCCGATTTTCGTTTTAACGTGAAAGCTGATACCACAGATTAGATATAGAATAGATAGAGGCTTCCTAAATATCAGTAGTTCCCGGTCAAAGGGGCAGGATCAAGAGGGTTGCGGGGTTTCCTCTCTTCACATTGTACATTGTACACCTTGGTTGTAATAATAGAATATGTAACACCTTGT
</code>```

答:
for splitting the file into 2 line blocks the tool to use is split

```<code>split -l 2 -d file file_
</code>```

the original file will generate file_xx sections each 2 lines long.  This will do all at once.  You can change 2 to your desired line count.

Body:
The file has millions of lines, arranged in 2 line blocks, where 1st line in each block is a header, marked with a > , followed by two lines of letter characters.

In linux and/or bash, how to split the file into smaller ones, preserving the 2block structure? Ideally, with some flexibility over how many are output, based on number of output files or the number of blocks per smaller file?

short example:

>k99_12
CCTTCTTCAATGCCAATACCCTCGAAGAATTGCACCGCCTCGAACAAACCACATGACACACCCACCGTCACTGGCTGACATTGCCGCACAACTTGAAGCCTATGACCCGCAGGCACTACCTGCCAATGAGGTCTTGAATTTTCTGGATCACTTGGTGACGCCAGTGCACGACTCAGAATCAGTCGACATCTTTGCAGCATTGGGCAGAGTCACTGCGCAA
>k99_27
ATCCAAGCCAGAGAATATGCCTACCCGCATCGCACCGCGATCTCGCAAATGTCGTGTAATCGCGCGGGTATCAACACCCTGAATGCCAATGATTCCTTGCTCAATCAATTCCGCCTCAAGATCATTTTGTGCGCGCCAATTTGATGTCAAAGAGGATGGGTTTCTAACAACAAACCCTGCCACCCAAATCTTTGATGACTCATTATCTAA
>k99_31
CCATTGCGCAAACGGACTGCCGGACACCAAGTGCACCTCGTGCGACAGACCATACTGGTCGTCATAAGAGAGTTCAGGGTTTTCGCGGTGGTCGGCCATGCCGTCCACATTGTGCACCTGCTGGTGCAGCGAACCGCCCATGGCCACATTGATTTCCTGGAAGCCACGGCAAATCCCCAGCAGGGGCACACCCTGCGCGACGCAGGCGCGTACCAAGGGCAAGGTCAGGCTGTCGCGGTGCGGATCCAGCGGCAGACGCGGA
>k99_35
AAAATTGAGTTTGAAGGAATTTCGCATTTCATCAAAAATCAACACGACGAGAGTGGTTCAACAACTATAAAACGTTGGGCAAAGGAATTTATGGACGAAATAAATTGTCCTGTTTGCGAAGGTTCACGATTAAAAAAAGAAGCTTTATTTTTCAAAATTAATGGAAAAAACATCACTGAATTATGCAATATGGATATTTCGGATGTCACGGCTTGGTTTTTGGAATTGAACACCCATTTATCAGATAAACAAAAGACTATAGCGACGGAGGTTATCAAGGAAATAAAAGATCGATTGGCCTTTTTAATGAATGTAGGTTTGGATTATTT
>k99_40
GAGGCCGGCGAAGGCGCGGTGATCGACGAGGAGGACGACGACGCTGGCGCGGGCGAGCGCGTCGGCGAGGGAAACGAGTTCCGCCCTGCCCTGCAGCGCTTTCGGCAAGGCGGTCACGTGCGGCTCGACGGCCAGGACCTTCAGGCCGGCGTCGGCGAGGTGCGCGGCGATCTCGACGGCGGGAGATTCACGGAGGTCGTCGACGTTCGCCTTGAAGGCGAGGCCGAGGCAGGCGACGGCGGCGCCAGAA
>k99_42
AGACCAAATCGCACGGCTAGCAGGATCAAAACGCAAGATGCGCGGGTCTCTTACTTCATCGCGCAGAGTAGGGCGCATCAGCGCGACTTTTTCGCGCACGTCATCGGCGCCTTTGCGGCCGTCTATGTTGAGGTCAAACTCAACCACCACCACCGACACGCCTTCATAACTGCGAGATGTGAGGGCATTGATACCGGCAATGGAATTGACTGCTTCTTCCACTTTTTTAGTCACCTCGCTCTCGACAATTTCAGGAGAGGCGCCTGGATATTCGGTGCTCACGACAACGACGGGCAAATCAATATTAGGAAACTGGTCGATCTTGAGGCGCTGATAAGAGAACAAGCCCAGCACCACAAAGGCAAGCATCACCATCGTTGCGAAGACGGGGTTTTTGAGGCTGACTTTGGTGA
>k99_75
AAAGGTAGCATTGAAGATTATACGCAGTTGTTTCAGGCAGCAGCACAAATTGCGAATGAATCGGCACATATGCAACTCGATATAGATGTCGAGGGATTCAACGAATTTGCTACGGCGGCGGACGACCTCAGTAAGTTATTCACTGGTTTCATTTTGAAGTTGGAGAATGTGAGTATCATCGACGATACTGTATTTTTGACTGCGGTGGCAAATGCTCTCTCGAAGATAAGCAATTTGTCGAAAGTGTTTGGTAAGTTCAAAGAAACTATATTGGGCACTTCGACAATTCGTTTGCCCAAATCCGCACATGATGCATCGGTTATACTGAAAGATGTGGTTGGGCAAATCAATTGTGCAATGACGTATATAAACCATTTTGTCGATTCGAGTGTTCCCGCACCAAGTGTTGCGGAATTATCGAAAGAAGAGAAGAATATAATCGACGCTGCGGTGACAACCATTCACAATTGGAATACATTGTGTGACCAAGGAGTTAGTATTGCCATGTCAAGCGACCCAGATATTCAATTTGTTAGTAATGCGAATCAATCGCT
>k99_76
TCGTAAGCTAACTAAATCAACTGAACAATCTATCACCAATAGTATGTAATCAGAAATCAACTTAAATCTCATATATTAATGAAAGTTTTATCAATTGTTGGAACAAGGCCGGAAATAATTAAGTTATCAAGAGTGTTTCATGAACTTGAAAAATATACTGAACACATTTTAGTACATACAGGTCAAAACTTTGATTATGAACTAAATGAAATATTTTTCAATGATCTTAAAATTAAGAAACCTGATTTTTTTTTAAATGTTGTTGGCGAATCTTTAGCTGATACTATTGCAAACATAATTTCCAAATCCGATAAAGTTCTAGAAAAAATAAAACCA
>k99_79
GATGTACTGGTACTCGTTGTAGGTCGTCGTCTTGCTACCTCTGCTGCTGTCGTTCGTGGCCTCGTTGCGGTGGTCGTAGTTGTTGTGGTCGCTCTCGCAGGCCCGCCGCTCAGAGCTTGGAACGAGTTCTTGGAGACGAAGTCTCCCAGCGTTGCGCCGCGAGGCGTCGGGCGAGGTCGAGCTGCGACCTTCGCCTGGACAAAGCCGTCCTGGACCAGAGAGATGTCCATCCGCTGCGGCGGCCCCTCTTCGACGCTCCTGACGGCGCCTGTCGTTGGCCTCTGCGGGCAGGCTCGGGAGGAGTGACCGGTCTTTTTGCAGATCCAGCACTTCCGGAGCTCCCGTGCGACCTCAGGCAGGGGGCACTTGATGGCGGCGTGCGACTCGCC
>k99_83
CCCGAACACAATCGCTTTAGTCGAGCGGGAAACGCGGTGGGATTATGCGGACCCAGCCTTTACGAACGGGATCGCGGAAGACTTCTCCATCGACCAGTCTACTCACTCGCTCTTCGGCGCCTCGAAGGTTGCCGCCGACGTTTTGGTGCAGGAATACGGCCGCTATTTTGGAATGCCTACTTGCGTGCTGCGCGGCGGCTGCCTCACCGGCCCGAATCACAGCGGCGTCCAG
>k99_90
GGCTGACGTACAAGATGCGCCGTCCGTGGTCACGCGGCACGCTGGGCGTGGTGTTCAACGCGTTGTATGCCGTCATGTTCCTGTTCACGATCACGGTGATCGCGTCGATTCTCCACTCGTTCGAGTTCAACGGGCTATCCATCTTCTTCTTCCTGTTCTTCCTGTCGCTCGTGACCTTCTTCGGCCTGAAGATTCGCAATACGCGCCGCGAGCTGATGGTGGTAGAGGCGCGCGTCGGCATCGTCGGCACGATCGCGGACATCCTGTTTCTCCCCATGATACGCGCCGGCCGCTGGGTCGCGCTCCGGGCGCCGCGGGCCATCGCCACGCGGCCGGTCCGGACCATTTCCATGATCCCGTACGGCCGAAGCACCTCGAGCAGACCGTCAATCTTGTCTTCCGTACCGGTGATCTCGATGATCAGCGAATCCACCGCCACGTCGATCACCCGCGCGCGGAACACCTCGGCGAGCTGCATGACGTGCGGCCTGGATTCCGCCGACGCGGCAAC
>k99_100
AAAATACAGGTCTTTCAATGATGAAAGAAATGGATGATGCAAAAAATCTCGTTGGAATTGATTATACGAAGCATTTTGCTGATTTGGTAGAGAAAGCAGATCCTTTTGGTTCTAAAGCAGCGTTTATGCCAATGAAAGTAATTACTGCTTTGGCTTTGTTTGGTGAAAACGGCTCAACGAAAGCATTGGAAAGCTCATTAAAAAGAGGTGGAAGTGAAGAAAATTTAAACGATCTTTATTTAAACAGAGTAGGTGAGTACAAATGGAATGGTAAAACCTGGATTAAAAATAAAGAAGTTAAAGATAAAATTATTTTACGCTTTCCATCTTCTAATGCTAAAACTGTAAATAACGCTTCTTATGAAATTTCATTTGTGAACTATGCTGGAGCAGGTTTGCCTGATGA
>k99_104
GGTTCCATACATGTAACGCCAGGAATAGTGGACAACATTTGGTGCATCAGTGCGCCACGACGAGCAAATGCCTCACGCATCATGTGCACCGCTGATAAATCACCACTGACTGCAGCAAGTGCTGCAACCTGTGACACGTTGGCAACGTTTGACGTGGCATGCGATTGGAAGTTTGTTGAAGCCTTCATGATGTCTTTCGGTCCA
>k99_108
CCGCAGCATCTGACCGAGATCGAAGGGGCGGCCGTAGGGGCGCCGGCTGCTGTGCTGGCGCGCTGGACGGCGGCGGGCATGGCGCCGGCAGTCGTCATCGGCGACGGCGCGTTGGCCTTCGAGTCCCTCCTCGCCGGAGAGGCCCGCGTGTGTGGCGCGCAGCCGCTCGCCGGGACAATCGGACGAATCGCGGCGATCCGCGCGGATCGGGGAGAAGCGGTGGAGCCACACGCCGTGCGCGCGCTGTACGTCCGGCGTTCTGACGCGGAGGTCGAGAGGGACCGTGCCCGCTGATTCGAATGGTGCGGCGCCCCTCGCGCTGACGGTCGATCTCTTGTCGTCACTCGACGAACTGGACGAGGTGATGGCGGTCGA
>k99_112
ATGTCGAGCGCCAGCATTAGCGGGCGGGCGGACAAGGATGTTGATGCGCGCTCAATCGCTTTGGTGAAAACCGGTGACGAAGAAGCCAGCGCTGGCCGCGTCGATAGCGCAATTGGCTGGTATGAAACTGCGCTCGCGGTCGACCCGCGCAACCGTGCCGCTTATGTCGCCATGGCGCGCGCCGTAAAATCCCAGGGGTTG
>k99_115
GCAGTGGATGCCATACCAGAAAAAGTCGGGATGGTGCGGCTCGAATTCGGCGGGCCCGATGGAGTAGACGGAGGTGATGTCACCGATCTTGGCGAACTTTGAGGCGAAGGTTTCAGGTGGATACCTAAGGGACGAAGAACTGAAGAGTGGGATTTTGTGTTCGCGGGCGAGGCGGACGATTTCGACGGCGTCTGTAAGAGAGCCGGCGAGGGGCTTGTCGATGAAGACGGGTTTTTTCGCGGCGAGGGTCTGGCGGAATTGTTCGAGGTGGGGGCGGCCGTCGACGCTTTCGATCAGA
>k99_117
CGTCTCTGAGCTTTTCAGCTTCCATCAACTTGGCTTTTCCTATGGCCGCACTGTCGGAAACAATCGCAATCGGCCCTAACCTGGCTCCCAAGCAAGCCATGTGCATCGCCACGTGCTCAGCGGCCCCGGACGAGATTCGATATCCCACCGGAATGGCGACCGCCATGGATCTGACACAAACCTTCCCGTCCTTTCGCCATACCGTCCGTCGCTTCGTACGTCGTCTGGTGTGGCGTCGCTGTCCTCCGTGGTGCTGTAGACGTTCTCGATGGGGTCGTCGCCCTGGAAGTACTGGAGGTGGCTGTAGTCGCGCGGGAC
>k99_121
ATGAGTACAACAGTCAGTCATAACTGCGTAAGGGGCACCTGTAAATCTAGCCAATGCATGTTCAAATTCTAGTATTTTCTCAAACATTTTCGCTCAAGTGATCTTGTTTAATTTCTCGCACTGGGCAATTTAGTAATTCTGCTATAGTATTTTTAACTGCTATTCTTTTATTATTCCAATTTCTTATTAGTATAGCACGTCGTCCAATTTCTTCCAAACTTAATTCTTCTTCGCAACCACTTTTTAATTCAGCTTCTAATGTCCAGATAGTATCATGTATTCTTTTGAGCTCATCAAAACACGTTTTAACAAGAGATAAATCGAATTGTGAAGTTTGATCTTGATACCAATTAAGTTCCTCTTGATTGCTGTGTGTCCGATCCCACTTAACTTCGGCTATGGCTAATCTATCAAATAGTTCAATTACTGGAAAGTGGTAACTCATAGATATAGTCCTTCAATTTTTTCTGGA
>k99_135
AAAAGACTGTTGGCTTCTCCCAAAAAATTTACTTAAAAAATAATATTCAGACAACAATTCTTGAAAGTGCTATGCTTTGAAAGTTGTGTTTTTTTTAATTATGGCCAAAGAAAAAACAATACACACAAAAAAAGTTTGAAACATGGCCGATTTTCGTTTTAACGTGAAAGCTGATACCACAGATTAGATATAGAATAGATAGAGGCTTCCTAAATATCAGTAGTTCCCGGTCAAAGGGGCAGGATCAAGAGGGTTGCGGGGTTTCCTCTCTTCACATTGTACATTGTACACCTTGGTTGTAATAATAGAATATGTAACACCTTGT

Body:
for splitting the file into 2 line blocks the tool to use is split

split -l 2 -d file file_

the original file will generate file_xx sections each 2 lines long.  This will do all at once.  You can change 2 to your desired line count.


问:
Google Oauth in webview deprecated
I am currently developing a mobile application using the ionic framework.  We recently decided to begin integrating social logins into the application.  Soon after adding google oauth, a notification indicating a deprecation of oauth requested through webviews in 2016/17 began appearing.  After researching the error I found the following article.  From my understanding cordova is run entirely using web views.

Does this mean authentication via oauth in an Ionic / Cordova app will now be impossible for both Android and iOS?  I have been researching for an entire day trying to find a work around ( Getting a call back from the system browser to my ionic application ) to no avail.

Does anyone have any experience or similar concerns who could share their experience with this news?

Thanks all

答:
Looks like the ionic team has pulled down this article: http://blog.ionic.io/google-oauth-changes/
Hopefully it will be back up soon.

For now, refer to this plugin, which I am almost positive was the recommendation:
https://github.com/EddyVerbruggen/cordova-plugin-googleplus

Title: Google Oauth in webview deprecated


问:
How to start `mockjax` back after `stop`
In my application I have a shuffle button to start and stop the mockjax response. as a first time, I am initiating the mockjax it works. later the user click on off button to stop mockjax service. ( I am showing server data )

for stop I use:

```<code>stopSimulation : function( ) {

            if( !this.retriveSimulationStatus() ) {
                console.log("i switched off!!");
                $.mockjax.clear(); //removes the simulation;
            }

        }
</code>```

But user clicks back to start button, But mockjax not intercepting again to provide the data.

so what is the correct way to stop and start the mockjax service? any one help me?

答:
Clearing the Mockjax handlers does NOT "stop" them, it erases them from Mockjax. There is no "start"/"stop" functionality. You will need to clear the handlers, then re-add the handlers when you want to start. Here's an example:</p>

```<code>var handler = { url: '/foo', responseText: { foo: 'bar' } };

function start() {
  $.mockjax(handler);
}

function stop() {
  $.mockjax.clear();
}
</code>```

Body:
In my application I have a shuffle button to start and stop the mockjax response. as a first time, I am initiating the mockjax it works. later the user click on off button to stop mockjax service. ( I am showing server data )

for stop I use:

stopSimulation : function( ) {

            if( !this.retriveSimulationStatus() ) {
                console.log("i switched off!!");
                $.mockjax.clear(); //removes the simulation;
            }

        }

But user clicks back to start button, But mockjax not intercepting again to provide the data.

so what is the correct way to stop and start the mockjax service? any one help me?

Body:
Clearing the Mockjax handlers does NOT "stop" them, it erases them from Mockjax. There is no "start"/"stop" functionality. You will need to clear the handlers, then re-add the handlers when you want to start. Here's an example:

var handler = { url: '/foo', responseText: { foo: 'bar' } };

function start() {
  $.mockjax(handler);
}

function stop() {
  $.mockjax.clear();
}