问:
Use a Macro on a list of information. New worksheet needed for each row of information
I'm new to all this Macro thing and haven't used before, so could do with a bit of help.

I've set up a Macro to create a new Quote from a template and list of information. I have a sheet named Summery which includes customer information etc and all of this info is needed to be added to the quote template. I have created a basic Macro and it does the job but I now need it to do the same for each customer listed. At the moment it only runs on the first row.
Please can someone assist in what code I need to use for it to run on the entire list of customers?

```<code>Sub Macro2()
'
' Macro2 Macro
' Create New Quote for each customer
'
' Keyboard Shortcut: Ctrl+q

    Sheets("Master").Select
    Sheets("Master").Copy After:=Sheets(2)
    Range("A13").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-9]C[1]"
    Range("A15").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-11]C[2]"
    Range("E13").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-9]C[-1]"
    Range("E15").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-11]C"
    Range("B19").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-15]C[5]"
    Range("B20").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-16]C[6]"
    Range("B21").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-17]C[7]"
    Range("B22").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-18]C[8]"
    Range("B23").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-19]C[9]"
    Range("B24").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-20]C[10]"
    Range("B25").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-21]C[11]"
    Range("B26").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-22]C[12]"
    Range("B27").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-23]C[13]"
    Range("B28").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-24]C[14]"
    Range("B30").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-26]C[15]"
    Range("B31").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-27]C[16]"
    Range("B32").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-28]C[17]"
    Range("B33").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-29]C[18]"
    Range("B34").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-30]C[19]"
    Range("B35").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-31]C[20]"
    Range("B36").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-32]C[21]"
    Range("B37").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-33]C[22]"
    Range("B38").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-34]C[23]"
    Range("B39").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-35]C[24]"
    Range("A40:D40").Select
    ActiveWindow.SmallScroll Down:=9
    Range("B41").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-37]C[25]"
    Range("B42").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-38]C[26]"
    Range("B43").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-39]C[27]"
    Range("B45").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-41]C[28]"
    Range("B47").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-43]C[29]"
    Range("B48").Select
    ActiveWindow.SmallScroll Down:=-9
    Range("C19").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-15]C[30]"
    Range("C20").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-16]C[31]"
    Range("C21").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-17]C[32]"
    Range("C22").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-18]C[33]"
    Range("C23").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-19]C[34]"
    Range("C24").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-20]C[35]"
    Range("C25").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-21]C[36]"
    Range("C26").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-22]C[37]"
    Range("C27").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-23]C[38]"
    Range("C28").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-24]C[39]"
    Range("C30").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-26]C[40]"
    Range("C31").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-27]C[41]"
    Range("C32").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-28]C[42]"
    Range("C33").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-29]C[43]"
    Range("C34").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-30]C[44]"
    Range("C35").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-31]C[45]"
    Range("C36").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-32]C[46]"
    Range("C37").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-33]C[47]"
    Range("C38").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-34]C[48]"
    Range("C39").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-35]C[49]"
    Range("A40:D40").Select
    ActiveWindow.SmallScroll Down:=15
    Range("C41").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-37]C[50]"
    Range("C42").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-38]C[51]"
    Range("C43").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-39]C[52]"
    Range("C45").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-41]C[53]"
    Range("C47").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-43]C[54]"
    Range("C48").Select
    ActiveSheet.Name = Range("A13").Value

End Sub
</code>```

Thanks

答:
You requirement is very much unclear and we don't even know how your 'Summery' sheet looks like (Perhaps a typo there). So I am writing this piece of code to give you an idea of how you can achieve this. Just change the references to the 'summery' sheet according to your requirement or make them dynamic.</p>

```<code>Sub do_random()
last_row = ThisWorkbook.Worksheets("Summery").Cells(1, 1).End(xlDown).Row

For i = 1 To last_row

   Sheets("Master").Select
   Sheets("Master").Copy After:=Sheets(2)
   Range("A13").Select
   ActiveCell.FormulaR1C1 = "=Summery!R[-9]C[1]"
   Range("A15").Select
   ActiveCell.FormulaR1C1 = "=Summery!R[-11]C[2]"
   Range("E13").Select
   ActiveCell.FormulaR1C1 = "=Summery!R[-9]C[-1]"
   ....
   'Do what ever you want in here.

Next i
End Sub
</code>```

Body:
I'm new to all this Macro thing and haven't used before, so could do with a bit of help.

I've set up a Macro to create a new Quote from a template and list of information. I have a sheet named Summery which includes customer information etc and all of this info is needed to be added to the quote template. I have created a basic Macro and it does the job but I now need it to do the same for each customer listed. At the moment it only runs on the first row.
Please can someone assist in what code I need to use for it to run on the entire list of customers?

Sub Macro2()
'
' Macro2 Macro
' Create New Quote for each customer
'
' Keyboard Shortcut: Ctrl+q

    Sheets("Master").Select
    Sheets("Master").Copy After:=Sheets(2)
    Range("A13").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-9]C[1]"
    Range("A15").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-11]C[2]"
    Range("E13").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-9]C[-1]"
    Range("E15").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-11]C"
    Range("B19").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-15]C[5]"
    Range("B20").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-16]C[6]"
    Range("B21").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-17]C[7]"
    Range("B22").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-18]C[8]"
    Range("B23").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-19]C[9]"
    Range("B24").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-20]C[10]"
    Range("B25").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-21]C[11]"
    Range("B26").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-22]C[12]"
    Range("B27").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-23]C[13]"
    Range("B28").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-24]C[14]"
    Range("B30").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-26]C[15]"
    Range("B31").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-27]C[16]"
    Range("B32").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-28]C[17]"
    Range("B33").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-29]C[18]"
    Range("B34").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-30]C[19]"
    Range("B35").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-31]C[20]"
    Range("B36").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-32]C[21]"
    Range("B37").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-33]C[22]"
    Range("B38").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-34]C[23]"
    Range("B39").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-35]C[24]"
    Range("A40:D40").Select
    ActiveWindow.SmallScroll Down:=9
    Range("B41").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-37]C[25]"
    Range("B42").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-38]C[26]"
    Range("B43").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-39]C[27]"
    Range("B45").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-41]C[28]"
    Range("B47").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-43]C[29]"
    Range("B48").Select
    ActiveWindow.SmallScroll Down:=-9
    Range("C19").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-15]C[30]"
    Range("C20").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-16]C[31]"
    Range("C21").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-17]C[32]"
    Range("C22").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-18]C[33]"
    Range("C23").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-19]C[34]"
    Range("C24").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-20]C[35]"
    Range("C25").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-21]C[36]"
    Range("C26").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-22]C[37]"
    Range("C27").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-23]C[38]"
    Range("C28").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-24]C[39]"
    Range("C30").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-26]C[40]"
    Range("C31").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-27]C[41]"
    Range("C32").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-28]C[42]"
    Range("C33").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-29]C[43]"
    Range("C34").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-30]C[44]"
    Range("C35").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-31]C[45]"
    Range("C36").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-32]C[46]"
    Range("C37").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-33]C[47]"
    Range("C38").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-34]C[48]"
    Range("C39").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-35]C[49]"
    Range("A40:D40").Select
    ActiveWindow.SmallScroll Down:=15
    Range("C41").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-37]C[50]"
    Range("C42").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-38]C[51]"
    Range("C43").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-39]C[52]"
    Range("C45").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-41]C[53]"
    Range("C47").Select
    ActiveCell.FormulaR1C1 = "=Summery!R[-43]C[54]"
    Range("C48").Select
    ActiveSheet.Name = Range("A13").Value

End Sub

Thanks

Body:
You requirement is very much unclear and we don't even know how your 'Summery' sheet looks like (Perhaps a typo there). So I am writing this piece of code to give you an idea of how you can achieve this. Just change the references to the 'summery' sheet according to your requirement or make them dynamic.

Sub do_random()
last_row = ThisWorkbook.Worksheets("Summery").Cells(1, 1).End(xlDown).Row

For i = 1 To last_row

   Sheets("Master").Select
   Sheets("Master").Copy After:=Sheets(2)
   Range("A13").Select
   ActiveCell.FormulaR1C1 = "=Summery!R[-9]C[1]"
   Range("A15").Select
   ActiveCell.FormulaR1C1 = "=Summery!R[-11]C[2]"
   Range("E13").Select
   ActiveCell.FormulaR1C1 = "=Summery!R[-9]C[-1]"
   ....
   'Do what ever you want in here.

Next i
End Sub


来源: stackexchange

问:
Python - Palindrome function: Receiving error "list indices must be integers or slices, not str"
I've been trying to use the following code to create a palindrome. I have a txt file named 'lowercasewords' which is essentially a list full of words in lowercase where I am querying from and I want to append words that are spelled the same reversed into a list named 'lines2'.

The code is below:

```<code>def palindrome():
    lines = open('lowercasewords.txt','r').read().splitlines()
    lines2 = []
    for x in lines:
        if (lines[x]) == (lines[x][::-1]) is True:
            lines2.append(str(x))
        else:
            pass
    print(lines2)
</code>```

However, I receive the error:

```<code>TypeError: list indices must be integers or slices, not str
</code>```

Can anyone help??? I can show that the word 'level' is the same reversed:

```<code>str(lines[106102]) == str(lines[106102][::-1])
True
</code>```

答:
When you run for x in lines: then x is set to the current word in the list. Your code is then trying to get the index of that word in lines. This is the equivalent of saying lines["hello"], which doesn't make any sense. The loop is already setting x to the value you want so you do not need to refer to lines any more.

You also do not need to check if something is True, the if statement is already testing for a statement being True or false.

You can fix it by simply replacing

```<code>if (lines[x]) == (lines[x][::-1]) is True:
</code>```

with

```<code>if x == x[::-1]:
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I've been trying to use the following code to create a palindrome. I have a txt file named 'lowercasewords' which is essentially a list full of words in lowercase where I am querying from and I want to append words that are spelled the same reversed into a list named 'lines2'.

The code is below:

def palindrome():
    lines = open('lowercasewords.txt','r').read().splitlines()
    lines2 = []
    for x in lines:
        if (lines[x]) == (lines[x][::-1]) is True:
            lines2.append(str(x))
        else:
            pass
    print(lines2)

However, I receive the error:

TypeError: list indices must be integers or slices, not str

Can anyone help??? I can show that the word 'level' is the same reversed:

str(lines[106102]) == str(lines[106102][::-1])
True

Body:
When you run for x in lines: then x is set to the current word in the list. Your code is then trying to get the index of that word in lines. This is the equivalent of saying lines["hello"], which doesn't make any sense. The loop is already setting x to the value you want so you do not need to refer to lines any more.

You also do not need to check if something is True, the if statement is already testing for a statement being True or false.

You can fix it by simply replacing

if (lines[x]) == (lines[x][::-1]) is True:

with

if x == x[::-1]:


问:
java -update database by editing cells not working?
I'm having trouble updating data from the database by editing / changing cell values and clicking on the update button, but he can not change the database that I changed to the cell. it's still the same into the last value. </p>

<p>here is my code: </p>

```<code>    public void directlyup() {
       int col=tablesample.getSelectedColumn();
       int row=tablesample.getSelectedRow();
       int index;
       index = Integer.parseInt(tablesample.getModel().getValueAt(row, 0).toString());
        try {
            String sql ="UPDATE invoice SET description = ?,qty = ?,unitprice = ?"
                    + ",total = ? WHERE id ="+row;
            pst = conn.prepareStatement(sql);
            pst.setString(1, (String) tablesample.getValueAt(row, 1));
            pst.setString(2, (String) tablesample.getValueAt(row, 2));
            pst.setString(3, (String) tablesample.getValueAt(row, 3));
            pst.setString(4, (String) tablesample.getValueAt(row, 4));
            pst.execute();
            JOptionPane.showMessageDialog(null, "Successfully Updated");
        } catch (Exception e) {
         JOptionPane.showMessageDialog(null, e);
        }
    }
</code>```

答:
It may be that you intended to use index instead of row in the WHERE clause?</p>

```<code>String sql ="UPDATE invoice SET description = ?,qty = ?,unitprice = ?"
                + ",total = ? WHERE id ="+index;
</code>```

Body:
I'm having trouble updating data from the database by editing / changing cell values and clicking on the update button, but he can not change the database that I changed to the cell. it's still the same into the last value.

here is my code:

    public void directlyup() {
       int col=tablesample.getSelectedColumn();
       int row=tablesample.getSelectedRow();
       int index;
       index = Integer.parseInt(tablesample.getModel().getValueAt(row, 0).toString());
        try {
            String sql ="UPDATE invoice SET description = ?,qty = ?,unitprice = ?"
                    + ",total = ? WHERE id ="+row;
            pst = conn.prepareStatement(sql);
            pst.setString(1, (String) tablesample.getValueAt(row, 1));
            pst.setString(2, (String) tablesample.getValueAt(row, 2));
            pst.setString(3, (String) tablesample.getValueAt(row, 3));
            pst.setString(4, (String) tablesample.getValueAt(row, 4));
            pst.execute();
            JOptionPane.showMessageDialog(null, "Successfully Updated");
        } catch (Exception e) {
         JOptionPane.showMessageDialog(null, e);
        }
    }

Body:
It may be that you intended to use index instead of row in the WHERE clause?

String sql ="UPDATE invoice SET description = ?,qty = ?,unitprice = ?"
                + ",total = ? WHERE id ="+index;


问:
Rails materialize-sass form with autocomplete and cocoon gem nested resource
I am using materialize-sass gem on a form. Using autocomplete feature to get Vendor names. other fields on the form are item names and quantity which are a nested resource. For this I am using cocoon gem

For some reason the very first time the page loads, all seems to work fine. But adding more fields does not seem to be working. I tried using drop down select and that does not show the list of items. I replaced it with another autocomplete and the main field does show however the auto complete feature does not work. Any idea what may be wrong?

Please see my code below.

purchase_orders _forms.html.erb

 <%= simple_form_for(@purchase_order) do |f| %>
 <%= f.error_notification %>

   <%= f.input :vendor_name, input_html: { class: 'vendor_name autocomplete' } %>

Item List

    <%= f.simple_fields_for :purchase_order_details do |purchase_order_detail| %>
    <%= render 'purchase_order_detail_fields', :f => purchase_order_detail %>

     <%= link_to_add_association 'Add More', f, :purchase_order_details %>

    <% end %>

 <%= f.button :submit %>
 <% end %>

```
</div>
</div>
</p>

<p>_purchase_order_detail_fields.html.erb
<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><div class="nested-fields">
 <div class="row">
  <div class="col l6">
   <%#= f.input(:item_id, collection: Ingredient.is_active, label_method: :title, value_method: :id) %>
   <%= f.input :item_name, input_html: { class: 'item_name autocomplete' } %>
  </div>
  <div class="col l5">
   <%= f.input :item_quantity %>
  </div>
  <div class="col l1">
   <%= link_to_remove_association "delete", f, :class => "material-icons teal-text text-lighten-1" %>
  </div>
  <%#= f.hidden_field :item_type , :value=> params[:category_id] %>
 </div>
</div></code>```

答:
Checking out the demo-project they use, and more specifically the init.js they use I notice two things: if you are using turbolinks you will have to do the same, and when using cocoon you will have to do something like: </p>

```<code>$('form').on('cocoon:before-insert', function(e, insertedItem) {
  $(insertedItem).find('select').material_select();
})
</code>```

Body:
I am using materialize-sass gem on a form. Using autocomplete feature to get Vendor names. other fields on the form are item names and quantity which are a nested resource. For this I am using cocoon gem

For some reason the very first time the page loads, all seems to work fine. But adding more fields does not seem to be working. I tried using drop down select and that does not show the list of items. I replaced it with another autocomplete and the main field does show however the auto complete feature does not work. Any idea what may be wrong?

Please see my code below.

purchase_orders _forms.html.erb

 <%= simple_form_for(@purchase_order) do |f| %>
 <%= f.error_notification %>

   <%= f.input :vendor_name, input_html: { class: 'vendor_name autocomplete' } %>

Item List

    <%= f.simple_fields_for :purchase_order_details do |purchase_order_detail| %>
    <%= render 'purchase_order_detail_fields', :f => purchase_order_detail %>

     <%= link_to_add_association 'Add More', f, :purchase_order_details %>

    <% end %>

 <%= f.button :submit %>
 <% end %>

_purchase_order_detail_fields.html.erb

   <%#= f.input(:item_id, collection: Ingredient.is_active, label_method: :title, value_method: :id) %>
   <%= f.input :item_name, input_html: { class: 'item_name autocomplete' } %>

   <%= f.input :item_quantity %>

   <%= link_to_remove_association "delete", f, :class => "material-icons teal-text text-lighten-1" %>

  <%#= f.hidden_field :item_type , :value=> params[:category_id] %>

Body:
Checking out the demo-project they use, and more specifically the init.js they use I notice two things: if you are using turbolinks you will have to do the same, and when using cocoon you will have to do something like:

$('form').on('cocoon:before-insert', function(e, insertedItem) {
  $(insertedItem).find('select').material_select();
})


问:
how to count up variables in java
my problem is the following: I want to set all panes white, just like this:

```<code>    paneVfeld1.setStyle("-fx-background-color: white");
    paneVfeld2.setStyle("-fx-background-color: white");
    paneVfeld3.setStyle("-fx-background-color: white");
    paneVfeld4.setStyle("-fx-background-color: white");
    paneVfeld5.setStyle("-fx-background-color: white");
    paneVfeld6.setStyle("-fx-background-color: white");
    paneVfeld7.setStyle("-fx-background-color: white");
    paneVfeld8.setStyle("-fx-background-color: white");
    paneVfeld9.setStyle("-fx-background-color: white");
    paneVfeld10.setStyle("-fx-background-color: white");
</code>```

But i seriously can´t do this for all my 42 panes, how can i shorten that, with an Array?, anything else?, thx for the help :)

答:
```<code>formatFields(String style, Pane... panes) {
 for (Pane pane : panes) {
 if (pane!=null) {
  pane.setStyle(style);
}
}
}
</code>```

and then call:

formatFields("-fx-background-color: white", field1, field2, field3, field4);

Title: how to count up variables in java

Body:
my problem is the following: I want to set all panes white, just like this:

    paneVfeld1.setStyle("-fx-background-color: white");
    paneVfeld2.setStyle("-fx-background-color: white");
    paneVfeld3.setStyle("-fx-background-color: white");
    paneVfeld4.setStyle("-fx-background-color: white");
    paneVfeld5.setStyle("-fx-background-color: white");
    paneVfeld6.setStyle("-fx-background-color: white");
    paneVfeld7.setStyle("-fx-background-color: white");
    paneVfeld8.setStyle("-fx-background-color: white");
    paneVfeld9.setStyle("-fx-background-color: white");
    paneVfeld10.setStyle("-fx-background-color: white");

But i seriously can´t do this for all my 42 panes, how can i shorten that, with an Array?, anything else?, thx for the help :)

Body:
formatFields(String style, Pane... panes) {
 for (Pane pane : panes) {
 if (pane!=null) {
  pane.setStyle(style);
}
}
}

and then call:

formatFields("-fx-background-color: white", field1, field2, field3, field4);


问:
Opening a named pipe in low integrity level
I'm working on an application which is made of two modules. These modules communicate through named pipes in the following environment:

Windows 7 Home Premium x64

Visual Studio 2008

C# / .Net 3.5

The server runs with administrator rights (high integrity level). The client runs in low integrity level. So that the client can connect to the server, I need to create the pipe in low integrity level. I manage to do this only when the server runs in medium integrity level.

I tested the following setups :

server : high, client : low => access refused

server : high, client : medium => access refused

server : high, client : high => OK

server : medium, client : low => OK

server : medium, client : medium => OK

server : low, client : low => OK

Setup #4 shows that the named pipe gets created with different integrity level than the one of the process, which is good. However, the setup I am interested in is the first one.

I have a sample which makes it easy to test. If the connection is successful, the clients writes "Connected" and the server writes "Received connection". If the connection fails, the client writes "Failed" and the server stays on "Waiting".

Here is how I execute the client program (for the server, simply replace NamePipeClient with NamedPipeServer):

medium integrity level:

open the command prompt

icacls NamedPipeClient.exe /setintegritylevel Medium

NamedPipeClient.exe

low integrity level:

open the command prompt

icacls NamedPipeClient.exe /setintegritylevel Low

NamedPipeClient.exe

high integrity level:

open the command prompt in admin mode

icacls NamedPipeClient.exe /setintegritylevel High

NamedPipeClient.exe

Any help will be greatly appreciated!

Server code

Program.cs

```<code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Win32.SafeHandles;
using System.IO.Pipes;

namespace NamedPipeServer
{
    class Program
    {
        static void Main(string[] args)
        {
            SafePipeHandle handle = LowIntegrityPipeFactory.CreateLowIntegrityNamedPipe("NamedPipe/Test");
            NamedPipeServerStream pipeServer = new NamedPipeServerStream(PipeDirection.InOut, true, false, handle);
            pipeServer.BeginWaitForConnection(HandleConnection, pipeServer);

            Console.WriteLine("Waiting...");
            Console.ReadLine();
        }

        private static void HandleConnection(IAsyncResult ar)
        {
            Console.WriteLine("Received connection");
        }
    }
}
</code>```

LowIntegrityPipeFactory.cs

```<code>using System;
using Microsoft.Win32.SafeHandles;
using System.Runtime.InteropServices;
using System.IO.Pipes;
using System.ComponentModel;
using System.IO;
using System.Security.Principal;
using System.Security.AccessControl;

namespace NamedPipeServer
{
    static class LowIntegrityPipeFactory
    {
        [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        private static extern SafePipeHandle CreateNamedPipe(string pipeName, int openMode,
            int pipeMode, int maxInstances, int outBufferSize, int inBufferSize, int defaultTimeout,
            SECURITY_ATTRIBUTES securityAttributes);

        [DllImport("Advapi32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = false)]
        private static extern bool ConvertStringSecurityDescriptorToSecurityDescriptor(
            [In] string StringSecurityDescriptor,
            [In] uint StringSDRevision,
            [Out] out IntPtr SecurityDescriptor,
            [Out] out int SecurityDescriptorSize
        );

        [StructLayout(LayoutKind.Sequential)]
        private struct SECURITY_ATTRIBUTES
        {
            public int nLength;
            public IntPtr lpSecurityDescriptor;
            public int bInheritHandle;
        }

        private const string LOW_INTEGRITY_SSL_SACL = "S:(ML;;NW;;;LW)";

        public static SafePipeHandle CreateLowIntegrityNamedPipe(string pipeName)
        {
            // convert the security descriptor
            IntPtr securityDescriptorPtr = IntPtr.Zero;
            int securityDescriptorSize = 0;
            bool result = ConvertStringSecurityDescriptorToSecurityDescriptor(
                LOW_INTEGRITY_SSL_SACL, 1, out securityDescriptorPtr, out securityDescriptorSize);
            if (!result)
                throw new Win32Exception(Marshal.GetLastWin32Error());

            SECURITY_ATTRIBUTES securityAttributes = new SECURITY_ATTRIBUTES();
            securityAttributes.nLength = Marshal.SizeOf(securityAttributes);
            securityAttributes.bInheritHandle = 1;
            securityAttributes.lpSecurityDescriptor = securityDescriptorPtr;

            SafePipeHandle handle = CreateNamedPipe(@"\\.\pipe\" + pipeName,
                PipeDirection.InOut, 100, PipeTransmissionMode.Byte, PipeOptions.Asynchronous,
                0, 0, PipeAccessRights.ReadWrite, securityAttributes);
            if (handle.IsInvalid)
                throw new Win32Exception(Marshal.GetLastWin32Error());

            return handle;
        }

        private static SafePipeHandle CreateNamedPipe(string fullPipeName, PipeDirection direction,
            int maxNumberOfServerInstances, PipeTransmissionMode transmissionMode, PipeOptions options,
            int inBufferSize, int outBufferSize, PipeAccessRights rights, SECURITY_ATTRIBUTES secAttrs)
        {
            int openMode = (int)direction | (int)options;
            int pipeMode = 0;
            if (maxNumberOfServerInstances == -1)
                maxNumberOfServerInstances = 0xff;

            SafePipeHandle handle = CreateNamedPipe(fullPipeName, openMode, pipeMode,
                maxNumberOfServerInstances, outBufferSize, inBufferSize, 0, secAttrs);
            if (handle.IsInvalid)
                throw new Win32Exception(Marshal.GetLastWin32Error());
            return handle;
        }

    }
}
</code>```

Client code

Program.cs

```<code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO.Pipes;

namespace NamedPipeClient
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                var pipeClient = new NamedPipeClientStream(".", "NamedPipe/Test",
                    PipeDirection.InOut,
                    PipeOptions.None);
                pipeClient.Connect(100);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Failed: " + ex);
                return;
            }

            Console.WriteLine("Connected");
            Console.ReadLine();
        }
    }
}
</code>```

答:
The answer I posted in December does work, despite the anonymous drive-by voting down which someone indulged themselves in. (At least, it does on Vista SP2 and I don't think there are any differences between Vista and Windows 7 which would affect this issue).

Here is a different approach which also works, specifying the DACL within the SDDL string used inside the pipe factory class:

Change the line in the CreateLowIntegrityNamedPipe(string pipeName) method which calls ConvertStringSecurityDescriptorToSecurityDescriptor, thus:

```<code>bool result = ConvertStringSecurityDescriptorToSecurityDescriptor(
     CreateSddlForPipeSecurity(), 1, out securityDescriptorPtr,
     out securityDescriptorSize);
</code>```

and provide an additional private static method, something like:

```<code>    private static string CreateSddlForPipeSecurity()
    {
        const string LOW_INTEGRITY_LABEL_SACL = "S:(ML;;NW;;;LW)";
        const string EVERYONE_CLIENT_ACE = "(A;;0x12019b;;;WD)";
        const string CALLER_ACE_TEMPLATE = "(A;;0x12019f;;;{0})";

        StringBuilder sb = new StringBuilder();
        sb.Append(LOW_INTEGRITY_LABEL_SACL);
        sb.Append("D:");
        sb.Append(EVERYONE_CLIENT_ACE);
        sb.AppendFormat(CALLER_ACE_TEMPLATE, WindowsIdentity.GetCurrent().Owner.Value);
        return sb.ToString();
    }
</code>```

My version sets the pipe access to allow any authenticated user to be a pipe client. You could add additional features to the pipe factory class to specify a list of allowed client SIDs or such like.

Body:
I'm working on an application which is made of two modules. These modules communicate through named pipes in the following environment:

Windows 7 Home Premium x64

Visual Studio 2008

C# / .Net 3.5

The server runs with administrator rights (high integrity level). The client runs in low integrity level. So that the client can connect to the server, I need to create the pipe in low integrity level. I manage to do this only when the server runs in medium integrity level.

I tested the following setups :

server : high, client : low => access refused

server : high, client : medium => access refused

server : high, client : high => OK

server : medium, client : low => OK

server : medium, client : medium => OK

server : low, client : low => OK

Setup #4 shows that the named pipe gets created with different integrity level than the one of the process, which is good. However, the setup I am interested in is the first one.

I have a sample which makes it easy to test. If the connection is successful, the clients writes "Connected" and the server writes "Received connection". If the connection fails, the client writes "Failed" and the server stays on "Waiting".

Here is how I execute the client program (for the server, simply replace NamePipeClient with NamedPipeServer):

medium integrity level:

open the command prompt

icacls NamedPipeClient.exe /setintegritylevel Medium

NamedPipeClient.exe

low integrity level:

open the command prompt

icacls NamedPipeClient.exe /setintegritylevel Low

NamedPipeClient.exe

high integrity level:

open the command prompt in admin mode

icacls NamedPipeClient.exe /setintegritylevel High

NamedPipeClient.exe

Any help will be greatly appreciated!

Server code

Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Win32.SafeHandles;
using System.IO.Pipes;

namespace NamedPipeServer
{
    class Program
    {
        static void Main(string[] args)
        {
            SafePipeHandle handle = LowIntegrityPipeFactory.CreateLowIntegrityNamedPipe("NamedPipe/Test");
            NamedPipeServerStream pipeServer = new NamedPipeServerStream(PipeDirection.InOut, true, false, handle);
            pipeServer.BeginWaitForConnection(HandleConnection, pipeServer);

            Console.WriteLine("Waiting...");
            Console.ReadLine();
        }

        private static void HandleConnection(IAsyncResult ar)
        {
            Console.WriteLine("Received connection");
        }
    }
}

LowIntegrityPipeFactory.cs

using System;
using Microsoft.Win32.SafeHandles;
using System.Runtime.InteropServices;
using System.IO.Pipes;
using System.ComponentModel;
using System.IO;
using System.Security.Principal;
using System.Security.AccessControl;

namespace NamedPipeServer
{
    static class LowIntegrityPipeFactory
    {
        [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        private static extern SafePipeHandle CreateNamedPipe(string pipeName, int openMode,
            int pipeMode, int maxInstances, int outBufferSize, int inBufferSize, int defaultTimeout,
            SECURITY_ATTRIBUTES securityAttributes);

        [DllImport("Advapi32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = false)]
        private static extern bool ConvertStringSecurityDescriptorToSecurityDescriptor(
            [In] string StringSecurityDescriptor,
            [In] uint StringSDRevision,
            [Out] out IntPtr SecurityDescriptor,
            [Out] out int SecurityDescriptorSize
        );

        [StructLayout(LayoutKind.Sequential)]
        private struct SECURITY_ATTRIBUTES
        {
            public int nLength;
            public IntPtr lpSecurityDescriptor;
            public int bInheritHandle;
        }

        private const string LOW_INTEGRITY_SSL_SACL = "S:(ML;;NW;;;LW)";

        public static SafePipeHandle CreateLowIntegrityNamedPipe(string pipeName)
        {
            // convert the security descriptor
            IntPtr securityDescriptorPtr = IntPtr.Zero;
            int securityDescriptorSize = 0;
            bool result = ConvertStringSecurityDescriptorToSecurityDescriptor(
                LOW_INTEGRITY_SSL_SACL, 1, out securityDescriptorPtr, out securityDescriptorSize);
            if (!result)
                throw new Win32Exception(Marshal.GetLastWin32Error());

            SECURITY_ATTRIBUTES securityAttributes = new SECURITY_ATTRIBUTES();
            securityAttributes.nLength = Marshal.SizeOf(securityAttributes);
            securityAttributes.bInheritHandle = 1;
            securityAttributes.lpSecurityDescriptor = securityDescriptorPtr;

            SafePipeHandle handle = CreateNamedPipe(@"\\.\pipe\" + pipeName,
                PipeDirection.InOut, 100, PipeTransmissionMode.Byte, PipeOptions.Asynchronous,
                0, 0, PipeAccessRights.ReadWrite, securityAttributes);
            if (handle.IsInvalid)
                throw new Win32Exception(Marshal.GetLastWin32Error());

            return handle;
        }

        private static SafePipeHandle CreateNamedPipe(string fullPipeName, PipeDirection direction,
            int maxNumberOfServerInstances, PipeTransmissionMode transmissionMode, PipeOptions options,
            int inBufferSize, int outBufferSize, PipeAccessRights rights, SECURITY_ATTRIBUTES secAttrs)
        {
            int openMode = (int)direction | (int)options;
            int pipeMode = 0;
            if (maxNumberOfServerInstances == -1)
                maxNumberOfServerInstances = 0xff;

            SafePipeHandle handle = CreateNamedPipe(fullPipeName, openMode, pipeMode,
                maxNumberOfServerInstances, outBufferSize, inBufferSize, 0, secAttrs);
            if (handle.IsInvalid)
                throw new Win32Exception(Marshal.GetLastWin32Error());
            return handle;
        }

    }
}

Client code

Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO.Pipes;

namespace NamedPipeClient
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                var pipeClient = new NamedPipeClientStream(".", "NamedPipe/Test",
                    PipeDirection.InOut,
                    PipeOptions.None);
                pipeClient.Connect(100);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Failed: " + ex);
                return;
            }

            Console.WriteLine("Connected");
            Console.ReadLine();
        }
    }
}

Body:
The answer I posted in December does work, despite the anonymous drive-by voting down which someone indulged themselves in. (At least, it does on Vista SP2 and I don't think there are any differences between Vista and Windows 7 which would affect this issue).

Here is a different approach which also works, specifying the DACL within the SDDL string used inside the pipe factory class:

Change the line in the CreateLowIntegrityNamedPipe(string pipeName) method which calls ConvertStringSecurityDescriptorToSecurityDescriptor, thus:

bool result = ConvertStringSecurityDescriptorToSecurityDescriptor(
     CreateSddlForPipeSecurity(), 1, out securityDescriptorPtr,
     out securityDescriptorSize);

and provide an additional private static method, something like:

    private static string CreateSddlForPipeSecurity()
    {
        const string LOW_INTEGRITY_LABEL_SACL = "S:(ML;;NW;;;LW)";
        const string EVERYONE_CLIENT_ACE = "(A;;0x12019b;;;WD)";
        const string CALLER_ACE_TEMPLATE = "(A;;0x12019f;;;{0})";

        StringBuilder sb = new StringBuilder();
        sb.Append(LOW_INTEGRITY_LABEL_SACL);
        sb.Append("D:");
        sb.Append(EVERYONE_CLIENT_ACE);
        sb.AppendFormat(CALLER_ACE_TEMPLATE, WindowsIdentity.GetCurrent().Owner.Value);
        return sb.ToString();
    }

My version sets the pipe access to allow any authenticated user to be a pipe client. You could add additional features to the pipe factory class to specify a list of allowed client SIDs or such like.

ContentLicense: CC BY-SA 2.5


问:
l10n in Angular: Custom Numbers
I'm working on an Arabic site and I need to support arabic locale for showing numbers. I tried using the arabic angular locale file but it does not entail changing the number from EN to AR.

For example, the number 120 in EN is ١٢٠ in AR. Is there way to get this angular? (and then do calculations).

Demo

答:
In case someone else is also looking into this now (2017), calling toLocaleString on a number object should return the number string in the given locale.

```<code>let numbers = 1234567890;
console.log(numbers.toLocaleString('ar-EN'));
</code>```

will log

```<code>١٬٢٣٤٬٥٦٧٬٨٩٠
</code>```

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString

Title: l10n in Angular: Custom Numbers

Body:
In case someone else is also looking into this now (2017), calling toLocaleString on a number object should return the number string in the given locale.

let numbers = 1234567890;
console.log(numbers.toLocaleString('ar-EN'));

will log

١٬٢٣٤٬٥٦٧٬٨٩٠

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString

ContentLicense: CC BY-SA 4.0


问:
Javascript - How to have a variable that combined a letter and a number call another variable
I am currently making a STEM Math Game. I made a function call onLoad() that gets 20 different random numbers that do not repeat and set them as variables. Now I'm trying to take that number and add Q to the front of it because I have different variables named Q1, Q2, etc. But when I try to console.log the variable X that combined the two all it displays is Q1 instead of the string in the variable Q1. Any help will be appreciated!

//Questions - Answers
var Q1 = "5 x 107 = ?";
//var A1 = "A: 50,000,000";
var A1 = "<button id='answerButton' type='button' class='reg'>A: 50,000,000</button> <button id='answerButton' type='button' class='reg'>B: 0.0000005</button>

<button id='answerButton' type='button' class='reg'>C: 5,000,000</button><button id='answerButton' type='button' class='reg'>D: 500,000</button>";
var Q2 = "3.868 x 109 = ?";
var A2 = "B: 3,868,000,000";
var Q3 = "What is the answer for 20000000 × 3.5 × 1000000 in scientific notation?";
var A3 = "A: 7 × 1013";
var Q4 = "123,000 = ?";
var A4 = "B: 1.23 x 105";
var Q5 = "0.00123 x 105 = ?";
var A5 = "A: 12.3 x 101";
var Q6 = "0.0686 x 100 = ?";
var A6 = "C: 0.0686";
var Q7 = "2.26 x 105 = ?";
var A7 = "B: 226,000";
var Q8 = "0.0002395 = ?";
var A8 = "C: 2.395 x 10-4";
var Q9 = "731,000 = ?";
var A9 = "A: 7.31 x 105";
var Q10 = "0.00018 = ?";
var A10 = "B: 1.8 x 10-4";

var Q11 = "2x = 54";
var A11 = "D: x = 27";
var Q12 = "x = 81";
var A12 = "A: x = 81";
var Q13 = "4x+8=7.2+5x";
var A13 = "C: x = 0.800";
var Q14 = "4(0.5f−0.25)=6+f";
var A14 = "C: f = 7";
var Q15 = "2+6g=11−3g";
var A15 = "B: g = 1";
var Q16 = "−11f=7(1−2f)+5";
var A16 = "A: f = 4";
var Q17 = "0.5s+1=7+4.5s";
var A17 = "B: s = -1.5";
var Q18 = "2(x+3) = 16";
var A18 = "D: x = 5";
var Q19 = "21+3j = 6";
var A19 = "C: j = -5";
var Q20 = "4(x-1) = -16";
var A20 = "A: x = -3";

var Q21 = "A company charges a flat fee of 1500 dollars to rent a yacht. In addition, renters must pay 100 dollars per hour. Which equation shows the cost C to rent a yacht for h hours?";
var A21 = "C: C = 100h + 1500";
var Q22 = "What is the equation of a line that has a slope of 3/5 and a y-intercept of 2?";
var A22 = "A: 5y - 3x = 10";
var Q23 = "Make an equation for sixteen more than a number is 9.";
var A23 = "C: 16 + x = 9";
var Q24 = "There are b boys in the class.  This is three more than four times the number of girls. How many girls are in the class?";
var A24 = "B: b = 3 + 4g";
var Q25 = "The sum of two numbers is 84, and one of them is 12 more than the other. What is the equation?";
var A25 = "D: x + 12 + x = 84";
var Q26 = "Anton's birthday party costs $2 for every guest he invites. Write an equation that shows the relationship between the guests x and the cost y.";
var A26 = "A: y = 2x";
var Q27 = "Allie jars 6 liters of jam every day. Write an equation that shows the relationship between the days x and the jam made y.";
var A27 = "C: y = 6x";
var Q28 = "Gabe can grow 8 flowers with every seed packet. Write an equation that shows the relationship between the number of seed packets x and the total number of flowers y.";
var A28 = "B: y = 8x";
var Q29 = "Bella's retirement party costs $6, plus an additional $1 for each guest she invites. Write an equation that shows the relationship between the guests x and the cost y.";
var A29 = "C: y = x + 6";
var Q30 = "Cole has already taken 4 pictures at home, and he expects to take 1 picture during every day of vacation. Write an equation that shows the relationship between the days of vacation x and the total number of pictures taken y.";
var A30 = "C: y = x + 4";

//Question Numbers
var N1 = Math.floor(Math.random() * 30) + 1;
var N2 = 0;
var N3 = 0;
var N4 = 0;
var N5 = 0;
var N6 = 0;
var N7 = 0;
var N8 = 0;
var N9 = 0;
var N10 = 0;
var N11 = 0;
var N12 = 0;
var N13 = 0;
var N14 = 0;
var N15 = 0;
var N16 = 0;
var N17 = 0;
var N18 = 0;
var N19 = 0;
var N20 = 0;

//On Game Load
function onLoad() {
 do {
  N2 = Math.floor(Math.random() * 30) + 1;
 } while(N2 === N1);

 do {
  N3 = Math.floor(Math.random() * 30) + 1;
 } while(N3 === N1 || N3 === N2);

 do {
  N4 = Math.floor(Math.random() * 30) + 1;
 } while(N4 === N1 || N4 === N2 || N4 === N3);

 do {
  N5 = Math.floor(Math.random() * 30) + 1;
 } while(N5 === N1 || N5 === N2 || N5 === N3 || N5 === N4);

 do {
  N6 = Math.floor(Math.random() * 30) + 1;
 } while(N6 === N1 || N6 === N2 || N6 === N3 || N6 === N4 || N6 === N5);

 do {
  N7 = Math.floor(Math.random() * 30) + 1;
 } while(N7 === N1 || N7 === N2 || N7 === N3 || N7 === N4 || N7 === N5 || N7 === N6);

 do {
  N8 = Math.floor(Math.random() * 30) + 1;
 } while(N8 === N1 || N8 === N2 || N8 === N3 || N8 === N4 || N8 === N5 || N8 === N6 || N8 === N7);

 do {
  N9 = Math.floor(Math.random() * 30) + 1;
 } while(N9 === N1 || N9 === N2 || N9 === N3 || N9 === N4 || N9 === N5 || N9 === N6 || N9 === N7 || N9 === N8);

 do {
  N10 = Math.floor(Math.random() * 30) + 1;
 } while(N10 === N1 || N10 === N2 || N10 === N3 || N10 === N4 || N10 === N5 || N10 === N6 || N10 === N7 || N10 === N8 || N10 === N9);

 do {
  N11 = Math.floor(Math.random() * 30) + 1;
 } while(N11 === N1 || N11 === N2 || N11 === N3 || N11 === N4 || N11 === N5 || N11 === N6 || N11 === N7 || N11 === N8 || N11 === N9 || N11 === N10);

 do {
  N12 = Math.floor(Math.random() * 30) + 1;
 } while(N12 === N1 || N12 === N2 || N12 === N3 || N12 === N4 || N12 === N5 || N12 === N6 || N12 === N7 || N12 === N8 || N12 === N9 || N12 === N10 || N12 === N11);

 do {
  N13 = Math.floor(Math.random() * 30) + 1;
 } while(N13 === N1 || N13 === N2 || N13 === N3 || N13 === N4 || N13 === N5 || N13 === N6 || N13 === N7 || N13 === N8 || N13 === N9 || N13 === N10 || N13 === N11 || N13 === N12);

 do {
  N14 = Math.floor(Math.random() * 30) + 1;
 } while(N14 === N1 || N14 === N2 || N14 === N3 || N14 === N4 || N14 === N5 || N14 === N6 || N14 === N7 || N14 === N8 || N14 === N9 || N14 === N10 || N14 === N11 || N14 === N12 || N14 === N13);

 do {
  N15 = Math.floor(Math.random() * 30) + 1;
 } while(N15 === N1 || N15 === N2 || N15 === N3 || N15 === N4 || N15 === N5 || N15 === N6 || N15 === N7 || N15 === N8 || N15 === N9 || N15 === N10 || N15 === N11 || N15 === N12 || N15 === N13 || N15 === N14);

 do {
  N16 = Math.floor(Math.random() * 30) + 1;
 } while(N16 === N1 || N16 === N2 || N16 === N3 || N16 === N4 || N16 === N5 || N16 === N6 || N16 === N7 || N16 === N8 || N16 === N9 || N16 === N10 || N16 === N11 || N16 === N12 || N16 === N13 || N16 === N14 || N16 === N15);

 do {
  N17 = Math.floor(Math.random() * 30) + 1;
 } while(N17 === N1 || N17 === N2 || N17 === N3 || N17 === N4 || N17 === N5 || N17 === N6 || N17 === N7 || N17 === N8 || N17 === N9 || N17 === N10 || N17 === N11 || N17 === N12 || N17 === N13 || N17 === N14 || N17 === N15 || N17 === N16);

 do {
  N18 = Math.floor(Math.random() * 30) + 1;
 } while(N18 === N1 || N18 === N2 || N18 === N3 || N18 === N4 || N18 === N5 || N18 === N6 || N18 === N7 || N18 === N8 || N18 === N9 || N18 === N10 || N18 === N11 || N18 === N12 || N18 === N13 || N18 === N14 || N18 === N15 || N18 === N16 || N18 === N17);

 do {
  N19 = Math.floor(Math.random() * 30) + 1;
 } while(N19 === N1 || N19 === N2 || N19 === N3 || N19 === N4 || N19 === N5 || N19 === N6 || N19 === N7 || N19 === N8 || N19 === N9 || N19 === N10 || N19 === N11 || N19 === N12 || N19 === N13 || N19 === N14 || N19 === N15 || N19 === N16 || N19 === N17 || N19 === N18);

 do {
  N20 = Math.floor(Math.random() * 30) + 1;
 } while(N20 === N1 || N20 === N2 || N20 === N3 || N20 === N4 || N20 === N5 || N20 === N6 || N20 === N7 || N20 === N8 || N20 === N9 || N20 === N10 || N20 === N11 || N20 === N12 || N20 === N13 || N20 === N14 || N20 === N15 || N20 === N16 || N20 === N17 || N20 === N18 || N20 === N19);

 questions();
}

function questions() {
 var Q = "Q";

 var x1 = Q.concat(N1);
 //var x1 = Q + N1;
 var y1 = document.getElementById("Q1");
 y1.innerHTML = x1;
 var z1 = document.getElementById("1").getElementsByClassName("answers");
 z1.innerHTML = A1;

 console.log(x1);
}```

答: You can use window object in JavaScript. Try replacing console.log(x1); by console.log(window[x1]);


问:
Build python-mysqlclient against mariadb-connector-c
I am trying to compile python-mysqlclient against mariadb-connector-c in a Conda environment.  That means that the install prefix is not /usr/local but, for example, $HOME/conda/envs/test.  I also want to use the auth_gssapi_client.so plugin.

Both packages build, but import MySQLdb raises the following exception:

```<code>Traceback (most recent call last):
  File "/opt/emsconda/conda-bld/env/test_tmp/run_test.py", line 2, in <module>
    import MySQLdb
  File "/opt/emsconda/conda-bld/env/lib/python3.6/site-packages/MySQLdb/__init__.py", line 19, in <module>
    import _mysql
ImportError: libmariadb.so.3: cannot open shared object file: No such file or directory
</code>```

The reason for this is that mysqlclient only searches lib/ but not
lib/mariadb even though it was configured with the right path and sucessfully
built.  I can work around this issue by copying the *.so files to lib/ (or
by creating a symlink), but then, it does not find the GSSAPI plugisn …

I build mariadb-connector-c 3.0.2 this way:

mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=$PREFIX -DCMAKE_BUILD_TYPE=Release ..
make
make install
```

<p>I can install it and run <code>mariadb_config</code> which gives this output:</p>

<pre class="lang-bash prettyprint-override"><code>Copyright 2011-2015 MariaDB Corporation AB
Get compiler flags for using the MariaDB Connector/C.
Usage: /opt/emsconda/conda-bld/mysqlclient_1510048680472/_h_env/bin/mariadb_config [OPTIONS]
  --cflags        [-I/opt/emsconda/conda-bld/env/include/mariadb -I/opt/emsconda/conda-bld/env/include/mariadb/mysql]
  --include       [-I/opt/emsconda/conda-bld/env/include/mariadb -I/opt/emsconda/conda-bld/env/include/mariadb/mysql]
  --libs          [-L/opt/emsconda/conda-bld/env/lib/mariadb/ -lmariadb -lpthread -ldl -lm -lssl -lcrypto]
  --libs_r        [-L/opt/emsconda/conda-bld/env/lib/mariadb/ -lmariadb -lpthread -ldl -lm -lssl -lcrypto]
  --libs_sys      [-lpthread -ldl -lm -lssl -lcrypto]
  --version       [10.2.6]
  --socket        [/tmp/mysql.sock]
  --port          [3306]
  --plugindir     [/opt/emsconda/conda-bld/env/lib/mariadb/plugin]
  --tlsinfo       [OpenSSL 1.0.2k]
</code>```

I then build python-mysqlclient 1.3.12 this way:

MYSQL_CONFIG="$PREFIX/bin/mariadb_config"
echo "mysql_config = $PREFIX/bin/mariadb_config" >> site.cfg
$PYTHON -m pip install -I --no-deps .
```

There are two possible solutions for this problem:

Configure mariadb-connector-c to directly put its stuff into lib/ – I have not found documentation on how to do this.

Make python-mysqlclient respect the paths that mariadb_config returns – How?

答:
You have to statically link the gssapi stuff into mariadb-connector-c and Python mysqlclient will work.

This is how to build mariadb-connector-c:

```<code>mkdir build
cd build

cmake \
    -DCMAKE_INSTALL_PREFIX=$PREFIX \
    -DINSTALL_LIBDIR=lib \
    -DINSTALL_PLUGINDIR=lib/plugin \
    -DWITH_MYSQLCOMPAT=ON \
    -DAUTH_GSSAPI=STATIC \
    -DCMAKE_BUILD_TYPE=Release \
    ..

make
make install

# WITH_MYSQLCOMPAT only creates links for the libs, not for the binary:
cd $PREFIX/bin
ln -s mariadb_config mysql_config
</code>```

Body:
I am trying to compile python-mysqlclient against mariadb-connector-c in a Conda environment.  That means that the install prefix is not /usr/local but, for example, $HOME/conda/envs/test.  I also want to use the auth_gssapi_client.so plugin.

Both packages build, but import MySQLdb raises the following exception:

Traceback (most recent call last):
  File "/opt/emsconda/conda-bld/env/test_tmp/run_test.py", line 2, in <module>
    import MySQLdb
  File "/opt/emsconda/conda-bld/env/lib/python3.6/site-packages/MySQLdb/__init__.py", line 19, in <module>
    import _mysql
ImportError: libmariadb.so.3: cannot open shared object file: No such file or directory

The reason for this is that mysqlclient only searches lib/ but not
lib/mariadb even though it was configured with the right path and sucessfully
built.  I can work around this issue by copying the *.so files to lib/ (or
by creating a symlink), but then, it does not find the GSSAPI plugisn …

I build mariadb-connector-c 3.0.2 this way:

mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=$PREFIX -DCMAKE_BUILD_TYPE=Release ..
make
make install

I can install it and run mariadb_config which gives this output:

Copyright 2011-2015 MariaDB Corporation AB
Get compiler flags for using the MariaDB Connector/C.
Usage: /opt/emsconda/conda-bld/mysqlclient_1510048680472/_h_env/bin/mariadb_config [OPTIONS]
  --cflags        [-I/opt/emsconda/conda-bld/env/include/mariadb -I/opt/emsconda/conda-bld/env/include/mariadb/mysql]
  --include       [-I/opt/emsconda/conda-bld/env/include/mariadb -I/opt/emsconda/conda-bld/env/include/mariadb/mysql]
  --libs          [-L/opt/emsconda/conda-bld/env/lib/mariadb/ -lmariadb -lpthread -ldl -lm -lssl -lcrypto]
  --libs_r        [-L/opt/emsconda/conda-bld/env/lib/mariadb/ -lmariadb -lpthread -ldl -lm -lssl -lcrypto]
  --libs_sys      [-lpthread -ldl -lm -lssl -lcrypto]
  --version       [10.2.6]
  --socket        [/tmp/mysql.sock]
  --port          [3306]
  --plugindir     [/opt/emsconda/conda-bld/env/lib/mariadb/plugin]
  --tlsinfo       [OpenSSL 1.0.2k]

I then build python-mysqlclient 1.3.12 this way:

MYSQL_CONFIG="$PREFIX/bin/mariadb_config"
echo "mysql_config = $PREFIX/bin/mariadb_config" >> site.cfg
$PYTHON -m pip install -I --no-deps .

There are two possible solutions for this problem:

Configure mariadb-connector-c to directly put its stuff into lib/ – I have not found documentation on how to do this.

Make python-mysqlclient respect the paths that mariadb_config returns – How?

Body:
You have to statically link the gssapi stuff into mariadb-connector-c and Python mysqlclient will work.

This is how to build mariadb-connector-c:

mkdir build
cd build

cmake \
    -DCMAKE_INSTALL_PREFIX=$PREFIX \
    -DINSTALL_LIBDIR=lib \
    -DINSTALL_PLUGINDIR=lib/plugin \
    -DWITH_MYSQLCOMPAT=ON \
    -DAUTH_GSSAPI=STATIC \
    -DCMAKE_BUILD_TYPE=Release \
    ..

make
make install

# WITH_MYSQLCOMPAT only creates links for the libs, not for the binary:
cd $PREFIX/bin
ln -s mariadb_config mysql_config


问:
Moment JS start and end of given month
I need to calculate a JS date given year=2014 and month=9 (September 2014).

I tried this:

```<code>var moment = require('moment');
var startDate = moment( year+'-'+month+'-'+01 + ' 00:00:00' );
            var endDate = startDate.endOf('month');
            console.log(startDate.toDate());
            console.log(endDate.toDate());
</code>```

Both of logs show:

```<code>Tue Sep 30 2014 23:59:59 GMT+0200 (CEST)
Tue Sep 30 2014 23:59:59 GMT+0200 (CEST)
</code>```

End date is correct but... why the start date is not?

答:
you can use this directly for the end or start date of the month

```<code>new moment().startOf('month').format("YYYY-DD-MM");
new moment().endOf("month").format("YYYY-DD-MM");
</code>```

you can change the format by defining a new format

Title: Moment JS start and end of given month

Body:
I need to calculate a JS date given year=2014 and month=9 (September 2014).

I tried this:

var moment = require('moment');
var startDate = moment( year+'-'+month+'-'+01 + ' 00:00:00' );
            var endDate = startDate.endOf('month');
            console.log(startDate.toDate());
            console.log(endDate.toDate());

Both of logs show:

Tue Sep 30 2014 23:59:59 GMT+0200 (CEST)
Tue Sep 30 2014 23:59:59 GMT+0200 (CEST)

End date is correct but... why the start date is not?

Body:
you can use this directly for the end or start date of the month

new moment().startOf('month').format("YYYY-DD-MM");
new moment().endOf("month").format("YYYY-DD-MM");

you can change the format by defining a new format


问:
How to tell what triggered jQuery focus()?
I have an input field and a button. It is necessary that when the button is clicked the input field gets focus.

I need the behaviour to be slightly different depending on whether the input field was focused manually by the user or if it was focused due the button being clicked.

It seems this would be relatively simple, but I couldn't come up with a solution so far. Any ideas very welcome.

```<code>$("button").click(function() {
    target_input = $("input");
    target_input.focus();
});

$("input").focus(function() {
    // if focus done manually by user
    //    do something
    // if focus done via button
    //    do something else
});
</code>```

答:
This works without global variables and it is cross-browser working solution:

$('button').click(function () {
  $(this).prev('input').focus()
})

$('input').click(function (e) { // yes, listen to click instead
   // original event exists only if input was clicked directly
  if (e.originalEvent) {
    console.log('manually triggered')
  }
})```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div style="background-color: yellow;">
  <input type="text">
  <button>Focus input</button>
  <br>
  <input type="text">
  <button>Focus input</button>
</div>

<script src="https://unpkg.com/jquery"></script></code>```

Body:
I have an input field and a button. It is necessary that when the button is clicked the input field gets focus.

I need the behaviour to be slightly different depending on whether the input field was focused manually by the user or if it was focused due the button being clicked.

It seems this would be relatively simple, but I couldn't come up with a solution so far. Any ideas very welcome.

$("button").click(function() {
    target_input = $("input");
    target_input.focus();
});

$("input").focus(function() {
    // if focus done manually by user
    //    do something
    // if focus done via button
    //    do something else
});

Body:
This works without global variables and it is cross-browser working solution:

$('button').click(function () {
  $(this).prev('input').focus()
})

$('input').click(function (e) { // yes, listen to click instead
   // original event exists only if input was clicked directly
  if (e.originalEvent) {
    console.log('manually triggered')
  }
})

<div style="background-color: yellow;">
  <input type="text">
  <button>Focus input</button>
  <br>
  <input type="text">
  <button>Focus input</button>
</div>

<script src="https://unpkg.com/jquery"></script>


问:
Javascript to get data from Weather Underground "history" API
I have problems to get data from Weather Underground from a historical day (same script works fine for my current observations). Example for yesterday:

```<code><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script>

heute=new Date();
jahr=heute.getFullYear();
monat=heute.getMonth()+1;
tag = heute.getDate()-1;

jQuery(document).ready(function($) {
  $.ajax({
  url : "http://api.wunderground.com/api/ea1cb0c0f1995212/history_'+jahr+monat+tag+'/q/pws:INORDRHE156.json",
  dataType : "jsonp",
  success : function(parsed_json) {

 var minhumidity = parsed_json.history.dailysummary[0].minhumidity;
 var day = parsed_json.history.dailysummary[0].date.pretty;
 document.getElementById("z8").innerHTML = minhumidity;
 document.getElementById("z9").innerHTML = date;

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

So "day" works for me, output is: November 13, 2017

But "minhumidity" should bei '90' (or some other value), but there will be just a blank.

I get both values (day and minhumidity) at the same way, where is the Problem?

Sorry for my english.

答:
your url "http://api.wunderground.com/api/ea1cb0c0f1995212/history_'+jahr+monat+tag+'/q/pws:INORDRHE156.json" change it to (note that i changed ' with "):

```<code><script>

heute=new Date();
jahr=heute.getFullYear();
monat=heute.getMonth()+1;
tag = heute.getDate()-1;

jQuery(document).ready(function($) {
  $.ajax({
  url : "http://api.wunderground.com/api/ea1cb0c0f1995212/history_"+jahr+monat+tag+"/q/pws:INORDRHE156.json",
  dataType : "jsonp",
  success : function(parsed_json) {

 var minhumidity = parsed_json.history.dailysummary[0].minhumidity;
 var day = parsed_json.history.dailysummary[0].date.pretty;
 document.getElementById("z8").innerHTML = minhumidity;
 document.getElementById("z9").innerHTML = date;

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

And please add var, let, const whatever to your variables. For example:

```<code>var heute = new Date();
var jahr = heute.getFullYear();
var monat = heute.getMonth()+1;
var tag = heute.getDate()-1;
</code>```

Body:
I have problems to get data from Weather Underground from a historical day (same script works fine for my current observations). Example for yesterday:

So "day" works for me, output is: November 13, 2017

But "minhumidity" should bei '90' (or some other value), but there will be just a blank.

I get both values (day and minhumidity) at the same way, where is the Problem?

Sorry for my english.

Body:
your url "http://api.wunderground.com/api/ea1cb0c0f1995212/history_'+jahr+monat+tag+'/q/pws:INORDRHE156.json" change it to (note that i changed ' with "):

<script>

heute=new Date();
jahr=heute.getFullYear();
monat=heute.getMonth()+1;
tag = heute.getDate()-1;

jQuery(document).ready(function($) {
  $.ajax({
  url : "http://api.wunderground.com/api/ea1cb0c0f1995212/history_"+jahr+monat+tag+"/q/pws:INORDRHE156.json",
  dataType : "jsonp",
  success : function(parsed_json) {

 var minhumidity = parsed_json.history.dailysummary[0].minhumidity;
 var day = parsed_json.history.dailysummary[0].date.pretty;
 document.getElementById("z8").innerHTML = minhumidity;
 document.getElementById("z9").innerHTML = date;

  }
  });
});
</script>

And please add var, let, const whatever to your variables. For example:

var heute = new Date();
var jahr = heute.getFullYear();
var monat = heute.getMonth()+1;
var tag = heute.getDate()-1;


问:
Format output in python
I have the following function which transforms list of numbers:

```<code>import numpy as np
from math import *

def walsh_transform(x):
    if len(x) > 3:
        n = len(x)
        m = trunc(log(n, 2))
        x = x[0:2 ** m]
        h2 = [[1, 1], [1, -1]]
        for i in range(m - 1):
            if i == 0:
                h = np.kron(h2, h2)
            else:
                h = np.kron(h, h2)

        return np.dot(h, x) / 2. ** m

arr = [1.0, 1.0, 1.0, 2.0, 0.0, 0.0, 0.0, 0.0]

print(walsh_transform(arr))
</code>```

It returns output [ 0.625 -0.125 -0.125  0.125  0.625 -0.125 -0.125  0.125]

How can I make it return output [0.625, -0.125, -0.125,  0.125,  0.625, -0.125, -0.125,  0.125] ? I.e. comma-separated values?

Title: Format output in python

Body:
I have the following function which transforms list of numbers:

import numpy as np
from math import *

def walsh_transform(x):
    if len(x) > 3:
        n = len(x)
        m = trunc(log(n, 2))
        x = x[0:2 ** m]
        h2 = [[1, 1], [1, -1]]
        for i in range(m - 1):
            if i == 0:
                h = np.kron(h2, h2)
            else:
                h = np.kron(h, h2)

        return np.dot(h, x) / 2. ** m

arr = [1.0, 1.0, 1.0, 2.0, 0.0, 0.0, 0.0, 0.0]

print(walsh_transform(arr))

It returns output [ 0.625 -0.125 -0.125  0.125  0.625 -0.125 -0.125  0.125]

How can I make it return output [0.625, -0.125, -0.125,  0.125,  0.625, -0.125, -0.125,  0.125] ? I.e. comma-separated values?

Body:
You can convert the resultant array to list to get a output as you wanted.

w = walsh_transform(arr) # w = [ 0.625 -0.125 -0.125  0.125  0.625 -0.125 -0.125  0.125]

print(list(w)) # output = [0.625, -0.125, -0.125, 0.125, 0.625, -0.125, -0.125, 0.125]


问:
Asp.net JavaScript OnClick not working
What I'm trying to do is, when I click on the button it should show an alert box.
Here is the code.

```<code>protected void btnAdd_Click(object sender, EventArgs e)
{
    string script = "<script type=\"text/javascript\">alert('abc 1');
    </script>";
    ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert 1",
    script);
    Response.Redirect("~/Index.aspx");

}
</code>```

It is working perfectly but when I put this same code in another page it does not work.

what are the things I have to look into? any suggestion please?

答:
May be you can try this - syntax may be wrong - </p>

```<code>  protected void btnAdd_Click(object sender, EventArgs e)
{
    Response.Redirect("~/Index.aspx?Issuccess=1");

}

index.aspx page -

protected void Page_Load()
{
     if(Request.QueryString["Issuccess"] != null && Convert.ToInt32(Request.QueryString["Issuccess"]) == 1)
     {
            string script = "<script type=\"text/javascript\">alert('abc 1');
            </script>";
            ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert 1",
            script);
     }
}
</code>```

Title: Asp.net JavaScript OnClick not working

Body:
What I'm trying to do is, when I click on the button it should show an alert box.
Here is the code.

protected void btnAdd_Click(object sender, EventArgs e)
{
    string script = "";
    ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert 1",
    script);
    Response.Redirect("~/Index.aspx");

}

It is working perfectly but when I put this same code in another page it does not work.

what are the things I have to look into? any suggestion please?

Body:
May be you can try this - syntax may be wrong -

  protected void btnAdd_Click(object sender, EventArgs e)
{
    Response.Redirect("~/Index.aspx?Issuccess=1");

}

index.aspx page -

protected void Page_Load()
{
     if(Request.QueryString["Issuccess"] != null && Convert.ToInt32(Request.QueryString["Issuccess"]) == 1)
     {
            string script = "<script type=\"text/javascript\">alert('abc 1');
            </script>";
            ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert 1",
            script);
     }
}


问:
How to use two database reference in Firebase Cloud Functions?
I'm using Firebase cloud Functions to Trigger Notifications and Can we use onWrite() on two database references. If possible how to accomplish?</p>

答:
Cloud Functions for Firebase lets you automatically run backend code in response to events triggered by Firebase features and HTTPS requests but a single cloud function can only respond to changes that happens also at a single location at a time.

If you have more that one node that you want to be triggered, you need to write separate (different) functions for each node that can work similarly.


问:
How to use Message security and UserName clientCredentialType without Certificate in WCF Service?
i have a WCF service with wsHttpBinding which my clients are my windows application and my website. both those clients are consumer of the my service. in the my service, i used a Message security and UserName clientCredentialType for clients authentication. i do not want use any certificate for this authentication. how do i? or you suggest to me other solution for this sake?</p>

答:
thanks  for your example. i used your example but i received this error:

The Scheme cannot be computed for this binding because this CustomBinding lacks a TransportBindingElement.  Every binding must have at least one binding element that derives from TransportBindingElement.

and other my question: for this solution i use from which project type in VS2010? a WCF Service Library in project or a WCF Service website. which one?

thank you for your answers.


问:
Why Oracle 11g XE listener stops working?
I have recently installed Oracle 11G XE on CentOS 7. For some reason the listener is stop working after it is initiated. I'm logging in to server with the user used to install the DB instance. To run the lsnrctl command I need to change to a user named oracle and load the environmental variables every time I change to this user, using the command . ./dbenv.sh.

This is the result when I execute lsnrctl start:

```<code>LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 08-NOV-2017 14:48:35

Copyright (c) 1991, 2011, Oracle.  All rights reserved.

Starting /u01/app/oracle/product/11.2.0/xe/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.2.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/xe/network/admin/listener.ora

Log messages written to /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC_FOR_XE)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.16.1.100)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC_FOR_XE)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.2.0 - Production
Start Date                08-NOV-2017 14:48:37
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Default Service           XE
Listener Parameter File   /u01/app/oracle/product/11.2.0/xe/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC_FOR_XE)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.16.1.100)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
</code>```

When I execute the command lsnrctl status after a few seconds this is whats shown:

```<code>LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 08-NOV-2017 14:49:13

Copyright (c) 1991, 2011, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC_FOR_XE)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 111: Connection refused
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=172.16.1.100)(PORT=1521)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 111: Connection refused
</code>```

My listener.ora file contained this:

```<code># listener.ora Network Configuration File:

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/xe)
  (PROGRAM = extproc)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.100)(PORT = 1521))
    )
  )
</code>```

答: Thank you guys, we solved the Windows issue, the solution was to update the Oracle Driver, everything is working now.</p>

Body:
I have recently installed Oracle 11G XE on CentOS 7. For some reason the listener is stop working after it is initiated. I'm logging in to server with the user used to install the DB instance. To run the lsnrctl command I need to change to a user named oracle and load the environmental variables every time I change to this user, using the command . ./dbenv.sh.

This is the result when I execute lsnrctl start:

LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 08-NOV-2017 14:48:35

Copyright (c) 1991, 2011, Oracle.  All rights reserved.

Starting /u01/app/oracle/product/11.2.0/xe/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.2.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/xe/network/admin/listener.ora

Log messages written to /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC_FOR_XE)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.16.1.100)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC_FOR_XE)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.2.0 - Production
Start Date                08-NOV-2017 14:48:37
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Default Service           XE
Listener Parameter File   /u01/app/oracle/product/11.2.0/xe/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC_FOR_XE)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.16.1.100)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

When I execute the command lsnrctl status after a few seconds this is whats shown:

LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 08-NOV-2017 14:49:13

Copyright (c) 1991, 2011, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC_FOR_XE)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 111: Connection refused
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=172.16.1.100)(PORT=1521)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 111: Connection refused

My listener.ora file contained this:

# listener.ora Network Configuration File:

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/xe)
  (PROGRAM = extproc)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.100)(PORT = 1521))
    )
  )


问:
What role do QEMU and KVM play in virtual machine I/O?
I find the boundary between QEMU and KVM very blurred. I find that someone says a virtual machine is a qemu process while others say a kvm process. What is it exactly?
And what role does QEMU and KVM plays in virtual machine I/O? For example, when a vm does PIO/MMIO, is it qemu or kvm that will trap it and turns it to hardware operation. Or both are responsible?</p>

答:
KVM: the code in the Linux kernel which provides a friendly interface to userspace for using the CPU virtualization. This includes functions that userspace can call for "create CPU", "run CPU", etc. For a full virtual machine, you need to have some userspace code which can use this. This is usually either QEMU, or the simpler "kvmtool"; some large cloud providers have their own custom userspace code instead.

QEMU: emulates a virtual piece of hardware, including disks, memory, CPUs, serial port, graphics, and other devices. Also provides mechanisms (a UI, and some programmable interfaces) for doing things like starting, stopping, and migrating. QEMU supports several different 'accelerator' modes for how it handles the CPU emulation:

TCG: pure emulation -- works anywhere, but very slow

KVM: uses the Linux kernel's KVM APIs to allow running guest code using host CPU hardware virtualization support

hax: similar to KVM, but using the Intel HAXM code, which will work on Windows hosts

From an implementation point of view the boundary between KVM and QEMU is very clear -- KVM is a part of the host kernel, whereas QEMU is a separate userspace program. For a user, you typically don't have to care where the boundary is, because that's an implementation detail.

To answer your question about what happens for MMIO:

the guest makes an MMIO access

this is trapped to the host kernel by the hardware

the host kernel (KVM) might then emulate this MMIO access itself, because a few devices are implemented in the kernel for performance reasons. This usually applies only to the interrupt controller and perhaps the iommu.

otherwise, KVM reports the MMIO access back to userspace (ie to QEMU, kvmtool, etc)

userspace then can handle the access, using its device emulation code

userspace then returns the result (eg the data to return for a read) to the kernel

the kernel updates the vcpu's register state as required to complete emulation of the instruction

the kernel then resumes execution of the VM at the following instruction


问:
Using progressbar in a simple file manipulation program?
How do I use a progress bar in a file modification program where the progress bar is increased every time when a file is processed and when all files are processed it reaches full value i.e. 100
I tried something like

```<code>string files=Directory.GetFiles(path,"*.txt",SearchOption.AllDirectories);
foreach (var file in files) {
                    progressBar1.Value=progressBar1.Value+100/(files.Length);
                     //Do some modification
}
MessageBox.Show("Done");
</code>```

But even after all files are processed the value of progress bar is still not full, what am I doing wrong?

答:
You need to set the ProgressBar.Maximum property to match the number of files, and then increment the value by 1 for each iteration of the loop:

```<code>var files = Directory.GetFiles(path,"*.txt",SearchOption.AllDirectories);

progressBar1.Maximum = files.Length;

foreach (var file in files) {
    progressBar1.Value = progressBar1.Value+1;
    //Do some modification
}

MessageBox.Show("Done");
</code>```

Body:
How do I use a progress bar in a file modification program where the progress bar is increased every time when a file is processed and when all files are processed it reaches full value i.e. 100
I tried something like

string files=Directory.GetFiles(path,"*.txt",SearchOption.AllDirectories);
foreach (var file in files) {
                    progressBar1.Value=progressBar1.Value+100/(files.Length);
                     //Do some modification
}
MessageBox.Show("Done");

But even after all files are processed the value of progress bar is still not full, what am I doing wrong?

Body:
You need to set the ProgressBar.Maximum property to match the number of files, and then increment the value by 1 for each iteration of the loop:

var files = Directory.GetFiles(path,"*.txt",SearchOption.AllDirectories);

progressBar1.Maximum = files.Length;

foreach (var file in files) {
    progressBar1.Value = progressBar1.Value+1;
    //Do some modification
}

MessageBox.Show("Done");


问:
Docker - php_network_getaddresses error when trying to connect to DB
Setting up a new Laravel install using docker, this is the docker-compose.yml file:

```<code>version: '2'

services:
web:
    image: nginx
    restart: always
    links:
        - "fpm"
    volumes:
        - ./build/volumes/nginx/conf.d:/etc/nginx/conf.d:ro
    volumes_from:
        - fpm
    ports:
        - 8080:80

mysql:
    image: mysql
    environment:
        MYSQL_ROOT_PASSWORD: "[OMMITTED]"
        MYSQL_DATABASE: "[OMMITTED]"
        MYSQL_USER: "[OMMITTED]"
        MYSQL_PASSWORD: "[OMMITTED]"

fpm:
    build:
        context: .
    volumes:
        - .:/var/www
</code>```

docker-compose up -d  works fine and I can see the web sever at http://localhost:8080/ , however when trying to do any type of connection to the database, I get a PDO::__construct(): php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known error message.

My .env file contains the following ( the DB_HOST is the container name ):

```<code>DB_CONNECTION=mysql
DB_HOST=container_mysql_1
DB_PORT=3306
DB_DATABASE=[OMMITTED]
DB_USERNAME=[OMMITTED]
DB_PASSWORD=[OMMITTED]
</code>```

Attempted to use localhost as the DB_HOST however, it comes back with the Access denied for user error and i've checked that the details are correct. I'm assuming the docker containers are not talking to each other?

答:
You missed docker link:</p>

```<code>fpm:
    build:
        context: .
    volumes:
        - .:/var/www
    links:
      - mysql:mysql
</code>```

Body:
Setting up a new Laravel install using docker, this is the docker-compose.yml file:

version: '2'

services:
web:
    image: nginx
    restart: always
    links:
        - "fpm"
    volumes:
        - ./build/volumes/nginx/conf.d:/etc/nginx/conf.d:ro
    volumes_from:
        - fpm
    ports:
        - 8080:80

mysql:
    image: mysql
    environment:
        MYSQL_ROOT_PASSWORD: "[OMMITTED]"
        MYSQL_DATABASE: "[OMMITTED]"
        MYSQL_USER: "[OMMITTED]"
        MYSQL_PASSWORD: "[OMMITTED]"

fpm:
    build:
        context: .
    volumes:
        - .:/var/www

docker-compose up -d  works fine and I can see the web sever at http://localhost:8080/ , however when trying to do any type of connection to the database, I get a PDO::__construct(): php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known error message.

My .env file contains the following ( the DB_HOST is the container name ):

DB_CONNECTION=mysql
DB_HOST=container_mysql_1
DB_PORT=3306
DB_DATABASE=[OMMITTED]
DB_USERNAME=[OMMITTED]
DB_PASSWORD=[OMMITTED]

Attempted to use localhost as the DB_HOST however, it comes back with the Access denied for user error and i've checked that the details are correct. I'm assuming the docker containers are not talking to each other?

Body:
You missed docker link:

fpm:
    build:
        context: .
    volumes:
        - .:/var/www
    links:
      - mysql:mysql


问:
Create a knobInput widget in Shiny App
I quickly tried to create a knob custom input widget in shiny, based on the  jQuery knob library. Besides, I also adapted the Rstudio tutorial to my specific case.
This is what I get here.

The only way to change the input is to enter its value in the knob text input area. However, I would like this input to change when scrolling up or down as well as dragging with the mouse. How can I modify my code to achieve this goal?

Below are the js codes:

knob-input.R

```<code># This function generates the client-side HTML for a knob input
knobInput <- function(inputId, label, value = NULL, min = 0, max = 100,
              angleArc = 360, angleOffset = 0, stopper = TRUE,
              rotation = "clockwise", skin = "tron") {
  tagList(
    # This makes web page load the JS file in the HTML head.
    # The call to singleton ensures it's only included once
    # in a page.
    shiny::singleton(
      shiny::tags$head(
        shiny::tags$script(src = "jquery.knob.js"),
        shiny::tags$script(src = "knob-input-binding.js")
      )
    ),

    shiny::tags$label(label, `for` = inputId),
    shiny::tags$input(id = inputId, type = "text", value = value, class = "dial",
              "data-value" = value,
              "data-min" = min,
              "data-max" = max,
              "data-angleArc" = angleArc,
              "data-angleOffset" = angleOffset,
              "data-stopper" = stopper,
              "data-rotation" = rotation,
              "data-skin" = skin
              )
  )
}

# Send an update message to a knob input on the client.
# This update message can change the value and/or label.
updateknobInput <- function(session, inputId,
                   label = NULL, value = NULL) {

  message <- dropNulls(list(label = label, value = value))
  session$sendInputMessage(inputId, message)
}

# Given a vector or list, drop all the NULL items in it
dropNulls <- function(x) {
  x[!vapply(x, is.null, FUN.VALUE = logical(1))]
}
</code>```

knob-input-binding.js

```<code>// Knob input binding

var knobInputBinding = new Shiny.InputBinding();

// An input binding must implement these methods
$.extend(knobInputBinding, {

  // This returns a jQuery object with the DOM element
  find: function(scope) {
   return $(scope).find('.dial');
  },

  // this method will be called on initialisation
  initialize: function(el){

     // extract the value from el
     // note here our knobInput does not yet exist
     var value = $(el).data("value");

     // initialize our knob based on the extracted state
     el.value = value;
  },

  // Given the DOM element for the input, return the value
  getValue: function(el) {
    return el.value;
  },

  // Set up the event listeners so that interactions with the
  // input will result in data being sent to server.
  // callback is a function that queues data to be sent to
  // the server.
  subscribe: function(el, callback) {
    $(el).on('keyup.knobInputBinding', function(event) {
      callback(true);
      // When called with true, it will use the rate policy,
      // which in this case is to debounce at 500ms.
    });

    $(el).on('change.knobInputBinding', function(event) {
      callback(false);
      // When called with false, it will NOT use the rate policy,
      // so changes will be sent immediately
    });
  },

  // Remove the event listeners
  unsubscribe: function(el) {
    $(el).off('.knobInputBinding');
  },

  // Receive messages from the server.
  // Messages sent by updateknobInput() are received by this function.
  receiveMessage: function(el, data) {
    if (data.hasOwnProperty('value'))
      this.initialize(el, data.value);

    if (data.hasOwnProperty('label'))
      $(el).parent().find('label[for="' + $escape(el.id) + '"]').text(data.label);

    $(el).trigger('change');
  },

  // This returns a full description of the input's state.
  // Note that some inputs may be too complex for a full description of the
  // state to be feasible.
  getState: function(el) {
    return {
      label: $(el).parent().find('label[for="' + $escape(el.id) + '"]').text(),
  value: el.value
    };
  },

  // The input rate limiting policy
  getRatePolicy: function() {
    return {
    // Can be 'debounce' or 'throttle'
      policy: 'debounce',
      delay: 500
    };
  }

});

Shiny.inputBindings.register(knobInputBinding, 'shiny.knobInput');
</code>```

basic-knob.js

```<code>$(function($) {
  $(".dial").knob();
});
</code>```

(If the third code snippet is not present, knobs are not rendered properly).

EDITS: here is the single file, shinyapp code

```<code>library(purrr)
source("knob-input.R")

ui <- fluidPage(
  titlePanel("Custom input example"),

  includeScript("www/basic-knob.js"),

  fluidRow(
    column(4, wellPanel(
      knobInput("knobval", "", value = 10),
      knobInput("knobval2", "", value = 20),
      actionButton("reset", "Reset Knob")
    )),
    column(8, wellPanel(
      verbatimTextOutput("value")
    ))
  )
)

server <- function(input, output, session) {

  output$value <- renderText({
    c(input$knobval, input$knobval2)
  })

  observe({
    # Run whenever reset button is pressed
    input$reset
    knobvec <- c("knobval", "knobval2")
    # Send an update to knobs, resetting their values
    map(knobvec, updateknobInput, session = session, value = 0)
  })
}

shinyApp(ui = ui, server = server)
</code>```

My second question is: how can I change the skin used? For example, I would like to use the data-skin="tron", like in the jQuery knob showcase.

Many thanks in advance.

答:
knob has a special way to deal with events, to trigger change you can add in your subscribe method this code :

```<code>$(el).trigger('configure', {
  'change': function (v) {
     callback(false);
  }
});
</code>```

EDIT: there is not really a "tron" skin, this is manually implemented in draw parameter when initialized, you can change your basic-knob.js file with this :

```<code>$(function($) {
    $(".dial").knob({
        draw: function() {
            // "tron" case
            if (this.$.data('skin') == 'tron') {
                this.cursorExt = 0.3;
                var a = this.arc(this.cv) // Arc
                    ,
                    pa // Previous arc
                    , r = 1;
                this.g.lineWidth = this.lineWidth;
                if (this.o.displayPrevious) {
                    pa = this.arc(this.v);
                    this.g.beginPath();
                    this.g.strokeStyle = this.pColor;
                    this.g.arc(this.xy, this.xy, this.radius - this.lineWidth, pa.s, pa.e, pa.d);
                    this.g.stroke();
                }
                this.g.beginPath();
                this.g.strokeStyle = r ? this.o.fgColor : this.fgColor;
                this.g.arc(this.xy, this.xy, this.radius - this.lineWidth, a.s, a.e, a.d);
                this.g.stroke();
                this.g.lineWidth = 2;
                this.g.beginPath();
                this.g.strokeStyle = this.o.fgColor;
                this.g.arc(this.xy, this.xy, this.radius - this.lineWidth + 1 + this.lineWidth * 2 / 3, 0, 2 * Math.PI, false);
                this.g.stroke();
                return false;
            }
        }
    });
});
</code>```

Title: Create a knobInput widget in Shiny App

Body:
I quickly tried to create a knob custom input widget in shiny, based on the  jQuery knob library. Besides, I also adapted the Rstudio tutorial to my specific case.
This is what I get here.

The only way to change the input is to enter its value in the knob text input area. However, I would like this input to change when scrolling up or down as well as dragging with the mouse. How can I modify my code to achieve this goal?

Below are the js codes:

knob-input.R

# This function generates the client-side HTML for a knob input
knobInput <- function(inputId, label, value = NULL, min = 0, max = 100,
              angleArc = 360, angleOffset = 0, stopper = TRUE,
              rotation = "clockwise", skin = "tron") {
  tagList(
    # This makes web page load the JS file in the HTML head.
    # The call to singleton ensures it's only included once
    # in a page.
    shiny::singleton(
      shiny::tags$head(
        shiny::tags$script(src = "jquery.knob.js"),
        shiny::tags$script(src = "knob-input-binding.js")
      )
    ),

    shiny::tags$label(label, `for` = inputId),
    shiny::tags$input(id = inputId, type = "text", value = value, class = "dial",
              "data-value" = value,
              "data-min" = min,
              "data-max" = max,
              "data-angleArc" = angleArc,
              "data-angleOffset" = angleOffset,
              "data-stopper" = stopper,
              "data-rotation" = rotation,
              "data-skin" = skin
              )
  )
}

# Send an update message to a knob input on the client.
# This update message can change the value and/or label.
updateknobInput <- function(session, inputId,
                   label = NULL, value = NULL) {

  message <- dropNulls(list(label = label, value = value))
  session$sendInputMessage(inputId, message)
}

# Given a vector or list, drop all the NULL items in it
dropNulls <- function(x) {
  x[!vapply(x, is.null, FUN.VALUE = logical(1))]
}

knob-input-binding.js

// Knob input binding

var knobInputBinding = new Shiny.InputBinding();

// An input binding must implement these methods
$.extend(knobInputBinding, {

  // This returns a jQuery object with the DOM element
  find: function(scope) {
   return $(scope).find('.dial');
  },

  // this method will be called on initialisation
  initialize: function(el){

     // extract the value from el
     // note here our knobInput does not yet exist
     var value = $(el).data("value");

     // initialize our knob based on the extracted state
     el.value = value;
  },

  // Given the DOM element for the input, return the value
  getValue: function(el) {
    return el.value;
  },

  // Set up the event listeners so that interactions with the
  // input will result in data being sent to server.
  // callback is a function that queues data to be sent to
  // the server.
  subscribe: function(el, callback) {
    $(el).on('keyup.knobInputBinding', function(event) {
      callback(true);
      // When called with true, it will use the rate policy,
      // which in this case is to debounce at 500ms.
    });

    $(el).on('change.knobInputBinding', function(event) {
      callback(false);
      // When called with false, it will NOT use the rate policy,
      // so changes will be sent immediately
    });
  },

  // Remove the event listeners
  unsubscribe: function(el) {
    $(el).off('.knobInputBinding');
  },

  // Receive messages from the server.
  // Messages sent by updateknobInput() are received by this function.
  receiveMessage: function(el, data) {
    if (data.hasOwnProperty('value'))
      this.initialize(el, data.value);

    if (data.hasOwnProperty('label'))
      $(el).parent().find('label[for="' + $escape(el.id) + '"]').text(data.label);

    $(el).trigger('change');
  },

  // This returns a full description of the input's state.
  // Note that some inputs may be too complex for a full description of the
  // state to be feasible.
  getState: function(el) {
    return {
      label: $(el).parent().find('label[for="' + $escape(el.id) + '"]').text(),
  value: el.value
    };
  },

  // The input rate limiting policy
  getRatePolicy: function() {
    return {
    // Can be 'debounce' or 'throttle'
      policy: 'debounce',
      delay: 500
    };
  }

});

Shiny.inputBindings.register(knobInputBinding, 'shiny.knobInput');

basic-knob.js

$(function($) {
  $(".dial").knob();
});

(If the third code snippet is not present, knobs are not rendered properly).

EDITS: here is the single file, shinyapp code

library(purrr)
source("knob-input.R")

ui <- fluidPage(
  titlePanel("Custom input example"),

  includeScript("www/basic-knob.js"),

  fluidRow(
    column(4, wellPanel(
      knobInput("knobval", "", value = 10),
      knobInput("knobval2", "", value = 20),
      actionButton("reset", "Reset Knob")
    )),
    column(8, wellPanel(
      verbatimTextOutput("value")
    ))
  )
)

server <- function(input, output, session) {

  output$value <- renderText({
    c(input$knobval, input$knobval2)
  })

  observe({
    # Run whenever reset button is pressed
    input$reset
    knobvec <- c("knobval", "knobval2")
    # Send an update to knobs, resetting their values
    map(knobvec, updateknobInput, session = session, value = 0)
  })
}

shinyApp(ui = ui, server = server)

My second question is: how can I change the skin used? For example, I would like to use the data-skin="tron", like in the jQuery knob showcase.

Many thanks in advance.

Body:
knob has a special way to deal with events, to trigger change you can add in your subscribe method this code :

$(el).trigger('configure', {
  'change': function (v) {
     callback(false);
  }
});

EDIT: there is not really a "tron" skin, this is manually implemented in draw parameter when initialized, you can change your basic-knob.js file with this :

$(function($) {
    $(".dial").knob({
        draw: function() {
            // "tron" case
            if (this.$.data('skin') == 'tron') {
                this.cursorExt = 0.3;
                var a = this.arc(this.cv) // Arc
                    ,
                    pa // Previous arc
                    , r = 1;
                this.g.lineWidth = this.lineWidth;
                if (this.o.displayPrevious) {
                    pa = this.arc(this.v);
                    this.g.beginPath();
                    this.g.strokeStyle = this.pColor;
                    this.g.arc(this.xy, this.xy, this.radius - this.lineWidth, pa.s, pa.e, pa.d);
                    this.g.stroke();
                }
                this.g.beginPath();
                this.g.strokeStyle = r ? this.o.fgColor : this.fgColor;
                this.g.arc(this.xy, this.xy, this.radius - this.lineWidth, a.s, a.e, a.d);
                this.g.stroke();
                this.g.lineWidth = 2;
                this.g.beginPath();
                this.g.strokeStyle = this.o.fgColor;
                this.g.arc(this.xy, this.xy, this.radius - this.lineWidth + 1 + this.lineWidth * 2 / 3, 0, 2 * Math.PI, false);
                this.g.stroke();
                return false;
            }
        }
    });
});