问:
Limitations of the Levenberg-Marquardt algorithm
I am using Levenberg-Marquardt algorithm to minimize a non-linear function of 6 parameters. I have got about 50 data points for each minimization, but I do not get sufficiently accurate results. Does the fact, that my parameters differ from each other by a few orders of magnitudes can be so much significant? If yes, where should I look for the solution? If no, what kind of limitations of LMA you met in your work (it may help to find other problems with my applictaion)?
Many Thanks for your help.

Edit: The problem I am trying to solve is to determine the best transformation T:

```<code>typedef struct
{
    double x_translation, y_translation, z_translation;
    double x_rotation, y_rotation, z_rotation;
} transform_3D;
</code>```

to fit the set of 3D points to the bunch of 3D lines. In detail I have got a set of coordinates of 3D points and equations of corresponding 3D lines, which should go through those points (in ideal situation). The LMA is minimizing the summ of distances of the transfomed 3D points to corresponding 3D lines.
The transform function is as follows:

```<code>cv::Point3d Geometry::transformation_3D(cv::Point3d point, transform_3D transformation)
{
    cv::Point3d p_odd,p_even;

    //rotation x
    p_odd.x=point.x;
    p_odd.y=point.y*cos(transformation.x_rotation)-point.z*sin(transformation.x_rotation);
    p_odd.z=point.y*sin(transformation.x_rotation)+point.z*cos(transformation.x_rotation);

    //rotation y
    p_even.x=p_odd.z*sin(transformation.y_rotation)+p_odd.x*cos(transformation.y_rotation);
    p_even.y=p_odd.y;
    p_even.z=p_odd.z*cos(transformation.y_rotation)-p_odd.x*sin(transformation.y_rotation);

    //rotation z
    p_odd.x=p_even.x*cos(transformation.z_rotation)-p_even.y*sin(transformation.z_rotation);
    p_odd.y=p_even.x*sin(transformation.z_rotation)+p_even.y*cos(transformation.z_rotation);
    p_odd.z=p_even.z;

    //translation
    p_even.x=p_odd.x+transformation.x_translation;
    p_even.y=p_odd.y+transformation.y_translation;
    p_even.z=p_odd.z+transformation.z_translation;

    return p_even;
}
</code>```

Hope this explanation will help a bit...

Edit2:

Some exemplary data is pasted below. 3D lines are described by the center point and the directional vector. Center point for all lines are (0,0,0) and 'uz' coordinate for each vector is equal to 1.
Set of 'ux' coordinates of directional vectors:

```<code>-1.0986, -1.0986, -1.0986,
-1.0986, -1.0990, -1.0986,
-1.0986, -1.0986, -0.9995,
-0.9996, -0.9996, -0.9995,
-0.9995, -0.9995, -0.9996,
-0.9003, -0.9003, -0.9004,
-0.9003, -0.9003, -0.9003,
-0.9003, -0.9003, -0.8011,
-0.7020, -0.7019, -0.6028,
-0.5035, -0.5037, -0.4045,
-0.3052, -0.3053, -0.2062,
-0.1069, -0.1069, -0.1075,
-0.1070, -0.1070, -0.1069,
-0.1069, -0.1070, -0.0079,
-0.0079, -0.0079, -0.0078,
-0.0078, -0.0079, -0.0079,
 0.0914,  0.0914,  0.0913,
 0.0913,  0.0914,  0.0915,
 0.0914,  0.0914
</code>```

Set of 'uy' coordinates of directional vectors:

```<code>-0.2032,  -0.0047,    0.1936,
0.3919,    0.5901,    0.7885,
0.9869,    1.1852,    -0.1040,
0.0944,    0.2927,    0.4911,
0.6894,    0.8877,    1.0860,
-0.2032,  -0.0047,    0.1936,
0.3919,    0.5902,    0.7885,
0.9869,    1.1852,    1.0860,
0.9869,    1.1852,    1.0861,
0.9865,    1.1853,    1.0860,
0.9870,    1.1852,    1.0861,
-0.2032,  -0.0047,    0.1937,
0.3919,    0.5902,    0.7885,
0.9869,    1.1852,    -0.1039,
0.0944,    0.2927,    0.4911,
0.6894,    0.8877,    1.0860,
-0.2032,  -0.0047,    0.1935,
0.3919,    0.5902,    0.7885,
0.9869,    1.1852
</code>```

and set of 3D points in (x. y. z. x. y. z. x. y. z. ...) form:

```<code> {{0, 0, 0}, {0, 16, 0},   {0, 32, 0},
 {0, 48, 0}, {0, 64, 0},   {0, 80, 0},
 {0, 96, 0}, {0, 112,0},   {8, 8, 0},
 {8, 24, 0}, {8, 40, 0},   {8, 56, 0},
 {8, 72, 0}, {8, 88, 0},   {8, 104, 0},
 {16, 0, 0}, {16, 16,0},   {16, 32, 0},
{16, 48, 0}, {16, 64, 0},  {16, 80, 0},
{16, 96, 0}, {16, 112, 0}, {24, 104, 0},
{32, 96, 0}, {32, 112, 0}, {40, 104, 0},
{48, 96, 0}, {48, 112, 0}, {56, 104, 0},
{64, 96, 0}, {64, 112, 0}, {72, 104, 0},
{80, 0, 0},  {80, 16, 0},  {80, 32, 0},
{80,48, 0},  {80, 64, 0},  {80, 80, 0},
{80, 96, 0}, {80, 112, 0}, {88,  8, 0},
{88, 24, 0}, {88, 40, 0},  {88, 56, 0},
{88, 72, 0}, {88, 88, 0},  {88, 104, 0},
{96, 0, 0},  {96, 16, 0},  {96, 32, 0},
{96, 48,0},  {96, 64, 0},  {96, 80, 0},
{96, 96, 0}, {96, 112, 0}}
</code>```

This is kind of an "easy" modelled data with very small rotations.

答:
Here you have your problem modeled and running with Mathematica.

I used the  "Levenberg-Marquardt" method.

This is why I asked for your data. With MY data, YOUR problems are always going to be easier:)

```<code>xnew[x_, y_, z_] :=
  RotationMatrix[rx, {1, 0, 0}].RotationMatrix[
     ry, {0, 1, 0}].RotationMatrix[rz, {0, 0, 1}].{x, y, z} + {tx, ty, tz};

(* Generate Sample Data*)
(* Angles 1/2,1/3,1/5 *)
(* traslation -> {1,2,3} *)
(* Minimum mean Noise 5% *)

data = Table[{{x, y, z},
  RotationMatrix[1/2, {1, 0, 0}].
  RotationMatrix[1/3, {0, 1, 0}].
  RotationMatrix[1/5, {0, 0, 1}].{x, y, z} +{1, 2, 3} +RandomReal[{-.05, .05}, 3]},
  {x, 0, 1, .1}, {y, 0, 1, .1}, {z, 0, 1, .1}];

data = Flatten[data, 2];

(* Now find the parameters*)
FindMinimum[
 Sum[SquaredEuclideanDistance[xnew[i[[1]] /. List -> Sequence],
   i[[2]]], {i, data}]
 , {rx, ry, rz, tx, ty, tz}, Method -> "LevenbergMarquardt"]
</code>```

Out:

```<code>{3.2423, {rx -> 0.500566, ry -> 0.334012, rz -> 0.199902,
          tx -> 0.99985,  ty -> 1.99939,  tz -> 3.00021}}
</code>```

(Within 1/1000 of the real values)

Edit

I worked a little with your data.

The problem is that your system is very bad conditioned. You need much more data to effectively calculate such small rotations.

These are the results I got:

Rotations in degrees:

```<code>rx = 179.99999999999999999999984968493536659553226696793
ry = 180.00000000000000000000006934755799995159952661222
rz = 180.0006286861217378980724139120849587855611645627
</code>```

Traslations

```<code>tx = 48.503663696727576867196234527227830090575281353092
ty = 63.974139455057300403798198525151849767949596684232
tz = -0.99999999999999999999997957276716543927459921348549
</code>```

I should calculate the errors, but I've no time right now.

BTW, rz = Pi + 0.000011 (in radians)

HTH!

Body:
I am using Levenberg-Marquardt algorithm to minimize a non-linear function of 6 parameters. I have got about 50 data points for each minimization, but I do not get sufficiently accurate results. Does the fact, that my parameters differ from each other by a few orders of magnitudes can be so much significant? If yes, where should I look for the solution? If no, what kind of limitations of LMA you met in your work (it may help to find other problems with my applictaion)?
Many Thanks for your help.

Edit: The problem I am trying to solve is to determine the best transformation T:

typedef struct
{
    double x_translation, y_translation, z_translation;
    double x_rotation, y_rotation, z_rotation;
} transform_3D;

to fit the set of 3D points to the bunch of 3D lines. In detail I have got a set of coordinates of 3D points and equations of corresponding 3D lines, which should go through those points (in ideal situation). The LMA is minimizing the summ of distances of the transfomed 3D points to corresponding 3D lines.
The transform function is as follows:

cv::Point3d Geometry::transformation_3D(cv::Point3d point, transform_3D transformation)
{
    cv::Point3d p_odd,p_even;

    //rotation x
    p_odd.x=point.x;
    p_odd.y=point.y*cos(transformation.x_rotation)-point.z*sin(transformation.x_rotation);
    p_odd.z=point.y*sin(transformation.x_rotation)+point.z*cos(transformation.x_rotation);

    //rotation y
    p_even.x=p_odd.z*sin(transformation.y_rotation)+p_odd.x*cos(transformation.y_rotation);
    p_even.y=p_odd.y;
    p_even.z=p_odd.z*cos(transformation.y_rotation)-p_odd.x*sin(transformation.y_rotation);

    //rotation z
    p_odd.x=p_even.x*cos(transformation.z_rotation)-p_even.y*sin(transformation.z_rotation);
    p_odd.y=p_even.x*sin(transformation.z_rotation)+p_even.y*cos(transformation.z_rotation);
    p_odd.z=p_even.z;

    //translation
    p_even.x=p_odd.x+transformation.x_translation;
    p_even.y=p_odd.y+transformation.y_translation;
    p_even.z=p_odd.z+transformation.z_translation;

    return p_even;
}

Hope this explanation will help a bit...

Edit2:

Some exemplary data is pasted below. 3D lines are described by the center point and the directional vector. Center point for all lines are (0,0,0) and 'uz' coordinate for each vector is equal to 1.
Set of 'ux' coordinates of directional vectors:

-1.0986, -1.0986, -1.0986,
-1.0986, -1.0990, -1.0986,
-1.0986, -1.0986, -0.9995,
-0.9996, -0.9996, -0.9995,
-0.9995, -0.9995, -0.9996,
-0.9003, -0.9003, -0.9004,
-0.9003, -0.9003, -0.9003,
-0.9003, -0.9003, -0.8011,
-0.7020, -0.7019, -0.6028,
-0.5035, -0.5037, -0.4045,
-0.3052, -0.3053, -0.2062,
-0.1069, -0.1069, -0.1075,
-0.1070, -0.1070, -0.1069,
-0.1069, -0.1070, -0.0079,
-0.0079, -0.0079, -0.0078,
-0.0078, -0.0079, -0.0079,
 0.0914,  0.0914,  0.0913,
 0.0913,  0.0914,  0.0915,
 0.0914,  0.0914

Set of 'uy' coordinates of directional vectors:

-0.2032,  -0.0047,    0.1936,
0.3919,    0.5901,    0.7885,
0.9869,    1.1852,    -0.1040,
0.0944,    0.2927,    0.4911,
0.6894,    0.8877,    1.0860,
-0.2032,  -0.0047,    0.1936,
0.3919,    0.5902,    0.7885,
0.9869,    1.1852,    1.0860,
0.9869,    1.1852,    1.0861,
0.9865,    1.1853,    1.0860,
0.9870,    1.1852,    1.0861,
-0.2032,  -0.0047,    0.1937,
0.3919,    0.5902,    0.7885,
0.9869,    1.1852,    -0.1039,
0.0944,    0.2927,    0.4911,
0.6894,    0.8877,    1.0860,
-0.2032,  -0.0047,    0.1935,
0.3919,    0.5902,    0.7885,
0.9869,    1.1852

and set of 3D points in (x. y. z. x. y. z. x. y. z. ...) form:

 {{0, 0, 0}, {0, 16, 0},   {0, 32, 0},
 {0, 48, 0}, {0, 64, 0},   {0, 80, 0},
 {0, 96, 0}, {0, 112,0},   {8, 8, 0},
 {8, 24, 0}, {8, 40, 0},   {8, 56, 0},
 {8, 72, 0}, {8, 88, 0},   {8, 104, 0},
 {16, 0, 0}, {16, 16,0},   {16, 32, 0},
{16, 48, 0}, {16, 64, 0},  {16, 80, 0},
{16, 96, 0}, {16, 112, 0}, {24, 104, 0},
{32, 96, 0}, {32, 112, 0}, {40, 104, 0},
{48, 96, 0}, {48, 112, 0}, {56, 104, 0},
{64, 96, 0}, {64, 112, 0}, {72, 104, 0},
{80, 0, 0},  {80, 16, 0},  {80, 32, 0},
{80,48, 0},  {80, 64, 0},  {80, 80, 0},
{80, 96, 0}, {80, 112, 0}, {88,  8, 0},
{88, 24, 0}, {88, 40, 0},  {88, 56, 0},
{88, 72, 0}, {88, 88, 0},  {88, 104, 0},
{96, 0, 0},  {96, 16, 0},  {96, 32, 0},
{96, 48,0},  {96, 64, 0},  {96, 80, 0},
{96, 96, 0}, {96, 112, 0}}

This is kind of an "easy" modelled data with very small rotations.

Body:
Here you have your problem modeled and running with Mathematica.

I used the  "Levenberg-Marquardt" method.

This is why I asked for your data. With MY data, YOUR problems are always going to be easier:)

xnew[x_, y_, z_] :=
  RotationMatrix[rx, {1, 0, 0}].RotationMatrix[
     ry, {0, 1, 0}].RotationMatrix[rz, {0, 0, 1}].{x, y, z} + {tx, ty, tz};

(* Generate Sample Data*)
(* Angles 1/2,1/3,1/5 *)
(* traslation -> {1,2,3} *)
(* Minimum mean Noise 5% *)

data = Table[{{x, y, z},
  RotationMatrix[1/2, {1, 0, 0}].
  RotationMatrix[1/3, {0, 1, 0}].
  RotationMatrix[1/5, {0, 0, 1}].{x, y, z} +{1, 2, 3} +RandomReal[{-.05, .05}, 3]},
  {x, 0, 1, .1}, {y, 0, 1, .1}, {z, 0, 1, .1}];

data = Flatten[data, 2];

(* Now find the parameters*)
FindMinimum[
 Sum[SquaredEuclideanDistance[xnew[i[[1]] /. List -> Sequence],
   i[[2]]], {i, data}]
 , {rx, ry, rz, tx, ty, tz}, Method -> "LevenbergMarquardt"]

Out:

{3.2423, {rx -> 0.500566, ry -> 0.334012, rz -> 0.199902,
          tx -> 0.99985,  ty -> 1.99939,  tz -> 3.00021}}

(Within 1/1000 of the real values)

Edit

I worked a little with your data.

The problem is that your system is very bad conditioned. You need much more data to effectively calculate such small rotations.

These are the results I got:

Rotations in degrees:

rx = 179.99999999999999999999984968493536659553226696793
ry = 180.00000000000000000000006934755799995159952661222
rz = 180.0006286861217378980724139120849587855611645627

Traslations

tx = 48.503663696727576867196234527227830090575281353092
ty = 63.974139455057300403798198525151849767949596684232
tz = -0.99999999999999999999997957276716543927459921348549

I should calculate the errors, but I've no time right now.

BTW, rz = Pi + 0.000011 (in radians)

HTH!


来源: stackexchange

问:
c# send uploaded file through email daily using asp.net web application
I just want to know, how to make a web-application which takes input of Excel files from user and send an email daily if that excel file has any new data available.

Should I use web service (with installation of that service in local computer) ? and yes then how to add Upload User-Interface. or Should I use only a web application and Should I add web-service in that application ?

Pls give way to come out of this problem.

Thankyou.

答:
Depends on the nature of the application you're building:

If you want the user to access this over internet, create it as an ASP.NET application (UI) and a Windows Service / Windows Task Scheduler on the Server to send out scheduled emails.

If you want the user to run the application from his/her local machine/server, create a windows forms application (UI) and a Windows Service / Windows Task Scheduler on the local machine to send out scheduled emails.

ContentLicense: CC BY-SA 3.0


问:
How to use the result of a query like parameters of another one ?? ORACLE
I have a query that returns this

```<code>SELECT COLNAME FROM TABLE_1 WHERE CATALOG_ID = 40;

    COLNAME
    ----------------
    CONVERTED_VALUE
    CONVERTED_VALUE_01
    CONVERTED_VALUE_02
    CONVERTED_VALUE_03
    VALUE_DESCRIPTION
</code>```

I need to convert this result into a query like the next:

```<code>SELECT CONVERTED_VALUE, CONVERTED_VALUE_01, CONVERTED_VALUE_02,
CONVERTED_VALUE_03 , VALUE_DESCRIPTION
FROM TABLE2 WHERE CATALOG_ID = 40;
</code>```

Is posible to do this in a single query I don't know for example

```<code>SELECT( SELECT COLNAME FROM TABLE_1 WHERE CATALOG_ID = 40 )
FROM TABLE_2 WHERE CATALOG_ID = 40;
</code>```

Obviously that doesn't work but is the idea :)

I really don't know how to achieve this. Any suggestion guys? I'm not an expert at using databases :(

I'm using Oracle 10.

The idea is basically convert the result of the first query into the parameters of the second one.

答: the return format of select statement does not match the column name format we need to provide, so it's not possible i guess :( </p>

ContentLicense: CC BY-SA 4.0

Body:
I have a query that returns this

SELECT COLNAME FROM TABLE_1 WHERE CATALOG_ID = 40;

    COLNAME
    ----------------
    CONVERTED_VALUE
    CONVERTED_VALUE_01
    CONVERTED_VALUE_02
    CONVERTED_VALUE_03
    VALUE_DESCRIPTION

I need to convert this result into a query like the next:

SELECT CONVERTED_VALUE, CONVERTED_VALUE_01, CONVERTED_VALUE_02,
CONVERTED_VALUE_03 , VALUE_DESCRIPTION
FROM TABLE2 WHERE CATALOG_ID = 40;

Is posible to do this in a single query I don't know for example

SELECT( SELECT COLNAME FROM TABLE_1 WHERE CATALOG_ID = 40 )
FROM TABLE_2 WHERE CATALOG_ID = 40;

Obviously that doesn't work but is the idea :)

I really don't know how to achieve this. Any suggestion guys? I'm not an expert at using databases :(

I'm using Oracle 10.

The idea is basically convert the result of the first query into the parameters of the second one.


问:
Authenticate in Django without a database
I have a Django app that gets it's data completely from apis. so I don't have to use database. Session data is stored on signed cookies. I tried to code a custom User model and a custom auth backend like on the docs, but I get the following error:
django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'my_app.MyUser' that has not been installed

My settings.py:

```<code>AUTH_USER_MODEL = 'my_app.MyUser'
AUTHENTICATION_BACKENDS = ('django.contrib.auth.backends.ModelBackend',
                           'my_app.backends.LoginAuthBackend',)
</code>```

models.py:

```<code>class MyUser(object):
    def save(self):
        pass
    objects = None
    username = ""
</code>```

Here, If a try use the AbstractUser from django instead of Object I got the following error: AttributeError: 'NoneType' object has no attribute '_meta' or the db table doesn't exit.

backends.py

```<code>class LoginAuthBackend(object):
    def authenticate(self, username=None, password=None):
        if username and password:
           try:
               response = my_auth_function(username, password)
               if response.status_code == 200:
                   token = response.get('my_key')
                   user = MyUser()
                   return user
            except MyCustomException:
                  return None
</code>```

It's drives me crazy. Looks like Django that's not easy to use without a DB.

EDIT

After several of tries, a simple way to solve this is remove  'django.contrib.auth.backends.ModelBackend' from AUTHENTICATION_BACKENDS and  AUTH_USER_MODEL from settings. The model continues basically the same way. works smoothly

答:
The default set of authentication back-end processors is defined in the AUTHENTICATION_BACKENDS setting. See the Django documentation for Customizing authentication.

By default, AUTHENTICATION_BACKENDS is set to:

```<code>['django.contrib.auth.backends.ModelBackend']
</code>```

That’s the basic authentication backend that checks the Django users database and queries the built-in permissions.

So, if you don't want the django.contrib.auth.backends.ModelBackend authentication method, remove that from the list. You'll probably want to find (or create) a different one and add that to the list.

Body:
I have a Django app that gets it's data completely from apis. so I don't have to use database. Session data is stored on signed cookies. I tried to code a custom User model and a custom auth backend like on the docs, but I get the following error:
django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'my_app.MyUser' that has not been installed

My settings.py:

AUTH_USER_MODEL = 'my_app.MyUser'
AUTHENTICATION_BACKENDS = ('django.contrib.auth.backends.ModelBackend',
                           'my_app.backends.LoginAuthBackend',)

models.py:

class MyUser(object):
    def save(self):
        pass
    objects = None
    username = ""

Here, If a try use the AbstractUser from django instead of Object I got the following error: AttributeError: 'NoneType' object has no attribute '_meta' or the db table doesn't exit.

backends.py

class LoginAuthBackend(object):
    def authenticate(self, username=None, password=None):
        if username and password:
           try:
               response = my_auth_function(username, password)
               if response.status_code == 200:
                   token = response.get('my_key')
                   user = MyUser()
                   return user
            except MyCustomException:
                  return None

It's drives me crazy. Looks like Django that's not easy to use without a DB.

EDIT

After several of tries, a simple way to solve this is remove  'django.contrib.auth.backends.ModelBackend' from AUTHENTICATION_BACKENDS and  AUTH_USER_MODEL from settings. The model continues basically the same way. works smoothly

Body:
The default set of authentication back-end processors is defined in the AUTHENTICATION_BACKENDS setting. See the Django documentation for Customizing authentication.

By default, AUTHENTICATION_BACKENDS is set to:

['django.contrib.auth.backends.ModelBackend']

That’s the basic authentication backend that checks the Django users database and queries the built-in permissions.

So, if you don't want the django.contrib.auth.backends.ModelBackend authentication method, remove that from the list. You'll probably want to find (or create) a different one and add that to the list.


问:
How to select optional parameters on oracle (Decrease execution time of oracle)?
I have to decrease execution time of this. This statement processing waste about 30 minutes when I just inserted on ":i_member_name", all other is null.

```<code>SELECT

A.MEMBER_NUM, A.MEMBER_NAME, B.MEMBER_INFO FROM REG_MEMBER A, MEMBER_DETAIL B

WHERE A.MEMBER_ID = B.MEMBER_ID

AND (LOWER(A.MEMBER_NAME)  LIKE LOWER(:i_member_name || '%'))

AND (LOWER(B.MEMBER_INFO) LIKE LOWER(:i_member_info || '%'))

AND (A.MEMBER_NUM  LIKE :i_member_num || '%')

AND (LOWER(B.MEMBER_ADD) LIKE LOWER('%' || :i_member_add || '%'))
</code>```

If I execute like this it's being ok just wasted 30 seconds.

```<code>SELECT

    A.MEMBER_NUM, A.MEMBER_NAME, B.MEMBER_INFO FROM REG_MEMBER A, MEMBER_DETAIL B

    WHERE A.MEMBER_ID = B.MEMBER_ID

    AND (LOWER(A.MEMBER_NAME)  LIKE LOWER(:i_member_name || '%'))

  --AND (LOWER(B.MEMBER_INFO) LIKE LOWER(:i_member_info || '%'))

  --AND (A.MEMBER_NUM  LIKE :i_member_num || '%')

  --AND (LOWER(B.MEMBER_ADD) LIKE LOWER('%' || :i_member_add || '%'))
</code>```

So I have a question: How to check parameter is null then don't read against more execution time. something like this

```<code>         SELECT A.MEMBER_NUM, A.MEMBER_NAME, B.MEMBER_INFO FROM REG_MEMBER A, MEMBER_DETAIL B
                    WHERE
(LOWER(A.MEMBER_NAME)  LIKE LOWER(:i_member_name || '%'))
         and   case when :i_member_num is null then return
        else (A.MEMBER_NUM LIKE :i_member_num || '%')
    end
</code>```

答:
The fastest way to check for optional parameters in SQL is usually with NVL.

Oracle can often expand an NVL expression into two separate sub-plans.  A FILTER operation will work at run time to choose only one part of the plan.  For example, it may use an INDEX RANGE SCAN with a bind value like 'Smith%' that is sargable; and it may use a TABLE ACCESS FULL with a bind value like NULL that is not sargable.

Below is an example using a small subset of the objects in your question:

```<code>--Create table and index.
create table reg_member(member_num number, member_name varchar2(100));
create index reg_member_idx on reg_member(lower(member_name));

--Generate explain plan.
EXPLAIN PLAN FOR
SELECT
    A.MEMBER_NUM, A.MEMBER_NAME
FROM REG_MEMBER A
WHERE NVL(:i_member_name, LOWER(A.MEMBER_NAME)) = LOWER(A.MEMBER_NAME);

--Show explain plan.
select * from table(dbms_xplan.display);

Plan hash value: 3501926772

----------------------------------------------------------------------------------------------------------
| Id  | Operation                              | Name            | Rows  | Bytes | Cost (%CPU)| Time     |
----------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                       |                 |     2 |   130 |     3   (0)| 00:00:01 |
|   1 |  VIEW                                  | VW_ORE_377C5901 |     2 |   130 |     3   (0)| 00:00:01 |
|   2 |   UNION-ALL                            |                 |       |       |            |          |
|*  3 |    FILTER                              |                 |       |       |            |          |
|   4 |     TABLE ACCESS BY INDEX ROWID BATCHED| REG_MEMBER      |     1 |   117 |     1   (0)| 00:00:01 |
|*  5 |      INDEX RANGE SCAN                  | REG_MEMBER_IDX  |     1 |       |     1   (0)| 00:00:01 |
|*  6 |    FILTER                              |                 |       |       |            |          |
|*  7 |     TABLE ACCESS FULL                  | REG_MEMBER      |     1 |   117 |     2   (0)| 00:00:01 |
----------------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   3 - filter(:I_MEMBER_NAME IS NOT NULL)
   5 - access(LOWER("MEMBER_NAME")=:I_MEMBER_NAME)
   6 - filter(:I_MEMBER_NAME IS NULL)
   7 - filter(LOWER("MEMBER_NAME") IS NOT NULL)

Note
-----
   - dynamic statistics used: dynamic sampling (level=2)
</code>```

NVL FILTER operations can work great in some cases.  But it's difficult to say if it would fix your specific problem because there are so many variables: do the objects have the right indexes, how do all the predicates work together, etc.  But NVL is a good place to start.

Body:
I have to decrease execution time of this. This statement processing waste about 30 minutes when I just inserted on ":i_member_name", all other is null.

SELECT

A.MEMBER_NUM, A.MEMBER_NAME, B.MEMBER_INFO FROM REG_MEMBER A, MEMBER_DETAIL B

WHERE A.MEMBER_ID = B.MEMBER_ID

AND (LOWER(A.MEMBER_NAME)  LIKE LOWER(:i_member_name || '%'))

AND (LOWER(B.MEMBER_INFO) LIKE LOWER(:i_member_info || '%'))

AND (A.MEMBER_NUM  LIKE :i_member_num || '%')

AND (LOWER(B.MEMBER_ADD) LIKE LOWER('%' || :i_member_add || '%'))

If I execute like this it's being ok just wasted 30 seconds.

SELECT

    A.MEMBER_NUM, A.MEMBER_NAME, B.MEMBER_INFO FROM REG_MEMBER A, MEMBER_DETAIL B

    WHERE A.MEMBER_ID = B.MEMBER_ID

    AND (LOWER(A.MEMBER_NAME)  LIKE LOWER(:i_member_name || '%'))

  --AND (LOWER(B.MEMBER_INFO) LIKE LOWER(:i_member_info || '%'))

  --AND (A.MEMBER_NUM  LIKE :i_member_num || '%')

  --AND (LOWER(B.MEMBER_ADD) LIKE LOWER('%' || :i_member_add || '%'))

So I have a question: How to check parameter is null then don't read against more execution time. something like this

         SELECT A.MEMBER_NUM, A.MEMBER_NAME, B.MEMBER_INFO FROM REG_MEMBER A, MEMBER_DETAIL B
                    WHERE
(LOWER(A.MEMBER_NAME)  LIKE LOWER(:i_member_name || '%'))
         and   case when :i_member_num is null then return
        else (A.MEMBER_NUM LIKE :i_member_num || '%')
    end

Body:
The fastest way to check for optional parameters in SQL is usually with NVL.

Oracle can often expand an NVL expression into two separate sub-plans.  A FILTER operation will work at run time to choose only one part of the plan.  For example, it may use an INDEX RANGE SCAN with a bind value like 'Smith%' that is sargable; and it may use a TABLE ACCESS FULL with a bind value like NULL that is not sargable.

Below is an example using a small subset of the objects in your question:

--Create table and index.
create table reg_member(member_num number, member_name varchar2(100));
create index reg_member_idx on reg_member(lower(member_name));

--Generate explain plan.
EXPLAIN PLAN FOR
SELECT
    A.MEMBER_NUM, A.MEMBER_NAME
FROM REG_MEMBER A
WHERE NVL(:i_member_name, LOWER(A.MEMBER_NAME)) = LOWER(A.MEMBER_NAME);

--Show explain plan.
select * from table(dbms_xplan.display);

Plan hash value: 3501926772

----------------------------------------------------------------------------------------------------------
| Id  | Operation                              | Name            | Rows  | Bytes | Cost (%CPU)| Time     |
----------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                       |                 |     2 |   130 |     3   (0)| 00:00:01 |
|   1 |  VIEW                                  | VW_ORE_377C5901 |     2 |   130 |     3   (0)| 00:00:01 |
|   2 |   UNION-ALL                            |                 |       |       |            |          |
|*  3 |    FILTER                              |                 |       |       |            |          |
|   4 |     TABLE ACCESS BY INDEX ROWID BATCHED| REG_MEMBER      |     1 |   117 |     1   (0)| 00:00:01 |
|*  5 |      INDEX RANGE SCAN                  | REG_MEMBER_IDX  |     1 |       |     1   (0)| 00:00:01 |
|*  6 |    FILTER                              |                 |       |       |            |          |
|*  7 |     TABLE ACCESS FULL                  | REG_MEMBER      |     1 |   117 |     2   (0)| 00:00:01 |
----------------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   3 - filter(:I_MEMBER_NAME IS NOT NULL)
   5 - access(LOWER("MEMBER_NAME")=:I_MEMBER_NAME)
   6 - filter(:I_MEMBER_NAME IS NULL)
   7 - filter(LOWER("MEMBER_NAME") IS NOT NULL)

Note
-----
   - dynamic statistics used: dynamic sampling (level=2)

NVL FILTER operations can work great in some cases.  But it's difficult to say if it would fix your specific problem because there are so many variables: do the objects have the right indexes, how do all the predicates work together, etc.  But NVL is a good place to start.


问:
Swift 3 array indexOf function is missing
When I try to print index of the array which contains any object. It's not suggesting the indexOf function. When I try to enter manually its shows error that I have attached screenshot.

But it's working for Array of String. Can anyone please help me to solve this?

Also Here I am showing my code

```<code>import UIKit

class ViewController: UIViewController {

    var arrayOfAnyObject: [Any] = [Any]()
    var arrayOfStringObject: [String] = [String]()

    override func viewDidLoad() {
        super.viewDidLoad()

         print("Index of string object array \(arrayOfStringObject.index(of: "anyString")!)")

         print("Index of any object array \(arrayOfAnyObject.index(of: "anyObject")!)")

        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}
</code>```

答:
You could either set the type that you need in the array (Int, String etc..) or convert the arrayOfAnyObject to AnyObject before you do the indexOf, like this:

```<code>print("Index of any object array \((arrayOfAnyObject as AnyObject).index(of: "anyObject"))")
</code>```

Body:
When I try to print index of the array which contains any object. It's not suggesting the indexOf function. When I try to enter manually its shows error that I have attached screenshot.

But it's working for Array of String. Can anyone please help me to solve this?

Also Here I am showing my code

import UIKit

class ViewController: UIViewController {

    var arrayOfAnyObject: [Any] = [Any]()
    var arrayOfStringObject: [String] = [String]()

    override func viewDidLoad() {
        super.viewDidLoad()

         print("Index of string object array \(arrayOfStringObject.index(of: "anyString")!)")

         print("Index of any object array \(arrayOfAnyObject.index(of: "anyObject")!)")

        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}

Body:
You could either set the type that you need in the array (Int, String etc..) or convert the arrayOfAnyObject to AnyObject before you do the indexOf, like this:

print("Index of any object array \((arrayOfAnyObject as AnyObject).index(of: "anyObject"))")


问:
Reset an SkSpriteNode physics simulation in Swift 3
So I'd like to move a square from the bottom left of the screen to the top right. However every time this action happens, the square has a little push towards the right side of the screen and also remains with its previous tilt... Can I just reset its physics simulation?</p>

```<code>object.removeAllActions()
object.position.y = frame.maxY + 50
object.position.x = frame.miX + 50
</code>```

答:
Here's how to reset completely a node's physics:

object.physicsBody = SKPhysicsBody()

I do this all the time. I find it easier to make a function to do this for me, so that way you don't have to reconfigure the pb each time you want it to be reset:

```<code>class Player: SKSpriteNode {

  func resetPB() {
    self.physicsBody = SKPhysicsBody(rectangleOf: self.size)
    self.physicsBody?.categoryBitMask = UInt(4)
    self.physicsBody?.mass = 35
    // And so on...
  }
}
</code>```

Or if you aren't using a subclass:

```<code>func resetPlayerPB(_ player: SKSpriteNode) {
  player.physicsBody = SKPhysicsBody(rectangleOf: player.size)
  // And so on...
}
</code>```

Body:
So I'd like to move a square from the bottom left of the screen to the top right. However every time this action happens, the square has a little push towards the right side of the screen and also remains with its previous tilt... Can I just reset its physics simulation?

object.removeAllActions()
object.position.y = frame.maxY + 50
object.position.x = frame.miX + 50

Body:
Here's how to reset completely a node's physics:

object.physicsBody = SKPhysicsBody()

I do this all the time. I find it easier to make a function to do this for me, so that way you don't have to reconfigure the pb each time you want it to be reset:

class Player: SKSpriteNode {

  func resetPB() {
    self.physicsBody = SKPhysicsBody(rectangleOf: self.size)
    self.physicsBody?.categoryBitMask = UInt(4)
    self.physicsBody?.mass = 35
    // And so on...
  }
}

Or if you aren't using a subclass:

func resetPlayerPB(_ player: SKSpriteNode) {
  player.physicsBody = SKPhysicsBody(rectangleOf: player.size)
  // And so on...
}


问:
Google maps API Basic Example
I've been unable to get the basic Google maps example working on my site.  I have the following div on my page:

```<code><div id="map_canvas" style="width:100%; height:100%"></div>
</code>```

And the following in the head of my document:

```<code><script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
    function initialize() {
        var latlng = new google.maps.LatLng(-34.397, 150.644);
        var myOptions = {
            zoom: 8,
            center: latlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    }
    jQuery(document).ready(initialize);
</script>
</code>```

It appears that the elements are getting loaded into my DOM, but there is no visible map on the page.

答: As per Google Map not showing up, it appears that percentage sizes on the div (e.g. 100%) don't work properly. I had to explicitly specify a pixel height and width for the div.</p>

ContentLicense: CC BY-SA 2.5

Title: Google maps API Basic Example

Body:
I've been unable to get the basic Google maps example working on my site.  I have the following div on my page:

And the following in the head of my document:

It appears that the elements are getting loaded into my DOM, but there is no visible map on the page.


问:
Mondrian with cassandra
I'm trying without success use a cassandra database with mondrian, there's some way to make it work? or it's just impossible cause mondrian only works with relational database? my code works with mysql

```<code>Connection connection = new Connection();
        connection.setCatalogPath( getClass().getResource( "/mySchema.xml" ).getPath() );
        connection.setDriver( "com.datastax.driver.core.Cluster" );
        connection.setUrl( "127.0.0.1:9160/myKeySpace" );
        connection.setPassword( "cassandra" );
        connection.setUser( "cassandra" );
        rolapConnection = (RolapConnection) DriverManager.getConnection( connection.getProperties(), null );
</code>```

I was trying to do this way, and always getting this error

mondrian.olap.MondrianException: Mondrian Error:Internal error: Error while creating SQL connection: Jdbc=jdbc:cassandra://127.0.0.1:9160/myKeySpace; JdbcUser=cassandra; JdbcPassword=cassandra

No suitable driver found for jdbc:cassandra://127.0.0.1:9160/myKeySpace

some super cool guy/girl could help me?

答:
Mondrian is not compatible with Cassandra.

Check Mondrian Database compatibility list

Use Datastax Java Driver :

```<code><dependency>
  <groupId>com.datastax.cassandra</groupId>
  <artifactId>cassandra-driver-core</artifactId>
  <version>3.2.0</version>
</dependency>
</code>```

Example :

```<code>Cluster cluster = null;
try {
    cluster = Cluster.builder()                                                    // (1)
            .addContactPoint("127.0.0.1")
            .build();
    Session session = cluster.connect();                                           // (2)

    ResultSet rs = session.execute("select release_version from system.local");    // (3)
    Row row = rs.one();
    System.out.println(row.getString("release_version"));                          // (4)
} finally {
    if (cluster != null) cluster.close();                                          // (5)
}
</code>```

Read More

Also there is a Cassandra JDBC Driver

http://www.dbschema.com/cassandra-jdbc-driver.html

Title: Mondrian with cassandra

Body:
I'm trying without success use a cassandra database with mondrian, there's some way to make it work? or it's just impossible cause mondrian only works with relational database? my code works with mysql

Connection connection = new Connection();
        connection.setCatalogPath( getClass().getResource( "/mySchema.xml" ).getPath() );
        connection.setDriver( "com.datastax.driver.core.Cluster" );
        connection.setUrl( "127.0.0.1:9160/myKeySpace" );
        connection.setPassword( "cassandra" );
        connection.setUser( "cassandra" );
        rolapConnection = (RolapConnection) DriverManager.getConnection( connection.getProperties(), null );

I was trying to do this way, and always getting this error

mondrian.olap.MondrianException: Mondrian Error:Internal error: Error while creating SQL connection: Jdbc=jdbc:cassandra://127.0.0.1:9160/myKeySpace; JdbcUser=cassandra; JdbcPassword=cassandra

No suitable driver found for jdbc:cassandra://127.0.0.1:9160/myKeySpace

some super cool guy/girl could help me?

Body:
Mondrian is not compatible with Cassandra.

Check Mondrian Database compatibility list

Use Datastax Java Driver :

<dependency>
  <groupId>com.datastax.cassandra</groupId>
  <artifactId>cassandra-driver-core</artifactId>
  <version>3.2.0</version>
</dependency>

Example :

Cluster cluster = null;
try {
    cluster = Cluster.builder()                                                    // (1)
            .addContactPoint("127.0.0.1")
            .build();
    Session session = cluster.connect();                                           // (2)

    ResultSet rs = session.execute("select release_version from system.local");    // (3)
    Row row = rs.one();
    System.out.println(row.getString("release_version"));                          // (4)
} finally {
    if (cluster != null) cluster.close();                                          // (5)
}

Read More

Also there is a Cassandra JDBC Driver

http://www.dbschema.com/cassandra-jdbc-driver.html


问:
How to check the value given is a positive or negative integer?
Lets say i have the value 10 assigned to a variable;

```<code>var values = 10;
</code>```

and i want to run a specific function if the value is a positive

```<code>if(values = +integer){
    //do something with positive
} else {
    //do something with negative values
}
</code>```

How would this be achieved?

答:
For checking positive integer:</p>

```<code>var isPositiveInteger = function(n) {
        return ($.isNumeric(n)) && (Math.floor(n) == n) && (n > 0);
}
</code>```

Body:
Lets say i have the value 10 assigned to a variable;

var values = 10;

and i want to run a specific function if the value is a positive

if(values = +integer){
    //do something with positive
} else {
    //do something with negative values
}

How would this be achieved?

Body:
For checking positive integer:

var isPositiveInteger = function(n) {
        return ($.isNumeric(n)) && (Math.floor(n) == n) && (n > 0);
}


问:
I can't download my iCloud calender anymore
I had a bat file which downloaded my iCloud calendar every hour. the link used was found via the iCloud site (the calendar is public shared). It has an webcal:// url but according to Apple's support you have to change this to http.

Using explorer of chrome, this file does not download.
In Chrome: {"reason":"Invalid or missing Origin header","error":1}
In Explorer: file seems to start, but then it says: "can't download ..."

My bat file:

```<code>@echo off
powershell -Command "(New-Object Net.WebClient).DownloadFile('http://p20-calendarws.icloud.com/ca/subscribe/1/...', 'D:\Backup\cal.ics')"
pause
</code>```

The code above gives me:

Exception calling "downloadfile" with "2" arguments: the remote server returned an error: 421 misdirected request.

This used to work fine, not anymore it seems.

Any thoughts? Anyone else doing something similar?

Tried replacing http with https, but no luck. Searching if iCloud made some changes didn't turn up any results.

答:
I found a solution to this issue that worked for me.

I had some calendars that had the error

{"reason":"Invalid or missing Origin header","error":1}

and some that didn't. Then I noticed that the ones that I could download without any trouble started with 'webcal://p05-' while those that had the error started with 'webcal://p45-'. So I simply unticked Public Calendar and clicked OK before selecting the calendar again and ticking Public Calendar. If that generates a URL starting with 'webcal://p45-', copy it to the browser and try downloading it, if not, try again until you get the right URL.

Body:
I had a bat file which downloaded my iCloud calendar every hour. the link used was found via the iCloud site (the calendar is public shared). It has an webcal:// url but according to Apple's support you have to change this to http.

Using explorer of chrome, this file does not download.
In Chrome: {"reason":"Invalid or missing Origin header","error":1}
In Explorer: file seems to start, but then it says: "can't download ..."

My bat file:

@echo off
powershell -Command "(New-Object Net.WebClient).DownloadFile('http://p20-calendarws.icloud.com/ca/subscribe/1/...', 'D:\Backup\cal.ics')"
pause

The code above gives me:

Exception calling "downloadfile" with "2" arguments: the remote server returned an error: 421 misdirected request.

This used to work fine, not anymore it seems.

Any thoughts? Anyone else doing something similar?

Tried replacing http with https, but no luck. Searching if iCloud made some changes didn't turn up any results.


问:
change span text using jquery based on parent element class
I checked through the forum but didn't find the solution for my problem. I am adding a class on an element based on the img src value. If img src contains 'amazon' a class is added to closest li element and based on that li element i'm changing text of a span. Till here everything is fine, after this I want to change the text of span whose parent li element doesn't have that class name. I can't figure out the solution for it. Here is my code.</p>

```<code><script>
jQuery(document).ready(function(){
    var select = 'img[src*="images-amazon.com"]';
    jQuery(select).closest("li").addClass("sac-amazon");

    var cls = jQuery("li.sac-amazon");
    var currency = jQuery("span.woocommerce-Price-currencySymbol");

    if(cls){
        currency.text("US $");
    }else if(!cls){
        currency.text("SG $");
    }

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

答:
I want to change the text of span whose parent li element doesn't have that class name

You need to target the child span only. use :not() selector to target li not having the class then use descendant selector

```<code>jQuery("li.sac-amazon span.woocommerce-Price-currencySymbol").text("US $");
jQuery("li:not(.sac-amazon) span.woocommerce-Price-currencySymbol").text("SG $");
</code>```

Body:
I want to change the text of span whose parent li element doesn't have that class name

You need to target the child span only. use :not() selector to target li not having the class then use descendant selector

jQuery("li.sac-amazon span.woocommerce-Price-currencySymbol").text("US $");
jQuery("li:not(.sac-amazon) span.woocommerce-Price-currencySymbol").text("SG $");


问:
How to create Dialog Box with Radio Buttons and return Value
I have a List of Objects. What I want to do:

Build a Dialog Box which shows a Radio Button for each element in the given List and returning the selected element/value by clicking on OK-Button.

Thanks in Advance.

答:
build your own form and add a public variable "a string for example" called "Result"</p>

```<code>public partial class YourDialog:Form
{
  public string Result = "";
  public YourDialog()
  {// add all the controls you need with the necessary handlers
   //add the OK button with an "On Click handler"
  }

  private void OK_Button_Click(object sender, EventArgs e)
  {
    //set the Result value according to your controls
    this.hide();// will explain in the main form
  }

}

// in your main form
private string GetUserResult()
{
  YourDialog NewDialog = new YourDialog();
  NewDialog.ShowDialog();//that's why you only have to hide it and not close it before getting the result

  string Result = NewDialog.Result;
  NewDialog.Close();
  return Result;
}
</code>```

Body:
build your own form and add a public variable "a string for example" called "Result"

public partial class YourDialog:Form
{
  public string Result = "";
  public YourDialog()
  {// add all the controls you need with the necessary handlers
   //add the OK button with an "On Click handler"
  }

  private void OK_Button_Click(object sender, EventArgs e)
  {
    //set the Result value according to your controls
    this.hide();// will explain in the main form
  }

}

// in your main form
private string GetUserResult()
{
  YourDialog NewDialog = new YourDialog();
  NewDialog.ShowDialog();//that's why you only have to hide it and not close it before getting the result

  string Result = NewDialog.Result;
  NewDialog.Close();
  return Result;
}


问:
CSS placing an absolute div beside another div (pure CSS popover)
I have a sidebar with a user profile picture (pink color). When the viewer hover on the image, a div (blue color) appears and it contains user details. Basically, I want an absolute positioned div appear next to its sibling.

It is functionally a popover, but I want to do it with pure CSS, is it possible?

I am using boostrap 4, it will be nice if the suggestion can co-exists with Bootstrap CSS. It will be awesome if the div can have an arrow associate with it.

My code is:

```<code><div>
    <div><figure class="figure"><img ... /></figure></div>
    //css-popover
    <div class="css-popover">User detail: ... bla bla bla ...</div>
</div>
</code>```

I tried to search in Stackoverflow, most of the question is related to float div and makes it beside, but I want something absolute positioned, and display on top of the body.

Update:

Most of the suggestions provided fulfill part of the requests. The suggested .css-popover width and height are bounded by the parents, but I wish the popover dimension be independent from the parent, i.e. just "popup" and it doesn't "change" the layout beneath.

And when the popup appear, it doesn't change the parent height too. I wish the sidebar "icon" (light pink icons) stay in place whenever a popup appear.

If it is not possible with CSS, then I just go for JS solution...

You can try your luck here. https://jsfiddle.net/byanjiong/nohno2bd/13/

(Note: the user content is long, so it height usually will exceed the profile image's height)

Update 2:
Thanks to @Gezzasa, his solution is working. ^_^

Guy, this is the working example of pure CSS popover! Amazing!

https://jsfiddle.net/byanjiong/nohno2bd/15/

Thanks, guy...

答:
hi you can try something like this

html

```<code><div class="container">
  <div class="img-con">
  <img src="https://images.google.com/images/branding/googleg/1x/googleg_standard_color_128dp.png" alt="" />
    <div class="info-con">
    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam modi, distinctio nostrum reprehenderit explicabo amet exped
  </div>
  </div>

</div>
</code>```

css

```<code>.img-con
{
  height:150px;
  width:150px;
  position: relative;
}
.info-con
{
  position: absolute;
  top:0;
  right:0;
  background-color: #5C6BC0;
  bottom:0;
  left:0;
  height:100%;
  width:100%;
  margin:auto;
  transition:all ease 0.4s;
  padding:3px;
  opacity:0;
}
.info-con::after
{
  content:"";
  position: absolute;
  left:-40px;
  top:0;
  bottom:0;
  margin:auto;
  height:0;
  border:20px solid transparent;
  border-right-color:#5C6BC0;
}
.img-con:hover .info-con
{
  right:-110%;
  left:auto;
  opacity:1;
}
</code>```

link for reference

Body:
I have a sidebar with a user profile picture (pink color). When the viewer hover on the image, a div (blue color) appears and it contains user details. Basically, I want an absolute positioned div appear next to its sibling.

It is functionally a popover, but I want to do it with pure CSS, is it possible?

I am using boostrap 4, it will be nice if the suggestion can co-exists with Bootstrap CSS. It will be awesome if the div can have an arrow associate with it.

My code is:

    //css-popover

User detail: ... bla bla bla ...

I tried to search in Stackoverflow, most of the question is related to float div and makes it beside, but I want something absolute positioned, and display on top of the body.

Update:

Most of the suggestions provided fulfill part of the requests. The suggested .css-popover width and height are bounded by the parents, but I wish the popover dimension be independent from the parent, i.e. just "popup" and it doesn't "change" the layout beneath.

And when the popup appear, it doesn't change the parent height too. I wish the sidebar "icon" (light pink icons) stay in place whenever a popup appear.

If it is not possible with CSS, then I just go for JS solution...

You can try your luck here. https://jsfiddle.net/byanjiong/nohno2bd/13/

(Note: the user content is long, so it height usually will exceed the profile image's height)

Update 2:
Thanks to @Gezzasa, his solution is working. ^_^

Guy, this is the working example of pure CSS popover! Amazing!

https://jsfiddle.net/byanjiong/nohno2bd/15/

Thanks, guy...

Body:
hi you can try something like this

html

<div class="container">
  <div class="img-con">
  <img src="https://images.google.com/images/branding/googleg/1x/googleg_standard_color_128dp.png" alt="" />
    <div class="info-con">
    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam modi, distinctio nostrum reprehenderit explicabo amet exped
  </div>
  </div>

</div>

css

.img-con
{
  height:150px;
  width:150px;
  position: relative;
}
.info-con
{
  position: absolute;
  top:0;
  right:0;
  background-color: #5C6BC0;
  bottom:0;
  left:0;
  height:100%;
  width:100%;
  margin:auto;
  transition:all ease 0.4s;
  padding:3px;
  opacity:0;
}
.info-con::after
{
  content:"";
  position: absolute;
  left:-40px;
  top:0;
  bottom:0;
  margin:auto;
  height:0;
  border:20px solid transparent;
  border-right-color:#5C6BC0;
}
.img-con:hover .info-con
{
  right:-110%;
  left:auto;
  opacity:1;
}

link for reference


问:
Stop Javascript and HTML from Loading From Cache
I am building a single page javascript app and when the application starts I use a single javascript file to load every other file I need on the fly. When I hit refresh, according to firebug, my HTML page as well as javascript pages will load with a 304 Not Modified Error and my javascript stops working.

I understand this is due to browser caching, but how can I avoid this? I load the initial HTML page with a single script call

```<code><script src="js/config.js" type="text/javascript"></script>
</code>```

and then continue to load the rest dynamically from within that script

```<code>window.onload = function () {
    var scripts = ['http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.1.min.js', 'js/core.js', 'js/sandbox.js']; //Application scripts
    var loaded = 0;
    //Callback is executed after all scripts have been loaded.
    var callback = function () {
        if (loaded + 1 == scripts.length) {
            //Create Modules
            CORE.loader("js/modules/Login.js", function () {
                CORE.createModule('loginForm', Login);
            });

            //Create HTML bindings.
            CORE.createBinding('appContainer', '#Login', 'login.html');
            CORE.bindHTML(window.location.hash); //Loads hash based page on startup
        } else {
            loaded++;
            loadScript(scripts[loaded], callback);
        }
    };

    loadScript(scripts[0], callback);

    function loadScript(scriptSrc, callback) {
        var script = document.createElement('script');
        script.type = 'text/javascript';
        script.async = true;
        script.src = scripts[loaded];

        if (script.readyState) {
            script.onreadystatechange = function () {
                if (script.readyState == 'loaded' || script.readyState == 'complete') {
                    script.onreadystatechange = null;
                    callback();
                }
            };
        } else {
            script.onload = function () {
                callback();
            };
        }

        document.getElementsByTagName('head')[0].appendChild(script);
    }
};
</code>```

I know that Gmail uses cookies to prevent this. Does anyone have any idea how to take that approach? Should I set the cookie on the server and then check it with JS on each page load/refresh and use something like window.location.refresh() if the cookie tells me the page is loaded from cache?

答:
After struggling with the cache issue for months, trying just about anything (including a script which changes the URLs using a parameter) I found a post which explains how to do that using the IIS.

Start IIS Manager (INETMGR from the start menu works for me)

Navigate to desired site in the Connections tree

Open Output Caching

Edit Feature Settings

Uncheck Enable cache and Enable kernel cache

If you cannot save changes, make sure your web.config file is not marked read only

IISRESET is required for the changes to take place

This is the original post, which mentions that it is relevant for IIS 7.5 (in Windows 7)
https://forums.iis.net/t/959070.aspx?How+do+you+disable+caching+in+IIS+

One of the things I tried before that was adding .html and .js in Output Caching, and checking "Prevent All Caching". So if it doesn't work after the IISRESET, try that, though I'm not sure it is actually required.

EDIT:

If it does not work, still in the IIS go to HTTP Response Headers and add new actions:

Name: cache-control, Value: no-cache

Name: expires, Value: 0

Body:
I am building a single page javascript app and when the application starts I use a single javascript file to load every other file I need on the fly. When I hit refresh, according to firebug, my HTML page as well as javascript pages will load with a 304 Not Modified Error and my javascript stops working.

I understand this is due to browser caching, but how can I avoid this? I load the initial HTML page with a single script call

and then continue to load the rest dynamically from within that script

window.onload = function () {
    var scripts = ['http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.1.min.js', 'js/core.js', 'js/sandbox.js']; //Application scripts
    var loaded = 0;
    //Callback is executed after all scripts have been loaded.
    var callback = function () {
        if (loaded + 1 == scripts.length) {
            //Create Modules
            CORE.loader("js/modules/Login.js", function () {
                CORE.createModule('loginForm', Login);
            });

            //Create HTML bindings.
            CORE.createBinding('appContainer', '#Login', 'login.html');
            CORE.bindHTML(window.location.hash); //Loads hash based page on startup
        } else {
            loaded++;
            loadScript(scripts[loaded], callback);
        }
    };

    loadScript(scripts[0], callback);

    function loadScript(scriptSrc, callback) {
        var script = document.createElement('script');
        script.type = 'text/javascript';
        script.async = true;
        script.src = scripts[loaded];

        if (script.readyState) {
            script.onreadystatechange = function () {
                if (script.readyState == 'loaded' || script.readyState == 'complete') {
                    script.onreadystatechange = null;
                    callback();
                }
            };
        } else {
            script.onload = function () {
                callback();
            };
        }

        document.getElementsByTagName('head')[0].appendChild(script);
    }
};

I know that Gmail uses cookies to prevent this. Does anyone have any idea how to take that approach? Should I set the cookie on the server and then check it with JS on each page load/refresh and use something like window.location.refresh() if the cookie tells me the page is loaded from cache?


问:
How to config credentials in Source Code Management section in Github Plugin for Jenkins?
Here is the test project I want Jenkins to build when there is new commit to this Github repo.

Here is the section on Jenkins for enter credentials for Github:

I know:

how to add SSH on Github

how account name and password works

But when I click this "Add", this huge window pops out:

I am freaked out since the form fields doens't match

account name & password,

SSH

I don't know how to fill the form to allow Jenkin to pull code from Github and start the build.

Please tell me how to fill the credential form to allow Jenkins to pull code from Github.

答:
If you want to use ssh, you should:

use an ssh url:

```<code>ssh://git@github.com/<username>/<reponame>
</code>```

Make sure to have the JENKINS SSH Credentials Plugin installed.

Then the popup should prompt you to define an ssh credential (registering a private key, since you have added the public key to your GitHub account profile)

Body:
If you want to use ssh, you should:

use an ssh url:

ssh://git@github.com/<username>/<reponame>

Make sure to have the JENKINS SSH Credentials Plugin installed.

Then the popup should prompt you to define an ssh credential (registering a private key, since you have added the public key to your GitHub account profile)


问:
Bypass excel csv formula conversion on fields starting with + or -
I have a csv file with contents:

```<code>"x","y","-z"
</code>```

When I import it I get:

How can I bypass this conversion?

Update

If you try:

```<code>   "x","y",="-z,a"
</code>```

The ",a" is not imported.

If you put a space in front:

```<code>   "x","y",=" -z"
</code>```

or

```<code>   "x","y"," -z"
</code>```

it will work fine

答: Your problem is that by using the CSV extension, you are forcing excel to interpret the file using its very strict CSV conventions, and this will often go against whatever it is you're trying to do unless the CSV file was originally created by Excel. Your easiest, and most reliable method of importing this CSV file, is to rename it to a TXT file, and then use the import function in excel to coerce columns in exactly the way you want.</p>

Body:
I have a csv file with contents:

"x","y","-z"

When I import it I get:

How can I bypass this conversion?

Update

If you try:

   "x","y",="-z,a"

The ",a" is not imported.

If you put a space in front:

   "x","y",=" -z"

or

   "x","y"," -z"

it will work fine


问:
VS2017 setup - wrong team services account used?
Newbe to Team Services...

Vs2015 Desktop Community for original setup.

I stumbled through the setup of our ...visualstudio.com account and it is working on two PCs. I went down the GIT path but I'm not really clear on the process, I just kept banging on it until it worked. It is working (mostly) for two VB.Net WinForm projects on two PCs.

I'm now setting up a brand new PC and I installed VS2017. I didn't install any extra software for GIT (can't find any directions for source control install for that either, TS GIT quick start doesn't mention setting up GIT) I logged into the visualstudio cloud from the new install and cloned one of the projects from the cloud GUI. The files came down OK but the project type is evidently wrong because the Solution Explorer always lists all files and I can't open a form in the GUI. I also tried to use VS2017 to clone/download the project with the same result.

Do I need to install GIT in a fresh install of VS2017? Download from where/how to get a proper hookup with VS2017?

Why am I getting the files OK but the project type is not VB.Net Winform? Can that be tweaked or should I start over?

I was able to download using the .zip option from visualstudio.com but it isn't connected to a local or cloud repository. I'm not sure it is a good idea to connect these "out of band" files to an exisitng repository. The project is of the correct type and it builds OK and works.

Thanks!

View of solution in broken project:

答:
It’s unnecessary to install extra software after you installed VS2017.

In short, use VS to work with git repo on VSTS (visual studio team services), you just need to connect your VSTS account in VS and clone a local repo as working copy for VSTS git repo. Operations in VS 2017 should be:

Connect your VSTS account in VS2017.

VS2017 -> team explorer -> manage connections -> connect to project.

If your VSTS account (sign up email address) hasn’t connected yet, click add an account. After that, you can select your VSTS project/repo to connect/clone.

Clone VSTS git repo locally.

If you didn’t clone git repo in step1, then right click a VSTS repo -> clone.

Work on the local repo.

After successfully cloned a repo, you are working on the local repo, you can also find the local repo’s name and branch you are working for in the right bottom of VS2017. Now the solutions should be same as what you find in VSTS.

And you can make change and commit for them. And then push your local commit(s) to VSTS git repo.

For VS2017, there are two forms to view solutions and files: solution related and all files/folders.

If you can’t find .Designer.vb and .resx files, you must use the second mode as the above graph.

To view all files/folder, you can switch the view to first mode as below graph.


问:
Is there any way to have images adapted on it's own to a fixed resolution but shouldn't look odd?
I mean literally like there is anyway which would take a portrait image and set it to landscape sizes along with extra background like for filling so that the image will not look odd?

For instance this one is the original picture :

And now here it's distorted due to the fact that I set height & width to fixed values as :

So is there any way which would turn this portrait picture into a landscap based picture with everything showing perfectly Okay not just by changing the resolutions just but I mean literally like will resize the picture in there and then add extra background to the picture so that the picture won't look odd?

Is it possible in HTML,CSS,PHP,JS?

答:
Even though the other answers all suggest it, I'm going to go against the grain and say I don't think it's appropriate in this case to add CSS rules for each image since it looks like you're creating some sort of gallery. It's probably better to just use an  tag right in your HTML and that way you can dynamically generate the src without overly complicating things:

.container {
    border: 1px solid #777;
    text-align: center;
    padding: 10px;
    margin: 10px;
}
.container img {
    max-height:100%;
    max-width: 100%;
    vertical-align: middle;
}
.helper {
    display: inline-block;
    height: 100%;
    vertical-align: middle;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class='container' style="width:200px;height:200px">
  <span class="helper"></span><img src="https://i.stack.imgur.com/5ZNYR.png">
</div>
<div class='container' style="width:400px;height:200px">
  <span class="helper"></span><img src="https://i.stack.imgur.com/5ZNYR.png">
</div>
<div class='container' style="width:200px;height:400px">
  <span class="helper"></span><img src="https://i.stack.imgur.com/5ZNYR.png">
</div></code>```

Just make sure you don't have any whitespace between .helper and the img. It should work for any dimensions of container and image.

Body:
Even though the other answers all suggest it, I'm going to go against the grain and say I don't think it's appropriate in this case to add CSS rules for each image since it looks like you're creating some sort of gallery. It's probably better to just use an <img> tag right in your HTML and that way you can dynamically generate the src without overly complicating things:

.container {
    border: 1px solid #777;
    text-align: center;
    padding: 10px;
    margin: 10px;
}
.container img {
    max-height:100%;
    max-width: 100%;
    vertical-align: middle;
}
.helper {
    display: inline-block;
    height: 100%;
    vertical-align: middle;
}

<div class='container' style="width:200px;height:200px">
  <span class="helper"></span><img src="https://i.stack.imgur.com/5ZNYR.png">
</div>
<div class='container' style="width:400px;height:200px">
  <span class="helper"></span><img src="https://i.stack.imgur.com/5ZNYR.png">
</div>
<div class='container' style="width:200px;height:400px">
  <span class="helper"></span><img src="https://i.stack.imgur.com/5ZNYR.png">
</div>

Just make sure you don't have any whitespace between .helper and the img. It should work for any dimensions of container and image.


问:
How to Get POST ID from one page to another page
I have created a message system in wordpress. There s a consultation page fr each user.also a sidebar with certain menus. when the submit button is clicked the admin reviews the question and answers it. The message will be shown in the inbox sidebar menu on the same consultation page.

but whtever i tried am not getting the reply message of the corresponding user. my problem is that when i defined the link for inbox there is no id being passed.later in tht particular page whtever id s am calling its bring up the page id only and nothing else.

This is the sidebar code:

```<code><li>
    <a href="<?php echo site_url();?>/inbox/?id=<?php echo get_current_user_id();?>"><i class="fa fa-sort-alpha-asc " aria-hidden="true"> </i> <span style="margin-left:10px;">Inbox</span>  </a>
</li>
</code>```

now its bringing the id = 1. no matter which user it is.

this is the inbox code:

```<code><?php
global $post;
$idd= $post->ID;

$title= $post->post_title;
var_dump($title);

echo "<div class= 'col-lg-4'><table style='width:500px;'><tr><td><b>Reply:</b> ".get_post_meta( $idd, 'docreply', true)."</td></tr></div>";

echo "<div class= 'col-lg-4'><table style='width:500px;'><tr><td><b>Amount:</b> ".get_post_meta( $idd, 'amount', true)."</td></tr></div>";
</code>```

答: Finally i have found a solution to my problem. I updated the post_meta values in to my user_meta and in the page where i need to display the data, i called the current user id and called the user_meta</p>

Body:
I have created a message system in wordpress. There s a consultation page fr each user.also a sidebar with certain menus. when the submit button is clicked the admin reviews the question and answers it. The message will be shown in the inbox sidebar menu on the same consultation page.

but whtever i tried am not getting the reply message of the corresponding user. my problem is that when i defined the link for inbox there is no id being passed.later in tht particular page whtever id s am calling its bring up the page id only and nothing else.

This is the sidebar code:

    <a href="<?php echo site_url();?>/inbox/?id=<?php echo get_current_user_id();?>">  Inbox

now its bringing the id = 1. no matter which user it is.

this is the inbox code:

<?php
global $post;
$idd= $post->ID;

$title= $post->post_title;
var_dump($title);

echo "

Reply: ".get_post_meta( $idd, 'docreply', true)."

";

echo "

Amount: ".get_post_meta( $idd, 'amount', true)."

";


问:
Setting Checkbox selection limit(allow to select only 2)
Actually i am looking to set the limitation for checkbox selection. With the below Script i am copying column(1) of each row which is checked to the div(Summary).

Javascrpit

```<code><script>
     var tableControl = document.getElementById('order-table');
     $('#jqcc').click(function ()
     {
     var result = []
     var count =
     document.querySelectorAll('input[type="checkbox"]:checked').length;
     var limit = 2;

        $('input:checkbox:checked', tableControl).each(function () {
            result.push($(this).parent().next().text() + "," + "<br>");
        });

    $("#Summary").html(result).show();

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

HTML

```<code>            <div class="form-group" id="jqcc">
            <table id="order-table" name="order-table">
               <tr>
                   <th>Select</th>
                   <th>Medication</th>
                   <th>Max Issue Limit</th>
                   <th>Quantity</th>
                   <th>X</th>
                   <th>Unit Price</th>
                   <th>=</th>
                   <th>Totals</th>
               </tr>
               <tbody id="contacts">
                    <tr class='odd'>
                    <td><input type='checkbox' class='single-checkbox'></td>
                    <td class='product-title'>" + item.Name + "</td>
                    <td>" + item.MaxIssueLimit + "</td>
                    <td class='hours'><input type='text' class='hours' oninput='calculate()'></input></td>
                    <td class='times'>X</td>
                    <td class='rate'><input type='text' class='rate' value=" + item.UnitPrice + " oninput='calculate()' disabled='disabled'/></td>
                    <td class='equals'>=</td>
                    <td class='date-total'><input type='text' class='date-total'  disabled='disabled'/></td>
                    <td class='med' style='display:none'>" + item.MedicationID + "</td>
                    </tr>
                    <tr class='odd'>
                    <td><input type='checkbox' class='single-checkbox'></td>
                    <td class='product-title'>" + item.Name1 + "</td>
                    <td>" + item.MaxIssueLimit1 + "</td>
                    <td class='hours'><input type='text' class='hours' oninput='calculate()'></input></td>
                    <td class='times'>X</td>
                    <td class='rate'><input type='text' class='rate' value=" + item.UnitPrice + " oninput='calculate()' disabled='disabled'/></td>
                    <td class='equals'>=</td>
                    <td class='date-total'><input type='text' class='date-total'  disabled='disabled'/></td>
                    <td class='med' style='display:none'>" + item.MedicationID + "</td>
                    </tr>
                    <tr class='odd'>
                    <td><input type='checkbox' class='single-checkbox'></td>
                    <td class='product-title'>" + item.Name2 + "</td>
                    <td>" + item.MaxIssueLimit2 + "</td>
                    <td class='hours'><input type='text' class='hours' oninput='calculate()'></input></td>
                    <td class='times'>X</td>
                    <td class='rate'><input type='text' class='rate' value=" + item.UnitPrice + " oninput='calculate()' disabled='disabled'/></td>
                    <td class='equals'>=</td>
                    <td class='date-total'><input type='text' class='date-total'  disabled='disabled'/></td>
                    <td class='med' style='display:none'>" + item.MedicationID + "</td>
                    </tr>
                </tbody>
            </table>
            </div>

          <div class="col-md-4">
          <div class="portlet light bordered">
            <div class="portlet-title">
                <div class="caption">
                    <span class="caption-subject font-blue bold uppercase">
                        Summary
                    </span>
                </div>
            </div>
            <div id="Summary" style="font-size:medium;">
            </div>
            <br>
          </div>
          </div>
</code>```

Now,i want to set the checkbox selection limitation. So, when i try to set the limit using if condition. i can able to set the limit, but when i try to click more than the limit, the copied contents of Div(Summary) also disable.

So, how can i set the limit without losing the copied contents from div(Summary)?

Any help appreciated. Thanks

答:
Well, there are many ways you can go about this

Simplest, I think, is to have a var that's available to all of your javascript functions that simply counts that's sole role is to count the number of checks user has already made.

Do this check them whenever a Class of the checkbox is change(d)

For example:

on an html that looks like this:

```<code>        <input type="checkbox" id='cb1' class='chkGroup'> Check1
        <input type="checkbox" id='cb2' class='chkGroup'> Check2
</code>```

You can check with jquery like this

```<code>        var totChecks = 0;
        $('.chkGroup').on('change', function() {
              if($(this).prop("checked") == true)
              {
                 if(totChecks > 2){
                   /*cancel your action*/
                   console.log("too many checks!");
                   return false;
                 }
                 /*otherwise, proceed*/
                 totChecks = totChecks + 1;
              }
             else //checkbox is unchecked, so remove a point from totChecks.
              {
                totChecks = totChecks - 1;
              }
        });
</code>```

Body:
Actually i am looking to set the limitation for checkbox selection. With the below Script i am copying column(1) of each row which is checked to the div(Summary).

Javascrpit

HTML

                   Select
                   Medication
                   Max Issue Limit
                   Quantity
                   X
                   Unit Price
                   =
                   Totals

                    <input type='checkbox' class='single-checkbox'>
                    " + item.Name + "
                    " + item.MaxIssueLimit + "
                    <input type='text' class='hours' oninput='calculate()'></input>
                    X
                    <input type='text' class='rate' value=" + item.UnitPrice + " oninput='calculate()' disabled='disabled'/>
                    =
                    <input type='text' class='date-total'  disabled='disabled'/>
                    " + item.MedicationID + "

                    <input type='checkbox' class='single-checkbox'>
                    " + item.Name1 + "
                    " + item.MaxIssueLimit1 + "
                    <input type='text' class='hours' oninput='calculate()'></input>
                    X
                    <input type='text' class='rate' value=" + item.UnitPrice + " oninput='calculate()' disabled='disabled'/>
                    =
                    <input type='text' class='date-total'  disabled='disabled'/>
                    " + item.MedicationID + "

                    <input type='checkbox' class='single-checkbox'>
                    " + item.Name2 + "
                    " + item.MaxIssueLimit2 + "
                    <input type='text' class='hours' oninput='calculate()'></input>
                    X
                    <input type='text' class='rate' value=" + item.UnitPrice + " oninput='calculate()' disabled='disabled'/>
                    =
                    <input type='text' class='date-total'  disabled='disabled'/>
                    " + item.MedicationID + "

                        Summary

Now,i want to set the checkbox selection limitation. So, when i try to set the limit using if condition. i can able to set the limit, but when i try to click more than the limit, the copied contents of Div(Summary) also disable.

So, how can i set the limit without losing the copied contents from div(Summary)?

Any help appreciated. Thanks

Body:
Well, there are many ways you can go about this

Simplest, I think, is to have a var that's available to all of your javascript functions that simply counts that's sole role is to count the number of checks user has already made.

Do this check them whenever a Class of the checkbox is change(d)

For example:

on an html that looks like this:

        <input type="checkbox" id='cb1' class='chkGroup'> Check1
        <input type="checkbox" id='cb2' class='chkGroup'> Check2

You can check with jquery like this

        var totChecks = 0;
        $('.chkGroup').on('change', function() {
              if($(this).prop("checked") == true)
              {
                 if(totChecks > 2){
                   /*cancel your action*/
                   console.log("too many checks!");
                   return false;
                 }
                 /*otherwise, proceed*/
                 totChecks = totChecks + 1;
              }
             else //checkbox is unchecked, so remove a point from totChecks.
              {
                totChecks = totChecks - 1;
              }
        });


问:
Print from java to jsp
i am trying to create a Facebook oAuth code which in the end will print user's First Name, Last Name,Email etc on browser. This will be made with java and jsp. So here is my java code

```<code>public class MainMenu extends HttpServlet {

private static final long serialVersionUID = 1L;
private String code="";

public void service(HttpServletRequest req, HttpServletResponse res)
        throws ServletException, IOException {

    code = req.getParameter("code");
    if (code == null || code.equals("")) {
        throw new RuntimeException(
                "ERROR: Didn't get code parameter in callback.");
    }
    FBConnection fbConnection = new FBConnection();
    String accessToken = fbConnection.getAccessToken(code);

    FBGraph fbGraph = new FBGraph(accessToken);
    String graph = fbGraph.getFBGraph();
    Map<String, String> fbProfileData = fbGraph.getGraphData(graph);
    ServletOutputStream out = res.getOutputStream();
    out.println("<h1>Facebook Login using Java</h1>");
    out.println("<h2>Application Main Menu</h2>");
    out.println("<div>Welcome "+fbProfileData.get("first_name"));
    out.println("<div>Your Email: "+fbProfileData.get("email"));
    out.println("<div>You are "+fbProfileData.get("gender"));

}
</code>```

}

and i have an empty jsp file.

答:
Use HttpServletResponse res to do that:

```<code>res.getWriter().write("<h2>Application Main Menu</h2>" +
                    "<h1>Facebook Login using Java</h1>" +
                    "<div>Welcome "+fbProfileData.get("first_name") +
                    "<div>Your Email: "+fbProfileData.get("email") +
                    "<div>You are "+fbProfileData.get("gender"));
res.getWriter().flush();
res.getWriter().close();
</code>```

Title: Print from java to jsp

Body:
i am trying to create a Facebook oAuth code which in the end will print user's First Name, Last Name,Email etc on browser. This will be made with java and jsp. So here is my java code

public class MainMenu extends HttpServlet {

private static final long serialVersionUID = 1L;
private String code="";

public void service(HttpServletRequest req, HttpServletResponse res)
        throws ServletException, IOException {

    code = req.getParameter("code");
    if (code == null || code.equals("")) {
        throw new RuntimeException(
                "ERROR: Didn't get code parameter in callback.");
    }
    FBConnection fbConnection = new FBConnection();
    String accessToken = fbConnection.getAccessToken(code);

    FBGraph fbGraph = new FBGraph(accessToken);
    String graph = fbGraph.getFBGraph();
    Map<String, String> fbProfileData = fbGraph.getGraphData(graph);
    ServletOutputStream out = res.getOutputStream();
    out.println("
Facebook Login using Java
");
    out.println("
Application Main Menu
");
    out.println("
Welcome "+fbProfileData.get("first_name"));
    out.println("
Your Email: "+fbProfileData.get("email"));
    out.println("
You are "+fbProfileData.get("gender"));

}

}

and i have an empty jsp file.

Body:
Use HttpServletResponse res to do that:

res.getWriter().write("<h2>Application Main Menu</h2>" +
                    "<h1>Facebook Login using Java</h1>" +
                    "<div>Welcome "+fbProfileData.get("first_name") +
                    "<div>Your Email: "+fbProfileData.get("email") +
                    "<div>You are "+fbProfileData.get("gender"));
res.getWriter().flush();
res.getWriter().close();


问:
unfold function in R?
R has fold function Reduce. is there a corresponding unfold function? say, given a starting value and apply a function recursively to get an array? The for loop will do the job, just wondering if there is more R-like way for this. thanks,

An example, the code below plot lorenz attractor in 8 lines (mimic F# Lorenz Attractor in 35 lines. But the for loop looks ugly. Can we do better?

```<code>s <- 10; b <- 8/3; p <- 28
dt <- 0.003; n<-2000
x <- matrix(0,n,3); x[1,] <- c(10,0,20)
for (i in 2:n){
    x[i,] <- x[i-1,] + c(s * (x[i-1,2] - x[i-1,1]),x[i-1,1] * (p - x[i-1,3]) - x[i-1,2],x[i-1,1] * x[i-1,2] - b * x[i-1,3]) * dt
}
library(rgl)
plot3d(x,type= 'l',col = 'red')
</code>```

答:
How about

```<code>n<-2000
params <- list(s=10,b=8/3,p=28,dt=0.003)
X0 <- X <- c(x=10,y=0,z=20)

itfun <- function(X) {
  with(c(as.list(X),params),
       X + c(s*(y-x),x*(p-z)-y,x*y-b*z)*dt)
}
Xmat <- rbind(X0,t(replicate(n,X <<- itfun(X))))

library(rgl)
plot3d(Xmat,type= 'l',col = 'red')
</code>```

or (incorporating answer from comments)

```<code>do.call(rbind,
 Reduce(function(X, i) {
   with(c(params, as.list(X)),
       X + c(s*(y-x),x*(p-z)-y,x*y-b*z)*dt)
   },
   seq(n), X, accumulate=TRUE)[-1])
</code>```

PS how do you count lines? If you use enough semicolons you can do the whole thing on one line :-) I count 11 statements in your code

edit: was missing some parentheses in the x update

Title: unfold function in R?

Body:
R has fold function Reduce. is there a corresponding unfold function? say, given a starting value and apply a function recursively to get an array? The for loop will do the job, just wondering if there is more R-like way for this. thanks,

An example, the code below plot lorenz attractor in 8 lines (mimic F# Lorenz Attractor in 35 lines. But the for loop looks ugly. Can we do better?

s <- 10; b <- 8/3; p <- 28
dt <- 0.003; n<-2000
x <- matrix(0,n,3); x[1,] <- c(10,0,20)
for (i in 2:n){
    x[i,] <- x[i-1,] + c(s * (x[i-1,2] - x[i-1,1]),x[i-1,1] * (p - x[i-1,3]) - x[i-1,2],x[i-1,1] * x[i-1,2] - b * x[i-1,3]) * dt
}
library(rgl)
plot3d(x,type= 'l',col = 'red')

Body:
How about

n<-2000
params <- list(s=10,b=8/3,p=28,dt=0.003)
X0 <- X <- c(x=10,y=0,z=20)

itfun <- function(X) {
  with(c(as.list(X),params),
       X + c(s*(y-x),x*(p-z)-y,x*y-b*z)*dt)
}
Xmat <- rbind(X0,t(replicate(n,X <<- itfun(X))))

library(rgl)
plot3d(Xmat,type= 'l',col = 'red')

or (incorporating answer from comments)

do.call(rbind,
 Reduce(function(X, i) {
   with(c(params, as.list(X)),
       X + c(s*(y-x),x*(p-z)-y,x*y-b*z)*dt)
   },
   seq(n), X, accumulate=TRUE)[-1])

PS how do you count lines? If you use enough semicolons you can do the whole thing on one line :-) I count 11 statements in your code

edit: was missing some parentheses in the x update


问:
Can Xcode8 customize a toolbar depending on size classes?
I want, using the storyboard, to add a UIBarButtonItem to a UIToolbar, but only for width:Regular and height:Regular devices.

In the bottom of the storyboard, I activate „Vary for Traits“, and select width and height, so that only iPad devices remain.

If I draw an UILabel to the canvas, the attributes inspector shows me, as expected, 2 „installed“ fields, one for all devices (unchecked), and one for wRhR devices (checked):

However, if I draw a UIBarButtonItem to my toolbar, these fields are not shown.

Does this mean that a toolbar cannot be customized depending on size classes?

答: Briefly speaking, size classes, or vary for traits, only work for UIView objects, but UIBarItem/UIBarButtonItem inherits from NSObject, not UIView.


问:
php/sql- How do I use LIKE operator on variable to pull results from database?
As question said, I want to use the LIKE Operator so whenever user inputs something, like "M", it returns all database entries starting with "m" rather then anything named just "M". This is my code

```<code>$strSymbolName = @$_REQUEST["searchSymbol"];
//searchSymbol is the variable with user Input inside

if(!empty($strSymbolName))
{ // process the form
 // Establish dbserver connection and default database

$db = $objDBUtil->Open();
 // Run a Query to get company name

$query = "SELECT symSymbol, symName FROM symbols " .
 "WHERE symSymbol =" . $objDBUtil->DBQuotes($strSymbolName);
//Retrieves company symbol and name from database. Stores this in result

$result = $db->query($query);`
</code>```

What I thought of doing was using the LIKE operator on the WHERE statement, so something like-

```<code>WHERE symSymbol LIKE = " . $objDBUtil->DBQuotes($strSymbolName);
</code>```

But this didn't work...How would I apply the LIKE operator here?

答:
just use LIKE query</p>

```<code>$db = $objDBUtil->Open();
$query = "SELECT symSymbol, symName FROM symbols WHERE symSymbol LIKE '%$strSymbolName%'";
$result = $db->query($query);
</code>```

Body:
As question said, I want to use the LIKE Operator so whenever user inputs something, like "M", it returns all database entries starting with "m" rather then anything named just "M". This is my code

$strSymbolName = @$_REQUEST["searchSymbol"];
//searchSymbol is the variable with user Input inside

if(!empty($strSymbolName))
{ // process the form
 // Establish dbserver connection and default database

$db = $objDBUtil->Open();
 // Run a Query to get company name

$query = "SELECT symSymbol, symName FROM symbols " .
 "WHERE symSymbol =" . $objDBUtil->DBQuotes($strSymbolName);
//Retrieves company symbol and name from database. Stores this in result

$result = $db->query($query);`

What I thought of doing was using the LIKE operator on the WHERE statement, so something like-

WHERE symSymbol LIKE = " . $objDBUtil->DBQuotes($strSymbolName);

But this didn't work...How would I apply the LIKE operator here?

Body:
just use LIKE query

$db = $objDBUtil->Open();
$query = "SELECT symSymbol, symName FROM symbols WHERE symSymbol LIKE '%$strSymbolName%'";
$result = $db->query($query);


问:
How to pass a 2D array by pointer in C?
I am learning C and am having trouble passing the pointer of a 2D array to another function that then prints the 2D array. Any help would be appreciated. </p>

```<code>int main( void ){
    char array[50][50];
    int SIZE;

    ...call function to fill array... this part works.

    printarray( array, SIZE );
}

void printarray( char **array, int SIZE ){
    int i;
    int j;

    for( j = 0; j < SIZE; j++ ){
        for( i = 0; i < SIZE; i ++){
            printf( "%c ", array[j][i] );
        }
        printf( "\n" );
    }
}
</code>```

答:
You can easily pass the 2d array using double pointer.

```<code>  void printarray( char **array, int n)
  {
     int i, j;
     for(i=0; i<n; i++ )
     {
         for(j=0; j<n; j++)
         {
            printf("%c ", array[i][j] );
         }
        printf( "\n" );
     }
  }

  int main()
  {
      int n = 2;
      int i, j;

      char **array = (char **) malloc(n * sizeof(char*));

      for (i=0; i<n; i++)
      {
        array[i] = (char *) malloc(n* sizeof(char));
      }

     for (i=0; i<n; i++)
     {
       for (j=0; j<n; j++)
       {
           scanf("%c ", &array[i][j]);
       }
     }

     printarray(array, n);

     return 0;
  }
</code>```

Full Code : Ideone

Title: How to pass a 2D array by pointer in C?

Body:
I am learning C and am having trouble passing the pointer of a 2D array to another function that then prints the 2D array. Any help would be appreciated.

int main( void ){
    char array[50][50];
    int SIZE;

    ...call function to fill array... this part works.

    printarray( array, SIZE );
}

void printarray( char **array, int SIZE ){
    int i;
    int j;

    for( j = 0; j < SIZE; j++ ){
        for( i = 0; i < SIZE; i ++){
            printf( "%c ", array[j][i] );
        }
        printf( "\n" );
    }
}

Body:
You can easily pass the 2d array using double pointer.

  void printarray( char **array, int n)
  {
     int i, j;
     for(i=0; i<n; i++ )
     {
         for(j=0; j<n; j++)
         {
            printf("%c ", array[i][j] );
         }
        printf( "\n" );
     }
  }

  int main()
  {
      int n = 2;
      int i, j;

      char **array = (char **) malloc(n * sizeof(char*));

      for (i=0; i<n; i++)
      {
        array[i] = (char *) malloc(n* sizeof(char));
      }

     for (i=0; i<n; i++)
     {
       for (j=0; j<n; j++)
       {
           scanf("%c ", &array[i][j]);
       }
     }

     printarray(array, n);

     return 0;
  }

Full Code : Ideone


问:
SELECT data based on given pairs
I have little experience using SQL, and I am now using JDBC to connect to my database.
I am using sqlite, my schema looks as follows:

```<code>id1, id2, value1, value2
</code>```

I want to extract rows based on a list of given pairs of id1 and id2.
I know Postgresql can do

```<code>SELECT  *
FROM    table
WHERE   ("id1", "id2") IN (('1', '2'), ('3', '4'));
</code>```

But what about sqlite?

答:
Instead of IN, you could use a JOIN using the two fields:

```<code>SELECT U.*
FROM Table U
  INNER JOIN Table1 UT
    ON U.id1 = UT.id1
    AND U.id2 = UT.id2
</code>```

Title: SELECT data based on given pairs

Body:
I have little experience using SQL, and I am now using JDBC to connect to my database.
I am using sqlite, my schema looks as follows:

id1, id2, value1, value2

I want to extract rows based on a list of given pairs of id1 and id2.
I know Postgresql can do

SELECT  *
FROM    table
WHERE   ("id1", "id2") IN (('1', '2'), ('3', '4'));

But what about sqlite?

Body:
Instead of IN, you could use a JOIN using the two fields:

SELECT U.*
FROM Table U
  INNER JOIN Table1 UT
    ON U.id1 = UT.id1
    AND U.id2 = UT.id2


问:
Is there a market amongst programmers for an OID-keyed blob store?
A friend has developed a very amazing blob store and I think it needs to be used, but I'm wondering whether people think such a thing has a market, and if programmers ever get to make these kinds of decisions.  It has support for online backups using deltas and is much faster than anything I know of, it's undergone rigorous testing and being used in some very niche applications.  I would think anyone with a binary file format would like to use it as an alternative.  It has a C++ interface and has been adapted to .NET serialisation.

It absolutely blows SQL blob tables out of the water.

Thoughts?

Edit: It is better because:

It is very fast.

It is transactional, with a full recovery scan, so far better than flat files.

答:
Depending on the licensing and cost, I'd certainly look at it. I asked about something like this just a couple weeks ago, and ended up using an SQLite database file for the moment, which I suspect is less than optimal.

(And I run my own software development company, so I do make the purchasing decisions. :-) )

OwnerDisplayName: Jesse Pepper

LastEditorDisplayName: Jesse Pepper

OwnerDisplayName: Head Geek


问:
Google Checkout Account Username
I'm looking for a method that returns me the Google Checkout User Account of the owner of the telephone...

I explain: when I buy an application over the market, in the phone is stored somewhere the Google Account that I use to purchase the app (that maybe can be different from the main google main account?). I need a method, if exists, that gives me this account (only the username, I don't need the password!).

Thanx in advance

答:
That doesn't exist.  The notion of what Google account is used for Market login assumes the device has a Market application, and that's not guaranteed.

An application wanting access to another's private data must be signed with the same key and the applications must have made provisions to share a UID.  This article has a nice overview of how all of this works.

Title: Google Checkout Account Username


问:
Linux LowFree and Slab
Currently, My Router ran into a weired situation which the MemoryFree keeps growing down, but with no one growing up while searching the /proc/meminfo! How could this happen?

At the very beginning:

```<code>MemTotal:         513112 kB
MemFree:          453244 kB
MemAvailable:     397132 kB
Buffers:            3664 kB
Cached:            11428 kB
SwapCached:            0 kB
Active:            10476 kB
Inactive:           8036 kB
Active(anon):       3512 kB
Inactive(anon):     1024 kB
Active(file):       6964 kB
Inactive(file):     7012 kB
Unevictable:           0 kB
Mlocked:               0 kB
HighTotal:         65536 kB
HighFree:          62968 kB
LowTotal:         447576 kB
LowFree:          390276 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:          3552 kB
Mapped:             3016 kB
Shmem:              1116 kB
Slab:              15412 kB
SReclaimable:       2952 kB
SUnreclaim:        12460 kB
KernelStack:         632 kB
PageTables:          396 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:      256556 kB
Committed_AS:      14288 kB
VmallocTotal:    1015800 kB
VmallocUsed:        7816 kB
VmallocChunk:     990320 kB
</code>```

After some days:

```<code>MemTotal:         513112 kB
MemFree:          298280 kB
MemAvailable:     241060 kB
Buffers:            3068 kB
Cached:            10700 kB
SwapCached:            0 kB
Active:            11084 kB
Inactive:           6284 kB
Active(anon):       4112 kB
Inactive(anon):     1180 kB
Active(file):       6972 kB
Inactive(file):     5104 kB
Unevictable:           0 kB
Mlocked:               0 kB
HighTotal:         65536 kB
HighFree:          62164 kB
LowTotal:         447576 kB
LowFree:          236116 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:          3644 kB
Mapped:             3064 kB
Shmem:              1692 kB
Slab:              17224 kB
SReclaimable:       2632 kB
SUnreclaim:        14592 kB
KernelStack:         576 kB
PageTables:          392 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:      256556 kB
Committed_AS:      14904 kB
VmallocTotal:    1015800 kB
VmallocUsed:        7656 kB
VmallocChunk:     952764 kB
</code>```

Since the SLAB area does not significant changed, so the leaks must not be leaked by the kmalloc/kfree API and their companions(LowFree is growing down, so the leak must be laying somewhere in the kernelspace). Can anybody help me?
Sorry for my poor english.

答:
Finally, I've found that the Leak was caused by the MTK WIFI driver, which called dev_alloc_skb to allocate an skb and forget to free it.
The dev_alloc_skb internally allocated the skb->data via alloc_pages directly and it not be recorded by the slab.</p>

Title: Linux LowFree and Slab

Body:
Currently, My Router ran into a weired situation which the MemoryFree keeps growing down, but with no one growing up while searching the /proc/meminfo! How could this happen?

At the very beginning:

MemTotal:         513112 kB
MemFree:          453244 kB
MemAvailable:     397132 kB
Buffers:            3664 kB
Cached:            11428 kB
SwapCached:            0 kB
Active:            10476 kB
Inactive:           8036 kB
Active(anon):       3512 kB
Inactive(anon):     1024 kB
Active(file):       6964 kB
Inactive(file):     7012 kB
Unevictable:           0 kB
Mlocked:               0 kB
HighTotal:         65536 kB
HighFree:          62968 kB
LowTotal:         447576 kB
LowFree:          390276 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:          3552 kB
Mapped:             3016 kB
Shmem:              1116 kB
Slab:              15412 kB
SReclaimable:       2952 kB
SUnreclaim:        12460 kB
KernelStack:         632 kB
PageTables:          396 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:      256556 kB
Committed_AS:      14288 kB
VmallocTotal:    1015800 kB
VmallocUsed:        7816 kB
VmallocChunk:     990320 kB

After some days:

MemTotal:         513112 kB
MemFree:          298280 kB
MemAvailable:     241060 kB
Buffers:            3068 kB
Cached:            10700 kB
SwapCached:            0 kB
Active:            11084 kB
Inactive:           6284 kB
Active(anon):       4112 kB
Inactive(anon):     1180 kB
Active(file):       6972 kB
Inactive(file):     5104 kB
Unevictable:           0 kB
Mlocked:               0 kB
HighTotal:         65536 kB
HighFree:          62164 kB
LowTotal:         447576 kB
LowFree:          236116 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:          3644 kB
Mapped:             3064 kB
Shmem:              1692 kB
Slab:              17224 kB
SReclaimable:       2632 kB
SUnreclaim:        14592 kB
KernelStack:         576 kB
PageTables:          392 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:      256556 kB
Committed_AS:      14904 kB
VmallocTotal:    1015800 kB
VmallocUsed:        7656 kB
VmallocChunk:     952764 kB

Since the SLAB area does not significant changed, so the leaks must not be leaked by the kmalloc/kfree API and their companions(LowFree is growing down, so the leak must be laying somewhere in the kernelspace). Can anybody help me?
Sorry for my poor english.