问:
How to put a TextView at the end of my ScrollView?
I want to add a TextView at the bottom of my ScrollView, in which I can put the version number. So when a user first enters the screen, they don't see the Version Number. After they Scroll down, they can see the version number at the bottom of the screen. I tried all kinds of ways, doesn't work.
The layout is pretty nested.

This is the screenshot of the layout implementing the code below

```<code>    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ScrollView
            android:id="@+id/scrollView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <LinearLayout
                android:id="@+id/linearLayoutThatDoesNotScroll"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@drawable/bg_splash"
                android:clickable="true"
                android:orientation="vertical">

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:padding="@dimen/cnt_full">

                    <RelativeLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerHorizontal="false"
                        android:layout_centerVertical="true"
                        android:layout_gravity="center">

                        <com.onkore.app.view.FontTextView
                            android:id="@+id/profile_num_trophies_won"
                            style="@style/Theme.App.Text.Headline"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentStart="true"
                            android:layout_marginTop="@dimen/cnt_half"
                            android:drawablePadding="@dimen/cnt_tiny"
                            android:drawableStart="@drawable/icon_trophy"
                            android:fontFamily="thick"
                            android:gravity="center_vertical"
                            android:text="99"
                            android:textColor="@color/color_text_primary_inverse"
                            android:textSize="32sp" />

                        <com.onkore.app.view.FontTextView
                            style="@style/Theme.App.Text.Caption"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_below="@id/profile_num_trophies_won"
                            android:text="@string/profile_trophies"
                            android:textColor="@color/color_text_primary_inverse" />
                    </RelativeLayout>

                    <RelativeLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerInParent="true">

                        <com.makeramen.roundedimageview.RoundedImageView
                            android:id="@+id/profile_user_pic"
                            android:layout_width="@dimen/profile_image_size"
                            android:layout_height="@dimen/profile_image_size"
                            android:layout_centerInParent="true"
                            android:layout_centerVertical="false"
                            android:src="@drawable/icon_profile_default"
                            app:riv_oval="true" />

                        <com.mikhaellopez.circularprogressbar.CircularProgressBar
                            android:id="@+id/profile_progress_bar"
                            android:layout_width="@dimen/profile_progress_bar_size"
                            android:layout_height="@dimen/profile_progress_bar_size"
                            android:layout_centerHorizontal="false"
                            android:layout_centerInParent="true"
                            android:layout_centerVertical="false"
                            app:cpb_background_progressbar_color="@color/color_base"
                            app:cpb_background_progressbar_width="@dimen/elev_06"
                            app:cpb_progress="25"
                            app:cpb_progressbar_color="@color/color_progress"
                            app:cpb_progressbar_width="@dimen/cnt_tiny" />

                        <com.onkore.app.view.FontTextView
                            android:id="@+id/profile_level"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_below="@id/profile_progress_bar"
                            android:layout_centerHorizontal="true"
                            android:layout_centerInParent="false"
                            android:layout_marginTop="@dimen/cnt_dbl"
                            android:textColor="@color/color_text_primary_inverse"
                            android:textSize="@dimen/text_size"
                            tools:text="Level 99" />

                    </RelativeLayout>

                    <com.onkore.app.view.FontTextView
                        android:id="@+id/profile_okoins"
                        style="@style/Theme.App.Coins.Balance"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentEnd="true"
                        android:layout_centerVertical="true"
                        android:layout_gravity="center_vertical"
                        tools:text="999k" />
                </RelativeLayout>

                <com.onkore.app.view.FontTextView
                    style="@style/Theme.App.Tile.Text"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginEnd="@dimen/cnt_full"
                    android:layout_marginStart="@dimen/cnt_full"
                    android:layout_marginTop="@dimen/cnt_full"
                    android:background="@drawable/bg_card_empty"
                    android:gravity="center"
                    android:paddingBottom="@dimen/cnt_dbl"
                    android:paddingTop="@dimen/cnt_part"
                    android:text="Tap to Personalize"
                    android:textAllCaps="true"
                    android:visibility="gone" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@color/color_primary_translucent"
                    android:visibility="gone">

                    <com.onkore.app.view.FontTextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Friends" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="50dp"
                    >

                    <TextView
                        android:id="@+id/versionName"
                        android:layout_width="match_parent"
                        android:layout_height="40dp"
                        android:background="@color/cardview_dark_background"
                        android:gravity="center_vertical|center_horizontal|center"
                        android:text="HAHA"
                        android:textColor="@color/cardview_light_background"
                        android:visibility="visible" />
                </LinearLayout>
            </LinearLayout>
        </ScrollView>

    </RelativeLayout>
</code>```

答:
maybe something like this?</p>

```<code><?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:layout_editor_absoluteX="8dp"
    tools:layout_editor_absoluteY="8dp">

    <ScrollView
        android:id="@+id/scrollView"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:id="@+id/linearLayoutThatDoesNotScroll"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/colorAccent"
            android:clickable="true"
            android:orientation="vertical">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="1000dp" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center_horizontal"
                android:text="version"
                android:textSize="50dp" />

        </LinearLayout>
    </ScrollView>
</RelativeLayout>
</code>```

Body:
I want to add a TextView at the bottom of my ScrollView, in which I can put the version number. So when a user first enters the screen, they don't see the Version Number. After they Scroll down, they can see the version number at the bottom of the screen. I tried all kinds of ways, doesn't work.
The layout is pretty nested.

This is the screenshot of the layout implementing the code below

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ScrollView
            android:id="@+id/scrollView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <LinearLayout
                android:id="@+id/linearLayoutThatDoesNotScroll"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@drawable/bg_splash"
                android:clickable="true"
                android:orientation="vertical">

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:padding="@dimen/cnt_full">

                    <RelativeLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerHorizontal="false"
                        android:layout_centerVertical="true"
                        android:layout_gravity="center">

                        <com.onkore.app.view.FontTextView
                            android:id="@+id/profile_num_trophies_won"
                            style="@style/Theme.App.Text.Headline"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentStart="true"
                            android:layout_marginTop="@dimen/cnt_half"
                            android:drawablePadding="@dimen/cnt_tiny"
                            android:drawableStart="@drawable/icon_trophy"
                            android:fontFamily="thick"
                            android:gravity="center_vertical"
                            android:text="99"
                            android:textColor="@color/color_text_primary_inverse"
                            android:textSize="32sp" />

                        <com.onkore.app.view.FontTextView
                            style="@style/Theme.App.Text.Caption"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_below="@id/profile_num_trophies_won"
                            android:text="@string/profile_trophies"
                            android:textColor="@color/color_text_primary_inverse" />
                    </RelativeLayout>

                    <RelativeLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerInParent="true">

                        <com.makeramen.roundedimageview.RoundedImageView
                            android:id="@+id/profile_user_pic"
                            android:layout_width="@dimen/profile_image_size"
                            android:layout_height="@dimen/profile_image_size"
                            android:layout_centerInParent="true"
                            android:layout_centerVertical="false"
                            android:src="@drawable/icon_profile_default"
                            app:riv_oval="true" />

                        <com.mikhaellopez.circularprogressbar.CircularProgressBar
                            android:id="@+id/profile_progress_bar"
                            android:layout_width="@dimen/profile_progress_bar_size"
                            android:layout_height="@dimen/profile_progress_bar_size"
                            android:layout_centerHorizontal="false"
                            android:layout_centerInParent="true"
                            android:layout_centerVertical="false"
                            app:cpb_background_progressbar_color="@color/color_base"
                            app:cpb_background_progressbar_width="@dimen/elev_06"
                            app:cpb_progress="25"
                            app:cpb_progressbar_color="@color/color_progress"
                            app:cpb_progressbar_width="@dimen/cnt_tiny" />

                        <com.onkore.app.view.FontTextView
                            android:id="@+id/profile_level"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_below="@id/profile_progress_bar"
                            android:layout_centerHorizontal="true"
                            android:layout_centerInParent="false"
                            android:layout_marginTop="@dimen/cnt_dbl"
                            android:textColor="@color/color_text_primary_inverse"
                            android:textSize="@dimen/text_size"
                            tools:text="Level 99" />

                    </RelativeLayout>

                    <com.onkore.app.view.FontTextView
                        android:id="@+id/profile_okoins"
                        style="@style/Theme.App.Coins.Balance"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentEnd="true"
                        android:layout_centerVertical="true"
                        android:layout_gravity="center_vertical"
                        tools:text="999k" />
                </RelativeLayout>

                <com.onkore.app.view.FontTextView
                    style="@style/Theme.App.Tile.Text"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginEnd="@dimen/cnt_full"
                    android:layout_marginStart="@dimen/cnt_full"
                    android:layout_marginTop="@dimen/cnt_full"
                    android:background="@drawable/bg_card_empty"
                    android:gravity="center"
                    android:paddingBottom="@dimen/cnt_dbl"
                    android:paddingTop="@dimen/cnt_part"
                    android:text="Tap to Personalize"
                    android:textAllCaps="true"
                    android:visibility="gone" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@color/color_primary_translucent"
                    android:visibility="gone">

                    <com.onkore.app.view.FontTextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Friends" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="50dp"
                    >

                    <TextView
                        android:id="@+id/versionName"
                        android:layout_width="match_parent"
                        android:layout_height="40dp"
                        android:background="@color/cardview_dark_background"
                        android:gravity="center_vertical|center_horizontal|center"
                        android:text="HAHA"
                        android:textColor="@color/cardview_light_background"
                        android:visibility="visible" />
                </LinearLayout>
            </LinearLayout>
        </ScrollView>

    </RelativeLayout>

Body:
maybe something like this?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:layout_editor_absoluteX="8dp"
    tools:layout_editor_absoluteY="8dp">

    <ScrollView
        android:id="@+id/scrollView"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:id="@+id/linearLayoutThatDoesNotScroll"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/colorAccent"
            android:clickable="true"
            android:orientation="vertical">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="1000dp" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center_horizontal"
                android:text="version"
                android:textSize="50dp" />

        </LinearLayout>
    </ScrollView>
</RelativeLayout>


来源: stackexchange

问:
PHP MVC: Query builder class for Data Mapper layer
I'm working on my own MVC framework in PHP. Its model layer consists of

Domain objects (also known as "models"), which encapsulate the business logic and

Data mappers, for transfering the data between the domain objects and the database.

A data mapper abstract class does not exist, each data mapper class containing its own implementation of the data access layer. The class methods of the data mappers contain, or will contain complex sql statements.

My question is: Under these circumstances, is the use of a query builder class - responsible for building the sql statements - a limitation, or are there some good arguments, why this component should be implemented?

I appreciate your help. Thank you.

答:
1.) A well featured query builder could be an advantage, in that it could provide an interface which would abstract the SQL dialect. Therefore, you could write your data mapper implementations without the need to consider the specific RDBMS you will be working with.

2.) In some of my DAO or Service classes, I may have two (or more) functions that perform slightly different queries against the same table(s). Sometimes, these queries can be quite large, and have a number of joins or sub-queries while only differing in the columns used in the WHERE clause. While it might make sense to keep these functions separated with signatures like, getEmployeesAgedBetween(Range<Integer> range) and getSalariedEmployeesAgedBetween(Range<Integer> range), these functions can grow quite quickly in number based upon your needs. Looking to refactor a case like this, I would aim for a more robust method that parameterizes all possible differences between these methods. It is apparent that I am only looking to make a more dynamic WHERE clause under the hood, so I would not necessarily need a full-fledged query builder. However, a WHERE clause builder would be quite useful. Using such an implementation, I could refactor the above functions into a single method with a signature like getEmployees(Where<EmployeeDAO.FIELDS> where). I have actually implemented such a method, and both my coworkers and myself have enjoyed working with, and maintaining such methods over the prior implementations.

ContentLicense: CC BY-SA 3.0


问:
How to check whether an element is Present inside another element or not in Jquery?
I have an html code which add elements  dynamically.
On button click i wanted to check whether the elements present inside the
div or not

HTML :

```<code><div id="mainDiv">
<span class="child">span1</span>
</div>
<button id="check"></button>
</code>```

JQuery:

```<code>$(function() {
$("#check").click(function(){
   // exist or not
});
</code>```

答:
Try this :

```<code>$(function() {
    $("#check").click(function(){
   if ( $(".child").parents("#mainDiv").length == 1 )
   {
         //  the child element is inside the parent
   }
    else
   {
           //it is not inside
   }
    });
});
</code>```

hope it is helpfull

Body:
I have an html code which add elements  dynamically.
On button click i wanted to check whether the elements present inside the
div or not

HTML :

span1

<button id="check"></button>

JQuery:

$(function() {
$("#check").click(function(){
   // exist or not
});

Body:
Try this :

$(function() {
    $("#check").click(function(){
   if ( $(".child").parents("#mainDiv").length == 1 )
   {
         //  the child element is inside the parent
   }
    else
   {
           //it is not inside
   }
    });
});

hope it is helpfull


问:
Wildfly Swarm security domain configuration
We are trying to migrate a project from Wildfly 10 to Wildfly Swarm 2017.6, and we have a reached a stumbling block porting the security-domain. Our security domain is configured as follows:

```<code><security-domain name="sec-id">
   <authentication-jaspi>
   <login-module-stack name="sec-id-module-stack">
   <login-module code="com.obbi.domain.security.loginmodule.jwt.JWTLoginModule" flag="sufficient" module="com.obbi.domain.security">
   <module-option name="expectedIssuer" value="CN=DI SIT signer"/>
   <module-option name="expectedAudience" value="Obbi"/>
   <module-option name="allowedClockSkewInSeconds" value="30"/>
   <module-option name="validateTokenSignature" value="false"/>
   <module-option name="maxFutureValidityInMinutes" value="525600"/>
   <module-option name="keyStoreFilePath" value="C:/wildfly-10.1.0.Final/standalone/configuration/keystore.jks"/>
   <module-option name="keyStorePassword" value="obbi123"/>
   <module-option name="validateCertificate" value="false"/>
   <module-option name="loadSystemPrincipals" value="true"/>
   <module-option name="loadSystemPrincipalsEndpoint" value="https://test.obbi.co.za:9443/services/v1/obbi-id?page=0&size=1000&username=%s"/>
   <module-option name="skipAllValidators" value="true"/>
   </login-module>
   </login-module-stack>
   <auth-module code="com.obbi.domain.security.JASPICServerAuthModule" flag="required" login-module-stack-ref="sec-id-module-stack"/>
   </authentication-jaspi>
</security-domain>
</code>```

We also have a standard module configured on com.obbi.domain.security. The module is just a standard module as follows:

```<code><module xmlns="urn:jboss:module:1.3" name="com.obbi.domain.security">
  <resources>
    <resource-root path="domain-service-security-jboss-2.0-SNAPSHOT.jar"/>
    <resource-root path="domain-service-security-client-2.0-SNAPSHOT.jar"/>
    <resource-root path="jose4j-0.5.0.jar"/>
  </resources>
  <dependencies>
    <module name="org.jboss.as.web"/>
    <module name="org.jboss.logging"/>
    <module name="org.picketbox"/>
    <module name="javax.api"/>
    <module name="javax.security.auth.message.api"/>
    <module name="javax.servlet.api"/>
  </dependencies>
</module>
</code>```

I can't find any wildfly swarm security fragment mappings that match to the subsystem. May I ask if they do exist, and if there is any documentation on them, of if anyone can assist in this forum can assist?

Regards

答:
I'm using the org.wildfly.swarm.security fraction:

```<code><dependency>
    <groupId>org.wildfly.swarm</groupId>
    <artifactId>security</artifactId>
</dependency>
</code>```

Documentation can be found in the reference guide, usage looks like:

```<code>SecurityFraction
        .defaultSecurityFraction()
        .securityDomain(new SecurityDomain("remote").classicAuthentication(new ClassicAuthentication()
                .loginModule(new LoginModule("Remoting")
                        .code("Remoting")
                        .flag(Flag.OPTIONAL)
                        .moduleOption("password-stacking", "useFirstPass"))
                .loginModule(new LoginModule("RealmDirect")
                        .code("RealmDirect")
                        .flag(Flag.REQUIRED)
                        .moduleOption("password-stacking", "useFirstPass"))));
</code>```

For your case, the call to classicAuthentication() should be replaced with jaspiAuthentication(). The login module can be deployed like any other module on Swarm.

Body:
We are trying to migrate a project from Wildfly 10 to Wildfly Swarm 2017.6, and we have a reached a stumbling block porting the security-domain. Our security domain is configured as follows:

<security-domain name="sec-id">
   <authentication-jaspi>
   <login-module-stack name="sec-id-module-stack">
   <login-module code="com.obbi.domain.security.loginmodule.jwt.JWTLoginModule" flag="sufficient" module="com.obbi.domain.security">
   <module-option name="expectedIssuer" value="CN=DI SIT signer"/>
   <module-option name="expectedAudience" value="Obbi"/>
   <module-option name="allowedClockSkewInSeconds" value="30"/>
   <module-option name="validateTokenSignature" value="false"/>
   <module-option name="maxFutureValidityInMinutes" value="525600"/>
   <module-option name="keyStoreFilePath" value="C:/wildfly-10.1.0.Final/standalone/configuration/keystore.jks"/>
   <module-option name="keyStorePassword" value="obbi123"/>
   <module-option name="validateCertificate" value="false"/>
   <module-option name="loadSystemPrincipals" value="true"/>
   <module-option name="loadSystemPrincipalsEndpoint" value="https://test.obbi.co.za:9443/services/v1/obbi-id?page=0&size=1000&username=%s"/>
   <module-option name="skipAllValidators" value="true"/>
   </login-module>
   </login-module-stack>
   <auth-module code="com.obbi.domain.security.JASPICServerAuthModule" flag="required" login-module-stack-ref="sec-id-module-stack"/>
   </authentication-jaspi>
</security-domain>

We also have a standard module configured on com.obbi.domain.security. The module is just a standard module as follows:

<module xmlns="urn:jboss:module:1.3" name="com.obbi.domain.security">
  <resources>
    <resource-root path="domain-service-security-jboss-2.0-SNAPSHOT.jar"/>
    <resource-root path="domain-service-security-client-2.0-SNAPSHOT.jar"/>
    <resource-root path="jose4j-0.5.0.jar"/>
  </resources>
  <dependencies>
    <module name="org.jboss.as.web"/>
    <module name="org.jboss.logging"/>
    <module name="org.picketbox"/>
    <module name="javax.api"/>
    <module name="javax.security.auth.message.api"/>
    <module name="javax.servlet.api"/>
  </dependencies>
</module>

I can't find any wildfly swarm security fragment mappings that match to the subsystem. May I ask if they do exist, and if there is any documentation on them, of if anyone can assist in this forum can assist?

Regards

Body:
I'm using the org.wildfly.swarm.security fraction:

<dependency>
    <groupId>org.wildfly.swarm</groupId>
    <artifactId>security</artifactId>
</dependency>

Documentation can be found in the reference guide, usage looks like:

SecurityFraction
        .defaultSecurityFraction()
        .securityDomain(new SecurityDomain("remote").classicAuthentication(new ClassicAuthentication()
                .loginModule(new LoginModule("Remoting")
                        .code("Remoting")
                        .flag(Flag.OPTIONAL)
                        .moduleOption("password-stacking", "useFirstPass"))
                .loginModule(new LoginModule("RealmDirect")
                        .code("RealmDirect")
                        .flag(Flag.REQUIRED)
                        .moduleOption("password-stacking", "useFirstPass"))));

For your case, the call to classicAuthentication() should be replaced with jaspiAuthentication(). The login module can be deployed like any other module on Swarm.


问:
Filtering any email address
I have an authorizer function which needs to check email rules with wildcards e.g.

mike.12@*.myapp.com

p*@*.in

julia.admin@myapp.*

so e.g.

peter@gmail.com => false

peter@myapp.it => true (3rd. rule)

pete@someapp.in => true (2nd rule)

I am a bit stuck on how to best construct a regex - or maybe there are other out of the box solutions?
Appreciate any help!
Thanks

答:
Pattern:

```<code>/^[^@]+@(?:(?:myapp\..+)|.+(?:\.in|myapp\.com))$/
</code>```

Pattern Demo

Test Cases:

user@fail.com       #fail

user@myapp.pass     #pass

user@pass.in        #pass

user@pass.myapp.com #pass

I used non-capturing groups, but you can use capture groups for pattern brevity if you wish.

I have ordered the "alternatives" with shorter mismatching patterns before longer ones for efficiency.

I also used a negated character class instead of a dot before @ for speed reasons.

Title: Filtering any email address

Body:
Pattern:

/^[^@]+@(?:(?:myapp\..+)|.+(?:\.in|myapp\.com))$/

Pattern Demo

Test Cases:

user@fail.com       #fail

user@myapp.pass     #pass

user@pass.in        #pass

user@pass.myapp.com #pass

I used non-capturing groups, but you can use capture groups for pattern brevity if you wish.

I have ordered the "alternatives" with shorter mismatching patterns before longer ones for efficiency.

I also used a negated character class instead of a dot before @ for speed reasons.


问:
Rails 3: Social Stream Gem. Where is the code?
I've installed social_stream according to the README ( https://github.com/ging/social_stream ) and it works fine, however, I'd like to have the code in my app/ directory and the code isn't there.

The same question arises for Devise and other gems. When I install it, I'd like to have access to the controllers, models, views, etc but it seems nothing is in the app/.

What do I have to do in order to put the code there and being able to change it as I'd like? Or, access it in other folder.

Thank you

答:
AFAIK, they are within vendor folders.

Unless you have a good explanation, you should not put the addon within same app folder.

Imagine if social_stream gets upgraded and new features are released, you would be lost.

ContentLicense: CC BY-SA 2.5


问:
'Variable is never used' warning in android studio
i have created a button(id- btnBank).
But there is waraning of variable 'btnBank'is never used.

code in activity_maps.xml

```<code><Button
        android:id="@+id/btnBank"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Bank" />
</code>```

code in MapsActivity.java

Button btnBank = (Button) findViewById(R.id.btnBank);

```<code>    btnRestaurant.setOnClickListener(new View.OnClickListener() {
        String Bank = "bank";
        @Override
        public void onClick(View v) {
            Log.d("onClick", "Button is Clicked");
            mMap.clear();
            String url = getUrl(latitude, longitude, Bank);
            Object[] DataTransfer = new Object[2];
            DataTransfer[0] = mMap;
            DataTransfer[1] = url;
            Log.d("onClick", url);
            GetNearbyPlacesData getNearbyPlacesData = new GetNearbyPlacesData();
            getNearbyPlacesData.execute(DataTransfer);
            Toast.makeText(MapsActivity.this,"Nearby Bank", Toast.LENGTH_LONG).show();
        }
    });
</code>```

In first line of java code 'btnBank' appears grey

答:
just add
btnBank=null; in your on create method, because its not set to anything , which is giving you the error</p>

Body:
i have created a button(id- btnBank).
But there is waraning of variable 'btnBank'is never used.

code in activity_maps.xml

<Button
        android:id="@+id/btnBank"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Bank" />

code in MapsActivity.java

Button btnBank = (Button) findViewById(R.id.btnBank);

    btnRestaurant.setOnClickListener(new View.OnClickListener() {
        String Bank = "bank";
        @Override
        public void onClick(View v) {
            Log.d("onClick", "Button is Clicked");
            mMap.clear();
            String url = getUrl(latitude, longitude, Bank);
            Object[] DataTransfer = new Object[2];
            DataTransfer[0] = mMap;
            DataTransfer[1] = url;
            Log.d("onClick", url);
            GetNearbyPlacesData getNearbyPlacesData = new GetNearbyPlacesData();
            getNearbyPlacesData.execute(DataTransfer);
            Toast.makeText(MapsActivity.this,"Nearby Bank", Toast.LENGTH_LONG).show();
        }
    });

In first line of java code 'btnBank' appears grey


问:
NuGet Packages not being restored with TFS
I'm running into an issue with some NuGet packages not being restored during the msbuild process in a TFS build definition.

I have a total of nine NuGet packages in my solution and I can see seven of nine getting restored from the packages folder, however the other two never get restored or even attempted to be restored.  The packages are listed in the packages.config and the corresponding folders exist in the build directory.

I've tried adding the additional NuGet Restore mentioned in this MS document and I've tried running the NuGet command manually without success.

Additional Details:

The solution is for a .Net website that doesn't have a project file

NuGet.exe version is 2.8.60318.667

TFS 2015

msbuild.exe 14.0.23107

Targeting .Net Framework 4.0 (But have tried 4.5 as well with the same result)

AWSSDK.Core and AWSSDK.DynamoDBv2 are not being restored.

Contents of packages.config:

```<code><?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="AWSSDK.Core" version="3.3.15" targetFramework="net40" requireReinstallation="true" />
  <package id="AWSSDK.DynamoDBv2" version="3.3.4.14" targetFramework="net40" requireReinstallation="true" />
  <package id="Microsoft.Bcl" version="1.1.10" targetFramework="net40" requireReinstallation="true" />
  <package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net40" />
  <package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net40" />
  <package id="RestSharp" version="105.2.3" targetFramework="net40" requireReinstallation="true" />
  <package id="StackExchange.Redis" version="1.1.603" targetFramework="net40" requireReinstallation="true" />
  <package id="Twilio" version="4.7.2" targetFramework="net40" />
  <package id="Twilio.Lookups" version="1.1.0" targetFramework="net40" />
</packages>
</code>```

From the TFS Output:

```<code>> Build started 6/29/2017 11:51:47 PM.
>      1>Project "B:\site_agent\_work\4d978bf9\Site\Site.sln" on node 1 (default targets).
>      1>ValidateSolutionConfiguration:
>          Building solution configuration "Debug|Any CPU". B:\site_agent\_work\4d978bf9\Site\site.metaproj(0,0): Warning MSB3268:
> The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the
> currently targeted framework. ".NETFramework,Version=v4.5". To resolve
> this problem, either remove the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll"
> or retarget your application to a framework version which contains
> "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
>      1>Project "B:\site_agent\_work\4d978bf9\Site\Site.sln" (1) is building "B:\site_agent\_work\4d978bf9\Site\site.metaproj" (2) on node
> 1 (default targets).
>      2>B:\site_agent\_work\4d978bf9\Site\site.metaproj : warning MSB3268: The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the
> currently targeted framework. ".NETFramework,Version=v4.5". To resolve
> this problem, either remove the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll"
> or retarget your application to a framework version which contains
> "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
> B:\site_agent\_work\4d978bf9\Site\site.metaproj(0,0): Warning MSB3268:
> The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Threading.Tasks, Version=4.0.0.0,
> Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be
> resolved in the currently targeted framework.
> ".NETFramework,Version=v4.5". To resolve this problem, either remove
> the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll"
> or retarget your application to a framework version which contains
> "System.Threading.Tasks, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
>      2>B:\site_agent\_work\4d978bf9\Site\site.metaproj : warning MSB3268: The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Threading.Tasks, Version=4.0.0.0,
> Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be
> resolved in the currently targeted framework.
> ".NETFramework,Version=v4.5". To resolve this problem, either remove
> the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll"
> or retarget your application to a framework version which contains
> "System.Threading.Tasks, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
> B:\site_agent\_work\4d978bf9\Site\site.metaproj(0,0): Warning MSB3268:
> The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Threading.Tasks, Version=4.0.0.0,
> Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be
> resolved in the currently targeted framework.
> ".NETFramework,Version=v4.5". To resolve this problem, either remove
> the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll"
> or retarget your application to a framework version which contains
> "System.Threading.Tasks, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
>      2>B:\site_agent\_work\4d978bf9\Site\site.metaproj : warning MSB3268: The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Threading.Tasks, Version=4.0.0.0,
> Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be
> resolved in the currently targeted framework.
> ".NETFramework,Version=v4.5". To resolve this problem, either remove
> the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll"
> or retarget your application to a framework version which contains
> "System.Threading.Tasks, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
> B:\site_agent\_work\4d978bf9\Site\site.metaproj(0,0): Warning MSB3268:
> The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the
> currently targeted framework. ".NETFramework,Version=v4.5". To resolve
> this problem, either remove the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll"
> or retarget your application to a framework version which contains
> "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
>      2>B:\site_agent\_work\4d978bf9\Site\site.metaproj : warning MSB3268: The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the
> currently targeted framework. ".NETFramework,Version=v4.5". To resolve
> this problem, either remove the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll"
> or retarget your application to a framework version which contains
> "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
> B:\site_agent\_work\4d978bf9\Site\site.metaproj(0,0): Warning MSB3268:
> The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\StackExchange.Redis.1.1.603\lib\net40\StackExchange.Redis.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the
> currently targeted framework. ".NETFramework,Version=v4.5". To resolve
> this problem, either remove the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\StackExchange.Redis.1.1.603\lib\net40\StackExchange.Redis.dll"
> or retarget your application to a framework version which contains
> "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
>      2>B:\site_agent\_work\4d978bf9\Site\site.metaproj : warning MSB3268: The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\StackExchange.Redis.1.1.603\lib\net40\StackExchange.Redis.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the
> currently targeted framework. ".NETFramework,Version=v4.5". To resolve
> this problem, either remove the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\StackExchange.Redis.1.1.603\lib\net40\StackExchange.Redis.dll"
> or retarget your application to a framework version which contains
> "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
> B:\site_agent\_work\4d978bf9\Site\site.metaproj(0,0): Warning MSB3268:
> The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\StackExchange.Redis.1.1.603\lib\net40\StackExchange.Redis.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Threading.Tasks, Version=4.0.0.0,
> Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be
> resolved in the currently targeted framework.
> ".NETFramework,Version=v4.5". To resolve this problem, either remove
> the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\StackExchange.Redis.1.1.603\lib\net40\StackExchange.Redis.dll"
> or retarget your application to a framework version which contains
> "System.Threading.Tasks, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
>      2>B:\site_agent\_work\4d978bf9\Site\site.metaproj : warning MSB3268: The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\StackExchange.Redis.1.1.603\lib\net40\StackExchange.Redis.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Threading.Tasks, Version=4.0.0.0,
> Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be
> resolved in the currently targeted framework.
> ".NETFramework,Version=v4.5". To resolve this problem, either remove
> the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\StackExchange.Redis.1.1.603\lib\net40\StackExchange.Redis.dll"
> or retarget your application to a framework version which contains
> "System.Threading.Tasks, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\site\Bin\AjaxControlToolkit.dll" to
> "site\\Bin\AjaxControlToolkit.dll".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll"
> to "site\\Bin\Microsoft.Threading.Tasks.Extensions.Desktop.dll".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.xml"
> to "site\\Bin\Microsoft.Threading.Tasks.Extensions.Desktop.xml".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.1.1.10\lib\net40\System.IO.dll"
> to "site\\Bin\System.IO.dll".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.1.1.10\lib\net40\System.IO.xml"
> to "site\\Bin\System.IO.xml".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.1.1.10\lib\net40\System.Threading.Tasks.dll"
> to "site\\Bin\System.Threading.Tasks.dll".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.1.1.10\lib\net40\System.Threading.Tasks.xml"
> to "site\\Bin\System.Threading.Tasks.xml".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Twilio.4.7.2\lib\3.5\Twilio.Api.dll"
> to "site\\Bin\Twilio.Api.dll".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Twilio.4.7.2\lib\3.5\Twilio.Api.pdb"
> to "site\\Bin\Twilio.Api.pdb".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Twilio.4.7.2\lib\3.5\Twilio.Api.xml"
> to "site\\Bin\Twilio.Api.xml".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Twilio.Lookups.1.1.0\lib\3.5\Twilio.Lookups.dll"
> to "site\\Bin\Twilio.Lookups.dll".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Twilio.Lookups.1.1.0\lib\3.5\Twilio.Lookups.pdb"
> to "site\\Bin\Twilio.Lookups.pdb".
>          C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v
> /localhost_55535 -p site\ -u -f
</code>```

答:
If other packages could be restored through TFS build.You could try to just restore the two specific packages only instead of nine.

The cause of this maybe due to someone accidentally checked in the packages folder in the project as some point so what appeared to be coming from local Nuget folder was just being copied out of the packages folder in the project.

If so, removing the packages folder from TFS and try again.

Body:
I'm running into an issue with some NuGet packages not being restored during the msbuild process in a TFS build definition.

I have a total of nine NuGet packages in my solution and I can see seven of nine getting restored from the packages folder, however the other two never get restored or even attempted to be restored.  The packages are listed in the packages.config and the corresponding folders exist in the build directory.

I've tried adding the additional NuGet Restore mentioned in this MS document and I've tried running the NuGet command manually without success.

Additional Details:

The solution is for a .Net website that doesn't have a project file

NuGet.exe version is 2.8.60318.667

TFS 2015

msbuild.exe 14.0.23107

Targeting .Net Framework 4.0 (But have tried 4.5 as well with the same result)

AWSSDK.Core and AWSSDK.DynamoDBv2 are not being restored.

Contents of packages.config:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="AWSSDK.Core" version="3.3.15" targetFramework="net40" requireReinstallation="true" />
  <package id="AWSSDK.DynamoDBv2" version="3.3.4.14" targetFramework="net40" requireReinstallation="true" />
  <package id="Microsoft.Bcl" version="1.1.10" targetFramework="net40" requireReinstallation="true" />
  <package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net40" />
  <package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net40" />
  <package id="RestSharp" version="105.2.3" targetFramework="net40" requireReinstallation="true" />
  <package id="StackExchange.Redis" version="1.1.603" targetFramework="net40" requireReinstallation="true" />
  <package id="Twilio" version="4.7.2" targetFramework="net40" />
  <package id="Twilio.Lookups" version="1.1.0" targetFramework="net40" />
</packages>

From the TFS Output:

> Build started 6/29/2017 11:51:47 PM.
>      1>Project "B:\site_agent\_work\4d978bf9\Site\Site.sln" on node 1 (default targets).
>      1>ValidateSolutionConfiguration:
>          Building solution configuration "Debug|Any CPU". B:\site_agent\_work\4d978bf9\Site\site.metaproj(0,0): Warning MSB3268:
> The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the
> currently targeted framework. ".NETFramework,Version=v4.5". To resolve
> this problem, either remove the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll"
> or retarget your application to a framework version which contains
> "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
>      1>Project "B:\site_agent\_work\4d978bf9\Site\Site.sln" (1) is building "B:\site_agent\_work\4d978bf9\Site\site.metaproj" (2) on node
> 1 (default targets).
>      2>B:\site_agent\_work\4d978bf9\Site\site.metaproj : warning MSB3268: The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the
> currently targeted framework. ".NETFramework,Version=v4.5". To resolve
> this problem, either remove the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll"
> or retarget your application to a framework version which contains
> "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
> B:\site_agent\_work\4d978bf9\Site\site.metaproj(0,0): Warning MSB3268:
> The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Threading.Tasks, Version=4.0.0.0,
> Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be
> resolved in the currently targeted framework.
> ".NETFramework,Version=v4.5". To resolve this problem, either remove
> the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll"
> or retarget your application to a framework version which contains
> "System.Threading.Tasks, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
>      2>B:\site_agent\_work\4d978bf9\Site\site.metaproj : warning MSB3268: The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Threading.Tasks, Version=4.0.0.0,
> Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be
> resolved in the currently targeted framework.
> ".NETFramework,Version=v4.5". To resolve this problem, either remove
> the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll"
> or retarget your application to a framework version which contains
> "System.Threading.Tasks, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
> B:\site_agent\_work\4d978bf9\Site\site.metaproj(0,0): Warning MSB3268:
> The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Threading.Tasks, Version=4.0.0.0,
> Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be
> resolved in the currently targeted framework.
> ".NETFramework,Version=v4.5". To resolve this problem, either remove
> the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll"
> or retarget your application to a framework version which contains
> "System.Threading.Tasks, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
>      2>B:\site_agent\_work\4d978bf9\Site\site.metaproj : warning MSB3268: The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Threading.Tasks, Version=4.0.0.0,
> Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be
> resolved in the currently targeted framework.
> ".NETFramework,Version=v4.5". To resolve this problem, either remove
> the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll"
> or retarget your application to a framework version which contains
> "System.Threading.Tasks, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
> B:\site_agent\_work\4d978bf9\Site\site.metaproj(0,0): Warning MSB3268:
> The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the
> currently targeted framework. ".NETFramework,Version=v4.5". To resolve
> this problem, either remove the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll"
> or retarget your application to a framework version which contains
> "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
>      2>B:\site_agent\_work\4d978bf9\Site\site.metaproj : warning MSB3268: The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the
> currently targeted framework. ".NETFramework,Version=v4.5". To resolve
> this problem, either remove the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll"
> or retarget your application to a framework version which contains
> "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
> B:\site_agent\_work\4d978bf9\Site\site.metaproj(0,0): Warning MSB3268:
> The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\StackExchange.Redis.1.1.603\lib\net40\StackExchange.Redis.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the
> currently targeted framework. ".NETFramework,Version=v4.5". To resolve
> this problem, either remove the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\StackExchange.Redis.1.1.603\lib\net40\StackExchange.Redis.dll"
> or retarget your application to a framework version which contains
> "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
>      2>B:\site_agent\_work\4d978bf9\Site\site.metaproj : warning MSB3268: The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\StackExchange.Redis.1.1.603\lib\net40\StackExchange.Redis.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the
> currently targeted framework. ".NETFramework,Version=v4.5". To resolve
> this problem, either remove the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\StackExchange.Redis.1.1.603\lib\net40\StackExchange.Redis.dll"
> or retarget your application to a framework version which contains
> "System.Runtime, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
> B:\site_agent\_work\4d978bf9\Site\site.metaproj(0,0): Warning MSB3268:
> The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\StackExchange.Redis.1.1.603\lib\net40\StackExchange.Redis.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Threading.Tasks, Version=4.0.0.0,
> Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be
> resolved in the currently targeted framework.
> ".NETFramework,Version=v4.5". To resolve this problem, either remove
> the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\StackExchange.Redis.1.1.603\lib\net40\StackExchange.Redis.dll"
> or retarget your application to a framework version which contains
> "System.Threading.Tasks, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
>      2>B:\site_agent\_work\4d978bf9\Site\site.metaproj : warning MSB3268: The primary reference
> "B:\site_agent\_work\4d978bf9\Site\packages\StackExchange.Redis.1.1.603\lib\net40\StackExchange.Redis.dll"
> could not be resolved because it has an indirect dependency on the
> framework assembly "System.Threading.Tasks, Version=4.0.0.0,
> Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be
> resolved in the currently targeted framework.
> ".NETFramework,Version=v4.5". To resolve this problem, either remove
> the reference
> "B:\site_agent\_work\4d978bf9\Site\packages\StackExchange.Redis.1.1.603\lib\net40\StackExchange.Redis.dll"
> or retarget your application to a framework version which contains
> "System.Threading.Tasks, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\site\Bin\AjaxControlToolkit.dll" to
> "site\\Bin\AjaxControlToolkit.dll".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll"
> to "site\\Bin\Microsoft.Threading.Tasks.Extensions.Desktop.dll".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.xml"
> to "site\\Bin\Microsoft.Threading.Tasks.Extensions.Desktop.xml".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.1.1.10\lib\net40\System.IO.dll"
> to "site\\Bin\System.IO.dll".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.1.1.10\lib\net40\System.IO.xml"
> to "site\\Bin\System.IO.xml".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.1.1.10\lib\net40\System.Threading.Tasks.dll"
> to "site\\Bin\System.Threading.Tasks.dll".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Microsoft.Bcl.1.1.10\lib\net40\System.Threading.Tasks.xml"
> to "site\\Bin\System.Threading.Tasks.xml".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Twilio.4.7.2\lib\3.5\Twilio.Api.dll"
> to "site\\Bin\Twilio.Api.dll".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Twilio.4.7.2\lib\3.5\Twilio.Api.pdb"
> to "site\\Bin\Twilio.Api.pdb".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Twilio.4.7.2\lib\3.5\Twilio.Api.xml"
> to "site\\Bin\Twilio.Api.xml".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Twilio.Lookups.1.1.0\lib\3.5\Twilio.Lookups.dll"
> to "site\\Bin\Twilio.Lookups.dll".
>          Copying file from "B:\site_agent\_work\4d978bf9\Site\packages\Twilio.Lookups.1.1.0\lib\3.5\Twilio.Lookups.pdb"
> to "site\\Bin\Twilio.Lookups.pdb".
>          C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v
> /localhost_55535 -p site\ -u -f


问:
join CompletableFuture vs synchronous method
Having:

```<code>String getData(String key){
    // Slow operation
}

CompletableFuture<String> getDataAsync(String key){
    return CompletableFuture.supplyAsync(() -> getData(key));
}
</code>```

What is the difference between the following?

a)

```<code>keyStream.map(key -> getData(key));
</code>```

b)

```<code>keyStream.map(key -> getDataAsync(key).join());
</code>```

Is there any advantage to use async in this case?

答:
IF the stream in both approach a and b are sequentially. there is no different between them, and you should avoiding use it. because you just run the getData in the ForkJoinPool.commonPool() & join the the map method until getData was completed.

IF the stream in both approach a and b are parallelism. there is no different between them too, and you also should avoiding use it. because a parallel stream is already using the ForkJoinPool.commonPool() for its operations.

Body:
Having:

String getData(String key){
    // Slow operation
}

CompletableFuture<String> getDataAsync(String key){
    return CompletableFuture.supplyAsync(() -> getData(key));
}

What is the difference between the following?

a)

keyStream.map(key -> getData(key));

b)

keyStream.map(key -> getDataAsync(key).join());

Is there any advantage to use async in this case?


问:
Kubernetes Persistent Volume Claim Indefinitely in Pending State
I created a PersistentVolume sourced from a Google Compute Engine persistent disk that I already formatted and provision with data. Kubernetes says the PersistentVolume is available.

```<code>kind: PersistentVolume
apiVersion: v1
metadata:
  name: models-1-0-0
  labels:
    name: models-1-0-0
spec:
  capacity:
    storage: 200Gi
  accessModes:
    - ReadOnlyMany
  gcePersistentDisk:
    pdName: models-1-0-0
    fsType: ext4
    readOnly: true
</code>```

I then created a PersistentVolumeClaim so that I could attach this volume to multiple pods across multiple nodes. However, kubernetes indefinitely says it is in a pending state.

```<code>kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: models-1-0-0-claim
spec:
  accessModes:
    - ReadOnlyMany
  resources:
    requests:
      storage: 200Gi
  selector:
    matchLabels:
      name: models-1-0-0
</code>```

Any insights? I feel there may be something wrong with the selector...

Is it even possible to preconfigure a persistent disk with data and have pods across multiple nodes all be able to read from it?

答:
With dynamic provisioning, you shouldn't have to create PVs and PVCs separately. In Kubernetes 1.6+, there are default provisioners for GKE and some other cloud environments, which should let you just create a PVC and have it automatically provision a PV and an underlying Persistent Disk for you.

For more on dynamic provisioning, see:

https://kubernetes.io/blog/2017/03/dynamic-provisioning-and-storage-classes-kubernetes/

Body:
I created a PersistentVolume sourced from a Google Compute Engine persistent disk that I already formatted and provision with data. Kubernetes says the PersistentVolume is available.

kind: PersistentVolume
apiVersion: v1
metadata:
  name: models-1-0-0
  labels:
    name: models-1-0-0
spec:
  capacity:
    storage: 200Gi
  accessModes:
    - ReadOnlyMany
  gcePersistentDisk:
    pdName: models-1-0-0
    fsType: ext4
    readOnly: true

I then created a PersistentVolumeClaim so that I could attach this volume to multiple pods across multiple nodes. However, kubernetes indefinitely says it is in a pending state.

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: models-1-0-0-claim
spec:
  accessModes:
    - ReadOnlyMany
  resources:
    requests:
      storage: 200Gi
  selector:
    matchLabels:
      name: models-1-0-0

Any insights? I feel there may be something wrong with the selector...

Is it even possible to preconfigure a persistent disk with data and have pods across multiple nodes all be able to read from it?

ContentLicense: CC BY-SA 4.0


问:
Lossy decompositions
If a relation is decomposed into 2 sub relations such that the decomposition is lossy then can these sub-relations be in any normal form (3nf or bcnf)  if the parent relation is in bcnf ?

Consider a relation R(S,T,U,V) with following functional dependencies:-
S->T , T->U, U->V, V->S.

Now if I decompose the above relation into 2 relations R1 and R2 such that R1 intersection R2 is null like R1(S,T) and R2(U,V) , then is the decomposition in bcnf?

I know that R1 can have functional dependencies S->T, T->S and R2 can have functional dependencies U->V and V->U which makes it look like BCNF.

My question was do we consider the decomposition as BCNF even though it's not a valid decomposition ? By not valid I mean lossy decomposition.

答:
From your (unclear) question:

If a relation is decomposed into 2 sub relations such that the decomposition is lossy

From a comment:

I just asked if there is a possibility that the decomposed relations be in bcnf if the parent relation is in bcnf

If that's your question then the answer is yes, there is.

Consider a variable with CK (candidate key) {a} in BCNF that can hold this:

```<code>a b
1 2
3 4
</code>```

Binary decomposition {{a},{b}} is lossy with components in BCNF.

(When trying to prove something wrong always check out some simple cases in case you can find a counterexample as proof.)

do we consider the decomposition as BCNF even though it's not a valid decomposition ? By not valid I mean lossy decomposition.

When we say that a decomposition is in a certain NF, that's short for saying that all its components are in that NF. But we only ever use this shorthand when the decomposition is lossless, ie when "decomposition" is understood to be short for "lossless decomposition", because lossy decompositions are not useful.

Title: Lossy decompositions

Body:
From your (unclear) question:

If a relation is decomposed into 2 sub relations such that the decomposition is lossy

From a comment:

I just asked if there is a possibility that the decomposed relations be in bcnf if the parent relation is in bcnf

If that's your question then the answer is yes, there is.

Consider a variable with CK (candidate key) {a} in BCNF that can hold this:

a b
1 2
3 4

Binary decomposition {{a},{b}} is lossy with components in BCNF.

(When trying to prove something wrong always check out some simple cases in case you can find a counterexample as proof.)

do we consider the decomposition as BCNF even though it's not a valid decomposition ? By not valid I mean lossy decomposition.

When we say that a decomposition is in a certain NF, that's short for saying that all its components are in that NF. But we only ever use this shorthand when the decomposition is lossless, ie when "decomposition" is understood to be short for "lossless decomposition", because lossy decompositions are not useful.


问:
D3: Separating data exit/remove/merge from drawing of elements
I am drawing some complex interactive SVGs with D3 v4 and running into some problems. My goals are:

Each data element corresponds to a group with multiple SVG shape elements (e.g. <g><circle></circle><circle></circle></g>)

The multiple SVG shape elements have to be drawn in a certain order (because they overlap)

Certain shape elements are updated without data elements being added or removed (e.g. when clicking on a shape, change the shape color)

I am running into trouble because the .data() -> .exit().remove() -> .enter() -> .merge() process requires a specific order and that order conflicts with the necessary draw order as well as the ability to update styles on the fly. This is what I started with, which does not work because of draw order:

```<code>function updateGraph() {
    let eachNodeG = allNodesG
        .selectAll('.eachNodeG')
        .data(graphData._nodes, function (d) {
            return d._id;
        })

    eachNodeG.exit().remove();

    let eachNodeGEnter = eachNodeG.enter()
        .append('g')
        .attr("class", "eachNodeG")

    eachNodeGEnter
        .append('circle')
        .classed('interactivecircle', true)
        .on('click', function (d) {...})

    let eachNodeG = eachNodeGEnter
        .merge(eachNodeG)
        .style('fill', function (d) {...}) //this is here b/c it needs to change
            // when data change (without them being added/removed)

    // this must be separate because the background circle needs to change even
    // when nodes are not added and removed; but this doesn't work here because
    // the circle needs to be in the background
    eachNodeG
        .append('circle')
        .classed('bgcircle', true)
}
</code>```

I thought maybe I could separate the data update process from the data drawing process entirely, by doing enter() exit() merge() just on the groups containing the data and then drawing everything afterward. But here I run into a different problem: either I remove and re-add all of the shapes on every update (which makes double-clicking difficult and seems like a waste of processing power), or I have to figure out some way to update only the shapes that have changed. Does it using the remove and re-add method looks like this:

```<code>// add/remove individual groups based on updated data
let eachNodeG = allNodesG
    .selectAll('.eachNodeG')
    .data(graphData._nodes)

eachNodeG.exit().remove();

let eachNodeGEnter = eachNodeG.enter()
    .append('g')
    .attr("class", "eachNodeG")

eachNodeG = eachNodeGEnter
    .merge(eachNodeG)

// draw (or remove and re-draw) elements within individual groups
d3.selectAll('.bgcircle').remove()

eachNodeG.append('circle')
    .classed('bgcircle', true)

d3.selectAll('.interactivecircle').remove()

eachNodeG.append('circle')
    .classed('interactivecircle', true)
    .style('fill', function (d) {...})
    .on('click',function(d){...})
})
</code>```

Is there a better way to draw the shapes in order while keeping them updateable?

答: You could use selection.raise or selection.lower to move circles after they have been created.</p>

Body:
I am drawing some complex interactive SVGs with D3 v4 and running into some problems. My goals are:

Each data element corresponds to a group with multiple SVG shape elements (e.g. <g><circle></circle><circle></circle></g>)

The multiple SVG shape elements have to be drawn in a certain order (because they overlap)

Certain shape elements are updated without data elements being added or removed (e.g. when clicking on a shape, change the shape color)

I am running into trouble because the .data() -> .exit().remove() -> .enter() -> .merge() process requires a specific order and that order conflicts with the necessary draw order as well as the ability to update styles on the fly. This is what I started with, which does not work because of draw order:

function updateGraph() {
    let eachNodeG = allNodesG
        .selectAll('.eachNodeG')
        .data(graphData._nodes, function (d) {
            return d._id;
        })

    eachNodeG.exit().remove();

    let eachNodeGEnter = eachNodeG.enter()
        .append('g')
        .attr("class", "eachNodeG")

    eachNodeGEnter
        .append('circle')
        .classed('interactivecircle', true)
        .on('click', function (d) {...})

    let eachNodeG = eachNodeGEnter
        .merge(eachNodeG)
        .style('fill', function (d) {...}) //this is here b/c it needs to change
            // when data change (without them being added/removed)

    // this must be separate because the background circle needs to change even
    // when nodes are not added and removed; but this doesn't work here because
    // the circle needs to be in the background
    eachNodeG
        .append('circle')
        .classed('bgcircle', true)
}

I thought maybe I could separate the data update process from the data drawing process entirely, by doing enter() exit() merge() just on the groups containing the data and then drawing everything afterward. But here I run into a different problem: either I remove and re-add all of the shapes on every update (which makes double-clicking difficult and seems like a waste of processing power), or I have to figure out some way to update only the shapes that have changed. Does it using the remove and re-add method looks like this:

// add/remove individual groups based on updated data
let eachNodeG = allNodesG
    .selectAll('.eachNodeG')
    .data(graphData._nodes)

eachNodeG.exit().remove();

let eachNodeGEnter = eachNodeG.enter()
    .append('g')
    .attr("class", "eachNodeG")

eachNodeG = eachNodeGEnter
    .merge(eachNodeG)

// draw (or remove and re-draw) elements within individual groups
d3.selectAll('.bgcircle').remove()

eachNodeG.append('circle')
    .classed('bgcircle', true)

d3.selectAll('.interactivecircle').remove()

eachNodeG.append('circle')
    .classed('interactivecircle', true)
    .style('fill', function (d) {...})
    .on('click',function(d){...})
})

Is there a better way to draw the shapes in order while keeping them updateable?


问:
Flex performance hit?
I looked at this demo:
http://bubblemark.com/

Flex seems very slow compared to silverlight 3. Unfortunately can't see pure flash but should flex be forbidden if performance is top requirements compared to Flash ?

答:
If performance is your top requirement, you shouldn't be writing for the Flash VM. ;)

The flex framework adds a lot of stuff that can go slowly, and coding without it will certainly give you a performance advantage.  However, it will also cripple you by removing all the nice UI stuff that's part of flex.  You'll have to do some tests for your particular application and see if the performance gain is worth the loss of ease of coding.

Title: Flex performance hit?


问:
Combine 2 columns in one and add a column to put remarks using if or case in SQL
I have 3 tables.

I want to get this result

I have tried union tables and it worked. I just need to combine 2 columns (Num_Typ) and (Add_Typ) in one column (Type) then if address or phone number is not available then display N/A. Next I will add a column (Remarks) depending on whether they have an address , a phone number or both, address only or phone only.

Here is the Query

```<code>SELECT
A.NAMES,
A.CODE,
B.NUM_TYP,
B.PHONE_NUN,
B.ADD_TYP,
B.ADDR
FROM NAMES A LEFT JOIN

(
SELECT PHONE.ID, PHONE.NUM_TYP, PHONE.PHONE_NUM, ADDRESS.ADD_TYP, ADDRESS.ADDR
FROM PHONE LEFT JOIN ADDRESS ON (PHONE.NUM_TYP = ADDRESS.ADD_TYP) AND (PHONE.ID = ADDRESS.ID)

UNION
SELECT ADDRESS.ID, PHONE.USG_TYP, PHONE.PHONE_NUM, ADDRESS.ADD_TYP, ADDRESS.ADDR
FROM ADDRESS LEFT JOIN PHONE ON (ADDRESS.ADD_TYP = PHONE.NUM_TYP) AND (ADDRESS.ID = PHONE.ID)) AS B ON A.ID = B.ID;
</code>```

Appreciate any help. Thanks.

答:
You can add a CASE expression to your query which renders the message you want:

```<code>SELECT
    A.NAMES,
    A.CODE,
    B.NUM_TYP,
    B.PHONE_NUN,
    B.ADD_TYP,
    B.ADDR,
    CASE WHEN B.PHONE_NUN IS NOT NULL AND B.ADDR IS NULL
         THEN 'MEMBER HAS PHONE ONLY'
         WHEN B.ADDR IS NOT NULL AND B.PHONE_NUM IS NULL
         THEN 'MEMBER HAS ADDR ONLY'
         WHEN B.PHONE_NUN IS NOT NULL AND B.ADDR IS NOT NULL
         THEN 'MEMBER HAS BOTH' END AS REMARKS
FROM NAMES A
LEFT JOIN ...
</code>```

Body:
I have 3 tables.

I want to get this result

I have tried union tables and it worked. I just need to combine 2 columns (Num_Typ) and (Add_Typ) in one column (Type) then if address or phone number is not available then display N/A. Next I will add a column (Remarks) depending on whether they have an address , a phone number or both, address only or phone only.

Here is the Query

SELECT
A.NAMES,
A.CODE,
B.NUM_TYP,
B.PHONE_NUN,
B.ADD_TYP,
B.ADDR
FROM NAMES A LEFT JOIN

(
SELECT PHONE.ID, PHONE.NUM_TYP, PHONE.PHONE_NUM, ADDRESS.ADD_TYP, ADDRESS.ADDR
FROM PHONE LEFT JOIN ADDRESS ON (PHONE.NUM_TYP = ADDRESS.ADD_TYP) AND (PHONE.ID = ADDRESS.ID)

UNION
SELECT ADDRESS.ID, PHONE.USG_TYP, PHONE.PHONE_NUM, ADDRESS.ADD_TYP, ADDRESS.ADDR
FROM ADDRESS LEFT JOIN PHONE ON (ADDRESS.ADD_TYP = PHONE.NUM_TYP) AND (ADDRESS.ID = PHONE.ID)) AS B ON A.ID = B.ID;

Appreciate any help. Thanks.

Body:
You can add a CASE expression to your query which renders the message you want:

SELECT
    A.NAMES,
    A.CODE,
    B.NUM_TYP,
    B.PHONE_NUN,
    B.ADD_TYP,
    B.ADDR,
    CASE WHEN B.PHONE_NUN IS NOT NULL AND B.ADDR IS NULL
         THEN 'MEMBER HAS PHONE ONLY'
         WHEN B.ADDR IS NOT NULL AND B.PHONE_NUM IS NULL
         THEN 'MEMBER HAS ADDR ONLY'
         WHEN B.PHONE_NUN IS NOT NULL AND B.ADDR IS NOT NULL
         THEN 'MEMBER HAS BOTH' END AS REMARKS
FROM NAMES A
LEFT JOIN ...


问:
How to convert delimited string into multi-dimensional array with associative keys?
Can anyone help with this regular expression please?

Here's an example string I'm trying to convert into php array.

$str="hopOptions:hops hopOptions:salmonSafe region:domestic region:specialty region:imported"

And I need the final aray to be:

```<code>$filters = array (
    "hopOptions"  => array("hops", "salmonSafe"),
    "region"      => array("domestic", "specialty", "imported")
);
</code>```

Any help or direction will be greatly appreciated!

答:
I do not know php and came up with this. Hope there's better way.

```<code>$str = "hopOptions:hops hopOptions:salmonSafe region:domestic region:specialty region:imported";

// it creates an array of pairs
$ta = array_map(function($s) {return explode(":", $s);}, explode(" ", $str));

// this loop converts the paris into desired form
$filters = array();
foreach($ta as $pair) {
    if (array_key_exists($pair[0], $filters)) {
        array_push($filters[$pair[0]], $pair[1]);
    }
    else {
        $filters[$pair[0]] = array($pair[1]);
    }
}

print_r($filters);
</code>```

Output:

```<code>Array
(
    [hopOptions] => Array
        (
            [0] => hops
            [1] => salmonSafe
        )

    [region] => Array
        (
            [0] => domestic
            [1] => specialty
            [2] => imported
        )

)
</code>```

Body:
Can anyone help with this regular expression please?

Here's an example string I'm trying to convert into php array.

$str="hopOptions:hops hopOptions:salmonSafe region:domestic region:specialty region:imported"

And I need the final aray to be:

$filters = array (
    "hopOptions"  => array("hops", "salmonSafe"),
    "region"      => array("domestic", "specialty", "imported")
);

Any help or direction will be greatly appreciated!

Body:
I do not know php and came up with this. Hope there's better way.

$str = "hopOptions:hops hopOptions:salmonSafe region:domestic region:specialty region:imported";

// it creates an array of pairs
$ta = array_map(function($s) {return explode(":", $s);}, explode(" ", $str));

// this loop converts the paris into desired form
$filters = array();
foreach($ta as $pair) {
    if (array_key_exists($pair[0], $filters)) {
        array_push($filters[$pair[0]], $pair[1]);
    }
    else {
        $filters[$pair[0]] = array($pair[1]);
    }
}

print_r($filters);

Output:

Array
(
    [hopOptions] => Array
        (
            [0] => hops
            [1] => salmonSafe
        )

    [region] => Array
        (
            [0] => domestic
            [1] => specialty
            [2] => imported
        )

)


问:
Clojure macros and default arguments when a macro calls another one
I have a problem with a pair of Clojure macros when a default argument is defined.

In the following situation with 2 macros, where mm02 calls mm01:

```<code>(defmacro mm01
  [ & [ { :keys [ f1 ] :or { f1 long } :as opts } ]]
  `(let []
    (println "(2) ~f1" ~f1)))

(defmacro mm02
  [ & [ { :keys [ f1 ] :as opts } ]]
  `(let []
     (println "(1) ~f1" ~f1)
     (mm01 ~@opts)))
</code>```

The evaluation of:

```<code>(mm02 { :f1 byte })
</code>```

prints out:

```<code>(1) ~f1 #function[clojure.core/byte]
(2) ~f1 #function[clojure.core/long]
</code>```

However, I would have expected:

```<code>(1) ~f1 #function[clojure.core/byte]
(2) ~f1 #function[clojure.core/byte]
</code>```

Am I doing anything wrong or I am missing something?

By the way, the evaluation of:

```<code>(mm01 { :f1 byte })
</code>```

prints out:

```<code>(2) ~f1 #function[clojure.core/byte]
</code>```

Thank you very much.

答:
~@ expands out a sequence of things into several individual things, inside of a syntax-quote context. Your opts binding is a map, which is conceptually a sequence of map-entries. You can see this in action by playing around in the repl with the expressions your macros will generate: this is often a useful way to look at the intermediate steps of a macro, compared to debugging by trial-and-error on the macro as a whole.

```<code>user=> (let [opts {:f1 'long}]
  #_=>   `(foo ~@opts))
(user/foo [:f1 long])
</code>```

See the square brackets around :f1 long? That's the problem: your other macro expects to be called with a map, not a vector. As a result, the destructuring fails to find the key you were looking for. To fix this, just remove the @ and use an ordinary unquote, not a splicing unquote.

```<code>user=> (let [opts {:f1 'long}]
  #_=>   `(foo ~opts))
(user/foo {:f1 long})
</code>```

As an additional improvement, you should replace the distracting [& [{...}]] argument stanza with just [{...}]. They behave the same except that the former allows the caller to pass zero arguments (filling in with nils), or any number of extra arguments, which all get ignored. Your version is very slightly more convenient for the caller if they meant to omit an argument and get defaults, but inevitably will lead them to a big hassle of debugging if they leave out an argument, or provide too many, accidentally.

Body:
I have a problem with a pair of Clojure macros when a default argument is defined.

In the following situation with 2 macros, where mm02 calls mm01:

(defmacro mm01
  [ & [ { :keys [ f1 ] :or { f1 long } :as opts } ]]
  `(let []
    (println "(2) ~f1" ~f1)))

(defmacro mm02
  [ & [ { :keys [ f1 ] :as opts } ]]
  `(let []
     (println "(1) ~f1" ~f1)
     (mm01 ~@opts)))

The evaluation of:

(mm02 { :f1 byte })

prints out:

(1) ~f1 #function[clojure.core/byte]
(2) ~f1 #function[clojure.core/long]

However, I would have expected:

(1) ~f1 #function[clojure.core/byte]
(2) ~f1 #function[clojure.core/byte]

Am I doing anything wrong or I am missing something?

By the way, the evaluation of:

(mm01 { :f1 byte })

prints out:

(2) ~f1 #function[clojure.core/byte]

Thank you very much.

Body:
~@ expands out a sequence of things into several individual things, inside of a syntax-quote context. Your opts binding is a map, which is conceptually a sequence of map-entries. You can see this in action by playing around in the repl with the expressions your macros will generate: this is often a useful way to look at the intermediate steps of a macro, compared to debugging by trial-and-error on the macro as a whole.

user=> (let [opts {:f1 'long}]
  #_=>   `(foo ~@opts))
(user/foo [:f1 long])

See the square brackets around :f1 long? That's the problem: your other macro expects to be called with a map, not a vector. As a result, the destructuring fails to find the key you were looking for. To fix this, just remove the @ and use an ordinary unquote, not a splicing unquote.

user=> (let [opts {:f1 'long}]
  #_=>   `(foo ~opts))
(user/foo {:f1 long})

As an additional improvement, you should replace the distracting [& [{...}]] argument stanza with just [{...}]. They behave the same except that the former allows the caller to pass zero arguments (filling in with nils), or any number of extra arguments, which all get ignored. Your version is very slightly more convenient for the caller if they meant to omit an argument and get defaults, but inevitably will lead them to a big hassle of debugging if they leave out an argument, or provide too many, accidentally.


问:
How to use biglm with more than 2^31 observations
I am working with a large set of data that contains more than 2^31 observations. The actual number of observations is close to 3.5 billion observations.

I am using the R package "biglm" to run a regression with approximately 70 predictors. I read in the data one million rows at a time and update the regression results. The data have been saved in the ffdf format using the R library "ffdf" to load quickly and avoid using up all my RAM.

Here is the basic outline of the code I am using:

```<code>library(ff,ffbase,biglm)
load.ffdf(dir='home')

dim(data) #the ffdf contains about 70 predictors and 3.5 billion rows

chunk_1 <- data[1:1000000,]
rest_of_data <- data[1000000:nrow(data),]

# Running biglm for first chunk
b <- biglm(y~x1+x2+...+x70, chunk_1)

chunks <- ceiling((nrow(rest_of_data)/1000000)

# Updating biglm results by iterating through the rest of the data chunks
for (i in seq(1,chunks)){
      start <- 1+((i-1))*1000000
      end <- min(i*1000000,nrow(d))
      d_chunk <- d[start:end,]
      b<-update(b,d_chunk)
}
</code>```

The results look great and everything is running smoothly until the cumulative number of observations from updating the model with each chunk of the data exceeds 2^31 observations. Then, I get an error that reads

```<code>In object$n + NROW(mm) : NAs produced by integer overflow
</code>```

How do I get around this overflow issue? Thanks in advance for your help!

答:
I believe that I have found the source of the issue in the biglm code.

The number of observations (n) is stored as an integer, which has a max value of 2^31 - 1.

The numeric type is not subject to this limit, and, as far as I can tell, can be used instead of integers to store n.

Here is a commit on github showing how to fix this problem with one additional line of code that converts the integer n to a numeric. As the model is updated, the number of rows in the new batch is added to the old n, so the type of n remains numeric.

I was able to reproduce the error described in this question and verify that my fix works with this code:

(WARNING: This consumes a large amount of memory, consider doing more iterations with a smaller array if you have tight memory constraints)

```<code>library(biglm)
df = as.data.frame(replicate(3, rnorm(10000000)))
a = biglm(V1 ~ V2 + V3, df)
for (i in 1:300) {
    a = update(a, df)
}
print(summary(a))
</code>```

In the original biglm library, this code outputs:

```<code>Large data regression model: biglm(ff, df)
Sample size =  NA
              Coef (95% CI) SE  p
(Intercept) -1e-04   NA  NA NA NA
V2          -1e-04   NA  NA NA NA
V3          -2e-04   NA  NA NA NA
</code>```

My patched version outputs:

```<code>Large data regression model: biglm(V1 ~ V2 + V3, df)
Sample size =  3.01e+09
              Coef   (95%    CI) SE p
(Intercept) -3e-04 -3e-04 -3e-04  0 0
V2          -2e-04 -2e-04 -1e-04  0 0
V3           3e-04  3e-04  3e-04  0 0
</code>```

The SE and p values are non-zero, just rounded in the output above.

I am fairly new to the R ecosystem, so I would appreciate it if someone could tell me how to submit this patch so that it can be reviewed by the original author and eventually included in the upstream package.

Body:
I am working with a large set of data that contains more than 2^31 observations. The actual number of observations is close to 3.5 billion observations.

I am using the R package "biglm" to run a regression with approximately 70 predictors. I read in the data one million rows at a time and update the regression results. The data have been saved in the ffdf format using the R library "ffdf" to load quickly and avoid using up all my RAM.

Here is the basic outline of the code I am using:

library(ff,ffbase,biglm)
load.ffdf(dir='home')

dim(data) #the ffdf contains about 70 predictors and 3.5 billion rows

chunk_1 <- data[1:1000000,]
rest_of_data <- data[1000000:nrow(data),]

# Running biglm for first chunk
b <- biglm(y~x1+x2+...+x70, chunk_1)

chunks <- ceiling((nrow(rest_of_data)/1000000)

# Updating biglm results by iterating through the rest of the data chunks
for (i in seq(1,chunks)){
      start <- 1+((i-1))*1000000
      end <- min(i*1000000,nrow(d))
      d_chunk <- d[start:end,]
      b<-update(b,d_chunk)
}

The results look great and everything is running smoothly until the cumulative number of observations from updating the model with each chunk of the data exceeds 2^31 observations. Then, I get an error that reads

In object$n + NROW(mm) : NAs produced by integer overflow

How do I get around this overflow issue? Thanks in advance for your help!

Body:
I believe that I have found the source of the issue in the biglm code.

The number of observations (n) is stored as an integer, which has a max value of 2^31 - 1.

The numeric type is not subject to this limit, and, as far as I can tell, can be used instead of integers to store n.

Here is a commit on github showing how to fix this problem with one additional line of code that converts the integer n to a numeric. As the model is updated, the number of rows in the new batch is added to the old n, so the type of n remains numeric.

I was able to reproduce the error described in this question and verify that my fix works with this code:

(WARNING: This consumes a large amount of memory, consider doing more iterations with a smaller array if you have tight memory constraints)

library(biglm)
df = as.data.frame(replicate(3, rnorm(10000000)))
a = biglm(V1 ~ V2 + V3, df)
for (i in 1:300) {
    a = update(a, df)
}
print(summary(a))

In the original biglm library, this code outputs:

Large data regression model: biglm(ff, df)
Sample size =  NA
              Coef (95% CI) SE  p
(Intercept) -1e-04   NA  NA NA NA
V2          -1e-04   NA  NA NA NA
V3          -2e-04   NA  NA NA NA

My patched version outputs:

Large data regression model: biglm(V1 ~ V2 + V3, df)
Sample size =  3.01e+09
              Coef   (95%    CI) SE p
(Intercept) -3e-04 -3e-04 -3e-04  0 0
V2          -2e-04 -2e-04 -1e-04  0 0
V3           3e-04  3e-04  3e-04  0 0

The SE and p values are non-zero, just rounded in the output above.

I am fairly new to the R ecosystem, so I would appreciate it if someone could tell me how to submit this patch so that it can be reviewed by the original author and eventually included in the upstream package.


问:
Modal not showing in when rendered in React component
What I'm trying to do: When I'm writing a project using React and Redux, I want to pop up a modal from RecordTaskPopUp component when the state isTimeOut of ManageTimer component is changed by a timer event (for readability purpose, I have directly defined isTimeOut to be true in the following code).

Problem: Modal not showing up on the page.

What I have done to find the problem:

I have changed .modal {display: block} in my css file but it still is not showing on the page.

I also try to render something else other than modal on my RecordTskPopUp component, it works perfectly fine. So I suppose the problem is with modal itself.

Paste the whole render snippet of RecordTaskPopUp from bootstrap document.

Can someone tell me what might be the possible cause of this problem? Thanks a lot!

```<code>class ManageTimer extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      isTimeOut: true
    }
  this.closePopUp = this.closePopUp.bind(this);
  }

  closePopUp() {
    this.setState({
    isTimeOut: false
    });
  }

  render() {
    return (
      {this.state.isTimeOut ?
      <RecordTaskPopUp
        closePopUp={this.closePopUp}/> :
      <p>There is still time remaining</p>
      }
    );
  }
}

const RecordTaskPopUp = ({closePopUp}) => {
   return (
      <div className="modal fade">
        <div className="modal-dialog" role="document">
          <div className="modal-content">
            <div className="modal-header">
              <h5 className="modal-title">Modal Header</h5>
              <button type="button" className="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true" onClick={closePopUp}>×</span>
              </button>
            </div>

            <div className="modal-body">
              <p> Modal Body</p>
            </div>

            <div className="modal-footer">
              <button type="button" className="btn btn-primary">Save changes</button>
              <button type="button" className="btn btn-secondary" data-dismiss="modal" onClick={closePopUp}>Close</button>
            </div>
          </div>
        </div>
      </div>
    </div>
   );
};
</code>```

答: The generic bootstrap modal uses javascript to be able to work properly. However, the way it is coded, is in the older style of dom rendering, which is completely different than how React does it. You are going to have to find a custom modal component built for react. I currently use "React Bootstrap". Your modal is never going to work if you are attempting to use the modal provided from the official Bootstrap source code.</p>

Body:
What I'm trying to do: When I'm writing a project using React and Redux, I want to pop up a modal from RecordTaskPopUp component when the state isTimeOut of ManageTimer component is changed by a timer event (for readability purpose, I have directly defined isTimeOut to be true in the following code).

Problem: Modal not showing up on the page.

What I have done to find the problem:

I have changed .modal {display: block} in my css file but it still is not showing on the page.

I also try to render something else other than modal on my RecordTskPopUp component, it works perfectly fine. So I suppose the problem is with modal itself.

Paste the whole render snippet of RecordTaskPopUp from bootstrap document.

Can someone tell me what might be the possible cause of this problem? Thanks a lot!

class ManageTimer extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      isTimeOut: true
    }
  this.closePopUp = this.closePopUp.bind(this);
  }

  closePopUp() {
    this.setState({
    isTimeOut: false
    });
  }

  render() {
    return (
      {this.state.isTimeOut ?
      <RecordTaskPopUp
        closePopUp={this.closePopUp}/> :

There is still time remaining

      }
    );
  }
}

const RecordTaskPopUp = ({closePopUp}) => {
   return (

Modal Header

              <button type="button" className="close" data-dismiss="modal" aria-label="Close">
                ×
              </button>

 Modal Body

              <button type="button" className="btn btn-primary">Save changes</button>
              <button type="button" className="btn btn-secondary" data-dismiss="modal" onClick={closePopUp}>Close</button>

   );
};