问:
UML generalization subclasses?
So, I am just a totally normal, everyday, boring human being who happens to be learning UML a the moment. I'd like to start out by saying that my problem isn't applied to a real situation, it is an exercise.

It says the following "each principal is the boss of one school, and each school has one principal". So far, so good with the multiplicity. The problems for me start arising with this statement "The principal must also be an administrator". How am I supposed to model that? I'm currently leaning towards a ternary association, but it doesn't seem very clear to me (probably because I am relatively new at this).

I've modeled it like this so far:

Any ideas?

All help is greatly appreciated and paid back in kind with cosmic love rays. Basically I'll think about how great you are for helping me while dropping a deuce.

答:
A simple solution is to not mix functionalities and rights. I mean, you have a classe User which get a Role. The Role is just a list of String, one string per role.

And each functionalities is associated with the list of needed roles to use the functionalities. The first step of a functionality is to test that the connected user gets the role needed to use the functionality.

And in a professional environment, users are managed through an LDAP (id Active Directory), each user gets a password and a set of roles. And it is not needed to have one class per role.

Could your "homework" be done in this way ?
(if look on stackoverflow, you will find others questions related to this topic).

By the way, the word extend on your schema is not needed: the chosen arrow means generalization which the UML modelization of an extend.

Title: UML generalization subclasses?


来源: stackexchange

问:
Converting a String to DateTime with new format
How do you convert a string such as 13.11.2017 into a DateTime with that format 13/11/2017

I tried several ways but i didn't get solution  .

```<code>string Arrival = Request.QueryString["Arrival"];//13.11.2017
DateTime datee = DateTime.ParseExact(Arrival , "dd/MM/yyyy", null);
</code>```

here is updated code i split the string :

```<code>            string Arrival = Request.QueryString["Arrival"];//13.11.2017
      string year = Arrival.Split('.')[2];
                   string month = Arrival.Split('.')[1];
                        string day = Arrival.Split('.')[0];
                        string date = day + "/" + month + "/" + year;
                        DateTime datee = DateTime.ParseExact(date, "dd/MM/yyyy", null);
</code>```

答:
```<code>using System.Text.RegularExpressions;

string Arrival = Request.QueryString["Arrival"]; // 13.11.2017
string dateString = Regex.Replace(Arrival, @"\.", "/"); // 13/11/2017
DateTime date = DateTime.ParseExact(dateString , "dd/MM/yyyy", null); // 11/13/2017 00:00:00
</code>```

ContentLicense: CC BY-SA 3.0

Body:
How do you convert a string such as 13.11.2017 into a DateTime with that format 13/11/2017

I tried several ways but i didn't get solution  .

string Arrival = Request.QueryString["Arrival"];//13.11.2017
DateTime datee = DateTime.ParseExact(Arrival , "dd/MM/yyyy", null);

here is updated code i split the string :

            string Arrival = Request.QueryString["Arrival"];//13.11.2017
      string year = Arrival.Split('.')[2];
                   string month = Arrival.Split('.')[1];
                        string day = Arrival.Split('.')[0];
                        string date = day + "/" + month + "/" + year;
                        DateTime datee = DateTime.ParseExact(date, "dd/MM/yyyy", null);


问:
Inner Join MySQL tables with sum of table
I searched the forum and tried a couple of the results on the form but I am still struggling with the following.
Will you guys please give me advice on the following:

```<code>Table 1: transactions
Rows: user_id, amount, received

Table 2: wallet
Rows: user_id, wallet_id
</code>```

I have 2 results which I need to join:

Result 1:

```<code>SELECT user_id, SUM(amount)FROM transactions WHERE received = '100' GROUP BY user_id
</code>```

Result 2:

```<code>SELECT * FROM transactions INNER JOIN wallet ON transactions.user_id = wallet.user_id
</code>```

What I am trying to do is to link the wallet_id of Table 2 by using the user_id and link it to the user_id on all transactions in table 1 which = to 100. I also need to sum the results on the amount row.
So it will display the total of each user_id and link the wallet to it.

I have tried:

```<code>SELECT user_id, SUM(amount)FROM transactions
INNER JOIN wallet ON transactions.user_id = wallet.user_id
WHERE received = '100' GROUP BY user_id
</code>```

but its not working.
Please help guys ;-)

答:
Thanks Guys. You guys rock!!!!!
This is what worked for me:

SELECT wallet_id, received, SUM(amount)FROM transaction INNER JOIN wallet ON transaction.user_id = wallet.uid WHERE received = '100' GROUP BY wallet_id

Body:
I searched the forum and tried a couple of the results on the form but I am still struggling with the following.
Will you guys please give me advice on the following:

Table 1: transactions
Rows: user_id, amount, received

Table 2: wallet
Rows: user_id, wallet_id

I have 2 results which I need to join:

Result 1:

SELECT user_id, SUM(amount)FROM transactions WHERE received = '100' GROUP BY user_id

Result 2:

SELECT * FROM transactions INNER JOIN wallet ON transactions.user_id = wallet.user_id

What I am trying to do is to link the wallet_id of Table 2 by using the user_id and link it to the user_id on all transactions in table 1 which = to 100. I also need to sum the results on the amount row.
So it will display the total of each user_id and link the wallet to it.

I have tried:

SELECT user_id, SUM(amount)FROM transactions
INNER JOIN wallet ON transactions.user_id = wallet.user_id
WHERE received = '100' GROUP BY user_id

but its not working.
Please help guys ;-)


问:
Finding all sizes of cuboids with given volume
I have an interval of integers and I need to find all unique cuboids which have a volume that falls within said interval.

I came up with a loop that goes over all uniqe combinations of 3 numbers (size of the cuboid) (1x1x1, 1x1x2, ...; also 2x1x1 is considered the same as 1x1x2) from 1 to the upper range of the interval, and then checks if the calculated volume falls within the interval. This solution works perfectly if the upper range isn't is too large. But if the interval ends in thousands the solution becomes very slow.

I am not really interested in code as I am in an algorithm on how to solve this differently. How would you go about solving this?

答:
I would probably loop over pairs for the first two dimensions, then directly calculate the min and max values of the third dimension to get in the interval, and save earlier solutions based on the product of the first two dimensions. Something like:</p>

```<code>volume_interval = (Vmin, Vmax)
solution_intervals = {}
for w = 1 to n do
    for d = w to n do
        // see whether we've already encountered this case before
        if solution_intervals[w*d] is not defined then
            // compute min and max height to get in volume interval
            min = ceiling(volume_interval.Vmin / (w*d))
            max = floor(volume_interval.Vmax / (w*d))
            solution_intervals[w*d] = (min, max)
        // look up precomputed solution
        soln = solution_intervals[w*d]
        // print out every possible set of dimensions
        for i = soln.min to soln.max do
            print w, d, h
</code>```

Body:
I would probably loop over pairs for the first two dimensions, then directly calculate the min and max values of the third dimension to get in the interval, and save earlier solutions based on the product of the first two dimensions. Something like:

volume_interval = (Vmin, Vmax)
solution_intervals = {}
for w = 1 to n do
    for d = w to n do
        // see whether we've already encountered this case before
        if solution_intervals[w*d] is not defined then
            // compute min and max height to get in volume interval
            min = ceiling(volume_interval.Vmin / (w*d))
            max = floor(volume_interval.Vmax / (w*d))
            solution_intervals[w*d] = (min, max)
        // look up precomputed solution
        soln = solution_intervals[w*d]
        // print out every possible set of dimensions
        for i = soln.min to soln.max do
            print w, d, h


问:
create an infinite loop to build a REPL in scheme
It strikes me beautiful, how i can create a REPL in Common Lisp using:

```<code> (loop (print (eval (read))))
</code>```

However, since I'm a complete noob in Lisp (and dialects), I miserably failed to achieve the same in Scheme, due to the lacking loop function.
I tried to implement it as

```<code>(define (loop x) x (loop x))
</code>```

But that doesn't seem to do anything (even when called as (loop (print 'foo))

So the question is: how to implement an infinite loop in Scheme?

答:
```<code>(define (loop x)
  x
  (loop x))
</code>```

This is an infinite loop when you call it. But it does not erad, evaluate or print. It takes an argument x, evaluates it then throws it away before callng itself with the same argument and it repeats.

For a REPL you want something like this:

```<code>(define (repl)
  (display (eval (read))) ; for side effect of printing only
  (repl))
</code>```

Usually a REPL has a way to exit:

```<code>(define (repl)
  (let ((in (read)))
    (when (not (eq? in 'exit))
      (print (eval in))
      (repl))))
</code>```

Body:
It strikes me beautiful, how i can create a REPL in Common Lisp using:

 (loop (print (eval (read))))

However, since I'm a complete noob in Lisp (and dialects), I miserably failed to achieve the same in Scheme, due to the lacking loop function.
I tried to implement it as

(define (loop x) x (loop x))

But that doesn't seem to do anything (even when called as (loop (print 'foo))

So the question is: how to implement an infinite loop in Scheme?

Body:
(define (loop x)
  x
  (loop x))

This is an infinite loop when you call it. But it does not erad, evaluate or print. It takes an argument x, evaluates it then throws it away before callng itself with the same argument and it repeats.

For a REPL you want something like this:

(define (repl)
  (display (eval (read))) ; for side effect of printing only
  (repl))

Usually a REPL has a way to exit:

(define (repl)
  (let ((in (read)))
    (when (not (eq? in 'exit))
      (print (eval in))
      (repl))))


问:
How to verify that an object transfer is complete
I want to send a message (a serializable object) from a java instance to another instance over a network. I would like to verify that the whole object has been sent correctly.

I suppose my first step is to calculate the checksum of the object. Then I include that checksum in the object OR build a container object for the message and its checksum.

Then my second step should be to verify the checksum against the object on the other side.

My third step would be for the receiver to send a confirmation message saying that the object in question was received and that the checksum has passed (or not). If I receive a failed checksum warning, I try to resend it a few times.

After a little while, if I never received a confirmation, I try to resend it a few times as well.

Questions :

Does my protocol sounds right to verify that an object was transferred correctly ?

I would also like to know how am I supposed to implement this in java ? Do I use the CRC32 class to generate the checksum ?

Bonus question : If I were to compress each message, do I generate the checksum before of after the compression, and how do I compress an object in java ?

答:
If you have a reasonably reliable network with a low error rate, you shouldn't need to add an additional checksum. I would implement your protocol without a checksum first and add if you are sure you need it.

You can compress the data with DeflatorOutputStream, InflatorInputStream.  If the compressed data is corrupted the Object is highly likely to throw an exception when unpacking it. i.e. it is very unlikely to have a subtle error.

However, unless your objects are large, they may not compress very well and could endup being larger with compression.

ContentLicense: CC BY-SA 2.5


问:
Script doesn't run React
I am trying to run a separate file with React.js code.

But when I am trying to run the file it does not work. The page is just a blank. If I do every in the HTML file in-line scripting it works just fine.

I want to have my html file like this:

```<code>    <!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>React - Projekt</title>
    <script src="../../js/react.min.js"></script>
    <script src="../../js/react-dom.min.js"></script>
    <script src="../../js/browser.min.js"></script>
    <script src="../../js/albums.js"></script>
</head>
<body>

    <div id="container"></div>

    <script type="text/babel" src="script.js"></script>

</body>
</html>
</code>```

and my js file:

```<code>var Albums = React.createClass({
    render: function() {
        return (
            <div className="albums">
                {this.state.albums.map(function(album, index) {
                    return (
                        <Album
                            album={album}
                            onClick={this.removeAlbum.bind(this, index)}
                            />
                    )
                }, this)}
            </div>
        )
    }
});

// Rendera the shit innehåll
ReactDOM.render(
    <Albums />,
    document.getElementById("container")
);
</code>```

Is there a way to make this work?

答:
You need to load babel core Browser to load your script.js as text/babel

It will read your script.js and transform to JSX. Insert this after react-dom

```<code><script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js"></script>
</code>```

Title: Script doesn't run React

Body:
I am trying to run a separate file with React.js code.

But when I am trying to run the file it does not work. The page is just a blank. If I do every in the HTML file in-line scripting it works just fine.

I want to have my html file like this:

    <!DOCTYPE html>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>React - Projekt</title>

and my js file:

var Albums = React.createClass({
    render: function() {
        return (

                {this.state.albums.map(function(album, index) {
                    return (
                        <Album
                            album={album}
                            onClick={this.removeAlbum.bind(this, index)}
                            />
                    )
                }, this)}

        )
    }
});

// Rendera the shit innehåll
ReactDOM.render(
    <Albums />,
    document.getElementById("container")
);

Is there a way to make this work?

Body:
You need to load babel core Browser to load your script.js as text/babel

It will read your script.js and transform to JSX. Insert this after react-dom

<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js"></script>


问:
Adding modal to upload image in a custom component in joomla 2.5
I am trying to built my custom component, in which I want to upload image from administrator.
For uploading image I want to use media manager modal, and that should return the image url in my text box. I have made following changes in the popup-imagemanager.js:

```<code>this.editor = decodeURIComponent(q.get('e_name')); //after this
//I added
this.return_url = decodeURIComponent(q.get('return_url'));
</code>```

and

```<code>//window.parent.jInsertEditorText(tag, this.editor);

//removed above line and added the following

if ( this.return_url == 1 )
{
 window.parent.document.getElementById(this.editor).value=url;
}
else
{
 window.parent.jInsertEditorText(tag, this.editor);
}
</code>```

and the code in my form is as under:

```<code><input class="text_area" type="text" name="imageurl" id="imageurl" size="50" maxlength="250" value="<?php echo $this->image->image;?>" />

 <div class="button2-left">
  <div class="image">
   <a rel="{handler: 'iframe', size: {x: 570, y: 400}}" href="index.php?      option=com_media&view=images&tmpl=component&e_name=imageurl&return_url=1"
   title="Image" class="modal-button">Select</a>
  </div>
</div>
</code>```

When I click the insert button after selecting an image in the modal, I get the error:

      window.parent.document.getElementById(this.editor) is null

I searched for it but was unable to solve it. Pls tell me what to do . Thnx

答:
The class in a tag must be "modal".</p>

```<code>JHTML::_('behavior.modal');

<a rel="{handler: 'iframe', size: {x: 570, y: 400}}" href="index.php?option=com_media&view=images&tmpl=component&e_name=imageurl&return_url=1"
   title="Image" class="modal">Select</a>
</code>```

Body:
I am trying to built my custom component, in which I want to upload image from administrator.
For uploading image I want to use media manager modal, and that should return the image url in my text box. I have made following changes in the popup-imagemanager.js:

this.editor = decodeURIComponent(q.get('e_name')); //after this
//I added
this.return_url = decodeURIComponent(q.get('return_url'));

and

//window.parent.jInsertEditorText(tag, this.editor);

//removed above line and added the following

if ( this.return_url == 1 )
{
 window.parent.document.getElementById(this.editor).value=url;
}
else
{
 window.parent.jInsertEditorText(tag, this.editor);
}

and the code in my form is as under:

<input class="text_area" type="text" name="imageurl" id="imageurl" size="50" maxlength="250" value="<?php echo $this->image->image;?>" />

   Select

When I click the insert button after selecting an image in the modal, I get the error:

      window.parent.document.getElementById(this.editor) is null

I searched for it but was unable to solve it. Pls tell me what to do . Thnx

Body:
The class in a tag must be "modal".

JHTML::_('behavior.modal');

<a rel="{handler: 'iframe', size: {x: 570, y: 400}}" href="index.php?option=com_media&view=images&tmpl=component&e_name=imageurl&return_url=1"
   title="Image" class="modal">Select</a>


问:
When scaling is determined, why is there a need for both screen size and density?
When scaling (A layout, an image, and so on), Android determines the scaling based on two factors: Screen size and screen density.

Why is there a need for both of them?

For simplicity, let's assume an app that has a single layout file, with several elements defined with dp units, and with no provided alternative resources.
In such a case, a scaling is applied (listing 2, Italic added):

At runtime, the system ensures the best possible display on the
  current screen with the following procedure for any given resource:

The system uses the appropriate alternative resource [...]

If no matching resource is available, the system uses the default
  resource and scales it up or down as needed to match the current
  screen size and density

Now, given the above,  what would not be possible, scaling-wise, if scaling would have been determined only by one of these factors?

A side note:

Numerous resources online regards the scaling functionality, but I'm having a hard time finding a direct explanation for the need of Android to use both size and density factors for it.

To add on that, the most cited resource, Supporting Multiple Screens, left things unclear for me when first stating that the four generalized sizes (small, medium, large, xlarge) are deprecated beginning with Android 3.2, while later repeatedly referring to those generalizations as if they are still used (E.g., when stating that "the system uses the appropriate resources based on the generalized size or density"), and other documentation pages do so as well (E.g., the table here).

On the other hand, the above cited page defines only one type of independency - a density independency, and not a size independency. Therefore, I was left confused.

答:
the system uses the default resource and scales it up or down as needed to match the current screen size and density

I think this is written in a confusing way, but is generally true. Image resources are scaled based on the screen density (when an appropriate alternative resource is not specified), but other resources can be "scaled" based on the screen size. For example, a layout resource will be "scaled up" on a tablet as opposed to a phone. I don't really know why the documentors chose to call this "scaling", but I believe this is what they mean.

In other words, the resources framework provides qualifiers for both density (e.g. -xxhdpi) and for size (e.g. -xlarge or -sw720dp), but will use non-qualified resources as fallbacks.

the four generalized sizes (small, medium, large, xlarge) are deprecated beginning with Android 3.2, while later repeatedly referring to those generalizations as if they are still used

They are deprecated, and yet they are still used. You are free to go ahead and create a layout-xlarge directory and put alternative layouts in it, and the system will use them when it deems doing so appropriate. It's just not recommended; you're better off using the -swXXXdp qualifiers these days, as this gives you much more control over your layouts.


问:
How to setup spree_static_content with spree 3.X and rails 5 to generate static pages
I have been trying to setup gem spree_static_content with spree 3.X and rails 5 but there are endless errors (migrations not running, gem dependencies) which are coming. Documentation is outdated and no help on any of the gems and spree commerce project. If someone has recently used these projects please share the debugging results. </p>

答:
When setting up spree_static_content gem with Rails 5.x and spree 3.x there are various errors you will get when you add only gem spree_static_content to your Gemfile.
Install following gems to your Gemfile and you will not get any error and will easily setup cms for static content for your application.

```<code>gem 'spree_static_content', github: 'spree-contrib/spree_static_content'

gem 'globalize', git: 'https://github.com/globalize/globalize'
gem 'activemodel-serializers-xml'

gem 'spree_i18n', github: 'spree-contrib/spree_i18n'
gem 'spree_globalize', github: 'spree-contrib/spree_globalize'
</code>```

Next, run following commands

```<code>bundle install
bundle exec rails g spree_i18n:install
bundle exec rails g spree_globalize:install
bundle exec rails g spree_static_content:install
</code>```

Now, simply create pages from admin but don't forget to select the store-name checkbox for route to work for spree 3.x.

Body:
When setting up spree_static_content gem with Rails 5.x and spree 3.x there are various errors you will get when you add only gem spree_static_content to your Gemfile.
Install following gems to your Gemfile and you will not get any error and will easily setup cms for static content for your application.

gem 'spree_static_content', github: 'spree-contrib/spree_static_content'

gem 'globalize', git: 'https://github.com/globalize/globalize'
gem 'activemodel-serializers-xml'

gem 'spree_i18n', github: 'spree-contrib/spree_i18n'
gem 'spree_globalize', github: 'spree-contrib/spree_globalize'

Next, run following commands

bundle install
bundle exec rails g spree_i18n:install
bundle exec rails g spree_globalize:install
bundle exec rails g spree_static_content:install

Now, simply create pages from admin but don't forget to select the store-name checkbox for route to work for spree 3.x.


问:
How to display the current date & time in the Freemarker template section of smooks?
I am able to display the contents of my incoming XML file using smooks in the freemarker template, but I want to add Current Date & time of my local system to identify the execution of my program.

```<code><ftl:freemarker applyOnElement="CreditCard">
    <ftl:template><!--        <BalanceInquiryRequest>
        <TransactionId>${BalanceInquiryRequest.TransactionId}</<TransactionId>
        <ConfigurationId>${BalanceInquiryRequest.ConfigurationId}</ConfigurationId>
        <CardNumberr>${.vars["GiftCard"].CardNumber}</CardNumberr>
        <ExpirationDate>${.vars["GiftCard"].ExpirationDate}</ExpirationDate>
        <SecurityCode>${.vars["GiftCard"].SecurityCode}</SecurityCode>
       *****************************
Here I want to display the current Date & time
    </BalanceInquiryRequest>
    --></ftl:template>
</ftl:freemarker>
</code>```

Can you tell me how can I add current date & time in the XML without having an entry in the incoming XML.

答:
You could write a short groovy script in the Smooks configuration file to populate a bean in the beancontext with today's date. Then the freemarker script could use the value from that bean.

Edit: You can read more about Groovy and Smooks here: http://www.smooks.org/mediawiki/index.php?title=V1.3:Smooks_v1.3_User_Guide#Groovy_Scripting

You probably want to use methods from http://www.milyn.org/javadoc/v1.2/smooks-cartridges/javabean/org/milyn/javabean/repository/BeanRepository.html and do something similar to:

```<code>  <g:groovy executeOnElement="xxx">
    <g:script>
    <!--
    addBean("date", new Date());
    -->
    </g:script>
</g:groovy>
</code>```

You should then be able to access the "date" bean in your freemarker.

Body:
I am able to display the contents of my incoming XML file using smooks in the freemarker template, but I want to add Current Date & time of my local system to identify the execution of my program.

<ftl:freemarker applyOnElement="CreditCard">
    <ftl:template></ftl:template>
</ftl:freemarker>

Can you tell me how can I add current date & time in the XML without having an entry in the incoming XML.

Body:
You could write a short groovy script in the Smooks configuration file to populate a bean in the beancontext with today's date. Then the freemarker script could use the value from that bean.

Edit: You can read more about Groovy and Smooks here: http://www.smooks.org/mediawiki/index.php?title=V1.3:Smooks_v1.3_User_Guide#Groovy_Scripting

You probably want to use methods from http://www.milyn.org/javadoc/v1.2/smooks-cartridges/javabean/org/milyn/javabean/repository/BeanRepository.html and do something similar to:

  <g:groovy executeOnElement="xxx">
    <g:script>
    <!--
    addBean("date", new Date());
    -->
    </g:script>
</g:groovy>

You should then be able to access the "date" bean in your freemarker.


问:
JavaScript setAttribute ID to row is Undefined
I am attempting to give each row that is dynamically added a unique ID. Basically by adding to the number each time the user clicks the add button. It is adding an ID, but not correctly, it is showing up as "undefined" in the dev tools.

var counter = 0;
function appendRow(id, style) {
  var table = document.getElementById(id); // table reference
  length = table.length,
  row = table.insertRow(table.rows.length, 'id');      // append table row
  row.setAttribute('id', style);
  row.setAttribute('idName', style);
  var i;
  // insert table cells to the new row
  for (i = 0; i < table.rows[0].cells.length; i++) {
      createCell(row.insertCell(i), i, 'cust' + counter);
      counter++
  }
}

function createCell(cell, text, style) {
  var div = document.createElement('div'), // create DIV element
      txt = document.createTextNode('_'); // create text node
  div.appendChild(txt);               // append text node to the DIV
  div.setAttribute('id', style);        // set DIV class attribute
  div.setAttribute('idName', style);    // set DIV class attribute for IE (?!)
  cell.appendChild(div);                   // append DIV to the table cell
}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>table {
  text-align: center;
}
td {
  width: 100px;
}

tr:nth-child(even) {
  background-color: #fff;
}
tr:nth-child(odd) {
  background-color: #eee;
}</code>```

<button id="addCust" class="addSort" onclick="appendRow('custList')">add customer</button>

            Customers
            Main Location

            Someone
            Somewhere

```

答:
Your style value is null here please check style value I have also added fiddle

Please check this code, When user is clicking on button the style value is undefined.

```<code><button id="addCust" class="addSort" ***onclick="appendRow('custList')"***>add customer</button>
</code>```

Appendrow function requires two parameters and you are just passing one.

var counter = 0;
$('#addCust').click(function() {
  var table = document.getElementById('custListTop'); // table reference
  length = table.length,
  row = table.insertRow(table.rows.length, 'id'); // append table row
  row.setAttribute('id', counter);
  row.setAttribute('idName', counter);
  var i;
  // insert table cells to the new row
  for (i = 0; i < table.rows[0].cells.length; i++) {
    createCell(row.insertCell(i), i, 'cust' + counter);
    counter++
  }
});

function createCell(cell, text, style) {
  var div = document.createElement('div'), // create DIV element
    txt = document.createTextNode('_'); // create text node
  div.appendChild(txt); // append text node to the DIV
  div.setAttribute('id', style); // set DIV class attribute
  div.setAttribute('idName', style); // set DIV class attribute for IE (?!)
  cell.appendChild(div); // append DIV to the table cell
}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>table {
  text-align: center;
}

td {
  width: 100px;
}

tr:nth-child(even) {
  background-color: #fff;
}

tr:nth-child(odd) {
  background-color: #eee;
}</code>```

<button id="addCust" class="addSort">add customer</button>

      Customers
      Main Location

      Someone
      Somewhere

```

Body:
I am attempting to give each row that is dynamically added a unique ID. Basically by adding to the number each time the user clicks the add button. It is adding an ID, but not correctly, it is showing up as "undefined" in the dev tools.

var counter = 0;
function appendRow(id, style) {
  var table = document.getElementById(id); // table reference
  length = table.length,
  row = table.insertRow(table.rows.length, 'id');      // append table row
  row.setAttribute('id', style);
  row.setAttribute('idName', style);
  var i;
  // insert table cells to the new row
  for (i = 0; i < table.rows[0].cells.length; i++) {
      createCell(row.insertCell(i), i, 'cust' + counter);
      counter++
  }
}

function createCell(cell, text, style) {
  var div = document.createElement('div'), // create DIV element
      txt = document.createTextNode('_'); // create text node
  div.appendChild(txt);               // append text node to the DIV
  div.setAttribute('id', style);        // set DIV class attribute
  div.setAttribute('idName', style);    // set DIV class attribute for IE (?!)
  cell.appendChild(div);                   // append DIV to the table cell
}

table {
  text-align: center;
}
td {
  width: 100px;
}

tr:nth-child(even) {
  background-color: #fff;
}
tr:nth-child(odd) {
  background-color: #eee;
}

<button id="addCust" class="addSort" onclick="appendRow('custList')">add customer</button>

            Customers
            Main Location

            Someone
            Somewhere

Body:
Your style value is null here please check style value I have also added fiddle

Please check this code, When user is clicking on button the style value is undefined.

<button id="addCust" class="addSort" ***onclick="appendRow('custList')"***>add customer</button>

Appendrow function requires two parameters and you are just passing one.

var counter = 0;
$('#addCust').click(function() {
  var table = document.getElementById('custListTop'); // table reference
  length = table.length,
  row = table.insertRow(table.rows.length, 'id'); // append table row
  row.setAttribute('id', counter);
  row.setAttribute('idName', counter);
  var i;
  // insert table cells to the new row
  for (i = 0; i < table.rows[0].cells.length; i++) {
    createCell(row.insertCell(i), i, 'cust' + counter);
    counter++
  }
});

function createCell(cell, text, style) {
  var div = document.createElement('div'), // create DIV element
    txt = document.createTextNode('_'); // create text node
  div.appendChild(txt); // append text node to the DIV
  div.setAttribute('id', style); // set DIV class attribute
  div.setAttribute('idName', style); // set DIV class attribute for IE (?!)
  cell.appendChild(div); // append DIV to the table cell
}

table {
  text-align: center;
}

td {
  width: 100px;
}

tr:nth-child(even) {
  background-color: #fff;
}

tr:nth-child(odd) {
  background-color: #eee;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button id="addCust" class="addSort">add customer</button>
<div class="custScroll">
  <table id="custListTop" contenteditable="false">
    <tr>
      <td style="border-top-left-radius: 5px;">Customers</td>
      <td style="border-top-right-radius: 5px;">Main Location</td>
    </tr>
  </table>
  <table id="custList" contenteditable="true">
    <tr>
      <td>Someone</td>
      <td>Somewhere</td>
    </tr>
  </table>
</div>


问:
Finding the longest palindrome within a string in Python
I'm trying to solve the Longest Palindromic Substring problem on LeetCode. The problem statement is:

Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.

Example:

```<code>Input: "babad"

Output: "bab"
</code>```

Note: "aba" is also a valid answer.
  Example:

```<code>Input: "cbbd"

Output: "bb"
</code>```

I've come up with the following solution (including some test cases):

```<code>import pytest

class Solution:
    def longestPalindrome(self, s):
        candidate = ""
        longest = ""
        contains_palindrome = False
        for i, char in enumerate(s):
            if i == 0:
                candidate = char
            elif i == 1:
                if s[1] == s[0]:
                    candidate = self.get_palindrome(s, start=0, end=1)
            elif i >= 2:
                if char == s[i-1]:
                    candidate = self.get_palindrome(s, start=i-1, end=i)
                elif char == s[i-2]:
                    candidate = self.get_palindrome(s, start=i-2, end=i)
            if len(candidate) > len(longest):
                longest = candidate
        return longest

    @staticmethod
    def get_palindrome(s, start, end):
        palindrome = s[start:end+1]
        while end < len(s) - 1:
            if s[end+1] == s[start] and Solution.all_same(palindrome):
                end += 1
                palindrome += s[end]
            else:
                break
        while (start > 0) and (end < len(s) - 1):
            start -= 1
            end += 1
            if s[start] == s[end]:
                palindrome = s[start] + palindrome + s[end]
            else:
                break
        return palindrome

    @staticmethod
    def all_same(items):
        return all(item == items[0] for item in items)

def test_1():
    assert Solution().longestPalindrome("babad") == "bab"

def test_2():
    assert Solution().longestPalindrome("cbbd") == "bb"

def test_3():
    assert Solution().longestPalindrome("abba") == "abba"

def test_4():
    assert Solution().longestPalindrome("a") == "a"

def test_5():
    assert Solution().longestPalindrome("ccc") == "ccc"

def test_6():
    assert Solution().longestPalindrome("aaaa") == "aaaa"

def test_7():
    assert Solution().longestPalindrome("aaabaaaa") == "aaabaaa"

if __name__ == "__main__":
    pytest.main([__file__])
</code>```

The problem is that I get a "time limit exceeded" error:

My understanding is that the time complexity of this algorithm is O(n^2), since for every character it checks for a palindrome which could be up to n characters long. In LeetCode's solutions there are also O(n^2) algorithms (in Java).

I'm guessing that the time limit is a bit too stringent for Python, which is slower than Java. Or am I missing something and is the time complexity of my solution actually greater than O(n^2)?

答:
I tried the 'dynamic programming' idea of finding centers of '0_th order' palindromes and then pruning as the depth j is increased and mismatches occur

the pruning is done inside list comps and should be relatively fast but still O(n^2)

```<code>class Solution:
    def longestPalindrome(self, s):

        s = '>' + s + '<'  # add guard values

        # make lists of '0_th order' palindrome 'centers', even and odd

        evn = [i for i, a in enumerate(zip(s, s[1:])) if a[0] == a[1]]

        odd = [i + 1 for i, a in enumerate(zip(s, s[2:])) if a[0] == a[1]]

        # prune lists of centers when elements +/- j from centers don't match

        evn_last, odd_last = [[1], 0], [[1], 1]

        j = 1
        while evn:
            evn_last = (evn, j)
            evn = [e for e in evn if s[e - j] == s[e + j + 1]]
            j += 1

        j = 1
        while odd:
            odd_last = (odd, j)
            odd = [e for e in odd if s[e - j] == s[e + j]]
            j += 1

        # determine longest, construct palindrome

        if 2 * evn_last[1] > 2 * odd_last[1] - 1:

            cntr = evn_last[0][0]
            pal = s[cntr] + s[cntr + 1]
            for i in range(1, evn_last[1]):
                pal = s[cntr - i] + pal + s[cntr + i + 1]
        else:
            cntr = odd_last[0][0]
            pal = s[cntr]
            for i in range(1, odd_last[1]):
                pal = s[cntr - i] + pal + s[cntr + i]
        return pal
</code>```

apologies if I got pasting into the Class wrapper wrong - OOP's not my thing

does pass your tests

may have figured out calling instances, obvious renaming

```<code>S = Solution()

%timeit S.fred_longestPalindrome("aba"*300)
17.8 ms ± 230 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)

%timeit S.Kurt_longestPalindrome("aba"*300)
52.8 ms ± 108 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
</code>```

Body:
I'm trying to solve the Longest Palindromic Substring problem on LeetCode. The problem statement is:

Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.

Example:

Input: "babad"

Output: "bab"

Note: "aba" is also a valid answer.
  Example:

Input: "cbbd"

Output: "bb"

I've come up with the following solution (including some test cases):

import pytest

class Solution:
    def longestPalindrome(self, s):
        candidate = ""
        longest = ""
        contains_palindrome = False
        for i, char in enumerate(s):
            if i == 0:
                candidate = char
            elif i == 1:
                if s[1] == s[0]:
                    candidate = self.get_palindrome(s, start=0, end=1)
            elif i >= 2:
                if char == s[i-1]:
                    candidate = self.get_palindrome(s, start=i-1, end=i)
                elif char == s[i-2]:
                    candidate = self.get_palindrome(s, start=i-2, end=i)
            if len(candidate) > len(longest):
                longest = candidate
        return longest

    @staticmethod
    def get_palindrome(s, start, end):
        palindrome = s[start:end+1]
        while end < len(s) - 1:
            if s[end+1] == s[start] and Solution.all_same(palindrome):
                end += 1
                palindrome += s[end]
            else:
                break
        while (start > 0) and (end < len(s) - 1):
            start -= 1
            end += 1
            if s[start] == s[end]:
                palindrome = s[start] + palindrome + s[end]
            else:
                break
        return palindrome

    @staticmethod
    def all_same(items):
        return all(item == items[0] for item in items)

def test_1():
    assert Solution().longestPalindrome("babad") == "bab"

def test_2():
    assert Solution().longestPalindrome("cbbd") == "bb"

def test_3():
    assert Solution().longestPalindrome("abba") == "abba"

def test_4():
    assert Solution().longestPalindrome("a") == "a"

def test_5():
    assert Solution().longestPalindrome("ccc") == "ccc"

def test_6():
    assert Solution().longestPalindrome("aaaa") == "aaaa"

def test_7():
    assert Solution().longestPalindrome("aaabaaaa") == "aaabaaa"

if __name__ == "__main__":
    pytest.main([__file__])

The problem is that I get a "time limit exceeded" error:

My understanding is that the time complexity of this algorithm is O(n^2), since for every character it checks for a palindrome which could be up to n characters long. In LeetCode's solutions there are also O(n^2) algorithms (in Java).

I'm guessing that the time limit is a bit too stringent for Python, which is slower than Java. Or am I missing something and is the time complexity of my solution actually greater than O(n^2)?

Body:
I tried the 'dynamic programming' idea of finding centers of '0_th order' palindromes and then pruning as the depth j is increased and mismatches occur

the pruning is done inside list comps and should be relatively fast but still O(n^2)

class Solution:
    def longestPalindrome(self, s):

        s = '>' + s + '<'  # add guard values

        # make lists of '0_th order' palindrome 'centers', even and odd

        evn = [i for i, a in enumerate(zip(s, s[1:])) if a[0] == a[1]]

        odd = [i + 1 for i, a in enumerate(zip(s, s[2:])) if a[0] == a[1]]

        # prune lists of centers when elements +/- j from centers don't match

        evn_last, odd_last = [[1], 0], [[1], 1]

        j = 1
        while evn:
            evn_last = (evn, j)
            evn = [e for e in evn if s[e - j] == s[e + j + 1]]
            j += 1

        j = 1
        while odd:
            odd_last = (odd, j)
            odd = [e for e in odd if s[e - j] == s[e + j]]
            j += 1

        # determine longest, construct palindrome

        if 2 * evn_last[1] > 2 * odd_last[1] - 1:

            cntr = evn_last[0][0]
            pal = s[cntr] + s[cntr + 1]
            for i in range(1, evn_last[1]):
                pal = s[cntr - i] + pal + s[cntr + i + 1]
        else:
            cntr = odd_last[0][0]
            pal = s[cntr]
            for i in range(1, odd_last[1]):
                pal = s[cntr - i] + pal + s[cntr + i]
        return pal

apologies if I got pasting into the Class wrapper wrong - OOP's not my thing

does pass your tests

may have figured out calling instances, obvious renaming

S = Solution()

%timeit S.fred_longestPalindrome("aba"*300)
17.8 ms ± 230 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)

%timeit S.Kurt_longestPalindrome("aba"*300)
52.8 ms ± 108 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)


问:
Unexpected app crashes: "hijack: Backend error: Exit status: 500 and could not find the exitcode file for the process"
app.crash  index: 0, reason: CRASHED, exit_description: Instance became unhealthy: hijack: Backend error: Exit status: 500, message: {"Type":"","Message":"no space left on device","Handle":"","ProcessID":""}                                                                                ; connection: process error: could not find the exitcode file for the process: stat /var/vcap/data/garden/depot/XXX/processes/XXX/exitcode: no such file or directory; connection:

Lately, the above error has been persistently occurring on several apps running in the AppCloud. There is no connection between the apps and the apps are very different with different buildpacks.

Can someone help me or has someone else the same problems?

Setup Example:
PHP Webapp deployed with the cloudfoundry php buildpack in Swisscom Application Cloud, the same App twice... one app crashes with the error above and the other app doesn't do the error (so very strange, one is running and one not with the exactly same config/environment), installed HTTPD and PHP with all dependencies in the linux container, Stack cflinuxfs2 (https://github.com/cloudfoundry/cflinuxfs2)

答:
We have investigated these crashes and have discovered, that they are due to an issue in our configuration of Cloud Foundry which causes the VMs which host the app containers to run out of iNodes. This then manifests itself with the OS reporting "no space left on device" which is arguably a bit misleading and had us fooled for a while.

We are currently working on a new release which will fix this issue. We plan to deploy this release to production as soon as possible. We will keep you updated via this post.

Update: we have rolled out a new platform release which has fixed the issue. Please check your event logs to confirm this.


问:
Xampp start giving errors
I am installing XAMPP on ubuntu10.10

(i) i have extracted tar xvfz xampp-linux-1.7.7.tar.gz -C ./opt into the opt folder

(ii) When i write: sudo ./opt/lampp/lampp start
I am getting the following errors:

```<code>cat: /opt/lampp/lib/VERSION: No such file or directory
./lampp: line 126: /opt/lampp/share/lampp/selinux: No such file or directory
Starting XAMPP for Linux ...
./lampp: line 133: /opt/lampp/share/lampp/nogroupcheck: No such file or directory
cat: /opt/lampp/lib/VERSION: No such file or directory
./lampp: line 126: /opt/lampp/share/lampp/selinux: No such file or directory
XAMPP: Another web server daemon is already running.
cat: /opt/lampp/lib/VERSION: No such file or directory
./lampp: line 126: /opt/lampp/share/lampp/selinux: No such file or directory
XAMPP: Starting MySQL...
./lampp: line 253: /opt/lampp/bin/mysql.server: No such file or directory
XAMPP: Couldn't start MySQL!
cat: /opt/lampp/lib/VERSION: No such file or directory
./lampp: line 126: /opt/lampp/share/lampp/selinux: No such file or directory
./lampp: line 140: /opt/lampp/share/lampp/alladdons: No such file or directory
XAMPP for Linux started.
</code>```

I searched through several forms on the net, but i am unable to rectify the error. I am a novice as far as xampp is concerned, so please excuse my ignore and help me find a solution?

答: This is happen when you don't give the correct path for the script.</p>

Title: Xampp start giving errors

Body:
I am installing XAMPP on ubuntu10.10

(i) i have extracted tar xvfz xampp-linux-1.7.7.tar.gz -C ./opt into the opt folder

(ii) When i write: sudo ./opt/lampp/lampp start
I am getting the following errors:

cat: /opt/lampp/lib/VERSION: No such file or directory
./lampp: line 126: /opt/lampp/share/lampp/selinux: No such file or directory
Starting XAMPP for Linux ...
./lampp: line 133: /opt/lampp/share/lampp/nogroupcheck: No such file or directory
cat: /opt/lampp/lib/VERSION: No such file or directory
./lampp: line 126: /opt/lampp/share/lampp/selinux: No such file or directory
XAMPP: Another web server daemon is already running.
cat: /opt/lampp/lib/VERSION: No such file or directory
./lampp: line 126: /opt/lampp/share/lampp/selinux: No such file or directory
XAMPP: Starting MySQL...
./lampp: line 253: /opt/lampp/bin/mysql.server: No such file or directory
XAMPP: Couldn't start MySQL!
cat: /opt/lampp/lib/VERSION: No such file or directory
./lampp: line 126: /opt/lampp/share/lampp/selinux: No such file or directory
./lampp: line 140: /opt/lampp/share/lampp/alladdons: No such file or directory
XAMPP for Linux started.

I searched through several forms on the net, but i am unable to rectify the error. I am a novice as far as xampp is concerned, so please excuse my ignore and help me find a solution?


问:
How do I convert a string to this format? pgAdmin claims this is a "byte array" but is it really?
I have a public key stored in a database, which is stored as 02fa6902e91e127d6d3410f6abc271a79ae24029079caa0db5819757e3c1c1c5a4. In a different part of the database, that same data as instead stored as "binary data" with the type "bytea". In pgAdmin III, and ONLY in pgAdmin III and ONLY when I run a query grabbing the row using another column, the data is returned as follows:

\002\372i\002\351\036\022}m4\020\366\253\302q\247\232\342@)\007\234\252\015\265\201\227W\343\301\301\305\244

I need to query for this specific "binary data" to pull up said rows in other parts of my code. However, I have never seen this data format before, it doesn't show up in pgAdmin4 even when I run a query on other columns (it shows up as "binary data" instead without the data above being shown). Querying using the weird format above gets me the data I want, but I have multiple public key strings that I need to convert to the odd format above, and I'm clueless as to how to go about doing this. It doesn't seem to be like any byte array I've ever seen.

答:
The two values are the same.

The difference is that the first representation is in hexadecimal (there should be a \x at the beginning), while in the second representation every non-ASCII byte is represented as \xxx with xxx being the octal value of the byte.

The first representation is the "modern" one, while the second was used in old PostgreSQL versions.

I suspect that your pgAdmin III is not the latest version.


问:
C++ C2466 error
Why we can do something like

```<code>        for(int i = 0; i < destination->imageSize; i=i+3)
        {

            buffer[2] = destination->imageData[i];
            buffer[1] = destination->imageData[i+1];
            buffer[0] = destination->imageData[i+2];
            buffer+=3;
        }
</code>```

but we can not do

```<code>                               char buffer[destination->imageSize];
</code>```

And how to such thing?

Sorry - I am quite new to C++...

BTW: my point is to create a function that would return a char with an image. If I'd use mem copy how do I delete returned value?

答: Hmm. Did you try creating a pointer or reference to destination->imageSize and passing that in for the index instead?</p>

Title: C++ C2466 error

Body:
Why we can do something like

        for(int i = 0; i < destination->imageSize; i=i+3)
        {

            buffer[2] = destination->imageData[i];
            buffer[1] = destination->imageData[i+1];
            buffer[0] = destination->imageData[i+2];
            buffer+=3;
        }

but we can not do

                               char buffer[destination->imageSize];

And how to such thing?

Sorry - I am quite new to C++...

BTW: my point is to create a function that would return a char with an image. If I'd use mem copy how do I delete returned value?


问:
Triggering element style changes/transforms from within react
I have a range-slider component and have it console.logging output whenever the slider is changed/moved/incremented. I want this to trigger a change in the scale of a css shape on my page so the css shape grows in size as you increment the volume slider from 1 to 10. I currently have my css styling sitting in separate .scss files. What is the correct way to scale it?</p>

答:
How about declaring the scale inline (I haven't tested this)?:

```<code>const styles = {
    transform: `scale(${x}%`
};

return (
    <element style={styles}></element>
);
</code>```

Where x is your variable being modified by the slider

Body:
How about declaring the scale inline (I haven't tested this)?:

const styles = {
    transform: `scale(${x}%`
};

return (
    <element style={styles}></element>
);

Where x is your variable being modified by the slider


问:
cssSelector vs XPath for selenium
As per my understanding, CSS selector traverses through the DOM. Because CSS files will not have any info about element position then why cssSelector is faster then XPath (theoretically).

Theoretically cssSelector taking less time then XPath as XPath need to traverse through HTML DOM.
XPath we can search elements backward or forward in the DOM hierarchy while CSS works only in a forward direction.

But if cssSelector also traverse through HTML DOM then how it make cssSelector faster.

In other words how cssSelector actually works internally and reason why it always preferable/recommended to use by everyone then xpath

Also please share other benefit of using cssSelector over XPath.

And vice versa in which area XPath are better then cssSelector

答:
I've read a lot of articles and I've seen some like this and this that have data that show that CSS selectors are faster and I've done a little testing and have come to the same conclusion. I talked to Dave Haeffner, author of elementalselenium.com, in Dec 2016 and asked him about the perf numbers on his site (in the post I linked above) since they were pretty old. He linked me a presentation (see pp18-23) where he updated the tests and CSS selectors are still faster but XPath is catching up in a few configs.

So we can see evidence that it's true but I've never seen anyone talk about the technical details of why. If I were to guess, it would be because a lot of work has gone into the different browsers to optimize the speed of page rendering. Having CSS selectors work quickly makes the page render faster and since the browser drivers take advantage of the browser's ability to locate elements, that means CSS selectors generally win. I've read that some browsers have improved their XPath locator speed but I think it will likely always lag behind CSS selectors because it's just much less common than CSS selectors.

Both CSS selectors and XPath have to traverse through the DOM so there's no real difference there other than the speed of the engine that does the traversing. The CSS selector engine is likely a fine tuned machine by this point vs the XPath engine because of the wide spread use of CSS selectors.

My general locator strategy is ID first, CSS selector for everything else. When nothing else works I use XPath. It will vary from site to site but in my experience, IDs are maybe ~10% of my locators. CSS selectors are probably ~80% and the last 10% is XPath. I generally use XPath for when I need to locate an element by the contained text and very rarely DOM traversal. An example of my XPath usage might be I need to find an element in a TABLE relative to a row label, e.g. the price of cheese in a table row where the first cell contains "cheese" and the third cell contains the price.

I think XPath is seen a lot on sites like SO and many blogs because of its easy access. All I have to do is right-click an element in the devtools and Copy XPath. The problem is many times that generates a bad, brittle XPath. A handcrafted XPath is better but it takes time and experience to handcraft a good XPath or CSS selector. Time that many aren't willing to put in. A badly crafted CSS selector or XPath will make things slower also. Many times there are any number of ways that an element could be located, some are way more efficient than others... it comes down to the efficiency of the locator and how you use it. A badly formed CSS selector isn't automatically going to be faster than a well formed XPath,.

ContentLicense: CC BY-SA 4.0

Title: cssSelector vs XPath for selenium


问:
section as default element in haml
when you don't specify the element a div is rendered by default. Is there an easy way to change the default element?

example:

```<code>#someid
  p
    lorem ispum
</code>```

will render

```<code><div id="someid"><p>lorem ipsum<p></div>
</code>```

but in this case, i would like to get

```<code><section id="someid"><p>lorem ipsum<p></section>
</code>```

答:
Negative. That DIV is hardwired into the way HAML is built. You would need to fork the project and change that, which would mean you change all of your divs to sections.

Here is the HAML parser on Github.

Title: section as default element in haml

Body:
when you don't specify the element a div is rendered by default. Is there an easy way to change the default element?

example:

#someid
  p
    lorem ispum

will render

lorem ipsum

but in this case, i would like to get

lorem ipsum


问:
Conditional Probability with binary variables
I have this set:

```<code>    1 2 3 4
r01 1 0 1 1
r02 1 1 0 1
r03 0 0 1 0
r04 0 0 1 0
</code>```

The code:

```<code>initial <- data.frame(c(1,1,0,0), c(0,1,0,0), c(1,0,1,1),c(1,1,0,0), row.names = c("r01","r02","r03","r04"))
colnames(initial) <- c(1:4)
</code>```

I need to get conditional probability, for example if I choose r03 as choosen object probability conditional table with r01 will be:

```<code>          |r03=0 |r03=1
    r01=0 | 1/3  | 0/1
    r01=1 | 2/3  | 1/1
</code>```

Other example, if I choose r03 and evaluate r02:

```<code>          |r03=0 |r03=1
    r02=0 | 0/3  | 1/1
    r02=1 | 3/3  | 0/1
</code>```

I don't know how to implement this table or just get this matrix values.

答:
I think that you are looking for this:

```<code>initial <- data.frame(c(1,1,0,0), c(0,1,0,0), c(1,0,1,1),c(1,1,0,0), row.names = c("r01","r02","r03","r04"))
colnames(initial) <- c(1:4)

tin <- data.frame(matrix(t(initial), ncol = 4, byrow = FALSE))
colnames(tin) <- rownames(initial)

tab <- table(tin$r01, tin$r03) #here specify values and get count
prop.table(tab,2)
</code>```

You also can add some rownames i colnames

EDIT:
Fixed probability and created matrix by columns

Body:
I have this set:

    1 2 3 4
r01 1 0 1 1
r02 1 1 0 1
r03 0 0 1 0
r04 0 0 1 0

The code:

initial <- data.frame(c(1,1,0,0), c(0,1,0,0), c(1,0,1,1),c(1,1,0,0), row.names = c("r01","r02","r03","r04"))
colnames(initial) <- c(1:4)

I need to get conditional probability, for example if I choose r03 as choosen object probability conditional table with r01 will be:

          |r03=0 |r03=1
    r01=0 | 1/3  | 0/1
    r01=1 | 2/3  | 1/1

Other example, if I choose r03 and evaluate r02:

          |r03=0 |r03=1
    r02=0 | 0/3  | 1/1
    r02=1 | 3/3  | 0/1

I don't know how to implement this table or just get this matrix values.

Body:
I think that you are looking for this:

initial <- data.frame(c(1,1,0,0), c(0,1,0,0), c(1,0,1,1),c(1,1,0,0), row.names = c("r01","r02","r03","r04"))
colnames(initial) <- c(1:4)

tin <- data.frame(matrix(t(initial), ncol = 4, byrow = FALSE))
colnames(tin) <- rownames(initial)

tab <- table(tin$r01, tin$r03) #here specify values and get count
prop.table(tab,2)

You also can add some rownames i colnames

EDIT:
Fixed probability and created matrix by columns


问:
How can I print the Students info?
Is there a way I can print my students with the information provided?
I created a service class with all the information about the course, where I wish to input my students info on a very simple way.

student class:

```<code>public class student {

    //Fields
    private static String classNumber = "264";
    private static String className = "Transfiguration";
    private static String instructor = "Professor McGonagall";

    private int studentId;
    private String firstname;
    private String lastname;
    private String address;
    private String city;
    private String state;
    private String email;

    //Getters and setters

    static String getClassNumber(){
        return (classNumber);
    }
    static String getClassName(){
        return (className);
    }
    static String getInstructor(){
        return (instructor);
    }
    static void setClassName(String name){
        className = name;
    }

    int getStudentId(){
        return (studentId);
    }
    String getFirstName(){
        return (firstname);
    }
    String getLastName(){
        return (lastname);
    }
    String getAddress(){
        return (address);
    }
    String getCity(){
        return (city);
    }
    String getState(){
        return (state);
    }
    String getEmail(){
        return (email);
    }
    void setFirstName(String first) {
        this.firstname = first;
    }
    void setLastName(String last) {
        this.lastname = last;
    }
    void setAddress(String rua) {
        this.address = rua;
    }
    void setCity(String cidade) {
        this.city = cidade;
    }
    void setEmail(Sring correio) {
        this.email = correio;
     }
     //Contructors
    student(String la) {
        this.firstname = first;
        this.lastname = last;
        this.studentId += 1000;
    }
    student(String la, int id, String first, String last, String rua, String cidade, String correio) {

        this(la);

        this.address = rua;
        this.city = cidade;
        this.email = correio;

     }

    public String toString() {
        String data = "Course: " + classNumber + " " + className +
                    "\t instructor: " + instructor +
                    "\t Student Number: " + id +
                    "\t Student Name: "  + firstname + " " + lastname +
                    "\t Address: " + rua + cidade +
                    "\t Email: " + correio;
        return (data);
    }

}
</code>```

studentTest class:

```<code>public class studentTest {
    public static void main (String [] args) {

        System.out.println("Course: " + student.getClassNumber() + student.getClassName());

        student a = new student("Kakashi", "Hatake", "W 69th st", "NY", "khsensei@ninja.com");
        student b = new student("Albus", "Dumbledore", "W 116th st", "NY", "princip-al@hogwarts.com" );
        student c = new student("Hyuk", "Jang", "321 Maple St", "NJ", "jh@actors.com");
        student d = new student("Michael", "Jackson", "543 thriller st", "NY", "mj@singer.com");
        student e = new student("Hamilton", "Alexander", "E 86th st", "NY", "justyouwait@broadway.com");

        String fname = a.firstname;
        System.out.println("First Name: " + fname);

        System.out.println(a.toString());
        System.out.println(b);
        System.out.println(c);
        System.out.println(d);
        System.out.println(e);
    }
}
</code>```

What I wish to do is print all the information on their proper place, however I must have forgotten something pretty serious that I'm getting error messages. Are the students info linked properly to the first class?

--

A few of the error messages I get:
"student.java:114: error: class studentTest is public, should be declared in a file named studentTest.java" - for this one, I've tried before and I can put both classes on the same file, why wouldn't be working now?

Some symbols can't be found:

symbol: variable first
location: class student
student.java:83: error: cannot find symbol
             this.lastname = last;

the same also happens with the variables id, last, rua, cidade, and correio.

there's also an error about the constructor
     constructor student.student(String) is no applicable
           (actual and formal argument lists differ in length)
     constructor student.student(String, int, String, String, String, String) is no applicable
student.java:124 error: no suitable constructor found for student (String, String...)

答:
I've added comments to better point out where the errors are that the compiler is complaining about. These are all very common compiler messages so you should take the time to understand what they are referring to and fix them. You will see them over and over again.

```<code>public class student { //class names start with an uppercase letter

//Fields
private static String classNumber = "264";
private static String className = "Transfiguration";
private static String instructor = "Professor McGonagall";

private int studentId;
private String firstname;
private String lastname;
private String address;
private String city;
private String state;
private String email;

//Getters and setters

static String getClassNumber(){
    return (classNumber);
}
static String getClassName(){
    return (className);
}
static String getInstructor(){
    return (instructor);
}
static void setClassName(String name){
    className = name;
}

int getStudentId(){
    return (studentId);
}
String getFirstName(){
    return (firstname);
}
String getLastName(){
    return (lastname);
}
String getAddress(){
    return (address);
}
String getCity(){
    return (city);
}
String getState(){
    return (state);
}
String getEmail(){
    return (email);
}
void setFirstName(String first) {
    this.firstname = first;
}
void setLastName(String last) {
    this.lastname = last;
}
void setAddress(String rua) {
    this.address = rua;
}
void setCity(String cidade) {
    this.city = cidade;
}
void setEmail(Sring correio) { //You misspelled the type of the parameter
    this.email = correio;
 }
 //Contructors
student(String la) {
    this.firstname = first; //The parameter list to this constructor
                            //only contains 'la', 'first' does not exist
    this.lastname = last; //The parameter list to this constructor
                          //only contains 'la', 'last' does not exist
    this.studentId += 1000;
}
student(String la, int id, String first, String last, String rua, String cidade, String correio) {

    this(la);

    this.address = rua;
    this.city = cidade;
    this.email = correio;

 }

public String toString() {
    String data = "Course: " + classNumber + " " + className +
                "\t instructor: " + instructor +
                "\t Student Number: " + id + //id is the parameter in the
                                             //constructor, not the private field name
                "\t Student Name: "  + firstname + " " + lastname +
                "\t Address: " + rua + cidade + //rua and cidade are parameters in the
                                             //constructor, not the private field names
                "\t Email: " + correio; //correio is the parameter in the
                                        //constructor, not the private field name
    return (data);
}

}
</code>```

studentTest class:

```<code>public class studentTest { //classes start with a capital letter and belong in seprate files
public static void main (String [] args) {

    System.out.println("Course: " + student.getClassNumber() + student.getClassName());

    //Student's constructor requires 7 arguments of type String, int, String, String, String, String, String
    student a = new student("Kakashi", "Hatake", "W 69th st", "NY", "khsensei@ninja.com");
    student b = new student("Albus", "Dumbledore", "W 116th st", "NY", "princip-al@hogwarts.com" );
    student c = new student("Hyuk", "Jang", "321 Maple St", "NJ", "jh@actors.com");
    student d = new student("Michael", "Jackson", "543 thriller st", "NY", "mj@singer.com");
    student e = new student("Hamilton", "Alexander", "E 86th st", "NY", "justyouwait@broadway.com");

    String fname = a.firstname; //firstname is a private field
    System.out.println("First Name: " + fname);

    System.out.println(a.toString());
    System.out.println(b);
    System.out.println(c);
    System.out.println(d);
    System.out.println(e);
}
}
</code>```

Title: How can I print the Students info?

Body:
Is there a way I can print my students with the information provided?
I created a service class with all the information about the course, where I wish to input my students info on a very simple way.

student class:

public class student {

    //Fields
    private static String classNumber = "264";
    private static String className = "Transfiguration";
    private static String instructor = "Professor McGonagall";

    private int studentId;
    private String firstname;
    private String lastname;
    private String address;
    private String city;
    private String state;
    private String email;

    //Getters and setters

    static String getClassNumber(){
        return (classNumber);
    }
    static String getClassName(){
        return (className);
    }
    static String getInstructor(){
        return (instructor);
    }
    static void setClassName(String name){
        className = name;
    }

    int getStudentId(){
        return (studentId);
    }
    String getFirstName(){
        return (firstname);
    }
    String getLastName(){
        return (lastname);
    }
    String getAddress(){
        return (address);
    }
    String getCity(){
        return (city);
    }
    String getState(){
        return (state);
    }
    String getEmail(){
        return (email);
    }
    void setFirstName(String first) {
        this.firstname = first;
    }
    void setLastName(String last) {
        this.lastname = last;
    }
    void setAddress(String rua) {
        this.address = rua;
    }
    void setCity(String cidade) {
        this.city = cidade;
    }
    void setEmail(Sring correio) {
        this.email = correio;
     }
     //Contructors
    student(String la) {
        this.firstname = first;
        this.lastname = last;
        this.studentId += 1000;
    }
    student(String la, int id, String first, String last, String rua, String cidade, String correio) {

        this(la);

        this.address = rua;
        this.city = cidade;
        this.email = correio;

     }

    public String toString() {
        String data = "Course: " + classNumber + " " + className +
                    "\t instructor: " + instructor +
                    "\t Student Number: " + id +
                    "\t Student Name: "  + firstname + " " + lastname +
                    "\t Address: " + rua + cidade +
                    "\t Email: " + correio;
        return (data);
    }

}

studentTest class:

public class studentTest {
    public static void main (String [] args) {

        System.out.println("Course: " + student.getClassNumber() + student.getClassName());

        student a = new student("Kakashi", "Hatake", "W 69th st", "NY", "khsensei@ninja.com");
        student b = new student("Albus", "Dumbledore", "W 116th st", "NY", "princip-al@hogwarts.com" );
        student c = new student("Hyuk", "Jang", "321 Maple St", "NJ", "jh@actors.com");
        student d = new student("Michael", "Jackson", "543 thriller st", "NY", "mj@singer.com");
        student e = new student("Hamilton", "Alexander", "E 86th st", "NY", "justyouwait@broadway.com");

        String fname = a.firstname;
        System.out.println("First Name: " + fname);

        System.out.println(a.toString());
        System.out.println(b);
        System.out.println(c);
        System.out.println(d);
        System.out.println(e);
    }
}

What I wish to do is print all the information on their proper place, however I must have forgotten something pretty serious that I'm getting error messages. Are the students info linked properly to the first class?

--

A few of the error messages I get:
"student.java:114: error: class studentTest is public, should be declared in a file named studentTest.java" - for this one, I've tried before and I can put both classes on the same file, why wouldn't be working now?

Some symbols can't be found:

symbol: variable first
location: class student
student.java:83: error: cannot find symbol
             this.lastname = last;

the same also happens with the variables id, last, rua, cidade, and correio.

there's also an error about the constructor
     constructor student.student(String) is no applicable
           (actual and formal argument lists differ in length)
     constructor student.student(String, int, String, String, String, String) is no applicable
student.java:124 error: no suitable constructor found for student (String, String...)

Body:
I've added comments to better point out where the errors are that the compiler is complaining about. These are all very common compiler messages so you should take the time to understand what they are referring to and fix them. You will see them over and over again.

public class student { //class names start with an uppercase letter

//Fields
private static String classNumber = "264";
private static String className = "Transfiguration";
private static String instructor = "Professor McGonagall";

private int studentId;
private String firstname;
private String lastname;
private String address;
private String city;
private String state;
private String email;

//Getters and setters

static String getClassNumber(){
    return (classNumber);
}
static String getClassName(){
    return (className);
}
static String getInstructor(){
    return (instructor);
}
static void setClassName(String name){
    className = name;
}

int getStudentId(){
    return (studentId);
}
String getFirstName(){
    return (firstname);
}
String getLastName(){
    return (lastname);
}
String getAddress(){
    return (address);
}
String getCity(){
    return (city);
}
String getState(){
    return (state);
}
String getEmail(){
    return (email);
}
void setFirstName(String first) {
    this.firstname = first;
}
void setLastName(String last) {
    this.lastname = last;
}
void setAddress(String rua) {
    this.address = rua;
}
void setCity(String cidade) {
    this.city = cidade;
}
void setEmail(Sring correio) { //You misspelled the type of the parameter
    this.email = correio;
 }
 //Contructors
student(String la) {
    this.firstname = first; //The parameter list to this constructor
                            //only contains 'la', 'first' does not exist
    this.lastname = last; //The parameter list to this constructor
                          //only contains 'la', 'last' does not exist
    this.studentId += 1000;
}
student(String la, int id, String first, String last, String rua, String cidade, String correio) {

    this(la);

    this.address = rua;
    this.city = cidade;
    this.email = correio;

 }

public String toString() {
    String data = "Course: " + classNumber + " " + className +
                "\t instructor: " + instructor +
                "\t Student Number: " + id + //id is the parameter in the
                                             //constructor, not the private field name
                "\t Student Name: "  + firstname + " " + lastname +
                "\t Address: " + rua + cidade + //rua and cidade are parameters in the
                                             //constructor, not the private field names
                "\t Email: " + correio; //correio is the parameter in the
                                        //constructor, not the private field name
    return (data);
}

}

studentTest class:

public class studentTest { //classes start with a capital letter and belong in seprate files
public static void main (String [] args) {

    System.out.println("Course: " + student.getClassNumber() + student.getClassName());

    //Student's constructor requires 7 arguments of type String, int, String, String, String, String, String
    student a = new student("Kakashi", "Hatake", "W 69th st", "NY", "khsensei@ninja.com");
    student b = new student("Albus", "Dumbledore", "W 116th st", "NY", "princip-al@hogwarts.com" );
    student c = new student("Hyuk", "Jang", "321 Maple St", "NJ", "jh@actors.com");
    student d = new student("Michael", "Jackson", "543 thriller st", "NY", "mj@singer.com");
    student e = new student("Hamilton", "Alexander", "E 86th st", "NY", "justyouwait@broadway.com");

    String fname = a.firstname; //firstname is a private field
    System.out.println("First Name: " + fname);

    System.out.println(a.toString());
    System.out.println(b);
    System.out.println(c);
    System.out.println(d);
    System.out.println(e);
}
}


问:
PDF/A compatibility processing color gradients in Ghostscript
I have this PDF image which contains color gradients. I want to convert it to a PDF/A with Ghostscript 9.22. My command is

```<code>gs -sDEVICE=pdfwrite -dBATCH -dNOPAUSE -dSAFER -sColorConversionStrategy=UseDeviceIndependentColor -dCompressFonts=true -dEmbedAllFonts=true -dPDFA -dPDFACompatibilityPolicy=1 -dDetectDuplicateImages=true -dFastWebView=true -sOutputFile=$2 $1
</code>```

but I got the following errors when trying to validate the result with PDFBox preflight:

2.4.3 : Invalid Color space, DestOutputProfile is missing

2.4.3 : Invalid Color space, DestOutputProfile is missing

2.4.3 : Invalid Color space, DestOutputProfile is missing

2.4.3 : Invalid Color space, The operator "f" can't be used without Color Profile

I thought I have to tell Ghostscript to use a color profile in the output, so I tried these parameters separately and together

```<code>-sOutputICCProfile=/usr/share/color/icc/CoatedFOGRA39.icc -sProfileOut=/usr/share/color/icc/CoatedFOGRA39.icc -sPostRenderProfile=/usr/share/color/icc/CoatedFOGRA39.icc
</code>```

without luck (I have the profile in that path).

What can I do?

Note: The figure is built with TikZ and is part of a document: I actually would like to have the whole document to be compliant, but it fails just on this figure.

答:
You haven't specified a PDFA_def.ps file. This is a requirement, it is not optional, and you must edit the contents to be correct. You can only specify the DestOutputProfile using the means outlined in the PDFA_def.ps file (basically a bunch of pdfmarks).

The steps are documented here

I'm not certain, but I would not use FastWebView to create a PDF/A file, I'm not sure that linearised files can be PDF/A compliant. Its also more or less pointless anyway.

Body:
I have this PDF image which contains color gradients. I want to convert it to a PDF/A with Ghostscript 9.22. My command is

gs -sDEVICE=pdfwrite -dBATCH -dNOPAUSE -dSAFER -sColorConversionStrategy=UseDeviceIndependentColor -dCompressFonts=true -dEmbedAllFonts=true -dPDFA -dPDFACompatibilityPolicy=1 -dDetectDuplicateImages=true -dFastWebView=true -sOutputFile=$2 $1

but I got the following errors when trying to validate the result with PDFBox preflight:

2.4.3 : Invalid Color space, DestOutputProfile is missing

2.4.3 : Invalid Color space, DestOutputProfile is missing

2.4.3 : Invalid Color space, DestOutputProfile is missing

2.4.3 : Invalid Color space, The operator "f" can't be used without Color Profile

I thought I have to tell Ghostscript to use a color profile in the output, so I tried these parameters separately and together

-sOutputICCProfile=/usr/share/color/icc/CoatedFOGRA39.icc -sProfileOut=/usr/share/color/icc/CoatedFOGRA39.icc -sPostRenderProfile=/usr/share/color/icc/CoatedFOGRA39.icc

without luck (I have the profile in that path).

What can I do?

Note: The figure is built with TikZ and is part of a document: I actually would like to have the whole document to be compliant, but it fails just on this figure.


问:
Eclipse Java Formatter - Newline before closing parentheses
Is it possible to configure the Eclipse Java Formatter to insert a newline before the closing parenthesis of expressions, method declarations, and method calls?

Notice the desired behavior on the lines marked with "XX" below.

=method declaration=

```<code>private static void fun1(
    int param1,
    String param2
){ // XX - notice this is on a new line

}
</code>```

=method call=

```<code>fun1(
    1,
    "param2"
); // XX
</code>```

=expression=

```<code>int a = (
    (
        (
            1 + 2
        )*23 // XX
    ) - 4 // XX
); // XX
</code>```

答:
I was trying to figure this out as well and found that this may help:

Windows" -> "Preferences" -> "Java" -> "Code Style" -> "Formatter" -> "Edit..." -> "Parentheses"

Set "Method Declaration" (beginning of line) to "Separated lines if Wrapped"

Set "Method Invocation" (End of line) to "Separated lines if Wrapped"

Then got to "Line Wrapping" -> "Method Declarations"
Set "Parameters" to "Wrap where Necessary" and "Force Split, Even if line shorter than maximum line width."

Then got to "Line Wrapping" -> "Function Declarations"
Set "Arguments" to "Wrap where Necessary" and "Force Split, Even if line shorter than maximum line width."
Set "Object allocation arguments" to "Wrap where Necessary" and "Force Split, Even if line shorter than maximum line width."

Then got to "Line Wrapping" -> "Expressions"
Set "Binary Expressions" to "Wrap where Necessary", "Force Split, Even if line shorter than maximum line width.", and "Wrap Before Operator"

Hope this works for you. Take care.

Body:
Is it possible to configure the Eclipse Java Formatter to insert a newline before the closing parenthesis of expressions, method declarations, and method calls?

Notice the desired behavior on the lines marked with "XX" below.

=method declaration=

private static void fun1(
    int param1,
    String param2
){ // XX - notice this is on a new line

}

=method call=

fun1(
    1,
    "param2"
); // XX

=expression=

int a = (
    (
        (
            1 + 2
        )*23 // XX
    ) - 4 // XX
); // XX


问:
Task wont run parallel using OpenMP. Is my setup or my code wrong?
I am using OpenMP successful to parallelize for loops in my c++ code. I tried to
step further and use OpenMP tasks. Unfortunately my code behaves
really strange, so i wrote a minimal example and found a problem.
I would like to define a couple of tasks. Each task should be executed once
by an idle thread.
Unfortunately i can only make all threads execute every task or
only one thread performing all tasks sequentially.

Here is my code which basically runs sequentially:

```<code>int main() {
    #pragma omp parallel
    {
        int id, nths;
        id = omp_get_thread_num();
        #pragma omp single nowait
        {
            #pragma omp task
            cout<<"My id is "<<id<<endl;
            #pragma omp task
            cout<<"My id is "<<id<<endl;
            #pragma omp task
            cout<<"My id is "<<id<<endl;
            #pragma omp task
            cout<<"My id is "<<id<<endl;
        }
    }
    return 0;
}
</code>```

Only worker 0 shows up and gives his id four times.
I expected to see "My id is 0; My id is 1; my id is 2; my id is 3;
If i delete #pragma omp single i get 16 messages, all threads execute
every single cout.

Is this a problem with my OpenMP setup or did I not get something about
tasks? I am using gcc 6.3.0 on Ubuntu and use -fopenmp flag properly.

答:
Your basic usage of OpenMP tasks (parallel -> single -> task) is correct, you misunderstand the intricacies of data-sharing attributes for variables.

First, you can easily confirm that your tasks are run by different threads by moving omp_get_thread_num() inside the task instead of accessing id.

What happens in your example, id becomes implicitly private within the parallel construct. However, inside the task, it becomes implicitly firstprivate. This means, the task copies the value from the thread that executes the single construct. A more elaborate discussion of a similar issue can be found here.

Note that if you used private within a nested task construct, it would not be the same private variable as the one of the outside parallel construct. Simply said, private does not refer to the thread, but the construct. That's the difference to threadprivate. However, threadprivate is not an attribute to a construct, but it's own directive and only applies to variables with file-scope, namespace-scope or static variables with block-scope.

Body:
I am using OpenMP successful to parallelize for loops in my c++ code. I tried to
step further and use OpenMP tasks. Unfortunately my code behaves
really strange, so i wrote a minimal example and found a problem.
I would like to define a couple of tasks. Each task should be executed once
by an idle thread.
Unfortunately i can only make all threads execute every task or
only one thread performing all tasks sequentially.

Here is my code which basically runs sequentially:

int main() {
    #pragma omp parallel
    {
        int id, nths;
        id = omp_get_thread_num();
        #pragma omp single nowait
        {
            #pragma omp task
            cout<<"My id is "<<id<<endl;
            #pragma omp task
            cout<<"My id is "<<id<<endl;
            #pragma omp task
            cout<<"My id is "<<id<<endl;
            #pragma omp task
            cout<<"My id is "<<id<<endl;
        }
    }
    return 0;
}

Only worker 0 shows up and gives his id four times.
I expected to see "My id is 0; My id is 1; my id is 2; my id is 3;
If i delete #pragma omp single i get 16 messages, all threads execute
every single cout.

Is this a problem with my OpenMP setup or did I not get something about
tasks? I am using gcc 6.3.0 on Ubuntu and use -fopenmp flag properly.


问:
Why doesn't my function list all the properties of an Array but does on ob?
Here is the code. My function doesn't work on the object Array but does on my object ob defined with an object literal.

function all_properties(object) {
 var value = "[";
 for (var prop in object) {

   value += '"' + prop + '"' + ","
 }
 value = value.slice(0,-1);
 value += "]";
 return value;
}

var ob = {first: 1, second: function () {}, third: function () {}}
console.log(all_properties(ob))
console.log(all_properties(Array))```

答:
Like most built-in objects, the properties of the Array constructor (which is not an array) are marked as non-enumerable, so for in won't see them.

Use Object.getOwnPropertyDescriptors() to see all properties.


问:
Netezza DB Query History
I would like to retrieve all the Netezza queries which was executed in database.In the Netezza GUI, I can able to retrieve only the active queries not the historic one.

I have googled that and nz_query_history database will help us to retrieve the information. But I don't know where to find this system database.

Please help me to find a solution for this.thanks in advance.

答:
There is a (free) tool that enables query history collection. At our site it’s called HISTDB, and it consists of several tables that is being fed by a process that is ‘near realtime’

See here: link to manual on IBM site

Title: Netezza DB Query History