问:
How will _Exit behave in a C++ program?
C99 offers the _Exit function, which exits "immediately", although it does may close file descriptors. Unix/POSIX extends this behavior by mandating the closing of all fd's without flushing (and offers the synonym _exit).

Will these functions call destructors for static objects when called from a C++ program? Does the C++ standard make any guarantees about _Exit?

(Inspired by this question; I suddenly wondered what happens in the typical fork-exec-_exit idiom in C++.)

答: There is an interesting analysis here in relation with concurrency and object destruction. As far as I know, destructors will not be called. There is nothing about it in the current standard.</p>

Title: How will _Exit behave in a C++ program?


来源: stackexchange

问:
How to auto adjust the views in Android Studio 3.0 according to the screen size of the device
enter image description hereI am unable to implement the auto-layout concept in Android Studio as i used to do in in Xcode.

Here are the screenshots, one is on Nexus One screen and another one is on Nexus 7's big screen. View aren't getting adjusted automatically according to the screen size.

答:
I haven't seen your code but there are a few things you can try:

 Use different drawables for different screen densities (drawables-hdpi, drawables-xhdpi and so on).

 In your .xml file when defining your sizes use dp instead of px. dp or display pixels will fill the screen according to how many pixels there are rather than assuming there are the same amount of pixels on each screen.

 Use Margins instead of absolute sizes. (e.g. android:layout_marginLeft="2dp") would mean that that item lets say a button will be 2 display pixels from the left margin of the phone.

ContentLicense: CC BY-SA 3.0


问:
How to assign annotation value from application.properties in Spring Boot?
I have an entity/model with discriminator formula and now I'm assigning a discriminator formula like the following sample,

```<code>@Entity
@DiscriminatorFormula("type")
class Student {
    // code
}
</code>```

In the same case, how can I assign discriminator value from application.properties in Spring Boot?

答: The expression in the class level annotation should be a constant, i.e., final and static. What you are trying to achieve is not possible. The best you can do is read it from a constant file rather than application.properties.

Body:
I have an entity/model with discriminator formula and now I'm assigning a discriminator formula like the following sample,

@Entity
@DiscriminatorFormula("type")
class Student {
    // code
}

In the same case, how can I assign discriminator value from application.properties in Spring Boot?


问:
Detect device from extension file (Swift)
How can I place my code to identify the device in the Extension file?

```<code>if UIDevice().userInterfaceIdiom == .pad {
        switch UIScreen.main.nativeBounds.height {
        case 2048:
            print("iPad Pro 9.7/Air")
        case 2224:
            print("iPad Pro 10.5")
        case 2732:
            print("iPad Pro 12.9")
            displayResultLabel.frame = CGRect(x: 2, y: 90, width: 370, height: 91)
            displayResultLabel.font = displayResultLabel.font.withSize(105)
        default:
            print("unknown")
        }
    }
</code>```

答:
```<code>extension THE_NAME_OF_CLASS_TO_EXTEND {

   func printDevice() {
        if UIDevice().userInterfaceIdiom == .pad {
            switch UIScreen.main.nativeBounds.height {
            case 2048:
                print("iPad Pro 9.7/Air")
            case 2224:
                print("iPad Pro 10.5")
            case 2732:
                print("iPad Pro 12.9")
                displayResultLabel.frame = CGRect(x: 2, y: 90, width: 370, height: 91)
                displayResultLabel.font = displayResultLabel.font.withSize(105)
            default:
                print("unknown")
            }
        }
    }
}
</code>```

Then you could use this:

```<code>THE_INSTANCE_OF_THE_CLASS_THAT_HAS_THE_NAME_OF_CLASS_TO_EXTEND.printDevice()
</code>```

So You just need to copy that code to a new file.

Replace The THE_NAME_OF_CLASS_TO_EXTEND with the name of your class

And replace the THE_INSTANCE_OF_THE_CLASS_THAT_HAS_THE_NAME_OF_CLASS_TO_EXTEND with the name of your INSTANCE of that class.. Than it'll work =]

Body:
How can I place my code to identify the device in the Extension file?

if UIDevice().userInterfaceIdiom == .pad {
        switch UIScreen.main.nativeBounds.height {
        case 2048:
            print("iPad Pro 9.7/Air")
        case 2224:
            print("iPad Pro 10.5")
        case 2732:
            print("iPad Pro 12.9")
            displayResultLabel.frame = CGRect(x: 2, y: 90, width: 370, height: 91)
            displayResultLabel.font = displayResultLabel.font.withSize(105)
        default:
            print("unknown")
        }
    }

Body:
extension THE_NAME_OF_CLASS_TO_EXTEND {

   func printDevice() {
        if UIDevice().userInterfaceIdiom == .pad {
            switch UIScreen.main.nativeBounds.height {
            case 2048:
                print("iPad Pro 9.7/Air")
            case 2224:
                print("iPad Pro 10.5")
            case 2732:
                print("iPad Pro 12.9")
                displayResultLabel.frame = CGRect(x: 2, y: 90, width: 370, height: 91)
                displayResultLabel.font = displayResultLabel.font.withSize(105)
            default:
                print("unknown")
            }
        }
    }
}

Then you could use this:

THE_INSTANCE_OF_THE_CLASS_THAT_HAS_THE_NAME_OF_CLASS_TO_EXTEND.printDevice()

So You just need to copy that code to a new file.

Replace The THE_NAME_OF_CLASS_TO_EXTEND with the name of your class

And replace the THE_INSTANCE_OF_THE_CLASS_THAT_HAS_THE_NAME_OF_CLASS_TO_EXTEND with the name of your INSTANCE of that class.. Than it'll work =]


问:
Using Button(GUI) and WhileLoop in Python
I have simple Python code whitch starts from command line on Raspberry PI like:

```<code>import ...

def def_1(....)
def def_2(....)

 if __name__ == ‘__main__’:
    while:
         def_1(....)
         def_2(....)
</code>```

So,I want to add 3 buttons(GUI):

Which starts only def_1(infinite loop)

Which starts only def_2(infinite loop)

Whitch end def_1 or def_2

How I can do it?

答:
first select which framework you want to work with pyqt, tkinter...

Then refer to the api´s doc, where especially documented how to use button, to construct buttons.

```<code>import Tkinter
import tkMessageBox

top = Tkinter.Tk()

def helloCallBack():
    tkMessageBox.showinfo( "Hello Python", "Hello World")

B = Tkinter.Button(top, text ="Hello", command = helloCallBack)

B.pack()
top.mainloop()
</code>```

in this mini example you can see, how to call a function within a button initializing. With the command definition. For more details in gui programming, edit some tutorials

example from https://www.tutorialspoint.com/python/tk_button.htm

Body:
I have simple Python code whitch starts from command line on Raspberry PI like:

import ...

def def_1(....)
def def_2(....)

 if __name__ == ‘__main__’:
    while:
         def_1(....)
         def_2(....)

So,I want to add 3 buttons(GUI):

Which starts only def_1(infinite loop)

Which starts only def_2(infinite loop)

Whitch end def_1 or def_2

How I can do it?

Body:
first select which framework you want to work with pyqt, tkinter...

Then refer to the api´s doc, where especially documented how to use button, to construct buttons.

import Tkinter
import tkMessageBox

top = Tkinter.Tk()

def helloCallBack():
    tkMessageBox.showinfo( "Hello Python", "Hello World")

B = Tkinter.Button(top, text ="Hello", command = helloCallBack)

B.pack()
top.mainloop()

in this mini example you can see, how to call a function within a button initializing. With the command definition. For more details in gui programming, edit some tutorials

example from https://www.tutorialspoint.com/python/tk_button.htm


问:
PLSQL check for the column value and replace it with blank
There is one column named 'Type' and it will have multiple comma separated values.

I have to check if it contains 'Test1','Test2 Test3' or 'Test4' and replace it with blank. How to do it?

I tried finding those words in the column value and using the replace function but it doesn't clear out the comma before/after the value.

Also if I replace the comma by blank, it will get replace before and after all the values. I also want to make sure that my code consumes the least execution time which is obviously not possible if I use three different update functions for all the records one by one.

答:
If you want to replace only the matching words (specific values) with blank

```<code>SELECT REPLACE('Test1 and Test2','Test1','') "Changes"
FROM DUAL;
</code>```

If you want to replace the whole value with blank when matching patterns

```<code>SELECT CASE WHEN 'Test1 and Test2' LIKE '%Test1%' THEN '' END
FROM DUAL;
</code>```

Body:
If you want to replace only the matching words (specific values) with blank

SELECT REPLACE('Test1 and Test2','Test1','') "Changes"
FROM DUAL;

If you want to replace the whole value with blank when matching patterns

SELECT CASE WHEN 'Test1 and Test2' LIKE '%Test1%' THEN '' END
FROM DUAL;


问:
Give the classes a specific id
I have a question about the class, and give the class a specific id.

For example I've got a html code like this:

```<code><div class="test">text1</div>
<div class="test">text2</div>
<div class="test">text3</div>
<div class="test">text4</div>
<div class="test">text5</div>
</code>```

My question is how can I add an id by each .test class.

I thought something like this in Jquery:

```<code>var i = 1;
$('.test').each(function(){
   $('.test').attr('id','id_'+i+'');
   i++
});
</code>```

This doesn't work I think it's something with .closest() or .next()
to solve this problem.

Regards,

Frank

EDIT:

I solved the problem by myself the answer is:

```<code>    $('.test').each(function(){
        $(this).attr('class','test').attr('id','id_'+i+'');
        i++;
    });
</code>```

答:
Much faster and simpler like this:

```<code>$('.test').each(function(i){
   this.id = 'id_' + i;
});
</code>```

There's no need for .attr() when setting or getting the id of an element.

Or if you wanted the numbers to start with 1, do this:

```<code>$('.test').each(function(i){
   this.id = 'id_' + (i + 1);
});
</code>```

ContentLicense: CC BY-SA 2.5

Title: Give the classes a specific id

Body:
I have a question about the class, and give the class a specific id.

For example I've got a html code like this:

text1

text2

text3

text4

text5

My question is how can I add an id by each .test class.

I thought something like this in Jquery:

var i = 1;
$('.test').each(function(){
   $('.test').attr('id','id_'+i+'');
   i++
});

This doesn't work I think it's something with .closest() or .next()
to solve this problem.

Regards,

Frank

EDIT:

I solved the problem by myself the answer is:

    $('.test').each(function(){
        $(this).attr('class','test').attr('id','id_'+i+'');
        i++;
    });

Body:
Much faster and simpler like this:

$('.test').each(function(i){
   this.id = 'id_' + i;
});

There's no need for .attr() when setting or getting the id of an element.

Or if you wanted the numbers to start with 1, do this:

$('.test').each(function(i){
   this.id = 'id_' + (i + 1);
});


问:
How to get "Manage User Secrets" in a .NET Core console-application?
When I create a new ASP .NET Core Web-Application, I can right-click the project in Visual Studio, and I see a context-menu entry called "Manage User Secrets".

When I create a new .NET Core Console-Application, I don't see this context-menu entry.

However, a "Web"-Application shows as "console" application in the project settings. Is there any way I can get this context-menu entry in a console-application ?

答:
1.Add to your project file (Prior to dotnet 2.1 only):

```<code><ItemGroup>
    <DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="2.0.0" />
 </ItemGroup>
</code>```

2.Set

```<code> <PropertyGroup>
     <UserSecretsId>a random user id: manually add</UserSecretsId>
 </PropertyGroup>
</code>```

Move to the migration project folder in Package Manager Console and add a key:value like:

```<code>dotnet user-secrets set "ConnectionStrings:DefaultConnection" "xxxxx"
</code>```

Remember to be in the directory of that project (for Package manager console this means cd'ing into the project, not solution level)

Body:
1.Add to your project file (Prior to dotnet 2.1 only):

<ItemGroup>
    <DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="2.0.0" />
 </ItemGroup>

2.Set

 <PropertyGroup>
     <UserSecretsId>a random user id: manually add</UserSecretsId>
 </PropertyGroup>

Move to the migration project folder in Package Manager Console and add a key:value like:

dotnet user-secrets set "ConnectionStrings:DefaultConnection" "xxxxx"

Remember to be in the directory of that project (for Package manager console this means cd'ing into the project, not solution level)

ContentLicense: CC BY-SA 4.0


问:
ORA-01843: not a valid month error in oracle while updating
I want to update my date column with the format as dd-mm-yy. And in my database the column is of date datatype. So while Updating I am sending data as

05-12-2017 but getting error as

ORA-01843: not a valid month

in my stored procedure I am sending it as

HOTO_ACCEPTENCE_DATE = TO_DATE(PHOTO_ACCEPTENCE_DATE, 'dd-m-yy'),

My full procedure:

```<code>PROCEDURE UPD_WF_BY_FIBER_ENG
(
  PJOB_PROGRESS_ID IN TBL_FIBER_INV_JOB_PROGRESS.JOB_PROGRESS_ID%TYPE,
  PSTATUS_ID IN TBL_FIBER_INV_JOB_PROGRESS.STATUS_ID%TYPE,
  --PLIT_OFFERED_LENGTH IN TBL_FIBER_INV_JOB_PROGRESS.LIT_OFFERED_LENGTH%TYPE,
  PHOTO_ACTUAL_LENGTH IN TBL_FIBER_INV_JOB_PROGRESS.HOTO_ACTUAL_LENGTH%TYPE,
  PLIT_ACTUAL_LENGTH IN TBL_FIBER_INV_JOB_PROGRESS.LIT_ACTUAL_LENGTH%TYPE,

  PHOTO_ACCEPTENCE_DATE IN TBL_FIBER_INV_JOB_PROGRESS.HOTO_ACCEPTENCE_DATE%TYPE,
  PLIT_ACCEPTENCE_DATE IN TBL_FIBER_INV_JOB_PROGRESS.LIT_ACCEPTENCE_DATE%TYPE,

  PAPPROVED_BY IN TBL_FIBER_INV_JOB_PROGRESS.APPROVED_BY%TYPE,
  PREJECTED_BY IN TBL_FIBER_INV_JOB_PROGRESS.REJECTED_BY%TYPE,

  PAPPROV_REJECT_REMARK IN TBL_FIBER_INV_JOB_PROGRESS.APPROV_REJECT_REMARK%TYPE,

  PMODIFIED_BY IN TBL_FIBER_INV_JOB_PROGRESS.MODIFIED_BY%TYPE,
  PUMS_GROUP_ASS_BY_ID IN TBL_FIBER_INV_JOB_PROGRESS.UMS_GROUP_ASS_BY_ID%TYPE,
  PUMS_GROUP_ASS_BY_NAME IN TBL_FIBER_INV_JOB_PROGRESS.UMS_GROUP_ASS_BY_NAME%TYPE,
  PUMS_GROUP_ASS_TO_ID IN TBL_FIBER_INV_JOB_PROGRESS.UMS_GROUP_ASS_TO_ID%TYPE,
  PUMS_GROUP_ASS_TO_NAME IN TBL_FIBER_INV_JOB_PROGRESS.UMS_GROUP_ASS_TO_NAME%TYPE,
  PISABDMISSING IN TBL_FIBER_INV_JOB_PROGRESS.ISABDMISSING%TYPE,
  --PSPVENDORXML IN XMLTYPE,
  POUTMSG OUT NVARCHAR2
)
AS
VCNTSPVENCNT NUMBER :=0;
BEGIN

  UPDATE TBL_FIBER_INV_JOB_PROGRESS
    SET STATUS_ID = PSTATUS_ID,
       -- LIT_OFFERED_LENGTH = PLIT_OFFERED_LENGTH,
        HOTO_ACTUAL_LENGTH = PHOTO_ACTUAL_LENGTH,
        LIT_ACTUAL_LENGTH = PLIT_ACTUAL_LENGTH,
        HOTO_ACCEPTENCE_DATE = TO_DATE(PHOTO_ACCEPTENCE_DATE, 'DD-MM-YY'),
        LIT_ACCEPTENCE_DATE = TO_DATE(PLIT_ACCEPTENCE_DATE,  'DD-MM-YY'),
        APPROVED_BY = PAPPROVED_BY,
        APPROVED_DATE = DECODE(PAPPROVED_BY,NULL,NULL,SYSDATE),
        REJECTED_BY = PREJECTED_BY,
        REJECTED_DATE = DECODE(PREJECTED_BY,NULL,NULL,SYSDATE),
        APPROV_REJECT_REMARK = PAPPROV_REJECT_REMARK,
        MODIFIED_BY = PMODIFIED_BY,
        MODIFIED_DATE = SYSDATE,
        UMS_GROUP_ASS_BY_ID = PUMS_GROUP_ASS_BY_ID,
        UMS_GROUP_ASS_BY_NAME = PUMS_GROUP_ASS_BY_NAME,
        UMS_GROUP_ASS_TO_ID = PUMS_GROUP_ASS_TO_ID,
        UMS_GROUP_ASS_TO_NAME = PUMS_GROUP_ASS_TO_NAME,
        ISABDMISSING = PISABDMISSING
    WHERE JOB_PROGRESS_ID   = PJOB_PROGRESS_ID;
</code>```

update

```<code>try
        {
            DBObject ObjDBObject = new DBObject(strConnectionString);
            string strProcedureName = strPackageName + ".UPD_WF_BY_FIBER_ENG";

            List<OracleParameter> lstParameters = new List<OracleParameter>();

            OracleParameter ObjOracleParameter = new OracleParameter("PJOB_PROGRESS_ID", FiberDataInsertion.PROG_ID);
            OracleParameter ObjOracleParameter1 = new OracleParameter("PSTATUS_ID", 1);
            OracleParameter ObjOracleParameter2 = new OracleParameter("PHOTO_ACTUAL_LENGTH", FiberDataInsertion.HOTO_ACTUAL_LENGTH);
            OracleParameter ObjOracleParameter3 = new OracleParameter("PLIT_ACTUAL_LENGTH", FiberDataInsertion.LIT_ACTUAL_LENGTH);
            OracleParameter ObjOracleParameter4 = new OracleParameter("PHOTO_ACCEPTENCE_DATE", FiberDataInsertion.HOTO_ACCP_DATE);
            OracleParameter ObjOracleParameter5 = new OracleParameter("PLIT_ACCEPTENCE_DATE", FiberDataInsertion.LIT_ACCP_DATE);
            OracleParameter ObjOracleParameter6 = new OracleParameter("PAPPROVED_BY", "NADEEM5.KHAN");
            OracleParameter ObjOracleParameter7 = new OracleParameter("PREJECTED_BY", "DB");
            OracleParameter ObjOracleParameter8 = new OracleParameter("PAPPROV_REJECT_REMARK", "this is test");
            OracleParameter ObjOracleParameter9 = new OracleParameter("PMODIFIED_BY", FiberDataInsertion.MODIFIED_BY);
            OracleParameter ObjOracleParameter10 = new OracleParameter("PUMS_GROUP_ASS_BY_ID", FiberDataInsertion.UMS_GROUP_ASS_BY_ID);
            OracleParameter ObjOracleParameter11 = new OracleParameter("PUMS_GROUP_ASS_BY_NAME", FiberDataInsertion.UMS_GROUP_ASS_BY_NAME);
            OracleParameter ObjOracleParameter12 = new OracleParameter("PUMS_GROUP_ASS_TO_ID", FiberDataInsertion.UMS_GROUP_ASS_TO_ID);
            OracleParameter ObjOracleParameter13 = new OracleParameter("PUMS_GROUP_ASS_TO_NAME", FiberDataInsertion.UMS_GROUP_ASS_TO_NAME);
            OracleParameter ObjOracleParameter14 = new OracleParameter("PISABDMISSING", FiberDataInsertion.MISS_ASBUILT);

            OracleParameter ObjOracleParameter15 = new OracleParameter
            {
                ParameterName = "POUTMSG",
                Size = 500,
                OracleDbType = OracleDbType.NVarchar2,
                Direction = ParameterDirection.Output
            };

            lstParameters.Add(ObjOracleParameter);
            lstParameters.Add(ObjOracleParameter1);
            lstParameters.Add(ObjOracleParameter2);
            lstParameters.Add(ObjOracleParameter3);
            lstParameters.Add(ObjOracleParameter4);
            lstParameters.Add(ObjOracleParameter5);
            lstParameters.Add(ObjOracleParameter6);
            lstParameters.Add(ObjOracleParameter7);
            lstParameters.Add(ObjOracleParameter8);
            lstParameters.Add(ObjOracleParameter9);
            lstParameters.Add(ObjOracleParameter10);
            lstParameters.Add(ObjOracleParameter11);
            lstParameters.Add(ObjOracleParameter12);
            lstParameters.Add(ObjOracleParameter13);
            lstParameters.Add(ObjOracleParameter14);
            lstParameters.Add(ObjOracleParameter15);

            strMessage = ObjDBObject.ExecuteNonQuery(strProcedureName, lstParameters);

        }
        catch (Exception)
        {
            throw;
        }
        return strMessage;
</code>```

Also the error details

at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure, Boolean bCheck)
   at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, String procedure, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, Boolean bCheck)
   at Oracle.DataAccess.Client.OracleCommand.ExecuteNonQuery()
   at FiberInventoryPortal.Models.DAL.DBObject.ExecuteNonQuery(String strProcedureName, List1 lstParameters) in d:\Nadeem\FiberInventory_214\FiberInventoryPortal\FiberInventoryPortal\Models\DAL\DBObject.cs:line 114`

答:
```<code>HOTO_ACCEPTENCE_DATE = TO_DATE(PHOTO_ACCEPTENCE_DATE, 'DD-MM-YY')
</code>```

TO_DATE( date_string, format_model, nls_params ) takes a string as the first argument so Oracle must implicitly convert a non-string argument to a string and is effectively doing:

```<code>HOTO_ACCEPTENCE_DATE = TO_DATE(
                         TO_CHAR(
                           PHOTO_ACCEPTENCE_DATE,
                           ( SELECT value
                             FROM   NLS_SESSION_PARAMETERS
                             WHERE  parameter = 'NLS_DATE_FORMAT' )
                         ),
                         'DD-MM-YY'
                       )
</code>```

If the NLS_DATE_FORMAT session parameter does not match DD-MM-YY then you will get an error. Since the NLS_DATE_FORMAT is a session parameter and can be changed by each user then relying on this is one way for your code to start raising exception as the users change their settings without your code ever changing.

What you want to do is just use:

```<code>HOTO_ACCEPTENCE_DATE = PHOTO_ACCEPTENCE_DATE,
</code>```

As you do not need to convert a date to anything when you are storing it as a date.

I want to update my date column with the format as dd-mm-yy.

A date does not have a format - it is stored internally to the database as 7-bytes (representing year, month, day, hour, minute and second) and it is not until whatever user interface you are using (i.e. SQL/Plus, SQL Developer, Java, etc) tries to display it to you, the user, and converts it into something you would find meaningful (usually a string) that the date has a format.

Body:
I want to update my date column with the format as dd-mm-yy. And in my database the column is of date datatype. So while Updating I am sending data as

05-12-2017 but getting error as

ORA-01843: not a valid month

in my stored procedure I am sending it as

HOTO_ACCEPTENCE_DATE = TO_DATE(PHOTO_ACCEPTENCE_DATE, 'dd-m-yy'),

My full procedure:

PROCEDURE UPD_WF_BY_FIBER_ENG
(
  PJOB_PROGRESS_ID IN TBL_FIBER_INV_JOB_PROGRESS.JOB_PROGRESS_ID%TYPE,
  PSTATUS_ID IN TBL_FIBER_INV_JOB_PROGRESS.STATUS_ID%TYPE,
  --PLIT_OFFERED_LENGTH IN TBL_FIBER_INV_JOB_PROGRESS.LIT_OFFERED_LENGTH%TYPE,
  PHOTO_ACTUAL_LENGTH IN TBL_FIBER_INV_JOB_PROGRESS.HOTO_ACTUAL_LENGTH%TYPE,
  PLIT_ACTUAL_LENGTH IN TBL_FIBER_INV_JOB_PROGRESS.LIT_ACTUAL_LENGTH%TYPE,

  PHOTO_ACCEPTENCE_DATE IN TBL_FIBER_INV_JOB_PROGRESS.HOTO_ACCEPTENCE_DATE%TYPE,
  PLIT_ACCEPTENCE_DATE IN TBL_FIBER_INV_JOB_PROGRESS.LIT_ACCEPTENCE_DATE%TYPE,

  PAPPROVED_BY IN TBL_FIBER_INV_JOB_PROGRESS.APPROVED_BY%TYPE,
  PREJECTED_BY IN TBL_FIBER_INV_JOB_PROGRESS.REJECTED_BY%TYPE,

  PAPPROV_REJECT_REMARK IN TBL_FIBER_INV_JOB_PROGRESS.APPROV_REJECT_REMARK%TYPE,

  PMODIFIED_BY IN TBL_FIBER_INV_JOB_PROGRESS.MODIFIED_BY%TYPE,
  PUMS_GROUP_ASS_BY_ID IN TBL_FIBER_INV_JOB_PROGRESS.UMS_GROUP_ASS_BY_ID%TYPE,
  PUMS_GROUP_ASS_BY_NAME IN TBL_FIBER_INV_JOB_PROGRESS.UMS_GROUP_ASS_BY_NAME%TYPE,
  PUMS_GROUP_ASS_TO_ID IN TBL_FIBER_INV_JOB_PROGRESS.UMS_GROUP_ASS_TO_ID%TYPE,
  PUMS_GROUP_ASS_TO_NAME IN TBL_FIBER_INV_JOB_PROGRESS.UMS_GROUP_ASS_TO_NAME%TYPE,
  PISABDMISSING IN TBL_FIBER_INV_JOB_PROGRESS.ISABDMISSING%TYPE,
  --PSPVENDORXML IN XMLTYPE,
  POUTMSG OUT NVARCHAR2
)
AS
VCNTSPVENCNT NUMBER :=0;
BEGIN

  UPDATE TBL_FIBER_INV_JOB_PROGRESS
    SET STATUS_ID = PSTATUS_ID,
       -- LIT_OFFERED_LENGTH = PLIT_OFFERED_LENGTH,
        HOTO_ACTUAL_LENGTH = PHOTO_ACTUAL_LENGTH,
        LIT_ACTUAL_LENGTH = PLIT_ACTUAL_LENGTH,
        HOTO_ACCEPTENCE_DATE = TO_DATE(PHOTO_ACCEPTENCE_DATE, 'DD-MM-YY'),
        LIT_ACCEPTENCE_DATE = TO_DATE(PLIT_ACCEPTENCE_DATE,  'DD-MM-YY'),
        APPROVED_BY = PAPPROVED_BY,
        APPROVED_DATE = DECODE(PAPPROVED_BY,NULL,NULL,SYSDATE),
        REJECTED_BY = PREJECTED_BY,
        REJECTED_DATE = DECODE(PREJECTED_BY,NULL,NULL,SYSDATE),
        APPROV_REJECT_REMARK = PAPPROV_REJECT_REMARK,
        MODIFIED_BY = PMODIFIED_BY,
        MODIFIED_DATE = SYSDATE,
        UMS_GROUP_ASS_BY_ID = PUMS_GROUP_ASS_BY_ID,
        UMS_GROUP_ASS_BY_NAME = PUMS_GROUP_ASS_BY_NAME,
        UMS_GROUP_ASS_TO_ID = PUMS_GROUP_ASS_TO_ID,
        UMS_GROUP_ASS_TO_NAME = PUMS_GROUP_ASS_TO_NAME,
        ISABDMISSING = PISABDMISSING
    WHERE JOB_PROGRESS_ID   = PJOB_PROGRESS_ID;

update

try
        {
            DBObject ObjDBObject = new DBObject(strConnectionString);
            string strProcedureName = strPackageName + ".UPD_WF_BY_FIBER_ENG";

            List<OracleParameter> lstParameters = new List<OracleParameter>();

            OracleParameter ObjOracleParameter = new OracleParameter("PJOB_PROGRESS_ID", FiberDataInsertion.PROG_ID);
            OracleParameter ObjOracleParameter1 = new OracleParameter("PSTATUS_ID", 1);
            OracleParameter ObjOracleParameter2 = new OracleParameter("PHOTO_ACTUAL_LENGTH", FiberDataInsertion.HOTO_ACTUAL_LENGTH);
            OracleParameter ObjOracleParameter3 = new OracleParameter("PLIT_ACTUAL_LENGTH", FiberDataInsertion.LIT_ACTUAL_LENGTH);
            OracleParameter ObjOracleParameter4 = new OracleParameter("PHOTO_ACCEPTENCE_DATE", FiberDataInsertion.HOTO_ACCP_DATE);
            OracleParameter ObjOracleParameter5 = new OracleParameter("PLIT_ACCEPTENCE_DATE", FiberDataInsertion.LIT_ACCP_DATE);
            OracleParameter ObjOracleParameter6 = new OracleParameter("PAPPROVED_BY", "NADEEM5.KHAN");
            OracleParameter ObjOracleParameter7 = new OracleParameter("PREJECTED_BY", "DB");
            OracleParameter ObjOracleParameter8 = new OracleParameter("PAPPROV_REJECT_REMARK", "this is test");
            OracleParameter ObjOracleParameter9 = new OracleParameter("PMODIFIED_BY", FiberDataInsertion.MODIFIED_BY);
            OracleParameter ObjOracleParameter10 = new OracleParameter("PUMS_GROUP_ASS_BY_ID", FiberDataInsertion.UMS_GROUP_ASS_BY_ID);
            OracleParameter ObjOracleParameter11 = new OracleParameter("PUMS_GROUP_ASS_BY_NAME", FiberDataInsertion.UMS_GROUP_ASS_BY_NAME);
            OracleParameter ObjOracleParameter12 = new OracleParameter("PUMS_GROUP_ASS_TO_ID", FiberDataInsertion.UMS_GROUP_ASS_TO_ID);
            OracleParameter ObjOracleParameter13 = new OracleParameter("PUMS_GROUP_ASS_TO_NAME", FiberDataInsertion.UMS_GROUP_ASS_TO_NAME);
            OracleParameter ObjOracleParameter14 = new OracleParameter("PISABDMISSING", FiberDataInsertion.MISS_ASBUILT);

            OracleParameter ObjOracleParameter15 = new OracleParameter
            {
                ParameterName = "POUTMSG",
                Size = 500,
                OracleDbType = OracleDbType.NVarchar2,
                Direction = ParameterDirection.Output
            };

            lstParameters.Add(ObjOracleParameter);
            lstParameters.Add(ObjOracleParameter1);
            lstParameters.Add(ObjOracleParameter2);
            lstParameters.Add(ObjOracleParameter3);
            lstParameters.Add(ObjOracleParameter4);
            lstParameters.Add(ObjOracleParameter5);
            lstParameters.Add(ObjOracleParameter6);
            lstParameters.Add(ObjOracleParameter7);
            lstParameters.Add(ObjOracleParameter8);
            lstParameters.Add(ObjOracleParameter9);
            lstParameters.Add(ObjOracleParameter10);
            lstParameters.Add(ObjOracleParameter11);
            lstParameters.Add(ObjOracleParameter12);
            lstParameters.Add(ObjOracleParameter13);
            lstParameters.Add(ObjOracleParameter14);
            lstParameters.Add(ObjOracleParameter15);

            strMessage = ObjDBObject.ExecuteNonQuery(strProcedureName, lstParameters);

        }
        catch (Exception)
        {
            throw;
        }
        return strMessage;

Also the error details

at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure, Boolean bCheck)
   at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, String procedure, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, Boolean bCheck)
   at Oracle.DataAccess.Client.OracleCommand.ExecuteNonQuery()
   at FiberInventoryPortal.Models.DAL.DBObject.ExecuteNonQuery(String strProcedureName, List1 lstParameters) in d:\Nadeem\FiberInventory_214\FiberInventoryPortal\FiberInventoryPortal\Models\DAL\DBObject.cs:line 114`

Body:
HOTO_ACCEPTENCE_DATE = TO_DATE(PHOTO_ACCEPTENCE_DATE, 'DD-MM-YY')

TO_DATE( date_string, format_model, nls_params ) takes a string as the first argument so Oracle must implicitly convert a non-string argument to a string and is effectively doing:

HOTO_ACCEPTENCE_DATE = TO_DATE(
                         TO_CHAR(
                           PHOTO_ACCEPTENCE_DATE,
                           ( SELECT value
                             FROM   NLS_SESSION_PARAMETERS
                             WHERE  parameter = 'NLS_DATE_FORMAT' )
                         ),
                         'DD-MM-YY'
                       )

If the NLS_DATE_FORMAT session parameter does not match DD-MM-YY then you will get an error. Since the NLS_DATE_FORMAT is a session parameter and can be changed by each user then relying on this is one way for your code to start raising exception as the users change their settings without your code ever changing.

What you want to do is just use:

HOTO_ACCEPTENCE_DATE = PHOTO_ACCEPTENCE_DATE,

As you do not need to convert a date to anything when you are storing it as a date.

I want to update my date column with the format as dd-mm-yy.

A date does not have a format - it is stored internally to the database as 7-bytes (representing year, month, day, hour, minute and second) and it is not until whatever user interface you are using (i.e. SQL/Plus, SQL Developer, Java, etc) tries to display it to you, the user, and converts it into something you would find meaningful (usually a string) that the date has a format.


问:
Convert IDN string to UTF-8
How can I convert IDNA ASCII to UTF8 in objective-C?
For example I have the following string:

```<code>xn--ixaia4a8au
</code>```

Is it possible?

答:
Punycode-Cocoa

Nate Weaver has published an Objective-C wrapper based on RFC 3492's pure C reference implementation called Punycode Cocoa:

A simple punycode/IDNA category on NSString, based on code and documentation from RFC 3492 and RFC 3490.

Use this to convert internationalized domain names (IDN) between Unicode and ASCII.

To use in your own projects, all you need is NSStringPunycodeAdditions.h/m. This project includes a sample testing app.

Title: Convert IDN string to UTF-8

Body:
How can I convert IDNA ASCII to UTF8 in objective-C?
For example I have the following string:

xn--ixaia4a8au

Is it possible?


问:
How to fix error 403 error php files
I'm running ubuntu 16.04 and installed LAMP this way:

Install Apache

sudo apt-get install apache2

Install MySQL

sudo apt-get install mysql-server

Install PHP

sudo apt-get install php7.0 libapache2-mod-php7.0

Restart Server

sudo /etc/init.d/apache2 restart

Check Apache

Working

Check PHP

php -r 'echo "\n\nYour PHP installation is working fine.\n\n\n";'

Working

Files structure:

/var/www/html/index.html > redirects to index.php
  /var/www/html/pages/index.php < this file is not working and all php files

The owner group is set to:

chown -R www-data:www-data /var/www

The folders permissions are 755. The index.php permssions is 644 This is my apache2.conf file: https://ghostbin.com/paste/wwhog

But when i go to: http://localhost/pages/index.php I get this 403 Forbidden error. It seems like i can't see php files.

答:
Try chown -R www-data:www-data /var/www, if you still get a 403, that means the problem is in apache2 conf, but i do not think.

I'll complete this response when i'll can see your apache's conf :) (apache2.conf & sites-enabled/000-default.conf -it should be the one you'are using in /var/www/html/-)

Title: How to fix error 403 error php files


问:
What is the ObjectRepository in doctrine and what is his role
In Doctrine there is an interface Doctrine\Common\Persistence\ObjectRepository .
Can someone explain the role and what are the uses of this interface.

答:
Well, it's not a Class, it's an Interface. It's part of the Doctrine Common library

It's implemented the Doctrine ORM library (Doctrine\ORM\EntityRepository) and by the Doctrine MongoDB Object Document Mapper (Doctrine\ODM\MongoDB\DocumentRepository).

If you don't want to use Doctrine ORM or MongoDB and write your own ObjectRepository instead, you should implement the interface.

The most common way to write your own EntityRepository (with Doctrine ORM) is to extend Doctrine\ORM\EntityRepository.


问:
C# DataTable Filter Fastest Way
I have a datatable that include over 300.000 records and this equals over 2.000.000 words. I have an algorithm that get all words from each records and working well but I feel it is looks like little slow.

I want to speed up this program.

Program works like that;

Getting all records from database to datatable.

Loop datatable and get all words from each record.

For each word check new datatable contains that word, if not add to new datatable.

I search some titles about speed up this program.

using foreach or for ? (I think, there is no difference)

for checking datatable has words or not, using DataTable.Select() or Linq (actually Linq is faster)

But I worry about that check each word contains or make a word field primary (I don't know it works or not) or getting all words without checking and after all works using a distinc.

Can you give me some advice. Thanks.

```<code>        DataTable dtProducts = getProducts();
        bool contains;
        string[] keys;

        dt.Columns.Add("keyword", typeof(string));

        for (int i = 0; i < dtProducts.Rows.Count; i++) //114040
        {
            keys = GetWords(dtProducts.Rows[i]["name"].ToString().Trim());

            foreach (string key in keys)
            {
                DataRow dr = dt.NewRow();
                dr["keyword"] = key;

                contains = dt.AsEnumerable().Any(row => key == row.Field<string>("keyword"));

                if (!contains)
                {
                    dt.Rows.Add(dr);
                }
            }
        }
</code>```

答:
Here you can see that the fastest method is Parallel together with Linq:</p>

```<code>        var sampleResults = from DataRow sampleRow in dataTableLocal.AsEnumerable()
                            where sampleRow.Field<string>("FirstColumn") == symbolName
                            select sampleRow;

        Parallel.ForEach(sampleResults, sampleRow =>
        {
            string sval = sampleRow["SecondColumn"].ToString();
        });
</code>```

Title: C# DataTable Filter Fastest Way

Body:
I have a datatable that include over 300.000 records and this equals over 2.000.000 words. I have an algorithm that get all words from each records and working well but I feel it is looks like little slow.

I want to speed up this program.

Program works like that;

Getting all records from database to datatable.

Loop datatable and get all words from each record.

For each word check new datatable contains that word, if not add to new datatable.

I search some titles about speed up this program.

using foreach or for ? (I think, there is no difference)

for checking datatable has words or not, using DataTable.Select() or Linq (actually Linq is faster)

But I worry about that check each word contains or make a word field primary (I don't know it works or not) or getting all words without checking and after all works using a distinc.

Can you give me some advice. Thanks.

        DataTable dtProducts = getProducts();
        bool contains;
        string[] keys;

        dt.Columns.Add("keyword", typeof(string));

        for (int i = 0; i < dtProducts.Rows.Count; i++) //114040
        {
            keys = GetWords(dtProducts.Rows[i]["name"].ToString().Trim());

            foreach (string key in keys)
            {
                DataRow dr = dt.NewRow();
                dr["keyword"] = key;

                contains = dt.AsEnumerable().Any(row => key == row.Field<string>("keyword"));

                if (!contains)
                {
                    dt.Rows.Add(dr);
                }
            }
        }

Body:
Here you can see that the fastest method is Parallel together with Linq:

        var sampleResults = from DataRow sampleRow in dataTableLocal.AsEnumerable()
                            where sampleRow.Field<string>("FirstColumn") == symbolName
                            select sampleRow;

        Parallel.ForEach(sampleResults, sampleRow =>
        {
            string sval = sampleRow["SecondColumn"].ToString();
        });


问:
Force eloquent to use mutators during serialization
Is there a way to force eloquent to use mutators when serializing data? I am currently converting my app to use vue.js and several fields are computed within the model, which I need to be included, in the serialized data.

Eloquent\Model - make toArray() utilize mutators

I understand why Taylor does not honour mutators but is there a way to override this behaviour?

答:
Before returning the model, you can do this

```<code>$model->setAppends(['mutator_1', 'mutator_2']);
return $model->toArray();
</code>```

if you want to use it on a collection :

```<code>$collection->each(function($model) { $model->setAppends(...); });
</code>```

Body:
Before returning the model, you can do this

$model->setAppends(['mutator_1', 'mutator_2']);
return $model->toArray();

if you want to use it on a collection :

$collection->each(function($model) { $model->setAppends(...); });


问:
how to compute the variable name of a session scope variable for a repeat control
I would like to compute the variable name of a sessionScope variable that I use as the data binding source for a xp:repeat control.

I notice the diamond to compute the variable name is not there. Perhaps it is possible via another way?

答: In theory it should be. Scoped variables are Maps. A dominoDocument datasource works as an object in the similar way - document1.myField runs as document1.getValue("myField") and document1.setValue("myField"). I know there are ways to bind to a computed field name, I think in a Custom Control, for example, getting a field name passed in would be document1[#{compositeData.passedField)]. So a similar process for binding to a scoped variable - sessionScope[#{myComputedVariable}] should, in theory, work.


问:
I have written a findClosestPrime() in C++, but Xcode complains that "Control may reach end of non-void function"
I've written a function in C++ to find the closest prime number after the input number. Let's assume the input number is larger than 100, so there is no special check for the cases when the input number is 1 or 2 or etc.

```<code>int getClosestPrime(int inputNum){
    bool isPrime = false;
    inputNum++;
    while (!isPrime){
        for (int i = 2; i <= inputNum/2; i++){
            if (inputNum % i == 0){
                isPrime = false;
                break; //if at any time found it's not a prime, break the for loop
            }
            isPrime = true;
        }
        if (isPrime == false){
            inputNum++;
        } else {
            return inputNum;
        }
    }
}
</code>```

I think the logic should be good enough as I tested here on ideone: https://ideone.com/hcUpvK it's giving the right results.

However, when I use Xcode to run the code, it always complains that "Control may reach end of non-void function".

Could anybody explain? Thanks!

答:
If you want to avoid the warning you could change the code slightly so that XCode would be able to see that your logic is sound (which it is). It might look something like this.</p>

```<code>int getClosestPrime(int inputNum){
    bool isPrime = false;
    inputNum++;
    while (!isPrime){
        isPrime = true; // assume the number is a prime
        for (int i = 2; i <= inputNum/2; i++){
            if (inputNum % i == 0){
                inputNum++; // go to next number
                isPrime = false; // the number is *not* a prime
                break; // done with this number
            }
        }
    }
    return inputNum;
}
</code>```

Body:
I've written a function in C++ to find the closest prime number after the input number. Let's assume the input number is larger than 100, so there is no special check for the cases when the input number is 1 or 2 or etc.

int getClosestPrime(int inputNum){
    bool isPrime = false;
    inputNum++;
    while (!isPrime){
        for (int i = 2; i <= inputNum/2; i++){
            if (inputNum % i == 0){
                isPrime = false;
                break; //if at any time found it's not a prime, break the for loop
            }
            isPrime = true;
        }
        if (isPrime == false){
            inputNum++;
        } else {
            return inputNum;
        }
    }
}

I think the logic should be good enough as I tested here on ideone: https://ideone.com/hcUpvK it's giving the right results.

However, when I use Xcode to run the code, it always complains that "Control may reach end of non-void function".

Could anybody explain? Thanks!

Body:
If you want to avoid the warning you could change the code slightly so that XCode would be able to see that your logic is sound (which it is). It might look something like this.

int getClosestPrime(int inputNum){
    bool isPrime = false;
    inputNum++;
    while (!isPrime){
        isPrime = true; // assume the number is a prime
        for (int i = 2; i <= inputNum/2; i++){
            if (inputNum % i == 0){
                inputNum++; // go to next number
                isPrime = false; // the number is *not* a prime
                break; // done with this number
            }
        }
    }
    return inputNum;
}


问:
How to define authenticated helper in routes.rb to call or access application controller current_user method
I want to define authenticated root for the application. I am using  omniauth-identity gem for the authentication and define current_user helper in application controller.

```<code>def current_user
  @current_user ||= User.find_by_id(session[:user_id]) if session[:user_id]
end
helper_method :current_user

def current_user=(user)
 session[:user_id] = user.id
end
</code>```

And in routes.rb
I want root based on condition

```<code> root to: 'map#index', constraints: Constraints
 root to: 'pages#about'
</code>```

And within Constraints.rb module defines matches? method

```<code>module Constraints
 def self.matches?(request)
   user = current_user(request)
   return true if user.present?
   false
 end
 def current_user(request)
   @current_user ||= User.find_by_id(request.session[:user_id]) if request.session[:user_id]
 end
end
</code>```

And it works fine but the problem duplicate method current_user or we need to check session twice.

In routes we need to pass request object and available locally. so how we can call or pass controller current_user method with request object. Any suggestion so we can define in one place and access it.

It's something similar to devise gem
authenticated and unauthenticated routes helper.

答:
Instead of adding condition in routes, Simply direct it to application controller method and there use redirect_to to redirect accordingly.

```<code>class ApplicationController
  def index
    if current_user
      redirect_to "maps_path"
    else
      redirect_to "pages_path"
  end

  def current_user
    # your logic
  end
end
</code>```

in routes.rb

```<code>root to: /
</code>```

Hope this solves your problem

Body:
I want to define authenticated root for the application. I am using  omniauth-identity gem for the authentication and define current_user helper in application controller.

def current_user
  @current_user ||= User.find_by_id(session[:user_id]) if session[:user_id]
end
helper_method :current_user

def current_user=(user)
 session[:user_id] = user.id
end

And in routes.rb
I want root based on condition

 root to: 'map#index', constraints: Constraints
 root to: 'pages#about'

And within Constraints.rb module defines matches? method

module Constraints
 def self.matches?(request)
   user = current_user(request)
   return true if user.present?
   false
 end
 def current_user(request)
   @current_user ||= User.find_by_id(request.session[:user_id]) if request.session[:user_id]
 end
end

And it works fine but the problem duplicate method current_user or we need to check session twice.

In routes we need to pass request object and available locally. so how we can call or pass controller current_user method with request object. Any suggestion so we can define in one place and access it.

It's something similar to devise gem
authenticated and unauthenticated routes helper.

Body:
Instead of adding condition in routes, Simply direct it to application controller method and there use redirect_to to redirect accordingly.

class ApplicationController
  def index
    if current_user
      redirect_to "maps_path"
    else
      redirect_to "pages_path"
  end

  def current_user
    # your logic
  end
end

in routes.rb

root to: /

Hope this solves your problem


问:
unable to select an item in cxImageComboBox1
I added 3 items to cxImageComboBox1.

Assigned ImageList1 for the images.
Looks like this :

At runtime it displays images correctly. However only the first image (1) can be selected. I can not select the '2' or '3' :

Why wont it allow me to make the selection ? I do not understand.
Also it wont allow me to set the ImageIndex to -1 so it displays empty at runtime.

答: You must make unique value for every Items (Set Value 1,2,3)</p>


问:
How determine Hive database size?
How determine Hive's database size from Bash or from Hive CLI?

hdfs and hadoop commands are also avaliable in Bash.

答:
if you want the size of your complete database run this on your "warehouse"

```<code>hdfs dfs -du -h /apps/hive/warehouse
</code>```

this gives you the size of each DB in your warehouse

if you want the size of tables in a specific DB run:

```<code>hdfs dfs -du -h /apps/hive/warehouse/<db_name>
</code>```

run a "grep warehouse" on hive-site.xml to find your warehouse path

Title: How determine Hive database size?

Body:
if you want the size of your complete database run this on your "warehouse"

hdfs dfs -du -h /apps/hive/warehouse

this gives you the size of each DB in your warehouse

if you want the size of tables in a specific DB run:

hdfs dfs -du -h /apps/hive/warehouse/<db_name>

run a "grep warehouse" on hive-site.xml to find your warehouse path


问:
What is the most minimal functional programming language?
What is the most minimal functional programming language?</p>

答:
BrainF*ck is a simple, easy to use programming language. Here's a quick rundown.

Imagine you have a near-infinite range of boxes, each empty. Luckily, you are not alone! You can move back and forth along the line, put things in them, and take them out. Though quite basic, with enough time you can do about anything: http://www.iwriteiam.nl/Ha_bf_inter.html. Here are the commands.

```<code>+ | add one to currrent box
- | take one from current box
> | move one box to the right
< | move one box to the left
[] | loop
. | print current value
, | input current value
</code>```

other stuff to look at:

P" | simplified BF

language f | newer simplified BF

http://www2.gvsu.edu/miljours/bf.html | cool BF stuff/intro

https://www.esolangs.org/wiki/Language_list | list of similar langs/variants

Body:
BrainF*ck is a simple, easy to use programming language. Here's a quick rundown.

Imagine you have a near-infinite range of boxes, each empty. Luckily, you are not alone! You can move back and forth along the line, put things in them, and take them out. Though quite basic, with enough time you can do about anything: http://www.iwriteiam.nl/Ha_bf_inter.html. Here are the commands.

+ | add one to currrent box
- | take one from current box
> | move one box to the right
< | move one box to the left
[] | loop
. | print current value
, | input current value

other stuff to look at:

P" | simplified BF

language f | newer simplified BF

http://www2.gvsu.edu/miljours/bf.html | cool BF stuff/intro

https://www.esolangs.org/wiki/Language_list | list of similar langs/variants


问:
How can I send more than 8 byte data over UART on android Things raspberry pie?
I want to send more than 8 byte data over the UART connection I am currently using USB 2.0 to TTL with 4 pin. I think my option is to use USB 2.0 to TTL with 6 pins is it correct?
If not what are my option?
for e.g I want to send 234212441325454543595674859764
how can i send it usb to TTL with 4 pins?</p>

答: If you really need 9-bit UART, please see this question. But if you want to send 234212441325454543595674859764 in ASCII - that is normal case for UART. Take a look at this and that and many other examples and tutorials. If you receive not full string, but it parts - just concat them.</p>


问:
Selecting data-style-name in (Python/Splinter)
I'd like to select an item in a specific color from an unordered list. One poster in another thread suggested I try browser.find_by_xpath("/html/body/a[@data-style-name='COLOR HERE'", but that didn't work. The XPath (taken from the website) looks like this: /html/body/div[2]/div/div[2]/ul/li[2]/a[1]. How could click this option in Splinter?

答:
You should try related XPath like

```<code>//a[@data-style-name='COLOR HERE']
</code>```

because /html/body/a[@data-style-name='COLOR HERE'] means that target link is immediate child of body node which is obviously not true...

Body:
You should try related XPath like

//a[@data-style-name='COLOR HERE']

because /html/body/a[@data-style-name='COLOR HERE'] means that target link is immediate child of body node which is obviously not true...


问:
dynamically show text box based on dynamically created dropdown menue
I am very new in jsp, and jquery
my code create dynamic text boxes and one drop-down menu based on button clicked,

after created textboxes I want to add one more textbox if the user select option male after the text boxes dynamically added.

the add code works, but the text box when selecting the male option not works.

please please help.

this is my code

```<code><body>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <br />
    <div class="container">
        <h3 align="center">Change Control Board (CCB)</h3>
        <br />
        <h4 align="center">Enter Change Details</h4>
        <br />
        <form name="form1" method="GET" action="jsv" id="form1">
            <div class="table-repsonsive">
                <span id="error"></span>
                <table class="table table-bordered" id="item_table">
                    <tr>
                        <th>Enter Change Name</th>
                        <th>Enter Change Description</th>
                        <th>Enter Change GW</th>
                        <th>Enter Change AW</th>
                        <th><button type="button" name="add" class="btn btn-success btn-sm add"><span class="glyphicon glyphicon-plus"></span></button></th>
                    </tr>
                </table>
                <div align="center">
                    <input type="submit" name="submit" class="btn btn-info" value="Insert" />
                </div>
            </div>
        </form>
    </div>
</body>

</html>
<script>
    $(document).ready(function() {

        $(document).on('click', '.add', function() {
            var html = '';
            html += '<tr> name="change_name1[]"';
            html += '<td><input type="text" name="change_name[]" class="form-control change_name" /></td>';
            html += '<td><textarea name="change_desc[]" class="form-control change_desc rows="3"" /></td>';
            html += '<td><input  type="text" name="change_GW[]" class="form-control change_GW" /></td>';
            html += '<td><input style="display:none;" id="business"  type="text" name="change_G[]" class="form-control change_GW" /></td>';

            html += '<td><select id="purpose" name="sex-type" class="form-control item_unit"><option value="0">select</option><option value="1">male</option><option value="2">Passing on to a client</option></select></td>';

            html += '<td><button type="button" name="remove" class="btn btn-danger btn-sm remove"><span class="glyphicon glyphicon-minus"></span></button></td></tr>';
            $('#item_table').append(html);
        });

        $(document).on('click', '.remove', function() {
            $(this).closest('tr').remove();
        });
    });

    $(document).ready(function() {
        $('#purpose').on('change', function() {
            if (this.value == '1') {
                $("#business").show();
            } else {
                $("#business").hide();
            }
        });
    });
</script>
</code>```

答:
Cut this code:

```<code>$('#purpose').on('change', function() {
  if ( this.value == '1')
    {
       $("#business").show();
    }
         else
    {
       $("#business").hide();
   }
}
</code>```

and paste it right behind  $('#item_table').append(html);

Two $(document).ready() sections make no sense. And the event handler (on click) needs to be attached after you create the select box.

Body:
I am very new in jsp, and jquery
my code create dynamic text boxes and one drop-down menu based on button clicked,

after created textboxes I want to add one more textbox if the user select option male after the text boxes dynamically added.

the add code works, but the text box when selecting the male option not works.

please please help.

this is my code

Change Control Board (CCB)

Enter Change Details

        <form name="form1" method="GET" action="jsv" id="form1">

                        Enter Change Name
                        Enter Change Description
                        Enter Change GW
                        Enter Change AW
                        <button type="button" name="add" class="btn btn-success btn-sm add"></button>

                    <input type="submit" name="submit" class="btn btn-info" value="Insert" />

        </form>

Body:
Cut this code:

$('#purpose').on('change', function() {
  if ( this.value == '1')
    {
       $("#business").show();
    }
         else
    {
       $("#business").hide();
   }
}

and paste it right behind  $('#item_table').append(html);

Two $(document).ready() sections make no sense. And the event handler (on click) needs to be attached after you create the select box.


问:
float is not displaying the right format . looking for xxxxxx.xx
```<code>float fRealEsate = 360000.00 * 0.04;
 Toast.makeText(v.getContext(), "Real Estate Brokerage Fee: "
                     + fRealEsate, Toast.LENGTH_SHORT).show();
</code>```

I need it to display 15600.00 but its displaying 15600.0

答:
```<code>float f = 123456.123456f;
NumberFormat nf = new DecimalFormat(".00");
System.out.println(nf.format(f));//123456.12
</code>```

Document

Body:
float fRealEsate = 360000.00 * 0.04;
 Toast.makeText(v.getContext(), "Real Estate Brokerage Fee: "
                     + fRealEsate, Toast.LENGTH_SHORT).show();

I need it to display 15600.00 but its displaying 15600.0

Body:
float f = 123456.123456f;
NumberFormat nf = new DecimalFormat(".00");
System.out.println(nf.format(f));//123456.12

Document


答:
You are adding select dynamically at run time.so, after adding Select You need to bind it's change event.
So Just make change into your javascript code </p>

```<code><script>
    $(document).ready(function(){
    counter=0;
    $(document).on('click', '.add', function(){
      counter=counter+1;
      var html = '';
     html += '<tr> name="change_name1[]"';
     html += '<td><input type="text" name="change_name[]" class="form-control change_name" /></td>';
     html += '<td><textarea name="change_desc[]" class="form-control change_desc rows="3"" /></td>';
     html += '<td><input  type="text" name="change_GW[]" class="form-control change_GW" /></td>';
     html += '<td><input style="display:none;" id="business_'+counter+'"  type="text" name="change_G[]" class="form-control change_GW" /></td>';

    html += '<td><select id="purpose_'+counter+'" name="sex-type" class="form-control item_unit"><option value="0">select</option><option value="1">male</option><option value="2">Passing on to a client</option></select></td>';

     html += '<td><button type="button" name="remove" class="btn btn-danger btn-sm remove"><span class="glyphicon glyphicon-minus"></span></button></td></tr>';
    $('#item_table').append(html);
    $('#purpose_'+counter).on('change', function() {
         if ( this.value == '1')
          {
            $("#business_"+counter).show();
          }
         else
        {
          $("#business_"+counter).hide();
         }

        });
    });

        $(document).on('click', '.remove', function(){
         $(this).closest('tr').remove();
        });

        });

    </script>
</code>```

Title: dynamically show text box based on dynamically created dropdown menue

Body:
You are adding select dynamically at run time.so, after adding Select You need to bind it's change event.
So Just make change into your javascript code

<script>
    $(document).ready(function(){
    counter=0;
    $(document).on('click', '.add', function(){
      counter=counter+1;
      var html = '';
     html += '<tr> name="change_name1[]"';
     html += '<td><input type="text" name="change_name[]" class="form-control change_name" /></td>';
     html += '<td><textarea name="change_desc[]" class="form-control change_desc rows="3"" /></td>';
     html += '<td><input  type="text" name="change_GW[]" class="form-control change_GW" /></td>';
     html += '<td><input style="display:none;" id="business_'+counter+'"  type="text" name="change_G[]" class="form-control change_GW" /></td>';

    html += '<td><select id="purpose_'+counter+'" name="sex-type" class="form-control item_unit"><option value="0">select</option><option value="1">male</option><option value="2">Passing on to a client</option></select></td>';

     html += '<td><button type="button" name="remove" class="btn btn-danger btn-sm remove"><span class="glyphicon glyphicon-minus"></span></button></td></tr>';
    $('#item_table').append(html);
    $('#purpose_'+counter).on('change', function() {
         if ( this.value == '1')
          {
            $("#business_"+counter).show();
          }
         else
        {
          $("#business_"+counter).hide();
         }

        });
    });

        $(document).on('click', '.remove', function(){
         $(this).closest('tr').remove();
        });

        });

    </script>


问:
opposite of object destructuring
Given the following example. Is there a shorthand for the field asignment </p>

```<code>let myObj = {someField: 'someValue'}
let foo = 'value'

myObj.foo = foo // I would like to do the opposite of object destructuring: const {foo} = myObj. I don't want to repeat foo twice.
</code>```

答:
You could use Object.assign with a short hand property.

const myObj = {}
const foo = 'value'

Object.assign(myObj, { foo });

console.log(myObj);```

Title: opposite of object destructuring

Body:
Given the following example. Is there a shorthand for the field asignment

let myObj = {someField: 'someValue'}
let foo = 'value'

myObj.foo = foo // I would like to do the opposite of object destructuring: const {foo} = myObj. I don't want to repeat foo twice.


问:
Getting Mean of all aggregated values for every quarter hour in dataframe and assigning
I have some sampled data from a sensor with no particular time differences between samples looking like this:

```<code>> Y_cl[[1]]
     index       Date     time Glucose                 POS
10      11 2017-06-10 03:01:00     136 2017-06-10 00:01:00
14      15 2017-06-10 03:06:00     132 2017-06-10 00:06:00
18      19 2017-06-10 03:11:00     133 2017-06-10 00:11:00
22      23 2017-06-10 03:16:00     130 2017-06-10 00:16:00
26      27 2017-06-10 03:20:59     119 2017-06-10 00:20:59
30      31 2017-06-10 03:26:00     115 2017-06-10 00:26:00
34      35 2017-06-10 03:30:59     117 2017-06-10 00:30:59
38      39 2017-06-10 03:36:00     114 2017-06-10 00:36:00
42      43 2017-06-10 03:40:59     113 2017-06-10 00:40:59
</code>```

The data is saved in the format of Dataframes stored in list Y_cl, each list element is for one day. I am trying to select ALL samples between every quarter hour of the clock and get the mean, resulting in 4 points for each hour of each day, mathematically defined (NOT CODE) as:

```<code>mean(Glucose(H:00 <Y_cl[[1]]$time< H:15))==> Glucose_av(H:00),
mean(Glucose(H:15 <Y_cl[[1]]$time< H:30))==> Glucose_av(H:15),
mean(Glucose(H:30 <Y_cl[[1]]$time< H:45))==> Glucose_av(H:30),
mean(Glucose(H:45 <Y_cl[[1]]$time< (H+1):00))==>Glucose_av(H:45)
</code>```

I have tried searching but have found links on how to select or cut every 15 minutes differences, while I need to group every hours data based on which quarter of the hour they are in, average, and assign the result to corresponding quarter. Y_cl[[1]]['POS'] is in standard POSIXct format.  Any help would be appreciated.

答:
I did it by flooring the result of the minutes of each time stamp divided by 15, where YPOS is the list within the time stamps for each day i with the list Y_cl exist:

```<code>SeI<- function(i){

*###seperate the hours from the minutes for use later and store in K1*
strftime(YPOS[[i]], format="%H")

K1<- (floor((as.numeric(strftime(YPOS[[i]], format="%M")))/15))*15

*###get the minutes and divide by 15, keeping the floor,multiplying by 15,store in K2*
K2<- strftime(YPOS[[i]], format="%Y-%m-%d %H", tz="GMT")

*###paste K1 and K2 together an save in POSTIXCT format as T_av*
TT<- paste0(K2, ':', K1)
T_av<- as.POSIXct(TT,format="%Y-%m-%d %H:%M", tz="GMT" )}
</code>```

and then applying it over all days in the list:

```<code>lapply(1:length(Y_cl), function(i) SeI(i) )
</code>```

My solution included taking the time stamps from the list Y_cl and saving it in YPOS.

Body:
I have some sampled data from a sensor with no particular time differences between samples looking like this:

> Y_cl[[1]]
     index       Date     time Glucose                 POS
10      11 2017-06-10 03:01:00     136 2017-06-10 00:01:00
14      15 2017-06-10 03:06:00     132 2017-06-10 00:06:00
18      19 2017-06-10 03:11:00     133 2017-06-10 00:11:00
22      23 2017-06-10 03:16:00     130 2017-06-10 00:16:00
26      27 2017-06-10 03:20:59     119 2017-06-10 00:20:59
30      31 2017-06-10 03:26:00     115 2017-06-10 00:26:00
34      35 2017-06-10 03:30:59     117 2017-06-10 00:30:59
38      39 2017-06-10 03:36:00     114 2017-06-10 00:36:00
42      43 2017-06-10 03:40:59     113 2017-06-10 00:40:59

The data is saved in the format of Dataframes stored in list Y_cl, each list element is for one day. I am trying to select ALL samples between every quarter hour of the clock and get the mean, resulting in 4 points for each hour of each day, mathematically defined (NOT CODE) as:

mean(Glucose(H:00 <Y_cl[[1]]$time< H:15))==> Glucose_av(H:00),
mean(Glucose(H:15 <Y_cl[[1]]$time< H:30))==> Glucose_av(H:15),
mean(Glucose(H:30 <Y_cl[[1]]$time< H:45))==> Glucose_av(H:30),
mean(Glucose(H:45 <Y_cl[[1]]$time< (H+1):00))==>Glucose_av(H:45)

I have tried searching but have found links on how to select or cut every 15 minutes differences, while I need to group every hours data based on which quarter of the hour they are in, average, and assign the result to corresponding quarter. Y_cl[[1]]['POS'] is in standard POSIXct format.  Any help would be appreciated.

Body:
I did it by flooring the result of the minutes of each time stamp divided by 15, where YPOS is the list within the time stamps for each day i with the list Y_cl exist:

SeI<- function(i){

*###seperate the hours from the minutes for use later and store in K1*
strftime(YPOS[[i]], format="%H")

K1<- (floor((as.numeric(strftime(YPOS[[i]], format="%M")))/15))*15

*###get the minutes and divide by 15, keeping the floor,multiplying by 15,store in K2*
K2<- strftime(YPOS[[i]], format="%Y-%m-%d %H", tz="GMT")

*###paste K1 and K2 together an save in POSTIXCT format as T_av*
TT<- paste0(K2, ':', K1)
T_av<- as.POSIXct(TT,format="%Y-%m-%d %H:%M", tz="GMT" )}

and then applying it over all days in the list:

lapply(1:length(Y_cl), function(i) SeI(i) )

My solution included taking the time stamps from the list Y_cl and saving it in YPOS.


问:
markitUp WYSIWYG JQuery Editor, basic question - Rails app
I recently installed MarkItUp, the JQuery WYSIWYG editor located here: http://markitup.jaysalvat.com/documentation/

It was a pretty easy install, and my text area looks correct. However, the text is submitted, and appears exactly how it looked in the text box. I.e. if bold in the text box is ** bold ** then thats what shows up in the view, ** bold **.

I feel like I've missed something obvious. Any ideas?

答:
You could use some markdown parser ... I suggest Rdiscount .
link text

have a good day!


问:
TypeError: db.collection is not a function
I am trying to post data to database that I have created on mLab and I am getting this error but I don't know whats going wrong.I also have read previously asked question on this topic but I am not able to solve my error as I am new to this. So here I am posting the code which I am trying to implement and It is taken from this tutorial https://medium.freecodecamp.com/building-a-simple-node-js-api-in-under-30-minutes-a07ea9e390d2.

server.js

```<code>const express = require('express');
const MongoClient = require('mongodb').MongoClient;
const bodyParser = require('body-parser');

const db = require('./config/db');

const app = express();

const port = 8000;

app.use(bodyParser.urlencoded({extened:true}));

MongoClient.connect(db.url,(err,database) =>{

    if (err) return console.log(err)
    require('./app/routes')(app,{});
    app.listen(port,() => {
        console.log("We are live on"+port);
    });

})
</code>```

db.js

```<code>module.exports = {
  url : "mongodb://JayTanna:Jay12345@ds147510.mlab.com:47510/testing"
};
</code>```

index.js

```<code>const noteroutes = require('./note_routes');

module.exports = function(app,db)
{
    noteroutes(app,db);

};
</code>```

note_routes.js

```<code>module.exports = function(app, db) {
  app.post('/notes', (req, res) => {
    const note = { text: req.body.body, title: req.body.title };
    db.collection('notes').insert(note, (err, result) => {
      if (err) {
        res.send({ 'error': 'An error has occurred' });
      } else {
        res.send(result.ops[0]);
      }
    });
  });
};
</code>```

答:
```<code>module.exports = function(app, db) {
  app.post('/notes', (req, res) => {
  const note = { text: req.body.body, title: req.body.title };
  db.collection('notes').insert(note, (err, result) => {
...
</code>```

db -> client

```<code>module.exports = function(app, client) {
  var db = client.db("name");
  app.post('/notes', (req, res) => {
  const note = { text: req.body.body, title: req.body.title };
  db.collection('notes').insert(note, (err, result) => {
...
</code>```

Body:
I am trying to post data to database that I have created on mLab and I am getting this error but I don't know whats going wrong.I also have read previously asked question on this topic but I am not able to solve my error as I am new to this. So here I am posting the code which I am trying to implement and It is taken from this tutorial https://medium.freecodecamp.com/building-a-simple-node-js-api-in-under-30-minutes-a07ea9e390d2.

server.js

const express = require('express');
const MongoClient = require('mongodb').MongoClient;
const bodyParser = require('body-parser');

const db = require('./config/db');

const app = express();

const port = 8000;

app.use(bodyParser.urlencoded({extened:true}));

MongoClient.connect(db.url,(err,database) =>{

    if (err) return console.log(err)
    require('./app/routes')(app,{});
    app.listen(port,() => {
        console.log("We are live on"+port);
    });

})

db.js

module.exports = {
  url : "mongodb://JayTanna:Jay12345@ds147510.mlab.com:47510/testing"
};

index.js

const noteroutes = require('./note_routes');

module.exports = function(app,db)
{
    noteroutes(app,db);

};

note_routes.js

module.exports = function(app, db) {
  app.post('/notes', (req, res) => {
    const note = { text: req.body.body, title: req.body.title };
    db.collection('notes').insert(note, (err, result) => {
      if (err) {
        res.send({ 'error': 'An error has occurred' });
      } else {
        res.send(result.ops[0]);
      }
    });
  });
};

Body:
module.exports = function(app, db) {
  app.post('/notes', (req, res) => {
  const note = { text: req.body.body, title: req.body.title };
  db.collection('notes').insert(note, (err, result) => {
...

db -> client

module.exports = function(app, client) {
  var db = client.db("name");
  app.post('/notes', (req, res) => {
  const note = { text: req.body.body, title: req.body.title };
  db.collection('notes').insert(note, (err, result) => {
...


问:
Bootstrap switch Toggle - One is on, the other is off using checkbox and jQuery
Help me for Bootstrap switch Toggle - One is on, the other is off using checkbox and jQuery.</p>

```<code><input type="checkbox" data-toggle="toggle" data-style="ios" data-size="normal" data-on="" data-off="" onclick="change_ins(1)" class="switch switch-on toggle" checked value="true" id="toggle1">
<input type="checkbox" data-toggle="toggle" data-style="ios" data-size="normal" data-on="" data-off="" onclick="change_ins(2)" class="switch switch-off toggle" id="toggle2">
<input type="checkbox" data-toggle="toggle" data-style="ios" data-size="normal" data-on="" data-off="" onclick="change_ins(3)" class="switch switch-off toggle" id="toggle3">
<input type="checkbox" data-toggle="toggle" data-style="ios" data-size="normal" data-on="" data-off="" onclick="change_ins(4)" class="switch switch-off toggle" id="toggle4">
<input type="checkbox" data-toggle="toggle" data-style="ios" data-size="normal" data-on="" data-off="" onclick="change_ins(5)" class="switch switch-off toggle" id="toggle5">
</code>```

答:
$(".toggle123").change(function() {
  var tid= this.id;

   if ($(this).is(":checked")) {
     $('.toggle123').each(function() {
    if(this.id != tid){ $("#"+this.id).bootstrapToggle('off'); }
});
      /* $(".toggle").bootstrapToggle('off');
   */

  }
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://gitcdn.github.io/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css" rel="stylesheet"/>

<input type="checkbox" data-toggle="toggle" data-style="ios" data-size="normal" data-on="" data-off="" class="switch switch-on toggle toggle123"  id="toggle1">
<input type="checkbox" data-toggle="toggle" data-style="ios" data-size="normal" data-on="" data-off="" class="switch switch-off toggle toggle123" id="toggle2">

<input type="checkbox" data-toggle="toggle" data-style="ios" data-size="normal" data-on="" data-off="" class="switch switch-off toggle toggle123" id="toggle3">

<input type="checkbox" data-toggle="toggle" data-style="ios" data-size="normal" data-on="" data-off="" class="switch switch-off toggle toggle123" id="toggle4">

<input type="checkbox" data-toggle="toggle" data-style="ios" data-size="normal" data-on="" data-off="" class="switch switch-off toggle toggle123" id="toggle5">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://gitcdn.github.io/bootstrap-toggle/2.2.2/js/bootstrap-toggle.min.js"></script></code>```

Body:
Help me for Bootstrap switch Toggle - One is on, the other is off using checkbox and jQuery.

<input type="checkbox" data-toggle="toggle" data-style="ios" data-size="normal" data-on="" data-off="" onclick="change_ins(1)" class="switch switch-on toggle" checked value="true" id="toggle1">
<input type="checkbox" data-toggle="toggle" data-style="ios" data-size="normal" data-on="" data-off="" onclick="change_ins(2)" class="switch switch-off toggle" id="toggle2">
<input type="checkbox" data-toggle="toggle" data-style="ios" data-size="normal" data-on="" data-off="" onclick="change_ins(3)" class="switch switch-off toggle" id="toggle3">
<input type="checkbox" data-toggle="toggle" data-style="ios" data-size="normal" data-on="" data-off="" onclick="change_ins(4)" class="switch switch-off toggle" id="toggle4">
<input type="checkbox" data-toggle="toggle" data-style="ios" data-size="normal" data-on="" data-off="" onclick="change_ins(5)" class="switch switch-off toggle" id="toggle5">

Body:
$(".toggle123").change(function() {
  var tid= this.id;

   if ($(this).is(":checked")) {
     $('.toggle123').each(function() {
    if(this.id != tid){ $("#"+this.id).bootstrapToggle('off'); }
});
      /* $(".toggle").bootstrapToggle('off');
   */

  }
});

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://gitcdn.github.io/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css" rel="stylesheet"/>

<input type="checkbox" data-toggle="toggle" data-style="ios" data-size="normal" data-on="&#8203;" data-off="&#8203;" class="switch switch-on toggle toggle123"  id="toggle1">
<input type="checkbox" data-toggle="toggle" data-style="ios" data-size="normal" data-on="&#8203;" data-off="&#8203;" class="switch switch-off toggle toggle123" id="toggle2">

<input type="checkbox" data-toggle="toggle" data-style="ios" data-size="normal" data-on="&#8203;" data-off="&#8203;" class="switch switch-off toggle toggle123" id="toggle3">

<input type="checkbox" data-toggle="toggle" data-style="ios" data-size="normal" data-on="&#8203;" data-off="&#8203;" class="switch switch-off toggle toggle123" id="toggle4">

<input type="checkbox" data-toggle="toggle" data-style="ios" data-size="normal" data-on="&#8203;" data-off="&#8203;" class="switch switch-off toggle toggle123" id="toggle5">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://gitcdn.github.io/bootstrap-toggle/2.2.2/js/bootstrap-toggle.min.js"></script>


问:
How do you install an SSL certificate on an AWS EC2 Wordpress server?
How can I install an SSL certificate to my EC2 instance running wordpress? I have tried the following links:

https://aws.amazon.com/blogs/aws/new-aws-certificate-manager-deploy-ssltls-based-apps-on-aws/
http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_server-certs.html
However I have been unable to successfully have any changes propagate.
Steps I followed:
-Request ACM SSL Certificate
-Create a Load Balancer with the SSL Certificate attached
-Attach load balancer to EC2 instance

答:
Another way to go is to manually set it up by logging in to your server. You should get some cheap SSL certificate and have it installed inside your /etc/apache2/ssl folder. Make sure your 443 port is opened and that openssl is installed on your server and enabled.

Here is a complete guide on how to do what I just said https://medium.com/@adnanxteam/how-to-add-ssl-certificate-to-laravel-on-ec2-aws-18104cc036d1


问:
Do processes need to be stopped manually
I'm new to multiprocessing in Python so I'm in doubt. My first idea was to use threads, but then I read about GIL and moved to multiprocessing.

My question is, when I start a process like this:

```<code>t1 = Process(target=run, args=lot)
t1.start()
</code>```

do I need to stop it somehow from the main process, or they shutdown when the run() method is finished?

I know that things like join() exist, but I'm scheduling a job every n minutes and start a couple of processes in parallel, and this procedure goes until stopped, so I don't really need to wait for processes to finish.

答:
GIL is not a big problem when doing little computation. Problems arise when doing computationally intensive tasks like networking or reading files while execution of a program is hung (hanged), which is where control flow is given to the kernel until input/output operation is performed. Once at that point, another thread can run in python.

If you are doing CPU-intensive programming, go with multiprocessing instead of GIL.

The join() method is used for thread synchronization, so when the main thread relies on data processed by another thread, it is important to use join(). When the main thread isn't reliant on the data that child threads process, join() is unnecessary. Your operating system will handle things like closing child processes in a safe manner.

EDIT: check this discussion for more details.

Body:
I'm new to multiprocessing in Python so I'm in doubt. My first idea was to use threads, but then I read about GIL and moved to multiprocessing.

My question is, when I start a process like this:

t1 = Process(target=run, args=lot)
t1.start()

do I need to stop it somehow from the main process, or they shutdown when the run() method is finished?

I know that things like join() exist, but I'm scheduling a job every n minutes and start a couple of processes in parallel, and this procedure goes until stopped, so I don't really need to wait for processes to finish.


问:
MacOS app does not run on the Xcode simulator
I've installed Xcode 4.2.1 on Mac OS X Lion.

When I create a new (Mac OS X Cocoa) project and I click "Run", Xcode says build succeeded, but doesn't run the project. No errors, but no application either.

When I do exactly the same thing on another Mac (but with OS X Snow Leopard and Xcode 4.0.1 installed), the created app starts bouncing in the dock and shows an empty window, like I would expect.

When I look in the Console, there seems to be nothing strange going on.
I tried reinstalling Xcode, deleting everything related to Xcode, but still no luck.

Anyone got an idea what could be the problem?

(I tried running an existing project which used to work, but that didn't show anything either)

Thanks.

答:
I had the same issue in late 2017 with Xcode 9.2.

I had to uncheck 'Debug Executable' and then my app was able to both run and stop.

You can open the settings by clicking Product -> Scheme -> Edit Scheme...


问:
how to set font-awesome check icon when click then check
i want to set font-awesome check icon that when ic click on it then its check when i click again its uncheck how this is possible .... i not use checkbox so plz tell me in this font-awesome check ....if its possible with jquery then tell me plzz how its done..
my code ....

<!DOCTYPE html>

 <title> </title>
 <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">

    first

    second

    third

```

答:
$("#box1").click(function() {
  $("#box1").css("display", "none");
  $("#check1").css("display", "block");

});
$("#check1").click(function() {
  $("#box1").css("display", "block");
  $("#check1").css("display", "none");

});

$("#box2").click(function() {
  $("#box2").css("display", "none");
  $("#check2").css("display", "block");

});
$("#check2").click(function() {
  $("#box2").css("display", "block");
  $("#check2").css("display", "none");

});
$("#box3").click(function() {
  $("#box3").css("display", "none");
  $("#check3").css("display", "block");

});
$("#check3").click(function() {
  $("#box3").css("display", "block");
  $("#check3").css("display", "none");

});```
<pre class="snippet-code-css lang-css prettyprint-override"><code><link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"><script type="text/javascript" src="js/jquery.js"></script><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"><style>#check1,
#check2,
#check3 {
  display: none;
}

</style></code>```

<!DOCTYPE html>

    <title></title>
    <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">

                first

                second

                third

```

Body:
$("#box1").click(function() {
  $("#box1").css("display", "none");
  $("#check1").css("display", "block");

});
$("#check1").click(function() {
  $("#box1").css("display", "block");
  $("#check1").css("display", "none");

});

$("#box2").click(function() {
  $("#box2").css("display", "none");
  $("#check2").css("display", "block");

});
$("#check2").click(function() {
  $("#box2").css("display", "block");
  $("#check2").css("display", "none");

});
$("#box3").click(function() {
  $("#box3").css("display", "none");
  $("#check3").css("display", "block");

});
$("#check3").click(function() {
  $("#box3").css("display", "block");
  $("#check3").css("display", "none");

});

<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"><script type="text/javascript" src="js/jquery.js"></script><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"><style>#check1,
#check2,
#check3 {
  display: none;
}

</style>

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
    <script type="text/javascript" src="js/jquery.js"></script>
    <style>
        #check1, #check2, #check3 {
            display: none;
        }
    </style>
</head>
<body>
    <ul>
        <li>
            <label>
                first
      <i class="fa fa-square-o" aria-hidden="true" id="box1"></i>
                <i class="fa fa-check-square" aria-hidden="true" id="check1"></i>
            </label>
        </li>
        <li>
            <label>
                second
               <i class="fa fa-square-o" aria-hidden="true" id="box2"></i>
                <i class="fa fa-check-square" aria-hidden="true" id="check2"></i>
            </label>
        </li>
        <li>
            <label>
                third
      <i class="fa fa-square-o" aria-hidden="true" id="box3"></i>
                <i class="fa fa-check-square" aria-hidden="true" id="check3"></i>
            </label>
        </li>
    </ul>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

</body>
    <script>
        $("#box1").click(function () {
            $("#box1").css("display", "none");
            $("#check1").css("display", "block");

        });
        $("#check1").click(function () {
            $("#box1").css("display", "block");
            $("#check1").css("display", "none");

        });

        $("#box2").click(function () {
            $("#box2").css("display", "none");
            $("#check2").css("display", "block");

        });
        $("#check2").click(function () {
            $("#box2").css("display", "block");
            $("#check2").css("display", "none");

        });
        $("#box3").click(function () {
            $("#box3").css("display", "none");
            $("#check3").css("display", "block");

        });
        $("#check3").click(function () {
            $("#box3").css("display", "block");
            $("#check3").css("display", "none");

        });
    </script>
</html>


问:
Populate Excel from Python list
I want to populate a excel sheet with data read from a text file.
My script opens a text file and then puts certain attributes into a list. I then want to populate my excel sheet with data in the list.

I have many txt documents in the same location so my script loops though the files.

What is wrong with my code ? It only populates one row.

```<code>import xlwt
import os

output = 'D:\Holding_Area\\test.xls'
file_path='Y:\\Testing\\Crashes'
pathappend=[]
r=1

for a in os.listdir(file_path):
    pathappend.append(file_path+'\\'+a)

def main():
    for x in pathappend:
        appendlist=[]
        wbk = xlwt.Workbook()
        sheet = wbk.add_sheet('python', cell_overwrite_ok=True)
        file = open(x)
        lines = file.readlines()
        appendlist.append(lines[1][2:10])
        appendlist.append(lines[1][13:21])
        appendlist.append(lines[4][15:30])
        appendlist.append(lines[10][13:22])
        appendlist.append(lines[11][9:28])
        appendlist.append(lines[22])
        appendlist.append(lines[31][84:113])
        appendlist.append(lines[27:29])
        file.close()
        for i,e in enumerate(appendlist):
            sheet.write(r,i,e)
            r+1

        wbk.save(output)
main()
</code>```

答:
Issue was with the 'r+1' it should be 'r+=1'; as shown below:</p>

```<code>import xlwt
import os

output = 'D:\Holding_Area\\test.xls'
file_path='Y:\\Testing\\Crashes'
pathappend=[]
r=1

for a in os.listdir(file_path):
    pathappend.append(file_path+'\\'+a)

def main():
    for x in pathappend:
        appendlist=[]
        wbk = xlwt.Workbook()
        sheet = wbk.add_sheet('python', cell_overwrite_ok=True)
        file = open(x)
        lines = file.readlines()
        appendlist.append(lines[1][2:10])
        appendlist.append(lines[1][13:21])
        appendlist.append(lines[4][15:30])
        appendlist.append(lines[10][13:22])
        appendlist.append(lines[11][9:28])
        appendlist.append(lines[22])
        appendlist.append(lines[31][84:113])
        appendlist.append(lines[27:29])
        file.close()
        for i,e in enumerate(appendlist):
            sheet.write(r,i,e)
            r+=1

    wbk.save(output)
main()
</code>```

Title: Populate Excel from Python list

Body:
I want to populate a excel sheet with data read from a text file.
My script opens a text file and then puts certain attributes into a list. I then want to populate my excel sheet with data in the list.

I have many txt documents in the same location so my script loops though the files.

What is wrong with my code ? It only populates one row.

import xlwt
import os

output = 'D:\Holding_Area\\test.xls'
file_path='Y:\\Testing\\Crashes'
pathappend=[]
r=1

for a in os.listdir(file_path):
    pathappend.append(file_path+'\\'+a)

def main():
    for x in pathappend:
        appendlist=[]
        wbk = xlwt.Workbook()
        sheet = wbk.add_sheet('python', cell_overwrite_ok=True)
        file = open(x)
        lines = file.readlines()
        appendlist.append(lines[1][2:10])
        appendlist.append(lines[1][13:21])
        appendlist.append(lines[4][15:30])
        appendlist.append(lines[10][13:22])
        appendlist.append(lines[11][9:28])
        appendlist.append(lines[22])
        appendlist.append(lines[31][84:113])
        appendlist.append(lines[27:29])
        file.close()
        for i,e in enumerate(appendlist):
            sheet.write(r,i,e)
            r+1

        wbk.save(output)
main()

Body:
Issue was with the 'r+1' it should be 'r+=1'; as shown below:

import xlwt
import os

output = 'D:\Holding_Area\\test.xls'
file_path='Y:\\Testing\\Crashes'
pathappend=[]
r=1

for a in os.listdir(file_path):
    pathappend.append(file_path+'\\'+a)

def main():
    for x in pathappend:
        appendlist=[]
        wbk = xlwt.Workbook()
        sheet = wbk.add_sheet('python', cell_overwrite_ok=True)
        file = open(x)
        lines = file.readlines()
        appendlist.append(lines[1][2:10])
        appendlist.append(lines[1][13:21])
        appendlist.append(lines[4][15:30])
        appendlist.append(lines[10][13:22])
        appendlist.append(lines[11][9:28])
        appendlist.append(lines[22])
        appendlist.append(lines[31][84:113])
        appendlist.append(lines[27:29])
        file.close()
        for i,e in enumerate(appendlist):
            sheet.write(r,i,e)
            r+=1

    wbk.save(output)
main()