问:
Offering both asynchronous and synchronous API with a target callback queue
I am writing a networking API. Since the underlying call to NSURLSession is always asynchronous, I offer an asynchronous API by default:

```<code>- (void) callBackendServerWithCompletion: (dispatch_block_t) completion;
</code>```

It’s also very convenient to offer a synchronous version of this API, for example to simplify testing the code in Xcode playgrounds. The synchronous call is written in terms of the asynchronous one:

```<code>- (void) callBackendSynchronously
{
    dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
    [self callBackendServerWithCompletion:^{
        dispatch_semaphore_signal(semaphore);
    }];
    dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
}
</code>```

This works fine.

Now I would like to add an extra convenience feature, a default dispatch queue to call the completion blocks on. This callback queue defaults to the UI queue, so that the consumer of this API doesn’t have to dispatch_async(dispatch_get_main_queue(), ^{…}) all the time:

```<code>// This:
[webservice callBackendServerWithCompletion:^{
    dispatch_async(dispatch_get_main_queue(), ^{
        [self updateUI];
    });
}];

// Would be replaced with this:
[webservice callBackendServerWithCompletion:^{
    // Guaranteed to run on the main queue
    [self updateUI];
}];
</code>```

This was fairly easy to do, but now I have a deadlock when calling the synchronous method on the main queue:

-callBackendSynchronously calls -callBackendServerWithCompletion and waits on the semaphore.

The asynchonous method processes the network request and dispatches the callback on the main queue.

Since the main queue is already waiting for the semaphore, the code deadlocks.

What’s a simple way to offer all three features, ie. both synchronous & asynchronous API methods and a default callback queue?

答:
A simple workaround was to add the callback queue not as a property, but as an argument for the async call:

```<code>/// Guaranteed to call the completion on the main queue
- (void) callBackendServerWithCompletion: (dispatch_block_t) completion;
/// Pick your own callback queue
- (void) callBackendServerWithTargetQueue: (dispatch_queue_t) callbackQueue completion: (dispatch_block_t) completion;
</code>```

Then the synchronous method may specify a global queue for the callback, breaking the deadlock because the semaphore is signalled from another thread:

```<code>- (void) callBackendSynchronously
{
    dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
    [self callBackendServerWithCallbackQueue:dispatch_get_global_queue(0, 0) completion:^{
        dispatch_semaphore_signal(semaphore);
    }];
    dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
}
</code>```

I’m not yet sure if there are some drawbacks.

Body:
I am writing a networking API. Since the underlying call to NSURLSession is always asynchronous, I offer an asynchronous API by default:

- (void) callBackendServerWithCompletion: (dispatch_block_t) completion;

It’s also very convenient to offer a synchronous version of this API, for example to simplify testing the code in Xcode playgrounds. The synchronous call is written in terms of the asynchronous one:

- (void) callBackendSynchronously
{
    dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
    [self callBackendServerWithCompletion:^{
        dispatch_semaphore_signal(semaphore);
    }];
    dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
}

This works fine.

Now I would like to add an extra convenience feature, a default dispatch queue to call the completion blocks on. This callback queue defaults to the UI queue, so that the consumer of this API doesn’t have to dispatch_async(dispatch_get_main_queue(), ^{…}) all the time:

// This:
[webservice callBackendServerWithCompletion:^{
    dispatch_async(dispatch_get_main_queue(), ^{
        [self updateUI];
    });
}];

// Would be replaced with this:
[webservice callBackendServerWithCompletion:^{
    // Guaranteed to run on the main queue
    [self updateUI];
}];

This was fairly easy to do, but now I have a deadlock when calling the synchronous method on the main queue:

-callBackendSynchronously calls -callBackendServerWithCompletion and waits on the semaphore.

The asynchonous method processes the network request and dispatches the callback on the main queue.

Since the main queue is already waiting for the semaphore, the code deadlocks.

What’s a simple way to offer all three features, ie. both synchronous & asynchronous API methods and a default callback queue?

Body:
A simple workaround was to add the callback queue not as a property, but as an argument for the async call:

/// Guaranteed to call the completion on the main queue
- (void) callBackendServerWithCompletion: (dispatch_block_t) completion;
/// Pick your own callback queue
- (void) callBackendServerWithTargetQueue: (dispatch_queue_t) callbackQueue completion: (dispatch_block_t) completion;

Then the synchronous method may specify a global queue for the callback, breaking the deadlock because the semaphore is signalled from another thread:

- (void) callBackendSynchronously
{
    dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
    [self callBackendServerWithCallbackQueue:dispatch_get_global_queue(0, 0) completion:^{
        dispatch_semaphore_signal(semaphore);
    }];
    dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
}

I’m not yet sure if there are some drawbacks.


来源: stackexchange

问:
How to scroll a specific area within "tbody"

I'm going to scroll left and right across the orange shaded area.

I have no idea how to apply this technology.

I want to avoid plug-ins as much as possible.

If you know how, please help me.

答:
The key to achieve this structure is use overflow scroll on parent element.
I have done it on codepen, you can find the link below.

http://codepen.io/cryptcslaughtr/pen/JWxqMy

HTML:

```<code><div class="container">
  <div class="header">
  HEADER HEADER HEADER HEADER HEADER HEADER HEADER HEADER
  </div>
  <div class="sidebar">
    <p>This</p>
    <p>Is</p>
    <p>Sidebar</p>
    <p>Block</p>
  </div>
  <div class="tcontainer">
    <table>
      <tbody>
        <tr>
          <td>1</td>
          <td>2</td>
          <td>3</td>
          <td>4</td>
          <td>5</td>
          <td>6</td>
          <td>7</td>
          <td>8</td>
          <td>9</td>
          <td>10</td>
        </tr>
        <tr>
          <td>1</td>
          <td>2</td>
          <td>3</td>
          <td>4</td>
          <td>5</td>
          <td>6</td>
          <td>7</td>
          <td>8</td>
          <td>9</td>
          <td>10</td>
        </tr>
        <tr>
          <td>1</td>
          <td>2</td>
          <td>3</td>
          <td>4</td>
          <td>5</td>
          <td>6</td>
          <td>7</td>
          <td>8</td>
          <td>9</td>
          <td>10</td>
        </tr>
        <tr>
          <td>1</td>
          <td>2</td>
          <td>3</td>
          <td>4</td>
          <td>5</td>
          <td>6</td>
          <td>7</td>
          <td>8</td>
          <td>9</td>
          <td>10</td>
        </tr>
        <tr>
          <td>1</td>
          <td>2</td>
          <td>3</td>
          <td>4</td>
          <td>5</td>
          <td>6</td>
          <td>7</td>
          <td>8</td>
          <td>9</td>
          <td>10</td>
        </tr>
      </tbody>
    </table>
  </div>
</div>  <td>10</td>
    </tr>
    <tr>
      <td>1</td>
      <td>2</td>
      <td>3</td>
      <td>4</td>
      <td>5</td>
      <td>6</td>
      <td>7</td>
      <td>8</td>
      <td>9</td>
      <td>10</td>
    </tr>
    <tr>
      <td>1</td>
      <td>2</td>
      <td>3</td>
      <td>4</td>
      <td>5</td>
      <td>6</td>
      <td>7</td>
      <td>8</td>
      <td>9</td>
      <td>10</td>
    </tr>
  </tbody>
</table>
</code>```

CSS

```<code>.header{
  padding:10px;
  background: #eee;
}
.sidebar{
  background: #ddd;
  float: left;
  width: 30%;
  min-width: 100px;
}
.container{
  width: 500px;
}
.tcontainer{
  width: 70%;
  overflow: auto;
}
td{
  background: grey;
  text-align: center;
  width: 50px;
  padding: 5px 20px;
}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
The key to achieve this structure is use overflow scroll on parent element.
I have done it on codepen, you can find the link below.

http://codepen.io/cryptcslaughtr/pen/JWxqMy

HTML:

<div class="container">
  <div class="header">
  HEADER HEADER HEADER HEADER HEADER HEADER HEADER HEADER
  </div>
  <div class="sidebar">
    <p>This</p>
    <p>Is</p>
    <p>Sidebar</p>
    <p>Block</p>
  </div>
  <div class="tcontainer">
    <table>
      <tbody>
        <tr>
          <td>1</td>
          <td>2</td>
          <td>3</td>
          <td>4</td>
          <td>5</td>
          <td>6</td>
          <td>7</td>
          <td>8</td>
          <td>9</td>
          <td>10</td>
        </tr>
        <tr>
          <td>1</td>
          <td>2</td>
          <td>3</td>
          <td>4</td>
          <td>5</td>
          <td>6</td>
          <td>7</td>
          <td>8</td>
          <td>9</td>
          <td>10</td>
        </tr>
        <tr>
          <td>1</td>
          <td>2</td>
          <td>3</td>
          <td>4</td>
          <td>5</td>
          <td>6</td>
          <td>7</td>
          <td>8</td>
          <td>9</td>
          <td>10</td>
        </tr>
        <tr>
          <td>1</td>
          <td>2</td>
          <td>3</td>
          <td>4</td>
          <td>5</td>
          <td>6</td>
          <td>7</td>
          <td>8</td>
          <td>9</td>
          <td>10</td>
        </tr>
        <tr>
          <td>1</td>
          <td>2</td>
          <td>3</td>
          <td>4</td>
          <td>5</td>
          <td>6</td>
          <td>7</td>
          <td>8</td>
          <td>9</td>
          <td>10</td>
        </tr>
      </tbody>
    </table>
  </div>
</div>  <td>10</td>
    </tr>
    <tr>
      <td>1</td>
      <td>2</td>
      <td>3</td>
      <td>4</td>
      <td>5</td>
      <td>6</td>
      <td>7</td>
      <td>8</td>
      <td>9</td>
      <td>10</td>
    </tr>
    <tr>
      <td>1</td>
      <td>2</td>
      <td>3</td>
      <td>4</td>
      <td>5</td>
      <td>6</td>
      <td>7</td>
      <td>8</td>
      <td>9</td>
      <td>10</td>
    </tr>
  </tbody>
</table>

CSS

.header{
  padding:10px;
  background: #eee;
}
.sidebar{
  background: #ddd;
  float: left;
  width: 30%;
  min-width: 100px;
}
.container{
  width: 500px;
}
.tcontainer{
  width: 70%;
  overflow: auto;
}
td{
  background: grey;
  text-align: center;
  width: 50px;
  padding: 5px 20px;
}


问:
Internet explorer passes undefined to success callback when fetching 30MB of data or more
I have a problem with fetching JSON data from server in Internet explorer. I am using standard jquery ajax call to the server to retrieve binary data representing file, which is then opened in FlowPaper's PDF viewer. Everything is OK for files of sizes up to 20MB. When I try to get data for files with size 30MB and up, the call comes back as successfull, but data sent to success callback is undefined. This behavior happens in Internet explorer only, but in Chrome or Opera everything works for all file sizes.

JS code is straightforward and simple

```<code>var id = "documentID";
var url = 'API/GetDocumentURL';
var data = JSON.stringify({
    "DocumentID": id
});
var type = 'POST';
var async = true;
var success = function (data) {
    debugger; // in IE data is undefined, other browsers have results stored in this variable
};
$.ajax({
    url: url,
    type: type,
    async: async,
    data: data,
    success: success
});
</code>```

Jquery version is 1-8-2, but I have a feeling that this is more a problem of Internet explorer, and not Jquery. Internet explorer version is 11.

Does anyone have any idea why Internet explorer is firing success callback, but not passing in the data retrieved with AJAX call?

答:
Returning the MIMEType of application/json; charset=utf8 caused this same behavior for me in IE8. Changing it to application/json; made IE8 magically start functioning. Check what your server is returning for a MIMEType and see if fiddling with that is causing an issue.

Edit: Actually what was causing the real problem is that it should be charset=utf-8 and not as shown above without the hyphen.

For more infor jquery Ajax response "undefined" with Internet Explorer

Body:
I have a problem with fetching JSON data from server in Internet explorer. I am using standard jquery ajax call to the server to retrieve binary data representing file, which is then opened in FlowPaper's PDF viewer. Everything is OK for files of sizes up to 20MB. When I try to get data for files with size 30MB and up, the call comes back as successfull, but data sent to success callback is undefined. This behavior happens in Internet explorer only, but in Chrome or Opera everything works for all file sizes.

JS code is straightforward and simple

var id = "documentID";
var url = 'API/GetDocumentURL';
var data = JSON.stringify({
    "DocumentID": id
});
var type = 'POST';
var async = true;
var success = function (data) {
    debugger; // in IE data is undefined, other browsers have results stored in this variable
};
$.ajax({
    url: url,
    type: type,
    async: async,
    data: data,
    success: success
});

Jquery version is 1-8-2, but I have a feeling that this is more a problem of Internet explorer, and not Jquery. Internet explorer version is 11.

Does anyone have any idea why Internet explorer is firing success callback, but not passing in the data retrieved with AJAX call?


问:
How to set dynamic route in codeigniter from database?
In my routes.php file I have added the following code for routing:

```<code>$route['report/:num'] = "home/reportcard/$1";
</code>```

Here is my controller code:

```<code><?php
    defined('BASEPATH') OR exit('No direct script access allowed');

    class Home extends CI_Controller
    {

        function __construct() {
            parent::__construct();

        if(empty($this->session->userdata('id_user'))){
            $this->session->set_flashdata('flash_data', 'You cannot access');
                    redirect('login');
        }
        }
        public function index(){
            $this->load->model("item_model");
            $data['records'] = $this->item_model->getAllItems();
            $this->load->view('home',$data);
        }

       function reportcard($id){
            $this->load->model("item_model");
            $data['report'] = $this->item_model->getReport($id);
            $this->load->view('report', $data);
        }

        function logout(){
            $data=['id_user','username'];
            $this->session->unset_userdata($data);
            redirect('login');

        }
    }
</code>```

Here is my model code:

```<code><?php
    class Item_model extends CI_Model
    {
        function getAllItems()
        {
            $this->load->database();
            $q = $this->db->get("item");
            if($q->num_rows() > 0)
            {
                return $q->result();
            }
            return array();
        }

        public function getReport($id){
            $this->db->select('*');
            $this->db->from('item');
            $this->db->where('item.id', $id);
            $query = $this->db->get();
            if($query->num_rows() > 0)
                return $data->result();
        }

}
?>
</code>```

this is the code of view. I just print the array in my report_view for testing purpose:

```<code><?php
defined('BASEPATH') OR exit('No direct script access allowed');
print_r($report);
?>
</code>```

this is my home_view code:

```<code><div class="row">
                <ul class="home-grid">
                    <?php foreach ($query->result() as $row): ?>
                    <li>
                        <a  href="<?php echo base_url() ?>report/<?=$row->item ?>/<?=$row->id ?>" class="btn btn-lg btn-warning view-report"><span class="glyphicon glyphicon-list-alt"></span> <br/>
                        <?=$row->item ?><br/>
                         <small>Click here for see report</small>
                        </a>
                    </li>
                    <?php endforeach; ?>
                </ul>
</code>```

I have tried multiple times to view the array. But failed to get array. How can I load the view? When I click my items from home, it will create a url like http://localhost/super_shop_register/report/1

But didn't show any data. Show "Object not found!". Here is the image of my view:
After Clicking item, it will show like this:

How can I solve this?

答:
your route should be like this:

```<code>$route['report/(:num)'] = "home/reportcard/$1";
</code>```

and make sure your htaccess file is there and have code:

```<code>RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php?/$0 [PT,L]
</code>```

Body:
In my routes.php file I have added the following code for routing:

$route['report/:num'] = "home/reportcard/$1";

Here is my controller code:

<?php
    defined('BASEPATH') OR exit('No direct script access allowed');

    class Home extends CI_Controller
    {

        function __construct() {
            parent::__construct();

        if(empty($this->session->userdata('id_user'))){
            $this->session->set_flashdata('flash_data', 'You cannot access');
                    redirect('login');
        }
        }
        public function index(){
            $this->load->model("item_model");
            $data['records'] = $this->item_model->getAllItems();
            $this->load->view('home',$data);
        }

       function reportcard($id){
            $this->load->model("item_model");
            $data['report'] = $this->item_model->getReport($id);
            $this->load->view('report', $data);
        }

        function logout(){
            $data=['id_user','username'];
            $this->session->unset_userdata($data);
            redirect('login');

        }
    }

Here is my model code:

<?php
    class Item_model extends CI_Model
    {
        function getAllItems()
        {
            $this->load->database();
            $q = $this->db->get("item");
            if($q->num_rows() > 0)
            {
                return $q->result();
            }
            return array();
        }

        public function getReport($id){
            $this->db->select('*');
            $this->db->from('item');
            $this->db->where('item.id', $id);
            $query = $this->db->get();
            if($query->num_rows() > 0)
                return $data->result();
        }

}
?>

this is the code of view. I just print the array in my report_view for testing purpose:

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
print_r($report);
?>

this is my home_view code:

                    <?php foreach ($query->result() as $row): ?>

                        <a  href="<?php echo base_url() ?>report/<?=$row->item ?>/<?=$row->id ?>" class="btn btn-lg btn-warning view-report">

                        <?=$row->item ?>

                         Click here for see report

                    <?php endforeach; ?>

I have tried multiple times to view the array. But failed to get array. How can I load the view? When I click my items from home, it will create a url like http://localhost/super_shop_register/report/1

But didn't show any data. Show "Object not found!". Here is the image of my view:
After Clicking item, it will show like this:

How can I solve this?

Body:
your route should be like this:

$route['report/(:num)'] = "home/reportcard/$1";

and make sure your htaccess file is there and have code:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php?/$0 [PT,L]


问:
Position fixed - not breaking out of document flow
Im pretty good with my css and i'd like to think i can figure why most things do what they do when it comes to frontend development. But i came across an issue today that I don't fully understand.

Heres the code:

.nav-toggle {
  position: absolute;
  transform: translateY(50%);
}

.nav-open .nav-toggle:after {
  background: rgba(0, 0, 0, 0.5);
  content: '';
  display: block;
  height: 100%;
  position: fixed;
  right: 0;
  top: 0;
  width: 100%;
  z-index: 1;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><span data-action="toggle-nav" class="action nav-toggle">
         <span>Menu</span>
</span></code>```

Here is a fiddle for it:

https://jsfiddle.net/0vm962be/1/

And here is the second fiddle with the transform commented out.

https://jsfiddle.net/0vm962be/2/

So you'll see the difference.

So, what i would expect to happen is the after would be 100% width of the body and 100% height of the body, when the parent element has a .nav-open class.

However because of 1 simple line of code (transform: translateY(50%)), this doesn't happen, what actually happens is the fixed element acts like a absolutely positioned element inside of the .nav-toggle and only goes 100% to its parent.

why would a transform on a parent have an impact of a fixed element? I though position: fixed; broke the document flow no matter what. And only listened to the window width height. I need to learn why this happened.

Any advice would be great. Links to specs etc?

答:
Use vh and vw instead percent:
https://jsfiddle.net/93ybxgau/1/</p>

```<code>.nav-open .nav-toggle:after {
  background: rgba(0, 0, 0, 0.5);
  content: '';
  display: block;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  width: 100vw;
  z-index: 1;
}
</code>```

Body:
Im pretty good with my css and i'd like to think i can figure why most things do what they do when it comes to frontend development. But i came across an issue today that I don't fully understand.

Heres the code:

.nav-toggle {
  position: absolute;
  transform: translateY(50%);
}

.nav-open .nav-toggle:after {
  background: rgba(0, 0, 0, 0.5);
  content: '';
  display: block;
  height: 100%;
  position: fixed;
  right: 0;
  top: 0;
  width: 100%;
  z-index: 1;
}

         Menu

Here is a fiddle for it:

https://jsfiddle.net/0vm962be/1/

And here is the second fiddle with the transform commented out.

https://jsfiddle.net/0vm962be/2/

So you'll see the difference.

So, what i would expect to happen is the after would be 100% width of the body and 100% height of the body, when the parent element has a .nav-open class.

However because of 1 simple line of code (transform: translateY(50%)), this doesn't happen, what actually happens is the fixed element acts like a absolutely positioned element inside of the .nav-toggle and only goes 100% to its parent.

why would a transform on a parent have an impact of a fixed element? I though position: fixed; broke the document flow no matter what. And only listened to the window width height. I need to learn why this happened.

Any advice would be great. Links to specs etc?

Body:
Use vh and vw instead percent:
https://jsfiddle.net/93ybxgau/1/

.nav-open .nav-toggle:after {
  background: rgba(0, 0, 0, 0.5);
  content: '';
  display: block;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  width: 100vw;
  z-index: 1;
}


问:
oracle sql developer update query
I want to insert plane_id in bookhangar table where book column having value 'no'.
my bookhangar table is

```<code>hangar_id |  book | plane_id
-------------------------------
han103    |   no  | null

han104    |   yes |pla102
</code>```

my tried query is

```<code>insert into bookhangar (plane_id) values('pla104') where book='no';
</code>```

but it doesnot inserted.

I tried another query

```<code>update  bookhangar set plane_id='PLA104' where book='no';
</code>```

It also doesnot work.

答:
Your update should be working:

```<code>update bookhangar
    set plane_id = 'PLA104'
    where book = 'no';
</code>```

If it does not, I would start by checking if this query works

```<code>select *
from bookhangar
where book = 'no';
</code>```

I suspect that will return no rows.  So, try this:

```<code>select *
from bookhangar
where book like '%no%';
</code>```

You will need to investigate what value is really being stored . . . perhaps it has hidden characters, such as spaces at the beginning of the string.

Title: oracle sql developer update query

Body:
I want to insert plane_id in bookhangar table where book column having value 'no'.
my bookhangar table is

hangar_id |  book | plane_id
-------------------------------
han103    |   no  | null

han104    |   yes |pla102

my tried query is

insert into bookhangar (plane_id) values('pla104') where book='no';

but it doesnot inserted.

I tried another query

update  bookhangar set plane_id='PLA104' where book='no';

It also doesnot work.

Body:
Your update should be working:

update bookhangar
    set plane_id = 'PLA104'
    where book = 'no';

If it does not, I would start by checking if this query works

select *
from bookhangar
where book = 'no';

I suspect that will return no rows.  So, try this:

select *
from bookhangar
where book like '%no%';

You will need to investigate what value is really being stored . . . perhaps it has hidden characters, such as spaces at the beginning of the string.


问:
command line argument in shell
I have two scripts, one being called in another.

I am trying to run these using command line arguments, but the issue is, arguments are not getting reflected into second script.

Full explanation:

```<code>**Script 1 : run_simulation**
prelayout_${1}_${2}.v.gz
-input dump.sh
**Script 2 : dump.sh**
prelayout__${1}_${2}_tetsbench_ctl.
</code>```

Now when I am executing ./run_simulation edt_intest chain
both arguments are getting reflected in 1st script but not in second i.e it is still reading prelayout__${1}_${2}_tetsbench_ctl as it is.

So, how to export arguments to dump.sh ?

Thanks in advance.

Tool used is irun(ncsim).

Script 1: run_simulate

```<code>`irun \`
`-v lib1 \`
`-v lib2 \`
`./prelayout_${1}_${2}_testbench.v.gz \`  <-- this is testbench
`-input dump.sh \`
`-f file_list \`
`-top prelayout_${1}_${2}_testbench_v_ctl \`  <-- top module of testbench
`+notimingchecks \`
`-log ${1}_${2}.log`   <-- log file
</code>```

Script 2 : dump.sh

```<code>`set tb_top prelayout_${1}_${2}_testbench_v_ctl`
`force $tb_top.q_reg1.Q 1`
`force $tb_top.q_reg2.Q 1`
</code>```

So when I run the command ./run_simulate edt_intest chain, all the variable inside run_simulate gets updated but not in dump.sh or file_list.

  How to achieve that ?

答:
Not completely sure whether I understand what you are trying to do.. but why don't you just do:

Script1:

```<code># Do Something
prelayout_${1}_${2}.v.gz
# Do Something
./Script2.sh "$1" "$2"
</code>```

This will make script 2 execute with the same arguments used to execute script 1.

Or, if you need the output of script 2 to be saved in a variable just do:

```<code># Do Something
prelayout_${1}_${2}.v.gz
# Do Something
INPUT_VAR="$(/bin/bash Script2.sh "$1" "$2")"
</code>```

Or, if you want more flexibility:

```<code># Do Something
prelayout_${1}_${2}.v.gz
# Do Something
ACTIVATE_SCRIPT2="$(/bin/bash Script1.sh)"
OUTPUT_SCRIPT2="$ACTIVATE_SCRIPT2 "$1" "$2""
</code>```

In your case, which however remains unclear to me, I guess you'll need something like:

Script1

```<code># Do Something
prelayout_${1}_${2}.v.gz
# Do Something
INPUT_SCRIPT2_INTO_SIMULATION_PROGRAM="$(/path/to/your/simulation/program -input Script2.sh "$1" "$2")"
</code>```

Then if you do:

./Script1.sh edt_intest chain Script1 will run the following command for you and save the output in a variable:

/path/to/your/simulation/program -input Script2.sh edt_intest chain

Title: command line argument in shell

Body:
I have two scripts, one being called in another.

I am trying to run these using command line arguments, but the issue is, arguments are not getting reflected into second script.

Full explanation:

**Script 1 : run_simulation**
prelayout_${1}_${2}.v.gz
-input dump.sh
**Script 2 : dump.sh**
prelayout__${1}_${2}_tetsbench_ctl.

Now when I am executing ./run_simulation edt_intest chain
both arguments are getting reflected in 1st script but not in second i.e it is still reading prelayout__${1}_${2}_tetsbench_ctl as it is.

So, how to export arguments to dump.sh ?

Thanks in advance.

Tool used is irun(ncsim).

Script 1: run_simulate

`irun \`
`-v lib1 \`
`-v lib2 \`
`./prelayout_${1}_${2}_testbench.v.gz \`  <-- this is testbench
`-input dump.sh \`
`-f file_list \`
`-top prelayout_${1}_${2}_testbench_v_ctl \`  <-- top module of testbench
`+notimingchecks \`
`-log ${1}_${2}.log`   <-- log file

Script 2 : dump.sh

`set tb_top prelayout_${1}_${2}_testbench_v_ctl`
`force $tb_top.q_reg1.Q 1`
`force $tb_top.q_reg2.Q 1`

So when I run the command ./run_simulate edt_intest chain, all the variable inside run_simulate gets updated but not in dump.sh or file_list.

  How to achieve that ?

Body:
Not completely sure whether I understand what you are trying to do.. but why don't you just do:

Script1:

# Do Something
prelayout_${1}_${2}.v.gz
# Do Something
./Script2.sh "$1" "$2"

This will make script 2 execute with the same arguments used to execute script 1.

Or, if you need the output of script 2 to be saved in a variable just do:

# Do Something
prelayout_${1}_${2}.v.gz
# Do Something
INPUT_VAR="$(/bin/bash Script2.sh "$1" "$2")"

Or, if you want more flexibility:

# Do Something
prelayout_${1}_${2}.v.gz
# Do Something
ACTIVATE_SCRIPT2="$(/bin/bash Script1.sh)"
OUTPUT_SCRIPT2="$ACTIVATE_SCRIPT2 "$1" "$2""

In your case, which however remains unclear to me, I guess you'll need something like:

Script1

# Do Something
prelayout_${1}_${2}.v.gz
# Do Something
INPUT_SCRIPT2_INTO_SIMULATION_PROGRAM="$(/path/to/your/simulation/program -input Script2.sh "$1" "$2")"

Then if you do:

./Script1.sh edt_intest chain Script1 will run the following command for you and save the output in a variable:

/path/to/your/simulation/program -input Script2.sh edt_intest chain


问:
Clickable link inside a text control like RichTextControl in WPF?
I want to be able to have some text clickable like in webpages in WPF. The control should have both non-functional text (for display) both also some of its parts as completely clickable.

Say like Wikipedia.

But this is an independent standalone offline app.

I tried various things but I couldn't do it, especially the clicking doesn't function like web pages, i.e. 1 click to open the url contained within the tools.

答:
If you don't have a requirement that it be a full-blown FlowDocument, then you can just use a plain old WPF TextBlock, and put Hyperlinks in it.

```<code><TextBlock>
    Here's some text with a
    <Hyperlink NavigateUri="Page2.xaml">link to another XAML page</Hyperlink>
    and a
    <Hyperlink NavigateUri="http://msdn.microsoft.com/">link to the
    Web</Hyperlink>.
</TextBlock>
</code>```

If you need scrolling, just put a ScrollViewer around it.

If you need the paginated, multi-column viewer, then you'll need to go with an all-out FlowDocument, but if all you want is text with hyperlinks, TextBlock + Hyperlink should be all you need.

ContentLicense: CC BY-SA 2.5

Body:
If you don't have a requirement that it be a full-blown FlowDocument, then you can just use a plain old WPF TextBlock, and put Hyperlinks in it.

<TextBlock>
    Here's some text with a
    <Hyperlink NavigateUri="Page2.xaml">link to another XAML page</Hyperlink>
    and a
    <Hyperlink NavigateUri="http://msdn.microsoft.com/">link to the
    Web</Hyperlink>.
</TextBlock>

If you need scrolling, just put a ScrollViewer around it.

If you need the paginated, multi-column viewer, then you'll need to go with an all-out FlowDocument, but if all you want is text with hyperlinks, TextBlock + Hyperlink should be all you need.


答:
```<code><div>
    <div class="contentTbl">
        <div class="tblContent">
            <div class="headerTblFix">
                <p>Header 1</p>
                <p>Header 2</p>
            </div>
            <div class="contentFixTbl contentTblSec">
                <div class="contentFixTblRow">
                    <p>Content Fix 1</p>
                    <p>Content Fix 1</p>
                </div>
                <div class="contentFixTblRow">
                    <p>Content Fix 2</p>
                    <p>Content Fix 2</p>
                </div>
                <div class="contentFixTblRow">
                    <p>Content Fix 3</p>
                    <p>Content Fix 3</p>
                </div>
                <div class="contentFixTblRow">
                    <p>Content Fix 4</p>
                    <p>Content Fix 4</p>
                </div>
                <div class="contentFixTblRow">
                    <p>Content Fix 5</p>
                    <p>Content Fix 5</p>
                </div>
                <div class="contentFixTblRow">
                    <p>Content Fix 6</p>
                    <p>Content Fix 6</p>
                </div>
                <div class="contentFixTblRow">
                    <p>Content Fix 7</p>
                    <p>Content Fix 7</p>
                </div>
            </div>
        </div>
        <div class="tblContent">
            <div class="headerTblFix">
                <p>Header 3</p>
                <p>Header 4</p>
            </div>
            <div class="contentScrollTbl contentTblSec">
                <div class="contentScrollTblRow">
                    <p>Content Scroll 1</p>
                    <p>Content Scroll 1</p>
                    <p>Content Scroll 1</p>
                    <p>Content Scroll 1</p>
                    <p>Content Scroll 1</p>
                    <p>Content Scroll 1</p>
                </div>
                <div class="contentScrollTblRow">
                    <p>Content Scroll 2</p>
                    <p>Content Scroll 2</p>
                    <p>Content Scroll 2</p>
                    <p>Content Scroll 2</p>
                    <p>Content Scroll 2</p>
                    <p>Content Scroll 2</p>
                </div>
                <div class="contentScrollTblRow">
                    <p>Content Scroll 3</p>
                    <p>Content Scroll 3</p>
                    <p>Content Scroll 3</p>
                    <p>Content Scroll 3</p>
                    <p>Content Scroll 3</p>
                    <p>Content Scroll 3</p>
                </div>
                <div class="contentScrollTblRow">
                    <p>Content Scroll 4</p>
                    <p>Content Scroll 4</p>
                    <p>Content Scroll 4</p>
                    <p>Content Scroll 4</p>
                    <p>Content Scroll 4</p>
                    <p>Content Scroll 4</p>
                </div>
                <div class="contentScrollTblRow">
                    <p>Content Scroll 5</p>
                    <p>Content Scroll 5</p>
                    <p>Content Scroll 5</p>
                    <p>Content Scroll 5</p>
                    <p>Content Scroll 5</p>
                    <p>Content Scroll 5</p>
                </div>
                <div class="contentScrollTblRow">
                    <p>Content Scroll 6</p>
                    <p>Content Scroll 6</p>
                    <p>Content Scroll 6</p>
                    <p>Content Scroll 6</p>
                    <p>Content Scroll 6</p>
                    <p>Content Scroll 6</p>
                </div>
                <div class="contentScrollTblRow">
                    <p>Content Scroll 7</p>
                    <p>Content Scroll 7</p>
                    <p>Content Scroll 7</p>
                    <p>Content Scroll 7</p>
                    <p>Content Scroll 7</p>
                    <p>Content Scroll 7</p>
                </div>
                <div class="contentScrollTblRow">
                    <p>Content Scroll 8</p>
                    <p>Content Scroll 8</p>
                    <p>Content Scroll 8</p>
                    <p>Content Scroll 8</p>
                    <p>Content Scroll 8</p>
                    <p>Content Scroll 8</p>
                </div>
                <div class="contentScrollTblRow">
                    <p>Content Scroll 9</p>
                    <p>Content Scroll 9</p>
                    <p>Content Scroll 9</p>
                    <p>Content Scroll 9</p>
                    <p>Content Scroll 9</p>
                    <p>Content Scroll 9</p>
                </div>
                <div class="contentScrollTblRow">
                    <p>Content Scroll 10</p>
                    <p>Content Scroll 10</p>
                    <p>Content Scroll 10</p>
                    <p>Content Scroll 10</p>
                    <p>Content Scroll 10</p>
                    <p>Content Scroll 10</p>
                </div>
                <div class="contentScrollTblRow">
                    <p>Content Scroll 11</p>
                    <p>Content Scroll 11</p>
                    <p>Content Scroll 11</p>
                    <p>Content Scroll 11</p>
                    <p>Content Scroll 11</p>
                    <p>Content Scroll 11</p>
                </div>
                <div class="contentScrollTblRow">
                    <p>Content Scroll 12</p>
                    <p>Content Scroll 12</p>
                    <p>Content Scroll 12</p>
                    <p>Content Scroll 12</p>
                    <p>Content Scroll 12</p>
                    <p>Content Scroll 12</p>
                </div>
                <div class="contentScrollTblRow">
                    <p>Content Scroll 13</p>
                    <p>Content Scroll 13</p>
                    <p>Content Scroll 13</p>
                    <p>Content Scroll 13</p>
                    <p>Content Scroll 13</p>
                    <p>Content Scroll 13</p>
                </div>
                <div class="contentScrollTblRow">
                    <p>Content Scroll 14</p>
                    <p>Content Scroll 14</p>
                    <p>Content Scroll 14</p>
                    <p>Content Scroll 14</p>
                    <p>Content Scroll 14</p>
                    <p>Content Scroll 14</p>
                </div>
            </div>
    </div>
</div>
<style>
.tblContent{
    display:inline-block;
    width: 304px;
}
.tblContent p{
    border: 1px solid #ccc;
    width: 150px;
    padding: 0px;
    margin: 0px;
    text-align: right;
    display: table-cell;
}
.headerTblFix, .contentFixTbl{
    position:fixed;
}
.headerTblFix{
    height:20px;
}
.contentFixTbl{
    height:150px;
    margin-top: 20px;
}
.contentScrollTbl{
    overflow: auto;
    width: 304px;
    height: 150px;
    position: absolute;
    margin-top: 20px;
}
</style>
</code>```

Title: How to scroll a specific area within "tbody"

Body:
I'm going to scroll left and right across the orange shaded area.

I have no idea how to apply this technology.

I want to avoid plug-ins as much as possible.

If you know how, please help me.


问:
How can I query two tables using php PDO?
I have two tables pre_application and applicants table. I want to query pre_application table for password and applicants table for application pin and if the two table have the records then applicant should be logged in. Below is my code:

```<code>if(isset($_POST['submit']) || $_SERVER['REQUEST_METHOD']=='POST'){

    try{
        $pin=$_POST['pin'];
        $pass=$_POST['password'];
        $stm=$dbh->query("SELECT password FROM pre_application WHERE password='$pass' UNION SELECT app_no FROM applicants WHERE app_no='$pin'");
        foreach($stm as $row);
        $appass=$row['password'];
        $appin=$row['app_no'];
        $name=$row['name'];
        if($stm) {
            header('location:approfile.php?applicant=$appass');
        } else {
            echo "<script> alert('Invalid Application Number or Password')</script>";
            exist();
        }
    } catch(Exception $e){
        echo $e->getMessage();
    }
}?>
</code>```

Someone should please help on the right syntax

答:
Thank you all for your contributions. After all this is how I have solved the problem.

```<code><?php
try{
                            $pin=$_POST['pin'];
                            $pass=$_POST['password'];
                            $stm=$dbh->prepare("SELECT pre_application.invoice_no,pre_application.password,applicants.invoice_no,applicants.app_no FROM pre_application INNER JOIN applicants ON pre_application.invoice_no=applicants.invoice_no WHERE pre_application.password=? AND applicants.app_no=?");
                            $stm->bindParam(1, $pass);
                            $stm->bindParam(2, $pin);
                            $stm->execute();
                            $row_count=$stm->rowCount();
                            if($row_count==1){
                                header('location:approfile.php');
                            }else{
                                echo "<script> alert('Invalid Application Number or Password')</script>";

                            }
                        }
                        catch(Exception $e){
                            echo $e->getMessage();
                        }
                        ?>
</code>```

The above code has worked but I would welcome a better way of achieving the same thing. thanks

ContentLicense: CC BY-SA 4.0

Body:
I have two tables pre_application and applicants table. I want to query pre_application table for password and applicants table for application pin and if the two table have the records then applicant should be logged in. Below is my code:

if(isset($_POST['submit']) || $_SERVER['REQUEST_METHOD']=='POST'){

    try{
        $pin=$_POST['pin'];
        $pass=$_POST['password'];
        $stm=$dbh->query("SELECT password FROM pre_application WHERE password='$pass' UNION SELECT app_no FROM applicants WHERE app_no='$pin'");
        foreach($stm as $row);
        $appass=$row['password'];
        $appin=$row['app_no'];
        $name=$row['name'];
        if($stm) {
            header('location:approfile.php?applicant=$appass');
        } else {
            echo "";
            exist();
        }
    } catch(Exception $e){
        echo $e->getMessage();
    }
}?>

Someone should please help on the right syntax

Body:
Thank you all for your contributions. After all this is how I have solved the problem.

<?php
try{
                            $pin=$_POST['pin'];
                            $pass=$_POST['password'];
                            $stm=$dbh->prepare("SELECT pre_application.invoice_no,pre_application.password,applicants.invoice_no,applicants.app_no FROM pre_application INNER JOIN applicants ON pre_application.invoice_no=applicants.invoice_no WHERE pre_application.password=? AND applicants.app_no=?");
                            $stm->bindParam(1, $pass);
                            $stm->bindParam(2, $pin);
                            $stm->execute();
                            $row_count=$stm->rowCount();
                            if($row_count==1){
                                header('location:approfile.php');
                            }else{
                                echo "<script> alert('Invalid Application Number or Password')</script>";

                            }
                        }
                        catch(Exception $e){
                            echo $e->getMessage();
                        }
                        ?>

The above code has worked but I would welcome a better way of achieving the same thing. thanks


问:
WPF: Is there any way to create Dynamic Templates
Unfortunately I have to create a application in WPF in school. I dont know much about it, but I know Javascript and some JS Frameworks well.
With Ember/Handelbars, it is really easy to create Templates. With Dynamic Template I mean: I have a markup (xaml) in wich I can put in a Data/Model and the Template renders based on the data. Then I can use this Template multiple times, every time put in a different model.

How can I create a dynamic template in WPF?
At the moment I have

```<code><Page.Resources>
  <Grid x:Key="char" Margin="-5,5,5,0">
    <TextBlock HorizontalAlignment="Center" TextWrapping="Wrap" Text="{Binding Path=variableModel.Name}" FontSize="16" Height="18"/>
    <ProgressBar Maximum="{Binding Path=variableModel.MaxHealth, Mode=OneWay}" Value="{Binding Path=variableModel.Health, Mode=OneWay}" Height="8"/>
  </Grid>
</Page.Resources>
</code>```

How can I make it dynamic, so that enemy can be variable data?
And then I can use it multiple times like:

```<code><StaticResource ResourceKey="char" variableModel="enemy"/>
<StaticResource ResourceKey="char" variableModel="player"/>
</code>```

So now I would have two charakters displayed, one is the enemy model and the oder the player. Both use the same template.

I know there are some Style or Data Templates, but I dont know how to make one template for multiple elements...

答:
Define a DataTemplate:

```<code><Page.Resources>
    <DataTemplate x:Key="char">
        <StackPanel Margin="-5,5,5,0">
            <TextBlock HorizontalAlignment="Center" TextWrapping="Wrap" Text="{Binding Path=Name}" FontSize="16" Height="18"/>
            <ProgressBar Maximum="{Binding Path=MaxHealth, Mode=OneWay}" Value="{Binding Path=Health, Mode=OneWay}" Height="8"/>
        </StackPanel>
    </DataTemplate>
</Page.Resources>
</code>```

You could then use a ContentControl and set is Content property to an instance of a class that has the Name, Health and MaxHealth properties:

```<code><ContentControl x:Name="cc" ContentTemplate="{StaticResource char}" />
</code>```

```<code>cc.Content = new Player();
</code>```

Body:
Unfortunately I have to create a application in WPF in school. I dont know much about it, but I know Javascript and some JS Frameworks well.
With Ember/Handelbars, it is really easy to create Templates. With Dynamic Template I mean: I have a markup (xaml) in wich I can put in a Data/Model and the Template renders based on the data. Then I can use this Template multiple times, every time put in a different model.

How can I create a dynamic template in WPF?
At the moment I have

<Page.Resources>
  <Grid x:Key="char" Margin="-5,5,5,0">
    <TextBlock HorizontalAlignment="Center" TextWrapping="Wrap" Text="{Binding Path=variableModel.Name}" FontSize="16" Height="18"/>
    <ProgressBar Maximum="{Binding Path=variableModel.MaxHealth, Mode=OneWay}" Value="{Binding Path=variableModel.Health, Mode=OneWay}" Height="8"/>
  </Grid>
</Page.Resources>

How can I make it dynamic, so that enemy can be variable data?
And then I can use it multiple times like:

<StaticResource ResourceKey="char" variableModel="enemy"/>
<StaticResource ResourceKey="char" variableModel="player"/>

So now I would have two charakters displayed, one is the enemy model and the oder the player. Both use the same template.

I know there are some Style or Data Templates, but I dont know how to make one template for multiple elements...

Body:
Define a DataTemplate:

<Page.Resources>
    <DataTemplate x:Key="char">
        <StackPanel Margin="-5,5,5,0">
            <TextBlock HorizontalAlignment="Center" TextWrapping="Wrap" Text="{Binding Path=Name}" FontSize="16" Height="18"/>
            <ProgressBar Maximum="{Binding Path=MaxHealth, Mode=OneWay}" Value="{Binding Path=Health, Mode=OneWay}" Height="8"/>
        </StackPanel>
    </DataTemplate>
</Page.Resources>

You could then use a ContentControl and set is Content property to an instance of a class that has the Name, Health and MaxHealth properties:

<ContentControl x:Name="cc" ContentTemplate="{StaticResource char}" />

cc.Content = new Player();


问:
Pass parameter from one jsp to another
Even there are many answers available to this question, still i am not able to find what i am missing. Below is my code, where i am trying to pass irepno parameter from main jsp to another using query parameter. But i am receiving null. Please someone help to findout what is the mistake.

main.jsp
Print Current Report

printcurreport.jsp
String repno = request.getParameter("irepno");```
</div>
</div>
</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><label>IRno:</label><input type="text" name="irepno" id="irepno" class="inp" value="<%=session.getAttribute("irepno")%>" /><br><br></code>```

答:
Yes to pass the values we have many ways,

from your example it seems you wanna pass values through QueryStrings.

In your code you are making mistake in the parameter, you are not fetching value through correct parameter which you have set in previous page.

```<code>    - main.jsp

         <a href="printcurreport.jsp?repno=${irepno}">Print Current Report</a>

          // Make sure irepno has some value.

    - printcurreport.jsp

       <%   out.println(request.getParameter("repno"));  %>

         // In your code you are making  mistake here in the parameter, you are not fetching value through correct parameter which you have set in previous page.
</code>```

Title: Pass parameter from one jsp to another

Body:
Even there are many answers available to this question, still i am not able to find what i am missing. Below is my code, where i am trying to pass irepno parameter from main jsp to another using query parameter. But i am receiving null. Please someone help to findout what is the mistake.

main.jsp
Print Current Report

printcurreport.jsp
String repno = request.getParameter("irepno");

IRno:<input type="text" name="irepno" id="irepno" class="inp" value="<%=session.getAttribute("irepno")%>" />

Body:
Yes to pass the values we have many ways,

from your example it seems you wanna pass values through QueryStrings.

In your code you are making mistake in the parameter, you are not fetching value through correct parameter which you have set in previous page.

    - main.jsp

         <a href="printcurreport.jsp?repno=${irepno}">Print Current Report</a>

          // Make sure irepno has some value.

    - printcurreport.jsp

       <%   out.println(request.getParameter("repno"));  %>

         // In your code you are making  mistake here in the parameter, you are not fetching value through correct parameter which you have set in previous page.


问:
regex join line infos
I have to parse this package:

```<code>WGS AUFFUELLUNGEN
ADMIN1          23.03.
17:09   -20-   1500.00
17:10   JD20    560.00
17:11  -2.0-    112.00
ADMIN1          24.03.
14:51   JD50    500.00
ADMIN2          27.03.
08:58   JD50    500.00
----------------------
               3172.00
</code>```

Parsing the user and date is easy:

```<code>\r?\n(.*)\s+(\d\d\.\d\d\.)
</code>```

Parsing the time, denomination and amount is easy too:

```<code>\r?\n(\d\d:\d\d)\s+(.*)\s+(\d+\.\d\d)
</code>```

But I need a parsing that detects user, date, time, denomination and amount for every booking at once.

Any ideas?

答:
Split the entire string by new line

Iterate over the each line and

```<code>  a. look for username and date by regex1, if matches then extract userName and Date
  b. if regex1 doesn't, then look for time, denomincation and amount regex2 . if it matches
     then extract  time, denomination and amount from this.

final String userRegex = "^(\\w+)\\s+(\\d+\\.\\d+\\.)$";
final String timeRegex = "^(\\d+:\\d+)\\s+([\\S]+)\\s+(\\d+\\.?\\d+)$";
</code>```

Sample Source:

```<code>public static void main(String[] args) {
    final String userRegex = "^(\\w+)\\s+(\\d+\\.\\d+\\.)$";
    final String timeRegex = "^(\\d+:\\d+)\\s+([\\S]+)\\s+(\\d+\\.?\\d+)$";

    final String string = "WGS AUFFUELLUNGEN\n"
            + "ADMIN1          23.03.\n"
            + "17:09   -20-   1500.00\n"
            + "17:10   JD20    560.00\n"
            + "17:11  -2.0-    112.00\n"
            + "ADMIN1          24.03.\n"
            + "14:51   JD50    500.00\n"
            + "ADMIN2          27.03.\n"
            + "08:58   JD50    500.00\n"
            + "----------------------\n"
            + "               3172.00\n";

    String[] list = string.split("\n");
    Matcher m;
    int cnt=1;
    for (String s : list) {
        m=Pattern.compile(userRegex).matcher(s);
        if (m.matches()) {

            System.out.println("##### List "+cnt+" ######");
            System.out.println("User Name:"+m.group(1));
            System.out.println("Date :"+m.group(2));
            cnt++;
        }
        else
        {
            m=Pattern.compile(timeRegex).matcher(s);
            if(m.matches())
            {
                System.out.println("Time :"+m.group(1));
                System.out.println("Denomination :"+m.group(2));
                System.out.println("Amount :"+m.group(3));
                System.out.println("---------------------");
            }
        }
    }
}
</code>```

Title: regex join line infos

Body:
I have to parse this package:

WGS AUFFUELLUNGEN
ADMIN1          23.03.
17:09   -20-   1500.00
17:10   JD20    560.00
17:11  -2.0-    112.00
ADMIN1          24.03.
14:51   JD50    500.00
ADMIN2          27.03.
08:58   JD50    500.00
----------------------
               3172.00

Parsing the user and date is easy:

\r?\n(.*)\s+(\d\d\.\d\d\.)

Parsing the time, denomination and amount is easy too:

\r?\n(\d\d:\d\d)\s+(.*)\s+(\d+\.\d\d)

But I need a parsing that detects user, date, time, denomination and amount for every booking at once.

Any ideas?

Body:
Split the entire string by new line

Iterate over the each line and

  a. look for username and date by regex1, if matches then extract userName and Date
  b. if regex1 doesn't, then look for time, denomincation and amount regex2 . if it matches
     then extract  time, denomination and amount from this.

final String userRegex = "^(\\w+)\\s+(\\d+\\.\\d+\\.)$";
final String timeRegex = "^(\\d+:\\d+)\\s+([\\S]+)\\s+(\\d+\\.?\\d+)$";

Sample Source:

public static void main(String[] args) {
    final String userRegex = "^(\\w+)\\s+(\\d+\\.\\d+\\.)$";
    final String timeRegex = "^(\\d+:\\d+)\\s+([\\S]+)\\s+(\\d+\\.?\\d+)$";

    final String string = "WGS AUFFUELLUNGEN\n"
            + "ADMIN1          23.03.\n"
            + "17:09   -20-   1500.00\n"
            + "17:10   JD20    560.00\n"
            + "17:11  -2.0-    112.00\n"
            + "ADMIN1          24.03.\n"
            + "14:51   JD50    500.00\n"
            + "ADMIN2          27.03.\n"
            + "08:58   JD50    500.00\n"
            + "----------------------\n"
            + "               3172.00\n";

    String[] list = string.split("\n");
    Matcher m;
    int cnt=1;
    for (String s : list) {
        m=Pattern.compile(userRegex).matcher(s);
        if (m.matches()) {

            System.out.println("##### List "+cnt+" ######");
            System.out.println("User Name:"+m.group(1));
            System.out.println("Date :"+m.group(2));
            cnt++;
        }
        else
        {
            m=Pattern.compile(timeRegex).matcher(s);
            if(m.matches())
            {
                System.out.println("Time :"+m.group(1));
                System.out.println("Denomination :"+m.group(2));
                System.out.println("Amount :"+m.group(3));
                System.out.println("---------------------");
            }
        }
    }
}


问:
Getting variable values from url
i am new to ansible and i am trying to achieve the following,

This is the sample playbook, here i am creating a reg key called "test" under HKLM:\SOFTWARE\myapp\Desk\ and i am adding 2 entries with items called hello and hi and i am assigning single same value "world" to both hello and hi.

i want to get the value for hello and hi from some file which will be stored in a repository or some url ..the value will be different for hello and hi.. is this possible ?

```<code>---
 - hosts: web
   tasks:
    - name: Create and add reg entries
      win_regedit:
       path: HKLM:\SOFTWARE\myapp\Desk\Test
       entry: "{{ item }}"
       data: world
       type: string
       state: present
      with_items:
         - hello
         - hi
</code>```

Update:

Some improvement here for a newbie, i am able to iterate through with_items with key value , but i want to have a file with key:value and i want the ansible to iterate through all the left side keys and create them and also fill them with the right side values..that is the entry in win_Regedit should have key and data should have values

```<code>---
 - hosts: web
   tasks:
    - name: Create and add reg entries
      win_regedit:
       path: HKLM:\SOFTWARE\myapp\Desk\Test
       entry: "{{ item.regkey }}"
       data: "{{ item.regvalue}}"
       type: string
       state: present
      with_items:
         - regkey: hello
           regvalue: world
         - regkey: hi
           regvalue: universe
</code>```

答:
To include variable from some file, you can use the include_vars module:

```<code>include_vars:
        file: vars.yml
</code>```

Edit What you want to do is probably something like below (did not try the win_regedit as I don't have any windows node):

Create a vars.yml:

```<code>---
var1: 'key1'
var2: 'key2'
d1: "{
  '{{var1}}': 'val1',
  '{{var2}}': 'val2'
}"
</code>```

Then launch the following playbook (see the with_dict statement):

```<code> ---
    - hosts: localhost
      remote_user: my_user

      tasks:
        - name: pull var_file
          url: http://example.com/path/to/vars
          dest: /path/to/vars.yml
          mode: 0440
        - name: include_vars
          include_vars:
            /path/to/vars.yml
        - name: Create and add reg entries
          win_regedit:
          path: HKLM:\SOFTWARE\myapp\Desk\Test
          entry: "{{ item.key }}"
          data: "{{ item.value}}"
          type: string
          state: present
          with_dict: "{{d1}}"
</code>```

Kudos to this answer for the with_dict trick

Title: Getting variable values from url

Body:
i am new to ansible and i am trying to achieve the following,

This is the sample playbook, here i am creating a reg key called "test" under HKLM:\SOFTWARE\myapp\Desk\ and i am adding 2 entries with items called hello and hi and i am assigning single same value "world" to both hello and hi.

i want to get the value for hello and hi from some file which will be stored in a repository or some url ..the value will be different for hello and hi.. is this possible ?

---
 - hosts: web
   tasks:
    - name: Create and add reg entries
      win_regedit:
       path: HKLM:\SOFTWARE\myapp\Desk\Test
       entry: "{{ item }}"
       data: world
       type: string
       state: present
      with_items:
         - hello
         - hi

Update:

Some improvement here for a newbie, i am able to iterate through with_items with key value , but i want to have a file with key:value and i want the ansible to iterate through all the left side keys and create them and also fill them with the right side values..that is the entry in win_Regedit should have key and data should have values

---
 - hosts: web
   tasks:
    - name: Create and add reg entries
      win_regedit:
       path: HKLM:\SOFTWARE\myapp\Desk\Test
       entry: "{{ item.regkey }}"
       data: "{{ item.regvalue}}"
       type: string
       state: present
      with_items:
         - regkey: hello
           regvalue: world
         - regkey: hi
           regvalue: universe

Body:
To include variable from some file, you can use the include_vars module:

include_vars:
        file: vars.yml

Edit What you want to do is probably something like below (did not try the win_regedit as I don't have any windows node):

Create a vars.yml:

---
var1: 'key1'
var2: 'key2'
d1: "{
  '{{var1}}': 'val1',
  '{{var2}}': 'val2'
}"

Then launch the following playbook (see the with_dict statement):

 ---
    - hosts: localhost
      remote_user: my_user

      tasks:
        - name: pull var_file
          url: http://example.com/path/to/vars
          dest: /path/to/vars.yml
          mode: 0440
        - name: include_vars
          include_vars:
            /path/to/vars.yml
        - name: Create and add reg entries
          win_regedit:
          path: HKLM:\SOFTWARE\myapp\Desk\Test
          entry: "{{ item.key }}"
          data: "{{ item.value}}"
          type: string
          state: present
          with_dict: "{{d1}}"

Kudos to this answer for the with_dict trick


问:
In IntelliJ IDEA, can I run only tests matching a regex pattern?
is it possible to create a Run/Debug configuration in IntelliJ that picks up only those files that match a regular expression?

I want to run all my unit tests. I don't want to run integration tests written by my colleagues. Integration tests contain the text "IT", so I thought the following regex would do:

```<code>^((?!IT).)*$
</code>```

But it didn't.

EDIT

As a trivial example, I tried the following regex:

^.*IT.*$

(which does exactly the opposite of what I want to achieve), but still I fail. It still picks up every single Test and runs it.

Example tests that get picked up:

```<code>com.my_company.session.SessionTest.java
com.my_company.test.server.api.ITAuthentication.java
</code>```

This is what the Test results panel looks like

答:
I've already provided the answer which describes how to exclude *IT.java tests, but as your question is different and you want to exclude *IT*.java tests (any test that has IT in its name), the pattern would be different:

```<code>^(?!.*IT.*).*$
</code>```

Note that it will not work with JUnit 5 in IntelliJ IDEA 2017.1, there is a known bug that is fixed for 2017.2 version:

IDEA-164088 JUnit 5 doesn't support pattern configurations

Body:
is it possible to create a Run/Debug configuration in IntelliJ that picks up only those files that match a regular expression?

I want to run all my unit tests. I don't want to run integration tests written by my colleagues. Integration tests contain the text "IT", so I thought the following regex would do:

^((?!IT).)*$

But it didn't.

EDIT

As a trivial example, I tried the following regex:

^.*IT.*$

(which does exactly the opposite of what I want to achieve), but still I fail. It still picks up every single Test and runs it.

Example tests that get picked up:

com.my_company.session.SessionTest.java
com.my_company.test.server.api.ITAuthentication.java

This is what the Test results panel looks like

Body:
I've already provided the answer which describes how to exclude *IT.java tests, but as your question is different and you want to exclude *IT*.java tests (any test that has IT in its name), the pattern would be different:

^(?!.*IT.*).*$

Note that it will not work with JUnit 5 in IntelliJ IDEA 2017.1, there is a known bug that is fixed for 2017.2 version:

IDEA-164088 JUnit 5 doesn't support pattern configurations


问:
How to sign AAR Artifacts in Android?
I'm currently developing a .AAR android library and I would like to sign the released artifacts with my own key, so that I can determine if a fake aar with the same name and functionality has been released by mine or not.

Notice 1 :

I want to be able to check the authenticity of my library programmatically, even if a fakely-cooked one, is forging just part of the functionality of my aar file.

Notice 2 :

I am not going to publish this aar into maven, sonatype or any other public repository. So I'm going to sign it for a typical release flow like signing an apk file.

答:
I haven't tried but this "should" work:

Create a block like this in your gradle config file for the aar you're going to create:

```<code>signedAar {
    signedConfig{
        storeFile file("path/to/keystore")
        storePassword "Password"
        keyAlias "Alias"
        keyPassword "AliasPassword"
    }
}
</code>```

then add this to the buildTypes -> release block of the same config file:

```<code>signingConfig  signedAar.signedConfig
</code>```

Let us know if this works

Title: How to sign AAR Artifacts in Android?

Body:
I haven't tried but this "should" work:

Create a block like this in your gradle config file for the aar you're going to create:

signedAar {
    signedConfig{
        storeFile file("path/to/keystore")
        storePassword "Password"
        keyAlias "Alias"
        keyPassword "AliasPassword"
    }
}

then add this to the buildTypes -> release block of the same config file:

signingConfig  signedAar.signedConfig

Let us know if this works


问:
How do I work with nested list in LISP
I am working on a homework assignment, and the first functions had me doing things like deleting a given element of a list, or displaying a given element of a list.  The next functions want me to delete nested lists, or display them.  Do you have any general tips for working with nested lists? I imagine the functions will be very similar to the ones I wrote before, just tweaked a bit. </p>

<p>Here are two example of functions I have written so far. Note I must use the "cond" style of writing functions. </p>

```<code>(defun delnth(L A)
  (cond ((= A 1) (rest L))
        (t (cons (first L) (delnth (rest L) (- A 1))))))

(defun remv(A L)
  (cond ((eq A (first L)) (remv A (rest L)))
        ((null L) nil)
        (t (cons (first L) (remv A (rest L) )))))
</code>```

答:
Both of your functions work with nested cons. '(1 2 3) is (1 . (2 . (3 . ())) and (cons 1 (cons 2 (cons 3 '()))). A nested list would be that you also have nested cons in the car of cons. eg. ((1 . ()) . ()) ; ==> ((1)).

It's important to be able to see ((1) (2 3)) and understand that it is ((1 . ()) . ((2 . (3 . ())) . ())) so that if you want to access 3 it's obviously the path d,a,d,a and in the reverse you can construct the accessor cadadr.

cons with cons in the car part are trees. When you make a function that walks the tree you need to walk both the car and the cdr in the event they are cons. Thus:

```<code>;; generic function to walk trees and reduce
;; by combiner every value accessed by term
;; the default argument to combiner is tree-null
(defun accumulate-tree (tree term combiner null-value)
  (labels ((rec (tree)
             (cond ((null tree) null-value)
                   ((atom tree) (funcall term tree))
                   (t (funcall combiner (rec (car tree))
                                        (rec (cdr tree)))))))
    (rec tree)))

(defun sum-numbers (tree)
  (accumulate-tree tree
                   #'identity
                   #'+
                   0))

(defun count-numbers (tree)
  (accumulate-tree tree
                   (lambda (v) (if (numberp v) 1 0))
                   #'+
                   0))

(sum-numbers '((1) (2 3) (((4)) 5)))   ; ==> 15
(count-numbers '(a b 4 3 (e f 5) . 9)) ; ==> 4
</code>```

The combiner doesn't need to reduce to an atom:

```<code>(defun reverse-tree (tree)
  (accumulate-tree tree
                   #'identity
                   (lambda (a d) (cons d a))
                   '()))
(reverse-tree '((1 2) (3 4)))
; ==> ((nil (nil . 4) . 3) (nil . 2) . 1)
</code>```

Title: How do I work with nested list in LISP

Body:
I am working on a homework assignment, and the first functions had me doing things like deleting a given element of a list, or displaying a given element of a list.  The next functions want me to delete nested lists, or display them.  Do you have any general tips for working with nested lists? I imagine the functions will be very similar to the ones I wrote before, just tweaked a bit.

Here are two example of functions I have written so far. Note I must use the "cond" style of writing functions.

(defun delnth(L A)
  (cond ((= A 1) (rest L))
        (t (cons (first L) (delnth (rest L) (- A 1))))))

(defun remv(A L)
  (cond ((eq A (first L)) (remv A (rest L)))
        ((null L) nil)
        (t (cons (first L) (remv A (rest L) )))))

Body:
Both of your functions work with nested cons. '(1 2 3) is (1 . (2 . (3 . ())) and (cons 1 (cons 2 (cons 3 '()))). A nested list would be that you also have nested cons in the car of cons. eg. ((1 . ()) . ()) ; ==> ((1)).

It's important to be able to see ((1) (2 3)) and understand that it is ((1 . ()) . ((2 . (3 . ())) . ())) so that if you want to access 3 it's obviously the path d,a,d,a and in the reverse you can construct the accessor cadadr.

cons with cons in the car part are trees. When you make a function that walks the tree you need to walk both the car and the cdr in the event they are cons. Thus:

;; generic function to walk trees and reduce
;; by combiner every value accessed by term
;; the default argument to combiner is tree-null
(defun accumulate-tree (tree term combiner null-value)
  (labels ((rec (tree)
             (cond ((null tree) null-value)
                   ((atom tree) (funcall term tree))
                   (t (funcall combiner (rec (car tree))
                                        (rec (cdr tree)))))))
    (rec tree)))

(defun sum-numbers (tree)
  (accumulate-tree tree
                   #'identity
                   #'+
                   0))

(defun count-numbers (tree)
  (accumulate-tree tree
                   (lambda (v) (if (numberp v) 1 0))
                   #'+
                   0))

(sum-numbers '((1) (2 3) (((4)) 5)))   ; ==> 15
(count-numbers '(a b 4 3 (e f 5) . 9)) ; ==> 4

The combiner doesn't need to reduce to an atom:

(defun reverse-tree (tree)
  (accumulate-tree tree
                   #'identity
                   (lambda (a d) (cons d a))
                   '()))
(reverse-tree '((1 2) (3 4)))
; ==> ((nil (nil . 4) . 3) (nil . 2) . 1)


问:
javascript get element by ID within ID
I would like to calculate the total price of the  if check box is checked by using JavaScript

I'm not allow to separate the id to 2 section of by adding div

for example.

```<code><form id="bookingForm">

 <section id = "checkcost">
      <h2>Total cost</h2>
     Total <input type="text" name="total" value="$0.00" size="10" readonly />
 </section>

</form>
</code>```

First, i use this method get the id

var frm = document.getElementById('bookingForm')

i m  trying to do by using the following code but this is not the correct method

frm.checkcost.total = calculate()

Since the input area to shows the total cost is inside the id="bookingForm", how should i display the total cost once the check box is checked??

ps:  here is the link i had try but it didn't work, and now i'm trying other method

onclick in php echo with error invalid unexpected token

答:
If there's only one field named total in the form, you don't need to worry about the section at all:

```<code>var frm = document.getElementById('bookingForm');
frm.total = calculate();
</code>```

or

```<code>document.querySelector("#bookingForm [name=total]").value = calculate();
</code>```

If you have multiple fields named total, then you just use the ID of the section:

```<code>document.querySelector("#checkcost [name=total]").value = calculate();
// ----------------------^
</code>```

document.querySelector finds the first element that matches a given CSS selector. You can use the full power of CSS to find elements in the document. There's also document.querySelectorAll which finds a list of matching elements. Finally, individual elements also have both methods, which look only within those elements. So for instance, we could also do this:

```<code>var frm = document.getElementById('bookingForm');
frm.querySelector("#checkcost [name=total]").value = calculate();
</code>```

(But that's just an example, not a suggestion; it's more round-about than necessary.)

Title: javascript get element by ID within ID

Body:
I would like to calculate the total price of the  if check box is checked by using JavaScript

I'm not allow to separate the id to 2 section of by adding div

for example.

<form id="bookingForm">

Total cost

     Total <input type="text" name="total" value="$0.00" size="10" readonly />

</form>

First, i use this method get the id

var frm = document.getElementById('bookingForm')

i m  trying to do by using the following code but this is not the correct method

frm.checkcost.total = calculate()

Since the input area to shows the total cost is inside the id="bookingForm", how should i display the total cost once the check box is checked??

ps:  here is the link i had try but it didn't work, and now i'm trying other method

onclick in php echo with error invalid unexpected token

Body:
If there's only one field named total in the form, you don't need to worry about the section at all:

var frm = document.getElementById('bookingForm');
frm.total = calculate();

or

document.querySelector("#bookingForm [name=total]").value = calculate();

If you have multiple fields named total, then you just use the ID of the section:

document.querySelector("#checkcost [name=total]").value = calculate();
// ----------------------^

document.querySelector finds the first element that matches a given CSS selector. You can use the full power of CSS to find elements in the document. There's also document.querySelectorAll which finds a list of matching elements. Finally, individual elements also have both methods, which look only within those elements. So for instance, we could also do this:

var frm = document.getElementById('bookingForm');
frm.querySelector("#checkcost [name=total]").value = calculate();

(But that's just an example, not a suggestion; it's more round-about than necessary.)


问:
ORA-01461: can bind a LONG value only for insert into a LONG column-Occurs when querying
When I try to query objects, I end up with following error:

```<code>ORA-01461: can bind a LONG value only for insert into a LONG column
</code>```

Could someone please help me on the cause and solution of the problem?

答:
In my particular case, I was trying to store a Base64 encoded file into a table BLOB field, using Mybatis.

So in my xml I had:

```<code><insert id="save..." parameterType="...DTO">
    <selectKey keyProperty="id" resultType="long" order="BEFORE">
        SELECT SEQ.nextVal FROM DUAL
    </selectKey>
    insert into MYTABLE(
        ID,
        ...,
        PDF
    ) values (
        #{id, jdbcType=VARCHAR},
        ...,
        #{tcPdf, jdbcType=BLOB},
    )
</insert>
</code>```

and in my DTO:

```<code>String getPdf(){
    return pdf;
}
</code>```

That makes to Mybatis threat as if were a String char sequence and try to store it as a Varchar. So my solution was the following:

In my DTO:

```<code>Byte[] getPdf(){
    return pdf.getBytes();
}
</code>```

And worked.

I hope this could help anybody.

Body:
When I try to query objects, I end up with following error:

ORA-01461: can bind a LONG value only for insert into a LONG column

Could someone please help me on the cause and solution of the problem?

Body:
In my particular case, I was trying to store a Base64 encoded file into a table BLOB field, using Mybatis.

So in my xml I had:

<insert id="save..." parameterType="...DTO">
    <selectKey keyProperty="id" resultType="long" order="BEFORE">
        SELECT SEQ.nextVal FROM DUAL
    </selectKey>
    insert into MYTABLE(
        ID,
        ...,
        PDF
    ) values (
        #{id, jdbcType=VARCHAR},
        ...,
        #{tcPdf, jdbcType=BLOB},
    )
</insert>

and in my DTO:

String getPdf(){
    return pdf;
}

That makes to Mybatis threat as if were a String char sequence and try to store it as a Varchar. So my solution was the following:

In my DTO:

Byte[] getPdf(){
    return pdf.getBytes();
}

And worked.

I hope this could help anybody.


问:
reached while popover is still visible
```<code>-(void)showsearch:(id)sender
{
    SearchViewController *searchview =[[SearchViewController alloc] initWithNibName:@"SearchViewController" bundle:nil];

    settingpopoverController = [[[UIPopoverController alloc]
                                    initWithContentViewController:searchview] autorelease];
    [searchview release];
    [settingpopoverController presentPopoverFromBarButtonItem:sender
                                    permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

}
</code>```

When I click on button, the app is crash and I got [UIPopoverController dealloc] reached while popover is still visible. message.

答:
Problem is you're setting

```<code>settingpopoverController =
</code>```

when you mean to do

```<code>self.settingpopoverController =
</code>```

for which the autorelease would be correct. The second one uses the property accessors, the first just uses the iVar.

Title: reached while popover is still visible

Body:
-(void)showsearch:(id)sender
{
    SearchViewController *searchview =[[SearchViewController alloc] initWithNibName:@"SearchViewController" bundle:nil];

    settingpopoverController = [[[UIPopoverController alloc]
                                    initWithContentViewController:searchview] autorelease];
    [searchview release];
    [settingpopoverController presentPopoverFromBarButtonItem:sender
                                    permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

}

When I click on button, the app is crash and I got [UIPopoverController dealloc] reached while popover is still visible. message.

Body:
Problem is you're setting

settingpopoverController =

when you mean to do

self.settingpopoverController =

for which the autorelease would be correct. The second one uses the property accessors, the first just uses the iVar.


问:
Docker: Download all from nltk in Dockerfile
How would I achieve the following in a Dockerfile:</p>

```<code>sudo python
import nltk
nltk.download('all')
</code>```

答:
If you add your code to the file downloadall.py this Dockerfile does the job on my machine:

```<code>FROM python:3
RUN pip install nltk
ADD downloadall.py /
CMD [ "python", "./downloadall.py" ]
</code>```

Let me know if it works for you!

Body:
How would I achieve the following in a Dockerfile:

sudo python
import nltk
nltk.download('all')

Body:
If you add your code to the file downloadall.py this Dockerfile does the job on my machine:

FROM python:3
RUN pip install nltk
ADD downloadall.py /
CMD [ "python", "./downloadall.py" ]

Let me know if it works for you!


问:
How to find the ndk revision number for your android setup
Is there a means to find the ndk revision number ideally from the cmd line or from within android studio?

My use case is android studio has run an update, replaced ndk-bundle with the latest version and I want to be able to find out what revision no. that is. i.e. r10d, r11a etc.

UPDATE

~/Android/Sdk/ndk-bundle/CHANGELOG.md looks like this - I can't see an explicit reference to the revision number, can you? maybe its just 11 but they usually have a letter as well?

```<code>Changelog
=========

Report issues to [GitHub].

[GitHub]: https://github.com/android-ndk/ndk/issues

NDK
---
 * Removed all sysroots for pre-GB platform levels. We dropped support for them
   in r11, but neglected to actually remove them.
 * Exception handling when using `c++_shared` on ARM32 now mostly works (see
   [Known Issues](#known-issues)). The unwinder will now be linked into each
   linked object rather than into libc++ itself.
 * Default compiler flags have been pruned:
   https://github.com/android-ndk/ndk/issues/27.
     * Full changes here: https://android-review.googlesource.com/#/c/207721/5.
 * `-fno-limit-debug-info` has been enabled by default for Clang debug builds.
   This should improve debugability with LLDB.
 * `--build-id` is now enabled by default.
     * This will be shown in native crash reports so you can easily identify
       which version of your code was running.
 * `NDK_USE_CYGPATH` should no longer cause problems with libgcc:
   http://b.android.com/195486.
 * `-Wl,--warn-shared-textrel` and`-Wl,--fatal-warnings` are now enabled by
   default. If you have shared text relocations, your app will not load on
   Marshmallow or later (and have never been allowed for 64-bit apps).
 * Precompiled headers should work better:
   https://github.com/android-ndk/ndk/issues/14 and
   https://github.com/android-ndk/ndk/issues/16.

Clang
-----

 * Clang has been updated to 3.8svn (r256229, build 2690385).
     * Note that Clang packaged in the Windows 64 NDK is actually 32-bit.
 * `__thread` should work for real this time.

GCC
---

 * Synchronized with the ChromeOS GCC @ `google/gcc-4_9` r227810.
 * Backported coverage sanitizer patch from ToT (r231296).
 * Fixed libatomic to not use ifuncs:
   https://github.com/android-ndk/ndk/issues/31.

Binutils
--------

 * "Erratum 843419 found and fixed" info messages are silenced.
 * Introduced option '--long-plt' to fix internal linker error when linking huge
   arm32 binaries.
 * Fixed wrong run time stubs for AArch64. This was causing jump addresses to be
   calculated incorrectly for very large DSOs.
 * Introduced default option '--no-apply-dynamic' to work around a dynamic
   linker bug for earlier Android releases.
 * NDK r11 KI for `dynamic_cast` not working with Clang, x86, `stlport_static`
   and optimization has been fixed.

GDB
---

 * Updated to GDB 7.11: https://www.gnu.org/software/gdb/news/.

Known Issues
------------

 * This is not intended to be a comprehensive list of all outstanding bugs.
 * x86 ASAN still does work. See discussion on
   https://android-review.googlesource.com/#/c/186276/
 * Exception unwinding with `c++_shared` still does not work for ARM on
   Gingerbread or Ice Cream Sandwich.
 * Bionic headers and libraries for Marshmallow and N are not yet exposed
   despite the presence of android-24. Those platforms are still the Lollipop
   headers and libraries (not a regression from r11).
 * RenderScript tools are not present (not a regression from r11):
   https://github.com/android-ndk/ndk/issues/7.
 * r12 will most likely not work with Android Studio/Gradle right away. The
   Gradle plugin will need to be updated to match the build changes we made in
   `ndk-build`.
 * We've regressed on http://b.android.com/41770.
</code>```

答:
I got the same problem when I was trying to build this version of boost and use the following line to retrieve my NDK version.

```<code>version=$(sed -En -e 's/^Pkg.Revision\s*=\s*([0-9a-f]+)/r\1/p' $source_properties)
</code>```

Where source_properties=$AndroidNDKRoot"/source.properties" at the root of your NDK folder.

Body:
Is there a means to find the ndk revision number ideally from the cmd line or from within android studio?

My use case is android studio has run an update, replaced ndk-bundle with the latest version and I want to be able to find out what revision no. that is. i.e. r10d, r11a etc.

UPDATE

~/Android/Sdk/ndk-bundle/CHANGELOG.md looks like this - I can't see an explicit reference to the revision number, can you? maybe its just 11 but they usually have a letter as well?

Changelog
=========

Report issues to [GitHub].

[GitHub]: https://github.com/android-ndk/ndk/issues

NDK
---
 * Removed all sysroots for pre-GB platform levels. We dropped support for them
   in r11, but neglected to actually remove them.
 * Exception handling when using `c++_shared` on ARM32 now mostly works (see
   [Known Issues](#known-issues)). The unwinder will now be linked into each
   linked object rather than into libc++ itself.
 * Default compiler flags have been pruned:
   https://github.com/android-ndk/ndk/issues/27.
     * Full changes here: https://android-review.googlesource.com/#/c/207721/5.
 * `-fno-limit-debug-info` has been enabled by default for Clang debug builds.
   This should improve debugability with LLDB.
 * `--build-id` is now enabled by default.
     * This will be shown in native crash reports so you can easily identify
       which version of your code was running.
 * `NDK_USE_CYGPATH` should no longer cause problems with libgcc:
   http://b.android.com/195486.
 * `-Wl,--warn-shared-textrel` and`-Wl,--fatal-warnings` are now enabled by
   default. If you have shared text relocations, your app will not load on
   Marshmallow or later (and have never been allowed for 64-bit apps).
 * Precompiled headers should work better:
   https://github.com/android-ndk/ndk/issues/14 and
   https://github.com/android-ndk/ndk/issues/16.

Clang
-----

 * Clang has been updated to 3.8svn (r256229, build 2690385).
     * Note that Clang packaged in the Windows 64 NDK is actually 32-bit.
 * `__thread` should work for real this time.

GCC
---

 * Synchronized with the ChromeOS GCC @ `google/gcc-4_9` r227810.
 * Backported coverage sanitizer patch from ToT (r231296).
 * Fixed libatomic to not use ifuncs:
   https://github.com/android-ndk/ndk/issues/31.

Binutils
--------

 * "Erratum 843419 found and fixed" info messages are silenced.
 * Introduced option '--long-plt' to fix internal linker error when linking huge
   arm32 binaries.
 * Fixed wrong run time stubs for AArch64. This was causing jump addresses to be
   calculated incorrectly for very large DSOs.
 * Introduced default option '--no-apply-dynamic' to work around a dynamic
   linker bug for earlier Android releases.
 * NDK r11 KI for `dynamic_cast` not working with Clang, x86, `stlport_static`
   and optimization has been fixed.

GDB
---

 * Updated to GDB 7.11: https://www.gnu.org/software/gdb/news/.

Known Issues
------------

 * This is not intended to be a comprehensive list of all outstanding bugs.
 * x86 ASAN still does work. See discussion on
   https://android-review.googlesource.com/#/c/186276/
 * Exception unwinding with `c++_shared` still does not work for ARM on
   Gingerbread or Ice Cream Sandwich.
 * Bionic headers and libraries for Marshmallow and N are not yet exposed
   despite the presence of android-24. Those platforms are still the Lollipop
   headers and libraries (not a regression from r11).
 * RenderScript tools are not present (not a regression from r11):
   https://github.com/android-ndk/ndk/issues/7.
 * r12 will most likely not work with Android Studio/Gradle right away. The
   Gradle plugin will need to be updated to match the build changes we made in
   `ndk-build`.
 * We've regressed on http://b.android.com/41770.

Body:
I got the same problem when I was trying to build this version of boost and use the following line to retrieve my NDK version.

version=$(sed -En -e 's/^Pkg.Revision\s*=\s*([0-9a-f]+)/r\1/p' $source_properties)

Where source_properties=$AndroidNDKRoot"/source.properties" at the root of your NDK folder.


问:
Text alignment without using table in html and css
I'm trying to learn HTML and CSS and using the old-school approach by creating a login page with three input controls (two text and one button). However, I'm using

 for the alignment issues of textboxes. But I've read somewhere that using tables is not considered a good approach. This is what I'm doing:

Home.html

```<code><div>
    <table>
        <thead>
            <tr><th><span>Login Page</span></th></tr>
        </thead>
        <tbody>
            <tr>
            <th><label>Username:</label></th>
            <td><input type="text" value="" /></td>
            </tr>
            <tr>
                <th><label>Password:</label></th>
                <td><input type="text" value="" /></td>
            </tr>
            <tr>
                <td><input type="button" value="Submit" /></td>
            </tr>
        </tbody>
    </table>
</div>
</code>```

However, I'm using some beginner stuff of CSS to align input controls without using tables and this is what I'm trying:

Home.html

```<code><div class="box">
    <span>Login Page</span>
    <br />
    <span>
        <label>Username:</label>
        <input type="text" value="" />
        <br />
        <label>Password:</label>
        <input type="text" value="" />
        <br />
        <input type="button" value="Submit" />
    </span>
</div>
</code>```

style.css

```<code>.box {
   margin: 10px 10px 10px 10px;
   border: dotted 2px #fff;
   width: 500px;
}

.box span:first-child {
    border: dotted 1px;
    margin-left: 30%;
    font-family: Arial, sans-serif;
    width: 50%;
}

.box span label:nth-of-type(odd)
{
    color:blue;
    font-family: Arial, sans-serif;
}

.box span label:nth-of-type(even)
{
    color: red;
    font-family: Arial, sans-serif;
    display: inline-block;
}
</code>```

My concern is using css, I'm able to align the input controls but I have to use multiple break tags (
) and also extra code for alignment which is easier by simply using the
 tag. Can someone suggest me the standard approach and either I'm on the right path or not?

答:
Although tables are a very good approach for forms but I prefer the much shorter and easier method ie CSS tables

Here is a code:

form {
  display: table;
}

p {
  display: table-row;
}

label {
  display: table-cell;
}

input {
  display: table-cell;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><form>
  <p>
    <label for="a">Short label:</label>
    <input id="a" type="text">
  </p>
  <p>
    <label for="b">Very very very long label:</label>
    <input id="b" type="text">
  </p>
</form></code>```

Body:
I'm trying to learn HTML and CSS and using the old-school approach by creating a login page with three input controls (two text and one button). However, I'm using

 for the alignment issues of textboxes. But I've read somewhere that using tables is not considered a good approach. This is what I'm doing:

Home.html

Login Page

            Username:
            <input type="text" value="" />

                Password:
                <input type="text" value="" />

                <input type="button" value="Submit" />

However, I'm using some beginner stuff of CSS to align input controls without using tables and this is what I'm trying:

Home.html

    Login Page

        Username:
        <input type="text" value="" />

        Password:
        <input type="text" value="" />

        <input type="button" value="Submit" />

style.css

.box {
   margin: 10px 10px 10px 10px;
   border: dotted 2px #fff;
   width: 500px;
}

.box span:first-child {
    border: dotted 1px;
    margin-left: 30%;
    font-family: Arial, sans-serif;
    width: 50%;
}

.box span label:nth-of-type(odd)
{
    color:blue;
    font-family: Arial, sans-serif;
}

.box span label:nth-of-type(even)
{
    color: red;
    font-family: Arial, sans-serif;
    display: inline-block;
}

My concern is using css, I'm able to align the input controls but I have to use multiple break tags (
) and also extra code for alignment which is easier by simply using the
 tag. Can someone suggest me the standard approach and either I'm on the right path or not?

Body:
Although tables are a very good approach for forms but I prefer the much shorter and easier method ie CSS tables

Here is a code:

form {
  display: table;
}

p {
  display: table-row;
}

label {
  display: table-cell;
}

input {
  display: table-cell;
}

<form>
  <p>
    <label for="a">Short label:</label>
    <input id="a" type="text">
  </p>
  <p>
    <label for="b">Very very very long label:</label>
    <input id="b" type="text">
  </p>
</form>


问:
What's the simplest way of returning the larger of two numbers?
Let's say I have an entity that looks like this:

```<code>public class Album()
{
    public DateTime LastUpdated { get; set; }
    public List<Picture> Pictures { get; set; }
}
</code>```

What I want to do is create a LastActivity property that will return the latest date of the activity. This is easy enough for the Pictures collection:

```<code>public DateTime LastActivity
{
    get { return Pictures.Max(x => x.LastUpdated); }
}
</code>```

However, I also want to consider the LastUpdated property on the Album entity as well. I could use this code:

```<code>public DateTime LastActivity
{
    get { return Pictures.Max(x => x.LastUpdated) > this.LastUpdated
              ? Pictures.Max(x => x.LastUpdated)
              : this.LastUpdated) };
}
</code>```

But this is bad because it will do the Max() transformation twice. Is there a better way of writing this code?

Answer

This is the solution I came up with, based on the accepted answer:

```<code>public virtual DateTime LastActivity
{
    get
    {
        var max = Pictures.Any() ? Pictures.Max(x => x.LastUpdated) : DateTime.MinValue;
        return max > this.LastUpdated ? max : this.LastUpdated;
    }
}
</code>```

The thing to watch out for is that if you do a Max() on an empty collection, you'll get an exception, so you have to check to see if there's anything in the collection first.

答:
To keep it LINQy...

```<code>public DateTime LastActivity
{
    get
    {
         return Pictures.Any(x => x.LastUpdated > this.LastUpdated)
                ? Pictures.Max(x => x.LastUpdated)
                : this.LastUpdated;
    }
}
</code>```

Update(s): added the default LastUpdated to be returned if the LINQ expression returns no results, and corrected for the OP's comment.

Body:
Let's say I have an entity that looks like this:

public class Album()
{
    public DateTime LastUpdated { get; set; }
    public List<Picture> Pictures { get; set; }
}

What I want to do is create a LastActivity property that will return the latest date of the activity. This is easy enough for the Pictures collection:

public DateTime LastActivity
{
    get { return Pictures.Max(x => x.LastUpdated); }
}

However, I also want to consider the LastUpdated property on the Album entity as well. I could use this code:

public DateTime LastActivity
{
    get { return Pictures.Max(x => x.LastUpdated) > this.LastUpdated
              ? Pictures.Max(x => x.LastUpdated)
              : this.LastUpdated) };
}

But this is bad because it will do the Max() transformation twice. Is there a better way of writing this code?

Answer

This is the solution I came up with, based on the accepted answer:

public virtual DateTime LastActivity
{
    get
    {
        var max = Pictures.Any() ? Pictures.Max(x => x.LastUpdated) : DateTime.MinValue;
        return max > this.LastUpdated ? max : this.LastUpdated;
    }
}

The thing to watch out for is that if you do a Max() on an empty collection, you'll get an exception, so you have to check to see if there's anything in the collection first.

Body:
To keep it LINQy...

public DateTime LastActivity
{
    get
    {
         return Pictures.Any(x => x.LastUpdated > this.LastUpdated)
                ? Pictures.Max(x => x.LastUpdated)
                : this.LastUpdated;
    }
}

Update(s): added the default LastUpdated to be returned if the LINQ expression returns no results, and corrected for the OP's comment.


问:
Is it possible to run code after all ajax call completed under the for loop statement?
I have a for loop statement, each loop will execute an ajax call.

```<code>$.each(arr, function(i, v) {
    var url = '/xml.php?id=' + v;
    $.ajax({
        url: url,
        type: 'GET',
        dataType: 'xml',
        success: function(xml) {
            if ($(xml).find('Lists').attr('total') == 1) {
                // some code here
            }
        },
        complete: function() {
            // some code here
        }
    })
})
</code>```

I want to run code after all ajax call completed under the loop, I have tried to place the code below to last line, it is not executed when the ajax call completed

```<code>    if (i == arr.length - 1) {
        // some code here
    }
</code>```

Therefore, if I have 10 times of loop, there are 10 times of ajax call. I want to run a code after there 10 times of ajax call completed, any ideas?

Is it better to use .ajaxComplete() or .done() to achieve it?

Thanks

答:
I came across a similar scenario but inside the loop, the AJAX call was done in another function call (called fetchData).

so I made the fetchData function return a Promise coming from the AJAX call and I chained it using the then clause in order to process the response.

Here's the Plunker link

```<code>$(document).ready(function() {
  var message = '';

  process();

  function process() {
    var promises = [];
    for (var i = 0; i < 3; i++) {
      var promise;
      (function (index) {
        promise = fetchData(index).then(function (response) {
          // do something with the response.
          message += 'Iteration ' + index + '\n';
        });
      })(i);

      promises.push(promise);
    }

    $.when.apply($, promises).then(function () {
      // do something after all the AJAX calls are completed.
      alert(message);
    });
  }

  function fetchData(param) {
    return $.ajax('data.json')
      .success(fetchDataSuccess)
      .error(fetchDataFailed);

    function fetchDataSuccess(response) {
      return response;
    }

    function fetchDataFailed(error) {
      console.error(error);
    }
  }
});
</code>```

Body:
I have a for loop statement, each loop will execute an ajax call.

$.each(arr, function(i, v) {
    var url = '/xml.php?id=' + v;
    $.ajax({
        url: url,
        type: 'GET',
        dataType: 'xml',
        success: function(xml) {
            if ($(xml).find('Lists').attr('total') == 1) {
                // some code here
            }
        },
        complete: function() {
            // some code here
        }
    })
})

I want to run code after all ajax call completed under the loop, I have tried to place the code below to last line, it is not executed when the ajax call completed

    if (i == arr.length - 1) {
        // some code here
    }

Therefore, if I have 10 times of loop, there are 10 times of ajax call. I want to run a code after there 10 times of ajax call completed, any ideas?

Is it better to use .ajaxComplete() or .done() to achieve it?

Thanks

Body:
I came across a similar scenario but inside the loop, the AJAX call was done in another function call (called fetchData).

so I made the fetchData function return a Promise coming from the AJAX call and I chained it using the then clause in order to process the response.

Here's the Plunker link

$(document).ready(function() {
  var message = '';

  process();

  function process() {
    var promises = [];
    for (var i = 0; i < 3; i++) {
      var promise;
      (function (index) {
        promise = fetchData(index).then(function (response) {
          // do something with the response.
          message += 'Iteration ' + index + '\n';
        });
      })(i);

      promises.push(promise);
    }

    $.when.apply($, promises).then(function () {
      // do something after all the AJAX calls are completed.
      alert(message);
    });
  }

  function fetchData(param) {
    return $.ajax('data.json')
      .success(fetchDataSuccess)
      .error(fetchDataFailed);

    function fetchDataSuccess(response) {
      return response;
    }

    function fetchDataFailed(error) {
      console.error(error);
    }
  }
});