VMware virtual machines wont resume from the command line

Question: I'm running VMWare Workstation on Ubuntu 10.10.  I have a series of virtual machines that I clone every week.
I've written a bash script that cycles through each of the virtual machines, softly suspends it, clones it, and then attempts to resume it.
The problem is, the VM's do not resume, so I have to manually resume them.  I'm trying to figure out how I can modify the script I've written to ensure the VMs resume.  I've included the script and a sample of the generated logfile showing the error message.
#!/bin/bash

##Author:   William Cooper
##Date: 2/15/2011
## Purpose:     Perform full backups of Virtual Machines
##      Running under VMWare Workstation

## Script won't run if the /nas directory doesn't exist
## The /nas directory is a mounted Buffalo Terastation
## Check /etc/fstab if this mountpoint is broken
   BACKUPDEST="/nas"

## No need to modify
   HOST=`hostname`
   DATEFILE=`/bin/date +%G%m%d`

## Run Command to find list of VM names:
## this will only be the name of the vm, no path and no .vmx
   VMLIST=`vmrun list | grep '/' | cut -d'/' -f3 | cut -d'.' -f1`

## Initialize Counter variable used to cycle through VMs in VMARRAY variable
   COUNTER=1

## Run Command to find list of VM Names and then store them in an Array:
## This will include full pathnames
   VMARRAY=( `vmrun list | grep '/'` )

#################################################################
## Functions

##
## Notify the starting time of backup in the log
##
function startScript {
   echo
   echo "----------------------------------------------------"
   echo "START - ${VM}"
   echo "Host: ${HOST}"
   echo "Date: `date`"
   echo
}

##
## Suspend VM
##
function suspendVM {
   ## Suspend the VM
   echo "Attempting to softly suspend "${VM}" . . ."
   vmrun suspend ${VMARRAY[${COUNTER}]} soft
   echo "${VM} Suspended on `date`"
   echo
}

##
## Backup VM
##
function doBackup {

   ## Check to see if the correct backup directory exists.
   if [ ! -d ${BACKUPDEST}/${VM} ]; then
      echo "${BACKUPDEST}/${VM} does not exist, creating . . ."
      mkdir "${BACKUPDEST}/${VM}"
      echo
   fi

   ## Backup VM (clone)
   echo "Backup of "${VM}" began: `date`"
   echo "Backup to ${BACKUPDEST}/${VM}/BACKUP/${DATEFILE} . . ."
   mkdir ${BACKUPDEST}/${VM}/BACKUP/${DATEFILE}
   vmrun clone ${VMARRAY[${COUNTER}]} ${BACKUPDEST}/${VM}/BACKUP/${DATEFILE}/${VM}.vmx full
   echo "Backup of "${VM}" ended: `date`"
   echo
}

##
## Start VM
##
function doStart {
   ## Resume VMs which were running [--type gui|sdl|vrdp|headless]
   echo "Attempting to resume "${VM}" . . ."
   vmrun start ${VMARRAY[${COUNTER}]}
   echo "${VM} Resumed on `date`"
   echo
}

##
## Notify the finishing time of backup in the log
##
function finishScript {
   echo "FINISH - ${VM}"
   echo "Host: ${HOST}"
   echo "Date: `date`"
   echo "----------------------------------------------------"
   echo
}

#################################################################
## Script

for VM in ${VMLIST}
do

   sleep 1
   ## StartScrip executes for logging
      startScript

   ## Suspend VM performs soft suspend
      suspendVM
      sleep 3

   ## Do Backup performs the VM clone
      doBackup
      sleep 3

   ## Start VM performs start vm
      doStart
      sleep 3

   ## FinishScript executes for logging
      finishScript

   ## Increment the Counter
      COUNTER=${COUNTER}+1

done | tee "${BACKUPDEST}/logs/VMClone_${DATEFILE}.log"

## Script
#################################################################
exit

An example of the generated logfile for each VM is shown below.
----------------------------------------------------
START - vmname
Host: servername
Date: Sat Feb 19 12:30:29 CST 2011

Attempting to softly suspend vmname . . .
vmname Suspended on Sat Feb 19 12:30:44 CST 2011

Backup of vmname began: Sat Feb 19 12:30:47 CST 2011
Backup to /nas/vmname/BACKUP/20110219 . . .
Backup of vmname ended: Sat Feb 19 12:43:16 CST 2011

Attempting to resume vmname . . .
Error: Cannot launch the UI because no display server is present in the current environment
vmname Resumed on Sat Feb 19 12:43:20 CST 2011

FINISH - vmname
Host: servername
Date: Sat Feb 19 12:43:23 CST 2011
----------------------------------------------------

Error: Cannot launch the UI because no display server is present in the current environment
Comment: Your counter increment works by way of a side effect of sorts. When you do `COUNTER=${COUNTER}+1` it builds an increasingly long string of the form `1+1+1+1+1` which gets arithmetically evaluated when it's used as an array subscript. I would recommend using `((COUNTER++))` instead. Also, you don't need all the decoration for array subscripts. You can use: `${VMARRAY[COUNTER]}` for example. Also, I recommend using `$()` instead of backticks for command substitution. They're more readable and can be more easily nested, etc. As for your question, can you provide more details of your environment?
Comment: X11 needs to be running and the `DISPLAY` variable needs to have a meaningful value.
Comment: Thanks for the tip on `((COUNTER++))`.  `$()` does indeed feel cleaner, but aside from the code cleaning suggestions you've given I'm not sure why the DISPLAY global breaks?  I run a cronjob that calls the script above every saturday.  I think what I'm going to try now is just manually setting `DISPLAY=:0.0` in the script to see if that fixes it.  Thanks.
Comment: The DISPLAY=:0.0 didn't work.  The only way I could ensure this script succeeds is to close down VMWare Workstation and select for the jobs to "Run in the Background" without being displayed.
Comment: Are you doing this on the TTY's (like `Ctl-Alt-F1`) or in a terminal in ubuntu? With a TTY, I could never get `DISPLAY` working properly, but in a terminal it works fine. At least for me.
Comment: Right now its a CronJob that runs a script (.sh) written in Notepad++
Answer: You could use the nogui paramater to the start command, e.g:
vmrun start yourmachine.vmx nogui

See: http://www.vmware.com/pdf/vix180_vmrun_command.pdf
Comment: In Workstation 7 on Ubuntu it seemed to ignore that parameter.  When I added it, it made no difference.  We have since implimented vSphere and ESXi 5.0.  Helpful answer though.
Answer: Since no solid answer has been found I'm just going to accept that under these specific circumstances there is no fix.

Ubuntu 10.10 x64
VMware Workstation 7

Solution: Close down VMware Workstation and choose for the VMs to "Run in the Background"
Works flawlessly after that.
Answer: try doing echo $DISPLAY on your terminal TTY where vmware workstation runs.
The echo $DISPLAY will return like :1000.0
you need to set
export DISPLAY=":1000.0"   in your script. then the script will resume the VM's..
i found this works when i use areca backup to resume my VM using postscript run in areca.
Answer: if the problem is because you are running vmrun from a ssh session, then another solution might be run a screen session on the server.
on the machine Workstation is running:
screen -S vmware

on the client machine,
ssh vmware-machine
screen -x vmware
vmrun start /path/to/vm.vmx


Cesàro summation in Hilbert space

Question: Let $H$ be Hilbert space, $\{e_n\}_{n\in \mathbb{Z}}$ be complete orthonormal basis, and bounded linear operator $U$ with $Ue_n=e_{n+1}$.
Then, for any comact operator $T$,
$$\lim _{n \to \infty } ||\frac{1}{n+1} \sum _{k=0} ^{n} U^k T U^{-k} ||=0$$
It is enough to prove $\lim _{k\to \infty }||U^k T U^{-k} ||=0$.
  $\{e_n\}$ is weak convergence sequence to $0$ by Bessel's inequality, so ${Te_n}$ is strong convergence sequence to $0$.
I tried to use it, but $||U^k T U^{-k} || \leq \sum _{m \in \mathbb{Z}} ||Te_{m-k}||$ appear, so it is not convergent to $0$ as $k\to \infty$.
Someone have an idea to prove ?
Comment: Please ask a new question instead of completely changing an old one.
Comment: Since $U$ is an isometry it's clear that $||U^k TU^{-k}||=||T||$.
Answer: $\newcommand\s{\frac1n\sum_{k=1}^n}$
$\newcommand\ss[1]{\s U^k#1U^{-k}}$
Edit: The reason this makes no sense is it's an answer to a totally different question. The question was edited; the new question has nothing whatever to do with the original.
Original question, I think, based on the answer: Say $H$ is a Hilbert space, $U$ is a unitary operator on $H$ and $T$ is a compact operator on $H$. Show that $$\lim_{n\to\infty}\left|\left|\frac 1n\sum_{j=1}^n U^jTU^{-j}\right|\right|=0.$$
Comment in the original question: This would follow if $||U^j TU^{-j}||\to0$.  How do we show that?
Answer:
Since $U$ is an isometric isomorphism it's clear that $||U^k TU^{-k}||=||T||$, so your plan  won't work.
Since $$\left|\left|\ss T-\ss{T'}\right|\right|\le||T-T'||\quad(*)$$you can assume that $T$ has finite rank. So $T$ is a finite sum of operators of rank one,  hence you can assume that $T$ has rank one: $$Tx=u<x,v>.$$So $$U^kTU^{-k}x=U^k u<U^{-k}x,v>.$$Now again $(*)$ shows that you can assume that $u$ is a finite linear combination of basis elements, and then that you can assume the same of $v$. So you can assume that $u=e_j$ and $v=e_m$, and now $$\begin{align}\left|\left|\ss Tx\right|\right|^2&=\frac1{n^2}\sum_{k=1}^n|<U^{-k},x>|^2
\\&=\frac1{n^2}\sum_{k=1}^n|<x,U^k v>|^2
\\&\le\frac1{n^2}||x||^2.\end{align}$$
Answer: Since Unitary operator,  $||U^k TU^{-k}||=||T||$, so it is not convergent to $0$.
By using spectrum, it is more easy to show

Cesàro summation in Hilbert space


Expected number of runs of length n in coin toss

Question: I'm writing a program for an assignment for my Probability and Statistics course. This program performs several millions of simulated coin tosses, and then analyses various properties of the generated sequence.
One of the things it does is count how many runs does the generated sequence contain, and their lengths. One result for 10.000.000 tosses is:

Number of runs of length 1 is: 2500986
Number of runs of length 2 is: 1246647
Number of runs of length 3 is: 625656
Number of runs of length 4 is: 311689
Number of runs of length 5 is: 156673
Number of runs of length 6 is: 78464
Number of runs of length 7 is: 39253
Number of runs of length 8 is: 19547
Number of runs of length 9 is: 9866
Number of runs of length 10 or more is: 9818

Now, my problem is following: I need to compare the result acquired by simulation to theoretical expectation of sorts. Basically, I need that same result as above, calculated on paper.
A pattern in the results obviously exists, but I just cant figure out a formula. Anyone, help please?
Comment: 1/4 1/8 1/16 ....
Comment: so... you're saying you don't see any consistent relationship between the amounts at the various lengths?
Comment: each one is 1/2 of the one before and  1/2 + 1/4 +1/8 ... =1
Comment: Well yes, that is why I said that the pattern is obvious. But I need a formula, preferably with an explanation as to WHY each one is 1/2 of the one before, and how do I get the first value. I need to calculate this independently of the simulation, and then compare these two results. Don't get me wrong, I'm not looking for someone to solve my homework for me, I just don't know what to do anymore.
Comment: @Davor, [this](http://mathforum.org/library/drmath/view/56637.html) might give you some ideas.
Comment: Well you said a formula and 1/2 1/4 1/8 etc is certainly a formula. It seem to me it indicates a rather simple proof.  Suppose you start throwing the coin and record the length of each run.   the first throw is either H or T.  the second throw can be H or T and the probability is  0.5 that they are it is different from the first throw. thus the probability is 0.5 that the length of the string is 1.  Similarly it is 0.25 that the length of the string is 2 and so on.
Answer: You can simply use the geometric distribution, which gives you the probability of a given number of Bernouilli trials before a success or in these case before the series is broken. The distribution is given as follow :
P = (1-p)^(k) * p
with p = .5 for a fair coin and k = 1 : 9
The idea is to compute the joint probability of k consecutive head/tail and one tail/head :
P{tail, tail,..., head} = P{tail}^k * P{head}.
Then you multiply this probability by 10^7 the number of trials in your simulation.
The results are the following :

2,500,000
1,250,000
625,000
312,500
156,250
etc.

which are quite close of your simulated results...
For the case of a run of length 10 or more, you have to do 1-(others prob, including k=0) which gives 9765.625.
You can compute these probabilities easily in R with P <- dgeom(1:9, prob=.5) and for P(10) : P <- 1- sum(dgeom(0:9, prob=.5))
Answer: You have n independent Bernoulli rv, $X_1, X_2, ..., X_n$ with $P(X_i=1)=P(X_i=0)=p=1/2$.  You generate n bits $b_1, b_2, ..., b_n$, as observations on this sequence. Let N be the rv giving the number of runs of one, for example, in the simulated sequence of bits.
$N=\sum_{i=1}^n Y_i$, where $Y_i$ is the random variable that takes 1 as value if $b_i$ is the starting bit of a run of ones and 0 otherwise. $E(Y_1)=P(Y_1=1)=p$ while for $i=2,...,n$ $P(Y_i=1)=P(X_{i-1}=0, X_i=1)=(1-p)p.$ Hence the expected value of N, is $E(N)=p+(n-1)(1-p)p$
Comment: @user2376, shouldn't $P(Y_i=1)$ be $P(X_{i-1}=0,X_{i}=1,X_{i-1}=0)$?
Comment: @mpiktas  If $b_i$ is the first bit in a run of ones,  why should be $b_{i+1}=0$? ( I think you intended to write $(Y_i=1)=(X_{i-1}=0, X_i=1, X_{i+1}=0)$)
Comment: There must be typos in this answer, because (for instance) when $p=1/3$ the formula gives $E(N)=1/3 + (n-1)(1-1/3)/(1/3) = 2n-5/3,$ which is far too large.


Using .MapOwinRoute() instead of the OwinStartup / Configuration class - negotiate returns 404

Question: I'm working on an app using SignalR 2 and am running into problems mapping SignalR through the .MapOwinRoute() extension method for the ASP.net 4 RouteTable.Routes. Like:
RouteTable.Routes.MapOwinRoute("signalr.hubs", "signalr/hubs", a => a.MapSignalR());

also added to Web.Config:
<appSettings>
    <add key="owin:AutomaticAppStartup" value="false" />
</appSettings

It maps up. Navigating to /signalr/hubs gives me the hubs proxies, but when I connect with my code:
$(function () {
   var orderProcessing = $.connection.orderProcessing;
   $.connection.hub.start().done(function () {
      orderProcessing.server.doStuff();
   });
});

The route /signalr/negotiate returns a 404.
Everything works fine when I do it like this:
[assembly: OwinStartup(typeof(Web.Startup))]

namespace Web
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            app.MapSignalR();
        }
    }
}

The problem is that using the OwinStartup is not an option for me, as I need to configure SignalR with my own dependency resolver linking it to the general IOC container I use and it is not ready at the point of OwinStartup. I also need to configure the JSON serializer with custom options that also gets configured at a later stage.
Can't quite figure out what I'm missing here.
Answer: You don't want to map a route to want to map a prefix (path). Also, you're using the wrong url and wrong IAppBuilder overload.
RouteTable.Routes.MapOwinPath("/signalr", app => app.RunSignalR());

The above logic takes any path that starts with SignalR and passes it to the SignalR middleware.


Every endomorphism $\psi$ of $\pi_1(S^1\times S^1, (1,1))$ can be expressed as $\psi = f_\ast$?

Question: I have to prove the following:

Using the canonical isomorphism $$\pi_1(S^1\times S^1,(1,1)) \cong \pi(S^1,1)\times \pi_1(S^1,1),$$ show that every endomorphism of the group $\pi_1(S^1\times S^1,(1,1))$ can be expressed as $f_\ast$ for some continuous map $f : S^1\times S^1 \to S^1\times S^1.$

[Note: We already know that the last property is true for $\pi_1(S^1,1)$, and it can be used.]
My attempt was trying to write the homomorphism as a direct product of homomorphisms from $\pi_1(S^1,1)$ to itself in order to use the Note. I can't conclude the solution since I think I can't recover the original homomorphism after considering the homomorphisms induced in each factor $\pi_1(S^1,1).$
I hope someone could help me and give me the idea to conclude the problem. It's important that it's my first course on algebraic topology and I'm only given the tools of fundamental groups.
Thanks in advance!
Comment: Thanks for your comments @freakish. The first comment is a direct road to the solution. I'm looking for a solution that uses the property for $S^1.$ In your second comment I think that you solve my difficulties, I was considering only the inclusion and projection always in the same factor. I was forgetting some combinatorics intrinsic to the problem of reconstruct a map. I think that you must post your comments as an answer.
Answer: First of all by $\mathbb{Z}^n$ I will understand any free abelian group of rank $n$. In particular I will literally write $\pi_1(S^1)=\mathbb{Z}$. This is to avoid many details arising from considering isomorphisms. Although a careful reader should try to fill the missing details.
Algebra
Consider $\psi:\mathbb{Z}^n\to\mathbb{Z}^n$ a homomorphism, $J_k:\mathbb{Z}\to\mathbb{Z}^n$, $J_k(x)=(0,\ldots,0,x,0,\ldots,0)$ the standard group embedding onto $k$-th coordinate and $P_k:\mathbb{Z}^n\to\mathbb{Z}$ the standard projection of $k$-th coordinate. So for any $1\leq s,t\leq n$ we have an induced homomorphism
$$\psi_{st}:\mathbb{Z}\to\mathbb{Z}$$
$$\psi_{st}=P_s\circ \psi\circ J_t$$
So any endomorphism $\psi:\mathbb{Z}^n\to\mathbb{Z}^n$ induces a set of homomorphism. The main observation is that this works in the other direction as well. If $\{\psi_{st}:\mathbb{Z}\to\mathbb{Z}\}$ is a set of homomorphisms then we can recreate $\psi$ via
$$\psi(x_1,\ldots,x_n)=\left[\begin{matrix}
\psi_{11} & \psi_{12} & \cdots & \psi_{1n} \\
\psi_{21} & \psi_{22} & \cdots & \psi_{2n} \\
\vdots & \vdots & \ddots & \vdots \\
\psi_{n1} & \psi_{n2} & \cdots & \psi_{nn} \\
\end{matrix}\right]\left[\begin{matrix}
x_1 \\
x_2 \\
\vdots \\
x_n
\end{matrix}\right]$$
So it's a matrix multiplication where $\psi_{st} x$ should be understood as $\psi_{st}(x)$.
And these two operations, i.e. $\psi\mapsto\{\psi_{st}\}$ and $\{\psi_{st}\}\mapsto\psi$ are inverses of each other. Meaning  $End(\mathbb{Z}^n)$ is equinumerous (even ring isomorphic) with $\mathbb{M}_{n^2}(End(\mathbb{Z}))$. In particular every set of morphisms $\{\psi_{st}\}$ uniquely determines the induced morphism $\psi$.
Side note: here $\mathbb{Z}$ didn't play any significant role. And indeed, this construction works well for any abelian group $A$. It even generalizes to modules. But it doesn't work for non-abelian groups.
Algebraic Topology
Throughout $1\in S^1\subseteq\mathbb{C}$ will be the implicit base point for all pointed spaces.
Back to the problem. So we know that $\pi_1((S^1)^n))=\mathbb{Z}^n$ is free abelian of rank $n$ and so any endomorphism is uniquely determined by $n^2$ corresponding $\mathbb{Z}\to\mathbb{Z}$ morphisms.
Consider continuous embedding $j_k:S^1\to (S^1)^n$, $j_k(z)=(1,\ldots,1,z,1,\ldots, 1)$ and continous standard projections $p_k:(S^1)^n\to S^1$. All you have to realize now is that $j_{k*}=J_k$ and $p_{k*}=P_k$. This requires some effort (but is not very hard) and I will not deal with it here.
But if you already know that then the rest becomes simple. You take any $\psi:\mathbb{Z}^n\to\mathbb{Z}^n$, you consider $\psi_{st}:\mathbb{Z}\to\mathbb{Z}$ as earlier, then you take $f_{st}:S^1\to S^1$ such that $f_{st*}=\psi_{st}$ and finally compose it back to $f:(S^1)^n\to(S^1)^n$ map in such a way that $f_{st}=p_s\circ f\circ j_t$. You do that by definining
$$f(x_1,\ldots,x_n)_k=f_{k1}(x_1)\cdots f_{kn}(x_n)$$
with complex multiplication on the right side. So it's similar to the matrix multiplication as defined in Algebra section, except we use complex number multiplication instead of the standard integer addition.
Side note: $f_{st}(1)=1$ because we work with pointed spaces.
The rest follows from the functoriality of $\pi_1$:
$$P_s\circ\pi_1(f)\circ J_t=\pi_1(p_s)\circ\pi_1(f)\circ\pi_1(j_t)=\pi_1(p_s\circ f\circ j_t)=\pi_1(f_{st})=\psi_{st}$$
Since both $\pi_1(f)$ and $\psi$ are determined by the same set of morphisms $\{\psi_{st}\}$ then they have to be equal.


Android several issues regarding object creation and initialisation

Question: The ApiClient.getClient().create( ApiInterface.class) is being called recreating the Retrofit client all the time. This costs and should happen only once.(The same applies to recyclerView).I think should use singleton..Also how I could find in Android Studio how many object created... Any help. Here is my code:
<code>public void fetchData() {
          ApiInterface apiService =
                  ApiClient.getClient().create(ApiInterface.class);
          Call<List<Currency>> call = apiService.getData("");
          if (isNetworkAvailable()) {
              call.enqueue(new Callback<List<Currency>>() {
                  @Override
                  public void onResponse(Call<List<Currency>> call, Response<List<Currency>> response) {
                      if (response.isSuccessful()) {
                          List<Currency> rew = response.body();
                          if(( moduloLoop % 2) == 0 ) {
                          for (int i =0; i < rew.size(); i++){
                                  mBuy.add(i, String.valueOf(rew.get(i).getBuy())+","+i);
                                  mSell.add(i, String.valueOf(rew.get(i).getSell())+","+i);
                                  mSharePreference.saveArray(MainActivity.this, mBuy,"BuyValue");
                            mSharePreference.saveArray(MainActivity.this, mSell,"SellValue");
                              }
                              mSell.clear();
                              mBuy.clear();
                          }
                          if( !isTablet){
                              recyclerView.setAdapter(new CurrencyAdapter(response.body(), R.layout.list_item_trade, MainActivity.this));
                          }else {
                              recyclerView.setAdapter(new CurrencyAdapter(response.body(), R.layout.tablet_list_item_trade, MainActivity.this));
                          }
                      } else {
                      alertError(MainActivity.this.getString(R.string.DownloadFailed));
                      }
                  }
                  @Override
                  public void onFailure(Call<List<Currency>> call, Throwable t) {
                      alertError(t.getMessage()+"");
                  }
              });
          }else {
              alertError(this.getString(R.string.network_unavailable));
           }
      }
// Trying to create a polling mechanism to update rates every couple of //seconds.
Handler h = new Handler();
private static final int DELAY = 25000;
        Runnable runnable;
        @Override
        protected void onStart() {
            h.postDelayed(new Runnable() {
                public void run() {
                    fetchData();
                    runnable = this;
                    moduloLoop++;
                    h.postDelayed(runnable, DELAY);
                }
            }, DELAY);
            super.onStart();
        }
    public class ApiClient {
        private static final String BASE_URL = "http://massignment.xxxxx.com/api/";
        private static Retrofit retrofit = null;
        public static Retrofit getClient() {
            if (retrofit==null) {
                retrofit = new Retrofit.Builder()
                        .baseUrl(BASE_URL)
                        .addConverterFactory(GsonConverterFactory.create())
                        .build();
            }
            return retrofit;
        }
    }
    public interface ApiInterface {
        @GET("rates")
        Call<List<Currency>> getData(@Query("") String values);
    }
</code>
Answer: To see how many objects are created:

Run the app in debug mode on a phone or emulator.
Go to the Android Monitor tab.
Click on the Monitors tab.
Click the "Dump Heap" icon.

After this a new tab will appear in the editor with all of the memory usage information.
https://developer.android.com/studio/profile/am-memory.html
Good luck! :-)


PQ subtends an angle of $45^{\circ}$ to the origin. Find the locus of the mid point of a chord PQ to circle $x^2+y^2-2ax-2by=0$

Question: A chord PQ of the circle $x^2+y^2-2ax-2by=0$ subtends an angle of $45^{\circ}$ to the origin.
Given that M is the mid point of PQ. Find the equation of the locus of M.
MY ATTEMPT
Centre of the given circle $=
\frac{-1}{2}[(-2a),(-2b)]=C(a,b)$
Let, $M(x,y)$
Slope of $CM$=$(\frac{b-y}{a-x})$
$CM\perp PQ$
$\therefore$ Slope of $PQ$=-$(\frac{a-x}{b-y})$
Equation of $PQ$ gives locus of $M(x,y)$
$\implies$$y_{PQ}=m_{PQ}x+c$
$\implies$$y=-(\frac{a-x}{b-y})+c$
But my approach above is wrong since the textbook answer is as below:
$x^2+y^2-2ax-2by+\frac{1}{2}(a^2+b^2)=0$
YOUR HELP WILL BE HIGHLY APPRECIATED
Comment: Typing mistake, $y^2$ has a positive coefficient
Answer: Hint: $O$ the origin is on the circle, $\angle POQ = 45^\circ$ means $\angle PCQ = 90^\circ$.
$M$ is on a circular arc centred at $C$ with shorter radius.
Answer: The given circle of center $O(a,b)$ and radius $r=\sqrt{a^2+b^2}$ contains the origin. Then, the chord $PQ$ subtends a right-angle to $O$ and the distance from $O$ to $PQ$ is $\frac1{\sqrt2}r$.
Thus, the locus is on a circle of center $(a,b)$ and radius $\frac1{\sqrt2}r$, which determines its equation as
$$(x-a)^2+(y-b)^2=\frac{1}{2}(a^2+b^2)$$


Use PowerShell to obtain Office 365 DNS records

Question: For the past while, I've been learning PowerShell to administrate our Office 365 tenancy instead of using the web interface.
After adding a new domain and confirming ownership of the domain name (all done through PowerShell), I was wondering if there's a cmdlet that can be used to obtain the zone records that should be configured for a domain that is to be managed by Office 365.
Gather the information you need to create Office 365 DNS records explains how to obtain this information using the web interface but I'd prefer to do as much as possible using PowerShell.
At the moment, I can use the Get-DkimSigningConfig to determine the correct CNAME record to enable DKIM, e.g.,
Get-DkimSigningConfig -Identity contoso.com | fl Selector?CNAME

This should generally be of the form selector1-contoso-com._domainkey.contoso.onmicrosoft.com but I found that for one of our managed domains the DKIM CNAME had to be set to selector1-contoso-com0i._domainkey.contoso.onmicrosoft.com (an additional 0i).
For the MX record, I'd expect it to be contoso-com.mail.protection.outlook.com but I'd like to be certain so I'm wondering if there's a PowerShell cmdlet or Azure object that lists the DNS records that should be configured for a managed domain (in particular what to use for the MX record).
I spent a lot of time searching the web and Microsoft's own documentation but I only found references to how to determine this information using the web interface.
Comment: FYI your guess on the MX record is off by one character.
Answer: A little bit late, but for future reference, this is now possible using the AzureAD module:
Get-AzureADDomainServiceConfigurationRecord -Name mydomain.com

Or if you want to get only the MX record:
(Get-AzureADDomainServiceConfigurationRecord -Name mydomain.com | `
           where RecordType -eq MX).MailExchange

You can also set the supported services for a newly added domain using:
Set-AzureADDomain -Name mydomain.com -SupportedServices Email, OfficeCommunicationsOnline, Intune

Comment: Thanks for answering. Unfortunately, since asking this question, I've changed jobs (to a Unix-only role) so I can't verify it. From a cursory look at the documentation, it looks like this will do the job so I've upvoted and accepted this answer. Hopefully, this can help others administer their Azure/365 tenancies.
Comment: I was able to use these commands and they work.  Thank you for the -SupportedServices argument.  That was what I was missing.


What do you call a very brief change of key

Question: When the key changes for a longer period and a new tonic is firmly established, we call it modulation. However, what do we call a very brief change of at most several measures, when harmony from another key brings the color of that key, but not strongly enough to make the listener forget about the original tonic?
Examples when this happen might be a secondary dominant (or several secondary functions), or modal interchange. E.g. if in the key of C we hear a progression A7-Dm, then followed by a progression in C, we likely interpret A7 as a secondary dominant. We hear it as borrowed from the key of Dm. I understand calling this modulation would be incorrect, but is there a more appropriate (and widely used) term?
Answer: The most common term is tonicization.
For example:

Tonicization is the process of making a non-tonic chord temporarily sound like tonic (SOURCE)

In music, tonicization is the treatment of a pitch other than the overall tonic (the "home note" of a piece) as a temporary tonic in a composition. (SOURCE)

Tonicization occurs when a chord or short succession of chords are borrowed from another key in order to emphasize—or tonicize—a chord in the home key. (See analyzing applied chords.) Modulation occurs when a longer succession of chords emphasizes a new tonic, leading to the perception of a new key. (SOURCE)
Comment: Jazz musicians usually refer to a tonicization as the "key of the moment"
Comment: @TomSerb I've been a jazz musician for several decades and have never heard that. Maybe a local expression?
Comment: it could be.  Except for a brief NY stint in the early 80s I've only worked in the midwest
Answer: See, there are two types of "brief changes in key" that we see in western music. When the harmony "changes key" (usually via secondary dominants), it is called "tonicization". When the scale used in the melody changes, while the harmony remains diatonic (i.e. a piece begins to play notes from the G major scale over a tonic chord in C major), it is called a "scale mutation".
Scale mutation is generally a term used to describe older music, specifically from the Galant Era. It was a term introduced by Giorgio Sanguinetti, I believe, in his amazing book on The Art of Partimento. Although the term is generally used to describe older music, I feel that it applies well to various other types of music, and is even more common in post-Galant-era music.
Comment: I've only ever heard "mutation" used in the context of medieval music, but not in the way you've defined it here. Can you point me to a resource where I can read more? It doesn't seem like this would actually change the key, but I have to allow I'm just not familiar with the term.
Comment: What do you mean by using G major scale over C chord? Do you mean playing C lydian scale, or rather indeed G ionian (same notes, but different tones are stressed)?
Comment: Aaron-- You're right. Scale mutation is generally a resource used to describe older music, specifically from the Galant Era. It was a term introduced by Giogio Sanguinetti, I believe, in his amazing book on The Art of Partimento.
It doesn't truly change the key, but tonicization does not either. If we tonicize G, we have not modulated to G, we are simply using a secondary dominant to lead to a G dominant seventh chord.
If we mutate the scale used in the melody to G Ionian, we have not modulated to G either, we are simply changing the mode for a brief period of time.
Comment: user1079505-- I was essentially describing a switch in mode. If we are playing a dominant chord in C Major, we can mutate the scale by playing a G Ionian scale over it instead of the usual C Ionian.
Comment: Your previous comment clarifies your intensions. Consider editing your question to include some elaboration along those lines — comments are sometimes deleted.
Comment: Of course, Aaron.
Answer: Secondary, Borrowed or Altered chords

Secondary chords are a type of altered or borrowed chord, chords
which are not part of the key the piece is in. They are by far the
most common sort of altered chord in tonal music.[2] Secondary chords
are referred to by the function they have and the key or chord to
which they function. Conventionally, they are written with the
notation "function/key". Thus, the most common secondary chord, the
dominant of the dominant, is written "V/V" and read as "five of five"
or "the dominant of the dominant". The major or minor triad on any
diatonic scale degree may have any secondary function applied to it;
secondary functions may even be applied to diminished triads in some
special circumstances.

SOURCE


Como incluir todas as minhas páginas dentro de uma só?

Question: estou desenvolvendo um sistema onde quero que na página "cardápio" seja incluído todas as minhas categorias, que já tem um layout próprio em sua página, para isso estou tentando usar o while loop desse jeito:

    <?php
        $stmt = $conn->prepare("SELECT * FROM dados_categoria WHERE ativo='S'");
        $stmt->execute();
        $resultado = $stmt->get_result();
            while($rows = $resultado->fetch_assoc()){

        echo '

'.$rows['nome_categoria'].'

                '.include('pages/'.$rows['categoria'].'.php').'

';

        }
    ?>

Infelizmente dessa maneira o site não carrega as páginas com o "include" e está apresentando o seguinte:
Warning: include(pages/pizza.php
): failed to open stream: No such file or directory in C:\xampp\htdocs\foodOrderSystem\pages\cardapio.php on line 11

Warning: include(): Failed opening 'pages/pizza.php
' for inclusion (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\foodOrderSystem\pages\cardapio.php on line 11

Answer: Posso estar errado mas acho que seu erro está aqui:
echo '

'.$rows['nome_categoria'].'

   '.include('pages/'.$rows['categoria'].'.php').'

';

Tente mudar para:
echo '
';
   echo '
'.$rows['nome_categoria'].'
';
   include('pages/'.$rows['categoria'].'.php');
echo '
';

Certifique-se que os arquivos com o mesmo nome da categoria exitam dentro da pasta.
Comment: Funcionou, dessa forma não da mais erro, entretanto ele só ta chamando 1 vez, quando era pra chamar 3 divs com 3 includes diferentes, como se o loop não estivesse funcionando, consegue imaginar qual seja a causa?
Comment: detalhe quando eu tiro o include do meio do código ele chama corretamente as 3 div's verifiquei e o diretorio e nome dos arquivos estão corretos, pois utilizo esse método de include em outra página desse mesmo projeto com base em informações do banco de dados, entretanto é um include único, ou seja só uma página sem ter um loop chamando várias páginas em uma só.
Comment: Após dar uma olhada no código logo percebi o motivo de executar o include apenas uma vez... Na minha pagina "pizza" por exemplo, existe uma query para pegar os dados do banco de dados, com isso quando eu chamo o include ele inclui esses dados do banco de dados substituindo minha query anterior da pagina cardapio, por conta disso o loop se encerra ali...
Comment: No caso do `include()`, entre outras funções nativas do PHP não é possível fazer a concatenação com elas, como foi na sua questão. Sobre a quebra do seu loop eu ia responder antes mas não deu, você conseguiu achar o problema. Eu geralmente nomeio as consultas com variáveis exclusivas, algo mais ou menos assim `$sel_categoria` `$sel_cardapio`
Answer: A resposta do amigo resolveu meu problema, entretanto como comentei o include estava me gerando conflito encerrando o meu loop while. Após analizar descobri que o problema eram duas variáveis iguais no meu cardapio e na página do include com valores diferentes.
Código antes:
<?php
$stmt = $conn->prepare("SELECT * FROM dados_categoria WHERE ativo='S'");
$stmt->execute();
$resultado = $stmt->get_result();
while($rows = $resultado->fetch_assoc()){
    echo '
';
    echo '
'.$rows['nome_categoria'].'
';
    include('pages/'.$rows['categoria'].'.php');
    echo '
';
}
?>

Código depois:
<?php
$stmt = $conn->prepare("SELECT * FROM dados_categoria WHERE ativo='S'");
$stmt->execute();
$resultante = $stmt->get_result();
while($cat = $resultante->fetch_assoc()){
    echo '
';
    echo '
'.$cat['nome_categoria'].'
';
    include('pages/'.$cat['categoria'].'.php');
    echo '
';
}
?>


Proving that the law of large numbers doesn't apply

Question: Given $X_1,X_2,\ldots$ – i.i.d, with $\mathbb{E}X_1=0$, $0<\mathbb{D}X_1<\infty$, and $S_n=\sum_{i=1}^n X_i$, one must prove that
$$
\forall \epsilon > 0:\ \lim_{n\rightarrow \infty}P\left(\left|\frac{S_n}{n^\alpha}\right|\leq \epsilon\right) =
\begin{cases}
0,&\alpha<\frac{1}{2}\\
1,&\alpha>\frac{1}{2}
\end{cases}
.$$
I know how to prove the case where $\alpha>\frac{1}{2}$, namely by applying the Chebyshev inequality. However, what can I do for the case where $\alpha<\frac{1}{2}$?
Comment: Do you know the central limit theorem?
Comment: @pax I'm assuming I do?
Answer: The central limit limit theorem says that
$$\lim_{N\to \infty} \mathbb{P}\left(\left|\frac{S_n}{\sigma n^{1/2}}\right|\le \epsilon\right)=\frac{1}{\sqrt{2\pi}}\int_{|x|\le \epsilon}e^{-x^2/2}dx=\mathbb{P}\left(\left|\cal{N}\right|\le \epsilon\right).$$
Now, if $\alpha<1/2$, we may choose, for any $M>0$, some $N$ such that for $n>N$, $1/n^{\alpha}>M/\sigma n^{1/2}$. For such $n$, we thus have that
$$\mathbb{P}\left(\left|\frac{S_n}{n^{\alpha}}\right|\le \epsilon\right)\le \mathbb{P}\left(\left|\frac{S_n}{\sigma n^{1/2}}\right|\le \frac{\epsilon}{M}\right).$$
Taking limits of both sides, we get that
$$\lim_{n\to \infty}\mathbb{P}\left(\left|\frac{S_n}{n^{\alpha}}\right|\le \epsilon\right)\le \mathbb{P}\left(\left|\mathcal{N}\right|\le \frac{\epsilon}{M}\right).$$
As $M$ was arbitrary, we may also take the limit as $M\to \infty $ on both sides to get that
$$\lim_{n\to \infty}\mathbb{P}\left(\left|\frac{S_n}{n^{\alpha}}\right|\le \epsilon\right)\le \lim_{M\to \infty}\mathbb{P}\left(\left|\mathcal{N}\right|\le \frac{\epsilon}{M}\right)=0.$$


CMS Vs Framework? Is Drupal A CMS, Framework, or CMF (Content Management Framework)?

Question: After Reading a Blog post: http://www.palantir.net/blog/drupal-not-cms  It made me curious about the current classification as CMS Vs Framework.
Please use Facts, where possible to justify your response.
CMS
A Content Management System (CMS)is a computer program that allows publishing, editing and modifying content as well as maintenance from a central interface. Such systems of content management provide procedures to manage workflow in a collaborative environment. These procedures can be manual steps or an automated cascade. CMSs have been available since the late 1990s.
CMSs are often used to run websites containing blogs, news, and shopping. Many corporate and marketing websites use CMSs. CMSs typically aim to avoid the need for hand coding, but may support it for specific elements or entire pages. Source: http://en.wikipedia.org/wiki/Content_management_system
Web Application Framework:
A web application framework (WAF) is a software framework that is designed to support the development of dynamic websites, web applications, web services and web resources. The framework aims to alleviate the overhead associated with common activities performed in web development. For example, many frameworks provide libraries for database access, templating frameworks and session management, and they often promote code reuse.
Source: http://en.wikipedia.org/wiki/Web_application_framework
If you would not consider Drupal 7 a Framework, do you think Drupal 8 would be?
Comment: Sorry, opinion based, and thus off-topic. FWIW: "The disconnect is that Drupal is not a Content Management System (CMS), nor has it been one for some time. Drupal is a Content Management Framework (CMF), from which you can build a CMS tailored specifically for your needs." - http://www.palantir.net/blog/drupal-not-cms
Comment: The large list of drupal api's,introduction of entities concept to other things than nodes is what make me feel everyday how strong drupal is as cmf. Examples like drupal commerce, organic groups are some examples possible because of strong framework nature of drupal
Comment: @letharian Can you suggest a better category for this?
Answer: Drupal is Content Management Framework (for Developers) as well as Content Management System (for Non-Programmers).
Drupal is a highly configurable open source and an application development framework providing the following features:

Drupal provides the structure for Web applications which is far more complex than a CMS such as:

Extend the functionality (using contributed or custom code).
Communicate with other Web applications.
Run applications written in PHP and other languages behind the scenes.
Provide responsive pages or integrate front-end languages.
Scale to handle large traffic numbers by making use of server technologies and provide the foundation for other as yet unthought of innovations.

Drupal is one of the most highly extensible frameworks available, and has the built-in ability to grow with your organization. Drupal was built from the ground up with a uniquely sophisticated granular level control system that provides unparalleled extensibility. With its vast feature-rich capabilities and growing community you'll never outgrow Drupal.
Pre-made functionality in Drupal can be overridden through hooks, or you can find workarounds that Do Not require modifying other modules.
Drupal maintains a vigilant security community, providing security release updates on an ongoing basis to achieve maximum site security, which is one of the reasons even the U.S. Government and governments around the world use Drupal.
Drupal's modular architecture allows complex solutions to be "assembled" quickly and reliably. Over Fifteen thousand modules are available for Drupal.

CMS (Content Management System) features of Drupal:

Drupal comes with many tools to help you organize, structure, find and re-use your content. Categorize with taxonomy, automatically create friendly path urls, create custom lists, associate content with other content on your site, and create smart defaults for content creators.
Manage content with an easy-to-use web interface. Drupal's flexibility handles countless content types including video, text, blog, podcasts, and polls with robust user management, menu handling, real-time statistics and optional revision control.
Drupal comes with great options for new user accounts and user permissions. Users can be assigned one or more roles, and each role can be set up with fine-grained permissions allowing users view and create only what the administrator permits. The Drupal 7 admin theme makes administering a site easier than ever.
Drupal's focus on social publishing can help you create sites and applications to help your users express their opinions and engage with one another. You can have tight control over who can create, view, administer, publish and otherwise interact with content on your site.
Drupal's presentation layer allows designers to create highly usable, interactive experiences that engage users and increase traffic. Use an existing Drupal theme for your site, giving it an instant identity! If you can't find one you like, try designing your own which others can use, too.
Answer: My personal answer to this is: Drupal is a CMS based upon a Framework. The framework is certainly not Symfony as Drupal just levarages the components of symfony but not use symfony fullstack.
In general though Drupal will still provide a lot of functionality out of the box, while a framework lets you do things fast from the ground up.


Is there any special meaning to dividing n! by (n-r)! for permutations other than to eliminate the "tail" of the numerator?

Question: For permutations, is there any mathematical representation that $(n - r)!$ has other than being used to take eliminate the tail of the numerator $n!$ so that only the number of "choices" we make are left in the end?
I saw someone post online about how $(n - r)!$ represent the number of ways we can arrange the numbers we don't care about, is that true?
Thanks!
Comment: There is even an arithmetic reason behind this (and binomial coefficient) look at [this post](https://math.stackexchange.com/questions/3543013/pine-tree-shaped-in-binomial-coefficients-and-a-proving-the-formula-derived-from?r=SearchResults)
Answer: Yes, it is true.  Let us take $n=7,r=4$ for example.  There are $7!$ ways to arrange all $7$ items in a line.  If I only want three of them, there are $\frac {7!}{(7-4)!}=7\cdot 6 \cdot 5$ ways to arrange them in a line.  One way to see this is to say there are $7$ choices for the first, $6$ choices for the second, and $5$ choices for the third.  Another way is to say there are $7!$ ways to put them in a line, but I don't care how the last four are arranged because I will ignore them.  There are $4!$ ways to arrange the last $4$, so there are $\frac {7!}{4!}$ ways to arrange the first three.
Comment: That makes a lot of sense, thanks!
Answer: Consider the following way to find the number of arrangements. Suppose you have $r$ distinguishable apples and $n-r$ indistinguishable oranges. Let's say $x$ is the number of distinct ways to arrange them. Now for every such arrangement, there are $(n-r)!$ ways to label the oranges from $1$ to $n-r$. So the number of distinguishable arrangements after labelling the oranges is exactly $x\cdot(n-r)!$, but it is also $n!$, since now you're just arranging $n$ distinguishable fruits. So you get $x = n!/(n-r)!$.


Gerar números aleatórios em java, armazenar em um vetor e ordená-los

Question: Preciso gerar 100000 números, armazená-los em um vetor e ordená-los utilizando o algoritmo BubbleSort, está aparecendo o erro "Exception in thread "main" java.lang.Error: Unresolved compilation problem:
at testaSort.main(testaSort.java:8)"

Código abaixo:
import java.util.*;
import java.util.Random;
import javax.swing.*;

    public class testaSort {

        public static void main(String[] args)
        {
            int i;
            long inicio;
            long fim;
            double tempo;
            int[] vetor = new int [100000];
            int intervaloInicial = 0;
            int intervaloFinal = 100000;
            for (i=0 ; i < vetor.length; i++)
            {
                vetor [i] = getRandomNumberRange(intervaloInicial , intervaloFinal);
                System.out.println(vetor[i]);}
            }
            private static int getRandomNumberRange(int min, int max)
            {
                Random r = new Random();
                return r.ints (min,(max+1)).limit(1).findFirst().getAsInt();
            }

            //BubbleSort
            System.out.println("--Bubblesort--");
            inicio = System.currentTimeMillis();
            Sort.bubbleSort(vetor);
            fim = System.currentTimeMillis();
            System.out.printf("%.3f ms%n", (fim - inicio) / 1000d);
     }
}

Answer: Essa mensagem indica que há erros de sintaxe que impedem o seu código de ser compilado.
Por exemplo, o bloco de código abaixo do comentário //BubbleSort está fora de um método. Além disso, você não implementou o algoritmo do Bubble Sort no seu código e há chaves sem fechamento.
Eu dei uma arrumada no seu código. O Bubble Sort que eu implementei foi retirado desse site: BubbleSort em Java e em C
import java.util.*;
import java.util.Random;
import javax.swing.*;

public class testaSort {
    public static void main(String[] args) {
        int i;
        long inicio;
        long fim;
        //double tempo;
        int[] vetor = new int[100000];
        int intervaloInicial = 0;
        int intervaloFinal = 100000;
        for (i = 0; i < vetor.length; i++) {
            vetor[i] = getRandomNumberRange(intervaloInicial, intervaloFinal);
            System.out.println(vetor[i]);
        }
        //BubbleSort
        System.out.println("--Bubblesort--");
        inicio = System.currentTimeMillis();
        bubbleSort(vetor);
        fim = System.currentTimeMillis();
        System.out.printf("%.3f ms%n", (fim - inicio) / 1000d);
    }

    private static int getRandomNumberRange(int min, int max) {
        Random r = new Random();
        return r.ints(min, (max + 1)).limit(1).findFirst().getAsInt();
    }

    public static void bubbleSort(int[] a){
        if(a == null){
            throw new NullPointerException("The array doesn't exist.");
        }
        for(int i = 0; i < a.length - 1; i++){
            for(int j = 0; j  a[j + 1]){
                    int temp = a[j];
                    a[j] = a[j + 1];
                    a[j + 1] = temp;
                }
            }
        }
    }
}

Exemplo de saída do seu programa:

65737
37487
85573
87395
...
68212
65816
25052
--Bubblesort--
23,910 ms
Answer: Você não está utilizando a variável "tempo". Então ela pode ser exluída.
Para o sort, você pode fazer seu próprio algorítmo de bublle sort ou usar o Arrays.sort() - esse não usa bubble sort.
Algorítmo bubble (se quiser ordenar ao contrário é só inverter o for):
private void bubbleSort(int[] vetor) {
    int aux;
    for(int i = 0; i<5; i++){
        for(int j = 0; j<4; j++){
            if(vetor[j] > vetor[j + 1]){
                aux = vetor[j];
                vetor[j] = vetor[j+1];
                vetor[j+1] = aux;
            }
        }
    }
}

Adaptando seu código:
public class testaSort {

    public static void main(String[] args) {
        int i;
        long inicio;
        long fim;
        int[] vetor = new int[100000];
        int intervaloInicial = 0;
        int intervaloFinal = 100000;
        for (i = 0; i < vetor.length; i++) {
            vetor[i] = getRandomNumberRange(intervaloInicial, intervaloFinal);
            System.out.println(vetor[i]);
        }
        // BubbleSort
        System.out.println("--Bubblesort--");
        inicio = System.currentTimeMillis();
        // Arrays.sort(vetor);
        bubbleSort(vetor);
        fim = System.currentTimeMillis();
        System.out.printf("%.3f ms%n", (fim - inicio) / 1000d);
    }

    private void bubbleSort(int[] vetor) {
        int aux;
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 4; j++) {
                if (vetor[j] > vetor[j + 1]) {
                    aux = vetor[j];
                    vetor[j] = vetor[j + 1];
                    vetor[j + 1] = aux;
                }
            }
        }
    }
}


how to integerate R script in Shiny web page?

Question: In R script, I built a svm model by provide training.
and in shiny webpage i designed user interface in which one textbox and two textarea are placed to get input from user.
Now i want that when user submit on button the textbox and textarea value should be used by R script program in which a training is given to model and now new input is used to classify data by built in model.
so how to pass text field value of shiny webpage to R script?
 ui <- fluidPage( fluidRow(id="form-row",column(6,offset =3 ,id="form-col",p(id="mandatory","'*' Fields are manadatory"),div(id = "form",
                              div(id="p-container",p(id="form-header","Your Question")),
                              div(id="form-field-container",
                              textInput("title", "*Title",  width='100%',placeholder="Your Title is here..."),
                             # verbatimTextOutput("value"),
                            textOutput("title_val"),
                            #for text area width 100%
                              tags$style(HTML(".shiny-input-container:not(.shiny-input-container-inline){width: 100%;}")),
                              textAreaInput("description", "*Description", width='100%',rows = 3, resize = "both",placeholder="Description..."),
                            textOutput("desc_val"),
                            textAreaInput("code", "*Code", width='100%',rows = 3, resize = "both",placeholder="Write your code..."),
                            textOutput("code_val"),
                            useShinyalert(),
                              actionButton("submit", "Submit", class = "btn-primary")
                              ))
        )
    )
)
server <- function(input, output, session){
  observeEvent( input$submit,{
    title_val <- as.character(input$title)
    desc_val <- as.character(input$description)
    code_val <- as.character(input$code)
    ques<- paste(desc_val, code_val,sep=" \n")
  shinyalert( title_val, ques, type = "success")

  })
}

shinyApp(ui=ui, server=server)

Answer: You could do something like this:
eval(parse(text = input$code))

You could use eval and parse to evaluate a string.
library(shiny)
library(tidyverse)
library(shinyalert)

ui <- fluidPage( fluidRow(id="form-row",column(6,offset =3 ,id="form-col",p(id="mandatory","'*' Fields are manadatory"),div(id = "form",
                div(id="p-container",p(id="form-header","Your Question")),
                div(id="form-field-container",
                textInput("title", "*Title",  width='100%',placeholder="Your Title is here..."),
                # verbatimTextOutput("value"),
                textOutput("title_val"),
                #for text area width 100%
                tags$style(HTML(".shiny-input-container:not(.shiny-input-container-inline){width: 100%;}")),
                textAreaInput("description", "*Description", width='100%',rows = 3, resize = "both",placeholder="Description..."),
                textOutput("desc_val"),
                textAreaInput("code", "*Code", width='100%',rows = 3, resize = "both",placeholder="Write your code..."),
                textOutput("code_val"),
                useShinyalert(),
                actionButton("submit", "Submit", class = "btn-primary")
                ))
)
)
)

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

    model <- reactive({

        data <- mtcars # use your own data, might it be in a fileinput or some other data

        result <- eval(parse(text = input$code)) # Should include a hint to what way your dataframe is called and how it looks.
        result

    })

    observeEvent( input$submit,{
        title_val <- as.character(input$title)
        desc_val <- as.character(input$description)
        code_val <- as.character(input$code)
        ques<- paste(desc_val, code_val,sep=" \n")
        shinyalert( title_val, ques, type = "success")

    })
}

shinyApp(ui=ui, server=server)

But to be honest, I do not like the idea to parse and evaluate text from a userinput. Far too many possibilites to run into trouble.
The main advantage that someone who is not familiar with R is gone when I have to copy and paste a script as input
Comment: thanks for your reply, but i am M.Tech student and making this project for college, i am new to R and not much familiar with R. so i didn't clearly understand it.                                                        I want to run R script in shiny webpage and when user enter new input it should become input of R script code
Comment: This happens with the function I provided to you. The user enters a text, the text gets parsed and evaluated by R.
Comment: i have r script to train model it takes a lot of time to run, and made a trained model. now i want to give new input to trained model rather than run all the script again from training to testing script, how will it solve?


Angular 4 HttpClient Query Parameters

Question: I have been looking for a way to pass query parameters into an API call with the new HttpClientModule's HttpClient and have yet to find a solution. With the old Http module you would write something like this.
getNamespaceLogs(logNamespace) {

    // Setup log namespace query parameter
    let params = new URLSearchParams();
    params.set('logNamespace', logNamespace);

    this._Http.get(`${API_URL}/api/v1/data/logs`, { search: params })
}

This would result in an API call to the following URL:
localhost:3001/api/v1/data/logs?logNamespace=somelogsnamespace
However, the new HttpClient get() method doesn't have a search property, so I am wondering where to pass in the query parameters?
Comment: With Angular 7, you can write your params as an object and use it like this:
`this.httpClient.get(url, { params }`  Check out https://stackoverflow.com/a/54211610/5042169
Answer: I ended up finding it through the IntelliSense on the get() function. So, I'll post it here for anyone who is looking for similar information.
Anyways, the syntax is nearly identical, but slightly different. Instead of using URLSearchParams() the parameters need to be initialized as HttpParams() and the property within the get() function is now called params instead of search.
import { HttpClient, HttpParams } from '@angular/common/http';

getLogs(logNamespace): Observable<any> {

    // Setup log namespace query parameter
    let params = new HttpParams().set('logNamespace', logNamespace);

    return this._HttpClient.get(`${API_URL}/api/v1/data/logs`, { params: params })
}

I actually prefer this syntax as its a little more parameter agnostic. I also refactored the code to make it slightly more abbreviated.
getLogs(logNamespace): Observable<any> {

    return this._HttpClient.get(`${API_URL}/api/v1/data/logs`, {
        params: new HttpParams().set('logNamespace', logNamespace)
    })
}

Multiple Parameters
The best way I have found thus far is to define a Params object with all of the parameters I want to define defined within. As @estus pointed out in the comment below, there are a lot of great answers in This Question as to how to assign multiple parameters.
getLogs(parameters) {

    // Initialize Params Object
    let params = new HttpParams();

    // Begin assigning parameters
    params = params.append('firstParameter', parameters.valueOne);
    params = params.append('secondParameter', parameters.valueTwo);

    // Make the API call using the new parameters.
    return this._HttpClient.get(`${API_URL}/api/v1/data/logs`, { params: params })

Multiple Parameters with Conditional Logic
Another thing I often do with multiple parameters is allow the use of multiple parameters without requiring their presence in every call. Using Lodash, it's pretty simple to conditionally add/remove parameters from calls to the API. The exact functions used in Lodash or Underscores, or vanilla JS may vary depending on your application, but I have found that checking for property definition works pretty well. The function below will only pass parameters that have corresponding properties within the parameters variable passed into the function.
getLogs(parameters) {

    // Initialize Params Object
    let params = new HttpParams();

    // Begin assigning parameters
    if (!_.isUndefined(parameters)) {
        params = _.isUndefined(parameters.valueOne) ? params : params.append('firstParameter', parameters.valueOne);
        params = _.isUndefined(parameters.valueTwo) ? params : params.append('secondParameter', parameters.valueTwo);
    }

    // Make the API call using the new parameters.
    return this._HttpClient.get(`${API_URL}/api/v1/data/logs`, { params: params })

Comment: The first snippet is wrong. `let params = new HttpParams(); params.set(...)` won't work as expected. See https://stackoverflow.com/questions/45459532/why-httpparams-doesnt-work-in-multiple-line-in-angular-4-3/45459672#45459672
Comment: @SavadKP you can set them like this
this.http.get(url, {headers: headers, params: params});

and read about  new HttpHeaders like HttpParams
Comment: @joshrathke Could you please add how to add header and params together?
Comment: I guess `new HttpParams({fromObject: { param1: 'value1', ... }});` is the easiest approach (angular 5+) then `params.set(...)`.
Answer: You can (in version 5+) use the fromObject and fromString constructor parameters when creating HttpParamaters to make things a bit easier
    const params = new HttpParams({
      fromObject: {
        param1: 'value1',
        param2: 'value2',
      }
    });

    // http://localhost:3000/test?param1=value1&param2=value2

or:
    const params = new HttpParams({
      fromString: `param1=${var1}&param2=${var2}`
    });

    //http://localhost:3000/test?paramvalue1=1&param2=value2

Comment: This is not needed anymore. You can just pass directly a JSON object to HttpClient. `const params = {'key': 'value'}` to:  `http.get('/get/url', { params: params })`
Comment: @danger89 True. But be warned: only string or string[] values allowed!
Comment: Saved huge amount of my time. I was constructing url by appending query params as string to the request url.
Answer: You can pass it like this
let param: any = {'userId': 2};
this.http.get(`${ApiUrl}`, {params: param})

Comment: True but that throws typing out the window
Comment: @DanLatimer You don't have to use any, so you can keep using typing all the way until you pass it to `params`
Comment: @DanLatimer: While generally true, typing is out of the window as soon as you use `HttpParams`, which has no checks whatsoever on whether the params map contains any particular key with a value of any particular type.
Answer: A more concise solution:
this._Http.get(`${API_URL}/api/v1/data/logs`, {
    params: {
      logNamespace: logNamespace
    }
 })

Answer: With Angular 7,
I got it working by using the following without using HttpParams.
import { HttpClient } from '@angular/common/http';

export class ApiClass {

  constructor(private httpClient: HttpClient) {
    // use it like this in other services / components etc.
    this.getDataFromServer().
      then(res => {
        console.log('res: ', res);
      });
  }

  getDataFromServer() {
    const params = {
      param1: value1,
      param2: value2
    }
    const url = 'https://api.example.com/list'

    // { params: params } is the same as { params }
    // look for es6 object literal to read more
    return this.httpClient.get(url, { params }).toPromise();
  }
}

Answer: joshrathke is right.
In angular.io docs is written that URLSearchParams from @angular/http is deprecated. Instead you should use HttpParams from @angular/common/http. The code is quite similiar and identical to what joshrathke have written.
For multiple parameters that are saved for instance in a object like
{
  firstParam: value1,
  secondParam, value2
}

you could also do
for(let property in objectStoresParams) {
  if(objectStoresParams.hasOwnProperty(property) {
    params = params.append(property, objectStoresParams[property]);
  }
}

If you need inherited properties then remove the hasOwnProperty accordingly.
Answer: If you have an object that can be converted to {key: 'stringValue'} pairs, you can use this shortcut to convert it:
this._Http.get(myUrlString, {params: {...myParamsObject}});

I just love the spread syntax!
Answer: search property of type URLSearchParams in RequestOptions class is deprecated in angular 4. Instead, you should use params property of type URLSearchParams.
Answer: You can simply set JSON object to params.
let params = {
logNamespace: 'somelogsnamespace'
//, add more if needed
};
this._Http.get(`${API_URL}/api/v1/data/logs`, { params: params });

Angular 4 HttpClient Query Parameters


Returning data via WCF service

Question: I want to return latitude and longitude variables via WCF to show user's location on the map. I can return the latitude, but can't do the same thing with the longitude, because method returns only one value. I thought about returning array, but don't know how to do that. Here is WP code:
    void proxy_getUsrLatCompleted(object sender, ServiceReference1.getUsrLatCompletedEventArgs e)
    {
        Grid MyGrid = new Grid();
        MyGrid.RowDefinitions.Add(new RowDefinition());
        MyGrid.RowDefinitions.Add(new RowDefinition());
        MyGrid.Background = new SolidColorBrush(Colors.Transparent);

        Rectangle MyRectangle = new Rectangle();
        MyRectangle.Fill = new SolidColorBrush(Colors.Black);
        MyRectangle.Height = 20;
        MyRectangle.Width = 20;
        MyRectangle.SetValue(Grid.RowProperty, 0);
        MyRectangle.SetValue(Grid.ColumnProperty, 0);

        MyGrid.Children.Add(MyRectangle);

        Polygon MyPolygon = new Polygon();
        MyPolygon.Points.Add(new Point(2, 0));
        MyPolygon.Points.Add(new Point(22, 0));
        MyPolygon.Points.Add(new Point(2, 40));
        MyPolygon.Stroke = new SolidColorBrush(Colors.Black);
        MyPolygon.Fill = new SolidColorBrush(Colors.Black);
        MyPolygon.SetValue(Grid.RowProperty, 1);
        MyPolygon.SetValue(Grid.ColumnProperty, 0);

        MyGrid.Children.Add(MyPolygon);

        MapOverlay MyOverlay = new MapOverlay();
        MyOverlay.Content = MyGrid;
        MyOverlay.PositionOrigin = new Point(0, 0.5);
        MapLayer MyLayer = new MapLayer();
        MyLayer.Add(MyOverlay);
        myMap.Layers.Add(MyLayer);

        float gLat = float.Parse(e.Result);
        myMap.Center = new GeoCoordinate(gLat, gLong);
        MyOverlay.GeoCoordinate = new GeoCoordinate(gLat, gLong);
    }

Comment: create a class that has both and return it, you have to decorate it with [DataContract]
Answer: You must define a class to hold both properties, and use it as the return value:
class Point
{
    public string Lat {get;set;}
    public string Lon {get;set}
}
public Point getUsrLocation(string uName)
{
    DataClasses1DataContext data = new DataClasses1DataContext();
    return (from s in data.Users where s.usrName == uName select new Point(){Lat=s.usrLat,Lon=s.usrLong}).Single();
}

Comment: could you tell me how I would get returned value, because I'm getting an error trying to do it this way: `float gLat = float.Parse(e.Result.Point.Lat);`
Comment: @Leek Did you generate your client proxy via **Add service reference**? If so your client code is now likely out of date.  Right-click your service reference and select **Update**
Comment: @MickyDuncan, I did and I have this class in my service reference, but still keep getting this error: `'PhoneApp1.ServiceReference1.Point' does not contain a definition for 'Point' and no extension method 'Point' accepting a first argument of type 'PhoneApp1.ServiceReference1.Point' could be found (are you missing a using directive or an assembly reference?)`
Comment: Please try e.Result.Lat instead.

Returning data via WCF service


Linq error while dragging and dropping my table from server explorer to dbml file

Question: I am currently working with LINQ and I got the problem ! I don't know why it seems like that ! Yesterday it was working totally fine ! I have dragged one table from my server explorer and dropped into dbml file and suddenly i got this error box...

one or more selected items contain a data type that is not supported
  by the designer

Let me give you table definition:
Table definition
Comment: @NoOne: Try without the HierarchyId type, the rest including the computed column looks ok.
Comment: well, what column types does it have?
Comment: Do you want us to guess? Show the code please...
Comment: It doesn't give runtime error
Comment: I m trying to drag table and if i drop on dbml file ... then BOOM !! error popups !
Comment: There is no column type like nvarchar or nchar ! I use "Computed column specification n--> Formula" value ([Node].[GetLevel]()) and "Is Persisted" as "yes". It don't allow me to edit data type !
Answer: The [Level] column is missing a datatype. If you didn't mean for that to be there, and it wasn't there when you tried it, then it's possible the hierarchyid.


How many different ways to select students for a team?

Question:
The starting line up for a basketball team of 5 players is to be selected from the team of 15 seniors and 10 juniors. The team is is set to pick a PG, SG, SF, PF, and C. How many ways are there to select the team if the PG has to be a senior and the SG has to be a junior?

So this is what I did.

PG - Senior
SG - Junior
SF - 14 Seniors or 9 Juniors
PF-  13 Seniors or 8 Juniors
C -  12 Seniors or 7 Juniors

so $$14(13)(12)(9)(8)(7)= 1,100,736$$ possible ways to select the team
is this right?
Comment: It doesn't look like you quite got it.  If the PG is a senior there are 15 options, and 10 options for the SG.  Note that this leaves $9+14 = 23$ team members to fill in the other positions.
Comment: So instead of looking at who is a senior and who is a junior, would you just do 23.22.21 =10,626 possible ways to select the team?
Comment: No, you have to take into account the first two positions.  Your comment shows the number of ways to fill the other three slots.
Answer: First select the senior for the PG - 15 ways, then junior for the SG - 10 ways.
and then you have $23\cdot22\cdot21$ ways to fill in the other positions.
In total this gives you:
$23\cdot22\cdot21\cdot15\cdot10 = 1593900$ ways to select the team


Como criar um build script para compilar o librtmp com o openssl?

Question: Estou implementando o projeto ijkplayer(android mediaplayer) mas estou com dificuldades em adaptar uma compilação automatizada do librtmp(rtmpdump).
Tenho o seguinte exemplo abaixo, usado para compilar o OpenSSL no ijkplayer:
ijkplayer/android/contrib/tools/do-compile-openssl.sh
#! /usr/bin/env bash

#--------------------
set -e

if [ -z "$ANDROID_NDK" ]; then
    echo "You must define ANDROID_NDK before starting."
    echo "They must point to your NDK directories.\n"
    exit 1
fi

#--------------------
# common defines
FF_ARCH=$1
if [ -z "$FF_ARCH" ]; then
    echo "You must specific an architecture 'arm, armv7a, x86, ...'.\n"
    exit 1
fi

FF_BUILD_ROOT=`pwd`
FF_ANDROID_PLATFORM=android-9

FF_BUILD_NAME=
FF_SOURCE=
FF_CROSS_PREFIX=

FF_CFG_FLAGS=
FF_PLATFORM_CFG_FLAGS=

FF_EXTRA_CFLAGS=
FF_EXTRA_LDFLAGS=

#--------------------
echo ""
echo "--------------------"
echo "[*] make NDK standalone toolchain"
echo "--------------------"
. ./tools/do-detect-env.sh
FF_MAKE_TOOLCHAIN_FLAGS=$IJK_MAKE_TOOLCHAIN_FLAGS
FF_MAKE_FLAGS=$IJK_MAKE_FLAG
FF_GCC_VER=$IJK_GCC_VER
FF_GCC_64_VER=$IJK_GCC_64_VER

#----- armv7a begin -----
if [ "$FF_ARCH" = "armv7a" ]; then
    FF_BUILD_NAME=openssl-armv7a
    FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAME

    FF_CROSS_PREFIX=arm-linux-androideabi
    FF_TOOLCHAIN_NAME=${FF_CROSS_PREFIX}-${FF_GCC_VER}

    FF_PLATFORM_CFG_FLAGS="android-armv7"

elif [ "$FF_ARCH" = "armv5" ]; then
    FF_BUILD_NAME=openssl-armv5
    FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAME

    FF_CROSS_PREFIX=arm-linux-androideabi
    FF_TOOLCHAIN_NAME=${FF_CROSS_PREFIX}-${FF_GCC_VER}

    FF_PLATFORM_CFG_FLAGS="android"

elif [ "$FF_ARCH" = "x86" ]; then
    FF_BUILD_NAME=openssl-x86
    FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAME

    FF_CROSS_PREFIX=i686-linux-android
    FF_TOOLCHAIN_NAME=x86-${FF_GCC_VER}

    FF_PLATFORM_CFG_FLAGS="android-x86"

elif [ "$FF_ARCH" = "x86_64" ]; then
    FF_ANDROID_PLATFORM=android-21

    FF_BUILD_NAME=openssl-x86_64
    FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAME

    FF_CROSS_PREFIX=x86_64-linux-android
    FF_TOOLCHAIN_NAME=${FF_CROSS_PREFIX}-${FF_GCC_64_VER}

    FF_PLATFORM_CFG_FLAGS="linux-x86_64"

elif [ "$FF_ARCH" = "arm64" ]; then
    FF_ANDROID_PLATFORM=android-21

    FF_BUILD_NAME=openssl-arm64
    FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAME

    FF_CROSS_PREFIX=aarch64-linux-android
    FF_TOOLCHAIN_NAME=${FF_CROSS_PREFIX}-${FF_GCC_64_VER}

    FF_PLATFORM_CFG_FLAGS="linux-aarch64"

else
    echo "unknown architecture $FF_ARCH";
    exit 1
fi

FF_TOOLCHAIN_PATH=$FF_BUILD_ROOT/build/$FF_BUILD_NAME/toolchain

FF_SYSROOT=$FF_TOOLCHAIN_PATH/sysroot
FF_PREFIX=$FF_BUILD_ROOT/build/$FF_BUILD_NAME/output

mkdir -p $FF_PREFIX
mkdir -p $FF_SYSROOT

#--------------------
echo ""
echo "--------------------"
echo "[*] make NDK standalone toolchain"
echo "--------------------"
. ./tools/do-detect-env.sh
FF_MAKE_TOOLCHAIN_FLAGS=$IJK_MAKE_TOOLCHAIN_FLAGS
FF_MAKE_FLAGS=$IJK_MAKE_FLAG

FF_MAKE_TOOLCHAIN_FLAGS="$FF_MAKE_TOOLCHAIN_FLAGS --install-dir=$FF_TOOLCHAIN_PATH"
FF_TOOLCHAIN_TOUCH="$FF_TOOLCHAIN_PATH/touch"
if [ ! -f "$FF_TOOLCHAIN_TOUCH" ]; then
    $ANDROID_NDK/build/tools/make-standalone-toolchain.sh \
        $FF_MAKE_TOOLCHAIN_FLAGS \
        --platform=$FF_ANDROID_PLATFORM \
        --toolchain=$FF_TOOLCHAIN_NAME
    touch $FF_TOOLCHAIN_TOUCH;
fi

#--------------------
echo ""
echo "--------------------"
echo "[*] check openssl env"
echo "--------------------"
export PATH=$FF_TOOLCHAIN_PATH/bin:$PATH

export COMMON_FF_CFG_FLAGS=

FF_CFG_FLAGS="$FF_CFG_FLAGS $COMMON_FF_CFG_FLAGS"

#--------------------
# Standard options:
FF_CFG_FLAGS="$FF_CFG_FLAGS zlib-dynamic"
FF_CFG_FLAGS="$FF_CFG_FLAGS no-shared"
FF_CFG_FLAGS="$FF_CFG_FLAGS --openssldir=$FF_PREFIX"
FF_CFG_FLAGS="$FF_CFG_FLAGS --cross-compile-prefix=${FF_CROSS_PREFIX}-"
FF_CFG_FLAGS="$FF_CFG_FLAGS $FF_PLATFORM_CFG_FLAGS"

#--------------------
echo ""
echo "--------------------"
echo "[*] configurate openssl"
echo "--------------------"
cd $FF_SOURCE
#if [ -f "./Makefile" ]; then
#    echo 'reuse configure'
#else
    echo "./Configure $FF_CFG_FLAGS"
    ./Configure $FF_CFG_FLAGS
#        --extra-cflags="$FF_CFLAGS $FF_EXTRA_CFLAGS" \
#        --extra-ldflags="$FF_EXTRA_LDFLAGS"
#fi

#--------------------
echo ""
echo "--------------------"
echo "[*] compile openssl"
echo "--------------------"
make depend
make $FF_MAKE_FLAGS
make install_sw

#--------------------
echo ""
echo "--------------------"
echo "[*] link openssl"
echo "--------------------"

Aqui o arquivo compile-openssl.sh que é usado para chamar o arquivo responsável pela compilação, do-compile-openssl.sh
ijkplayer/android/contrib/compile-openssl.sh
#! /usr/bin/env bash

#----------
export ANDROID_NDK="/run/media/root/linux/workspace/android-ndk-r11c"

UNI_BUILD_ROOT=`pwd`
FF_TARGET=$1
set -e
set +x

FF_ACT_ARCHS_32="armv5 armv7a x86"
FF_ACT_ARCHS_64="armv5 armv7a arm64 x86 x86_64"
FF_ACT_ARCHS_ALL=$FF_ACT_ARCHS_64

echo_archs() {
    echo "===================="
    echo "[*] check archs"
    echo "===================="
    echo "FF_ALL_ARCHS = $FF_ACT_ARCHS_ALL"
    echo "FF_ACT_ARCHS = $*"
    echo ""
}

echo_usage() {
    echo "Usage:"
    echo "  compile-openssl.sh armv5|armv7a|arm64|x86|x86_64"
    echo "  compile-openssl.sh all|all32"
    echo "  compile-openssl.sh all64"
    echo "  compile-openssl.sh clean"
    echo "  compile-openssl.sh check"
    exit 1
}

echo_nextstep_help() {
    #----------
    echo ""
    echo "--------------------"
    echo "[*] Finished"
    echo "--------------------"
    echo "# to continue to build ffmpeg, run script below,"
    echo "sh compile-ffmpeg.sh "
    echo "# to continue to build ijkplayer, run script below,"
    echo "sh compile-ijk.sh "
}

#----------
case "$FF_TARGET" in
    "")
        echo_archs armv7a
        sh tools/do-compile-openssl.sh armv7a
    ;;
    armv5|armv7a|arm64|x86|x86_64)
        echo_archs $FF_TARGET
        sh tools/do-compile-openssl.sh $FF_TARGET
        echo_nextstep_help
    ;;
    all32)
        echo_archs $FF_ACT_ARCHS_32
        for ARCH in $FF_ACT_ARCHS_32
        do
            sh tools/do-compile-openssl.sh $ARCH
        done
        echo_nextstep_help
    ;;
    all|all64)
        echo_archs $FF_ACT_ARCHS_64
        for ARCH in $FF_ACT_ARCHS_64
        do
            sh tools/do-compile-openssl.sh $ARCH
        done
        echo_nextstep_help
    ;;
    clean)
        echo_archs FF_ACT_ARCHS_64
        for ARCH in $FF_ACT_ARCHS_ALL
        do
            if [ -d openssl-$ARCH ]; then
                cd openssl-$ARCH && git clean -xdf && cd -
            fi
        done
        rm -rf ./build/openssl-*
    ;;
    check)
        echo_archs FF_ACT_ARCHS_ALL
    ;;
    *)
        echo_usage
        exit 1
    ;;
esac

Até agora fiz as seguintes modificações para a adaptação da compilação do librtmp:
Arquivo do-compile-openssl.sh modificado para do-compile-librtmp.sh
#! /usr/bin/env bash

#--------------------
set -e

if [ -z "$ANDROID_NDK" ]; then
    echo "You must define ANDROID_NDK before starting."
    echo "They must point to your NDK directories.\n"
    exit 1
fi

#--------------------
# common defines
FF_ARCH=$1
if [ -z "$FF_ARCH" ]; then
    echo "You must specific an architecture 'arm, armv7a, x86, ...'.\n"
    exit 1
fi

FF_BUILD_ROOT=`pwd`
FF_ANDROID_PLATFORM=android-9

FF_BUILD_NAME=
FF_SOURCE=
FF_CROSS_PREFIX=

FF_CFG_FLAGS=
FF_PLATFORM_CFG_FLAGS=

FF_EXTRA_CFLAGS=
FF_EXTRA_LDFLAGS=

#--------------------
echo ""
echo "--------------------"
echo "[*] make NDK standalone toolchain"
echo "--------------------"
. ./tools/do-detect-env.sh
FF_MAKE_TOOLCHAIN_FLAGS=$IJK_MAKE_TOOLCHAIN_FLAGS
FF_MAKE_FLAGS=$IJK_MAKE_FLAG
FF_GCC_VER=$IJK_GCC_VER
FF_GCC_64_VER=$IJK_GCC_64_VER

#----- armv7a begin -----
if [ "$FF_ARCH" = "armv7a" ]; then
    FF_BUILD_NAME=librtmp-armv7a
    FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAME

    FF_CROSS_PREFIX=arm-linux-androideabi
    FF_TOOLCHAIN_NAME=${FF_CROSS_PREFIX}-${FF_GCC_VER}

    FF_PLATFORM_CFG_FLAGS="android-armv7"

elif [ "$FF_ARCH" = "armv5" ]; then
    FF_BUILD_NAME=librtmp-armv5
    FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAME

    FF_CROSS_PREFIX=arm-linux-androideabi
    FF_TOOLCHAIN_NAME=${FF_CROSS_PREFIX}-${FF_GCC_VER}

    FF_PLATFORM_CFG_FLAGS="android"

elif [ "$FF_ARCH" = "x86" ]; then
    FF_BUILD_NAME=librtmp-x86
    FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAME

    FF_CROSS_PREFIX=i686-linux-android
    FF_TOOLCHAIN_NAME=x86-${FF_GCC_VER}

    FF_PLATFORM_CFG_FLAGS="android-x86"

elif [ "$FF_ARCH" = "x86_64" ]; then
    FF_ANDROID_PLATFORM=android-21

    FF_BUILD_NAME=librtmp-x86_64
    FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAME

    FF_CROSS_PREFIX=x86_64-linux-android
    FF_TOOLCHAIN_NAME=${FF_CROSS_PREFIX}-${FF_GCC_64_VER}

    FF_PLATFORM_CFG_FLAGS="linux-x86_64"

elif [ "$FF_ARCH" = "arm64" ]; then
    FF_ANDROID_PLATFORM=android-21

    FF_BUILD_NAME=librtmp-arm64
    FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAME

    FF_CROSS_PREFIX=aarch64-linux-android
    FF_TOOLCHAIN_NAME=${FF_CROSS_PREFIX}-${FF_GCC_64_VER}

    FF_PLATFORM_CFG_FLAGS="linux-aarch64"

else
    echo "unknown architecture $FF_ARCH";
    exit 1
fi

FF_TOOLCHAIN_PATH=$FF_BUILD_ROOT/build/$FF_BUILD_NAME/toolchain

FF_SYSROOT=$FF_TOOLCHAIN_PATH/sysroot
FF_PREFIX=$FF_BUILD_ROOT/build/$FF_BUILD_NAME/output

mkdir -p $FF_PREFIX
mkdir -p $FF_SYSROOT

#--------------------
echo ""
echo "--------------------"
echo "[*] make NDK standalone toolchain"
echo "--------------------"
. ./tools/do-detect-env.sh
FF_MAKE_TOOLCHAIN_FLAGS=$IJK_MAKE_TOOLCHAIN_FLAGS
FF_MAKE_FLAGS=$IJK_MAKE_FLAG

FF_MAKE_TOOLCHAIN_FLAGS="$FF_MAKE_TOOLCHAIN_FLAGS --install-dir=$FF_TOOLCHAIN_PATH"
FF_TOOLCHAIN_TOUCH="$FF_TOOLCHAIN_PATH/touch"
if [ ! -f "$FF_TOOLCHAIN_TOUCH" ]; then
    $ANDROID_NDK/build/tools/make-standalone-toolchain.sh \
        $FF_MAKE_TOOLCHAIN_FLAGS \
        --platform=$FF_ANDROID_PLATFORM \
        --toolchain=$FF_TOOLCHAIN_NAME
    touch $FF_TOOLCHAIN_TOUCH;
fi

#--------------------
echo ""
echo "--------------------"
echo "[*] check librtmp env"
echo "--------------------"
export PATH=$FF_TOOLCHAIN_PATH/bin:$PATH

export COMMON_FF_CFG_FLAGS=

FF_CFG_FLAGS="$FF_CFG_FLAGS $COMMON_FF_CFG_FLAGS"

#--------------------
# Standard options:
FF_CFG_FLAGS="$FF_CFG_FLAGS zlib-dynamic"
FF_CFG_FLAGS="$FF_CFG_FLAGS no-shared"
FF_CFG_FLAGS="$FF_CFG_FLAGS --openssldir=$FF_PREFIX"
FF_CFG_FLAGS="$FF_CFG_FLAGS --cross-compile-prefix=${FF_CROSS_PREFIX}-"
FF_CFG_FLAGS="$FF_CFG_FLAGS $FF_PLATFORM_CFG_FLAGS"

#--------------------
echo ""
echo "--------------------"
echo "[*] configurate librtmp"
echo "--------------------"
cd $FF_SOURCE
#if [ -f "./Makefile" ]; then
#    echo 'reuse configure'
#else
    echo "./Configure $FF_CFG_FLAGS"
    ./Configure $FF_CFG_FLAGS
#        --extra-cflags="$FF_CFLAGS $FF_EXTRA_CFLAGS" \
#        --extra-ldflags="$FF_EXTRA_LDFLAGS"
#fi

#--------------------
echo ""
echo "--------------------"
echo "[*] compile librtmp"
echo "--------------------"
make depend
make $FF_MAKE_FLAGS
make install_sw

#--------------------
echo ""
echo "--------------------"
echo "[*] link librtmp"
echo "--------------------"

Manualmente posso executar a compilação em standalone do librtmp com o OpenSSL com o seguinte comando /run/media/root/linux/workspace/android-ndk-r11c/ndk-build TARGET_PLATFORM=android-14 TARGET_ARCH_ABI=armeabi-v7a NDK_PROJECT_PATH=. usando os arquivos do rtmpdump abaixo.
rtmpdump/Android.mk
LOCAL_PATH := $(call my-dir)

subdirs := $(addprefix $(LOCAL_PATH)/,$(addsuffix /Android.mk, \
        librtmp \
    ))

ifeq($(TARGET_ARCH_ABI), armeabi)
    SSL := ../../v_openssl/OpenSSL-1.0.2g_armeabi
endif

ifeq($(TARGET_ARCH_ABI), armeabi-v7a)
    SSL := ../../v_openssl/OpenSSL-1.0.2g_armeabi-v7a
endif

ifeq($(TARGET_ARCH_ABI), x86)
    SSL := ../../v_openssl/OpenSSL-1.0.2g_x86
endif

#SSL := ~/SSL
ifndef SSL
$(error "You must define SSL before starting")
endif

include $(subdirs)

rtmpdump/Makefile
VERSION=v2.4

prefix=/usr/local

CC=$(CROSS_COMPILE)gcc
LD=$(CROSS_COMPILE)ld

SYS=posix
#SYS=mingw

CRYPTO=OPENSSL
#CRYPTO=POLARSSL
#CRYPTO=GNUTLS
LIBZ=-lz
LIB_GNUTLS=-lgnutls -lhogweed -lnettle -lgmp $(LIBZ)
LIB_OPENSSL=-lssl -lcrypto $(LIBZ)
LIB_POLARSSL=-lpolarssl $(LIBZ)
CRYPTO_LIB=$(LIB_$(CRYPTO))
DEF_=-DNO_CRYPTO
CRYPTO_DEF=$(DEF_$(CRYPTO))

DEF=-DRTMPDUMP_VERSION=\"$(VERSION)\" $(CRYPTO_DEF) $(XDEF)
OPT=-O2
CFLAGS=-Wall $(XCFLAGS) $(INC) $(DEF) $(OPT)
LDFLAGS=-Wall $(XLDFLAGS)

bindir=$(prefix)/bin
sbindir=$(prefix)/sbin
mandir=$(prefix)/man

BINDIR=$(DESTDIR)$(bindir)
SBINDIR=$(DESTDIR)$(sbindir)
MANDIR=$(DESTDIR)$(mandir)

LIBS_posix=
LIBS_darwin=
LIBS_mingw=-lws2_32 -lwinmm -lgdi32
LIB_RTMP=-Llibrtmp -lrtmp
LIBS=$(LIB_RTMP) $(CRYPTO_LIB) $(LIBS_$(SYS)) $(XLIBS)

THREADLIB_posix=-lpthread
THREADLIB_darwin=-lpthread
THREADLIB_mingw=
THREADLIB=$(THREADLIB_$(SYS))
SLIBS=$(THREADLIB) $(LIBS)

LIBRTMP=librtmp/librtmp.a
INCRTMP=librtmp/rtmp_sys.h librtmp/rtmp.h librtmp/log.h librtmp/amf.h

EXT_posix=
EXT_darwin=
EXT_mingw=.exe
EXT=$(EXT_$(SYS))

PROGS=rtmpdump rtmpgw rtmpsrv rtmpsuck

all:    $(LIBRTMP) $(PROGS)

$(PROGS): $(LIBRTMP)

install:    $(PROGS)
    -mkdir -p $(BINDIR) $(SBINDIR) $(MANDIR)/man1 $(MANDIR)/man8
    cp rtmpdump$(EXT) $(BINDIR)
    cp rtmpgw$(EXT) rtmpsrv$(EXT) rtmpsuck$(EXT) $(SBINDIR)
    cp rtmpdump.1 $(MANDIR)/man1
    cp rtmpgw.8 $(MANDIR)/man8
    @cd librtmp; $(MAKE) install

clean:
    rm -f *.o rtmpdump$(EXT) rtmpgw$(EXT) rtmpsrv$(EXT) rtmpsuck$(EXT)
    @cd librtmp; $(MAKE) clean

FORCE:

$(LIBRTMP): FORCE
    @cd librtmp; $(MAKE) all

rtmpdump: rtmpdump.o
    $(CC) $(LDFLAGS) -o $@$(EXT) $@.o $(LIBS)

rtmpsrv: rtmpsrv.o thread.o
    $(CC) $(LDFLAGS) -o $@$(EXT) $@.o thread.o $(SLIBS)

rtmpsuck: rtmpsuck.o thread.o
    $(CC) $(LDFLAGS) -o $@$(EXT) $@.o thread.o $(SLIBS)

rtmpgw: rtmpgw.o thread.o
    $(CC) $(LDFLAGS) -o $@$(EXT) $@.o thread.o $(SLIBS)

rtmpgw.o: rtmpgw.c $(INCRTMP) Makefile
rtmpdump.o: rtmpdump.c $(INCRTMP) Makefile
rtmpsrv.o: rtmpsrv.c $(INCRTMP) Makefile
rtmpsuck.o: rtmpsuck.c $(INCRTMP) Makefile
thread.o: thread.c thread.h

rtmpdump/jni/Application.mk
NDK_TOOLCHAIN_VERSION := 4.9
APP_ABI := all
APP_PROJECT_PATH := $(shell pwd)
APP_BUILD_SCRIPT := $(APP_PROJECT_PATH)/Android.mk

rtmpdump/librtmp/Android.mk
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_C_INCLUDES += $(NDK_PROJECT_PATH)/librtmp \
    $(SSL)/include

LOCAL_SRC_FILES:= \
    amf.c \
    hashswf.c \
    log.c \
    parseurl.c \
    rtmp.c

LOCAL_CFLAGS += -I$(SSL)/include -DUSE_OPENSSL
#LOCAL_LDLIBS += -L$(SSL)/libs/$(TARGET_ARCH_ABI)
#Modificado para OpenSSL 1.0.2g stand alone build
LOCAL_LDLIBS += -L$(SSL)
LOCAL_LDLIBS += -lssl -lcrypto -lz

LOCAL_MODULE := librtmp

include $(BUILD_SHARED_LIBRARY)

rtmpdump/librtmp/Makefile
VERSION=v2.4

prefix=/usr/local

incdir=$(prefix)/include/librtmp
bindir=$(prefix)/bin
libdir=$(prefix)/lib
mandir=$(prefix)/man
BINDIR=$(DESTDIR)$(bindir)
INCDIR=$(DESTDIR)$(incdir)
LIBDIR=$(DESTDIR)$(libdir)
MANDIR=$(DESTDIR)$(mandir)

CC=$(CROSS_COMPILE)gcc
LD=$(CROSS_COMPILE)ld
AR=$(CROSS_COMPILE)ar

SYS=posix
CRYPTO=OPENSSL
#CRYPTO=GNUTLS
DEF_POLARSSL=-DUSE_POLARSSL
DEF_OPENSSL=-DUSE_OPENSSL
DEF_GNUTLS=-DUSE_GNUTLS
DEF_=-DNO_CRYPTO
REQ_GNUTLS=gnutls
REQ_OPENSSL=libssl,libcrypto
LIBZ=-lz
LIBS_posix=
LIBS_darwin=
LIBS_mingw=-lws2_32 -lwinmm -lgdi32
LIB_GNUTLS=-lgnutls -lhogweed -lnettle -lgmp $(LIBZ)
LIB_OPENSSL=-lssl -lcrypto $(LIBZ)
LIB_POLARSSL=-lpolarssl $(LIBZ)
PRIVATE_LIBS=$(LIBS_$(SYS))
CRYPTO_LIB=$(LIB_$(CRYPTO)) $(PRIVATE_LIBS)
CRYPTO_REQ=$(REQ_$(CRYPTO))
CRYPTO_DEF=$(DEF_$(CRYPTO))

SO_VERSION=0
SOX_posix=so
SOX_darwin=dylib
SOX_mingw=dll
SOX=$(SOX_$(SYS))
SO_posix=.$(SOX).$(SO_VERSION)
SO_darwin=.$(SO_VERSION).$(SOX)
SO_mingw=-$(SO_VERSION).$(SOX)
SO_EXT=$(SO_$(SYS))

SODIR_posix=$(LIBDIR)
SODIR_darwin=$(LIBDIR)
SODIR_mingw=$(BINDIR)
SODIR=$(SODIR_$(SYS))

SO_LDFLAGS_posix=-shared -Wl,-soname,$@
SO_LDFLAGS_darwin=-dynamiclib -twolevel_namespace -undefined dynamic_lookup \
    -fno-common -headerpad_max_install_names -install_name $(libdir)/$@
SO_LDFLAGS_mingw=-shared -Wl,--out-implib,librtmp.dll.a
SO_LDFLAGS=$(SO_LDFLAGS_$(SYS))

INSTALL_IMPLIB_posix=
INSTALL_IMPLIB_darwin=
INSTALL_IMPLIB_mingw=cp librtmp.dll.a $(LIBDIR)
INSTALL_IMPLIB=$(INSTALL_IMPLIB_$(SYS))

SHARED=yes
SODEF_yes=-fPIC
SOLIB_yes=librtmp$(SO_EXT)
SOINST_yes=install_so
SO_DEF=$(SODEF_$(SHARED))
SO_LIB=$(SOLIB_$(SHARED))
SO_INST=$(SOINST_$(SHARED))

DEF=-DRTMPDUMP_VERSION=\"$(VERSION)\" $(CRYPTO_DEF) $(XDEF)
OPT=-O2
CFLAGS=-Wall $(XCFLAGS) $(INC) $(DEF) $(OPT) $(SO_DEF)
LDFLAGS=$(XLDFLAGS)

OBJS=rtmp.o log.o amf.o hashswf.o parseurl.o

all:    librtmp.a $(SO_LIB)

clean:
    rm -f *.o *.a *.$(SOX) *$(SO_EXT) librtmp.pc

librtmp.a: $(OBJS)
    $(AR) rs $@ $?

librtmp$(SO_EXT): $(OBJS)
    $(CC) $(SO_LDFLAGS) $(LDFLAGS) -o $@ $^ $> $(CRYPTO_LIB)
    ln -sf $@ librtmp.$(SOX)

log.o: log.c log.h Makefile
rtmp.o: rtmp.c rtmp.h rtmp_sys.h handshake.h dh.h log.h amf.h Makefile
amf.o: amf.c amf.h bytes.h log.h Makefile
hashswf.o: hashswf.c http.h rtmp.h rtmp_sys.h Makefile
parseurl.o: parseurl.c rtmp.h rtmp_sys.h log.h Makefile

librtmp.pc: librtmp.pc.in Makefile
    sed -e "s;@prefix@;$(prefix);" -e "s;@libdir@;$(libdir);" \
        -e "s;@VERSION@;$(VERSION);" \
        -e "s;@CRYPTO_REQ@;$(CRYPTO_REQ);" \
        -e "s;@PRIVATE_LIBS@;$(PRIVATE_LIBS);" librtmp.pc.in > $@

install:    install_base $(SO_INST)

install_base:   librtmp.a librtmp.pc
    -mkdir -p $(INCDIR) $(LIBDIR)/pkgconfig $(MANDIR)/man3 $(SODIR)
    cp amf.h http.h log.h rtmp.h $(INCDIR)
    cp librtmp.a $(LIBDIR)
    cp librtmp.pc $(LIBDIR)/pkgconfig
    cp librtmp.3 $(MANDIR)/man3

install_so: librtmp$(SO_EXT)
    cp librtmp$(SO_EXT) $(SODIR)
    $(INSTALL_IMPLIB)
    cd $(SODIR); ln -sf librtmp$(SO_EXT) librtmp.$(SOX)

A grande questão é: Como vou modificar esses arquivos(do-compile-librtmp.sh) para que ao executar o ./compile-librtmp.sh all sejam compilados automaticamente as arquiteturas definidas nele junto com o OpenSSL?.
Answer: Você precisa replicar o compile-openssl.sh, apenas modificando pro arquivo que vc criou "do-compile-librtmp.sh"
UNI_BUILD_ROOT=`pwd`
FF_TARGET=$1
set -e
set +x

FF_ACT_ARCHS_32="armv5 armv7a x86"
FF_ACT_ARCHS_64="armv5 armv7a arm64 x86 x86_64"
FF_ACT_ARCHS_ALL=$FF_ACT_ARCHS_64

echo_archs() {
    echo "===================="
    echo "[*] check archs"
    echo "===================="
    echo "FF_ALL_ARCHS = $FF_ACT_ARCHS_ALL"
    echo "FF_ACT_ARCHS = $*"
    echo ""
}

echo_usage() {
    echo "Usage:"
    echo "  compile-librtmp.sh armv5|armv7a|arm64|x86|x86_64"
    echo "  compile-librtmp.sh all|all32"
    echo "  compile-librtmp.sh all64"
    echo "  compile-librtmp.sh clean"
    echo "  compile-librtmp.sh check"
    exit 1
}

echo_nextstep_help() {
    #----------
    echo ""
    echo "--------------------"
    echo "[*] Finished"
    echo "--------------------"
    echo "# to continue to build ffmpeg, run script below,"
    echo "sh compile-ffmpeg.sh "
    echo "# to continue to build ijkplayer, run script below,"
    echo "sh compile-ijk.sh "
}

#----------
case "$FF_TARGET" in
    "")
        echo_archs armv7a
        sh tools/do-compile-librtmp.sh armv7a
    ;;
    armv5|armv7a|arm64|x86|x86_64)
        echo_archs $FF_TARGET
        sh tools/do-compile-librtmp.sh $FF_TARGET
        echo_nextstep_help
    ;;
    all32)
        echo_archs $FF_ACT_ARCHS_32
        for ARCH in $FF_ACT_ARCHS_32
        do
            sh tools/do-compile-librtmp.sh $ARCH
        done
        echo_nextstep_help
    ;;
    all|all64)
        echo_archs $FF_ACT_ARCHS_64
        for ARCH in $FF_ACT_ARCHS_64
        do
            sh tools/do-compile-librtmp.sh $ARCH
        done
        echo_nextstep_help
    ;;
    clean)
        echo_archs FF_ACT_ARCHS_64
        for ARCH in $FF_ACT_ARCHS_ALL
        do
            if [ -d librtmp-$ARCH ]; then
                cd librtmp-$ARCH && git clean -xdf && cd -
            fi
        done
        rm -rf ./build/librtmp-*
    ;;
    check)
        echo_archs FF_ACT_ARCHS_ALL
    ;;
    *)
        echo_usage
        exit 1
    ;;
esac

Comment: Não consegui compilar usando um build script, optei pela compilação manual, esses scripts são bons, mas apenas para o ijkplayer, usá-los em outros projetos é bem complicado. O jeito é compilar manualmente com o build-ndk... pois o librtmp usa os arquivos Makefile para a configuração, e passar isso para um build script é extremamente complicado. Agradeço a ajuda.


How to evaluate the quality of sound of a piano?

Question: While looking for a new piano I was wondering how to evaluate the quality of tone and sound of a piano as an instrument?
What makes the difference between a good and an even better instrument? What are objectifiable criteria to judge this?
I'm also interested in categorizing aspects of piano sound regardless of quality: what makes it different without having to say it is better? In a way I 'm looking for an analytical framework as a way to improve my listening skills, I suppose.
Comment: Sound quality is entirely subjective and something you can really only assess via experience, IMO.
Comment: The only things I could think that could possibly be *objectively* better/worse between two instruments might be some aspects that made the piano easier to play - feel of keys, pedals, etc. - nothing to do with sound. The question about different aspects of sound is still interesting.
Comment: Of course there's a subjective dimension, but I would think that there is a reason (beyond the mechanical) some pianos are (much) more expensive than others. It isn't arbitrary. And even the subjective opinion can be expressed with reasons. "I like this piano better because it sounds more..." "A professional pianist will choose that piano because its tone is..."
Comment: @TimH  True, there will be sonic characteristics that cost more money to create with current manufacturing techniques - but that doesn't mean that their presence makes the instrument objectively better. A piano that sounds great for one piece, in one hall, is not always the best for another. Sticking to talking about aspects of sound as you suggest in your last paragraph will be a clearer discussion.
Comment: While you're looking for a piano, what sort of criteria do the guys in the shops use?
Comment: You can't objectify the unobjectifiable. It has been said that no two Steinway pianos ever made have sounded the same, and my playing experience doesn't contradict that. The price variation between models is mostly caused by the amount of hand-finishing work done on them. As for "the guys in the shops", never forget they are salespeople, and their recommendation will be strongly influenced by the amount of money they think they can get you to spend, and the amount of commission they can get from the sale.
Comment: @dead rat: I don't know,  a piano that sounds like crap sounds like crap. I had one, I know.
Answer: Before getting into sound quality, one thing that can set pianos apart is their action. Last time I knew a lot about what was going on with pianos, only pianos with horizontal strings (grand style) could have a full proper double escapement action. That affects how quickly you can play the same note again after you've played it at least once, and/or how far you have to release a key before you can play it again. This isn't super important for all pianists, but some pieces can be demanding in this area (e.g., the middle section of Samuel Goldenberg and Schmuyle from Pictures at an Exhibition).
For sound quality, I can think of three broad categories that almost anyone should be able to discern between pianos.
Brightness: This one is probably the easiest to hear and will mostly be related to the hammers and the felt thereon. One important thing about selecting the brightness you want in a piano is that in general, pianos get brighter as they age because the felt on the hammers is compacted. So consider looking for a piano that is slightly less bright than you like.
Low end depth: This one is mostly going to be about how much money you have because getting a real boom out of the low notes pretty much requires longer strings. This is why people play 9 foot grand pianos when they can.
Finally, harmonic richness: This will also be related to your budget but more in the way in that you can buy into a better level of richness and once you get up there the differences become much more subtle. Already this category starts off as the least obvious to the ear. To me I hear the difference in the "middle" of the sound. What is going on besides just hearing the notes and the brightness and low end. This quality will also often mature because it has a firm basis in the sound board and its design and materials. Wood matures through its whole life so as the sound board ages the sound should become richer. You might try playing some pianos at a store and talk to the staff about tone quality and sound board construction.
I recommend playing a few pianos that are out of your price range completely to get a sense of what the more affordable pianos are trying to compromise on. You'll want to be able to choose the compromises you make.
To me there's a break point around five of six feet in grand pianos where at that size and up you have a real serious instrument for life. For some of the smaller baby grands you might compare them to higher end uprights because for less money and a lot less living room/music room space you can get quality sound while only sacrificing action.
If you're on a super tight budget you should compare digital pianos. I don't know if anyone makes spinets any more but I can't see spending money on one instead of a high quality digital.
One more difference you can find in piano construction is the implementation of the quiet pedal, sometimes called "una corda". That means "one string" and the classic design for the pedal is that the whole keyboard and hammer action slide to the side so the hammers only hit one string instead of two (in the main range, two instead of three on the high end and glancing on the one string for the low notes). This is another area where you often need a grand body to put in the authentic action but I have seen at least one upright with authentic una corda action.
Enjoy your search! Definitely get out and play as many instruments as you can. Be the customer! Play around, ask questions, and learn. If it's not a lifetime investment this time around, hopefully it will be the next time.
Comment: +1 for all the info. I still feel that there can be compromises, though. One piano may sound better than another to an individual, but they maybe don't get on as well with the action on that piano. Choices! I love the sound of some of the Yamahas I've played, but found the action hard work. But which, out of just two criteria, is more important?
Comment: I think which criteria are most important has to be a personal decision. You're choosing your piano, not mine or anyone else's.
Comment: +1 for "play some pianos you can't afford". IMHO that's a good strategy, because then you get the idea of what to look for. Everybody has a different sense of what they like, and this enables us to understand your personal preferences.
Answer: Some objective differences to listen for:

Dynamic range. On an "entry level" instrument, if you play with enough force you get more mechanical noises, not louder notes. In a really poor instrument you might even break something. The quality of the action also limits how softly you can play without randomly not playing notes at all. In the 6-figure price range, you can hit the keys as hard as you like (i.e. using your whole upper body weight, not just your fingers or arm) and the piano won't have "maxed out".
Inharmonicity. The harmonics of the strings are never exactly in tune with the fundamental. This is more pronounced in the bass register and if the strings are shorter. In extreme cases this can sound like the "beats" caused by out-of-tune octaves, but coming from a single note.
Non-harmonic tones, for example noises from the strings adjacent to the note being played. Bass strings can produce unwanted high-pitched sounds (an octave above middle C, or higher) by vibrating along their length rather than transversely.
Mechanical noises - rattles, buzzes, etc coming from the structure of the instrument independent of the strings. Unless the cause is obvious (like a loose object that shouldn't be inside the instrument!) they are usually bad news and suggest something is seriously wrong (e.g. a cracked soundboard).
Effectiveness of the dampers, and of releasing the sustain (right) pedal.
Overall tone-color. One way to describe this is by analogy with a singer's vowel sounds. You are probably looking for a tone that sounds like "aaaa" or "oh". "Eeee" suggests the tone is too thin. "Oooo" suggests the instrument is worn out, or the hammers have been voiced to soft (and correcting that defect by making them harder is MUCH more difficult than making them even softer).