Max WP upload limit won't change after editing php.ini

Question: I'm wondering if anyone has any ideas about this - I've been struggling with increasing the max upload size for my wp site for weeks now.
I've tried editing the php.ini parameters 'upload_max_filesize' (umf), 'post_max_filesize' (pmf), 'memory_limit' (ml) to no avail.  I need to upload files up to 500M in size and mysteriously managed to get it to upload somewhere around 410M max (even though I had 500M in the .ini file and the wp media panel said 'max file upload size: 500M').  Suddenly today I went to upload and it read 'max file upload size: 0 B' - I checked the .ini and it was set to 2M for 'umf', 0 for 'pmf' (something must have been written over).
I changed umf to 500M, pmf to 500M, ml to 1000M, restarted nginx via command line (the host is digital ocean, os Ubuntu) and the WP media interface still reads 0 B.  I checked my info.php file and umf reads 2M there.  The loaded config file path is '/etc/php/7.0/fpm/php.ini' and that's the one I'm editing.  If anyone had any suggestions before I smash my screen w/ a hammer I would greatly appreciate it :)
Answer: Try doing it in your functions.php and see if it makes a change or not.
<code>@ini_set( 'upload_max_size' , '500M' );
@ini_set( 'post_max_size', '500M');
@ini_set( 'max_execution_time', '300' );
</code>
If that doesn't work you can also do it in your .htaccess file for WordPress if you're using Apache.
<code>php_value upload_max_filesize 500M
php_value post_max_size 500M
php_value max_execution_time 300
php_value max_input_time 300
</code>
Comment: Thanks Jordan - I tried to add this to the end of both default functions.php and functions.php in the child theme I'm using but nothing changes.  The site uses nginx so there is .htaccess


apt-cache --installed show lists packages that are not installed

Question: The --installed option does not appear to do anything. The man page isn't specific as to what is intended by its behavior, ie I can't tell if it either. For the applicable actions (presumably show and showpkg):

Only returns the version of the package that is installed
Only returns information for packages that are installed that match the query

In any case, it does not appear to do either of the above, instead returning the same output regardless of the option.
Comment: http://explainshell.com/explain?cmd=apt-cache+--installed and it's present in man apt-cache show
Answer: They are explaining things wrong. That option is a modifier of the rdepends and depends commands:

--installed
      Limit the output of depends and rdepends to packages which are currently installed. Configuration
      Item: APT::Cache::Installed

But then, it just don't show that, but is the list of the package that are installed, i. e.:
$ apt-cache depends kde-baseapps-bin
kde-baseapps-bin
  Depends: kde-runtime
  Depends: libc6
  Depends: libkdecore5
  Depends: libkdeui5
  Depends: libkfile4
  Depends: libkio5
  Depends: libkparts4
  Depends: libqt4-dbus
  Depends: libqt4-xml
  Depends: libqtcore4
  Depends: libqtgui4
  Depends: libstdc++6
  Depends: libx11-6
  Depends: kde-baseapps-data
  Breaks: <kcontrol>
  Breaks: <kcontrol:amd64>
  Breaks: kdebase-bin
  Breaks: <kdebase-bin:amd64>
  Breaks: <kdesktop>
  Breaks: <kdesktop:amd64>
  Replaces: kdebase-bin
  Replaces: <kdebase-bin:amd64>
  Conflicts: kde-baseapps-bin:amd64

As you can see, all the dependencies of the package, if I use --installed:
apt-cache --installed depends kde-baseapps-bin
kde-baseapps-bin
  Depends: libc6
  Depends: libqt4-dbus
  Depends: libqt4-xml
  Depends: libqtcore4
  Depends: libqtgui4
  Depends: libstdc++6
  Depends: libx11-6

Shorter, right? Out of all dependencies of that package, those are the only ones that I have installed. That's what the --installed modifier do, it do not list all the installed package.


How can you place query results into an arbitrarily large array?

Question: I have a site with friends list, and such. I use while loops to iterate through the lists, and I wanted to use a foreach loop instead.
The while loop works just as it should there's no problem with it. I'm not asking how to use a foreach loop. But when I tried changing the while loop I realized the following code;
   <?php

$my_id = $_SESSION['user_id'];
$request = "SELECT `request_from` FROM `friend_requests` WHERE `request_to`='$my_id' ";
$request_query = mysqli_query($conn, $request);
while ($run_request = mysqli_fetch_array($request_query)){
$from = $run_request['request_from'];
$username = getuser($from, 'username');

echo"
";
echo "
".$username."
";
echo "
";
echo "
";
}

output:

sammy davis jr
frank sinatra
dean martin

Doesn't produce AN array the contains friends, it contains an arbitrary number of arrays, that have only one element in them. As when I do
print_r($runrequest);

output:

Array ( [0] => 20 [request_from] => 20 )
Array ( [0] => 21 [request_from] => 21 )
Array ( [0] => 19 [request_from] => 19 )

So my question is, is there a way for me to rewrite my mysqli_query so that I produce only one, arbitrarily large, array that I would then iterate through with a foreach loop. As opposed to the query I have which produces an arbitrary number of arrays, that I have to iterate through with a while loop.
Comment: I just did print_r(...)  to show that a series of arrays were being produced and not one
Comment: Sorry, getuser(); is a special function I wrote to print a username based off of a uid
Answer: $run_request is an array of just the 1 row/result per iteration. If you want an array with all the data build it in the loop. You don't need the getuser function, you can use a join to get the user's names with the one query.
$request = "SELECT u.name as name FROM `friend_requests` as fr
            join users as u
            on u.userid = fr.request_from
            WHERE `request_to`='$my_id' ";
$request_query = mysqli_query($conn, $request);
while ($run_request = mysqli_fetch_array($request_query)){
     $users[] = $run_request['name'];
}
print_r($users);

Alternatively you could use http://php.net/manual/en/mysqli-result.fetch-all.php.


Pandas: how to make openpyxl the default engine for all read_excel operations?

Question: Since read_exceldefault engine xlrd has been deprecated in newer pandas releases, how do I make openpyxl the default engine of all my pd.read_excel calls?
Now, if I update pandas, I must put the parameter engine="openpyxl" in all my pd.read_excel calls. It looks unnecessary.
Comment: From the [docs](https://pandas.pydata.org/pandas-docs/version/1.2.0/reference/api/pandas.read_excel.html#pandas.read_excel): Otherwise if path_or_buffer is an xls format, xlrd will be used., **Otherwise if openpyxl is installed, then openpyxl will be used**.
Answer: It's easy! You can do it by changing the default values of the method by going to the _base.py inside the environment's pandas folder. You can find it as follows:
import pandas as pd
print(pd.__file__)

Once in the pandas folder, dive into the folder io > excel > _base.py
Open the file and find
def read_excel(...)

You will find the default value for engine. Change it to 'openpyxl'
If you're using vscode, simply right click on the instance of the method .read_excel and press F12, or go to the definition and change it right away.
Answer: If you're using pandas version 1.1.5 or other new version this might help:
Run print(pd.__file__) to see where your pandas library is stored. Usually, the file path would end in "Lib\site-packages\pandas". Then, open folder "io" and folder "excel" right after. You will find there the "_base.py" file.
Look for the def __init__. You will find there the default engine to read Excel files. It should be on line 849. I  should read:
if engine is None:
    engine = "openpyxl"


Diagonalizable over $\mathbb{Z}/p$ versus over the algebraic closure

Question: If $k$ is the algebraic closure of $\mathbb{Z}/p$ for a prime $p$, and $M$ is a matrix in $GL_n(\mathbb{Z}/p)$. The canonical inclusion $\mathbb{Z}/p \subset k$ lets us view $M$ as a matrix over $k$.
Is $M$ diagonalizable over $\mathbb{Z}/p$ $\iff$ $M$ is diagonalizable over $k$?
Going left to right seems to be true, since if $P^{-1}MP$ is diagonalizable when $P \in GL_n(\mathbb{Z}/p)$, then including these matrices into $GL_n(k)$ gives a diagonalization of $M$ over $k$. But what about the other direction? If it's not true, is there an addition condition one could impose that would make it true?
Comment: The minimal polynomial must be separable and split completely.
Comment: I think an argument using $\Bbb R$ and $\Bbb C$ would carry over, if not directly, then at least in spirit (as in, you can't use the exact same numbers, obviously, but more or less the same argument ought to work).
Comment: Since $k$ is the algebraic closure of $\mathbb{F}_p$ - a field of characteristic $p>0$ there can be no inclusion $\mathbb{Z} \subseteq k$.
Answer: If $p$ is not congruent 1 mod 4, the equation $x^2+1=0$ does not admit a solution in $\mathbb F_p$, hence the matrix $$\begin{bmatrix}0&-1\\1&0\end{bmatrix}$$
is not diagonizable over $\mathbb F_p$. It is diagonalizable over the algebraic closure $\overline{\mathbb{F}_p}$ however, since $x^2+1 = (x-i)(x+i)$ in $\overline{\mathbb F_p}$.
As linear algebra tells you: If you want a matrix $A$ over a field $K$ to be diagonalizable, its characteristic polynomial has to split completely and the dimensions of the respective eigenspaces have to match the algebraic multiplicities. This is an if and only if, so it is not clear to me what "additional condition" you are asking for.
In fact, by a mere counting argument we can deduce that in every finite field $F$ of odd characteristic there is an element $t$, which is not a square, ie. for which $x^2-t$ does not admit a solution in $F$. Thus the matrix
$$\begin{bmatrix}0&t\\1&0\end{bmatrix}$$
is not diagonizable over $F$, while it is over $\overline{F}$. So your there cannot be a criterion making your equivalence hold true in general (unless maybe p=2, but we can find a counterexample there too).
Comment: For $p=2$, we can consider $\begin{pmatrix}0 & -1\\1 & -1\end{pmatrix}$, whose characteristic polynomial is $X^2+X+1$, which has no root in $\mathbb{F}_2$. In general, over a finite field, there are polynomials with no root of any degree $n >1$ (and in fact, irreducible polynomials of any degree).


How do you make an image span the width of eBay's description field exactly? (No horizontal scrolling)

Question: eBay listings have a description field with 5000 character limit. It allows some html tags and the style attribute, but a lot of functionality is disabled.
When I insert an image that is too wide, eBay adds horizontal scrolling, which is a terrible user experience. I want an image that automatically resizes to the available width without triggering horizontal scrolling.
It seems the most widely used, and officially recommended method of resizing to different screens, is changing the viewport using the meta tag as described here.
Unfortunately this also changes the text size, and doesn't give the option to only scale one image and not others. Is this the only method? Or is there another way?
Or am I just using the meta tag wrong? (I put <meta name="viewport" content="width=device-width, initial-scale=1"> on the first line and wrote the rest of the description under it.)
Comment: @UnbrandedManchester and to answer your question more literally, yes I have been using inline css. Inline css seems to work fine. (But knowing eBay, you never know what they have disabled from it.)
Comment: tbh I hate eBay with a passion - I did this a good few years ago https://www.ebay.co.uk/itm/Luxury-Faux-Silk-Slubbed-Pair-Curtains-Eyelet-Ring-Top-Lined-Inc-Tiebacks/161252347460?hash=item258b638e44:m:mtXBwYC7NUybzIcYHu9mC_g&var=460293583564 - take a look at the header image and the containers wrapped around it, it may help.
Comment: This is... very good. I'm going to take some time to study it. I don't know yet if it answers my question in the literal sense, but if you included that link in an official answer it would definitely get my upvote even if I found it not to deserve the green tick.
Comment: You're using the meta tag correctly from what I can see, have you tried putting inline css into the image tag like:  or even  ??
Comment: @UnbrandedManchester I did just now. No luck. "max-width:100%" seems to have made  it a few pixels smaller, but if it worked correctly it would have made the image half size. It was a solid attempt though. Thanks for trying. (I was expecting it to work when I read it.)
Answer: This is the old code I've used for a template in the past. Using containers and remotely hosted CSS I was able to constrain images to the container wrapped around the whole template.
Unfortunately, as you know, eBay is a bit rubbish when it comes to responsive CSS, so this doesn't work well when under 1400px (I think).
I think you may be able to add some responsive media queries in order to stack this properly. However, this was created before the days of good responsive design I'm afraid.
CSS
@charset "utf-8";
/* CSS Document */

body {
background:#ffffff;
/*background-image:url(http://www.unbmedia.co.uk/Clients/UNB09029/bg.jpg);*/
background-position:center;
background-repeat:repeat-y;
}

/* Constrain Page Size */
.pagewidth {
    width:954px;
    text-align: centre;
    left: 0;
    margin:auto;
}

.pageminwidth {
    text-align: left;
    left: 0;
}

/* Footer Links with Country Names */
#sFooter {
    text-align:center;
    font-size:10px;
}

/* Ebay Footer Links */
span.ebay{
    text-align:center;
}

#title{
    font:Arial, Helvetica, sans-serif;
    font-family:Arial, Helvetica, sans-serif;
    font-size:24px;
    background:#548101;
    color:#FFF;
    padding:20px;
    color:#777;
    font-size:14px;
    padding:3px;
    font-family: serif;
    letter-spacing: 0.5px;
    font-weight: 100;
    transition: all 0.3s;
}

#left-men-tit{
    background: #18213E;

    color:white;
    font-size:14px;
    padding:3px;
    font-family: serif;
    letter-spacing: 0.5px;
    font-weight: 100;
    transition: all 0.3s;
    padding:10px;

}

#left-men{
    font:Arial, Helvetica, sans-serif;
    font-family:Arial, Helvetica, sans-serif;
    color:#548101;
    font-size:14px;
    padding-left:12px;
    padding-top:3px;
    padding-bottom:3px;

}

#desc-title-list{
    font:Arial, Helvetica, sans-serif;
    font-family:Arial, Helvetica, sans-serif;
    color:#548101;
    font-size:12px;
}

#desc-desc-list{
    font:Arial, Helvetica, sans-serif;
    font-family:Arial, Helvetica, sans-serif;   color:#000000;
    font-size:12px;
}

#product-desc-title{
    font:Arial, Helvetica, sans-serif;
    font-family:Arial, Helvetica, sans-serif;   color:#fff;
    font-size:12px;
    background-color:#548101;
    padding:10px;

}

#product-desc{
    font:Arial, Helvetica, sans-serif;
    font-family:Arial, Helvetica, sans-serif;
    color:#000000;
    font-size:12px;
    padding-left:5px;
}

td#product-desc{
    border:thin;
    border-color:#000;
}
table#desc{
    font:Arial, Helvetica, sans-serif;
    font-family:Arial, Helvetica, sans-serif;
    vertical-align:text-top;
}

#Main{
    font:Arial, Helvetica, sans-serif;
    font-family:Arial, Helvetica, sans-serif;
    vertical-align:top;
}

#main-holder{
    font-size:0px;
}

/* Category Links */
a:link{
    font:Arial, Helvetica, sans-serif;
    font-family:Arial, Helvetica, sans-serif;
    color:#777;
    font-size:12px;
    padding:3px;
    text-decoration:none;
    font-weight:bold;
}

a:visited{
    font:Arial, Helvetica, sans-serif;
    font-family:Arial, Helvetica, sans-serif;
    color:#777;
    font-size:12px;
    padding:3px;
    text-decoration:none;
    font-weight:bold;
}

a:hover{
    font:Arial, Helvetica, sans-serif;
    font-family:Arial, Helvetica, sans-serif;
    color: #18213E;
    font-size:12px;
    /*background:#024873;*/
    text-decoration:none;
    padding:3px;
    font-weight:bold;
    padding-left: 7px;
}

a:active{
    font:Arial, Helvetica, sans-serif;
    font-family:Arial, Helvetica, sans-serif;
    color:#548101;
    font-size:12px;
    /*background:#024873;*/
    text-decoration:none;
    padding:3px;
    font-weight:bold;
}

div#EBdescription{
    font-size:0px;
}

/*** NEW LISTING TEMPLATE CSS ***/
.container{ width: 100%; max-width: 1100px; margin:auto;}
.ebayList-MainCol{float: right; width: 79%;}
.ebayList-LeftCol{float: right; width: 21%; margin-top: 162px;}
.ebayList-LeftCol h3{display: block; width: 87%; padding: 10px; margin: 0 0px 0 0; background: #18213E; color: white;
font-size: 16px; font-weight: 100; border: 1px solid black; width: 200px;}
.ebayList-LeftCol ul{ border: 1px solid #CCC; padding: 10px; margin: 0 10px 0 0; }
.ebayList-LeftCol li:before { content: ">"; padding-left: 5px; padding-right: 5px; margin-left: 0px; font-size: 14px;}
    .ebayList-LeftCol li{ list-style: none; font-size: 14px; font-weight: 100; color:#777; padding: 10px 0;}
        .ebayList-LeftCol li a:link{font-weight: 100; color:#777!important; font-family: serif; font-size: 14px; letter-spacing: 0.5px; transition: all 0.3s;}
        .ebayList-LeftCol li a:hover{transition: all 0.3s;}
.ebayList-Header img{ width: 100%;}
.ebayList-ProductImage{width: 100%; text-align: center;}
    .ebayList-ProductImage img{width: 100%; margin: auto; position: relative; text-align: center;}
    .ebayList-ProductImage h1{ text-align: center; font-weight: 100; letter-spacing: 1px; font-size: 26px; color: #18213E; max-width: 900px; width: 100%; margin: 50px auto; }
.ebayList-Summary--Wrapper{float: left;}
  .ebayList-Summary { width: 50%; float: left;}
.ebayList-Summary h2{ font-weight: 100; font-size: 16px; margin-top: 30px; border-bottom: 1px solid #ccc;padding-bottom: 10px;}
    .ebayList-Summary p{ font-weight: 100; font-size: 14px; line-height: 22px;}
.ebayList-Spec { width: 48%; float: left; margin-bottom: 20px; margin-top: 0px; padding-left: 2%}
.ebayList-Spec h2{font-weight: 100; font-size: 16px; margin-top: 30px; border-bottom: 1px solid #ccc;padding-bottom: 10px;}
    .ebayList-Spec dl{ width: 100%;}
        .ebayList-Spec dt{ width: 30%; float: left; font-weight: bold; margin: 0; font-size: 14px; margin-bottom: 5px;}
        .ebayList-Spec dd{ width: 70%; float: left; margin: 0; font-size: 14px; margin-bottom: 5px;}
.ebayList-Shipping-Returns { float: left; width: 50%; text-align: left; margin-bottom: 50px;}
    .ebayList-Shipping-Returns img{width:98%;}
    .ebayList-Shipping-Returns + .ebayList-Shipping-Returns{text-align: right;}
.ebayList-footer{float: left;}
    .ebayList-footer img{ width: 100%;}

@media (max-width:1000px) {
    .ebayList-LeftCol{ display: none; }
    .ebayList-MainCol{ width: 100%; }
}
@media (max-width:700px) {
    .ebayList-Spec{ width: 100%; padding-left: 0;}
    .ebayList-Summary{ width: 100%; }
    .ebayList-Shipping-Returns{ width: 100%; }
}

Listing Description:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://remote.littens.co.uk/listing.css" type="text/css">

CHILDREN'S CHARACTER DESIGN BEANBAG BEAN BAG SEAT FILLED JUNIOR KIDS TODDLER

Product Summary

These are official novelty character licensed beanbags. These are filled to a perfect volume of 3 cubic ft, giving it an ideal structure and cushioning for the children to sit and enjoy. These would make an ideal piece of soft furniture in
          a child's room. All our products are fully compliant to the UK Furniture and Furnishings Regulations.

Please select the design you require from the drop down menu at the top.

Specification

Product

Beanbag

Brand

Assort

Version

Kids

Colour

Assort

Size

3 Cubic Feet

Dimensions

50x50x50cm

Includes

Beanbag & Filling

Material

100% Cotton / Polystyrene Bead

Washable

Cover Machine Washable

Suitability

Over 3 Years Of Age

Shop Categories

Duvets

Pillows

Mattress Toppers

Curtains

Duvet Covers Sets

Cushion Covers

Bedding Bundle Sets

Childrens Room

Nursery & Baby

Livingroom

Bed Linen

Bedspreads / Throws

Comment: I'll give this an upvote for now and a closer look tomorrow.
Comment: I'm still not sure how you've done it, but playing with the screen width here http://vi.vipr.ebaydesc.com/ws/eBayISAPI.dll?ViewItemDescV4&item=161252347460&t=1531907441000&category=45515&seller=littensco&excSoj=1&excTrk=1&lsite=3&ittenable=false&domain=ebay.co.uk&descgauge=1&cspheader=1&oneClk=2&secureDesc=0 I know you've done it. But even more impressive are the columns. How did you do that!?
Comment: Found it! `@media (max-width:1000px)` works? Good to know
Comment: A tip to improve your page: https://tamebay.com/2018/05/eliminate-see-full-item-description-blue-buttons-on-ebay-listings.html#:~:text=If%20you%20are%20getting%20a,you%20need%20to%20remove%20it.
Answer: I found this site when trying to solve the same problem. I'm new to coding and generally reverse engineer stuff until I get something to work.
My banner is the same image url as the ebay shop banner, yet it failed to scale properly with the code I was using.
As it happens I tried the following and it seems to have helped.  If it helps someone else then great.


ScrollView with multiple pages

Question: Normally, tutorials of UIScrollView talk about multiple pages with the size of the screen.
Beginning with the first page in the screen and the second page appearing a little in the right side:

And when scrolled, the same thing occurs with the second page: the first and the third page appears in the left/right side.

This scrollView is "implementable"? There's a way to use pages but with not entire screen width?
Comment: are you trying to make a scrollview only scroll horizontally?
Comment: I'm sorry for don't say it in the question. Yes, @yulz, just horizontal scroll.
Answer: try setting your scroll view content size
scrollView.contentSize = CGSizeMake(W, 1);

remember that "W" has to be a number greater then your scroll view's width in order to scroll horizontal. 1 is where you set the hight of your content size, if you'd like it to scroll vertically you'd make the "1" greater then your scrollview's hight.
Comment: I already did it. Don't worked. It's still considering every page width as the view width.
Answer: Yes you can do that, just change the size of your scroll view to your desired size,
Content Size as (numberOfPages * width) of your scrollview
Also enable pagination
scrollView.pagingEnabled = YES;
scrollView.contentSize = CGSizeMake(numberOfPages * scrollView.frame.size.width, 1);

For more idea, refer to this sample project, just change scrollview size in xib :)
Hope it helps :)
Comment: Thanks for the answer, but I think that you don't understood my question. Doing it you will create a page with the view width (320 pt), not exactly what I want: pages with another pages in the left/right side (as in the images).
Comment: Basically that's the idea, but when the user scrolls, the main page (in the center), goes to the left, and sets the main page to the right side. It's kinda weird to explain with text. Hope you understand. :P
Comment: I understood, Do you want this http://www.cocoacontrols.com/controls/icarousel ?  Using simple scrollview, that is not possible
Comment: Thanks a lot for the class! It'll do the job! :P
Answer: You need to implement a scroll view container (e.g. ScrollViewContainer) to handle -hitTest:withEvent: method:
ScrollViewContainer.h:
@interface BookAlbumScrollViewContainer : UIView {
  UIScrollView * theScrollView_;
}

@property (nonatomic, retain) UIScrollView * theScrollView;

@end

ScrollViewContainer.m:
@implementation BookAlbumScrollViewContainer

@synthesize theScrollView = theScrollView_;

//...

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
  UIView * child = [super hitTest:point withEvent:event];
  if (child == self)
    return self.theScrollView;
  return child;
}

@end

HERE is a related QA on -hitTest:withEvent: method.
When you set your scroll view, set it like:
CGFloat yourScrollViewPageWidth = 280.f;
CGRect yourScrollViewFrame = CGRectMake((320.f - yourScrollViewPageWidth) / 2.f, 0.f, yourScrollViewPageWidth, 200.f);
CGRect theScrollViewContainerFrame = CGRectMake(0.f, 0.f, 320.f, 200.f);

// Your scroll view
yourScrollView_ = [[UIScrollView alloc] initWithFrame:yourScrollViewFrame];
//...
[self.view addSubview:bookScrollView_];

// Your scroll view container to handle touches, it should be over |yourScrollView_|
theScrollViewContainer_ = [ScrollViewContainer alloc];
[theScrollViewContainer_ initWithFrame:theScrollViewContainerFrame];
[theScrollViewContainer_ setBookAlbumScrollView:yourScrollView_];
[self.view theScrollViewContainer_];

ScrollView with multiple pages


Linear singly-celled two-layer ANN with produces constant predictions

Question: Say that we want to fit a straight line in the plane through the origin and the point (1, 2). We can view this as linear regression with a sample of size 1 and no intercept. This, on the other hand, can be represented as a rather trivial neural network with no hidden layers and no activation. In Keras, this would look as follows:
model = keras.Sequential([
    keras.layers.Dense(1, input_shape=(1,), use_bias=False,
                       kernel_initializer=keras.initializers.Zeros()),
])

model.compile(loss='mse', optimizer=keras.optimizers.Adam(lr=.1))

Running
model.fit([[1]], [[2]], epochs=50)

we get our desired result. Namely, model.predict([[1]]) produces a number close to 2.
Now, include a second layer in the model:
model2 = keras.Sequential([
    keras.layers.Dense(1, input_shape=(1,), use_bias=False,
                       kernel_initializer=keras.initializers.Zeros()),
    keras.layers.Dense(1, use_bias=False,
                       kernel_initializer=keras.initializers.Zeros())
])

model2.compile(loss='mse',
               optimizer=keras.optimizers.Adam(lr=.1))

This time around, no matter what we throw after model2.fit, we'll find that model2.predict is constantly equal to zero. Moreover, this happens regardless of which one of Keras' gradient descent algorithms is used.
This is surprising since the two models are equivalent in the sense that the parameter of the first model can be realized as the product of the two parameters in the second one. That is, we are fitting a straight line y = abx by trying to find values of a and b. Taking, for instance, a = 2 and b = 1 would produce a perfect fit.
So, what's the difference?
Comment: Are you initializing all weights to zero? That is generally a very bad idea. Usually small random values are used.
Answer: This turns out to be a rather unfortunate side effect of the chosen initial values. It is easy to see that for the given sample, the gradient of the mean squared error optimization objective is
(a, b) ↦ 2(b(ab − 2), a(ab − 2))
which happens to equal zero when (a, b) = (0, 0). Choosing any other initial values for the parameters, and everything goes through as expected. In particular, using
kernel_initializer=keras.initializers.Constant(.1)

in both layers would produce the desired result.
The same issue does not occur in the one-layer case since here the gradient is
a ↦ 2(a − 2)
which is zero only when a = 2.


A mathematical approach to economics

Question: Are there books or papers where economics is formalized and studied very rigorously? I am very interested in this topic. I would preferably like free online books and/or papers, but that is not necessary.
Comment: I am looking for an axiomatic approach, not merely a computational one, to economics.
Comment: Standard graduate treatment of microeconomics is: Mas-Colell, Whinston, Green (1995): Microeconomic theory. If you are looking for very rigorous papers, check out articles in the Journal of Mathematical Economics (recent ones, the old ones (80s and prior) are on today's "normal" level).
Comment: I guess you mean with statistics?
Comment: What are you looking for exactly? A lot of the more advanced stuff is very mathematical, just look at any book on macroeconomic or microeconomic theory...
Comment: I still think that a lot of the macroeconomic and microeconomic theory books that are out there are what it sounds like you're asking for. I mean utility functions are mathematical functions, so a lot of what you do is mathematical in nature with interpretations that mean something in terms of economics. As long as you don't estimate models, there is no computational aspect to it either. I'm just saying it's hard to answer your question as economics is a quite mathematical subject to begin with.
Comment: @hejseb: Most micro or macro books out there do not use the *axiomatic approach*, which was popular in the hey-days of mathematical economics (think Debreu's: Theory of Value). The same is true of most books in applied mathematics: **naive** set theory is used instead of **axiomatic** set theory.
Answer: Be careful of what you wish for... Bernt Stigun's book "Towards a Formal Science of Economics: The Axiomatic Method in Economics" probably goes above and beyond of what you had in mind when asking for rigor. He starts with mathematical logic (first-order languages)...
http://www.amazon.com/Toward-Formal-Science-Economics-Econometrics/dp/0262192845/
Also I have a vague impression some research in "epistemic game theory" may use the axiomatic approach but I might be wrong.
Comment: Yes, that is exactly what I want.
Answer: Gerard Debreu's Theory of Value provides a mathematically rigorous analysis of the theory of general equilibrium in economics. It is considered a classic by many economists and won the author a Nobel Prize in Economics.
Here's the link to the pdf of the monograph: http://cowles.econ.yale.edu/P/cm/m17/m17-all.pdf.
Comment: @Trurl Sure if we want to develop economic intuition, but if you are looking for an advanced microeconomic textbook with rigorous mathematics then I would recommend *Microeconomic Theory* textbook by Mas-Colell, Whinston, and Green.
Comment: Axiomatic yes, but it sometimes is hard to see it is economics.  Maybe start with a micro textbook such as Varian.
Answer: You might be interested in Economics for mathematicians by Cassels. It is more focused on what mathematicians find interesting, rather than what economists find useful.
Answer: Axiomatic Theory of Economics, 1999, by Victor Aguilar
This is a short 26-page simplified exposition written at the undergraduate level:
http://axiomaticeconomics.com/Axiomatic_Economics_Article_by_Aguilar.pdf
Answer: You can check the Handbook of mathematical economics edited by Michael Intriligator, Kenneth Arrow.
In general, the Handbooks in Economics contains several interesting topics.
Handbooks page

A mathematical approach to economics


How should I show that there is only one stationary path for this given functional?

Question: Let the stationary path of the functional $S[y]=\int_{0}^{v}(y'^2+y^2)dx, y(0)=1, y(v)=v, v>0$ be $y=\cosh(x)+B\sinh(x), 0\leq x\leq v$, where $B$ and $v$ are given by the solutions of the equations $v=\cosh(v)+B\sinh(v)$ and $B^2-1=2\sinh(v)+2B\cosh(v)$. Suppose that $v$ is given by the real solution(s) of $f(v)=0$, where $f(v)=v^2-2v(1+\sinh(v))\cosh(v)+1+2\sinh(v)$. Show that there is only one stationary path. Note that a graphical argument alone is insufficient. Please give rigorous analysis to back up your explanation.
My plan is to show that the equation of $f(v)=v^2-2v(1+\sinh(v))\cosh(v)+1+2\sinh(v)=0$ has a unique solution but I don't know how to. Should I find $f'(v)$ first? If that's the case, then I have $f'(v)=2v-2(1+\sinh(v))\cosh(v)-2v\sinh(v)+2\cosh(v)=0$. But what should I do from here?
Answer: The function
$$
f(v)=v^2-2v(1+\sinh(v))\cosh(v)+1+2\sinh(v) \tag{1}
$$
is continuous, $f(0)=1$ and $\lim_{v\to\infty}f(v)=-\infty$; therefore, $f$ must have at least one positive real root. On the other hand, since
\begin{align}
f'(v)=-2\sinh(v)(\cosh(v)+v+2v\sinh(v))<0\quad\text{if $v>0$}, \tag{2}
\end{align}
$f$ is strictly decreasing in the interval $(0,\infty)$, hence it can have at most one positive real root. We conclude, therefore, that $f$ has exactly one positive real root, which implies that $S$ has only one stationary path.
Comment: This really made sense!


Firebase network activity

Question: When using Firebase on the client (Chrome/Firefox) with these scripts:
<code>    <!-- Firebase -->
    <script src="https://cdn.firebase.com/js/client/1.0.15/firebase.js"></script>
    <!-- AngularFire Library -->
    <script src="https://cdn.firebase.com/libs/angularfire/0.7.1/angularfire.min.js"></script>
</code>
And this code:
<code>.controller('WaitlistController', ['$scope', '$firebase', function($scope, $firebase) {
    var partiesRef = new Firebase('https://wait-and-eat-justin.firebaseio.com/');

    $scope.parties = $firebase(partiesRef);

    $scope.party = {name: '', phone: '', size: ''};

    $scope.saveParty = function() {
        $scope.parties.$add($scope.party);
        $scope.party = {name: '', phone: '', size: ''};
    };
}]);
</code>
Everything works just fine (ie. Firebase receives updates), BUT I don't see any network traffic in the Chrome Developer tools nor the Firebug debugger for Firefox.  Why can't I see the Firebase network traffic?  I am assuming its using Websockets.
Comment: When I execute this snippet `new Firebase('https://wait-and-eat-justin.firebaseio.com/').once('value', function(s) { console.log(s.val()); })`, I see a few web sockets calls in Chrome's Network tab: `wss://wait-and-eat-justin.firebaseio.com/.ws?v=5` with one frame `{"d":{"t":"r","d":"s-dal5-nss-16.firebaseio.com"},"t":"c"}`. Can you try if it shows up for you with that snippet?
Comment: Also, whyyyyy would you use 1.0.15 and 0.7.1 when the latest are 2.1.0 and 0.9.1 respectively? It hurts my heart.
Comment: I'd like to know as well. AFAK Firebase uses the internet to communicate with my browser. I don't think that it uses the phone line, telex, or pigeons or something else.
Answer: Firebase uses Websockets. If you select WS or WebSockets on your Network tab, and refresh the page, you should see something.
In my case it was loading very early in the page, so it's easy to miss.

Firebase network activity


Django sitemap set custom paginate size?

Question: So I'm using Django (1.11)'s sitemap framework and I need to add about 3.6m records into a sitemap.
Django's built-in index sitemap automatically creates a paginated version of the sitemap.  I believe each paginated sitemap page contains up to 50000 records.  That is too big and takes too long to load.
Is there some way to set a custom number of records contained within each paginated sitemap page?
Answer: You can inherit from Sitemap class and rewrite the limit property


Trying to make img's sit absolutely positioned at the bottom of their parent div

Question: From my understanding you can use absolute positioning inside of it's parent to place it exactly where ever you want. Like explained here: http://css-tricks.com/absolute-positioning-inside-relative-positioning/
I'm trying to get my img elements to sit on the bottom of their parent divs but when I give the img's an absolute position the layout breaks. It seems like I need to assign a height to the section or the divs but nothing seems to work.
Please note that I commented out the absolute positioning on the images in the css so the layout is more presentable

CSS:
section {
    margin: 100 auto;
}

section#artImages {
    width: 673px;
    height: auto;
    position: relative;
    display: block;
}

    section#artImages div {
        float: right;
        height: auto;
        position: relative;
    }

        div#artImage1 {
            width: 288px;
        }

        div#artImage2 {
            width: 144px;
        }

    section#artImages div img {
        width: 100%;
        /* position: absolute; */
        bottom: 0;
    }

Here is my jsfiddle http://jsfiddle.net/PsMff/ Below is an illustration of what I'm looking for.
Comment: you've to assign images' parent elements some height as `position:absolute` _disconnects_ them from the layout and they don't affect their parents' height anymore
Answer: You are correct ... the divs need to have some hight assigned, if you want to keep the current html markup.
Note: you also don't need to use the html elements' tag-names in combination with ids (e.g. div#artImage1), as one id can only refer to one specific element in the markup.
You could try something like this (jsfiddle), I gave the divs hight: 300px:
section {display: block}
#artImages {
    margin: 0 auto;
    width: 673px;
}
#artImages div {
    position:relative;
    float:right;
    height:300px;
}
#artImage1 {
    width: 288px;
}
#artImage2 {
    width: 144px;
}
#artImage3 {
    position:relative;
    width:100%;
    background-color:blue;
}
#artImages div img {
    position:absolute;
    width: 100%;
    bottom: 0;
}

Another option:
If you don't want to assign a height to the divs, but rather have it adjust to the higher one of them,
wrap another container around the upper two divs. Here I added the #floater div to your markup:

and now float right the #floater and use display:inline-block; on #artImage1 and #artImage2 and bottom:0; on images. Something like this:
section {display: block}
#artImages {
    margin: 0 auto;
    width: 673px;
}
#floater, #artImage3 {
    float:right;
}
#artImage1, #artImage2 {
    display:inline-block;
    width: 288px;
}
#artImage2 { width: 144px }
#artImage3 { width: 100% }
#artImages img {
    width: 100%;
    bottom: 0;
}

jsfiddle example
Answer: Use class attribute in place of id, then add the following code
  position : relative;
  bottom : 0px;
  clear : both;


Constructor values not being applied on startup

Question: I've recently made a volumetric rendering system in hope to use them for particle effects, whilst attempting a dust emitter, i noticed that the positioning of the particles was completely wrong. I generate seeded random numbers which i feed into each individual particle in order to set the position. When i start debugging as normal, the particles will only spawn on top of one another in two positions. When applying a breakpoint and stepping though the loop one particle at a time and then continuing on, each particle was in its assigned random position. In addition to this, whilst testing the problem on a large particle pool, i used a hitcount to break the loop on a certain number, and found that when this occurs it only initialises them to one to the two aforementioned positions. What could be causing this?
VolumetricDust::VolumetricDust(string type, Transform* transform, ID3D11Device* pDevice, int width, int height, int depth, bool instanceFlag, int instanceCount)
{

  for (int i = 0; i < POOL_SIZE; i++)
 {
    // PROBLEM LOOP
    particles_[i] = new ParticleVolume("Resources\\nucleon.raw", transform, width, height, depth, instanceFlag, instanceCount);
    particles_[i]->Initialise(pDevice);

    srand((unsigned int)time(NULL));
    int test = (rand() % 100 + 1);
    int test1 = rand() % 30 + 1;
    int test2 = rand() % 50 + 1;

    particles_[i]->SetVelocity(XMFLOAT3(0.0f, (float)test, 0.0f));
    particles_[i]->GetTransform()->SetPosition((float)test, (float)test1, (float)test2);

  }

 posReset = transform;
 _transform = transform;

 mWidth = width;
 mHeight = height;
 mDepth = depth;

 isInstance = instanceFlag;
 instanceNum = instanceCount;

_currentTime = 0.0f;
_spawnTime = 5.0f;
_newTime = 0.1f;
_dustTime = 0.0f;
particleTime = 5.0f;
_type = type;
_pd3dDevice = pDevice;
}

void VolumetricDust::SpawnEmitter()
{

for (int i = 0; i < POOL_SIZE; i++)
{
    if (!particles_[i]->GetParticleOn())
    {

        particles_[i]->SetParticleOn(true);
        break;
    }

}

}

void VolumetricDust::Update(float dt, Camera* cam)
{
_transform->Update();
_currentTime += dt;
_dustTime += dt;

for (int i = 0; i < POOL_SIZE; i++)
{
    SpawnEmitter();

    if (particles_[i]->GetParticleOn())
    {

        //posReset->SetPosition(XMFLOAT3(0.0f, 0.0f, 0.0f));

        particles_[i]->Update(dt, cam, posReset->GetPosition());
    }

    if (_transform)
    {
        _transform->Update();
    }

}

}

void VolumetricDust::Draw(ID3D11DeviceContext * _pImmediateContext, ConstantBuffer3D & cb, ID3D11Buffer* _pConstantBuffer)
{
 for (int i = 0; i < POOL_SIZE; i++)
 {
    if (particles_[i]->GetParticleOn())
    {
        particles_[i]->Draw(_pImmediateContext, cb, _pConstantBuffer);
    }

 }

}

Answer: You should call srand only once.
When  you call it in a loop like this, the odds are very high that you get the same time value each round. That resets the random numbers, and you will get the same result for most, if not all, points.
Stopping in the debugger will let the real time change between calls to time, and you get separate random values because the seed will now be different.
Comment: You should consider using [](http://en.cppreference.com/w/cpp/numeric/random) instead of the legacy ``rand`` / ``srand`` functions
Comment: Thank you so much! I've only recently started using srand, and i wasn't aware of this!


MethodNotAllowed on deleting an item with AJAX and Laravel

Question:
SOLUTION IN LAST COMMENT OF ANSWER

I have this function here
function delTag(e, name){
    var tag_id = $(e).attr('rel');
    $.ajax({
        type: "DELETE",
        url: '/admin/tags/'+ tag_id+'' ,
        success: function(data){
            $('#tags_tr'+tag_id).remove();
            toastr.error('Tag '+name+' has been deleted');
            console.log("dsa");
        },
        error: function(data){
            console.log('Error:');
        }
    });
}

I call it like this:
@foreach($tags as $tag)
    <button onclick='delTag(this, "{{$tag->name}}")' rel={{$tag->id}} type="button"  data-dismiss="modal" class="btn btn-danger">Yes</button>
@endforeach

And i get this:

My record is deleted from the database correctly, but, ajax throws error. Why is this happaneing?
Here is my whole route if it helps...
Route::get('admin/', 'AdminController@getAdminIndex')->name('admin.index');
Route::delete('admin/users/{id}', 'Auth\\RegisterController@destroy')->name('admin.users.destroy');
Route::put('admin/users/{id}', 'Auth\\RegisterController@update')->name('admin.users.update');
Route::resource('/admin/posts', 'PostController');
Route::resource('/admin/roles', 'RoleController');
Route::delete('/admin/comments/{id}/{user_id}', 'CommentsController@destroy')->name('comments.destroy');
Route::resource('/admin/comments', 'CommentsController', [
    'except' => ['store', 'destroy']
]);
Route::get('/administrator', 'AdminController@getAdmin')->name('admin');
Route::put('/admin/comments/approve/{id}', 'CommentsController@updateApprove')->name('admin.comments.approve');
Route::put('/admin/tags/associate/{tagName}', 'TagController@updateAssociation')->name('admin.tags.associate');
Route::put('/admin/categories/associate/{categoryName}', 'CategoryController@updateAssociation')->name('admin.categories.associate');

Route::resource('/admin/categories', 'CategoryController');
Route::resource('/admin/tags', 'TagController');
Route::get('/admin/pages/tables/{user_id}', 'AdminController@getTables')->name('admin.pages.tables');
Route::get('/admin/pages', 'AdminController@getIndex')->name('admin.pages.index');

Comment: i can see there is no wild card after route /admin/tags/{no wild card}
Comment: you haven't specified the GET or POST method in ajax call
Comment: why should I? The method is DELETE
Comment: What do you mean there is no wild card? I don't know something about that
Answer: With the ajax call you need also to provide csrf_token.
You can keep it on the page in the hidden input field, like this for example:
<input id="csrf" type="hidden" name="_token" value="{{ csrf_token() }}">

And then add it to your ajax call with key "_token". So your delTag function will become something like this:
function delTag(e, name){
    var tag_id = $(e).attr('rel');
    var csrfToken = $("#csrf").val(); // here you're obtaining token from the page
    $.ajax({
        type: "DELETE",
        url: '/admin/tags/'+ tag_id+'' ,
        data: {
            "_token": csrfToken //Here you're passing the token
        },
        success: function(data){
            $('#tags_tr'+tag_id).remove();
            toastr.error('Tag '+name+' has been deleted');
            console.log("dsa");
        },
        error: function(data){
            console.log('Error:');
        }
    });
}

Comment: This is not my problem, i verify the csrf like this on $(document).ready             $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });
Comment: You are right, in this case TokenMismatch would be thrown, not MethodNotAllowed. Can you post destroy() method of your TagController?
Comment: OH MY GOD, had forgotten a redirection to tags.index at destroy because i implemented it before ajax. . Thank you :)
Comment: Great, glad could help :)


Deserializing a Java Binary Tree from a String

Question: My question is a tiny bit different from the results I found, and I haven't used Java in quite a while (novice), so I need some clarification.
Basically, I'm pretty sure my implementation is mostly correct, I just wanted to give some back story to what I was doing.
So, my real problem is that I have serialized a binary tree to a string:
      1
   2     3
 4   5

as:
1 2 4 # # 5 # # 3 # #

where the # are just null nodes.
My problem comes when I'm trying to rebuild it from the string. I've been doing some digging for quite a few hours, but I think I'm overcomplicating it. I just need to know the simplest way to read the string as such (delimited by whitespace):
the first element is 1, so we will change that to an int and make a node with that as the element. The next is 2, so do the same, then 4. The next is a #, so we ignore that as there is no leaf, etc.
then, I need to send the remaining part of the string (minus what has already been read from the front) into a recursive call.
In summary, my question is basically "what's the easiest way to parse it as described, and send the remaining string into a recursive call?"
Answer: Below is my code to serialize a binary and deserialize a binary tree.
We just dump the tree in preorder into a string.
Here, I used code from Rahul, but I modified it to be more concise.
public class DeSerializationBinaryTree {
    public static String serialize(Node root) {
        if (root == null)
            return "# ";
        else {
            return root.val + " " + serialize(root.left) + serialize(root.right);
        }
    }

    public static Node deserialize(String res) {
        String[] tokens = res.trim().split("\\s+");
        return deserialize(tokens);
    }

    static int index = 0;

    private static Node deserialize(String[] stringArray) {
        if (index >= stringArray.length)
            return null;
        if (stringArray[index].equals("#")) {
            index++;
            return null;
        }

        int value = Integer.parseInt(stringArray[index]);
        Node tree = new Node(value);
        index++;
        tree.left = deserialize(stringArray);
        tree.right = deserialize(stringArray);
        return tree;
    }

    private static void inorder(Node root) {
        if (root != null) {
            inorder(root.left);
            System.out.println(root.val);
            inorder(root.right);
        }
    }

    public static void main(String[] args) {
        Node root = new Node(30);
        Node node1 = new Node(10);
        Node node2 = new Node(20);
        Node node3 = new Node(50);
        Node node4 = new Node(45);
        Node node5 = new Node(35);
        root.left = node1;
        root.right = node2;
        node1.left = node3;
        node2.left = node4;
        node2.right = node5;

        System.out.println(serialize(root));
        Node node = deserialize("30 10 50 # # # 20 45 # # 35 # # ");
        inorder(node);
    }
}

Answer: I would use parentheses when serializing the tree to a string:
1(2(3 4) 5(6))

Describes the tree:
         1
       /   \
      /     \
     /       \
    2         5
   / \       /
  /   \     /
 3     4   6

There is some ambiguity when you have just one child because you can't tell whether the child is a left or a right child. In that case you can have an explicit "no child" character:
1(2(3 4) 5(# 6))     //6 is the right child
1(2(3 4) 5(6 #))     //6 is the left child

So when parsing it, whenever you encounter an opening parenthesis you're looking at the children of the current node. When you encounter a closing parenthesis you know you're done with the children of that node and so you can fall back to the previous level.
Comment: The existing syntax is unambiguous if you interpret it as the OP describes in his question.  It is basically a pre-order depth first traversal, outputting '#' each time a null is encountered.
Comment: @StephenC Yes, if you have a specified order of traversal then there is no ambiguity.
Answer: use this java method..consider you have string array...
private static Tree<Integer> deserialize(Tree<Integer> tree,
        String[] stringArray) {
    // TODO Auto-generated method stub
    if(index>=stringArray.length)
        return null;
    if(stringArray[index].equals("#")){
        index++;
        return null;

    }
    int value=Integer.parseInt(stringArray[index]);
    tree=new Tree<Integer>(value);
    index++;
    tree.left=deserialize(tree.left, stringArray);
    tree.right=deserialize(tree.right, stringArray);
    return tree;
}

Answer:
I just need to know the simplest way to read the string as such (delimited by whitespace)

Create a Scanner from the String, and use hasInt() / nextInt() and next().  Something like this:
    Scanner s = new Scanner(inputString);
    s.setDelimiters("\\s+");
    ...

    if (s.hasInt()) {
        int = s.nextInt();
        // ... create a node and recurse twice to populate its children
    } else if (s.next().equals("#")) {
        // ... this is a null node
    } else {
        // ... syntax error
    }

Answer: private int index =0;

/**
 * Saves this tree to a file.
 * @param filename the name of the file in which to save this tree;
 *              if null, uses default file name
 * @return   true if successful save
 *          false otherwise
 * @throws IOException if unexpected IO error
 */

public final boolean save(String filename) throws IOException{
    List<String> sbtList = new ArrayList<>();
    sbtList = preOrderSerialize(this, sbtList);
    for (String sbtList1 : sbtList) {
        System.out.println(sbtList1);
    }
    try{
        OutputStream file = new FileOutputStream (filename);
        OutputStream buffer = new BufferedOutputStream(file);
        output = new ObjectOutputStream(buffer);
        output.writeObject(sbtList);

    }catch (IOException e){
        System.err.println("Save not successful" + e);
        return false;
    }
    finally {
        output.close();
    }
   return true;
}
/**
 * The pre-order traversal to serialize a binary tree
 * @param sbt
 * @return
 * @throws IOException
 */
private List<String> preOrderSerialize(StringBinaryTree sbt, List<String> myList){
    if (sbt == null){
        myList.add("# ");
    }
    else{
        //sbt.add(this.value + "");
        myList.add(this.value + " ");
        preOrderSerialize(sbt.leftNode, myList);
        preOrderSerialize(sbt.rightNode, myList);
    }
   return myList;
}

/**
 * Restores this tree from a file.
 * @param filename the name of the file from which to restore the tree;
 * if null, uses default file name.
 * @return true if successful restore
 *          false otherwise
 * @throws IOException if there is an IO issue
 */
public final boolean restore(String filename) throws IOException{
    try {
        InputStream file = new FileInputStream (filename);
        InputStream buffer = new BufferedInputStream (file);
        input = new ObjectInputStream(buffer);
        try{
            List <String> restoreSBT = (List<String>)input.readObject();
            StringBinaryTree root = deSerialize (restoreSBT);
        } finally {
            input.close();
        }
    }
    catch(IOException ex){
        System.err.println("File Not Restored" + ex);
        return false;
    }
    catch (ClassNotFoundException e){
        System.err.println("Cannot read file: Class Not Found"+ e);
        return false;
    }
    return true;
}

private StringBinaryTree deSerialize(List<String> restoreSBT ){
    if (index >= restoreSBT.size()){
        return null;
    }
    if (restoreSBT.get(index).equals("#")){
        index ++;
        return null;
    }
    StringBinaryTree root = new StringBinaryTree (restoreSBT.get(index));
    index++;
    root.leftNode = deSerialize(restoreSBT);
    root.rightNode = deSerialize(restoreSBT);
    return root;
}

Comment: Code only answers arent allowed on Stackoverflow


Implement method return Volley request response

Question: I am handling a  lot of internet request in my android application so I want to make a volley request inside a method and return the result of request in order to write less code So that every time I need to make a request I will call the method. Is this a good way or not? if so how to implement this method ?
Answer: Having one point of entry and exit for all Network requests is not necessarily a bad implementation, though it does make your application tightly coupled and riddled with unnecessary parameters.
That said, It is not a 'wrong implementation'. Just, not scalable maybe.
Refer Google's official documentation here. Scroll down to the heading Example: GsonRequest. That should answer your question.


DataGrid VB.NET 2005 URL writing

Question: I have DataGrid and I have a hyperlink field but I want to send some information with this link by using URLwriting. I have tried this, but it's not working. So, please help me out.
<code>~/Logout.aspx?ID="row.Cells(1).Text"
</code>
I want to send the value of data grid's column but I am getting "row.Cells.Text" instead of receiving the value of this. So I want to know how I would be able to get the value of this column.
Comment: your code-snipped would'nt even compile... I suggest to post a more meaningful part.
Comment: As a start, have a look at following link: http://authors.aspalliance.com/aspxtreme/webforms/controls/addinghyperlinkfieldstogridview.aspx
Answer: Try:
<code>"~/Logout.aspx?ID=" & row.Cells(1).Value
</code>
See if that gets you what you want.
A little more clarification would be nice if this isn't what you are looking for.

DataGrid VB.NET 2005 URL writing


Android DownloadManager "Impossible to open file"

Question: I'm using DownloadManager to download a file from a webService. The download end successfuly, but when I try to open the new file in the "download" folder I've got this error "Impossible to open file" (and I know I can open this type of file).
Also, when I plug my phone to my computer and when I open the download file with it, the file open successfuly and is not corrupted.
I don't have other error, so I'm really lost !
Here my code:
    /*Data*/
    int filePosition = position - _subFolderNameList.length;
    String url = _folder.getFiles().get(filePosition).getUrl();
    String FileName = _folder.getFiles().get(filePosition).getName();
    String Description = _folder.getFiles().get(filePosition).getUrl();

    /*Prepare request*/
    DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
    request.setDescription(Description);
    request.setTitle(FileName);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        request.allowScanningByMediaScanner();
        request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
    }
    request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, FileName);

    DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
    manager.enqueue(request); // Send request

Edit: Permission in the Manifest:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

Comment: what type of file are you downloading? and how are you trying to "open" it? You've only posted code for downloading.
Comment: I try to downloading all kind of extension but for the test I only try with file like PDF because I know I can open it with my phone.
To open it I just go in the download folder (with my phone) and I just click on the file.
Comment: Have you ensured you can open `.pdf` files, downloaded *by hand* with your phone (Maybe theres just no app installed to handle the VIEW Intent)? Because I couldnt open many file types with my device by default...
Comment: Yes I am, because I trie to download the same files with others application (e.g google chrome), and when I open it in the download folder that works.
Also I can't open images (JPEG, PNG etc.) download by my app too.
I guess it's a reading permission problem or that the file isn't recognized by his extension but it's weird.
Answer: Okay I found the problem !
I had to specify the "MIME content type" of the file using setMimeType().
public DownloadManager.Request setMimeType (String mimeType);

Comment: Hi, not sure if you still around SOF, but if you are downloading from a link to file which you don't know what file extension is that, how do you know which MIME type to set?
Answer: Yes you have to specify the MIME type.
Adding a few more details to the accepted answer.
public DownloadManager.Request setMimeType (String mimeType);

To get MIME type you can use the following function.
private String getMimeFromFileName(String fileName) {
    MimeTypeMap map = MimeTypeMap.getSingleton();
    String ext = MimeTypeMap.getFileExtensionFromUrl(fileName);
    return map.getMimeTypeFromExtension(ext);
}

and the following is the Xamarin.Android implementation of the same :
        private static string GetMimeTypeFromFileName(string fileName)
        {
            var map = MimeTypeMap.Singleton;
            var ext = MimeTypeMap.GetFileExtensionFromUrl(fileName);
            return map.GetMimeTypeFromExtension(ext);
        }


How to replay an animated GIF in javascript (vanilla) - Without JQuery

Question: My current issue is that I have a loading bar animation on my web-based app that is shown (obviously) when the whole page or specific things are loading up. It is supposed to look like one of those Samsung TV Apps so it needs to be quite polished with the UX.
What me and my team are doing right now is a mix between creating an element for it and I assumed it gets cached in the local device which is an issue. I've known of a few ways that I can go around this like adding a Math.random() query at the end of the src url but I'd rather not follow that route for now.
I also saw a way that I believe involved simply setting the element.src = 'theSameUrl.gif'  URL to be the same and I assume forcing the device to reload the file instead of using the cached one.
I would also be open to trying new file types that could make this a lot easier but I must keep in mind that this app will work on a LOT of different hardware, from Samsung TV's to BT Boxes or even Virgin Media Tv Boxes, amazon firestick etc.
At this point I'll take anything :P
Comment: Look [here](https://stackoverflow.com/questions/40498474/play-gif-image-in-html-with-infinite-loop#:~:text=Looping%20is%20encoded%20into%20the,the%20src%20is%20a%20video.). I hope it helps you.
Comment: Unfortunately that is not what I was looking for, the gif is already looping. What I want is that it restarts when it is visible ALL times
Answer:
You can "force it" to reload by wiping it source: img.src = ""
Then you set it again: img.src = "your_src_path"

This way your .gif will start from zero, at least on Edge, Chrome and Firefox, it should work the same way on a TV.
Comment: Ah I see that seems to be the only possibility. Do you know if this reloads it from cache or  re-downloads it?
Comment: It reloads from cache. In this case, HTTP response status should be `304 Not Modified`. Even total network transferred data (Bytes) does not increase when you get that response status.
Comment: Nice, sick man thanks this was extremely helpful. My team decided not to go ahead with restarting the gif as it took too much time already and the project has some redundancies for this. But I will keep this in mind for the future cheers!


No activity found to handle Intent - android.intent.action.OPEN_DOCUMENT

Question: I am trying my hand on Storage Access Framework of android 4.4
I have developed a dummy app which fires an intent on start of the activity.
    Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    startActivityForResult(intent, READ_REQUEST_CODE);

Also I have developed another dummy app which serves as the file-provider.
        <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.saf"
    android:versionCode="1"
    android:versionName="1.0" >
<uses-sdk
    android:minSdkVersion="19"
    android:targetSdkVersion="19" />

<uses-permission android:name="android.permission.MANAGE_DOCUMENTS"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.saf.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <provider
        android:name="com.example.saf.MyFileProvider"
        android:authorities="com.example.saf.documents"
        android:exported="@bool/is_kitkat"
        android:enabled="@bool/is_kitkat"
        android:grantUriPermissions="@bool/is_kitkat"
        android:permission="android.permission.MANAGE_DOCUMENTS">
        <intent-filter>
            <action android:name="android.content.action.DOCUMENTS_PROVIDER" />
        </intent-filter>
    </provider>

</application>

I have implemented the class MyFileProvider.
But when I launch the user-app (the one which fires the intent), I get the following error
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.OPEN_DOCUMENT cat=[android.intent.category.OPENABLE] }

I was just following developer docs of android. Any ideas what I might be doing wrong?
Edit:
Here is my latest Manifest.
Also do I need to have a "proper" implementation of the MyFileProvider "extends DocumentsProvider"? Can I just return null in the functions for now?
Comment: Does your dummy app uses-permission `android.permission.MANAGE_DOCUMENTS`?
Comment: @SherifelKhatib - actually it did not have that permission. but i added it and checked. still the same error.
Answer: Add a mime type, or simply intent.setType("*/*").
This seems to be a known issue. setType() is required.
Edit: you also need to add android:enabled="true", note that you should reference it from values and not directly so as only to enable it for >=kitkat. So android:enabled="@bool/is_kitkat", <bool name="atLeastKitKat">false</bool> in /res/values/ and <bool name="atLeastKitKat">true</bool> in /res/values-v19/
Comment: it worked! but still i cannot see the my host app which is working as the provider.
Comment: still not able to see my host app which is working as the provider.
Answer: To open all files add this line:
intent.setType("*/*") ;

and if you need to filter to display images add this line:
intent.setType("image/*");

Answer: Just cast your intent,
like,
     Intent intent = new Intent("android.intent.action.GET_CONTENT");
    ((Intent)intent).addCategory("android.intent.category.OPENABLE");
    ((Intent)intent).setType("*/*");

Comment: Lots of unecessary casting.... you might as well just write `new Intent("android.intent.action.GET_CONTENT").addCategory(Intent.CATEGORY_OPENABLE).setType("*/*");` and get the same result, with much less operations


Get path to original python executable (not the virtualenv)

Question: Inside a virtualenv, sys.executable gives /path/to/venv/bin/python. How do I get the path of the python that the virtualenv was created from, such as /usr/bin/python3?
For example,
$ cd /tmp
$ virtualenv -p /usr/bin/python3 venv
Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /tmp/venv/bin/python3
Also creating executable in /tmp/venv/bin/python
Installing setuptools, pip, wheel...
done.
$ venv/bin/python -c 'import sys; print(sys.executable)'
/tmp/venv/bin/python

The answer that I want is /usr/bin/python3.
Comment: It **is** `/path/to/venv/bin/python`.
Comment: It's not pedantry. Without further clarification, it is unclear whether the path the questioner really needs is `/usr/bin/python3`, `/tmp/venv/bin/python`, or `/tmp/venv/bin/python3`. Answering the question in its current state is questionably useful, and more likely to be misleading than helpful to future readers.
Comment: The path you say you want is **not** the "real python executable" or "the python that the virtualenv uses". Your desires are inconsistent with themselves.
Comment: Why is it so easy to pedantically disagree, rather than to help?
Comment: @user2357112 I sure would appreciate some clarification: what is the distinction between the "real python executable" and the "actual Python installation"?
Comment: @Hatshepsut: When running your virtualenv's Python, you are not actually using `/usr/bin/python3`. `/usr/bin/python3` is not involved in any way. I think you could delete that file and still use your virtualenv (though I haven't tested it, and it'd be a really bad idea to delete that file either way). Virtualenv setup creates a new executable at `/tmp/venv/bin/python3`, and the virtualenv uses that executable.
Comment: @user2357112 So an accurate title would be the "original" executable?
Comment: "Original executable" would be an accurate description of `/usr/bin/python3`.
Comment: @user2357112 I've edited the title accordingly. Hopefully it's now accurate and clear.
Comment: @Hatshepsut, Did you find an answer? I understand what you mean and would like to know as well.
Answer: In a virtualenv, sys.real_prefix is the directory of the actual Python installation being used by the virtualenv.
Other variables worth checking are sys.base_prefix and sys.base_exec_prefix.
Example code to run in virtualenv:
import sys
print(sys.base_prefix)

Comment: Is there a cross-platform way to get the python executable out of that directory? For example, my `sys.real_prefix` is `/usr`. So I could `os.path.join(sys.real_prefix, ...)` but IIRC it'll use `Scripts` or `bin` depending on the platform?
Comment: @Hatshepsut: That pathlib snippet isn't as reliable as you're thinking. There's no guarantee the Python executable is going to be under that path. (It wasn't on two systems I just checked, one Windows, one Linux.) ...and I see you've already deleted the comment.
Comment: @Hatshepsut `virtualenv` itself uses hard-coded platform-specific paths. `sysconfig` has no entry specifically for Python executable. So no cross-platform way AFAICS.
Answer: If you run python -m sysconfig this will output the system configuration to the terminal. There you can see the BINDIR variable.
Therefore you can programatically get this path as well as compute the executable path from within python with:
import sysconfig
from pathlib import Path

bin_dir = sysconfig.get_config_var("BINDIR")
executable_path = Path(bin_dir, "python")


Brownian motion and geometric series convergence

Question: I'm confused with the property of Brownian motion that it is of infinite variation.
Consider the sequence
$$\sum_{i=0}^{t-1} a^{t-i} (B_{i+1} - B_i)$$
where $a \in [0,1)$ and $B_t$ is Brownian motion.
Would this sequence converge for $t \rightarrow \infty$ like the geometric series? Or does it not converge due to infinite variation of Brownian motion?
Comment: So you are asking about the exponential moving average (EMA) of a sequence of independent identically distributed (i.i.d.) normal variables. No, there will be no convergence.
Comment: This doesn't really have anything to do with the infinite variation of Brownian motion.  That usually refers to the fact that if we look at partitions $0 = t_1 < t_2 < ... < t_N = T$ of the interval $[0,T]$, then $\sum_{i=1}^N |B_{t_{i+1}}-B_{t_i}| \rightarrow \infty$ as the partition gets finer.  That is, the infinite variation property is about adding up the increments over a fixed period of time, rather than over an infinite time frame.
Answer: The variables $$S_m= \sum_{i=0}^{m-1} a^{m-i} (B_{i+1} - B_i)$$ converge in distribution to the law of
$$\sum_{j=1}^\infty a^j Z_j \,,$$
where $Z_j$ are i.i.d. standard normal variables.
The variables $ S_m$
do not converge a.s. because
$E[S_m S_{m+k}] \to 0$ as $k \to \infty$ for each $m$.
Comment: Are you really sure? The variance of a single sum is $\frac{a^2}{1-a^2}(1-a^{2t})$, so the sum over the variances of the first $N$ sums behaves like $\frac{a^2}{1-a^2}(N-\frac{a^2}{1-a^2}(1-a^{2N}))$ which certainly diverges.
Comment: I misread the coefficients.  The sum does not converge pointwise, only in distribution. I will correct my answer.
Comment: I have a question about the absolute value of the increments. If we do not consider the absolute value of the increments, would the sum then converge? The sequence $\sum_{i=0}^t B(i+1)-B(i)$ should converge due to telescopic sum to $B_t-B_0$, but when $t$ goes to infinity then it does not converge, am I right?


How to echo multiple images from json using PHP

Question: I'm very new to php/json so please bare with me.  I'm building a real estate website and would like to display images in a gallery or slideshow.  I'm having issues figuring out how to access more than one image at a time.
json looks like this:
[{
"Media": [ { "MediaULR": "https://dvvjkgh94f2v6.cloudfront.net/62e30b5c/33639334/83dcefb7.jpeg",
             "ShortDescription": "Infinity edge pool and spa." },
              "MediaULR": "https://dvvjkgh94f2v6.cloudfront.net/62e30b5c/33639334/7d65264f.jpeg",
             "ShortDescription": "Golf on four awarding-winning courses." }]
}]

I can access this first image using:
<?php foreach($mls as $mls): ?>
<img src="<?php echo $mls->Media[0]->MediaURL; ?>">
<?php endforeach; ?>

How do I go about displaying both images?  The Media[0] is selecting the first image.  I can't simply create a new echo with [1] because there could be countless images.
Thanks for any help!
Comment: Loop through the Media array.
Comment: In your controller `$mls = jsonOrSomething['Media']`. However you can do the following as well:`foreach($mls['Media'] as $item){ echo $item->MediaULR; }`
Comment: Thanks!  If anyone is interested here is the code that got it to work:
Comment: Media as $jmedia) echo ''?>
Comment: If you made it work you should add it as a proper answer below. Then it can receive upvotes and be found in searches. That doesn't happen if you just put it in the comments. Answering your own question is encouraged :-)
Answer: Thanks! If anyone is interested here is the code that got it to work:
<?php foreach($mls->Media as $jmedia) echo 'MediaURL.'";>'?>


where does samba store its passwords?

Question: I'm trying to make a program that will store the passwords with users input (a web app), rather than having to do it from the command line. The problem is that I don't know where the passwords are being stored as to change then.
Answer: The default Samba configuration on my system puts the password database in /var/lib/samba/passdb.tdb. Note that this is a binary database, not a flat text file.
You can tell Samba to use a text file by setting the "passdb backend" parameter in /etc/samba/smb.conf. But Samba uses a different password hashing algorithm from the one in /etc/shadow.
source
Comment: In addition: You can check it with `sudo su` and `tdbtool`. Maybe you will open `open passdb.tdb`. However, you will receive the hex password. So you can only check if a new entry has been added and not what the password is.
Comment: in my case, it's `/var/lib/samba/private/passdb.tdb`

where does samba store its passwords?


Multiple SELECT, Avoid duplicate results for one table in MySQL query

Question: How can I select from two tables where table 1 returns 1 row and table 2 returns multiple rows resulting in NO duplicates from table 1?
Below, page.title has one row.   page_images.image_loc can have anything from 1 to 10.  If page_images.image_loc has 2 or more, page.title will be duplicated for the count of page_images.image_loc rows.  How can I limit page.title to 1, but not page_images.image_loc?
$query = mysql_query("
                      SELECT page.title,
                      page_images.image_loc
                      FROM page, page_images
                      WHERE page.url_category = '$category' AND
                      page.url_title = page_images.page_title
                    ");

Answer: You could try SELECT page.title, GROUP_CONCAT(page_images.image_loc) AS image_locs ... GROUP BY page.title to collect all the image_loc values in one row, then separate the list with explode().


Dereferencing an array of struct pointers

Question: I have declared 2 structs: point (which holds 2 doubles) and circle (which holds a point and the radius of the circle, a double).
typedef struct {
    double x;
    double y;
} point;

typedef struct {
    point m;
    double r;
} circle;

To create a circle I use these 2 functions:
point* read_point() {
    point* p = malloc (sizeof(point));
    printf("\nx middle:");
    scanf("%lf",&p->x);
    printf("\ny middle:");
    scanf("%lf",&p->y);
    return p;
}

circle* read_circle() {
    circle* c = malloc(sizeof(circle));
    point* p = read_point();
    printf("\nradius circle:");
    scanf("%lf",&c->r);
    c->m = *p;
}

In my main I declare an array of circle pointers, add one circle and then try to print out the center point and the radius. (At this point my program crashes.)
circle* array[3];
array[0] = read_circle();
print_circle(array[0]); //Crashes

This is what the print function looks like:
void print_circle(circle* c){
    point p = c->m;
    printf("\n%lf",p.x);
    printf("\n%lf",p.y);
    printf("\n%lf",c->r);
}

Comment: Craaaaaank up the warnings. `-Wall -Wextra` on GCC and Clang.
Comment: You have a memory leak: You allocate memory for the point, then in `read_circle` you *copy* the `point` structure but never free the memory you allocated for it.
Comment: a memory leak after `point* p = read_point();`.
Answer: read_circle isn't returning c (or anything, for that matter).
Comment: Thank you, this was indeed the problem. 2 hours of work for a simple exercise from school and I miss something like that.
Answer: You might also want to check the return value of malloc().
Comment: @Agnaroc [Don't cast the return value of malloc()](http://stackoverflow.com/questions/605845/do-i-cast-the-result-of-malloc)

What I ment is to check if malloc() failed (i.e. returned NULL)
Comment: If I cast using (point*) and (circle*) respectively, is my solution then correct ? (I know I have to free after I use point and circle)
Comment: @Mikrosaft: Good advice, but wouldn't solve the current problem.
Comment: @ScottHunter True, but since you already answered it, I didn't feel like I needed to write it again. (It would have made more sense if I commented on his question, but I still can't due to low reputation)
Comment: @Mikrosaft in the school examples malloc is always casted. Why shouldn't it be done here ?
Comment: @Agnaroc Read the link I sent, it gives a few reasons why not to cast.
The only reason I can think of to cast malloc(), is to add compilability between C and C++ (in C++ the cast is mandatory), but since you're writing in C, and since in C++ [you shouldn't use malloc()](http://stackoverflow.com/questions/184537/in-what-cases-do-i-use-malloc-vs-new), I see no reason to cast.


How to switch between different activities like tabs in android?

Question:
I need to develop an application which contain these tabs shown in the image. Each tab contain a form which will be filled by the user.User can switch to any tab.
User click Activity1, Activity 1 gets displayed and user enters some data; then user press Activity 2, activity 2 gets displayed, user press Activity1 again, Activity 1 gets displayed with the data entered by the user(not the blank activity).
At the end when user click "Save" I need to get all the data from these activities and save it somewhere.
I have worked a lot in java but new to android, I am stuck in developing the UI for this scenario. However I have done this many times in iOS.
Anybody please share your experience of developing such UI.
Thanks,
Comment: I think you will be needing fragments on it.
Comment: please try to Activity1 data set in Onresume method so i think when u back activity2 to activity1 so run OnresumeMethod not Oncreate method.
Comment: And also take a look here: http://stackoverflow.com/questions/10912602/swipeytabs-how-to-create-swipey-tabs-using-actionbarsherlock-library You might be of a need of `ViewPager` or `SwipeView`
Answer: Fragments will be more suitable for this scenario, the benefit are

They are light weight and faster
Managed automatically by the FragmentManager.
Data Sharing between Fragments is smoother and simpler than it is for Activities
They don't complicate the Architecture of the Application

You can have as many Fragments as you want in you Activity. Following two links can be useful for you.
A similar Thread
A Good Tutorial
Another good tutorial
If even after that you decide to use Activities, You need to think
Comment: I have implemented it using fragments but how can I access data from all the fragments? Thanks
Comment: Put the variables in  Activity, generate getter/ setter and than from Fragments call `((YourActivity) getActivity()).`.... Consider designing separate classes for set of variable which are related to each other. So that data sharing is further enhanced...


AWS redshift-data API: An error occurred (ResourceNotFoundException) when calling the DescribeStatement operation: Query does not exist

Question: I'm currently banging my head against the wall since a few days trying to solve a strange issue happening with the recently released redshift data-api. I'm trying to execute a SQL statement on my Redshift cluster using the execute statement api and list the statement using the list statements api.
When testing locally, the API behaves well and I have no issues listing the statements. However, after deploying my code on Lambda, I'm suddenly not able to find any of my executed queries even though I'm receiving 200 responses for the execute statements requests.
Here is an extract of my CloudWatch logs showing the execute statement 200 response with the query ID:
{
"level": "INFO",
"location": "execute_asynchronous_sql_query:71",
"message": {
    "message": "Successfully submitted sql query to redshift cluster",
    "query_id": "706a0ca1-084c-4733-a534-571993afd23a",
    "execution_statement_response": {
        "ClusterIdentifier": "#######",
        "CreatedAt": "2021-01-15 06:00:37.504000+00:00",
        "Database": "#######",
        "Id": "706a0ca1-084c-4733-a534-571993afd23a",
        "SecretArn": "arn:aws:secretsmanager:##############",
        "ResponseMetadata": {
            "RequestId": "#######",
            "HTTPStatusCode": 200,
            "HTTPHeaders": {
                "x-amzn-requestid": "#######",
                "content-type": "application/x-amz-json-1.1",
                "content-length": "237",
                "date": "Fri, 15 Jan 2021 06:00:38 GMT"
            },
            "RetryAttempts": 0
        },
        "StatementName": "ww-redshift-asynch-2021-01-15T06:00:37.206308-summary_spots.sql"
    }
},
"timestamp": "2021-01-15 06:00:38,008",
"service": "ww_dashboard",
"sampling_rate": 0,
"sample_rate": 0.4,
"xray_trace_id": "##############"

}
And here is the error I get when trying to describe the SQL statement status using the AWS cli with that query ID.
    aws redshift-data describe-statement --id 706a0ca1-084c-4733-a534-571993afd23a

    An error occurred (ResourceNotFoundException) when calling the DescribeStatement operation: Query does not exist.

Answer: The role/user to execute describe-statement or get-statement-result need to be same with the one you use to execute-statement.
Also, need to be same region.
Comment: thanks @
fei, is there any documentation on that?
Comment: https://docs.aws.amazon.com/redshift/latest/mgmt/data-api.html, you can assume the statement owner role to get the statement
Comment: can the org admin not see it?


App crashing on Windows Phone when deployed in Release mode

Question: We have developed a Xamarin Forms app supporting Android, iOS and Windows Phone. The app is working on all three OSes when deployed in Debug mode.
It's also working on Android and iOS when deployed in Release mode. It crashes immediately after displaying Splash screen on Windows Phone 8.1/10 when deployed with Release mode, but strangely all works fine when deployed using Debug mode.
What is the reason?
Is there a way to get see the app log to diagnose the crash reason?
EDIT 1:
Hi Gerald/Demitrian,
Thanks a lot for your response. Please find below the contents for Output window. There is a XamlParseException but no additional information. I have also attached the debug log from "Decuments\Debug" folder of a Windows Phone.
Contents from output window:
'AgHost.exe' (CoreCLR: DefaultDomain): Loaded 'C:\windows\system32\mscorlib.ni.dll'. Symbols loaded.
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Windows.RuntimeHost.ni.dll'. Symbols loaded.
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Windows.ni.dll'. Symbols loaded.
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Net.ni.dll'. Cannot find or open the PDB file.
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\System.ni.dll'. Symbols loaded.
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Xml.ni.dll'. Symbols loaded.
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\data\ProgramData\Microsoft\Windows\AppRepository\Packages\MultiEventsApp_126.96.36.199_neutral__74wf2z3scmpey\NI\MultiEventsApp.WinPhone.ni.DLL'. Symbols loaded.
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\Microsoft.Phone.ni.dll'. Symbols loaded.
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\data\ProgramData\Microsoft\Windows\AppRepository\Packages\MultiEventsApp_220.127.116.11_neutral__74wf2z3scmpey\NI\MultiEventsApp.ni.DLL'. Symbols loaded.
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\data\ProgramData\Microsoft\Windows\AppRepository\Packages\MultiEventsApp_188.8.131.52_neutral__74wf2z3scmpey\NI\Parse.ni.DLL'. Cannot find or open the PDB file.
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\data\ProgramData\Microsoft\Windows\AppRepository\Packages\MultiEventsApp_184.108.40.206_neutral__74wf2z3scmpey\NI\Parse.Phone.ni.DLL'. Cannot find or open the PDB file.
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\data\ProgramData\Microsoft\Windows\AppRepository\Packages\MultiEventsApp_184.108.40.206_neutral__74wf2z3scmpey\NI\Xamarin.Forms.Core.ni.DLL'. Cannot find or open the PDB file.
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Runtime.ni.dll'. Symbols loaded.
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Threading.Tasks.ni.dll'. Symbols loaded.
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\Microsoft.Phone.Interop.ni.dll'. Symbols loaded.
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Core.ni.dll'. Symbols loaded.
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\WinMetadata\Windows.winmd'. Cannot find or open the PDB file.
Exception thrown: 'System.ArgumentNullException' in mscorlib.ni.dll
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\data\ProgramData\Microsoft\Windows\AppRepository\Packages\MultiEventsApp_22.214.171.124_neutral__74wf2z3scmpey\NI\Xamarin.Forms.Platform.WP8.ni.DLL'. Cannot find or open the PDB file.
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\data\ProgramData\Microsoft\Windows\AppRepository\Packages\MultiEventsApp_188.8.131.52_neutral__74wf2z3scmpey\NI\ZXing.Net.Mobile.Forms.WindowsPhone.ni.DLL'. Cannot find or open the PDB file.
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\data\ProgramData\Microsoft\Windows\AppRepository\Packages\MultiEventsApp_184.108.40.206_neutral__74wf2z3scmpey\NI\ImageCircle.Forms.Plugin.WindowsPhone.ni.DLL'. Cannot find or open the PDB file.
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\data\ProgramData\Microsoft\Windows\AppRepository\Packages\MultiEventsApp_188.8.131.52_neutral__74wf2z3scmpey\NI\Xamarin.Forms.Maps.WP8.ni.DLL'. Cannot find or open the PDB file.
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\data\ProgramData\Microsoft\Windows\AppRepository\Packages\MultiEventsApp_220.127.116.11_neutral__74wf2z3scmpey\NI\ZXing.Net.Mobile.Forms.ni.DLL'. Cannot find or open the PDB file.
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\data\ProgramData\Microsoft\Windows\AppRepository\Packages\MultiEventsApp_188.8.131.52_neutral__74wf2z3scmpey\NI\ZXingNetMobile.ni.DLL'. Cannot find or open the PDB file.
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\data\ProgramData\Microsoft\Windows\AppRepository\Packages\MultiEventsApp_126.96.36.199_neutral__74wf2z3scmpey\NI\ZXing.Net.Mobile.Core.ni.DLL'. Cannot find or open the PDB file.
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\data\ProgramData\Microsoft\Windows\AppRepository\Packages\MultiEventsApp_220.127.116.11_neutral__74wf2z3scmpey\NI\System.Windows.Interactivity.ni.DLL'. Cannot find or open the PDB file.
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\data\ProgramData\Microsoft\Windows\AppRepository\Packages\MultiEventsApp_126.96.36.199_neutral__74wf2z3scmpey\NI\microsoft.phone.controls.toolkit.ni.DLL'. Cannot find or open the PDB file.
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Collections.ni.dll'. Symbols loaded.
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Resources.ResourceManager.ni.dll'. Symbols loaded.
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\data\ProgramData\Microsoft\Windows\AppRepository\Packages\MultiEventsApp_220.127.116.11_neutral__74wf2z3scmpey\NI\ImageCircle.Forms.Plugin.Abstractions.ni.DLL'. Cannot find or open the PDB file.
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\data\ProgramData\Microsoft\Windows\AppRepository\Packages\MultiEventsApp_22.214.171.124_neutral__74wf2z3scmpey\NI\Xamarin.Forms.Maps.ni.DLL'. Cannot find or open the PDB file.
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\Microsoft.Phone.Maps.ni.dll'. Symbols loaded.
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Runtime.Serialization.ni.dll'. Symbols loaded.
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\data\ProgramData\Microsoft\Windows\AppRepository\Packages\MultiEventsApp_22.214.171.124_neutral__74wf2z3scmpey\NI\Xamarin.Forms.Xaml.ni.DLL'. Cannot find or open the PDB file.
'AgHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Diagnostics.Debug.ni.dll'. Symbols loaded.
Exception thrown: 'Xamarin.Forms.Xaml.XamlParseException' in Xamarin.Forms.Xaml.ni.DLL
Exception thrown: 'System.Reflection.TargetInvocationException' in mscorlib.ni.dll
Exception thrown: 'System.Reflection.TargetInvocationException' in Microsoft.Phone.ni.dll

Contents from Documents\Debug folder:
Dump Summary
------------
Dump File:  MultiEventsApp with exception E0434352 on 1-07-2017 17.55.dmp : C:\Users\Pocket_User\Desktop\MultiEventsApp with exception E0434352 on 1-07-2017 17.55.dmp
Last Write Time:    1/7/2017 5:55:50 PM
Process Name:   aghost.exe : aghost.exe
Process Architecture:   ARM
Exception Code: 0xE0434352
Exception Information:
Heap Information:   Present

System Information
------------------
OS Version: 10.0.14393
CLR Version(s): 4.5.22926.0

Modules
-------
Module Name Module Path Module Version
----------- ----------- --------------
aghost.exe  aghost.exe  10.0.14393.576
ntdll.dll   ntdll.dll   10.0.14393.576
KERNELBASE.dll  KERNELBASE.dll  10.0.14393.576
combase.dll combase.dll 10.0.14393.576
ucrtbase.dll    ucrtbase.dll    10.0.14393.576
RPCRT4.dll  RPCRT4.dll  10.0.14393.576
kernel32legacy.dll  kernel32legacy.dll  10.0.14393.576
bcryptPrimitives.dll    bcryptPrimitives.dll    10.0.14393.576
msvcrt.dll  msvcrt.dll  7.0.14393.576
kernel.appcore.dll  kernel.appcore.dll  10.0.14393.576
OLEAUT32.dll    OLEAUT32.dll    10.0.14393.576
shcore.dll  shcore.dll  10.0.14393.576
AgHostSvcs.dll  AgHostSvcs.dll  10.0.14393.576
TaskHostCore.dll    TaskHostCore.dll    10.0.14393.576
msvcp_win.dll   msvcp_win.dll   10.0.14393.576
wintypes.dll    wintypes.dll    10.0.14393.576
OnDemandBrokerClient.dll    OnDemandBrokerClient.dll    10.0.14393.576
advapi32legacy.dll  advapi32legacy.dll  10.0.14393.576
sechost.dll sechost.dll 10.0.14393.576
CoreUIComponents.dll    CoreUIComponents.dll    0.0.0.0
CoreMessaging.dll   CoreMessaging.dll   10.0.14393.576
EMCLIENT.dll    EMCLIENT.dll    10.0.14393.576
TASKHOSTSVCS.dll    TASKHOSTSVCS.dll    10.0.14393.576
WpPortingLibrary.dll    WpPortingLibrary.dll    0.0.0.0
SspiCli.dll SspiCli.dll 10.0.14393.576
minuser.dll minuser.dll 0.0.0.0
win32u.dll  win32u.dll  10.0.14393.576
gdi32.dll   gdi32.dll   10.0.14393.576
modernapiexthost.dll    modernapiexthost.dll    0.0.0.0
SecRuntime.dll  SecRuntime.dll  0.0.0.0
gdi32min.dll    gdi32min.dll    10.0.14393.576
WpCoreUtil.DLL  WpCoreUtil.DLL  0.0.0.0
msvcp110_win.dll    msvcp110_win.dll    10.0.14393.576
storageusage.dll    storageusage.dll    10.0.14393.576
procthreadexthost.dll   procthreadexthost.dll   0.0.0.0
ntmarta.dll ntmarta.dll 10.0.14393.576
CoreApplicationShim.dll CoreApplicationShim.dll 0.0.0.0
twinapi.appcore.dll twinapi.appcore.dll 10.0.14393.576
bcrypt.dll  bcrypt.dll  10.0.14393.576
PsmApp.dll  PsmApp.dll  10.0.14393.576
AppModelProxy.dll   AppModelProxy.dll   0.0.0.0
pacmantileshim.dll  pacmantileshim.dll  10.0.14393.576
VEEventDispatcher.dll   VEEventDispatcher.dll   10.0.14393.576
ActXPrxy.dll    ActXPrxy.dll    10.0.14393.576
pacmanclient.dll    pacmanclient.dll    10.0.14393.576
RMClient.dll    RMClient.dll    10.0.14393.576
mrmcorer.dll    mrmcorer.dll    10.0.14393.576
windows.ui.dll  windows.ui.dll  10.0.14393.576
dcomp.dll   dcomp.dll   10.0.14393.576
inputhost.dll   inputhost.dll   0.0.0.0
textinputframework.dll  textinputframework.dll  10.0.14393.576
CRYPTBASE.dll   CRYPTBASE.dll   10.0.14393.576
npctrl.dll  npctrl.dll  0.0.0.0
PROPSYS.dll PROPSYS.dll 7.0.14393.576
agcore.dll  agcore.dll  4.1.60221.0
SL_InterprocDll.dll SL_InterprocDll.dll 0.0.0.0
WS2_32.dll  WS2_32.dll  10.0.14393.576
CRYPT32.dll CRYPT32.dll 10.0.14393.576
d3d11.dll   d3d11.dll   10.0.14393.576
WININET.dll WININET.dll 11.0.14393.576
ole32_wp.dll    ole32_wp.dll    10.0.14393.576
urlmon.dll  urlmon.dll  11.0.14393.576
PlatformInterop.dll PlatformInterop.dll 0.0.0.0
MSASN1.dll  MSASN1.dll  10.0.14393.576
dxgi.dll    dxgi.dll    10.0.14393.576
iertutil.dll    iertutil.dll    11.0.14393.576
shlwapi.dll shlwapi.dll 10.0.14393.576
cfgmgr32.dll    cfgmgr32.dll    10.0.14393.576
dsclient.dll    dsclient.dll    10.0.14393.576
Windows.Storage.dll Windows.Storage.dll 10.0.14393.576
powrprof.dll    powrprof.dll    10.0.14393.576
profapi.dll profapi.dll 10.0.14393.576
coreclr.dll coreclr.dll 4.5.22926.0
CRYPTSP.dll CRYPTSP.dll 10.0.14393.576
werapiexthost.dll   werapiexthost.dll   0.0.0.0
mscorlib.ni.dll mscorlib.ni.dll 4.5.22926.0
rsaenh.dll  rsaenh.dll  10.0.14393.576
System.Windows.RuntimeHost.ni.dll   System.Windows.RuntimeHost.ni.dll   184.108.40.206
System.Windows.ni.dll   System.Windows.ni.dll   4.7.50915.0
System.Net.ni.dll   System.Net.ni.dll   4.7.50915.0
System.ni.dll   System.ni.dll   4.5.22926.0
System.Xml.ni.dll   System.Xml.ni.dll   4.5.22926.0
appchromeapi.dll    appchromeapi.dll    0.0.0.0
qcdx11um8612.dll    qcdx11um8612.dll    9.18.2074.0
MSVCR120.dll    MSVCR120.dll    12.0.21005.1
qcdx11compiler8612.dll  qcdx11compiler8612.dll  1.0.2074.0
MSVCP120.dll    MSVCP120.dll    12.0.21005.1
ShellChromeAPI.dll  ShellChromeAPI.dll  0.0.0.0
MultiEventsApp.WinPhone.ni.DLL  MultiEventsApp.WinPhone.ni.DLL  18.104.22.168
Microsoft.Phone.ni.dll  Microsoft.Phone.ni.dll  0.0.0.0
MultiEventsApp.ni.DLL   MultiEventsApp.ni.DLL   126.96.36.199
Parse.ni.DLL    Parse.ni.DLL    184.108.40.206
Parse.Phone.ni.DLL  Parse.Phone.ni.DLL  126.96.36.199
Xamarin.Forms.Core.ni.DLL   Xamarin.Forms.Core.ni.DLL   188.8.131.52
System.Runtime.ni.dll   System.Runtime.ni.dll   4.5.22926.0
System.Threading.Tasks.ni.dll   System.Threading.Tasks.ni.dll   4.5.22926.0
Microsoft.Phone.Interop.ni.dll  Microsoft.Phone.Interop.ni.dll  0.0.0.0
phoneinfo.dll   phoneinfo.dll   0.0.0.0
System.Core.ni.dll  System.Core.ni.dll  4.5.22926.0
wpnapps.dll wpnapps.dll 10.0.14393.576
XmlLite.dll XmlLite.dll 10.0.14393.576
Windows.ni.winmd    Windows.ni.winmd    0.0.0.0
Windows.winmd   Windows.winmd   0.0.0.0
StorageProxy.dll    StorageProxy.dll    0.0.0.0
Windows.Storage.ApplicationData.dll Windows.Storage.ApplicationData.dll 10.0.14393.576
YPerfHealthLogger.dll   YPerfHealthLogger.dll   0.0.0.0
dwrite.dll  dwrite.dll  10.0.14393.576
Xamarin.Forms.Platform.WP8.ni.DLL   Xamarin.Forms.Platform.WP8.ni.DLL   22.214.171.124
ZXing.Net.Mobile.Forms.WindowsPhone.ni.DLL  ZXing.Net.Mobile.Forms.WindowsPhone.ni.DLL  126.96.36.199
ImageCircle.Forms.Plugin.WindowsPhone.ni.DLL    ImageCircle.Forms.Plugin.WindowsPhone.ni.DLL    126.96.36.199
Xamarin.Forms.Maps.WP8.ni.DLL   Xamarin.Forms.Maps.WP8.ni.DLL   126.96.36.199
ZXing.Net.Mobile.Forms.ni.DLL   ZXing.Net.Mobile.Forms.ni.DLL   18.104.22.168
ZXingNetMobile.ni.DLL   ZXingNetMobile.ni.DLL   220.127.116.11
ZXing.Net.Mobile.Core.ni.DLL    ZXing.Net.Mobile.Core.ni.DLL    22.214.171.124
System.Windows.Interactivity.ni.DLL System.Windows.Interactivity.ni.DLL 3.0.30924.0
microsoft.phone.controls.toolkit.ni.DLL microsoft.phone.controls.toolkit.ni.DLL 18.104.22.168
System.Collections.ni.dll   System.Collections.ni.dll   4.5.22926.0
System.Resources.ResourceManager.ni.dll System.Resources.ResourceManager.ni.dll 4.5.22926.0
ImageCircle.Forms.Plugin.Abstractions.ni.DLL    ImageCircle.Forms.Plugin.Abstractions.ni.DLL    184.108.40.206
Xamarin.Forms.Maps.ni.DLL   Xamarin.Forms.Maps.ni.DLL   220.127.116.11
Microsoft.Phone.Maps.ni.dll Microsoft.Phone.Maps.ni.dll 3.0.30701.2350
System.Runtime.Serialization.ni.dll System.Runtime.Serialization.ni.dll 4.5.22926.0
Xamarin.Forms.Xaml.ni.DLL   Xamarin.Forms.Xaml.ni.DLL   220.127.116.11
System.Diagnostics.Debug.ni.dll System.Diagnostics.Debug.ni.dll 4.5.22926.0
errorhandlingext.dll    errorhandlingext.dll    10.0.10011.16384
mintdh.dll  mintdh.dll  10.0.14393.576

EDIT 2:
I made some progress on this issue. FontFamily property was causing issue in my case. So if remove the fontfamily property and run the app in Release mode, exception is not thrown anymore but the way the screen is rendered on the device doesn't look like in any way the it's rendered in Debug mode.

I have attached both the screen shots. I tried adding second option in Forms.Init as told by John but it's giving me error as the method doesn't support second option.

Debug mode screenshot

Release mode screenshot

On above behavior, I have following questions:

Why the app is correctly working in Debug mode and not in Release
mode?
Why the screen renders correctly in Debug mode and not in
Release mode?
Why it doesn't throw any error the way it throws in
Release mode?
Is there any missing reference? Not sure if this is the case as the app would have thrown an exception saying so.

Any suggestions?
Comment: Did you already check the Output window?
Comment: As the question is currently written, it is difficult to assist you due to missing information. As mentioned [here](https://msdn.microsoft.com/windows/uwp/get-started/enable-your-device-for-development), you can find the dumps in your phone's storage in the Documents\Debug folder. Please attach the contents of the dump to your post.
Answer: A couple of quick notes:
1.- Looks like the Register button is taking all the screen Height, have you tried to specify a Height for this button? Something like:
Button.HeightRequest = "40";

2.- Have you tried Linking behavior "Don't link"?
Answer: Finally, my problem is resolved. Please find the solution below if you have the same problem.
A step by step re-creation of the project revealed that my app was working fine until I added Xamarin.Forms.Maps package in my app. I was installing the latest version of Maps package which was upgrading it's dependant packages  to a higher version. Maps plugin caused Xamarin.Forms package to upgrade from 126.96.36.199 to 220.127.116.11. So when I was deploying the app with this version of Xamarin Forms in release mode, it was causing the app crashing and UI issues mentioned in my earlier response above.
To resolve the problem, I fall back to a lover version of Maps which was compatible with 188.8.131.52 version of Xamarin Forms and voila!
Looks like there is a bug in 22.214.171.124 version of Xamarin Forms.