问:
After clean project, FirebaseAnalytics causes a crash for ClassNotFoundException
Since yesterday I am in trouble fixing this mistake. This error I started to find after a "clean" failed, because of the "freezing" of Visual Studio I was forced to stop the process.
This is the error stack:

```<code>11-14 10:57:30.210 I/mono-stdout(20645): Java.Lang.ClassNotFoundException: com.google.firebase.analytics.FirebaseAnalytics ---> Java.Lang.ClassNotFoundException: Didn't find class "com.google.firebase.analytics.FirebaseAnalytics" on path: DexPathList[[zip file "/data/app/com.myappname.packagename-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myappname.packagename-1/lib/arm, /data/app/com.myappname.packagename-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
Java.Lang.ClassNotFoundException: com.google.firebase.analytics.FirebaseAnalytics ---> Java.Lang.ClassNotFoundException: Didn't find class "com.google.firebase.analytics.FirebaseAnalytics" on path: DexPathList[[zip file "/data/app/com.myappname.packagename-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myappname.packagename-1/lib/arm, /data/app/com.myappname.packagename-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
11-14 10:57:30.217 I/mono-stdout(20645):    --- End of inner exception stack trace ---
   --- End of inner exception stack trace ---
11-14 10:57:30.217 I/mono-stdout(20645):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/jenkins/workspace/xamarin-android/xamarin-android/external/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:151
11-14 10:57:30.218 I/mono-stdout(20645):   at Java.Interop.JniEnvironment+StaticMethods.CallStaticObjectMethod (Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00069] in <ea989c10241f4c8a9adb15ef93d69358>:0
11-14 10:57:30.218 I/mono-stdout(20645):   at Android.Runtime.JNIEnv.CallStaticObjectMethod (System.IntPtr jclass, System.IntPtr jmethod, Android.Runtime.JValue* parms) [0x00000] in /Users/builder/data/lanes/4986/fb018c56/source/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.g.cs:562
11-14 10:57:30.218 I/mono-stdout(20645):   at Android.Runtime.JNIEnv.CallStaticObjectMethod (System.IntPtr jclass, System.IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00017] in /Users/builder/data/lanes/4986/fb018c56/source/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.g.cs:568
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/jenkins/workspace/xamarin-android/xamarin-android/external/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:151
  at Java.Interop.JniEnvironment+StaticMethods.CallStaticObjectMethod (Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00069] in <ea989c10241f4c8a9adb15ef93d69358>:0
  at Android.Runtime.JNIEnv.CallStaticObjectMethod (System.IntPtr jclass, System.IntPtr jmethod, Android.Runtime.JValue* parms) [0x00000] in /Users/builder/data/lanes/4986/fb018c56/source/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.g.cs:562
  at Android.Runtime.JNIEnv.CallStaticObjectMethod (System.IntPtr jclass, System.IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00017] in /Users/builder/data/lanes/4986/fb018c56/source/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.g.cs:568
  at Android.Runtime.J
NIEnv.FindClass (System.String classname) [0x00007] in /Users/builder/data/lanes/4986/fb018c56/source/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.cs:602
11-14 10:57:30.219 I/mono-stdout(20645):   at Android.Runtime.JNIEnv.FindClass (System.String classname) [0x00007] in /Users/builder/data/lanes/4986/fb018c56/source/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.cs:602
11-14 10:57:30.219 I/mono-stdout(20645):   at Android.Runtime.JNIEnv.FindClass (System.String className, System.IntPtr& cachedJniClassHandle) [0x00011] in /Users/builder/data/lanes/4986/fb018c56/source/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.cs:616
11-14 10:57:30.219 I/mono-stdout(20645):   at Firebase.Analytics.FirebaseAnalytics.get_class_ref () [0x00000] in <0d9bc83400c247fbb8133267b3bc506d>:0
11-14 10:57:30.220 I/mono-stdout(20645):   at Firebase.Analytics.FirebaseAnalytics.GetInstance (Android.Content.Context context) [0x00014] in <0d9bc83400c247fbb8133267b3bc506d>:0
11-14 10:57:30.220 I/mono-stdout(20645):   at com.meba.ui.EXAApplication.InitializeEXAApplication (com.meba.ui.android.controls.EXAActivity MainActivity) [0x00022] in C:\Progetti\com.meba\com.meba.ui.android\controls\EXAApplication.cs:677
11-14 10:57:30.220 I/mono-stdout(20645):   --- End of managed Java.Lang.ClassNotFoundException stack trace ---
  at Android.Runtime.JNIEnv.FindClass (System.String className, System.IntPtr& cachedJniClassHandle) [0x00011] in /Users/builder/data/lanes/4986/fb018c56/source/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.cs:616
  at Firebase.Analytics.FirebaseAnalytics.get_class_ref () [0x00000] in <0d9bc83400c247fbb8133267b3bc506d>:0
  at Firebase.Analytics.FirebaseAnalytics.GetInstance (Android.Content.Context context) [0x00014] in <0d9bc83400c247fbb8133267b3bc506d>:0
  at com.meba.ui.EXAApplication.InitializeEXAApplication (com.meba.ui.android.controls.EXAActivity MainActivity) [0x00022] in C:\Progetti\com.meba\com.meba.ui.android\controls\EXAApplication.cs:677
  --- End of managed Java.Lang.ClassNotFoundException stack trace ---
java.lang.ClassNotFoundException: com.google.firebase.analytics.FirebaseAnalytics
11-14 10:57:30.220 I/mono-stdout(20645): java.lang.ClassNotFoundException: com.google.firebase.analytics.FirebaseAnalytics
11-14 10:57:30.221 I/mono-stdout(20645):    at java.lang.Class.classForName(Native Method)
11-14 10:57:30.221 I/mono-stdout(20645):    at java.lang.Class.forName(Class.java:324)
    at java.lang.Class.classForName(Native Method)
    at java.lang.Class.forName(Class.java:324)
    at md5a8add535933d47bad1d9f0eed06bba35.MainActivity.n_onCreate(Native Method)
    at md5a8add535933d47bad1d9f0eed06bba35.MainActivity.onCreate(MainActivity.java:29)
    at android.app.Activity.performCreate(Activity.java:6301)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2519)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654)
    at android.app.ActivityThread.-wrap11(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)
    at android.os.Handler.dispatchMessage(Handler.java:111)
    at android.os.Looper.loop(Looper.java:207)
    at android.app.ActivityThread.main(ActivityThread.java:5728)
11-14 10:57:30.221 I/mono-stdout(20645):    at md5a8add535933d47bad1d9f0eed06bba35.MainActivity.n_onCreate(Native Method)
11-14 10:57:30.222 I/mono-stdout(20645):    at md5a8add535933d47bad1d9f0eed06bba35.MainActivity.onCreate(MainActivity.java:29)
11-14 10:57:30.222 I/mono-stdout(20645):    at android.app.Activity.performCreate(Activity.java:6301)
11-14 10:57:30.222 I/mono-stdout(20645):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
11-14 10:57:30.222 I/mono-stdout(20645):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2519)
11-14 10:57:30.222 I/mono-stdout(20645):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654)
11-14 10:57:30.222 I/mono-stdout(20645):    at android.app.ActivityThread.-wrap11(ActivityThread.java)
11-14 10:57:30.223 I/mono-stdout(20645):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)
11-14 10:57:30.223 I/mono-stdout(20645):    at android.os.Handler.dispatchMessage(Handler.java:111)
11-14 10:57:30.223 I/mono-stdout(20645):    at android.os.Looper.loop(Looper.java:207)
11-14 10:57:30.223 I/mono-stdout(20645):    at android.app.ActivityThread.main(ActivityThread.java:5728)
11-14 10:57:30.223 I/mono-stdout(20645):    at java.lang.reflect.Method.invoke(Native Method)
11-14 10:57:30.223 I/mono-stdout(20645):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
11-14 10:57:30.223 I/mono-stdout(20645):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
11-14 10:57:30.224 I/mono-stdout(20645): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.analytics.FirebaseAnalytics" on path: DexPathList[[zip file "/data/app/com.myappname.packagename-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myappname.packagename-1/lib/arm, /data/app/com.myappname.packagename-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
11-14 10:57:30.224 I/mono-stdout(20645):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
11-14 10:57:30.224 I/mono-stdout(20645):    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
11-14 10:57:30.224 I/mono-stdout(20645):    at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
11-14 10:57:30.224 I/mono-stdout(20645):    ... 16 more
11-14 10:57:30.224 I/mono-stdout(20645):    Suppressed: java.lang.ClassNotFoundException: com.google.firebase.analytics.FirebaseAnalytics
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.analytics.FirebaseAnalytics" on path: DexPathList[[zip file "/data/app/com.myappname.packagename-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myappname.packagename-1/lib/arm, /data/app/com.myappname.packagename-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
    ... 16 more
    Suppressed: java.lang.ClassNotFoundException: com.google.firebase.analytics.FirebaseAnalytics
        at java.lang.Class.classForName(Native Method)
        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
        a
t java.lang.ClassLoader.loadClass(ClassLoader.java:504)
        ... 17 more
    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
11-14 10:57:30.224 I/mono-stdout(20645):        at java.lang.Class.classForName(Native Method)
11-14 10:57:30.224 I/mono-stdout(20645):        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
11-14 10:57:30.225 I/mono-stdout(20645):        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
11-14 10:57:30.225 I/mono-stdout(20645):        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
11-14 10:57:30.225 I/mono-stdout(20645):        ... 17 more
11-14 10:57:30.225 I/mono-stdout(20645):    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
</code>```

I have try to re-clean, rebuild, build, check references (all ok), try on different device (Huawei Android 7.0, thl Android 6.0), update SDK and company from Android SDK Manager, update Xamarin and VS.
I tried to move everything through SVN on another machine, but the problem was also found on the other.

Any idea or help?

I replaced my package name in output with a fake.

Before I found the error I updated the device OS (Huawei P9), but the error is also found on a THL with different OS

答:
After days with the same problem I understand this:

If you has downloaded Library from Nuget you need to be sure about some points:

1) XAMARIN.DOWNLOAD.BUILD
Updating from Android SDK Manager is unusefull for Xamarin Binders, this because VS use (I suppose) Xamarin.Download.Build to align jar during compiling process. This is the reason you always need to include this components in projects (if you use some Xamarin Binders).

To check if you have downloaded all jars and to understand wich components are miss, browse the folder library_projects\ in obj folder.
If is all OK you will find classes.jar

Don't mantain this folder manually because any CLEAN operation delete the content of the folder.

2) ALIGN VERSIONS DEPENDENCIES
All Google libraries are part of the same "Service package"
If you use different google services (firebase, maps, cloud platform)
be sure that al components you use are at same version and that components have the same dependencies, if not align components. If you don't repair this you problably encour in strange compiling error about missing methods in jar file. I'll suppose this happen because the libraries have the same dependency but in different versions.

3) ALWAYS USE NUGET
Use always NUGET for add/remove componnents. When I manually referenced different version of components previously downloaded with NUGET for solving the same problem, I continuosly had compiling error. This is caused because if you refer library manually (and remove manually the previous reference) in you project file (.prj) remains "Import instructions" of wrong reference.

4) CHECK COMPILING OUTPUT
If you dont understand the compiling error. Check the Full detailed log of compiling process (You can set it in VS Options). Usually One strange error depend by previous warning not listed in default output mode.

Body:
Since yesterday I am in trouble fixing this mistake. This error I started to find after a "clean" failed, because of the "freezing" of Visual Studio I was forced to stop the process.
This is the error stack:

11-14 10:57:30.210 I/mono-stdout(20645): Java.Lang.ClassNotFoundException: com.google.firebase.analytics.FirebaseAnalytics ---> Java.Lang.ClassNotFoundException: Didn't find class "com.google.firebase.analytics.FirebaseAnalytics" on path: DexPathList[[zip file "/data/app/com.myappname.packagename-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myappname.packagename-1/lib/arm, /data/app/com.myappname.packagename-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
Java.Lang.ClassNotFoundException: com.google.firebase.analytics.FirebaseAnalytics ---> Java.Lang.ClassNotFoundException: Didn't find class "com.google.firebase.analytics.FirebaseAnalytics" on path: DexPathList[[zip file "/data/app/com.myappname.packagename-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myappname.packagename-1/lib/arm, /data/app/com.myappname.packagename-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
11-14 10:57:30.217 I/mono-stdout(20645):    --- End of inner exception stack trace ---
   --- End of inner exception stack trace ---
11-14 10:57:30.217 I/mono-stdout(20645):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/jenkins/workspace/xamarin-android/xamarin-android/external/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:151
11-14 10:57:30.218 I/mono-stdout(20645):   at Java.Interop.JniEnvironment+StaticMethods.CallStaticObjectMethod (Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00069] in <ea989c10241f4c8a9adb15ef93d69358>:0
11-14 10:57:30.218 I/mono-stdout(20645):   at Android.Runtime.JNIEnv.CallStaticObjectMethod (System.IntPtr jclass, System.IntPtr jmethod, Android.Runtime.JValue* parms) [0x00000] in /Users/builder/data/lanes/4986/fb018c56/source/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.g.cs:562
11-14 10:57:30.218 I/mono-stdout(20645):   at Android.Runtime.JNIEnv.CallStaticObjectMethod (System.IntPtr jclass, System.IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00017] in /Users/builder/data/lanes/4986/fb018c56/source/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.g.cs:568
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/jenkins/workspace/xamarin-android/xamarin-android/external/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:151
  at Java.Interop.JniEnvironment+StaticMethods.CallStaticObjectMethod (Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00069] in <ea989c10241f4c8a9adb15ef93d69358>:0
  at Android.Runtime.JNIEnv.CallStaticObjectMethod (System.IntPtr jclass, System.IntPtr jmethod, Android.Runtime.JValue* parms) [0x00000] in /Users/builder/data/lanes/4986/fb018c56/source/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.g.cs:562
  at Android.Runtime.JNIEnv.CallStaticObjectMethod (System.IntPtr jclass, System.IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00017] in /Users/builder/data/lanes/4986/fb018c56/source/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.g.cs:568
  at Android.Runtime.J
NIEnv.FindClass (System.String classname) [0x00007] in /Users/builder/data/lanes/4986/fb018c56/source/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.cs:602
11-14 10:57:30.219 I/mono-stdout(20645):   at Android.Runtime.JNIEnv.FindClass (System.String classname) [0x00007] in /Users/builder/data/lanes/4986/fb018c56/source/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.cs:602
11-14 10:57:30.219 I/mono-stdout(20645):   at Android.Runtime.JNIEnv.FindClass (System.String className, System.IntPtr& cachedJniClassHandle) [0x00011] in /Users/builder/data/lanes/4986/fb018c56/source/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.cs:616
11-14 10:57:30.219 I/mono-stdout(20645):   at Firebase.Analytics.FirebaseAnalytics.get_class_ref () [0x00000] in <0d9bc83400c247fbb8133267b3bc506d>:0
11-14 10:57:30.220 I/mono-stdout(20645):   at Firebase.Analytics.FirebaseAnalytics.GetInstance (Android.Content.Context context) [0x00014] in <0d9bc83400c247fbb8133267b3bc506d>:0
11-14 10:57:30.220 I/mono-stdout(20645):   at com.meba.ui.EXAApplication.InitializeEXAApplication (com.meba.ui.android.controls.EXAActivity MainActivity) [0x00022] in C:\Progetti\com.meba\com.meba.ui.android\controls\EXAApplication.cs:677
11-14 10:57:30.220 I/mono-stdout(20645):   --- End of managed Java.Lang.ClassNotFoundException stack trace ---
  at Android.Runtime.JNIEnv.FindClass (System.String className, System.IntPtr& cachedJniClassHandle) [0x00011] in /Users/builder/data/lanes/4986/fb018c56/source/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.cs:616
  at Firebase.Analytics.FirebaseAnalytics.get_class_ref () [0x00000] in <0d9bc83400c247fbb8133267b3bc506d>:0
  at Firebase.Analytics.FirebaseAnalytics.GetInstance (Android.Content.Context context) [0x00014] in <0d9bc83400c247fbb8133267b3bc506d>:0
  at com.meba.ui.EXAApplication.InitializeEXAApplication (com.meba.ui.android.controls.EXAActivity MainActivity) [0x00022] in C:\Progetti\com.meba\com.meba.ui.android\controls\EXAApplication.cs:677
  --- End of managed Java.Lang.ClassNotFoundException stack trace ---
java.lang.ClassNotFoundException: com.google.firebase.analytics.FirebaseAnalytics
11-14 10:57:30.220 I/mono-stdout(20645): java.lang.ClassNotFoundException: com.google.firebase.analytics.FirebaseAnalytics
11-14 10:57:30.221 I/mono-stdout(20645):    at java.lang.Class.classForName(Native Method)
11-14 10:57:30.221 I/mono-stdout(20645):    at java.lang.Class.forName(Class.java:324)
    at java.lang.Class.classForName(Native Method)
    at java.lang.Class.forName(Class.java:324)
    at md5a8add535933d47bad1d9f0eed06bba35.MainActivity.n_onCreate(Native Method)
    at md5a8add535933d47bad1d9f0eed06bba35.MainActivity.onCreate(MainActivity.java:29)
    at android.app.Activity.performCreate(Activity.java:6301)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2519)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654)
    at android.app.ActivityThread.-wrap11(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)
    at android.os.Handler.dispatchMessage(Handler.java:111)
    at android.os.Looper.loop(Looper.java:207)
    at android.app.ActivityThread.main(ActivityThread.java:5728)
11-14 10:57:30.221 I/mono-stdout(20645):    at md5a8add535933d47bad1d9f0eed06bba35.MainActivity.n_onCreate(Native Method)
11-14 10:57:30.222 I/mono-stdout(20645):    at md5a8add535933d47bad1d9f0eed06bba35.MainActivity.onCreate(MainActivity.java:29)
11-14 10:57:30.222 I/mono-stdout(20645):    at android.app.Activity.performCreate(Activity.java:6301)
11-14 10:57:30.222 I/mono-stdout(20645):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
11-14 10:57:30.222 I/mono-stdout(20645):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2519)
11-14 10:57:30.222 I/mono-stdout(20645):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654)
11-14 10:57:30.222 I/mono-stdout(20645):    at android.app.ActivityThread.-wrap11(ActivityThread.java)
11-14 10:57:30.223 I/mono-stdout(20645):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)
11-14 10:57:30.223 I/mono-stdout(20645):    at android.os.Handler.dispatchMessage(Handler.java:111)
11-14 10:57:30.223 I/mono-stdout(20645):    at android.os.Looper.loop(Looper.java:207)
11-14 10:57:30.223 I/mono-stdout(20645):    at android.app.ActivityThread.main(ActivityThread.java:5728)
11-14 10:57:30.223 I/mono-stdout(20645):    at java.lang.reflect.Method.invoke(Native Method)
11-14 10:57:30.223 I/mono-stdout(20645):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
11-14 10:57:30.223 I/mono-stdout(20645):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
11-14 10:57:30.224 I/mono-stdout(20645): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.analytics.FirebaseAnalytics" on path: DexPathList[[zip file "/data/app/com.myappname.packagename-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myappname.packagename-1/lib/arm, /data/app/com.myappname.packagename-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
11-14 10:57:30.224 I/mono-stdout(20645):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
11-14 10:57:30.224 I/mono-stdout(20645):    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
11-14 10:57:30.224 I/mono-stdout(20645):    at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
11-14 10:57:30.224 I/mono-stdout(20645):    ... 16 more
11-14 10:57:30.224 I/mono-stdout(20645):    Suppressed: java.lang.ClassNotFoundException: com.google.firebase.analytics.FirebaseAnalytics
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.analytics.FirebaseAnalytics" on path: DexPathList[[zip file "/data/app/com.myappname.packagename-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myappname.packagename-1/lib/arm, /data/app/com.myappname.packagename-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
    ... 16 more
    Suppressed: java.lang.ClassNotFoundException: com.google.firebase.analytics.FirebaseAnalytics
        at java.lang.Class.classForName(Native Method)
        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
        a
t java.lang.ClassLoader.loadClass(ClassLoader.java:504)
        ... 17 more
    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
11-14 10:57:30.224 I/mono-stdout(20645):        at java.lang.Class.classForName(Native Method)
11-14 10:57:30.224 I/mono-stdout(20645):        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
11-14 10:57:30.225 I/mono-stdout(20645):        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
11-14 10:57:30.225 I/mono-stdout(20645):        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
11-14 10:57:30.225 I/mono-stdout(20645):        ... 17 more
11-14 10:57:30.225 I/mono-stdout(20645):    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

I have try to re-clean, rebuild, build, check references (all ok), try on different device (Huawei Android 7.0, thl Android 6.0), update SDK and company from Android SDK Manager, update Xamarin and VS.
I tried to move everything through SVN on another machine, but the problem was also found on the other.

Any idea or help?

I replaced my package name in output with a fake.

Before I found the error I updated the device OS (Huawei P9), but the error is also found on a THL with different OS


来源: stackexchange

问:
How to hide javascript from being seen on the inspect element
Is there any efficient way or plugin to include in order to hide javascript from being seen on the inspect element?</p>

答:
One word answer: no.

It is a badly created site if the site's security depends on "hiding" the source code. Try uglifying your code if you really don't want others seeing it, but it can always be reverse-engineered.

ContentLicense: CC BY-SA 3.0


问:
IONIC 2 : While deploying an IONIC app to android device : Task 'wrapper' not found in root project 'android'
While deploying ionic app to android it's giving error as follows, It seems gradle is missing but when I check cordova requirements the gradle is installed. What's happening here?

```<code>auli@auli-H81H3-M4:~/ionic/iProjects/gplusauth$ cordova run android
ANDROID_HOME=/home/auli/Android/Sdk
JAVA_HOME=/usr/lib/jvm/java-8-oracle

FAILURE: Could not determine which tasks to execute.

* What went wrong:
Task 'wrapper' not found in root project 'android'.

* Try:
Run gradle tasks to get a list of available tasks.

BUILD FAILED

Total time: 1.385 secs
Error: /usr/share/gradle/bin/gradle: Command failed with exit code 1
</code>```

and here is cordova requirements:

```<code>Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-26,android-25,android-24,android-23,android-22,android-21,android-20,android-19,android-18,android-17,android-16,android-15,android-14
Gradle: installed /usr/share/gradle/bin/gradle
</code>```

答:
I solved this issue with upgrading gradle to latest version.

https://www.vultr.com/docs/how-to-install-gradle-on-ubuntu-16-10

Body:
While deploying ionic app to android it's giving error as follows, It seems gradle is missing but when I check cordova requirements the gradle is installed. What's happening here?

auli@auli-H81H3-M4:~/ionic/iProjects/gplusauth$ cordova run android
ANDROID_HOME=/home/auli/Android/Sdk
JAVA_HOME=/usr/lib/jvm/java-8-oracle

FAILURE: Could not determine which tasks to execute.

* What went wrong:
Task 'wrapper' not found in root project 'android'.

* Try:
Run gradle tasks to get a list of available tasks.

BUILD FAILED

Total time: 1.385 secs
Error: /usr/share/gradle/bin/gradle: Command failed with exit code 1

and here is cordova requirements:

Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-26,android-25,android-24,android-23,android-22,android-21,android-20,android-19,android-18,android-17,android-16,android-15,android-14
Gradle: installed /usr/share/gradle/bin/gradle


问:
React Native: Failed to install on any devices
I just started studying React Native. I did all the Android SDK setup and tested everything using Android studio. Using Android Studio, the Hello World app works and runs on my phone with no errors.
However, I followed every step it takes to run my React Native app on my Android phone:

Enabled USB debugging on my phone

Checked the "Allow installs from unknown sources" on my phone

I plugged in my phone and did all the setting about device ID

But when I run my app (which was created using react-native init AwesomeProject), I get the following error.

When I run react-native run-android, I get this:

FAILURE: Build failed with an exception.

What went wrong: Execution failed for task ':app:installDebug'.

Failed to install on any devices.

Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 1 mins 20.824 secs Could not install the app on the
  device, read the error above for details. Make sure you have an
  Android emulator running or a device connected and have set up your
  Android development environment:
  https://facebook.github.io/react-native/docs/android-setup.html

When I run adb devices, I get this:

adb server is out of date.  killing...
  * daemon started successfully *
  List of devices attached   ????????????   no permissions
  emulator-5554 device

I don't care that the app isn't running even on the emulator-5554 device that seems to have no problem. What I want is for the app to run on my phone which appears to be the app listed as ????????????   no permissions.
I'll appreciate any help!

答:
You must setup android virtual device (AVD) in Android Studio first before you can  react-native run-android.

Other than that, you can also run standalone android avd via Terminal(Mac) / CMD (Window) with the command android avd and setup AVD there. After the simulator has run, then you can run react-native run-android

NOTE: Read the whole RN android setup guide

https://facebook.github.io/react-native/releases/0.24/docs/android-setup.html


问:
Qt - Display a QChartView in a QDialog window
I have been following this example to try create a line chart in a QDialog window. Instead of adding the chart to the UI with:

```<code>window.setCentralWidget(chartView);
</code>```

I am adding it to the UI with this line:

```<code>QChartView *chartView = new QChartView(chart, ui->widget_chart);
</code>```

I have a QWidget called widget_chart added to my UI file and a horizontal layout applied. The chart is shown but it is very small. I would have expected that by applying the layout, the chart would take up the full width of the window. And that it would be dynamically resize if I resized the window.

Screenshot of program

How can I make it so that the chart takes up the full width of the QWidget?

Here is the full code for my dialog.cpp file:

```<code>#include "dialog.h"
#include "ui_dialog.h"
#include <QtCharts>

Dialog::Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
{
    ui->setupUi(this);

    QLineSeries *series = new QLineSeries();

    series->append(0, 6);
    series->append(2, 4);
    series->append(3, 8);
    series->append(7, 4);
    series->append(10, 5);

    QChart *chart = new QChart();
    chart->legend()->hide();
    chart->addSeries(series);
    chart->createDefaultAxes();
    chart->setTitle("Simple line chart example");

    QChartView *chartView = new QChartView(chart, ui->widget_chart);
    chartView->setRenderHint(QPainter::Antialiasing);

}

Dialog::~Dialog()
{
    delete ui;
}
</code>```

答:
I had similar problem. I resolved it using layouts. Create layout for your QWidget, and then add QChartView using addWidget function:

```<code>your_layout->addWidget(chartView)
</code>```

Body:
I have been following this example to try create a line chart in a QDialog window. Instead of adding the chart to the UI with:

window.setCentralWidget(chartView);

I am adding it to the UI with this line:

QChartView *chartView = new QChartView(chart, ui->widget_chart);

I have a QWidget called widget_chart added to my UI file and a horizontal layout applied. The chart is shown but it is very small. I would have expected that by applying the layout, the chart would take up the full width of the window. And that it would be dynamically resize if I resized the window.

Screenshot of program

How can I make it so that the chart takes up the full width of the QWidget?

Here is the full code for my dialog.cpp file:

#include "dialog.h"
#include "ui_dialog.h"
#include <QtCharts>

Dialog::Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
{
    ui->setupUi(this);

    QLineSeries *series = new QLineSeries();

    series->append(0, 6);
    series->append(2, 4);
    series->append(3, 8);
    series->append(7, 4);
    series->append(10, 5);

    QChart *chart = new QChart();
    chart->legend()->hide();
    chart->addSeries(series);
    chart->createDefaultAxes();
    chart->setTitle("Simple line chart example");

    QChartView *chartView = new QChartView(chart, ui->widget_chart);
    chartView->setRenderHint(QPainter::Antialiasing);

}

Dialog::~Dialog()
{
    delete ui;
}

Body:
I had similar problem. I resolved it using layouts. Create layout for your QWidget, and then add QChartView using addWidget function:

your_layout->addWidget(chartView)


问:
Remove an overlay of a div on hover
I have a div with a background image and a linear-gradient overlay. I would like to transition the linear-gradient to completely transparent when the div is hovered over.

.board-grid {
  display: flex;
  justify-content: center;
  flex-direction: row;
}

.board-focus {
  margin: 10px;
  background: #FFF;
  text-decoration: None;
  border-radius: 10px;
  height:30vh;
  width:25vw;
  display: flex;
  align-items: center;
  justify-content: center;
}

.board-name {
  text-transform: uppercase;
  //max-width: 50%;
  color: #FFF;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="board-grid">

    <div class="board-focus" style="background: linear-gradient(0deg,rgba(0,0,0,0.5),rgba(0,0,0,0.5)), url(https://placeimg.com/480/300/any); background-size: cover; background-position: center center; background-repeat: no-repeat;">
      <div class="board-name">
        <p>John Doe</p>
      </div>
    </div>

</div></code>```

Fiddle

答:
You Can use code like below

.board-grid {
  display: flex;
  justify-content: center;
  flex-direction: row;
}
.board-focus {
  margin: 10px;
  background: #FFF;
  text-decoration: None;
  border-radius: 10px;
  height:30vh;
  width:25vw;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(0deg,rgba(0,0,0,0.5),rgba(0,0,0,0.5)),url(https://placeimg.com/480/300/any);
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
}

.board-name {
  text-transform: uppercase;
  // max-width: 50%;
  color: #FFF;
  }
  .board-focus:hover
  {
    background-image:url(https://placeimg.com/480/300/any);;
  }```
<pre class="snippet-code-html lang-html prettyprint-override"><code>   <div class="board-grid">
  <div class="board-focus" style="">
  <div class="board-name">
      <p>John Doe</p>
  </div>
</div>
</div>
  </a>
</div></code>```

Title: Remove an overlay of a div on hover

Body:
I have a div with a background image and a linear-gradient overlay. I would like to transition the linear-gradient to completely transparent when the div is hovered over.

.board-grid {
  display: flex;
  justify-content: center;
  flex-direction: row;
}

.board-focus {
  margin: 10px;
  background: #FFF;
  text-decoration: None;
  border-radius: 10px;
  height:30vh;
  width:25vw;
  display: flex;
  align-items: center;
  justify-content: center;
}

.board-name {
  text-transform: uppercase;
  //max-width: 50%;
  color: #FFF;
}

John Doe

Fiddle

Body:
You Can use code like below

.board-grid {
  display: flex;
  justify-content: center;
  flex-direction: row;
}
.board-focus {
  margin: 10px;
  background: #FFF;
  text-decoration: None;
  border-radius: 10px;
  height:30vh;
  width:25vw;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(0deg,rgba(0,0,0,0.5),rgba(0,0,0,0.5)),url(https://placeimg.com/480/300/any);
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
}

.board-name {
  text-transform: uppercase;
  // max-width: 50%;
  color: #FFF;
  }
  .board-focus:hover
  {
    background-image:url(https://placeimg.com/480/300/any);;
  }

   <div class="board-grid">
  <a href=''><div class="board-focus" style="">
  <div class="board-name">
      <p>John Doe</p>
  </div>
</div></a>
</div>
  </a>
</div>


问:
Deriving from Binding class (Silverlight 4.0)
Using the existing Binding class, we can write,

```<code> <TextBox Text="{Binding Email, Mode=TwoWay}"/>
</code>```

So we can write anything as Email; there is no validity check by Binding itself. I started writing a class BindingMore deriving from Binding so that eventually I could write,

```<code> <TextBox Text="{local:BindingMore Email, Validate=SomeMethod, Mode=TwoWay}"/>
</code>```

Where SomeMethod is some ICommand or delegate which will be triggered to validate the Email .  That is my objective, and I've not written that yet.

As of now, I've written just this code,

```<code>public class BindingMore : System.Windows.Data.Binding
{
    public BindingMore() : base()
    {
    }
    public BindingMore(string path) : base(path)
    {
    }
}
</code>```

So, at this stage, BindingMore is exactly equivalent to Binding, yet when I write

```<code> <TextBox Text="{local:BindingMore Email, Mode=TwoWay}"/>
</code>```

It's giving me runtime error. But when I write,

```<code> <TextBox Text="{local:BindingMore Path=Email, Mode=TwoWay}"/>
</code>```

It's working fine. Can anybody tell me why it's giving runtime error in the first case?

Unfortunately, the error is not shown. All it shows is this:

Also, I get the following error message from XAML (even when it builds perfectly and runs (in the second case)):

Type 'local:BindingMore' is used like
  a markup extension but does not derive
  from MarkupExtension.

答: Custom Markup Extensions are not supported in Silverlight. Try using an Attached Property approach or a Behavior.

ContentLicense: CC BY-SA 2.5

Body:
Using the existing Binding class, we can write,

 <TextBox Text="{Binding Email, Mode=TwoWay}"/>

So we can write anything as Email; there is no validity check by Binding itself. I started writing a class BindingMore deriving from Binding so that eventually I could write,

 <TextBox Text="{local:BindingMore Email, Validate=SomeMethod, Mode=TwoWay}"/>

Where SomeMethod is some ICommand or delegate which will be triggered to validate the Email .  That is my objective, and I've not written that yet.

As of now, I've written just this code,

public class BindingMore : System.Windows.Data.Binding
{
    public BindingMore() : base()
    {
    }
    public BindingMore(string path) : base(path)
    {
    }
}

So, at this stage, BindingMore is exactly equivalent to Binding, yet when I write

 <TextBox Text="{local:BindingMore Email, Mode=TwoWay}"/>

It's giving me runtime error. But when I write,

 <TextBox Text="{local:BindingMore Path=Email, Mode=TwoWay}"/>

It's working fine. Can anybody tell me why it's giving runtime error in the first case?

Unfortunately, the error is not shown. All it shows is this:

Also, I get the following error message from XAML (even when it builds perfectly and runs (in the second case)):

Type 'local:BindingMore' is used like
  a markup extension but does not derive
  from MarkupExtension.


问:
Col Span Split For First td cell with table header

    Header
    Header
    Header

    Col 3
    Col 1
    Col 2

```

From the above code i need to share first td with two th cells. how it is possible to share the first td cell to share with th if td colspan is greater than th colspan. I got error in first td cell only while sharing with two th headers?

答:
Try This :

  <colgroup>
    <col style="width:25%;" />
    <col style="width:25%;" />
    <col style="width:25%;" />
    <col style="width:25%;" />
  </colgroup>

    Header
    Header
    Header

    Col 3
    Col 1
    Col 2

```

Body:
    Header
    Header
    Header

    Col 3
    Col 1
    Col 2

From the above code i need to share first td with two th cells. how it is possible to share the first td cell to share with th if td colspan is greater than th colspan. I got error in first td cell only while sharing with two th headers?

Body:
Try This :

<table border="1">
  <colgroup>
    <col style="width:25%;" />
    <col style="width:25%;" />
    <col style="width:25%;" />
    <col style="width:25%;" />
  </colgroup>
  <tr>
    <th scope="col" colspan="1">Header</th>
    <th scope="col" colspan="2" >Header</th>
    <th scope="col" colspan="1">Header</th>
  </tr>
  <tr>

    <td colspan="2">Col 3</td>
    <td  colspan="1">Col 1</td>
    <td  colspan="1">Col 2</td>
  </tr>
</table>


问:
How to extract an array from string input?
Input is in this format...

```<code>String input = "3 12#45#33 94#54#23 98#59#27";
</code>```

To be extracted in this array...

```<code>int[][] array = new int[3][3];
</code>```

答:
You can split the string and then iterate over the array. Which results in something like this:</p>

```<code>String input = "3 12#45#33 94#54#23 98#59#27";
String[] strings = input.split(" ");

int size = Integer.parseInt(strings[0]);
int[][] result = new int[size][size];

for( int i = 0; i < strings.length - 1; i++ ){
    String[] strings2 = strings[i + 1].split("#");
    for( int j = 0; j < strings2.length; j++ ){
        result[i][j] = Integer.parseInt(strings2[j]); // add the parsed int to result
    }
}
</code>```

Body:
Input is in this format...

String input = "3 12#45#33 94#54#23 98#59#27";

To be extracted in this array...

int[][] array = new int[3][3];

Body:
You can split the string and then iterate over the array. Which results in something like this:

String input = "3 12#45#33 94#54#23 98#59#27";
String[] strings = input.split(" ");

int size = Integer.parseInt(strings[0]);
int[][] result = new int[size][size];

for( int i = 0; i < strings.length - 1; i++ ){
    String[] strings2 = strings[i + 1].split("#");
    for( int j = 0; j < strings2.length; j++ ){
        result[i][j] = Integer.parseInt(strings2[j]); // add the parsed int to result
    }
}


问:
Python Ordered Pairs
I am new to python, and I am trying to generate ordered pairs, and then evaluate the Domain and Range of the set relation. My issue with my current code is that it sets up the list just fine, but rather than giving me the actual ordered pair, it gives me (what I am assuming is) the address of the ordered pair.</p>

```<code>    relation = [[] for i in range(numOrderPairs)]
    for x in range(numOrderPairs):
       inputOrderPair = input("\nPlease enter an ordered pair, i.e (x, y).")
       orderPair = (int(t.strip("(),")) for t in inputOrderPair.split())
       relation[x] = orderPair
    print(relation)

    >>>[<generator object <genexpr> at 0x7f4242a0ab48>, <generator object
       <genexpr> at 0x7f4242a0aba0>, <generator object <genexpr> at
       0x7f4242a0abf8>]
</code>```

答:
A simpler and safer way is to eval your expression, with ast.literal_eval :

Exemple :

```<code>In [70]: inputOrderPair='(2,4)'

In [71]: ast.literal_eval(inputOrderPair)
Out[71]: (2, 4)
</code>```

Title: Python Ordered Pairs

Body:
I am new to python, and I am trying to generate ordered pairs, and then evaluate the Domain and Range of the set relation. My issue with my current code is that it sets up the list just fine, but rather than giving me the actual ordered pair, it gives me (what I am assuming is) the address of the ordered pair.

    relation = [[] for i in range(numOrderPairs)]
    for x in range(numOrderPairs):
       inputOrderPair = input("\nPlease enter an ordered pair, i.e (x, y).")
       orderPair = (int(t.strip("(),")) for t in inputOrderPair.split())
       relation[x] = orderPair
    print(relation)

    >>>[<generator object <genexpr> at 0x7f4242a0ab48>, <generator object
       <genexpr> at 0x7f4242a0aba0>, <generator object <genexpr> at
       0x7f4242a0abf8>]

Body:
A simpler and safer way is to eval your expression, with ast.literal_eval :

Exemple :

In [70]: inputOrderPair='(2,4)'

In [71]: ast.literal_eval(inputOrderPair)
Out[71]: (2, 4)


问:
My bootstrap navbar brand not linking back to home page
I can't connect back to my home page when clicking the bootstrap brand. How can I get it to link back to home page (see a class="navbar-brand")? Below is my code and I don't see anything wrong, much appreciated.

```<code>    <nav class="navbar navbar-static-top navbar-default" role="navigation">
      <div class="container">

      <!-- Brand and toggle get grouped for better mobile display -->
      <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">

          <span class="sr-only">Toggle navigation</span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
    </button>

 <a class="navbar-brand" href= "#">Biru29 今晚啤酒</a>

  </div>

  <!-- Collect the nav links, forms, and other content for toggling -->
  <div class="collapse navbar-collapse navbar-ex1-collapse">
  <ul class="nav navbar-nav navbar-left">
      <li><%= link_to "精選啤酒", birus_path %></li>
      <li><%= link_to "啤酒紀錄片", birumentary_path %></li>
    </ul>

    <ul class="nav navbar-nav navbar-right">
      <li><%= link_to "詢購單+", orders_path %></li>
      <li><%= link_to "暫停會員", pause_path %></li>
      <li><%= link_to "取消會員", cancel_path %></li>
    </ul>
  </div><!-- /.navbar-collapse -->
</div><!-- /.container -->
</nav>
</code>```

答: Looks like your # tag is not linking any where try to link it to a section in your website with the id of that same section</p>

Body:
I can't connect back to my home page when clicking the bootstrap brand. How can I get it to link back to home page (see a class="navbar-brand")? Below is my code and I don't see anything wrong, much appreciated.

        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">

          Toggle navigation

    </button>

 Biru29 今晚啤酒

<%= link_to "精選啤酒", birus_path %>

<%= link_to "啤酒紀錄片", birumentary_path %>

<%= link_to "詢購單+", orders_path %>

<%= link_to "暫停會員", pause_path %>

<%= link_to "取消會員", cancel_path %>


问:
How to pass parameters into url after render() in Django?
I'm trying to use Google's Custom Search Engine product to display results from a query on a page for a personal web app.

How CSE is working is that it takes parameters from the URL as search terms: i.e., www.mydomain.com/results.html?q=hello+world would return results for a "hello world" query on the page. You put some JS code they give you on your page, so it's a bit of a black box.

However, with URL routing and render() on Django, I'm guessing the basics is that www.mydomain.com/results gets routed to a views.results calls which renders results.html as www.mydomain.com/results.

What is the best-practice for submitting a query through a form, and passing it to www.mydomain.com/results.html?q=hello+world instead of redirecting to www.mydomain.com/results and having Django render the results/html file?

Sorry, I'm relatively new. I can try to piece things together, but I feel there has got to be a very efficient way of handling this situation. Thanks for understanding

答:
Thanks for the responses, but I'm not sure that will work.

First, the Google CSE JS code looks like this:

```<code>  <div class="container">
     <gcse:searchresults-only></gcse:searchresults-only>
  </div>
</code>```

I'm not sure if it uses the request.GET["q"] method.

Second, I want to process the "q" parameter with additional things beyond what the form sends. Does that make sense?

I want the workflow to be like this:

```<code>    query = {'keywords':request.GET.get('k'),
         'urls':request.GET.get('u'),
         'collections':request.GET.getlist('c'),
         'filetypes':request.GET.getlist('f')
         }
    query_final = create_query(query) # Some other function
    return render(request,'app_search/results.html') # Need to go to domain.com/results.html?q=blahblahblah
</code>```

Body:
Thanks for the responses, but I'm not sure that will work.

First, the Google CSE JS code looks like this:

  <div class="container">
     <gcse:searchresults-only></gcse:searchresults-only>
  </div>

I'm not sure if it uses the request.GET["q"] method.

Second, I want to process the "q" parameter with additional things beyond what the form sends. Does that make sense?

I want the workflow to be like this:

    query = {'keywords':request.GET.get('k'),
         'urls':request.GET.get('u'),
         'collections':request.GET.getlist('c'),
         'filetypes':request.GET.getlist('f')
         }
    query_final = create_query(query) # Some other function
    return render(request,'app_search/results.html') # Need to go to domain.com/results.html?q=blahblahblah


问:
Rendering Sliced images using Javascript
I have been given the task of rendering sliced images using javascript.

My teacher has supplied me with a folder of sliced images. I have been asked to place each image into a table  individually. There are 4 rows and 5 columns per row (20 sliced images). I now need to use javascript to render the images, creating an whole image with no blank spaces or gaps in between the slices.

My teacher has given me a clue in that I need to use a nested for loop to render the slices together and that the rendering should be achieved by a single statement.

I understand nested for loops, but I cannot seem to wrap my head this task. Can someone please show me how to render sliced images within a table, using a single nested for loop statement, leaving no gaps or blank spaces?

```<code>//JavaScript

var numRows = 4;
var numCols = 5;

var redBowl = document.getElementsByClassName('orderImage');
  var orderImage = '';

for (var i = 0; i < numRows; i++) {
    orderImage += '<tr>';
        for(var j = 0; j < numCols; j++) {
            orderImage += '<td>' + i + j + '</td>';
    }
orderImage += '</tr>';
}

redBowl.innerHTML = orderImage;

//HTML

<table class="orderImage">

<tr>

<td><img src="images/bcpot002_r1_c1.jpg" width="130" height="80"
     alt="Red Bowl" title="Red Bowl"/></td>

<td><img src="images/bcpot002_r1_c2.jpg" width="130" height="80"
     alt="Red Bowl" title="Red Bowl"/></td>
<td><img src="images/bcpot002_r1_c3.jpg" width="130" height="80"
     alt="Red Bowl" title="Red Bowl"/></td>
<td><img src="images/bcpot002_r1_c4.jpg" width="130" height="80"
    alt="Red bowl" title="Red Bowl"/></td>
<td><img src="images/bcpot002_r1_c5.jpg" width="130" height="80"
    alt="Red bowl" title="Red Bowl"/></td>

</tr>

<tr>

<td><img src="images/bcpot002_r2_c1.jpg" width="130" height="80"
    alt="Red Bowl" title="Red Bowl"/></td>
<td><img src="images/bcpot002_r2_c2.jpg" width="130" height="80
    alt="Red
     Bowl" title="Red Bowl"/></td>
<td><img src="images/bcpot002_r2_c3.jpg" width="130" height="80"
    alt="Red Bowl" title="Red Bowl"/></td>
<td><img src="images/bcpot002_r2_c4.jpg" width="130" height="80"
    alt="Red Bowl" title="Red Bowl"/></td>
<td><img src="images/bcpot002_r2_c5.jpg" width="130" height="80"
    alt="Red Bowl" title="Red Bowl"/></td>

</tr>

<tr>

<td><img src="images/bcpot002_r3_c1.jpg" width="130" height="80"
     alt="Red Bowl" title="Red Bowl"/></td>
<td><img src="images/bcpot002_r3_c2.jpg" width="130" height="80"
     alt="Red Bowl" title="Red Bowl"/></td>
<td><img src="images/bcpot002_r3_c3.jpg" width="130" height="80
     alt="Red Bowl" title="Red Bowl"/></td>
<td><img src="images/bcpot002_r3_c4.jpg" width="130" height="80
     alt="Red Bowl" title="Red Bowl"/></td>
<td><img src="images/bcpot002_r3_c5.jpg" width="130" height="80"
     alt="Red Bowl" title="Red Bowl"/></td>

</tr>

<tr>

<td><img src="images/bcpot002_r4_c1.jpg" width="130" height="80"
     alt="Red Bowl" title="Red Bowl"/></td>
<td><img src="images/bcpot002_r4_c2.jpg" width="130" height="80"
     alt="Red Bowl" title="Red Bowl"/></td>
<td><img src="images/bcpot002_r4_c3.jpg" width="130" height="80"
     alt="Red Bowl" title="Red Bowl"/></td>
<td><img src="images/bcpot002_r4_c4.jpg" width="130" height="80"
     alt="Red Bowl" title="Red Bowl"/></td>
<td><img src="images/bcpot002_r4_c5.jpg" width="130" height="80"
     alt="Red Bowl" title="Red Bowl"/></td>

</tr>

</table>
</code>```

答:
I made a simple nested loop example. Is this help enough or what have you tried and where are you stuck?

var ele = document.getElementById('table');
var table = '';

for(var i = 0 ; i < 4 ; i++) {
 table += '
';
  for(var j = 0 ; j < 5 ; j++) {
   table += '' + i + j + '	';
  }
  table += '
';
}
ele.innerHTML = table;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>td {
  border: 1px solid lightgray;
}</code>```

```

Body:
I have been given the task of rendering sliced images using javascript.

My teacher has supplied me with a folder of sliced images. I have been asked to place each image into a table  individually. There are 4 rows and 5 columns per row (20 sliced images). I now need to use javascript to render the images, creating an whole image with no blank spaces or gaps in between the slices.

My teacher has given me a clue in that I need to use a nested for loop to render the slices together and that the rendering should be achieved by a single statement.

I understand nested for loops, but I cannot seem to wrap my head this task. Can someone please show me how to render sliced images within a table, using a single nested for loop statement, leaving no gaps or blank spaces?

//JavaScript

var numRows = 4;
var numCols = 5;

var redBowl = document.getElementsByClassName('orderImage');
  var orderImage = '';

for (var i = 0; i < numRows; i++) {
    orderImage += '
';
        for(var j = 0; j < numCols; j++) {
            orderImage += '' + i + j + '	';
    }
orderImage += '
';
}

redBowl.innerHTML = orderImage;

//HTML

Body:
I made a simple nested loop example. Is this help enough or what have you tried and where are you stuck?

var ele = document.getElementById('table');
var table = '';

for(var i = 0 ; i < 4 ; i++) {
 table += '<tr>';
  for(var j = 0 ; j < 5 ; j++) {
   table += '<td>' + i + j + '</td>';
  }
  table += '</tr>';
}
ele.innerHTML = table;

td {
  border: 1px solid lightgray;
}

<table id="table"></table>


问:
How to write a file into preference store in Eclipse
I want to write a CSS file into the preference store instead of into a local file path and read back whenever it requires.

I am new to Eclipse, an example would be helpful for me...

答:
The preference store is for key-value-pairs, not for files.

See Eclipse Preferences - Tutorial


问:
Looking for something more efficient than setInterval
I am using some collision code I found on stack overflow, it uses .setInterval which when lowered to something like in a game doesn't seem very efficient. I wish to reset #div1 upon a false result.

Would an EventListener be preferable?
What would be the best alternative for something with collisions possibly happening every second?

```<code>window.setInterval(function() {
  var bang = collision(collisionOne, collisionTwo);
  $('#result').text(bang);
   if (bang) === false){
     $('#div1').detach();
     }
  }, 20);
</code>```

答:
In some cases, the function might need longer than the interval time to finish execution. Consider using setInterval in every 5 seconds, variables might prevent the request from completing on time. What would happen is that you'll end up with a bunch of queued requests that may not necessarily return in order.
You can use instead...

```<code>function interval(){

    setTimeout(interval, wait);
};
</code>```

where the wait is a time variable.

Body:
I am using some collision code I found on stack overflow, it uses .setInterval which when lowered to something like in a game doesn't seem very efficient. I wish to reset #div1 upon a false result.

Would an EventListener be preferable?
What would be the best alternative for something with collisions possibly happening every second?

window.setInterval(function() {
  var bang = collision(collisionOne, collisionTwo);
  $('#result').text(bang);
   if (bang) === false){
     $('#div1').detach();
     }
  }, 20);

Body:
In some cases, the function might need longer than the interval time to finish execution. Consider using setInterval in every 5 seconds, variables might prevent the request from completing on time. What would happen is that you'll end up with a bunch of queued requests that may not necessarily return in order.
You can use instead...

function interval(){

    setTimeout(interval, wait);
};

where the wait is a time variable.


问:
How to change color of button when clicked in WP7?
In WP7 whenever a button is clicked ,the background of button becomes white showing that button is clicked and becomes normal on releasing the mouse button.But I want to change the color of button selection from white to orange.How can i dot it?</p>

答:
If you're developing for Windows phone, Blend is free and it's an incredibly powerful. I would go so far as to say mandatory, I highly recommend you use it. In Blend it's a simple matter of editing the "Pressed" state style.

In Visual studio, in Solution Explorer, right click on your XAML page and select "open in Expression Blend"

Right Click on the button -> Edit Template -> Create Copy (Just choose the defaults for the save dialogue)

Click on the "states" tab: (You'll see a list of all the different visual states the button can have)

Select the "Pressed" state and edit away to your heats content, visually.

And you're done!

Compare that to trying to edit the raw XAML, as you would have to in VS.


问:
how to change html content which is loaded inside other html 's body tag
I'm loading one html page in other, lets say, home.html is called inside index.html but now I wanted to change some content of home.html with the help of java script or jquery inside of index.html
below is what I've tried so far

index.html

```<code>   <html>
    <body> </body>
</html>
<script>
    $('body').load('home.html');
    // below div **session_error** is from home.html page,I wanted to change its text on this page
           $('#session_error').html("This is session out errror");

</script>
</code>```

答:
The .load() call is asynchronous.  So you need to wait for it to be done before making changes.

something like:

```<code>$('body').load('home.html', function() {
   $('#session_error').html("This is session out errror");
});
</code>```

Body:
The .load() call is asynchronous.  So you need to wait for it to be done before making changes.

something like:

$('body').load('home.html', function() {
   $('#session_error').html("This is session out errror");
});


问:
wmic cpu get LoadPercentage always returns empty value
I'm use wmic command to get current CPU utilization, the command are:

```<code>wmic cpu get LoadPercentage /value
</code>```

It's works fine at first, but somehow it doesn't shows the LoadPercentage, but always returns with empty result like:

```<code>C:\Users\Administrator>wmic cpu get LoadPercentage /value

LoadPercentage=
</code>```

It's so weird and I'm pretty sure that the result don't match with the taskmgr.exe. I also tried this command without /value, the result is still the same.

I have copy a large file in my server, and the CPU usage in TaskManager and wmic is like:

no matter what value is in TaskManager, the wmic always return empty value.

答:
Use below mentioned powershell query for the same:

```<code>gwmi Win32_PerfFormattedData_PerfOS_Processor | select PercentProcessorTime
</code>```

Body:
I'm use wmic command to get current CPU utilization, the command are:

wmic cpu get LoadPercentage /value

It's works fine at first, but somehow it doesn't shows the LoadPercentage, but always returns with empty result like:

C:\Users\Administrator>wmic cpu get LoadPercentage /value

LoadPercentage=

It's so weird and I'm pretty sure that the result don't match with the taskmgr.exe. I also tried this command without /value, the result is still the same.

I have copy a large file in my server, and the CPU usage in TaskManager and wmic is like:

no matter what value is in TaskManager, the wmic always return empty value.

Body:
Use below mentioned powershell query for the same:

gwmi Win32_PerfFormattedData_PerfOS_Processor | select PercentProcessorTime


问:
JavaScript Save Cookies
I am following a tutorial for cookies and in the tutorial you enter your name, and you can refresh then display your name, so the name is actually saved as a cookie. However when I am trying this in a personal file, the cookie is not being saved if I refresh the page, I can only see the cookie once per session, so how do I save the cookie for as many sessions as I want?

I suppose you can't use cookies in a snippet, but if you can help, copy and paste this into a personal file.

function WriteCookie() {
  customer = document.getElementById('customer');
  if (customer.innerHTML == "") {
    alert("Enter some value!");
    return;
  }
  cookievalue = escape(customer.innerHTML);
  document.cookie = "name=" + cookievalue;
  console.log("name=" + cookievalue);

  // expires
  var now = new Date();
  now.setMonth(now.getMonth() + 1);

  document.cookie = "expires=" + now.toUTCString() + ";"
  // output = document.getElementById('output');
  // output.innerHTML = cookievalue;
}

function ReadCookie() {
  var allcookies = document.cookie;
  console.log("All Cookies : " + allcookies);

  // Get all the cookies pairs in an array
  cookiearray = allcookies.split(';');

  // Now take key value pair out of this array
  for (var i = 0; i < cookiearray.length; i++) {
    name = cookiearray[i].split('=')[0];
    value = cookiearray[i].split('=')[1];
    console.log("Key is : " + name + " and Value is : " + value);
  }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><html>

<head>
</head>

<body>
  <form name="myform" action="">
    <!-- Enter name: <input type="text" name="customer"/> -->
    <h4>Enter Name:</h4>
    <h4 contenteditable="true" id="customer" style="background-color: #eee"></h4>
    <!-- <h4>Your Name is:</h4>
         <h4 id="output" style="width: 100%; height: 20px; background-color: #ddd;"></h4> -->
    <input type="button" value="Set Cookie" onclick="WriteCookie();" />
    <input type="button" value="Read Cookie" onclick="ReadCookie();" />
  </form>
</body>

</html></code>```

答:
Use localstorage instead.
it's much easier

or:  also sessionStorage is suitable

Title: JavaScript Save Cookies

Body:
I am following a tutorial for cookies and in the tutorial you enter your name, and you can refresh then display your name, so the name is actually saved as a cookie. However when I am trying this in a personal file, the cookie is not being saved if I refresh the page, I can only see the cookie once per session, so how do I save the cookie for as many sessions as I want?

I suppose you can't use cookies in a snippet, but if you can help, copy and paste this into a personal file.

function WriteCookie() {
  customer = document.getElementById('customer');
  if (customer.innerHTML == "") {
    alert("Enter some value!");
    return;
  }
  cookievalue = escape(customer.innerHTML);
  document.cookie = "name=" + cookievalue;
  console.log("name=" + cookievalue);

  // expires
  var now = new Date();
  now.setMonth(now.getMonth() + 1);

  document.cookie = "expires=" + now.toUTCString() + ";"
  // output = document.getElementById('output');
  // output.innerHTML = cookievalue;
}

function ReadCookie() {
  var allcookies = document.cookie;
  console.log("All Cookies : " + allcookies);

  // Get all the cookies pairs in an array
  cookiearray = allcookies.split(';');

  // Now take key value pair out of this array
  for (var i = 0; i < cookiearray.length; i++) {
    name = cookiearray[i].split('=')[0];
    value = cookiearray[i].split('=')[1];
    console.log("Key is : " + name + " and Value is : " + value);
  }
}

  <form name="myform" action="">

Enter Name:

    <input type="button" value="Set Cookie" onclick="WriteCookie();" />
    <input type="button" value="Read Cookie" onclick="ReadCookie();" />
  </form>


问:
jQuery: Enabling a text field based on selecting a certain drop down value
I think I am very close to solving this, but I am going wrong somewhere.

If from the dropdown 'Mercedes' is selected, then the text input should be enabled (note with the actual system there are no class or id names so I have to go by the form name).

I also need it to check on initial page load if this value is set to Mercedes, in that case the input should not be showing either.

This is what I have so far (Fiddle):

HTML:

Your Car:

```<code><select name="car">
  <option value=""></option>
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="mercedes">Mercedes</option>
  <option value="audi">Audi</option>
</select>
<br>
What do you like about your Mercedes?
<input type="text" name="likemercedes">
</code>```

jQuery:

```<code>$("input[type='text'][name='likemercedes']").prop('disabled', true);

if($("input[type='text'][name='car']").val() == "mercedes")
{
    $("input[type='text'][name='likemercedes']").removeAttr('disabled');
}
</code>```

答:
Your Car:

```<code><select abc="facility" >
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>
    <option value="mercedes">Mercedes</option>
    <option value="audi">Audi</option>
</select>

<br>What do you like about your Mercedes?
<input name="test" type="text" id="disabled_input"/>

$(document).ready(function() {
    $('#disabled_input').attr('disabled','disabled');
    $('select[abc="facility"]').on('change',function(){
    var  others = $(this).val();
        if(others == "mercedes"){
            $('#disabled_input').removeAttr('disabled');
        }
        else{
            $('#disabled_input').attr('disabled','disabled');
        }

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

JSFiddle

Body:
I think I am very close to solving this, but I am going wrong somewhere.

If from the dropdown 'Mercedes' is selected, then the text input should be enabled (note with the actual system there are no class or id names so I have to go by the form name).

I also need it to check on initial page load if this value is set to Mercedes, in that case the input should not be showing either.

This is what I have so far (Fiddle):

HTML:

Your Car:

<select name="car">
  <option value=""></option>
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="mercedes">Mercedes</option>
  <option value="audi">Audi</option>
</select>

What do you like about your Mercedes?
<input type="text" name="likemercedes">

jQuery:

$("input[type='text'][name='likemercedes']").prop('disabled', true);

if($("input[type='text'][name='car']").val() == "mercedes")
{
    $("input[type='text'][name='likemercedes']").removeAttr('disabled');
}

Body:
Your Car:

<select abc="facility" >
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>
    <option value="mercedes">Mercedes</option>
    <option value="audi">Audi</option>
</select>

<br>What do you like about your Mercedes?
<input name="test" type="text" id="disabled_input"/>

$(document).ready(function() {
    $('#disabled_input').attr('disabled','disabled');
    $('select[abc="facility"]').on('change',function(){
    var  others = $(this).val();
        if(others == "mercedes"){
            $('#disabled_input').removeAttr('disabled');
        }
        else{
            $('#disabled_input').attr('disabled','disabled');
        }

    });
});

JSFiddle


问:
Do you have any good examples of "architecture for architecture's sake"?
Just listening to this week's podcast and thought it would be nice to group together some of your experiences where you've seen the "architecture" side of design dominate things a little more than it should.

Java often gets a bad press in this respect, and an increasingly bad press as the perceived complexity of Java EE increases. My Java experience against time graph nose-dives significantly after 2004 so I don't feel qualified to comment.

My most recent experience is with an architect desperately trying to accurately represent an object model in a set of (relational) database tables (happened to be Oracle). The result is a database schema that's impossible to query efficiently without first pre-joining a bunch of tables (in materialized views).

答:
In every place I have worked for the last five years!

My official job titles have contained "architect" for the last six years, but, on a grumpy day I am more of an anti-architect, on less grumpy days I am a "minimalist architect".

If there isnt a good staighforward and obvious reason for a component, framework or feature to be there then I drop it!

On the occasions where I have been overruled the extra uneccsary architecural features have always turned out to be the biggest problem area.

OwnerDisplayName: Nick Pierpoint

ContentLicense: CC BY-SA 4.0

LastEditorDisplayName: Nick Pierpoint

OwnerDisplayName: James Anderson


问:
How to shuffle data in python keeping some n number of rows intact
I want to shuffle my data in such manner that each 4 rows remain intact. For example I have 16 rows then first 4 rows can go to last and then second four rows may go to third  and so on in any particular order. I am trying to do thins in python</p>

答:
Setup

Consider the dataframe df

```<code>df = pd.DataFrame(np.random.randint(10, size=(16, 4)), columns=list('WXYZ'))
df

    W  X  Y  Z
0   9  8  6  2
1   0  9  5  5
2   7  5  9  4
3   7  1  1  8
4   7  7  2  2
5   5  5  0  2
6   9  3  2  7
7   5  7  2  9
8   6  6  2  8
9   0  7  0  8
10  7  5  5  2
11  6  0  9  5
12  9  2  2  2
13  8  8  2  5
14  4  1  5  6
15  1  2  3  9
</code>```

Option 1

Inspired by @B.M. and @Divakar

I'm using np.random.permutation because it returns a copy that is a permuted version of what was passed.  This means I can then pass that directly to iloc and return what I need.

```<code>df.iloc[np.random.permutation(np.arange(16).reshape(-1, 4)).ravel()]

    W  X  Y  Z
12  9  2  2  2
13  8  8  2  5
14  4  1  5  6
15  1  2  3  9
0   9  8  6  2
1   0  9  5  5
2   7  5  9  4
3   7  1  1  8
8   6  6  2  8
9   0  7  0  8
10  7  5  5  2
11  6  0  9  5
4   7  7  2  2
5   5  5  0  2
6   9  3  2  7
7   5  7  2  9
</code>```

Option 2

I'd add a level to the index that we can call on when shuffling

```<code>d = df.set_index(np.arange(len(df)) // 4, append=True).swaplevel(0, 1)
d

      W  X  Y  Z
0 0   9  8  6  2
  1   0  9  5  5
  2   7  5  9  4
  3   7  1  1  8
1 4   7  7  2  2
  5   5  5  0  2
  6   9  3  2  7
  7   5  7  2  9
2 8   6  6  2  8
  9   0  7  0  8
  10  7  5  5  2
  11  6  0  9  5
3 12  9  2  2  2
  13  8  8  2  5
  14  4  1  5  6
  15  1  2  3  9
</code>```

Then we can shuffle

```<code>pd.concat([d.xs(i) for i in np.random.permutation(range(4))])

    W  X  Y  Z
12  9  2  2  2
13  8  8  2  5
14  4  1  5  6
15  1  2  3  9
4   7  7  2  2
5   5  5  0  2
6   9  3  2  7
7   5  7  2  9
0   9  8  6  2
1   0  9  5  5
2   7  5  9  4
3   7  1  1  8
8   6  6  2  8
9   0  7  0  8
10  7  5  5  2
11  6  0  9  5
</code>```

Body:
Setup

Consider the dataframe df

df = pd.DataFrame(np.random.randint(10, size=(16, 4)), columns=list('WXYZ'))
df

    W  X  Y  Z
0   9  8  6  2
1   0  9  5  5
2   7  5  9  4
3   7  1  1  8
4   7  7  2  2
5   5  5  0  2
6   9  3  2  7
7   5  7  2  9
8   6  6  2  8
9   0  7  0  8
10  7  5  5  2
11  6  0  9  5
12  9  2  2  2
13  8  8  2  5
14  4  1  5  6
15  1  2  3  9

Option 1

Inspired by @B.M. and @Divakar

I'm using np.random.permutation because it returns a copy that is a permuted version of what was passed.  This means I can then pass that directly to iloc and return what I need.

df.iloc[np.random.permutation(np.arange(16).reshape(-1, 4)).ravel()]

    W  X  Y  Z
12  9  2  2  2
13  8  8  2  5
14  4  1  5  6
15  1  2  3  9
0   9  8  6  2
1   0  9  5  5
2   7  5  9  4
3   7  1  1  8
8   6  6  2  8
9   0  7  0  8
10  7  5  5  2
11  6  0  9  5
4   7  7  2  2
5   5  5  0  2
6   9  3  2  7
7   5  7  2  9

Option 2

I'd add a level to the index that we can call on when shuffling

d = df.set_index(np.arange(len(df)) // 4, append=True).swaplevel(0, 1)
d

      W  X  Y  Z
0 0   9  8  6  2
  1   0  9  5  5
  2   7  5  9  4
  3   7  1  1  8
1 4   7  7  2  2
  5   5  5  0  2
  6   9  3  2  7
  7   5  7  2  9
2 8   6  6  2  8
  9   0  7  0  8
  10  7  5  5  2
  11  6  0  9  5
3 12  9  2  2  2
  13  8  8  2  5
  14  4  1  5  6
  15  1  2  3  9

Then we can shuffle

pd.concat([d.xs(i) for i in np.random.permutation(range(4))])

    W  X  Y  Z
12  9  2  2  2
13  8  8  2  5
14  4  1  5  6
15  1  2  3  9
4   7  7  2  2
5   5  5  0  2
6   9  3  2  7
7   5  7  2  9
0   9  8  6  2
1   0  9  5  5
2   7  5  9  4
3   7  1  1  8
8   6  6  2  8
9   0  7  0  8
10  7  5  5  2
11  6  0  9  5


问:
Compiling custom package for Linux Embedded Development Environment (LEDE) (same as OpenWRT)
Hi all,

Platform: x86_64

I successfully installed a Linux Embedded Development Environment (LEDE) x86/64 (same as OpenWRT) to my virtual machine.

I developed a custom package "Hello World" for Linux Embedded Development Environment (LEDE) with SDK and cross-compiled it . Then, tested it on my virtual machine and it worked.
But, then I have my own code to port that is, for raw packet sniffer in c and I want to port that code. So, I copied same code under that same file that I used for "Hello world" (helloworld.c). Again, I successfully cross-compiled new binary "*.ipk format" then send it on my LEDE virtual machine and did opkg install xxxxxx.ipk. It installed, but same output. I mean "Hello world".

I don't know how. Because, code changed this time. Then, again for testing a wrote a simple factorial code and again . During testing in virtual machine. I found that it didn't work because same output again that is, "Hello world".

Documentation:Hello world package for LEDE using LEDE Source
I am developing using SDK instead of source.I followed every thing in Documentation excluding source compiling and all.

Documentation for SDK: Compile custom package using SDK

Makefile for Hello World code:

```<code>include $(TOPDIR)/rules.mk

# Name, version and release number
# The name and version of your package are used to define the variable to point to the build directory of your package: $(PKG_BUILD_DIR)
PKG_NAME:=helloworld
PKG_VERSION:=1.0
PKG_RELEASE:=1

# Source settings (i.e. where to find the source codes)
# This is a custom variable, used below
SOURCE_DIR:=/home/buildbot/helloworld

include $(INCLUDE_DIR)/package.mk

# Package definition; instructs on how and where our package will appear in the overall configuration menu ('make menuconfig')
define Package/helloworld
  SECTION:=examples
  CATEGORY:=Examples
  TITLE:=Hello, World!
endef

# Package description; a more verbose description on what our package does
define Package/helloworld/description
  A simple "Hello, world!" -application.
endef

# Package preparation instructions; create the build directory and copy the source code.
# The last command is necessary to ensure our preparation instructions remain compatible with the patching system.
define Build/Prepare
        mkdir -p $(PKG_BUILD_DIR)
        cp $(SOURCE_DIR)/* $(PKG_BUILD_DIR)
        $(Build/Patch)
endef

# Package build instructions; invoke the target-specific compiler to first compile the source file, and then to link the file into the final executable
define Build/Compile
        $(TARGET_CC) $(TARGET_CFLAGS) -o $(PKG_BUILD_DIR)/helloworld.o -c $(PKG_BUILD_DIR)/helloworld.c
        $(TARGET_CC) $(TARGET_LDFLAGS) -o $(PKG_BUILD_DIR)/$1 $(PKG_BUILD_DIR)/helloworld.o
endef

# Package install instructions; create a directory inside the package to hold our executable, and then copy the executable we built previously into the folder
define Package/helloworld/install
        $(INSTALL_DIR) $(1)/usr/bin
        $(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(1)/usr/bin
endef

# This command is always the last, it uses the definitions and variables we give above in order to get the job done
$(eval $(call BuildPackage,helloworld))
</code>```

答:
I cross-compiled the same code again and tested it with LinkIt Smart 7688 and everything is working as expected. So, I think something went wrong with that LEDE Virtual Machine that I created for testing.

LinkIt Smart 7688:
It is an open development board which is based on OpenWrt Linux distribution and MT7688.
The platform also offers options to create device applications in
Python, Node.js and C programming language.

So, I think It is one of the best board available for IoT things within 12.90 US  Dollars.

Body:
Hi all,

Platform: x86_64

I successfully installed a Linux Embedded Development Environment (LEDE) x86/64 (same as OpenWRT) to my virtual machine.

I developed a custom package "Hello World" for Linux Embedded Development Environment (LEDE) with SDK and cross-compiled it . Then, tested it on my virtual machine and it worked.
But, then I have my own code to port that is, for raw packet sniffer in c and I want to port that code. So, I copied same code under that same file that I used for "Hello world" (helloworld.c). Again, I successfully cross-compiled new binary "*.ipk format" then send it on my LEDE virtual machine and did opkg install xxxxxx.ipk. It installed, but same output. I mean "Hello world".

I don't know how. Because, code changed this time. Then, again for testing a wrote a simple factorial code and again . During testing in virtual machine. I found that it didn't work because same output again that is, "Hello world".

Documentation:Hello world package for LEDE using LEDE Source
I am developing using SDK instead of source.I followed every thing in Documentation excluding source compiling and all.

Documentation for SDK: Compile custom package using SDK

Makefile for Hello World code:

include $(TOPDIR)/rules.mk

# Name, version and release number
# The name and version of your package are used to define the variable to point to the build directory of your package: $(PKG_BUILD_DIR)
PKG_NAME:=helloworld
PKG_VERSION:=1.0
PKG_RELEASE:=1

# Source settings (i.e. where to find the source codes)
# This is a custom variable, used below
SOURCE_DIR:=/home/buildbot/helloworld

include $(INCLUDE_DIR)/package.mk

# Package definition; instructs on how and where our package will appear in the overall configuration menu ('make menuconfig')
define Package/helloworld
  SECTION:=examples
  CATEGORY:=Examples
  TITLE:=Hello, World!
endef

# Package description; a more verbose description on what our package does
define Package/helloworld/description
  A simple "Hello, world!" -application.
endef

# Package preparation instructions; create the build directory and copy the source code.
# The last command is necessary to ensure our preparation instructions remain compatible with the patching system.
define Build/Prepare
        mkdir -p $(PKG_BUILD_DIR)
        cp $(SOURCE_DIR)/* $(PKG_BUILD_DIR)
        $(Build/Patch)
endef

# Package build instructions; invoke the target-specific compiler to first compile the source file, and then to link the file into the final executable
define Build/Compile
        $(TARGET_CC) $(TARGET_CFLAGS) -o $(PKG_BUILD_DIR)/helloworld.o -c $(PKG_BUILD_DIR)/helloworld.c
        $(TARGET_CC) $(TARGET_LDFLAGS) -o $(PKG_BUILD_DIR)/$1 $(PKG_BUILD_DIR)/helloworld.o
endef

# Package install instructions; create a directory inside the package to hold our executable, and then copy the executable we built previously into the folder
define Package/helloworld/install
        $(INSTALL_DIR) $(1)/usr/bin
        $(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(1)/usr/bin
endef

# This command is always the last, it uses the definitions and variables we give above in order to get the job done
$(eval $(call BuildPackage,helloworld))


问:
Question on my Class implemention in C#
Currently i have a class which has only properties

```<code>class MyEntity
{
    public string FirstName { get; set; }
    public string LastName  { get; set; }
}
</code>```

In my other class, I use to set the values like

```<code>MyEntity objEnt = new MyEntity();
objEnt.FirstName="abc";
objEnt.LastName = "edf";
</code>```

The reason i have the class MyEntity with only properties is to ensure adherence.

Question here is, if this approach is correct? I can have multiple instances of MyEntity

Can i use Static Class for this? How can i use Generics in this?

BTW the implementation is in C#

Thanks in advance

Cheers,

Karthik

答:
As already said it depends from your needs.
Just to note that you can't use static class as you want to have multiple instances and also there can be issues with synchronization while access from multiple threads.

As for generics ... whats for you need it here ?

Title: Question on my Class implemention in C#

Body:
Currently i have a class which has only properties

class MyEntity
{
    public string FirstName { get; set; }
    public string LastName  { get; set; }
}

In my other class, I use to set the values like

MyEntity objEnt = new MyEntity();
objEnt.FirstName="abc";
objEnt.LastName = "edf";

The reason i have the class MyEntity with only properties is to ensure adherence.

Question here is, if this approach is correct? I can have multiple instances of MyEntity

Can i use Static Class for this? How can i use Generics in this?

BTW the implementation is in C#

Thanks in advance

Cheers,

Karthik


问:
Convert number into culture specific
I have a number like  202667.4. I want to convert this to number based on culture.

For Ex:

In "de"(German) the number should be in 202.667,40.

Any help will be greatly appreciated.

Thanks.

答:
You can use Culture info while parsing number into German format

Try with this approach:

```<code>string.Format(System.Globalization.CultureInfo.GetCultureInfo("de-DE"), "{0:000,000.00}", <your number>)
</code>```

for example:

```<code> string result = string.Format(System.Globalization.CultureInfo.GetCultureInfo("de-DE"), "{0:000,000.00}", 202667.4)
</code>```

Title: Convert number into culture specific

Body:
You can use Culture info while parsing number into German format

Try with this approach:

string.Format(System.Globalization.CultureInfo.GetCultureInfo("de-DE"), "{0:000,000.00}", <your number>)

for example:

 string result = string.Format(System.Globalization.CultureInfo.GetCultureInfo("de-DE"), "{0:000,000.00}", 202667.4)


问:
How to extract parts of nested multi-level JSON objects / array and flatten it with JavaScript
I'm working with the following data structure:

```<code>"data": {
    "products": [
        [
            {
                "category": "A",
                "items": [
                    {
                        "name": "Aloe",
                        "price": 10
                    },
                    {
                        "name": "Apples",
                        "price": 5
                    }
                ]
            },
            {
                "category": "B",
                "items": [
                    {
                        "name": "Bread",
                        "price": 5
                    }
                ]
            }
        ],
        [
            {
                "category": "C",
                "items": [
                    {
                        "name": "Candy",
                        "price": 5
                    },
                    {
                        "name": "Crayon",
                        "price": 5
                    }
                ]
            },
            {
                "category": "D",
                "items": [
                    {
                        "name": "Dice",
                        "price": 5
                    },
                    {
                        "name": "Doll",
                        "price": 10
                    }
                ]
            }
        ]
    ]
}
</code>```

I'd like extract parts of it to flatten so the results is as follows:

```<code>[
    {
        "name": "Aloe",
        "price": 10
    },
    {
        "name": "Apples",
        "price": 5
    },
    {
        "name": "Bread",
        "price": 5
    },
    {
        "name": "Candy",
        "price": 5
    },
    {
        "name": "Crayon",
        "price": 5
    },
    {
        "name": "Dice",
        "price": 5
    },
    {
        "name": "Doll",
        "price": 10
    }
]
</code>```

How can I accomplish this?

I have tried this:

```<code>for (var sets in data.products) {
  for (var categories in sets) {
    for (var items in categories) {
      for (var item in items) {
        // assemble new array
      }
    }
  }
}
</code>```

... but had problems looping through the children objects. I've found a couple other similar questions, but they seem to address simpler data structures, and flatten the entire object rather than parts of it.

Any pointers would be appreciated.

答:
I have assigned your JSON object for data to a variable first. See the code below:

```<code>var pro={
    "products": [
        [
            {
                "category": "A",
                "items": [
                    {
                        "name": "Aloe",
                        "price": 10
                    },
                    {
                        "name": "Apples",
                        "price": 5
                    }
                ]
            },
            {
                "category": "B",
                "items": [
                    {
                        "name": "Bread",
                        "price": 5
                    }
                ]
            }
        ],
        [
            {
                "category": "C",
                "items": [
                    {
                        "name": "Candy",
                        "price": 5
                    },
                    {
                        "name": "Crayon",
                        "price": 5
                    }
                ]
            },
            {
                "category": "D",
                "items": [
                    {
                        "name": "Dice",
                        "price": 5
                    },
                    {
                        "name": "Doll",
                        "price": 10
                    }
                ]
            }
        ]
    ]
}
var flatArray=[];
for(var i=0; i<pro.products.length; i++){
  for(var j=0; j<pro.products[i].length;j++){
    for(var k=0; k<pro.products[i][j].items.length;k++){
      flatArray.push(pro.products[i][j].items[k]);
    }
  }
}
</code>```

The flatArray will be your required flattened array of objects. Hope this is clear enough.

Body:
I'm working with the following data structure:

"data": {
    "products": [
        [
            {
                "category": "A",
                "items": [
                    {
                        "name": "Aloe",
                        "price": 10
                    },
                    {
                        "name": "Apples",
                        "price": 5
                    }
                ]
            },
            {
                "category": "B",
                "items": [
                    {
                        "name": "Bread",
                        "price": 5
                    }
                ]
            }
        ],
        [
            {
                "category": "C",
                "items": [
                    {
                        "name": "Candy",
                        "price": 5
                    },
                    {
                        "name": "Crayon",
                        "price": 5
                    }
                ]
            },
            {
                "category": "D",
                "items": [
                    {
                        "name": "Dice",
                        "price": 5
                    },
                    {
                        "name": "Doll",
                        "price": 10
                    }
                ]
            }
        ]
    ]
}

I'd like extract parts of it to flatten so the results is as follows:

[
    {
        "name": "Aloe",
        "price": 10
    },
    {
        "name": "Apples",
        "price": 5
    },
    {
        "name": "Bread",
        "price": 5
    },
    {
        "name": "Candy",
        "price": 5
    },
    {
        "name": "Crayon",
        "price": 5
    },
    {
        "name": "Dice",
        "price": 5
    },
    {
        "name": "Doll",
        "price": 10
    }
]

How can I accomplish this?

I have tried this:

for (var sets in data.products) {
  for (var categories in sets) {
    for (var items in categories) {
      for (var item in items) {
        // assemble new array
      }
    }
  }
}

... but had problems looping through the children objects. I've found a couple other similar questions, but they seem to address simpler data structures, and flatten the entire object rather than parts of it.

Any pointers would be appreciated.

Body:
I have assigned your JSON object for data to a variable first. See the code below:

var pro={
    "products": [
        [
            {
                "category": "A",
                "items": [
                    {
                        "name": "Aloe",
                        "price": 10
                    },
                    {
                        "name": "Apples",
                        "price": 5
                    }
                ]
            },
            {
                "category": "B",
                "items": [
                    {
                        "name": "Bread",
                        "price": 5
                    }
                ]
            }
        ],
        [
            {
                "category": "C",
                "items": [
                    {
                        "name": "Candy",
                        "price": 5
                    },
                    {
                        "name": "Crayon",
                        "price": 5
                    }
                ]
            },
            {
                "category": "D",
                "items": [
                    {
                        "name": "Dice",
                        "price": 5
                    },
                    {
                        "name": "Doll",
                        "price": 10
                    }
                ]
            }
        ]
    ]
}
var flatArray=[];
for(var i=0; i<pro.products.length; i++){
  for(var j=0; j<pro.products[i].length;j++){
    for(var k=0; k<pro.products[i][j].items.length;k++){
      flatArray.push(pro.products[i][j].items[k]);
    }
  }
}

The flatArray will be your required flattened array of objects. Hope this is clear enough.


问:
what is the best practice for forgot password process?
I am currently developing a c# web application that allows users to login with a password. A feature that I need to include is a forgot password function.

What is the recommended process for forgot password?

I was considering this:

User clicks forgot password, enter email address

Email sent

Click on link in email (link only valid once and within time period)

Taken to the site and asked to enter new password (should they also give answer to security question?)

Password changed, email sent to user of such

User now can log in with new password

答:
We have two ways to retrieve the forgot password:
1. Through registered email id
2. Through registered mobile number

Registered Email id:

a. Ask the user to provide the registered email id

b. The system checks the provided email id is available in the DB or not

c. If Email ID is there in the DB then system send the Email to reset the password but if Email id is not there in the DB then system show the alert messaged.

d. The user must provide strong password while resetting the forgot password.

e. Password reset successfully and is also change in the DB with respect to the Email ID.

Registered Mobile number:

The process is almost same as the email but in this case, OTP will be sent over the registered mobile number.
We need to integrate the 3rd part SDK for this or we can use the imessage in IOS.


问:
how to re-arrange divs
```<code><div class="row">
  <div class="pimage clr">
    <img src="./images/portfolio/1.jpg" alt="Avatar" class="image" style="width:100%">
    <div class="middle">
      <div class="text">Onet</div>
    </div>
  </div>
  <div class="pvideo">
    <img src="./images/portfolio/2.jpg" alt="Avatar" class="image" style="width:100%">
    <div class="middle">
      <div class="text">two</div>
    </div>
  </div>
  <div class="pimage">
    <img src="./images/portfolio/3.jpg" alt="Avatar" class="image" style="width:100%">
    <div class="middle">
      <div class="text">three</div>
    </div>
  </div>
</div>
</div>
</code>```

in larger display  i want this to display in the same order, but for tablet i want to display one and three together and two below them.

答:
I would suggest you to use css flexbox

```<code>.item {
  order: <integer>; /* default is 0 */
}
</code>```

It good to understand the concept, so please check the links below.
csstricks

w3school flexbox

Title: how to re-arrange divs

Body:
Onet

two

three

in larger display  i want this to display in the same order, but for tablet i want to display one and three together and two below them.

Body:
I would suggest you to use css flexbox

.item {
  order: <integer>; /* default is 0 */
}

It good to understand the concept, so please check the links below.
csstricks

w3school flexbox