Relationship in View

Question: I need to have two content type: "book" and "article".
Then I want to make a view that shows the title of the book (which is in the content type book) and the titles of each article (found in the content type article).  Which field should I add to the content type "article" to make sure it is plugged into a certain book? And how do I set the View?
Comment: Are articles part of the Book ? or do you want to link articles to a book ?>
Answer: Although your question seems a bit less detailed than it should be, I assume that you need some way to connect a node type (article) to another node type (book). For this you can use References module or Entity References will be even better.
You can add an entity reference field to book content type. Then, when you create a book, you can select relevant articles. If you want to have two-way relationship (book <--> article) then you can also use this module: drupal.org/project/cer
A good addition can be this module also: http://drupal.org/project/inline_entity_form which allows you to create or select your articles when you create a book.
Then in your view, you can show book's titles as fields.
Add a relationship with your entity refrence field.
Add a field "title" but select relationship you just added.
Group the results by first field (title only)

Relationship in View


Prove the existence of a graph of 15 vertices with some vertices degree given

Question: this is the exercise:
If possible draw a graph with 15 vertices having
3 vertices with degree 4;
4 vertices with degree 3;
6 vertices with degree 2;
0 vertices with degree greater than the ones of the above.
This is the graph I have done by myself:

my questions are,
the graph I have done is right?
and also, since in the given exercise we have the number of vertices and the degree of some of them, is there exists any theorem or algorithm that says to us if a graph with a certain configuration is possibie to draw? It is labourious sometimes to try to draw a graph going by attempts, and without any certainty of its existance.
Can you help me? Thanks!
Answer: The theorem concerning existence you are interested in is probably the following comprehensive result for simple graphs (no loops or multi edges): https://en.wikipedia.org/wiki/Erd%C5%91s%E2%80%93Gallai_theorem.  There is also an algorithmic approach, which another answer addresses, but if what you are after is a sanity check before you start trying to realize the degree sequence with a graph, then Erdos-Gallai should help.
I would just write a simple program to use the theorem as a verifier for a given sequence.  (A possible python implementation is given at the bottom)
But we can also verify by hand of course. In your case, the conditions given determine your degree sequence to be:
$$(4,4,4,3,3,3,3,2,2,2,2,2,2,x,y)$$ where $x \geq y$ and $x,y \in \{0,1\}$.
As you can see from your own work, $(x,y)$ could be $(1,1)$ or $(0,0)$.  But the handshake lemma shows that $(1,0)$ is not possible (sum of degree sequence must be even).
Let's work with your sequence, $$(4,4,4,3,3,3,3,2,2,2,2,2,2,1,1)$$.
First of all, the handshake lemma checks out because the sum of the degree sequence is even.
The partial sums of your degree sequence are
$$(4,8,12,15,18,21,24,26,28,30,32,34,36,37,38)$$
The sequence $(k(k-1))$ for $k=1\ldots n$ is
$$(0,2,6,12,20,30,42,56,72,90,110,132,156,182,210)$$
The $\sum\limits_{i=k+1}^{n}\min(d_i,k)$ summation yields the sequence:
$$(14, 24, 26, 23, 20, 17, 14, 12, 10, 8, 6, 4, 2, 1, 0)$$
Summing the previous two sequences we see that
that the RHS sequence in the theorem is
$$(14, 26, 32, 35, 40, 47, 56, 68, 82, 98, 116, 136, 158, 183, 210)$$
Which is everywhere greater than the LHS sequence of partial sums of the degree sequence
$$(4,8,12,15,18,21,24,26,28,30,32,34,36,37,38)$$
This verifies that a graph exists satisfying your degree sequence, which you now know because you constructed just such a graph!
Possible Python implementation of the code:
<code>
def erdos_gallai(ds):
    n = len(ds)
    lhs = reduce(lambda c, x: c + [c[-1] + x], ds, [0])[1:]
    rhs1 = [k*(k-1) for k in range (1, n+1)]
    rhs2 = [sum([min(ds[i], k+1) for i in range (k+1, n)]) for k in range (0,n)]
    for i in range (n):
        if lhs[i] > rhs1[i] + rhs2[i]:
            return False
    return True
</code>
Comment: Note that $k$ stays fixed over the summation ($i$ varies).
For $k=1$, the summation is $\sum\limits_{i=2}^{15}\min(d_i, 1)=\min(d_2, 1) + \min(d_3, 1) + \ldots + \min(d_{15},1)$.  Since $d_i \geq 1$ for all $i$, this is just $\sum\limits_{i=2}^{15} 1 = 14$
Comment: Sorry I don't understand the summation $\sum\limits_{i=k+1}^{n}\min(d_i,k)$. For example:  if $k=1), min(d_2,1) = min(4,1) = 1$  if $k = 2),  min(d_2,1) + min(d_3,2) = min(4,1) + min(4,2) = 1 + 2 = 3$ from what springs that $14$?
Comment: The degree sequence could also be $(4,4,4,3,3,3,3,2,2,2,2,2,2,0,0)$. That graph is also feasible.
Comment: Oh definitely, good point.  For some reason I thought the question stipulated $0$ vertices with degree $0$.
Answer: Your example is correct. The Havel–Hakimi algorithm is an effective procedure for determining whether a given degree sequence can be realized (by a simple graph) and constructing such a graph if possible.
P.S. In a comment you ask if the algorithm works for trees. In general, if we apply the Havel–Hakimi algorithm to the degree sequence of a tree, the output graph will not necessarily be a tree; for example, $3,3,3,1,1,1,1,1$ is the degree sequence of a tree, but the algorithm does not produce a tree. However, the algorithm can easily be adapted so as to produce a tree whenever that is possible.
Let $d_1,\dots,d_n$ be a sequence of nonnegative integers, $n\gt1.$ If some $d_i=0$ then it's not the degree sequence of a tree, because a tree (with more than one vertex) can't have an isolated vertex. Hence we may assume that all $d_i$ are positive. Moreover, we may assume that $d_1+\cdots+d_n=2(n-1),$ otherwise it can't be the degree sequence of a tree.
Let $G$ be the output of the Havel–Hakimi algorithm. The graph $G$ has $n$ vertices and $n-1$ edges. If it is not already a tree, then it has at least two components, at least one of which is not a tree. Let $H_1,H_2$ be two components of $G,$ and suppose that $H_2$ is not a tree. Let $uv$ be any edge of $H_1,$ and let $xy$ be an edge of $H_2$ which lies on a cycle, so that $H_2-xy$ is connected. If we delete the edges $xy$ and $uv$ and replace them with edges $xu$ and $yv,$ the resulting graph $G'=G-xy-uv+xv$ has the same degree sequence as $G$ but one less component. Repeat this construction until we get a graph with the same degree sequence but just one component, i.e., a tree.
Comment: Note that the Havel–Hakimi algorithm is quite different from the  Erdős–Gallai theorem described in the other answer. The  Erdős–Gallai gives you a yes/no answer but does not show you how to construct the graph.
Comment: I'm editing my answer to include a discussion of trees.
Comment: once completed this algorithm, reading from end to beginning, step by step, is it possible to draw a graph?
Comment: With the [Havel–Hakimi](https://en.wikipedia.org/wiki/Havel%E2%80%93Hakimi_algorithm) algorithm, at each step you choose a vertex and draw some edges. If the input sequence is not "graphic" (meaning there is no simple graph with the given degrees), then at some point it will be carry out the next step. If the sequence is graphic, the algorithm will produce a graph with the given degree sequence.
Comment: in every step, different from the last, I have to add a vertex.
Comment: Is this algorithm valid also for trees?
Comment: No. The graphical sequence $3,3,3,1,1,1,1,1$ is the degree sequence of a tree, but the Havel–Hakimi algorithm applied to this sequence will not produce a tree.
Comment: What I said in my (now deleted) comment is not quite right, because the degree sequence of a tree (with more than one vertex) can't have any zeros.
Comment: Can you give me a practice example about trees using the algorithm? (or also, do you know another algorithm, based on what said above, that it is fully applicable on trees?)
Comment: Here the exercise considering Trees instead: http://math.stackexchange.com/questions/2144759/prove-the-existence-of-a-tree-of-15-vertices-with-some-vertices-degree-given


tf.data, construct a batch with different data?

Question: I want to construct a batch of data with batchsize 16, using tf.data, where [:8] is a kind of data A, [8:16] is a kind of data B.
It is easy to do without tf.data. If use tf.data, the code could be:
def _decode_record(record, name_to_features):
    example = tf.parse_single_example(record, name_to_features)
    return example

dataA = tf.data.TFRecordDataset(input_files)
dataA = dataA.apply(
            tf.contrib.data.map_and_batch(
                lambda record: _decode_record(record, name_to_features),
                batch_size=batch_size)
           )

How to do it next?
I try:
dataB = tf.data.TFRecordDataset(input_files2)
dataB = dataB.apply(
            tf.contrib.data.map_and_batch(
                lambda record: _decode_record(record, name_to_features),
                batch_size=batch_size)
           )
dataC = dataA.concatenate(dataB)

But concatenate is: Append the whole dataset dataB to the end of dataA.
For concatenate, note that name_to_features should be same for dataA and dataB, which means I should pad a lot dummy data.
I don't want to use tf.cond or tf.where to judge different data inside the model_fn of tf.estimator, where it is also very hard to debug.
Answer: One solution is to judge different data:
import tensorflow as tf

data_type = tf.constant([1, 2, 1, 2])
where_index1 = tf.where(tf.equal(data_type, 1))
where_index2 = tf.where(tf.equal(data_type, 2))

data = tf.constant([[10,10],[20,20],[30,30],[40,40]])

data1 = tf.gather_nd(data,where_index1)
data2 = tf.gather_nd(data,where_index2)

sess = tf.Session()

print(sess.run(data1))
print(sess.run(data2))

But this answer just bypass the question somehow.
Answer: You can zip the datasets together, then construct batches from the (dataA, dataB) pairs:
import tensorflow as tf

dataset_1 = tf.data.Dataset.from_tensors(1).repeat(100)
dataset_2 = tf.data.Dataset.from_tensors(2).repeat(100)

dataset = tf.data.Dataset.zip((dataset_1, dataset_2))
dataset = dataset.batch(8)
dataset = dataset.map(lambda a, b: tf.concat([a, b], 0))

Produces
tf.Tensor([1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2], shape=(16,), dtype=int32)
tf.Tensor([1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2], shape=(16,), dtype=int32)
tf.Tensor([1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2], shape=(16,), dtype=int32)
tf.Tensor([1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2], shape=(16,), dtype=int32)
...

Comment: I havn't try it in my real code. Just accept the answer first.


How to convert a string to an image to make a single executable

Question: I created a simple program that creates a window with tkinter. I converted the background image of the canvas into a string so that I can compile it with the main program to create a single executable file.
I used the following code to make the conversion from image to text:
import base64

with open("background.png", "rb") as imageFile:
    str = base64.b64encode(imageFile.read())
text_file = open("background.txt", "wb")
text_file.write(str)
text_file.close()

The problem now is that I can't figure out how to convert the text file back into an image. This the reduced version of my simple window program. I am using Python 3.4 and have imported io and tried using io.StringIO to no avail.
from Tkinter import *
from PIL import ImageTk,Image
import io

...other stuff

backgroundImage=root.PhotoImage(io.StringIO('background.txt')) # This line is my problem
backgroundLabel=root.Label(parent,image=backgroundImage)

...more stuff

Answer: So, you want to have the actual base64 encoded graphic as part of your .py file?  Then you'll need to manually copy the contents of background.txt into your .py file... something like this:
background_image = """\
019248a8b2f129d    # obviously not real data  ;)
c12e0284a8172f0
""".strip()

and then have something like:
# untested
backgroundImage = root.PhotoImage(io.StringIO(base64.decode(background_image)))
...

Comment: @user4261180: Sure can -- import the other file, then reference the string: `import images` ... `...base64.decode(images.background)...`
Comment: I think it would be more convenient to have the base64 encoded graphic as part of a separate `.py` file, to keep the code organized. Can I set `background_image` equal to a string from another `.py` file?
Comment: Thanks, i didn't think of that. A module is in fact just a script. But how does the program know the file path of the string file if it is not a module?


Verificar se o framework 3.5 está instalado na maquina

Question: Tenho de efectuar uma função em C# que verifique se a framework 3.5 esta instalada na maquina mas  sem usar Registry.LocalMachine.OpenSubKey("Software\Windows\Microsoft.NET\..."), pois esta função ter de ser usada em diversas maquinas diferentes todas elas com caminhos diferentes para a Framework.
Answer: A localização física dos arquivos é diferente do Registry. Independente do local onde o .NET foi instalado, uma chave em Software\\Microsoft\\NET Framework Setup\\NDP\\v3.5 será criada.
O método descrito por você irá funcionar.


'TwitterException' with message 'Not Found'

Question: Viewing the syslog, I see errors like for the Twitter Module 7.x-5.11
Do you have an idea of how to solve it?
'TwitterException' with message 'Not Found' in /home/superstar/public_html/sites/all/modules/twitter/twitter.lib.php:164#012Stack trace:#012#0 /home/superstar/public_html/sites/all/modules/twitter/twitter.lib.php(117): Twitter->request('https://api.twi...')#012#1 /home/superstar/public_html/sites/all/modules/twitter/twitter.lib.php(1248): Twitter->auth_request('https://api.twi...',
Answer: This looks like it is failing in a portion of the code that has to do with authorization. Just starting with the simplest explanation, are you sure that your credentials/oauth settings are correct?


how to show dialog window from background service without open application Activity

Question: Hey I am developed Reminder service application. i want to show popup when application background service notify me. without interfering my application activity or open activity display popup and i can cancel/close popup.
Unfortunately i tried many methods but i am unable to perform this event to show dialog with non Activity class. now i don't have any error on my code. it is toast where i initiated view. it shows message waiting for foreground, but i don't want to open activity and show popup. how i can do this possible help me out please. here i am posting my service code.
public class StartAlaramService extends Service {

private WindowManager mWindowManager;
private WindowManager.LayoutParams mParams;
private View mRootView;
private Context mContext = null;
private LayoutInflater mInflater = null;
private View alertView = null;

@Override
public void onCreate() {
    super.onCreate();
    mContext=this;
}

@Override
public IBinder onBind(Intent intent) {
    return null;
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {

    try{

        if (null != mWindowManager) {
            if (null != alertView) {
                mWindowManager.removeView(alertView);
            }
            mWindowManager = null;
            mParams = null;
            mInflater = null;
            alertView = null;
        }

    } catch (Exception ex){
        ex.printStackTrace();
        Log.e("SERVICE ", " Code Error");
    }

    showView();
    return StartAlaramService.START_NOT_STICKY;

}

private void initState() {

    Log.e("SERVICE ", "Intiate View State");

    int LAYOUT_FLAG;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        LAYOUT_FLAG = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
    } else {
        LAYOUT_FLAG = WindowManager.LayoutParams.TYPE_PHONE;
    }

        mParams = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.MATCH_PARENT,
                WindowManager.LayoutParams.MATCH_PARENT,
                LAYOUT_FLAG,
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
                PixelFormat.TRANSLUCENT);

    if (null == mWindowManager) {
        mWindowManager = ((WindowManager) mContext.getSystemService(WINDOW_SERVICE));
    }
}

private void showView() {

    try{

        initState();
        // Create the view
        mRootView = initView();
        // Show the view
        mWindowManager.addView(mRootView, mParams);
        // Do some extra stuff when the view's ready

    } catch (Exception ex){
        ex.printStackTrace();
        Log.e("SERVICE ", " EXCEPTION " + ex.getMessage());
    }

}

private View initView() {

        mInflater = (LayoutInflater) getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        mWindowManager = (WindowManager) mContext.getSystemService(WINDOW_SERVICE);
        LayoutInflater li = LayoutInflater.from(mContext);
        setTheme(R.style.custom_dialog);
        alertView = li.inflate(R.layout.custom_layout_notification, null);

    return alertView;
}

}

SYSTEM ALERT PERMISSION already defined in Manifest.
Comment: of course... but still i have some issue with dialog automatically closed after  sometime.. after completing i will post code .
Comment: Your best shot is to use ForegroundService and display a notification instead of popup window.
Comment: how i can do,  can you provide some reference. i don't want open activity and display popup or dialog window is it possible ?
Comment: you can try a hack approach and make an activity look like a dialog with transparent background and stuff and launch that
Comment: I'm afraid I think it's not possible
Comment: i also think it is not possible and yes @Kushan i tried this but ask me to change client requirement
Comment: but how will the client know that this is not a dialog? make it look like a dialog
Comment: he show me note application and set reminder and kill application. it is  displaying popup dialog with 2 button option dismiss and goto note activity and click on dismiss.  insulting
Comment: @RahulKhurana Worked .. got solution we can open dialog after killing application
Comment: @Dens that's great. Would you mind sharing the link so it would be helpful to others
Comment: Were you able to find solution ?? If yes, can you please share the code. I also want to dialog from a foreground service.
Answer: To Resolve SYSTEM ALERT PERMISSION You have to get permission of DrawOverlays. You can get this permission through following two steps.
Step 1: Put below code in Main activity which check whether permission is given or not if not then then it will ask for permission.
if (Build.VERSION.SDK_INT >= 23) {
        if (!Settings.canDrawOverlays(this)) {
            Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
                    Uri.parse("package:" + getPackageName()));
            startActivityForResult(intent, ACTION_MANAGE_OVERLAY_PERMISSION_REQUEST_CODE);
        }
    }

Step 2: Then after Add below code in onActivityResult.
if (Build.VERSION.SDK_INT >= 23) {
        if (requestCode == ACTION_MANAGE_OVERLAY_PERMISSION_REQUEST_CODE) {
            if (Settings.canDrawOverlays(this)) {

            }
        }
    }

Answer: Maybe you can change the type.
LAYOUT_FLAG = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;

Comment: I found another answer.        [link](https://stackoverflow.com/questions/3599563/alert-dialog-from-android-service/33572463#33572463)
Comment: partially your answer helpful. i forgot to add ettings.canDrawOverlays(this). now i dialog is open. but it is closed after 15 second


Given a cubic function, and its quadratic derivative- can I recover the cubic from quadratic?

Question: Background: I'm trying to learn how to work with cubic and quadratic bezier splines for various drawing libraries, and working through how to approximate a cubic spline with a quadratic spline. It's occured to me that it should be possible to approximate any continuous parametric function with an arbitrary series of interconnected quadratic splines, as long as you have a suitable fitness function for each section.
It has further occured to me that the derivative of any cubic spline is expressible as a quadratic spline. So now I am curious.
if I have an abitrary function f(t);
its derivative f'(t);
and I can approximate f'(t) with a series of quadratic splines...
can I have some way of assuming those quadratics as derivatives of cubics, and directly compute a series of cubics that then approximates f(t) from the quadratics?
is there something wrong with my reasoning here?
(edited for brevity)
(clarification)
I mentioned I was working through how to approximate a cubic spline with a quadratic spline. Let us assume for the purposes of this question that I have already solved this problem, and I have a procedure P which takes any arbitrary function f(t) (which could be a cubic spline, or anything else) with the constraint that we will only approximate over intervals where f'(t) is continuous.
The question therefore is not how do I approximate a cubic with a quadric but, given that I have procedure P, if I apply procedure P to f'(t) to compute a series of quadratic splines, can I use that information to recover a cubic spline approximation of f(t).
From the answers, if I am understanding corrrectly,  I think that I can so long as I can still use f(t) to recover this "integral constant". This is an acceptable solution since what I want is something like a procedure P2 which can take a f(t) and give me a sequence of cubic splines which approximate it.
edit: further, it seems that if we have f(t) and its f'(t) and its f''(t) we could even do a straight forward linear approximation of f''(t) and recover a cubic spline approximation of f(t) by solving for the integral constants in f'(t) and f(t).
neat.
Comment: A spline is a curve that goes through some given data points. The derivative of a cubic function is certainly a quadratic function, but the quadratic won't go through the same data points as the cubic, so I don't see the derivative of a cubic spline being a quadratic spline (for the same data points).
Comment: @talmid no no, you certainly understood my question well enough and you have answered it to my satisfaction.
Comment: @GerryMyerson: The OP seems to be asking whether, if you have a quadratic spline for f'(t), you can find a cubic spline for f(t): this makes sense: if you have a cubic function approximating a set of points given by a curve f(t), then the quadratic function that is its derivative will also approximate the set of points given by the other curve f'(t), though it may not be (AFAICT) the best quadratic approximation unless the cubic function was already exact for f(t).
Comment: @ShreevatsaR You are correct that is what I am asking. Thanks for that.
Comment: @Breton I'm not entirely sure if I understand or can answer your question, but if you don't find my answer satisfactory, I suggest that you un-accept it, as to let others know that this question remains unanswered.
Answer: In general, we can only recover $f$ from $f'$ up to a constant summand, the famous constant of integration. For example, $x^3 + 2x + 4$ and $x^3 + 2x - 5$ have the same derivative, $3x^2 + 2$. Suppose we have a derivative of second degree $f' = ax^2 + bx + c$. Then, $f$ could be any of $\frac{1}{3}ax^3 + \frac{1}{2}bx^2 + cx + d$, with $d \in \mathbb{R}$. So, in order to uniquely recover $f$, we would have to find $d$. We need more information; the derivative is never enough to determine the original function.
If, for example, we know the value of $f$ at any point $x_0$, we can get the original function back, because we could then pose the equation $f(x_0) = \frac{1}{3}ax_0^3 + \frac{1}{2}bx_0^2 + cx_0 + d$ and solve for $d$.
It seems that I have answered the question in the title, which doesn't correspond to the question in the post. I agree with Gerry's comment, anyway, that we can't simply differentiate a cubic spline for a set of points to get to a quadratic spline for the same set of points. This is somewhat related to what I wrote above: a derivative of a function doesn't say much about the exact values of the function at each point, precisely because it "forgets" a constant. So, once we differentiate the cubic spline, we don't know anything about the exact images of any value, so in particular, the derivative doesn't have to pass by the original set of points at all.
Edit:
Ok, so I'm a bit confused about what you're asking, to be honest. I don't know if my answer is relevant, but I'd like to add a third comment regarding the same issue: if we have a spline for $f'$, we won't be able to get a spline for $f$ if we don't have any further information; because the spline for $f'$ is also a spline for $(f+C)'$, with $C \in \mathbb{R}$ any constant, but it's certainly not true that there's one unique spline that works for all such $f+C$. In any case, you need more information about $f$, something that goes beyond what you can deduce from $f'$.


Como extrair um dado de um array em php

Question: Boa pessoal, bom esse meu pequeno script para postagens verifica se ja existe, se sim ele nao grava, se nao ele grava no bd. Quero colocar nele um sistema de curtida, entao eu criei uma tabela mas para eu indentificar a postagem e tal eu preciso do ID do post.. Até ai tudo certo.. Se vc olhar la no "print_r($idcheck);" ele me retorna um array com o id e o post, mas eu presiso extrair o id em forma de string, mas pela minha falta de conhecimento até ag não consegui resolver isso..
Array
(
    [0] => Array
        (
            [id] => 62
            [conteudo] => jjjjjjjjjjjjjjjjjjj
        )
)
preciso só do id, mas quando eu coloco echo $idcheck["id"] ou idcheck[0] da erro..

<code>        $status = 1;

        if( isset( $_POST['publicar'] ) ){

            date_default_timezone_set('America/Sao_Paulo');
            $form['data']       = date('Y-m-d H:i:s');
            $form['conteudo']   = str_replace( '\r\n', "\n", DBEscape( trim( $_POST['conteudo'] ) ));
            $form['status']     = DBEscape( strip_tags( trim( $status ) ) );
            if( empty( $form['conteudo'] ) )
                echo'';
            else {

                $dbCheck = DBRead( 'posts', "WHERE conteudo = '". $form['conteudo'] ."'" );

                if( $dbCheck )
                    echo '<script>alert("Desculpe, mas já contaram esse segredo!");</script>';
                else {

                    if( DBCreate( 'posts', $form ) ){
                        $idcheck = DBRead( 'posts', "WHERE conteudo = '". $form['conteudo'] ."'", 'id, conteudo');
                        var_dump($idcheck);
                        echo '<pre>';
                        print_r($idcheck);
                        echo '</pre>';
                        //echo '<script>document.getElementById("myP").style.visibility = "visible";</script>';
                        echo '<script>alert("Seu segredo foi postado com sucesso!");</script>';
                    }
                    else
                        echo '<script>alert("Desculpe, ocorreu um erro...");</script>';
                }
            }

        }
?>
</code>
Answer: Tente o seguinte:
<code>$id = (string)$idcheck[0]['id'];
</code>
Pelo que vi, essa variável $idcheck é um array multidimensional.
Também sugeri forçar o valor para string, para certificar de que a variável $id receberá o valor como string.
Comment: deu certoo!! valeu.. Eu tambem encontrei outra forma, fazer um foreach dentro de outro
Comment: Dá certo também fazer dois laços... mas se a variável é pequena dessa maneira e não contém muitos dados, acessar o valor diretamente pode ser melhor. De qualquer forma, boa sorte!
Comment: Valeu, ajudou muito!

Como extrair um dado de um array em php


Hartshorne Proposition 9.5

Question: The Proposition is that : Let $f:X\longrightarrow Y$ be a flat morphism of schemes of finite type over a field $k$. For any point $x\in X$, let $y=f(x)$. Then
$\dim_x(X_y)=\dim_x(X)-\dim_y(Y)$. Here for any scheme $X$ and any point $x\in X$, by $\dim_x(X)$, we mean the dimension of the local ring $\mathcal{O}_{x,X}$.
They begin the proof as follows :
First we make a base change $Y'\longrightarrow Y$ where $Y'=\textrm{Spec }  \mathcal{O}_{y,Y}$ and consider the morphism $f':X'\longrightarrow Y'$ where $X'=X\times_{Y} Y'$. Then $f'$ is also flat, $x$ lifts to $X'$ and the three numbers are the same.
What is meant by : $x$ lifts to $X'$. It is not the inverse image, because the inverse image could contain  more than one element. What does it mean?
Thank you in advance!
Comment: I do not have the book in front of me, but in general lifts need not be unique. One can still choose a lift.
Comment: Think about $x$ as being a morphism from Spec of some field to $X$. To say it lifts to $X'$ means that there is a morphism to $X'$ such that the obvious triangle commutes.
Comment: How do we think of $x$ as a morphism?
Comment: @poorna Consider a scheme X. For a scheme T the set of scheme morphisms Hom(T,X) is named the set of points of X with values in T (EGA I,3.5).

This concept generalizes the intuitive notion of a point of a scheme: In case T=Spec(A) with a local ring A the morphisms Spec(A)⟶X correspond bijectively to the local morphisms $\mathscr O_{X,x}⟶A$ with x∈X. Notably for A=K a field we obtain

Hom(Spec K,X)={k(x)⟶K:x∈X},

i.e. the points of X with values in Spec K, the K-valued points of X, are the points x∈X - taken in the topological sense - with K an extension field of the residue field k(x).
Answer: @poorna The answer to your question follows from the universal property of the fibre product:
We have the fibre product
$$\begin{array}
X\ \ \ X' & \stackrel{}{\longrightarrow} & X \\
\ \ \downarrow{f'} & & \downarrow{f} \\
Spec(\mathscr O_{Y,y}) & \stackrel{j_y}{\longrightarrow} & Y
\end{array}
$$
Consider the local ring $A = Spec(\mathscr O_{X,x})$. Due to the universal property of the fibre product the commutative square defining in a topological sense $x$ and $y=f(x)$
$$\begin{array}
XSpec \ A & \stackrel{j_X}{\longrightarrow} & X \\
\ \ \downarrow{} & & \downarrow{f} \\
Spec(\mathscr O_{Y,y}) & \stackrel{j_y}{\longrightarrow} & Y
\end{array}
$$
maps into the fibre product via a unique morphism
$$Spec \ A  \stackrel{j_{x'}}{\longrightarrow} X'$$
Referring to my previous comment, the latter morphism is a point of $X'$. It lifts the 'point' $x$, i.e. $Spec \ A \stackrel{j_X}{\longrightarrow} X$, to $X'$.
Comment: If you consider points the elements of the topological space$|X|$ underlying a scheme $X$ then you have the point $j_x(\mathcal m_A) \in |X|$ and its lift $j_{x'}(\mathcal m_A) \in |X'|$. I assume you think along these lines.

When refering to the more general concept from EGA the morphism $j_x: Spec A \longrightarrow X$ is a point of $X$ with value in $Spec A$ and $j_{x'}: Spec A \longrightarrow X'$, the point of $X'$ with value in $Spec A$, is a lift of $j_x$.
Comment: Thank you! I am still not clear actually. We get the unique morphism $j_{x'}:Spec\ A\longrightarrow X'$ which factors through $X$. Do they refer to this morphism as the lift of $x$. Or is it the image of the $\mathcal{m}_x$, the unique closed point of $Spec\ A$ in $X'$
Comment: I tried working along these lines, but I am still unable to understand, why the three numbers are the same. In particular, if $x'\in X'$ is the lift of $x$, why is $dim_{x'}X'=dim_x X$?
Comment: @gradstudent I am also having serious difficulty understanding the proof. There is a much easier proof in Algebraic Geometry I -Ulrich Gortz, Torsten Wedhorn, Corollary 14.95, page-464 (with a different hypothesis)

Hartshorne Proposition 9.5


The Least Squares Assumption $E[u_i|X_i] =0$

Question: Assume the following linear relationship:
$Y_i = \beta_0 + \beta_1 X_i + u_i$, where $Y_i$ is the dependent variable, $X_i$ a single independent variable and $u_i$ the error term. According to Stock & Watson (Introduction to Econometrics; Chapter 4), the first least squares assumption is $E[u_i|X_i]=0$.
The following figure shows the estimated relationship:

Obviously, the relationship between $Y$ and $X$ is a nonlinear. As a result, the average of the estimated residuals $\widehat{u}_i$ is not necessarily zero for each $X_1$ value. I have two questions:
(i) Does this imply that $E[u_i|X_i] \neq 0$? If not, why is this the case?
(ii) Is the OLS estimator of $\beta_1$ always biased, if the population relationship is nonlinear. Why is this the case? What is the formal condition?
Comment: A question to ponder upon: if the model is misspecifed, how could you define unbiasedness of parameter estimators?
Answer: The modeling assumption about $u_i$ in linear regression is $E(u_i)=0$ (you don't have to condition on $X_i$). Now the scatter plot you showed indicated that the function might involve a quadratic term in $X_i$ and hence the model that is linear in $X$ is misspecified.  $E(U_iX_i)$ maybe 0 or it could be some other value when the model is misspecified.  Because of the missing term(s), the slope parameter for $X$ is biased.  I would suggest including a quadratic term in $X$ and seeing how the model and residuals look.
Answer: If the true population regression function is nonlinear but the estimated regression is linear, then this functional form misspecification makes the OLS estimator biased. This bias is a type of omitted variable bias in which the omitted variables are the terms that reflect the missing nonlinear aspects of the regression function. For example, if the population regression function is a quadratic polynomial, then a regression that omits the square of the independent variable would suffer from omitted variable bias. To sum up, the estimator of the partial effect of a change in one of the variables will, in general, be biased.
Answer: Transformation of the original variables may be in order. What one wants to see ideally is not only linearity, but also either homoscedasticity and/or normal distribution of residuals. Try taking logarithms of the IV, other transformations include in general both or either axis taking of logarithms, roots and powers (e.g., square roots), exponentiation, reciprocals, and offsets of these ($x-k$, or $y-k$ where k is some constant).


Does the coin have to flip in NFL rules?

Question: In a 2016 NFL playoff game between the Green Bay Packers and the Arizona Cardinals, the game went to overtime. On the overtime coin flip, the referee threw the coin in the air and it didn't flip. The Packers, who had lost the toss, convinced the referee to flip the coin again (with no change in the outcome). If the result had changed, I imagine this would have caused considerable controversy. Is there actually a rule in the NFL rulebook that the coin must flip over at least once for the toss to be valid?
Answer: As a Packer fan I remember the situation and recall that at the time this happened there was no rule demanding the coin to actually flip.
Here is  a video of Dean Blandino VP of officiating at the time explaining the situation, that by rule the coin didn't actually have to flip, but common sense dictated that it should in order for the flip to be fair. And so Clete Blakeman the referee did the right thing to redo the coin toss.
Fun fact, after the game Aaron Rodgers mentioned he wanted to switch to heads for the second toss, but the referee did the second flip before he had the chance to choose a coin side again. After the 2015-2016 season, the NFL updated its rules to explicitly handle such situation. Section 2, Article 2 (coin toss) states:

If the coin does not turn over in the air or the toss is compromised in any way, the Referee shall toss it again. The captain's original call may not be changed.

Well, it also turned out that they heard what Rodgers said after the game. The new rule also states that the captain's choice stands, thus in case of a re-flip, the teams cannot change the side of coin picked before the first toss.


Chamar funções em C a partir do R

Question: Estou precisando otimizar algumas funções que estão na linguagem C, porém utilizando os pacotes de algoritmos genéticos no R.
Existe alguma forma de chamar funções de C no R?
Em matlab eu sei que existe essa possibilidade através de mex. No R tem algo parecido?
Comment: Olá Bruno. Eu editei a sua pergunta pra alterar o título de forma a deixá-lo mais condizente com a pergunta. Acho que assim ele deve atrair a atenção correta. Se você não gostar da edição, pode alterá-la você mesmo ou até mesmo desfazê-la.
Comment: O meu Google devolve [Using R — Calling C Code 'Hello World!'](http://mazamascience.com/WorkingWithData/?p=1067) que parece explicar bem como ligar as duas linguagens (notaL eu nao sei R, nem experimentei nada desse artigo).
Comment: Bruno, a não ser que você tenha dúvidas mais específicas sobre a interface entre as linguagens, a resposta para a sua pergunta atualmente é "Sim: `.C`, `.Call` e `External`", que podem ser vistas no link postado pelo pmg e também no [livro do Hadley Wickham](http://adv-r.had.co.nz/C-interface.html), ambos em inglês.
Comment: Obrigado @Luiz Vieira , você saberia me ajudar?
Comment: Por nada. Eu conheço pouco do R, então acho que não consigo ajudar. Mas olhei brevemente o artigo que o @pmg postou pra você e lá parece ter muita informação útil. Pode ir te ajudando até alguém que entende mais postar uma resposta aqui. Se você mesmo descobrir como faz com base nesse artigo, por favor poste você mesmo uma resposta aqui (pois a ideia é manter conhecimento que ajude não apenas a você, mas a outros usuários futuros que podem ter a mesma dúvida). :)
Comment: se você quer exemplo de código, veja o pacote data.table
Answer: Acho que atualmente a forma mais limpa e mais fácil de integrar códigos de C++ (ou C no seu caso) é usando o pacote Rcpp (link do CRAN) (site do pacote aqui).
Com o Rcpp você pode definir uma função na própria seção usando a função cppFunction:
library(Rcpp)
cppFunction('int soma(int x, int y){
            int soma = x+y;
            return soma;
            }')
soma(1,2)
[1] 3

Ou você também pode definir suas funções em um arquivo .cpp e usar a função sourceCpp. Você vai especificar no cabeçalho do arquivo que você está usando o Rcpp #include <Rcpp.h>, using namespace Rcpp; e em seguida definir suas funções. Se você estiver usando o RStudio, ao pedir para criar um novo arquivo c++ ele já te dá a estrutura mínima do arquivo.
#include <Rcpp.h>
using namespace Rcpp;

// This is a simple example of exporting a C++ function to R. You can
// source this function into an R session using the Rcpp::sourceCpp
// function (or via the Source button on the editor toolbar). Learn
// more about Rcpp at:
//
//   http://www.rcpp.org/
//   http://adv-r.had.co.nz/Rcpp.html
//   http://gallery.rcpp.org/
//

// [[Rcpp::export]]
NumericVector timesTwo(NumericVector x) {
  return x * 2;
}

// You can include R code blocks in C++ files processed with sourceCpp
// (useful for testing and development). The R code will be automatically
// run after the compilation.
//

/*** R
timesTwo(42)
*/

Bom, com isso já dá para você começar a tentar  passar o código para o R. Para mais detalhes eu recomendo o livro do Hadley para uma introdução mais geral e os vignettes do pacote e o livro do Dirk para mais detalhes sobre o Rcpp.
Comment: Perfeito @Carlos Cinelli , muito bom seu post! Me ajudou bastante.

Chamar funções em C a partir do R


Selecionar e calcular colunas - SQLite

Question: Olá...
<code>//selecionar valores da tabela:

    public Cursor IMC(){
            Cursor cursor;
            String[] campos =  {"SELECT (peso/(altura*altura)) FROM medidas WHERE codigo = (SELECT codigo FROM medidas ORDER BY codigo DESC LIMIT 1)"};

            db = banco.getReadableDatabase();

            cursor = db.query("medidas", campos, null, null, null, null, null, null);

            if(cursor!=null){
                cursor.moveToFirst();
            }
            db.close();
            return cursor;
        }
</code>
No SQLExpert o SELECT buscando só uma coluna ou uma operação simples como peso+altura dá certo, porém essa no código acima retorna 0. Já constatei que está criando o banco e salvando os valores.
<code>//mostrar o resultado do SELECT em um TextView
public void resultadoIMC() {

                BancoController crud = new BancoController(getBaseContext());
                Cursor cursor = crud.IMC();

                TextView tv = (TextView) findViewById(R.id.txtresultado_imc);

                tv.setText(cursor.getString(cursor.getColumnIndex(String.valueOf(0))));

            }
</code>
Neste código não retorna valor nenhum, mesmo alterando o SELECT para buscar o valor de uma única coluna (No SQLExpert o SELECT funciona).
Alguém tem alguma ideia do q está errado???
Answer: <code>//você precisa abrir a conexão antes
db = banco.getReadableDatabase();

//salvando a query antes. Eu NÃO conferi se a query está correta
//só coloquei a maneira certa de fazer um SELECT
String query =  "SELECT (peso/(altura*altura)) FROM medidas WHERE codigo = (SELECT codigo FROM medidas ORDER BY codigo DESC LIMIT 1)";

//usando rawQuery, que é o correto
Cursor cursor = db.rawQuery(query,null);
</code>

Selecionar e calcular colunas - SQLite


Como validar campos com o Flutter?

Question: Tenho uma tela que precisa validar 2 campos. Caso uma ou ambas receba valores errados, me retorna um snackbar com a mensagem do erro. Porém, gostaria de deixar o campo em vermelho, assim que retornar a snackbar, mas, não consigo fazer esse retorno.
TextFormField(
                                // ignore: deprecated_member_use

                                controller: _emailController,
                                decoration: InputDecoration(
                                    prefixIcon: Icon(
                                      Icons.mail_outline,
                                      color: greenColor,
                                    ),
                                    border: OutlineInputBorder(

                                      borderRadius: BorderRadius.circular(12),
                                    ),
                                    labelText: 'E-mail'),

                                validator: (email) {
                                  if (!emailValid(email))
                                    return _errorSnackBar(errorEmail);
                                  return null;
                                },
                              )

Agora com apenas uma mensagem de erro no return a barra destorce completamente
Answer: O validator do TextFormField não serve apenas para deixar a barra vermelha, ele fica menor porque obrigatoriamente você deveria informar uma mensagem de erro no próprio componente e não mostrar uma SnackBar, esse é o comportamento original.
Você retorna null se a validação passou e retorna o erro, uma String, caso não passou.
validator: (String value){
if(value.isEmpty) return "O campo está vazio!";
else return null;
}
Você tem duas opções:

Modo padrão, mostrar apenas o erro no próprio componente, removendo a SnackBar.

Usando validação externa, colocando seu TextFormField dentro de um Container e dando um border pra ele, trocando dinamicamente a cor desse border caso tenha um erro, isso é mais trabalhoso porque praticamente você fará a funcionalidade do TextFormField na mão.

Como validar campos com o Flutter?


Permutations and Groups in Abstract Algebra

Question: Prove:  If $G$ is a group and $a \in G$, show that the two functions $l_a(x) = a * x$ and $r_a(x) = x * a$ are both permutations of $G$.
I know the definition of permutation is a function that maps from a set to itself that is both one to one and onto. This question that our professor has given us seems to be out of left field because we haven't been over mappings at all. Besides assuming the hypothesis of course, I'm not exactly sure where to begin on this problem. Any help would be appreciated.
Answer: Let $a\in G$. You know by the definition of a group that every element has an inverse. Now define $l_a:G\to G$ by $l_a(x)=ax$. Assume $l_a(x)=l_a(y)$ for $x,y\in G$. Then $ax=ay$ and by multiplying both sides from the left side by the inverse $a^{-1}$ you get $x=y$. So $l_a$ is one to one. Now take any $y\in G$. Then $l_a(a^{-1}y)=aa^{-1}y=y$, so $l_a$ is also onto. Now do the same thing for $r_a$.
Answer: Hint: If $S$ is a set, $f : S\to S$ is a permutation if and only if $f$ admits an inverse function $g : S\to S$ such that $f\circ g = \operatorname{id}_S = g\circ f.$ Can you find inverses to your functions $l_a,r_a : G\to G$?


Split string into multiple string separated

Question: I have a string "What is Facebook?.| A. Website B. Internet C. Social Network D. Game"
How can I split and stored that string into 5 string separated in C# programming? I try to split with my code but the result I have just a mess.
What result I expect is that after split, I have 5 string variable separated like:
string A = "What is Facebook?"
string B = "A. Website"
string C = "B. Internet"
string D = "C. Social Network"
string E = "D. Game"

That is my code:
String value = "What is Facebook?.| A. Website B. Internet C. Social Network D. Game";
Char delimiter = '|';
String[] substrings = value.Split(delimiter);

Comment: You need another split to split the second part. Have you tried anything for it? You can try with regex.
Comment: You may need to write a RegExp, like this one: `^(.*)\|.*(A\..*)(B\..*)(C\..*)(D\..*)$`
Comment: Sometime, no matter what you do, this split is going to fail.
Comment: If you can change the pattern.... Best do so.. Just add a `|` at the beginning of each section
Comment: What precisely were you expecting as output of your "split"?  Currently you'd only get two strings if you split on the '|'.
Comment: @AndreyNasonov saviour
Comment: @GiladGreen I try your suggest and get the result match with what I want. But how to stored the output string into 5 string variable separated?
Comment: @AndreyNasonov I do like you said String pattern = "^ (.*)\|.* (A\..*)(B\..*)(C\..*)(D\..*)$"; but C# return an error: "Unrecognized escape sequence"
Comment: [Edit](https://stackoverflow.com/posts/47293010/edit) your question to show us what you are doing. The result of the regex will include the five separated strings in the `Groups` property. To put Andrey's regex into a C# string you need to precede it with `@`.
Answer: You can split by \|?\s+(?=[A-Z]\.) :
string[] substrings = Regex.Split(value, @"\|?\s+(?=[A-Z]\.)");

Comment: It's return nothing :((
Comment: I see. Your demo output fine. But not exactly my result I expect. You just print out only once string value, but what I need is output separate value like: string A = "What is Facebook?" and string B = "A. Website" and string C = "B.Social media" and etc.... Hope u can help me solve this problem. By the way, thanks so much Slai.
Comment: ahhh yeah yeah! I see! It's work fine. You use string.Join() method so the result output all value. If I just want each value separated, so I just do substring[0] and so on.... Thanks @Slai !!! U just save me from the hell ~~
Answer: If it were me, I would create a simple class that holds a question and the possible answers. This way, you can parse your string into a class which can do other fancy things, like display itself correctly, and could contain a property that indicates the index of the correct answer (so you can compare the user's selection with the correct index).
For example, this class has a static Parse method that takes in your string and returns an instance of the class. It also overrides ToString so that it displays the Question and Answers in a nice way:
public class QuestionAndAnswers
{
    public string Question { get; set; }
    public List<string> Answers { get; set; }
    public int IndexOfCorrectAnswer { get; set; }

    public static QuestionAndAnswers Parse(string qaInput)
    {
        if (qaInput == null) throw new ArgumentNullException(nameof(qaInput));

        var result = new QuestionAndAnswers();

        var parts = Regex.Split(qaInput, @"\|?\s+(?=[A-Z]\.)");

        result.Question = parts[0].TrimEnd('.');
        result.Answers = parts.Skip(1).ToList();

        return result;
    }

    public override string ToString()
    {
        return $"{Question}\n  {string.Join("\n  ", Answers)}";
    }
}

Then it can be use something like this:
private static void Main()
{
    var input = "What is Facebook?.| A. Website B. Internet C. Social Network D. Game";

    var qa = QuestionAndAnswers.Parse(input);

    Console.WriteLine(qa);

    Console.WriteLine("\nDone!\nPress any key to exit...");
    Console.ReadKey();
}

Output
Comment: Yes I see. Many developers (of course, genius !) here help me so much. But both of you just return one result that output only one string, when I really want the 5 string variable separated! Please help me ~~
Comment: The five strings are separated. One is stored in the `qa.Question` property, and the other 4 are stored in a `List` in the `qa.Answers` property.
Comment: yaya I see ^^ I just try to run again and solved out the expect my output.
Answer: Like @Andrey Nasonov's comment said, this is a good application for regular expressions.
The following will get you your split, though I feel like there must be a better way to represent \s(\w.[\w\s]+ repeating four times.
Regex splitter = new Regex(@"(.*)\|\s(\w\.[\w\s]+)\s(\w\.[\w\s]+)\s(\w\.[\w\s]+)\s(\w\.[\w\s]+)");
string[] results = splitter.Split(input);

stringA = results[0];
stringB = results[1];
stringC = results[2];
stringD = results[3];
stringE = results[4];

Comment: It's return an error "Index was outside the bounds of the array." at line string B = results[1] and corrupt the program without nothing result I expect.
Comment: I just double-checked and it runs as expected for me. Make sure you copied the Regex splitter = new ...... line verbatim. You might also check to see exactly what strings are in results after the split by using a breakpoint and the watch window (I'm assuming you're using Visual Studio).
Comment: Yes do I, but when it running, it make an error at line string B and corrupt everything. I also try to debug and sound like it out of range of array or something that I can't understand!
Comment: If it's giving you an out of range error on line B, that means results.length must equal 1, and it doesn't like you trying to access the second index (because that index doesn't exist). Sounds like it isn't splitting correctly.


How to pass value to popup window using codeigniter?

Question: I know that you can use anchor_popup() to open up a new window in codeigniter, but what i cant figure out is how to pass values using that.
Here is the code i am using,
$attr = array('width'=>'800','height'=>'700');
echo anchor_popup('friends/'.$uid.'/'.$suid.'','add as friend',$attr);

Now i get a popup window which links to friends/34/34 where friends is a controller and rest are values which i want to give to my controller. but iam getting an error 404,
404 Page Not Found
The page you requested was not found.
I am using uri segment to grab the values.
Could any tell me what i am doing wrong?
Answer: the link friends/34/34/ is looking for a controller called "friends" and a method called "34", hence why it can't be found.
If your friends controller has no other methods, then change the link to this:
echo anchor_popup('friends/index/'.$uid.'/'.$suid,'add as friend',$attr);
else, add the appropriate method.


For loop and by function error with R

Question: I everybody !
I'm discovering the R world for my PhD work and I have several problems when I want to implement loop to simplify analysis.
My data frame is :
'data.frame':   3581 obs. of  8 variables:
 $ Date          : Factor w/ 7 levels "03-03-17","10-02-17",..:
 $ Experimentator: Factor w/ 9 levels "BURLET","DECHAUD",..:
 $ Origin        : Factor w/ 3 levels "FRANCE","JAPAN",..:
 $ City          : Factor w/ 6 levels "MONTPELLIER",..:
 $ Lineage       : Factor w/ 27 levels "L21","L22","L26",..:
 $ Sex           : Factor w/ 2 levels "Female","Male":
 $ ccr           : int  1183 1813 1866 1745 1210 1463 2477 1506

The first 6 are my factors and the last my quantitative variable.
I need to work with several factors in same time, then when I want to do a shapiro.test for example :
with by:
by(data$ccr, c(data$Date, data$Sex, data$Lineage), shapiro.test() )
Error in tapply(seq_len(3581L), list(`c(data$Date, data$Sex,
data$Lineage)` = c(2L,  : the arguments must have the same length

With a for loop it's hard to me so I tried to write :
for(sex in levels(data$Sex)){
  for(date in levels(data$Date)){
    for(lineage in levels(data$Lineage)){
      shapiro.test(data$ccr[,lineage])
    }
  }
}

bu I don't know how to increment my loop...
Thank for any help !
Comment: In `by`, the grouping variables (`INDICES`) should be "a _`list`_ of factors". Compare `by(mtcars, c(mtcars$vs, mtcars$am), function(dat) shapiro.test(dat$mpg))` (your case), with `by(mtcars, list(mtcars$vs, mtcars$am), function(dat) shapiro.test(dat$mpg))`.
Comment: You should at least tell us which package(s) you are using here.
Comment: you need for all 3581 records?
Comment: Great !!

Thank for the by() function, it was simple ! and efficient, now i just need to learn how save result in a file but it's great !

The for loop doesn't work :

Error in ccr_global $ ccr [, lineage]: incorrect number of dimensions
The by solution seem to be the best choice !
Answer: for loops are not necessary to do this in R. I don't think using the by() function is the best way either. The easiest way would be to use the dplyr infrastructure :
library(dplyr)
data %>%
  group_by(Sex, Date, Lineage) %>%
  filter(n() > 2)  %>%
  summarise(shapiro_pvalue = shapiro.test(ccr)$p.value,
            shapiro_stat = shapiro.test(ccr)$statistic)

filter(n() > 2) handles the fact that shapiro.test needs at least 3 samples to be computed.
(Credits to Rui Barradas for the good reproducible example !)
dplyr is  quite different from base R, but if you are starting your PhD and need to use R, it is worth using it if you want to make your life simpler.
Answer: You can use index to run like this
index <- 1

while(index != 3582){
  for(sex in levels(data$Sex)){
    for(date in levels(data$Date)){
      for(lineage in levels(data$Lineage)){
        shapiro.test(data$ccr[,lineage])
        index <- index + 1
      }
    }
  }
}

Answer: You can do it using base R but instead of by use split/lapply.
First, some fake data, with it's name changed to dat since data already is an R function.
set.seed(9235)    # make it reproducible
n <- 3581
d <- seq(as.Date("2017-01-01"), as.Date("2017-12-31"), by = "day")
d <- format(d, "%d-%m-%y")
dat <- data.frame(
    Date = sample(d, n, TRUE),
    Experimentator = sample(LETTERS[1:9], n, TRUE),
    Origin = sample(LETTERS[11:13], n, TRUE),
    Lineage = sample(paste0("L", 1:27), n, TRUE),
    Sex = sample(c("F", "M"), n, TRUE),
    ccr = sample(3000, n, TRUE)
)

Now the code. Note that shapiro.test only accepts data with number of non-missing values must be between 3 and 5000.
sp <- split(dat$ccr, list(dat$Date, dat$Sex, dat$Lineage))
sp <- sp[which(sapply(sp, function(x) length(x) > 2))]

result <- lapply(sp, shapiro.test)

For loop and by function error with R


Putting two divs next to each other with borders in bootstrap 3?

Question: I'm trying to align some text next to twitter's button, and have them all line up with borders. Unfortunately, the text div shrinks and floats to the upper left with its borders. The button seems fine because bootstrap properly aligns everything. But both the text and button divs suffer from padding (or margin) issues in that the borders won't line up to form a rectangle (with a border line in between the text and button div also).
This is what I'm aiming for:

The grey 1px borders are supposed to be equal all around, but I had trouble with my touchpad.
This is what I have so far:

                                                 Text!

                                                Button!

CSS:
 .textdiv {
         border-top: 1px solid #DDDDDD;
         border-left: 1px solid #DDDDDD;
         border-right: 1px solid #DDDDDD;
         border-bottom: 1px solid #DDDDDD;
         margin: 0 auto;
    }
    .btndiv {
         border-top: 1px solid #DDDDDD;
         border-bottom: 1px solid #DDDDDD;
         border-right: 1px solid #DDDDDD;
    }
    .mydiv {
         width:30%;
    }

Comment: http://jsfiddle.net/ub4TC/36/
Answer: HTML

Text!

  Button!

CSS
.row {
    width:250px;
    margin:0px auto;
    border:1px solid black;
    height:75px;
    background-color:#f2f2f2;
}
col-sm-6 {
    width:200px;
    margin:0px auto;
    text-align:center;
}
div.textdiv {
    border:1px solid #9a9a9a;
    background-color:Aqua;
    padding:5px;
    color:black;
    font: bold 16px arila;
    width:100px;
    float:left;
    text-align:center;
    margin-left:10px;
    margin-top:25px;
    margin-right:3px;
}
div.col-sm-6 a {
    border:1px solid #9a9a9a;
    margin:0px auto;
    background-color:Aqua;
    color:black;
    text-decoration:none;
    font: bold 16px arila;
    width:100px;
    padding:5px;
    margin-left:3px;
    margin-right:10px;
    margin-top:25px;
    float:right;
    text-align:center;
}

Working Fiddle
Output:
Answer: I've just made some updates in the way things get their padding. Please take a looke at the followingo fiddle:
http://jsfiddle.net/WNPRA/1/
I created a new class to handle some problemns and updated the css to be more neat.
div.no-padding {
    padding: 0;
}

div.textdiv {
    padding: 7px 12px 7px 12px ;
    text-align: center;
}

Please, do not consider the col-xs-6 classes I added. They are just to make things work on fiddle.
Comment: @DMelo The textdiv and the btndiv aren't next to each other though?
Comment: I'm so sorry. Pasted the wrong link. Look this one, please: http://jsfiddle.net/WNPRA/1/
Comment: @DMelo Thanks! Is there any way to have the textdiv auto resize its width if I have a longer text like "Text!Text!Text!Text!Text!Text!Text!"? Right now it spills into the other div if the text gets longer or grows in height if the text is a long sentence.
Comment: does .mydiv needs to be 30% ?
Comment: @DMelo Oh, no it doesn't need to be 30%. But the entire thing should be as the sum of the width of btndiv and textdiv. If the text is very little in both divs, then `mydiv` should be small. I added the 30% because the two divs kept separating, but I want them side-by-side with borders like how you have it right now.
Comment: @user21398, this may not be so beautyfull, since I took some grid classes off, but it worked: http://jsfiddle.net/WNPRA/2/
Comment: @DMelo Thanks so much! One last thing. I don't see the border on the left side of the textdiv. I tried adding this line to `div.textdiv`: `border-left: 4px solid #f00`, but it still doesn't show
Comment: remove the .row class from the upper div or try  `div.row{ margin-left: 0px; }` http://jsfiddle.net/WNPRA/3/
Answer: Here is one idea for you:
http://jsfiddle.net/panchroma/y79gm/
The html is almost exactly the same as yours except I wraped your textdiv block in .btndiv class ( to provide the border), added the class of btn to .textdiv so that it inherits the same bootstrap styling as the btn link, and I added
.textdiv{
cursor:default;
}

to force the cursor to stay as the default arrow when over the text block.
Good luck!


If $\operatorname{char} K =p$ and $[F:K]$ is finite and not divisible by $p$, then $F$ is separable over $K$

Question: Consider the following question,

If $\operatorname{char} K =p$ and $[F:K]$ is finite and not divisible by $p$, then prove that $F$ is separable
over $K$.

I am really sorry but I am not able to use the given information to solve the problem. I am not able to deduce anything using $p$ doesn't divides $[F:K]$ .
It is my humble request to you to kindly give some hints.
I am following Abstarct Algebra by Joseph Gallian.
Comment: Hint: The degree of an irreducible inseparable polynomial always is a multiple of $p$
Comment: @leoli1 Can you please give reference for proof of above statement?
Comment: See the answer by reuns
Answer: Assume that $F/K$ is not separable.
There is $a\in F$ with $K$-minimal polynomial $f\in K[x]$ such that $K(a)/K$ is not separable, ie. $f'(a)=0$.
But then $f(a)=f'(a)=0$ means that $\gcd(f,f')\ne 1$, if also $\gcd(f,f')\ne f$ we get that $\gcd(f,f')$ divides $f$ which isn't irreducible. Therefore $f'(a)=f(a)=0$ and $f$ irreducible implies $\gcd(f,f')=f$ which implies $f'=0$ ie. $f \in K[x^p]$.
Whence $p$ divides $\deg(f)=[K(a):K]$ which divides $[F:K]$.
Comment: In 2nd paragraph of ypur answer, I think you meant  that $\gcd(f,f')\ne f$ divides  f which implies f isn't irreducible , instead of "which isn't irreducible". Am i right?
Comment: In the next line, you wrote that f is irreducible. How did you deduced that. f is minimal polynomial not necessary irreducible. Kindly explain?
Comment: "Irreducible $\in E[x]$ with $a$ in its roots" is the definition of "minimal polynomial of $a$ over $E$".


SQL Full Outer Join with Multiple Tables

Question: First I have 4 Tables

Table0, Columns: num, desc
Table1, Columns: num, qty1
Table2, Columns: num, qty2
Table3, Columns: num, qty3
Table4, Columns: num, qty4

(not all num have values in qty1 or qty2 or qty3 or qty4, therefore I need a full join)
and my query:
SELECT Table0.num, SUM(Table1.qty1 ), SUM(Table2.qty2 ), SUM(Table3.qty3 ), SUM(Table4.qty4)
FROM Table0
FULL OUTER JOIN Table1 ON Table0.num = Table1.num
FULL OUTER JOIN Table2 ON Table0.num = Table2.num
FULL OUTER JOIN Table3 ON Table0.num = Table3.num
FULL OUTER JOIN Table4 ON Table0.num = Table4.num
GROUP BY Table0.num

Somehow its returning just 1 row of data:

num | qty1 | qty2 | qty3 | qty4 |
---------------------------------
    | 100  | 20   |  77  |  969 |

But I was expecting like the example at
http://www.w3schools.com/sql/sql_join_full.asp
like:

num | qty1 | qty2 | qty3 | qty4 |
---------------------------------
1   |   0  |  2   |  3   |   2  |
2   |   1  |  0   |  0   |   0  |
3   |   7  |  0   |  9   |   0  |
4   |   0  |  0   |  0   |  10  |
5   |   0  |  0   |  7   |   0  |
6   |   8  |  2   |  9   |   3  |
7   |   0  |  1   |  0   |   0  |
(I don't know this solves it)
However I got similar to the result the box above by changing all the tables to:

Table1, Columns: num, qty1, qty2, qty3, qty4
Table2, Columns: num, qty2, qty1, qty3, qty4
Table3, Columns: num, qty3, qty1, qty2, qty4
Table4, Columns: num, qty4, qty1, qty2, qty3
Comment: It's quite impressive that it's returning any data at all, given that MySQL doesn't support `FULL OUTER JOIN`.
Comment: You are clearly **not** using MySQL if that statement runs without error.
Comment: Would need to show us the rows in these tables to.  It would appear Table0.num contains null or whitespace instead of the values you expect.
Comment: Table0.num has no null blank values
Comment: Table1~4.num 's value are equal to values in Table0.num
Answer: There are no matches between the num columns in each table and thus you are getting the outer records.  As when there is no match on the match key, the records are shown with that column as null.
The way you full outer join, Table0.num would need to exist in ALL the other tables.  I.e. if num == 1 was only in Table0 and Table1, but not Table2 and 3, then it will not match on all 4 and thus be a null num.
What you probably want is something more like
SELECT Table0.num,
     (Select SUM(Table1.qty1 ) From Table1 Where Table1.num = Table0.num) as one,
     (Select SUM(Table2.qty1 ) From Table2 Where Table2.num = Table0.num) as two,
     ...
From Table0

My syntax might be a little off and there's probably more efficient ways.  But the general idea is you do a subquery for each relation since they are independent.
Comment: The problem is not whether or not you use inner/outer join, it's that there simply isn't a correlation between all 4 tables.  There is only a correlation between table 0 and each other table.  I.e. table1 is not related to table2.  I updated to give an example of relating table0 to each other table independently.
Comment: well if my query was like "JOIN" instead of "FULL OUTER JOIN" I would get results..
Answer: You need to do one of two things (and both of these assume that Table0 has all instances of num) -

If all rows are already summed for the 'leaf' tables (1 - 4), then a simple LEFT JOIN (with a COALESCE() in the select) will suffice - you don't even need the GROUP BY.
If you need the rows summed, you're going to need to sum them before the join, given that otherwise multiple rows per num in different tables will cause the results to multiply.

Something like this:
SELECT Table0.num, COALESCE(Table1.qty, 0), COALESCE(Table2.qty, 0),
                   COALESCE(Table3.qty, 0), COALESCE(Table4.qty, 0)
FROM Table0
LEFT JOIN (SELECT num, SUM(qty1) as qty
           FROM Table1
           GROUP BY num) Table1
ON Table1.num = Table0.num
LEFT JOIN (SELECT num, SUM(qty2) as qty
           FROM Table2
           GROUP BY num) Table2
ON Table2.num = Table0.num
LEFT JOIN (SELECT num, SUM(qty3) as qty
           FROM Table3
           GROUP BY num) Table3
ON Table3.num = Table0.num
LEFT JOIN (SELECT num, SUM(qty4) as qty
           FROM Table4
           GROUP BY num) Table4
ON Table4.num = Table0.num

(working SQLFiddle example)
Answer: There is a work-around solution. You can add one additional table to join your tables. For example:
Tablex; columns: tablex_id (PK, AI) (newly created table)
Table0; columns: tablex_id, num, desc (added new field 'tablex_id')
Table1; columns: tablex_id, num, qty1 (added new field 'tablex_id')
Table2; columns: tablex_id, num, qty2 (added new field 'tablex_id')
Table3; columns: tablex_id, num, qty3 (added new field 'tablex_id')
Table4; columns: tablex_id, num, qty4 (added new field 'tablex_id')
Every time you add record to Table0, Table1, Table2, Table3 and Table4, you should add record to Tablex first and get the tablex_id and put it in your table(s) accordingly.
If you want to join them, just do something like this:
select t0.desc, t1.qty, t2.qty, t3.qty, t4.qty
from Tablex tx
left join Table0 t0
  on tx.tablex_id = t0.tablex_id
left join Table0 t1
  on tx.tablex_id = t1.tablex_id
left join Table2 t2
  on tx.tablex_id = t2.tablex_id
left join Table3 t3
  on tx.tablex_id = t3.tablex_id
left join Table4 t4
 on tx.tablex_id = t4.tablex_id


Relation between $t$ and ${\chi}^2$

Question: Recently I faced a problem to find the relation between $t$ and ${\chi}^2$. We were just taught about the relation between $t$ and $F$ as well as $F$ and ${\chi}^2$.So, I proceeded in this way,
We know ${t_n}^2$ follows $F(1,n)$ distribution   $..........(1)$
Again, suppose $F(n_1,n_2)$ denotes $F$ distribution with $n_1$ and $n_2$ degrees of freedom. For large values of $n_2$, $n_1F$ follows ${\chi_{n_1}}^2$
So, from $(1)$,  ${t_n}^2=F(1,n)$
For large values of $n$,
 $1.F=F$ will follow ${\chi_1}^2$
Therefore, ${t_n}^2={\chi_1}^2$
If my procedure is correct?
Answer: Simply note that $t_\infty = \mathcal{N}$ and $\mathcal{N}^2 = \chi_1^2$, where $\mathcal{N}$ is the standard normal distribution.
Comment: What $\mathcal{N}$ means ?
Comment: It is the normal distribution, I have edited the answer to clarify.

Relation between $t$ and ${\chi}^2$


Estimating VAR by GLS versus OLS: efficiency

Question: Suppose I have a VAR model with different regressors in different equations (this could be due to restricting some coefficients of a full VAR($p$) model to zero or having some different exogenous regressors in different equations).
Suppose also that the model is correctly specified.
I will be interested in asymptotic results (small sample properties may be more complicated, so I leave them aside for simplicity).
Such a model can be estimated by GLS or by equation-by-equation OLS.
Both GLS and OLS estimators will be unbiased.
GLS estimator will be more efficient than equation-by-equation OLS estimator. I understand this means that the variance-covariance matrix of the GLS coefficient vector will be "smaller" than that of OLS (the difference of the two matrices will be a negative semidefinite matrix).
Question: will all the diagonal elements of the variance-covariance matrix be smaller in the GLS case? In other words, will each and every coefficient have a smaller variance in GLS case?
Here is a related question comparing OLS and GLS.
Answer: Yes. Let the GLS covariance matrix be $V_G$ and the OLS covariance matrix $V_O$. Then, as you point out, GLS being efficient means that $V_O-V_G$ is positive semi-definite. This means that for any non-zero vector $z$, $z'(V_O-V_G)z\geq0$. Let's suppose that the dimension of the covariance matrices is $K\times K$. Then, if we choose $z$ to be $e_i$, where $e_i$ is the $i$th column of the $K\times K$ identity matrix, it follows that
$$
e_i'(V_O-V_G)e_i\geq 0,
$$
or, in words, every diagonal element of $V_O$ is greater than (or equal to) that of $V_G$.
Comment: Lovely answer! To the point, transparent, easy to follow. Thanks!


Occasional Timeouts with Zabbix agents behind an AWS Network Load Balancer

Question: My architecture in AWS is as follows:
There are 2 identical zabbix agents (based on zabbix/zabbix-agent:centos-4.0.11) each one running on a different EC2 instance.
Zabbix server runs on a third instance (also dockerized with dockbix using 4.0 version as well), all three of them inside the same VPC.
The idea is to have a Network Load Balancer that listens to the port that both agents run (10050) and have those 2 aforementioned instances being registered on the target group.
Then, the DNS of this NLB would be provided to the Zabbix host configuration as the interface. The goal is to have multiple zabbix hosts targeting the same NLB and their requests being routed according to traffic load to the different agent. There is a zabbix agent item in each host that invokes a UserParameter (a python script) that is defined in each one of the two zabbix agent conf file.
My problem is as follows: zabbix_get (and the equivalent call made automatically according to the interval set in the host conf) timeouts occasionally. One time I get a successful response

{"response":"success","info":"processed: 4; failed: 0; total: 4; seconds spent: 0.000106"}

(python script used is pretty fast, it just takes 1 second) and other times I get a response such as:

zabbix_get [4515]: Timeout while executing operation.

This happens one after another. So one succeeded and the next timeouts, then the next succeeds and so on.
I have tried to test the connection with telnet, and it works all the time. I have even tried to use a simple tcp echo container, which also worked fine all the time.
Any ideas on what might be wrong would be greatly appreciated :)
EDIT: Just wanted to note that this behavior occurs not just with my custom UserParameter defined script, but also with built-in agent calls such as agent.version or agent.ping or net.tcp.port[<serverIp>, 10051] etc
EDIT2: With tcpdump src <serverIp> run inside the agent instances it seems there is similar traffic happening with a successful and a timed out response
Answer: So apparently I needed to enable cross-AZ load balancing for my internal nlb. That's why it was timing out every second request, as all my instances were in one availability region.


Transformation of random variables with a unit Jacobian

Question: Please see the screenshot of the book Financial Time Series Analysis by Tsay. Given the formula for $v$.
$$\boldsymbol{v} = \boldsymbol{K} (\boldsymbol{y} - \mu_{1 | 0}  1^T)$$
It below says they're related by a unit Jacobian, but I cannot seem to figure this out. The change of variable formula is given as $f_v(v) = f_y(g^{-1}(v)) \frac{d g^{-1}(v)}{dv}$ where $f$ represents the pdf. The Jacobian never is equal to the identity matrix so I am unsure exactly what the author refers to here.
Answer: The Jacobian matrix of the transformation $v=f(y)$ is the matrix whose $(i,j)$ entry is $\frac{\partial v_i}{\partial y_j}$. You can check that when $f(y) = K(y - \mu 1_T)$ this Jacobian matrix is precisely $K$ (e.g., write what $v_i$ is in terms of $y_1, \ldots, y_T$ and take the derivative with respect to $y_j$).
Confusingly, "Jacobian" is often used to refer to this matrix ("Jacobian matrix") as well as its determinant ("Jacobian determinant"). The determinant of $K$ is $1$. This is the quantity that appears in the change of variables formula.
Comment: Ah this makes sense. I knew the derivative was $K$ but I forgot the need to take the determinant to account for the volume change. I see why it is termed a unit Jacobian now!


How to query for null in nested db_or conditional

Question: I am trying to perform a query as listed below (notice the check for NULL)
$query = db_select('node', 'n');
/* add fields and joins... */
$query->condition(db_or()
      ->condition(db_and()
                  ->condition('join_alias1.field_date_unassigned_value', NULL, 'IS')
                  ->condition('join_alias2.field_date_assigned_value', $end_date, '<='))
      ->condition(db_and()
                  ->condition('join_alias1.field_date_unassigned_value', $start_date, '>=')
                  ->condition('join_alias2.field_date_assigned_or_submitted_value', $end_date, '<=')));

I am aware that Drupal expects Null values to be checked like
$query->isNull('myfield');

But I don't understand how to perform a query like I listed above while using $query->isNull().
Any ideas? Thanks
Answer: You can use isNull() in the db_and() condition, it'll work just fine:
$query->condition(db_or()
  ->condition(db_and()
    ->isNull('join_alias1.field_date_unassigned_value')
    ->condition('join_alias2.field_date_assigned_value', $end_date, '<=')
  )
  ->condition(db_and()
    ->condition('join_alias1.field_date_unassigned_value', $start_date, '>=')
    ->condition('join_alias2.field_date_assigned_or_submitted_value', $end_date, '<=')
  )
);


Server accessible via SSH and HTTP on all machines except one client

Question: Edit 3:
Weird discovery.  This problem is only happening from one specific client.  All three sites are accessible via domain name from any computer except my primary desktop.  This desktop can only access the server (for HTTP or for SSH) via the local IP address 192.168.0.X not via the external IP or the domain name(s).  From all other machines, everything works as expected.
I checked my fail2ban logs and firewall to make sure this specific machine wasn't getting blocked.  What else could the problem be?  It's a huge pain to not be able to access my server from my primary desktop.
Both are hard-wired to the same router via ethernet cables, if that matters.

Original Post:
I have three virtual hosts defined in Apache (all three with .conf files stored in /etc/apache2/sites-available that have been enabled via a2ensite).
Prior to updating from Ubuntu 16.04 to Ubuntu 18.04, all three worked fine.  After updating, none of them would load in the browser, so I did a lot of troubleshooting.  Here is what I have done/double-checked so far:

Reinstalled apache2 and php
Checked apache2.conf, including running apache2ctl -t to debug - there are no errors.
Checked conf files for each site, ran apache2ctl -S to ensure all were recognized.  Each one specifies the ServerName (domain name) and DocumentRoot (local directory).  These values have been triple checked for correctness.
Checked DNS settings.  All three domain names do point to the correct IP address (used dig to confirm).
Checked firewall settings - port 80 is open and Apache is listening on it.

When accessing any of the three sites by domain name, the browser gives the error message: "This site can't be reached. domain.com took too long to respond."
I can access the default site (the first one loaded by Apache) with no problem if I type the IP address in the browser instead of the domain name.
I feel like this is some sort of Apache configuration I'm messing up somehow but all I have is the default apache2.conf file from fresh installation along with the virtual host conf files, which all have the following format:
<VirtualHost *:80>
    ServerName somedomain.com
    DocumentRoot "/var/www/foldername"
    <Directory /var/www/foldername>
        Options -Indexes
        AllowOverride XXXXXXXXXX
    </Directory>
</VirtualHost>

The AllowOverride is None for one site and Fileinfo Options for the other two.
Any idea what I'm missing?

Edit 1: Adding output from dig, ping, and curl
angela@pop-os:~$ dig mydomain.com

; <<>> DiG 9.11.5-P1-1ubuntu2.5-Ubuntu <<>> mydomain.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 65412
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;mydomain.com.          IN  A

;; ANSWER SECTION:
mydomain.com.       1799    IN  A   MY_SERVER_IP

;; Query time: 60 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Sat Aug 31 23:54:55 EDT 2019
;; MSG SIZE  rcvd: 57

angela@pop-os:~$ ping mydomain.com
PING mydomain.com (MY_SERVER_IP) 56(84) bytes of data.
^C
--- mydomain.com ping statistics ---
18 packets transmitted, 0 received, 100% packet loss, time 415ms

angela@pop-os:~$ curl -v mydomain.com
* Expire in 0 ms for 6 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 1 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 2 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 2 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 2 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 2 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 2 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 2 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 2 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 2 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 2 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 2 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 2 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 2 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 2 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 2 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 2 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 2 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 2 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 2 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
* Expire in 0 ms for 1 (transfer 0x558ffb3d7880)
*   Trying MY_SERVER_IP...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0x558ffb3d7880)

Edit 2: Adding output for curl ip_address and also for netstat.
angela@pop-os:~$ curl -v MY_SERVER_IP
* Expire in 0 ms for 6 (transfer 0x5601183bb880)
*   Trying MY_SERVER_IP...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0x5601183bb880)
* connect to MY_SERVER_IP port 80 failed: Connection timed out
* Failed to connect to MY_SERVER_IP port 80: Connection timed out
* Closing connection 0
curl: (7) Failed to connect to MY_SERVER_IP port 80: Connection timed out

user@server:~$ sudo netstat -anp | grep apache
tcp6       0      0 :::80                   :::*                    LISTEN      28228/apache2

Comment: The error you are giving sounds more indicative of a DNS or domain resolution issue. Can you show that the domain is resolving correctly maybe using `ping` and `curl -v your domain.com` to prove the issue might be elsewhere?
Comment: Added output from dig, ping, and curl to the original post - all three appear to be finding the correct IP address (identified by `MY_SERVER_IP` in the output above).
Comment: The curl output looks strange to me... can you also curl.just the IP address to see that it returns the HTTP headers of the default vhost? The current curl output doesn't seem to output any headers which is concerning. But definitely looks like maybe it is Apache not listening on the domain vhost correctly.
Comment: Ah, the extra "expire in" curl stuff may actually be some debug stuff that slipped in a release: https://curl.haxx.se/mail/archive-2019-02/0013.html
Comment: Added the curl output you suggested to original post; also added netstat output from the server.
Comment: Have you confirmed that Apache process is the correct one and not some hanging around from the upgrade? I'm wondering if there is a zombie Apache process hanging on to Port 80 that isn't responding. Curl is failing to connect to the Port but netstat does indeed show a process listening. I would next try forcefully killing that process and making sure there is a new process listening when Apache is started.
Comment: I have restarted the server throughout this troubleshooting process, so I doubt it was a zombie Apache. :)  But I did just kill the existing apache process, restarted apache, then double checked that the new apache process was listening on port 80 (output is same as above, but with new pid).  curl still times out & browser still cannot connect to domain name.
Comment: OK. Unfortunately, I'm not quite sure what might be going on here. I can only offer some other suggestions such as working backwards to a default Apache config to try and eliminate any user changes. If it still doesn't work then it is more likely a network issue. Try to run the same curl commands on the server itself against 127.0.0.1. If working there then it might next make sense to run a `tcpdump` during some requests and load the dump into Wireshark to try and determine what is happening non the wire and if the requests even get to the server.
Comment: Okay thanks for trying to help!  I'll work on those suggestions and update the post if any new info comes up.
Answer: I'm not sure if this is the "right" solution, but it worked for me.  In the end, all I did was add a line to /etc/hosts on the "broken" client that could not connect to the server.  I put the internal IP address (which I have my router set up to keep the same for all of my main devices, including my server) followed by a space separated list of the domains hosted on that server.  Example:
192.168.0.1     domain1.com domain2.com domain3.com sub.domain3.com

This doesn't seem like a good, dynamic, permanent fix.  But it solves the problem for now.


Palindrome of numbers from 1-n

Question: A palindrome is a number or word that is the same when read forward
and backward, for example, "176671" and "civic." Can the number obtained by writing
the numbers from 1 to n in order (n > 1) be a palindrome?
Comment: That's why he defined a palindrome as "number or word"
Comment: I covered all bases :)
Comment: Maybe I misread. Thought the word "word" was not there initially.
Comment: Related: http://puzzling.stackexchange.com/questions/42567/
Answer: No. With $n=1$, we do have a palindrome of course.
But for $n>1$ we can clearly exclude the case $n\le 10$.
In fact, we need $n\equiv 1\pmod {10}$, as the palindromic string ms
must end in "$\ldots 1$".
Let $k\ge1$ with $10^k<n<10^{k+1}$. Then there is exactly one position in the assumed palindromic string "$12345\ldots54321$" where "$1\underbrace{0\ldots0}_k1$" occurs: In the absence of leading zeroes, only the two $1$s in this block can be leading digits of some numbers, and since no number has more than $k+1$ digits, indeed both $1$s must be leading digits, i.e. the only position where this pattern occurs is at the number $10^k$ (together with the leading $1$ of $10^k+1$). For a palindrome, such a uniquely occuring subpalindrome must be in the very middle. But it is preceeded by "$\underbrace{9\ldots9}_k$" from $10^k-1$ and followed by "$\underbrace{0\ldots0}_{k-1}1$" as the rest of $10^k+1$, contradicting the palindromic symmetry.
Answer: The answer is no - there's a variety of ways to prove this. For example, consider the number $k$ in the list with the most 0's, say $m$ of them. Clearly, $k$ must consist of a single digit followed by $m$ 0's, otherwise there would be a number before it with more 0's. Now we have two cases:

Case 1: $k$ is the only number with $m$ 0's. Then $k$ must be the middle number in the palindrome, otherwise $k$ does not have a unique number of 0's. However, the resulting concatenation of integers is not a palindrome since the number before $k$   , $(\ldots999)$, is not symmetric with the number after it: $(\ldots00001)$.
Case 2: There are multiple numbers with $m$ 0's. Consider the rightmost one, say $k=n\cdot10^m$ for some $n>1$. Then, $k$ is embedded in the palindrome between $((n-1)999\ldots)$ and $((n)00\ldots01)$. Since $k$ is the rightmost appearance of $m$ 0's, the leftmost appearance is thus $(10\ldots0(n))(00\ldots0(n))(99\ldots9(n-1))$. However, this is absurd since the left most appearance is naturally $10^m$.

Therefore, it's impossible for the concatenation of the $n$ integers $1$ through $n$ to be a palindrome.
Answer: Here's a beginning of the task where the numbers do not have to be in order. Note that a palindrome can have at most one digit which occurs an odd number of times - the centre digit if the number of digits is odd.
Now after 1, you have to have all digits 1-9 - nine digits. If you stop below 100 you will always have an odd number of digits (1-9 plus pairs from the two digit numbers). So you can work on digit parities to reduce the number of cases you have to consider.

Palindrome of numbers from 1-n


How to check solaris LDOM build?

Question: I have a newly built Solaris LDOM, I need to check the same for acceptance. Can anybody tell me which commands I need to perform to check whether the LDOM is properly built?
Comment: You should take a moment to review the questions you've asked to see if any of the answers worked for you.  Only you've only marked accepted answers on 2 of your questions so far.  It's good feedback to the community to know when an answer solves the problem.
Comment: yes will it do shortly..
Comment: Hi, Any response to the above question?
Answer: Properly built for what? You need to define what you want your LDOM to be ready to serve. An LDOM build is no different from a normal Solaris installation.
The only things to check that are LDOM specific are possibly hardware resources available to the LDOM, has the SA assigned the correct number of threads/cores to the LDOM, correct amount of memory and disk etc. The commands to check this are the same as you use to check in non-LDOM Solaris (psrinfo, prtdiag etc).

How to check solaris LDOM build?