text:
Q: mlock a variable in python I'm working on a password manager application for linux and I'm using Python for it.
Because of the security reasons I want to call mlock system call in order to avoid swapping password variable on hard drive.
I noticed that python itself didn't wrap this function.
so is there any way so can I avoid swapping?
Thanks

A: For CPython, there is no good answer for this that doesn't involve writing a Python C extension, since mlock works on pages, not objects. The internals of the str object differ from version to version (in Py3.3 and higher, a str may actually have several copies of the data in memory in different encodings, some inlined after the object structure, some dynamically allocated separately and linked by pointer), and even if you used ctypes to retrieve the necessary addresses and mlock-ed them all through ctypes mlock calls, you'll have a hell of a time determining when to mlock and when to munlock. Since mlock works on pages, you'd have to carefully track how many strings are currently in any given page (because if you just mlock and munlock blindly, and there are more than one things to lock in a page, the first munlock would unlock all of them; mlock/munlock is a boolean flag, it doesn't count the number of locks and unlocks).
Even if you manage that, you still would have a race between password acquisition and mlock during which the data could be written to swap, and those cached alternate encodings are computed lazily, so mlocking the non-NULL pointers at any given time doesn't necessarily mean those pointers might not be populated later.
You could partially avoid these problems through careful use of the mmap module and memoryviews (mmap gives you pages of memory, memoryview references said memory without copying it, so ctypes could be used to mlock the page), but you'd have to build it all from scratch (can't use the getpass module because it would store as a str for a moment).
In short, Python doesn't care about swapping or memory protection in the way you want; it trusts the swap file to be configured to your desired security (e.g. disabled or encrypted), neither providing additional protection nor providing the information you'd need to add it in.


text:
Q: Application is Crashing when EditText View is Left Empty I have Created three edit text views for Name , body weight and height
Name is taking PersonName Values , body-weight and height are taking number values
i am using the following code to check weather the EditText Views are left empty or not . as you can see below i tried everything to get if the code block is empty but still the application is getting Crashed when i am leaving the editText view empty. WHat could Possibly go wrong ?
if(getName.equals("") || getName.length()<=2 || getName.equals(null) || getName.trim().length()<1)
                        {
                            NameWarning.setText("Please Enter Your Name Correctly");
                        }
                        else if(heightcm.getText().toString().equals("") || heightcm.getText()==null || heightcm.getText().toString().equals(null) || heightcm.getText().toString().trim().length()<1)
                        {
                            HeightWarning.setText("Please Enter Your Height Correctly");
                        }
                        else if(getWeight.getText().toString().equals("") || getWeight.getText().toString()==null || getWeight.getText().toString().equals(null) || getWeight.getText().toString().trim().length()<1)
                        {
                            WeightWarning.setText("Please Enter Your Weight Correctly");
                        }
                        else if (getName.equals("") || heightcm.getText().toString().equals("") || getWeight.getText().toString().equals("") || getName==null || heightcm.getText().toString()==null || getWeight.getText().toString()==null || getName.equals(null) || heightcm.getText().toString().equals(null) || getWeight.getText().toString().equals(null)
                                || getName.trim().length()<1 || heightcm.getText().toString().trim().length()<1 || getWeight.getText().toString().trim().length()<1)
                        {
                            NameWarning.setText("Please Fill Your Details Correctly !!");
                            HeightWarning.setText("Please Fill Your Details Correctly !!");
                            WeightWarning.setText("Please Fill Your Details Correctly !!");
                        }

I am getting this file when the application is getting crashed
// Compiled from Integer.java (version 1.5 : 49.0, super bit)
// Signature: Ljava/lang/Number;Ljava/lang/Comparable<Ljava/lang/Integer;>;
public final class java.lang.Integer extends java.lang.Number implements java.lang.Comparable {

  // Field descriptor #11 I
  public static final int MAX_VALUE = 2147483647;

  // Field descriptor #11 I
  public static final int MIN_VALUE = -2147483648;

  // Field descriptor #11 I
  public static final int SIZE = 32;

  // Field descriptor #19 Ljava/lang/Class;
  // Signature: Ljava/lang/Class<Ljava/lang/Integer;>;
  public static final java.lang.Class TYPE;

  // Method descriptor #23 (I)V
  // Stack: 3, Locals: 2
  public Integer(int value);
     0  aload_0 [this]
     1  invokespecial java.lang.Number() [1]
     4  new java.lang.RuntimeException [2]
     7  dup
     8  ldc <String "Stub!"> [3]
    10  invokespecial java.lang.RuntimeException(java.lang.String) [4]
    13  athrow
      Line numbers:
        [pc: 0, line: 6]
      Local variable table:
        [pc: 0, pc: 14] local: this index: 0 type: java.lang.Integer
        [pc: 0, pc: 14] local: value index: 1 type: int

  // Method descriptor #30 (Ljava/lang/String;)V
  // Stack: 3, Locals: 2
  public Integer(java.lang.String string) throws java.lang.NumberFormatException;
     0  aload_0 [this]
     1  invokespecial java.lang.Number() [1]
     4  new java.lang.RuntimeException [2]
     7  dup
     8  ldc <String "Stub!"> [3]
    10  invokespecial java.lang.RuntimeException(java.lang.String) [4]
    13  athrow
      Line numbers:
        [pc: 0, line: 7]
      Local variable table:
        [pc: 0, pc: 14] local: this index: 0 type: java.lang.Integer
        [pc: 0, pc: 14] local: string index: 1 type: java.lang.String

  // Method descriptor #36 ()B
  // Stack: 3, Locals: 1
  public byte byteValue();
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 8]
      Local variable table:
        [pc: 0, pc: 10] local: this index: 0 type: java.lang.Integer

  // Method descriptor #38 (Ljava/lang/Integer;)I
  // Stack: 3, Locals: 2
  public int compareTo(java.lang.Integer object);
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 9]
      Local variable table:
        [pc: 0, pc: 10] local: this index: 0 type: java.lang.Integer
        [pc: 0, pc: 10] local: object index: 1 type: java.lang.Integer

  // Method descriptor #41 (Ljava/lang/String;)Ljava/lang/Integer;
  // Stack: 3, Locals: 1
  public static java.lang.Integer decode(java.lang.String string) throws java.lang.NumberFormatException;
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 10]
      Local variable table:
        [pc: 0, pc: 10] local: string index: 0 type: java.lang.String

  // Method descriptor #43 ()D
  // Stack: 3, Locals: 1
  public double doubleValue();
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 11]
      Local variable table:
        [pc: 0, pc: 10] local: this index: 0 type: java.lang.Integer

  // Method descriptor #45 (Ljava/lang/Object;)Z
  // Stack: 3, Locals: 2
  public boolean equals(java.lang.Object o);
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 12]
      Local variable table:
        [pc: 0, pc: 10] local: this index: 0 type: java.lang.Integer
        [pc: 0, pc: 10] local: o index: 1 type: java.lang.Object

  // Method descriptor #49 ()F
  // Stack: 3, Locals: 1
  public float floatValue();
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 13]
      Local variable table:
        [pc: 0, pc: 10] local: this index: 0 type: java.lang.Integer

  // Method descriptor #41 (Ljava/lang/String;)Ljava/lang/Integer;
  // Stack: 3, Locals: 1
  public static java.lang.Integer getInteger(java.lang.String string);
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 14]
      Local variable table:
        [pc: 0, pc: 10] local: string index: 0 type: java.lang.String

  // Method descriptor #51 (Ljava/lang/String;I)Ljava/lang/Integer;
  // Stack: 3, Locals: 2
  public static java.lang.Integer getInteger(java.lang.String string, int defaultValue);
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 15]
      Local variable table:
        [pc: 0, pc: 10] local: string index: 0 type: java.lang.String
        [pc: 0, pc: 10] local: defaultValue index: 1 type: int

  // Method descriptor #53 (Ljava/lang/String;Ljava/lang/Integer;)Ljava/lang/Integer;
  // Stack: 3, Locals: 2
  public static java.lang.Integer getInteger(java.lang.String string, java.lang.Integer defaultValue);
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 16]
      Local variable table:
        [pc: 0, pc: 10] local: string index: 0 type: java.lang.String
        [pc: 0, pc: 10] local: defaultValue index: 1 type: java.lang.Integer

  // Method descriptor #55 ()I
  // Stack: 3, Locals: 1
  public int hashCode();
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 17]
      Local variable table:
        [pc: 0, pc: 10] local: this index: 0 type: java.lang.Integer

  // Method descriptor #55 ()I
  // Stack: 3, Locals: 1
  public int intValue();
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 18]
      Local variable table:
        [pc: 0, pc: 10] local: this index: 0 type: java.lang.Integer

  // Method descriptor #58 ()J
  // Stack: 3, Locals: 1
  public long longValue();
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 19]
      Local variable table:
        [pc: 0, pc: 10] local: this index: 0 type: java.lang.Integer

  // Method descriptor #60 (Ljava/lang/String;)I
  // Stack: 3, Locals: 1
  public static int parseInt(java.lang.String string) throws java.lang.NumberFormatException;
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 20]
      Local variable table:
        [pc: 0, pc: 10] local: string index: 0 type: java.lang.String

  // Method descriptor #61 (Ljava/lang/String;I)I
  // Stack: 3, Locals: 2
  public static int parseInt(java.lang.String string, int radix) throws java.lang.NumberFormatException;
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 21]
      Local variable table:
        [pc: 0, pc: 10] local: string index: 0 type: java.lang.String
        [pc: 0, pc: 10] local: radix index: 1 type: int

  // Method descriptor #64 ()S
  // Stack: 3, Locals: 1
  public short shortValue();
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 22]
      Local variable table:
        [pc: 0, pc: 10] local: this index: 0 type: java.lang.Integer

  // Method descriptor #66 (I)Ljava/lang/String;
  // Stack: 3, Locals: 1
  public static java.lang.String toBinaryString(int i);
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 23]
      Local variable table:
        [pc: 0, pc: 10] local: i index: 0 type: int

  // Method descriptor #66 (I)Ljava/lang/String;
  // Stack: 3, Locals: 1
  public static java.lang.String toHexString(int i);
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 24]
      Local variable table:
        [pc: 0, pc: 10] local: i index: 0 type: int

  // Method descriptor #66 (I)Ljava/lang/String;
  // Stack: 3, Locals: 1
  public static java.lang.String toOctalString(int i);
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 25]
      Local variable table:
        [pc: 0, pc: 10] local: i index: 0 type: int

  // Method descriptor #71 ()Ljava/lang/String;
  // Stack: 3, Locals: 1
  public java.lang.String toString();
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 26]
      Local variable table:
        [pc: 0, pc: 10] local: this index: 0 type: java.lang.Integer

  // Method descriptor #66 (I)Ljava/lang/String;
  // Stack: 3, Locals: 1
  public static java.lang.String toString(int i);
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 27]
      Local variable table:
        [pc: 0, pc: 10] local: i index: 0 type: int

  // Method descriptor #72 (II)Ljava/lang/String;
  // Stack: 3, Locals: 2
  public static java.lang.String toString(int i, int radix);
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 28]
      Local variable table:
        [pc: 0, pc: 10] local: i index: 0 type: int
        [pc: 0, pc: 10] local: radix index: 1 type: int

  // Method descriptor #41 (Ljava/lang/String;)Ljava/lang/Integer;
  // Stack: 3, Locals: 1
  public static java.lang.Integer valueOf(java.lang.String string) throws java.lang.NumberFormatException;
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 29]
      Local variable table:
        [pc: 0, pc: 10] local: string index: 0 type: java.lang.String

  // Method descriptor #51 (Ljava/lang/String;I)Ljava/lang/Integer;
  // Stack: 3, Locals: 2
  public static java.lang.Integer valueOf(java.lang.String string, int radix) throws java.lang.NumberFormatException;
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 30]
      Local variable table:
        [pc: 0, pc: 10] local: string index: 0 type: java.lang.String
        [pc: 0, pc: 10] local: radix index: 1 type: int

  // Method descriptor #75 (I)I
  // Stack: 3, Locals: 1
  public static int highestOneBit(int i);
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 31]
      Local variable table:
        [pc: 0, pc: 10] local: i index: 0 type: int

  // Method descriptor #75 (I)I
  // Stack: 3, Locals: 1
  public static int lowestOneBit(int i);
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 32]
      Local variable table:
        [pc: 0, pc: 10] local: i index: 0 type: int

  // Method descriptor #75 (I)I
  // Stack: 3, Locals: 1
  public static int numberOfLeadingZeros(int i);
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 33]
      Local variable table:
        [pc: 0, pc: 10] local: i index: 0 type: int

  // Method descriptor #75 (I)I
  // Stack: 3, Locals: 1
  public static int numberOfTrailingZeros(int i);
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 34]
      Local variable table:
        [pc: 0, pc: 10] local: i index: 0 type: int

  // Method descriptor #75 (I)I
  // Stack: 3, Locals: 1
  public static int bitCount(int i);
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 35]
      Local variable table:
        [pc: 0, pc: 10] local: i index: 0 type: int

  // Method descriptor #81 (II)I
  // Stack: 3, Locals: 2
  public static int rotateLeft(int i, int distance);
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 36]
      Local variable table:
        [pc: 0, pc: 10] local: i index: 0 type: int
        [pc: 0, pc: 10] local: distance index: 1 type: int

  // Method descriptor #81 (II)I
  // Stack: 3, Locals: 2
  public static int rotateRight(int i, int distance);
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 37]
      Local variable table:
        [pc: 0, pc: 10] local: i index: 0 type: int
        [pc: 0, pc: 10] local: distance index: 1 type: int

  // Method descriptor #75 (I)I
  // Stack: 3, Locals: 1
  public static int reverseBytes(int i);
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 38]
      Local variable table:
        [pc: 0, pc: 10] local: i index: 0 type: int

  // Method descriptor #75 (I)I
  // Stack: 3, Locals: 1
  public static int reverse(int i);
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 39]
      Local variable table:
        [pc: 0, pc: 10] local: i index: 0 type: int

  // Method descriptor #75 (I)I
  // Stack: 3, Locals: 1
  public static int signum(int i);
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 40]
      Local variable table:
        [pc: 0, pc: 10] local: i index: 0 type: int

  // Method descriptor #87 (I)Ljava/lang/Integer;
  // Stack: 3, Locals: 1
  public static java.lang.Integer valueOf(int i);
     0  new java.lang.RuntimeException [2]
     3  dup
     4  ldc <String "Stub!"> [3]
     6  invokespecial java.lang.RuntimeException(java.lang.String) [4]
     9  athrow
      Line numbers:
        [pc: 0, line: 41]
      Local variable table:
        [pc: 0, pc: 10] local: i index: 0 type: int

  // Method descriptor #88 (Ljava/lang/Object;)I
  // Stack: 2, Locals: 2
  public bridge synthetic int compareTo(java.lang.Object x0);
    0  aload_0 [this]
    1  aload_1 [x0]
    2  checkcast java.lang.Integer [5]
    5  invokevirtual java.lang.Integer.compareTo(java.lang.Integer) : int [6]
    8  ireturn
      Line numbers:
        [pc: 0, line: 2]
      Local variable table:
        [pc: 0, pc: 9] local: this index: 0 type: java.lang.Integer
        [pc: 0, pc: 9] local: x0 index: 1 type: java.lang.Object

  // Method descriptor #91 ()V
  // Stack: 1, Locals: 0
  static {};
    0  aconst_null
    1  putstatic java.lang.Integer.TYPE : java.lang.Class [7]
    4  return
      Line numbers:
        [pc: 0, line: 47]
}

A: Try out this way:

 if(getName.getText.toString().equals("") || getName.getText().toString().length()<=2 || getName.getText().toString().equals(null) || getName.getText().toString().trim().length()<1)
                    {
                        NameWarning.setText("Please Enter Your Name Correctly");
                    }
                   ..................

Use .getText().toString() for your first if condition also.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Make indexable an ajax based webpage I want to make indexable my ajax based website.
I have read this doc: https://developers.google.com/webmasters/ajax-crawling/docs/getting-started But I don't understand it at all.
I think I need to do it:

*

*Write this tag in a webpage, for example: www.myweb.com/mypage
<meta name="fragment" content="!">

*I'm using UrlRewriteFilter for my Tomcat Server (http://tuckey.org/urlrewrite/), so I think I could redirect the urls with the substring: "?_escaped_fragment_=" to a html snapshot (which I can build manually, writing my custom meta-description, title and content???)
<rule>
   <from>^/mypage\?_escaped_fragment_=</from>
   <to type="forward">/snapshots/mypage.html</to>
</rule>

*Write the URLs (without the escaped fragment) into the sitemap.xml
...
<url>
<loc>www.myweb.com/mypage</loc>
...
</url>
...

Is it right? I need to do something more?

A: Ok, it is right, but the UrlRewriteFilter syntax is a bit different:
<rule>

    <condition name="_escaped_fragment_" type="parameter" operator="equal"></condition>

    <from>^/mypage/</from>

    <to last="true">/snapshots/mypage.html</to>

</rule>


text:
Q: why is BroadcastReceiver called twice from the OnPostExecute in asystask? The Question is Simple that I created Broadcaster class in Fragrment class.
and call Asystask class for my perform.
After execute the class (on onPostExecute method), I send the Broadcaster with intent to Fragment class ONLY ONCE.
However, the result is I got into the OnReiver method 2 times.
(I verified by using Log that I got into the onPostExecute method and send the broadcaster once, But the OnReiver method triggered twice).
Anyone can give me help. It bugs me and wasted so much time.  Thank you
public class Fragment extends Fragment{

@Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

      currentView = inflater.inflate(R.layout.left_panel, container, false);
      mContext = currentView.getContext();
      init();
      return currentView;
  }

  @Override
  public void onResume(){
      super.onResume();
      LocalBroadcastManager.getInstance(getActivity()).registerReceiver(albumListBroadcaster, new IntentFilter(CommonUtilities.BROADCASTEROFALBUMTITLELIST));
  }

  private void init(){

      albumListBroadcaster = new AlbumListBroadcaster();

      setOnClickButtonsEvent();
      clearBtn();
  }

  public void setOnClickButtonsEvent(){
      //modifyBtn.setOnClickListener(new ModifyAccountBtnListener());
      modifyBtn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent intent = new Intent(mContext, WebActivity.class);
                startActivityForResult(intent, REQUESTCODE);
            }
        });
  }

   @Override
    public void onActivityResult(int requestCode, int resultCode, Intent intentData) {

     // TODO Auto-generated method stub
        if(requestCode == REQUESTCODE){
            if(resultCode == RESULT_OK){
                //sendBroadcaster();
                data = this.getActivity().getSharedPreferences(CommonUtilities.SHAREDPREFERENCEURL, 0);
                String usertToken = data.getString("userToken", "");
                String mobileUserId = data.getString("mobileUserId", "");
                String services = intentData.getStringExtra("servicesJSONArray");

                try {
                    JSONArray socialMedias = new JSONArray(services);
                    Log.d("socialMedias", socialMedias.toString());
                    clearBtn();
                    //JSONArray accountInfo = new JSONArray(services);
                    mDisplayPicOnAlbumFragment.onDisplayPicOnAlbumFragment(new JSONArray());
                    if(socialMedias.length() > 0){

                        totalArrayForAlbum = new JSONArray();
                        int lastNum = socialMedias.length();

                        for(int i = 0;i< lastNum;i++){
                            JSONObject one = socialMedias.getJSONObject(i);
                            String socialName = one.getString("service_display_name");
                            activateBtn(i,socialName);
                            String serviceName = one.getString("service_name");
                            Map <String,String> map = new HashMap<String,String>();
                            map.put("userToken", usertToken);
                            map.put("userId", mobileUserId);
                            map.put("serviceName", serviceName);
                            new RequestAlbums(map,getActivity()).execute(CommonUtilities.ALBUMLISTURL);

                        }
                    }else{
                        ArrayList<String> emptyArr = new ArrayList<String>();
                        emptyArr.add(getString(R.string.emptyList));
                        createMenu(emptyArr);

                    }
                } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

            }
        }
     super.onActivityResult(requestCode, resultCode, intentData);
}

public class AlbumListBroadcaster extends BroadcastReceiver{

    String title = "";

    @Override
    public void onReceive(Context context, Intent intent) {
        Log.d("OnRecive","i am here");

       }
}

   public class RequestAlbums extends AsyncTask<Object,Object,String>{

private HttpEntity httpEntity;
private HttpGet httpGet;
private HttpClient httpClient;
private InputStream inputStream;
private HttpResponse httpResponse;
private Map<String,String> param;
private Context mContext;

public RequestAlbums(Map<String,String> param,Context c){
    this.param = param;
    mContext = c;
}

@Override
protected void onPreExecute(){
    // TODO Auto-generated method stub
    super.onPreExecute();
}

 @Override
 protected void onPostExecute(String result) {
        // TODO Auto-gworkenerated method stub
      Log.d("background", result);
      ArrayList<String> resultArr = getOnlyTitle(result);
      Intent intent = new Intent(CommonUtilities.BROADCASTEROFALBUMTITLELIST);
      intent.putStringArrayListExtra("titleList", resultArr);
      intent.putExtra("resultInfo", result);
      //intent.putExtra("titleList", resultArr.toString());

      LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
      //super.onPostExecute(result);
}

@Override
protected String doInBackground(Object... input) {

    ---
}

  }

A: Have you noticed that you have your sendBroadcast() function being called in your onActivityResult?
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intentData) {

 // TODO Auto-generated method stub
    if(requestCode == REQUESTCODE){
        if(resultCode == RESULT_OK){
            sendBroadcaster();


text:
Q: Is it possible to implement Bool using only functions and Sigma? Is it possible to implement the Bool type, including its constructors and dependent eliminator:
Bool      : Set
true      : Bool
false     : Bool
bool-elim : ∀ (P : Bool -> Set) -> P true -> P false -> (b : Bool) -> P b

Using only Sigma and dependent functions? I.e., without using native datatypes?


text:
Q: IBM MFP 8 PushNotification adapter Need to create an adapter using IBM MFP 8 as PUSH ADAPTER to send the notification from App to the user.
Ex: if i confirm/success any steps, send a notification to user that this step completed successfully.
How to do the same ?

A: The push service exposes a REST endpoint for dispatching notifications.
The Java adapter also exposes REST endpoints.
It is unclear why you wish to complicate matters by wrapping the Push service endpoints within an adapter and then let a client access the Java endpoint, which in turn calls the Push endpoint.
Whether you access Java adapter from non-MFP clients or Push service, you still have to go with OAuth token obtained from confidential clients. And Java adapter scopes and Push adapter scopes are very different.
If you really need to do what you are asking, you could do two things:
a) first obtain a token covering all the scopes your Java adapter + Push service needs and then pass this along when calling Java adapter. Within Java adapter, use AuthenticationContext to retrieve the token data and use this to invoke the Push service.
b) obtain a token covering only Java adapter. Once the call is within Java adapter, invoke the token endpoint to obtain a token covering all the scopes Push service needs. Now invoke the Push service separately, with the Push token and dispatch the notification.


text:
Q: Pointer in C++ copy constructor I try to learn copy constructors principle.
I have this code and I need to COPY data to testB data type.
Right now, I only copy pointers to previous memory but I need to copy all data.
Can you help me?
#include <cstdio>
#include <stdio.h>

struct Test {
    int i, *p;

    Test(int i): i(i), p(new int[i]){

        p[0] = 1;
        p[1] = 2;
        p[2] = 3;

    }
    ~Test() {

    }
};
struct TestB : Test {

    TestB(const Test &test) : Test(test){
        p = new int[3];
        p[0] = test.p[0];
        p[1] = test.p[1];
        p[2] = test.p[2];
        i = test.i;
    }
};

int main(){
    Test test(3);
    TestB b = test;

    return 0;
}

A: First off, what you are trying to implement is a converting constructor, not a copy constructor, since you are trying to convert a Test object into a TestB object, rather than create a copy of a TestB object from another TestB object.
Since the array exists in Test, you should implement an actual copy constructor (and a copy assignment operator) in Test, and then TestB's converting constructor can call Test's copy constructor.  Test's copy constructor can then allocate a new array that has the same number of items as the array being copied, and copy the values from the original array into the new array, eg:
#include <utility>

struct Test {
    int i, *p;

    Test(int i): i(i), p(new int[i]) {
        for(int j = 0; j < i; ++j)
            p[j] = j+1;
    }

    Test(const Test &src): i(src.i), p(new int[src.i]) {
        for(int j = 0; j < i; ++j)
            p[j] = src.p[j];
    }

    ~Test() {
        delete[] p;
    }

    // don't forget an assignment operator too, per the Rule of 3:
    // https://en.cppreference.com/w/cpp/language/rule_of_three
    Test& operator=(const Test &rhs) {
        if (this != &rhs) {
            Test tmp(rhs);
            std::swap(i, tmp.i);
            std::swap(p, tmp.p);
        }
        return *this;
    }
};

struct TestB : Test {
    TestB(const Test &test) : Test(test) {}
};

int main(){
    Test test(3);
    TestB b = test;
    return 0;
}

That being said, you should use std::vector instead of new[], then you get all of the array management for free since std::vector already implements everything for you, eg:
#include <vector>

struct Test {
    std::vector<int> p;

    Test(int i): p(i) {
        for(int j = 0; j < i; ++j)
            p[j] = j+1;
    }
};

struct TestB : Test {
    TestB(const Test &test) : Test(test) {}
};

int main(){
    Test test(3);
    TestB b = test;
    return 0;
}


text:
Q: Left Join with Case Hi I am new to sql I am using PHP myadmin I am wondering if you someone could teach or help me how to put left join condition with case condition in query because individually both query is working fine but when mixed together it is not working
here is the query
SELECT id, address,
        CASE
            WHEN <condition here>
            WHEN <condition here>
        END AS con1
FROM tblA WHERE address != ''

query to left join without case
SELECT tblA.id as Id, tblA.Address as Address, tblB.Status as Status
FROM tblA
LEFT JOIN tblB ON tblA.id=tblB.location

output for this query is
   id         Address     Status
    1222       add1       completed
    1332       add2       used
    1332       add2       completed
    1555       add3
    1776       add4

I am finding hard time to join the sql query together can anyone explain or teach me how I am trying to put it like this
SELECT tblA.id, tblA.address, tblB.Status,

CASE WHEN address = 'vip' THEN 'vip'
        ELSE NULL END AS con1

    FROM tblA  LEFT JOIN tblB ON tblA.id=tblB.location

which is incorrect


text:
Q: RSelenium: Error while downloading files with Chrome I am using RSelenium to download a number of .xls files. I was able to get a somewhat passable solution using the following code to set up the server, which specifies not to create a pop-up when I click on the download link and where to download the file to. However, without fail, once I download the 101st file (saved as "report (100).xls) the download pop-up begins appearing in the browser Selenium is driving.
eCaps <- list(
  chromeOptions =
    list(prefs = list(
      "profile.default_content_settings.popups" = 0L,
      "download.prompt_for_download" = FALSE,
      "download.default_directory" = "mydownloadpath"
    )
    )
)

rd <- rsDriver(browser = "chrome", port=4566L, extraCapabilities = eCaps)

The function to download then looks like:
vote.downloading <- function(url){

  #NB: this function assumes browser already up and running, options set correctly

  Sys.sleep(1.5)

  browser$navigate(url)

  down_button <- browser$findElement(using="css",
                                     "table:nth-child(4) tr:nth-child(3) a")
  down_button$clickElement()

}

For reference, the sites I'm getting the download from look like this: http://www.moscow_city.vybory.izbirkom.ru/region/moscow_city?action=show&root=774001001&tvd=4774001137463&vrn=4774001137457&prver=0&pronetvd=null&region=77&sub_region=77&type=427&vibid=4774001137463
The link being used for the download reads "Версия для печати" for those who don't know Russian.
I can't simply stop the function when the dialog begins popping up and pick up where I left off, because it's part of a larger function that scrapes links from drop-down menus that lead to the sites from the download link. This would also be extremely annoying, as there are 400+ files to download.
Is there some way I can alter the Chrome profile or my scraping function to prevent the system dialog from popping up every 101 files? Or is there a better way altogether to get these files downloaded?

A: No need for Selenium:
library(httr)

httr::GET(
  url = "http://www.moscow_city.vybory.izbirkom.ru/servlet/ExcelReportVersion",
  query = list(
    region="77",
    sub_region="77",
    root="774001001",
    global="null",
    vrn="4774001137457",
    tvd="4774001137463",
    type="427",
    vibid="4774001137463",
    condition="",
    action="show",
    version="null",
    prver="0",
    sortorder="0"
  ),
  write_disk("/tmp/report.xls"), ## CHANGE ME
  verbose()
) -> res

I save it off to an object so you can run warn_for_status() or other such checks.
It shld be straightforward to wrap that in a function with parameters to make it more generic.


text:
Q: created an Hyperlink to a specific Sheet after filling a form (excel VBA) I explain my problem:
I have a form in which I register the name of my Supplier and the delivery note number. This data is then saved in a SupplierSheet specific to this supplier (each supplier has its own evaluation sheet), a copy of the form is printed in pdf format before it is reset to 0.
I would like to create a hyperlink that does the following:  open the corresponding pdf file by clicking on the hyperlink (Hyperlink=delivery note number corresponding to a supplier delivery).
I currently have a code that works but without hyperlink. I would like to replace ActiveCell.value = Lieferschein_Nr with ActiveCell.value = Hyperlink to my pdf. Here is my code (sorry for some german words in it):
Dim Datum As String, Lieferschein_Nr As String, No As Integer, Wareneingang_bewertung As String, Ist_Menge As String, Qualitätsprüfung_bewertung As String, bestellnummer As Double, Sage_Nr As String, Liefermenge As Double, Lieferant As String
Dim Chemin, lien, lien2 As String, c As Range
Worksheets("Wareneingangsbewertung").Select ' select the worksheet Wareneingangsbewertung and extract the important values
'Following values are important for the analysis
Datum = Range("D1")
Lieferschein_Nr = Range("B5")
Wareneingang_bewertung = Range("D8")
Mengeprüfung_bewertung = Range("D15")
Qualitätsprüfung_bewertung = Range("D19")
bestellnummer = Range("B4")
Sage_Nr = Range("B6")
Liefermenge = Range("D5")
Lieferant = Range("B1")
Ist_Menge = Range("D6")

'Preview if needed
'Sheets(Array("Wareneingangsbewertung")).PrintPreview

Worksheets("Wareneingangsbewertung").Activate

box1 = MsgBox("Wollen Sie  Daten übertragen und drucken?", vbYesNo) ' Confirmation Message asking if the Process should start and save the value in the differents sheets
If box1 = vbNo Then 'If no we exit the Programm and stay on the Wareneingangsbewertung Page to make changes
Exit Sub
End If

      Dim cell As Range, cell2 As Boolean
    For Each cell In Range("B1,B4,B5,B6,D2,D5,D6,B9,B10,B11,B12,B13,B16,B20") ' define this cells as important cells. Those Cells have to be fullfilled or the programm wont save the values in the other sheets
        If cell.value = "" Then
            'Selektion auf die Zelle setzen
            cell.Select
            MsgBox "Das Pflichtfeld in Zelle " & cell.Address & " wurde nicht ausgefüllt!", vbExclamation ' When the Field isn't complited an Message will pop up and aks the user to fill the missing cells
        cell2 = True
        End If
        Next ' Go to the next cell without value
        If cell2 = True Then
       Exit Sub ' exit the programme once all the requested fields that need to be filled were shown. The user cann fill them again
        End If
        If cell2 = False Then ' Once all the requested field were correctly fild the programm can start. All the value are being copied in the differents sheets

' When all the requested fields are filled and the user selects YES the Process can start
If box1 = vbYes Then
MsgBox "Daten werden übertragen." & Chr(13) & Chr(10) & Chr(13) & Chr(10) & "Formular wird gedruckt." ' Message showing the beginning of the programm
Dim xRg As Excel.Range ' define the object xRg as range
Dim wSh As Excel.Worksheet ' define the object wBk as worksheet
Dim wBk As Excel.Workbook ' define the object wBk as workbook

Set wSh = Worksheets("Choices") ' Set the active worksheet as Choices
Set wBk = ActiveWorkbook ' In this worksbook
Application.ScreenUpdating = False
For Each xRg In wSh.Range("E3:E72") ' Do the process for all the suppliers presents in the  List in the Sheet Choices
With wBk

If Worksheets("Wareneingangsbewertung").Range("B1") = xRg.value Then ' If the Worksheet ist the same as the Supplier name then the process can start
Worksheets(xRg.value).Select ' xRG.Value is the name of the sheet/ supplier sheet
Worksheets(xRg.value).Range("B11").Select ' select B11 , the first cell for the supplier evaluation
If Worksheets(xRg.value).Range("B11").Offset(1, 0) <> "" Then ' Fill the first cells that is free. If B11 or the following are filled then we go to the next free cell
Worksheets(xRg.value).Range("B11").End(xlDown).Select ' go down
End If

ActiveCell.Offset(1, 0).Select 'move from the active cell once to one under
ActiveCell.value = Datum 'put the date

ActiveCell.Offset(0, 1).Select 'move from the active cell once to the right
ActiveCell.value = Lieferschein_Nr
"...."
End If

On Error GoTo 0
End With
Next xRg 'Go to the next Range
Application.ScreenUpdating = False
' print in pdf
Worksheets("Wareneingangsbewertung").Activate
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="D:\Tool Supplier Evaluation\" & Range("B5").value & ".pdf" ' => Part that work well

' Code i tried but that doesn't work

hypertexteChemin = "D:\Tool Supplier Evaluation\"
lien = Chemin & Worksheets("Wareneingangsbewertung").Range("B5").value
ActiveCell.value = ActiveSheet.Hyperlinks.Add(ActiveCell, Address:="", SubAddress:=lien, TextToDisplay:=Worksheets("Wareneingangsbewertung").Range("B5").value)


text:
Q: How to get files count from particular library? I'm using Sharepoint 2007 and unfortunately don't have any ways to server site scripting, no C# or PowerShell.

*

*Is there any way to get total number of files in a given Library using SPServices ?

*It would be great if I could also access files attributes. So for instance I have attribute called 'FileType' use to store technical type of the document. Lets say 'TECH1', 'TECH2', 'TECHN' I would want to get count of files with only FileType =  'TECH2'.

*Also attribute  'Modified'. Any chance to loop through files in a library and count all files older than for instance today - 365 days ?
Maybe it can be done  easier than SPServices ? I'm not that much web programmer :(
I was playing around with:
myObject = new ActiveXObject("Scripting.FileSystemObject");
f = myObject.GetFolder("\\\\mysite\\sites\\space\\Library\\");
myDate.setDate(myDate.getDate()-365);
var FSo = new Enumerator(f.Files);
for(i=0;!FSo.atEnd();FSo.moveNext())`

But this turned out to be dead end working from my local but not on the server
Updated code:
I've just did what you wrote and put the code on the server like below but nothing is being display.
How do I check response xml ?
Thanks
<script language="javascript" type="text/javascript">

var soapEnv = "<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>
<soap:Body>
<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>
    <listName>Library</listName>
   <query>
   <Query>
<Where>
  <Lt>
     <FieldRef Name='Modified' />
     <Value Type='DateTime'>
        <Today  Offset = '-15' />
     </Value>
  </Lt>
</Where>
</Query></query>
</GetListItems>
</soap:Body>";

$.ajax({
url: "/_vti_bin/lists.asmx",
type: "POST",
dataType: "xml",
data: soapEnv,
complete: ProcessListItems,
contentType: "text/xml; charset=\"utf-8\""
});

function ProcessListItems(xData, status) {
//to count items
var itemCount=$(xData.responseXML).find("z\\:row").length;
//to iterate through items
$(xData.responseXML).find("z\\:row").each(function()
{
alert(itemCount);
}

</script>

A: You can use lists.asmx web service to achieve the task from client side using ajax call, navigate to http:// yoursitename/_vti_bin/lists.asmx and find GetListItems, or you can directly navigate to http:// yoursitename/_vti_bin/lists.asmx?op=GetListItems , check the soap header format and construct your ajax, you can easily get file attributes, count of files. And you can always use CAML query to filter the data as you wish. Let me know if you need any further help.

Sample code
first construct the soap envelope
var soapEnv = "<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>
<soap:Body>
<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>
    <listName>Your Doc Library Name</listName>
    <query><Query>Your caml query goes here</Query></query>
</GetListItems>
</soap:Body>";

then ajax call -
$.ajax({
url: "/_vti_bin/lists.asmx",
type: "POST",
dataType: "xml",
data: soapEnv,
complete: ProcessListItems,
contentType: "text/xml; charset=\"utf-8\""
});

and in the ProcessListItems you can do whatever you wish -
function ProcessListItems(xData, status) {
//to count items
var itemCount=$(xData.responseXML).find("z\\:row").length;
//to iterate through items
$(xData.responseXML).find("z\\:row").each(function(){//your logic here});}

have a look at raw response xml to know how you can retrieve one specific xml attribute, in general if you wish to retrieve say TECH field of a record inside .each function it should be like - $(this).attr('ows_TECH') but please have a look at response xml to be sure
and for CAML part if you need help, you can check this

Your CAML will look like
<Query>
<Where>
  <Lt>
     <FieldRef Name='Modified' />
     <Value Type='DateTime'>
        <Today  Offset = '-365' />
     </Value>
  </Lt>
</Where>
</Query>

But please do check for correctness, I have not tested it


text:
Q: Building multiple CPP files with mpic++ fails I'm a newbie in using MPI, and I want to run my cpp project with mpi. I have a main cpp file which includes the main mpi stuff, and two other cpp files that are needed (and being called) in the main one.
In Ubuntu, I am doing:
mpic++ -o mainFile.cpp otherFile1.cpp otherFile2.cpp
But I am getting this error:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x24): undefined reference to `main' collect2: error: ld returned 1 exit status
I have mpic++ installed and I can run some other (one cpp file and very simple) projects, but not this one.
Could you please help?


text:
Q: Keras multi input one shared embedding layer Is it possible to simply share one embedding layer with one input with multiple features ?
Is it possible to avoid to create multiple inputs layers one by feature.
I would like to avoid to create 34 input layers (one by feature).
The goal is to pass throw one embedding layer 34 feature sequence, get 34 embedded vector sequences. Concatenate them to obtain one super feature vector sequence. And then feed a LSTM.
input shape (None,100,34) -> Embedding_layer_size_64 -> (None,100, 34*64) -> LSTM -> softmax
hope it's clear

A: The Solution:
# Shared embedding
embedding_layer = Embedding(input_dim = vocab_size+1, output_dim = emb_dim, input_length = nb_timesteps, mask_zero = True)

# For every features we have it's own input
feature_inputs = [Input(shape=(nb_timesteps, ), name='feature_' + str(i + 1)) for i in range(nb_features)]

# Repeat this for every feature
feature_embeddings = [embedding_layer(f) for f in feature_inputs]

# Concatenate the embedding outputs
concatenated_embeddings = concatenate(feature_embeddings, axis=-1)

lstm_1 = LSTM(output_dim)(concatenated_embeddings)

output_layer = Dense(nb_classes, activation='softmax')(lstm_1)

model = Model(inputs=feature_inputs, outputs=output_layer, name="Multi_feature_Embedding_LSTM")


text:
Q: Multi select drop down list in UWP I want multi select drop down list for my mvvm cross UWP app. So is there any predefined control? Or I need to implement custom control to achieve this.
Any help or suggestions would be appreciated.
Thank You

A: Surprised that such common scenario is still not supported by built-in UWP ComboBox and that I couldn't found any working solutions anywhere.
Here is my minimal solution in case anyone else is looking.
XAML:
<UserControl
    x:Class="MonoTorrent.GUI.Controls.MultiSelectComboBox"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300"
    d:DesignWidth="400">

    <StackPanel x:Name="rootElement" Orientation="Vertical" Margin="0">
        <Button x:Name="comboBoxButton" BorderBrush="Gray" BorderThickness="2" Background="Transparent"
                VerticalAlignment="Top" Click="ComboBoxButton_Click"
                HorizontalAlignment="Stretch" FontSize="14" MinHeight="26" Height="26" Padding="0"
                Width="{Binding ElementName=rootElement, Path=ActualWidth}">
            <Grid VerticalAlignment="Stretch" Width="{Binding ElementName=rootElement, Path=ActualWidth}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="32" />
                </Grid.ColumnDefinitions>
                <TextBlock x:Name="SelectedValueTextBlock"
                            Grid.Column="0" VerticalAlignment="Center" FontSize="15" HorizontalAlignment="Left" Padding="7,0,0,0" />
                <FontIcon Grid.Column="1" FontSize="12" FontFamily="Segoe MDL2 Assets" Glyph="" HorizontalAlignment="Right"
                                                Margin="0,5,10,5" VerticalAlignment="Center" />
            </Grid>
        </Button>
        <Popup x:Name="comboBoxPopup" IsLightDismissEnabled="True">
            <Border BorderBrush="{ThemeResource ComboBoxDropDownBorderBrush}"
                                BorderThickness="{ThemeResource ComboBoxDropdownBorderThickness}"
                                Background="{ThemeResource ComboBoxDropDownBackground}"
                                HorizontalAlignment="Stretch">
                <ListView x:Name="listView"
                    SelectionMode="Multiple"
                    SingleSelectionFollowsFocus="False"
                    SelectionChanged="ListView_SelectionChanged">
                </ListView>
            </Border>
        </Popup>
    </StackPanel>
</UserControl>

C#:
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

namespace MonoTorrent.GUI.Controls
{
    public sealed partial class MultiSelectComboBox : UserControl
    {
        #region ItemsSource dependency property
        public object ItemsSource
        {
            get { return GetValue(ItemsSourceProperty); }
            set
            {
                SetValue(ItemsSourceProperty, value);
                listView.ItemsSource = value;
            }
        }

        public static readonly DependencyProperty ItemsSourceProperty =
            DependencyProperty.Register("ItemsSource", typeof(object), typeof(MultiSelectComboBox), new PropertyMetadata(new List<object>(), OnItemsSourcePropertyChanged));

        private static void OnItemsSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            MultiSelectComboBox instance = d as MultiSelectComboBox;
            if (instance != null && e.NewValue != null)
            {
                instance.listView.ItemsSource = e.NewValue;
            }
        }
        #endregion

        #region ItemTemplate dependency property
        public DataTemplate ItemTemplate
        {
            get { return (DataTemplate)GetValue(ItemTemplateProperty); }
            set
            {
                SetValue(ItemTemplateProperty, value);
                listView.ItemTemplate = value;
            }
        }

        public static readonly DependencyProperty ItemTemplateProperty =
            DependencyProperty.Register("ItemTemplate", typeof(DataTemplate), typeof(MultiSelectComboBox), new PropertyMetadata(null, OnItemTemplatePropertyChanged));

        private static void OnItemTemplatePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            MultiSelectComboBox instance = d as MultiSelectComboBox;
            if (instance != null && e.NewValue as DataTemplate != null)
            {
                instance.listView.ItemTemplate = (DataTemplate)e.NewValue;
            }
        }
        #endregion

        #region SelectedItems dependency property
        public IList<object> SelectedItems
        {
            get { return (IList<object>)GetValue(SelectedItemsProperty); }
            set { SetValue(SelectedItemsProperty, value); }
        }

        public static readonly DependencyProperty SelectedItemsProperty =
            DependencyProperty.Register("SelectedItems", typeof(IList<object>), typeof(MultiSelectComboBox), new PropertyMetadata(new List<object>()));
        #endregion

        #region PopupHeight dependency property
        public double PopupHeight
        {
            get { return (double)GetValue(PopupHeightProperty); }
            set
            {
                SetValue(PopupHeightProperty, value);
                if (value != 0)
                {
                    listView.Height = value;
                }
            }
        }

        public static readonly DependencyProperty PopupHeightProperty =
            DependencyProperty.Register("PopupHeight", typeof(double), typeof(MultiSelectComboBox), new PropertyMetadata(0.0, OnPopupHeightPropertyChanged));

        private static void OnPopupHeightPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            MultiSelectComboBox instance = d as MultiSelectComboBox;
            if (instance != null && (double)e.NewValue != 0)
            {
                instance.listView.Height = (double)e.NewValue;
            }
        }
        #endregion

        #region PopupWidth dependency property
        public double PopupWidth
        {
            get { return (double)GetValue(PopupWidthProperty); }
            set
            {
                SetValue(PopupWidthProperty, value);
                if (value != 0)
                {
                    listView.Width = value;
                }
            }
        }

        public static readonly DependencyProperty PopupWidthProperty =
            DependencyProperty.Register("PopupWidth", typeof(double), typeof(MultiSelectComboBox), new PropertyMetadata(0.0, OnPopupWidthPropertyChanged));

        private static void OnPopupWidthPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            MultiSelectComboBox instance = d as MultiSelectComboBox;
            if (instance != null && (double)e.NewValue != 0)
            {
                instance.listView.Width = (double)e.NewValue;
            }
        }
        #endregion

        #region NoSelectionText dependency property
        public string NoSelectionText
        {
            get { return (string)GetValue(NoSelectionTextProperty); }
            set { SetValue(NoSelectionTextProperty, value); }
        }

        public static readonly DependencyProperty NoSelectionTextProperty =
            DependencyProperty.Register("NoSelectionText", typeof(string), typeof(MultiSelectComboBox), new PropertyMetadata("No selection"));
        #endregion

        #region MultipleSelectionTextFormat dependency property
        public string MultipleSelectionTextFormat
        {
            get { return (string)GetValue(MultipleSelectionTextFormatProperty); }
            set { SetValue(MultipleSelectionTextFormatProperty, value); }
        }

        public static readonly DependencyProperty MultipleSelectionTextFormatProperty =
            DependencyProperty.Register("MultipleSelectionTextFormat", typeof(string), typeof(MultiSelectComboBox), new PropertyMetadata("{0} selected"));
        #endregion

        public MultiSelectComboBox()
        {
            this.InitializeComponent();
            this.Loaded += MultiSelectComboBox_Loaded;
        }

        private void MultiSelectComboBox_Loaded(object sender, RoutedEventArgs e)
        {
            this.UpdateSelectionText();
        }

        private void ComboBoxButton_Click(object sender, RoutedEventArgs e)
        {
            listView.SelectedItems.Clear();
            foreach (var item in SelectedItems)
            {
                listView.SelectedItems.Add(item);
            }
            this.comboBoxPopup.IsOpen = true;
        }

        private void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (!comboBoxPopup.IsOpen)
            {
                return;
            }

            this.SelectedItems = listView.SelectedItems.ToList();
            UpdateSelectionText();
        }

        private void UpdateSelectionText()
        {
            if (this.SelectedItems == null || this.SelectedItems.Count == 0)
            {
                this.SelectedValueTextBlock.Text = NoSelectionText;
            }
            else if (this.SelectedItems.Count == 1)
            {
                this.SelectedValueTextBlock.Text = this.SelectedItems.First().ToString();
            }
            else
            {
                this.SelectedValueTextBlock.Text = String.Format(MultipleSelectionTextFormat, this.SelectedItems.Count);
            }
        }
    }
}

Usage:
<controls:MultiSelectComboBox x:Name="MultiSelectComboBox"
    ItemsSource="{Binding Values}"
    SelectedItems="{Binding SelectedValues, Mode=TwoWay}"
    NoSelectionText="{Binding EmptySelectionString}"
    MultipleSelectionTextFormat="{Binding MultipleSelectedFormatString}"
    PopupHeight="500" PopupWidth="200"
    HorizontalAlignment="Stretch" FontSize="14" MinHeight="26" Height="26">
    <controls:MultiSelectComboBox.ItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding}" />
        </DataTemplate>
    </controls:MultiSelectComboBox.ItemTemplate>
</controls:MultiSelectComboBox>

Notes:

*

*In current state can only be bound to a primitive type collection
like List< String >.

*SelectedValues has to be List< object >, you can use
Cast< T > to convert from List< String >.

A: There is no built-in multi-select combobox in UWP, but you can build your own like this - Issue with multiselect combobox control in Windows 8 .
Basically you can add checkboxes to each item in a combobox and create a logic that will gather the selected items and provide a bindable way to access them.
To make it even simpler, you can create a special class that will have a IsChecked property and just add the checkbox with two-way binding to this property. This will ensure checking of the box in the UI will be reflected in the class and you can then just enumerate all the items to find those that have IsChecked set to true.

A: I would build it something like this...
First build your class
public class MultiSelectComboBox : ComboBox
{
    public List<ComboBoxItem> SelectedItems
    {
        get { return (List<ComboBoxItem>)GetValue(SelectedItemsProperty); }
        set { SetValue(SelectedItemsProperty, value); }
    }

    public static readonly DependencyProperty SelectedItemsProperty =
        DependencyProperty.Register("SelectedItems", typeof(List<ComboBoxItem>), typeof(MultiSelectComboBox), new PropertyMetadata(new List<ComboBoxItem>()));

    public static void SetIsSelected(UIElement element, bool value)
    {
        element.SetValue(IsSelectedProperty, value);
    }
    public static bool GetIsSelected(UIElement element)
    {
        return (bool)element.GetValue(IsSelectedProperty);
    }

    public static readonly DependencyProperty IsSelectedProperty =
        DependencyProperty.RegisterAttached("IsSelected", typeof(bool), typeof(ComboBoxItem), new PropertyMetadata(false, OnIsSelectedChanged));

    public static void SetParentComboBox(UIElement element, MultiSelectComboBox value)
    {
        element.SetValue(ParentComboBoxProperty, value);
    }
    public static MultiSelectComboBox GetParentComboBox(UIElement element)
    {
        return (MultiSelectComboBox)element.GetValue(ParentComboBoxProperty);
    }

    public static readonly DependencyProperty ParentComboBoxProperty =
        DependencyProperty.RegisterAttached("ParentComboBox", typeof(MultiSelectComboBox), typeof(MultiSelectComboBox), new PropertyMetadata(null));

    protected override DependencyObject GetContainerForItemOverride()
    {
        ComboBoxItem comboBoxitem = new ComboBoxItem();
        MultiSelectComboBox.SetParentComboBox(comboBoxitem, this);
        return comboBoxitem;
    }

    private static void OnIsSelectedChanged(object comboBoxItem, DependencyPropertyChangedEventArgs args)
    {
        ComboBoxItem item = comboBoxItem as ComboBoxItem;

        if (item != null)
        {
          MultiSelectComboBox parent = MultiSelectComboBox.GetParentComboBox(item);
          if (MultiSelectComboBox.GetIsSelected(item))
          {
              parent.SelectedItems.Add(item);
          }
          else
          {
              parent.SelectedItems.Remove(item);
          }
        }
    }

}

Then create your items template
    <local:MultiSelectComboBox ItemsSource="{Binding Items}" SelectedItems="{Binding SelectedItems, Mode=TwoWay}">
        <local:MultiSelectComboBox.ItemTemplate>
            <DataTemplate>
                <CheckBox Content="{Binding ItemContent}" IsChecked="{Binding RelativeSource={RelativeSource AncestorType=ComboBoxItem}, Path=IsSelected, Mode=TwoWay}"/>
            </DataTemplate>
        </local:MultiSelectComboBox.ItemTemplate>
    </local:MultiSelectComboBox>

However, this might take some massaging to get working. In the end you want to subclass Combobox and make it do some new stuff.


text:
Q: Add eventlistener to a class? I'm trying to add a eventlistener to a class but it's not working at all, I have done the same method with ID's and it worked perfectly but it's not working for classes. I'm still kinda new to Javascript so I apologize if it's something very simple.
const boxes = document.getElementsByClassName('box_img');

boxes.addEventListener("click", function(){
    console.log('Hi');
    });


text:
Q: Does Cloudant on Bluemix have a performance issue? I have a mobile app using Cloudant CDTReplicator to synch the local datastore and the remote DB. The app was fast at the start, but then the synch would take more than 10 seconds when there are just 180 normal documents, each having a few string fields in the remote DB. And the delta between the local and remote is minimal.
After I deleted all the 180 documents, it speeds up greatly. So looks like it is related to number of documents.
Can you please let me know if there is a performance issue with Cloudant replication? Or this is a problem with my coding? The code is just to start the replicator, not much there.
Thank you,
Jen

A: From the status page https://developer.ibm.com/bluemix/support/#status Cloudant is reported as having some issues on US-South. The problem is related though to a "service broker timeout" generic message.


text:
Q: sending mails with different domain names in python I'm getting "SMTP AUTH extension not supported by server" while sending mails with different domain names.
For example, I have sent mails using person@example.com. Here my domain is example.com.
when I trying send mail I am getting "SMTP AUTH extension not supported by server" error
here is my code
settings.py
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.somedomain.com'
EMAIL_HOST_USER = 'Admin@somedomain.com'
EMAIL_HOST_PASSWORD = '***********'
EMAIL_PORT = 25
EMAIL_USE_TLS = True

views.py
msg = "Hi,this is testing mail."
try:
    send_mail('Appointment mail',msg,'',['user@somedomain.com'])
    response = 'Message sent successfully.You will receive response in very soon.Thank you.'
except Exception as e:
    response = e
return HttpResponse(response)

Can anyone help me, Thanks in advance!

A: I think this could help you. Getting 'str' object has no attribute 'get' in Django. You cannot return 'str' directly as a response. You need HttpResponse
from django.http import HttpResponse
return HttpResponse(response)

Hope this helps.


text:
Q: Iterate using auto&& in for loop In clion 2017.1 when I choose live template for iterating a range (Ctrl+J iter), then I get the following code:
for (auto &&item : __) {

}

Is it really a good idea to use forwading reference as iteration object? If its used as a live template then maybe it is becoming a standard?


text:
Q: How to add a CSS table-striped class to dynamically generated row in jQuery Datatable? So I know that if you do addClass(myCSSClass), it should add said class to the datatable row.
My problem is that this doesn't seem to work.
My code is like below:
var table = ('#datatable').Datatable();
table.row.add(['<button type="button" id="Details">A button</button>']).addClass("success").draw();

The addClass() function is mentioned in the datatables documentation. But it doesn't work with bootstrap table-striped class success.
I need the table-striped class 'success' to be added to the row I am creating in my Datatable. How can I get this to work?

A: You don't need the css classes, you can just add these css to your code.
tbody tr:nth-child(odd) {
   background-color: #ccc; `the color you prefer`
}

tbody tr:nth-child(even) {
   background-color: #fff; `the color you prefer`
}

Anonther thing you can try is to write code in the row created callback, more information about this can be found here:
https://datatables.net/examples/advanced_init/row_callback.html

A: It is because you trying add class to not existing object.
Try my snippet:

$(document).ready(function() {
    var table = $('#datatable').DataTable();
    table.row.add(['<button type="button" id="Details">A button</button>']).draw();
    $('#datatable').find('tr').last().addClass("success");
});
tr.success { background-color:green !important; }

<link href="https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css" rel="stylesheet"/>

      1

A: I think its just $(row).addClass("success") as in this example datatables.net/reference/option/createdRow
(Quoting a comment by @Brent Boden) Thanks for the quick reply! :)


text:
Q: Is it OK to be picky about math you find interesting? I am a layman interested in mathematics, and I would like to hear mathematicians' views on the following: Is it normal to be picky about mathematical stuff you find interesting?
I ask because 80% of math I encounter does not seem interesting to me. I want to know if this is true for most people or if there is something wrong with me.

A: At any particular moment, or for stretches of time, it is entirely reasonable to find various things boring... or incomprehensible, or both.
But/and as one learns more, one's opinions will inevitably change.
And, yes, admittedly, many published papers are contrived, with the main goal of having a publication to make a good impression on dept heads, deans, and funding agencies. No real intrinsic interest... and it's hard to tell, from an amateur's or novice's viewpoint.
So I'd recommend that you (and everyone...) follow their own tastes and curiosity, BUT be open to the possibility that things that seem boring or pointless or incomprehensible at one moment may later seem quite otherwise. Don't pretend to make permanent decisions...

A: I'm an undergraduate in mathematics. There are certain modules that I look forward to and others that I dread. Liking the entirety of mathematics is pretty unlikely.
You are normal, congrats!

A: You wade into the realm of personal taste.  I'd say math is like wine:  different things appeal to different sorts.

A: I would say that this highly depends on the level of your education and your goals.  If you are a postdoc or an advanced graduate student, with a very strong math education under your belt, you are somewhat free to say that certain areas are not as interesting to you as others.  You have some idea of what the kind of field you want to pursue, and which techniques may or may not be useful to you.  There is a huge amount of math out there, much of it very specialized and probably not interesting to mathematicians outside of that particular field.  Of course, even professionals should be cautious about dismissing fields of mathematics - mathematicians are very often surprised to see that techniques they may have otherwise dismissed turn out to be useful.
However, if you are pursuing a general math education but you are not currently an expert, you should be very careful about dismissing math as uninteresting.  It would be a big mistake to say "linear algebra is boring, so I won't bother."  Linear algebra is useful for virtually every subfield of math - it's a very important part of any mathematicians' education.  These basic fields should be studied even if they seem uninteresting at first glance, because they are indispensable.
If you are not pursuing a general math education - e.g., you are studying it as a hobby, or you have a very specific goal in mind that you know requires only a specific subset of the typical coursework - then you are more free to pick and choose to study a few things that are interesting to you.

A: If you are contemplating a math degree, or any other degree for that matter, I would advise a much higher interest rate than 20%. Life is too short to spend time on something that uninteresting. While a 100% interest in all math topics is unlikely, I would say that the mathematicians I know, and probably most of the people answering questions here, have a very much higher interest rate.

A: I would say it would be unwise and rather odd for a mathematician to dismiss any part of the subject matter of mathematics as uninteresting. The subject is very large and there are deep connections between apparently very different aspects: as a simple example, consider the many different proofs of the fundamental theorem of algebra. If 80% of the maths that you encounter seems to be uninteresting to you and you can't see why that 80% of interest to anyone else, then I don't think maths is for you. (I'm personally not very excited by the the theory of differential equations, but I know it's an important subject and I appreciate all the work that's been done on it over the centuries.)


text:
Q: Vim paste is pasting some old line copied weeks ago, ignoring current copied line Earlier I had a 32-bit system where my Vim (with spf13-bundle) used to work fine. I upgraded it to 64-bit, reusing the home folder contents. After moving to 64-bit, I am facing this problem.
If I copy some line from a file using Ctrl + C and then pastE in Vim using Esc + p, it pastes some line copied weeks ago, instead of my current copied line which I want to paste.
Perhaps, the vim is not taking lines from clipboard. Please help me on this.
EDIT
I found following block in my .viminfo :
# Registers:
""0 LINE    0
    find the number of pairs for which |ai+aj-K| is minimal possible (and this minimal possible value), having the array a[] and the integer K given.
"1  LINE    0
    find the number of pairs for which |ai+aj-K| is minimal possible (and this minimal possible value), having the array a[] and the integer K given.
"2  LINE    0
    find the number of pairs for which |ai+aj-K| is minimal possible (and this minimal possible value), having the array a[] and the integer K given.
"3  LINE    0
    find the number of pairs for which |ai+aj-K| is minimal possible (and this minimal possible value), having the array a[] and the integer K given.
"4  LINE    0
    find the number of pairs for which |ai+aj-K| is minimal possible (and this minimal possible value), having the array a[] and the integer K given.
"5  LINE    0
    find the number of pairs for which |ai+aj-K| is minimal possible (and this minimal possible value), having the array a[] and the integer K given.
"6  LINE    0

"7  LINE    0
    [DATA STRUCTURE] : Array
"8  LINE    0

"9  LINE    0
    [DATA STRUCTURE] : Array
"-  CHAR    0
    find the number of pairs for which |ai+aj-K| is minimal possible (and this minimal possible value), having the array a[] and the integer K given.

and this is the line find the number of pairs for which |ai+aj-K| is minimal possible (and this minimal possible value), having the array a[] and the integer K given. getting pasted again and again instead of actual one.

A: The paste you are using is not the same as system clipboard.
If you did not install any plug-in, when you press p, it is pasting the lines you yank with y previously.
If you don't want to install any plug-in, the quickest way is to press shift + Ins under insert mode to paste the system clipboard.
Or you can use * to access system clipboard. Under normal mode, type "*p will do.

A: By default, Vim's paste command uses the internal unnamed register, not the system clipboard. For that, prepend "+ to the paste command, or
:set clipboard+=unnamedplus

in your ~/.vimrc. The spf13 distribution presumably did that (without you knowing), and you got used to that.
Vim "distributions" like spf-13 and Janus lure you with a quick install and out-of-the-box settings, but you pay the price with increased complexity (you need to understand both Vim's runtime loading scheme and the arbitrary conventions of the distribution) and inflexibility (the distribution may make some things easier, but other things very difficult). Vim is incredibly customizable, using someone else's customization makes no sense.


text:
Q: Removing duplicates from an array of objects I have an object which has  json objects called
mainobject =
 Array[2]
>0: object
 >Innerobject1 : Array[2]
  >0 : object
     Name : "Xavier"
     Dup  : "B"
  >1 : object
     Name : "Gh"
     Dup : "B"
>1: object
 >Innerobject2 : Array[2]
  >0 : object
     Name : "Cat"
     Dup :  "C"
  >1 : object
     Name : "Dog"
     Dup : "D"

I need to make the "dup" as "" which was already present in the first object if any .My expected output is:
Array[2]
>0: object
 >Innerobject1 : Array[2]
  >0 : object
     Name : "Xavier"
     Dup  : "B"
  >1 : object
     Name : "Gh"
     Dup : ""
>1: object
 >Innerobject2 : Array[2]
  >0 : object
     Name : "Cat"
     Dup :  "C"
  >1 : object
     Name : "Dog"
     Dup : "D"

Edit:
The object in json format:
:
"[{"Innerobject1":[{"Name" :"Xavier","Dup":"B"},{"Name" :"Gh","Dup":"B"}]},
{"Innerobject2":[{"Name" : "Cat","Dup":"C"},{"Name":"Dog", "Dup":"D"}]}]"

A: I'm not quite sure that I have interpreted your posted array of objects correct. But you can do something like this:
Iterate over the array and store the key you want to be unique in an object. When encountered more then once set the new value to an empty string:
var seen = {};
mainobject.forEach(function(obj) {
   if (seen[obj.Name]) {
       obj.Name = "";
   }
   seen[obj.Name] = true;
});

You might need multiply iterations, dependents on how many nested arrays you got:
var seen = {};
mainobject.forEach(function(inner_arr) {
   inner_arr.forEach(function(obj) {
       if (seen[obj.Name]) {
           obj.Name = "";
       }
       seen[obj.Name] = true;
    });
});

A: The solution using Array.forEach and Object.keys functions:
var mainobject = JSON.parse('[{"Innerobject1":[{"Name" :"Xavier","Dup":"B"},{"Name" :"Gh","Dup":"B"}]},{"Innerobject2":[{"Name" : "Cat","Dup":"C"},{"Name":"Dog", "Dup":"D"}]}]');

mainobject.forEach(function(obj){
    Object.keys(obj).forEach(function(k){
        obj[k].forEach(function(o){
            if (this["Dup"]) {
                (this["Dup"].indexOf(o["Dup"]) !== -1)? o["Dup"] = "" : this["Dup"].push(o["Dup"]);
            } else {
                this["Dup"] = [o["Dup"]];
            }
        })
    });
}, {});

console.log(JSON.stringify(mainobject, 0, 4));

The console.log output:
[
    {
        "Innerobject1": [
            {
                "Name": "Xavier",
                "Dup": "B"
            },
            {
                "Name": "Gh",
                "Dup": ""
            }
        ]
    },
    {
        "Innerobject2": [
            {
                "Name": "Cat",
                "Dup": "C"
            },
            {
                "Name": "Dog",
                "Dup": "D"
            }
        ]
    }
]


text:
Q: How to read json files from sub folders in ADLS and ingest them into ADX through Azure data factory I have ADLS Gen2 storage with a parent folder and multiple sub folders and each folders having json files. I want to get the file names and create table in ADX with the name of json files.
I think I have to use get metadata activity here.. the folder structure looks like this.

/UserData/Overground/UsersFolder/ProjectName/Environment1/data/json/demo-02/2021/01/28/03/

under this folder, we have multiple json files

demo-02-2021-01-28-03-30.json
demo-02-2021-01-28-03-30.json
demo-02-2021-01-28-03-30.json

other folders look also like this
and under each of these folder, multiple json files are available.

/UserData/Overground/UsersFolder/ProjectName/Environment1/data/json/demo-02/2021/01/28/02/
/UserData/Overground/UsersFolder/ProjectName/Environment1/data/json/demo-02/2021/01/29/04/
/UserData/Overground/UsersFolder/ProjectName/Environment1/data/json/demo-02/2021/01/29/05/
/UserData/Overground/UsersFolder/ProjectName/Environment1/data/json/demo-02/2022/01/01/05/

Using ADF I need to get json files from ADLS storage , create tables in ADX with the name of json files and ingest data into the tables.
the schema of the tables is (value:string, name:string,timestamp:date)

Thanks in advance for any help

A: If you have a nested folder structure, loop through each folder and get the required files using the process below.

*

*Using Get Metadata get the child items under the main folder and pass them to ForEach activity.

*Inside ForEach activity add execute pipeline and pass the current item to child pipeline parameters.

*In the child pipeline, pass the parameter value to get metadata activity to get the next child items inside the subfolder and pass them to ForEach activity.

*Repeat the process till you get the list of files and copy them to sink using copy data activity.
Refer to these SO link1 & link2 for a similar process with repro details.


text:
Q: Xamarin Forms Master Detail Page Icon, and Menu Icon I'm following the instructions here;
https://www.syntaxismyui.com/xamarin-forms-masterdetail-page-navigation-recipe/
The navigation bar icon is placed too far to the right by default. Is there a way to center it on the navigation bar?  The hamburger menu icon is also pushed far to the right.
EDIT:  I added a picture for an example of what I have.  Funny thing, in another app the icon is all the way to the left.

EDIT:
Here's the code:
   public class RootPage : MasterDetailPage
{
    MenuPage menuPage;
    public RootPage()
    {

        menuPage = new MenuPage();
        menuPage.Menu.ItemSelected += (sender, e) => NavigateTo(e.SelectedItem as MenuItem);
        Master = menuPage;
        NavigationPage page = new NavigationPage(new Home());
        page.BarBackgroundColor = Color.FromHex("#56198E");
        Detail = page;

    }

    void NavigateTo(MenuItem menu)
    {
        if (menu == null)
            return;
        Page displayPage = (Page)Activator.CreateInstance(menu.TargetType);
        NavigationPage page = new NavigationPage(displayPage);
        page.BarBackgroundColor = Color.FromHex("#56198E");
        Detail = page;

        menuPage.Menu.SelectedItem = null;
        IsPresented = false;
    }
}

 public class MenuPage : ContentPage
{
    public ListView Menu { get; set; }

    public MenuPage()
    {
        Icon = "settings.png";
        Title = "menu"; // The Title property must be set.
        BackgroundColor = Color.FromHex("#56198E");

        Menu = new MenuListView();

        var menuLabel = new ContentView
        {
            Padding = new Thickness(10, 36, 0, 5),
            Content = new Label
            {
                TextColor = Color.FromHex("#C8C8C8"),
                Text = "MENU",
            }
        };

        var layout = new StackLayout
        {
            Spacing = 0,
            VerticalOptions = LayoutOptions.FillAndExpand
        };
        layout.Children.Add(menuLabel);
        layout.Children.Add(Menu);

        Content = layout;
    }
}

 public class MenuListView : ListView
{
    public MenuListView()
    {
        List<MenuItem> data = new MenuListData();

        ItemsSource = data;
        VerticalOptions = LayoutOptions.FillAndExpand;
        BackgroundColor = Color.Transparent;
        // SeparatorVisibility = SeparatorVisibility.None;

        var cell = new DataTemplate(typeof(MenuCell));
        cell.SetBinding(MenuCell.TextProperty, "Title");
        cell.SetBinding(MenuCell.ImageSourceProperty, "IconSource");

        ItemTemplate = cell;
    }
}

   public class MenuListData : List<MenuItem>
{
    public MenuListData()
    {
        this.Add(new MenuItem()
        {
            Title = " Home",
            IconSource = "Home.png",
            TargetType = typeof(Home)
        });

        this.Add(new MenuItem()
        {
            Title = " Register for Classes",
            IconSource = "Calendar.png",
            TargetType = typeof(Register)
        });

        this.Add(new MenuItem()
        {
            Title = " Search Instructors",
            IconSource = "ContactsSearch.png",
            TargetType = typeof(SearchInstructors)
        });

    }
}

   public class MenuItem
{
    public string Title { get; set; }

    public string IconSource { get; set; }

    public Type TargetType { get; set; }
}

A: I would recommend trying different icon sizes. I was having some issues myself when the image was too large. In my tests I was originally using a 144x144 image and it worked correctly most of the time. When I attempted a 700x700 pixel image it was dead center and I would lose my title.
Screen Resolution - 768x1280
App Icon
144x144 - Slightly away from flush next to the Menu Icon
700x700 - Center
Menu Icon -44x44 (and always flush to the left)


text:
Q: ionic 2 sqlite plugin_not_installed pls help me i cant solve my problem on ionic 2 sqlite. on the first run of my app i have successfully created the table "players", and i can also insert and fetch on this table. but when i try to exit and re-open my app it prompts me "plugin_not_installed".
i am following the new documentation of ionic frame work . i observe on this documentation it doesn't have db.openDatabase() function which some tutorials always mention.
   import { SQLite, SQLiteObject } from '@ionic-native/sqlite';
import { AlertController } from 'ionic-angular';
export class Players {
    name:string;    //ngmodel from html
    players:new Array<Object>(); //used to list all players
constructor(private sqlite: SQLite,public alertCtrl: AlertController) {
this.initializeDatabase(); //create table if not exists

}
ionViewDidLoad(){
        this.fetch();
}
initializeDatabase(){
    this.sqlite.create({
  name: 'data.db',
  location: 'default'
})
  .then((db: SQLiteObject) => {
    db.executeSql('create table if not exists(playerId integer primary key,fullname varchar(50));', {})
      .then(() => console.log('Executed SQL'))
      .catch(e => this.showAlert( JSON.stringify(e)));
  })
  .catch(e => this.showAlert( JSON.stringify(e)));
}
fetch(){
        let sql="select fullname from players";
        this.sqlite.create({
  name: 'data.db',
  location: 'default'
}).then((db: SQLiteObject) => {
    db.executeSql(sql, {})
      .then((data) => {
          this.players=[];
          for(let index=0;index,data.rows.length;index++){
              this.players.push({fullname:data.rows.item(index).fullname});
          }
      })
      .catch(e => this.showAlert( JSON.stringify(e)));
  })
  .catch(e => this.showAlert( JSON.stringify(e)));
}
create(){
    let name=this.name;
        let sql="INSERT INTO players (playerId,fullname) values (?,?)";
        this.sqlite.create({
  name: 'data.db',
  location: 'default'
}).then((db: SQLiteObject) => {
    db.executeSql(sql, [null,name])
      .then(() => console.log('successfully created'))
      .catch(e => this.showAlert( JSON.stringify(e)));
  })
  .catch(e => this.showAlert( JSON.stringify(e)));
}
  showAlert(msg:string) {
    let alert = this.alertCtrl.create({
      title: 'Info',
      subTitle:msg,
      buttons: ['OK']
    });
    alert.present();
  }
}

A: install the SQLite plugin using the below command :

ionic cordova plugin add cordova-sqlite-storage --save
npm install --save @ionic-native/sqlite

Import the SQLite class to the app.module.ts file

import { SQLite, SQLiteObject } from '@ionic-native/sqlite';
providers: [SQLite, ...

and build in your device


text:
Q: Masking color android I want to make an image transparent in android, so I did some research but came to the conclusion that I did'nt really get it. So I am drawing A couple of bitmaps on my canvas, and in 1 kind of bitmap I want to make the red transparent. i found A piece of code but I doesn't really do anything. this is my code:
if(PictureArray[a]==0){
                Paint Remove = new Paint();
                Remove.setARGB(255, 255, 0, 0);
                int removeColor=Remove.getColor();
                Remove.setAlpha(0);
                Remove.setXfermode(new AvoidXfermode(removeColor,0,AvoidXfermode.Mode.TARGET));
                c.drawBitmap(Stone, x, c.getHeight()/2, null);
            }

A: Use a transparent PNG. No need to overengineer it ;)


text:
Q: Angular: Ngx Scrollbar Parent with horizontal scroll having columns(children) with vertical scroll issues dragging horizontal across child w/ V-Scroll
Hi,
I have drag and drop with Native HTML5 API, but when the column(child) which has vertical scroll enabled, i'm not able to drag item across it as the parent horizontal scrolls and child vertical scroll overlaps. i need the item in each column to be able to dragged across all the children(columns) irrespective of vertical scroll enabled or disabled.
The drag/ horizontal scroll stops when it encounters child with vertical scroll.
Note: I'm not using CDK lib for drag and drop.
TIA


text:
Q: Typescript outfile with System.JS - Module instantiation error I'm using TypeScript to generate a single outFile that compiles my modules, loaded with SystemJS. When I follow the documentation on loading bundles, as suggested by this SO answer, I get an error:
Uncaught (in promise) Error: Module instantiation did not call an anonymous or correctly named System.register.
    Instantiating http://localhost:50001/Content/js/app.js
    Loading app.js
        at vendor.js?v=c419d08…:4

Here is the setup script in my index.html file:
SystemJS.import("/Content/js/app.js").then(function (mod) {
    return SystemJS.import("admin/js/startup");
});

app.js looks like this:
System.register("shared/js/utilities", [], function (exports_1, context_1) {
    ...
});

System.register("admin/js/startup", ["shared/js/utilities"], function (exports_2, context_2) {
    ...
});

My tsconfig.json, if it helps:
{
    "compilerOptions": {
        "noImplicitAny": false,
        "noEmitOnError": true,
        "removeComments": false,
        "sourceMap": true,
        "target": "es5",
        "module": "system",
        "outFile": "app.js"
    },
    "compileOnSave": true,
    "exclude": [
        "node_modules",
        "wwwroot"
    ]
}

UPDATE: I had been using systemjs/dist/system-production.js, because the documentation states that modules already transpiled into the System.register format, which is done by TypeScript, can be loaded by the production loader. If I switch to using systemjs/dist/system.js, I do not get the errors. I still don't see how I am getting this error from the production loader if I'm already working with System.register formatted modules.


text:
Q: How can I connect Thermal printer with php? I wanna connect thermal printer with php base website.
I have make a restaurant website with php and now I want that when client pay the bill via card it print the reciept auto on thermal printer.
will someone help me to do this ??

A: You are asking wrong question, so, please modify it. Actually it's not connected to PHP at all. U need to know how access this printer programmatically, check it's documentation if they have an API for this.
Also, please check this question.

A: Check the list of printers from this list and if your printer is one of them. You can simply download script from the link below:
https://github.com/mike42/escpos-php
Add this code to your PHP page. But remember printer should be attached with server not your system. Or you can test it through xamp or appserv if you want to test it on your system.
require __DIR__ . '/vendor/autoload.php';
use Mike42\Escpos\PrintConnectors\FilePrintConnector;
use Mike42\Escpos\Printer;
$connector = new FilePrintConnector("php://stdout");
$printer = new Printer($connector);
$printer -> text("Hello World!\n");
$printer -> cut();
$printer -> close();


text:
Q: UIView set frame and set center not applied I expect to change UIView (UISegmentedView to be more detailed) to change position but it's not applied:
- (void)viewDidLoad
{
    [super viewDidLoad];

    self.segmentedControl.frame = CGRectMake(0, 0, 3 * 75, 50); // not working
    self.segmentedControl.center = self.view.center; // not working

    [self.segmentedControl setWidth:75 forSegmentAtIndex:0]; // working
    [self.segmentedControl setWidth:75 forSegmentAtIndex:1]; // working
    [self.segmentedControl setWidth:75 forSegmentAtIndex:2]; // working
}

One more result it that segment #3 can't be clicked though it's enabled and the right part of segment #2 is not clickable too which makes me think there is control active area width limitation. The view is created in UIViewController inheritor and xib.

A: I've posted this as an answer so you can check it as valid. For anyone having this problems, the first thing I would check is if autolayout is enabled on your view's interface builder.
Open your view in the Interface Builder. Now, on the utilities, show the file inspector. You will find a checkbox "Use Autolayout". If it's checked, try unchecking it to see if it solves your problem.


text:
Q: Is the absolute value of distance covariance a metric? I'm reasonably certain the absolute value of the distance covariance satisfies

*

*$d(x, y) \ge 0$     (non-negativity, or separation axiom)

*$d(x, y) = 0$   if and only if   $x = y$     (identity of indiscernibles, or coincidence axiom)

*$d(x, y) = d(y, x)$     (symmetry)

But I'm not sure about:
4) $d(x, z) \le d(x, y) + d(y, z)$     (subadditivity / triangle inequality).
I'm thinking in particular of a space of timeseries, but I don't think that matters too much.

A: If by distance covariancen you mean this
http://en.wikipedia.org/wiki/Distance_correlation#Distance_covariance
then the point 2. is false. There are many possibilities for this distance to be 0.

A: Distance covariance and distance Correlation do not satisfy the triangular inequality.
Pearson's correlation itself on centered data or otherwise, does not satisfy the inequality, and hence is known as a semi-metric.

A: You got it: covariance, of course, induces a metric:
$$
d(x,y) = \sqrt{ \text{Cov}(x-y,x-y) }
$$
but NOT:
$$
d(x,y) = \text{Cov}(x,y)
$$
Actually I'm thinking about the property of the triangle inequality. Or, what effect does this property induce?

A: Ok, from doing some more reading, the assumption in the question is wrong. Covariance actually defines an inner product, if (as I understand it) you first remove the mean of each variable. That is, covariance satisfies the following:

*

*Conjugate symmetry: $Cov(X,Y) = Cov(Y,X)$

*Linearity in the first argument: $Cov(aX+bY,Z) = a\cdot Cov(X,Z) + b\cdot Cov(Y,Z)$

*Positive semi-definiteness: $Cov(X,X) = 0$ with equality only for X constant (This is where the removal of the mean comes in: $Cov(X,Y) = \langle X-\bar{X},Y-\bar{Y}\rangle$, such that $Var(X) = 0 \iff X_i = \bar{X}\ \forall\ i$ [X is constant, so removing the mean gives the zero vector])

This inner product induces a norm, also with the mean of the random variable removed: $\|X-\bar{X}\| = Var(X)$
And the norm in turn induces a metric: $d(X,Y) = \|(X-\bar{X})-(Y-\bar{Y})\| = Var(X-Y)$
So in a sense, Covariance does define a metric, just not in the way I first thought. It's been a whole 6 months since I studies any linear algebra, so I might have some of those slightly screwed up. Please correct me if I'm wrong!
The same applies to distance covariance, as is pretty clear from the wikipedia article, although it's a different inner product.


text:
Q: Check if greps return containsa certain word When I execute a command like this:
~/foo/bar | grep <someID>

the output is in this format:
"<someID>": "ENABLED",

The status "ENABLED" can also be something different but i want to check if my ID is ENABLED
I tried it with this:
output= ~/foo/bar | grep <someID>
echo $output

if [[ $output =~ .*ENABLED.* ]]; then  // Method 1
echo "is enabled"
else
echo "not enabled"
fi

case "$output" in                      // Method 2
*ENABLED*)
echo "is enabled"
;;
esac

but i always get that it is not enabled.
Basically what i want to do is to check if the return of grep contains the word "ENABLED".
Any ideas?

A: In straight-forward way:
some_id=2    # for example
if ~/foo/bar | grep -q "$some_id"'": *"ENABLED"' ; then
    echo "is enabled"
else
    echo "not enabled"
fi

A: you need to put backticks in your first line of code. if you did not do that, then that might be your mistake, because $output is undefined therefore empty string.
output=`~/foo/bar | grep <someID>`

A: Both your strategies for checking the content of $output would work if you just got the appropriate data into the variable. There are multiple ways to get command output into a variable. The following are all functionally equivalent.
output=`~/bin/foo | grep "\"<someID>\""`       # deprecated -- use $(...) instead

output="$(~/bin/foo | grep "\"<someID>\"")"    # may result in multiple lines of output

read -r output < <(~/bin/foo | grep "\"<someID>\"")  # uses "Process Substitution"

The first two of these will work in any old POSIX shell. The first one even works in csh/tcsh. The last one, using Process Substitution, is bash-only (or at least, not POSIX).
But as you've seen in another answer, you probably don't need a variable. You can use a regex to match the whole line that you're interested in:
if ~/foo/bar | grep -q "\"$someID\""'": *"ENABLED"'; then
  echo "enabled"
else
  echo "disabled"
fi

This construct is safer if there's the possibility that $someID might appear multiple times in your output, with different values.
If you use a case statement, then you'd want to make sure you know what to do if $someID turns up multiple times.
while read -r output; do
  case "$output" in
    *ENABLED*) echo "enabled" ;;
    *DISABLED) echo "disabled" ;;
    *) echo "ERROR: Unknown state." >&2 ;;
  esac
done < <(~/foo/bar | grep "\"$someID\"")

A: Try something like this:
some_command > /tmp/some_file.tmp
if grep -q "Some_Text" "/tmp/some_file.tmp";
then
echo "These are not the stormtroopers you are looking for."
else
echo "Stay gold, ponyboy."
fi

# Removing the tmp file is optional, but I'm OCD, so...
rm /tmp/some_file.tmp

This command will for-sure work on a Ubuntu system out of the box, or any *nix system with BASH terminal. You can adapt for your own usage.
Inspired by https://stackoverflow.com/a/28360230/4272202