text:
Q: Weblogic 12 SSL setup with Demo Trust Keystore I have following setup
TestDomain1 running on port 7001 (SSL Listen port not enabled)

*

*wls console -> AdminServer -> Keystore tab
  Keystores: Demo Identity and Demo Trust
  Demo Identity Keystore: C:\Oracle\Middleware\Oracle_Home\user_projects\domains\TestDomain\security\DemoIdentity.jks
  Demo Trust Keystore:

C:\PROGRA~1\ORACLE\ORACLE~1\wlserver\server\lib\DemoTrust.jks

*wls console -> AdminServer -> SSL tab
  Identity and Trust Locations: Keystore
  Certificate Location: from Demo Identity Keystore
  Trusted Certificate Authorities: from Demo Trust Keystore and Java Standard Trust Keystore

TestDomain2(SSL Enabled) running on port 9001 and SSL listen port is 7002.
 Exactly same setup as above domain (so both domain were created with
 default setup and I have not made any changes except enabling SSL
 listen port in this domain)

I have a webservice running on TestDomain1 and this webservice calls an HTTPS URL on TestDomain2. I am getting following error on TestDomain1
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
What does this error mean. Based on the above setup truststore path is already given in TestDomain1. I am not trying 2 way SSL. I just want to be able to invoke and HTTPS URL.
Following is my code to access the HTTPS URL
HttpClient client = new HttpClient();
    ProtocolSocketFactory factory = new SSLProtocolSocketFactory();
    Protocol https = new Protocol("https", factory, 7002);
    client.getHostConfiguration().setHost("localhost", 7002, https);

    PostMethod post = new PostMethod("https://localhost:7002/somecontext/someresource");
    post.setParameter("sapCreateRequest", request.getSapRequestPayload());
    try {
        client.executeMethod(post);
        BufferedReader reader = new BufferedReader(new InputStreamReader(post.getResponseBodyAsStream()));
        String line = null;
        while((line = reader.readLine()) != null) {
            logger.info(line);
        }
        // print response to stdout
        System.out.println(post.getResponseBodyAsStream());
    } catch(Exception ex) {
        logger.error("Error while communicating with SSL resource: {}", ex.getMessage());
    } finally {
        // be sure the connection is released back to the connection
        // manager
        post.releaseConnection();
    }


text:
Q: Show that, if every tangent line of a unit speed curve $\beta$ passes through a fixed point $p$, then $β$ is a line. Just wondering whether my proof is valid or not, feedback would be very appreciated!
If the tangent line $T$ always intersects a particular point $p$ then it must be the case that $T$ is constantly pointing either directly towards $p$ or directly away from $p$. We assume that $\beta$ is smooth and hence we are forced to pick one of the two options ($T$ can't instantaneously switch directions if $\beta$ is smooth.) Without loss of generality, assume $T$ is pointing towards $p$.
$T$ is a vector composed of magnitude and direction. Since $T$ is a unit vector, its magnitude is never changing. Since $T$ is always pointing directly towards $p$, its direction is never changing. Hence, $T$ is a constant vector. Then,
$T$ is constant $\Rightarrow |T'| = \kappa = 0$. Given that $\kappa = 0$, $\beta$ must be a straight line.

A: First, a little feedback:
"Since $T$ is always pointing directly towards $p$, its direction is never changing."
I don't quite see how this follows from our OP talrefae's argument; I think a little more work is needed to establish this.
These things being written, I believe the following argument contains a correct demonstration that $T(s)$ is, in fact, constant, and hence that it's direction does not change:
I'm going to assume $p$ does not lie on the curve $\beta(s)$.
First of all, what is the line $l$ tangent to $\beta(s)$ for some particular value of $s$?  Well, one way to express it is in the form
$l(\tau, s) = \beta(s) + \tau T(s); \tag 1$
that is, for some $s$, the "curve" $l(\tau, s)$, considered as a function of the parameter $\tau$, takes the value $\beta(s)$ when $\tau = 0$, and it's tangent vector $T(s)$ is constant with respect to $\tau$:  it is well-known, and easy to see, that for fixed $s$, $l(\tau, s)$ is the line through $\beta(s)$ in the direction of $T(s)$.  Since by definition
$\dot \beta(s) = T(s), \tag 2$
we see that (1) indeed presents the line tangent to the curve $\beta(s)$ at $s$; since we are given that this line passes through the point $p$, for some value of $\tau(s)$ depending on $s$, we have
$p = \beta(s) + \tau(s) T(s); \tag 3$
it is easy to see that $\tau(s)$ is a differentiable function of $s$, since (3) may be written
$\tau(s) T(s) = p - \beta(s), \tag 4$
whence, since $T(s) \cdot T(s) = 1$ (because $\beta(s)$ is a unit speed curve),
$\tau(s) = \tau(s) T(s) \cdot T(s) = (p - \beta(s)) \cdot T(s), \tag 5$
so $\tau$ is a differentiable function of $s$.  We may thus take $d/ds$ of each side of (3):
$0 = \dot p = \dot \beta(s) + \dot \tau(s) T(s) + \tau(s) \dot T(s), \tag 6$
where $\dot p = 0$ since $p$ is fixed; we substitute (2) into this equation and find
$T(s) + \dot \tau(s) T(s) + \tau (s) \dot T(s) = 0, \tag 7$
or
$(\dot \tau(s) + 1)T(s) + \tau(s) \dot T(s) = 0; \tag 8$
now
$T(s) \cdot T(s) = 1 \Longrightarrow T(s) \cdot T'(s) = 0; \tag 9$
thus,
$\dot \tau(s) + 1 = (\dot \tau(s) + 1)T(s) \cdot T(s) + T(s) \cdot T'(s) = 0, \tag{10}$
that is,
$\dot \tau(s) = -1; \tag{11}$
we note in passing that the unique solution to this with $\tau(s_0) = \tau_0$ is
$\tau(s) = s_0 -s + \tau_0 = 0 \Longleftrightarrow s = s_0 + \tau_0; \tag{12}$
we also observe that (4) further yields
$\tau^2(s) = \tau^2(s) T(s) \cdot T(s) = (\tau(s)T(s)) \cdot (\tau(s) T(s)) = (p - \beta(s)) \cdot (p - \beta(s)) \ne 0 \tag{13}$
when $p \ne \beta(s)$, which binds since we have assumed $p$ is not on the curve $\beta(s)$; (8) then leads us to
$\dot \tau(s) + 1 = 0, \; \tau(s) \ne 0 \Longrightarrow \dot T(s) = 0 \Longrightarrow T(s) = T_0; \tag{14}$
we may now integrate (2) with $T(s) = T_0$ and $\beta(s) = \beta(s_0)$ at $s = s_0$:
$\dot \beta(s) = T(s) = T_0 \Longrightarrow \beta(s) = T_0 (s - s_0) + \beta(s_0), \tag{15}$
the equation of a straight line.

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to override the "new tab" page of browser with a specific URL using Crossrider APIs? How to override the "new tab" page of browser with a specific URL using Crossrider APIs?
In Chrome and other browsers, you can override the "new tab" page with a specific URL [i.e. http://www.mysiteurl.com/]. How can you implement this using Crossrider APIs?

A: Currently, the Crossrider API does not support this feature but we will consider adding an API to approximate this behavior for all supported browsers.
[Disclaimer: I am a Crossrider employee]


text:
Q: Add current product to the current logged in user meta data In WooCommerce product page, I'm trying to add the current product as a new user meta data. Am I doing this right?
Then how can I retrieve this product meta data in cart page?
// save for later
public function save_for_later(){
    if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
        global $woocommerce;
        // get user details
        global $current_user;
        get_currentuserinfo();

        $product = wc_get_product( get_the_ID() );;

        if (is_user_logged_in())
        {
            $user_id = $current_user->ID;
            $meta_key = 'product';
            $meta_value = $product;
            update_user_meta( $user_id, $meta_key, $meta_value);
        }
        exit();
    }
}

A: Instead of saving the complete WC_Product Object, Which is a complex huge and heavy peace of data that can not be saved as meta data, you should just better save the product ID.
Why? Because the product ID is just an integer (so something very light) and will allow you to get the WC_Product Object easily from the saved product ID.
Now global $woocommerce is unneeded and if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { is not really required (If it's needed you set add it back in the function).
Also get_currentuserinfo(); is deprecated, unneeded too and replaced by wp_get_current_user().
You should better need to be sure that the current post ID is a "product" post type. So try the following code instead:
// save for later
public function save_for_later(){
    global $post;

    // Check that the current post ID is a product ID and that current user is logged in
    if ( is_user_logged_in() && is_a($post, 'WP_Post') && get_post_type() === 'product' ) {
        update_user_meta( get_current_user_id(), 'product_id', get_the_id());
    }
    exit();
}

Now to retrieve this custom user meta data and the WC_Product Object (from the product ID), you will use:
$product_id = get_user_meta( get_current_user_id(), 'product_id', true );

// Get an instance of the WC_Product object from the product ID
$product = wc_get_product( $product_id );

In cart page, you might just need the product ID, depending on what you are trying to do. Everything should work.


text:
Q: AngularJs - How can I disable the submit button until the current text on my input is updated? I have an issue try to achieve this result, pretty much what I need is to disable the submit button until the current text in the input field is updated. Please if you can help me with this it would be really appreciated.

A: Below is the sample of disabling button until you enter some value in input
Using ng-disabled and $dirty

angular.module('myApp', []);
angular.module('myApp').controller('MyController', MyController);

function MyController($scope) {
  $scope.name = "Angular Form";
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="MyController">
  <form name="form">
    <input type="text" name="name" ng-model="name">
    <button type="submit" ng-disabled="!form.name.$dirty">submit</button>
  </form>
</div>

Have a look at angularJS form validations:
FormController
scotch.io


text:
Q: iOS show up in list of 'sharing apps' I dont know what this is called and cant find anything on this...
When your in iphoto and click share a list of apps show up to do the sharing through, facebook and Twitter (if installed) email, sms, etc.  How do I get my app in that list so when the user wants to share a photo my application is available to be the one to do the sharing. Im assuming the ios passes the photo to the app and myapp catches it and does work with it.
Thanks

A: This is not possible for 3rd party applications.


text:
Q: How to get media query to recognize landscape orientation? I have a JQM app with a fixed footer.  In order to get around a rendering issue when the keyboard is shown, I found some CSS3 media queries that set the visibility of the .ui-footer-fixed class to visible if the min-height of the screen is more than a certain number of pixels based on the orientation.
The portrait mode screen size and orientation is detected correctly and shows/hides the class as I would expect when the keyboard is displayed and hidden.  When in landscape mode, however, the landscape orientation is not detected and the default visibility of hidden takes over.
This is the pertinent script that sets up these media queries:
var win = $(window),
    height = win.height(),
    width = win.width();

document.write([
    "<style>",
    ".ui-footer-fixed { visibility: hidden; }",
    "@media screen and (orientation: portrait) and (min-height: " + (Math.max(width, height) - 10) + "px)",
    "{ .ui-footer-fixed { visibility: visible; }",
    "@media screen and (orientation: landscape) and (min-height: " + (Math.min(width, height) - 30) + "px)",
    "{ .ui-footer-fixed { visibility: visible; }",
    "</style>"
].join(" "));

What am I doing wrong?
Thanks,
Matthew

A: The answer lay in the original solution I tried, but there were some closing curly braces missing from the two @media queries.
The solution came from this SO post: jquery-mobile-hide-fixed-footer-when-keyboard

A: In answer to the question how to get media query to recognize landscape orientation?
@media screen and (orientation:landscape)
{
   body
   {
      background: red;
   }
}


text:
Q: How to improve this query mysql and rails 5 We have three tables users, stores and store_customer_associations, where a user can be a customer for many stores.
I've tried to place another index in primary key but without success (and other too).
(currently these are our indexes in each table)
mysql> SHOW INDEXES FROM store_customer_associations;
+-------+------------+-------------------------------------+--------------+----------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name                            | Seq_in_index | Column_name          | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-------+------------+-------------------------------------+--------------+----------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| users |          0 | PRIMARY                             |            1 | id                   | A         |     9386515 |     NULL | NULL   |      | BTREE      |         |               |
| users |          0 | tmp_idx_users_id                    |            1 | id                   | A         |     9386515 |     NULL | NULL   |      | BTREE      |         |               |
+-------+------------+-------------------------------------+--------------+----------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
10 rows in set (0.00 sec)

mysql> SHOW INDEXES FROM store_customer_associations;
+-----------------------------+------------+-----------------------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table                       | Non_unique | Key_name                                      | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-----------------------------+------------+-----------------------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| store_customer_associations |          0 | PRIMARY                                       |            1 | id          | A         |    51298761 |     NULL | NULL   |      | BTREE      |         |               |
| store_customer_associations |          1 | index_store_customer_associations_on_store_id |            1 | store_id    | A         |       50096 |     NULL | NULL   | YES  | BTREE      |         |               |
| store_customer_associations |          1 | index_store_customer_associations_on_user_id  |            1 | user_id     | A         |    25649380 |     NULL | NULL   | YES  | BTREE      |         |               |
+-----------------------------+------------+-----------------------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
3 rows in set (0.00 sec)

We are using rails 5.1 (this is a big rails 4 legacy database).
Then we need to make this query fast:
SELECT  COUNT(*)
    FROM  `users`
    INNER JOIN  `store_customer_associations`
         ON `users`.`id` = `store_customer_associations`.`user_id`
    WHERE  `store_customer_associations`.`store_id` = STORE_ID;

+----------+
| COUNT(*) |
+----------+
|  1997632 |
+----------+
1 row in set (6.64 sec)

mysql> EXPLAIN     SELECT  COUNT(*)
    FROM  `users`
    INNER JOIN  `store_customer_associations`
         ON `users`.`id` = `store_customer_associations`.`user_id`
    WHERE  `store_customer_associations`.`store_id` = STORE_ID;

+------+-------------+-----------------------------+--------+--------------------------------------------------------------------------------------------+-----------------------------------------------+---------+---------------------------------------------------------+---------+-------------+
| id   | select_type | table                       | type   | possible_keys                                                                              | key                                           | key_len | ref                             | rows    | Extra       |
+------+-------------+-----------------------------+--------+--------------------------------------------------------------------------------------------+-----------------------------------------------+---------+---------------------------------------------------------+---------+-------------+
|    1 | SIMPLE      | store_customer_associations | ref    | index_store_customer_associations_on_store_id,index_store_customer_associations_on_user_id | index_store_customer_associations_on_store_id | 5       | const                             | 4401812 | Using where |
|    1 | SIMPLE      | users                       | eq_ref | PRIMARY,tmp_idx_users_id                                                                   | PRIMARY                                       | 4       | trustvox_production.store_customer_associations.user_id |       1 | Using index |
+------+-------------+-----------------------------+--------+--------------------------------------------------------------------------------------------+-----------------------------------------------+---------+---------------------------------------------------------+---------+-------------+
2 rows in set (0.00 sec)

UPDATE 1
mysql> EXPLAIN     SELECT  COUNT(*)
    FROM  `users`
    INNER JOIN  `store_customer_associations`
         ON `users`.`id` = `store_customer_associations`.`user_id`
    WHERE  `store_customer_associations`.`store_id` = STORE_ID;

+------+-------------+-----------------------------+--------+-------------------------------------------------------------------------------------------------------------+-----------------------------------------------+---------+---------------------------------------------------------+---------+-------------+
| id   | select_type | table                       | type   | possible_keys                                                                                | key                                           | key_len | ref                                              | rows    | Extra       |
+------+-------------+-----------------------------+--------+-------------------------------------------------------------------------------------------------------------+-----------------------------------------------+---------+---------------------------------------------------------+---------+-------------+
|    1 | SIMPLE      | store_customer_associations | ref    | index_store_customer_associations_on_store_id,index_store_customer_associations_on_user_id,user_id_store_id | index_store_customer_associations_on_store_id | 5       | const                                              | 4401812 | Using where |
|    1 | SIMPLE      | users                       | eq_ref | PRIMARY,tmp_idx_users_id                                                                                | PRIMARY                                       | 4       | trustvox_production.store_customer_associations.user_id |       1 | Using index |
+------+-------------+-----------------------------+--------+-------------------------------------------------------------------------------------------------------------+-----------------------------------------------+---------+---------------------------------------------------------+---------+-------------+
2 rows in set (0.00 sec)

UPDATE 2
mysql>     SELECT  COUNT(*)
    FROM  users
    INNER JOIN  store_customer_associations
        FORCE INDEX FOR JOIN  (PRIMARY, user_id_store_id)
         ON users.id = store_customer_associations.user_id
    WHERE  store_customer_associations.store_id = STORE_ID;

+----------+
| COUNT(*) |
+----------+
|  1997632 |
+----------+
1 row in set (28.90 sec)

mysql> EXPLAIN     SELECT  COUNT(*)
    FROM  users
    INNER JOIN  store_customer_associations
        FORCE INDEX FOR JOIN  (PRIMARY, user_id_store_id)
         ON users.id = store_customer_associations.user_id
    WHERE  store_customer_associations.store_id = STORE_ID;
+------+-------------+-----------------------------+-------+--------------------------+------------------+---------+------------------------------------+---------+-------------+
| id   | select_type | table                       | type  | possible_keys            | key              | key_len | ref                                | rows    | Extra       |
+------+-------------+-----------------------------+-------+--------------------------+------------------+---------+------------------------------------+---------+-------------+
|    1 | SIMPLE      | users                       | index | PRIMARY,tmp_idx_users_id | tmp_idx_users_id | 4       | NULL                               | 8675689 | Using index |
|    1 | SIMPLE      | store_customer_associations | ref   | user_id_store_id         | user_id_store_id | 10      | trustvox_production.users.id,const |       1 | Using index |
+------+-------------+-----------------------------+-------+--------------------------+------------------+---------+------------------------------------+---------+-------------+
2 rows in set (0.00 sec)

mysql>

UPDATE 3
mysql> EXPLAIN     SELECT  COUNT(*)
    FROM  users
    INNER JOIN
        ( SELECT  *
            FROM  store_customer_associations
            WHERE  store_id = 75856
        ) sca  ON users.id = sca.user_id;

+------+-------------+-----------------------------+--------+-------------------------------------------------------------------------------------------------------------+-----------------------------------------------+---------+---------------------------------------------------------+---------+-------------+
| id   | select_type | table                       | type   | possible_keys                                                                                | key                                           | key_len | ref                                              | rows    | Extra       |
+------+-------------+-----------------------------+--------+-------------------------------------------------------------------------------------------------------------+-----------------------------------------------+---------+---------------------------------------------------------+---------+-------------+
|    1 | SIMPLE      | store_customer_associations | ref    | index_store_customer_associations_on_store_id,index_store_customer_associations_on_user_id,user_id_store_id | index_store_customer_associations_on_store_id | 5       | const                                              | 4401812 | Using where |
|    1 | SIMPLE      | users                       | eq_ref | PRIMARY,tmp_idx_users_id                                                                                | PRIMARY                                       | 4       | trustvox_production.store_customer_associations.user_id |       1 | Using index |
+------+-------------+-----------------------------+--------+-------------------------------------------------------------------------------------------------------------+-----------------------------------------------+---------+---------------------------------------------------------+---------+-------------+

UPDATE 4
mysql> ALTER TABLE store_customer_associations DROP INDEX index_store_customer_associations_on_store_id;
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> ALTER TABLE store_customer_associations DROP INDEX index_store_customer_associations_on_user_id;
Query OK, 0 rows affected (0.02 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> CREATE INDEX index_on_store_id_and_user_id ON store_customer_associations (store_id, user_id);
Query OK, 0 rows affected (45.95 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> CREATE INDEX index_store_customer_associations_on_user_id ON store_customer_associations(user_id);
Query OK, 0 rows affected (33.06 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> CREATE INDEX index_store_customer_associations_on_store_id ON store_customer_associations(store_id);
Query OK, 0 rows affected (38.58 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> SHOW INDEXES FROM store_customer_associations;
+-----------------------------+------------+-----------------------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table                       | Non_unique | Key_name                                      | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-----------------------------+------------+-----------------------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| store_customer_associations |          0 | PRIMARY                                       |            1 | id          | A         |    10305620 |     NULL | NULL   |      | BTREE      |         |               |
| store_customer_associations |          1 | index_on_store_id_and_user_id                 |            1 | store_id    | A         |        8244 |     NULL | NULL   | YES  | BTREE      |         |               |
| store_customer_associations |          1 | index_on_store_id_and_user_id                 |            2 | user_id     | A         |    10305620 |     NULL | NULL   | YES  | BTREE      |         |               |
| store_customer_associations |          1 | index_store_customer_associations_on_user_id  |            1 | user_id     | A         |    10305620 |     NULL | NULL   | YES  | BTREE      |         |               |
| store_customer_associations |          1 | index_store_customer_associations_on_store_id |            1 | store_id    | A         |        6424 |     NULL | NULL   | YES  | BTREE      |         |               |
+-----------------------------+------------+-----------------------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
5 rows in set (0.00 sec)

A: U need to make index for 2 parameters for store_curstometer_associations because in query index is not because where part.
create index user_id_store_id on store_customer_associations (user_id, store_id)

Should help u out
Example
mysql> show indexes from api_plexts;
+------------+------------+----------------------------------------+--------------+--------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table      | Non_unique | Key_name                               | Seq_in_index | Column_name        | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+------------+------------+----------------------------------------+--------------+--------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| api_plexts |          0 | PRIMARY                                |            1 | id                 | A         |      206318 |     NULL | NULL   |      | BTREE      |         |               |
| api_plexts |          0 | index_api_plexts_on_guid               |            1 | guid               | A         |      215475 |     NULL | NULL   | YES  | BTREE      |         |               |
| api_plexts |          1 | index_api_plexts_on_api_agent_id       |            1 | api_agent_id       | A         |        1565 |     NULL | NULL   | YES  | BTREE      |         |               |
| api_plexts |          1 | index_api_plexts_on_from_api_portal_id |            1 | from_api_portal_id | A         |       11401 |     NULL | NULL   | YES  | BTREE      |         |               |
| api_plexts |          1 | index_api_plexts_on_to_api_portal_id   |            1 | to_api_portal_id   | A         |        9566 |     NULL | NULL   | YES  | BTREE      |         |               |
+------------+------------+----------------------------------------+--------------+--------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
5 rows in set (0.00 sec)

mysql> show indexes from api_portals;
+-------------+------------+--------------------------------------+--------------+-----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table       | Non_unique | Key_name                             | Seq_in_index | Column_name     | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-------------+------------+--------------------------------------+--------------+-----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| api_portals |          0 | PRIMARY                              |            1 | id              | A         |       20530 |     NULL | NULL   |      | BTREE      |         |               |
| api_portals |          0 | index_api_portals_on_guid            |            1 | guid            | A         |       19891 |     NULL | NULL   | YES  | BTREE      |         |               |
| api_portals |          1 | index_api_portals_on_owner_agent_id  |            1 | owner_agent_id  | A         |         718 |     NULL | NULL   | YES  | BTREE      |         |               |
| api_portals |          1 | index_api_portals_on_api_map_tile_id |            1 | api_map_tile_id | A         |        5480 |     NULL | NULL   | YES  | BTREE      |         |               |
+-------------+------------+--------------------------------------+--------------+-----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
explain select count(*) from api_portals ap JOIN api_plexts al FORCE INDEX FOR JOIN (PRIMARY) on ap.id = al.from_api_portal_id  where al.api_agent_id = 2\G;

mysql> show indexes from api_plexts;
+------------+------------+----------------------------------------+--------------+--------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table      | Non_unique | Key_name                               | Seq_in_index | Column_name        | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+------------+------------+----------------------------------------+--------------+--------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| api_plexts |          0 | PRIMARY                                |            1 | id                 | A         |      206318 |     NULL | NULL   |      | BTREE      |         |               |
| api_plexts |          0 | index_api_plexts_on_guid               |            1 | guid               | A         |      215475 |     NULL | NULL   | YES  | BTREE      |         |               |
| api_plexts |          1 | index_api_plexts_on_api_agent_id       |            1 | api_agent_id       | A         |        1565 |     NULL | NULL   | YES  | BTREE      |         |               |
| api_plexts |          1 | index_api_plexts_on_from_api_portal_id |            1 | from_api_portal_id | A         |       11401 |     NULL | NULL   | YES  | BTREE      |         |               |
| api_plexts |          1 | index_api_plexts_on_to_api_portal_id   |            1 | to_api_portal_id   | A         |        9566 |     NULL | NULL   | YES  | BTREE      |         |               |
+------------+------------+----------------------------------------+--------------+--------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
5 rows in set (0.00 sec)

mysql> show indexes from api_portals;
+-------------+------------+--------------------------------------+--------------+-----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table       | Non_unique | Key_name                             | Seq_in_index | Column_name     | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-------------+------------+--------------------------------------+--------------+-----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| api_portals |          0 | PRIMARY                              |            1 | id              | A         |       20530 |     NULL | NULL   |      | BTREE      |         |               |
| api_portals |          0 | index_api_portals_on_guid            |            1 | guid            | A         |       19891 |     NULL | NULL   | YES  | BTREE      |         |               |
| api_portals |          1 | index_api_portals_on_owner_agent_id  |            1 | owner_agent_id  | A         |         718 |     NULL | NULL   | YES  | BTREE      |         |               |
| api_portals |          1 | index_api_portals_on_api_map_tile_id |            1 | api_map_tile_id | A         |        5480 |     NULL | NULL   | YES  | BTREE      |         |               |
+-------------+------------+--------------------------------------+--------------+-----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+

mysql> explain select count(*) from api_portals ap JOIN api_plexts al on ap.id = al.from_api_portal_id where al.api_agent_id = 2;
+----+-------------+-------+------------+--------+-------------------------------------------------------------------------+----------------------------------+---------+-------------------------------+------+----------+--------------------------+
| id | select_type | table | partitions | type   | possible_keys                                                           | key                              | key_len | ref                           | rows | filtered | Extra                    |
+----+-------------+-------+------------+--------+-------------------------------------------------------------------------+----------------------------------+---------+-------------------------------+------+----------+--------------------------+
|  1 | SIMPLE      | al    | NULL       | ref    | index_api_plexts_on_api_agent_id,index_api_plexts_on_from_api_portal_id | index_api_plexts_on_api_agent_id | 5       | const                         |  271 |   100.00 | Using where              |
|  1 | SIMPLE      | ap    | NULL       | eq_ref | PRIMARY                                                                 | PRIMARY                          | 8       | ingress.al.from_api_portal_id |    1 |   100.00 | Using where; Using index |
+----+-------------+-------+------------+--------+-------------------------------------------------------------------------+----------------------------------+---------+-------------------------------+------+----------+--------------------------+

this is exactly your case U can see using where
mysql> create index testime on api_plexts (api_agent_id, from_api_portal_id);                                                                                Query OK, 0 rows affected (3.71 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> show indexes from api_plexts;
+------------+------------+----------------------------------------+--------------+--------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table      | Non_unique | Key_name                               | Seq_in_index | Column_name        | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+------------+------------+----------------------------------------+--------------+--------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| api_plexts |          0 | PRIMARY                                |            1 | id                 | A         |      200644 |     NULL | NULL   |      | BTREE      |         |               |
| api_plexts |          0 | index_api_plexts_on_guid               |            1 | guid               | A         |      209549 |     NULL | NULL   | YES  | BTREE      |         |               |
| api_plexts |          1 | index_api_plexts_on_api_agent_id       |            1 | api_agent_id       | A         |        1522 |     NULL | NULL   | YES  | BTREE      |         |               |
| api_plexts |          1 | index_api_plexts_on_from_api_portal_id |            1 | from_api_portal_id | A         |       11087 |     NULL | NULL   | YES  | BTREE      |         |               |
| api_plexts |          1 | index_api_plexts_on_to_api_portal_id   |            1 | to_api_portal_id   | A         |        9303 |     NULL | NULL   | YES  | BTREE      |         |               |
| api_plexts |          1 | testime                                |            1 | api_agent_id       | A         |        1817 |     NULL | NULL   | YES  | BTREE      |         |               |
| api_plexts |          1 | testime                                |            2 | from_api_portal_id | A         |       52277 |     NULL | NULL   | YES  | BTREE      |         |               |
+------------+------------+----------------------------------------+--------------+--------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
7 rows in set (0.00 sec)

VOILA!!!

mysql> explain select count(*) from api_portals ap JOIN api_plexts al on ap.id = al.from_api_portal_id where al.api_agent_id = 2\G;                            *************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: al
   partitions: NULL
         type: ref
possible_keys: index_api_plexts_on_api_agent_id,index_api_plexts_on_from_api_portal_id,testime
          key: testime
      key_len: 5
          ref: const
         rows: 271
     filtered: 100.00
        Extra: Using where; Using index
*************************** 2. row ***************************
           id: 1
  select_type: SIMPLE
        table: ap
   partitions: NULL
         type: eq_ref
possible_keys: PRIMARY
          key: PRIMARY
      key_len: 8
          ref: ingress.al.from_api_portal_id
         rows: 1
     filtered: 100.00
        Extra: Using where; Using index
2 rows in set, 1 warning (0.00 sec)

A: store_customer_associations:  INDEX(store_id, user_id)  -- "covering"

store_id is first -- to handle the WHERE; user_id is added so that the only the index need by touched.
A tutorial that lets you discover the INDEX yourself:  http://mysql.rjweb.org/doc.php/index_cookbook_mysql


text:
Q: Breaking on user input without delay in Java? I have a while loop that reads from a socket, and instead of a timer, I want to break, close the socket and end the program on user input, but I don't want the user to have to enter a "1" or "continue" or "something" for each reading. I just want if there is input from the user, break and close, otherwise, if there is no interference, continue.
I am afraid I am going to have to use a timer, which I don't want to do because it would delay receiving from the socket, and I need to have little or no delay if possible.
Is there some Java function that does this or a simple solution I am missing?
EDIT:
I don't want to wait for the user input. I just want to continue unless user input is detected, but the point is that there is no delay in checking to see if the user has entered something. I am going on the program assuming that it should simply continue until the user says otherwise.

A: I think I have worked out that you want to specify a timeout period? You can set a timeout by calling on the Socket the method setSoTimeout(int timeout), you can also specify it through the Socket constructor. See Socket API here
Hope this helps.

A: The best way to do this is probably to start a thread running which awaits user input. if this is detected then the thread can set a flag which is checked inside the loop.

A: How about binding a event listener to your input, and if there is a input you handle it(in this case close the socket connection)
You have a "similar" sample here
EDIT: Didnt fully read your question. Thought you hade some kind of GUI. Since you dont then you coudl do something like this (havent use threads in a while in Java so this is "pseudocode" but i hope you get tthe picture):
public void start()
{
        Console console = System.console();
        if (console != null)
        {
                Thread th = new Thread(yourWorkerClass);
                th.run();

                //blocking
                String readLine = console.readLine("Do something: ", (Object[])null);
                th.stopYourWorkMethod();

        }
}

A: You need Threading for your requirement. Open a new thread that reads from socket while in your main thread you wait for user input. When you get the input you can interrupt your other thread.
You can do a Thread class such as:
public class ClientThread extends Thread {
    private String address;
    private int port;

    ClientThread(String address, int port) {
        this.address = address;
        this.port = port;
    }

    public void run() {
        // connect to socket and start reading
        . . .
    }
}

And then use it in your application with:
ClientThread c = new ClientThread("127.0.0.1", 4547);
c.start();

A: You can do an isReady on the input stream to see if there is any data there. In the simplest case, you could sleep for the specified time, then check isReady, and proceed or abort as required. If you want to respond immediately when the user sends the cancel signal, you could have a loop that keeps checking isReady and checking the current time against a starting time, and breaks when either condition is met. If there's some other work that you want to do while waiting for this to happen, you could put it in a separate thread. (In which case the loop should include a yield() to let other things happen.)

A: You probably want two threads.
One thread should read user input and put that "command" in a variable that is shared with another thread.
The second thread should process "commands" from that variable (you probably want a queue of commands being built). That thread should wait for commands being placed in the queue.
The variable (probably a queue) holding the commands should be protected by a synchronized block. The second thread should wait() on the object that is being synchronized on and the first thread should run notify() on that object when it has placed a command there.
Then the second thread can process commands and react to them without having to wait for user input (as long as there are commands to process) and be immediately woken up when there is something to do.


text:
Q: why possibility_1=0 and possibility_2=0 doesnt changing? import math
import random

possibility_1=0
possibility_2=0

while True:
    list = [0, 1]
    number_1=random.choice(list)
    number_2=random.choice(list)
    number_3=random.choice(list)

    number_total=str(number_1)+","+str(number_2)+","+str(number_3)

    if number_total==(1,1,0) or number_total==(0,0,1):
        possibility_1 +=1

    if number_total==(1,1,1) or number_total==(0,0,0):
        possibility_2 +=1

    print(str(number_total)+"      possibility_11= "+ str(possibility_1)+" possibility_12= "+ str(possibility_2))

guys the possibility_1 and possibility_2 doesn!t changing. Please help me I want to make a heads or tails code and simulate it then check the possibilities.

A: Looks like number_total is a string so the output would be "1,1,0" you are comparing with a tuple. This means the if statements will not be invoked.
if number_total=="1,1,0" or number_total=="0,0,1":


text:
Q: Import resources and create VM from image using terraform Im trying to import the resources and and create VM from the existing image on Azure. All the imports are successful but when I run terraform apply, I get the following error:
enter image description here
here is the code:
provider "azurerm" {
    version = "2.0.0"
    subscription_id = var.subscriptionID

    features {}
}
resource "azurerm_resource_group" "TerraformResourceGroup" {

}

resource "azurerm_network_security_group" "TerraformSecurityGroup" {

}

resource "azurerm_virtual_network" "TerraformVirtualNetwork" {

}

resource "azurerm_network_interface" "TerraformNetworkInterface" {

}

resource "azurerm_virtual_machine" "TerraformVM" {
  name                  = var.VM
  location              = var.location
  resource_group_name   = azurerm_resource_group.TerraformResourceGroup.name
  network_interface_ids = [azurerm_network_interface.TerraformNetworkInterface.id]
  vm_size               = "Standard_DS1_v2"

 storage_image_reference {
    id  = "/subscriptions/--/resourceGroups/TerraformResourceGroup/providers/Microsoft.Compute/images/TerraformVM-image-20210201164126"
}

  storage_os_disk {
    name              = "disk1"
    caching           = "ReadWrite"
    create_option     = "FromImage"
    managed_disk_type = "Standard_LRS"
    }

  os_profile {
    computer_name  = var.name
    admin_username = var.username
    admin_password = var.password
  }

  os_profile_windows_config {
     provision_vm_agent = true
  }

  tags = {
    environment = "staging"
  }
}

Please help
Ok, Let me explain a bit clear. I created a rg and deployed a vm using terraform, then captured the VM. now I need to deploy a vm using that image in same rg. Do I need to use import or data sources? if I use data source I'm getting the following:Error deleting Virtual Network "xx" (Resource Group "yy"): network.VirtualNetworksClient#Delete: Failure sending request: StatusCode=400 -- Original Error: Code="InUseSubnetCannotBeDeleted" Message="Subnet xx is in use by /subscriptions/--/resourceGroups/yy/providers/Microsoft.Network/networkInterfaces/xx/ipConfigurations/internal and cannot be deleted. In order to delete the subnet, delete all the resources within the subnet.
Code using data sources
provider "azurerm" {
    version = "2.0.0"
    subscription_id = var.subscriptionID

    features {}
}
data "azurerm_resource_group" "TerraformResourceGroup" {
  name     = var.resourceGroupName
}

data "azurerm_network_security_group" "TerraformSecurityGroup" {
  name                = var.securityGroup
  resource_group_name = data.azurerm_resource_group.TerraformResourceGroup.name
}

data "azurerm_virtual_network" "TerraformVirtualNetwork" {
  name                = var.virtualNetwork
  resource_group_name = data.azurerm_resource_group.TerraformResourceGroup.name
}

data "azurerm_subnet" "TerraformSubNet" {
  name                 = var.subnet
  virtual_network_name = var.virtualNetwork
  resource_group_name  = data.azurerm_resource_group.TerraformResourceGroup.name
}

# Create public IPs
resource "azurerm_public_ip" "test" {
    name                         = var.publicIP
    location                     = "${data.azurerm_resource_group.TerraformResourceGroup.location}"
    resource_group_name          = "${data.azurerm_resource_group.TerraformResourceGroup.name}"
    allocation_method            = "Static"

}

# create a network interface
resource "azurerm_network_interface" "TerraformNetworkInterface" {
  name                = var.networkInterface
  location            = "${data.azurerm_resource_group.TerraformResourceGroup.location}"
  resource_group_name = "${data.azurerm_resource_group.TerraformResourceGroup.name}"

  ip_configuration {
    name                          = "testconfiguration1"
    subnet_id                     = "${data.azurerm_subnet.TerraformSubNet.id}"
    private_ip_address_allocation = "dynamic"
   // public_ip_address_id          = "${azurerm_public_ip.test.id}"
  }
}

resource "azurerm_virtual_machine" "TerraformVM" {
  name                  = var.VM
  location              = var.location
  resource_group_name   = data.azurerm_resource_group.TerraformResourceGroup.name
  network_interface_ids = [azurerm_network_interface.TerraformNetworkInterface.id]
  vm_size               = "Standard_DS1_v2"

 storage_image_reference {
    id  = "/subscriptions/----/resourceGroups/TerraformResourceGroup/providers/Microsoft.Compute/images/TerraformVM-image-20210202111108"
    }

  storage_os_disk {
    name              = "Imagedisk"
    caching           = "ReadWrite"
    create_option     = "FromImage"
    managed_disk_type = "Standard_LRS"
    }

  os_profile {
    computer_name  = var.name
    admin_username = var.username
    admin_password = var.password
  }

  os_profile_windows_config {
     provision_vm_agent = true
  }

  tags = {
    environment = "staging"
  }
}

Could you please help

A: From the error message, you are missing parameters in azurerm_network_interface.
You need to add location and resource_group_name in resource "azurerm_network_interface":
Here is an example:
    provider "azurerm" {
        version = "2.0.0"
        subscription_id = var.subscriptionID

        features {}
    }

    variable "prefix" {
         default = "tfvmex"
     }

    resource "azurerm_resource_group" "TerraformResourceGroup" {
      name     = "${var.prefix}-resources"
      location = "West US 2"
    }
   resource "azurerm_network_security_group" "TerraformSecurityGroup" {

   }

    resource "azurerm_virtual_network" "TerraformVirtualNetwork" {
      name                = "${var.prefix}-network"
      address_space       = ["10.0.0.0/16"]
      location            = azurerm_resource_group.main.location
      resource_group_name = azurerm_resource_group.main.name
    }

    resource "azurerm_network_interface" "TerraformNetworkInterface" {
      name                = "${var.prefix}-nic"
      location            = azurerm_resource_group.main.location
      resource_group_name = azurerm_resource_group.main.name

    }

    ......

For more detailed info, you could refer to this doc about Terraform azurerm_virtual_machine.

A: The Terraform import command does not generate a Terraform resource configuration. Instead, it imports your existing resources into Terraform's state.
After importing your existing resources into the state file. You need to manually create a corresponding resource configuration file referring to the information provided by the state and manage your existing infrastructure with Terraform.
For example, you can run terraform show, which provides human-readable output from a state or plan file.

Then you can copy the attributes of name and location and contents to fill the block of
resource "azurerm_resource_group" "TerraformResourceGroup" {
    location = "westeurope"
    name     = "nancyexample-resources"
}

You can fill the remaining blocks in the same way. After that, you can check for errors in your configuration by running the terraform plan command. Terraform plan shows you the changes that would take place if you were to apply the configurations with the terraform apply command. If there are any arguments missing or not set, you can modify your configuration file to meet the requirements.
Once you have verified the configurations, you can run terraform apply to create the new resources. For more information, see Import Terraform configuration.


text:
Q: Connect SPWF04SA using WPA2 and MicroPython I am trying to connect an STM32 Nucleo WIFI expansion board (SPWF04SA) to our wireless network using the built-in MicroPython interpreter. According to the datasheet it is supposed to be supported.
I can list the available networks using
import network
wlan = WLAN()
nets = wlan.scan()
for net in nets:
    print(net)

And I get
(ssid='PE0000', bssid='00:13:60:FF:8F:2D', auth='WPA2 ', channel=4, rssi=-65)
(ssid='PE9000', bssid='02:13:60:FF:8F:2D', auth='WPA2 ', channel=4, rssi=-67)
(ssid='PE0200', bssid='B8:C7:5D:07:CF:D3', auth='WPA2 ', channel=6, rssi=-85)

I then try to connect to network PE9000 (or any of them for that matter) using:
wlan.connect('PE9000',(WLAN.WPA2,'xxxx'))

And I get:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: type object 'WLAN' has no attribute 'WPA2'

If I try to use WLAN.WPA for the security type I don't get the error but, obviously, it won't connect to the network.
Any help would be appreciated.

A: I was having this same problem with my ESP8266 module. I have included some code below that helped me fix the issue. I am using micropython 1.9.2.
    configuration_filename = 'configuration.json'

    station_config = network.WLAN(network.STA_IF)

    if not station_config.isconnected():
        with open(configuration_filename, 'r') as configuration_file:
            json_configuration = configuration_file.read()
            json_config = json.loads(json_configuration)

            ssid = json_config['ssid']
            password = json_config['password']
            station_config.connect(ssid, password)
            while not station_config.isconnected():
                machine.idle() # save power while waiting
            print('WLAN connection succeeded!')

A: I finally got it working. In case anyone else ever runs into this it appears the syntax is slightly non-standard for these boards. Instead of calling wlan.connect() I had to use the following:
w.init(mode=WLAN.STA, ssid='PE9000', auth=(WLAN.WPA, 'xxxx'))

Even though I specify WPA instead of WPA2 it must figure it out and connect anyway.


text:
Q: Decomposition of a linear map to nilpotent and diagonalizable matrices. Question
Let $V$ be a vector space over the complex field $C$ , and let $T$ be an linear map $V\rightarrow V$. Show that exists a pair of linear maps $D$ and $N$ such that $D+N=A$, $D$ is diagonalizable, $N$ is nilpotent, and DN=ND.
I found this
endomorphism as sum of two endomorphisms (nilpotent and diagonalizable)
where he said "you can transform so that ϕ is on jordan form, and then split this matrix in a diagonal and a nilpotent"
But I didn't get his explanation. How can I decompose the jordan marix of T? any why does it proves the commute  and sum of the linear maps?
Any help would be appreciated,
Thanks!


text:
Q: Building a histogram from MongoDB with Pymongo I'm trying to create a histogram of MongoDB documents in the following format:
{
    "_id":1
    "Properties":[
    {
        "type": "a"
    },
    {
        "type": "d"
    }
    ]
}

{
    "_id":2
    "Properties":[
    {
        "type": "c"
    },
    {
        "type": "a"
    }
    ]
}

{
    "_id":3
    "Properties":[
    {
        "type": "c"
    },
    {
        "type": "d"
    }
    ]
}

The output in this example should be:
a = 2
c = 2
d = 2
My workaround at the moment includes querying the entire collection with:
collection.find({})

And afterwards traversing and accumulating the data with a python dictionary.
I'm sure that there's a better way to do this in the MongoDB query itself, can I achieve this data in a single query as I suspect?
Note that I don't know which "types" I may find before the query is performed.

A: In this case, you can use MongoDB aggregation.
More about Aggregation: https://docs.mongodb.org/manual/core/aggregation-introduction/
db.collection.aggregate([
    { $unwind : "$Properties" },
    { $group: { _id: "$Properties.type", count: { $sum: 1 } } }
]);

Output:
{
    "result" : [
        {
            "_id" : "c",
            "count" : 2.0000000000000000
        },
        {
            "_id" : "d",
            "count" : 2.0000000000000000
        },
        {
            "_id" : "a",
            "count" : 2.0000000000000000
        }
    ],
    "ok" : 1.0000000000000000
}

In Python:
from pymongo import MongoClient

if __name__ == '__main__':
    db = MongoClient().test
    pipeline = [
        { "$unwind" : "$Properties" },
        { "$group": { "_id": "$Properties.type", "count": { "$sum": 1 } } }
    ]
    print list(db.collection.aggregate(pipeline))

Output:
[{u'count': 2, u'_id': u'c'}, {u'count': 2, u'_id': u'd'}, {u'count': 2, u'_id': u'a'}]

A: Not sure if this can fit to your scenario, but you can do them separate by property like:
count_a = collection.find({'Properties.type':'a'}).count()
count_b = collection.find({'Properties.type':'b'}).count()
count_c = collection.find({'Properties.type':'c'}).count()

If you do not know the type you create a variable that would take different type and can simply do something like:
mistery_type = 'assign the misery type in var when you know it'
mistery_type_count = collection.find({'Properties.type': mistery_type}).count()


text:
Q: How to dettach input devices in startup? I would like to dettach external input devices connected to the computer on boot (external mouse, keyboard, badusb). Udev cannot help me with that because the input devices are connected in boot time.
I have tried to create a script via rc.local and xinput, however it seems like xinput is unknown in startup (when I run to script manually, it worked, so its a xinput and boot problem).
Are there other ways to do so in startup without blocking an entire usb port?

A: you can use (xinput):
xinput list
⎡ Virtual core pointer                     id=2 [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer               id=4 [slave  pointer  (2)]
⎜   ↳ MOSART Semi. HP Wireless Keyboard and Mouse id=10 [slave  pointer  (2)]
⎜   ↳ ELAN0707:00 04F3:30DA Touchpad           id=12 [slave  pointer  (2)]
⎜   ↳ ELAN2514:00 04F3:23C4                   id=13 [slave  pointer  (2)]
⎜   ↳ ELAN2514:00 04F3:23C4 Pen               id=14 [slave  pointer  (2)]
⎣ Virtual core keyboard                   id=3 [master keyboard (2)]
    ↳ Virtual core XTEST keyboard             id=5 [slave  keyboard (3)]
    ↳ Power Button                             id=6 [slave  keyboard (3)]
    ↳ Video Bus                               id=7 [slave  keyboard (3)]
    ↳ Power Button                             id=8 [slave  keyboard (3)]
    ↳ MOSART Semi. HP Wireless Keyboard and Mouse id=9 [slave  keyboard (3)]
    ↳ HP Wide Vision HD Camera: HP Wi         id=11 [slave  keyboard (3)]
    ↳ Intel HID events                         id=15 [slave  keyboard (3)]
    ↳ Intel HID 5 button array                 id=16 [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard             id=17 [slave  keyboard (3)]
    ↳ HP WMI hotkeys                           id=18 [slave  keyboard (3)]
    ↳ HP Wireless hotkeys                     id=19 [slave  keyboard (3)]


text:
Q: How to manage the OCLogger file? I'm debugging a hybrid Worklight (6.1.0.01) application in Xcode (5.1.1).  I'm seeing the following message in my log:

[DEBUG] [OCLogger] Max file size exceeded for log messages.

I"m assuming that this log file is managed by Worklight, as I do not have any custom native code running or explicit references to OCLogger.  I do have calls to WL.Logger.debug.
How can I manage this log file?  And where is it on my file system?  (Truncating it will probably do the trick at this point.)

A: It is enabled by default. But you can disable using native or Javascript API Calls.
[OCLogger setCapture: NO];
For more info client side log capture
client side logging in client apps


text:
Q: Rails Dynamic Forms with Cascading Select I am trying to implement some nested form elements that have values based on a select box value in the main form. As it stands right now when I make the selection in the main form it changes the values displayed in all currently displayed nested form, but when I click the button to add a new nested form element, the new form elements display values that are not based on the primary select. What I need is for any time the button is clicked to add a new nested form, the values in that form should be based on the select box in the main form.
Here are the steps and what is happening:

Here are the steps and the desired results:

Here is what my partial looks like. This is what is displayed when the "new" button is clicked:

  <%= f.select :area_id, options_for_select(@areas.collect {|c| [ c.area_name, c.id ] }), {include_blank: true}, {:class => 'form-control area_select'} %>
  <%= f.select :product_id, options_for_select(@products.collect {|p| [ p.product_number, p.id ] }), {include_blank: true}, {:class => 'form-control product_select'} %>
  <%= f.number_field :quantity, class: 'form-control', "min" => 1 %>
  <%= f.select :accessory_id, options_for_select(@accessories.collect {|p| [ p.product_number, p.id ] }), {include_blank: true}, {:class => 'form-control accessory_select'} %>
  <%= f.text_field :notes, class: 'form-control' %>
  <%= link_to_remove_association ''.html_safe, f %>

All of this action is when I'm creating a new record, here is the code from my controller for the new method:
  def new
    if current_user
      @estimate = Estimate.new
      @estimate.estimate_details.build
      @default_user = current_user.id
      @product_type = 3
      @areas = Area.where("product_type_id = ?", @product_type)
      @products = Product.select("product_number, id").where("product_type_id = ? AND active = 't' ", @product_type)
      @accessories = Product.select("product_number, id").where("product_type_id = ? AND active = 't' AND accessory = 't'", @product_type)
    else
      redirect_to root_path, notice: 'You are not logged in.'
    end
  end

This is the method from the controller (the same controller as new above) that updates the select boxes:
  def update_select
    @product_type = params[:product_type_id]
    @areas = Area.where("product_type_id = ?", params[:product_type_id])
    @products = Product.where("product_type_id = ? AND active = 't'", params[:product_type_id])
    @accessories = Product.where("product_type_id = ? AND active = 't' AND accessory = 't'", params[:product_type_id])
    respond_to do |format|
      format.js
    end
  end

I was thinking that @product_type would be set to the default in the "new" method of the controller. When the update_select method is run, it should update the @product_type and this would be used when the new elements were created...but that didn't work.
Update
Here is my update_select.js. This does update the three select boxes in the nested form, but I have to add a dynamic form and then make a selection in the main form select box in order for the fields to be correct for the newly added form details.
$(".area_select").empty().append("<%= escape_javascript(render(partial: "select_boxes/area", collection: @areas)) %>")
$(".product_select").empty().append("<%= escape_javascript(render(partial: "select_boxes/product", collection: @products)) %>")
$(".accessory_select").empty().append("<%= escape_javascript(render(partial: "select_boxes/accessory", collection: @accessories)) %>")

Here are the partials referenced by the above js:
Accessory:
<option value="<%= accessory.id %>"><%= accessory.product_number %></option>

Product:
<option value="<%= product.id %>"><%= product.product_number %></option>

Area:
<option value="<%= area.id %>"><%= area.area_name.titleize %></option>

And just for good measure here is the script that triggers the update_select
$ ->
  $(document).on 'change', '#product_type_select', (evt) ->
    $.ajax
      url:'/estimates/new/update_select',
      type: 'GET',
      dataType: 'script',
      data: {
        product_type_id: $("#product_type_select option:selected").val()
      }
      error: (jqXHR, textStatus, errorThrown) ->
        console.log("AJAX Error: #{textStatus} #{errorThrown}")
      success: (data, textStatus, jqXHR) ->
        console.log("Dynamic area select OK!")


text:
Q: How can we prove that light is an Electromagnetic wave? In many books it is written that light is an electromagnetic wave, as we know there does not exist any oscillator that can oscillate an electron with a frequency of light.
My question is, how can we prove that light is electromagnetic in nature ? what is light ? is there any physical meaning.

A: This question comes from a false premise.
To say "you can't oscillate an electron at the speed of light" is like saying you can't drive a car at the temperature of boiling water. They're not measuring the same thing. Oscillation is a measure of cycles-per-unit-time. Speed is a measure of distance-per-unit-time. They're different things with different units.
We can absolutely oscillate electrons at the frequency of light. That's how radios work. A properly functional radio is proof that light is electromagnetic in nature. If light wasn't electromagnetic then it wouldn't induce a current in a radio antenna.
"What is light?" is a philosophical question with many different answers depending on the context. That's because a single "thing" can have multiple definitions. You could say the USA is "the country founded by George Washington" or "the nation-state immediately south of Canada" or "the federal republic formed in 1789". All three definitions refer to the same United States of America.
In physics, the word "light" has a well-defined physical meaning. But there's multiple ways of defining that one thing. You can define light as "electromagnetic wave", "photons" or "that stuff a lamp shoots at you". Which definition you use depends on who you're talking to and what you're talking about.

A:
how can we prove that light is electromagnetic in nature ?

The easiest way is to observe that it interacts with charged particles. The electromagnetic force is by definition the force that acts on charged particles. Furthermore, it is a long range force, unlike the strong and weak forces which act only over nuclear distances. So light acts at long distances and interacts with charged particles, therefore it is an electromagnetic force.
Besides this, it behaves as expected regarding electromagnetic interactions with materials. It is reflected by smooth conductors and dielectrics, and when it is reflected from dielectrics it becomes polarized.

A: The first indication was that the speed of light matches that predicted by Maxwell's electromagnetic equations.

A:
as we know there does not exist any oscillator that can oscillate an electron with a frequency of light

Wrong. There does exist such an oscillator, it's called wiggler, and is used in the free electron laser. Depending on magnetic field, velocity of the electron beam and period the magnet arrangement, it can generate a wide range of EM frequencies.

A: If two electrons in serial move in a resistance because of a voltage, then voltage makes them to move very close, whereas the electric fields of the electrons repel.  So, there is a strain in electric field and light energy is released.  Electric field between these two electrons in serial satisfies Maxwell equations.  So, light waves may be considered as electromagnetic waves.


text:
Q: How to configure prescaler and interrupt for the Timer used in the capture function of the ESP32's MCPWM module? I am working on a project where every 50ms I need to send a 15us pulse from a microcontroller port, to discharge a capacitor. During the counting of these 50ms, this capacitor is charged again, producing a sawtooth wave. Then, its output is connected to a comparator circuit, which in turn has its output connected to another port of the microcontroller. Thus, when detecting a falling edge on this port, the microcontroller must use a capture peripheral to get the value of the timer count.
This is used for 16-bit AD conversion of signals, and works well on PIC microcontrollers, however, I need to replace the PIC with an ESP32. To accomplish this task, I tried to use the capture function of the MCPWM module, but I cannot change the clock speed of the timer (which is 80Mhz) to overflow in 50ms, and I cannot set an overflow interrupt on this timer to send the 15us pulse to discharge the capacitor.
Is there a way of doing that using this microcontroller?


text:
Q: Are there any standards for tmlanguage keyword types? .tmlanguage files work by defining a list of key value pairs. Regular expressions are the keys and the type of syntax is the value. This is done in the following XML-ish manner:
<key>match</key>
<string>[0-9]</string>
<key>name</key>
<string>constant.numeric</string>

My main question is: Is there a list of values that could go in place of constant.numeric  if the file is to be used by a text editor like Sublime?

A: For a basic introduction, check out the Language Grammars section of the TextMate Manual. The Naming Conventions section describes some of the base scopes, like comment, keyword, meta, storage, etc. These classes can then be subclassed to give as much detail as possible - for example, constant.numeric.integer.long.hexadecimal.python. However, it is very important to note that these are not hard-and-fast rules - just suggestions. This will become obvious as you scan through different language definitions and see, for example, all the different ways that functions are scoped - meta.function-call, support.function.name, meta.function-call punctuation.definition.parameters, etc.
The best way to learn about scopes is to examine existing .tmLanguage files, and to look through the source of different languages and see what scopes are assigned where. The XML format is very difficult to casually browse through, so I use the excellent PackageDev plugin to translate the XML to YAML. It is then much easier to scan and see what scopes are described by what regexes:

Another way to learn is to see how different language constructs are scoped, and for that I highly recommend using ScopeAlways. Once installed and activated, just place your cursor and the scope(s) that apply to that particular position are shown in the status bar. This is particularly useful when designing color schemes, as you can easily see which selectors will highlight a language feature of interest.

If you're interested, the color scheme used here is Neon, which I designed to make as many languages as possible look as good as possible, covering as many scopes as possible. Feel free to look through it to see how the different language elements are highlighted; this could also help you in designing your .tmLanguage to be consistent with other languages.
I hope all this helps, good luck!

A: Yes. The .tmlanguage format was originally used by TextMate. The TextMate manual provides full documentation for the format, including the possible types of language constructs.
Copied from the relevant docs page, in hierarchical format:

*

*comment — for comments.

*

*line — line comments, we specialize further so that the type of comment start character(s) can be extracted from the scope

*

*double-slash — // comment

*double-dash — -- comment

*number-sign — # comment

*percentage — % comment

*character — other types of line comments.

*block — multi-line comments like /* … */ and <!-- … -->.

*

*documentation — embedded documentation.

*constant — various forms of constants.

*

*numeric — those which represent numbers, e.g. 42, 1.3f, 0x4AB1U.

*character — those which represent characters, e.g. <, \e, \031.

*escape — escape sequences like \e would be constant.character.escape.

*language — constants (generally) provided by the language which are "special" like true, false, nil, YES, NO, etc.

*other — other constants, e.g. colors in CSS.

*entity — an entity refers to a larger part of the document, for example a chapter, class, function, or tag. We do not scope the entire entity as entity.* (we use meta.* for that). But we do use entity.* for the "placeholders" in the larger entity, e.g. if the entity is a chapter, we would use entity.name.section for the chapter title.

*

*name — we are naming the larger entity.

*

*function — the name of a function.

*type — the name of a type declaration or class.

*tag — a tag name.

*section — the name is the name of a section/heading.

*other — other entities.

*

*inherited-class — the superclass/baseclass name.

*attribute-name — the name of an attribute (mainly in tags).
  we are naming the larger entity.

*invalid — stuff which is "invalid".

*

*illegal — illegal, e.g. an ampersand or lower-than character in HTML (which is not part of an entity/tag).

*deprecated — for deprecated stuff e.g. using an API function which is deprecated or using styling with strict HTML.

*keyword — keywords (when these do not fall into the other groups).

*

*control — mainly related to flow control like continue, while, return, etc.

*operator — operators can either be textual (e.g. or) or be characters.

*other — other keywords.

*markup — this is for markup languages and generally applies to larger subsets of the text.

*

*underline — underlined text.

*

*link — this is for links, as a convenience this is derived from markup.underline so that if there is no theme rule which specifically targets markup.underline.link then it will inherit the underline style.

*bold — bold text (text which is strong and similar should preferably be derived from this name).

*heading — a section header. Optionally provide the heading level as the next element, for example markup.heading.2.html for <h2>…</h2> in HTML.

*italic — italic text (text which is emphasized and similar should preferably be derived from this name).

*list — list items.

*

*numbered — numbered list items.

*unnumbered — unnumbered list items.

*quote — quoted (sometimes block quoted) text.

*raw — text which is verbatim, e.g. code listings. Normally spell checking is disabled for markup.raw.

*other — other markup constructs.

*meta — the meta scope is generally used to markup larger parts of the document. For example the entire line which declares a function would be meta.function and the subsets would be storage.type, entity.name.function, variable.parameter etc. and only the latter would be styled. Sometimes the meta part of the scope will be used only to limit the more general element that is styled, most of the time meta scopes are however used in scope selectors for activation of bundle items. For example in Objective-C there is a meta scope for the interface declaration of a class and the implementation, allowing the same tab-triggers to expand differently, depending on context.

*storage — things relating to "storage".

*

*type — the type of something, class, function, int, var, etc.

*modifier — a storage modifier like static, final, abstract, etc.

*string — strings.

*

*quoted — quoted strings.

*

*single — single quoted strings: 'foo'.

*double — double quoted strings: "foo".

*triple — triple quoted strings: """Python""".

*other — other types of quoting: $'shell', %s{...}.

*unquoted — for things like here-docs and here-strings.

*interpolated — strings which are "evaluated": `date`, $(pwd).

*regexp — regular expressions: /(\w+)/.

*other — other types of strings (should rarely be used).

*support — things provided by a framework or library should be below support.

*

*function — functions provided by the framework/library. For example NSLog in Objective-C is support.function.

*class — when the framework/library provides classes.

*type — types provided by the framework/library, this is probably only used for languages derived from C, which has typedef (and struct). Most other languages would introduce new types as classes.

*constant — constants (magic values) provided by the framework/library.

*variable — variables provided by the framework/library. For example NSApp in AppKit.

*other — the above should be exhaustive, but for everything else use support.other.

*variable — variables. Not all languages allow easy identification (and thus markup) of these.

*

*parameter — when the variable is declared as the parameter.

*language — reserved language variables like this, super, self, etc.

*other — other variables, like $some_variables.


text:
Q: Yahoo Pipes how to truncate items per feed with multiple feeds I have a Yahoo Pipe where I bring in a number of feeds via an OPML file. Rather than using truncate to limit the resulting number of items that get exported, I want to limit the number of items on a per feed basis. So if I have 60 feeds I want the latest 20 items from each one, not the latest 20 from the combined feeds.

A: You can do this by creating 2 pipes:

*

*A pipe that fetches a feed (one of the 60), and truncates after 20 items

*Another that loops over feed URLs, and for each URL calls the first pipe

Here's an example of the first pipe:
http://pipes.yahoo.com/pipes/pipe.info?_id=f6d1e5fa8873064f0265352e9ea9cd34
Here's an example of the second:
http://pipes.yahoo.com/pipes/pipe.info?_id=4b86c5d956b2f99a460a0520ff8c55b2


text:
Q: Sorting GridView on Another page as sorted on a previous page I have a gridview in my application.
On click of a button, same grid with same columns is also loaded in another page.
Now what I want to do is if user has sorted the grid with some column on 1sr page, grid on another page which loads on click of button should also be sorted with same column which user has selected on previous page.
How can I achieve this.
Any help in this regard would be appreciated... :)

A: I believe you could use a session variable to store the sort direction. So, when you are loading the GridView you ask for the session variable in order to sort it properly.
It should be something similar to this:
private string getSortDirectionString()
    {
        if (Session["sortDirection"] == null)
        {
            Session["sortDirection"] = "ASC";
        }
        else
        {
            if (Session["sortDirection"].ToString() == "ASC")
            {
                Session["sortDirection"] = "DESC";
                return Session["sortDirection"].ToString();
            }
            if (Session["sortDirection"].ToString() == "DESC")
            {
                Session["sortDirection"] = "ASC";
                return Session["sortDirection"].ToString();
            }
        }
        return Session["sortDirection"].ToString();
    }

And this is how you should sort your GridView:
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
    {
        listBind(); //procedure to populate your GridView
        DataSet dsSortTable = GridView1.DataSource as DataSet;
        DataTable dtSortTable = dsSortTable.Tables[0];
        if (dtSortTable != null)
        {
            DataView dvSortedView = new DataView(dtSortTable);
            dvSortedView.Sort = e.SortExpression + " " + getSortDirectionString();
            Session["sortExpression"] = e.SortExpression;
            GridView1.DataSource = dvSortedView;
            GridView1.DataBind();
        }
    }

In this way you'll always have the sortExpression stored in the session variable and you could use it across the whole app.
Hope this helps!

A: As a rough outline you could -

*

*Write a value to a hidden field when the sort param of the first grid
is changed

*Pick up the parameter when moving to the second page and append it to
the querystring

*On the second page retreive the parameter form the querysting and
sort the grid accordingly


text:
Q: A reference pages for the latest version of c++ For c++03, there are next reference pages :

*

*cplusplus

*IBM pages for c++

*MSDN c++ reference pages

I used cplusplus as reference pages as a reference for c++ classes and functions (I am aware it is has errors, but is quite ok).
However, all these pages are for c++03.
Are there similar pages for c++11?

A: I usually refer to the latest
standard draft
You can also check cppreference.com, but it is still incomplete.

A: I often refer to the Bjarne Stroustrup's "C++0x - the next ISO C++ standard" page.


text:
Q: IPython Notebook in a virtualenv, using Python 3.3 I have my Ubuntu 12.04 system set up so that I can create a virtualenv with either Python 2.7 or Python 3.3, and run IPython Notebook. The problem is, I don't know exactly what I did to my system to make this possible. I am trying to help someone else get their system set up the same way, and I'm not sure what packages I am missing.
On my system I can run the following commands to get IPython Notebook running in a virtualenv:
~$ mkdir test_ipython3.3
~$ cd test_ipython3.3
~/test_ipython3.3$ virtualenv -p python3.3 venv
~/test_ipython3.3$ source venv/bin/activate
(venv)~/test_ipython3.3$ pip install ipython[all]==1.1.0

I can do the same set of commands with virtualenv -p python2.7 venv, and have an almost identical environment except it runs Python 2.7.
I am trying to get a 12.04 installation on virtualbox set up so that I can run these commands successfully as well, but I keep failing. After building a clean Ubuntu 12.04 machine in virtualbox, I do the following:
# Update machine:
sudo apt-get update
sudo apt-get dist-upgrade

# Install Python 3.3:
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:fkrull/deadsnakes
sudo apt-get update
sudo apt-get install python3.3

# Install virtualenv
sudo apt-get install python-pip
sudo pip install pip --upgrade
sudo pip install virtualenv

# Install necessary packages:
sudo apt-get install python-dev python3.3-dev libzmq-dev

# Build a venv, using Python 2.7, which works:
~$ mkdir test_ipython2.7
~$ cd test_ipython2.7
~/test_ipython2.7$ virtualenv -p python2.7 venv
~/test_ipython2.7$ source venv/bin/activate
(venv)~/test_ipython2.7$ pip install ipython[all]==1.1.0
(venv)~/test_ipython2.7$ ipython notebook
# Works, opening an ipynb that runs Python 3.3

# Build a venv, using Python 3.3, which fails:
~$ mkdir test_ipython3.3
~$ cd test_ipython3.3
~/test_ipython3.3$ virtualenv -p python3.3 venv
~/test_ipython3.3$ source venv/bin/activate
(venv)~/test_ipython3.3$ pip install ipython[all]==1.1.0
(venv)~/test_ipython3.3$ ipython notebook
# Fails, says that ipython is not installed, despite having reported otherwise

After trying to install ipython in the 3.3 virtualenv, I get a message that ipython and a number of supporting packages have been installed successfully. But when I try to run ipython or ipython notebook, I get a message that ipython is not installed. Watching the install process, and scrolling back through the output, I can't find any obvious failures. I even installed zmq from source, so I have zmq 4.0.3 installed, which ipython is finding during its installation.
Can anyone spot where I am going wrong?

A: IPython 1.x creates scripts with a '3' suffix when installed with Python 3, to avoid conflict with IPython installed with Python 2, so the command you want is:
ipython3 notebook

In current development IPython (will be 2.0), this behavior is changed somewhat, where IPython installs both the non-suffix and the suffix entry points (ipython and ipython3 on Python 3, ipython and ipython2 on Python 2), following the pattern established by other packages, such as nose.

I'm still quite curious about the best way to install ipython when you want access to a 2.7 interpreter sometimes, and a 3.3 interpreter other times.

There are two ways to deal with this:
The first is to create an ipython script somewhere very high priority in your PATH (I use ~/bin),
with the contents:
#!/usr/bin/env python
import IPython
IPython.start_ipython()

This will use the current python on your PATH, no matter what, so when you activate a Python 3 env, ipython will use that, etc.
The second is to just use:
python -m IPython

or
python3 -m IPython

which is the same as typing ipython, but you are specifying the interpreter to use explicitly, so there can be no doubt about what Python is in use.

A: These problems seem to be solved at: http://ihrke.github.io/jupyter.html


text:
Q: Simple Couchbase with C# client setup failing I'm trying to set up a simple sample Couchbase setup, communicating over the C# client, but it's giving me fits.  I've installed Couchbase and added a memcached bucket.  Here is my simple code for communicating with it:
public static void MemcachedTest()
{
    CouchbaseClient client = new CouchbaseClient(); // failure point!
    client.Store(Enyim.Caching.Memcached.StoreMode.Set, "Testing", "Hello world");
    var test = client.Get("Testing");
}

Here is my app.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
  <configSections>

  </configSections>
  <couchbase>
    <servers bucket="testbucket">
      <add uri="http://127.0.0.1"/> // tried lots of different values here.
    </servers>
  </couchbase>
  <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" /></startup>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

The error is a null reference exception with no inner exception details.  The stack trace is:
at Couchbase.CouchbaseClient..ctor(ICouchbaseClientConfiguration configuration)
at Couchbase.CouchbaseClient..ctor()
at CacheClientTests.Program.MemcachedTest() in C:\Dev\Experiments\CacheClientTests\CacheClientTests\CacheClientTests\Program.cs:line 72
at CacheClientTests.Program.Main(String[] args) in C:\Dev\Experiments\CacheClientTests\CacheClientTests\CacheClientTests\Program.cs:line 79
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Why is this simple configuration failing?

A: Your problem is the App.config is not structured correctly and you are not specifying port 8091 in your bootstrap URI:
<configuration>
  <configSections>

  </configSections>
  <couchbase>
    <servers bucket="testbucket">
      <add uri="http://127.0.0.1:8091/pools"/>
    </servers>
  </couchbase>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
  </startup>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

That should work correctly. Your specific problem was the <startup> element wasn't lined up correctly - note that if there is a <configSections> section it must be the first element after <configuration>.


text:
Q: Porqué se ejecuta la primera línea de código de la función antes de ser llamada(UnboundLocalError: local variable 'plan' referenced before assignment) Tengo el siguiente código:
plan=[]

def newUser():
    plan[0] = input('Introduce tu plan (Lite/Pro/Mega): ')
    print(plan[0])

newUser()

La primera línea de código de la función se ejecuta antes de que se llame a la misma, y luego cuando se llama la función da el siguiente error:

UnboundLocalError: local variable 'plan' referenced before assignment

¿Qué debo hacer para evitar que se ejecute la primera línea de la función antes de ser llamada?
Dejo también un enlace al vídeo debuggeando el código para que veáis en concreto

https://mega.nz/file/g1tSTQiA#Uf4Xwo28nnw_I9ml-NWr9kI_7Wly5b26YmMnesn7gjA

A: Prueba poniendolo de esta manera:
def newUser():
    plan = input('Introduce tu plan (Lite/Pro/Mega): ')
    print(plan)

newUser()

Así usas una variable en lugar de un array para guardar el valor, que es lo que está causando el problema.


text:
Q: Terraform: How to use locate the Bitnami Kafka AMI ID I was wondering how to list all of the Bitnami Kafka AMI ID for all the size offering?

A: You can try the aws_ami_ids data source https://www.terraform.io/docs/providers/aws/d/ami_ids.html:
provider "aws" {
  region = "us-east-1"
}

data "aws_ami_ids" "bitnami_kafka" {
  owners = ["979382823631"] # bitnami

  filter {
    name   = "name"
    values = ["bitnami-kafka-*"]
  }
}

output "bitnami_kafka_ids" {
  value = "${data.aws_ami_ids.bitnami_kafka.ids}"
}

This is more or less the same than doing:
aws ec2 describe-images --owners 979382823631 --filters "Name=name,Values=bitnami-kafka-*", but with Terraform, it only returns the AMI ids.


text:
Q: Mockito returns null instead of Future.successful I'm having a bit of a problem getting Mockito to return a Future which gets mapped in the unit under test.
The stubbed method in question is this:
when(urlRequest.post(any())).thenReturn(Future.successful(badOAuthResponse))

Where badOAuthQuery is a Map defined elsewhere and badOAuthResponse is a mocked WSResponse defined elsewhere.
The line in question where it gets called is:
val response = client.url(oAuthUrl).withHeaders(headers: _*).post(requestMap)

Where client is a mocked WSClient, with its methods stubbed elsewhere.
I've narrowed the problem down somewhere around the POST request. Stepping through the debugger shows that all the previous method calls before the .post() return fine, but stepping past the line, response is set to null.
The line afterwards, where the NullPointerException actually gets triggered, is this:
response.map { resp =>

Obviously the problem is that response was set to null in the line before, but I don't know why Mockito doesn't return a successful Future containing the mocked object above.
Any help would be hugely appreciated! Thanks!

A: Ok, I figured out the problem, after a lot of head scratching. It turns out that the object I was mocking (WSRequestHolder) has two methods called post: post(body: File) and post[T](body: T)(implicit wrt: Writeable[T], ct: ContentTypeOf[T]). I had assumed that my mock was set up for the latter method call, but it turns out that I needed to more explicitly call the method as follows:
when(urlRequest.post[Map[String, Seq[String]]](any())(any(), any())
  .thenReturn(Future.successful(badOAuthResponse))


text:
Q: Determining highway direction in here maps Does Here map iOS sdk provides Highway direction?
Example: While driving on US Highways/Interstate, Here map is providing information like I-5 or WA-14.
Can we get which highway/interstate direction we are heading into. Like I-5 N or WA-14 S.

A: You can allways use course infromation taken from currentPosition(NMAGeoPositon object) of the NMAPositionManager.
Swift
NMAPositionManager.sharedInstance().currentPosition?.course

or Objective-C
[NMAPositionManager sharedPositioningManager].currentPosition.course

Valid course values are in the range [0, 360), with 0 degrees representing north and values increasing clockwise. Thus, east is 90 degrees, south is 180 degrees, and so on. Will be NMAGeoPositionUnknownValue if unknown.

Also it can be obtained from waypoint course.
calculatedRoute.waypoints[idx].course;

or aliases 'start', 'destination' can be used
calculatedRoute.start.course;
calculatedRoute.destination.course;

Another one is to use mapOrientation of maneuver
calculatedRoute.maneuvers[idx].mapOrientation

The angle (from north) at the start of the maneuver, in degrees. Zero represents true-north, with increasing values representing a clockwise progression of map orientation.


text:
Q: How to create time sheet approver in Sharepoint 2010 i am new to stack overflow and also newbie to Sharepoint. I want to create a approver for approving the time sheet in Sharepoint 2010.The approver should be able to approve all the time-sheets. how can i do that?

A: Create One New user and Add that user to the Approvers group for that TimeSheet List.
IF you dont understand then let me know


text:
Q: Save database storage or save queries accesing to multiple tables? I am considering the structural database´s design of the following specific problem:
I have 2 different tables belonging to the same database. In the first table the detailed data of different objects is stored, where the column id refers to the the specific object.
On the other hand, the second table stores every single change that the objects in the first table have perceived. Every single row in our second table stores as well the id referencing to the object as the version_id which defines the different state versions of the objects, that is every single change effectuated.
Now let´s say the 'eliminated' parameter is set to "true" in a row of objects table for declaring an object as not visible in the object´s manager site. In our display site the table version is accesed for showing a linked object´s version, nevertheless the system shouldn´t display it if the object refered by id is marked as eliminated.
For solving this problem, I have two possible solutions: either increment the database storage, adding an eliminated column to theversion table, or I add a query in php for processing the parameter eliminated from the objects table after receiving the object id from the version table.
I want to know which disadvantage and advantage are presented in both different solutions, if saving storage cost would be prefarable than processing more queries and accesing multiple queries for receiving the data, or if contrary sacrificing storage cost and spreading the eliminated column into the version table leads to a better response time performance of the site by sparing multiple queries for accesing data from other tables.
CREATE TABLE `objects` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `eliminated`  tinyint(1) DEFAULT NULL,
  ...

  PRIMARY KEY (`id`),
 KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8

CREATE TABLE `version` (
 `version_id` int(11) NOT NULL AUTO_INCREMENT,
 `object_id` int(11) NOT NULL,
 `eliminated`  tinyint(1) DEFAULT NULL, //optional
  ...

  PRIMARY KEY (`version_id`),
 KEY `id` (`version_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8

A: The advantage of adding an eliminated column to the version table is that it provides you with details of the object elimination. It allows you to store details of the elimination for the object.
The drawback is that you are saving an extra row and also adding an extra column, which can create an overhead if there are a lot of rows in the table.
Which solution you use depends on how much data is being stored in your tables and also what data needs to be displayed to the user