问:
Unicode in vb.net
How to use Unicode available in vb6 in vb.net?

Is there any equivalent of vb6 Unicode in vb.net??

答:
VB 6 did not support Unicode, at least not directly. There were ways around it, but it was a royal pain in the rear. If you are asking does VB 6 support unicode like VB.NET, the answer is no.

If, instead, you are asking whether or not you can use something like code pages in VB.NET, the answer is an indirect yes, although I see no reason to jump through that hoop to support globalization/localization, as the paradigm has shifted.

OwnerDisplayName: renu

LastEditorDisplayName: JaredPar

Title: Unicode in vb.net

OwnerDisplayName: Gregory A Beamer

ContentLicense: CC BY-SA 2.5


来源: stackexchange

问:
How is the colon used when running a program in the command line?
I'm taking a Java assessment test. I do not understand the use of the colon in the command line. Could someone please elaborate? Thanks.

Here is the question...

Given:

```<code>class One {
    int x = 0;
    {assert x == 1;}
}
public class Two {
    public static void main(String[] args) {
        int y = 0;
        assert y == 0;
        if(args.length > 0)
            new One();
    }
}
</code>```

Which of the following will run without error? (Choose all that apply.)

```A. java Two
B. java Two x
C. java -ea Two
D. java -ea Two x
E. java -ea:One Two
F. java -ea:One Two x
G. java -ea:Two Two x
```

答: You could refer to Standard Options</p>

ContentLicense: CC BY-SA 3.0

Body:
I'm taking a Java assessment test. I do not understand the use of the colon in the command line. Could someone please elaborate? Thanks.

Here is the question...

Given:

class One {
    int x = 0;
    {assert x == 1;}
}
public class Two {
    public static void main(String[] args) {
        int y = 0;
        assert y == 0;
        if(args.length > 0)
            new One();
    }
}

Which of the following will run without error? (Choose all that apply.)

A. java Two
B. java Two x
C. java -ea Two
D. java -ea Two x
E. java -ea:One Two
F. java -ea:One Two x
G. java -ea:Two Two x

Body: You could refer to Standard Options


问:
Should i ask READ or WRITE permission to access Mediastore images in Android Q?
I recently updated my app to Target API 29 (Android Q). It is a Photo app which takes pictures and stores images in Gallery. I get WRITE_EXTERNAL_STORAGE permission to create folder in primary external storage through 'getExternalStoragePublicDirectory' and read images from the gallery. Since, the above method is deprecated and Google recommends three options and i chose Mediastore.

Ref: https://developer.android.com/reference/android/os/Environment#getExternalStoragePublicDirectory(java.lang.String)

Since we don't need write permission to store images anymore, i stopped asking write permission from the user when taking picture. But to read the images, we need permission. As per this table, Google recommends getting either WRITE_EXTERNAL_STORAGE or READ_EXTERNAL_STORAGE.

Ref: https://developer.android.com/training/data-storage

It also says that "For other apps to access your file, though the other app needs the READ_EXTERNAL_STORAGE permission"

And this recommendation in Android doc,
https://developer.android.com/training/data-storage/shared/documents-files

“If your app uses the media store, however, you must request the READ_EXTERNAL_STORAGE permission to access other apps’ media files.”

I tested with my existing WRITE_EXTERNAL_STORAGE permission and i was able to read images from gallery. But from the above recommendations, i feel that it is better I should go for READ_EXTERNAL_STORAGE which gives more finer permission control.

Which one would be more appropriate?

答:
Android updated their docs to use only read external storage while accessing images. Here is the reference
https://developer.android.com/training/data-storage/use-cases

ContentLicense: CC BY-SA 4.0


问:
JS Calculate distance from centre of viewport
I'm trying to centre an image with absolute position when hovering.
but since the image is nested within multiple divs, top and left distances are not ideal.

How can I change the script so that it refers to the centre of the viewport instead?

$(document).mousemove(function(e) {
  $("#image").css({
    left: e.clientX,
    top: e.clientY
  });
});
```

答:
Not exactly sure what you are trying to achieve but a possible solution can be in the lines of

$(document).mousemove(function(e) {
  $("#image").css({
    left: document.body.clientWidth / 2,
    top: document.body.clientHeight / 2
  });
});
```


问:
How to create getters and setters for all sub-properties of a Vuex state property efficiently?
I couldn't find the answer anywhere.

Let's say we have Vuex store with the following data:

Vuex store

state: {
  dialogs: {
    dialogName1: {
      value: false,
      data: {
        fileName: '',
        isValid: false,
        error: '',
        ... 10 more properties
      }
    },
    dialogName2: {
      value: false,
      data: {
        type: '',
        isValid: false,
        error: '',
        ... 10 more properties
      }
    }
  }
}
```

<h2>Dialogs.vue</h2>

<pre class="lang-html prettyprint-override"><code><div v-if="dialogName1Value">
  <input
    v-model="dialogName1DataFileName"
    :error="dialogName1DataIsValid"
    :error-text="dialogName1DataError"
  >

  <v-btn @click="dialogName1Value = false">
    close dialog
  </v-btn>
</div>
<!-- the other dialogs here -->
</code>```

Question

Let's say we need to modify some of these properties in Dialogs.vue.

What's the best practices for creating a getter and setter for every dialog property efficiently, without having to do it all manually like this:

computed: {
  dialogName1Value: {
    get () {
      return this.$store.state.dialogs.dialogName1.value
    },
    set (value) {
      this.$store.commit('SET', { key: 'dialogs.dialogName1.value', value: value })
    }
  },
  dialogName1DataFileName: {
    get () {
      return this.$store.state.dialogs.dialogName1.data.fileName
    },
    set (value) {
      this.$store.commit('SET', { key: 'dialogs.dialogName1.data.fileName', value: value })
    }
  },
  dialogName1DataIsValid: {
    get () {
      return this.$store.state.dialogs.dialogName1.data.isValid
    },
    set (value) {
      this.$store.commit('SET', { key: 'dialogs.dialogName1.data.isValid', value: value })
    }
  },
  dialogName1DataIsError: {
    get () {
      return this.$store.state.dialogs.dialogName1.data.error
    },
    set (value) {
      this.$store.commit('SET', { key: 'dialogs.dialogName1.data.error', value: value })
    }
  },
  ... 10 more properties
```

And this is only 4 properties...

I suppose I could generate those computed properties programmatically in created(), but is that really the proper way to do it?

Are there obvious, commonly known solutions for this issue that I'm not aware of?

答:
For setting those things in only one central function you can use something like this:

```<code><input
  :value="dialogName1DataFileName"
  @input="update_inputs($event, 'fileName')">

// ...
methods:{
  update_inputs($event, whichProperty){
    this.$store.commit("SET_PROPERTIES", {newVal: $event.target.value, which:"whichProperty"})
  }
}
</code>```

mutation handler:

```<code>// ..

mutations:{
  SET_PROPERTIES(state, payload){
    state.dialogName1.data[payload.which] = payload.newVal
  }
}
</code>```

Let me explain more what we done above. First we change to v-model type to :value and @input base. Basically you can think, :value is getter and @input is setter for that property. Then we didn't commit in first place, we calling update_inputs function to commit because we should determine which inner property we will commit, so then we did send this data as a method parameter (for example above code is 'fileName') then, we commit this changes with new value of data and info for which property will change. You can make this logic into your whole code blocks and it will solved your problem.

And one more, if you want to learn more about this article will help you more:
https://pekcan.dev/v-model-using-vuex/

Body:
I couldn't find the answer anywhere.

Let's say we have Vuex store with the following data:

Vuex store

state: {
  dialogs: {
    dialogName1: {
      value: false,
      data: {
        fileName: '',
        isValid: false,
        error: '',
        ... 10 more properties
      }
    },
    dialogName2: {
      value: false,
      data: {
        type: '',
        isValid: false,
        error: '',
        ... 10 more properties
      }
    }
  }
}

Dialogs.vue

  <input
    v-model="dialogName1DataFileName"
    :error="dialogName1DataIsValid"
    :error-text="dialogName1DataError"
  >

  <v-btn @click="dialogName1Value = false">
    close dialog
  </v-btn>

Question

Let's say we need to modify some of these properties in Dialogs.vue.

What's the best practices for creating a getter and setter for every dialog property efficiently, without having to do it all manually like this:

computed: {
  dialogName1Value: {
    get () {
      return this.$store.state.dialogs.dialogName1.value
    },
    set (value) {
      this.$store.commit('SET', { key: 'dialogs.dialogName1.value', value: value })
    }
  },
  dialogName1DataFileName: {
    get () {
      return this.$store.state.dialogs.dialogName1.data.fileName
    },
    set (value) {
      this.$store.commit('SET', { key: 'dialogs.dialogName1.data.fileName', value: value })
    }
  },
  dialogName1DataIsValid: {
    get () {
      return this.$store.state.dialogs.dialogName1.data.isValid
    },
    set (value) {
      this.$store.commit('SET', { key: 'dialogs.dialogName1.data.isValid', value: value })
    }
  },
  dialogName1DataIsError: {
    get () {
      return this.$store.state.dialogs.dialogName1.data.error
    },
    set (value) {
      this.$store.commit('SET', { key: 'dialogs.dialogName1.data.error', value: value })
    }
  },
  ... 10 more properties

And this is only 4 properties...

I suppose I could generate those computed properties programmatically in created(), but is that really the proper way to do it?

Are there obvious, commonly known solutions for this issue that I'm not aware of?

Body:
For setting those things in only one central function you can use something like this:

<input
  :value="dialogName1DataFileName"
  @input="update_inputs($event, 'fileName')">

// ...
methods:{
  update_inputs($event, whichProperty){
    this.$store.commit("SET_PROPERTIES", {newVal: $event.target.value, which:"whichProperty"})
  }
}

mutation handler:

// ..

mutations:{
  SET_PROPERTIES(state, payload){
    state.dialogName1.data[payload.which] = payload.newVal
  }
}

Let me explain more what we done above. First we change to v-model type to :value and @input base. Basically you can think, :value is getter and @input is setter for that property. Then we didn't commit in first place, we calling update_inputs function to commit because we should determine which inner property we will commit, so then we did send this data as a method parameter (for example above code is 'fileName') then, we commit this changes with new value of data and info for which property will change. You can make this logic into your whole code blocks and it will solved your problem.

And one more, if you want to learn more about this article will help you more:
https://pekcan.dev/v-model-using-vuex/


问:
Fast check of first inequality
I am looking for a function similar to match, but it should have an inequality as test and stop at the first occurrence.

```<code>a <- c(1,3,5,7,9,12)
b <- 6
# the output should be 4
# i tried this one:  match(min(a [b <= a ]),a ), but with much data it is slow
</code>```

答: You can still use match: match(TRUE, b <= a)

Title: Fast check of first inequality

Body:
I am looking for a function similar to match, but it should have an inequality as test and stop at the first occurrence.

a <- c(1,3,5,7,9,12)
b <- 6
# the output should be 4
# i tried this one:  match(min(a [b <= a ]),a ), but with much data it is slow


问:
Replace null with known value with same id
How can I do that in a optimal way?

TABLE

```<code>ID FLAG VALUE
----------------------------
1   Y   52
1   N   NULL
2   Y   51
3   N   54
</code>```

OUTPUT

```<code>ID FLAG VALUE
----------------------------
1   Y   52
1   N   52
2   Y   51
3   N   54
</code>```

答:
you can do it in two ways

```<code>SELECT Id,
       Flag,
       MAX(Value) OVER(PARTITION BY Id) CValue
FROM   Table_1
</code>```

or

```<code>select X.Id, X.Flag,
case when ISNULL(X.Value,0) = 0 then
(select MAX(A.Value) from Table_1 A where A.Id = X.Id)
 else X.Value end
from Table_1 X
</code>```

Body:
How can I do that in a optimal way?

TABLE

ID FLAG VALUE
----------------------------
1   Y   52
1   N   NULL
2   Y   51
3   N   54

OUTPUT

ID FLAG VALUE
----------------------------
1   Y   52
1   N   52
2   Y   51
3   N   54

Body:
you can do it in two ways

SELECT Id,
       Flag,
       MAX(Value) OVER(PARTITION BY Id) CValue
FROM   Table_1

or

select X.Id, X.Flag,
case when ISNULL(X.Value,0) = 0 then
(select MAX(A.Value) from Table_1 A where A.Id = X.Id)
 else X.Value end
from Table_1 X


问:
I want to define a class for receiving some information from the user and then printing them in the C++ console
I am going to define a class with the following features. However, when I run the compiler, I encounter with some errors relating to string variables. I do not know how to solve the problem for this code.

```<code>#include <iostream>
#include <conio.h>
#include <string>
#include <cstring>

using namespace std;

class Name
{

   public:

        int age;
        int id;
        std::string name ;
        std::string family ;
        std::string fathername ;

        Name()
        {
           name = "l";
           family = "p";
           fathername = "mh";
           age = 26;
           id = 80;
        }

        friend void setinformation()
        {
               std::string n;
               std::string f;
               std::string fn;
               cout << "Please Enter Your Name" << " ";
               cin >> n ;
               name = n;
               cout << "Please Enter Your Family" << " ";
               cin >> f ;
               family = f;
               cout << "Please Enter Your Father Name" << " ";
               cin >> fn ;
               fathername = fn;
               cout << "Please Enter Your age" << " ";
               cin >> A ;
               age = A;
               cout << "Please Enter Your id" << " ";
               cin >> i ;
               id = i;

        }
};

main()
{
    Name a;
    a.setinformation();

    cout << a.age << endl << a.name;

    getch();
}
</code>```

Here are the errors I have received:

```<code>General: TDM-GCC 4.8.1 64-bit Release
Executing g++.exe...
g++.exe "D:\Program Files\Dev-Cpp\Class Name.cpp" -o "D:\Program Files\Dev-Cpp\Class Name.exe" -g3 -I"D:\Program Files\Dev-Cpp\MinGW64\include" -I"D:\Program Files\Dev-Cpp\MinGW64\x86_64-w64-mingw32\include" -I"D:\Program Files\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.8.1\include" -I"D:\Program Files\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.8.1\include\c++" -L"D:\Program Files\Dev-Cpp\MinGW64\lib" -L"D:\Program Files\Dev-Cpp\MinGW64\x86_64-w64-mingw32\lib" -static-libgcc -g3
D:\Program Files\Dev-Cpp\Class Name.cpp: In constructor 'Name::Name()':
D:\Program Files\Dev-Cpp\Class Name.cpp:26:15: warning: overflow in implicit constant conversion [-Woverflow]
            id = 80;
               ^

D:\Program Files\Dev-Cpp\Class Name.cpp: In function 'void setinformation()':
D:\Program Files\Dev-Cpp\Class Name.cpp:15:21: error: invalid use of non-static data member 'Name::name'
         std::string name ;
                     ^
D:\Program Files\Dev-Cpp\Class Name.cpp:39:13: error: from this location
             name = n;
             ^
D:\Program Files\Dev-Cpp\Class Name.cpp:16:21: error: invalid use of non-static data member 'Name::family'
         std::string family ;
                     ^
D:\Program Files\Dev-Cpp\Class Name.cpp:42:13: error: from this location
             family = f;
             ^
D:\Program Files\Dev-Cpp\Class Name.cpp:17:21: error: invalid use of non-static data member 'Name::fathername'
         std::string fathername ;
                     ^
D:\Program Files\Dev-Cpp\Class Name.cpp:45:13: error: from this location
             fathername = fn;
             ^
D:\Program Files\Dev-Cpp\Class Name.cpp:47:20: error: 'A' was not declared in this scope
             cin >> A ;
                    ^
D:\Program Files\Dev-Cpp\Class Name.cpp:13:13: error: invalid use of non-static data member 'Name::age'
         int age;
             ^
D:\Program Files\Dev-Cpp\Class Name.cpp:48:13: error: from this location
             age = A;
             ^
D:\Program Files\Dev-Cpp\Class Name.cpp:50:20: error: 'i' was not declared in this scope
             cin >> i ;
                    ^
D:\Program Files\Dev-Cpp\Class Name.cpp:14:7: error: invalid use of non-static data member 'Name::id'
   int id;
       ^
D:\Program Files\Dev-Cpp\Class Name.cpp:51:7: error: from this location
       id = i;
       ^
D:\Program Files\Dev-Cpp\Class Name.cpp: In function 'int main()':
D:\Program Files\Dev-Cpp\Class Name.cpp:64:7: error: 'class Name' has no member named 'setinformation'
     a.setinformation();
       ^

Compilation failed after 0.24 seconds with errors
</code>```

答:
There are multiple problems in your code:

main needs a return type

There are unused includes

Use the constructor initializer list and not the constructor body

Make setinformation a member function and not a friend function

Don't use using namespace std;

```<code>#include <iostream>
#include <string>

class Name
{
   public:
        int age;
        int id;
        std::string name;
        std::string family;
        std::string fathername;

        Name() : age(26), id(80), name("l"), family("p"), fathername("mh")
        {}

        void setinformation()
        {
               std::cout << "Please Enter Your Name" << " ";
               std::cin >> name;
               std::cout << "Please Enter Your Family" << " ";
               std::cin >> family;
               std::cout << "Please Enter Your Father Name" << " ";
               std::cin >> fathername;
               std::cout << "Please Enter Your age" << " ";
               std::cin >> age;
               std::cout << "Please Enter Your id" << " ";
               std::cin >> id;
        }
};

int main()
{
    Name a;
    a.setinformation();

    std::cout << a.age << '\n' << a.name;
}
</code>```

Body:
I am going to define a class with the following features. However, when I run the compiler, I encounter with some errors relating to string variables. I do not know how to solve the problem for this code.

#include <iostream>
#include <conio.h>
#include <string>
#include <cstring>

using namespace std;

class Name
{

   public:

        int age;
        int id;
        std::string name ;
        std::string family ;
        std::string fathername ;

        Name()
        {
           name = "l";
           family = "p";
           fathername = "mh";
           age = 26;
           id = 80;
        }

        friend void setinformation()
        {
               std::string n;
               std::string f;
               std::string fn;
               cout << "Please Enter Your Name" << " ";
               cin >> n ;
               name = n;
               cout << "Please Enter Your Family" << " ";
               cin >> f ;
               family = f;
               cout << "Please Enter Your Father Name" << " ";
               cin >> fn ;
               fathername = fn;
               cout << "Please Enter Your age" << " ";
               cin >> A ;
               age = A;
               cout << "Please Enter Your id" << " ";
               cin >> i ;
               id = i;

        }
};

main()
{
    Name a;
    a.setinformation();

    cout << a.age << endl << a.name;

    getch();
}

Here are the errors I have received:

General: TDM-GCC 4.8.1 64-bit Release
Executing g++.exe...
g++.exe "D:\Program Files\Dev-Cpp\Class Name.cpp" -o "D:\Program Files\Dev-Cpp\Class Name.exe" -g3 -I"D:\Program Files\Dev-Cpp\MinGW64\include" -I"D:\Program Files\Dev-Cpp\MinGW64\x86_64-w64-mingw32\include" -I"D:\Program Files\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.8.1\include" -I"D:\Program Files\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.8.1\include\c++" -L"D:\Program Files\Dev-Cpp\MinGW64\lib" -L"D:\Program Files\Dev-Cpp\MinGW64\x86_64-w64-mingw32\lib" -static-libgcc -g3
D:\Program Files\Dev-Cpp\Class Name.cpp: In constructor 'Name::Name()':
D:\Program Files\Dev-Cpp\Class Name.cpp:26:15: warning: overflow in implicit constant conversion [-Woverflow]
            id = 80;
               ^

D:\Program Files\Dev-Cpp\Class Name.cpp: In function 'void setinformation()':
D:\Program Files\Dev-Cpp\Class Name.cpp:15:21: error: invalid use of non-static data member 'Name::name'
         std::string name ;
                     ^
D:\Program Files\Dev-Cpp\Class Name.cpp:39:13: error: from this location
             name = n;
             ^
D:\Program Files\Dev-Cpp\Class Name.cpp:16:21: error: invalid use of non-static data member 'Name::family'
         std::string family ;
                     ^
D:\Program Files\Dev-Cpp\Class Name.cpp:42:13: error: from this location
             family = f;
             ^
D:\Program Files\Dev-Cpp\Class Name.cpp:17:21: error: invalid use of non-static data member 'Name::fathername'
         std::string fathername ;
                     ^
D:\Program Files\Dev-Cpp\Class Name.cpp:45:13: error: from this location
             fathername = fn;
             ^
D:\Program Files\Dev-Cpp\Class Name.cpp:47:20: error: 'A' was not declared in this scope
             cin >> A ;
                    ^
D:\Program Files\Dev-Cpp\Class Name.cpp:13:13: error: invalid use of non-static data member 'Name::age'
         int age;
             ^
D:\Program Files\Dev-Cpp\Class Name.cpp:48:13: error: from this location
             age = A;
             ^
D:\Program Files\Dev-Cpp\Class Name.cpp:50:20: error: 'i' was not declared in this scope
             cin >> i ;
                    ^
D:\Program Files\Dev-Cpp\Class Name.cpp:14:7: error: invalid use of non-static data member 'Name::id'
   int id;
       ^
D:\Program Files\Dev-Cpp\Class Name.cpp:51:7: error: from this location
       id = i;
       ^
D:\Program Files\Dev-Cpp\Class Name.cpp: In function 'int main()':
D:\Program Files\Dev-Cpp\Class Name.cpp:64:7: error: 'class Name' has no member named 'setinformation'
     a.setinformation();
       ^

Compilation failed after 0.24 seconds with errors

Body:
There are multiple problems in your code:

main needs a return type

There are unused includes

Use the constructor initializer list and not the constructor body

Make setinformation a member function and not a friend function

Don't use using namespace std;

#include <iostream>
#include <string>

class Name
{
   public:
        int age;
        int id;
        std::string name;
        std::string family;
        std::string fathername;

        Name() : age(26), id(80), name("l"), family("p"), fathername("mh")
        {}

        void setinformation()
        {
               std::cout << "Please Enter Your Name" << " ";
               std::cin >> name;
               std::cout << "Please Enter Your Family" << " ";
               std::cin >> family;
               std::cout << "Please Enter Your Father Name" << " ";
               std::cin >> fathername;
               std::cout << "Please Enter Your age" << " ";
               std::cin >> age;
               std::cout << "Please Enter Your id" << " ";
               std::cin >> id;
        }
};

int main()
{
    Name a;
    a.setinformation();

    std::cout << a.age << '\n' << a.name;
}


问:
Query RDS endpoint name from within Oracle RDS SE
We are converting an existing Oracle application to run with AWS RDS Oracle Standard Edition.  For support purposes, the application uses a query like select sys_context('userenv','server_host') from dual to retrieve the name of the server the Oracle database is actually running on. We have 100+ of these Oracle instances, and we've found that having a SQL query retrieve that information is more reliable the depending on what a user, or some configuration files, say they should be connected with.

The issue is, when running in an AWS RDS Oracle database, the above query only returns an internal hostname, for example, ip-172-17-5-56, which we find difficult to match up with the actual RDS Endpoint names.

How can we, using Oracle PL/SQL, retrieve the true RDS endpoint name that the query is running in?

Thanks

答: I've found the endpoint seems to be quite separate from the database itself. It's more of a DNS name that just points you there. Short of asking AWS support, I would suggest just stashing the endpoint in a table when you create the RDS instance. You could also build a little Python script to iterate through all of your RDS instances and add that table after the fact.</p>


问:
azure traffic manager degraded
currently I wanna host website by using azure CDN and azure blob storage, I wanna do the CDN failover and recovery management to handle the situation like the primary endpoint is failed and CDN can automatically switch to secondary endpoint, i try use azure traffic manager to do it, based on this doc.

Base on the doc i provide above, based on the step it saids, im quite confused about it, this is my settings:

Routing method is priority, type of endpoint is external endpoints, test1 with priority 1, test2 with priority 2

test.trafficmanager.net  ->   which is my traffic manager url, i map it with my Cname test.mydomain.com in azure 365 domain center, Monitor status is degraded in traffic manager profiles

test1.azureedge.net  ->   which is my primary endpoint, i map it with cdnverify.test.mydomain.com in domain center but i cant map test1.azureedge.net with test.mydomain.com in CDN profile, return 200 when i go to test1.azureedge.net, Monitor status is degraded as well

test2.azureedge.net  ->   which is my secondary endpoint, i cant set up the map for to cdnverify.test subdomain in domain center, it says "Another DNS record already exists for this host name. Type a different name". Monitor status is degraded as well

when i go to test.trafficmanager.net, return 404; when i go to both test1.azureedge.net and test2.azureedge.net, return 200

is there any steps wrong or missing?

答: you're doing it wrong. CDN is for static content delivery, if there's a problem in one of the cdn nodes, you'll probably won't know, but the content will be delivered automatically by another node. Traffic Manager should be used with VM / Web Apps, then if one of the instances is down, it will failover to another instance / region</p>

Title: azure traffic manager degraded


问:
Oracle SQL - Count only one of specified value
I do hope someone can help me with this.

I am doing two count functions on on of my columns, both specified by where the column has a specific text (see below code). On my count for meeting (WHERE EVENT_TYPE = 'meeting_start'), I have found that this can pop up more than once within the same meeting. I need to only count this once per meeting event id and cannot find a way to do this.

```<code>select I.CRM_INSTANCE_NAME,
       C.CUSTOMER_NAME,
       U.USER_NAME,
       ltrim(TO_CHAR(U.CREATED_DATE ,'mm-yyyy'),'0') AS USER_ACTIVATION_DATE,
       ltrim(TO_CHAR(U.LAST_UPDATED_DATE ,'dd-mm-yyyy'),'0') AS LAST_ACTIVITY_DATE,
       COUNT(E.EVENT_TYPE) AS MEETING,
       COUNT(F.EVENT_TYPE) AS FINALISED

       FROM SBX_USERS U
        LEFT JOIN SBX_CUSTOMERS C on U.CUSTOMER_ID = C.CUSTOMER_ID
        LEFT JOIN SBX_CRM_INSTANCES I on C.CRM_INSTANCE_ID = I.CRM_INSTANCE_ID
        LEFT JOIN SBX_MEETING M on U.USER_ID = M.USER_ID
        LEFT JOIN SBX_EVENTS E ON SOURCE_ID  = M.MEETING_ID
        LEFT JOIN (SELECT * FROM SBX_EVENTS WHERE EVENT_TYPE = 'meeting_start' AND EVENT_CREATION_DATE >=add_months(sysdate, -12)) E on E.SOURCE_ID = M.MEETING_ID
        LEFT JOIN (SELECT * FROM SBX_EVENTS WHERE EVENT_TYPE = 'finalize'AND EVENT_CREATION_DATE >=add_months(sysdate, -12)) F on F.SOURCE_ID = M.MEETING_ID

where U.ENABLED_FLAG IN ('Y','E')

group by  I.CRM_INSTANCE_NAME, C.CUSTOMER_NAME, U.USER_NAME, ltrim(TO_CHAR(U.CREATED_DATE ,'mm-yyyy'),'0'), ltrim(TO_CHAR(U.LAST_UPDATED_DATE ,'dd-mm-yyyy'),'0')
order by  I.CRM_INSTANCE_NAME;
</code>```

Above is the code I am using at that moment, thanks in advance for your help.

Regards

Dr

答:
You need a group by inside your subselect, what you call 'Table E', like so:</p>

```<code>select I.CRM_INSTANCE_NAME,
       C.CUSTOMER_NAME,
       U.USER_NAME,
       ltrim(TO_CHAR(U.CREATED_DATE ,'mm-yyyy'),'0') AS USER_ACTIVATION_DATE,
       ltrim(TO_CHAR(U.LAST_UPDATED_DATE ,'dd-mm-yyyy'),'0') AS LAST_ACTIVITY_DATE,
       COUNT(E.MEETING_NO) AS MEETING,
       COUNT(F.EVENT_TYPE) AS FINALISED

       FROM SBX_USERS U
        LEFT JOIN SBX_CUSTOMERS C on U.CUSTOMER_ID = C.CUSTOMER_ID
        LEFT JOIN SBX_CRM_INSTANCES I on C.CRM_INSTANCE_ID = I.CRM_INSTANCE_ID
        LEFT JOIN SBX_MEETING M on U.USER_ID = M.USER_ID
        LEFT JOIN SBX_EVENTS E ON SOURCE_ID  = M.MEETING_ID
        LEFT JOIN (SELECT EVENT_TYPE,SOURCE_ID,count(*) MEETING_NO FROM SBX_EVENTS WHERE EVENT_TYPE = 'meeting_start' AND EVENT_CREATION_DATE >=add_months(sysdate, -12) GROUP BY EVENT_TYPE,SOURCE_ID) E on E.SOURCE_ID = M.MEETING_ID
        LEFT JOIN (SELECT * FROM SBX_EVENTS WHERE EVENT_TYPE = 'finalize'AND EVENT_CREATION_DATE >=add_months(sysdate, -12)) F on F.SOURCE_ID = M.MEETING_ID

where U.ENABLED_FLAG IN ('Y','E')

group by  I.CRM_INSTANCE_NAME, C.CUSTOMER_NAME, U.USER_NAME, ltrim(TO_CHAR(U.CREATED_DATE ,'mm-yyyy'),'0'), ltrim(TO_CHAR(U.LAST_UPDATED_DATE ,'dd-mm-yyyy'),'0')
order by  I.CRM_INSTANCE_NAME;
</code>```

Body:
I do hope someone can help me with this.

I am doing two count functions on on of my columns, both specified by where the column has a specific text (see below code). On my count for meeting (WHERE EVENT_TYPE = 'meeting_start'), I have found that this can pop up more than once within the same meeting. I need to only count this once per meeting event id and cannot find a way to do this.

select I.CRM_INSTANCE_NAME,
       C.CUSTOMER_NAME,
       U.USER_NAME,
       ltrim(TO_CHAR(U.CREATED_DATE ,'mm-yyyy'),'0') AS USER_ACTIVATION_DATE,
       ltrim(TO_CHAR(U.LAST_UPDATED_DATE ,'dd-mm-yyyy'),'0') AS LAST_ACTIVITY_DATE,
       COUNT(E.EVENT_TYPE) AS MEETING,
       COUNT(F.EVENT_TYPE) AS FINALISED

       FROM SBX_USERS U
        LEFT JOIN SBX_CUSTOMERS C on U.CUSTOMER_ID = C.CUSTOMER_ID
        LEFT JOIN SBX_CRM_INSTANCES I on C.CRM_INSTANCE_ID = I.CRM_INSTANCE_ID
        LEFT JOIN SBX_MEETING M on U.USER_ID = M.USER_ID
        LEFT JOIN SBX_EVENTS E ON SOURCE_ID  = M.MEETING_ID
        LEFT JOIN (SELECT * FROM SBX_EVENTS WHERE EVENT_TYPE = 'meeting_start' AND EVENT_CREATION_DATE >=add_months(sysdate, -12)) E on E.SOURCE_ID = M.MEETING_ID
        LEFT JOIN (SELECT * FROM SBX_EVENTS WHERE EVENT_TYPE = 'finalize'AND EVENT_CREATION_DATE >=add_months(sysdate, -12)) F on F.SOURCE_ID = M.MEETING_ID

where U.ENABLED_FLAG IN ('Y','E')

group by  I.CRM_INSTANCE_NAME, C.CUSTOMER_NAME, U.USER_NAME, ltrim(TO_CHAR(U.CREATED_DATE ,'mm-yyyy'),'0'), ltrim(TO_CHAR(U.LAST_UPDATED_DATE ,'dd-mm-yyyy'),'0')
order by  I.CRM_INSTANCE_NAME;

Above is the code I am using at that moment, thanks in advance for your help.

Regards

Dr

Body:
You need a group by inside your subselect, what you call 'Table E', like so:

select I.CRM_INSTANCE_NAME,
       C.CUSTOMER_NAME,
       U.USER_NAME,
       ltrim(TO_CHAR(U.CREATED_DATE ,'mm-yyyy'),'0') AS USER_ACTIVATION_DATE,
       ltrim(TO_CHAR(U.LAST_UPDATED_DATE ,'dd-mm-yyyy'),'0') AS LAST_ACTIVITY_DATE,
       COUNT(E.MEETING_NO) AS MEETING,
       COUNT(F.EVENT_TYPE) AS FINALISED

       FROM SBX_USERS U
        LEFT JOIN SBX_CUSTOMERS C on U.CUSTOMER_ID = C.CUSTOMER_ID
        LEFT JOIN SBX_CRM_INSTANCES I on C.CRM_INSTANCE_ID = I.CRM_INSTANCE_ID
        LEFT JOIN SBX_MEETING M on U.USER_ID = M.USER_ID
        LEFT JOIN SBX_EVENTS E ON SOURCE_ID  = M.MEETING_ID
        LEFT JOIN (SELECT EVENT_TYPE,SOURCE_ID,count(*) MEETING_NO FROM SBX_EVENTS WHERE EVENT_TYPE = 'meeting_start' AND EVENT_CREATION_DATE >=add_months(sysdate, -12) GROUP BY EVENT_TYPE,SOURCE_ID) E on E.SOURCE_ID = M.MEETING_ID
        LEFT JOIN (SELECT * FROM SBX_EVENTS WHERE EVENT_TYPE = 'finalize'AND EVENT_CREATION_DATE >=add_months(sysdate, -12)) F on F.SOURCE_ID = M.MEETING_ID

where U.ENABLED_FLAG IN ('Y','E')

group by  I.CRM_INSTANCE_NAME, C.CUSTOMER_NAME, U.USER_NAME, ltrim(TO_CHAR(U.CREATED_DATE ,'mm-yyyy'),'0'), ltrim(TO_CHAR(U.LAST_UPDATED_DATE ,'dd-mm-yyyy'),'0')
order by  I.CRM_INSTANCE_NAME;


问:
Load multiple excel files in multiple tables using single connection in SSIS
I am loading multiple excel files into multiple SQL server table.

these excel files are the city, state, etc. Is it possible to create a single flat file connection? currently, I am creating for city and state and for other src. attached the screenshot for better understanding.

答:
If all of the source files are structured exactly the same (number of columns, data types, header rows, etc.), it would be possible to re-use a single flat file connection.

In general, though, the best practice is to create a connection for each file. It makes the package easier to understand in a year or two when you, or someone else, has to open it up again to fix or update it. It will also make it much easier to fix later if one or more of the files ends up changing (new columns, etc.).


问:
spring google oauth2 return no access_token
I'm trying to implement OAuth2 with Google in my Spring Boot application and when I retrieve the Principle object, what I get is given at the last.

Here is the method,that I use to retrieve the user:

```<code>@GetMapping("/user")
    public Principal user(Principal user) {
        return user;
    }
</code>```

In the response I can find no access_token or something, although I find hash of it and id_token.

So how can I retrieve it ?

```<code>{
  "authorities": [
    {
      "authority": "ROLE_USER",
      "attributes": {
        "at_hash": "jVwoBv3AueI07-VJqKN0-A",
        "sub": "108161422188958518395",
        "email_verified": true,
        "iss": "https://accounts.google.com",
        "given_name": "test",
        "locale": "en",
        "nonce": "4ByS7UbIYimkIOJvHUznNQGZ42GxgYh9tCM1K4vKfYc",
        "picture": "https://lh3.googleusercontent.com/a-/AOh14Gh6AHe4iGXQ9XKVgfVV35w31UbSzKs84xUYuNNS=s96-c",
        "aud": [
          "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com"
        ],
        "azp": "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com",
        "name": "test testing",
        "exp": 1590535843,
        "family_name": "testing",
        "iat": 1590532243,
        "email": "test@gamil.com"
      },
      "idToken": {
        "tokenValue": "123",
        "issuedAt": 1590532243,
        "expiresAt": 1590535843,
        "claims": {
          "at_hash": "jVwoBv3AueI07-VJqKN0-A",
          "sub": "108161422188958518395",
          "email_verified": true,
          "iss": "https://accounts.google.com",
          "given_name": "test",
          "locale": "en",
          "nonce": "4ByS7UbIYimkIOJvHUznNQGZ42GxgYh9tCM1K4vKfYc",
          "picture": "https://lh3.googleusercontent.com/a-/AOh14Gh6AHe4iGXQ9XKVgfVV35w31UbSzKs84xUYuNNS=s96-c",
          "aud": [
            "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com"
          ],
          "azp": "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com",
          "name": "test testing",
          "exp": 1590535843,
          "family_name": "testing",
          "iat": 1590532243,
          "email": "test@gamil.com"
        },
        "subject": "108161422188958518395",
        "authorizedParty": "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com",
        "accessTokenHash": "jVwoBv3AueI07-VJqKN0-A",
        "nonce": "4ByS7UbIYimkIOJvHUznNQGZ42GxgYh9tCM1K4vKfYc",
        "audience": [
          "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com"
        ],
        "issuer": "https://accounts.google.com",
        "authenticatedAt": null,
        "authorizationCodeHash": null,
        "authenticationContextClass": null,
        "authenticationMethods": null,
        "address": {
          "formatted": null,
          "streetAddress": null,
          "locality": null,
          "region": null,
          "postalCode": null,
          "country": null
        },
        "locale": "en",
        "zoneInfo": null,
        "fullName": "test testing",
        "familyName": "testing",
        "nickName": null,
        "updatedAt": null,
        "website": null,
        "middleName": null,
        "birthdate": null,
        "gender": null,
        "givenName": "test",
        "email": "test@gamil.com",
        "phoneNumber": null,
        "picture": "https://lh3.googleusercontent.com/a-/AOh14Gh6AHe4iGXQ9XKVgfVV35w31UbSzKs84xUYuNNS=s96-c",
        "profile": null,
        "emailVerified": true,
        "phoneNumberVerified": null,
        "preferredUsername": null
      },
      "userInfo": null
    },
    {
      "authority": "SCOPE_https://www.googleapis.com/auth/userinfo.email"
    },
    {
      "authority": "SCOPE_https://www.googleapis.com/auth/userinfo.profile"
    },
    {
      "authority": "SCOPE_openid"
    }
  ],
  "details": {
    "remoteAddress": "0:0:0:0:0:0:0:1",
    "sessionId": "D3DCD92FB24A25CFC8B64160DD5C155B"
  },
  "authenticated": true,
  "principal": {
    "authorities": [
      {
        "authority": "ROLE_USER",
        "attributes": {
          "at_hash": "jVwoBv3AueI07-VJqKN0-A",
          "sub": "108161422188958518395",
          "email_verified": true,
          "iss": "https://accounts.google.com",
          "given_name": "test",
          "locale": "en",
          "nonce": "4ByS7UbIYimkIOJvHUznNQGZ42GxgYh9tCM1K4vKfYc",
          "picture": "https://lh3.googleusercontent.com/a-/AOh14Gh6AHe4iGXQ9XKVgfVV35w31UbSzKs84xUYuNNS=s96-c",
          "aud": [
            "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com"
          ],
          "azp": "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com",
          "name": "test testing",
          "exp": 1590535843,
          "family_name": "testing",
          "iat": 1590532243,
          "email": "test@gamil.com"
        },
        "idToken": {
          "tokenValue": "123",
          "issuedAt": 1590532243,
          "expiresAt": 1590535843,
          "claims": {
            "at_hash": "jVwoBv3AueI07-VJqKN0-A",
            "sub": "108161422188958518395",
            "email_verified": true,
            "iss": "https://accounts.google.com",
            "given_name": "test",
            "locale": "en",
            "nonce": "4ByS7UbIYimkIOJvHUznNQGZ42GxgYh9tCM1K4vKfYc",
            "picture": "https://lh3.googleusercontent.com/a-/AOh14Gh6AHe4iGXQ9XKVgfVV35w31UbSzKs84xUYuNNS=s96-c",
            "aud": [
              "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com"
            ],
            "azp": "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com",
            "name": "test testing",
            "exp": 1590535843,
            "family_name": "testing",
            "iat": 1590532243,
            "email": "test@gamil.com"
          },
          "subject": "108161422188958518395",
          "authorizedParty": "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com",
          "accessTokenHash": "jVwoBv3AueI07-VJqKN0-A",
          "nonce": "4ByS7UbIYimkIOJvHUznNQGZ42GxgYh9tCM1K4vKfYc",
          "audience": [
            "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com"
          ],
          "issuer": "https://accounts.google.com",
          "authenticatedAt": null,
          "authorizationCodeHash": null,
          "authenticationContextClass": null,
          "authenticationMethods": null,
          "address": {
            "formatted": null,
            "streetAddress": null,
            "locality": null,
            "region": null,
            "postalCode": null,
            "country": null
          },
          "locale": "en",
          "zoneInfo": null,
          "fullName": "test testing",
          "familyName": "testing",
          "nickName": null,
          "updatedAt": null,
          "website": null,
          "middleName": null,
          "birthdate": null,
          "gender": null,
          "givenName": "test",
          "email": "test@gamil.com",
          "phoneNumber": null,
          "picture": "https://lh3.googleusercontent.com/a-/AOh14Gh6AHe4iGXQ9XKVgfVV35w31UbSzKs84xUYuNNS=s96-c",
          "profile": null,
          "emailVerified": true,
          "phoneNumberVerified": null,
          "preferredUsername": null
        },
        "userInfo": null
      },
      {
        "authority": "SCOPE_https://www.googleapis.com/auth/userinfo.email"
      },
      {
        "authority": "SCOPE_https://www.googleapis.com/auth/userinfo.profile"
      },
      {
        "authority": "SCOPE_openid"
      }
    ],
    "attributes": {
      "at_hash": "jVwoBv3AueI07-VJqKN0-A",
      "sub": "108161422188958518395",
      "email_verified": true,
      "iss": "https://accounts.google.com",
      "given_name": "test",
      "locale": "en",
      "nonce": "4ByS7UbIYimkIOJvHUznNQGZ42GxgYh9tCM1K4vKfYc",
      "picture": "https://lh3.googleusercontent.com/a-/AOh14Gh6AHe4iGXQ9XKVgfVV35w31UbSzKs84xUYuNNS=s96-c",
      "aud": [
        "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com"
      ],
      "azp": "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com",
      "name": "test testing",
      "exp": 1590535843,
      "family_name": "testing",
      "iat": 1590532243,
      "email": "test@gamil.com"
    },
    "idToken": {
      "tokenValue": "123",
      "issuedAt": 1590532243,
      "expiresAt": 1590535843,
      "claims": {
        "at_hash": "jVwoBv3AueI07-VJqKN0-A",
        "sub": "108161422188958518395",
        "email_verified": true,
        "iss": "https://accounts.google.com",
        "given_name": "test",
        "locale": "en",
        "nonce": "4ByS7UbIYimkIOJvHUznNQGZ42GxgYh9tCM1K4vKfYc",
        "picture": "https://lh3.googleusercontent.com/a-/AOh14Gh6AHe4iGXQ9XKVgfVV35w31UbSzKs84xUYuNNS=s96-c",
        "aud": [
          "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com"
        ],
        "azp": "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com",
        "name": "test testing",
        "exp": 1590535843,
        "family_name": "testing",
        "iat": 1590532243,
        "email": "test@gamil.com"
      },
      "subject": "108161422188958518395",
      "authorizedParty": "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com",
      "accessTokenHash": "jVwoBv3AueI07-VJqKN0-A",
      "nonce": "4ByS7UbIYimkIOJvHUznNQGZ42GxgYh9tCM1K4vKfYc",
      "audience": [
        "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com"
      ],
      "issuer": "https://accounts.google.com",
      "authenticatedAt": null,
      "authorizationCodeHash": null,
      "authenticationContextClass": null,
      "authenticationMethods": null,
      "address": {
        "formatted": null,
        "streetAddress": null,
        "locality": null,
        "region": null,
        "postalCode": null,
        "country": null
      },
      "locale": "en",
      "zoneInfo": null,
      "fullName": "test testing",
      "familyName": "testing",
      "nickName": null,
      "updatedAt": null,
      "website": null,
      "middleName": null,
      "birthdate": null,
      "gender": null,
      "givenName": "test",
      "email": "test@gamil.com",
      "phoneNumber": null,
      "picture": "https://lh3.googleusercontent.com/a-/AOh14Gh6AHe4iGXQ9XKVgfVV35w31UbSzKs84xUYuNNS=s96-c",
      "profile": null,
      "emailVerified": true,
      "phoneNumberVerified": null,
      "preferredUsername": null
    },
    "userInfo": null,
    "claims": {
      "at_hash": "jVwoBv3AueI07-VJqKN0-A",
      "sub": "108161422188958518395",
      "email_verified": true,
      "iss": "https://accounts.google.com",
      "given_name": "test",
      "locale": "en",
      "nonce": "4ByS7UbIYimkIOJvHUznNQGZ42GxgYh9tCM1K4vKfYc",
      "picture": "https://lh3.googleusercontent.com/a-/AOh14Gh6AHe4iGXQ9XKVgfVV35w31UbSzKs84xUYuNNS=s96-c",
      "aud": [
        "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com"
      ],
      "azp": "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com",
      "name": "test testing",
      "exp": 1590535843,
      "family_name": "testing",
      "iat": 1590532243,
      "email": "test@gamil.com"
    },
    "name": "108161422188958518395",
    "subject": "108161422188958518395",
    "expiresAt": 1590535843,
    "authorizedParty": "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com",
    "accessTokenHash": "jVwoBv3AueI07-VJqKN0-A",
    "nonce": "4ByS7UbIYimkIOJvHUznNQGZ42GxgYh9tCM1K4vKfYc",
    "audience": [
      "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com"
    ],
    "issuer": "https://accounts.google.com",
    "issuedAt": 1590532243,
    "authenticatedAt": null,
    "authorizationCodeHash": null,
    "authenticationContextClass": null,
    "authenticationMethods": null,
    "address": {
      "formatted": null,
      "streetAddress": null,
      "locality": null,
      "region": null,
      "postalCode": null,
      "country": null
    },
    "locale": "en",
    "zoneInfo": null,
    "fullName": "test testing",
    "familyName": "testing",
    "nickName": null,
    "updatedAt": null,
    "website": null,
    "middleName": null,
    "birthdate": null,
    "gender": null,
    "givenName": "test",
    "email": "test@gamil.com",
    "phoneNumber": null,
    "picture": "https://lh3.googleusercontent.com/a-/AOh14Gh6AHe4iGXQ9XKVgfVV35w31UbSzKs84xUYuNNS=s96-c",
    "profile": null,
    "emailVerified": true,
    "phoneNumberVerified": null,
    "preferredUsername": null
  },
  "authorizedClientRegistrationId": "google",
  "credentials": "",
  "name": "108161422188958518395"
}
</code>```

答:
Inside Controller :

```<code>@Autowired
private GoogleOAuth2 googleOAuth2;
...
@GetMapping("/token")
    public String token() {
        System.out.println(googleOAuth2.getAccessToken());
        return googleOAuth2.getAccessToken();
}
...
</code>```

Google OAuth2 class:

```<code>public class GoogleOAuth2 extends ApiBinding {

    private String accessToken;

    public GoogleOAuth2(String accessToken) {
        super(accessToken);
        this.accessToken=accessToken;
    }

    public String getAccessToken() {
        return accessToken;
    }
}
</code>```

And configure OAuth2 with this class. @Configuration annotation for class,@Bean,@RequestScope for configuring method.

Body:
I'm trying to implement OAuth2 with Google in my Spring Boot application and when I retrieve the Principle object, what I get is given at the last.

Here is the method,that I use to retrieve the user:

@GetMapping("/user")
    public Principal user(Principal user) {
        return user;
    }

In the response I can find no access_token or something, although I find hash of it and id_token.

So how can I retrieve it ?

{
  "authorities": [
    {
      "authority": "ROLE_USER",
      "attributes": {
        "at_hash": "jVwoBv3AueI07-VJqKN0-A",
        "sub": "108161422188958518395",
        "email_verified": true,
        "iss": "https://accounts.google.com",
        "given_name": "test",
        "locale": "en",
        "nonce": "4ByS7UbIYimkIOJvHUznNQGZ42GxgYh9tCM1K4vKfYc",
        "picture": "https://lh3.googleusercontent.com/a-/AOh14Gh6AHe4iGXQ9XKVgfVV35w31UbSzKs84xUYuNNS=s96-c",
        "aud": [
          "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com"
        ],
        "azp": "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com",
        "name": "test testing",
        "exp": 1590535843,
        "family_name": "testing",
        "iat": 1590532243,
        "email": "test@gamil.com"
      },
      "idToken": {
        "tokenValue": "123",
        "issuedAt": 1590532243,
        "expiresAt": 1590535843,
        "claims": {
          "at_hash": "jVwoBv3AueI07-VJqKN0-A",
          "sub": "108161422188958518395",
          "email_verified": true,
          "iss": "https://accounts.google.com",
          "given_name": "test",
          "locale": "en",
          "nonce": "4ByS7UbIYimkIOJvHUznNQGZ42GxgYh9tCM1K4vKfYc",
          "picture": "https://lh3.googleusercontent.com/a-/AOh14Gh6AHe4iGXQ9XKVgfVV35w31UbSzKs84xUYuNNS=s96-c",
          "aud": [
            "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com"
          ],
          "azp": "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com",
          "name": "test testing",
          "exp": 1590535843,
          "family_name": "testing",
          "iat": 1590532243,
          "email": "test@gamil.com"
        },
        "subject": "108161422188958518395",
        "authorizedParty": "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com",
        "accessTokenHash": "jVwoBv3AueI07-VJqKN0-A",
        "nonce": "4ByS7UbIYimkIOJvHUznNQGZ42GxgYh9tCM1K4vKfYc",
        "audience": [
          "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com"
        ],
        "issuer": "https://accounts.google.com",
        "authenticatedAt": null,
        "authorizationCodeHash": null,
        "authenticationContextClass": null,
        "authenticationMethods": null,
        "address": {
          "formatted": null,
          "streetAddress": null,
          "locality": null,
          "region": null,
          "postalCode": null,
          "country": null
        },
        "locale": "en",
        "zoneInfo": null,
        "fullName": "test testing",
        "familyName": "testing",
        "nickName": null,
        "updatedAt": null,
        "website": null,
        "middleName": null,
        "birthdate": null,
        "gender": null,
        "givenName": "test",
        "email": "test@gamil.com",
        "phoneNumber": null,
        "picture": "https://lh3.googleusercontent.com/a-/AOh14Gh6AHe4iGXQ9XKVgfVV35w31UbSzKs84xUYuNNS=s96-c",
        "profile": null,
        "emailVerified": true,
        "phoneNumberVerified": null,
        "preferredUsername": null
      },
      "userInfo": null
    },
    {
      "authority": "SCOPE_https://www.googleapis.com/auth/userinfo.email"
    },
    {
      "authority": "SCOPE_https://www.googleapis.com/auth/userinfo.profile"
    },
    {
      "authority": "SCOPE_openid"
    }
  ],
  "details": {
    "remoteAddress": "0:0:0:0:0:0:0:1",
    "sessionId": "D3DCD92FB24A25CFC8B64160DD5C155B"
  },
  "authenticated": true,
  "principal": {
    "authorities": [
      {
        "authority": "ROLE_USER",
        "attributes": {
          "at_hash": "jVwoBv3AueI07-VJqKN0-A",
          "sub": "108161422188958518395",
          "email_verified": true,
          "iss": "https://accounts.google.com",
          "given_name": "test",
          "locale": "en",
          "nonce": "4ByS7UbIYimkIOJvHUznNQGZ42GxgYh9tCM1K4vKfYc",
          "picture": "https://lh3.googleusercontent.com/a-/AOh14Gh6AHe4iGXQ9XKVgfVV35w31UbSzKs84xUYuNNS=s96-c",
          "aud": [
            "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com"
          ],
          "azp": "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com",
          "name": "test testing",
          "exp": 1590535843,
          "family_name": "testing",
          "iat": 1590532243,
          "email": "test@gamil.com"
        },
        "idToken": {
          "tokenValue": "123",
          "issuedAt": 1590532243,
          "expiresAt": 1590535843,
          "claims": {
            "at_hash": "jVwoBv3AueI07-VJqKN0-A",
            "sub": "108161422188958518395",
            "email_verified": true,
            "iss": "https://accounts.google.com",
            "given_name": "test",
            "locale": "en",
            "nonce": "4ByS7UbIYimkIOJvHUznNQGZ42GxgYh9tCM1K4vKfYc",
            "picture": "https://lh3.googleusercontent.com/a-/AOh14Gh6AHe4iGXQ9XKVgfVV35w31UbSzKs84xUYuNNS=s96-c",
            "aud": [
              "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com"
            ],
            "azp": "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com",
            "name": "test testing",
            "exp": 1590535843,
            "family_name": "testing",
            "iat": 1590532243,
            "email": "test@gamil.com"
          },
          "subject": "108161422188958518395",
          "authorizedParty": "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com",
          "accessTokenHash": "jVwoBv3AueI07-VJqKN0-A",
          "nonce": "4ByS7UbIYimkIOJvHUznNQGZ42GxgYh9tCM1K4vKfYc",
          "audience": [
            "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com"
          ],
          "issuer": "https://accounts.google.com",
          "authenticatedAt": null,
          "authorizationCodeHash": null,
          "authenticationContextClass": null,
          "authenticationMethods": null,
          "address": {
            "formatted": null,
            "streetAddress": null,
            "locality": null,
            "region": null,
            "postalCode": null,
            "country": null
          },
          "locale": "en",
          "zoneInfo": null,
          "fullName": "test testing",
          "familyName": "testing",
          "nickName": null,
          "updatedAt": null,
          "website": null,
          "middleName": null,
          "birthdate": null,
          "gender": null,
          "givenName": "test",
          "email": "test@gamil.com",
          "phoneNumber": null,
          "picture": "https://lh3.googleusercontent.com/a-/AOh14Gh6AHe4iGXQ9XKVgfVV35w31UbSzKs84xUYuNNS=s96-c",
          "profile": null,
          "emailVerified": true,
          "phoneNumberVerified": null,
          "preferredUsername": null
        },
        "userInfo": null
      },
      {
        "authority": "SCOPE_https://www.googleapis.com/auth/userinfo.email"
      },
      {
        "authority": "SCOPE_https://www.googleapis.com/auth/userinfo.profile"
      },
      {
        "authority": "SCOPE_openid"
      }
    ],
    "attributes": {
      "at_hash": "jVwoBv3AueI07-VJqKN0-A",
      "sub": "108161422188958518395",
      "email_verified": true,
      "iss": "https://accounts.google.com",
      "given_name": "test",
      "locale": "en",
      "nonce": "4ByS7UbIYimkIOJvHUznNQGZ42GxgYh9tCM1K4vKfYc",
      "picture": "https://lh3.googleusercontent.com/a-/AOh14Gh6AHe4iGXQ9XKVgfVV35w31UbSzKs84xUYuNNS=s96-c",
      "aud": [
        "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com"
      ],
      "azp": "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com",
      "name": "test testing",
      "exp": 1590535843,
      "family_name": "testing",
      "iat": 1590532243,
      "email": "test@gamil.com"
    },
    "idToken": {
      "tokenValue": "123",
      "issuedAt": 1590532243,
      "expiresAt": 1590535843,
      "claims": {
        "at_hash": "jVwoBv3AueI07-VJqKN0-A",
        "sub": "108161422188958518395",
        "email_verified": true,
        "iss": "https://accounts.google.com",
        "given_name": "test",
        "locale": "en",
        "nonce": "4ByS7UbIYimkIOJvHUznNQGZ42GxgYh9tCM1K4vKfYc",
        "picture": "https://lh3.googleusercontent.com/a-/AOh14Gh6AHe4iGXQ9XKVgfVV35w31UbSzKs84xUYuNNS=s96-c",
        "aud": [
          "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com"
        ],
        "azp": "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com",
        "name": "test testing",
        "exp": 1590535843,
        "family_name": "testing",
        "iat": 1590532243,
        "email": "test@gamil.com"
      },
      "subject": "108161422188958518395",
      "authorizedParty": "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com",
      "accessTokenHash": "jVwoBv3AueI07-VJqKN0-A",
      "nonce": "4ByS7UbIYimkIOJvHUznNQGZ42GxgYh9tCM1K4vKfYc",
      "audience": [
        "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com"
      ],
      "issuer": "https://accounts.google.com",
      "authenticatedAt": null,
      "authorizationCodeHash": null,
      "authenticationContextClass": null,
      "authenticationMethods": null,
      "address": {
        "formatted": null,
        "streetAddress": null,
        "locality": null,
        "region": null,
        "postalCode": null,
        "country": null
      },
      "locale": "en",
      "zoneInfo": null,
      "fullName": "test testing",
      "familyName": "testing",
      "nickName": null,
      "updatedAt": null,
      "website": null,
      "middleName": null,
      "birthdate": null,
      "gender": null,
      "givenName": "test",
      "email": "test@gamil.com",
      "phoneNumber": null,
      "picture": "https://lh3.googleusercontent.com/a-/AOh14Gh6AHe4iGXQ9XKVgfVV35w31UbSzKs84xUYuNNS=s96-c",
      "profile": null,
      "emailVerified": true,
      "phoneNumberVerified": null,
      "preferredUsername": null
    },
    "userInfo": null,
    "claims": {
      "at_hash": "jVwoBv3AueI07-VJqKN0-A",
      "sub": "108161422188958518395",
      "email_verified": true,
      "iss": "https://accounts.google.com",
      "given_name": "test",
      "locale": "en",
      "nonce": "4ByS7UbIYimkIOJvHUznNQGZ42GxgYh9tCM1K4vKfYc",
      "picture": "https://lh3.googleusercontent.com/a-/AOh14Gh6AHe4iGXQ9XKVgfVV35w31UbSzKs84xUYuNNS=s96-c",
      "aud": [
        "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com"
      ],
      "azp": "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com",
      "name": "test testing",
      "exp": 1590535843,
      "family_name": "testing",
      "iat": 1590532243,
      "email": "test@gamil.com"
    },
    "name": "108161422188958518395",
    "subject": "108161422188958518395",
    "expiresAt": 1590535843,
    "authorizedParty": "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com",
    "accessTokenHash": "jVwoBv3AueI07-VJqKN0-A",
    "nonce": "4ByS7UbIYimkIOJvHUznNQGZ42GxgYh9tCM1K4vKfYc",
    "audience": [
      "693417856482-slejtj57gb2nrcehe82ih45o2vdhkj5t.apps.googleusercontent.com"
    ],
    "issuer": "https://accounts.google.com",
    "issuedAt": 1590532243,
    "authenticatedAt": null,
    "authorizationCodeHash": null,
    "authenticationContextClass": null,
    "authenticationMethods": null,
    "address": {
      "formatted": null,
      "streetAddress": null,
      "locality": null,
      "region": null,
      "postalCode": null,
      "country": null
    },
    "locale": "en",
    "zoneInfo": null,
    "fullName": "test testing",
    "familyName": "testing",
    "nickName": null,
    "updatedAt": null,
    "website": null,
    "middleName": null,
    "birthdate": null,
    "gender": null,
    "givenName": "test",
    "email": "test@gamil.com",
    "phoneNumber": null,
    "picture": "https://lh3.googleusercontent.com/a-/AOh14Gh6AHe4iGXQ9XKVgfVV35w31UbSzKs84xUYuNNS=s96-c",
    "profile": null,
    "emailVerified": true,
    "phoneNumberVerified": null,
    "preferredUsername": null
  },
  "authorizedClientRegistrationId": "google",
  "credentials": "",
  "name": "108161422188958518395"
}

Body:
Inside Controller :

@Autowired
private GoogleOAuth2 googleOAuth2;
...
@GetMapping("/token")
    public String token() {
        System.out.println(googleOAuth2.getAccessToken());
        return googleOAuth2.getAccessToken();
}
...

Google OAuth2 class:

public class GoogleOAuth2 extends ApiBinding {

    private String accessToken;

    public GoogleOAuth2(String accessToken) {
        super(accessToken);
        this.accessToken=accessToken;
    }

    public String getAccessToken() {
        return accessToken;
    }
}

And configure OAuth2 with this class. @Configuration annotation for class,@Bean,@RequestScope for configuring method.


问:
Load remote form in rails 3 with javascript
I am new in rails and javascript. This may be a very simple question but I am still unable to figure it out.
The goal is that, I have a link to button that when clicked should load a address form on the same page. The link to code is

<%= link_to "Add Address", new_address_path, {:class => "button"}, {:remote => true} %>

The address file "addresses/new.html.erb" is:

```<code><div id="newaddr">
  <%= render :partial => 'form', :local => @address %>
</div>
</code>```

The form is "addresses/_form.html.erb":

```<code><%= form_for(@address, :remote => true) do |f| %>
  <%= render 'shared/error_messages', :object => f.object %>
  <%= f.text_field :line_1 %>
  <%= f.submit %>
<% end %>
</code>```

The javascript file "addresses/new.js.erb":

```<code>$('#newaddr').append("<%= escape_javaScript(render 'form', :local => @address) %>");
</code>```

The new method in addresses_controller file is:

```<code>def new
  @title = "Add Address"
  @address = Address.new
  respond_to do |format|
    format.js
  end
end
</code>```

But it doesn't work. Is there anything I am missing here?

Thanks!

答:
Change your new.js.erb file:</p>

```<code>$('#newaddr').append("#{escape_javascript(render :partial => 'form', :local => @address)}");
</code>```

Body:
I am new in rails and javascript. This may be a very simple question but I am still unable to figure it out.
The goal is that, I have a link to button that when clicked should load a address form on the same page. The link to code is

<%= link_to "Add Address", new_address_path, {:class => "button"}, {:remote => true} %>

The address file "addresses/new.html.erb" is:

  <%= render :partial => 'form', :local => @address %>

The form is "addresses/_form.html.erb":

<%= form_for(@address, :remote => true) do |f| %>
  <%= render 'shared/error_messages', :object => f.object %>
  <%= f.text_field :line_1 %>
  <%= f.submit %>
<% end %>

The javascript file "addresses/new.js.erb":

$('#newaddr').append("<%= escape_javaScript(render 'form', :local => @address) %>");

The new method in addresses_controller file is:

def new
  @title = "Add Address"
  @address = Address.new
  respond_to do |format|
    format.js
  end
end

But it doesn't work. Is there anything I am missing here?

Thanks!

Body:
Change your new.js.erb file:

$('#newaddr').append("#{escape_javascript(render :partial => 'form', :local => @address)}");


问:
Android viewmodel unit test with livedata
I am unit testing my viewmodel and I always keep getting NullPointerException.

Here is my viewmodel code -

```<code>class LoginViewModel(private val myUseCase: MyUseCase) :BaseViewModel() {

    private val viewState = LoginViewState()

    fun onLoginClicked() =
        Transformations.map(
            myUseCase.performUseCaseAction(
                MyAction.LoginUser(
                    email,password)
            )
        ) {
            when (it) {
                is MyResult.Loading -> viewState.copy(loading = true)
                is MyResult.UserLoggedIn -> viewState.copy(
                    loading = false,
                    userLoggedIn = true
                )
                is MyResult.Error -> viewState.copy(loading = false, error = it.error)
            }
        }
}
</code>```

Here is the MyUseCase interface code -

```<code>interface MyUseCase {

    fun performUseCaseAction(action: MyAction): LiveData<MyResult>
}
</code>```

Here is the unit test for the same -

```<code>@RunWith(MockitoJUnitRunner::class)
class LoginViewModelTest {

    @get:Rule
    val instantExecutorRule = InstantTaskExecutorRule()

    private lateinit var viewModel: LoginViewModel

    @Mock
    private lateinit var myUseCase: MyUseCase

    @Mock
    private lateinit var observer: Observer<LoginViewState>

    @Before
    fun setUp() {
        MockitoAnnotations.initMocks(this)
        viewModel = LoginViewModel(useCase)
    }

    @Test
    fun login_loginClicked_userLoggedInExpected() {
        //Given
        val viewState = LoginViewState()

        //When
        val liveData1 = MutableLiveData<MyResult>()
        `when`(useCase.performUseCaseAction(
            MyAction.LoginUser("email","password")
        )).thenReturn(liveData1)
        liveData1.postValue(MyResult.UserLoggedIn)

        viewModel.onLoginClicked().observeForever(observer)

        //Then
        verify(observer).onChanged(viewState.copy(loading = true))
        verify(observer).onChanged(viewState.copy(loading = false, userLoggedIn = true))
    }
}
</code>```

Here is the output I get -

```<code>java.lang.NullPointerException
at androidx.lifecycle.MediatorLiveData$Source.plug(MediatorLiveData.java:141)
at androidx.lifecycle.MediatorLiveData.onActive(MediatorLiveData.java:118)
at androidx.lifecycle.LiveData$ObserverWrapper.activeStateChanged(LiveData.java:437)
at androidx.lifecycle.LiveData.observeForever(LiveData.java:232)
at com.client.personaldiary.view.viewmodel.LoginViewModelTest.onLoginClicked(LoginViewModelTest.kt:88)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.mockito.internal.runners.DefaultInternalRunner$1$1.evaluate(DefaultInternalRunner.java:44)
at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.mockito.internal.runners.DefaultInternalRunner$1.run(DefaultInternalRunner.java:74)
at org.mockito.internal.runners.DefaultInternalRunner.run(DefaultInternalRunner.java:80)
at org.mockito.internal.runners.StrictRunner.run(StrictRunner.java:39)
at org.mockito.junit.MockitoJUnitRunner.run(MockitoJUnitRunner.java:163)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
</code>```

答:
It seems about stubbing(when/thenReturn) timing problem.
This is not a problem for most sequential statement,
but when stubbing LiveData, it is tricky since

When your ViewModel and mocked MyUseCase are set up,
mocked MyUseCase is already evaluated.
However, in test method,

```<code>`when`(useCase.performUseCaseAction(
            MyAction.LoginUser("email","password")
        )).thenReturn(liveData1)
</code>```

below method is not affected from above stubbing method,

```<code>viewModel.onLoginClicked()
</code>```

so return null, therefore 'observeForever` raise the NPE.

The good practice of my thinking is that
1. ViewModel's initialization is after stubbing

```<code>`when`()...
viewModel = LoginViewModel(useCase)
</code>```

or using liveData coroutine builder in your source code refer to:
https://github.com/android/architecture-components-samples/tree/master/LiveDataSample

```<code>liveData { emitSource(....map { ... }) }
</code>```

Body:
I am unit testing my viewmodel and I always keep getting NullPointerException.

Here is my viewmodel code -

class LoginViewModel(private val myUseCase: MyUseCase) :BaseViewModel() {

    private val viewState = LoginViewState()

    fun onLoginClicked() =
        Transformations.map(
            myUseCase.performUseCaseAction(
                MyAction.LoginUser(
                    email,password)
            )
        ) {
            when (it) {
                is MyResult.Loading -> viewState.copy(loading = true)
                is MyResult.UserLoggedIn -> viewState.copy(
                    loading = false,
                    userLoggedIn = true
                )
                is MyResult.Error -> viewState.copy(loading = false, error = it.error)
            }
        }
}

Here is the MyUseCase interface code -

interface MyUseCase {

    fun performUseCaseAction(action: MyAction): LiveData<MyResult>
}

Here is the unit test for the same -

@RunWith(MockitoJUnitRunner::class)
class LoginViewModelTest {

    @get:Rule
    val instantExecutorRule = InstantTaskExecutorRule()

    private lateinit var viewModel: LoginViewModel

    @Mock
    private lateinit var myUseCase: MyUseCase

    @Mock
    private lateinit var observer: Observer<LoginViewState>

    @Before
    fun setUp() {
        MockitoAnnotations.initMocks(this)
        viewModel = LoginViewModel(useCase)
    }

    @Test
    fun login_loginClicked_userLoggedInExpected() {
        //Given
        val viewState = LoginViewState()

        //When
        val liveData1 = MutableLiveData<MyResult>()
        `when`(useCase.performUseCaseAction(
            MyAction.LoginUser("email","password")
        )).thenReturn(liveData1)
        liveData1.postValue(MyResult.UserLoggedIn)

        viewModel.onLoginClicked().observeForever(observer)

        //Then
        verify(observer).onChanged(viewState.copy(loading = true))
        verify(observer).onChanged(viewState.copy(loading = false, userLoggedIn = true))
    }
}

Here is the output I get -

java.lang.NullPointerException
at androidx.lifecycle.MediatorLiveData$Source.plug(MediatorLiveData.java:141)
at androidx.lifecycle.MediatorLiveData.onActive(MediatorLiveData.java:118)
at androidx.lifecycle.LiveData$ObserverWrapper.activeStateChanged(LiveData.java:437)
at androidx.lifecycle.LiveData.observeForever(LiveData.java:232)
at com.client.personaldiary.view.viewmodel.LoginViewModelTest.onLoginClicked(LoginViewModelTest.kt:88)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.mockito.internal.runners.DefaultInternalRunner$1$1.evaluate(DefaultInternalRunner.java:44)
at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.mockito.internal.runners.DefaultInternalRunner$1.run(DefaultInternalRunner.java:74)
at org.mockito.internal.runners.DefaultInternalRunner.run(DefaultInternalRunner.java:80)
at org.mockito.internal.runners.StrictRunner.run(StrictRunner.java:39)
at org.mockito.junit.MockitoJUnitRunner.run(MockitoJUnitRunner.java:163)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Body:
It seems about stubbing(when/thenReturn) timing problem.
This is not a problem for most sequential statement,
but when stubbing LiveData, it is tricky since

When your ViewModel and mocked MyUseCase are set up,
mocked MyUseCase is already evaluated.
However, in test method,

`when`(useCase.performUseCaseAction(
            MyAction.LoginUser("email","password")
        )).thenReturn(liveData1)

below method is not affected from above stubbing method,

viewModel.onLoginClicked()

so return null, therefore 'observeForever` raise the NPE.

The good practice of my thinking is that
1. ViewModel's initialization is after stubbing

`when`()...
viewModel = LoginViewModel(useCase)

or using liveData coroutine builder in your source code refer to:
https://github.com/android/architecture-components-samples/tree/master/LiveDataSample

liveData { emitSource(....map { ... }) }


问:
No installed Cordapp and localhost:1009/api returns a 404 via Http
I'm trying to expose an API for a CorDapp and the functions are not displaying.
I'm starting the nodes with the command ./runnodes. The Building process is successful. WebserverPluginRegistry is also implemented.
But if I try to connect to the Webserver with http://localhost:10009/ I get the Message "No  installed custom Cordapp".  I should only get this Message, if the Plugin is empty. But the Plugin is not empty!

If I try to Connect the node webserver endpoints with http://localhost:10009/api/XXX/me I get the Error Message:  HTTP ERROR 404 Problem accessing api/XXX/me  Reason: Not found

I know this is very vague but I cannot find any errors that indicate a specific area. Any help would be appreciated.

TransactionAPI.kt

package com.YYY.api

import ……

val SERVICE_NAMES = listOf("Notary", "Network Map Service")

// This API is accessible from /api/XXX. All paths specified below are relative to it.
@Path("XXX")
class TransactionApi(private val rpcOps: CordaRPCOps) {
    private val myLegalName: CordaX500Name = rpcOps.nodeInfo().legalIdentities.first().name

    companion object {
        private val logger: Logger = loggerFor<TransactionApi>()
    }

    /**
     * Returns the node's name.
     */
    @GET
    @Path("me")
    @Produces(MediaType.APPLICATION_JSON)
    fun whoami() = mapOf("me" to myLegalName)

    /**
     * Returns all parties registered with the [NetworkMapService]. These names can be used to look up identities
     * using the [IdentityService].
     */
    @GET
    @Path("peers")
    @Produces(MediaType.APPLICATION_JSON)
    fun getPeers(): Map<String, List<CordaX500Name>> {
        val nodeInfo = rpcOps.networkMapSnapshot()
        return mapOf("peers" to nodeInfo
                .map { it.legalIdentities.first().name }
                //filter out myself, notary and eventual network map started by driver
                .filter { it.organisation !in (SERVICE_NAMES + myLegalName.organisation)})
    }

    /**
     * Displays all XYZ that exist in the node's vault.
     */
    @GET
    @Path("XYZ")
    @Produces(MediaType.APPLICATION_JSON)
    fun getXYZ() = rpcOps.vaultQueryBy<XYZ>().states

````
</div>
</div>
</p>

<p>WebserverPluginRegistry</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code># Register a ServiceLoader service extending from net.corda.webserver.services.WebServerPluginRegistry.
com.XXX.plugin.TransactionPlugin</code>```

TransactionPlugin

package com.XXX.plugin

import com.XXX.api.TransactionApi
import net.corda.core.messaging.CordaRPCOps
import net.corda.webserver.services.WebServerPluginRegistry
import java.util.function.Function

class TransactionPlugin : WebServerPluginRegistry {

    // A list of classes that exposes web APIs.
    override val webApis:   List<Function<CordaRPCOps, out Any>> = listOf(Function(::TransactionApi))

    // A list of directories in the resources directory that will be served by Jetty under /web.
    override val staticServeDirs = mapOf(
            "XXX" to javaClass.classLoader.getResource("XXXWeb").toExternalForm()
    )

}```

答:
This is a duplicated question. You can find the answer in this question.

For any users prior to 2020, the Corda webserver is deprecated.

We now recommend users to use Spring boot. You can check this project as an example.

Body:
I'm trying to expose an API for a CorDapp and the functions are not displaying.
I'm starting the nodes with the command ./runnodes. The Building process is successful. WebserverPluginRegistry is also implemented.
But if I try to connect to the Webserver with http://localhost:10009/ I get the Message "No  installed custom Cordapp".  I should only get this Message, if the Plugin is empty. But the Plugin is not empty!

If I try to Connect the node webserver endpoints with http://localhost:10009/api/XXX/me I get the Error Message:  HTTP ERROR 404 Problem accessing api/XXX/me  Reason: Not found

I know this is very vague but I cannot find any errors that indicate a specific area. Any help would be appreciated.

TransactionAPI.kt

package com.YYY.api

import ……

val SERVICE_NAMES = listOf("Notary", "Network Map Service")

// This API is accessible from /api/XXX. All paths specified below are relative to it.
@Path("XXX")
class TransactionApi(private val rpcOps: CordaRPCOps) {
    private val myLegalName: CordaX500Name = rpcOps.nodeInfo().legalIdentities.first().name

    companion object {
        private val logger: Logger = loggerFor<TransactionApi>()
    }

    /**
     * Returns the node's name.
     */
    @GET
    @Path("me")
    @Produces(MediaType.APPLICATION_JSON)
    fun whoami() = mapOf("me" to myLegalName)

    /**
     * Returns all parties registered with the [NetworkMapService]. These names can be used to look up identities
     * using the [IdentityService].
     */
    @GET
    @Path("peers")
    @Produces(MediaType.APPLICATION_JSON)
    fun getPeers(): Map<String, List<CordaX500Name>> {
        val nodeInfo = rpcOps.networkMapSnapshot()
        return mapOf("peers" to nodeInfo
                .map { it.legalIdentities.first().name }
                //filter out myself, notary and eventual network map started by driver
                .filter { it.organisation !in (SERVICE_NAMES + myLegalName.organisation)})
    }

    /**
     * Displays all XYZ that exist in the node's vault.
     */
    @GET
    @Path("XYZ")
    @Produces(MediaType.APPLICATION_JSON)
    fun getXYZ() = rpcOps.vaultQueryBy<XYZ>().states

`

WebserverPluginRegistry

# Register a ServiceLoader service extending from net.corda.webserver.services.WebServerPluginRegistry.
com.XXX.plugin.TransactionPlugin

TransactionPlugin

package com.XXX.plugin

import com.XXX.api.TransactionApi
import net.corda.core.messaging.CordaRPCOps
import net.corda.webserver.services.WebServerPluginRegistry
import java.util.function.Function

class TransactionPlugin : WebServerPluginRegistry {

    // A list of classes that exposes web APIs.
    override val webApis:   List<Function<CordaRPCOps, out Any>> = listOf(Function(::TransactionApi))

    // A list of directories in the resources directory that will be served by Jetty under /web.
    override val staticServeDirs = mapOf(
            "XXX" to javaClass.classLoader.getResource("XXXWeb").toExternalForm()
    )

}


问:
Rundeck operation from Slack
I'm running Terraform script from Rundeck. When I run terraform plan, complete output should go to slack. If everything is fine, I need to approve it in slack. Then it should run terraform apply.

答: You can design a job that executes the terraform plan (step) with slack notification, and using this app call another job that executes terraform apply (as the same way of the first job). At the moment of call your terraform scripts, maybe a good idea is to use -auto-approve argument to avoid the interactive behavior on Rundeck, another alternative is using expect to execute your terraform scripts.

Title: Rundeck operation from Slack


问:
how does android calculate the res directories
I have read http://developer.android.com/guide/practices/screens_support.html and http://developer.android.com/reference/android/util/DisplayMetrics.html and I somehow left with a gap here.

How is the transition from DisplayMetrics.densityDpi to for example String ("ldpi") done?

And more importantly from DisplayMetrics.widthPixels and DisplayMetrics.widthPixels to for example String ("large")

For the first I can whip up a switch statement easy enough. But the 2nd one is quite more complex. Does anybody know any details? Is there a function which does it?

I even searched the source and did not find anything. But maybe i looked for the wrong thing.

答:
If I understand correctly, you want to get the current screen density, and return a string(ie "mdpi'), and the same with size.

Have you looked at the R.attr constants screenSize and screenDensity? The android docs list the hard values there, but I'm almost positive you'll have to whip up a switch for both functions. It shouldn't be too bad as long as you have the values, either way.

Update:
Here's an idea... Check the orientation, swap if necessary, and run an if/else block based on the values in the R.attr.screenSize doc. No need to retrieve the resources that way. You might want to check the API level somewhere, though, because xlarge isn't supported on earlier versions.

```<code>String screenSize(int width, int height) {
    if(width > height) {
        int tmp = width;
        width = height;
        height = tmp;
    }
    if(width >= 600 && height >= 800)
        return "xlarge";
    else if(width >= 400 && height >= 530)
        return "large";
    else if(width >= 320 && height >= 480)
        return "normal";

    return "small";
}
</code>```

I could be wrong, but it seems reasonable to me.

Body:
If I understand correctly, you want to get the current screen density, and return a string(ie "mdpi'), and the same with size.

Have you looked at the R.attr constants screenSize and screenDensity? The android docs list the hard values there, but I'm almost positive you'll have to whip up a switch for both functions. It shouldn't be too bad as long as you have the values, either way.

Update:
Here's an idea... Check the orientation, swap if necessary, and run an if/else block based on the values in the R.attr.screenSize doc. No need to retrieve the resources that way. You might want to check the API level somewhere, though, because xlarge isn't supported on earlier versions.

String screenSize(int width, int height) {
    if(width > height) {
        int tmp = width;
        width = height;
        height = tmp;
    }
    if(width >= 600 && height >= 800)
        return "xlarge";
    else if(width >= 400 && height >= 530)
        return "large";
    else if(width >= 320 && height >= 480)
        return "normal";

    return "small";
}

I could be wrong, but it seems reasonable to me.


问:
Laravel Parameter Grouping (and/or where)
I upgraded Laravel to version 7, and when I do a query like this:

```<code>$users = User::where('name', '=', 'John')
           ->where(function ($query) {
               $query->where('votes', '>', 100)
                     ->orWhereNull('title');
           })
           ->get();
</code>```

it doesn't work as expected, and I got this error  [SQL Server] Must specify table to select from

because the SQL should be like this:

```<code>select * from users where name = 'John' and (votes > 100 or title is null)
</code>```

but when I debug the returned query it shows like this:

```<code>select * from users where name = 'John' and (select * votes > 100 or title is null) is null
</code>```

The above query it just an example of my complex query, and I have a lot like this query in all of my project so I don't need a replacement, I just need to know how to fix it as it worked fine before upgrading

答:
```<code>$users = User::where('name', '=', 'John')
           ->where(function ($query) {
               $query->from('users')
                     ->where('votes', '>', 100)
                     ->orWhereNull('title');
           })
           ->get();

</code>```

Body:
I upgraded Laravel to version 7, and when I do a query like this:

$users = User::where('name', '=', 'John')
           ->where(function ($query) {
               $query->where('votes', '>', 100)
                     ->orWhereNull('title');
           })
           ->get();

it doesn't work as expected, and I got this error  [SQL Server] Must specify table to select from

because the SQL should be like this:

select * from users where name = 'John' and (votes > 100 or title is null)

but when I debug the returned query it shows like this:

select * from users where name = 'John' and (select * votes > 100 or title is null) is null

The above query it just an example of my complex query, and I have a lot like this query in all of my project so I don't need a replacement, I just need to know how to fix it as it worked fine before upgrading


问:
How to Convert User input to Encoder value type
I have MVC 5 project that use System.Drawing; System.Drawing.Imaging; I want the user to select image quality when it is jpeg This is my approach:

```<code>   Encoder quality = Encoder.Quality; //quality should be user input
                    var ratio = new EncoderParameter(quality, 100L);
                    var codecParams = new EncoderParameters(1);
                    codecParams.Param[0] = ratio;
                    convertedImage.Save(outputImagePath, GetEncoder(ImageFormat.Jpeg), codecParams);
</code>```

Due to some use cases I have  public async Task bool and I can't declare encoder parameter.
Thus my question: How to convert string(user input) to encoder.
If we want to convert string to Int, simple:

```<code>var name = Convert.ToInt32(userinput);
</code>```

答:
If you are going to get values like "quality" vs. "colordepth", you could do something like this, as long as you know the possible values:

```<code>switch (userInput.ToLower())
{
     case "quality":
         quality = Encoder.Quality;
         break;
     case "colordepth":
         quality = Encoder.ColorDepth;
         break;
     // etc....
}
</code>```

Taking a quick look, it look like the Encoder constructor requires a guid.  So, if you wanted to create the encoder from a guid value, the following tries to parse the userInput and create an Encoder if it is a valid guid.  It seems like you may actually need to make sure the guid is a valid value for the constructor as well.

```<code>Encoder quality;
if (Guid.TryParse(userInput, out Guid result))
{
    quality = new Encoder(result);
}
else
{
    // default to something if userInput isn't valid?
}
</code>```

Body:
I have MVC 5 project that use System.Drawing; System.Drawing.Imaging; I want the user to select image quality when it is jpeg This is my approach:

   Encoder quality = Encoder.Quality; //quality should be user input
                    var ratio = new EncoderParameter(quality, 100L);
                    var codecParams = new EncoderParameters(1);
                    codecParams.Param[0] = ratio;
                    convertedImage.Save(outputImagePath, GetEncoder(ImageFormat.Jpeg), codecParams);

Due to some use cases I have  public async Task bool and I can't declare encoder parameter.
Thus my question: How to convert string(user input) to encoder.
If we want to convert string to Int, simple:

var name = Convert.ToInt32(userinput);

Body:
If you are going to get values like "quality" vs. "colordepth", you could do something like this, as long as you know the possible values:

switch (userInput.ToLower())
{
     case "quality":
         quality = Encoder.Quality;
         break;
     case "colordepth":
         quality = Encoder.ColorDepth;
         break;
     // etc....
}

Taking a quick look, it look like the Encoder constructor requires a guid.  So, if you wanted to create the encoder from a guid value, the following tries to parse the userInput and create an Encoder if it is a valid guid.  It seems like you may actually need to make sure the guid is a valid value for the constructor as well.

Encoder quality;
if (Guid.TryParse(userInput, out Guid result))
{
    quality = new Encoder(result);
}
else
{
    // default to something if userInput isn't valid?
}


问:
Autohotkey: how to declare global variable after #ifwinactive
When I declare a global variable after #ifwinactive, an error message pop up showing that the variable is not declared.

I have a long script where there are many #ifwinactive ahk_exe xxx. Below those codes, I want to declare a global variable. But that doesn't work. Whenever I run the script, it warns me the global variable is not declared. Here's a brief of my script.

On the top of the script I have these environment settings:

```<code>#NoEnv
#Warn
SendMode Input
SetWorkingDir %A_ScriptDir%
SetTitleMatchMode, 2
</code>```

Then I have many window-specific hotkeys:

```<code>#ifwinactive ahk_exe Explorer.EXE
;some hotkeys
#ifwinactive ahk_exe WINWORD.EXE
;some extra hotkeys
;etc.
</code>```

At the bottom, I try to declare a global variable and this is where the error occurs:

```<code>#ifwinactive
a := 1
^p::
    if (a != 1){
        a := 1
    } else {
        a := 0
    }
return

#if winactive("- YouTube -") and a != 1
    p::msgbox,Yes
#if a = 1 and winactive("- YouTube -")
    p::msgbox,no
#if
</code>```

答:
You're declaring the variable a outside of the auto-execute section.

Code execution never actually reaches a := 1, it's stopped when your first hotkey definition is met.

Also, it's not an error, just a warning. Due to how forgiving AHK is, it doesn't actually matter if you don't declare the variable before use. It'll start off with the default value of nothing, which works for your a != 1 check.

Also, after you run the ^p hotkey at least once, it'll behave as intended.

But anyway, to get rid of warning, you'd declare the variable in the auto-execute section of your script (at the top).

And an extra thing to consider:

Don't use #If unless you actually need it. It can cause trouble (as the documentation states), depending on what sort of a script you have.

If a win active check, and a toggle is all you need to check for, I don't think it really warrants usage of #If.

Body:
When I declare a global variable after #ifwinactive, an error message pop up showing that the variable is not declared.

I have a long script where there are many #ifwinactive ahk_exe xxx. Below those codes, I want to declare a global variable. But that doesn't work. Whenever I run the script, it warns me the global variable is not declared. Here's a brief of my script.

On the top of the script I have these environment settings:

#NoEnv
#Warn
SendMode Input
SetWorkingDir %A_ScriptDir%
SetTitleMatchMode, 2

Then I have many window-specific hotkeys:

#ifwinactive ahk_exe Explorer.EXE
;some hotkeys
#ifwinactive ahk_exe WINWORD.EXE
;some extra hotkeys
;etc.

At the bottom, I try to declare a global variable and this is where the error occurs:

#ifwinactive
a := 1
^p::
    if (a != 1){
        a := 1
    } else {
        a := 0
    }
return

#if winactive("- YouTube -") and a != 1
    p::msgbox,Yes
#if a = 1 and winactive("- YouTube -")
    p::msgbox,no
#if


问:
Can I restrict the visibility of C# extension methods to classes in the same assembly?
Say I have these files:

MyCode.cs

```<code>namespace MyCodeNamespace
{
  public class MyClass
  {
    //OMITTED
  }

  internal static class MyExtensions
  {
    internal static void Foo(this string str)
    {
      //OMITTED
    }
  }
}
</code>```

OtherCode.cs

```<code>using MyCodeNamespace;
namespace OtherCodeNamespace
{
  //OMITTED
}
</code>```

The two files are part of the same assembly.  Is there any way I can make Foo accessible to MyCode.cs but not to OtherCode.cs?  My question is similar to this question:
C# Extension Methods only visible and accessible within one class ("private")
But its accepted answer isn't really what I'm looking for.  I want to make an extension method that's only visible to the code I'm working on, and according to the answer to the above question, someone could still access it by adding a "using" statement.  Is there a way I can create an extension method that is only visible to my code, and nowhere else, not even by another class in the same assembly?

I ask because the syntax for calling an extension method is handy and would be useful for what I'm working on (otherwise I'd just create a private method instead), but I don't want others to see it and use it from their code in case it doesn't do what they assume it does.  And thanks to Visual Studio's intellisense, my extension methods are currently showing up in the list of available methods (along with the option to add the namespace they're in).

答:
think about similar thing;

c# assembly, friend assembly
will try InternalsVisibleTo;
if your classes is closed maybe will not helpfull but you can try it;

Body:
Say I have these files:

MyCode.cs

namespace MyCodeNamespace
{
  public class MyClass
  {
    //OMITTED
  }

  internal static class MyExtensions
  {
    internal static void Foo(this string str)
    {
      //OMITTED
    }
  }
}

OtherCode.cs

using MyCodeNamespace;
namespace OtherCodeNamespace
{
  //OMITTED
}

The two files are part of the same assembly.  Is there any way I can make Foo accessible to MyCode.cs but not to OtherCode.cs?  My question is similar to this question:
C# Extension Methods only visible and accessible within one class ("private")
But its accepted answer isn't really what I'm looking for.  I want to make an extension method that's only visible to the code I'm working on, and according to the answer to the above question, someone could still access it by adding a "using" statement.  Is there a way I can create an extension method that is only visible to my code, and nowhere else, not even by another class in the same assembly?

I ask because the syntax for calling an extension method is handy and would be useful for what I'm working on (otherwise I'd just create a private method instead), but I don't want others to see it and use it from their code in case it doesn't do what they assume it does.  And thanks to Visual Studio's intellisense, my extension methods are currently showing up in the list of available methods (along with the option to add the namespace they're in).