问:
Uniform EditText size
I'm trying to get all edit text views to be the same size without using a hard definition like px or dp, but rather to use a wrap_content and get them all to be the same size. This is what I have, but it doesn't work:

```<code>    enterAge = (EditText) findViewById(R.id.enterAge);
    enterAge.addTextChangedListener(new TextWatcher1());

    enterWeight = (EditText) findViewById(R.id.enterWeight);
    enterWeight.addTextChangedListener(new TextWatcher2());
    enterWeight.setWidth(enterAge.getWidth());

    enterHeight = (EditText) findViewById(R.id.enterHeight);
    enterHeight.addTextChangedListener(new TextWatcher3());
    enterHeight.setWidth(enterAge.getWidth());

    enterMealFrequency = (EditText) findViewById(R.id.enterMealFrequency);
    enterMealFrequency.addTextChangedListener(new TextWatcher4());
    enterMealFrequency.setWidth(enterAge.getWidth());
</code>```

Any suggestions on why this isn't working the way I want it to?

答:
I have solved similar problem introducing my own class which extends EditText, e.g.

```<code>public class SimpleEditText extends EditText
{
    private static float textSize=14.0;

    public SimpleEditText(Context context)
    {
        super(context);
        this.setTextSize(textSize);
    }

    public SimpleEditText(Context context, AttributeSet attrs)
    {
        super(context, attrs);
        this.setTextSize(textSize);
    }

    public SimpleEditText(Context context, AttributeSet attrs, int defStyle)
    {
        super(context, attrs, defStyle);
        this.setTextSize(textSize);
    }
}
</code>```

In resource you can directly use reference to SimpleEditText instead of EditText (for sure one have to keep in mind that all size related XML attributes will be ignored...)

Title: Uniform EditText size

Body:
I'm trying to get all edit text views to be the same size without using a hard definition like px or dp, but rather to use a wrap_content and get them all to be the same size. This is what I have, but it doesn't work:

    enterAge = (EditText) findViewById(R.id.enterAge);
    enterAge.addTextChangedListener(new TextWatcher1());

    enterWeight = (EditText) findViewById(R.id.enterWeight);
    enterWeight.addTextChangedListener(new TextWatcher2());
    enterWeight.setWidth(enterAge.getWidth());

    enterHeight = (EditText) findViewById(R.id.enterHeight);
    enterHeight.addTextChangedListener(new TextWatcher3());
    enterHeight.setWidth(enterAge.getWidth());

    enterMealFrequency = (EditText) findViewById(R.id.enterMealFrequency);
    enterMealFrequency.addTextChangedListener(new TextWatcher4());
    enterMealFrequency.setWidth(enterAge.getWidth());

Any suggestions on why this isn't working the way I want it to?

Body:
I have solved similar problem introducing my own class which extends EditText, e.g.

public class SimpleEditText extends EditText
{
    private static float textSize=14.0;

    public SimpleEditText(Context context)
    {
        super(context);
        this.setTextSize(textSize);
    }

    public SimpleEditText(Context context, AttributeSet attrs)
    {
        super(context, attrs);
        this.setTextSize(textSize);
    }

    public SimpleEditText(Context context, AttributeSet attrs, int defStyle)
    {
        super(context, attrs, defStyle);
        this.setTextSize(textSize);
    }
}

In resource you can directly use reference to SimpleEditText instead of EditText (for sure one have to keep in mind that all size related XML attributes will be ignored...)


来源: stackexchange

问:
How to perform FST (Finite State Transducer) composition
Consider the following FSTs :

```<code>T1

0 1 a : b
0 2 b : b
2 3 b : b
0 0 a : a
1 3 b : a

T2

0 1 b : a
1 2 b : a
1 1 a : d
1 2 a : c
</code>```

How do I perform the composition operation on these two FSTs (i.e. T1 o T2)
I saw some algorithms but couldn't understand much. If anyone could explain it in a easy way it would be a major help.

Please note that this is NOT a homework. The example is taken from the lecture slides where the solution is given but I couldn't figure out how to get to it.

答:
T1 and T2

Composition of T1 and T2

The states of the composition T are pairs of a T1 state and a T2 state. T satisfies the following conditions:

its initial state is the pair of the initial state of T1 and the initial state
of T2

Its final states are pairs of a final state of T1 and a final state of T2

There is a transition t from (q1, q2) to (r1, r2) for each pair of transitions T1 from q1 to r1 and T2 from q2 to r2 such that the output label of T1 matches the input label of T2. The transition T takes its input label from T1, its output label from T2, and its weight is the combination of the weights of T1 and T2 done with the same operation
that combines weights along a path.

Since there are no weights we can ignore this. Above was picked up exactly from a following beautiful paper. Link here

ContentLicense: CC BY-SA 2.5

Body:
Consider the following FSTs :

T1

0 1 a : b
0 2 b : b
2 3 b : b
0 0 a : a
1 3 b : a

T2

0 1 b : a
1 2 b : a
1 1 a : d
1 2 a : c

How do I perform the composition operation on these two FSTs (i.e. T1 o T2)
I saw some algorithms but couldn't understand much. If anyone could explain it in a easy way it would be a major help.

Please note that this is NOT a homework. The example is taken from the lecture slides where the solution is given but I couldn't figure out how to get to it.

ContentLicense: CC BY-SA 4.0


问:
How to count in a range with .Find() function in VBA
I have the following Excel Worksheet

With the following .Find() function I found the value that I need and the cell.

```<code>Dim finalResult as Range
Dim finalValue as String
Dim headValue as string

finalValue = "Banana"
headValue = "Food"

Set finalResult = Worksheets("mySheet").Range("A1:A20").Find(finalValue, LookIn:=xlValues, After:=headValue)
</code>```

My question is: Knowing the Start = Food and the End = Banana of the range, how do I count how many cells there are between?

Thank you

答:
Multiple options really:</p>

```<code>Sub Test()

Dim rng As Range: Set rng = Worksheets("mySheet").Range("A:A")
Dim rng1 As Range, rng2 As Range

'-------------------------------------
'Option 1: Range.Object
Set rng1 = rng.Find("Food", Lookat:=xlWhole)
Set rng2 = rng.Find("Banana", Lookat:=xlWhole)

If Not rng1 Is Nothing And Not rng2 Is Nothing Then
    Debug.Print rng2.Row - rng1.Row
End If

'-------------------------------------
'Option 2: Application.Match
With Application
    rw1 = .Match("Food", rng, 0)
    rw2 = .Match("Banana", rng, 0)
    If IsError(rw1) = False And IsError(rw2) = False Then
        Debug.Print rw2 - rw1
    End If
End With

'-------------------------------------
'Option 3: xlDown
Set rng1 = rng.Find("Food", Lookat:=xlWhole)
If Not rng1 Is Nothing Then
    Debug.Print rng1(rng1.Rows.Count, 1).End(xlDown).Row - rng1.Row
End If

End Sub
</code>```

Body:
I have the following Excel Worksheet

With the following .Find() function I found the value that I need and the cell.

Dim finalResult as Range
Dim finalValue as String
Dim headValue as string

finalValue = "Banana"
headValue = "Food"

Set finalResult = Worksheets("mySheet").Range("A1:A20").Find(finalValue, LookIn:=xlValues, After:=headValue)

My question is: Knowing the Start = Food and the End = Banana of the range, how do I count how many cells there are between?

Thank you

Body:
Multiple options really:

Sub Test()

Dim rng As Range: Set rng = Worksheets("mySheet").Range("A:A")
Dim rng1 As Range, rng2 As Range

'-------------------------------------
'Option 1: Range.Object
Set rng1 = rng.Find("Food", Lookat:=xlWhole)
Set rng2 = rng.Find("Banana", Lookat:=xlWhole)

If Not rng1 Is Nothing And Not rng2 Is Nothing Then
    Debug.Print rng2.Row - rng1.Row
End If

'-------------------------------------
'Option 2: Application.Match
With Application
    rw1 = .Match("Food", rng, 0)
    rw2 = .Match("Banana", rng, 0)
    If IsError(rw1) = False And IsError(rw2) = False Then
        Debug.Print rw2 - rw1
    End If
End With

'-------------------------------------
'Option 3: xlDown
Set rng1 = rng.Find("Food", Lookat:=xlWhole)
If Not rng1 Is Nothing Then
    Debug.Print rng1(rng1.Rows.Count, 1).End(xlDown).Row - rng1.Row
End If

End Sub


问:
Convert column number to column letter in VBA
I use the following VBA code to insert the column number from Cell C1 into Cell B1:

```<code>Sub AdressColumn()
Sheet1.Range("B1").Value = Sheet1.Range("C1").Column
End Sub
</code>```

In this case the result on my spreadsheet looks like this:

```<code>    A     B    C
1         3
2
3
</code>```

All this works fine so far.

However, instead of inserting the 3 I would prefer to insert the letter of the column. In this case the letter C should be inserted into Cell B1.

I also tried to go with the formula here but I could not make it work since in my case I do not use a given number. Instead I refer to a Column with the .Column function.

What do I have to change in my formula to make it work?

答:
user4039065 is very close, but the subscript at the end of the line should be (2). Then, e.g., 677 represents column "ZA" and column 16384 represents "XFD" by the function below:

```<code>    Const MAX_COL_NUMBER = 16384
        ...
    Function columnNumberToColumnString(col As Integer) As String

      If col > MAX_COL_NUMBER Or col < 1 Then
        columnNumberToColumnString = "ERROR":     Exit Function
      Else

        columnNumberToColumnString = Split(Columns(col).Address, "$")(2)

      End If

' delete code block below after seeing how Split works
msg = "Split <" & Columns(col).Address & ">"
    For i = 0 To UBound(Split(Columns(col).Address, "$"))
        msg = msg + Chr(13) & Chr(10) & "Substring " & i & _
              " is <" & Split(Columns(col).Address, "$")(i) & ">"
    Next
MsgBox msg

  End Function
</code>```

In fact, if I use (1) in place of my (2), for column 26 I get Z:, not just Z, as explained below.

The Split function, when used with a valid Excel column address, returns an array  of length 3, showing in stages how the final result is arrived at.

For 256, for example, the results displayed by the msg code block are:

```<code>Address of column number 256 is <$IV:$IV>
Substring 0 is <>           (since first $ is first character, strip it and all after)
Substring 1 is <IV:>        (since second $ is after the :, strip it and all after)
Substring 2 is <IV>         (since : above is a usual delimiter, strip it)
</code>```

Split "Returns a zero-based, one-dimensional array containing ... 'all substrings' " (if the limit (third) argument is omitted) of the given expression (first argument).

Body:
I use the following VBA code to insert the column number from Cell C1 into Cell B1:

Sub AdressColumn()
Sheet1.Range("B1").Value = Sheet1.Range("C1").Column
End Sub

In this case the result on my spreadsheet looks like this:

    A     B    C
1         3
2
3

All this works fine so far.

However, instead of inserting the 3 I would prefer to insert the letter of the column. In this case the letter C should be inserted into Cell B1.

I also tried to go with the formula here but I could not make it work since in my case I do not use a given number. Instead I refer to a Column with the .Column function.

What do I have to change in my formula to make it work?

Body:
user4039065 is very close, but the subscript at the end of the line should be (2). Then, e.g., 677 represents column "ZA" and column 16384 represents "XFD" by the function below:

    Const MAX_COL_NUMBER = 16384
        ...
    Function columnNumberToColumnString(col As Integer) As String

      If col > MAX_COL_NUMBER Or col < 1 Then
        columnNumberToColumnString = "ERROR":     Exit Function
      Else

        columnNumberToColumnString = Split(Columns(col).Address, "$")(2)

      End If

' delete code block below after seeing how Split works
msg = "Split <" & Columns(col).Address & ">"
    For i = 0 To UBound(Split(Columns(col).Address, "$"))
        msg = msg + Chr(13) & Chr(10) & "Substring " & i & _
              " is <" & Split(Columns(col).Address, "$")(i) & ">"
    Next
MsgBox msg

  End Function

In fact, if I use (1) in place of my (2), for column 26 I get Z:, not just Z, as explained below.

The Split function, when used with a valid Excel column address, returns an array  of length 3, showing in stages how the final result is arrived at.

For 256, for example, the results displayed by the msg code block are:

Address of column number 256 is <$IV:$IV>
Substring 0 is <>           (since first $ is first character, strip it and all after)
Substring 1 is <IV:>        (since second $ is after the :, strip it and all after)
Substring 2 is <IV>         (since : above is a usual delimiter, strip it)

Split "Returns a zero-based, one-dimensional array containing ... 'all substrings' " (if the limit (third) argument is omitted) of the given expression (first argument).


问:
wait to promises inside for loop to end. Angular 7 / Typescript
I'm working with Angular 7 and I have a function that have a promise and save the result in an array like this:

```<code>appendImage(item){

this.imageCompress.compressFile(item, 50, 50).then(
  result => {
    this.compressedImages.push(result);
    return this.compressedImages;
  });
</code>```

}

And I'm calling this function/promise from another function that have a for loop:

```<code>async compressFiles() {

if(this.elementsSelected.length > 0){
 for(let i = 0; i < this.elementsSelected.length; i++){
   let actual = this.elementsSelected[i].src;
   let res = await this.appendImage(actual);
   console.log(res);
 }

  return this.compressedImages;

}else{
  console.warn("No Images Selected");
}
</code>```

}

And I need to return the array when all promise calls ends. When I print the array from the appendImage() function, I get the array just like I wanted it, but doing the console.log(res) I get undefined.
What am I doing wrong?

答:
In order to properly await your function, you need to return the promise.

```<code>appendImage(item){

this.imageCompress.compressFile(item, 50, 50).then(
  result => {
    this.compressedImages.push(result);
    return this.compressedImages;
  });
}
</code>```

should be

```<code>appendImage(item){
// this is a promise, and you need to return it, in order to use await
return this.imageCompress.compressFile(item, 50, 50).then(
  result => {
    this.compressedImages.push(result);
    return this.compressedImages;
  });
}
</code>```

Body:
I'm working with Angular 7 and I have a function that have a promise and save the result in an array like this:

appendImage(item){

this.imageCompress.compressFile(item, 50, 50).then(
  result => {
    this.compressedImages.push(result);
    return this.compressedImages;
  });

}

And I'm calling this function/promise from another function that have a for loop:

async compressFiles() {

if(this.elementsSelected.length > 0){
 for(let i = 0; i < this.elementsSelected.length; i++){
   let actual = this.elementsSelected[i].src;
   let res = await this.appendImage(actual);
   console.log(res);
 }

  return this.compressedImages;

}else{
  console.warn("No Images Selected");
}

}

And I need to return the array when all promise calls ends. When I print the array from the appendImage() function, I get the array just like I wanted it, but doing the console.log(res) I get undefined.
What am I doing wrong?

Body:
In order to properly await your function, you need to return the promise.

appendImage(item){

this.imageCompress.compressFile(item, 50, 50).then(
  result => {
    this.compressedImages.push(result);
    return this.compressedImages;
  });
}

should be

appendImage(item){
// this is a promise, and you need to return it, in order to use await
return this.imageCompress.compressFile(item, 50, 50).then(
  result => {
    this.compressedImages.push(result);
    return this.compressedImages;
  });
}


问:
Javascript alert box for textarea values using PHP
While submitting below:

It gives me an alert as "hey";

But while submitting below:

It doesn't alert anything.

PHP Code:

```<code>$text = htmlspecialchars($_POST['tval']);
echo "<script>alert('".$text."');</script>";
</code>```

HTML Code:

```<code><textarea cols="40" rows="5" type="text" name="tval" placeholder="Type Here..." required></textarea>
</code>```

答:
The problem is that you have a line break in your javascript code, so it produces an error. You can check the Developer Console (F12) to see what the error is. This however, should fix the problem:

```<code>$text = htmlspecialchars($_POST['tval']);
echo "<script>alert('". json_encode($text) ."');</script>";
</code>```

json_encode is a quick and easy way to transform line breaks in a string into the \n format, which the alertbox supports. See here:

https://www.w3schools.com/js/tryit.asp?filename=tryjs_alert2

Update: See demo here

Update 2: Make sure to only run this code snippet if your form is submitted, and the 'tval' is set in POST, otherwise you'll get a warning, and PHP will interpret the empty value as null. Example:

```<code>if(isset($_POST['tval'])) {
    $text = htmlspecialchars($_POST['tval']);
    echo "<script>alert('". json_encode($text) ."');</script>";
}
</code>```

Body:
While submitting below:

It gives me an alert as "hey";

But while submitting below:

It doesn't alert anything.

PHP Code:

$text = htmlspecialchars($_POST['tval']);
echo "";

HTML Code:

<textarea cols="40" rows="5" type="text" name="tval" placeholder="Type Here..." required></textarea>

Body:
The problem is that you have a line break in your javascript code, so it produces an error. You can check the Developer Console (F12) to see what the error is. This however, should fix the problem:

$text = htmlspecialchars($_POST['tval']);
echo "<script>alert('". json_encode($text) ."');</script>";

json_encode is a quick and easy way to transform line breaks in a string into the \n format, which the alertbox supports. See here:

https://www.w3schools.com/js/tryit.asp?filename=tryjs_alert2

Update: See demo here

Update 2: Make sure to only run this code snippet if your form is submitted, and the 'tval' is set in POST, otherwise you'll get a warning, and PHP will interpret the empty value as null. Example:

if(isset($_POST['tval'])) {
    $text = htmlspecialchars($_POST['tval']);
    echo "<script>alert('". json_encode($text) ."');</script>";
}


问:
How can I cause Python 3.5 to crash?
We are using embedded cpython as a scripting language in our app.  We are modifying our sys.path at startup to make sure that we don't execute code from outside our app, but a user with a sitecustomize.py in their PYTHONPATH is causing code to execute before we have a chance to fix sys.path, and we believe their code has a hard crash (not an exception, which site.py will catch and handle gracefully).

I believe the correct fix is to simply clear the PYTHONPATH variable from the environment before we initialize python, but I can't test it properly because I can't recreate the problem.

The simplest way I've found is using ctypes to write to memory, such as:

```<code>import ctypes
p = (ctypes.c_char).from_address(0)
while True:
  p[0] = 0
  p = p + 1
</code>```

But in Python 3.5, it doesn't allow me to write to c_char types, giving the error "TypeError: 'c_char' object does not support item assignment".

I've tried a few of the methods available in https://wiki.python.org/moin/CrashingPython to no avail.

Is there a reliable way to crash python 3.5 from pure Python code?

答:
Simply put 0 / 0 on the line of code you want to trigger the crash. You will get a ZeroDivisionError

I think this is the easiest way to force a crash

ContentLicense: CC BY-SA 3.0

Title: How can I cause Python 3.5 to crash?

Body:
We are using embedded cpython as a scripting language in our app.  We are modifying our sys.path at startup to make sure that we don't execute code from outside our app, but a user with a sitecustomize.py in their PYTHONPATH is causing code to execute before we have a chance to fix sys.path, and we believe their code has a hard crash (not an exception, which site.py will catch and handle gracefully).

I believe the correct fix is to simply clear the PYTHONPATH variable from the environment before we initialize python, but I can't test it properly because I can't recreate the problem.

The simplest way I've found is using ctypes to write to memory, such as:

import ctypes
p = (ctypes.c_char).from_address(0)
while True:
  p[0] = 0
  p = p + 1

But in Python 3.5, it doesn't allow me to write to c_char types, giving the error "TypeError: 'c_char' object does not support item assignment".

I've tried a few of the methods available in https://wiki.python.org/moin/CrashingPython to no avail.

Is there a reliable way to crash python 3.5 from pure Python code?


问:
Localtunnel running problem, doesn't work at all
I installed localtunnel globaly by runnnig this command npm install -g localtunnel.

After that when I run lt --port 8080, absolutely nothing happens. Does anyone know why?

答:
It seems like localtunnel is currently down.
Click here to go to the github issues page for more information and updates</p>


问:
Filter rows with only one element in a dataset using r
I'd like to retain rows with only one element and I am struggling to find a code/package that allows me to do that.

to be clearer, this is an example of my dataset:

Dataset extract

Considering variable A1, I would like to remove row 5 as it has two elements (CA) and considering variable A2, rows 16 (TAA) and 19 (GA) should be removed. I tried to use the "str_remove" command but the cells with two or more elements are all different in terms of letters they include as well as number of elements in them (e.g, one cell can have two elements and others have even 5 elements in it), so I cannot establish a pattern.

Do you have any suggestion?
Thanks for your help

Silvia

答:
```<code>df[apply(apply(df[,c("A1","A2"),drop=F],2,nchar),1,max)==1,]
</code>```

where you can replace c("A1","A2") with your vector of columns.

Body:
df[apply(apply(df[,c("A1","A2"),drop=F],2,nchar),1,max)==1,]

where you can replace c("A1","A2") with your vector of columns.


问:
Cannot fix The provided execution role does not have permissions to call CreateNetworkInterface on EC2
I am trying to deploy with VPC and this is my serverless.yaml

```<code>
vpcSettings: &vpcSettings
  vpc: ${self:custom.allVpcSettings.${self:provider.stage}.vpc}

provider:
  name: aws
  runtime: nodejs10.x
  stage: ${opt:stage, 'local'}
  region: us-west-1
  memorySize: 256
  timeout: 30
  deploymentPrefix: fs-sls-${self:provider.stage}-deploy
  deploymentBucket: fs-serverless-deployment
  variables: ${file(.env.${opt:stage, self:provider.stage}.json)}
  environment:
    NODE_ENV: ${self:provider.variables.NODE_ENV}

functions:
  ping:
    handler: src/handler.ping
    description: Let us know if the service is up and running
    events:
      - http:
          path: ping
          method: get
          cors: true
  graphql:
    handler: src/handler.graphqlHandler
    <<: *vpcSettings
    description: One function where all GQL request comes
    memorySize: 1024
    events:
      - http:
          path: graphql
          method: post
          cors: true
      - http:
          path: graphql
          method: get
          cors: true

plugins:
  - serverless-offline

custom:
  serverless-offline:
    port: 6000
  allVpcSettings:
    local:
      vpc: 'This is a dummy value that should be ignored'
    dev:
      vpc:
        securityGroupIds:
          - sg-xxxxxxxxxxxxxxx
        subnetIds:
          - subnet-xxxxxxxxxxxxxxx
          - subnet-xxxxxxxxxxxxxxx
    prod:
      vpc:
        securityGroupIds:
          - sg-xxxxxxxxxxxxxxx
        subnetIds:
          - subnet-xxxxxxxxxxxxxxx
          - subnet-xxxxxxxxxxxxxxx
</code>```

It fails with the following error

```<code>
  Serverless Error ---------------------------------------

  The provided execution role does not have permissions to call CreateNetworkInterface on EC2

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              10.16.0
     Framework Version:         1.52.0
     Plugin Version:            2.0.0
     SDK Version:               2.1.1
</code>```

The user that I created for this purpose has AdministratorAccess as well as AWSLambdaVPCAccessExecutionRole in it's permissions. What else is expected here?

答:
So I fixed it. It means the role of deploying lambda doesn't have permission. So it boils down to the fact to give it the role. First, confirm if you have the role.
Check in the image where to look for the role.

Once you don't find it. Which you most likely won't. Take the Role name and goto IAM -> Roles and Search for the role name and add AWSLambdaVPCAccessExecutionRole to the selected role.
This should give it the required permission.

Now try deploying the SLS and it should work.

Once you have the role, edit it by adding the

Body:
I am trying to deploy with VPC and this is my serverless.yaml

vpcSettings: &vpcSettings
  vpc: ${self:custom.allVpcSettings.${self:provider.stage}.vpc}

provider:
  name: aws
  runtime: nodejs10.x
  stage: ${opt:stage, 'local'}
  region: us-west-1
  memorySize: 256
  timeout: 30
  deploymentPrefix: fs-sls-${self:provider.stage}-deploy
  deploymentBucket: fs-serverless-deployment
  variables: ${file(.env.${opt:stage, self:provider.stage}.json)}
  environment:
    NODE_ENV: ${self:provider.variables.NODE_ENV}

functions:
  ping:
    handler: src/handler.ping
    description: Let us know if the service is up and running
    events:
      - http:
          path: ping
          method: get
          cors: true
  graphql:
    handler: src/handler.graphqlHandler
    <<: *vpcSettings
    description: One function where all GQL request comes
    memorySize: 1024
    events:
      - http:
          path: graphql
          method: post
          cors: true
      - http:
          path: graphql
          method: get
          cors: true

plugins:
  - serverless-offline

custom:
  serverless-offline:
    port: 6000
  allVpcSettings:
    local:
      vpc: 'This is a dummy value that should be ignored'
    dev:
      vpc:
        securityGroupIds:
          - sg-xxxxxxxxxxxxxxx
        subnetIds:
          - subnet-xxxxxxxxxxxxxxx
          - subnet-xxxxxxxxxxxxxxx
    prod:
      vpc:
        securityGroupIds:
          - sg-xxxxxxxxxxxxxxx
        subnetIds:
          - subnet-xxxxxxxxxxxxxxx
          - subnet-xxxxxxxxxxxxxxx

It fails with the following error

  Serverless Error ---------------------------------------

  The provided execution role does not have permissions to call CreateNetworkInterface on EC2

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              10.16.0
     Framework Version:         1.52.0
     Plugin Version:            2.0.0
     SDK Version:               2.1.1

The user that I created for this purpose has AdministratorAccess as well as AWSLambdaVPCAccessExecutionRole in it's permissions. What else is expected here?


问:
How to write to a file, using the logging Python module?
How can I use the logging module in Python to write to a file? Every time I try to use it, it just prints out the message.</p>

答:
here's a simpler way to go about it. this solution doesn't use a
config dictionary and uses a rotation file handler, like so:

```<code>import logging
from logging.handlers import RotatingFileHandler

logging.basicConfig(handlers=[RotatingFileHandler(filename=logpath+filename,
                     mode='w', maxBytes=512000, backupCount=4)], level=debug_level,
                     format='%(levelname)s %(asctime)s %(message)s',
                    datefmt='%m/%d/%Y%I:%M:%S %p')

logger = logging.getLogger('my_logger')
</code>```

or like so:

```<code>import logging
from logging.handlers import RotatingFileHandler

handlers = [ RotatingFileHandler(filename=logpath+filename,
            mode='w',
            maxBytes=512000,
            backupCount=4)
           ]
logging.basicConfig(handlers=handlers,
                    level=debug_level,
                    format='%(levelname)s %(asctime)s %(message)s',
                    datefmt='%m/%d/%Y%I:%M:%S %p')

logger = logging.getLogger('my_logger')
</code>```

the handlers variable needs to be an iterable. logpath+filename and debug_level are just variables holding the
respective info. of course, the values for the function params are up
to you.

the first time i was using the logging module i made the mistake of writing the following, which generates an OS file lock error (the
above is the solution to that):

```<code>import logging
from logging.handlers import RotatingFileHandler

logging.basicConfig(filename=logpath+filename,
       level=debug_level,
       format='%(levelname)s %(asctime)s %(message)s',
       datefmt='%m/%d/%Y%I:%M:%S %p')

logger = logging.getLogger('my_logger')
logger.addHandler(RotatingFileHandler(
       filename=logpath+filename,
       mode='w',
       maxBytes=512000,
       backupCount=4))
</code>```

Body:
here's a simpler way to go about it. this solution doesn't use a
config dictionary and uses a rotation file handler, like so:

import logging
from logging.handlers import RotatingFileHandler

logging.basicConfig(handlers=[RotatingFileHandler(filename=logpath+filename,
                     mode='w', maxBytes=512000, backupCount=4)], level=debug_level,
                     format='%(levelname)s %(asctime)s %(message)s',
                    datefmt='%m/%d/%Y%I:%M:%S %p')

logger = logging.getLogger('my_logger')

or like so:

import logging
from logging.handlers import RotatingFileHandler

handlers = [ RotatingFileHandler(filename=logpath+filename,
            mode='w',
            maxBytes=512000,
            backupCount=4)
           ]
logging.basicConfig(handlers=handlers,
                    level=debug_level,
                    format='%(levelname)s %(asctime)s %(message)s',
                    datefmt='%m/%d/%Y%I:%M:%S %p')

logger = logging.getLogger('my_logger')

the handlers variable needs to be an iterable. logpath+filename and debug_level are just variables holding the
respective info. of course, the values for the function params are up
to you.

the first time i was using the logging module i made the mistake of writing the following, which generates an OS file lock error (the
above is the solution to that):

import logging
from logging.handlers import RotatingFileHandler

logging.basicConfig(filename=logpath+filename,
       level=debug_level,
       format='%(levelname)s %(asctime)s %(message)s',
       datefmt='%m/%d/%Y%I:%M:%S %p')

logger = logging.getLogger('my_logger')
logger.addHandler(RotatingFileHandler(
       filename=logpath+filename,
       mode='w',
       maxBytes=512000,
       backupCount=4))


问:
How do I make DateTextBox (dojo) still display invalid value date after submitting screen?
I'm using DateTextBox from dojo library in my Web page.
After entering an invalid value manually in DateTextbox then submitting the screen, this value disappears :(.
My idea is to keep showing this value so that users can see which wrong value they have entered.
How can I do this?

Any help is highly appreciated,

Thanks in advance :)

答:
See this simple code in c# if ever could help you.</p>

```<code>//// In your code-behind:
//// String formate should ‘mm/dd/yyyy’
 if (!IsValidDate( dateFrom))
 {
     AlMessageBox.Show(this, "Invalide Date");
     this.txtDateFrom.Focus();
     return;
 }

 Proceed....
 .....

// String formate should ‘mm/dd/yyyy’
public static Boolean IsValidDate(string date)
{
  bool retValue = true;
  if (date == string.Empty)
  {
        return false;
  }
  if ((date.Split(‘/’).Length – 1) != 2) // Count the occurence of ‘/’ should be 2
  {
        return false;
  }

  int mon = date.Split(‘/’)[0].ToInt();
  int day = date.Split(‘/’)[1].ToInt();
  int yr = date.Split(‘/’)[2].ToInt();

  if (mon > 12 || mon == 0) // Validate month
  {
        return false;
  }
  int daysLimitInMonth = GetDaysInMonth(mon);

  if (day > daysLimitInMonth || day == 0 )
  {
        return false;
  }

  if (yr < 1000 ) // Bellow 1000 years is not invalid
  {
        return false;
  }

  return retValue;
}

private static int GetDaysInMonth(int mon)
{
    int daysLimitInMonth = 31;

    switch (mon)
    {
    case 2: // case month is Feb
        if (IsLeapYear(mon)) // determine the year if is Leap Year
           daysLimitInMonth = 29;
        else
            daysLimitInMonth = 28;
        break;

    case 4: // April
        daysLimitInMonth = 30;
    case 6: // June
         daysLimitInMonth = 30;
    case 9: // Sept
         daysLimitInMonth = 30;
    case 11: // Nov
        daysLimitInMonth = 30;

    default:
        daysLimitInMonth = 31;
        break;
   }
   return daysLimitInMonth;
}

private static bool IsLeapYear(int year)
{
    if ((year % 400) == 0)
        return true;
    if ((year % 100) == 0)
        return false;
    if ((year % 4) == 0)
        return true;
    return false;
}

public class AlMessageBox
{
   private static Hashtable m_executingPages = new Hashtable();
   private MessageBox() { }
   public static void Show(string sMessage)
   {
      // If this is the first time a page has called this method then
      if (!m_executingPages.Contains(HttpContext.Current.Handler))
      {
         // Attempt to cast HttpHandler as a Page.
         Page executingPage = HttpContext.Current.Handler as Page;
         if (executingPage != null)
         {
            // Create a Queue to hold one or more messages.
            Queue messageQueue = new Queue();
            // Add our message to the Queue
            messageQueue.Enqueue(sMessage);
            // Add our message queue to the hash table. Use our page reference
            // (IHttpHandler) as the key.
            m_executingPages.Add(HttpContext.Current.Handler, messageQueue);
            // Wire up Unload event so that we can inject
            // some JavaScript for the alerts.
            executingPage.Unload += new EventHandler(ExecutingPage_Unload);
         }
     }
     else
     {
         // If were here then the method has allready been
         Queue queue = (Queue)m_executingPages[HttpContext.Current.Handler];
         // Add our message to the Queue
         queue.Enqueue(sMessage);
      }
 }

 public static void Show(System.Web.UI.Page page, string msg)
 {
     ScriptManager.RegisterClientScriptBlock(page, page.GetType(),
     "clientScript", "javascript:alert('" + msg + "');", true);
 }

 private static void ExecutingPage_Unload(object sender, EventArgs e)
 {
     // Get our message queue from the hashtable
     Queue queue = (Queue)m_executingPages[HttpContext.Current.Handler];
     if (queue != null)
     {
        StringBuilder sb = new StringBuilder();
        // How many messages have been registered?
        int iMsgCount = queue.Count;
        // Use StringBuilder to build up our client slide JavaScript.
        sb.Append("<script language='javascript'>");
        // Loop round registered messages
        string sMsg;
        while (iMsgCount-- > 0)
        {
            sMsg = (string)queue.Dequeue();
            sMsg = sMsg.Replace("\n", "\\n");
            sMsg = sMsg.Replace("\"", "'");
            sb.Append(@"alert( """ + sMsg + @""" );");
        }
        // Close our JS
        sb.Append(@"</script>");
        // Were done, so remove our page reference from the hashtable
        m_executingPages.Remove(HttpContext.Current.Handler);
        // Write the JavaScript to the end of the response stream.
        HttpContext.Current.Response.Write(sb.ToString());
        }
   }
}
</code>```

Body:
See this simple code in c# if ever could help you.

//// In your code-behind:
//// String formate should ‘mm/dd/yyyy’
 if (!IsValidDate( dateFrom))
 {
     AlMessageBox.Show(this, "Invalide Date");
     this.txtDateFrom.Focus();
     return;
 }

 Proceed....
 .....

// String formate should ‘mm/dd/yyyy’
public static Boolean IsValidDate(string date)
{
  bool retValue = true;
  if (date == string.Empty)
  {
        return false;
  }
  if ((date.Split(‘/’).Length – 1) != 2) // Count the occurence of ‘/’ should be 2
  {
        return false;
  }

  int mon = date.Split(‘/’)[0].ToInt();
  int day = date.Split(‘/’)[1].ToInt();
  int yr = date.Split(‘/’)[2].ToInt();

  if (mon > 12 || mon == 0) // Validate month
  {
        return false;
  }
  int daysLimitInMonth = GetDaysInMonth(mon);

  if (day > daysLimitInMonth || day == 0 )
  {
        return false;
  }

  if (yr < 1000 ) // Bellow 1000 years is not invalid
  {
        return false;
  }

  return retValue;
}

private static int GetDaysInMonth(int mon)
{
    int daysLimitInMonth = 31;

    switch (mon)
    {
    case 2: // case month is Feb
        if (IsLeapYear(mon)) // determine the year if is Leap Year
           daysLimitInMonth = 29;
        else
            daysLimitInMonth = 28;
        break;

    case 4: // April
        daysLimitInMonth = 30;
    case 6: // June
         daysLimitInMonth = 30;
    case 9: // Sept
         daysLimitInMonth = 30;
    case 11: // Nov
        daysLimitInMonth = 30;

    default:
        daysLimitInMonth = 31;
        break;
   }
   return daysLimitInMonth;
}

private static bool IsLeapYear(int year)
{
    if ((year % 400) == 0)
        return true;
    if ((year % 100) == 0)
        return false;
    if ((year % 4) == 0)
        return true;
    return false;
}

public class AlMessageBox
{
   private static Hashtable m_executingPages = new Hashtable();
   private MessageBox() { }
   public static void Show(string sMessage)
   {
      // If this is the first time a page has called this method then
      if (!m_executingPages.Contains(HttpContext.Current.Handler))
      {
         // Attempt to cast HttpHandler as a Page.
         Page executingPage = HttpContext.Current.Handler as Page;
         if (executingPage != null)
         {
            // Create a Queue to hold one or more messages.
            Queue messageQueue = new Queue();
            // Add our message to the Queue
            messageQueue.Enqueue(sMessage);
            // Add our message queue to the hash table. Use our page reference
            // (IHttpHandler) as the key.
            m_executingPages.Add(HttpContext.Current.Handler, messageQueue);
            // Wire up Unload event so that we can inject
            // some JavaScript for the alerts.
            executingPage.Unload += new EventHandler(ExecutingPage_Unload);
         }
     }
     else
     {
         // If were here then the method has allready been
         Queue queue = (Queue)m_executingPages[HttpContext.Current.Handler];
         // Add our message to the Queue
         queue.Enqueue(sMessage);
      }
 }

 public static void Show(System.Web.UI.Page page, string msg)
 {
     ScriptManager.RegisterClientScriptBlock(page, page.GetType(),
     "clientScript", "javascript:alert('" + msg + "');", true);
 }

 private static void ExecutingPage_Unload(object sender, EventArgs e)
 {
     // Get our message queue from the hashtable
     Queue queue = (Queue)m_executingPages[HttpContext.Current.Handler];
     if (queue != null)
     {
        StringBuilder sb = new StringBuilder();
        // How many messages have been registered?
        int iMsgCount = queue.Count;
        // Use StringBuilder to build up our client slide JavaScript.
        sb.Append("<script language='javascript'>");
        // Loop round registered messages
        string sMsg;
        while (iMsgCount-- > 0)
        {
            sMsg = (string)queue.Dequeue();
            sMsg = sMsg.Replace("\n", "\\n");
            sMsg = sMsg.Replace("\"", "'");
            sb.Append(@"alert( """ + sMsg + @""" );");
        }
        // Close our JS
        sb.Append(@"</script>");
        // Were done, so remove our page reference from the hashtable
        m_executingPages.Remove(HttpContext.Current.Handler);
        // Write the JavaScript to the end of the response stream.
        HttpContext.Current.Response.Write(sb.ToString());
        }
   }
}


问:
wordpress max upload size doesn't change
I need to change Wordpress Maximum upload file size to something more than 2mb.
I have changed max upload file size in Multisite Settings to 19500.
I also edited php.ini changing post_max_size to 25M, upload_max_filesize to 20M and memory_limit to 128M.
What else do I need to do in order to achieve my goal?
I'm on localhost on mac.</p>

答:
Alright, here are a few solutions I can think of for a localhost user. With localhost, I assume you have full control so try the below options if any works let me know.

.htaccess
Edit the .htaccess file in your WordPress site’s root folder and add the following code:

```<code>php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 300
php_value max_input_time 300
</code>```

Theme functions
add the following code to the theme’s functions.php file, you can increase the upload size:

```<code>@ini_set( 'upload_max_size' , '64M' );
@ini_set( 'post_max_size', '64M');
@ini_set( 'max_execution_time', '300' );
</code>```

let me know if any of this works.

Body:
Alright, here are a few solutions I can think of for a localhost user. With localhost, I assume you have full control so try the below options if any works let me know.

.htaccess
Edit the .htaccess file in your WordPress site’s root folder and add the following code:

php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 300
php_value max_input_time 300

Theme functions
add the following code to the theme’s functions.php file, you can increase the upload size:

@ini_set( 'upload_max_size' , '64M' );
@ini_set( 'post_max_size', '64M');
@ini_set( 'max_execution_time', '300' );

let me know if any of this works.


问:
How To Copy Tables And Their Specific Columns To Another Database in Oracle
I have huge sized Oracle Db, and for reporting, queries are working too slow because of the network traffic. The data warehouse tools are expensive so that I have decided to create a new database and feed it from the main database in every quarter. I was fresh in the company and I am not working as a DBA, so I have worked on 48 different SQL queries to detect which Db tables and columns are using for reporting and finished. Now I know which Db tables and columns are using. At that stage, I wanted to ask the best methods to create a new database with the same tables and columns names with the data of the main database?</p>

答:
On Target (where tables need to be created) login as DBA user and grant create database link privilege to user who will own these tables. Something like,

grant create database link to adnan;

Login as that user now which will own the table and then create a private database link

CREATE DATABASE LINK dblink
CONNECT TO [username at sourcedb] IDENTIFIED BY [sourcedb] user password>
USING '[remote_database_name_in_tnsnames.ora file or actual connect identifier]';

using connection string directly instead of tnsnames.ora-
CREATE DATABASE LINK dblink
    CONNECT TO remote_user IDENTIFIED BY password
    USING '(DESCRIPTION=
                (ADDRESS=(PROTOCOL=TCP)(HOST=oracledb.example.com)(PORT=1521))
                (CONNECT_DATA=(SERVICE_NAME=service_name))
            )';

create table <yourtablenmae> as select * from [table_name_at_sourcedb]@dblink where rownum<1; --- This will create empty table if you want with data remove where condition.

Disclaimer: Haven't ran this so there might be some mistakes.


问:
PIL: can i have multiple sizes of text of the SAME font? (Python)
Currently trying to have the same font for an image with PIL but with different sizes.

Tried to have two different font instances but it didn't work. How can I do that?

答:
I think you mean this:

```<code>#!/usr/bin/env python3

from PIL  import Image, ImageFont, ImageDraw

# Create a black canvas
canvas = Image.new('RGB', (400,200))

# Get a drawing context
draw = ImageDraw.Draw(canvas)
monospace20 = ImageFont.truetype("/Library/Fonts/Andale Mono.ttf",20)
monospace50 = ImageFont.truetype("/Library/Fonts/Andale Mono.ttf",50)

draw.text((10, 10), "Hello 20", font=monospace20, fill=(255,255,255))
draw.text((10, 90), "Hello 50", font=monospace50, fill=(255,255,255))

canvas.save('result.png')
</code>```

Body:
I think you mean this:

#!/usr/bin/env python3

from PIL  import Image, ImageFont, ImageDraw

# Create a black canvas
canvas = Image.new('RGB', (400,200))

# Get a drawing context
draw = ImageDraw.Draw(canvas)
monospace20 = ImageFont.truetype("/Library/Fonts/Andale Mono.ttf",20)
monospace50 = ImageFont.truetype("/Library/Fonts/Andale Mono.ttf",50)

draw.text((10, 10), "Hello 20", font=monospace20, fill=(255,255,255))
draw.text((10, 90), "Hello 50", font=monospace50, fill=(255,255,255))

canvas.save('result.png')


问:
Apache server keeps crashing, "caught SIGTERM, shutting down"
This just started happening three weeks or so ago. The content of my website hasn't changed, it's just a phpBB forum using MySQL as a back end.

Nothing has changed in well over a year but recently, every two days or so, the server just shuts down and cannot be accessed at all, I have to notify my service provider to physically restart the machine.

It seems to be tied to these SIGTERM errors I find in the logs. Problem is I have no idea how to fix these kinds of things or find the root cause as my skills in this area are lacking.

Anyone have any ideas what could be going on?

Apache/2.2.3 (CentOS)

20051115

Linux 2.6.18-028stab057.4 #1 SMP Fri Aug 1 10:47:59 MSD 2008 x86_64

From the error log:

```<code>[Sun Nov 01 15:18:53 2009] [notice] caught SIGTERM, shutting down
</code>```

Not entirely sure that's what's causing me my problems but it doesn't sound like a good thing.

I can post more log information if needed

[Sun Nov 01 05:07:17 2009] [notice] Digest: generating secret for digest authentication ...
[Sun Nov 01 05:07:17 2009] [notice] Digest: done
[Sun Nov 01 05:07:19 2009] [notice] mod_python: Creating 4 session mutexes based on 10 max processes and 0 max threads.
[Sun Nov 01 05:07:19 2009] [warn] RSA server certificate CommonName (CN) `plesk' does NOT match server name!?
[Sun Nov 01 05:07:19 2009] [warn] RSA server certificate CommonName (CN) `plesk' does NOT match server name!?
[Sun Nov 01 05:07:19 2009] [warn] RSA server certificate CommonName (CN) `plesk' does NOT match server name!?
[Sun Nov 01 05:07:19 2009] [warn] Init: SSL server IP/port conflict: default-64-6-237-192:443 (/etc/httpd/conf.d/zz010_psa_httpd.conf:83) vs. webmail:443 (/etc/httpd/conf.d/zz010_psa_httpd.conf:159)
[Sun Nov 01 05:07:19 2009] [warn] Init: You should not use name-based virtual hosts in conjunction with SSL!!
[Sun Nov 01 05:07:19 2009] [warn] WARNING: Attempt to change ServerLimit ignored during restart
[Sun Nov 01 05:07:19 2009] [notice] Apache/2.2.3 (CentOS) configured -- resuming normal operations
[Sun Nov 01 15:16:11 2009] [error] [client 127.0.0.1] Invalid method in request get
[Sun Nov 01 15:18:53 2009] [notice] caught SIGTERM, shutting down
[Sun Nov 01 15:19:27 2009] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Sun Nov 01 15:19:27 2009] [warn] RSA server certificate CommonName (CN) `plesk' does NOT match server name!?
[Sun Nov 01 15:19:27 2009] [warn] RSA server certificate CommonName (CN) `plesk' does NOT match server name!?
[Sun Nov 01 15:19:27 2009] [warn] RSA server certificate CommonName (CN) `plesk' does NOT match server name!?
[Sun Nov 01 15:19:27 2009] [warn] Init: SSL server IP/port conflict: default-64-6-237-192:443 (/etc/httpd/conf.d/zz010_psa_httpd.conf:83) vs. webmail:443 (/etc/httpd/conf.d/zz010_psa_httpd.conf:159)
[Sun Nov 01 15:19:27 2009] [warn] Init: You should not use name-based virtual hosts in conjunction with SSL!!
[Sun Nov 01 15:19:27 2009] [notice] Digest: generating secret for digest authentication ...
[Sun Nov 01 15:19:27 2009] [notice] Digest: done
[Sun Nov 01 15:19:27 2009] [notice] mod_python: Creating 4 session mutexes based on 10 max processes and 0 max threads.
[Sun Nov 01 15:19:27 2009] [warn] RSA server certificate CommonName (CN) `plesk' does NOT match server name!?
[Sun Nov 01 15:19:27 2009] [warn] RSA server certificate CommonName (CN) `plesk' does NOT match server name!?
[Sun Nov 01 15:19:27 2009] [warn] RSA server certificate CommonName (CN) `plesk' does NOT match server name!?
[Sun Nov 01 15:19:27 2009] [warn] Init: SSL server IP/port conflict: default-64-6-237-192:443 (/etc/httpd/conf.d/zz010_psa_httpd.conf:83) vs. webmail:443 (/etc/httpd/conf.d/zz010_psa_httpd.conf:159)
[Sun Nov 01 15:19:27 2009] [warn] Init: You should not use name-based virtual hosts in conjunction with SSL!!
[Sun Nov 01 15:19:27 2009] [notice] Apache/2.2.3 (CentOS) configured -- resuming normal operations
[Sun Nov 01 16:42:31 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 16:47:25 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 16:59:22 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 17:37:42 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 17:44:54 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 17:44:55 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 17:44:56 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 18:14:45 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 18:40:30 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 20:10:59 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 20:35:10 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 20:43:07 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 20:43:46 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 21:25:39 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 21:26:03 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 21:56:57 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 22:21:02 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 22:25:16 2009] [error] server reached MaxClients setting, consider raising the MaxClients setting
[Sun Nov 01 22:25:17 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 22:25:18 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 22:25:20 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 22:25:21 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 22:25:22 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 22:46:47 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 22:52:56 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 22:56:07 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 22:56:51 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 22:56:58 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 23:00:41 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 23:09:59 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 23:23:49 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 23:27:14 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 23:36:25 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 23:54:06 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 00:12:44 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 00:12:50 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 00:13:23 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 00:39:06 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 00:52:50 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 00:53:02 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 01:13:38 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 01:13:39 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 01:13:40 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 01:23:01 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 01:43:47 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 01:45:51 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 01:46:27 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 01:47:25 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 02:23:02 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 02:25:37 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 02:25:38 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 02:52:29 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 02:52:51 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 03:49:29 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 03:49:48 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 04:35:33 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 04:46:01 2009] [error] [client 66.96.201.63] File does not exist: /var/www/vhosts/default/htdocs/README
[Mon Nov 02 04:46:01 2009] [error] [client 66.96.201.63] File does not exist: /var/www/vhosts/default/htdocs/horde
[Mon Nov 02 04:46:01 2009] [error] [client 66.96.201.63] File does not exist: /var/www/vhosts/default/htdocs/horde2
[Mon Nov 02 04:46:01 2009] [error] [client 66.96.201.63] File does not exist: /var/www/vhosts/default/htdocs/horde3
[Mon Nov 02 04:46:01 2009] [error] [client 66.96.201.63] File does not exist: /var/www/vhosts/default/htdocs/horde-3.0.9
[Mon Nov 02 04:46:01 2009] [error] [client 66.96.201.63] File does not exist: /var/www/vhosts/default/htdocs/Horde
[Mon Nov 02 04:46:02 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 05:01:06 2009] [error] [client 58.246.73.74] File does not exist: /var/www/vhosts/default/htdocs/README
[Mon Nov 02 05:01:06 2009] [error] [client 58.246.73.74] File does not exist: /var/www/vhosts/default/htdocs/horde
[Mon Nov 02 05:01:07 2009] [error] [client 58.246.73.74] File does not exist: /var/www/vhosts/default/htdocs/horde2
[Mon Nov 02 05:01:08 2009] [error] [client 58.246.73.74] File does not exist: /var/www/vhosts/default/htdocs/horde3
[Mon Nov 02 05:01:08 2009] [error] [client 58.246.73.74] File does not exist: /var/www/vhosts/default/htdocs/horde-3.0.9
[Mon Nov 02 05:01:09 2009] [error] [client 58.246.73.74] File does not exist: /var/www/vhosts/default/htdocs/Horde
[Mon Nov 02 05:01:09 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 05:01:10 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 05:01:11 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 09:17:58 2009] [notice] caught SIGTERM, shutting down
[Mon Nov 02 09:18:58 2009] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Mon Nov 02 09:18:58 2009] [warn] RSA server certificate CommonName (CN) `plesk' does NOT match server name!?
[Mon Nov 02 09:18:58 2009] [warn] RSA server certificate CommonName (CN) `plesk' does NOT match server name!?
[Mon Nov 02 09:18:58 2009] [warn] RSA server certificate CommonName (CN) `plesk' does NOT match server name!?
[Mon Nov 02 09:18:58 2009] [warn] Init: SSL server IP/port conflict: default-64-6-237-192:443 (/etc/httpd/conf.d/zz010_psa_httpd.conf:83) vs. webmail:443 (/etc/httpd/conf.d/zz010_psa_httpd.conf:159)
[Mon Nov 02 09:18:58 2009] [warn] Init: You should not use name-based virtual hosts in conjunction with SSL!!
[Mon Nov 02 09:18:58 2009] [notice] Digest: generating secret for digest authentication ...
[Mon Nov 02 09:18:58 2009] [notice] Digest: done
[Mon Nov 02 09:18:58 2009] [notice] mod_python: Creating 4 session mutexes based on 10 max processes and 0 max threads.
[Mon Nov 02 09:18:58 2009] [warn] RSA server certificate CommonName (CN) `plesk' does NOT match server name!?
[Mon Nov 02 09:18:58 2009] [warn] RSA server certificate CommonName (CN) `plesk' does NOT match server name!?
[Mon Nov 02 09:18:58 2009] [warn] RSA server certificate CommonName (CN) `plesk' does NOT match server name!?
[Mon Nov 02 09:18:58 2009] [warn] Init: SSL server IP/port conflict: default-64-6-237-192:443 (/etc/httpd/conf.d/zz010_psa_httpd.conf:83) vs. webmail:443 (/etc/httpd/conf.d/zz010_psa_httpd.conf:159)
[Mon Nov 02 09:18:58 2009] [warn] Init: You should not use name-based virtual hosts in conjunction with SSL!!
[Mon Nov 02 09:18:58 2009] [notice] Apache/2.2.3 (CentOS) configured -- resuming normal operations
[Mon Nov 02 09:32:34 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
```

答:
Apache is not running

It could also be something as simple as Apache not being configured to start automatically on boot. Assuming you are on a Red Hat-like system such as CentOS or Fedora, the chkconfig –list command will show you which services are set to start for each runlevel. You should see a line like

```<code>    httpd           0:off   1:off   2:on    3:on    4:on    5:on    6:off
</code>```

If instead it says "off" all the way across, you can activate it with chkconfig httpd on. OR you can start apache manually from your panel.

Body:
This just started happening three weeks or so ago. The content of my website hasn't changed, it's just a phpBB forum using MySQL as a back end.

Nothing has changed in well over a year but recently, every two days or so, the server just shuts down and cannot be accessed at all, I have to notify my service provider to physically restart the machine.

It seems to be tied to these SIGTERM errors I find in the logs. Problem is I have no idea how to fix these kinds of things or find the root cause as my skills in this area are lacking.

Anyone have any ideas what could be going on?

Apache/2.2.3 (CentOS)

20051115

Linux 2.6.18-028stab057.4 #1 SMP Fri Aug 1 10:47:59 MSD 2008 x86_64

From the error log:

[Sun Nov 01 15:18:53 2009] [notice] caught SIGTERM, shutting down

Not entirely sure that's what's causing me my problems but it doesn't sound like a good thing.

I can post more log information if needed

[Sun Nov 01 05:07:17 2009] [notice] Digest: generating secret for digest authentication ...
[Sun Nov 01 05:07:17 2009] [notice] Digest: done
[Sun Nov 01 05:07:19 2009] [notice] mod_python: Creating 4 session mutexes based on 10 max processes and 0 max threads.
[Sun Nov 01 05:07:19 2009] [warn] RSA server certificate CommonName (CN) `plesk' does NOT match server name!?
[Sun Nov 01 05:07:19 2009] [warn] RSA server certificate CommonName (CN) `plesk' does NOT match server name!?
[Sun Nov 01 05:07:19 2009] [warn] RSA server certificate CommonName (CN) `plesk' does NOT match server name!?
[Sun Nov 01 05:07:19 2009] [warn] Init: SSL server IP/port conflict: default-64-6-237-192:443 (/etc/httpd/conf.d/zz010_psa_httpd.conf:83) vs. webmail:443 (/etc/httpd/conf.d/zz010_psa_httpd.conf:159)
[Sun Nov 01 05:07:19 2009] [warn] Init: You should not use name-based virtual hosts in conjunction with SSL!!
[Sun Nov 01 05:07:19 2009] [warn] WARNING: Attempt to change ServerLimit ignored during restart
[Sun Nov 01 05:07:19 2009] [notice] Apache/2.2.3 (CentOS) configured -- resuming normal operations
[Sun Nov 01 15:16:11 2009] [error] [client 127.0.0.1] Invalid method in request get
[Sun Nov 01 15:18:53 2009] [notice] caught SIGTERM, shutting down
[Sun Nov 01 15:19:27 2009] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Sun Nov 01 15:19:27 2009] [warn] RSA server certificate CommonName (CN) `plesk' does NOT match server name!?
[Sun Nov 01 15:19:27 2009] [warn] RSA server certificate CommonName (CN) `plesk' does NOT match server name!?
[Sun Nov 01 15:19:27 2009] [warn] RSA server certificate CommonName (CN) `plesk' does NOT match server name!?
[Sun Nov 01 15:19:27 2009] [warn] Init: SSL server IP/port conflict: default-64-6-237-192:443 (/etc/httpd/conf.d/zz010_psa_httpd.conf:83) vs. webmail:443 (/etc/httpd/conf.d/zz010_psa_httpd.conf:159)
[Sun Nov 01 15:19:27 2009] [warn] Init: You should not use name-based virtual hosts in conjunction with SSL!!
[Sun Nov 01 15:19:27 2009] [notice] Digest: generating secret for digest authentication ...
[Sun Nov 01 15:19:27 2009] [notice] Digest: done
[Sun Nov 01 15:19:27 2009] [notice] mod_python: Creating 4 session mutexes based on 10 max processes and 0 max threads.
[Sun Nov 01 15:19:27 2009] [warn] RSA server certificate CommonName (CN) `plesk' does NOT match server name!?
[Sun Nov 01 15:19:27 2009] [warn] RSA server certificate CommonName (CN) `plesk' does NOT match server name!?
[Sun Nov 01 15:19:27 2009] [warn] RSA server certificate CommonName (CN) `plesk' does NOT match server name!?
[Sun Nov 01 15:19:27 2009] [warn] Init: SSL server IP/port conflict: default-64-6-237-192:443 (/etc/httpd/conf.d/zz010_psa_httpd.conf:83) vs. webmail:443 (/etc/httpd/conf.d/zz010_psa_httpd.conf:159)
[Sun Nov 01 15:19:27 2009] [warn] Init: You should not use name-based virtual hosts in conjunction with SSL!!
[Sun Nov 01 15:19:27 2009] [notice] Apache/2.2.3 (CentOS) configured -- resuming normal operations
[Sun Nov 01 16:42:31 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 16:47:25 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 16:59:22 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 17:37:42 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 17:44:54 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 17:44:55 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 17:44:56 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 18:14:45 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 18:40:30 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 20:10:59 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 20:35:10 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 20:43:07 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 20:43:46 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 21:25:39 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 21:26:03 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 21:56:57 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 22:21:02 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 22:25:16 2009] [error] server reached MaxClients setting, consider raising the MaxClients setting
[Sun Nov 01 22:25:17 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 22:25:18 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 22:25:20 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 22:25:21 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 22:25:22 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 22:46:47 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 22:52:56 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 22:56:07 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 22:56:51 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 22:56:58 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 23:00:41 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 23:09:59 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 23:23:49 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 23:27:14 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 23:36:25 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Sun Nov 01 23:54:06 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 00:12:44 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 00:12:50 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 00:13:23 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 00:39:06 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 00:52:50 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 00:53:02 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 01:13:38 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 01:13:39 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 01:13:40 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 01:23:01 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 01:43:47 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 01:45:51 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 01:46:27 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 01:47:25 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 02:23:02 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 02:25:37 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 02:25:38 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 02:52:29 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 02:52:51 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 03:49:29 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 03:49:48 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 04:35:33 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 04:46:01 2009] [error] [client 66.96.201.63] File does not exist: /var/www/vhosts/default/htdocs/README
[Mon Nov 02 04:46:01 2009] [error] [client 66.96.201.63] File does not exist: /var/www/vhosts/default/htdocs/horde
[Mon Nov 02 04:46:01 2009] [error] [client 66.96.201.63] File does not exist: /var/www/vhosts/default/htdocs/horde2
[Mon Nov 02 04:46:01 2009] [error] [client 66.96.201.63] File does not exist: /var/www/vhosts/default/htdocs/horde3
[Mon Nov 02 04:46:01 2009] [error] [client 66.96.201.63] File does not exist: /var/www/vhosts/default/htdocs/horde-3.0.9
[Mon Nov 02 04:46:01 2009] [error] [client 66.96.201.63] File does not exist: /var/www/vhosts/default/htdocs/Horde
[Mon Nov 02 04:46:02 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 05:01:06 2009] [error] [client 58.246.73.74] File does not exist: /var/www/vhosts/default/htdocs/README
[Mon Nov 02 05:01:06 2009] [error] [client 58.246.73.74] File does not exist: /var/www/vhosts/default/htdocs/horde
[Mon Nov 02 05:01:07 2009] [error] [client 58.246.73.74] File does not exist: /var/www/vhosts/default/htdocs/horde2
[Mon Nov 02 05:01:08 2009] [error] [client 58.246.73.74] File does not exist: /var/www/vhosts/default/htdocs/horde3
[Mon Nov 02 05:01:08 2009] [error] [client 58.246.73.74] File does not exist: /var/www/vhosts/default/htdocs/horde-3.0.9
[Mon Nov 02 05:01:09 2009] [error] [client 58.246.73.74] File does not exist: /var/www/vhosts/default/htdocs/Horde
[Mon Nov 02 05:01:09 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 05:01:10 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 05:01:11 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 02 09:17:58 2009] [notice] caught SIGTERM, shutting down
[Mon Nov 02 09:18:58 2009] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Mon Nov 02 09:18:58 2009] [warn] RSA server certificate CommonName (CN) `plesk' does NOT match server name!?
[Mon Nov 02 09:18:58 2009] [warn] RSA server certificate CommonName (CN) `plesk' does NOT match server name!?
[Mon Nov 02 09:18:58 2009] [warn] RSA server certificate CommonName (CN) `plesk' does NOT match server name!?
[Mon Nov 02 09:18:58 2009] [warn] Init: SSL server IP/port conflict: default-64-6-237-192:443 (/etc/httpd/conf.d/zz010_psa_httpd.conf:83) vs. webmail:443 (/etc/httpd/conf.d/zz010_psa_httpd.conf:159)
[Mon Nov 02 09:18:58 2009] [warn] Init: You should not use name-based virtual hosts in conjunction with SSL!!
[Mon Nov 02 09:18:58 2009] [notice] Digest: generating secret for digest authentication ...
[Mon Nov 02 09:18:58 2009] [notice] Digest: done
[Mon Nov 02 09:18:58 2009] [notice] mod_python: Creating 4 session mutexes based on 10 max processes and 0 max threads.
[Mon Nov 02 09:18:58 2009] [warn] RSA server certificate CommonName (CN) `plesk' does NOT match server name!?
[Mon Nov 02 09:18:58 2009] [warn] RSA server certificate CommonName (CN) `plesk' does NOT match server name!?
[Mon Nov 02 09:18:58 2009] [warn] RSA server certificate CommonName (CN) `plesk' does NOT match server name!?
[Mon Nov 02 09:18:58 2009] [warn] Init: SSL server IP/port conflict: default-64-6-237-192:443 (/etc/httpd/conf.d/zz010_psa_httpd.conf:83) vs. webmail:443 (/etc/httpd/conf.d/zz010_psa_httpd.conf:159)
[Mon Nov 02 09:18:58 2009] [warn] Init: You should not use name-based virtual hosts in conjunction with SSL!!
[Mon Nov 02 09:18:58 2009] [notice] Apache/2.2.3 (CentOS) configured -- resuming normal operations
[Mon Nov 02 09:32:34 2009] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/

Body:
Apache is not running

It could also be something as simple as Apache not being configured to start automatically on boot. Assuming you are on a Red Hat-like system such as CentOS or Fedora, the chkconfig –list command will show you which services are set to start for each runlevel. You should see a line like

    httpd           0:off   1:off   2:on    3:on    4:on    5:on    6:off

If instead it says "off" all the way across, you can activate it with chkconfig httpd on. OR you can start apache manually from your panel.


问:
Creating react-native project with spesific version
I run npx react-native init bilettm --version 0.59 this command in powershell.At the end of this process I can't create project.Because It gives me an annoying error like this 429 Too Many Requests - GET https://registry.npmjs.org/errorhandler.I am a newcomer in react native.Anyone knows what I should do ?

答:
```<code>react-native init newproject --version react-native@0.59
</code>```

try above command, Hope it works for you.

Body:
react-native init newproject --version react-native@0.59

try above command, Hope it works for you.


问:
Access the variables of a component
I'd like to access a component variable. This variable is modified by an html input.

Here is my current code

Parent :

```<code><template>
   <component>Child</component>
</template>

<script>
export default {
    data () {
        return {
          dataChild : '',
    }
</script>
</code>```

Child :

```<code><template>
    <input type="text" name="data" v-model="data" class="form-control">
</template>

<script>
  export default {
    data () {
      return {
          data: ''
      }
    }
  }
</script>
</code>```

I've looked all over the internet but nothing works on my side or I'm doing wrong :(

Thanks in advance

答:
you can use like below:

Parent

```<code><template>
    <component @input-child="childData"></component>
</template>
<script>
import Component from "@/components/Component";
export default {
   components: { Component },
   data() {
       return {
      dataChild: ""
   };
},
methods: {
    childData(data) {
       console.log(data);
      // you can assign it to dataChild variable
   }
  }
};
</script>
</code>```

Child

```<code><template>
<input
    type="text"
    name="data"
    v-model="data"
    @input="$emit('input-child', data)"
    class="form-control"
 />
</template>

<script>
export default {
    data() {
        return {
            data: ""
        };
    }
};
</script>
</code>```

Title: Access the variables of a component

Body:
I'd like to access a component variable. This variable is modified by an html input.

Here is my current code

Parent :

<template>
   <component>Child</component>
</template>

Child :

<template>
    <input type="text" name="data" v-model="data" class="form-control">
</template>

I've looked all over the internet but nothing works on my side or I'm doing wrong :(

Thanks in advance

Body:
you can use like below:

Parent

<template>
    <component @input-child="childData"></component>
</template>
<script>
import Component from "@/components/Component";
export default {
   components: { Component },
   data() {
       return {
      dataChild: ""
   };
},
methods: {
    childData(data) {
       console.log(data);
      // you can assign it to dataChild variable
   }
  }
};
</script>

Child

<template>
<input
    type="text"
    name="data"
    v-model="data"
    @input="$emit('input-child', data)"
    class="form-control"
 />
</template>

<script>
export default {
    data() {
        return {
            data: ""
        };
    }
};
</script>


问:
Ruby on Rails: How to create a "recent_search_path" helper method?
I have implemented a search feature of my application. After submitting a search term, you are redirected to a url that looks something like this:

```<code>http://localhost:3000/search?utf8=✓&search=term
</code>```

I want to be able to store this in the session and link to it later:

```<code><%= link_to 'Back', recent_search_path %>
</code>```

How might I achieve this?

答:
Thanks to rc for referring me to a very similar question. This could be achieved by storing the current path in the session:

```<code>session[:recent_search_path] = request.url
</code>```

...and retrieving it again in the view:

```<code><%= link_to "Back to search results", session[:recent_search_path] %>
</code>```

Body:
I have implemented a search feature of my application. After submitting a search term, you are redirected to a url that looks something like this:

http://localhost:3000/search?utf8=✓&search=term

I want to be able to store this in the session and link to it later:

<%= link_to 'Back', recent_search_path %>

How might I achieve this?

Body:
Thanks to rc for referring me to a very similar question. This could be achieved by storing the current path in the session:

session[:recent_search_path] = request.url

...and retrieving it again in the view:

<%= link_to "Back to search results", session[:recent_search_path] %>


问:
Ld cannot find libraries, even with ldconfig, and even ld -L -lmylib doesn't open
I got a new system, with Ubuntu 18.04.4.
I am trying to install my environments to compile nvcc and I need glew glfw etc.
here I am trying to install glew 1.10.0 for this program by running the make file and I get the following (other library failures during other installs as well):

```<code>$ make
cc -shared -Wl,-soname=libGLEW.so.1.10 -o lib/libGLEW.so.1.10.0 tmp/linux/default/shared/glew.o -L/usr/lib -lXmu -lXi -lGL -lXext -lX11
/usr/bin/ld: cannot find -lXmu
/usr/bin/ld: cannot find -lXi
collect2: error: ld returned 1 exit status
Makefile:108: recipe for target 'lib/libGLEW.so.1.10.0' failed
make: *** [lib/libGLEW.so.1.10.0] Error 1
</code>```

After sudo ldconfig also no change in the above

I even tried the following

```<code>$ sudo ld -verbose -L/usr/lib/x86_64-linux-gnu -lXmu
GNU ld (GNU Binutils for Ubuntu) 2.30
  Supported emulations:
   elf_x86_64
   elf32_x86_64
   elf_i386
   elf_iamcu
   i386linux
   elf_l1om
   elf_k1om
   i386pep
   i386pe
using internal linker script:
</code>```

...omitting some terminal output

```<code>==================================================
attempt to open //usr/local/lib/x86_64-linux-gnu/libXmu.so failed
attempt to open //usr/local/lib/x86_64-linux-gnu/libXmu.a failed
attempt to open //lib/x86_64-linux-gnu/libXmu.so failed
attempt to open //lib/x86_64-linux-gnu/libXmu.a failed
attempt to open //usr/lib/x86_64-linux-gnu/libXmu.so failed
attempt to open //usr/lib/x86_64-linux-gnu/libXmu.a failed
attempt to open //usr/lib/x86_64-linux-gnu64/libXmu.so failed
attempt to open //usr/lib/x86_64-linux-gnu64/libXmu.a failed
attempt to open //usr/local/lib64/libXmu.so failed
attempt to open //usr/local/lib64/libXmu.a failed
attempt to open //lib64/libXmu.so failed
attempt to open //lib64/libXmu.a failed
attempt to open //usr/lib64/libXmu.so failed
attempt to open //usr/lib64/libXmu.a failed
attempt to open //usr/local/lib/libXmu.so failed
attempt to open //usr/local/lib/libXmu.a failed
attempt to open //lib/libXmu.so failed
attempt to open //lib/libXmu.a failed
attempt to open //usr/lib/libXmu.so failed
attempt to open //usr/lib/libXmu.a failed
attempt to open //usr/x86_64-linux-gnu/lib64/libXmu.so failed
attempt to open //usr/x86_64-linux-gnu/lib64/libXmu.a failed
attempt to open //usr/x86_64-linux-gnu/lib/libXmu.so failed
attempt to open //usr/x86_64-linux-gnu/lib/libXmu.a failed
ld: cannot find -lXmu
</code>```

I am really confused and I don't know how to move on from this point. Do I have to make linkers for each library or there is a simpler more correct method to doing this.
And just to confirm

```<code>locate libXmu
/usr/lib/x86_64-linux-gnu/libXmu.so.6
/usr/lib/x86_64-linux-gnu/libXmu.so.6.2.0
/usr/lib/x86_64-linux-gnu/libXmuu.so.1
/usr/lib/x86_64-linux-gnu/libXmuu.so.1.0.0
</code>```

答:
I believe that eventhough I have been working on linux for 2 years, I am still a newbie.

I just

```<code>sudo apt-get install libxmu-dev
</code>```

&

```<code>sudo apt-get install libxi-dev
</code>```

and the installation worked.

Body:
I got a new system, with Ubuntu 18.04.4.
I am trying to install my environments to compile nvcc and I need glew glfw etc.
here I am trying to install glew 1.10.0 for this program by running the make file and I get the following (other library failures during other installs as well):

$ make
cc -shared -Wl,-soname=libGLEW.so.1.10 -o lib/libGLEW.so.1.10.0 tmp/linux/default/shared/glew.o -L/usr/lib -lXmu -lXi -lGL -lXext -lX11
/usr/bin/ld: cannot find -lXmu
/usr/bin/ld: cannot find -lXi
collect2: error: ld returned 1 exit status
Makefile:108: recipe for target 'lib/libGLEW.so.1.10.0' failed
make: *** [lib/libGLEW.so.1.10.0] Error 1

After sudo ldconfig also no change in the above

I even tried the following

$ sudo ld -verbose -L/usr/lib/x86_64-linux-gnu -lXmu
GNU ld (GNU Binutils for Ubuntu) 2.30
  Supported emulations:
   elf_x86_64
   elf32_x86_64
   elf_i386
   elf_iamcu
   i386linux
   elf_l1om
   elf_k1om
   i386pep
   i386pe
using internal linker script:

...omitting some terminal output

==================================================
attempt to open //usr/local/lib/x86_64-linux-gnu/libXmu.so failed
attempt to open //usr/local/lib/x86_64-linux-gnu/libXmu.a failed
attempt to open //lib/x86_64-linux-gnu/libXmu.so failed
attempt to open //lib/x86_64-linux-gnu/libXmu.a failed
attempt to open //usr/lib/x86_64-linux-gnu/libXmu.so failed
attempt to open //usr/lib/x86_64-linux-gnu/libXmu.a failed
attempt to open //usr/lib/x86_64-linux-gnu64/libXmu.so failed
attempt to open //usr/lib/x86_64-linux-gnu64/libXmu.a failed
attempt to open //usr/local/lib64/libXmu.so failed
attempt to open //usr/local/lib64/libXmu.a failed
attempt to open //lib64/libXmu.so failed
attempt to open //lib64/libXmu.a failed
attempt to open //usr/lib64/libXmu.so failed
attempt to open //usr/lib64/libXmu.a failed
attempt to open //usr/local/lib/libXmu.so failed
attempt to open //usr/local/lib/libXmu.a failed
attempt to open //lib/libXmu.so failed
attempt to open //lib/libXmu.a failed
attempt to open //usr/lib/libXmu.so failed
attempt to open //usr/lib/libXmu.a failed
attempt to open //usr/x86_64-linux-gnu/lib64/libXmu.so failed
attempt to open //usr/x86_64-linux-gnu/lib64/libXmu.a failed
attempt to open //usr/x86_64-linux-gnu/lib/libXmu.so failed
attempt to open //usr/x86_64-linux-gnu/lib/libXmu.a failed
ld: cannot find -lXmu

I am really confused and I don't know how to move on from this point. Do I have to make linkers for each library or there is a simpler more correct method to doing this.
And just to confirm

locate libXmu
/usr/lib/x86_64-linux-gnu/libXmu.so.6
/usr/lib/x86_64-linux-gnu/libXmu.so.6.2.0
/usr/lib/x86_64-linux-gnu/libXmuu.so.1
/usr/lib/x86_64-linux-gnu/libXmuu.so.1.0.0

Body:
I believe that eventhough I have been working on linux for 2 years, I am still a newbie.

I just

sudo apt-get install libxmu-dev

&

sudo apt-get install libxi-dev

and the installation worked.


问:
areTimestampsInSnapshotsEnabled' is deprecated
so I set this firestore db setting like this

```<code>let db = Firestore.firestore()
let settings = db.settings
settings.areTimestampsInSnapshotsEnabled = true // <--- the problem in this line
db.settings = settings
</code>```

but it is said that

areTimestampsInSnapshotsEnabled' is deprecated

so what should I do ?

答:
As per the documentation FirebaseFirestore Framework Reference
FirestoreSettings informs:

Specifies whether to use FIRTimestamps for timestamp fields in FIRDocumentSnapshots. This is now enabled by default and should not be disabled.

So, you don't need to declare this line anymore, only if you want to opt-out of this feature, where you would set to false this parameter on the API.

Let me know if the information helped you!

Body:
so I set this firestore db setting like this

let db = Firestore.firestore()
let settings = db.settings
settings.areTimestampsInSnapshotsEnabled = true // <--- the problem in this line
db.settings = settings

but it is said that

areTimestampsInSnapshotsEnabled' is deprecated

so what should I do ?


问:
wait to promises inside for loop to end. Angular 7 / Typescript
I'm working with Angular 7 and I have a function that have a promise and save the result in an array like this:

```<code>appendImage(item){

this.imageCompress.compressFile(item, 50, 50).then(
  result => {
    this.compressedImages.push(result);
    return this.compressedImages;
  });
</code>```

}

And I'm calling this function/promise from another function that have a for loop:

```<code>async compressFiles() {

if(this.elementsSelected.length > 0){
 for(let i = 0; i < this.elementsSelected.length; i++){
   let actual = this.elementsSelected[i].src;
   let res = await this.appendImage(actual);
   console.log(res);
 }

  return this.compressedImages;

}else{
  console.warn("No Images Selected");
}
</code>```

}

And I need to return the array when all promise calls ends. When I print the array from the appendImage() function, I get the array just like I wanted it, but doing the console.log(res) I get undefined.
What am I doing wrong?

答:
You are not returning from appendImage.

Try the below using an async function.

```<code>async appendImage(item) {
    const result = await this.imageCompress.compressFile(item, 50, 50);
    this.compressedImages.push(result);
    return this.compressedImages;
}
</code>```

Body:
I'm working with Angular 7 and I have a function that have a promise and save the result in an array like this:

appendImage(item){

this.imageCompress.compressFile(item, 50, 50).then(
  result => {
    this.compressedImages.push(result);
    return this.compressedImages;
  });

}

And I'm calling this function/promise from another function that have a for loop:

async compressFiles() {

if(this.elementsSelected.length > 0){
 for(let i = 0; i < this.elementsSelected.length; i++){
   let actual = this.elementsSelected[i].src;
   let res = await this.appendImage(actual);
   console.log(res);
 }

  return this.compressedImages;

}else{
  console.warn("No Images Selected");
}

}

And I need to return the array when all promise calls ends. When I print the array from the appendImage() function, I get the array just like I wanted it, but doing the console.log(res) I get undefined.
What am I doing wrong?

Body:
You are not returning from appendImage.

Try the below using an async function.

async appendImage(item) {
    const result = await this.imageCompress.compressFile(item, 50, 50);
    this.compressedImages.push(result);
    return this.compressedImages;
}


问:
use cdn library in vue js
i have this code snippet and i must use this library for my vue js project:
i put this in my index.html:

```<code><script type="text/javascript">
  !function(){function t(){var t=document.createElement("script");t.type="text/javascript",t.async=!0,localStorage.getItem("rayToken")?t.src="https://app.raychat.io/scripts/js/"+o+"?rid="+localStorage.getItem("rayToken")+"&href="+window.location.href:t.src="https://app.raychat.io/scripts/js/"+o;var e=document.getElementsByTagName("script")[0];e.parentNode.insertBefore(t,e)}var e=document,a=window,o="17a4bb2d-06c8-480d-ba58-045c86187534";"complete"==e.readyState?t():a.attachEvent?a.attachEvent("onload",t):a.addEventListener("load",t,!1)}();
</script>
</code>```

the problem is i want to use a function of it inside of created hook in App.vue and i get undefined and when i use that function with delay it works.
how can i ensure that library is completely loaded and then use that function.

what is the solution??

App.vue:

```<code>          Raychat.setUser({
                email: this.$store.state.userInfo.email,
                name: this.$store.state.userInfo.name,
                phone: this.$store.state.userInfo.phone,
                updateOnce: true
           })
</code>```

答:
There are several ways you can do it, and it really depends how much of the code snippet you want to edit. If you are at liberty to actually update/change the embed code, you can, instead of allowing to create a new
<script type="text/javascript">
  !function(){function t(){var t=document.querySelector('#raychat-script');t.type="text/javascript",t.async=!0,localStorage.getItem("rayToken")?t.src="https://app.raychat.io/scripts/js/"+o+"?rid="+localStorage.getItem("rayToken")+"&href="+window.location.href:t.src="https://app.raychat.io/scripts/js/"+o;var e=document.getElementsByTagName("script")[0];}var e=document,a=window,o="...";"complete"==e.readyState?t():a.attachEvent?a.attachEvent("onload",t):a.addEventListener("load",t,!1)}();
</script>
```

<p>Then, you can simply listen to the <code>load</code> event on <code>#raychat-script</code>, and invoke the logic that you need:</p>

```document.querySelector('#raychat-script').addEventListener('load', () => {
    // When the third party script is loaded
});
```

<p><strong>Warning:</strong> The major drawback of this method is that if another dev overwrites your embed code or that the company changes their strategy, it might not work.</p>

<hr>

<p>If this is not an alternative, your only way is a passive solution, which involves creating some kind of polling method that simply checks if it is possible to access the <code>Raychat</code> variable: </p>

```let timer;
let attempts = 10;
const interval = 250;

function onRaychatLoadedCallback() {
    // Logic here
}

timer = window.setInterval(() => {
    if (attempts <= 0) {
        window.clearInterval(timer);
        console.warn(`Waited for ${attempts * interval / 1000}s, unable to detect if Raychat is loaded`);
        return;
    }

    if (Raychat && typeof Raychat === 'function') {
        window.clearInterval(timer);
        onRaychatLoadedCallback();
    }

    attempts--;
}, interval);
```

Title: use cdn library in vue js

Body:
i have this code snippet and i must use this library for my vue js project:
i put this in my index.html:

the problem is i want to use a function of it inside of created hook in App.vue and i get undefined and when i use that function with delay it works.
how can i ensure that library is completely loaded and then use that function.

what is the solution??

App.vue:

          Raychat.setUser({
                email: this.$store.state.userInfo.email,
                name: this.$store.state.userInfo.name,
                phone: this.$store.state.userInfo.phone,
                updateOnce: true
           })

Body:
There are several ways you can do it, and it really depends how much of the code snippet you want to edit. If you are at liberty to actually update/change the embed code, you can, instead of allowing to create a new <script> element, let it modify the src of a pre-existing empty <script> element to which you can attach an event listener to. I have remove the base64 number string for the o variable because it might be sensitive information:

<script type="text/javascript" id="raychat-script"></script>
<script type="text/javascript">
  !function(){function t(){var t=document.querySelector('#raychat-script');t.type="text/javascript",t.async=!0,localStorage.getItem("rayToken")?t.src="https://app.raychat.io/scripts/js/"+o+"?rid="+localStorage.getItem("rayToken")+"&href="+window.location.href:t.src="https://app.raychat.io/scripts/js/"+o;var e=document.getElementsByTagName("script")[0];}var e=document,a=window,o="...";"complete"==e.readyState?t():a.attachEvent?a.attachEvent("onload",t):a.addEventListener("load",t,!1)}();
</script>

Then, you can simply listen to the load event on #raychat-script, and invoke the logic that you need:

document.querySelector('#raychat-script').addEventListener('load', () => {
    // When the third party script is loaded
});

Warning: The major drawback of this method is that if another dev overwrites your embed code or that the company changes their strategy, it might not work.

If this is not an alternative, your only way is a passive solution, which involves creating some kind of polling method that simply checks if it is possible to access the Raychat variable:

let timer;
let attempts = 10;
const interval = 250;

function onRaychatLoadedCallback() {
    // Logic here
}

timer = window.setInterval(() => {
    if (attempts <= 0) {
        window.clearInterval(timer);
        console.warn(`Waited for ${attempts * interval / 1000}s, unable to detect if Raychat is loaded`);
        return;
    }

    if (Raychat && typeof Raychat === 'function') {
        window.clearInterval(timer);
        onRaychatLoadedCallback();
    }

    attempts--;
}, interval);


问:
TabLayoutPanel - Show tabs based on roles
I'm developing a GWT-Application where the navigation is mainly a TabLayoutPane, where each Tab represents a different functionality. What I need is to only show tabs the user is allowed to see (each user has a role like user or admin).

The problem is I don't know how to achieve this, especially with UIBinder.

Here's what I thought of:

Don't use UIBinder and build the TabLayoutPanel programmatically.

Use UIBinder and just hide certain tabs based on each users role (which sounds like it would be quite inefficient).

Or are there better ways to achieve something like this?

答:
I would go with approach number one as it is much cleaner, imho.
However, make sure that you don't use it as security feature and don't show any sensitive information that non admin is not allowed to see. Since all construction will occur in javascript in the browser, it will be fairly simple to fool browser into showing admin tabs without appropriate authorization.</p>


问:
How to modify the default execution order of sql script in liquibase?
I am trying to run a bunch of sql script in the Liquibase. But, be default, liquibase executes all the scripts in the order they are placed in the directory. Is there any way by which I can alter the execution default execution of these scripts i..e, execute by create table script first and then all the insert script.

My master changelog file :

```<code><?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
        xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
                      http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
    <includeAll path="../migration/" relativeToChangelogFile="true"/>
</databaseChangeLog>
</code>```

I am placing all the sql script in migration folder.

答:
You can't modify the execution order. The only thing you can do is to change the order of files in your /migration directory by renaming them.

As far as I know, Liquibase sorts files in alphabetical order.

And inside the files Liquibase executes changeSets one by one from top to bottom.

OR

You can use <include> instead of <includeAll>. This way you'd be able to include changeLog files in the order you need.

```<code><?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
        xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
                      http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
    <include file="../migration/changeLog_3.xml" relativeToChangelogFile="true"/>
    <include file="../migration/changeLog_1.xml" relativeToChangelogFile="true"/>
    <include file="../migration/changeLog_2.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>
</code>```

Body:
I am trying to run a bunch of sql script in the Liquibase. But, be default, liquibase executes all the scripts in the order they are placed in the directory. Is there any way by which I can alter the execution default execution of these scripts i..e, execute by create table script first and then all the insert script.

My master changelog file :

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
        xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
                      http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
    <includeAll path="../migration/" relativeToChangelogFile="true"/>
</databaseChangeLog>

I am placing all the sql script in migration folder.

Body:
You can't modify the execution order. The only thing you can do is to change the order of files in your /migration directory by renaming them.

As far as I know, Liquibase sorts files in alphabetical order.

And inside the files Liquibase executes changeSets one by one from top to bottom.

OR

You can use <include> instead of <includeAll>. This way you'd be able to include changeLog files in the order you need.

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
        xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
                      http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
    <include file="../migration/changeLog_3.xml" relativeToChangelogFile="true"/>
    <include file="../migration/changeLog_1.xml" relativeToChangelogFile="true"/>
    <include file="../migration/changeLog_2.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>