问:
No such file or directorye
I am trying to run this bash script which runs fine but gives error to the following lines.

```<code>cut -f2 $fpath | $preprocess_exec > SNLI/s1.$split
cut -f3 $fpath | $preprocess_exec > SNLI/s2.$split
</code>```

and,

```<code>cut -f2 $fpath.tok | $preprocess_exec > MultiNLI/s1.$split
cut -f3 $fpath.tok | $preprocess_exec > MultiNLI/s2.$split
</code>```

Error Message

```<code>: No such file or directorye
</code>```

The problem is specifically in $preprocess_exec which is a Sed script. The script says, it cannot find the file but I can see the input file is there where it should be.

Any idea why this is happening?

Update

I changed the command as follows and now there is no error produced by the bash script.

```<code>cut -f2 $fpath.tok | sed -f $preprocess_exec > MultiNLI/s1.$split
cut -f3 $fpath.tok | sed -f $preprocess_exec > MultiNLI/s2.$split
</code>```

But I am doubting that $preprocess_exec is not making any changes to the input file.

Does anyone have any thought on this?

答:
Hmmm... running your bash script in debug mode (-x) would help. Just guessing: is your sed script executable? If not...</p>

```<code>chmod +x ./tokenizer.sed
</code>```

Title: No such file or directorye

Body:
I am trying to run this bash script which runs fine but gives error to the following lines.

cut -f2 $fpath | $preprocess_exec > SNLI/s1.$split
cut -f3 $fpath | $preprocess_exec > SNLI/s2.$split

and,

cut -f2 $fpath.tok | $preprocess_exec > MultiNLI/s1.$split
cut -f3 $fpath.tok | $preprocess_exec > MultiNLI/s2.$split

Error Message

: No such file or directorye

The problem is specifically in $preprocess_exec which is a Sed script. The script says, it cannot find the file but I can see the input file is there where it should be.

Any idea why this is happening?

Update

I changed the command as follows and now there is no error produced by the bash script.

cut -f2 $fpath.tok | sed -f $preprocess_exec > MultiNLI/s1.$split
cut -f3 $fpath.tok | sed -f $preprocess_exec > MultiNLI/s2.$split

But I am doubting that $preprocess_exec is not making any changes to the input file.

Does anyone have any thought on this?

Body:
Hmmm... running your bash script in debug mode (-x) would help. Just guessing: is your sed script executable? If not...

chmod +x ./tokenizer.sed


来源: stackexchange

问:
Instagram new logo css background
Recently, Instagram logo has changed as you all know. I need vector logo but it is not possible, I mean gradients. Is there any css code for new logo? </p>

答:
Here's the code for the icon with the gradient background. Hope this helps. :)

#insta {
  background: radial-gradient(circle at 30% 107%, #fdf497 0%, #fdf497 5%, #fd5949 45%, #d6249f 60%, #285AEB 90%);
  -webkit-background-clip: text;
          /* Also define standard property for compatibility */
          background-clip: text;
  -webkit-text-fill-color: transparent;

  font-size: 200px; /* change this to change the size*/

}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet" />
<i class="fa fa-instagram" id="insta" aria-hidden="true"></i></code>```

I found 2 more great implementations of the font awesome icon here-
https://codepen.io/monir/pen/wGZWvB (new logo)
https://codepen.io/thomasrye/pen/VaRoYv (old logo)

ContentLicense: CC BY-SA 3.0

Title: Instagram new logo css background

Body:
Here's the code for the icon with the gradient background. Hope this helps. :)

#insta {
  background: radial-gradient(circle at 30% 107%, #fdf497 0%, #fdf497 5%, #fd5949 45%, #d6249f 60%, #285AEB 90%);
  -webkit-background-clip: text;
          /* Also define standard property for compatibility */
          background-clip: text;
  -webkit-text-fill-color: transparent;

  font-size: 200px; /* change this to change the size*/

}

<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet" />
<i class="fa fa-instagram" id="insta" aria-hidden="true"></i>

I found 2 more great implementations of the font awesome icon here-
https://codepen.io/monir/pen/wGZWvB (new logo)
https://codepen.io/thomasrye/pen/VaRoYv (old logo)

ContentLicense: CC BY-SA 4.0


问:
Not clear about the meaning of auto.offset.reset and enable.auto.commit in Kafka
I am new to Kafka,and I don't really understand the meaning of Kafka configuration, can anyone explain in a more understandable way to me?

Here is my code:

```<code>val kafkaParams = Map[String, Object](
  "bootstrap.servers" -> "master:9092,slave1:9092",
  "key.deserializer" -> classOf[StringDeserializer],
  "value.deserializer" -> classOf[StringDeserializer],
  "group.id" -> "GROUP_2017",
  "auto.offset.reset" -> "latest", //earliest or latest
  "enable.auto.commit" -> (true: java.lang.Boolean)
)
</code>```

what does it mean in my code?

答:
auto.offset.reset is ONLY at play when there is no valid committed offset; such as at the first time you start the system, or after a committed offset expires and is deleted because its too old.

enable.auto.commit is about a choice to have offsets committed automatically in the background vs explicit manual control in the foreground.

```<code>auto.offset.reset
</code>```

What to do when there is no initial offset in Kafka or if the current offset does not exist any more on the server (e.g. because that data has been deleted):

earliest: automatically reset the offset to the earliest offset

latest: automatically reset the offset to the latest offset

none: throw exception to the consumer if no previous offset is found for the consumer's group

anything else: throw exception to the consumer.

```<code>Type:
string
Default:
latest
Valid Values:
[latest, earliest, none]
Importance:
medium
</code>```
```<code>enable.auto.commit
</code>```

If true, the consumer's offset will be periodically committed in the background.

```<code>Type:
boolean
Default:
true
Valid Values:

Importance:
medium
</code>```
```<code>auto.commit.interval.ms
</code>```

The frequency in milliseconds that the consumer offsets are auto-committed to Kafka if enable.auto.commit is set to true.

```<code>Type:
int
Default:
5000 (5 seconds)
Valid Values:
[0,...]
Importance:
low
</code>```

The full set of consumer configuration parameters in documented on the Apache Kafka web site at https://kafka.apache.org/documentation.html#newconsumerconfigs

Body:
I am new to Kafka,and I don't really understand the meaning of Kafka configuration, can anyone explain in a more understandable way to me?

Here is my code:

val kafkaParams = Map[String, Object](
  "bootstrap.servers" -> "master:9092,slave1:9092",
  "key.deserializer" -> classOf[StringDeserializer],
  "value.deserializer" -> classOf[StringDeserializer],
  "group.id" -> "GROUP_2017",
  "auto.offset.reset" -> "latest", //earliest or latest
  "enable.auto.commit" -> (true: java.lang.Boolean)
)

what does it mean in my code?

Body:
auto.offset.reset is ONLY at play when there is no valid committed offset; such as at the first time you start the system, or after a committed offset expires and is deleted because its too old.

enable.auto.commit is about a choice to have offsets committed automatically in the background vs explicit manual control in the foreground.

auto.offset.reset

What to do when there is no initial offset in Kafka or if the current offset does not exist any more on the server (e.g. because that data has been deleted):

earliest: automatically reset the offset to the earliest offset

latest: automatically reset the offset to the latest offset

none: throw exception to the consumer if no previous offset is found for the consumer's group

anything else: throw exception to the consumer.

Type:
string
Default:
latest
Valid Values:
[latest, earliest, none]
Importance:
medium

enable.auto.commit

If true, the consumer's offset will be periodically committed in the background.

Type:
boolean
Default:
true
Valid Values:

Importance:
medium

auto.commit.interval.ms

The frequency in milliseconds that the consumer offsets are auto-committed to Kafka if enable.auto.commit is set to true.

Type:
int
Default:
5000 (5 seconds)
Valid Values:
[0,...]
Importance:
low

The full set of consumer configuration parameters in documented on the Apache Kafka web site at https://kafka.apache.org/documentation.html#newconsumerconfigs


问:
Finding pyspark StreamingContext state
So I'm using another pyspark program to control when the StreamingContext starts and stops executing its streams. At the same time I'm trying to get this program to run:

```<code>import sys
from pyspark import SparkContext
from pyspark.streaming import StreamingContext

if __name__ == '__main__':
    if len(sys.argv) != 2:
        sys.exit("Usage: <fileName> <appId>")

    appId = sys.argv[1]
    context = None

    for ssc in StreamingContext.getActive():
        if ssc.sparkContext.applicationId == appId:
            context = ssc
            break
    else:
        sys.exit("No StreamingContext found with matching appId")

    #while context has started but not stopped
        print("StreamingContext is working, writing data to stream.")
        #write data to stream
</code>```

I'm able to find the context that my other program created, the problem is I don't if it has started or stopped. awaitTermination() doesn't seem to work in this case since I want to continuously check the state of context rather than to let the program hang. Is there anyway for me to do this?

I'm using:

Python 3.6

PySpark 2.1.1

答: I believe the answer was less complicated than I thought. context == StreamingContext.getActive() should do.

Title: Finding pyspark StreamingContext state

Body:
So I'm using another pyspark program to control when the StreamingContext starts and stops executing its streams. At the same time I'm trying to get this program to run:

import sys
from pyspark import SparkContext
from pyspark.streaming import StreamingContext

if __name__ == '__main__':
    if len(sys.argv) != 2:
        sys.exit("Usage: <fileName> <appId>")

    appId = sys.argv[1]
    context = None

    for ssc in StreamingContext.getActive():
        if ssc.sparkContext.applicationId == appId:
            context = ssc
            break
    else:
        sys.exit("No StreamingContext found with matching appId")

    #while context has started but not stopped
        print("StreamingContext is working, writing data to stream.")
        #write data to stream

I'm able to find the context that my other program created, the problem is I don't if it has started or stopped. awaitTermination() doesn't seem to work in this case since I want to continuously check the state of context rather than to let the program hang. Is there anyway for me to do this?

I'm using:

Python 3.6

PySpark 2.1.1


问:
Set input values when one input value change JQuery
Now, when the 1st row value change, the 2nd and 3rd row change accordingly.
The problem is this's hard code, i don't know the no of rows as it's generated from the database.Any idea?Many thanks

$("#A1").keyup(function() {
    $("#B1").val($("#A1").val());
});

$("#A1").keyup(function() {
    $("#C1").val($("#A1").val());
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<tr>
<td><input type="text" id="A1" name="A" value=""></td>
</tr><br>
<tr>
<td><input type="text" id="B1" name="A" value=""></td>
</tr>
<br>
<tr>
<td><input type="text" id="C1" name="A" value=""></td>
</tr></code>```

答:
You can assign the value to all the inputs in your HTML, like this:

$("#A1").keyup(function() {
    $("input").val($("#A1").val());
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<tr>
<td><input type="text" id="A1" name="A" value=""></td>
</tr><br>
<tr>
<td><input type="text" id="B1" name="A" value=""></td>
</tr>
<br>
<tr>
<td><input type="text" id="C1" name="A" value=""></td>
</tr></code>```

Body:
Now, when the 1st row value change, the 2nd and 3rd row change accordingly.
The problem is this's hard code, i don't know the no of rows as it's generated from the database.Any idea?Many thanks

$("#A1").keyup(function() {
    $("#B1").val($("#A1").val());
});

$("#A1").keyup(function() {
    $("#C1").val($("#A1").val());
});

<input type="text" id="A1" name="A" value="">

<input type="text" id="B1" name="A" value="">

<input type="text" id="C1" name="A" value="">

Body:
You can assign the value to all the inputs in your HTML, like this:

$("#A1").keyup(function() {
    $("input").val($("#A1").val());
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<tr>
<td><input type="text" id="A1" name="A" value=""></td>
</tr><br>
<tr>
<td><input type="text" id="B1" name="A" value=""></td>
</tr>
<br>
<tr>
<td><input type="text" id="C1" name="A" value=""></td>
</tr>


问:
How to use ssh jenkins plugin in pipeline to remotely execute in the remote machine
I used ssh plugin in Jenkins Job to ssh into a remote machine and run commands in that machine. I am trying to use the pipeline for Jenkins and I cannot find the script for the plugin.</p>

答:
It looks like this is not supported.

ssh-plugin is not listed in the pipeline compatibility list.

There is no reference to any workflow plugin inside the ssh-plugin POM, like in e.g. the ssh-agent plugins POM.

The last release of ssh-plugin is Jan 8, 2014.

I'd conclude this plugin is abandoned. However there is some commit activity. Consider writing an issue.


问:
Taking the crypt of a password is adding some weird foobar thing so that it doesn't equal
```<code>#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>
#include <crypt.h>

int main(int argc, string argv[])
{
    if(argc > 2){ printf("too many arguments\n"); return 51; }
    if(argc < 2){ printf("too few arguments\n"); return 50; }
    //if(strlen(argv[1]) > 4){ printf("Password is greater than 4 characters\n"); return 52; }

    if(argc == 2) //make sure there are enough args
    {
        char hash_guess[] = "rofk";
        //long long counter = 0;

        //while(guess != argv[1]) //crypt(hash_guess, "50") != argv[1]) //while answer not correct
        //{
            for(int a = 65; a < 91; a++)
            {
                for(int b = 65; b < 91; b++)
                {
                    for(int c = 65; c < 91; c++)
                    {
                        for(int d = 65; d < 91; d++)
                        {
                            for(int A = 0; A < 9; A = A + 5) //control if first is caps or not
                            {
                                for(int B = 1 ; B < 9 ; B = B + 5)//control if second is caps or not
                                {
                                    for(int C = 2; C < 9; C = C + 5) //control if third is caps or not
                                    {
                                        for(int D = 3; D < 9; D = D + 5) //control if fourth is caps or not
                                        {
                                            hash_guess[0] = a;
                                            hash_guess[1] = b;
                                            hash_guess[2] = c;
                                            hash_guess[3] = d;
                                            hash_guess[A] = tolower(hash_guess[A]);
                                            hash_guess[B] = tolower(hash_guess[B]);
                                            hash_guess[C] = tolower(hash_guess[C]);
                                            hash_guess[D] = tolower(hash_guess[D]);
                                            printf("%s\n", hash_guess);

                                            string cryptoguess = (crypt(hash_guess, "50"));
                                            string input = argv[1];

                                            if( cryptoguess == input ) { return 0; }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            //}
        //}
        //string guess = crypt(hash_guess, "50");
        //printf("%lli", counter);
    }
    }
}
</code>```

I'm trying to make a program that goes through every 4 letter word, starting on aaaa and going to ZZZZ. I got that part done.

Part of the assignment is to encrypt that, and if the encryption matches an encrypted password, then you know you "hacked" their password. When I compare the encrypted password that I manually enter and the one that comes up by using the crypt function, they are the same, but in the debugger I see this for when it is encrypted by the computer:

```<code>"0x7ffff7dd9200 <_ufc_foobar+131200> "50k72iioeOiJU""
</code>```

and the normal one that I enter shows

```<code>"0x7fffffffe34f "50k72iioeOiJU""
</code>```

the same thing without the _ufc_foobar. Does anyone know why that is there and how I can get rid of it?

答:
<_ufc_foobar+131200> isn't part of the string. It's your debugger attempting to figure out where the string came from, and assign a name to it. In this case, it's come up with a bogus result -- _ufc_foobar is the name of a function or variable somewhere else in the program, and your string happens to be stored 131,200 bytes (about 128 KB) after that in memory.

You can safely ignore this. Your strings are equal. They just happen to be stored in different parts of memory (which is normal).

Body:
#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>
#include <crypt.h>

int main(int argc, string argv[])
{
    if(argc > 2){ printf("too many arguments\n"); return 51; }
    if(argc < 2){ printf("too few arguments\n"); return 50; }
    //if(strlen(argv[1]) > 4){ printf("Password is greater than 4 characters\n"); return 52; }

    if(argc == 2) //make sure there are enough args
    {
        char hash_guess[] = "rofk";
        //long long counter = 0;

        //while(guess != argv[1]) //crypt(hash_guess, "50") != argv[1]) //while answer not correct
        //{
            for(int a = 65; a < 91; a++)
            {
                for(int b = 65; b < 91; b++)
                {
                    for(int c = 65; c < 91; c++)
                    {
                        for(int d = 65; d < 91; d++)
                        {
                            for(int A = 0; A < 9; A = A + 5) //control if first is caps or not
                            {
                                for(int B = 1 ; B < 9 ; B = B + 5)//control if second is caps or not
                                {
                                    for(int C = 2; C < 9; C = C + 5) //control if third is caps or not
                                    {
                                        for(int D = 3; D < 9; D = D + 5) //control if fourth is caps or not
                                        {
                                            hash_guess[0] = a;
                                            hash_guess[1] = b;
                                            hash_guess[2] = c;
                                            hash_guess[3] = d;
                                            hash_guess[A] = tolower(hash_guess[A]);
                                            hash_guess[B] = tolower(hash_guess[B]);
                                            hash_guess[C] = tolower(hash_guess[C]);
                                            hash_guess[D] = tolower(hash_guess[D]);
                                            printf("%s\n", hash_guess);

                                            string cryptoguess = (crypt(hash_guess, "50"));
                                            string input = argv[1];

                                            if( cryptoguess == input ) { return 0; }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            //}
        //}
        //string guess = crypt(hash_guess, "50");
        //printf("%lli", counter);
    }
    }
}

I'm trying to make a program that goes through every 4 letter word, starting on aaaa and going to ZZZZ. I got that part done.

Part of the assignment is to encrypt that, and if the encryption matches an encrypted password, then you know you "hacked" their password. When I compare the encrypted password that I manually enter and the one that comes up by using the crypt function, they are the same, but in the debugger I see this for when it is encrypted by the computer:

"0x7ffff7dd9200 <_ufc_foobar+131200> "50k72iioeOiJU""

and the normal one that I enter shows

"0x7fffffffe34f "50k72iioeOiJU""

the same thing without the _ufc_foobar. Does anyone know why that is there and how I can get rid of it?


问:
Converting EditText to int? (Android)
I am wondering how to convert an EditText input to an int, I have the user input a number, which then divides it by 8.

MainActivity.java:

```<code>@SuppressWarnings("unused")
public void calcSpeed(View view)
{
    setContentView(R.layout.activity_speed);

    final TextView mTextView = (TextView) findViewById(R.id.textView3);
    mTextView.setText("You should be getting: " +netSpedCalcd);
}
</code>```

activity_main.xml:

```<code>    <EditText
    android:id="@+id/editText1"
    android:inputType="number"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:layout_marginTop="62dp"
    android:ems="10" >
</code>```

答:
```<code>int total_Parson = Integer.parseInt(etRegularTickets.getText().toString());
int ticket_price=Integer.parseInt(TicketData.get(0).getTicket_price_regular());
total_ticket_amount = ticket_price * total_Parson;
etRegularPrice.setText(""+total_ticket_amount);
</code>```

Title: Converting EditText to int? (Android)

Body:
I am wondering how to convert an EditText input to an int, I have the user input a number, which then divides it by 8.

MainActivity.java:

@SuppressWarnings("unused")
public void calcSpeed(View view)
{
    setContentView(R.layout.activity_speed);

    final TextView mTextView = (TextView) findViewById(R.id.textView3);
    mTextView.setText("You should be getting: " +netSpedCalcd);
}

activity_main.xml:

    <EditText
    android:id="@+id/editText1"
    android:inputType="number"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:layout_marginTop="62dp"
    android:ems="10" >


答:
Different from other answers given here, changing all input elements is too risky in my opinion. What I would suggest id adding a class to all input fields you wish to change, and changing your function to a JQuery selector according to this class (In the example below, the class I added is called changable).

$("#A1").keyup(function() {
    $(".changable").val($("#A1").val());
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<tr>
<td><input type="text" id="A1" class="changable" value=""></td>
</tr><br>
<tr>
<td><input type="text" id="B1" class="changable" value=""></td>
</tr>
<br>
<tr>
<td><input type="text" id="C1" class="changable" value=""></td>
</tr></code>```

Title: Set input values when one input value change JQuery

Body:
Different from other answers given here, changing all input elements is too risky in my opinion. What I would suggest id adding a class to all input fields you wish to change, and changing your function to a JQuery selector according to this class (In the example below, the class I added is called changable).

$("#A1").keyup(function() {
    $(".changable").val($("#A1").val());
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<tr>
<td><input type="text" id="A1" class="changable" value=""></td>
</tr><br>
<tr>
<td><input type="text" id="B1" class="changable" value=""></td>
</tr>
<br>
<tr>
<td><input type="text" id="C1" class="changable" value=""></td>
</tr>


问:
Getting an element from a Set
Why doesn't Set provide an operation to get an element that equals another element?

```<code>Set<Foo> set = ...;
...
Foo foo = new Foo(1, 2, 3);
Foo bar = set.get(foo);   // get the Foo element from the Set that equals foo
</code>```

I can ask whether the Set contains an element equal to bar, so why can't I get that element? :(

To clarify, the equals method is overridden, but it only checks one of the fields, not all. So two Foo objects that are considered equal can actually have different values, that's why I can't just use foo.

答:
you can use Iterator class</p>

```<code>import java.util.Iterator;
import java.util.HashSet;

public class MyClass {
 public static void main(String[ ] args) {
 HashSet<String> animals = new HashSet<String>();
animals.add("fox");
animals.add("cat");
animals.add("dog");
animals.add("rabbit");

Iterator<String> it = animals.iterator();
while(it.hasNext()) {
  String value = it.next();
  System.out.println(value);
 }
 }
}
</code>```

Title: Getting an element from a Set

Body:
Why doesn't Set provide an operation to get an element that equals another element?

Set<Foo> set = ...;
...
Foo foo = new Foo(1, 2, 3);
Foo bar = set.get(foo);   // get the Foo element from the Set that equals foo

I can ask whether the Set contains an element equal to bar, so why can't I get that element? :(

To clarify, the equals method is overridden, but it only checks one of the fields, not all. So two Foo objects that are considered equal can actually have different values, that's why I can't just use foo.

Body:
you can use Iterator class

import java.util.Iterator;
import java.util.HashSet;

public class MyClass {
 public static void main(String[ ] args) {
 HashSet<String> animals = new HashSet<String>();
animals.add("fox");
animals.add("cat");
animals.add("dog");
animals.add("rabbit");

Iterator<String> it = animals.iterator();
while(it.hasNext()) {
  String value = it.next();
  System.out.println(value);
 }
 }
}


问:
Different python versions in centos
I have a centos 7 machine , which has 2 python versions , python giver sveriosn 2.7.5 and python2.7 givers version . 2.7.13. I want to make 2.7.13 as default version, such that when I check python --version it gives 2.7.13 and not 2.7.5 . I have added both to PATH.</p>

答:
If you set Python 2.7.13 to your PATH and not 2.7.5, the used Python should be 2.7.13.
Or you can try to set the PYTHONPATH variable

Title: Different python versions in centos


问:
Render Razor View to string in ASP.NET Core
I use RazorEngine for parsing of templates in my MVC 6 project like this:

```<code>Engine.Razor.RunCompile(File.ReadAllText(fullTemplateFilePath), templateName, null, model);
</code>```

It works fine for the beta 6. It does not work after upgrading to beta 7 with the error:

MissingMethodException: Method not found: "Void Microsoft.AspNet.Razor.CodeGenerators.GeneratedClassContext.set_ResolveUrlMethodName(System.String)".
      in RazorEngine.Compilation.CompilerServiceBase.CreateHost(Type templateType, Type modelType, String className)

This is global.json:

```<code>{
  "projects": [ "src", "test" ],
  "sdk": {
    "version": "1.0.0-beta7",
    "runtime": "clr",
    "architecture": "x64"
  }
}
</code>```

This is project.json:

```<code>...
"dependencies": {
    "EntityFramework.SqlServer": "7.0.0-beta7",
    "EntityFramework.Commands": "7.0.0-beta7",
    "Microsoft.AspNet.Mvc": "6.0.0-beta7",
    "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta7",
    "Microsoft.AspNet.Authentication.Cookies": "1.0.0-beta7",
    "Microsoft.AspNet.Authentication.Facebook": "1.0.0-beta7",
    "Microsoft.AspNet.Authentication.Google": "1.0.0-beta7",
    "Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-beta7",
    "Microsoft.AspNet.Authentication.Twitter": "1.0.0-beta7",
    "Microsoft.AspNet.Diagnostics": "1.0.0-beta7",
    "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta7",
    "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta7",
    "Microsoft.AspNet.Server.IIS": "1.0.0-beta7",
    "Microsoft.AspNet.Server.WebListener": "1.0.0-beta7",
    "Microsoft.AspNet.StaticFiles": "1.0.0-beta7",
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-beta7",
    "Microsoft.Framework.Configuration.Abstractions": "1.0.0-beta7",
    "Microsoft.Framework.Configuration.Json": "1.0.0-beta7",
    "Microsoft.Framework.Configuration.UserSecrets": "1.0.0-beta7",
    "Microsoft.Framework.Logging": "1.0.0-beta7",
    "Microsoft.Framework.Logging.Console": "1.0.0-beta7",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta7",
    "RazorEngine": "4.2.2-beta1"
  },
...
  "frameworks": {
    "dnx451": { }
  },
...
</code>```

My template is:

@model dynamic
@{
    Layout = null;
}

<!DOCTYPE html>

    <meta charset="utf-8" />
    <title>Registration</title>

    Hello, @Model

```

Does anyone have similar problems?
There is another way to parse templates in MVC 6?

答:
Extension method for converting partial views to string response.

```<code>public static class PartialViewToString
{
    public static async Task<string> ToString(this PartialViewResult partialView, ActionContext actionContext)
    {
        using(var writer = new StringWriter())
        {
            var services = actionContext.HttpContext.RequestServices;
            var executor = services.GetRequiredService<PartialViewResultExecutor>();
            var view = executor.FindView(actionContext, partialView).View;
            var viewContext = new ViewContext(actionContext, view, partialView.ViewData, partialView.TempData, writer, new HtmlHelperOptions());
            await view.RenderAsync(viewContext);
            return writer.ToString();
        }
    }
}
</code>```

Usage in your controller actions.

```<code>public async Task<IActionResult> Index()
{
    return await PartialView().ToString(ControllerContext)
}
</code>```

.NET 5 Implementation

```<code>public static async Task<string> ViewToString(this PartialViewResult partialView, Controller controller)
    {
        using (var writer = new StringWriter())
        {
            var services = controller.ControllerContext.HttpContext.RequestServices;
            var viewEngine = services.GetService(typeof(ICompositeViewEngine)) as ICompositeViewEngine;
            var viewName = partialView.ViewName ?? controller.ControllerContext.ActionDescriptor.ActionName;
            var view = viewEngine.FindView(controller.ControllerContext, viewName, false).View;
            var viewContext = new ViewContext(controller.ControllerContext, view, partialView.ViewData, partialView.TempData, writer, new HtmlHelperOptions());
            await view.RenderAsync(viewContext);
            return writer.ToString();
        }
    }
</code>```

Body:
I use RazorEngine for parsing of templates in my MVC 6 project like this:

Engine.Razor.RunCompile(File.ReadAllText(fullTemplateFilePath), templateName, null, model);

It works fine for the beta 6. It does not work after upgrading to beta 7 with the error:

MissingMethodException: Method not found: "Void Microsoft.AspNet.Razor.CodeGenerators.GeneratedClassContext.set_ResolveUrlMethodName(System.String)".
      in RazorEngine.Compilation.CompilerServiceBase.CreateHost(Type templateType, Type modelType, String className)

This is global.json:

{
  "projects": [ "src", "test" ],
  "sdk": {
    "version": "1.0.0-beta7",
    "runtime": "clr",
    "architecture": "x64"
  }
}

This is project.json:

...
"dependencies": {
    "EntityFramework.SqlServer": "7.0.0-beta7",
    "EntityFramework.Commands": "7.0.0-beta7",
    "Microsoft.AspNet.Mvc": "6.0.0-beta7",
    "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta7",
    "Microsoft.AspNet.Authentication.Cookies": "1.0.0-beta7",
    "Microsoft.AspNet.Authentication.Facebook": "1.0.0-beta7",
    "Microsoft.AspNet.Authentication.Google": "1.0.0-beta7",
    "Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-beta7",
    "Microsoft.AspNet.Authentication.Twitter": "1.0.0-beta7",
    "Microsoft.AspNet.Diagnostics": "1.0.0-beta7",
    "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta7",
    "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta7",
    "Microsoft.AspNet.Server.IIS": "1.0.0-beta7",
    "Microsoft.AspNet.Server.WebListener": "1.0.0-beta7",
    "Microsoft.AspNet.StaticFiles": "1.0.0-beta7",
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-beta7",
    "Microsoft.Framework.Configuration.Abstractions": "1.0.0-beta7",
    "Microsoft.Framework.Configuration.Json": "1.0.0-beta7",
    "Microsoft.Framework.Configuration.UserSecrets": "1.0.0-beta7",
    "Microsoft.Framework.Logging": "1.0.0-beta7",
    "Microsoft.Framework.Logging.Console": "1.0.0-beta7",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta7",
    "RazorEngine": "4.2.2-beta1"
  },
...
  "frameworks": {
    "dnx451": { }
  },
...

My template is:

@model dynamic
@{
    Layout = null;
}

<!DOCTYPE html>

    <meta charset="utf-8" />
    <title>Registration</title>

    Hello, @Model

Does anyone have similar problems?
There is another way to parse templates in MVC 6?

Body:
Extension method for converting partial views to string response.

public static class PartialViewToString
{
    public static async Task<string> ToString(this PartialViewResult partialView, ActionContext actionContext)
    {
        using(var writer = new StringWriter())
        {
            var services = actionContext.HttpContext.RequestServices;
            var executor = services.GetRequiredService<PartialViewResultExecutor>();
            var view = executor.FindView(actionContext, partialView).View;
            var viewContext = new ViewContext(actionContext, view, partialView.ViewData, partialView.TempData, writer, new HtmlHelperOptions());
            await view.RenderAsync(viewContext);
            return writer.ToString();
        }
    }
}

Usage in your controller actions.

public async Task<IActionResult> Index()
{
    return await PartialView().ToString(ControllerContext)
}

.NET 5 Implementation

public static async Task<string> ViewToString(this PartialViewResult partialView, Controller controller)
    {
        using (var writer = new StringWriter())
        {
            var services = controller.ControllerContext.HttpContext.RequestServices;
            var viewEngine = services.GetService(typeof(ICompositeViewEngine)) as ICompositeViewEngine;
            var viewName = partialView.ViewName ?? controller.ControllerContext.ActionDescriptor.ActionName;
            var view = viewEngine.FindView(controller.ControllerContext, viewName, false).View;
            var viewContext = new ViewContext(controller.ControllerContext, view, partialView.ViewData, partialView.TempData, writer, new HtmlHelperOptions());
            await view.RenderAsync(viewContext);
            return writer.ToString();
        }
    }


问:
Parallelizing python function with dictionary as input
I want to call a function func in python with a dictionary dict_a as input. How can I parallelize these calls so that each elemt (key-value pair) of the dictionary is called as a separate process? I am using python 3.6

```<code>from multiprocessing import Pool
with Pool(processes=6) as p:
    p.starmap(func, dict_a)
</code>```

答:
Are you looking for:

```<code>with Pool(processes=6) as p:
    p.starmap(func, list(dict_a.items()))
</code>```

so it's a list of key/value pairs.

Body:
I want to call a function func in python with a dictionary dict_a as input. How can I parallelize these calls so that each elemt (key-value pair) of the dictionary is called as a separate process? I am using python 3.6

from multiprocessing import Pool
with Pool(processes=6) as p:
    p.starmap(func, dict_a)

Body:
Are you looking for:

with Pool(processes=6) as p:
    p.starmap(func, list(dict_a.items()))

so it's a list of key/value pairs.


问:
Problems Compiling OCILIB OCI Wrapper Library
I'm trying to compile demo in ocilib3.8.1/demo. After successfully installing the ocilib library, I then compile demo source conn.c below :

```<code>#include "ocilib.h"

int main(void)
{
    OCI_Connection *cn;

    if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT))
        return EXIT_FAILURE;

    cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT);

    printf("Server major    version : %i\n",   OCI_GetServerMajorVersion(cn));
    printf("Server minor    version : %i\n",   OCI_GetServerMinorVersion(cn));
    printf("Server revision version : %i\n\n", OCI_GetServerRevisionVersion(cn));
    printf("Connection      version : %i\n\n", OCI_GetVersionConnection(cn));

    OCI_Cleanup();

    return EXIT_SUCCESS;
}
</code>```

Compile using gcc :

```<code>$gcc -Wall conn.c -o conn.o -I/usr/local/include \
    -DOCI_IMPORT_LINKAGE -DOCI_CHARSET_ANSI
</code>```

Error :

```<code>$ gcc -Wall conn.c -o conn.o -I/usr/local/include \
    -DOCI_IMPORT_LINKAGE -DOCI_CHARSET_ANSI
/tmp/ccMgFQri.o: In function `main':
conn.c:(.text+0x26): undefined reference to `OCI_Initialize'
conn.c:(.text+0x4f): undefined reference to `OCI_ConnectionCreate'
conn.c:(.text+0x63): undefined reference to `OCI_GetServerMajorVersion'
conn.c:(.text+0x82): undefined reference to `OCI_GetServerMinorVersion'
conn.c:(.text+0xa1): undefined reference to `OCI_GetServerRevisionVersion'
conn.c:(.text+0xc0): undefined reference to `OCI_GetVersionConnection'
conn.c:(.text+0xd6): undefined reference to `OCI_Cleanup'
collect2: ld returned 1 exit status
</code>```

I'm using redhat el5, gcc version 3.4.6 20060404 (Red Hat 3.4.6-4), instant client Release 10.2.0.5.0.

Thanks for help. I'm newbies in linux programming ..

答:
you have to link against ocilib !

add "-locilib" to the command line :)

ContentLicense: CC BY-SA 2.5

Body:
I'm trying to compile demo in ocilib3.8.1/demo. After successfully installing the ocilib library, I then compile demo source conn.c below :

#include "ocilib.h"

int main(void)
{
    OCI_Connection *cn;

    if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT))
        return EXIT_FAILURE;

    cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT);

    printf("Server major    version : %i\n",   OCI_GetServerMajorVersion(cn));
    printf("Server minor    version : %i\n",   OCI_GetServerMinorVersion(cn));
    printf("Server revision version : %i\n\n", OCI_GetServerRevisionVersion(cn));
    printf("Connection      version : %i\n\n", OCI_GetVersionConnection(cn));

    OCI_Cleanup();

    return EXIT_SUCCESS;
}

Compile using gcc :

$gcc -Wall conn.c -o conn.o -I/usr/local/include \
    -DOCI_IMPORT_LINKAGE -DOCI_CHARSET_ANSI

Error :

$ gcc -Wall conn.c -o conn.o -I/usr/local/include \
    -DOCI_IMPORT_LINKAGE -DOCI_CHARSET_ANSI
/tmp/ccMgFQri.o: In function `main':
conn.c:(.text+0x26): undefined reference to `OCI_Initialize'
conn.c:(.text+0x4f): undefined reference to `OCI_ConnectionCreate'
conn.c:(.text+0x63): undefined reference to `OCI_GetServerMajorVersion'
conn.c:(.text+0x82): undefined reference to `OCI_GetServerMinorVersion'
conn.c:(.text+0xa1): undefined reference to `OCI_GetServerRevisionVersion'
conn.c:(.text+0xc0): undefined reference to `OCI_GetVersionConnection'
conn.c:(.text+0xd6): undefined reference to `OCI_Cleanup'
collect2: ld returned 1 exit status

I'm using redhat el5, gcc version 3.4.6 20060404 (Red Hat 3.4.6-4), instant client Release 10.2.0.5.0.

Thanks for help. I'm newbies in linux programming ..


问:
Scrapy - Downloader middleware not being loaded?
I've been trying to enable Downloader middleware in my scrapy project but it doesn't seem like it is being recognized at all. I have installed some third party middleware and I cannot tell if it is being used or not. I have even tried uninstalling the middleware packages and running my code and it runs without raising any error saying that the package does not exist or anything hence the confusion.

Everything in my settings.py is being used properly like other settings and parameters are showing up normally as they are defined in settings.py, but it just feels like downloader middleware is not working at all.

This is the downloader_middleware code in my settings.py file

```<code>DOWNLOADER_MIDDLEWARE = {
    'scrapy.downloadermiddlewares.useragent.UserAgentMiddleware': None,
    'scrapy_fake_useragent.middleware.RandomUserAgentMiddleware': 110, #installed with pip
    'scrapy.downloadermiddlewares.retry.RetryMiddleware': 190,
    'scrapy_proxies.RandomProxy': 200, #installed with pip
    'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware': 210,
}
</code>```

Here is my log when I run scrapy crawl spider:

```<code>2017-07-06 12:46:20 [scrapy.middleware] INFO: Enabled downloader middlewares:
['scrapy.downloadermiddlewares.httpauth.HttpAuthMiddleware',
 'scrapy.downloadermiddlewares.downloadtimeout.DownloadTimeoutMiddleware',
 'scrapy.downloadermiddlewares.defaultheaders.DefaultHeadersMiddleware',
 'scrapy.downloadermiddlewares.useragent.UserAgentMiddleware',
 'scrapy.downloadermiddlewares.retry.RetryMiddleware',
 'scrapy.downloadermiddlewares.redirect.MetaRefreshMiddleware',
 'scrapy.downloadermiddlewares.httpcompression.HttpCompressionMiddleware',
 'scrapy.downloadermiddlewares.redirect.RedirectMiddleware',
 'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware',
 'scrapy.downloadermiddlewares.stats.DownloaderStats']
</code>```

it seems like the downlaoder_middleware code is just being ignored as UserAgentMiddleware is being enabled anyways regardless of other third part middleware that I installed.

Also I have tried using custom settings in my spider.py like this (the custom pipeline did work as intended) but the same things happened regardless if I had the custom settings or not:

```<code>custom_settings = {
        'ITEM_PIPELINES': {
            'someCustomPipeline': 300,
        },

        'DOWNLOADER_MIDDLEWARE': {
            'scrapy.downloadermiddlewares.useragent.UserAgentMiddleware': None,
            'scrapy_fake_useragent.middleware.RandomUserAgentMiddleware': 110, #installed with pip
            'scrapy.downloadermiddlewares.retry.RetryMiddleware': 190,
            'scrapy_proxies.RandomProxy': 200, #installed with pip
            'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware': 210,
        }
    }
</code>```

答: To disable all default middleware, the docs says that you should set all middlewares found in DOWNLOADER_MIDDLEWARES_BASE to None explicitly in your DOWNLOADER_MIDDLEWARE. as is said in the docs here?

Body:
I've been trying to enable Downloader middleware in my scrapy project but it doesn't seem like it is being recognized at all. I have installed some third party middleware and I cannot tell if it is being used or not. I have even tried uninstalling the middleware packages and running my code and it runs without raising any error saying that the package does not exist or anything hence the confusion.

Everything in my settings.py is being used properly like other settings and parameters are showing up normally as they are defined in settings.py, but it just feels like downloader middleware is not working at all.

This is the downloader_middleware code in my settings.py file

DOWNLOADER_MIDDLEWARE = {
    'scrapy.downloadermiddlewares.useragent.UserAgentMiddleware': None,
    'scrapy_fake_useragent.middleware.RandomUserAgentMiddleware': 110, #installed with pip
    'scrapy.downloadermiddlewares.retry.RetryMiddleware': 190,
    'scrapy_proxies.RandomProxy': 200, #installed with pip
    'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware': 210,
}

Here is my log when I run scrapy crawl spider:

2017-07-06 12:46:20 [scrapy.middleware] INFO: Enabled downloader middlewares:
['scrapy.downloadermiddlewares.httpauth.HttpAuthMiddleware',
 'scrapy.downloadermiddlewares.downloadtimeout.DownloadTimeoutMiddleware',
 'scrapy.downloadermiddlewares.defaultheaders.DefaultHeadersMiddleware',
 'scrapy.downloadermiddlewares.useragent.UserAgentMiddleware',
 'scrapy.downloadermiddlewares.retry.RetryMiddleware',
 'scrapy.downloadermiddlewares.redirect.MetaRefreshMiddleware',
 'scrapy.downloadermiddlewares.httpcompression.HttpCompressionMiddleware',
 'scrapy.downloadermiddlewares.redirect.RedirectMiddleware',
 'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware',
 'scrapy.downloadermiddlewares.stats.DownloaderStats']

it seems like the downlaoder_middleware code is just being ignored as UserAgentMiddleware is being enabled anyways regardless of other third part middleware that I installed.

Also I have tried using custom settings in my spider.py like this (the custom pipeline did work as intended) but the same things happened regardless if I had the custom settings or not:

custom_settings = {
        'ITEM_PIPELINES': {
            'someCustomPipeline': 300,
        },

        'DOWNLOADER_MIDDLEWARE': {
            'scrapy.downloadermiddlewares.useragent.UserAgentMiddleware': None,
            'scrapy_fake_useragent.middleware.RandomUserAgentMiddleware': 110, #installed with pip
            'scrapy.downloadermiddlewares.retry.RetryMiddleware': 190,
            'scrapy_proxies.RandomProxy': 200, #installed with pip
            'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware': 210,
        }
    }


答:
The weird junk you are seeing is visualization of offsets of memory addresses in your code which can be ignored.

In your code you are using string when GNU specifies char * is the result of the crypt function.

Therefore, you cannot compare the pointers to the char array using == but instead need to use strcmp C comparing pointers (with chars)

For crypt see: http://www.gnu.org/software/libc/manual/html_node/crypt.html

Title: Taking the crypt of a password is adding some weird foobar thing so that it doesn't equal


问:
What exactly do the low, high and optimum attributes do in the meter element?
The MDN uses the name of these attributes too describe them, so it doesn't really explain them. They dont really seem to have a default functionality to them, so  I'm assuming min and max needs to be used with them. Does the browser use them somehow, or is their sole purpose to be used with javascript? Also is it possible to style the meter's other then width and height?</p>

```<code><meter min="0" low="30"  value="50" optimum="50" high="80" max="100" >
    What is their use?
</meter>
</code>```

答:
These three attribute high, low,optimum does not have any such significant effect but do effect the color of the meter gauge based on the value and the value of these attributes. The color varies between yellow, red, green.
Below is a small demo.

  Values Without optimum value

Value between low and high:<meter value=50 min=0 max=100 low=30 high=90></meter>
 Value less than low and greater than min:<meter value=25 min=0 max=100 low=30 high=90></meter>
 Value greater than high and less than max:<meter value=95 min=0 max=100 low=30 high=90></meter>
 Value equal to high :<meter value=90 min=0 max=100 low=30 high=90></meter>
 Value equal to low :<meter value=30 min=0 max=100 low=30 high=90></meter>

Value greater than high and less than max :<meter value=95 min=0 max=100 low=30 high=90></meter>

MDN Example: value is greater than high:<meter min=0 low=69 high=80 max=100 value=84></meter>

  Values With optimum value Greater Than high

Value between low and high:<meter value=50 min=0 max=100 low=30 high=90 optimum=95></meter>

Value less than low and greater than min:<meter value=25 min=0 max=100 low=30 high=90 optimum=95></meter>
 Value greater than high and less than max: <meter value=95 min=0 max=100 low=30 high=90 optimum=95></meter>

Value equal to high :<meter value=90 min=0 max=100 low=30 high=90 optimum=95></meter>

Value equal to low :<meter value=30 min=0 max=100 low=30 high=90 optimum=95></meter>

Value greater than high and less than max :<meter value=95 min=0 max=100 low=30 high=90 optimum=95></meter>

    Values With optimum value Less Than high

  Value between low and high:<meter value=50 min=0 max=100 low=30 high=90 optimum=85></meter>

  Value less than low and greater than min:<meter value=25 min=0 max=100 low=30 high=90 optimum=85></meter>

  Value greater than high and less than max:
  <meter value=95 min=0 max=100 low=30 high=90 optimum=85></meter>

  Value equal to high :<meter value=90 min=0 max=100 low=30 high=90 optimum=85></meter>

  Value equal to low :<meter value=30 min=0 max=100 low=30 high=90 optimum=85></meter>

  Value greater than high and less than max :<meter value=95  min=0 max=100 low=30 high=90 optimum=85></meter>
```

In the above demo you can observe the difference between the colors of the meter gauge based on its value and low-high range. Though i Think there is still a inconsistency as you can see the last two meter gauges in the first group both have value greater than high value but still are of different color.

Even after spending hours in googling i was also not able to get the exact explanation for these attributes. But above is what i had found out.

Hope this helps you :)

Body:
The MDN uses the name of these attributes too describe them, so it doesn't really explain them. They dont really seem to have a default functionality to them, so  I'm assuming min and max needs to be used with them. Does the browser use them somehow, or is their sole purpose to be used with javascript? Also is it possible to style the meter's other then width and height?

<meter min="0" low="30"  value="50" optimum="50" high="80" max="100" >
    What is their use?
</meter>

Body:
These three attribute high, low,optimum does not have any such significant effect but do effect the color of the meter gauge based on the value and the value of these attributes. The color varies between yellow, red, green.
Below is a small demo.

<h3>
  Values Without optimum value
</h3>

Value between low and high:<meter value=50 min=0 max=100 low=30 high=90></meter><br> Value less than low and greater than min:<meter value=25 min=0 max=100 low=30 high=90></meter><br> Value greater than high and less than max:<meter value=95 min=0 max=100 low=30 high=90></meter><br> Value equal to high :<meter value=90 min=0 max=100 low=30 high=90></meter><br> Value equal to low :<meter value=30 min=0 max=100 low=30 high=90></meter><br>
Value greater than high and less than max :<meter value=95 min=0 max=100 low=30 high=90></meter><br>
MDN Example: value is greater than high:<meter min=0 low=69 high=80 max=100 value=84></meter>

<h3>
  Values With optimum value Greater Than high
</h3>

Value between low and high:<meter value=50 min=0 max=100 low=30 high=90 optimum=95></meter><br>
Value less than low and greater than min:<meter value=25 min=0 max=100 low=30 high=90 optimum=95></meter><br> Value greater than high and less than max: <meter value=95 min=0 max=100 low=30 high=90 optimum=95></meter><br>
Value equal to high :<meter value=90 min=0 max=100 low=30 high=90 optimum=95></meter><br>
Value equal to low :<meter value=30 min=0 max=100 low=30 high=90 optimum=95></meter><br>
Value greater than high and less than max :<meter value=95 min=0 max=100 low=30 high=90 optimum=95></meter><br>

  <h3>
    Values With optimum value Less Than high
  </h3>

  Value between low and high:<meter value=50 min=0 max=100 low=30 high=90 optimum=85></meter><br>
  Value less than low and greater than min:<meter value=25 min=0 max=100 low=30 high=90 optimum=85></meter><br>
  Value greater than high and less than max:
  <meter value=95 min=0 max=100 low=30 high=90 optimum=85></meter><br>
  Value equal to high :<meter value=90 min=0 max=100 low=30 high=90 optimum=85></meter><br>
  Value equal to low :<meter value=30 min=0 max=100 low=30 high=90 optimum=85></meter><br>
  Value greater than high and less than max :<meter value=95  min=0 max=100 low=30 high=90 optimum=85></meter><br>

In the above demo you can observe the difference between the colors of the meter gauge based on its value and low-high range. Though i Think there is still a inconsistency as you can see the last two meter gauges in the first group both have value greater than high value but still are of different color.

Even after spending hours in googling i was also not able to get the exact explanation for these attributes. But above is what i had found out.

Hope this helps you :)


问:
Can webdriver get the style sheet url that is being used by an element
I am working on a test case in which I need to verify that changing an option in a drop down list changes the styling the page. I am wondering if Webdriver is capable of getting the css document url from an element. I feel as this is the best solution for my test case as I do now know what will change on the page but I do know it will have a different css source from the original page load. Attached is a screenshot of the information I am hoping to extract. Maybe possible with getCssValue() but I am not sure what css property that would be if any.

答:
```<code><input id="username" name="name" value="selenium">input</input>
</code>```

You can user element.getAttirbute(""); , in this case if you use driver.findElement(By.Id('username')).getAttribute("value"); It will return selenium.

Body:
<input id="username" name="name" value="selenium">input</input>

You can user element.getAttirbute(""); , in this case if you use driver.findElement(By.Id('username')).getAttribute("value"); It will return selenium.


问:
How to create a checkbox using the DocX library
Is the checkbox control supported in the DocX library? I'm browsing the classes and I can't find one for Checkbox. How to create a checkbox using DocX?</p>

答:
You can add the checkbox symbol.

```<code>/// <summary>
/// Helper method to handle the special symbol text.
/// </summary>
/// <param name="hex"></param>
/// <returns></returns>
private char HexToChar(string hex)
{
    return (char)ushort.Parse(hex, System.Globalization.NumberStyles.HexNumber);
}
</code>```

Then, you can insert the checkbox as normal text.

```<code>// generate a sentence, which includes two checkboxes.
// checkbox Decimal Value is 9722, and Hex Value is 2610
var checkbox = HexToChar("2610");
</code>```

Body:
You can add the checkbox symbol.

/// <summary>
/// Helper method to handle the special symbol text.
/// </summary>
/// <param name="hex"></param>
/// <returns></returns>
private char HexToChar(string hex)
{
    return (char)ushort.Parse(hex, System.Globalization.NumberStyles.HexNumber);
}

Then, you can insert the checkbox as normal text.

// generate a sentence, which includes two checkboxes.
// checkbox Decimal Value is 9722, and Hex Value is 2610
var checkbox = HexToChar("2610");


问:
Visibility of expanding last view in the expandable RecyclerView

I want the  things in the last expandable item to be fully visible when it is clicked,Now what is happening means when I click on last item it expands down, but I manually need to scroll up again to see the the things inside the expanded item.How can the last expandable item be fully visible.
I am using Recyclerview.

答:
Just a supplementary:
If you use h6ah4i/advrecyclerview, you can use the following code snippet:</p>

```<code>    @Override
    public boolean onHookGroupExpand(int groupPosition, boolean fromUser) {
        // NOTE21: collapse all other groups when one item expand.
        mExpMgr.collapseAll();

        // NOTE21: Visibility of expanding last view in the expandable recyclerview
        if (groupPosition == getGroupCount() - 1) {
            mRecyclerView.smoothScrollToPosition(groupPosition + getChildCount(groupPosition));
        }
        return true;
    }
</code>```

Body:
Just a supplementary:
If you use h6ah4i/advrecyclerview, you can use the following code snippet:

    @Override
    public boolean onHookGroupExpand(int groupPosition, boolean fromUser) {
        // NOTE21: collapse all other groups when one item expand.
        mExpMgr.collapseAll();

        // NOTE21: Visibility of expanding last view in the expandable recyclerview
        if (groupPosition == getGroupCount() - 1) {
            mRecyclerView.smoothScrollToPosition(groupPosition + getChildCount(groupPosition));
        }
        return true;
    }


问:
Invalid SSL Certificate error on iPod Touch - works for iPhone
We are developing an iOS Application that connects to a server over https using nsurlconnection sendsynchronousrequest

We are getting the following error in the iPod Touch 3.2. However, the exact same code does not give any error on iPhone 3.1
Error message:
The certificate for this server is invalid. You might be connecting to a server that is pretending to be “xx.xx.xxx.xxx” which could put your confidential information at risk

We are trying to connect to a server https: subdomain.domain.com and the certificate actually belongs only to https: domain.com Could that be the reason of the above inconsistency? Any idea why it works on iPhone and not on the iPod Touch. The certificate is signed by GoDaddy. Could it be that the iPod Touch does not have GoDaddy's root certificate?

We need to find a way around this problem without preferably using private APIs. Any help will be appreciated. Thanks.

答: We had almost this exact problem: A certificate error on a particular device running the same code that worked on multiple other devices.  It turned out that this had to do with the internal date of the problem device not being current.  Our SSL certificate was up to date, but the device was set outside the valid date range.  It's worth checking because it could happen to anyone - even the iTunes app reviewer rejected the app for this reason.  Luckily we were familiar with the issue, appealed and got a quick approval.</p>


问:
Focus first button when there are two buttons in a window
I use Window to show a dialog, the dialog has two buttons: confirm and cancel, but the cancel button always focus, even i set its Focusable=False, while i want to let confirm button to be focused as default, then i can execute the confirmhandler when enter key is pressed.

```<code>  <Button x:Name="btnConfirm" Content="Confirm" HorizontalAlignment="Right" Margin="0,0,100,10" VerticalAlignment="Bottom" Width="75" Click="btnConfirm_Click" Focusable="True"/>
  <Button x:Name="btnCancel" Content="Cancel" HorizontalAlignment="Right" Margin="0,0,10,10" VerticalAlignment="Bottom" Width="75" IsDefault="True" Click="btnCancel_Click" Focusable="False"/>
</code>```

答:
You need to move IsDefault="True" from btnCancel to btnConfirm:

```<code><Button x:Name="btnConfirm" ... IsDefault="True" ... />
</code>```

For btnCancel you can set IsCancel:

```<code><Button x:Name="btnCancel" ... IsCancel="True" ... />
</code>```

Body:
I use Window to show a dialog, the dialog has two buttons: confirm and cancel, but the cancel button always focus, even i set its Focusable=False, while i want to let confirm button to be focused as default, then i can execute the confirmhandler when enter key is pressed.

  <Button x:Name="btnConfirm" Content="Confirm" HorizontalAlignment="Right" Margin="0,0,100,10" VerticalAlignment="Bottom" Width="75" Click="btnConfirm_Click" Focusable="True"/>
  <Button x:Name="btnCancel" Content="Cancel" HorizontalAlignment="Right" Margin="0,0,10,10" VerticalAlignment="Bottom" Width="75" IsDefault="True" Click="btnCancel_Click" Focusable="False"/>

Body:
You need to move IsDefault="True" from btnCancel to btnConfirm:

<Button x:Name="btnConfirm" ... IsDefault="True" ... />

For btnCancel you can set IsCancel:

<Button x:Name="btnCancel" ... IsCancel="True" ... />


问:
Seeking improvement recommendations for my PROD deployment process
I'm looking for a more robust, cheap option for production deployment of my node backend.

Currently my method is to run E2E tests locally, then at around 2AM I'll ssh into the production server, pull a release tag from my prod branch in git, restart all the scripts, and then run E2E tests again with fingers crossed.

It feels very cheap and there must be a better way. Is there something that would be able to automate this deployment process, including running my E2E tests, maybe notifying a Slack channel when it's done? Something that knows what release version is currently deployed. Whats the current best practice for deployment and what's the next step up from my current practice?

Thanks

答:
A better  practice would be to formalize that deployment process as a Jenkins pipeline, which would be part of your sources, and be used by any Jenkins server (2.x).

Jenkins has a Slack plugin, so that job will be able to interact with a Slack channel.


问:
Design decision? 4 minute report... tying up the server
I have a few reports that are taking up to 4 minutes to run in my RoR application. Since then, my users are experiencing delays with their simple tasks in the systems where the system stops responding.

I am still trying to look into the main cause of the issue to see if the reporting and the system-hangs are related. Does anyone have any advise on how I should go about restructing my report to it does not take 4 minutes to run?

So far I have looked into running a background job every night that calculates all of the figures I want so the reporting times will be significantly decreased. I am yet to find a solution that may use middleware or in memory instances to derive reports instead of hitting the DB with a large query.

Technical info:

The VPS is running 384 MB of RAM (will an increase be a suficient work-around?)

The reports are a combination of SQLs with some heavy ruby scripting to massage the contents so they are displayed in a readible fashion

DB tables contain between 2,000 to 30,000 rows

Technical Report Info

DB-query-1 has 5 inner joins. It is run first to create a lookup hash

DB-query-2 has 5 inner joins. It is run once and each record of its resultset is traversed

For each record of (2.), DB-query-3 (containing 5 inner joins) is run

For each record of (2.), the lookup hash from (1.) is traversed to perform some calculations

From writing this through Anon's request of additional information I can already see the sting of a nested loop...

答:
30,000 records is nothing. You should be able to perform a full dump export/import of a database that size in less than 4 seconds, so something seems not right :)

If you can provide us with some information about the tables, their relationships and what your report is about, I'm sure we can offer some specific advice on how to improve things.

Some general advice on performant reports:
Don't use an ORM-tool for reports, unless the report requirements are very trivial (in which case it would be called a list, not a report). Go for a hand crafted SQL with attitude.

Don't listen to the Zealots who forbid you to use vendor specific SQL extensions. You paid (moneywise or time spent) for this specific dbms. Use it to its fullest!

Do as much work as humanly possible inside the database. (When using the extensions, this becomes much easier). Databases are built for searching, sorting and aggregating data, and they do it very well. A table with 1,000,000 rows at an average row size of 200 bytes will consume less than 200 MB. Assuming that the disk subsystem can deliver 50mb/s, it would take 4 seconds to perform a SUM(value) over the entire table. That's the theoretical upper limit. If you need more, you have to pre-compute data so that the working set becomes smaller (google for "aggregate" and "rollup").

This potentially means writing longer and more complicated queries. Long complex SQL often confuses the optimizer so that it comes up with a suboptimal execution plan. Solving this usually requires solid experience with the specific dbms product. Having a normalized database with full referential integrity and constraint checking makes this a less common issue though.

Don't run queries in a loop. If your query takes 1 ms to complete, it does not take 1 second to run 1000 queries. Each call has to "pay" for network delay, marshalling/unmarshalling the data, potential locking issues, parsing, fetching, etc.

(updated)

If the expected (and acceptable) runtime is more than a second or so, you can afford to lookup some values and provide them as literals to help the optimizer. This can be used to remove non-correlated subqueries and joins.

Keep user-defined functions to a minimum. They confuse the optimizer and often forces row-processing (which is non-scalable).


问:
wso2is curl claims authorization
I have spent a lot if time in the documentation and this Q/A forum but have still not ascertained the information I need/understand.  The model that I ham working with does not exactly meld with WSO2IS very well.  The programmer is set in their ways and will not budge on change, nothing I can do about that.  They are just after the security that is provided by WSO2IS.  So here is programmers model, NOT sso.
user->web_site->wso2is authorization->website
It is to have every user login every time.  What they want from wso2s is to send user_name, password and company_id and to return valid/invalid id and a set of permission. External id should work well as a claim for the company id.
I have been able to create a user, but not able to add a role for that user and I have not been able to get authorization.  I can get some of the information about the user via SCIM : curl -v -k --user admin:admin https://wso2-dev.h3net.com:9443/wso2/scim/Users/d9bef03a-ddcf-44fc-a431-3b71e618b61e
What I need are 3 curl commands via REST like commands
Here's what I have for adding a user : curl -k -X POST -H "Authorization: Basic YWRtaW46YWRtaW4=" -H "Content-Type: application/json" -d '{"user":{"username":"Gomez","realm":"PRIMARY","password":"Password1!","claims":[{"uri":"http://wso2.org/claims/givenname","value":"Gomez"},{"uri":"http://wso2.org/claims/emailaddress","value":"bnpatton@west.com"},{"uri":"http://wso2.org/claims/lastname","value":"Adams"},{"uri":"http://wso2.org/claims/mobile","value":"1234567890"}]},"properties":[]}' "https://wso2-dev.h3net.com:9443/api/identity/user/v0.9/me

This does not show haw to add a role for the user, just claims.
With something like the above, how would I do the following :
1. add roles to a user
2. authorize user when just only have user_name, password and company_id(external_id claim)
3. return permissions with authorization or a separate curl command?

答:
Question 1

You can refer this comment for adding roles to the user using SCIM API.

Question 2

In this case, you can use XACML for claim based authorization. Please refer this blog for the implementation.

Question 3

WSO2IS server is working as policy decision point(PDP). Based on the decision you can access the resource in the resource server.

Title: wso2is curl claims authorization


问:
how to make a server listen to a path in nodejs
Can anyone help me figure out how to make a server in nodejs to listen to a specific path in localhost? If I replace the following path by 'port: 3000' then the localhost:3000 works properly but I just cannot find out how to carry out with path.</p>

```<code>var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);
server.listen({path:__dirname + '/example.html'});
app.get('/',function(req, res){
res.sendFile(__dirname + '/example.html');
});
</code>```

答:
Servers don't listen to a path (unless it's a path to a local IPC endpoint).  Here's where the IPC path info is documented for .listen().  So a server doesn't listen to a path such as /admin.  For requests from the outside world, servers listen to a port and when an http request comes into that port (with any path as part of that request), they can look at the specific path requested in the http reuqest and then act accordingly.

It is possible to build or configure a proxy that will listen on a specific port and based on the path in the http request, it will then forward the request to another server on another port so that the other server will only ever receive requests starting with a particular path.  I believe that the Nginx proxy server can be configured to do that.

If you can back up and describe what you're really trying to accomplish, we can help better with a specific code or tool recommendation.

Body:
Can anyone help me figure out how to make a server in nodejs to listen to a specific path in localhost? If I replace the following path by 'port: 3000' then the localhost:3000 works properly but I just cannot find out how to carry out with path.

var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);
server.listen({path:__dirname + '/example.html'});
app.get('/',function(req, res){
res.sendFile(__dirname + '/example.html');
});


问:
Python: how to create scatterplots of fixed ranges, across several intervals?
I have the following pandas DataFrame:

```<code>import pandas as pd
df = pd.read_table(...)
df

>>> df
>>>    interval  location type  y_axis
0        01      1230    X      50
1        01      1609    X      55
2        01      1903    Y      54
3        01      2574    A      58
4        01      3151    A      57
5        01      3198    B      46
6        01      3312    X      50
...                 .....
         02      42      X      31
         02      214     A      23
         02      598     X      28
....
</code>```

There are several intervals, e.g. 01, 02, etc. Within each interval, data points lie within the range of 1 to 10,000. In df, the first datapoint is at 40, the next at 136, etc.

Interval 02 also has a range from 1 to 15,000.

I would like to create a scatterplot, such that the range of 1 to 15000 is proportionally plotted for each interval. Then the first point would be plotted at 1230, the next plotted at 1609, etc. I would also like a vertical line which shows where the intervals are. The scatterplot's x-axis should be spaced from 1 to 10,000. Each interval is a "region", containing this x-axis from 1 to 10,000. So the coordinates on the x-axis are interval1: 1 to 15000, interval2: 1 to 15000, interval 3: 1 to 15000, etc. (It is almost like several individual scatterplots concatenated together.)

How does one accomplish this? Without this complication of intervals, if one wished to create a scatterplot from this DataFrame, one would use:

```<code>df.plot(kind='scatter', x = "location", y = "y_axis")
</code>```

Here are the first 50 rows:

```<code>d = {"interval" : ["01",
 "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01",
 "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01",
 "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01",
 "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01",
 "01", "01", "01", "01", "01"], "location" : [1230, 1609,
 1903, 2574, 3151, 3198, 3312, 3659, 3709,
 3725, 4172, 4542, 4860, 4900, 5068, 5220,
 5260, 5339, 5442, 5529, 5773, 6128, 6165,
 6177, 6269, 6275, 6460, 7167, 7361, 7361,
 8051, 8222, 8305, 8992, 9104, 9439, 9844,
 10045, 10764, 10787, 11104, 11478, 11508,
 11684, 12490, 12590, 12794, 12803, 13823,
 13982], "type" : ["X", "X", "Y", "A", "A",
     "B", "X", "X", "X", "B", "B", "A", "A", "A", "B", "B", "X",
     "B", "Y", "X", "X", "Y", "Y", "C", "A", "X", "X", "Z", "Z",
     "B", "X", "X", "A", "A", "Y", "X", "A", "X", "X", "Z", "Z",
     "C", "X", "Y", "Y", "Z", "Z", "Z", "Z", "Z"],  "y_axis" : [50, 55,
    54, 58, 57, 46, 50, 55, 46, 42, 56, 55, 55, 45, 52, 51, 45, 48, 50,
     49, 53, 55, 45, 40, 49, 37, 52, 58, 52, 4, 58, 52, 49, 58, 50, 55,
    56, 53, 58, 43, 55, 55, 44, 52, 59, 49, 53, 39, 60, 52]}
</code>```

答:
Using Altair you can easily separate the two intervals as different columns/colors.

```<code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

cat = ["01"] *5 + ["02"]*4
x = np.append(np.arange(1,6), np.arange(2.5,4.1,0.5))
y = np.random.randint(12,24, size=len(cat))
df = pd.DataFrame({"cat":cat, "x":x, "y":y})
</code>```

By columns

```<code>from altair import *
Chart(df).mark_point().encode(x='x', y='y', column='cat').configure_cell(width=200, height=150)
</code>```

By color

```<code>from altair import *
Chart(df).mark_point().encode(x='x', y='y', color='cat').configure_cell(width=200, height=150)
</code>```

Body:
I have the following pandas DataFrame:

import pandas as pd
df = pd.read_table(...)
df

>>> df
>>>    interval  location type  y_axis
0        01      1230    X      50
1        01      1609    X      55
2        01      1903    Y      54
3        01      2574    A      58
4        01      3151    A      57
5        01      3198    B      46
6        01      3312    X      50
...                 .....
         02      42      X      31
         02      214     A      23
         02      598     X      28
....

There are several intervals, e.g. 01, 02, etc. Within each interval, data points lie within the range of 1 to 10,000. In df, the first datapoint is at 40, the next at 136, etc.

Interval 02 also has a range from 1 to 15,000.

I would like to create a scatterplot, such that the range of 1 to 15000 is proportionally plotted for each interval. Then the first point would be plotted at 1230, the next plotted at 1609, etc. I would also like a vertical line which shows where the intervals are. The scatterplot's x-axis should be spaced from 1 to 10,000. Each interval is a "region", containing this x-axis from 1 to 10,000. So the coordinates on the x-axis are interval1: 1 to 15000, interval2: 1 to 15000, interval 3: 1 to 15000, etc. (It is almost like several individual scatterplots concatenated together.)

How does one accomplish this? Without this complication of intervals, if one wished to create a scatterplot from this DataFrame, one would use:

df.plot(kind='scatter', x = "location", y = "y_axis")

Here are the first 50 rows:

d = {"interval" : ["01",
 "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01",
 "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01",
 "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01",
 "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01",
 "01", "01", "01", "01", "01"], "location" : [1230, 1609,
 1903, 2574, 3151, 3198, 3312, 3659, 3709,
 3725, 4172, 4542, 4860, 4900, 5068, 5220,
 5260, 5339, 5442, 5529, 5773, 6128, 6165,
 6177, 6269, 6275, 6460, 7167, 7361, 7361,
 8051, 8222, 8305, 8992, 9104, 9439, 9844,
 10045, 10764, 10787, 11104, 11478, 11508,
 11684, 12490, 12590, 12794, 12803, 13823,
 13982], "type" : ["X", "X", "Y", "A", "A",
     "B", "X", "X", "X", "B", "B", "A", "A", "A", "B", "B", "X",
     "B", "Y", "X", "X", "Y", "Y", "C", "A", "X", "X", "Z", "Z",
     "B", "X", "X", "A", "A", "Y", "X", "A", "X", "X", "Z", "Z",
     "C", "X", "Y", "Y", "Z", "Z", "Z", "Z", "Z"],  "y_axis" : [50, 55,
    54, 58, 57, 46, 50, 55, 46, 42, 56, 55, 55, 45, 52, 51, 45, 48, 50,
     49, 53, 55, 45, 40, 49, 37, 52, 58, 52, 4, 58, 52, 49, 58, 50, 55,
    56, 53, 58, 43, 55, 55, 44, 52, 59, 49, 53, 39, 60, 52]}

Body:
Using Altair you can easily separate the two intervals as different columns/colors.

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

cat = ["01"] *5 + ["02"]*4
x = np.append(np.arange(1,6), np.arange(2.5,4.1,0.5))
y = np.random.randint(12,24, size=len(cat))
df = pd.DataFrame({"cat":cat, "x":x, "y":y})

By columns

from altair import *
Chart(df).mark_point().encode(x='x', y='y', column='cat').configure_cell(width=200, height=150)

By color

from altair import *
Chart(df).mark_point().encode(x='x', y='y', color='cat').configure_cell(width=200, height=150)


问:
Angular 4 - Can I create a form dynamically with ngFor?
I'm trying to dynamically create an editable form with ngFor. Basically, a data grid and that's what I'd be using some other systems--maybe that's the way I should go, but I tried this first.

```<code><form #employeeForm="ngForm">
      <tr *ngFor="let employee of newEmployees | filter:filterCriteria; let i = index" [class.active]="i == selectedRow" [attr.rowIndex]="i">
          <td class="clickable" (click)="showEmployee(i)">
             <div>{{employee.avatar}}</div>
          </td>
          <td>
            <md-input-container dividerColor="accent" >
             <input mdInput placeholder="name" value={{employee.name}} name="employee-name-{{employee.id}}" [(ngModel)]="employee-name-{{employee.id}}"/>
           </md-input-container>
        </td>
       ...
        <td>
       <md-icon (click)="saveEmployeeChanges(employee.id)">save</md-icon></td>
        </tr>
</form>
</code>```

Am I barking up the wrong tree here? If this can work, how do I access each input fields (there would be more) from within the component? And how do I get the values of every field in the row (not just the one that changed last).

答:
There are many ways to solve this problem.

Have you seen this as an example: https://angular.io/guide/dynamic-form

But what you have is an option as well. You can change this:

```<code><md-icon (click)="saveEmployeeChanges(employee.id)">
</code>```

to this:

```<code><md-icon (click)="saveEmployeeChanges(employeeForm)">
</code>```

That will pass the form and all of its associated controls to your component class.

To access the controls on the form you can use:

```<code>employeeForm.get('name').value;
</code>```

You can find out more in the Angular docs here: https://angular.io/guide/reactive-forms#inspect-formcontrol-properties

Body:
I'm trying to dynamically create an editable form with ngFor. Basically, a data grid and that's what I'd be using some other systems--maybe that's the way I should go, but I tried this first.

<form #employeeForm="ngForm">

{{employee.avatar}}

            <md-input-container dividerColor="accent" >
             <input mdInput placeholder="name" value={{employee.name}} name="employee-name-{{employee.id}}" [(ngModel)]="employee-name-{{employee.id}}"/>
           </md-input-container>

       ...

       <md-icon (click)="saveEmployeeChanges(employee.id)">save</md-icon>

</form>

Am I barking up the wrong tree here? If this can work, how do I access each input fields (there would be more) from within the component? And how do I get the values of every field in the row (not just the one that changed last).

Body:
There are many ways to solve this problem.

Have you seen this as an example: https://angular.io/guide/dynamic-form

But what you have is an option as well. You can change this:

<md-icon (click)="saveEmployeeChanges(employee.id)">

to this:

<md-icon (click)="saveEmployeeChanges(employeeForm)">

That will pass the form and all of its associated controls to your component class.

To access the controls on the form you can use:

employeeForm.get('name').value;

You can find out more in the Angular docs here: https://angular.io/guide/reactive-forms#inspect-formcontrol-properties


问:
bootstrap/modal: how to show page within it?
I have a modal like below:

```<code><div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h3 class="modal-title">Modal Demo</h3>
      </div>
      <div class="modal-body">
        <a href="https://www.google.com">google</a>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>

  </div>
</div>
</code>```

When the modal pops up and I click "google", I expect to see the page shown within the modal. Is it possible? I don't have to use modal but would like solution "compatible" with bootstrap.

Thanks for the help.

答:
Put this code in HTML

```<code><div class="modal fade bs-modal-sm" id="modal"  role="dialog"  aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
        </div>
    </div>
</div>
</code>```

Jquery Function

```<code>function show_modal(target, title, size) {
    jQuery('#modal').removeData('bs.modal');
    jQuery('.modal-content').html('');
    jQuery('.modal-dialog').removeClass('modal-lg');
    jQuery('#modal').removeClass('create_event_task');
    jQuery('.modal-dialog').addClass(size);
    var newTarget = target.indexOf("?") >= 0 ? target + '&modal-title=' + title : target + '?modal-title=' + title;
    jQuery('#modal').modal({remote: encodeURI(newTarget)});
}
</code>```

Call JQuery function , using Onclick event.

```<code>show_modal('admin_users', 'Delete User', '');
</code>```

I am using this function for open a page within my application , you can try it using a URL.

Hope this answer is helpful to you.

Body:
I have a modal like below:

        <button type="button" class="close" data-dismiss="modal">×</button>

Modal Demo

        google

        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>

When the modal pops up and I click "google", I expect to see the page shown within the modal. Is it possible? I don't have to use modal but would like solution "compatible" with bootstrap.

Thanks for the help.

Body:
Put this code in HTML

<div class="modal fade bs-modal-sm" id="modal"  role="dialog"  aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
        </div>
    </div>
</div>

Jquery Function

function show_modal(target, title, size) {
    jQuery('#modal').removeData('bs.modal');
    jQuery('.modal-content').html('');
    jQuery('.modal-dialog').removeClass('modal-lg');
    jQuery('#modal').removeClass('create_event_task');
    jQuery('.modal-dialog').addClass(size);
    var newTarget = target.indexOf("?") >= 0 ? target + '&modal-title=' + title : target + '?modal-title=' + title;
    jQuery('#modal').modal({remote: encodeURI(newTarget)});
}

Call JQuery function , using Onclick event.

show_modal('admin_users', 'Delete User', '');

I am using this function for open a page within my application , you can try it using a URL.

Hope this answer is helpful to you.


问:
Server to Server ssh via Private Key -- Permission denied (publickey)
I know this question is from the list of probably most downvoted questions but nonetheless have been stuck on it since morning, so worth a try getting a positive response from the community. I have already went through various already questions asked and their solutions, but guess it's not working.

I am following the https://docs.gitlab.com/ee/ci/examples/deployment/composer-npm-deploy.html to write deploy script from gitlab runner to my server. Hence, the runner (ubuntu/docker based) needs to transfer the files to my server and because the runner is dynamic (In this case - both are droplets)

I am using the private key of my server

Placing the private key in the runner by running

eval $(ssh-agent -s)

nano /root/.ssh/id_rsa_sid (pasted the private key content from my server (.ssh/id_rsa))

ssh-add /root/.ssh/id_rsa_sid

Identity added: /root/.ssh/id_rsa_sid (/root/.ssh/id_rsa_sid)

Now, when I do ssh -v root@serverip, I am getting Permission denied (publickey). (I tried -i key file path flag as well -- same result)

```<code>root@ubuntu-512mb-sgp1-01:~/.ssh# ssh -v -i id_rsa_sid root@serverip
OpenSSH_7.2p2 Ubuntu-4ubuntu2.2, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 128.xxx.xxx.xxx [128.xxx.xxx.xxx] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: key_load_public: No such file or directory
debug1: identity file id_rsa_sid type -1
debug1: key_load_public: No such file or directory
debug1: identity file id_rsa_sid-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.2
debug1: Remote protocol version 2.0, remote software version
OpenSSH_7.2p2 Ubuntu-4ubuntu2.2
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.2 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 128.199.253.228:22 as 'root'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:/El3UFF60r6/qNAwvfyIzx6Cf6N2YuXed/UU5QWEP1Q
debug1: Host '128.199.253.228' is known and matches the ECDSA host key.
debug1: Found key in /root/.ssh/known_hosts:1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /root/.ssh/id_rsa_sid
debug1: Authentications that can continue: publickey
debug1: Trying private key: id_rsa_sid
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).
</code>```

As you can see, it trying the file both as public key and private key but failing.

I went to the server for logs:

cat /var/log/auth.log

```<code>Jul  5 13:13:16 docker-512mb-sgp1-01 sshd[2371]: Connection closed by 128.yyy.yyy.yy port 43292 [preauth]
</code>```

Please let me know what I am doing wrong or if you may - point me to right resource.

答:
For anyone like me (who came looking for an answer here)

Did a bit of troubleshooting and found it to be rather a silly mistake.

Add the server's public key to it's authorized keys file. That will do :-)

Thanks

Body:
I know this question is from the list of probably most downvoted questions but nonetheless have been stuck on it since morning, so worth a try getting a positive response from the community. I have already went through various already questions asked and their solutions, but guess it's not working.

I am following the https://docs.gitlab.com/ee/ci/examples/deployment/composer-npm-deploy.html to write deploy script from gitlab runner to my server. Hence, the runner (ubuntu/docker based) needs to transfer the files to my server and because the runner is dynamic (In this case - both are droplets)

I am using the private key of my server

Placing the private key in the runner by running

eval $(ssh-agent -s)

nano /root/.ssh/id_rsa_sid (pasted the private key content from my server (.ssh/id_rsa))

ssh-add /root/.ssh/id_rsa_sid

Identity added: /root/.ssh/id_rsa_sid (/root/.ssh/id_rsa_sid)

Now, when I do ssh -v root@serverip, I am getting Permission denied (publickey). (I tried -i key file path flag as well -- same result)

root@ubuntu-512mb-sgp1-01:~/.ssh# ssh -v -i id_rsa_sid root@serverip
OpenSSH_7.2p2 Ubuntu-4ubuntu2.2, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 128.xxx.xxx.xxx [128.xxx.xxx.xxx] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: key_load_public: No such file or directory
debug1: identity file id_rsa_sid type -1
debug1: key_load_public: No such file or directory
debug1: identity file id_rsa_sid-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.2
debug1: Remote protocol version 2.0, remote software version
OpenSSH_7.2p2 Ubuntu-4ubuntu2.2
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.2 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 128.199.253.228:22 as 'root'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:/El3UFF60r6/qNAwvfyIzx6Cf6N2YuXed/UU5QWEP1Q
debug1: Host '128.199.253.228' is known and matches the ECDSA host key.
debug1: Found key in /root/.ssh/known_hosts:1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /root/.ssh/id_rsa_sid
debug1: Authentications that can continue: publickey
debug1: Trying private key: id_rsa_sid
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).

As you can see, it trying the file both as public key and private key but failing.

I went to the server for logs:

cat /var/log/auth.log

Jul  5 13:13:16 docker-512mb-sgp1-01 sshd[2371]: Connection closed by 128.yyy.yyy.yy port 43292 [preauth]

Please let me know what I am doing wrong or if you may - point me to right resource.


问:
what is the simplest way to check for occurrence of character/substring in dataframe values?
consider a pandas dataframe that has values such as 'a - b'. I would like to check for the occurrence of '-' anywhere across all values of the dataframe without looping through individual columns. Clearly a check such as the following won't work:

if '-' in df.values

Any suggestions on how to check for this? Thanks.

答:
I'd use stack() + .str.contains() in this case:

```<code>In [10]: df
Out[10]:
   a      b      c
0  1  a - b      w
1  2      c      z
2  3      d  2 - 3

In [11]: df.stack().str.contains('-').any()
Out[11]: True

In [12]: df.stack().str.contains('-')
Out[12]:
0  a      NaN
   b     True
   c    False
1  a      NaN
   b    False
   c    False
2  a      NaN
   b    False
   c     True
dtype: object
</code>```

Body:
I'd use stack() + .str.contains() in this case:

In [10]: df
Out[10]:
   a      b      c
0  1  a - b      w
1  2      c      z
2  3      d  2 - 3

In [11]: df.stack().str.contains('-').any()
Out[11]: True

In [12]: df.stack().str.contains('-')
Out[12]:
0  a      NaN
   b     True
   c    False
1  a      NaN
   b    False
   c    False
2  a      NaN
   b    False
   c     True
dtype: object


问:
AWS Kinesis Firehose - using Index Rotation (Elasticsearch)
I have set up a new AWS Kinesis Firehose stream and I'd like to create a new index on a weekly basis.

For that, I should use Index Rotation setting when configuring the stream.

But, do I have to the new index every weekend for the next upcoming week?
If not (hopefully not), how does Firehose knows what mapping to use? does it use the mapping defined in the index that I specified in the Index setting?

More over, lets say I have old data, can I make Firehose to create an index with the relevant timestamp according to the dates in specified in my old data?

Thank you !

答:
Have you tried to consider creating index template in elastic search. Thay way new indexes will pick the mapping defined in index template.

Refer to following link for details

https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html