问:
extra vertical space in IE after div clear
I have created a simple grid of divs by left floating them and an empty div with a clear at the end of each row.

This works fine in Firefox, but in IE I get extra vertical space between rows. I tried to apply the "clearfix" method, but I must be doing something wrong.

Why does IE insert the extra vertical space and how can I get rid of it?

```<code><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <style>
        root {
            display: block;
        }

        body {
            background: white;
        }

        .colorChip {
            position:relative;
            float: left;
            width: 20px;
            height: 20px;
            margin: 2px;
            border-style: solid;
            border-width: 1px;
            border-color: black;
        }

        .clear {
            clear: both;
        }

        .clearfix {
            display:inline-block;
        }

        .clearfix:after, .container:after {
            clear:both;
            content:".";
            display:block;
            height:0;
            visibility:hidden;
        }

        * html .clearfix {
            height:1%;
        }
        .clearfix {
            display:block;
        }

    </style>
    <!--[if IE]>
<style type="text/css">
  .clearfix {
    zoom: 1;     /* triggers hasLayout */
</style>
<![endif]-->

  </head>

  <body>
    <div class="colorChip clearfix" style="background: rgb(163,143,88)"></div>
    <div class="colorChip" style="background: rgb(190,170,113)"></div>
    <div class="colorChip" style="background: rgb(190,250,113)"></div>
    <div class="clear"></div>
    <div class="colorChip clearfix" style="background: rgb(187,170,128)"></div>
    <div class="colorChip" style="background: rgb(215,197,154)"></div>
    <div class="colorChip" style="background: rgb(243,225,181)"></div>
    <div class="clear"></div>
    <div class="colorChip clearfix" style="background: rgb(104,94,68)"></div>
    <div class="colorChip" style="background: rgb(129,118,92)"></div>
    <div class="colorChip" style="background: rgb(155,144,116)"></div>
    <div class="clear"></div>
  </body>
</html>
</code>```

答:
IE is a bit funny about empty
s - it likes to give them the height of a line of text.

If you change .clear to this, it'll shrink to 1 pixel:

```<code>    .clear {
        clear: both;
        height: 1px;
        overflow: hidden;
    }
</code>```

Put a background colour on to see what's happening

OwnerDisplayName: lajos

Body:
I have created a simple grid of divs by left floating them and an empty div with a clear at the end of each row.

This works fine in Firefox, but in IE I get extra vertical space between rows. I tried to apply the "clearfix" method, but I must be doing something wrong.

Why does IE insert the extra vertical space and how can I get rid of it?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

Body:
IE is a bit funny about empty <div>s - it likes to give them the height of a line of text.

If you change .clear to this, it'll shrink to 1 pixel:

    .clear {
        clear: both;
        height: 1px;
        overflow: hidden;
    }

Put a background colour on to see what's happening

OwnerDisplayName: RoBorg


来源: stackexchange

问:
Extensible Records and Higher Order Functions
I want to specify a type for records that have an id field whose type is a Uuid. So, I'm using extensible records. The type looks like this:

```<code>type alias WithId a = { a | id : Uuid }
</code>```

So far, so good. But then I went to create a Json.Encoder -- that is, a function of type WithId a -> Value -- for this type. I need a way to encode the underlying value, so I want to take a first argument of type a -> Value. Since I know a is a record, I can safely assume it is encoded to a JSON object, even though Elm doesn't expose the data types for Value.

However, when I create such a function, I get a compile error:

```<code>    The argument to function `encoder` is causing a mismatch.

27|             encoder a
                        ^
Function `encoder` is expecting the argument to be:

    a

But it is:

    WithId a

Hint: Your type annotation uses type variable `a` which means any type of value
can flow through. Your code is saying it CANNOT be anything though! Maybe change
your type annotation to be more specific? Maybe the code has a problem? More at:
<https://github.com/elm-lang/elm-compiler/blob/0.18.0/hints/type-annotations.md>

Detected errors in 1 module.
</code>```

I'm confused. Isn't something of type WithId a going to contain all the fields of a, and therefore shouldn't WithId a be an a through the type alias structural typing?

What am I missing? Why isn't the type alias of WithId a allowing me to use a WithId a as an instance of a, even though it is defined as {a|...}?

ADDENDUM

I've marked an answer below (which amounts to "You just can't do that, but here's what you're supposed to be doing."), but I'm still a bit unsatisfied. I guess I'm confused by the use of the term type alias. My understanding was that records were always a type alias, because they were explicitly specifying a subset of fields among all possible fields...but the underlying type was still the unifying record type (akin to a JS Object).

I guess I don't understand why we say:

```<code>type alias Foo = { bar : Int }
</code>```

instead of

```<code>type Foo = { bar : Int }
</code>```

The former implies to me that any record with { bar : Int } is a Foo, which would imply to me that {a|bar:Int} is both of the same type as a and a Foo. Where am I wrong here? I'm confused. I feel like I'm not grokking records.

ADDENDUM 2

My goal is not just to have a type WithId that specifies there is an .id on a field, but rather to have two types: Foo and WithId Foo where Foo has structure { bar:Int } and WithId Foo has structure { bar:Int, id:Uuid}.  I'd then like to also have a WithId Baz, WithId Quux, etc., etc., with a single encoder and single decoder function for WithId a.

The basic issue is that I have persisted and non-persisted data, which have the exact same structure, except that once something is persisted, I have an id. And want I type-level guarantees that records are persisted in certain cases, so Maybe doesn't work.

答:
Your reasoning about what you know about a WithId a value and what you should therefore be able to do with it (i.e. treat it as an a) is logically sound, but Elm’s support for extensible records just doesn't play with the type system in a way that permits that. Indeed, Elm’s extensible record types are specifically designed not to allow access to the full record.

What extensible records are designed for is to declare that a function will only access certain fields of a record, and the compiler then enforces that constraint:

```<code>type alias WithId a =
    { a | id : Uuid }

isValidId : WithId a -> Bool
isValidId withId =
    -- can only access .id

updateId : WithId a -> WithId a
updateId withId =
    { withId |
        id = -- can only access .id
    }
</code>```

When used to write functions that work on a small slice of a large program model, for example, this provides powerful guarantees about what a given function is able to do. Your updateUser function, for example, can be constrained only to access the user field of your model, rather than having free reign to access perhaps dozens of fields in your model. When you are later trying to debug an unexpected change to your model, these constraints help you quickly rule out many functions as being responsible for that change.

For more concrete examples of the above, I recommend Richard Feldman’s elm-europe 2017 talk https://youtu.be/DoA4Txr4GUs (see 23:10 in that video for the part showing extensible records).

I had the same excitement followed by confused disappointment when I first learned about extensible records, but in hindsight I think that comes from my deeply ingrained Object Oriented Programming instincts. I saw “extensible” and my brain jumped straight to “inheritance”. But Elm doesn't implement extensible records in a way that can support type inheritance.

The real intended purpose of extensible records, as illustrated in the examples above, is to constrain functions’ access to only a subset of a large record type.

As for your specific use case, I'd suggest starting with an Encoder for each of your data types, and if you want to reuse the implementation of an ID encoder, call a shared idEncoder function from within each of your encoders.

ContentLicense: CC BY-SA 3.0

Body:
I want to specify a type for records that have an id field whose type is a Uuid. So, I'm using extensible records. The type looks like this:

type alias WithId a = { a | id : Uuid }

So far, so good. But then I went to create a Json.Encoder -- that is, a function of type WithId a -> Value -- for this type. I need a way to encode the underlying value, so I want to take a first argument of type a -> Value. Since I know a is a record, I can safely assume it is encoded to a JSON object, even though Elm doesn't expose the data types for Value.

However, when I create such a function, I get a compile error:

    The argument to function `encoder` is causing a mismatch.

27|             encoder a
                        ^
Function `encoder` is expecting the argument to be:

    a

But it is:

    WithId a

Hint: Your type annotation uses type variable `a` which means any type of value
can flow through. Your code is saying it CANNOT be anything though! Maybe change
your type annotation to be more specific? Maybe the code has a problem? More at:
<https://github.com/elm-lang/elm-compiler/blob/0.18.0/hints/type-annotations.md>

Detected errors in 1 module.

I'm confused. Isn't something of type WithId a going to contain all the fields of a, and therefore shouldn't WithId a be an a through the type alias structural typing?

What am I missing? Why isn't the type alias of WithId a allowing me to use a WithId a as an instance of a, even though it is defined as {a|...}?

ADDENDUM

I've marked an answer below (which amounts to "You just can't do that, but here's what you're supposed to be doing."), but I'm still a bit unsatisfied. I guess I'm confused by the use of the term type alias. My understanding was that records were always a type alias, because they were explicitly specifying a subset of fields among all possible fields...but the underlying type was still the unifying record type (akin to a JS Object).

I guess I don't understand why we say:

type alias Foo = { bar : Int }

instead of

type Foo = { bar : Int }

The former implies to me that any record with { bar : Int } is a Foo, which would imply to me that {a|bar:Int} is both of the same type as a and a Foo. Where am I wrong here? I'm confused. I feel like I'm not grokking records.

ADDENDUM 2

My goal is not just to have a type WithId that specifies there is an .id on a field, but rather to have two types: Foo and WithId Foo where Foo has structure { bar:Int } and WithId Foo has structure { bar:Int, id:Uuid}.  I'd then like to also have a WithId Baz, WithId Quux, etc., etc., with a single encoder and single decoder function for WithId a.

The basic issue is that I have persisted and non-persisted data, which have the exact same structure, except that once something is persisted, I have an id. And want I type-level guarantees that records are persisted in certain cases, so Maybe doesn't work.

Body:
Your reasoning about what you know about a WithId a value and what you should therefore be able to do with it (i.e. treat it as an a) is logically sound, but Elm’s support for extensible records just doesn't play with the type system in a way that permits that. Indeed, Elm’s extensible record types are specifically designed not to allow access to the full record.

What extensible records are designed for is to declare that a function will only access certain fields of a record, and the compiler then enforces that constraint:

type alias WithId a =
    { a | id : Uuid }

isValidId : WithId a -> Bool
isValidId withId =
    -- can only access .id

updateId : WithId a -> WithId a
updateId withId =
    { withId |
        id = -- can only access .id
    }

When used to write functions that work on a small slice of a large program model, for example, this provides powerful guarantees about what a given function is able to do. Your updateUser function, for example, can be constrained only to access the user field of your model, rather than having free reign to access perhaps dozens of fields in your model. When you are later trying to debug an unexpected change to your model, these constraints help you quickly rule out many functions as being responsible for that change.

For more concrete examples of the above, I recommend Richard Feldman’s elm-europe 2017 talk https://youtu.be/DoA4Txr4GUs (see 23:10 in that video for the part showing extensible records).

I had the same excitement followed by confused disappointment when I first learned about extensible records, but in hindsight I think that comes from my deeply ingrained Object Oriented Programming instincts. I saw “extensible” and my brain jumped straight to “inheritance”. But Elm doesn't implement extensible records in a way that can support type inheritance.

The real intended purpose of extensible records, as illustrated in the examples above, is to constrain functions’ access to only a subset of a large record type.

As for your specific use case, I'd suggest starting with an Encoder for each of your data types, and if you want to reuse the implementation of an ID encoder, call a shared idEncoder function from within each of your encoders.


问:
How to resolve repository certificate error in Gradle build
I installed latest version of android studio. I had jdk 8 which was already installed. When I opened android studio, I got below error.

```<code>Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0.

Could not resolve com.android.support:appcompat-v7:26.1.0.
Required by:
    project :app
 > Could not resolve com.android.support:appcompat-v7:26.1.0.
    > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.pom'.
          > Could not GET 'https://dl.google.com/dl/android/maven2/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.pom'.
                   > sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
                               > PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
                                              > unable to find valid certification path to requested target
</code>```

So I removed JDK 8 and installed JDK 9, added environment variables (in windows 10). Then I restarted my system and started android studio, I still got above error. I even added

```<code>repositories {
    maven { url "https://maven.google.com" }
}
</code>```

to gradle script. But I'm still getting same error. How do I fix this error?

答:
Modify in project level gradle according below

```<code>// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

repositories {
    google()
    jcenter()
}

dependencies {
    classpath 'com.android.tools.build:gradle:3.0.0'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    }
 }

allprojects {
     repositories {
      google()
      jcenter()
   }
 }

 task clean(type: Delete) {
  delete rootProject.buildDir
}
</code>```

Then, remove appcompat-v7:26.1.0 dependency from app level gradle then next
Go to Android Studio File > Project Structure > app >Dependencies > tap on + > Library Dependencies > add dependenceis as per your requirements then OK.

Also you can try to tap on synchronize project with gradle file

For more please go for below link

https://developer.android.com/studio/build/gradle-plugin-3-0-0.html

Edited

I think your problem is different so please go with below links,

"PKIX path building failed" and "unable to find valid certification path to requested target"

Resolving javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed Error?

https://github.com/appscode-ci/cibox/issues/16

https://www.mkyong.com/webservices/jax-ws/suncertpathbuilderexception-unable-to-find-valid-certification-path-to-requested-target/

Body:
I installed latest version of android studio. I had jdk 8 which was already installed. When I opened android studio, I got below error.

Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0.

Could not resolve com.android.support:appcompat-v7:26.1.0.
Required by:
    project :app
 > Could not resolve com.android.support:appcompat-v7:26.1.0.
    > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.pom'.
          > Could not GET 'https://dl.google.com/dl/android/maven2/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.pom'.
                   > sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
                               > PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
                                              > unable to find valid certification path to requested target

So I removed JDK 8 and installed JDK 9, added environment variables (in windows 10). Then I restarted my system and started android studio, I still got above error. I even added

repositories {
    maven { url "https://maven.google.com" }
}

to gradle script. But I'm still getting same error. How do I fix this error?

Body:
Modify in project level gradle according below

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

repositories {
    google()
    jcenter()
}

dependencies {
    classpath 'com.android.tools.build:gradle:3.0.0'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    }
 }

allprojects {
     repositories {
      google()
      jcenter()
   }
 }

 task clean(type: Delete) {
  delete rootProject.buildDir
}

Then, remove appcompat-v7:26.1.0 dependency from app level gradle then next
Go to Android Studio File > Project Structure > app >Dependencies > tap on + > Library Dependencies > add dependenceis as per your requirements then OK.

Also you can try to tap on synchronize project with gradle file

For more please go for below link

https://developer.android.com/studio/build/gradle-plugin-3-0-0.html

Edited

I think your problem is different so please go with below links,

"PKIX path building failed" and "unable to find valid certification path to requested target"

Resolving javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed Error?

https://github.com/appscode-ci/cibox/issues/16

https://www.mkyong.com/webservices/jax-ws/suncertpathbuilderexception-unable-to-find-valid-certification-path-to-requested-target/


问:
Registering Spring Cloud Microservice with Eureka server
I am trying to create spring cloud microservices and also need to include eureka server and zuul as spring cloud tools. Now I created one module in my one spring boot project. I registered that service with eureka server. And also I created one spring boot project for adding zuul service discovery and also registered with eureka project.

Here my doubt is that When I am adding another module as another spring boot project, Can I register that application also with my current eureka server as client? What type of relation that eureka server project and microservice having? one-To-One or One-To-Many? Can I register 3 or 4 microservices with one eureka server as client?

答:
Eureka Server will let you add as many microservices (modules of spring boot projects like you said).

From Spring Cloud landing page:

As long as Spring Cloud Netflix and Eureka Core are on the classpath
  any Spring Boot application with @EnableEurekaClient will try to
  contact a Eureka server on http://localhost:8761 (the default value of
  eureka.client.serviceUrl.defaultZone):

That means that you can use a single eureka server for multiple microservices which are registered as clients to the eureka server.

So yes, it's a One-To-Many relationship.

You will want at one point to look into multiple Eureka servers used in load balancing, for redundancy purposes, but for now you will be fine.


问:
Unable to generate signed apk in Android Studio, getting error Error:Execution failed for task ':app:transformClassesWith
I am generating a signed apk in android studio but I'm getting following error:

Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
  com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/auth/api/signin/internal/zzp.class

This is my build.gradle

```<code>apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.firebase-perf'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    defaultConfig {
        applicationId "net.jetserve.mocamandroid"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 10000002
        versionName "1.000000b"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
        externalNativeBuild {
            cmake {
                cppFlags "-frtti -fexceptions"
            }
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
        }
    }
}

repositories {
    maven { url 'https://zendesk.jfrog.io/zendesk/repo' }
}

dependencies {
    //HELP CENTER
    compile group: 'com.zendesk', name: 'sdk', version: '1.11.0.1'
    compile group: 'com.zendesk', name: 'sdk-providers', version: '1.11.0.1'
    compile (group: 'com.zendesk', name: 'sdk', version: '1.8.0.1') {
        exclude module: 'appcompat-v7';
        exclude module: 'support-v4';
        exclude module: 'design';
        exclude module: 'recyclerview-v7'
    }

    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile project(':openCVLibrary320')
    compile project(':libwebrtc')
    compile project(':dialogLibrary')

    //WebRTC socket
    compile('io.socket:socket.io-client:1.0.0') {
        exclude group: 'org.json', module: 'json'
    }

    //firebase
    compile 'com.android.support:appcompat-v7:26.0.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.firebase:firebase-core:11.6.0'
    compile 'com.google.firebase:firebase-auth:11.6.0'
    compile 'com.google.firebase:firebase-database:11.6.0'
    compile 'com.firebaseui:firebase-ui-database:2.3.0'
    compile 'com.firebaseui:firebase-ui-auth:2.3.0'
    compile 'com.firebaseui:firebase-ui-storage:2.3.0'
    compile 'com.firebaseui:firebase-ui:2.3.0'
    compile 'com.facebook.android:facebook-android-sdk:4.25.0'
    testCompile 'junit:junit:4.12'

    compile 'de.hdodenhof:circleimageview:2.2.0'

    //bottom navigation bar in settings activity
    compile 'com.aurelhubert:ahbottomnavigation:1.3.3'

    //ripple effect
    compile 'com.balysv:material-ripple:1.0.2'

    //compile 'com.github.bluejamesbond:textjustify-android:2.1.6'

    //notification
    compile 'com.google.firebase:firebase-messaging:11.6.0'

    compile 'com.google.firebase:firebase-perf:11.6.0'

    compile 'com.google.firebase:firebase-ads:11.6.0'

}
apply plugin: 'com.google.gms.google-services'
</code>```

答:
You should use 3.1.0 version.

```<code>  compile 'com.firebaseui:firebase-ui-database:3.1.0'
  compile 'com.firebaseui:firebase-ui:3.1.0'
  compile 'com.firebaseui:firebase-ui-auth:3.1.0'
  compile 'com.firebaseui:firebase-ui-storage:3.1.0'
</code>```

If same problem coming then Remove

```<code> compile 'com.google.firebase:firebase-auth:11.6.0'
</code>```

Body:
I am generating a signed apk in android studio but I'm getting following error:

Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
  com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/auth/api/signin/internal/zzp.class

This is my build.gradle

apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.firebase-perf'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    defaultConfig {
        applicationId "net.jetserve.mocamandroid"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 10000002
        versionName "1.000000b"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
        externalNativeBuild {
            cmake {
                cppFlags "-frtti -fexceptions"
            }
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
        }
    }
}

repositories {
    maven { url 'https://zendesk.jfrog.io/zendesk/repo' }
}

dependencies {
    //HELP CENTER
    compile group: 'com.zendesk', name: 'sdk', version: '1.11.0.1'
    compile group: 'com.zendesk', name: 'sdk-providers', version: '1.11.0.1'
    compile (group: 'com.zendesk', name: 'sdk', version: '1.8.0.1') {
        exclude module: 'appcompat-v7';
        exclude module: 'support-v4';
        exclude module: 'design';
        exclude module: 'recyclerview-v7'
    }

    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile project(':openCVLibrary320')
    compile project(':libwebrtc')
    compile project(':dialogLibrary')

    //WebRTC socket
    compile('io.socket:socket.io-client:1.0.0') {
        exclude group: 'org.json', module: 'json'
    }

    //firebase
    compile 'com.android.support:appcompat-v7:26.0.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.firebase:firebase-core:11.6.0'
    compile 'com.google.firebase:firebase-auth:11.6.0'
    compile 'com.google.firebase:firebase-database:11.6.0'
    compile 'com.firebaseui:firebase-ui-database:2.3.0'
    compile 'com.firebaseui:firebase-ui-auth:2.3.0'
    compile 'com.firebaseui:firebase-ui-storage:2.3.0'
    compile 'com.firebaseui:firebase-ui:2.3.0'
    compile 'com.facebook.android:facebook-android-sdk:4.25.0'
    testCompile 'junit:junit:4.12'

    compile 'de.hdodenhof:circleimageview:2.2.0'

    //bottom navigation bar in settings activity
    compile 'com.aurelhubert:ahbottomnavigation:1.3.3'

    //ripple effect
    compile 'com.balysv:material-ripple:1.0.2'

    //compile 'com.github.bluejamesbond:textjustify-android:2.1.6'

    //notification
    compile 'com.google.firebase:firebase-messaging:11.6.0'

    compile 'com.google.firebase:firebase-perf:11.6.0'

    compile 'com.google.firebase:firebase-ads:11.6.0'

}
apply plugin: 'com.google.gms.google-services'

Body:
You should use 3.1.0 version.

  compile 'com.firebaseui:firebase-ui-database:3.1.0'
  compile 'com.firebaseui:firebase-ui:3.1.0'
  compile 'com.firebaseui:firebase-ui-auth:3.1.0'
  compile 'com.firebaseui:firebase-ui-storage:3.1.0'

If same problem coming then Remove

 compile 'com.google.firebase:firebase-auth:11.6.0'


问:
How to stretch the table to fill all available space
This question might be simple, but I cannot find an answer.

I have the following html:

```<code><div>
  some text
  <div>
    <table>
        <tr><td>
            Test
        </tr>
    </table>
  </div>
</div>
</code>```

and css:

```<code>body,html {
    height: 100%;
    width: 100%;
    margin: 0;
}

table {
    height: 100%;
    margin: 0 auto;
    background: red;
}
</code>```

How can I stretch the table vertically without change of the height property of div? I want the table to have height: 100% but it does not work because the outer containers do not have a fixed height (as I understand).

http://jsfiddle.net/8qedxug9/

答:
In order to declare the height of an element relatively (in %), you will need to declare the height of its parent element. So, you'll need to declare the heights of your divs:

```<code><div>
  some text
  <div>
    <table>
        <tr><td>
            Test
        </tr>
    </table>
  </div>
</div>
</code>```

CSS:

```<code>body,html {
    height: 100%;
    width: 100%;
    margin: 0;
}

div {
  height: 100%;
}

table {
    height: 100%;
    margin: 0 auto;
    background: red;
}
</code>```

Body:
This question might be simple, but I cannot find an answer.

I have the following html:

  some text

            Test

and css:

body,html {
    height: 100%;
    width: 100%;
    margin: 0;
}

table {
    height: 100%;
    margin: 0 auto;
    background: red;
}

How can I stretch the table vertically without change of the height property of div? I want the table to have height: 100% but it does not work because the outer containers do not have a fixed height (as I understand).

http://jsfiddle.net/8qedxug9/

Body:
In order to declare the height of an element relatively (in %), you will need to declare the height of its parent element. So, you'll need to declare the heights of your divs:

<div>
  some text
  <div>
    <table>
        <tr><td>
            Test
        </tr>
    </table>
  </div>
</div>

CSS:

body,html {
    height: 100%;
    width: 100%;
    margin: 0;
}

div {
  height: 100%;
}

table {
    height: 100%;
    margin: 0 auto;
    background: red;
}


问:
Squeak Smalltalk -"Print specific integers" Error message, how to improve and why?
what I want is:
From integers 1 to 130, I want to print some specific integers already given in an array.
They are: 2 32 44 67 89 111 123 which are stored in small-to-big order.

Here's my codes:

```<code>|a n myArray|

myArray := #(2 32 44 67 89 111 123).

n := 1.
a := myArray at: n.

1 to: 130 do: [:i|
        i = a
        ifTrue: [
                Transcript show: i; cr.
                n := n + 1.
                a := myArray at: n.
                ].
        ].
</code>```

The output is very good except for an Error Message.

By my current level, I have no idea why that Error Message appears.

Q1: Why  Error Message appears ?

Q2: How can I improve that?

Update:

I found another way to solve this issue:

```<code>|myArray|

myArray := #(2 32 44 67 89 111 123).

n := 1.
a := myArray at: n.

1 to: 130 do: [:i|
    i = a
    ifTrue: [
        Transcript show: i; cr.
        n := n +1.

        n = 8
        ifTrue: [n := n - 1].

         a := myArray at: n.
        ].
    ].
</code>```

Looks ugly though.

Updated again:

```<code>|a n myArray|

myArray := #(2 32 44 67 89 111 123).

n := 1.
a := myArray at: n.

1 to: 130 do: [:i|
        i = a
        ifTrue: [
                Transcript show: i; cr.
                n := n + 1.

                (n = 8) ifTrue:  [^'Found it!'].

                a := myArray at: n.
                ].
        ].
</code>```

答:
From integers 1 to 130, I want to print some specific integers already given in an array

```<code>1 to: 130 do: [ :i |
    (array includes: i) ifTrue: [ Transcript show: i; cr. ] ]
</code>```

Body:
what I want is:
From integers 1 to 130, I want to print some specific integers already given in an array.
They are: 2 32 44 67 89 111 123 which are stored in small-to-big order.

Here's my codes:

|a n myArray|

myArray := #(2 32 44 67 89 111 123).

n := 1.
a := myArray at: n.

1 to: 130 do: [:i|
        i = a
        ifTrue: [
                Transcript show: i; cr.
                n := n + 1.
                a := myArray at: n.
                ].
        ].

The output is very good except for an Error Message.

By my current level, I have no idea why that Error Message appears.

Q1: Why  Error Message appears ?

Q2: How can I improve that?

Update:

I found another way to solve this issue:

|myArray|

myArray := #(2 32 44 67 89 111 123).

n := 1.
a := myArray at: n.

1 to: 130 do: [:i|
    i = a
    ifTrue: [
        Transcript show: i; cr.
        n := n +1.

        n = 8
        ifTrue: [n := n - 1].

         a := myArray at: n.
        ].
    ].

Looks ugly though.

Updated again:

|a n myArray|

myArray := #(2 32 44 67 89 111 123).

n := 1.
a := myArray at: n.

1 to: 130 do: [:i|
        i = a
        ifTrue: [
                Transcript show: i; cr.
                n := n + 1.

                (n = 8) ifTrue:  [^'Found it!'].

                a := myArray at: n.
                ].
        ].

Body:
From integers 1 to 130, I want to print some specific integers already given in an array

1 to: 130 do: [ :i |
    (array includes: i) ifTrue: [ Transcript show: i; cr. ] ]


问:
MFC Classes and C++ style casts
I'm wondering if I haven't fully understood C++ casts versus old C-Style cast. In MFC I have this method:

```<code>CWnd * GetDlgItem(UINT uResId);
</code>```

I'm expecting that a CComboBox (or CEdit), which is derived from CWnd, requires this kind of cast:

```<code>dynamic_cast<CComboBox *>(GetDlgItem(IDC_COMBO1));
// for CEdit:
dynamic_cast<CEdit *>(GetDlgItem(IDC_EDIT1));
</code>```

but this operation causes a crash for using null pointer, that means that cast have failed. Using:

```<code>reinterpret_cast<CComboBox *>(GetDlgItem(IDC_COMBO1));
// for CEdit:
reinterpret_cast<CEdit *>(GetDlgItem(IDC_EDIT1));
</code>```

fixes the problem, but I'm disappointed.
What am I missing?

答:
I'm wondering if I haven't fully understood C++ casts versus old C-Style cast. In MFC I have this method:

Probably you do understand the difference well, but MFC had been released before the RTTI in the C++ standard, having its own support for RTTI, which doesn't meet the standard way.

So alternatively, you could use DYNAMIC_DOWNCAST instead as follows:

```<code>DYNAMIC_DOWNCAST(CEdit, GetDlgItem(IDC_EDIT1));
</code>```

The common practice for this, however, is not to cast, but to create a member variable that represents your MFC control, using DDX_Control, which you can easily accomplish by doing Right Click, and selecting Add Variable... or through MFC Class Wizard.

EDIT

So I misunderstood an essential part of the OP's question about when the crash occurs. The crash is because of dereferencing nullptr, the valid result of dynamic_cast, not the dynamic_cast itself.

@xMRi answers why it crashes in detail.

Title: MFC Classes and C++ style casts

Body:
I'm wondering if I haven't fully understood C++ casts versus old C-Style cast. In MFC I have this method:

CWnd * GetDlgItem(UINT uResId);

I'm expecting that a CComboBox (or CEdit), which is derived from CWnd, requires this kind of cast:

dynamic_cast<CComboBox *>(GetDlgItem(IDC_COMBO1));
// for CEdit:
dynamic_cast<CEdit *>(GetDlgItem(IDC_EDIT1));

but this operation causes a crash for using null pointer, that means that cast have failed. Using:

reinterpret_cast<CComboBox *>(GetDlgItem(IDC_COMBO1));
// for CEdit:
reinterpret_cast<CEdit *>(GetDlgItem(IDC_EDIT1));

fixes the problem, but I'm disappointed.
What am I missing?

Body:
I'm wondering if I haven't fully understood C++ casts versus old C-Style cast. In MFC I have this method:

Probably you do understand the difference well, but MFC had been released before the RTTI in the C++ standard, having its own support for RTTI, which doesn't meet the standard way.

So alternatively, you could use DYNAMIC_DOWNCAST instead as follows:

DYNAMIC_DOWNCAST(CEdit, GetDlgItem(IDC_EDIT1));

The common practice for this, however, is not to cast, but to create a member variable that represents your MFC control, using DDX_Control, which you can easily accomplish by doing Right Click, and selecting Add Variable... or through MFC Class Wizard.

EDIT

So I misunderstood an essential part of the OP's question about when the crash occurs. The crash is because of dereferencing nullptr, the valid result of dynamic_cast, not the dynamic_cast itself.

@xMRi answers why it crashes in detail.

ContentLicense: CC BY-SA 4.0


问:
How can I make an image function as a button, and make it perform an action when clicked ( start a keyframe event, run a script)?
I've just started coding at school, and our teacher is horrible. I have to teach myself how to code, and for that reason, I've come here seeking help :). I've created this website using some simple html and css, and what I would like now is for the image I'm using in my navigation bar to act as a button, and when pressed, do something cool, like make an animation, or start a keyframe event where a few keyframes that I've set will trigger (like blinking text) or maybe even run a cool javascript. This is mostly for show, but at the same time, I'm here to learn. If my code is poorly written, feel free to correct it. Thank you.

HTML

```<code><!DOCTYPE html>
<html lang="en">
<head>
    <link rel="icon" href="bilde.png">
    <meta charset="UTF-8">
    <title>Bully</title>
</head>
<body>
<link rel="stylesheet" type="text/css" href="css/stil2.css">
</center>
<center><ul class="navigation">
   <li><a href="bully2.html">Home</a></li>
  <li><a href="contact.html">Contact</a></li>
 <li><a href="" target="_blank">
         [This is that I want to use as a button ->] <img src="bilde.png" alt="Emblem" style="width:120px;height:120px;border:0";>
        </a>
  <li><a href="orbok2.html">Gallery</a></li>
  <li><a href="Lore.html">Lore</a></li>
</ul>

<ul class="flex-container">
    <li class="flex-item" style="font-size:42px;"><h1>~Breaking News~</h1>
  <li class="flex-item"><h1><ins>26. October, 2017.</ins></h1><br><a style="font-size:32px;">The release of the videogame "Bully 2" has just been confirmed, according to a variety of different reliable sources. Spokesperson Bad Andy from Bullworth Chess Club confirmed the release date of Bully 2 to be on January 1st of 2019. "Bully's long-awaited sequel will be a tremendous success in today's videogame-industry," said Andy in an interview with Russel Barro, owner of The Bullworth Herald.<br></a><h2>~Jimmy Hopkins~</h2></li>
  <center><ul class="flex-container">
  <center><li class="flex-item"><h1><ins>18. October, 2017.</ins></h1><br><a style="font-size:32px;">Fire alarm was set off at 11:24 by unknown student or person. Faculty and staff encourage all students to send in clues and tips about the incident to: Bullworthacademy@edu.com</a><br><h2>~Staff~</h2></li>
  <center><ul class="flex-container">
  <center><li class="flex-item"><h1><ins>Bully 2 "confirmed" by R* insider?</ins></h1><br><a style="font-size:32px;">Trusted gtaforum.com-admin "Yan2295" made a post on April 21st saying this: <br> <br> </a>
  <img src="yan.png" style="border:2.5px solid black;width:65%;height:250px;">
  </p><br><h2>~Russel Hustle~</h2></li>
</div>
</ul>

</body>
</html>

CSS
@import "compass/css3";

/* http://meyerweb.com/eric/tools/css/reset/
   v2.0 | 20110126
   License: none (public domain)
*/

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
  }
body{
  background-image:url("brun.jpeg");
  background-repeat:no-repeat;
  background-size:1270px;
  background-attachment:fixed;
}

.flex-container {
  padding:0;
  margin:0;
  width:1000px;
  list-style: none;
  flex-direction:column;

  display: -webkit-box;
  display: -moz-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;

  -webkit-flex-flow: row-wrap;
  justify-content: center;
}

.flex-item {
  background-color: rgba(0, 0, 0, 0.25);
  margin-top: 0px;
  margin-bottom:0px;
  margin-left:0;
  border-top:0px solid ;
  border-left:3px solid rgba(0, 0, 0, 1);
  border-bottom:0px solid ;
  border-right:3px solid rgba(0, 0, 0, 1);
  border-radius:0px;
  padding-bottom:100px;
  padding-top:100px;

  line-height:40px;
  color:rgba(252, 174, 26, 255);
  font-weight: bold;
  font-size: 26px;
  font-family:NarcissusOpenSG;
  text-align:center;
  flex-grow: 0;
  justify-content:space-around;
  animation-name:text;
  animation-iteration-count:infinite;
  animation-duration:2s;
  animation-direction:alternate;
}
@keyframes jtext{

from {
  color:rgba(252, 174, 26, 255);
}
to{
    color:rgba(0, 0, 0, 0.5);
}
}
.navigation {
  list-style: none;
  border-top:3px solid black;
  border-bottom:0px solid black;
  width:994px;
  border-right:3px solid black;
  border-left:3px solid black;
  margin-top:5px;
  margin-bottom:0px;
  text-align:center;
  align-items:center;
  padding:0;
  border-top-left-radius:50px;
  border-top-right-radius:50px;
  background-color: rgba(0, 0, 0, 0.25);

  display: -webkit-box;
  display: -moz-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;

  -webkit-flex-flow: row wrap;
  justify-content:space-around;
  font-family:NarcissusOpenSG;
  font-size:28px;
}

.navigation a {
  text-decoration: none;
  display: block;
  padding:0;
  padding: 1em;
  opacity:0.5;
  transition-duration:0.5s;
  color:rgba(252, 174, 26, 255);
}

.navigation a:hover {
  color;
  background:;
  opacity:1;
  animation-duration:1.5s;
  animation-iteration-count:infinite;
  animation-name:blink;
  animation-direction:alternate;
}
keyframes blink {

from {
opacity:0.75;
  }

to {
opacity:0;
}
}
@media all and (max-width: 800px) {
  .navigation {
    justify-content: space-around;
  }
}

@media all and (max-width: 600px) {
  .navigation {
    -webkit-flex-flow: column wrap;
    flex-flow: column wrap;
  }

  .navigation a {
    text-align: center;
    padding:10px;
    border-top: 1px solid rgba(255,255,255,0.3);
    border-bottom: 1px solid rgba(0,0,0,0.1);
  }

  .navigation li:last-of-type a {
    border-bottom: 0;
}
</code>```

答:
You can add image button with below tag inside button

```<code><input type="image" src="http://somesite.com/somepath/someimage.png" />
</code>```

or

```<code><button style="background: url(someimage.png)" ... />
</code>```

Body:
I've just started coding at school, and our teacher is horrible. I have to teach myself how to code, and for that reason, I've come here seeking help :). I've created this website using some simple html and css, and what I would like now is for the image I'm using in my navigation bar to act as a button, and when pressed, do something cool, like make an animation, or start a keyframe event where a few keyframes that I've set will trigger (like blinking text) or maybe even run a cool javascript. This is mostly for show, but at the same time, I'm here to learn. If my code is poorly written, feel free to correct it. Thank you.

HTML

<!DOCTYPE html>

    <link rel="icon" href="bilde.png">
    <meta charset="UTF-8">
    <title>Bully</title>

<link rel="stylesheet" type="text/css" href="css/stil2.css">

Home

Contact

         [This is that I want to use as a button ->]

Gallery

Lore

~Breaking News~

26. October, 2017.

The release of the videogame "Bully 2" has just been confirmed, according to a variety of different reliable sources. Spokesperson Bad Andy from Bullworth Chess Club confirmed the release date of Bully 2 to be on January 1st of 2019. "Bully's long-awaited sequel will be a tremendous success in today's videogame-industry," said Andy in an interview with Russel Barro, owner of The Bullworth Herald.

~Jimmy Hopkins~

18. October, 2017.

Fire alarm was set off at 11:24 by unknown student or person. Faculty and staff encourage all students to send in clues and tips about the incident to: Bullworthacademy@edu.com

~Staff~

Bully 2 "confirmed" by R* insider?

Trusted gtaforum.com-admin "Yan2295" made a post on April 21st saying this:

~Russel Hustle~

CSS
@import "compass/css3";

/* http://meyerweb.com/eric/tools/css/reset/
   v2.0 | 20110126
   License: none (public domain)
*/

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
  }
body{
  background-image:url("brun.jpeg");
  background-repeat:no-repeat;
  background-size:1270px;
  background-attachment:fixed;
}

.flex-container {
  padding:0;
  margin:0;
  width:1000px;
  list-style: none;
  flex-direction:column;

  display: -webkit-box;
  display: -moz-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;

  -webkit-flex-flow: row-wrap;
  justify-content: center;
}

.flex-item {
  background-color: rgba(0, 0, 0, 0.25);
  margin-top: 0px;
  margin-bottom:0px;
  margin-left:0;
  border-top:0px solid ;
  border-left:3px solid rgba(0, 0, 0, 1);
  border-bottom:0px solid ;
  border-right:3px solid rgba(0, 0, 0, 1);
  border-radius:0px;
  padding-bottom:100px;
  padding-top:100px;

  line-height:40px;
  color:rgba(252, 174, 26, 255);
  font-weight: bold;
  font-size: 26px;
  font-family:NarcissusOpenSG;
  text-align:center;
  flex-grow: 0;
  justify-content:space-around;
  animation-name:text;
  animation-iteration-count:infinite;
  animation-duration:2s;
  animation-direction:alternate;
}
@keyframes jtext{

from {
  color:rgba(252, 174, 26, 255);
}
to{
    color:rgba(0, 0, 0, 0.5);
}
}
.navigation {
  list-style: none;
  border-top:3px solid black;
  border-bottom:0px solid black;
  width:994px;
  border-right:3px solid black;
  border-left:3px solid black;
  margin-top:5px;
  margin-bottom:0px;
  text-align:center;
  align-items:center;
  padding:0;
  border-top-left-radius:50px;
  border-top-right-radius:50px;
  background-color: rgba(0, 0, 0, 0.25);

  display: -webkit-box;
  display: -moz-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;

  -webkit-flex-flow: row wrap;
  justify-content:space-around;
  font-family:NarcissusOpenSG;
  font-size:28px;
}

.navigation a {
  text-decoration: none;
  display: block;
  padding:0;
  padding: 1em;
  opacity:0.5;
  transition-duration:0.5s;
  color:rgba(252, 174, 26, 255);
}

.navigation a:hover {
  color;
  background:;
  opacity:1;
  animation-duration:1.5s;
  animation-iteration-count:infinite;
  animation-name:blink;
  animation-direction:alternate;
}
keyframes blink {

from {
opacity:0.75;
  }

to {
opacity:0;
}
}
@media all and (max-width: 800px) {
  .navigation {
    justify-content: space-around;
  }
}

@media all and (max-width: 600px) {
  .navigation {
    -webkit-flex-flow: column wrap;
    flex-flow: column wrap;
  }

  .navigation a {
    text-align: center;
    padding:10px;
    border-top: 1px solid rgba(255,255,255,0.3);
    border-bottom: 1px solid rgba(0,0,0,0.1);
  }

  .navigation li:last-of-type a {
    border-bottom: 0;
}

Body:
You can add image button with below tag inside button

<input type="image" src="http://somesite.com/somepath/someimage.png" />

or

<button style="background: url(someimage.png)" ... />


问:
select a date in dropdown makes another one to the same date
What I want to do is when the starting date is selected in the first dropdown, the ending date dropdown automatically jumps to the same date.

Just like in JAL website.  Best Example->  http://www.jal.co.jp/

All I could find were stuffs like below but this is not what I want to do.

-http://stackoverflow.com/questions/1974798/javascript-how-to-make-auto-select-another-drop-down

-http://jsajax.com/EditRunDemo.aspx

-http://stackoverflow.com/questions/1966407/how-to-populate-dropdown-with-dynamic-date-based-on-2-other-dropdown-boxes

Does anybody know how to do this?
Please give me some advise....

I'm using rails and jquery, so anything that goes along with them would be great! Thanks!

答:
I use 2 input with type text (from_date and to_date), but it's the same deal as with a dropdown. they look like this:

```<code><div>From: <%= text_field_tag :from_date, params[:from_date],:class => "date" %> </div>
<div>To: <%= text_field_tag :to_date, params[:to_date],:class => "date" %> </div>
</code>```

then, using jquery and the datepicker plugin i do this:

```<code><script type="text/javascript">
   $(document).ready(function() {

     $( ".date" ).datepicker({
       dateFormat: 'mm-dd-yy'
     });

     $("#from_date").change(function() {
       var d = $("#from_date").val();
       $("#to_date").val(d);
     })

   });
</script>
</code>```

as you can see, I'm setting the date format options for the datepicker, and checking to see when something changes in the from_date box. if something changes (i picked a date from the calendar), the contents get copied in the second box (to_date).

ContentLicense: CC BY-SA 2.5

Body:
I use 2 input with type text (from_date and to_date), but it's the same deal as with a dropdown. they look like this:

<div>From: <%= text_field_tag :from_date, params[:from_date],:class => "date" %> </div>
<div>To: <%= text_field_tag :to_date, params[:to_date],:class => "date" %> </div>

then, using jquery and the datepicker plugin i do this:

<script type="text/javascript">
   $(document).ready(function() {

     $( ".date" ).datepicker({
       dateFormat: 'mm-dd-yy'
     });

     $("#from_date").change(function() {
       var d = $("#from_date").val();
       $("#to_date").val(d);
     })

   });
</script>

as you can see, I'm setting the date format options for the datepicker, and checking to see when something changes in the from_date box. if something changes (i picked a date from the calendar), the contents get copied in the second box (to_date).


问:
Using python with regex to match and mail
I am trying to write a script that reads a log file that matches all items that have specific strings, i.e., today's date, a constant word, and the first number after the word. I am fairly new to Python, and have several issues;

How to match different groups using regular expressions without having one variable for each regex match
(var1 = date + word + 7-something, var2 = date + word + 9-something, and so on)

How to print the matches by group suffixed by another word, such as:

Group 1

Geneva:

2017-11-14: Word: 7712742 (1346134)

Group 2

Helsinki:

2017-11-02: Word: 9124741 (912478)

I would then like to write all of these matches and their suffixes to an e-mail.
The current way I have tried to tackle this is:

```<code>import time
import re
import glob

logpath = glob.glob('C:\\path\\to\\file*.log')[0]
readfile = open(logpath, "r")
daysdate = time.strftime("%Y-%m-%d")
regex = re.compile(daysdate + ".*[Word:] \d.+")
for line in readfile:
    req_id = regex.findall(line)
    for word in req_id:
        #this print shows all regex matches from the log file
        print(req_id,)
...
    mail.Body += "%s\n" % word
    mail.Send()
</code>```

Now, this prints out all matches for today's date and sends a mail to the desired user(s), but I am yet to find a way to do it as described above, short of creating and writing to several files, which then are read from. This feels like a very non-Pythonic way (and just bad practice for scripting overall).

Would one want go about this using several loops, such as for each match where the date is date + word + 7-something, print("Geneva:\n", req_id7), or are there other, better ways to solve this? The output of such an example gives:

```<code>Geneva: ['2017-11-15 04.03.18: Word: 78271187 (783342)']
Geneva: ['2017-11-15 04.03.19: Word: 75612345 (755491)']
Geneva: ['2017-11-15 04.03.22: Word: 70145678 (798640)']
</code>```

Where I would like the output to be:

```<code>Geneva:
['2017-11-15 04.03.18: Word: 78271187 (783342)']
['2017-11-15 04.03.19: Word: 75612345 (755491)']
['2017-11-15 04.03.22: Word: 70145678 (798640)']
</code>```

答:
You can try:</p>

```<code>print(req_id.replace("Geneva: ",""),)
</code>```

Body:
I am trying to write a script that reads a log file that matches all items that have specific strings, i.e., today's date, a constant word, and the first number after the word. I am fairly new to Python, and have several issues;

How to match different groups using regular expressions without having one variable for each regex match
(var1 = date + word + 7-something, var2 = date + word + 9-something, and so on)

How to print the matches by group suffixed by another word, such as:

Group 1

Geneva:

2017-11-14: Word: 7712742 (1346134)

Group 2

Helsinki:

2017-11-02: Word: 9124741 (912478)

I would then like to write all of these matches and their suffixes to an e-mail.
The current way I have tried to tackle this is:

import time
import re
import glob

logpath = glob.glob('C:\\path\\to\\file*.log')[0]
readfile = open(logpath, "r")
daysdate = time.strftime("%Y-%m-%d")
regex = re.compile(daysdate + ".*[Word:] \d.+")
for line in readfile:
    req_id = regex.findall(line)
    for word in req_id:
        #this print shows all regex matches from the log file
        print(req_id,)
...
    mail.Body += "%s\n" % word
    mail.Send()

Now, this prints out all matches for today's date and sends a mail to the desired user(s), but I am yet to find a way to do it as described above, short of creating and writing to several files, which then are read from. This feels like a very non-Pythonic way (and just bad practice for scripting overall).

Would one want go about this using several loops, such as for each match where the date is date + word + 7-something, print("Geneva:\n", req_id7), or are there other, better ways to solve this? The output of such an example gives:

Geneva: ['2017-11-15 04.03.18: Word: 78271187 (783342)']
Geneva: ['2017-11-15 04.03.19: Word: 75612345 (755491)']
Geneva: ['2017-11-15 04.03.22: Word: 70145678 (798640)']

Where I would like the output to be:

Geneva:
['2017-11-15 04.03.18: Word: 78271187 (783342)']
['2017-11-15 04.03.19: Word: 75612345 (755491)']
['2017-11-15 04.03.22: Word: 70145678 (798640)']

Body:
You can try:

print(req_id.replace("Geneva: ",""),)


问:
JavaScript heap out of memory error while creating build in angular 2
I want to create build in angular 2, I have write ng build --prod --aot command and get following error.

```<code>  180823 ms: Mark-sweep 1338.1 (1437.6) -> 1338.1 (1437.6) MB, 1325.4 / 0.0 ms [allocation failure] [GC in old space requested].
  182147 ms: Mark-sweep 1338.1 (1437.6) -> 1338.1 (1437.6) MB, 1323.7 / 0.0 ms [allocation failure] [GC in old space requested].
  183495 ms: Mark-sweep 1338.1 (1437.6) -> 1344.6 (1418.6) MB, 1347.4 / 0.0 ms [last resort gc].
  184844 ms: Mark-sweep 1344.6 (1418.6) -> 1351.3 (1418.6) MB, 1348.6 / 0.0 ms [last resort gc].

<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x5ec47cfb51 <JS Object>
    1: token(aka token) [0x5ec4704381 <undefined>:1724] [pc=0x3e2345467b26] (this=0x5ec4704381 <undefined>,type=0x5ec4704fb1 <String[4]: name>,value=0x3363e2ffb931 <String[62]: __WEBPACK_IMPORTED_MODULE_35__angular_material_button_button__>,is_comment=0x5ec4704381 <undefined>)
    2: arguments adaptor frame: 2->3
    3: read_word(aka read_word) [0x5ec4704381 <undefined>:~1957] [pc=0x3e23435a05fb]...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [@angular/cli]
 2: 0x1096a4c [@angular/cli]
 3: v8::Utils::ReportApiFailure(char const*, char const*) [@angular/cli]
 4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [@angular/cli]
 5: v8::internal::Factory::NewTransitionArray(int) [@angular/cli]
 6: v8::internal::TransitionArray::Insert(v8::internal::Handle<v8::internal::Map>, v8::internal::Handle<v8::internal::Name>, v8::internal::Handle<v8::internal::Map>, v8::internal::SimpleTransitionFlag) [@angular/cli]
 7: v8::internal::Map::ShareDescriptor(v8::internal::Handle<v8::internal::Map>, v8::internal::Handle<v8::internal::DescriptorArray>, v8::internal::Descriptor*) [@angular/cli]
 8: v8::internal::Map::CopyAddDescriptor(v8::internal::Handle<v8::internal::Map>, v8::internal::Descriptor*, v8::internal::TransitionFlag) [@angular/cli]
 9: v8::internal::Map::CopyWithField(v8::internal::Handle<v8::internal::Map>, v8::internal::Handle<v8::internal::Name>, v8::internal::Handle<v8::internal::FieldType>, v8::internal::PropertyAttributes, v8::internal::Representation, v8::internal::TransitionFlag) [@angular/cli]
10: v8::internal::Map::TransitionToDataProperty(v8::internal::Handle<v8::internal::Map>, v8::internal::Handle<v8::internal::Name>, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyAttributes, v8::internal::Object::StoreFromKeyed) [@angular/cli]
11: v8::internal::LookupIterator::PrepareTransitionToDataProperty(v8::internal::Handle<v8::internal::JSObject>, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyAttributes, v8::internal::Object::StoreFromKeyed) [@angular/cli]
12: v8::internal::StoreIC::LookupForWrite(v8::internal::LookupIterator*, v8::internal::Handle<v8::internal::Object>, v8::internal::Object::StoreFromKeyed) [@angular/cli]
13: v8::internal::StoreIC::UpdateCaches(v8::internal::LookupIterator*, v8::internal::Handle<v8::internal::Object>, v8::internal::Object::StoreFromKeyed) [@angular/cli]
14: v8::internal::StoreIC::Store(v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Name>, v8::internal::Handle<v8::internal::Object>, v8::internal::Object::StoreFromKeyed) [@angular/cli]
15: v8::internal::Runtime_StoreIC_Miss(int, v8::internal::Object**, v8::internal::Isolate*) [@angular/cli]
16: 0x3e2341a092a7
Aborted (core dumped)
</code>```

I have also try following command inside my project :

```<code>node --max-old-space-size=8192 node_modules/@angular/compiler-cli/src/main.js -p tsconfig-aot.json
</code>```

and get following error :

Error: ENOENT: no such file or directory, lstat 'tsconfig-aot.json'
          at Error (native)
          at Object.fs.lstatSync (fs.js:982:18)
          at Object.main (/root/Desktop/rc1-dev/client/node_modules/@angular/tsc-wrapped/src/main.js:20:16)
          at main (/root/Desktop/rc1-dev/client/node_modules/@angular/compiler-cli/src/main.js:14:16)
          at Object. (/root/Desktop/rc1-dev/client/node_modules/@angular/compiler-cli/src/main.js:30:5)
          at Module._compile (module.js:570:32)
          at Object.Module._extensions..js (module.js:579:10)
          at Module.load (module.js:487:32)
          at tryModuleLoad (module.js:446:12)
          at Function.Module._load (module.js:438:3)
      Compilation failed

答:
Try running build script in package json by the following script:

```<code>"scripts": {
   "build-prod": "node --max_old_space_size=5048 ./node_modules/@angular/cli/bin/ng build --prod --aot --no-sourcemap"
}
</code>```

then run "npm run build-prod".

Body:
I want to create build in angular 2, I have write ng build --prod --aot command and get following error.

  180823 ms: Mark-sweep 1338.1 (1437.6) -> 1338.1 (1437.6) MB, 1325.4 / 0.0 ms [allocation failure] [GC in old space requested].
  182147 ms: Mark-sweep 1338.1 (1437.6) -> 1338.1 (1437.6) MB, 1323.7 / 0.0 ms [allocation failure] [GC in old space requested].
  183495 ms: Mark-sweep 1338.1 (1437.6) -> 1344.6 (1418.6) MB, 1347.4 / 0.0 ms [last resort gc].
  184844 ms: Mark-sweep 1344.6 (1418.6) -> 1351.3 (1418.6) MB, 1348.6 / 0.0 ms [last resort gc].

<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x5ec47cfb51 <JS Object>
    1: token(aka token) [0x5ec4704381 <undefined>:1724] [pc=0x3e2345467b26] (this=0x5ec4704381 <undefined>,type=0x5ec4704fb1 <String[4]: name>,value=0x3363e2ffb931 <String[62]: __WEBPACK_IMPORTED_MODULE_35__angular_material_button_button__>,is_comment=0x5ec4704381 <undefined>)
    2: arguments adaptor frame: 2->3
    3: read_word(aka read_word) [0x5ec4704381 <undefined>:~1957] [pc=0x3e23435a05fb]...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [@angular/cli]
 2: 0x1096a4c [@angular/cli]
 3: v8::Utils::ReportApiFailure(char const*, char const*) [@angular/cli]
 4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [@angular/cli]
 5: v8::internal::Factory::NewTransitionArray(int) [@angular/cli]
 6: v8::internal::TransitionArray::Insert(v8::internal::Handle<v8::internal::Map>, v8::internal::Handle<v8::internal::Name>, v8::internal::Handle<v8::internal::Map>, v8::internal::SimpleTransitionFlag) [@angular/cli]
 7: v8::internal::Map::ShareDescriptor(v8::internal::Handle<v8::internal::Map>, v8::internal::Handle<v8::internal::DescriptorArray>, v8::internal::Descriptor*) [@angular/cli]
 8: v8::internal::Map::CopyAddDescriptor(v8::internal::Handle<v8::internal::Map>, v8::internal::Descriptor*, v8::internal::TransitionFlag) [@angular/cli]
 9: v8::internal::Map::CopyWithField(v8::internal::Handle<v8::internal::Map>, v8::internal::Handle<v8::internal::Name>, v8::internal::Handle<v8::internal::FieldType>, v8::internal::PropertyAttributes, v8::internal::Representation, v8::internal::TransitionFlag) [@angular/cli]
10: v8::internal::Map::TransitionToDataProperty(v8::internal::Handle<v8::internal::Map>, v8::internal::Handle<v8::internal::Name>, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyAttributes, v8::internal::Object::StoreFromKeyed) [@angular/cli]
11: v8::internal::LookupIterator::PrepareTransitionToDataProperty(v8::internal::Handle<v8::internal::JSObject>, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyAttributes, v8::internal::Object::StoreFromKeyed) [@angular/cli]
12: v8::internal::StoreIC::LookupForWrite(v8::internal::LookupIterator*, v8::internal::Handle<v8::internal::Object>, v8::internal::Object::StoreFromKeyed) [@angular/cli]
13: v8::internal::StoreIC::UpdateCaches(v8::internal::LookupIterator*, v8::internal::Handle<v8::internal::Object>, v8::internal::Object::StoreFromKeyed) [@angular/cli]
14: v8::internal::StoreIC::Store(v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Name>, v8::internal::Handle<v8::internal::Object>, v8::internal::Object::StoreFromKeyed) [@angular/cli]
15: v8::internal::Runtime_StoreIC_Miss(int, v8::internal::Object**, v8::internal::Isolate*) [@angular/cli]
16: 0x3e2341a092a7
Aborted (core dumped)

I have also try following command inside my project :

node --max-old-space-size=8192 node_modules/@angular/compiler-cli/src/main.js -p tsconfig-aot.json

and get following error :

Error: ENOENT: no such file or directory, lstat 'tsconfig-aot.json'
          at Error (native)
          at Object.fs.lstatSync (fs.js:982:18)
          at Object.main (/root/Desktop/rc1-dev/client/node_modules/@angular/tsc-wrapped/src/main.js:20:16)
          at main (/root/Desktop/rc1-dev/client/node_modules/@angular/compiler-cli/src/main.js:14:16)
          at Object. (/root/Desktop/rc1-dev/client/node_modules/@angular/compiler-cli/src/main.js:30:5)
          at Module._compile (module.js:570:32)
          at Object.Module._extensions..js (module.js:579:10)
          at Module.load (module.js:487:32)
          at tryModuleLoad (module.js:446:12)
          at Function.Module._load (module.js:438:3)
      Compilation failed

Body:
Try running build script in package json by the following script:

"scripts": {
   "build-prod": "node --max_old_space_size=5048 ./node_modules/@angular/cli/bin/ng build --prod --aot --no-sourcemap"
}

then run "npm run build-prod".


问:
SunPKCS11 provider in MacOS for Firefox
I managed to get the SunPKCS11 to work with Firefox ESR 52.0 under Windows, but I am unable to get it to load in MacOS. I've already tried several different configuration and directly loading it via PKCS11 but nothing worked, can anyone give me some pointer?

pkcs11.cfg configuration as follow:

```<code>name = FirefoxKeyStore
library = "/Applications/Firefox.app/Contents/MacOS/fixed-for-java-runtime/libsoftokn3.dylib"
attributes = compatibility
nssArgs = "configdir='/Users/helloworld/Library/Application Support/Firefox/Profiles/wasdwasd.default-1453211557245' certPrefix='' keyPrefix='' secmod='secmod.db' flags='readOnly' "
slot = 2
</code>```

Then in Java, I've tried to load it like this:

```<code>FileInputStream fis = new FileInputStream("pkcs11.cfg");
Provider provider = new SunPKCS11(fis);
Security.addProvider(provider);
</code>```

However this immediately gives me the following error:

```<code>sunpkcs11: Initializing PKCS#11 library /Applications/Firefox.app/Contents/MacOS/fixed-for-java-runtime/libsoftokn3.dylib
sunpkcs11: Multi-threaded initialization failed: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_DEVICE_ERROR
Exception in thread "main" java.security.ProviderException: Initialization failed
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:376)
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:107)
</code>```

You maybe asking why do I load the .dylib from the weird folder, that's because I used install_name_tool in MacOS to change the @executable_path to @loader_path in order to get the library dependency to work (since I'm trying to run this in Eclipse rather than from Firefox itself).

I also tried to use the solution suggested here: How to finalize SunPKCS11 Provider after it is initialized? and it was a no-go either... I get the same error.

As well as trying various different configuration settings mentioned here: https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/PKCS11/Module_Specs#Softoken_Specific_Parameters

EDIT1

I tried the method mentioned by @FaithReaper but it still throw the same error. I tried changing the slot value to 0, 1 or -1 and result the same. It looks like there are problem loading the underlaying PKCS11 object.

```<code>Caused by: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_DEVICE_ERROR
at sun.security.pkcs11.wrapper.PKCS11.C_Initialize(Native Method)
at sun.security.pkcs11.wrapper.PKCS11$SynchronizedPKCS11.C_Initialize(PKCS11.java:1545)
at sun.security.pkcs11.wrapper.PKCS11.getInstance(PKCS11.java:157)
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:330)
</code>```

I dunno if this would help, but I ran the modutil on the FireFox profile and is dumping this info:

```<code>modutil -dbdir "/Users/eto/Library/Application Support/Firefox/Profiles/ew2g332o.default-1453211557245" -rawlist

library= name="NSS Internal PKCS #11 Module"
parameters="configdir=/Users/eto/Library/Application Support/Firefox/Profiles/ew2g332o.default-1453211557245 certPrefix= keyPrefix= secmod=secmod.db flags=readOnly "
NSS="Flags=internal,critical trustOrder=75 cipherOrder=100 slotParams=(1={slotFlags=[RSA,DSA,DH,RC2,RC4,DES,RANDOM,SHA1,MD5,MD2,SSL,TLS,AES,Camellia,SEED,SHA256,SHA512] askpw=any timeout=30})"
</code>```

Listing of PKCS #11 Modules

NSS Internal PKCS #11 Module
   uri: pkcs11:library-manufacturer=Mozilla%20Foundation;library-description=NSS%20Internal%20Crypto%20Services;library-version=3.33
  slots: 2 slots attached    status: loaded

slot: NSS Internal Cryptographic Services  token: NSS Generic Crypto
  Services    uri:
  pkcs11:token=NSS%20Generic%20Crypto%20Services;manufacturer=Mozilla%20Foundation;serial=0000000000000000;model=NSS%203

slot: NSS User Private Key and Certificate Services    token: NSS
  Certificate DB      uri:
  pkcs11:token=NSS%20Certificate%20DB;manufacturer=Mozilla%20Foundation;serial=0000000000000000;model=NSS%203

答:
First of all, I have noticed the different way you insert/add Provider with me. Can you try to add the Provider this way? (it may be irrelavent)

```<code>Provider p = new SunPKCS11(new ByteArrayInputStream(config.getBytes()));
Security.insertProviderAt(p, 1);
KeyStore.Builder builder = null;
builder = KeyStore.Builder.newInstance("PKCS11", p,
    new KeyStore.CallbackHandlerProtection(new UtilTarjetas().new CustomCallbackHandler()));
cardKeyStore = builder.getKeyStore();
</code>```

Then, maybe you can try the approach here:

https://github.com/avocado-framework/avocado/issues/1112

That is:

apahim commented on 7 Apr 2016

@will-Do, nss folks were able to track this issue down and seems like they are going to consider a change in NSS_InitContext(), which should include a SECMOD_RestartModules(PR_FALSE) after a fork(). Anyway, they also provided a better workaround than the one I provided you. If you set the environment variable NSS_STRICT_NOFORK to DISABLED then the code is expected to work. It worked for me and I'd like to check if it works for you as well. Looking forward to see your results.

Also, some sources suggests that it may be a token or slot problem. You can try to change slot index to 0, or -1.

Title: SunPKCS11 provider in MacOS for Firefox

Body:
I managed to get the SunPKCS11 to work with Firefox ESR 52.0 under Windows, but I am unable to get it to load in MacOS. I've already tried several different configuration and directly loading it via PKCS11 but nothing worked, can anyone give me some pointer?

pkcs11.cfg configuration as follow:

name = FirefoxKeyStore
library = "/Applications/Firefox.app/Contents/MacOS/fixed-for-java-runtime/libsoftokn3.dylib"
attributes = compatibility
nssArgs = "configdir='/Users/helloworld/Library/Application Support/Firefox/Profiles/wasdwasd.default-1453211557245' certPrefix='' keyPrefix='' secmod='secmod.db' flags='readOnly' "
slot = 2

Then in Java, I've tried to load it like this:

FileInputStream fis = new FileInputStream("pkcs11.cfg");
Provider provider = new SunPKCS11(fis);
Security.addProvider(provider);

However this immediately gives me the following error:

sunpkcs11: Initializing PKCS#11 library /Applications/Firefox.app/Contents/MacOS/fixed-for-java-runtime/libsoftokn3.dylib
sunpkcs11: Multi-threaded initialization failed: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_DEVICE_ERROR
Exception in thread "main" java.security.ProviderException: Initialization failed
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:376)
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:107)

You maybe asking why do I load the .dylib from the weird folder, that's because I used install_name_tool in MacOS to change the @executable_path to @loader_path in order to get the library dependency to work (since I'm trying to run this in Eclipse rather than from Firefox itself).

I also tried to use the solution suggested here: How to finalize SunPKCS11 Provider after it is initialized? and it was a no-go either... I get the same error.

As well as trying various different configuration settings mentioned here: https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/PKCS11/Module_Specs#Softoken_Specific_Parameters

EDIT1

I tried the method mentioned by @FaithReaper but it still throw the same error. I tried changing the slot value to 0, 1 or -1 and result the same. It looks like there are problem loading the underlaying PKCS11 object.

Caused by: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_DEVICE_ERROR
at sun.security.pkcs11.wrapper.PKCS11.C_Initialize(Native Method)
at sun.security.pkcs11.wrapper.PKCS11$SynchronizedPKCS11.C_Initialize(PKCS11.java:1545)
at sun.security.pkcs11.wrapper.PKCS11.getInstance(PKCS11.java:157)
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:330)

I dunno if this would help, but I ran the modutil on the FireFox profile and is dumping this info:

modutil -dbdir "/Users/eto/Library/Application Support/Firefox/Profiles/ew2g332o.default-1453211557245" -rawlist

library= name="NSS Internal PKCS #11 Module"
parameters="configdir=/Users/eto/Library/Application Support/Firefox/Profiles/ew2g332o.default-1453211557245 certPrefix= keyPrefix= secmod=secmod.db flags=readOnly "
NSS="Flags=internal,critical trustOrder=75 cipherOrder=100 slotParams=(1={slotFlags=[RSA,DSA,DH,RC2,RC4,DES,RANDOM,SHA1,MD5,MD2,SSL,TLS,AES,Camellia,SEED,SHA256,SHA512] askpw=any timeout=30})"

Listing of PKCS #11 Modules

NSS Internal PKCS #11 Module
   uri: pkcs11:library-manufacturer=Mozilla%20Foundation;library-description=NSS%20Internal%20Crypto%20Services;library-version=3.33
  slots: 2 slots attached    status: loaded

slot: NSS Internal Cryptographic Services  token: NSS Generic Crypto
  Services    uri:
  pkcs11:token=NSS%20Generic%20Crypto%20Services;manufacturer=Mozilla%20Foundation;serial=0000000000000000;model=NSS%203

slot: NSS User Private Key and Certificate Services    token: NSS
  Certificate DB      uri:
  pkcs11:token=NSS%20Certificate%20DB;manufacturer=Mozilla%20Foundation;serial=0000000000000000;model=NSS%203

Body:
First of all, I have noticed the different way you insert/add Provider with me. Can you try to add the Provider this way? (it may be irrelavent)

Provider p = new SunPKCS11(new ByteArrayInputStream(config.getBytes()));
Security.insertProviderAt(p, 1);
KeyStore.Builder builder = null;
builder = KeyStore.Builder.newInstance("PKCS11", p,
    new KeyStore.CallbackHandlerProtection(new UtilTarjetas().new CustomCallbackHandler()));
cardKeyStore = builder.getKeyStore();

Then, maybe you can try the approach here:

https://github.com/avocado-framework/avocado/issues/1112

That is:

apahim commented on 7 Apr 2016

@will-Do, nss folks were able to track this issue down and seems like they are going to consider a change in NSS_InitContext(), which should include a SECMOD_RestartModules(PR_FALSE) after a fork(). Anyway, they also provided a better workaround than the one I provided you. If you set the environment variable NSS_STRICT_NOFORK to DISABLED then the code is expected to work. It worked for me and I'd like to check if it works for you as well. Looking forward to see your results.

Also, some sources suggests that it may be a token or slot problem. You can try to change slot index to 0, or -1.


问:
Update sqlite db entry using put method flask
I want to update sqlite entry using put http method. When I send request via postman I get this error:

Method Not Allowed

The method is not allowed for the requested URL.

Here is my code:

```<code>@app.route('/api/users/<int:user_id>', methods=['PUT'])
def put_user(user_id):
    user = {
        'id': user_id,
        'login': request.json['login'],
        'password': request.json['password'],
    }
    cursor.execute('UPDATE USERS SET login=?, password=? WHERE id=?', (user['login'], user['password'], user['id']))
    connection.commit()
    return jsonify(user), 200
</code>```

Here is request:

http://192.168.0.101:5000/api/users/4/

```<code>{
    "id": 4,
    "login": "bbbb",
    "password": "aaaa"
}
</code>```

http://192.168.0.101:5000/api/users/

```<code>[
     {
         "id": 1,
         "login": "123",
         "password": "1231231"
     },
     {
         "id": 2,
         "login": "login",
         "password": "sfsdfsd"
     },
     {
         "id": 3,
         "login": "4444",
         "password": "sass"
     },
     {
         "id": 4,
         "login": "ffff",
         "password": "aaaa"
     }
]
</code>```

答: SOLUTION: I added key 'Accept' and value 'application/json' to headers tab in postman and it works!

Body:
I want to update sqlite entry using put http method. When I send request via postman I get this error:

Method Not Allowed

The method is not allowed for the requested URL.

Here is my code:

@app.route('/api/users/<int:user_id>', methods=['PUT'])
def put_user(user_id):
    user = {
        'id': user_id,
        'login': request.json['login'],
        'password': request.json['password'],
    }
    cursor.execute('UPDATE USERS SET login=?, password=? WHERE id=?', (user['login'], user['password'], user['id']))
    connection.commit()
    return jsonify(user), 200

Here is request:

http://192.168.0.101:5000/api/users/4/

{
    "id": 4,
    "login": "bbbb",
    "password": "aaaa"
}

http://192.168.0.101:5000/api/users/

[
     {
         "id": 1,
         "login": "123",
         "password": "1231231"
     },
     {
         "id": 2,
         "login": "login",
         "password": "sfsdfsd"
     },
     {
         "id": 3,
         "login": "4444",
         "password": "sass"
     },
     {
         "id": 4,
         "login": "ffff",
         "password": "aaaa"
     }
]


问:
Comand "play install maven" doesn't work
I'm doing like in official Play instruction says:

first you need to download and install apache maven

finally, you need to install the play-maven module

play install maven

I have installed maven. I have created a new Play project, then I send a command "play install maven". Here is console output:

D:\PlayFrameworkProject\Library2\Library2>play install maven

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256M;
support was removed in 8.0

[info] Loading project definition from D:\PlayFrameworkProject\Library2\Library2\project

[info] Set current project to Library2 (in build file:/D:/PlayFrameworkProject/Library2/Library2/)

[error] Not a valid command: install (similar: initialize, inspect, shell)

[error] Not a valid project ID: install

[error] Expected ':' (if selecting a configuration)

[error] Not a valid key: install (similar: lintian, initialize, dist)

[error] install

[error]        ^

Here is link for instruction
https://www.playframework.com/modules/maven-head/home

What wrong I'm doing?

答:
These instructions appear to be fore the play-maven plugin, which hasn't been updated since 2011. I'd say it's out of date and doesn't work anymore.

A more recent plugin is here: https://github.com/play2-maven-plugin/play2-maven-plugin. This plugin is developed by a third party so I'm not sure how well it works.

The official way to run Play is to use sbt instead of Maven. Instructions for installing and running Play with sbt are here: https://www.playframework.com/documentation/2.6.x/Installing#Installing-Play-with-SBT


问:
How to show very specific potion of the image

From the image above, I want to show only the portion (inside of white border) of image. I'm using React Native but I think this can be either Javascript, CSS, or React Native problem.

The example white border location information can be given: If the white square is located in (200, 200) at left top coordinate with 100 wide square, the data for white square is left:200, top:200, thumbSize:100.

Example Code:

```<code>return (
  <Image
    source={require('../../path/img.jpg')}
    ??
    style={{??}}
  />
);
</code>```

Can I show very specific portion of the image with given data? (left, top, thumbSize)

Thanks!!

UPDATE Expected output is 100 by 100 square located at (200, 200).

答:
Tested on Chromium 62

```<code>img {
 position: absolute;
 clip: rect(0px,60px,200px,0px);
 }
</code>```

using clip property in CSS you can clip it.
show any part you want to show.

Body:
From the image above, I want to show only the portion (inside of white border) of image. I'm using React Native but I think this can be either Javascript, CSS, or React Native problem.

The example white border location information can be given: If the white square is located in (200, 200) at left top coordinate with 100 wide square, the data for white square is left:200, top:200, thumbSize:100.

Example Code:

return (
  <Image
    source={require('../../path/img.jpg')}
    ??
    style={{??}}
  />
);

Can I show very specific portion of the image with given data? (left, top, thumbSize)

Thanks!!

UPDATE Expected output is 100 by 100 square located at (200, 200).

Body:
Tested on Chromium 62

img {
 position: absolute;
 clip: rect(0px,60px,200px,0px);
 }

using clip property in CSS you can clip it.
show any part you want to show.


问:
Complex html to plain text - Angular 4 / Javascript
I am working on the project and I have a problem. The thing is I need to decode html that I get as a part of JSON object from API. The html is quite tricky so I need to ask for your help guys.

That is the sample value that I need to translate into plain text:

\rSave up to 49% bla bla some text, text, text World of text and text text. For text details of text prices, click on the location required.
\r

To text your text text call

0871 222 text and quote

ELG2017

\r

Yeah I know, it's horrible. Well, that's what I have to decode..

Thanks a lot!

答:
You can use something like this:

```<code>htmlToText(html) {
  var tmp = document.createElement('DIV'); // TODO: Check if this the way to go with Angular
  tmp.innerHTML = html;
  return tmp.textContent || tmp.innerText || '';
}
</code>```

https://jsfiddle.net/z762py3s/

Body:
You can use something like this:

htmlToText(html) {
  var tmp = document.createElement('DIV'); // TODO: Check if this the way to go with Angular
  tmp.innerHTML = html;
  return tmp.textContent || tmp.innerText || '';
}

https://jsfiddle.net/z762py3s/


问:
How to create service in Android and consume it?
I am very new to the Android platform. Now in my app I want to create service and so please give me some info that how to create a service and consume it in my app. And how to start the service when the OS starts up?</p>

答:
All the information that should be necessary, including examples on how to create and consume services, is available directly from the Android documentation here.

It is doubtful that any answer could provide more insight into creating and consuming Services then that link.


问:
Apache camel 2.17 No consumer available on end point using spring context
Getting no consumers available at end point while inter connecting two different camel contexts.
JBoss Fuse 6.3
EAP server 6.4
Package: War

Camel Context 1:

```<code><?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans            http://www.springframework.org/schema/beans/spring-beans.xsd                   http://camel.apache.org/schema/spring                 http://camel.apache.org/schema/spring/camel-spring.xsd">
    <camelContext xmlns="http://camel.apache.org/schema/spring">
        <route id="_route1">
            <from id="_from1" uri="file:C:/Temp/Selva/inbox?noop=true"/>
            <log id="_log1" loggingLevel="INFO" message=" Proxy Route..!!! "/>
            <to id="_to1" uri="direct-vm:inProvider"/>
        </route>
    </camelContext>
</beans>
</code>```

Camel Context2:

```<code><?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans                          http://www.springframework.org/schema/beans/spring-beans.xsd                           http://camel.apache.org/schema/spring                            http://camel.apache.org/schema/spring/camel-spring.xsd">
    <camelContext  xmlns="http://camel.apache.org/schema/spring">
        <route id="_route1">
            <from id="_from1" uri="direct-vm:inProvider"/>
            <log id="_log1" loggingLevel="INFO" message="Modelling Platform Router..!!! "/>
            <to id="_to1" uri="file:C:/Users/cpiespc/Selva/outbox"/>
        </route>
    </camelContext>
</beans>
</code>```

web.xml:

```<code><?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
      <display-name>CamelContext</display-name>
      <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:META-INF/spring/*.xml</param-value>
      </context-param>
      <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>
    </web-app>
</code>```

答:
You cannot connect via direct-vm on JBoss EAP as the classloader isolation will prevent that when deploying as WAR files.

You may be able to do it via wildfly-camel sub-modules, but I don't know, but you can ask that team: https://github.com/wildfly-extras/wildfly-camel

Body:
Getting no consumers available at end point while inter connecting two different camel contexts.
JBoss Fuse 6.3
EAP server 6.4
Package: War

Camel Context 1:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans            http://www.springframework.org/schema/beans/spring-beans.xsd                   http://camel.apache.org/schema/spring                 http://camel.apache.org/schema/spring/camel-spring.xsd">
    <camelContext xmlns="http://camel.apache.org/schema/spring">
        <route id="_route1">
            <from id="_from1" uri="file:C:/Temp/Selva/inbox?noop=true"/>
            <log id="_log1" loggingLevel="INFO" message=" Proxy Route..!!! "/>
            <to id="_to1" uri="direct-vm:inProvider"/>
        </route>
    </camelContext>
</beans>

Camel Context2:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans                          http://www.springframework.org/schema/beans/spring-beans.xsd                           http://camel.apache.org/schema/spring                            http://camel.apache.org/schema/spring/camel-spring.xsd">
    <camelContext  xmlns="http://camel.apache.org/schema/spring">
        <route id="_route1">
            <from id="_from1" uri="direct-vm:inProvider"/>
            <log id="_log1" loggingLevel="INFO" message="Modelling Platform Router..!!! "/>
            <to id="_to1" uri="file:C:/Users/cpiespc/Selva/outbox"/>
        </route>
    </camelContext>
</beans>

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
      <display-name>CamelContext</display-name>
      <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:META-INF/spring/*.xml</param-value>
      </context-param>
      <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>
    </web-app>


问:
How do i execute alert() in parent component after onClick in child component
In here, i'm passing data from child to parent and i am able to pass it through but i want alert function to execute only after onClick event is triggered in the child component but it is executing everytime onSubmit event is fired, it looks like there is a requirement of some life cycle method in order to make it work but i'm not getting it. Can someone help me with this please

Parent

```<code>onList(list) {
  alert(list);
 }

  render() {
    return (
      <div>
       <form>
        <input type='textarea'
               onKeyPress={this.handleSubmit}
        />
        <Child {...this.state} sendList={this.onList}/>
       </form>
      </div>
    )
  }
</code>```

Child

```<code>    {
      this.props.listArr.map((list,index) => {
         return(
           <div key={index}>
            <li>{list}
              <div>
               <button className="btn btn-primary btn-xs glyphicon glyphicon-pencil" onClick={this.props.sendList(list)} />
              </div>
            </li>
           </div>
         )})
     }
</code>```

答:
You can use event.preventDefault() on button click so the form doesn't get submitted.

const Child = ({ sendList, list }) =>

    <button onClick={(event) => sendList(event, list)}>Click</button>

class Parent extends React.Component {
  constructor() {
    super()

    this.onList = this.onList.bind(this)
  }

  onList(event, list) {
    event.preventDefault()
    console.log('onList', list)
  }

  render() {
    return (
      <form>
        <Child sendList={this.onList} list={[]} />
      </form>
    )
  }
}

ReactDOM.render(
  <Parent />,
  document.getElementById('root')
)```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
<div id="root"></div></code>```

Body:
In here, i'm passing data from child to parent and i am able to pass it through but i want alert function to execute only after onClick event is triggered in the child component but it is executing everytime onSubmit event is fired, it looks like there is a requirement of some life cycle method in order to make it work but i'm not getting it. Can someone help me with this please

Parent

onList(list) {
  alert(list);
 }

  render() {
    return (

       <form>
        <input type='textarea'
               onKeyPress={this.handleSubmit}
        />
        <Child {...this.state} sendList={this.onList}/>
       </form>

    )
  }

Child

    {
      this.props.listArr.map((list,index) => {
         return(

{list}

               <button className="btn btn-primary btn-xs glyphicon glyphicon-pencil" onClick={this.props.sendList(list)} />

         )})
     }

Body:
You can use event.preventDefault() on button click so the form doesn't get submitted.

const Child = ({ sendList, list }) =>
  <div>
    <button onClick={(event) => sendList(event, list)}>Click</button>
  </div>

class Parent extends React.Component {
  constructor() {
    super()

    this.onList = this.onList.bind(this)
  }

  onList(event, list) {
    event.preventDefault()
    console.log('onList', list)
  }

  render() {
    return (
      <form>
        <Child sendList={this.onList} list={[]} />
      </form>
    )
  }
}

ReactDOM.render(
  <Parent />,
  document.getElementById('root')
)

<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
<div id="root"></div>


问:
Java - Performance difference between static and non static
How big is difference in performance, when class is initialized every time and methods are not static (new Class()) or methods in this class are static and usage of them is like Class.method()?

Example code:

```<code>//File Class1
public class Class1{
    public static void myMethod(){
        System.out.println("Static method, usage: Class1.myMethod();")
    }
}

//File Class2
public class Class2{
    public void myNonStaticMethod(){
        System.out.println("Non static method, usage: Class2 class2 = new Class2(); class2.myNonStaticMethod();")
    }
}
</code>```

Which one will be faster? Static or method with class initialization?

PS. Sorry, if I did any mistake. English is not my main language. :P

答:
It just depends on what you are trying to achieve. The point of making a method or a variable static is for when you want to be able to access them without necessarily creating instances of their parent classes. For example:

You can have a class for calculating Body Mass index. Within that class you can have a method x for converting Kilograms to Pounds. Now one can one to do a conversion of Kilograms to pounds but not want to calculate their Body Mass index. In this kind of scenario it makes sense to make that method x static, so one can do a conversion of Kilograms to pounds without creating a new instance of x.

So it's not about performance really, but about usage.

Body:
How big is difference in performance, when class is initialized every time and methods are not static (new Class()) or methods in this class are static and usage of them is like Class.method()?

Example code:

//File Class1
public class Class1{
    public static void myMethod(){
        System.out.println("Static method, usage: Class1.myMethod();")
    }
}

//File Class2
public class Class2{
    public void myNonStaticMethod(){
        System.out.println("Non static method, usage: Class2 class2 = new Class2(); class2.myNonStaticMethod();")
    }
}

Which one will be faster? Static or method with class initialization?

PS. Sorry, if I did any mistake. English is not my main language. :P


问:
Array doesn't work in Vue

This code works well. But if I change the code, it doesn't work.

I'd like anyone to help me if they has experience in Vue.js.

答: It does work, it should be used like this {{colorList[0]}} not {{this.colorList[0]}}since vue template is using the “Mustache” syntax.

Title: Array doesn't work in Vue


问:
if statements for c++
My program so far, my question is do i have to include the if statements after each cout/cin code or is there a way to generalize it? : </p>

```<code>#include <iostream>
using namespace std;

int main ()
{
   double watts, hours_per_day, watt_hours, dollars_per_wh, result;

   dollars_per_wh= .00008;

   cout << " How many Watts for the Air conditioner? ";
   cin >> watts;
   cout << " How many hours/day do you run the Air Conditioner? ";
   cin >> hours_per_day;

   if (watts< 0)
   {
      cout << "Error- negative watts detected " << endl;
      return 1;
   }

   if (hours_per_day< 0)
   {
      cout << "Error - negative hours/day detected " << endl;
      return 1;
   }

   cout << "How many Watts for the Television? " ;
   cin >> watts;
   cout << "How many hours/day do you run the Television? " ;
   cin >> hours_per_day;

   if (watts< 0)
   {
      cout << "Error- negative watts detected " << endl;
      return 1;
   }

   if (hours_per_day< 0)
   {
      cout << "Error - negative hours/day detected " << endl;
      return 1;
   }

   cout << "How many Watts for the Washer? " ;
   cin >> watts;
   cout << "How many hours/day do you run the Washer? " ;
   cin >> hours_per_day;

   if (watts< 0)
   {
      cout << "Error- negative watts detected " << endl;
      return 1;
   }

   if (hours_per_day< 0)
   {
      cout << "Error - negative hours/day detected " << endl;
      return 1;
   }

  return 0 ;
}
</code>```

答:
You can write a function that takes two parameters:

```<code>bool check(int watts, int hours_per_day)
{
    if (watts< 0)
    {
        cout << "Error- negative watts detected " << endl;
        return false;
    }

   if (hours_per_day< 0)
   {
        cout << "Error - negative hours/day detected " << endl;
        return false;
   }
}
</code>```

Then in your main function you can replace the two if statements with one:

```<code>if(!check(watts, hours_per_day))
{
    return 1;
}
</code>```

If you want to collect all the inputs first and then evaluate them, then maybe use an array for watts and hours_per_day.  Then you can run through the array and check each entry.

Title: if statements for c++

Body:
My program so far, my question is do i have to include the if statements after each cout/cin code or is there a way to generalize it? :

#include <iostream>
using namespace std;

int main ()
{
   double watts, hours_per_day, watt_hours, dollars_per_wh, result;

   dollars_per_wh= .00008;

   cout << " How many Watts for the Air conditioner? ";
   cin >> watts;
   cout << " How many hours/day do you run the Air Conditioner? ";
   cin >> hours_per_day;

   if (watts< 0)
   {
      cout << "Error- negative watts detected " << endl;
      return 1;
   }

   if (hours_per_day< 0)
   {
      cout << "Error - negative hours/day detected " << endl;
      return 1;
   }

   cout << "How many Watts for the Television? " ;
   cin >> watts;
   cout << "How many hours/day do you run the Television? " ;
   cin >> hours_per_day;

   if (watts< 0)
   {
      cout << "Error- negative watts detected " << endl;
      return 1;
   }

   if (hours_per_day< 0)
   {
      cout << "Error - negative hours/day detected " << endl;
      return 1;
   }

   cout << "How many Watts for the Washer? " ;
   cin >> watts;
   cout << "How many hours/day do you run the Washer? " ;
   cin >> hours_per_day;

   if (watts< 0)
   {
      cout << "Error- negative watts detected " << endl;
      return 1;
   }

   if (hours_per_day< 0)
   {
      cout << "Error - negative hours/day detected " << endl;
      return 1;
   }

  return 0 ;
}

Body:
You can write a function that takes two parameters:

bool check(int watts, int hours_per_day)
{
    if (watts< 0)
    {
        cout << "Error- negative watts detected " << endl;
        return false;
    }

   if (hours_per_day< 0)
   {
        cout << "Error - negative hours/day detected " << endl;
        return false;
   }
}

Then in your main function you can replace the two if statements with one:

if(!check(watts, hours_per_day))
{
    return 1;
}

If you want to collect all the inputs first and then evaluate them, then maybe use an array for watts and hours_per_day.  Then you can run through the array and check each entry.


问:
Adding textview below each group of items in listview
First of all,I am sorry if my question is meaningless or wrong.

I need to add textview as the footer view to listview ,and that
  footer view should be repeated for particular number of items.

For example,

If I am having 50 items in a list, whenever I am displaying it in listview , the textview should be displayed below the each group of 10 items (That is the textview should separate 10 items).

Can anyone help me please. I don't even know "using footer view to achieve this is right or not". Thanks!

答: You could @Override getItemViewType and return 2 type of views based on the position (you set a condition there). Also, in onBindViewHolder (if you use a Recyclerview, and I suggest you to do that) you will check which view was returned and what data to fetch.  This post should help you understand perfectly.