text:
Q: Definition issue JPA with 3 tables and composite primary keys I have three jpa-defined tables: 'continent', 'country', and 'region'.
They have whole part relations, ie. a country cannot exist without a continent.
Therefore I modeled the classes for continent and country and the spring generated ddl is fine, everything works:
@Entity
public class Continent {

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private Short id;
//[..]
}

@Entity
public class Country implements Serializable {

    private static final long serialVersionUID = -6825504967607930373L;

    @Id
    @ManyToOne
    @JoinColumn(name="continent_id")
    private Continent continent;

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private Short id;
//[..]
}

But if I add Region, I don't know how to define the relation without hibernate giving me an error during initialization (see below).
@Entity
public class Region {

    @Id
    @ManyToOne
    @JoinColumns({
//      @JoinColumn(name="continent_id"),
        @JoinColumn(name="country_id")
    })
    private Country country;

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    Short id;

//[..]
}

This definition gives me the error
Caused by: org.hibernate.MappingException: Foreign key (FK_otariwhls1krq0bo780jtvbqn:region [country_id])) must have same number of columns as the referenced primary key (country [id,continent_id])
at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.java:110)

but if I remove the // from the continent_id join column i get this error instead:
Caused by: org.hibernate.AnnotationException: A Foreign key refering com...Country from com...bo.Region has the wrong number of column. should be 1
at org.hibernate.cfg.annotations.TableBinder.bindFk(TableBinder.java:502)

What am I doing wrong? I'm using Hibernate 4.3.11 final on mysql in a Springboot 1.3 environment.

A: Use only the @JoinColumn(name="country_id") wihtout @JoinColumns (note the plural) and remove the @Id from the Region.country property.


text:
Q: Why isn't _mm_div_epi64/_mm_div_epu64 defined? I've noticed that _mm_div_epi64/_mm_div_epu64 isn't defined in the headers for simd intrinsics and I don't get why it wouldn't. If it was multiplication it would make sense since 64bit * 64bit = 128bit, which would overflow but 64bit / 64bit = 64bit.
Unless there's some unforeseen issue with 64bit division for xmm registers.
Note: I am using Visual Studio 2017

A: Which header are you looking in?  According to the Intel Intrinsics Guide, both of those instructions are defined in "immintrin.h".

redpajama_set_name: RedPajamaStackExchange


text:
Q: I am using Hortonworks sandbox for Hadoop ...How do I debug Java code in eclipse? I'm using Hortonworks sandbox for Hadoop, But I am using Eclipse on Windows for the Java code. And hortonworks sandbox installed in Oracle virtual box. I created executable jar for that Java code and then run in hortons. How do I debug the Java code in eclipse?

A: One of the way debugging Hadoop in Eclipse is by running hadoop in local mode because map reduce task run in its own JVM.
Also explore MRUnit and Jumbune's debugger.
https://github.com/impetus-opensource/jumbune
The below blogposts may also help you.
http://let-them-c.blogspot.com/2011/07/running-hadoop-locally-on-eclipse.html
http://let-them-c.blogspot.com/2011/07/configurations-of-running-hadoop.html
How to debug hadoop mapreduce jobs from eclipse?


text:
Q: 3D Animation Between Activity in Android How to create animation between two Activity look like As Screen shot in android

A: Search for jazzyviewpager. this is the  link to the library. It has many cool animations to play with.

A: I think it's not activity animation, i believe it's fragments animation , activity animation is much more hard to implement smooth ,  read here about fragment

A: You may need to override Activity.overPendingtransition, and define transition animations in xml. Refer to this.


text:
Q: How do you delete only the duplicates that fulfill another condition in R? I want to clean up this data-set.Example Table

It contains many duplicates. I want to delete only the duplicates from the UUID column that have the highest value in the column Shape_Area. A loop must be created that detects the duplicates and compares the values from column Area within the found duplicates.
I've tried the duplicate function, but I cannot trust that the selected value is the greatest value from column Area.
I want an Output table that includes unique values that have the greatest value in column Area.
Can anyone help on this one?

A: you can use the dplyr package like this
library(dplyr)
newdata <- mydata %>%
    group_by(UUID) %>%
    arrange(-Shape_Area) %>%
    slice(1)

For each value of UUID this code creates a group and then arranges each group with respect to Shape_Area. Then only the first row (e.g. the highest value) is selected.
If you want to save this data use this:
write.csv(newdata, file = "Output.csv")


text:
Q: Creating an Internal Only Service in Kubernetes Im trying to create an internal service only within kubernetes. Its a clamav service, the docker container runs on port 3310. I have created a deployment and a service.
I have put the service and deployment in a 'clamav' namespace
I have port forwarded both the service and pods and can confirm it works as expected.
If I connect directly to the pod and run curl localhost:3310 its good, if i curl clamav (no port as ive configured 80 as the incoming service port) (which clamav being the service name) I get the following 503 error:
upstream connect error or disconnect/reset before headers. reset reason: connection termination

If I connect to a different service and try the same curl clamav.clamav I get the same error. (no port as ive configured 80 as the incoming service port)
Do I need something else other than a service and deployment or is something misconfigured?
The service spec is shown below.
spec:
  clusterIP: 10.10.255.194
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: 3310
  selector:
    app: clamav
  sessionAffinity: None
  type: ClusterIP

I have tried changing the name to "3310-3310" and changing the port to "3310" as well... had to update the curl commands to have the :3310 for the port... but same error.
Also just to add, I do have the istio service mesh running in this cluster and injected.
Thanks
Kevin

A: The answer to this was the service, changing it to:
spec:
  clusterIP: 10.10.255.194
  ports:
  - name: tcp-clamav
    port: 80
    targetPort: 3310
  selector:
    app: clamav
  sessionAffinity: None
  type: ClusterIP

Fixed the issue


text:
Q: How to Get Links Wthin a Parent Div to not Toggle I have the following code to toggle elements in a list when the parent div ".row" is clicked to show more content ".ExpandPane" however when links within that parent div ".row" is click they also activate the toggle function
Is there a way I could solve this I would like to be able to click anywhere in the parent div ".row" but allow the links within that parent div ".Row" to function as normal and not activating the toggle function.
Html

content.....

content...

content....

JQuery
 $(".Row").toggle(
      function () {
        $(this).find('.ExpandPane').show();
        //$(this).find('.PhotoShow').hide();
        //$(this).find('.PhotoHide').show();

      },
      function () {
        $(this).find('.ExpandPane').hide();
        //$(this).find('.PhotoHide').hide();
        //$(this).find('.PhotoShow').show();
      });

$(".acceptBtn").click(function(event) {
  alert("hi");
});

A: $(".acceptBtn").click(function(event) {
  alert("hi");
  event.stopPropagation();
});

stopPropagation() prevents the event from bubbling up to your parent divs. Also, this question has been answered about 100 times on SO.


text:
Q: Mobile SO site doesn't show comment edit link in Firefox The stock Android browser shows an edit link for comments. The Firefox version doesn't.
(Somewhat related, the edit box in the Android browser is reallllly tiny.)

A: Firefox mobile isn't really supported, it's market share is too low (I just checked, we've seen it from less than 5k clients in the last 48 hours) and doesn't ship as the built in browser on any major devices.
If this were a big break (couldn't view questions, or similar) then we'd fix it, but comment editing is too minor.


text:
Q: wireless not working after installing Lubuntu 14.04 after i installed lubuntu my wifi is not working.
########## wireless info START ##########

Report from: 25 May 2015 17:02 IST +0530

Booted last: 25 May 2015 16:38 IST +0530

Script from: 21 May 2015 09:10 UTC +0000

##### release ###########################

Distributor ID: Ubuntu
Description:    Ubuntu 14.04.1 LTS
Release:        14.04
Codename:       trusty

##### kernel ############################

Linux 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:12 UTC 2014 i686 i686 i686 GNU/Linux

Parameters: ro, quiet, splash, vt.handoff=7

"wireless-info.txt" 380 lines, 11905 characters


text:
Q: Unable to append div and change display mode I have one div with id controlContainer and I have 3 other div whose display is none and I am appending and prepending them using jQuery, and changing the display mode to block but it doesn't work.

$(document).ready(function() {
  var i = 1;
  if (i = 1) {
    var group = $('#beforeUpload').clone().attr("id", "beforeUpload" + i);
    $(group).css("Display", "block");
    $(group).appendTo("#controlContainer");

    var group2 = $("#uploadHeading").clone().attr("id", "uploadHeading" + i);
    $(group).css("Display", "block");
    $("#beforeUpload" + i).prepend(group2);

    var group5 = $('#afterUpload').clone().attr("id", "afterUpload" + i);
    $(group).css("Display", "block");
    $(group5).appendTo("#beforeUpload" + i);
  }
});

Main Container

It will append to "Main Container" and this is Before Upload

It will prepend to "Main Container" and this is Upload Heading

It will append to "Main Container" and this is After Upload

A: Firstly your Display should be display in css wasn't correct secondly you were not appending to right group and i have also updated latest jquery version.
This will work for you:

$(document).ready(function () {
    var i = 1;
    if (i = 1) {
        var group = $('#beforeUpload').clone().attr("id", "beforeUpload" + i);
        $(group).css("display", "block");
        $(group).appendTo("#controlContainer");

        var group2 = $("#uploadHeading").clone().attr("id", "uploadHeading" + i);
        $(group2).css("display", "block");
        $("#beforeUpload" + i).prepend(group2);

        var group5 = $('#afterUpload').clone().attr("id", "afterUpload" + i);
        $(group5).css("display", "block");
        $(group5).appendTo("#beforeUpload" + i);
    }
});
<!DOCTYPE html>

 <title></title>

Main Container

It will append to "Main Container" and this is Before Upload

It will prepend to "Main Container" and this is Upload Heading

It will append to "Main Container" and this is After Upload

A: As @Rory McCrossan stated:
1.Display needs to be display.
2.You've reused group variable in several places instead of the correct groupN variable.
3.if (i = 1) { //assignment needs to be if (i == 1) { //comparison
Correct that and your code will work.
Working snippet:-

$(document).ready(function () {
  var i = 1;
  if (i == 1) { //check with ==
    var group = $('#beforeUpload').clone().attr("id", "beforeUpload" + i);
    $(group).css("display", "block");
    $(group).appendTo("#controlContainer");

    var group2 = $("#uploadHeading").clone().attr("id", "uploadHeading" + i);
    $(group2).css("display", "block"); // need to be group2 instead of group
    $("#beforeUpload" + i).prepend(group2);

    var group5 = $('#afterUpload').clone().attr("id", "afterUpload" + i);
    $(group5).css("display", "block");// need to be group5 instead of group
    $(group5).appendTo("#beforeUpload" + i);
  }
});

<!DOCTYPE html>

    <title></title>

Main Container

It will append to "Main Container" and this is Before Upload

It will prepend to "Main Container" and this is Upload Heading

It will append to "Main Container" and this is After Upload

Note:- Try to use latest jQuery library


text:
Q: Why is CloudFront varying CORS headers response based on Accept-Encoding? I'm trying to get CORS to work properly with Amazon S3 + CloudFront.
After setting my CORS Configuration, it seems to work properly:
$ curl -H "Origin: https://app.close.io" -I "https://d4389n07pf8cq.cloudfront.net/built/app.9e1f9ee9.js" -s | grep Access
Access-Control-Allow-Origin: https://app.close.io
Access-Control-Allow-Methods: GET, HEAD
Access-Control-Max-Age: 3000
Access-Control-Allow-Credentials: true

But when the resource is requested with Accept-Encoding: gzip then the CORS headers aren't returned properly.
$ curl -H "Origin: https://app.close.io" -H "Accept-Encoding: gzip" -I "https://d4389n07pf8cq.cloudfront.net/built/app.9e1f9ee9.js" -s | grep Access
(nothing)

Why is that?
My CORS configuration looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
    <CORSRule>
        <AllowedOrigin>https://app.close.io</AllowedOrigin>
        <AllowedMethod>GET</AllowedMethod>
        <AllowedMethod>HEAD</AllowedMethod>
        <MaxAgeSeconds>3000</MaxAgeSeconds>
        <AllowedHeader>Authorization</AllowedHeader>
        <AllowedHeader>Content-*</AllowedHeader>
        <AllowedHeader>Host</AllowedHeader>
        <AllowedHeader>Accept-Encoding</AllowedHeader>
    </CORSRule>
</CORSConfiguration>

(I've also tried a CORS configuration with the Accent-Encoding header removed.)
The S3 object itself is gzipped, and has "Metadata" of Content-Encoding: gzip, Cache-Control: public, max-age=31536000, and Content-Type: application/javascript.
I don't understand why CloudFront+S3 CORS isn't working properly when requesting gzip.

A: I think that the problem you are having is caused by CloudFront's lack of native support for CORS. At this time they do not support Vary on the Origin header so it's possible that CloudFront delivered an old cached response that did not have the correct CORS headers for your second request (with accept encoding: gzip).
Have a look at this thread on the AWS forum for a workaround to this missing CORS support:
https://forums.aws.amazon.com/message.jspa?messageID=422504#422532

A: On June 26, 2014 AWS released proper Vary: Origin behavior on CloudFront so I added some instructions on this question reflecting how we got it set up right.

A: This might help for you as I've successfully gotten CORS to work on S3 and Cloudfront. I noticed the first time S3 and Cloudfront pull files they pretty much cache the headers, even after you've changed them.  Be sure "query param" versioning is enabled and you can add ?v=1 to the end of your file. This "updated" the headers for us and CORS was all good.


text:
Q: TypeError: Cannot call method 'then' in failed test of Restangular call I'm having a bit of trouble testing an AngularJS controller that is using Restangular to query an API. The test fails with TypeError: Cannot call method 'then' of undefined which is in reference to the promise returned from Restangular.
I've reproduced the error in plunker here
I know I'm overlooking something small, but I can't figure out what it is?
Using AngularJS 1.2.5 and Restangular 1.2.0.

A: It looks like you are trying to resolve the promise again inside your test.
Since it's already been then()'d in the controller, you just need to set it to the variable you set in the callback:
        resolvedValue = $scope.disaggregators;

instead of doing then() again.
See updated plunkr here
note: I hard set the response to match since the api call doesn't work


text:
Q: Capped collections - BsonId, uniqueness and index I want to use a capped collection as a cache store, I plan on selecting using a compound index - key and expiry-date. Since it's impossible to update/delete from a capped collection, I will add new entries with new expiry dates and just select the one with future expiry.
1) Is this the optimal way of creating the index if I'll be using Query.GTE("expiry", DateTime.Now) in the query?
cacheColl.EnsureIndex(new IndexKeysBuilder().Ascending("key").Descending("expiry"));

2) Do I need a [BsonId] attribute on the class? I know that "key" won't be unique. Does a record need to have a unique id entry??
3) My only motivation for using a capped collection is to limit the final size of the cache (both disk and memory) and not having to delete expired cache items myself. Is there a reason to prefer a regular collection and update items / delete expired ones? Even if I delete the documents, I read that space is not freed (would I need to compact?)

A: 1) The index looks about right. You can also add a sort descending and limit 1 to the query if you only care about the latest.
2) No. In a capped collection, _id is not automatically created and is not required. The reason why I needs to be unique on normal collections is because a unique index on _id is created for that collection by default.
3) There are pros and cons to both approach and which is better is totally dependent on your needs. One thing you might want to consider about capped collection is that it will not be easy to resize the collection once you created it. This will be problematic if you realize later on that the size you initially set was too small to fit into the time frame window that you needed.
P.S. You are right about the part that the space used by extents of a deleted document is not being freed back. However, Mongo keeps track of these extents and reuse them whenever possible.


text:
Q: Spring-managed request scoped bean constructor called twice on press of JSF command button I am using JSF-Spring integration, I am calling a Spring-managed request scoped bean method from the JSP using JSF <h:commandButton>. One thing I can't understand is that the constructor of the Spring bean is called twice. Why does this happen?
Here is the Spring managed bean:
@org.springframework.stereotype.Component
@org.springframework.context.annotation.Scope("request")
public class MyAction implements java.io.Serializable {

    public MyAction(){
        System.out.println("inside request scoped bean");
    }

Here is the JSF view:
<h:commandButton value="add" action="#{MyAction.add}" />

A: Can you debug to trace where the constructor is getting called from ? Pretty sure one of the calls is it is being tried to initialize from some other place and one from the application / ui

A: I got the answer, the constructor was being called twice because of cglib proxy mechanism of Spring.


text:
Q: Irreducible factorization I fully understand the concept of irreducible factorization, however, is there a method in order to find the irreducible factors?
For example if we have the polynomial $$x^{12}-1$$ in mod $2$

A: Mod 2, $x^{12}-1=(x^{6}+1)^{2}=((x^{3}+1)^{2})^{2}=(((x-1)(x^{2}+x+1))^{2})^{2}$. mod 2, $x^{2}+x+1$ has no roots so is irreducible!

A: $X^n - 1$ factors over the integers (and therefore over any field) as the product of the cyclotomic polynomials $C_k(X)$ for $k$ dividing $n$.   In this case
$$ X^{12} - 1 = C_1(X) C_2(X) C_3(X) C_4(X) C_6(X) C_{12}(X)\\ = (X-1)(X+1)(X^2+X+1)(X^2+1)(X^2-X+1)(X^4 - X^2 + 1)$$
Of course, over $Z_2$, $+1 = -1$.  If a quadratic factors, the factors must be linear, and the only quadratic factor that has a root in $\mathbb Z_2$ is $X^2+1 = (X + 1)^2$.  $X^4 + X^2 + 1$ has no linear factors, but it does factor into quadratics: since $X^4 + 1 = (X^2 + 1)^2$, $X^4 + X^2 + 1 = (X^2 + 1)^2 + X^2 = (X^2 + X + 1)^2$.
Thus the factorization is
$$X^{12}-1 = (X+1)^4(X^2+X+1)^4$$


text:
Q: Scatterplot axis labels are wrong when plotting dates I am trying to do a scatter plot of 2 time series data - the data is stored in a data frame. The background of the image is quite grainy and axis labels are not visible when I do:
ggplot(data=dat,aes(x,y))+geom_point()

With below, I get only dark vertical lines:
plot(dat$x,dat$y)

plot() and ggplot() did work after applying as.numeric() to the data(as below) but the axis labels are indices[1,2,...] and not the range of actual values.
plot(as.numeric(dat$x),as.numeric(dat$y))
ggplot(data=dat,aes(as.numeric(x),as.numeric(y)))+geom_point()

I cannot post the images here as I am new to this forum.

A: By default, the data was getting converted into factor while converting from matrix to data.frame. Below code fixed it.
data.frame(mydata,stringsAsFactors = FALSE)


text:
Q: Spring Cloud Eureka with Non-JVM Language (PHP) / Discovering Services Using Eureka REST Endpoints I'm using Spring Eureka as discovery server in my application which is implemented using microservices architecture. The services are mostly created with PHP, and they register themselves on start-up using Eureka REST endpoints and each one of them sends a heartbeat every 30 seconds and everything works well.
Now, imagine service A wants to talk to service B. How does the discovery happen?
Currently I think service A should send a GET request to http://localhost:8761/eureka/apps/service-B endpoint, retrieve the list of current instances of service B and choose between them. Is it the right approach?
What about load-balancing? Should I implement that in my services to ask for a different instance every time? Or choose between them randomly?
Any help would be greatly appreciated.
Update: Take a look at this library.

A: There is an easy way to do this with Spring Cloud Netflix Sidecar: http://cloud.spring.io/spring-cloud-static/Camden.SR7/#_polyglot_support_with_sidecar
If you want to continue to implementing this yourself you have several options. With client side load balancing you could retrieve all instances from Eureka and then choose one randomly at the consuming side. If you want server side load balancing you will be needing an extra component, like Zuul, and let it do the load balancing and routing. Zuul uses the eureka configuration so it is easy to integrate it.


text:
Q: How to mixin a js action when there is already a mixin declared on it I need to apply some additional code to Magento_Checkout\js\set-shipping-information.js.
However, I have got a third party module which already declared a mixin on it
        'Magento_Checkout/js/action/set-shipping-information': {
            'Amasty_Checkout/js/action/set-shipping-information-mixin': amasty_mixin_enabled
        },

How can apply my second mixin? Is it just a matter of:
        'Magento_Checkout/js/action/set-shipping-information': {
            'Foodentyco_Checkout/js/action/set-shipping-information-mixin': true
        },

Many thanks


text:
Q: Magento Frontend Certification in 2016 The official study guide for the Magento Frontend Developer Certification states that the exam is based on Magento CE 1.7, and that the questions "test skills that apply to both CE 1.7 and EE 1.12". These versions are obviously getting pretty old now and there have been changes to the Magento theme layer in the newer versions. Improved theme fallback and RWD theme for example.
The study guide is copyright 2013 x.commerce so is clearly a bit out of date. Does anyone who has sat the exam recently know if it has been updated to include questions related to CE 1.9 and EE 1.14.

A: Ok after completing the exam I can confirm that it does test CE 1.9 and EE 1.14. Well thats what it states at the start of the exam anyway.
In terms of the new theme fallback it wasn't really covered, at least in the questions I got. All the theme fallback questions were based on the pre 1.9 system. It did have a number of questions related to responsive theming which is a new concept for Magento in the 1.9 rwd theme.


text:
Q: Making two ssh port-forwarding connections in one "go" I have two servers, A and B. I'm connecting to B jumping trough A with ProxyJump, my sshconfig looks something like this:
Host A
...

Host B
...
ProxyJump A

I have applications running on A and B, and I'm doing port-forwarding to my localhost, like this:
ssh A -NL 8888:node:8888
ssh B -NL 9999:node:9999
The problem is that every time I'm connecting to A it requires 2FA. Is there some way I can do these two port-forwards in one "go" without needing to authenticate to A twice? I'd like to not use connection sharing (ControlMaster) if possible as I have ran into issues with this, they port stays blocked after the connection goes down for some time. Or is connection sharing the only way to do it? Perhaps if I use ControlPersist no it will not block the port if I need to reconnect?


text:
Q: Pivot Table Most Current Data Excel I have a work pivot table setup to measure skills of employees. Now the process as it currently stands, is that every few months an employee will go and update one to three of skills.
The pivot table then looks like this:
Skills            6/1/2016  12/31/2016  4/3/2017    9/1/2016    Grand Total
Action Oriented         3       4       3           2               4

So currently the Grand Total function, takes the max. I was wondering if there is anyway to set up a calculated field in the pivot table, that will take values as of the last date. And if certain skills arn't updated it will just take the the last value thats already in there.
I.e. if skills: action oriented, creative, and management abilities all got updated on 9/1/2016. But the last time client focus was updated was in June, then this calculation field will take the june value for client focus.

A: If your data is stored in the Excel data model (Power Pivot) you can use DAX-functions to check for the latest date values only. This provides a lot more feature than the regular pivot table and is quite easy to set up (just click "import from table" if you data is already stored in Excel).
I don't know what the source table looks like but you can either create a calculated column to check for the MAX([date] / LASTDATE[date] or create a measure / calculated field to count or sum up values with the last date only as in =CALCULATE(SUM([you value column]),LASTDATE([your date column]).
Check this for more info.


text:
Q: print everything in one line Lets say that you have the following lines generated by a PHP framework:
ID: 1
Name: David
LoginName: DavidAppple
Password: IamDavid
Email: IamDavid@gmail.com
Phone: +555 333 222 111

say that you want to get these in 1 line, so it becomes:
ID: 1   Name: David LoginName: DavidAppple Password: IamDavid Email: IamDavid@gmail.com  Phone: +555 333 222

all in a single line how can you do that?
this is CSS CODE:
div.view
{
    padding: 10px;
    margin: 10px 0;
}

    ID:
    1

    Name:
    David

    LoginName:
    DavidAppple

    Password:
    IamDavid

    Email:
    IamDavid@gmail.com

    Phone:
    +555 333 222 111

this is the html part generated by PHP framwrok Yii, I want to be able to remove the
 so I can have everything in 1 line.

A: If every lines is wrapped by a div.view you can try:
div.view
{
    display: inline;
}

A: You have break tags  br that are causing this.
Just hide them. Then the other items will re-assume their inline defaults.
div.view br {
    display: none;
}

div.view {
  padding: 10px;
  margin: 10px 0;
}
div.view br {
  display: none;
}

    ID:
    1

    Name:
    David

    LoginName:
    DavidAppple

    Password:
    IamDavid

    Email:
    IamDavid@gmail.com

    Phone:
    +555 333 222 111

A: Css property indicates the span of float: left . Encapsulala within the div where encuente .
An example :

span {float:left);

A: Simply str_replace() br tag with empty string if you have the produced string available to you in PHP. If not, just make sure br tags are set to display:none within the div.view.


text:
Q: Using conditional statements during the Wordpress loop I'm using the Vitrux theme in Wordpress. The home page display posts in a tiled layout from the 'Portfolio' post type. I want to get three posts from a different post type ('Shoots'). Adding the code here after the call to the loop works:
    if (have_posts()) : while (have_posts()) : the_post();
        if ($post->post_title == "Latest Shoots")
            {
            $portfolio_replacement = 'shoots'; // the post type to query
            query_posts(array('orderby' => 'date', 'post_type'=>$portfolio_replacement, 'posts_per_page' => 3));
            }

but only if the 'Latest Shoots' post is the first one in the main portfolio. You can see this in action here:
http://www.snaprockandpop.samcampsall.co.uk
(the posts added by the if statement are the three nearest the bottom of the layout, which replace the 'Latest Shoots' post).
How would I create conditional statements like this that will execute at any point in the Wordpress loop? I can't guarantee that this one will always happen be at the beginning, plus I'd like to write some other queries to change the layout on this site.
What's the best way to do this, and how would I go about learning it? I've got a very basic understanding of PHP but I'm keen to learn more, so please be gentle!


text:
Q: eBay iFrame listing autoheight I was looking at creating my own ebay listing templates when I thought of using iframes the only trouble is Cross Site Scripting.
This is on ebay
// this script gets the height of the iframe which is stored in a hidden field on the iframe

This is the iframe

Ebay Test Listing

    <input type="text" id="size">
            other information etc...

Now the iframe is on my website but how can I send the height of the iframe to mywebsite and adjust it automatically?
The script works perfectly when running the ebay code on my site?

A: You can't. This is not possible.


text:
Q: Facebook does not redirect to callback URL after user logins Im having an app which allows user connect to his facebook account.
If the user facebook is already logged in there is no issue with it but if facebook has not been logged in yet the app redirect it to the facebook login page, after user logs in, it redirect to facebook home page instead of call back url.
Here is the generated call back url by PHP:
https://www.facebook.com/v2.6/dialog/oauth?client_id=XXXXXXXXXXXXXX&state=af0be0925ecf8bc7348c06c23bacaac9&response_type=code&sdk=php-sdk-5.3.1&redirect_uri=http%3A%2F%2Finsights.app%2Ffacebook%2Fcallback&scope=email%2Cread_insights%2Cmanage_pages%2Cpublic_profile%2Cads_read%2C+ads_management

In addition to above scenario, when the user is already logged in to facebook but has not used my app and the app trying to get facebook's permission it happens and redirect to facebook home page instead of call back url.

A: What you can do is to check if the user is authorized in the callback URL script and only the redirect to the home page.


text:
Q: how do I setup Ant buildscript project.properties file? Hello I a having problem setting up Ant BuildScript
When I Run ant, the Java Scripts and CSS are not compressed and the and the stylesheet link is not update to a random number.
In the project.properties file I am using the following.
file.root.stylesheet    = screen.css
dir.js              = includes/js
dir.js.main         = ${dir.js}
#build.css.scss         = true
dir.css             = css

Build sass is turned off because it is already been compiled by compass
I have tried to have a single js file by putting this line around the js scripts
<!-- //-beg- concat_js -->
<script src="includes/js/script1.js"></script>
<script src="includes/js/script2.js"></script>
<!-- //-end- concat_js -->

The folder structure I am using is the folwing:

*

*css/

*img/

*includes/sass

*

*foundation.scc, screen.scss

*includes/js

*includes/file.php

I am getting the following error's
-js.all.minify:
     [echo] Minifying scripts
     [copy] Copying 4 files to c:\projectfolder\intermediate\includes\js
    [apply] c:\projectfolder\includes\js\plugins.js:86: ERROR - Parse error. IE8 (and below) will parse trailing commas in array and object literals incorrectly. If you are targeting newer
versions of JS, set the appropriate language_in option.
    [apply]                     firstName :  "required",
    [apply]                     ^
    [apply]
    [apply] 1 error(s), 0 warning(s)
    [apply] Result: 1

-js.main.concat:
     [echo] Concatenating Main JS scripts based on index.html...
     [exec] Result: 1
   [concat] c:\projectfolder\intermediate\Exception does not exist.
   [concat] c:\projectfolder\intermediate\in does not exist.
   [concat] c:\projectfolder\intermediate\thread does not exist.
   [concat] c:\projectfolder\intermediate\"main" does not exist.
   [concat] c:\projectfolder\intermediate\java.io.FileNotFoundException: does not exist.
   [concat] c:\projectfolder\intermediate\index.html does not exist.
   [concat] c:\projectfolder\intermediate\(Het does not exist.
   [concat] c:\projectfolder\intermediate\systeem does not exist.
   [concat] c:\projectfolder\intermediate\kan does not exist.
   [concat] c:\projectfolder\intermediate\het does not exist.
   [concat] c:\projectfolder\intermediate\opgegeven does not exist.
   [concat] c:\projectfolder\intermediate\bestand does not exist.
   [concat] c:\projectfolder\intermediate\niet does not exist.
   [concat] c:\projectfolder\intermediate\vinden) does not exist.
   [concat] c:\projectfolder\intermediate\at does not exist.
   [concat] c:\projectfolder\intermediate\java.io.FileInputStream.open(Native does not exist.
   [concat] c:\projectfolder\intermediate\Method) does not exist.
   [concat] c:\projectfolder\intermediate\at does not exist.
   [concat] c:\projectfolder\intermediate\java.io.FileInputStream.<init>(FileInputStream.java:138) does not exist.
   [concat] c:\projectfolder\intermediate\at does not exist.
   [concat] c:\projectfolder\intermediate\java.io.FileInputStream.<init>(FileInputStream.java:97) does not exist.
   [concat] c:\projectfolder\intermediate\at does not exist.
   [concat] c:\projectfolder\intermediate\java.io.FileReader.<init>(FileReader.java:58) does not exist.
   [concat] c:\projectfolder\intermediate\at does not exist.
   [concat] c:\projectfolder\intermediate\FindAttribute.main(Unknown does not exist.
   [concat] c:\projectfolder\intermediate\Source) does not exist.

I have placed a full error log one my jsfiddle account
http://jsfiddle.net/piggybattery/bpxBM/1/
Does anyone know how to chain to this structure?

A: Fix the trailing comma causing the minification error. that's just a good idea.
Other than that, it looks like there are about a million things that could be going wrong. the build script was created to be pretty easy to use with HTML-Boilerplate structure. When you start to add things like PHP, and SASS and Foundation, there are more and more things that go wrong. It can work with those things, you just need to be aware of the changes your making and reflect them in the build script.
The biggest thing to remember is that the paths in the properties file need to point to real files that Ant and Java can find.
So, from the root of your project (one up from your build directory) make sure the strings that you're building with the dir.* and file.* properties point to things that exist on disk and in your source code. So, for example, if the script can't find your file.root.page (it looks for index.html by default. I'm guessing you don't have an index.html in your project?) it can't concatenate the scripts inside the comments. Additionally, if it can't find your file.root.stylesheet things will go wrong (is your main CSS file in css/screen.css? Is it referenced in your HTML? That's where I swap out the source.) Same for file.root.script other things will go wrong (is file.root.script set to script1.js or script2.js? Again, that helps me change the source) Basically every time you make a change from the default HTML5 Boilderplate structure you need to reflect that in those properties.


text:
Q: construct the focii and asymptotes with compass and ruler, given a non rectangular hyperbola Problem: Given a non-rectangular hyperbola only, construct its asymptotes and focii with compass and straightedge.
Reference (1) works if the hyperbola is rectangular.
Reference (2-comment) states that reference (1) construction should work for non-rectangular hyperbolas also.
Reference (3) is similar to reference (1) and also constructs the foci.
As I follow the steps in reference (3) the "asymptote" that is constructed for a non-rectangular hyperbola is not the asymptote. It approaches the asymptote as the random point on the hyperbola gets farther from the center.  It approaches the conjugate axis as the random point on the hyperbola approaches the vertex.
Here is my geogebra construction.  https://www.geogebra.org/geometry/uycqtrrk.  I hope the link works to show you what I have done.  It seems to open better in Chrome than Safari.  And I had to sign in to GeoGebra to open the test file I sent myself.

*

*Constructing the asymptotes of a hyperbola by compass and straightedge.

*Constructing the asymptotes of a hyperbola by compass and straightedge. (comment)

*http://whistleralley.com/conics/conic_construction/hyperbola_parts/

A: We need to solve this problem in chunks.  First chunk is to find the center.
Construct any chord of the hyperbola.  Then construct another, parallel chord.  Bisect both chords and draw the line connecting the generated midpoint.  This line is called the conjugate diameter with respect to the set of parallel chords you just used, and it is guaranteed to pass through the center.  In a similar way construct another conjugate diameter using a pair of chords parallel to each other but not parallel to the first two.  The two conjugate diameters intersect at the center, which I now label $O$.
Next comes the transverse axis.  Center the compasses at $O$ and make a circle with radius $r$, big enough to hit the hyperbola at four points which, of course, are the vertices of a rectangle.  Construct the perpendicular bisector of either side that connects two points within the same branch of the hyperbola.  This cuts through $O$ and is the transverse axis.
Now we are ready to attack the asymptotes.  For the rectangle you just constructed, define $l$ as the length of transverse axis from the center to either point where it hits the rectangle.  Now construct a larger rectangle centered on $O$, with radius $r'$ and half-length $l'$ corresponding respectively to $r$ and $l$ from the first rectangle.
Construct a right triangle with a vertex at $O$, a leg from $O$  along the transverse axis measuring $\sqrt{(l')^2-l^2}$, and hypoteneuse $\sqrt{(r')^2-r^2}$.  The hypoteneuse will be directed along an asymptote, and the other asymptote is obtained via a mirror reflection through the transverse axis.
Finally we go for the foci.  Go back to the transverse axis and drop a perpendicular to it from either of the vertices where it hits the hyperbola.  This intersects an asymptote (pick either one) at point $P$.  Construct the circle through $P$ centered on $O$, which intersects the transverse axis at the foci.
Done!


text:
Q: How to setup Detail Accessory Type in Custom Cell I have custom cell class for each cell I have on my table. I added detail accessory type to each cell. I want the user to click on the detail accessory type (the blue circle with i in it) and a pop up should show more information about that specific cell. I have googled around and have not found a solution for detail accessory type.

Following is the custom class for my first cell.
class SocialTableCell: UITableViewCell {

@IBOutlet weak var social:UILabel?
@IBOutlet weak var toggle:UISwitch?

override func awakeFromNib() {
    super.awakeFromNib()
}
override func setSelected(selected: Bool, animated: Bool) {
    super.setSelected(selected, animated: animated)
}
}

Any Help will be highly appreciated.
Thanks

A: The UITableViewDelegate protocol has a method tableView:accessoryButtonTappedForRowWithIndexPath: that is being called when a user tapped on the accessory button in one of the cells. So you have to implement that method in your TableViewController:
func tableView(_ tableView: UITableView, accessoryButtonTappedForRowWithIndexPath indexPath: NSIndexPath) {
   // show the alert here
}

Also you have to make sure that you set the UITableView.delegate to the ViewController that implements that method.


text:
Q: Group radio buttons on Excel I have two groups of radio buttons on the same Excel worksheet that I want them to work exclusively from each other.
I tried to search online for answers, and got to know there was GroupName Property which can be used to group the radio buttons, however, I haven't been able to locate this property.
Can anyone tell me how to find it?
There is only object positioning under the property tab of the format control window.

A: You need to add a group box control and then insert the radio buttons into that group box.
See here for more info: Add a group box or frame control to a worksheet

A: Use ActiveX controls

and in developer mode right click on RadioButton

and in properties box


text:
Q: Range of Earth's gravitational field We know that the acceleration due to gravity acting on a body situated h meter away from the surface of the earth is given by,
$$g' = (1 - 2h/r)g,$$ where $\,r$ = Radius of the earth ($R$) + $h$. Now we can find the range of the earth's gravitational field, i.e, where does the value of g' become $0$.
Now, $g'$ becomes $0\,$ if $\,h = R/ 2$. Radius of the earth = $6.37\cdot10^6$ m, so $R/ 2 = 3.18\cdot10^6$ m. Therefore, at a distance $3.18\cdot10^6$ m distance away from the surface of the earth, the gravitational field of the earth becomes zero or the value of $g$ becomes zero. Is my math correct? If not, why?

A: Range of the gravitational field of any body, not just the earth, extends upto infinity. The formula you are using is an approximation that only applies when $h<<R$ which is definitely not the case when $h=R/2$.
The more general formula for $g$ is $g = GM_e/r^2$ where $G$ is the universal gravitational constant, $M_e$ is the mass of the earth and $r$ is the distance of the object from the centre of the earth. As you can see, the value of $g$ gets smaller and smaller but never zero as $r$ gets larger and larger. If we now, substitute $r = R+h$ where $r$ is the radius of the earth, and $h$ is the distance from the surface of the earth, then apply the first order approximation for $h<<R$ then we get the formula you used.

A: Think about how you got the formula.
We had, $g$=$GM\over R^2$ and $g\prime$=$GM\over (R+h)^2$ .
Now from them we get,
$g\prime$=$R^2\over (R+h)^2$$\times g$
$\implies$ $g\prime$=$ g\over(1+h/R)^2$
From here, by an approximation, $h<<R$ we get your formula.
But if you want to get $g\prime$=0, the denominator must go to infinity, which implies $h$ goes to infinity. Which is a basic assumption of the gravitational field.


text:
Q: $\gamma$ in Newton's Second Law of Motion in Differential Form I am teaching myself Differential Equations from a website. In the website I am up to Direction Fields and an example of a differential equation is Newton's Second Law of Motion. It is written on the website like this:
$$m\frac{dv}{dt}=mg-\gamma v$$
I know that $m$ is the mass, $g$ is the gravitational acceleration, $v$ is the velocity, and $t$ is the time, but what does $\gamma$ stand for?

A: The general form of Newton's Law for constant mass is
$$
m \frac{dv}{dt} = F
$$
so in your case, $F = mg - \gamma v$ is the provided force law. In your case your force happens to depend on the velocity; the greater the velocity, the more negative the force, so it is a kind of friction or drag. $\gamma$ is just the proportionality constant between the friction force $F_{fric} = -\gamma v$ and the velocity, just like $k$ is the proportionality constant between the position and the force $F_{spring} = -kx$ for a spring.

A: The $\gamma$ here is some coefficient/constant (which has the units $\mathrm{kg\,s^{-1}}$). This formula is saying that the resultant force $F = \mathrm{d}v/\mathrm{d}t$ is equal to the force on the mass from gravity minus some force $\gamma v$ which is dependent on velocity.
To me, you are right, this does not make too much sense from a Newtonian standpoint (IMO) as this is representing a drag linearly dependent on velocity which is never the case in my experience. It would make more sense if the resistive force was written as $\lambda v^{2}$ (and the units of $\lambda$ amended accordingly for some arbitrary example case), this could then represent an air/fluid resistance where $\lambda$ is some type of 'drag coefficient'.
I hope this helps.


text:
Q: Which Hyperspace Topologies Yield Topological Lattices? At least on a continuum, the binary operations of intersection and union are Vietoris-continuous. But the Vietoris topology only applies the the collection of NONEMPTY closed subsets, and this means our lattice would lack a 0 element.
Is there any meaningful topology for the collection of ALL closed subsets of a space, such that if forms a topological lattice under the Boolean set operations? What restrictions must be made on the space under consideration, in order to allow this?

A: Let $(X,\tau)$ be a topological space. Then you can topologize the powerset $\mathcal{P}(X)$ with the topology $\tau_{\mathcal{P}}$ generated by the subbasis
$\{\mathcal{S} \subseteq \mathcal{P}(X): (\bigcup \mathcal{S}) \in \tau\}$.
Then the operations $\cap, \cup$ are continous operations on $(\mathcal{P}(X), \tau_{\mathcal{P}})$, and of course these operations stay continuous if you restrict yourself to the lattice of all closed subsets of $X$ (including $\emptyset$).

A: One does see (in some of the literature) the empty set as an element of the hyperspace $H(X)$, and in that case the $\emptyset$ is an isolated point when we use the Vietoris topology. This is in many cases unwanted: for non-empty closed sets we have (assuming $X$ is $T_1$) that $X$ connected iff $H(X)$ connected, but if $H(X)$ always has the isolated point, we'd have to modify that a bit to $H(X) \setminus \{\emptyset\}$ is connected, etc.
But $\emptyset$ being isolated might spoil continuity of $\cap$, but I don't think it does (for normal spaces at least) : if $(A,B)$ is a pair of closed sets with $A \cap B = \emptyset$, then we might have that $A = \emptyset$ or $B = \emptyset$, but then $\{\emptyset\} \times H(X)$, or $H(X) \times \{\emptyset\}$ resp. is then a neighbourhood of $(A,B)$ in $H(X) \times H(X)$ that maps into $\{\emptyset\}$, and otherwise $A,B$ are non-empty closed and disjoint sets, so in a normal space $X$ we find disjoint open sets $U \supseteq A$, $V \supseteq B$. And then $\langle U \rangle \times \langle V \rangle$ is a basic product neighbourhood (where $\langle O \rangle = \{F \in H(X): F \subseteq O, F \cap O \neq \emptyset \}$ is the usual Vietoris open set) in $H(X) \times H(X)$ that also maps into $\{\emptyset\}$. So at all new pairs (compared to the non-empty situation) the $\cap$ operation is also continuous.


text:
Q: Reactjs setState issue In react, I'm storing the data in state. The issue is that I'm able to store and read the state within the function. But if I try to read it in render() method, I'm not able to read the state. Here is the below code :
import Opt from './GenerateData.jsx';

constructor(props) {
    this.state = {
        options : ""
    }

    this.handleOptions = this.handleOptions.bind(this);
}

handleOptions(params) {
    this.setState({
        options: params
    });

    // here it will print the state value
    console.log(this.state.options)
}

// but it won't print it here..
render() {
    return (

        <Opt handleOptions={this.handleOptions.bind(this)} />
        ...
        ...
        <FilterOpts name="optionSelection" data={this.state.options} />
    )
}

In GenerateData.jsx
class GenerateData extends React.Component {
    componentDidMount() {
        var d = [1,2,3,4];
        this.props.handleOptions(d);
    }

    render() {
        return (

        )
    }
}

A: React setState() is asynchronous. It does not immediately mutate this.state but creates a pending state transition.
You can try this code to log the updated state.
handleOptions(params) {
    this.setState({
            options: params
        }, () => {console.log(this.state.options);}
    );
}


text:
Q: Airflow seems to be losing track of tasks and considering them failed I'm using cloud composer composer-1.10.6-airflow-1.10.6
There seems to be a problem with airflow starting tasks and losing track of them. The logs stop, and eventually it gets marked as failed, but actually the task completes successfully. This is a big problem for non-idempotent tasks (like tasks that append data) if we have retries configured. Whenever this happens I have to go and manually investigate if the task actually did complete or not, and mark the job accordingly.
Here's an example log. It's a typical log from this problem. Not much useful info in it, basically they just look like they end prematurely (hence It feels like airflow as lost track of the job). Meanwhile the job has still completed successfully.
*** Reading remote log from gs://bucket/log/path/log.log
[2020-08-31 12:16:33,450] {taskinstance.py:630} INFO - Dependencies all met for <TaskInstance: builder.launch_loader_prd 2020-08-30T10:30:00+00:00 [queued]>
[2020-08-31 12:16:33,569] {taskinstance.py:630} INFO - Dependencies all met for <TaskInstance: builder.launch_loader_prd 2020-08-30T10:30:00+00:00 [queued]>
[2020-08-31 12:16:33,571] {taskinstance.py:841} INFO -
--------------------------------------------------------------------------------
[2020-08-31 12:16:33,572] {taskinstance.py:842} INFO - Starting attempt 1 of 1
[2020-08-31 12:16:33,572] {taskinstance.py:843} INFO -
--------------------------------------------------------------------------------
[2020-08-31 12:16:33,605] {taskinstance.py:862} INFO - Executing <Task(DataflowTemplateOperator): launch_loader_prd> on 2020-08-30T10:30:00+00:00
[2020-08-31 12:16:33,608] {base_task_runner.py:133} INFO - Running: ['airflow', 'run', 'builder', 'launch_loader_prd', '2020-08-30T10:30:00+00:00', '--job_id', '449104', '--pool', 'default_pool', '--raw', '-sd', 'DAGS_FOLDER/mydag.py', '--cfg_path', '/tmp/tmpmzlheavp']

Any help is appreciated. Thanks.

A: The log you shared seems to be the expected log of a task starting. If the task fail and it's  marked as failed after some time, I'd check if there are logs similar to the following:

Executor reports task instance <TaskInstance: YOUR_TASK 2020-08-31 10:30:00+00:00 [queued]> finished (failed) although the task says its queued. Was the task killed externally?.

Check for these kind of logs in Stackdriver to get more information on why the task was marked as failed.
Now, regarding the issue itself, I can see that you're executing a DataflowTemplateOperator, what might be happening is that either the task is unable to get back the status from Dataflow because of some issue (see the example) and it fails, or, the task eventually times out waiting for the job to finish and it is marked as failed (if this is the case you will see the "Timeout" message in the logs. The solution is to increase the timeout for the tasks execution).
In both cases, my suggestion is to look for the logs directly in Stackdriver to get more information about your task.
If the issue is not only related to the DataflowTemplateOperator but to any task, then I would check the overall status of the cluster to see if there are any errors with pod evictions or similar issues.


text:
Q: Idea's on how to use ASP .Net MVC4 with ADFS and User roles and information I'm building a Web Application using ASP.Net and MVC4.  This web application is going to be used by another company but we are hosting it.  We were told that we had to use ADFS.  We don't know what kind of information is going to come over to us in the authentication but we need to allow for users to have roles.  I assume that when authenticated a username should be returned.  So i'm thinking I would build a user table in the database for admins and super admins.  When a user comes over, we will check if there username exist in the database and if so we would read their role from the database  If they do not exist in the database they are public.
All that being said here is my dilemma that I need to solve.  How do I do this without writing custom code everywhere in the application to check for authorized and check for role?  I would like to use the [AuthorizeAttribute(roles)].  Should I create a custom role provider?  All ideas are welcome.  BTW, we can not have the client manage the roles and pass it over because this company is a Fortune 100 company and they do not have time to handle these request.

A: I would recommend looking at some of Dominick Baier's work on securing MVC with claims. He's worked with some other developer's as well to build Thinktecture, which has both an Identity Server component and libraries for assisting in the processing of claims while abstracting some of the nitty-gritty details.
As for the roles portion of what you need to do, you can build a custom ClaimsAuthenticationManager and have that perform whatever transformations or additions to the users claim set at initial login. Dominick has a couple of excellent PluralSight courses that go into much more detail on this process. He also has this free video out there, which details the authorization portion around minute ~44.
I recently went through the effort of getting ADFS setup and authenticating some of the MVC apps at our company. The resources I have referenced were invaluable in helping me in that process.


text:
Q: Android: how to center horizontally a ConstraintLayout inside a ListView row? I am trying to center a ConstraintLayout inside a ListView's row (the ListView contains 6 rows, each containing 6 squares).
I have written this inside the view XML:
<!-- Grid view -->
<androidx.constraintlayout.widget.ConstraintLayout
    android:id="@+id/list_view_container"
    android:layout_width="0dp"
    android:layout_height="0dp"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintTop_toBottomOf="@id/top_view"
    app:layout_constraintBottom_toTopOf="@id/bottom_view" >

    <ListView
        android:id="@+id/list_view"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:listSelector="@android:color/transparent"
        android:divider="@null"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

The row XML:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/test_id"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        android:maxWidth="306dp">

    <FrameLayout
        android:id="@+id/box1"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintWidth_percent="0.166666"
        app:layout_constraintDimensionRatio="1:1"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent">

        <View
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="1dp"
            android:background="@color/black" />

    </FrameLayout>

    <FrameLayout
        android:id="@+id/box2"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintWidth_percent="0.166666"
        app:layout_constraintDimensionRatio="1:1"
        app:layout_constraintStart_toEndOf="@id/box1"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent">

        <View
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="1dp"
            android:background="@color/black" />

    </FrameLayout>

    <FrameLayout
        android:id="@+id/box3"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintWidth_percent="0.166666"
        app:layout_constraintDimensionRatio="1:1"
        app:layout_constraintStart_toEndOf="@id/box2"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent">

        <View
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="1dp"
            android:background="@color/black" />

    </FrameLayout>

    <FrameLayout
        android:id="@+id/box4"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintWidth_percent="0.166666"
        app:layout_constraintDimensionRatio="1:1"
        app:layout_constraintStart_toEndOf="@id/box3"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent">

        <View
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="1dp"
            android:background="@color/black" />

    </FrameLayout>

    <FrameLayout
        android:id="@+id/box5"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintWidth_percent="0.166666"
        app:layout_constraintDimensionRatio="1:1"
        app:layout_constraintStart_toEndOf="@id/box4"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent">

        <View
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="1dp"
            android:background="@color/black" />

    </FrameLayout>

    <FrameLayout
        android:id="@+id/box6"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintWidth_percent="0.166666"
        app:layout_constraintDimensionRatio="1:1"
        app:layout_constraintStart_toEndOf="@id/box5"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent">

        <View
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="1dp"
            android:background="@color/black" />

    </FrameLayout>

    </androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

When I look at the design version of it in Android Studio, it looks like this:

So it looks like well centered, but when I compile the app, nothing appears on screen.
If I replace test_id's layout_width with match_parent, the list view appears but the content is sticked to the left of the screen instead of centered:

What should I do here?
Thank you for your help

A: Specifying constant size for a view is usually wrong. Your layout is not in right format. Please specify what you want to achieve. And try to remove maxWidth="306dp" from test_id and add these lines to it:
android:layout_width="0dp"
app:layout_constraintWidth_percent="0.7"


text:
Q: Problems with Table Formatting Excel2Latex I am using excel2latex and then inserting the tables into a latex document.
I can get the tables looking perfect in Word or Excel, but somehow in the conversion, the table is skewed and one of the columns is way out.
Any help would be appreciated.

% Table generated by Excel2LaTeX from sheet 'Sheet1'
\begin{table}[htbp]
  \centering
  \caption{Add caption}
    \begin{tabular}{cccccc}
    \multicolumn{6}{c}{Table I} \\
    \multicolumn{6}{c}{\textbf{Summary Statistics, Monthly Excess Stock Returns}} \\
    \multicolumn{6}{c}{\textbf{S\&P 500 and US XYZ}} \\
    \multicolumn{6}{p{44.22em}}{This table reports summary statistics for XYZ currency excess returns (in percent) for industrialized countries. The excess return is the return on the broad market index and 123 XYZ in excess of the three-month US treasury bill rate. Data are from DataSource. FRED, Federal Reserve Economics Data. Blank Text. } \bigstrut[b]\\
    \hline
          & Mean  & Std.  &       & Mean  & Std. \bigstrut\\
    \hline
    \textcolor[rgb]{ 0,  .439,  .753}{\textbf{S\&P 500}} & 0.01  & 9.24  & S\&P 500 & 0.01  & 0.01 \bigstrut[t]\\
    S\&P 500 & 0.01  & 7.52  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 7.98  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 7.1   & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 7.21  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 6.9   & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 7.87  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 6.14  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 7.35  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 6.31  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 8.61  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 6.1   & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 9.42  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 10.83 & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 7.3   & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 5.73  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 7.59  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 7.23  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 7.69  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 4.77  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 9.29  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 10.52 & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 6.53  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 8.13  & S\&P 500 & 0.01  & 0.01 \\
    \end{tabular}%
  \label{tab:addlabel}%
\end{table}%

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="css/my.css" type="text/css"?>
<?sw-tagdefs href="resource://app/res/tagdefs/latexdefs.xml" type="text/xml" ?>

  <sw-meta id="sw-meta" product="Scientific WorkPlace" version="2017081800" created="Wed Mar
01 2017 11:41:53 GMT-0700 (MST)" lastrevised="Tue Jul 31 2018 11:38:53 GMT+0100 (GMT Daylight
Time)"/>
    <preamble hide="true">
      <documentclass class="article"/>
      <requirespackage package="amsfonts" pri="010"/>
      <requirespackage req="amsmath" pri="010"/>
      <preambleTeX><![CDATA[\newtheorem {theorem}{Theorem}
\newtheorem {acknowledgement}[theorem]{Acknowledgement} \newtheorem {algorithm}[theorem]{Algorithm}
\newtheorem {axiom}[theorem]{Axiom} \newtheorem {case}[theorem]{Case}
\newtheorem {claim}[theorem]{Claim} \newtheorem {conclusion}[theorem]{Conclusion}
\newtheorem {condition}[theorem]{Condition} \newtheorem {conjecture}[theorem]{Conjecture}
\newtheorem {corollary}[theorem]{Corollary} \newtheorem {criterion}[theorem]{Criterion}
\newtheorem {definition}[theorem]{Definition} \newtheorem {example}[theorem]{Example}
\newtheorem {exercise}[theorem]{Exercise} \newtheorem {lemma}[theorem]{Lemma}
\newtheorem {notation}[theorem]{Notation} \newtheorem {problem}[theorem]{Problem}
\newtheorem {proposition}[theorem]{Proposition} \newtheorem {remark}[theorem]{Remark}
\newtheorem {solution}[theorem]{Solution} \newtheorem {summary}[theorem]{Summary}
\newenvironment {proof}[1][Proof]{\noindent \textbf {#1.} }{\ \rule {0.5em}{0.5em}}]]>
      </preambleTeX>
    </preamble>

    <title xmlns="http://www.w3.org/1999/xhtml">Standard <texlogo
xmlns="http://www.w3.org/1999/xhtml" name="latex">LATEX</texlogo> Article
    </title>
    <author> A. U. Thor
      <msibr invisDisplay="↵" type="newLine"/>
      University of Stewart Island

    </author>
    <maketitle/>

      <sectiontitle>Standard <texlogo xmlns="http://www.w3.org/1999/xhtml"
name="latex">LATEX</texlogo> Article
      </sectiontitle>
      <bodyText>This document illustrates the appearance of an article created with the shell <bold>
Standard <texlogo xmlns="http://www.w3.org/1999/xhtml"
name="latex">LATEX</texlogo> Article</bold> or the shell <bold> Blank -
Standard <texlogo xmlns="http://www.w3.org/1999/xhtml"
name="latex">LATEX</texlogo> Article</bold>. Both shells produce
documents with centered title information, left-justified headings, theorem environments, and
appendices.
      </bodyText>
      <bodyText>The standard <texlogo xmlns="http://www.w3.org/1999/xhtml"
name="latex">LATEX</texlogo> shells provide the most general and portable set
of document features. You can achieve almost any typesetting effect by beginning with a standard
shell and adding    <texlogo xmlns="http://www.w3.org/1999/xhtml"
name="latex">LATEX</texlogo> packages as necessary.
      </bodyText>
      <bodyText>The document class base file for this shell is <typewriter>article.cls</typewriter>.
      </bodyText>
      <bodyText><texb name="Table1" pre="0" pri="0"><![CDATA[% Table generated by Excel2LaTeX from
sheet 'Sheet1' \begin{table}[htbp]   \centering     \begin{tabular}{cccccc}
    \multicolumn{6}{c}{Table I} \\
    \multicolumn{6}{c}{\textbf{Summary Statistics, Monthly Excess
Stock Returns}} \\     \multicolumn{6}{c}{\textbf{S\&P 500 and US XYZ}} \\
    \multicolumn{6}{p{44.22em}}{This table reports summary statistics for XYZ currency excess
returns (in percent) for industrialized countries. The excess return is the return on the broad
market index and 123 XYZ in excess of the three-month US treasury bill rate. Data are from
DataSource. FRED, Federal Reserve Economics Data. Blank Text. } \bigstrut[b]\\
    \hline           & Mean  & Std.  &       & Mean  & Std. \bigstrut\\
    \hline
    \textcolor[rgb]{ 0,  .439,  .753}{\textbf{S\&P 500}} & 0.01  & 9.24  & S\&P 500 &
0.01  & 0.01 \bigstrut[t]\\     S\&P 500 & 0.01  & 7.52  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 7.98  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 7.1   & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 7.21  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 6.9   & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 7.87  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 6.14  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 7.35  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 6.31  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 8.61  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 6.1   & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 9.42  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 10.83 & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 7.3   & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 5.73  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 7.59  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 7.23  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 7.69  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 4.77  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 9.29  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 10.52 & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 6.53  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 8.13  & S\&P 500 & 0.01  & 0.01 \\     \end{tabular}%
  \label{tab:addlabel}% \end{table}%]]></texb>

      </bodyText>

A: *

*as starting point i use answer of DG'

*apparently you like to have table spread over whole text width (not very nice to my taste)

*i suggest to align numbers at decimal points (usual i use S column type from the package siunitx)

*for horizontal line use rules from the package booktabs
\documentclass{article}
\usepackage{xcolor}
\usepackage{booktabs, tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcommand\mcx[1]{\multicolumn{1}{C}{#1}}
\usepackage{siunitx}
\usepackage{caption}
\captionsetup[table]{justification=centering, labelsep=newline, font=bf, skip=1ex}

\begin{document}
    \begin{table}[htbp]
\caption{Summary Statistics, Monthly Excess Stock Returns S\&P 500 and US XYZ}
\label{tab:addlabel}%
This table reports summary statistics for XYZ currency excess returns (in percent) for industrialized countries. The excess return is the return on the broad market index and 123 XYZ in excess of the three-month US treasury bill rate. Data are from DataSource. FRED, Federal Reserve Economics Data. Blank Text.

    \medskip
    \begin{tabularx}{\linewidth}{ C *{2}{S[table-format=2.2]}
                                  C *{2}{S[table-format=2.2]}
                                }
    \toprule
            & \mcx{Mean}& {Std.}    &           & \mcx{Mean}& \mcx{Std.} \\
    \midrule
\textcolor{cyan}{\textbf{S\&P 500}}
            & 0.01      & 9.24      & S\&P 500  & 0.01      & 0.01 \\
S\&P 500    & 0.01      & 7.52      & S\&P 500  & 0.01      & 0.01 \\
S\&P 500    & 0.01      & 7.98      & S\&P 500  & 0.01      & 0.01 \\
S\&P 500    & 0.01      & 7.1       & S\&P 500  & 0.01      & 0.01 \\
S\&P 500    & 0.01      & 7.21      & S\&P 500  & 0.01      & 0.01 \\
S\&P 500    & 0.01      & 6.9       & S\&P 500  & 0.01      & 0.01 \\
S\&P 500    & 0.01      & 7.87      & S\&P 500  & 0.01      & 0.01 \\
S\&P 500    & 0.01      & 6.14      & S\&P 500  & 0.01      & 0.01 \\
S\&P 500    & 0.01      & 7.35      & S\&P 500  & 0.01      & 0.01 \\
S\&P 500    & 0.01      & 6.31      & S\&P 500  & 0.01      & 0.01 \\
S\&P 500    & 0.01      & 8.61      & S\&P 500  & 0.01      & 0.01 \\
S\&P 500    & 0.01      & 6.1       & S\&P 500  & 0.01      & 0.01 \\
S\&P 500    & 0.01      & 9.42      & S\&P 500  & 0.01      & 0.01 \\
S\&P 500    & 0.01      & 10.83     & S\&P 500  & 0.01      & 0.01 \\
S\&P 500    & 0.01      & 7.3       & S\&P 500  & 0.01      & 0.01 \\
S\&P 500    & 0.01      & 5.73      & S\&P 500  & 0.01      & 0.01 \\
S\&P 500    & 0.01      & 7.59      & S\&P 500  & 0.01      & 0.01 \\
S\&P 500    & 0.01      & 7.23      & S\&P 500  & 0.01      & 0.01 \\
S\&P 500    & 0.01      & 7.69      & S\&P 500  & 0.01      & 0.01 \\
S\&P 500    & 0.01      & 4.77      & S\&P 500  & 0.01      & 0.01 \\
S\&P 500    & 0.01      & 9.29      & S\&P 500  & 0.01      & 0.01 \\
S\&P 500    & 0.01      & 10.52     & S\&P 500  & 0.01      & 0.01 \\
S\&P 500    & 0.01      & 6.53      & S\&P 500  & 0.01      & 0.01 \\
S\&P 500    & 0.01      & 8.13      & S\&P 500  & 0.01      & 0.01 \\
S\&P 500    & 0.01      & 5.83      &      RF   & 0.01      & 0.01 \\
    \bottomrule
\end{tabularx}
    \end{table}

A: The title and description of the table should go on the caption. You can use the package caption to control how the captions are set.
\documentclass{article}
\usepackage{xcolor}
\usepackage{caption}

\begin{document}

% Table generated by Excel2LaTeX from sheet 'Sheet1'
\begin{table}[htbp]
\centering

\caption{Summary Statistics, Monthly Excess Stock Returns}
\caption*{\textbf{S\&P 500 and US XYZ}

This table reports summary statistics for XYZ currency excess returns (in percent) for industrialized countries. The excess return is the return on the broad market index and 123 XYZ in excess of the three-month US treasury bill rate. Data are from DataSource. FRED, Federal Reserve Economics Data. Blank Text.}

    \begin{tabular}{cccccc}
    \hline
          & Mean  & Std.  &       & Mean  & Std. \\
    \hline
    \textcolor[rgb]{ 0,  .439,  .753}{\textbf{S\&P 500}} & 0.01  & 9.24  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 7.52  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 7.98  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 7.1   & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 7.21  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 6.9   & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 7.87  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 6.14  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 7.35  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 6.31  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 8.61  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 6.1   & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 9.42  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 10.83 & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 7.3   & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 5.73  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 7.59  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 7.23  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 7.69  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 4.77  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 9.29  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 10.52 & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 6.53  & S\&P 500 & 0.01  & 0.01 \\
    S\&P 500 & 0.01  & 8.13  & S\&P 500 & 0.01  & 0.01 \\
    \end{tabular}%
  \label{tab:addlabel}%
\end{table}%

\end{document}


text:
Q: Send array to JSON PHP I got these arrays

$address = array("1JzSZFs2DQke2B3S4pBxaNaMzzVZaG4Cqh", "12Cf6nCcRtKERh9cQm3Z29c9MWvQuFSxvT", "1dice6YgEVBf88erBFra9BHf6ZMoyvG88")

$amount= array("100000000","150000000","200000000")

and I want to convert them to json format like below:

{
    "1JzSZFs2DQke2B3S4pBxaNaMzzVZaG4Cqh": 100000000,
    "12Cf6nCcRtKERh9cQm3Z29c9MWvQuFSxvT": 1500000000,
    "1dice6YgEVBf88erBFra9BHf6ZMoyvG88": 200000000
}

I tried too much but couldn't figure out how to do that in PHP, any ideas?

A: Use array_combine:
echo json_encode(array_combine($address, array_map('intval', $amount)));


text:
Q: What Does This Loop Optimization Profile Mean? I am getting started using VTune.  As an educational example, I'm trying my hand at some micro-optimization in debug mode.  Here's a toy example from my codebase.  This code appears in a C++ non-const method, and ".data_length" is an int field of the object (offset 32 bytes), typically a large number:
for (int i=0;i<data_length;++i) { /*...*/ }

VTune helpfully showed me the assembly (from MSVC 2013) for the for loop.  Note the performance numbers, in seconds (I removed all the timings that don't register).  I also added some annotation:
0x140433084 mov dword ptr [rsp+0x588], 0x0 |       | ;"i=0"
0x14043308f jmp 0x1404330a1 <Block 77>     |       | ;jump to compare and loop body
                                           |       |
0x140433091 Block 76:                      |       | ;"++i"
0x140433091 mov eax, dword ptr [rsp+0x588] | 0.451 |
0x140433098 inc eax                        | 0.002 |
0x14043309a mov dword ptr [rsp+0x588], eax |       |
                                           |       |
0x1404330a1 Block 77:                      |       | ;if (!(i<data_length)) goto next section
0x1404330a1 mov rax, qword ptr [rsp+0x6f0] | 0.407 |
0x1404330a9 mov eax, dword ptr [rax+0x20]  |       | ;  move "data_length" into "eax".
0x1404330ac cmp dword ptr [rsp+0x588], eax | 1.195 | ;  "i<data_length;"
0x1404330b3 jnl 0x140433106 <Block 80>     |       |
0x1404330b5 Block 78:                      |       |
. . .                                      |       | ;Loop body.  There's a jmp in here to
                                           |       | ;  block 76.
                                           |       |
0x140433106 Block 80:                      |       | ;code following loop

What this tells me is that loading i to increment it is incurring a caching failure (why isn't a register, geez?).  Second, that the test logic is pretty sluggish--especially loading ".data_length" each time.

I figured, why not load it once and then use decrement:
for (int i=data_length-1;i>=0;--i) { /*...*/ }

The assembly and timing look like:
0x140433084 mov rax, qword ptr [rsp+0x6f0] |       | ;Same code, but now only happens once!
0x14043308c mov eax, dword ptr [rax+0x20]  |       |
0x14043308f dec eax                        |       | ;"data_length-1"
0x140433091 mov dword ptr [rsp+0x588], eax |       | ;"i=data_length-1;"
0x140433098 jmp 0x1404330aa <Block 77>     |       | ;jump to compare and loop body
                                           |       |
0x14043309a Block 76:                      |       | ;"++i"
0x14043309a mov eax, dword ptr [rsp+0x588] | 0.357 |
0x1404330a1 dec eax                        | 0.002 |
0x1404330a3 mov dword ptr [rsp+0x588], eax |       |
                                           |       |
0x1404330aa Block 77:                      |       | ;if (i<0) goto next section
0x1404330aa cmp dword ptr [rsp+0x588], 0x0 | 0.401 | ;  "i>=0;"
0x1404330b2 jl 0x140433105 <Block 80>      | 2.806 |
0x1404330b4 Block 78:                      |       |
. . .                                      |       | ;Loop body.  Same as above, I think.
                                           |       |
0x140433105 Block 80:                      |       | ;code following loop

Look at that jl!  Three seconds for a jump?  I thought maybe the location wasn't in the instruction cache, but as you can see it's actually quite close (right after the loop body, as you'd expect).  More importantly, the first method should have the same problem anyway.  The first version's jnl didn't even register.
My guess is that its timing is getting eaten up in the loop body--although it's weird that it happens in one case but not the other.  Do I have more work to do looking in to that?
I wrote all this, and now looking again I think it may be a boring branch prediction issue.  CPUs like to take branches backward in loops, but in this case the branch to block 80 shouldn't be taken most of the time.

I'm definitely still learning this, so assuming I annotated everything mostly correctly, I have a few questions:

*

*Am I right in thinking that i should probably be a register, and that it will become one in optimized mode?

*Whatever is happening with that jl in the second version?  Is it indeed a branch prediction fail?  Why doesn't it show up on the next instruction?

Edit: The CPU this is being tested on is an Intel 990X (Gulftown, 2011).

A: i should probably be in a register (e.g. if the compiler optimised); however it's also possible that the code in the loop body (not shown) uses all the registers and that it's better for performance to avoid putting i in a register (especially if that loop body contains an inner loop or function call or something).
I have no idea what your CPU is (VIA, AMD, Intel; Atom, Xeon; how old), but the branch prediction in modern CPUs should handle that branch well. However you could maybe expect a branch mis-prediction when the loop terminates, and if the number of iterations is low (e.g. data_length-1 is small) that single mis-prediction might be significant.


text:
Q: Flutter :- How manage the backstack like in Android "SingleTask"? I am trying to manage the backstack in Flutter like in Android we manage it from launchMode (eg. SingleTask,SingleTop , Standard etc..) , For it i have tried the Routes in flutter, but did not get the success, please check the below code, which i have tried to achieve the backstack.
Widget makeRoute(
    {@required BuildContext context,
    @required String routeName,
    Object arguments}) {
  final Widget child =
      _buildRoute(context: context, routeName: routeName, arguments: arguments);
  return child;
}

Widget _buildRoute({
  @required BuildContext context,
  @required String routeName,
  Object arguments,
}) {
  switch (routeName) {
    case '/':
      return SplashScreen();

    case '/A':              //// NAME OF SCREEN IS A
      return A();

    case '/B':              //// NAME OF SCREEN IS B
      MyBean docs = arguments as MyBean;
      return B(dataToShow: docs);

    case '/C':              //// NAME OF SCREEN IS C
      MyBean docs = arguments as MyBean;
      return C(dataToShow: docs);

    case '/D':             //// NAME OF SCREEN IS D
      return D();

  }
}

I am jumping the screens from A->B->C->D are as follow,
From A->B , I navigate it like below.
Navigator.of(context).pushNamed('/B');

From B->C , I navigate it like below.
 Navigator.of(context).pushNamed('/C', arguments: myList[index]);

And finally, From C->D , I navigate it like below.
Navigator.of(context).pushNamed('/D');

As from the above code, I successfully navigated to the A------>D screens and also carrying data successfully.
But my main concern is that i want to navigate from the D->A or D->B screen using the backstack without opening another screen, So i have tried the below code but it is not working , please check the below code.
From D->A, I have tried like
Navigator.popUntil(context, ModalRoute.withName('/A'));

And even tried in this manner like below.
 Navigator.of(context)
          .popUntil(ModalRoute.withName("/A"));

I even this way to manage the flow like below
 SchedulerBinding.instance.addPostFrameCallback((_) {
                      Navigator.popUntil(context, ModalRoute.withName('/A'));

                    });

But both are not working properly
Please check my main() class
void main() {
  runApp(
      MaterialApp(
        debugShowCheckedModeBanner: false,
        title: '',
        theme: ThemeData(
          brightness: Brightness.light,
          primarySwatch: Colors.grey,
          primaryColor: ColorConst.PRIMARY_COLOR,
          accentColor: ColorConst.ACCENT_COLOR,
          primaryColorBrightness: Brightness.light,

          accentColorBrightness: Brightness.light,
        ),

          onGenerateRoute: (RouteSettings settings) {
            return MaterialPageRoute(
              builder: (BuildContext context) => makeRoute(
                context: context,
                routeName: settings.name,
                arguments: settings.arguments,
              ),
              maintainState: true,
              fullscreenDialog: false,
            );
          }

      )
  );
}

And getting the following exception from above code like below.
═ (2) Exception caught by widgets library ═══════════════════════════════════════════════════
'package:flutter/src/widgets/navigator.dart': Failed assertion: line 2330 pos 12: '!_debugLocked': is not true.
The relevant error-causing widget was:
  MaterialApp **file:///Users/apple/Documents/BitBucket%20Projects/loyalityapp_android/lib/main.dart:10:7**
════════════════════════════════════════════════════════════════════════════════════════════════════

A: If you are using the following code to pop until the route "/A" using Navigator.popUntil method then you should have to set your opening screen with the help of "initialRoute" property in your MaterialApp Widget instead of "home" property.
Navigator.popUntil(context, ModalRoute.withName('/A'));

Because, here you are navigating to the route "A" with the help of "push navigator routes" and want to pop using "named routes"

Also, you can set it with "/" route in your routes property as Follow,
initialRoute : "A",

OR
routes:{
          "/": (context)=> A(),
}

Every thing other is fine in your code.

A: I have solved the problem by using the MaterialPageRoute and referred this link to get the solution Click here
From A->B->C->D screen navigation, I have used this approach
From A->B screen
 Navigator.push(
                    context,
                    MaterialPageRoute(
                      settings: RouteSettings(name: "B"),
                      builder:  (context) => SCREEN_B(),
                    ),
                  );

And from B->C, I haved used this along with parameters like below
 Navigator.push(
              context,
              MaterialPageRoute(
                settings: RouteSettings(name: "C"),
                builder:  (context) => SCREEN_C(dataToShow:myList[index]),
              ),
            );

From C->D screen
 Navigator.push(
                    context,
                    MaterialPageRoute(
                      settings: RouteSettings(name: "D"),
                      builder:  (context) => SCREEN_D(),
                    ),
                  );

And main logic is here navigations from D->A or D->B, from below liens of code
Navigator.popUntil(context, ModalRoute.withName("A"));  //YOU CAN USE "B" TO NAVIGATE

At the last one more thing which I need to add here is that when I want to perform any action like refresh activity and anything else from screen D->A
Then inside the A screen, we need to use then method  like below
Navigator.push(
          context,
          MaterialPageRoute(
            settings: RouteSettings(
                name: "B"),
            builder: (context) =>
                B(dataToShow: MYLIST[index]),
          ),
        ).then((value) {
          //// THIS METHOD IS ENVOKE WHEN SCREEN COME FROM D->A OR B->A, YOU CAN PERFROM CAN TASK HERE
        });


text:
Q: Opsworks cookbooks complains of missing method I am trying to deploy my rails app with opsworks recipes that I get from AWS. I tried to setup the entire thing by referring a blog here. Whatever he says is "php" or "php-app", I replaced with "rails" and my app name.
My role JSON for the app looks like this -

{
  "name": "hercules",
  "description": "OpsWorks recipe run-list for the rails app layer",
  "app_type": "rails",
  "default_attributes": {
    "max_pool_size": 5
  },
  "run_list": [
    "recipe[opsworks_initial_setup]",
    "recipe[dependencies]",
    "recipe[unicorn::rails]",
    "recipe[rails::configure]",
    "recipe[deploy::default]",
    "recipe[deploy::rails]"
  ],
  "chef_type": "role",
  "json_class": "Chef::Role"
}

When I try to deploy, it runs other recipes well and gets stuck on this error for deploy::rails -

    ==> app: ================================================================================
==> app: Recipe Compile Error in /tmp/vagrant-chef-3/chef-solo-1/cookbooks/deploy/recipes/rails.rb
==> app: ================================================================================
==> app:
==> app:
==> app: NoMethodError
==> app: -------------
==> app: No resource or method named opsworks_deploy' forChef::Recipe "rails"'
==> app:
==> app:
==> app: Cookbook Trace:
==> app: ---------------
==> app:   /tmp/vagrant-chef-3/chef-solo-1/cookbooks/deploy/recipes/rails.rb:20:in block in from_file'
==> app:   /tmp/vagrant-chef-3/chef-solo-1/cookbooks/deploy/recipes/rails.rb:2:ineach'
==> app:   /tmp/vagrant-chef-3/chef-solo-1/cookbooks/deploy/recipes/rails.rb:2:in `from_file'
==> app:

If I open the rails.rb:20, that function is there -

  opsworks_deploy do
    Chef::Log.info("****** hi there *")
    Chef::Log.info("#{application}")
    Chef::Log.info(deploy.inspect)
    app application
    deploy_data deploy
  end

Am I missing something terribly stupid here?

A: OK. After spending 2 days behind this, in some far corner of google's search results, I found this - https://tickets.opscode.com/browse/CHEF-5011
Pasting some relevant info below -

A change to the Recipe DSL causes any NoMethodError or NameError that occurs inside a Resource's do..end block to be incorrectly reported as something like
  No resource or method named file' forChef::Recipe "default"'
  For example, the error in the following recipe code is clearly the no_method_here bit inside the file resource:
file "/tmp/whatever" do
    no_method_here
  end
However, the error gets reported as:
================================================================================
Recipe Compile Error in /private/tmp/error_message_repro/repro/recipes/default.rb
================================================================================
NoMethodError

No resource or method named file' forChef::Recipe "default"'
Cookbook Trace:

/private/tmp/error_message_repro/repro/recipes/default.rb:1:infrom_file'`
Relevant File Content:

  /private/tmp/error_message_repro/repro/recipes/default.rb:
1>> file "/tmp/whatever" do
    2:    no_method_here
    3:  end
    4:

And someone puts in a patch and a oneliner -

sudo wget https://github.com/opscode/chef/raw/29e732d97ec7e28b2111aca9f93edfd1bc257c2d/lib/chef/dsl/recipe.rb -O /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.0/lib/chef/dsl/recipe.rb --no-check-certificate

(assumes your chef client is in /opt/chef)
Hope this helps someone going through same pain.


text:
Q: php 3 array loop to send single email from first array I have three arrays. They are all index based arrays [0], [1]... They are:
$array_userinfo[login][email]
$array_userallmeetingfoldersco[login,folder-id]
$array_expiredmeetingscos[sco-id,folder-id,name,date-modified,date-end

$array_userinfo 's first element (login) matches $array_userallmeetingfoldersco 's first element (login). In turn, $array_expiredmeetingssco 's second element (folder-id).
What I need to achieve is that IF array_userinfo's 'login' is found inside $array_userallmeetingfoldersco's 'login' then find any matching 'folder-id' between $array_userallmeetingfoldersco and $array_expiredmeetingscos and, if found, send email only once to the 'email' address of $array_userinfo; the email ideally includes 'name', 'date-modified', 'date-end' fields from $array_expiredmeetingscos array.
Update: Code for loops added
foreach($array_userinfo as $userInfo) {//user logins; make this into easy to search
 $checkAgainstLogins[$userInfo[0]] = $userInfo[1];//0 is login, 1 is email
}

foreach($array_expiredmeetingscos as $expiredMeetings) {//expired meetings. make this into easy to search
$checkAgainstExpiredMeetings[$expiredMeetings[1]] = $expiredMeetings[2];//1 is folder-id, 2 is name
}

//loops for email follow
foreach($array_userallmeetingfoldersco as $matchingLogins) {
  if(isset($checkAgainstLogins[$matchingLogins])) {//login matched. Now find matching 'folder-id'
   foreach($array_expiredmeetingscos as $matchingFolderID) {
     if(isset($checkAgainstExpiredMeetings[$matchingFolderID])) {//folder-id matched
     //add to some array of expired Meetings? then email?
     }
   }
}

}
So loop within loop but the complicating factor is to send email only once. Any code to share?
Thanks!


text:
Q: SignedXml.LoadXml() throws a CryptographicException I have a connection to an external WebService which was running flawless for ages until medio may 2018. Suddenly I started getting a CryptographicException with the message "Malformed XML Signature". My investigation tells me the following:
The exception is thrown from the line LoadXml(signature); in a class that inherits from System.Security.Cryptography.Xml.SignedXml
Here's the code:
public bool CheckAssertionSignature()
    {
        if (Xml == null || Xml.DocumentElement == null)
            return false;

        var xmlass = Xml.DocumentElement.LocalName == "Assertion" ? Xml.DocumentElement : Xml.GetElementsByTagName("Assertion", Namespaces.Saml)[0] as XmlElement;
        var signature = xmlass.GetElementsByTagName("Signature", Namespaces.Ds)[0] as XmlElement;
        if (signature == null) return false;
        LoadXml(signature);
        var cert = KeyInfo.Cast<KeyInfoX509Data>().Select(d => d.Certificates[0] as X509Certificate2).FirstOrDefault(c => c != null);

        return cert != null && CheckSignature(cert, true);
    }

What I've learned so far is:
A colleague and I have tested the code locally on two different versions of windows 10. His version is newer than mine. He gets the error and I don't.
The xml processed by the code is identical
The error started on the 16th of may 2018 and on that date the server installed this security update https://support.microsoft.com/da-dk/help/4099635/security-and-quality-rollup-for-net-framework-3-5-4-5-2-4-6-4-6-1-4-6
We know that a similar update earlier caused a similar problem:
https://support.microsoft.com/en-us/help/3148821/after-you-apply-security-update-3141780-net-framework-applications-enc
Has anyone an idea about how to solve this problem (and is anybody else experiencing the problem)?
PS. The code is running on a Windows srv 2012 R2 and the problem also exists on a  windows srv 2016

A: We found a solution! It seems that the System.Security update has forced a more strict validation of the XML Signatures.
In the XML we receive, the Signature elements id property is written "id". According to Schema for XML Signatures (http://www.w3.org/2000/09/xmldsig#) it should be "Id". The LoadXml method before the security update did not throw up about this, but after it does.
Since the received XML is with the inappropriate attribute , we have create the following workaround to change the attribute:
if (signature.Attributes.GetNamedItem("id") is XmlAttribute oldId)
{
    signature.Attributes.Remove(oldId);
    if (signature.OwnerDocument != null)
    {
        var newId = signature.OwnerDocument.CreateAttribute("Id");
        newId.Value = oldId.Value;
        signature.Attributes.Append(newId);
    }
}

Although we don't understand why the validation should be so strict, that only "Id" validates as ok... Never the less, I doubt we get through to Microsoft, rolling it back :D


text:
Q: How to transfer the value of id demo to the textbox value I'm trying to get the value of range slider so i decided to use javascript to show the value of slider in span id = demo. Is there any idea how to transfer the value of javascript into textbox so that i can condition the value.
My Php and HTML
<input id="mySlider" type="range" min="1" max="6" name="rangee" step="1" value="1" onchange="resizeImage();" style="width:510px;">

Width:   <input name="num" type="text" value="<?php  ?>" />

      <?php

        $_POST["rangee"] = $_POST["num"];
        $ranger = $_POST["rangee"];

        if($ranger == "1"){
          echo "39 inches";
        }else if($ranger == "2"){
          echo "39 inches";
        }else if($ranger == "3"){
          echo "54 inches";
        }else if($ranger == "4"){
          echo "60 inches";
        }else if($ranger == "5"){
          echo "76 inches";
        }else if($ranger == "6"){
          echo "72 inches";
        }

      ?>

My Javascript
  var slider = document.getElementById("mySlider");
  var output = document.getElementById("demo");
  output.innerHTML = slider.value;

  slider.oninput = function() {
    output.innerHTML = this.value;
  }

  function resizeImage() {
  var image = document.getElementById('img-wrapper'),
      ranger = document.getElementById('mySlider');
  image.style.width = 120*(mySlider.value / 1)+'px';
  }

I really appreciate your help. Thanks in advance.

A: If you looking set your textbox value based on your slider value, you can use this.

function resizeImage(value) {
  var image = document.getElementById('img-wrapper'),
    ranger = document.getElementById('mySlider'),
    newvalue = value;
  //image.style.width = 120 * (mySlider.value / 1) + 'px';

  //uncommand this part if you looking for inches value
  /*if (value == 1) {
    newvalue = '39 inches';
  }else if (value == 2) {
    newvalue = '41 inches';
  }*/

  $('#num').val(newvalue);
}

<input id="mySlider" type="range" min="1" max="6" name="rangee" step="1" value="1" onchange="resizeImage(this.value);" style="width:510px;">

Width:
  <input id="num" name="num" type="text" />

But if you looking for inches value based on your slider value, you need uncommand this part
    /*if (value == 1) {
     newvalue = '39 inches';
    }else if (value == 2) {
     newvalue = '41 inches';
    }*/


text:
Q: Mark has been invalidated error I read the android dev guide on loading large bitmaps efficiently.Here's some code to explain what Im doing.
fis = imageToSend.getReadStream();
InputStream is = new BufferedInputStream(fis);
bitmapToSend = decodeSampleBitmapFromStream(is, 60, 60);
.
.
.
public Bitmap decodeSampleBitmapFromStream(InputStream is, int reqWidth, int reqHeight){
      // First decode with inJustDecodeBounds=true to check dimensions
      final BitmapFactory.Options options = new BitmapFactory.Options();
      options.inJustDecodeBounds = true;
      BitmapFactory.decodeStream(is,null,options);

      // Calculate inSampleSize
      options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);

      // Decode bitmap with inSampleSize set
      options.inJustDecodeBounds = false;
      try {
        is.reset();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
      return  BitmapFactory.decodeStream(is,null,options);
}

public static int calculateInSampleSize(
        BitmapFactory.Options options, int reqWidth, int reqHeight) {
// Raw height and width of image
final int height = options.outHeight;
final int width = options.outWidth;
int inSampleSize = 1;

if (height > reqHeight || width > reqWidth) {

    final int halfHeight = height / 2;
    final int halfWidth = width / 2;

    // Calculate the largest inSampleSize value that is a power of 2 and keeps both
    // height and width larger than the requested height and width.
    while ((halfHeight / inSampleSize) > reqHeight
            && (halfWidth / inSampleSize) > reqWidth) {
        inSampleSize *= 2;
    }
}

return inSampleSize;
}

I am trying to decode the fis by setting inJustDecodeBounds true and then calculating the sample size but its returning me an IOException :Mark has been invalidated.Can someone explain what this error is and how to fix it?