Moon Light Box

Time is Money

Android - permission vs uses-permission

| Comments

In App A, you will be a sender. And it need declare your custom permission.

<permission android:name="AAA.BBB.CCC" 
            android:label="APP_A" 
            android:protectionLevel="signature" />

In App B, you will be a receiver.

<uses-permission android:name="AAA.BBB.CCC"/>
.
.
.
<receiver 
        android:name="my.app.BroadcastReceiver"
        android:permission="AAA.BBB.CCC">
        <intent-filter>
            <action android:name="my.app.Action" />
        </intent-filter>
</receiver>

https://stackoverflow.com/questions/8816623/how-to-use-custom-permissions-in-android/8817231#8817231

https://stackoverflow.com/questions/11770794/how-to-set-permissions-in-broadcast-sender-and-receiver-in-android

https://stackoverflow.com/questions/14450839/uses-permission-vs-permission-for-android-permissions-in-the-manifest-xml-file

JavaScript - == vs ===

| Comments

== will do "implicit type conversion"

var num = 0;
var obj = new String("0");
var str = "0";

console.log(num == num); // true
console.log(obj == obj); // true
console.log(str == str); // true

console.log(num == obj); // true
console.log(num == str); // true
console.log(obj == str); // true
console.log(null == undefined); // true

// 除了少數情況,這兩個應該是 false。
console.log(obj == null);
console.log(obj == undefined);

=== will not do "implicit type conversion"

var num = 0;
var obj = new String("0");
var str = "0";

console.log(num === num); // true
console.log(obj === obj); // true
console.log(str === str); // true

console.log(num === obj); // false
console.log(num === str); // false
console.log(obj === str); // false
console.log(null === undefined); // false
console.log(obj === null); // false
console.log(obj === undefined); // false

https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Equality_comparisons_and_sameness
https://dotblogs.com.tw/alantsai/2013/06/27/106134

Docker - Install Keycloak

| Comments

# docker run -d --name keycloak -p 8080:8080 -e PROXY_ADDRESS_FORWARDING=true -e KEYCLOAK_USER=johnny -e KEYCLOAK_PASSWORD=1q2w3e4r --restart unless-stopped jboss/keycloak

If you enconter this error.

{{notification.header}} {{notification.message}} 
Loading... 

Add below headers in nginx config of keycloak.

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

http://piotrnowicki.com/java/2017/01/09/keycloak-docker-with-ssl-proxy/

http://www.codingpedia.org/ama/how-to-configure-nginx-in-production-to-serve-angular-app-and-reverse-proxy-nodejs#nginx-configuration-to-reverse-proxy-keycloak