问:
Proguard error if i use itext Library jar
Proguard won't work with iText library. the errors are related to org.spongycastle.** org.bouncycastle.* and com.itext.pdf.** I have tried to use keep on these packages without success.

My proguard config file is this:

```<code>-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
-optimizationpasses 5
-allowaccessmodification
-dontpreverify

-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose

-keepattributes *Annotation*
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService

# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
-keepclasseswithmembernames class * {
    native <methods>;
}

-keepclassmembers public class * extends android.view.View {
   void set*(***);
   *** get*();
}

-keepclassmembers class * extends android.app.Activity {
   public void *(android.view.View);
}

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

-keepclassmembers class * implements java.io.Serializable {
    static final long serialVersionUID;
    private static final java.io.ObjectStreamField[] serialPersistentFields;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
    java.lang.Object writeReplace();
    java.lang.Object readResolve();
}

-keepclassmembers class **.R$* {
    public static <fields>;
}

-dontwarn android.support.**
-dontwarn javax.activation.**
-dontwarn org.apache.**
-dontwarn org.bouncycastle.**
-dontwarn sun.misc.Unsafe
-dontwarn com.google.**
-dontwarn com.esotericsoftware.**
-dontwarn javax.naming.**

-libraryjars <java.home>/lib/rt.jar

-keepattributes *Annotation*

-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class com.android.vending.licensing.ILicensingService
-keep class com.google.**
-keep class * extends com.google.api.client.json.GenericJson {
*;
}
-keep class javax.** {*;}
-keep class java.lang.reflect.**
-keep class com.sun.** {*;}
-keep class myjava.** {*;}
-keep class org.apache.**
-keep class org.bouncycastle.**
-keep public class Mail {*;}
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep class org.spongycastle.**
-keep class com.itextpdf.text.pdf.** {*;}
-keep class com.esotericsoftware.**

-dontshrink
</code>```

The error log

```<code>Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.RIPEMD160$Digest
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.RIPEMD256$Digest
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.GOST3411$Digest
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.MD2
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.MD5
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.SHA1
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.SHA224
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.SHA256
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.SHA384
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.SHA512
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.RIPEMD128
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.RIPEMD160
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.RIPEMD256
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.GOST3411
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.CertificateInfo: can't find referenced class org.spongycastle.asn1.ASN1Sequence
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.CertificateInfo: can't find referenced class org.spongycastle.asn1.ASN1InputStream
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.CertificateInfo: can't find referenced class org.spongycastle.asn1.ASN1TaggedObject
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.CertificateInfo: can't find referenced class org.spongycastle.asn1.ASN1Primitive
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.CertificateInfo$X500Name: can't find referenced class org.spongycastle.asn1.ASN1Sequence
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.CertificateInfo$X500Name: can't find referenced class org.spongycastle.asn1.ASN1Set
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.CertificateInfo$X500Name: can't find referenced class org.spongycastle.asn1.ASN1String
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.CertificateInfo$X500Name: can't find referenced class org.spongycastle.asn1.ASN1ObjectIdentifier
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.CertificateUtil: can't find referenced class org.spongycastle.asn1.x509.Extension
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.CertificateUtil: can't find referenced class org.spongycastle.asn1.ASN1ObjectIdentifier
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.TSAInfoBouncyCastle: can't find referenced class org.spongycastle.tsp.TimeStampTokenInfo
Error:ProGuard: [MyApp] Warning: there were 667 unresolved references to classes or interfaces.
Error:ProGuard: [MyApp]          You may need to add missing library jars or update their versions.
Error:ProGuard: [MyApp]          If your code works fine without the missing classes, you can suppress
Error:ProGuard: [MyApp]          the warnings with '-dontwarn' options.
</code>```

答:
This works fine for itextg-5.5.10

```<code># proguard configuration for iText

-keep class org.spongycastle.** { *; }
-dontwarn org.spongycastle.**

-keep class com.itextpdf.** { *; }

-keep class javax.xml.crypto.dsig.** { *; }
-dontwarn javax.xml.crypto.dsig.**

-keep class org.apache.jcp.xml.dsig.internal.dom.** { *; }
-dontwarn org.apache.jcp.xml.dsig.internal.dom.**

-keep class javax.xml.crypto.dom.** { *; }
-dontwarn javax.xml.crypto.dom.**

-keep class org.apache.xml.security.utils.** { *; }
-dontwarn org.apache.xml.security.utils.**

-keep class javax.xml.crypto.XMLStructure
-dontwarn javax.xml.crypto.XMLStructure
</code>```

Body:
Proguard won't work with iText library. the errors are related to org.spongycastle.** org.bouncycastle.* and com.itext.pdf.** I have tried to use keep on these packages without success.

My proguard config file is this:

-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
-optimizationpasses 5
-allowaccessmodification
-dontpreverify

-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose

-keepattributes *Annotation*
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService

# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
-keepclasseswithmembernames class * {
    native <methods>;
}

-keepclassmembers public class * extends android.view.View {
   void set*(***);
   *** get*();
}

-keepclassmembers class * extends android.app.Activity {
   public void *(android.view.View);
}

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

-keepclassmembers class * implements java.io.Serializable {
    static final long serialVersionUID;
    private static final java.io.ObjectStreamField[] serialPersistentFields;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
    java.lang.Object writeReplace();
    java.lang.Object readResolve();
}

-keepclassmembers class **.R$* {
    public static <fields>;
}

-dontwarn android.support.**
-dontwarn javax.activation.**
-dontwarn org.apache.**
-dontwarn org.bouncycastle.**
-dontwarn sun.misc.Unsafe
-dontwarn com.google.**
-dontwarn com.esotericsoftware.**
-dontwarn javax.naming.**

-libraryjars <java.home>/lib/rt.jar

-keepattributes *Annotation*

-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class com.android.vending.licensing.ILicensingService
-keep class com.google.**
-keep class * extends com.google.api.client.json.GenericJson {
*;
}
-keep class javax.** {*;}
-keep class java.lang.reflect.**
-keep class com.sun.** {*;}
-keep class myjava.** {*;}
-keep class org.apache.**
-keep class org.bouncycastle.**
-keep public class Mail {*;}
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep class org.spongycastle.**
-keep class com.itextpdf.text.pdf.** {*;}
-keep class com.esotericsoftware.**

-dontshrink

The error log

Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.RIPEMD160$Digest
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.RIPEMD256$Digest
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.GOST3411$Digest
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.MD2
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.MD5
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.SHA1
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.SHA224
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.SHA256
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.SHA384
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.SHA512
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.RIPEMD128
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.RIPEMD160
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.RIPEMD256
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.GOST3411
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.CertificateInfo: can't find referenced class org.spongycastle.asn1.ASN1Sequence
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.CertificateInfo: can't find referenced class org.spongycastle.asn1.ASN1InputStream
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.CertificateInfo: can't find referenced class org.spongycastle.asn1.ASN1TaggedObject
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.CertificateInfo: can't find referenced class org.spongycastle.asn1.ASN1Primitive
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.CertificateInfo$X500Name: can't find referenced class org.spongycastle.asn1.ASN1Sequence
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.CertificateInfo$X500Name: can't find referenced class org.spongycastle.asn1.ASN1Set
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.CertificateInfo$X500Name: can't find referenced class org.spongycastle.asn1.ASN1String
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.CertificateInfo$X500Name: can't find referenced class org.spongycastle.asn1.ASN1ObjectIdentifier
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.CertificateUtil: can't find referenced class org.spongycastle.asn1.x509.Extension
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.CertificateUtil: can't find referenced class org.spongycastle.asn1.ASN1ObjectIdentifier
Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.TSAInfoBouncyCastle: can't find referenced class org.spongycastle.tsp.TimeStampTokenInfo
Error:ProGuard: [MyApp] Warning: there were 667 unresolved references to classes or interfaces.
Error:ProGuard: [MyApp]          You may need to add missing library jars or update their versions.
Error:ProGuard: [MyApp]          If your code works fine without the missing classes, you can suppress
Error:ProGuard: [MyApp]          the warnings with '-dontwarn' options.

Body:
This works fine for itextg-5.5.10

# proguard configuration for iText

-keep class org.spongycastle.** { *; }
-dontwarn org.spongycastle.**

-keep class com.itextpdf.** { *; }

-keep class javax.xml.crypto.dsig.** { *; }
-dontwarn javax.xml.crypto.dsig.**

-keep class org.apache.jcp.xml.dsig.internal.dom.** { *; }
-dontwarn org.apache.jcp.xml.dsig.internal.dom.**

-keep class javax.xml.crypto.dom.** { *; }
-dontwarn javax.xml.crypto.dom.**

-keep class org.apache.xml.security.utils.** { *; }
-dontwarn org.apache.xml.security.utils.**

-keep class javax.xml.crypto.XMLStructure
-dontwarn javax.xml.crypto.XMLStructure


来源: stackexchange

问:
how to save "set solib-search-path"
I wonder linux gdb debugging.

I have 1 execute file, 1 core dump file.
so, I opened it in linux
like this,

```<code>gdb exefilename -c exefuilename.core
</code>```

but, I only show error message.

```<code>warning: Could not load shared library symbols for 44 libraries, e.g. /usr/local/lib/libboost_system.so.1.55.0.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?
</code>```

so, I input command,

```<code>set solib-search-path /librarypath/
</code>```

and symbol read succeed.
and, I input command

```<code>quit
</code>```

and, I reopen dump file. like this,

```<code>gdb exefilename -c exefuilename.core
</code>```

but still show same error message.

```<code>warning: Could not load shared library symbols for 44 libraries, e.g. /usr/local/lib/libboost_system.so.1.55.0.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?
</code>```

I don't want to show this error message never.
so, I want to save library search path.
how Can I do?

答:
You can create a file called .gdbinit

You can put this either in your home folder (and it will be loaded for all projects) or in your current directory (and it will be used for gdb sessions loaded from this folder).

There are a bunch of interesting examples of various complexity around.  I'd keep it simple to start with - just create a .gdbinit in your local folder with that one line

```<code>set solib-search-path /librarypath/
</code>```

And maybe add more later, if you need to.

ContentLicense: CC BY-SA 3.0

Title: how to save "set solib-search-path"

Body:
I wonder linux gdb debugging.

I have 1 execute file, 1 core dump file.
so, I opened it in linux
like this,

gdb exefilename -c exefuilename.core

but, I only show error message.

warning: Could not load shared library symbols for 44 libraries, e.g. /usr/local/lib/libboost_system.so.1.55.0.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?

so, I input command,

set solib-search-path /librarypath/

and symbol read succeed.
and, I input command

quit

and, I reopen dump file. like this,

gdb exefilename -c exefuilename.core

but still show same error message.

warning: Could not load shared library symbols for 44 libraries, e.g. /usr/local/lib/libboost_system.so.1.55.0.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?

I don't want to show this error message never.
so, I want to save library search path.
how Can I do?

Body:
You can create a file called .gdbinit

You can put this either in your home folder (and it will be loaded for all projects) or in your current directory (and it will be used for gdb sessions loaded from this folder).

There are a bunch of interesting examples of various complexity around.  I'd keep it simple to start with - just create a .gdbinit in your local folder with that one line

set solib-search-path /librarypath/

And maybe add more later, if you need to.


问:
Asp MVC 2: Obfusicate Entity-IDs
Project type: Asp MVC 2/NHibernate/C#

Problem

If you have an edit page in an web application you will come to the problem that you have to send and then receive the id of the entity you're editing, the IDs of sub-entities, entities that can be selected by dropdownmenus,...

As it is possible to modify a form-post, an evil user could try to send back another ID which maybe would grant him more rights (if i.e. that ID was related to a security entity).

My approach

Create a GUID and associate it with the ID

Save the association in the http session

Wait for the response and extract the real ID out of the received GUID.

Question:

What techniques do you use to obfusicate an entity-ID?

答:
If you're doing that much for GUIDs, why not just use GUIDs for the identity of the entity itself that's actually stored in the database (though I'd advise against it)?

Or you could have a server side encryption scheme that encrypts and then subsequently decrypts the id (this is a long the same lines as what you're doing except you're not storing anything random like this in the session (yuck :) ).

You could even forget trying to do this at all since a lot of sites are "affected" by this issue, and it's obviously not a problem (StackOverflow for example). The overhead is just too much.

Also, if you're worried about security, why don't you have some sort of granular permissions set on the individual action/even entity level. This would solve some problems as well.

EDIT:

Another problem with your solution is inconsistent unique identifiers. If a user says "ID as23423he423fsda has 'invalid' data", how do you know which ID it belongs to if it's changing on every request (assuming you're going to change the id in the URL as well)? You'd be much better of with an encryption algorithm that always hashes to the same value therefore, you can easily perform a lookup (if you need it) and also the user has consistent identifiers.

ContentLicense: CC BY-SA 2.5

Title: Asp MVC 2: Obfusicate Entity-IDs


问:
UILabel attributed text can't have multiple lines if you change baseline offset attribute
I want to change brackets's baseline offset in a words, like "[推]blablabla".

```<code>NSRange range = [text rangeOfString:@"[推]"];
if (range.location == 0) {
    [text addAttribute:NSBaselineOffsetAttributeName value:@(0.5) range:NSMakeRange(0, 1)];
    [text addAttribute:NSBaselineOffsetAttributeName value:@(0.5) range:NSMakeRange(range.length-1, 1)];
}
</code>```

but the second line of the label disappears and gets truncated. Anyone have an idea?

答:
I've did some quick test, and it seems that if you add a whitespace at the first of your string, it will work as expected</p>

```<code>// make sure your text looks like @" [推]your content"
if (range.location == 1) {
    [text addAttribute:NSBaselineOffsetAttributeName value:@(0.5) range:NSMakeRange(1, 1)];
    [text addAttribute:NSBaselineOffsetAttributeName value:@(0.5) range:NSMakeRange(range.length, 1)];
}
</code>```

Body:
I want to change brackets's baseline offset in a words, like "[推]blablabla".

NSRange range = [text rangeOfString:@"[推]"];
if (range.location == 0) {
    [text addAttribute:NSBaselineOffsetAttributeName value:@(0.5) range:NSMakeRange(0, 1)];
    [text addAttribute:NSBaselineOffsetAttributeName value:@(0.5) range:NSMakeRange(range.length-1, 1)];
}

but the second line of the label disappears and gets truncated. Anyone have an idea?

Body:
I've did some quick test, and it seems that if you add a whitespace at the first of your string, it will work as expected

// make sure your text looks like @" [推]your content"
if (range.location == 1) {
    [text addAttribute:NSBaselineOffsetAttributeName value:@(0.5) range:NSMakeRange(1, 1)];
    [text addAttribute:NSBaselineOffsetAttributeName value:@(0.5) range:NSMakeRange(range.length, 1)];
}


问:
NoClassDefFoundError: com/google/api/client/auth/oauth2/Credential
Adding the suggested line(s):

```<code>CountDownLatch latch = new CountDownLatch(1);
..
latch.countDown();
latch.await();
</code>```

surrounding the database query exposes the following exception after ant jar from Netbeans:

```<code>-do-jar:

jar:

BUILD SUCCESSFUL
Total time: 2 seconds
thufir@doge:~/NetBeansProjects/Firebase$
thufir@doge:~/NetBeansProjects/Firebase$ java -jar dist/
Firebase.jar  lib/
thufir@doge:~/NetBeansProjects/Firebase$ java -jar dist/Firebase.jar
Exception in thread "pool-4-thread-1" java.lang.NoClassDefFoundError: com/google/api/client/auth/oauth2/Credential
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at com.google.firebase.auth.FirebaseCredentials$CertCredential.fetchCredential(FirebaseCredentials.java:276)
    at com.google.firebase.auth.FirebaseCredentials$BaseCredential$1.call(FirebaseCredentials.java:229)
    at com.google.firebase.auth.FirebaseCredentials$BaseCredential$1.call(FirebaseCredentials.java:224)
    at com.google.firebase.tasks.Tasks$1.run(Tasks.java:78)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: com.google.api.client.auth.oauth2.Credential
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 19 more
^Cthufir@doge:~/NetBeansProjects/Firebase$
thufir@doge:~/NetBeansProjects/Firebase$
thufir@doge:~/NetBeansProjects/Firebase$ ll dist/lib/
total 5024
drwxrwxr-x 2 thufir thufir    4096 Jul  3 20:19 ./
drwxrwxr-x 3 thufir thufir    4096 Jul  3 20:18 ../
-rw-rw-r-- 1 thufir thufir  648491 Jul  3 20:19 firebase-admin-5.2.0.jar
-rw-rw-r-- 1 thufir thufir  430683 Jul  3 20:19 firebase-client-jvm-2.2.3.jar
-rw-rw-r-- 1 thufir thufir  610019 Jul  3 20:19 firebase-server-sdk-3.0.3.jar
-rw-rw-r-- 1 thufir thufir  199100 Jul  3 20:19 google-api-client-1.22.0.jar
-rw-rw-r-- 1 thufir thufir  239194 Jul  3 20:19 google-api-client-1.4.1-beta.jar
-rw-rw-r-- 1 thufir thufir   16799 Jul  3 20:19 google-api-client-auth-oauth2-1.2.3-alpha.jar
-rw-rw-r-- 1 thufir thufir    6720 Jul  3 20:19 google-http-client-jackson2-1.22.0.jar
-rw-rw-r-- 1 thufir thufir 2575022 Jul  3 20:19 guava-22.0.jar
-rw-rw-r-- 1 thufir thufir  316575 Jul  3 20:19 jackson-core-2.9.0.pr4.jar
-rw-rw-r-- 1 thufir thufir   15896 Jul  3 20:19 jackson-jaxrs-json-provider-2.9.0.pr4.jar
-rw-rw-r-- 1 thufir thufir   57264 Jul  3 20:19 json-20170516.jar
thufir@doge:~/NetBeansProjects/Firebase$
</code>```

code:

```<code>package dur.bounceme.net.firebase;

import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseOptions;
import com.google.firebase.auth.FirebaseCredentials;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.CountDownLatch;
import java.util.logging.Level;
import java.util.logging.Logger;

public class FirebaseQuery {

    private static final Logger log = Logger.getLogger(FirebaseQuery.class.getName());
    private DatabaseReference databaseReference = null;
    private Properties firebaseProperties = null;

    public FirebaseQuery() {
    }

    void setProperties(Properties firebaseProperties) {
        this.firebaseProperties = firebaseProperties;
    }

    void pushUsers(List<User> users) {
        for (User u : users) {
            databaseReference.child("users").child(u.uuid.toString()).setValue(u);
        }
    }

    void tryQuery() {
        try {
            query();
        } catch (IOException ex) {
            Logger.getLogger(FirebaseQuery.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InterruptedException ex) {
            Logger.getLogger(FirebaseQuery.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void query() throws FileNotFoundException, IOException, InterruptedException {
        String url = firebaseProperties.getProperty("url");
        FileInputStream serviceAccount = new FileInputStream("serviceAccountKey.json");
        FirebaseOptions options = new FirebaseOptions.Builder()
                .setCredential(FirebaseCredentials.fromCertificate(serviceAccount))
                .setDatabaseUrl(url)
                .build();
        FirebaseApp firebaseApp = FirebaseApp.initializeApp(options);
        FirebaseDatabase firebaseDatabase = FirebaseDatabase.getInstance(firebaseApp, url);
        databaseReference = firebaseDatabase.getReference().getRoot();

        CountDownLatch latch = new CountDownLatch(1);
        databaseReference.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                String key = null;
                String value = null;
                for (DataSnapshot childSnapshot : dataSnapshot.getChildren()) {
                    key = childSnapshot.getKey();
                    value = (String) childSnapshot.getValue();
                    log.info(key + "\t\t" + value);
                }
                latch.countDown();
            }

            @Override
            public void onCancelled(DatabaseError databaseError) {
                latch.countDown();
                throw databaseError.toException();
            }
        });
        latch.await();
    }
}
</code>```

So far as I can tell these are the correct packages, but apparently not because there's no Credential class:

```<code>thufir@doge:~/NetBeansProjects/Firebase$
thufir@doge:~/NetBeansProjects/Firebase$ jar -tf dist/lib/google-api-client-auth-oauth2-1.2.3-alpha.jar
META-INF/
META-INF/MANIFEST.MF
com/
com/google/
com/google/api/
com/google/api/client/
com/google/api/client/auth/
com/google/api/client/auth/oauth2/
com/google/api/client/auth/oauth2/AccessProtectedResource$AccessTokenIntercepter.class
com/google/api/client/auth/oauth2/AccessProtectedResource$UsingAuthorizationHeader.class
com/google/api/client/auth/oauth2/AccessProtectedResource$UsingQueryParameter.class
com/google/api/client/auth/oauth2/AccessProtectedResource$UsingFormEncodedBody.class
com/google/api/client/auth/oauth2/AccessProtectedResource.class
com/google/api/client/auth/oauth2/AccessTokenRequest$AuthorizationCodeGrant.class
com/google/api/client/auth/oauth2/AccessTokenRequest$ResourceOwnerPasswordCredentialsGrant.class
com/google/api/client/auth/oauth2/AccessTokenRequest$AssertionGrant.class
com/google/api/client/auth/oauth2/AccessTokenRequest$RefreshTokenGrant.class
com/google/api/client/auth/oauth2/AccessTokenRequest.class
com/google/api/client/auth/oauth2/AccessTokenErrorResponse$KnownError.class
com/google/api/client/auth/oauth2/AccessTokenErrorResponse.class
com/google/api/client/auth/oauth2/AccessTokenResponse.class
com/google/api/client/auth/oauth2/AuthorizationRequestUrl$ResponseType.class
com/google/api/client/auth/oauth2/AuthorizationRequestUrl.class
com/google/api/client/auth/oauth2/AuthorizationResponse$KnownError.class
com/google/api/client/auth/oauth2/AuthorizationResponse.class
META-INF/maven/
META-INF/maven/com.google.api.client/
META-INF/maven/com.google.api.client/google-api-client-auth-oauth2/
META-INF/maven/com.google.api.client/google-api-client-auth-oauth2/pom.xml
META-INF/maven/com.google.api.client/google-api-client-auth-oauth2/pom.properties
thufir@doge:~/NetBeansProjects/Firebase$
</code>```

where can I download the JAR with this specific class?  Exception occurs regardless of whether run from the CLI through ant run, running the JAR directly as above, or using Netbeans.

答:
Class added in verson 1.7 see java docs

Upgrade your jar. See download

Body:
Adding the suggested line(s):

CountDownLatch latch = new CountDownLatch(1);
..
latch.countDown();
latch.await();

surrounding the database query exposes the following exception after ant jar from Netbeans:

-do-jar:

jar:

BUILD SUCCESSFUL
Total time: 2 seconds
thufir@doge:~/NetBeansProjects/Firebase$
thufir@doge:~/NetBeansProjects/Firebase$ java -jar dist/
Firebase.jar  lib/
thufir@doge:~/NetBeansProjects/Firebase$ java -jar dist/Firebase.jar
Exception in thread "pool-4-thread-1" java.lang.NoClassDefFoundError: com/google/api/client/auth/oauth2/Credential
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at com.google.firebase.auth.FirebaseCredentials$CertCredential.fetchCredential(FirebaseCredentials.java:276)
    at com.google.firebase.auth.FirebaseCredentials$BaseCredential$1.call(FirebaseCredentials.java:229)
    at com.google.firebase.auth.FirebaseCredentials$BaseCredential$1.call(FirebaseCredentials.java:224)
    at com.google.firebase.tasks.Tasks$1.run(Tasks.java:78)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: com.google.api.client.auth.oauth2.Credential
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 19 more
^Cthufir@doge:~/NetBeansProjects/Firebase$
thufir@doge:~/NetBeansProjects/Firebase$
thufir@doge:~/NetBeansProjects/Firebase$ ll dist/lib/
total 5024
drwxrwxr-x 2 thufir thufir    4096 Jul  3 20:19 ./
drwxrwxr-x 3 thufir thufir    4096 Jul  3 20:18 ../
-rw-rw-r-- 1 thufir thufir  648491 Jul  3 20:19 firebase-admin-5.2.0.jar
-rw-rw-r-- 1 thufir thufir  430683 Jul  3 20:19 firebase-client-jvm-2.2.3.jar
-rw-rw-r-- 1 thufir thufir  610019 Jul  3 20:19 firebase-server-sdk-3.0.3.jar
-rw-rw-r-- 1 thufir thufir  199100 Jul  3 20:19 google-api-client-1.22.0.jar
-rw-rw-r-- 1 thufir thufir  239194 Jul  3 20:19 google-api-client-1.4.1-beta.jar
-rw-rw-r-- 1 thufir thufir   16799 Jul  3 20:19 google-api-client-auth-oauth2-1.2.3-alpha.jar
-rw-rw-r-- 1 thufir thufir    6720 Jul  3 20:19 google-http-client-jackson2-1.22.0.jar
-rw-rw-r-- 1 thufir thufir 2575022 Jul  3 20:19 guava-22.0.jar
-rw-rw-r-- 1 thufir thufir  316575 Jul  3 20:19 jackson-core-2.9.0.pr4.jar
-rw-rw-r-- 1 thufir thufir   15896 Jul  3 20:19 jackson-jaxrs-json-provider-2.9.0.pr4.jar
-rw-rw-r-- 1 thufir thufir   57264 Jul  3 20:19 json-20170516.jar
thufir@doge:~/NetBeansProjects/Firebase$

code:

package dur.bounceme.net.firebase;

import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseOptions;
import com.google.firebase.auth.FirebaseCredentials;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.CountDownLatch;
import java.util.logging.Level;
import java.util.logging.Logger;

public class FirebaseQuery {

    private static final Logger log = Logger.getLogger(FirebaseQuery.class.getName());
    private DatabaseReference databaseReference = null;
    private Properties firebaseProperties = null;

    public FirebaseQuery() {
    }

    void setProperties(Properties firebaseProperties) {
        this.firebaseProperties = firebaseProperties;
    }

    void pushUsers(List<User> users) {
        for (User u : users) {
            databaseReference.child("users").child(u.uuid.toString()).setValue(u);
        }
    }

    void tryQuery() {
        try {
            query();
        } catch (IOException ex) {
            Logger.getLogger(FirebaseQuery.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InterruptedException ex) {
            Logger.getLogger(FirebaseQuery.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void query() throws FileNotFoundException, IOException, InterruptedException {
        String url = firebaseProperties.getProperty("url");
        FileInputStream serviceAccount = new FileInputStream("serviceAccountKey.json");
        FirebaseOptions options = new FirebaseOptions.Builder()
                .setCredential(FirebaseCredentials.fromCertificate(serviceAccount))
                .setDatabaseUrl(url)
                .build();
        FirebaseApp firebaseApp = FirebaseApp.initializeApp(options);
        FirebaseDatabase firebaseDatabase = FirebaseDatabase.getInstance(firebaseApp, url);
        databaseReference = firebaseDatabase.getReference().getRoot();

        CountDownLatch latch = new CountDownLatch(1);
        databaseReference.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                String key = null;
                String value = null;
                for (DataSnapshot childSnapshot : dataSnapshot.getChildren()) {
                    key = childSnapshot.getKey();
                    value = (String) childSnapshot.getValue();
                    log.info(key + "\t\t" + value);
                }
                latch.countDown();
            }

            @Override
            public void onCancelled(DatabaseError databaseError) {
                latch.countDown();
                throw databaseError.toException();
            }
        });
        latch.await();
    }
}

So far as I can tell these are the correct packages, but apparently not because there's no Credential class:

thufir@doge:~/NetBeansProjects/Firebase$
thufir@doge:~/NetBeansProjects/Firebase$ jar -tf dist/lib/google-api-client-auth-oauth2-1.2.3-alpha.jar
META-INF/
META-INF/MANIFEST.MF
com/
com/google/
com/google/api/
com/google/api/client/
com/google/api/client/auth/
com/google/api/client/auth/oauth2/
com/google/api/client/auth/oauth2/AccessProtectedResource$AccessTokenIntercepter.class
com/google/api/client/auth/oauth2/AccessProtectedResource$UsingAuthorizationHeader.class
com/google/api/client/auth/oauth2/AccessProtectedResource$UsingQueryParameter.class
com/google/api/client/auth/oauth2/AccessProtectedResource$UsingFormEncodedBody.class
com/google/api/client/auth/oauth2/AccessProtectedResource.class
com/google/api/client/auth/oauth2/AccessTokenRequest$AuthorizationCodeGrant.class
com/google/api/client/auth/oauth2/AccessTokenRequest$ResourceOwnerPasswordCredentialsGrant.class
com/google/api/client/auth/oauth2/AccessTokenRequest$AssertionGrant.class
com/google/api/client/auth/oauth2/AccessTokenRequest$RefreshTokenGrant.class
com/google/api/client/auth/oauth2/AccessTokenRequest.class
com/google/api/client/auth/oauth2/AccessTokenErrorResponse$KnownError.class
com/google/api/client/auth/oauth2/AccessTokenErrorResponse.class
com/google/api/client/auth/oauth2/AccessTokenResponse.class
com/google/api/client/auth/oauth2/AuthorizationRequestUrl$ResponseType.class
com/google/api/client/auth/oauth2/AuthorizationRequestUrl.class
com/google/api/client/auth/oauth2/AuthorizationResponse$KnownError.class
com/google/api/client/auth/oauth2/AuthorizationResponse.class
META-INF/maven/
META-INF/maven/com.google.api.client/
META-INF/maven/com.google.api.client/google-api-client-auth-oauth2/
META-INF/maven/com.google.api.client/google-api-client-auth-oauth2/pom.xml
META-INF/maven/com.google.api.client/google-api-client-auth-oauth2/pom.properties
thufir@doge:~/NetBeansProjects/Firebase$

where can I download the JAR with this specific class?  Exception occurs regardless of whether run from the CLI through ant run, running the JAR directly as above, or using Netbeans.


问:
"The page cannot be displayed because an internal server error has occurred", Azure Website,
I have deployed the azure website to East US location, Reserved instance. I have CustomErrors=On. After few minutes of work (with quite good performance) app is hanging, slowing down. (I don't see any errors in elmah.) After that starts to return 500 error. My custom error page is not displayed (I see only "The page cannot be displayed because an internal server error has occurred." in plain text) so I can't even customize it. Then the app is restarted. We cannot go into production like that. I don't know what to do.</p>

答: In my case, i just changed Target Framework from 3.5 to 4.5 in project properties.


问:
How to get iOS 10.3.2(14F89)
I need run my Project with Xcode7,but my iPhone iOS Version is 10.3.2(14F89),How to get iOS10.3.2(14F89) Device support files??</p>

答:
Follow these steps:

Close/Quit Xcode 7 completely.

Download Xcode 8.3.3 from Apple site

Step one

Right click on the downloaded .dmg file and show package contents

Navigate to Contents/Developer/Platforms/iPhoneOS.platform/Developer/

Copy the SDKs folder

Go to older version of Xcode, e.g. Xcode 7, in the Finder -> Applications -> Xcode

Right click and show package contents

Navigate to Contents/Developer/Platforms/iPhoneOS.platform/Developer/

Paste the copied SDKs folder here

Step two

Right click on the downloaded .dmg file and show package contents

Navigate to Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/

Copy the 10.3 folder

Go to older version of Xcode, e.g. Xcode 7, in the Finder -> Applications -> Xcode

Right click and show package contents

Navigate to Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/

Paste the copied 10.3 folder here

Finally restart you old Xcode.

Title: How to get iOS 10.3.2(14F89)


问:
How to store MySQL date in Javascript array?
I have searched over the Internet, there is a lot of way to store MySQL records into Javascript array though PHP, like this one. However I can't really store the date record in Javascript.

Let say,

My MySQL date record rows in column called holiday_date: 2017-06-25, 2017-06-26, 2017-06-27.

How can I store in Javascript after I converted them into json by

```<code><?php
    $sql = "SELECT public_holiday.holiday_date
            FROM public_holiday";
    $result = mysqli_query($conn, $sql);

    $result_array = Array();

    while($row = mysqli_fetch_assoc($result))
    {
         $result_array[] = $row;
    }

    $json_array = json_encode($result_array);

    echo $json_array;
  ?>
</code>```

?

I have tried to store them into a javascript date array like

```<code>var holidays = [<?php //sample array for example
        $loop_one = true;
        foreach ($result_array as $date)
        {
            if ($loop_one)
            {
                echo "'new Date(\'$date\')'";
                $loop_one=false;
            }
            else
            {
                echo ", 'new Date(\'$date\')'";
            }
        }
?>];
</code>```

but all of these are invalid.

I need your help, much appreciated.

答:
So in your sample, the $result_array variable will be a PHP array like:

```<code>$result_array = ['2017-06-25', '2017-06-26', '2017-06-27'];
</code>```

You do not really need to convert this to JSON before passing it to your Javascript.  Instead, you could print those string values directly into your Javascript to instantiate the date object, i.e.

```<code><?php
$sql = "SELECT holiday_date FROM public_holiday";
$result = mysqli_query($conn, $sql);

$result_array = Array();

while($row = mysqli_fetch_assoc($result))
{
     $result_array[] = $row['holiday_date'];  # Return the actual date value and not an array
}
?>
</code>```

Javascript Part:

```<code>var holidays = [<?php
    $firstLoop = true;
    foreach ($result_array as $date_result) {
        # Here you could format your $date_result variable as a specific datetime format if needed to make it compatible with Javascripts Date class.
        if ($firstLoop) {
            $firstLoop = false;
            echo "new Date('$date_result')";
        } else {
            echo ", new Date('$date_result')";
        }
    }
?>];
</code>```

In this example, I'm constructing a javascript array of new Date($phpDateTime) objects.

Body:
I have searched over the Internet, there is a lot of way to store MySQL records into Javascript array though PHP, like this one. However I can't really store the date record in Javascript.

Let say,

My MySQL date record rows in column called holiday_date: 2017-06-25, 2017-06-26, 2017-06-27.

How can I store in Javascript after I converted them into json by

<?php
    $sql = "SELECT public_holiday.holiday_date
            FROM public_holiday";
    $result = mysqli_query($conn, $sql);

    $result_array = Array();

    while($row = mysqli_fetch_assoc($result))
    {
         $result_array[] = $row;
    }

    $json_array = json_encode($result_array);

    echo $json_array;
  ?>

?

I have tried to store them into a javascript date array like

var holidays = [<?php //sample array for example
        $loop_one = true;
        foreach ($result_array as $date)
        {
            if ($loop_one)
            {
                echo "'new Date(\'$date\')'";
                $loop_one=false;
            }
            else
            {
                echo ", 'new Date(\'$date\')'";
            }
        }
?>];

but all of these are invalid.

I need your help, much appreciated.

Body:
So in your sample, the $result_array variable will be a PHP array like:

$result_array = ['2017-06-25', '2017-06-26', '2017-06-27'];

You do not really need to convert this to JSON before passing it to your Javascript.  Instead, you could print those string values directly into your Javascript to instantiate the date object, i.e.

<?php
$sql = "SELECT holiday_date FROM public_holiday";
$result = mysqli_query($conn, $sql);

$result_array = Array();

while($row = mysqli_fetch_assoc($result))
{
     $result_array[] = $row['holiday_date'];  # Return the actual date value and not an array
}
?>

Javascript Part:

var holidays = [<?php
    $firstLoop = true;
    foreach ($result_array as $date_result) {
        # Here you could format your $date_result variable as a specific datetime format if needed to make it compatible with Javascripts Date class.
        if ($firstLoop) {
            $firstLoop = false;
            echo "new Date('$date_result')";
        } else {
            echo ", new Date('$date_result')";
        }
    }
?>];

In this example, I'm constructing a javascript array of new Date($phpDateTime) objects.


问:
Auto-creating A records with kubernetes services
I've got a kubernetes 1.6.2 cluster, and am creating a service like:

```<code>kind: Service
apiVersion: v1
metadata:
  name: hello
  namespace: myns
  annotations:
      service.beta.kubernetes.io/aws-load-balancer-internal: 0.0.0.0/0
      dns.alpha.kubernetes.io/internal: mydomain.com
spec:
  selector:
    app: hello-world
  ports:
    - protocol: "TCP"
      port: 80
      targetPort: 5000
  type: LoadBalancer
</code>```

I'd expect this to create an internal ELB (which it does) but also set up an A record on the AWS Route53 hosted zone for mydomain.com as per https://github.com/kubernetes/kops/tree/master/dns-controller (which it doesn't). Is there something I need to do to enable A record creation?

答:
In route 53 create a type A record with Alias Yes prior to launching your cluster and Kurbernetes will audio update it with proper Alias Target which gets resolved to the correct IP upon app boot up when you issue

```<code>kubectl expose rs .....
</code>```

Body:
I've got a kubernetes 1.6.2 cluster, and am creating a service like:

kind: Service
apiVersion: v1
metadata:
  name: hello
  namespace: myns
  annotations:
      service.beta.kubernetes.io/aws-load-balancer-internal: 0.0.0.0/0
      dns.alpha.kubernetes.io/internal: mydomain.com
spec:
  selector:
    app: hello-world
  ports:
    - protocol: "TCP"
      port: 80
      targetPort: 5000
  type: LoadBalancer

I'd expect this to create an internal ELB (which it does) but also set up an A record on the AWS Route53 hosted zone for mydomain.com as per https://github.com/kubernetes/kops/tree/master/dns-controller (which it doesn't). Is there something I need to do to enable A record creation?

Body:
In route 53 create a type A record with Alias Yes prior to launching your cluster and Kurbernetes will audio update it with proper Alias Target which gets resolved to the correct IP upon app boot up when you issue

kubectl expose rs .....


问:
MessageTransformation exception during error handling in Spring Integration
I have a http inboundgateway and defined an error channel to the gateway .

```<code><int-http:inbound-gateway
    request-channel="requestChannel"  reply-channel="replyChannel"
        supported-methods="POST" request-payload-type="com.test.RequestWsDTO"
    path="/trips/modify" error-channel="errorChannel" >
    <int-http:request-mapping consumes="application/json" produces="application/json" />
</int-http:inbound-gateway>
</code>```

From the gateway , it goes to a transformer to transform the message to an appropriate request for ws outboundgateway

```<code><int:transformer id="segmentCancelTransformer" ref="segmentCancelTransformerBean" input-channel="segmentCancelChannel"
             method="transform" output-channel="rcsChannel"/>
    <beans:bean id="segmentCancelTransformerBean" class="com.test.SegmentCancelRequestTransformer" />
</code>```

I throw a runtime exception from the Transformer .

I have defined an service activator to handle the exception

```<code>   <int:service-activator input-channel="errorChannel" ref="exceptionhandler" method="createErrorResponse"/>
<beans:bean id="exceptionTransformer" class="com.test.ExceptionHandler" />
</code>```

In the ExceptionHandler class , I am handling the exception like

```<code>public  ErrorDTO createErrorResponse(ErrorMessage msg) {
        System.out.println("Exception occured "+msg.getPayload());
        ErrorDTO dto=new ErrorDTO ();
      ......................
</code>```

msg.getPayload() is showing the exception to be of "org.springframework.integration.transformer.MessageTransformationException"

Exception message stacktrace:

```<code>Exception occured org.springframework.integration.transformer.MessageTransformationException: Failed to transform Message; nested exception is org.springframework.messaging.MessageHandlingException: nested exception
</code>```

What am i doing wrong here ?

答:
That's really correct and also useful. First, you deal with messaging where the loosely-coupling is the first of principles between components. Another advantage is the failedMessage set to the property of the MessagingException which you can use to determine the problem.

Since the error maybe from another thread, it's hard to determine what's wrong by just a custom exception. Anyway you always can find your own cause in the stack trace.

Body:
I have a http inboundgateway and defined an error channel to the gateway .

<int-http:inbound-gateway
    request-channel="requestChannel"  reply-channel="replyChannel"
        supported-methods="POST" request-payload-type="com.test.RequestWsDTO"
    path="/trips/modify" error-channel="errorChannel" >
    <int-http:request-mapping consumes="application/json" produces="application/json" />
</int-http:inbound-gateway>

From the gateway , it goes to a transformer to transform the message to an appropriate request for ws outboundgateway

<int:transformer id="segmentCancelTransformer" ref="segmentCancelTransformerBean" input-channel="segmentCancelChannel"
             method="transform" output-channel="rcsChannel"/>
    <beans:bean id="segmentCancelTransformerBean" class="com.test.SegmentCancelRequestTransformer" />

I throw a runtime exception from the Transformer .

I have defined an service activator to handle the exception

   <int:service-activator input-channel="errorChannel" ref="exceptionhandler" method="createErrorResponse"/>
<beans:bean id="exceptionTransformer" class="com.test.ExceptionHandler" />

In the ExceptionHandler class , I am handling the exception like

public  ErrorDTO createErrorResponse(ErrorMessage msg) {
        System.out.println("Exception occured "+msg.getPayload());
        ErrorDTO dto=new ErrorDTO ();
      ......................

msg.getPayload() is showing the exception to be of "org.springframework.integration.transformer.MessageTransformationException"

Exception message stacktrace:

Exception occured org.springframework.integration.transformer.MessageTransformationException: Failed to transform Message; nested exception is org.springframework.messaging.MessageHandlingException: nested exception

What am i doing wrong here ?


问:
String match and do the condition
When I try to match a string and do some conditions; it always fails to do so. </p>

```<code>date=`date +%Y%m%d`
kol="/home/user/test_$date"
regex='Terminating the script'

if [ -f $kol ]; then

  sudo tail -f $kol | while read line; do
     if [[  $line  = *"Terminating the"* ]]
     then

        echo "failed"

     else

        echo $line >> /home/user/test123_$date

     fi
else

   echo "File is not yet present"
   exit 0
fi
</code>```

<p>I have also tried with regex and that to failed. So when ever I input the matching string into the file ($path) it wont output "failed"; Is there anything wrong in the code. Help is much appreciated. </p>

答:
You can try this. At least it works for me:

```<code>sudo tail -f $1 | while read line; do

    if [[ $line = '' ]]
    then
        break
    fi

    if [[  $line = *"Terminating the"* ]]
    then
        echo "failed"
    else
        echo $line >> /home/nurzhan/test123_$date
    fi
    done < "$1"
</code>```

$path is parameter to the running script. Also note that by default the command tail returns only 10 last lines.

Title: String match and do the condition

Body:
When I try to match a string and do some conditions; it always fails to do so.

date=`date +%Y%m%d`
kol="/home/user/test_$date"
regex='Terminating the script'

if [ -f $kol ]; then

  sudo tail -f $kol | while read line; do
     if [[  $line  = *"Terminating the"* ]]
     then

        echo "failed"

     else

        echo $line >> /home/user/test123_$date

     fi
else

   echo "File is not yet present"
   exit 0
fi

I have also tried with regex and that to failed. So when ever I input the matching string into the file ($path) it wont output "failed"; Is there anything wrong in the code. Help is much appreciated.

Body:
You can try this. At least it works for me:

sudo tail -f $1 | while read line; do

    if [[ $line = '' ]]
    then
        break
    fi

    if [[  $line = *"Terminating the"* ]]
    then
        echo "failed"
    else
        echo $line >> /home/nurzhan/test123_$date
    fi
    done < "$1"

$path is parameter to the running script. Also note that by default the command tail returns only 10 last lines.


问:
Initializing logistic regression coefficients when using the Spark dataset-based ML APIs?
By default, logistic regression training initializes the coefficients to be all-zero. However, I would like to initialize the coefficients myself. This would be useful, for example, if a previous training run crashed after several iterations -- I could simply restart training with the last known set of coefficients.

Is this possible with any of the dataset/dataframe-based APIs, preferably Scala?

Looking at the Spark source code, it seems that there is a method setInitialModel to initialize the model and its coefficients, but it's unfortunately marked as private.

The RDD-based API seems to allow initializing coefficients: one of the overloads of LogisticRegressionWithSGD.run(...) accepts an initialWeights vector. However, I would like to use the dataset-based API instead of the RDD-based API because (1) the former supports elastic net regularization (I couldn't figure out how to do elastic net with the RDD-based logistic regression) and (2) because the RDD-based API is in maintenance mode.

I could always try using reflection to call that private setInitialModel method, but I would like to avoid this if possible (and maybe that wouldn't even work... I also can't tell if setInitialModel is marked private for a good reason).

答:
Feel free to override the method. Yes you will need to copy that class into your own work area. That's fine: do not fear.

When you build your project -either via maven or sbt - your local copy of the class will "win" and shade the one in MLlib.  Fortunately the other classes in that same package will not be shaded.

I have used this approach many times with overriding Spark classes: actually your build times should be small as well.


问:
Why does C++ constructor accept incorrect type as a parameter?
The title pretty much says it all. I have a constructor

```<code>Brain::Synapse::Synapse(Neuron *new_neuron);
</code>```

But when I pass it an incorrect type (a member from a vector like this)

```<code>std::vector<Motor_Neuron*> neurons;
Synapse *new_synapse = new Synapse(neurons[neuron_index]);
</code>```

It works just fine (and that's the issue). Motor_Neuron is a derived class from Neuron, so I suspect this is why. My problem ultimately is that I need some Synapses to be connected to Neurons and others to Motor_Neurons. The Synapse class has a member that is a pointer to the "connected neuron". I have been trying to overload the constructor, but I don't think that will work, because if one of the constructors accepts the wrong type I don't see how the correct constructor will be selected.

答:
If Motor_Neuron inherits from Neuron, then it isn't an incorrect type.  That is the entire basis of inheritance; that inherited classes are their parent classes, just with some extra bits and pieces.

It sounds more like you need to work on your application's class hierarchy.  The SOLID principles are great guidelines.  The relevant one is the Liskov Substitution Principle which states that “objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.”  If your Motor_Neuron cannot fill the role of a Neuron, then it should not inherit from it.  If it needs to leverage some functionality from a Neuron, maybe have it have a Neuron as a member and use its functions from there.

There are work arounds with creating a Motor_Neuron constructor and deleting it or throwing an exception, but I don't really condone trying to fix the symptom like that, and instead get to the source; your design.

Body:
The title pretty much says it all. I have a constructor

Brain::Synapse::Synapse(Neuron *new_neuron);

But when I pass it an incorrect type (a member from a vector like this)

std::vector<Motor_Neuron*> neurons;
Synapse *new_synapse = new Synapse(neurons[neuron_index]);

It works just fine (and that's the issue). Motor_Neuron is a derived class from Neuron, so I suspect this is why. My problem ultimately is that I need some Synapses to be connected to Neurons and others to Motor_Neurons. The Synapse class has a member that is a pointer to the "connected neuron". I have been trying to overload the constructor, but I don't think that will work, because if one of the constructors accepts the wrong type I don't see how the correct constructor will be selected.


问:
How can i use a closure to log all values in the array with a SetInterval?
```<code>function displayValues(values) {
    for (var i = 0; i < values.length; i++) {
       setInterval(function() {
          console.log('The item ' + i + ' has value ' + values[i]) //Currently only logs length of array
      }, 500)
    }
}
var array = ['a', 'b', 'c', 'd'];
displayValues(array)
</code>```

I encapsulated the SetInterval in a function which currently logs index 0 and value a, but I can never get the rest of the values. Here is my code below. Am I close?

```<code>function display(values) {

  function getVal(){
    return setInterval(function() {
          console.log('The item ' + i + ' has value ' + values[i])
      }, 500)
  }
    for (var i = 0; i < values.length; i++) {
       return getVal()
    }
}
</code>```

答:
This way you can loop as, var is declared outside setInterval function and by 500ms completes the loops starts completing instead of waiting (async behaviour). So it always takes i as length of array i.e i++ till i < value.length

function displayValues(values) {
  for (var i = 0; i < values.length; i++) {
    (function(j) {
      setInterval(function() {
        console.log('The item ' + j + ' has value ' + values[j]);
      }, 500);
    })(i);
  }
}
var array = ['a', 'b', 'c', 'd'];
displayValues(array)```
</div>
</div>
</p>

<p>Lets take in an encapsulated way </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>function display(values) {
  function getVal(j) {
    setInterval(function() {
      console.log('The item ' + j + ' has value ' + values[j]);
    }, 500);
  }
  for (var i = 0; i < values.length; i++) {
    getVal(i);
  }
}

var arr = ['a', 'b', 'c', 'd'];
display(arr);</code>```

And the above both are same. 2nd snippet says there is an external function named getVal and in 1st snippet its just an anonymous function.

Body:
function displayValues(values) {
    for (var i = 0; i < values.length; i++) {
       setInterval(function() {
          console.log('The item ' + i + ' has value ' + values[i]) //Currently only logs length of array
      }, 500)
    }
}
var array = ['a', 'b', 'c', 'd'];
displayValues(array)

I encapsulated the SetInterval in a function which currently logs index 0 and value a, but I can never get the rest of the values. Here is my code below. Am I close?

function display(values) {

  function getVal(){
    return setInterval(function() {
          console.log('The item ' + i + ' has value ' + values[i])
      }, 500)
  }
    for (var i = 0; i < values.length; i++) {
       return getVal()
    }
}

Body:
This way you can loop as, var is declared outside setInterval function and by 500ms completes the loops starts completing instead of waiting (async behaviour). So it always takes i as length of array i.e i++ till i < value.length

function displayValues(values) {
  for (var i = 0; i < values.length; i++) {
    (function(j) {
      setInterval(function() {
        console.log('The item ' + j + ' has value ' + values[j]);
      }, 500);
    })(i);
  }
}
var array = ['a', 'b', 'c', 'd'];
displayValues(array)

Lets take in an encapsulated way

function display(values) {
  function getVal(j) {
    setInterval(function() {
      console.log('The item ' + j + ' has value ' + values[j]);
    }, 500);
  }
  for (var i = 0; i < values.length; i++) {
    getVal(i);
  }
}

var arr = ['a', 'b', 'c', 'd'];
display(arr);

And the above both are same. 2nd snippet says there is an external function named getVal and in 1st snippet its just an anonymous function.


问:
React component with debounceTime errors when using Sinon
I have the following React component

explore enter code here

```<code>class IncrementalSearch extends React.Component {

    constructor(props) {
        super(props);
        this.onSearch$ = new Subject();
        this.onChange = this.onChange.bind(this);
    }

    componentDidMount() {
        console.log(this.simpleText);
        this.subscription = this.onSearch$
            .debounceTime(300)
            .subscribe(debounced => {
                this.props.onPerformIncrementalSearch(debounced);
            });
    }

    componentWillUnmount() {
        if (this.subscription) {
            this.subscription.unsubscribe();
        }
    }

    onChange(e) {
        const newText = e.target.value;
        this.onSearch$.next(newText);
    }

    render() {
        return (
            <div className={styles.srchBoxContaner}>
                <input
                    className={styles.incSrchTextBox}
                    type="text" name="search" placeholder="Search.."
                    onChange={this.onChange}
                />
            </div>
        );
    }
}
</code>```

I am trying to test this using Enzyme, Jest, and Sinon.  My unit test looks like the following

```<code>it('calls componen`enter code here`tDidMount', () => {

        const componentDidMountSpy = sinon.spy(IncrementalSearch.prototype, 'componentDidMount');
        const wrapper = mount(<IncrementalSearch />);
        expect(IncrementalSearch.prototype.componentDidMount.calledOnce).toEqual(true);
        componentDidMountSpy.restore();
    });
</code>```

When I run the code I get the following error

TypeError: this.onSearch$.debounceTime is not a function

at IncrementalSearch.componentDidMount
  (src/components/common/incrementalSearch/IncrementalSearch.jsx:37:13)
        at Function.invoke (node_modules/sinon/lib/sinon/spy.js:194:51)

However if I comment out the debounceTime and leave everything else it passes.  How do I fix this?

答:
I just added the following import and it worked

```<code>import 'rxjs/add/operator/debounceTime';
</code>```

I still do not know why this does not work in unit tests and works when I am running the main app, but it works.

Body:
I have the following React component

explore enter code here

class IncrementalSearch extends React.Component {

    constructor(props) {
        super(props);
        this.onSearch$ = new Subject();
        this.onChange = this.onChange.bind(this);
    }

    componentDidMount() {
        console.log(this.simpleText);
        this.subscription = this.onSearch$
            .debounceTime(300)
            .subscribe(debounced => {
                this.props.onPerformIncrementalSearch(debounced);
            });
    }

    componentWillUnmount() {
        if (this.subscription) {
            this.subscription.unsubscribe();
        }
    }

    onChange(e) {
        const newText = e.target.value;
        this.onSearch$.next(newText);
    }

    render() {
        return (

                <input
                    className={styles.incSrchTextBox}
                    type="text" name="search" placeholder="Search.."
                    onChange={this.onChange}
                />

        );
    }
}

I am trying to test this using Enzyme, Jest, and Sinon.  My unit test looks like the following

it('calls componen`enter code here`tDidMount', () => {

        const componentDidMountSpy = sinon.spy(IncrementalSearch.prototype, 'componentDidMount');
        const wrapper = mount(<IncrementalSearch />);
        expect(IncrementalSearch.prototype.componentDidMount.calledOnce).toEqual(true);
        componentDidMountSpy.restore();
    });

When I run the code I get the following error

TypeError: this.onSearch$.debounceTime is not a function

at IncrementalSearch.componentDidMount
  (src/components/common/incrementalSearch/IncrementalSearch.jsx:37:13)
        at Function.invoke (node_modules/sinon/lib/sinon/spy.js:194:51)

However if I comment out the debounceTime and leave everything else it passes.  How do I fix this?

Body:
I just added the following import and it worked

import 'rxjs/add/operator/debounceTime';

I still do not know why this does not work in unit tests and works when I am running the main app, but it works.


问:
Exclusion pattern not working for vsts build
I'm trying to setup our CI environment using VSTS build but I need to exclude one project from the nuget packaging.  I'm using the Nuget pack task.  I'm setting the path to csproj field to
**\*.csproj;-:**\<name of proj>.csproj

However, it seems to be excluding all projects and not packaging anything.  I've done some research and the exclusion takes priority over the inclusion, but even when I specify the exact location of the project to exclude it still excludes everything.  Remove the -: bit correctly builds everything so it's definitely something wrong with the exclusion.

Does anyone know if this is a bug (https://github.com/Microsoft/vsts-tasks/issues/4336 looks similar, but not the same). Or am I doing something wrong?

答:
Yes, the negative pattern seems can't work.

There is an issue here which I added a comment, you can follow up.


问:
ERR_CONNECTION_TIMED_OUT for Launching Google
My PC is connecting the internet through Mobile.
While launching Google,am getting "ERR_CONNECTION_TIMED_OUT " some time "NET::ERR_CERT_COMMON_NAME_INVALID" error(Tried with chrome,firefox,IE).But site can reach from mobile.Could you please help on this ? Kindly let me know if any log require for verification.</p>

答: Try to clear your browser data such as cookies, app data, cache files etc</p>


问:
How to get email and username from a Facebook login button?
We want to allow users to log into our site though Facebook. But how can I get Facebook's button to return the user's email and username?

right after the body tags:

```<code><script>
    window.fbAsyncInit = function() {
        FB.init({
            appId      : '331796760587640',
            cookie     : true,
            xfbml      : true,
            version    : 'v2.9'
        });
        FB.AppEvents.logPageView();
    };

    (function(d, s, id){
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) {return;}
        js = d.createElement(s); js.id = id;
        js.src = "//connect.facebook.net/en_US/sdk.js";
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));

</script>
</code>```

in the nav bar (or login menu):

```<code><div class="fb-login-button" data-max-rows="1" data-size="small" data-button-type="login_with" data-show-faces="false" data-auto-logout-link="false" data-use-continue-as="false"></div>
</code>```

but looks like this just logs them into Facebook, not to our site. How can i get the user's email and username after they click the button? Something like this:

```<code>var username = ???
var email = ???
attempt_login(username, email);
</code>```

答: You wont be able to get that information from the login response. You will need to add a second call to me?fields=name,email using the access token from the login response.

Body:
We want to allow users to log into our site though Facebook. But how can I get Facebook's button to return the user's email and username?

right after the body tags:

in the nav bar (or login menu):

but looks like this just logs them into Facebook, not to our site. How can i get the user's email and username after they click the button? Something like this:

var username = ???
var email = ???
attempt_login(username, email);


问:
Getting a certain class from an element using wildcard
I am wanting to get the class starting with logo, only example item is:

jQuery(document).ready(function($) {

  // add classes to tab items
  var listItems = $(".vc_tta-tab a");
  // loop through all tab items
  listItems.each(function(idx, item) {
    var listItem = $(item);
    var tabID = listItem.attr("href");
    console.log(tabID);
    var matchCard = $(tabID).find('[class^="logo-"]');
    var tabClass = $(tabID).attr("class");
    console.log(tabClass);
    console.log(matchCard);

  });
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="vc_general vc_tta vc_tta-tabs vc_tta-color-grey vc_tta-style-classic vc_tta-shape-rounded vc_tta-spacing-1 vc_tta-tabs-position-top vc_tta-controls-align-left">
  <div class="vc_tta-tabs-container">
    <ul class="vc_tta-tabs-list">
      <li class="vc_tta-tab vc_active" data-vc-tab=""><span class="vc_tta-title-text">Symantec SSL/TLS Certificates</span></li>
      <li class="vc_tta-tab" data-vc-tab=""><span class="vc_tta-title-text">GeoTrust SSL Certificates</span></li>
      <li class="vc_tta-tab" data-vc-tab=""><span class="vc_tta-title-text">RapidSSL Certificates</span></li>
      <li class="vc_tta-tab" data-vc-tab=""><span class="vc_tta-title-text">Thawte SSL Certificates</span></li>
      <li class="vc_tta-tab" data-vc-tab=""><span class="vc_tta-title-text">Certum SSL Certificates</span></li>
      <li class="vc_tta-tab" data-vc-tab=""><span class="vc_tta-title-text">Comodo SSL Certificates</span></li>
    </ul>
  </div>
  <div class="vc_tta-panels-container">
    <div class="vc_tta-panels">
      <div class="vc_tta-panel vc_active logo-ssl-symantec" id="ssl-brand-symantec" data-vc-content=".vc_tta-panel-body">
        <div class="vc_tta-panel-heading">
          <h4 class="vc_tta-panel-title"><span class="vc_tta-title-text">Symantec SSL/TLS Certificates</span></h4>
        </div>
        <div class="vc_tta-panel-body"></div>
      </div>
      <div class="vc_tta-panel logo-ssl-geotrust" id="ssl-brand-geotrust" data-vc-content=".vc_tta-panel-body">
        <div class="vc_tta-panel-heading">
          <h4 class="vc_tta-panel-title"><span class="vc_tta-title-text">GeoTrust SSL Certificates</span></h4>
        </div>
        <div class="vc_tta-panel-body"></div>
      </div>
      <div class="vc_tta-panel logo-ssl-rapidssl" id="ssl-brand-rapidssl" data-vc-content=".vc_tta-panel-body">
        <div class="vc_tta-panel-heading">
          <h4 class="vc_tta-panel-title"><span class="vc_tta-title-text">RapidSSL Certificates</span></h4>
        </div>
        <div class="vc_tta-panel-body"></div>
      </div>
      <div class="vc_tta-panel logo-ssl-thawte" id="ssl-brand-thawte" data-vc-content=".vc_tta-panel-body">
        <div class="vc_tta-panel-heading">
          <h4 class="vc_tta-panel-title"><span class="vc_tta-title-text">Thawte SSL Certificates</span></h4>
        </div>
        <div class="vc_tta-panel-body"></div>
      </div>
      <div class="vc_tta-panel logo-ssl-certum" id="ssl-brand-certum" data-vc-content=".vc_tta-panel-body">
        <div class="vc_tta-panel-heading">
          <h4 class="vc_tta-panel-title"><span class="vc_tta-title-text">Certum SSL Certificates</span></h4>
        </div>
        <div class="vc_tta-panel-body"></div>
      </div>
      <div class="vc_tta-panel logo-ssl-comodo" id="ssl-brand-comodo" data-vc-content=".vc_tta-panel-body">
        <div class="vc_tta-panel-heading">
          <h4 class="vc_tta-panel-title"><span class="vc_tta-title-text">Comodo SSL Certificates</span></h4>
        </div>
        <div class="vc_tta-panel-body"></div>
      </div>
    </div>
  </div>
</div></code>```

It is working by finding ID and matching that but can't get it to select that class I am wanting.

Also, I then want to take that class and set to the parent element of the initial href.

答:
The problem is the search class is inside classes list. One way is to read all classes and than extract the required type of classes.
Here is the sample working code. I have not added code to check for uniqueness in search results for class list.

jQuery(document).ready(function($) {
    var allLogoClasses = [];
    // add classes to tab items
    var listItems = $(".vc_tta-tab a");
    // loop through all tab items
    listItems.each(function(idx, item) {
    var listItem = $(item);
    var tabID = listItem.attr("href");
 var classes = $(tabID).attr('class');
 if(classes) {
  classes = classes.split(" ");
  for(var index = 0; index < classes.length; index++) {
   if(classes[index].startsWith("logo-")) {
    allLogoClasses.push(classes[index]);
   }
  }
 }
 });
 console.log(allLogoClasses);
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="vc_general vc_tta vc_tta-tabs vc_tta-color-grey vc_tta-style-classic vc_tta-shape-rounded vc_tta-spacing-1 vc_tta-tabs-position-top vc_tta-controls-align-left">
   <div class="vc_tta-tabs-container">
      <ul class="vc_tta-tabs-list">
         <li class="vc_tta-tab vc_active" data-vc-tab=""><span class="vc_tta-title-text">Symantec SSL/TLS Certificates</span></li>
         <li class="vc_tta-tab" data-vc-tab=""><span class="vc_tta-title-text">GeoTrust SSL Certificates</span></li>
         <li class="vc_tta-tab" data-vc-tab=""><span class="vc_tta-title-text">RapidSSL Certificates</span></li>
         <li class="vc_tta-tab" data-vc-tab=""><span class="vc_tta-title-text">Thawte SSL Certificates</span></li>
         <li class="vc_tta-tab" data-vc-tab=""><span class="vc_tta-title-text">Certum SSL Certificates</span></li>
         <li class="vc_tta-tab" data-vc-tab=""><span class="vc_tta-title-text">Comodo SSL Certificates</span></li>
      </ul>
   </div>
   <div class="vc_tta-panels-container">
      <div class="vc_tta-panels">
         <div class="vc_tta-panel vc_active logo-ssl-symantec" id="ssl-brand-symantec" data-vc-content=".vc_tta-panel-body">
            <div class="vc_tta-panel-heading">
               <h4 class="vc_tta-panel-title"><span class="vc_tta-title-text">Symantec SSL/TLS Certificates</span></h4>
            </div>
            <div class="vc_tta-panel-body"></div>
         </div>
         <div class="vc_tta-panel logo-ssl-geotrust" id="ssl-brand-geotrust" data-vc-content=".vc_tta-panel-body">
            <div class="vc_tta-panel-heading">
               <h4 class="vc_tta-panel-title"><span class="vc_tta-title-text">GeoTrust SSL Certificates</span></h4>
            </div>
            <div class="vc_tta-panel-body"></div>
         </div>
         <div class="vc_tta-panel logo-ssl-rapidssl" id="ssl-brand-rapidssl" data-vc-content=".vc_tta-panel-body">
            <div class="vc_tta-panel-heading">
               <h4 class="vc_tta-panel-title"><span class="vc_tta-title-text">RapidSSL Certificates</span></h4>
            </div>
            <div class="vc_tta-panel-body"></div>
         </div>
         <div class="vc_tta-panel logo-ssl-thawte" id="ssl-brand-thawte" data-vc-content=".vc_tta-panel-body">
            <div class="vc_tta-panel-heading">
               <h4 class="vc_tta-panel-title"><span class="vc_tta-title-text">Thawte SSL Certificates</span></h4>
            </div>
            <div class="vc_tta-panel-body"></div>
         </div>
         <div class="vc_tta-panel logo-ssl-certum" id="ssl-brand-certum" data-vc-content=".vc_tta-panel-body">
            <div class="vc_tta-panel-heading">
               <h4 class="vc_tta-panel-title"><span class="vc_tta-title-text">Certum SSL Certificates</span></h4>
            </div>
            <div class="vc_tta-panel-body"></div>
         </div>
         <div class="vc_tta-panel logo-ssl-comodo" id="ssl-brand-comodo" data-vc-content=".vc_tta-panel-body">
            <div class="vc_tta-panel-heading">
               <h4 class="vc_tta-panel-title"><span class="vc_tta-title-text">Comodo SSL Certificates</span></h4>
            </div>
            <div class="vc_tta-panel-body"></div>
         </div>
      </div>
   </div>
</div></code>```

The other way is to grab the required class using regular expression from the class list string.

I hope this helps you!!

Body:
I am wanting to get the class starting with logo, only example item is:

jQuery(document).ready(function($) {

  // add classes to tab items
  var listItems = $(".vc_tta-tab a");
  // loop through all tab items
  listItems.each(function(idx, item) {
    var listItem = $(item);
    var tabID = listItem.attr("href");
    console.log(tabID);
    var matchCard = $(tabID).find('[class^="logo-"]');
    var tabClass = $(tabID).attr("class");
    console.log(tabClass);
    console.log(matchCard);

  });
});

Symantec SSL/TLS Certificates

GeoTrust SSL Certificates

RapidSSL Certificates

Thawte SSL Certificates

Certum SSL Certificates

Comodo SSL Certificates

Symantec SSL/TLS Certificates

GeoTrust SSL Certificates

RapidSSL Certificates

Thawte SSL Certificates

Certum SSL Certificates

Comodo SSL Certificates

It is working by finding ID and matching that but can't get it to select that class I am wanting.

Also, I then want to take that class and set to the parent element of the initial href.

Body:
The problem is the search class is inside classes list. One way is to read all classes and than extract the required type of classes.
Here is the sample working code. I have not added code to check for uniqueness in search results for class list.

jQuery(document).ready(function($) {
    var allLogoClasses = [];
    // add classes to tab items
    var listItems = $(".vc_tta-tab a");
    // loop through all tab items
    listItems.each(function(idx, item) {
    var listItem = $(item);
    var tabID = listItem.attr("href");
 var classes = $(tabID).attr('class');
 if(classes) {
  classes = classes.split(" ");
  for(var index = 0; index < classes.length; index++) {
   if(classes[index].startsWith("logo-")) {
    allLogoClasses.push(classes[index]);
   }
  }
 }
 });
 console.log(allLogoClasses);
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="vc_general vc_tta vc_tta-tabs vc_tta-color-grey vc_tta-style-classic vc_tta-shape-rounded vc_tta-spacing-1 vc_tta-tabs-position-top vc_tta-controls-align-left">
   <div class="vc_tta-tabs-container">
      <ul class="vc_tta-tabs-list">
         <li class="vc_tta-tab vc_active" data-vc-tab=""><a href="#ssl-brand-symantec" data-vc-tabs="" data-vc-container=".vc_tta"><span class="vc_tta-title-text">Symantec SSL/TLS Certificates</span></a></li>
         <li class="vc_tta-tab" data-vc-tab=""><a href="#ssl-brand-geotrust" data-vc-tabs="" data-vc-container=".vc_tta"><span class="vc_tta-title-text">GeoTrust SSL Certificates</span></a></li>
         <li class="vc_tta-tab" data-vc-tab=""><a href="#ssl-brand-rapidssl" data-vc-tabs="" data-vc-container=".vc_tta"><span class="vc_tta-title-text">RapidSSL Certificates</span></a></li>
         <li class="vc_tta-tab" data-vc-tab=""><a href="#ssl-brand-thawte" data-vc-tabs="" data-vc-container=".vc_tta"><span class="vc_tta-title-text">Thawte SSL Certificates</span></a></li>
         <li class="vc_tta-tab" data-vc-tab=""><a href="#ssl-brand-certum" data-vc-tabs="" data-vc-container=".vc_tta"><span class="vc_tta-title-text">Certum SSL Certificates</span></a></li>
         <li class="vc_tta-tab" data-vc-tab=""><a href="#ssl-brand-comodo" data-vc-tabs="" data-vc-container=".vc_tta"><span class="vc_tta-title-text">Comodo SSL Certificates</span></a></li>
      </ul>
   </div>
   <div class="vc_tta-panels-container">
      <div class="vc_tta-panels">
         <div class="vc_tta-panel vc_active logo-ssl-symantec" id="ssl-brand-symantec" data-vc-content=".vc_tta-panel-body">
            <div class="vc_tta-panel-heading">
               <h4 class="vc_tta-panel-title"><a href="#ssl-brand-symantec" data-vc-accordion="" data-vc-container=".vc_tta-container"><span class="vc_tta-title-text">Symantec SSL/TLS Certificates</span></a></h4>
            </div>
            <div class="vc_tta-panel-body"></div>
         </div>
         <div class="vc_tta-panel logo-ssl-geotrust" id="ssl-brand-geotrust" data-vc-content=".vc_tta-panel-body">
            <div class="vc_tta-panel-heading">
               <h4 class="vc_tta-panel-title"><a href="#ssl-brand-geotrust" data-vc-accordion="" data-vc-container=".vc_tta-container"><span class="vc_tta-title-text">GeoTrust SSL Certificates</span></a></h4>
            </div>
            <div class="vc_tta-panel-body"></div>
         </div>
         <div class="vc_tta-panel logo-ssl-rapidssl" id="ssl-brand-rapidssl" data-vc-content=".vc_tta-panel-body">
            <div class="vc_tta-panel-heading">
               <h4 class="vc_tta-panel-title"><a href="#ssl-brand-rapidssl" data-vc-accordion="" data-vc-container=".vc_tta-container"><span class="vc_tta-title-text">RapidSSL Certificates</span></a></h4>
            </div>
            <div class="vc_tta-panel-body"></div>
         </div>
         <div class="vc_tta-panel logo-ssl-thawte" id="ssl-brand-thawte" data-vc-content=".vc_tta-panel-body">
            <div class="vc_tta-panel-heading">
               <h4 class="vc_tta-panel-title"><a href="#ssl-brand-thawte" data-vc-accordion="" data-vc-container=".vc_tta-container"><span class="vc_tta-title-text">Thawte SSL Certificates</span></a></h4>
            </div>
            <div class="vc_tta-panel-body"></div>
         </div>
         <div class="vc_tta-panel logo-ssl-certum" id="ssl-brand-certum" data-vc-content=".vc_tta-panel-body">
            <div class="vc_tta-panel-heading">
               <h4 class="vc_tta-panel-title"><a href="#ssl-brand-certum" data-vc-accordion="" data-vc-container=".vc_tta-container"><span class="vc_tta-title-text">Certum SSL Certificates</span></a></h4>
            </div>
            <div class="vc_tta-panel-body"></div>
         </div>
         <div class="vc_tta-panel logo-ssl-comodo" id="ssl-brand-comodo" data-vc-content=".vc_tta-panel-body">
            <div class="vc_tta-panel-heading">
               <h4 class="vc_tta-panel-title"><a href="#ssl-brand-comodo" data-vc-accordion="" data-vc-container=".vc_tta-container"><span class="vc_tta-title-text">Comodo SSL Certificates</span></a></h4>
            </div>
            <div class="vc_tta-panel-body"></div>
         </div>
      </div>
   </div>
</div>

The other way is to grab the required class using regular expression from the class list string.

I hope this helps you!!


问:
Mysql Index is not being used correctly
I got a strange problem with a simple MySQL index.

I got the following table:

```<code>CREATE TABLE `import` (
  `import_id` int(11) NOT NULL AUTO_INCREMENT,
  `import_title` text,
  `import_url` text,
  `import_description` text,
  `import_completed` enum('y','n') NOT NULL DEFAULT 'n',
  `import_user` int(11) DEFAULT NULL,
  `import_added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`import_id`),
  KEY `import_added` (`import_added`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
</code>```

In that table are a few thousand rows and I want to get the first 100 with the following Select Clause:

```<code>SELECT
  import_id,
  import_title,
  import_url,
  import_description,
  import_user,
  import_added
FROM import
WHERE import_completed = 'n'
ORDER by import_added ASC
LIMIT 0,100
</code>```

When I use DESCRIBE to take a closer look at the query, my local machine uses the "added" index and returns 100 rows within a few milliseconds like expected.

When I use the same database with the same structure and content on my "production" server and use DESCRIBE there, it shows that the index is used as well, but it returns all rows in that table and the query takes about 6 seconds.

What am I missing? Why is the index not working correctly?

答:
Wrong usage of index

```<code>...
KEY `import_added` (import_completed, import_added) ...
</code>```

And do a query execution plan

```<code>desc extended SELECT
  import_id,
  import_title,
  import_url,
  import_description,
  import_user,
  import_added
FROM import
WHERE import_completed = 'n'
ORDER by import_added ASC
LIMIT 0,100;
</code>```

Title: Mysql Index is not being used correctly

Body:
I got a strange problem with a simple MySQL index.

I got the following table:

CREATE TABLE `import` (
  `import_id` int(11) NOT NULL AUTO_INCREMENT,
  `import_title` text,
  `import_url` text,
  `import_description` text,
  `import_completed` enum('y','n') NOT NULL DEFAULT 'n',
  `import_user` int(11) DEFAULT NULL,
  `import_added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`import_id`),
  KEY `import_added` (`import_added`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

In that table are a few thousand rows and I want to get the first 100 with the following Select Clause:

SELECT
  import_id,
  import_title,
  import_url,
  import_description,
  import_user,
  import_added
FROM import
WHERE import_completed = 'n'
ORDER by import_added ASC
LIMIT 0,100

When I use DESCRIBE to take a closer look at the query, my local machine uses the "added" index and returns 100 rows within a few milliseconds like expected.

When I use the same database with the same structure and content on my "production" server and use DESCRIBE there, it shows that the index is used as well, but it returns all rows in that table and the query takes about 6 seconds.

What am I missing? Why is the index not working correctly?

Body:
Wrong usage of index

...
KEY `import_added` (import_completed, import_added) ...

And do a query execution plan

desc extended SELECT
  import_id,
  import_title,
  import_url,
  import_description,
  import_user,
  import_added
FROM import
WHERE import_completed = 'n'
ORDER by import_added ASC
LIMIT 0,100;


问:
Way to dynamically link to js scripts from client-side js?
Is there a way to dynamically link javascript pages based on client-side javascript logic? For example in client-side html code I want something like:

```<code><script>
    if(photoUpdate){
      import "./phtoLoader.js"       //Something like this?
    }
</script>
</code>```

I am currently using server side to supply dynamic script imports and it feels very inefficient.

答:
You can create a dynamic script element and append to your document body. </p>

```<code>function loadJS(file) {
    var jsElm = document.createElement("script");
    jsElm.type = "application/javascript";
    jsElm.src = file;
    document.body.appendChild(jsElm);
}
</code>```

Body:
Is there a way to dynamically link javascript pages based on client-side javascript logic? For example in client-side html code I want something like:

I am currently using server side to supply dynamic script imports and it feels very inefficient.

Body:
You can create a dynamic script element and append to your document body.

function loadJS(file) {
    var jsElm = document.createElement("script");
    jsElm.type = "application/javascript";
    jsElm.src = file;
    document.body.appendChild(jsElm);
}


问:
Error: Android SDK not found with ionic run android
I have try to debug fro a few days. I want to run ionic code with Genymotion as emulator. I am using windows 10. My C drive is run out of space and I installed everything in D drive.

However, when I run ionic run android, I get the Error: Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable.

I have the SDK directories as below:
[![enter image description here][1]][1][![enter image description here][2]][2][![enter image description here][3]][3]

I also set the Environment Variables with ANDROID_HOME and its path
[![enter image description here][4]][4][![enter image description here][5]][5]

Besides, I also try numerous way to set the path as below, but all still fail with same error.

D:\sdk-tools-windows-3859397\tools and D:\sdk-tools-windows-3859397\platform-tools

D:\sdk-tools-windows-3859397\platform-tools only

ANDOIRD_HOME set to D:\sdk-tools-windows-3859397\

remove ANDROID_HOME and set path D:\sdk-tools-windows-3859397\platform-tools and D:\sdk-tools-windows-3859397\tools

The adb is working and able to detect the device in genymotion
[![enter image description here][6]][6]

I think I have try almost everything but still see the error. Please advice how to make it work.
If I run only ionic serve, there is no error.

答:
See this link:

http://www.360logica.com/blog/how-to-set-path-environmental-variable-for-sdk-in-windows/

Or open command prompt and exec:

```<code>set ANDROID_HOME=D:\sdk-tools-windows-3859397

set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools
</code>```

Body:
See this link:

http://www.360logica.com/blog/how-to-set-path-environmental-variable-for-sdk-in-windows/

Or open command prompt and exec:

set ANDROID_HOME=D:\sdk-tools-windows-3859397

set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools