问:
reversing order of CSS transitions
I have a menu button, and a hidden list. I'm toggling classes to create a drop-down effect.

When the classes are added, it opens the drop-down just fine.

However on the removal of the classes, as you'll see in the following code snippet, the transition isn't as seamless. Basically what I'd like to do is reverse the order the transitions happen in, but I'm not sure how to accomplish this.

Thanks for the help.

$('.contact-menu-button').children('svg').click(function (event) {
 event.stopPropagation();
  $('.contact-menu-items').toggleClass('show');
  $('.contact-menu-button').children('svg').toggleClass('rotate');
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>@import url(https://fonts.googleapis.com/css?family=Kanit:200,400);

* {
  font-family: Kanit, sans-serif;
}

div {
  display: inline-block;
  padding: 5px;
}

.container {
  width: 90%;
  color: #fff;
  background-color: #4a7ff7;
  border-radius: 8px 8px 0 0;
  box-shadow: 0px 5px 5px 0px rgba(0, 0, 0, 0.4);
}

.active-contact {
  padding-right: 0;
}

.contact-menu {
  position: relative;
  padding-left: 0;
}

.contact-menu-button {
  background-color: transparent;
  border: none;
  border-radius: 4px;
  outline: none;
  color: #fff;
  padding: 0;
  width: 25px;
  cursor: pointer;
  transform: translateY(3px);
}

.contact-menu-button > svg {
    height: 20px;
    width: 20px;
    border-radius: 15px;
    stroke: #fff;
    transition: transform 250ms linear, border-radius 250ms ease-in 275ms;
}

.contact-menu-button > svg:hover {
  background-color: #fff;
  stroke: #4a7ff7;
}

.contact-menu-button > svg:active {
    stroke: #fff;
    background-color: #000;
}

.contact-menu-button > .rotate {
    background-color: #000;
    border-radius: 0 0 15px 15px;
    transform: rotate(180deg);
}

.contact-menu-button > .rotate:hover {
  background-color: #000;
  stroke: #fff;
}

.contact-menu-items {
    visibility: hidden;
    height: 0;
    overflow: hidden;
    color: #fff;
    position: absolute;
    list-style-type: none;
    padding: 10px 0;
    margin: 0 5px 5px 5px;
    border-radius: 6px 0 6px 6px;
    background-color: #000;
    transform: translate(-57px, -6px);
    transition: visibility 250ms ease-out 550ms, height 250ms ease-out 550ms;
}

.contact-menu-items > li {
    padding: 1px 15px 1px 15px;
}

.contact-menu-items.show {
    visibility: visible;
    height: 50px;
}

.contact-menu-items > li:hover {
    background-color: #fff;
    color: #000;
}</code>```

    John Smith

    <button class="contact-menu-button">
      <svg>
        <path d="M4 9 l 6 5 l 6 -5" stroke-width="1.5" fill="none" />
      </svg>
    </button>

        Edit

        Delete

```

答:
you need to catch event from the button, not the SVG within ;)

$('.contact-menu-button').click(function (event) {
 event.stopPropagation();
  $('.contact-menu-items').toggleClass('show');
  $('.contact-menu-button').children('svg').toggleClass('rotate');
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>@import url(https://fonts.googleapis.com/css?family=Kanit:200,400);

* {
  font-family: Kanit, sans-serif;
}

div {
  display: inline-block;
  padding: 5px;
}

.container {
  width: 90%;
  color: #fff;
  background-color: #4a7ff7;
  border-radius: 8px 8px 0 0;
  box-shadow: 0px 5px 5px 0px rgba(0, 0, 0, 0.4);
}

.active-contact {
  padding-right: 0;
}

.contact-menu {
  position: relative;
  padding-left: 0;
}

.contact-menu-button {
  background-color: transparent;
  border: none;
  border-radius: 4px;
  outline: none;
  color: #fff;
  padding: 0;
  width: 25px;
  cursor: pointer;
  transform: translateY(3px);
}

.contact-menu-button > svg {
    height: 20px;
    width: 20px;
    border-radius: 15px;
    stroke: #fff;
    transition: transform 250ms linear, border-radius 250ms ease-in 275ms;
}

.contact-menu-button > svg:hover {
  background-color: #fff;
  stroke: #4a7ff7;
}

.contact-menu-button > svg:active {
    stroke: #fff;
    background-color: #000;
}

.contact-menu-button > .rotate {
    background-color: #000;
    border-radius: 0 0 15px 15px;
    transform: rotate(180deg);
}

.contact-menu-button > .rotate:hover {
  background-color: #000;
  stroke: #fff;
}

.contact-menu-items {
    visibility: hidden;
    height: 0;
    overflow: hidden;
    color: #fff;
    position: absolute;
    list-style-type: none;
    padding: 10px 0;
    margin: 0 5px 5px 5px;
    border-radius: 6px 0 6px 6px;
    background-color: #000;
    transform: translate(-57px, -6px);
    transition: visibility 250ms ease-out 550ms, height 250ms ease-out 550ms;
}

.contact-menu-items > li {
    padding: 1px 15px 1px 15px;
}

.contact-menu-items.show {
    visibility: visible;
    height: 50px;
}

.contact-menu-items > li:hover {
    background-color: #fff;
    color: #000;
}</code>```

    John Smith

    <button class="contact-menu-button">
      <svg>
        <path d="M4 9 l 6 5 l 6 -5" stroke-width="1.5" fill="none" />
      </svg>
    </button>

        Edit

        Delete

```

Title: reversing order of CSS transitions

Body:
I have a menu button, and a hidden list. I'm toggling classes to create a drop-down effect.

When the classes are added, it opens the drop-down just fine.

However on the removal of the classes, as you'll see in the following code snippet, the transition isn't as seamless. Basically what I'd like to do is reverse the order the transitions happen in, but I'm not sure how to accomplish this.

Thanks for the help.

$('.contact-menu-button').children('svg').click(function (event) {
 event.stopPropagation();
  $('.contact-menu-items').toggleClass('show');
  $('.contact-menu-button').children('svg').toggleClass('rotate');
});

@import url(https://fonts.googleapis.com/css?family=Kanit:200,400);

* {
  font-family: Kanit, sans-serif;
}

div {
  display: inline-block;
  padding: 5px;
}

.container {
  width: 90%;
  color: #fff;
  background-color: #4a7ff7;
  border-radius: 8px 8px 0 0;
  box-shadow: 0px 5px 5px 0px rgba(0, 0, 0, 0.4);
}

.active-contact {
  padding-right: 0;
}

.contact-menu {
  position: relative;
  padding-left: 0;
}

.contact-menu-button {
  background-color: transparent;
  border: none;
  border-radius: 4px;
  outline: none;
  color: #fff;
  padding: 0;
  width: 25px;
  cursor: pointer;
  transform: translateY(3px);
}

.contact-menu-button > svg {
    height: 20px;
    width: 20px;
    border-radius: 15px;
    stroke: #fff;
    transition: transform 250ms linear, border-radius 250ms ease-in 275ms;
}

.contact-menu-button > svg:hover {
  background-color: #fff;
  stroke: #4a7ff7;
}

.contact-menu-button > svg:active {
    stroke: #fff;
    background-color: #000;
}

.contact-menu-button > .rotate {
    background-color: #000;
    border-radius: 0 0 15px 15px;
    transform: rotate(180deg);
}

.contact-menu-button > .rotate:hover {
  background-color: #000;
  stroke: #fff;
}

.contact-menu-items {
    visibility: hidden;
    height: 0;
    overflow: hidden;
    color: #fff;
    position: absolute;
    list-style-type: none;
    padding: 10px 0;
    margin: 0 5px 5px 5px;
    border-radius: 6px 0 6px 6px;
    background-color: #000;
    transform: translate(-57px, -6px);
    transition: visibility 250ms ease-out 550ms, height 250ms ease-out 550ms;
}

.contact-menu-items > li {
    padding: 1px 15px 1px 15px;
}

.contact-menu-items.show {
    visibility: visible;
    height: 50px;
}

.contact-menu-items > li:hover {
    background-color: #fff;
    color: #000;
}

    John Smith

    <button class="contact-menu-button">
      <svg>
        <path d="M4 9 l 6 5 l 6 -5" stroke-width="1.5" fill="none" />
      </svg>
    </button>

        Edit

        Delete

Body:
you need to catch event from the button, not the SVG within ;)

$('.contact-menu-button').click(function (event) {
 event.stopPropagation();
  $('.contact-menu-items').toggleClass('show');
  $('.contact-menu-button').children('svg').toggleClass('rotate');
});

@import url(https://fonts.googleapis.com/css?family=Kanit:200,400);

* {
  font-family: Kanit, sans-serif;
}

div {
  display: inline-block;
  padding: 5px;
}

.container {
  width: 90%;
  color: #fff;
  background-color: #4a7ff7;
  border-radius: 8px 8px 0 0;
  box-shadow: 0px 5px 5px 0px rgba(0, 0, 0, 0.4);
}

.active-contact {
  padding-right: 0;
}

.contact-menu {
  position: relative;
  padding-left: 0;
}

.contact-menu-button {
  background-color: transparent;
  border: none;
  border-radius: 4px;
  outline: none;
  color: #fff;
  padding: 0;
  width: 25px;
  cursor: pointer;
  transform: translateY(3px);
}

.contact-menu-button > svg {
    height: 20px;
    width: 20px;
    border-radius: 15px;
    stroke: #fff;
    transition: transform 250ms linear, border-radius 250ms ease-in 275ms;
}

.contact-menu-button > svg:hover {
  background-color: #fff;
  stroke: #4a7ff7;
}

.contact-menu-button > svg:active {
    stroke: #fff;
    background-color: #000;
}

.contact-menu-button > .rotate {
    background-color: #000;
    border-radius: 0 0 15px 15px;
    transform: rotate(180deg);
}

.contact-menu-button > .rotate:hover {
  background-color: #000;
  stroke: #fff;
}

.contact-menu-items {
    visibility: hidden;
    height: 0;
    overflow: hidden;
    color: #fff;
    position: absolute;
    list-style-type: none;
    padding: 10px 0;
    margin: 0 5px 5px 5px;
    border-radius: 6px 0 6px 6px;
    background-color: #000;
    transform: translate(-57px, -6px);
    transition: visibility 250ms ease-out 550ms, height 250ms ease-out 550ms;
}

.contact-menu-items > li {
    padding: 1px 15px 1px 15px;
}

.contact-menu-items.show {
    visibility: visible;
    height: 50px;
}

.contact-menu-items > li:hover {
    background-color: #fff;
    color: #000;
}

<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<div class="container">
  <div class="active-contact">
    John Smith
  </div>
  <div class="contact-menu">
    <button class="contact-menu-button">
      <svg>
        <path d="M4 9 l 6 5 l 6 -5" stroke-width="1.5" fill="none" />
      </svg>
    </button>
    <ul class="contact-menu-items">
      <li>
        <a>Edit</a>
      </li>
      <li>
        <a>Delete</a>
      </li>
    </ul>
  </div>
</div>


来源: stackexchange

问:
Get field values using reflection
I am not able to get the field value.What I am trying to do is get the Object at runtime. Please let me know where I am going wrong.

Test.class

```<code>import java.lang.reflect.Field;

public class Test {

public static void main(String[] args) throws ClassNotFoundException, NoSuchFieldException, SecurityException,
        IllegalArgumentException, IllegalAccessException {

    final Field field = Class.forName("com.logging.EX").getDeclaredField("value");
    field.setAccessible(true);
    field.get(Class.forName("com.logging.EX"));
}
</code>```

}

EX.class

```<code>public class EX {

private String value;

public EX(){
    value="data";
}
/**
 * @return the value
 */
public String getValue() {
    return value;
}

/**
 * @param value
 *            the value to set
 */
public void setValue(String value) {
    this.value = value;
}
</code>```

}

答:
Something like this...

```<code>import java.lang.reflect.Field;

public class Test {
    public static void main(String... args) {
        try {
            Foobar foobar = new Foobar("Peter");
            System.out.println("Name: " + foobar.getName());
            Class<?> clazz = Class.forName("com.csa.mdm.Foobar");
            System.out.println("Class: " + clazz);
            Field field = clazz.getDeclaredField("name");
            field.setAccessible(true);
            String value = (String) field.get(foobar);
            System.out.println("Value: " + value);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

class Foobar {
    private final String name;

    public Foobar(String name) {
        this.name = name;
    }

    public String getName() {
        return this.name;
    }
}
</code>```

Or, you can use the newInstance method of class to get an instance of your object at runtime. You'll still need to set that instance variable first though, otherwise it won't have any value.

E.g.

```<code>Class<?> clazz = Class.forName("com.something.Foobar");
Object object = clazz.newInstance();
</code>```

Or, where it has two parameters in its constructor, String and int for example...

```<code>Class<?> clazz = Class.forName("com.something.Foobar");
Constructor<?> constructor = clazz.getConstructor(String.class, int.class);
Object obj = constructor.newInstance("Meaning Of Life", 42);
</code>```

Or you can interrogate it for its constructors at runtime using clazz.getConstructors()

NB I deliberately omitted the casting of the object created here to the kind expected, as that would defeat the point of the reflection, as you'd already be aware of the class if you do that, which would negate the need for reflection in the first place.

ContentLicense: CC BY-SA 3.0

Title: Get field values using reflection

Body:
I am not able to get the field value.What I am trying to do is get the Object at runtime. Please let me know where I am going wrong.

Test.class

import java.lang.reflect.Field;

public class Test {

public static void main(String[] args) throws ClassNotFoundException, NoSuchFieldException, SecurityException,
        IllegalArgumentException, IllegalAccessException {

    final Field field = Class.forName("com.logging.EX").getDeclaredField("value");
    field.setAccessible(true);
    field.get(Class.forName("com.logging.EX"));
}

}

EX.class

public class EX {

private String value;

public EX(){
    value="data";
}
/**
 * @return the value
 */
public String getValue() {
    return value;
}

/**
 * @param value
 *            the value to set
 */
public void setValue(String value) {
    this.value = value;
}

}

Body:
Something like this...

import java.lang.reflect.Field;

public class Test {
    public static void main(String... args) {
        try {
            Foobar foobar = new Foobar("Peter");
            System.out.println("Name: " + foobar.getName());
            Class<?> clazz = Class.forName("com.csa.mdm.Foobar");
            System.out.println("Class: " + clazz);
            Field field = clazz.getDeclaredField("name");
            field.setAccessible(true);
            String value = (String) field.get(foobar);
            System.out.println("Value: " + value);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

class Foobar {
    private final String name;

    public Foobar(String name) {
        this.name = name;
    }

    public String getName() {
        return this.name;
    }
}

Or, you can use the newInstance method of class to get an instance of your object at runtime. You'll still need to set that instance variable first though, otherwise it won't have any value.

E.g.

Class<?> clazz = Class.forName("com.something.Foobar");
Object object = clazz.newInstance();

Or, where it has two parameters in its constructor, String and int for example...

Class<?> clazz = Class.forName("com.something.Foobar");
Constructor<?> constructor = clazz.getConstructor(String.class, int.class);
Object obj = constructor.newInstance("Meaning Of Life", 42);

Or you can interrogate it for its constructors at runtime using clazz.getConstructors()

NB I deliberately omitted the casting of the object created here to the kind expected, as that would defeat the point of the reflection, as you'd already be aware of the class if you do that, which would negate the need for reflection in the first place.


问:
Enforce invariants spanning multiple aggregates (set validation) in Domain-driven Design
To illustrate the problem we use a simple case: there are two aggregates - Lamp and Socket. The following business rule always must be enforced: Neither a Lamp nor a Socket can be connected more than once at the same time. To provide an appropriate command we conceive a Connector-service with the Connect(Lamp, Socket)-method to plug them.

Because we want to comply to the rule that one transaction should involve only one aggregate, it's not advisable to set the association on both aggregates in the Connect-transaction. So we need an intermediate aggregate which symbolizes the Connection itself. So the Connect-transaction would just create a new Connection with the given components. Unfortunately, at this point the troubles begin; how can we ensure the consistency of connection-state? It may happen that many simultaneous users want to plug the same components at the exact same time, so our "consistency check" wouldn't reject the request. New Connection-aggregates would be stored, because we only lock at aggregate-level. The system would be inconsistent without even knowing that.

But how should we set the boundary of our aggregates to ensure our business rule? We could conceive a Connections-aggregate which gathers all active connections (as Connection-entity), thereby enabling our locking-algorithm which would properly reject duplicate Connect-requests. On the other hand this approach is inefficient and does not scale, further it is counter-intuitive in terms of domain language.

Do you know what I'm missing?

Edit: To sum up the problem, imagine an aggregate User. Since the definition of an aggregate is to be a transaction-based unit we are able to enforce invariants by locking this unit per transaction. All is fine. But now a business rule arises: the username must be unique. Therefore we must somehow reconcile our aggregate boundaries with this new requirement. Assuming millions of users registering at the same time, it becomes a problem. We try to ensure this invariant in a non-locked state since multiple users means multiple aggregates.

According to the book "Domain-driven Design" by Eric Evans one should apply eventual consistency as soon as multiple aggregates are involved in a single transaction. But is this really the case here and does is make sense?

Applying eventual consistency here would entail registering the User and afterwards checking the invariant with the username. If two Users actually set the same username the system would undo the second registering and notify the User. Thinking about this scenario disconcerts me because it disrupts the whole registering process. Sending the confirmation e-mail, for example, had to be delayed and so forth.

I think I'm just forgetting about something in general but I don't know what. It seems to me that I need something like invariants on Repository-level.

答:
In addition to the suggestions already made, consider that some of these problems are very similar to database concurrency problems. Say that you have a contact, and one user changes the name, and another user changes the phone number for this contact. If you write a command that updates the whole contact with the state as it was after modification, then one of the two will overwrite the change of the other with the old value, unless measures are taken.

If, however, you write a 'ChangeEmailForContact' command, then already you will only change that one field and not have a conflict with the name change, which would similarly be a 'Name' or 'RenameContact' command.

Now what if two people change the email address shortly after the other? A really efficient way is to pass the original value (original email address) along with the new value in your command. Now you can check when updating the email address if the original email address was the same as the current email address (so it is a valid starting point), or if the new email address is the same as the current email address (no need to do anything). If not, then, only then, are you in a conflict situation.

Now, apply this to your 'set operation'. The first time a lightbulb is moved into a 'connection' (perhaps I would call it fixture), it is moving from unassigned to connection1. Then, when a lightbulb is moved, it must be moved from connection1 to connection2, say. Now you can validate if that lightbulb is already assigned, if it was assigned to connection1 or if something has changed in the meantime.

It doesn't solve everything of course, but for the tiny case that remains, that tiny moment where two initial assignments happen close enough together, you either have to go for say a redis cache of assigned usernames to validate against or give an admin an easy tool to solve this very rare instance. You could for instance make a projection that occasionally reports on such situations and make sure renaming isn't too painful.


问:
Does struct assignment guarantee padding to also be equal
Say I have a struct with 2 fields and the implementation of C that I have also has some padding between these fields.

If I create two variables of the struct and assign one to another, will the padding be guaranteed to be equal?

I know that for most compilers it would be so (because they just call memcpy), but I want to know what is specified about the padding in the standard?

Intention for this question is, can I use memcmp to check equality of structs.

Say I have a compiler which emits code that just assigns all the members of the struct instead of doing memcpy, will it be a valid implementation of the assignment of struct operation?

答: I don't think that you can use memcmp, because the memory between the members (i.e. the content in the "padding"-area) is not guaranteed to have a certain value, and assigning such a struct-object to another is not required to copy the padding content as well.


问:
Javascript find a position of a word in a string containing HTML
I got the following HTML:

```<code><div id="editable_phrase">
   My
   <span style="background-color: #19FC49;"> first</span>
   <span style="background-color: #09AC20;"> first</span> //note 2 firsts here
   <span style="background-color: #D2C3EA;"> phrase</span>
</div>
</code>```

And the original phrase that is - My first phrase

I need to find a position of a first letter of a selected word in my original phrase. So if I select (highlight with a mouse) phrase, I need to get 10 (or whatever it is). I tried to use charAt() or window.getSelection but still getting wrong results.

Moreover, if I select the same word but in different positions (like inm my example above where there are 2 first words) I get the same result as it finds the position of the first word while I need the second one.

I can use jQuery. Any ideas would be welcome. Thank you.

答:
iterate over the children of the div, and concat them to one string until you get to the desired value, and then return the length of it.
for example, something like this:
var str = "";</p>

```<code>var bool = false;
$('#editable_phrase').children().each(function(){
    if ($(this).text() == "phrase")
        bool = true;
    if (!bool)
        str+=$(this).text();
});
</code>```

Body:
I got the following HTML:

   My
    first
    first //note 2 firsts here
    phrase

And the original phrase that is - My first phrase

I need to find a position of a first letter of a selected word in my original phrase. So if I select (highlight with a mouse) phrase, I need to get 10 (or whatever it is). I tried to use charAt() or window.getSelection but still getting wrong results.

Moreover, if I select the same word but in different positions (like inm my example above where there are 2 first words) I get the same result as it finds the position of the first word while I need the second one.

I can use jQuery. Any ideas would be welcome. Thank you.

Body:
iterate over the children of the div, and concat them to one string until you get to the desired value, and then return the length of it.
for example, something like this:
var str = "";

var bool = false;
$('#editable_phrase').children().each(function(){
    if ($(this).text() == "phrase")
        bool = true;
    if (!bool)
        str+=$(this).text();
});


问:
Passport.js: Sign in with Github and return email address
I have built a node.js web app that uses passport.js with the passport-github strategy. Here is my code:

```<code>var express = require('express');
var app = express();
app.use(express.static('public'));
var passport = require('passport');
var GithubStrategy = require('passport-github').Strategy;
passport.use(new GithubStrategy({
    clientID: "foo",
    clientSecret: "bar",
    callbackURL: "baz",
    profileFields: ['email']
}, function(accessToken, refreshToken, profile, done) {
    return done(null, profile);
}));
passport.serializeUser(function(user, done) {
    done(null, user);
});
passport.deserializeUser(function(user, done) {
    done(null, user);
});
app.use(session({
    secret: 'this is a secret',
    resave: false,
    saveUninitialized: true
}));
app.use(passport.initialize());
app.use(passport.session());
app.set('view engine', 'ejs');
app.get('/', function(req, res) {
    html = JSON.stringify(req.user, null, 4);
    res.render('index', {
        title: 'My Home Page',
        html: html
    });
});
//Login
app.get('/login', function(req, res) {
    res.render('login', {
        title: 'Login to Chordscribble!'
    });
});
//Logout
app.get('/logout', function(req, res) {
    req.logout();
    res.redirect('/');
});
// GitHub
app.get('/auth/github', passport.authenticate('github', {
    scope: ['user:email']
}));
app.get('/auth/github/callback', passport.authenticate('github', {
    failureRedirect: '/login'
}), function(req, res) {
    res.redirect('/');
});
app.listen(3000);
</code>```

Everything is working fine except that I am getting a return value of null for the email address. My first question is, is there a way to guarantee that I will always get an email address? And, my second question is, if not, what how should I store this in a database without an email address? Possibly by assigning my own user id field and using their Github ID? Is the GitHub ID always going to be unique?

答:
GitHub users can configure in their GitHub profile (Personal settings/Profile) a "Public email".

If they don't have selected a public email address, you won't receive any user email from GitHub.

The GitHub ID will be (probably) unique and permanent. But I suggest you to double check GitHub policies.

Body:
I have built a node.js web app that uses passport.js with the passport-github strategy. Here is my code:

var express = require('express');
var app = express();
app.use(express.static('public'));
var passport = require('passport');
var GithubStrategy = require('passport-github').Strategy;
passport.use(new GithubStrategy({
    clientID: "foo",
    clientSecret: "bar",
    callbackURL: "baz",
    profileFields: ['email']
}, function(accessToken, refreshToken, profile, done) {
    return done(null, profile);
}));
passport.serializeUser(function(user, done) {
    done(null, user);
});
passport.deserializeUser(function(user, done) {
    done(null, user);
});
app.use(session({
    secret: 'this is a secret',
    resave: false,
    saveUninitialized: true
}));
app.use(passport.initialize());
app.use(passport.session());
app.set('view engine', 'ejs');
app.get('/', function(req, res) {
    html = JSON.stringify(req.user, null, 4);
    res.render('index', {
        title: 'My Home Page',
        html: html
    });
});
//Login
app.get('/login', function(req, res) {
    res.render('login', {
        title: 'Login to Chordscribble!'
    });
});
//Logout
app.get('/logout', function(req, res) {
    req.logout();
    res.redirect('/');
});
// GitHub
app.get('/auth/github', passport.authenticate('github', {
    scope: ['user:email']
}));
app.get('/auth/github/callback', passport.authenticate('github', {
    failureRedirect: '/login'
}), function(req, res) {
    res.redirect('/');
});
app.listen(3000);

Everything is working fine except that I am getting a return value of null for the email address. My first question is, is there a way to guarantee that I will always get an email address? And, my second question is, if not, what how should I store this in a database without an email address? Possibly by assigning my own user id field and using their Github ID? Is the GitHub ID always going to be unique?


问:
C# - Call the same javascript function inside a loop
Good day!

I am trying to achieve to change the color in the calendar cell of EXT Calendar for each holiday (holiday dates are from the database). But it only changes the first holiday which is the first line in the database.

My client side code :

```<code>        var applyCss = function (param1) {
        var css = "#CalendarPanel1-month-day-" + param1 + " {background-color: pink;}";

        Ext.net.ResourceMgr.registerCssClass("someCssClassId", css);
    };
</code>```

My server side code:

```<code>DataTable holiday = Attendance.getInstance().getHolidays();

            for (var i = 0; i < holiday.Rows.Count; i++)
            {
                var hd = holiday.Rows[i]["holiday_date"].ToString();
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "myScript", "applyCss(" + hd + ")", true);

            }
</code>```

Appreciate any recommendations / suggestions / solutions. Thanks!

答:
Use

```<code>X.AddScript("applyCss(" + hd + ")");
</code>```

(but the array string appending approach provided by the others works too)

Body:
Good day!

I am trying to achieve to change the color in the calendar cell of EXT Calendar for each holiday (holiday dates are from the database). But it only changes the first holiday which is the first line in the database.

My client side code :

        var applyCss = function (param1) {
        var css = "#CalendarPanel1-month-day-" + param1 + " {background-color: pink;}";

        Ext.net.ResourceMgr.registerCssClass("someCssClassId", css);
    };

My server side code:

DataTable holiday = Attendance.getInstance().getHolidays();

            for (var i = 0; i < holiday.Rows.Count; i++)
            {
                var hd = holiday.Rows[i]["holiday_date"].ToString();
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "myScript", "applyCss(" + hd + ")", true);

            }

Appreciate any recommendations / suggestions / solutions. Thanks!

Body:
Use

X.AddScript("applyCss(" + hd + ")");

(but the array string appending approach provided by the others works too)


问:
Clearing the text from the python shell
OK, so I am currently messing around coding hangman in python and was wondering if I can clear what it says in the python shell as I don't just wan't the person to read the word.

```<code>import time
keyword = input(" Please enter the word you want the person to guess")
lives = int(input("How many lives would you like to have?"))
print ("There are ", len(keyword), "letters in the word")

time.sleep(2)

guess = input("please enter your guess")
</code>```

I would like to remove all the text  in the shell.

答:
```<code>print("\n" * 100)
</code>```

There is no other way to do it then to just spam the console.

Title: Clearing the text from the python shell

Body:
OK, so I am currently messing around coding hangman in python and was wondering if I can clear what it says in the python shell as I don't just wan't the person to read the word.

import time
keyword = input(" Please enter the word you want the person to guess")
lives = int(input("How many lives would you like to have?"))
print ("There are ", len(keyword), "letters in the word")

time.sleep(2)

guess = input("please enter your guess")

I would like to remove all the text  in the shell.

Body:
print("\n" * 100)

There is no other way to do it then to just spam the console.


问:
How to not wrap row on browser resize
I am using Bootstrap to structure the page like this. Each row has the same structure.

```<code><div class="outerDiv">
    <div class="row">
        <div class="col-md-6">
            ...
        </div>
        <div class="col-md-1">
            ...
        </div>
        <div class="col-md-1">
            ...
        </div>
        <div class="col-md-1">
            ...
        </div>
        <div class="col-md-1">
            ...
        </div>
        <div class="col-md-1">
            ...
        </div>
    </div>

    <div class="row">
        <div class="col-md-6">
            ...
        </div>
        <div class="col-md-1">
            ...
        </div>
        <div class="col-md-1">
            ...
        </div>
        <div class="col-md-1">
            ...
        </div>
        <div class="col-md-1">
            ...
        </div>
        <div class="col-md-1">
            ...
        </div>
    </div>
</div>
</code>```

This is working fine and looks like this.

```<code><------col-md-6------><-col-md-1-><-col-md-1-><-col-md-1-><-col-md-1-><-col-md-1->
<------col-md-6------><-col-md-1-><-col-md-1-><-col-md-1-><-col-md-1-><-col-md-1->
</code>```

But when the browser resizes horitontally (gets narrower). The pages becomes the following:

```<code><------col-md-6------>
<-col-md-1->
<-col-md-1->
<-col-md-1->
<-col-md-1->
<-col-md-1->
<------col-md-6------>
<-col-md-1->
<-col-md-1->
<-col-md-1->
<-col-md-1->
<-col-md-1->
</code>```

So how do I make it so that it does not stack? And have to be scrolled?

I have tried applying the following css but does not work.

```<code>.row {
    white-space: nowrap;
    min-width: 1250px;
    overflow: auto;
}
</code>```

答:
You would have to use the corresponding grid column classes for each screen size. For example, using .col-xs-* and .col-sm-* for extra small and small screens as described in the Boostrap documentation: http://getbootstrap.com/css/#grid-options</p>

```<code><div class="row">
    <div class="col-md-6 col-sm-6 col-xs-6">
        ...
    </div>
    <div class="col-md-1 col-sm-1 col-xs-1">
        ...
    </div>
    <div class="col-md-1 col-sm-1 col-xs-1">
        ...
    </div>
    <div class="col-md-1 col-sm-1 col-xs-1">
        ...
    </div>
    <div class="col-md-1 col-sm-1 col-xs-1">
        ...
    </div>
    <div class="col-md-1 col-sm-1 col-xs-1">
        ...
    </div>
</div>
</code>```

Title: How to not wrap row on browser resize

Body:
I am using Bootstrap to structure the page like this. Each row has the same structure.

            ...

            ...

            ...

            ...

            ...

            ...

            ...

            ...

            ...

            ...

            ...

            ...

This is working fine and looks like this.

<------col-md-6------><-col-md-1-><-col-md-1-><-col-md-1-><-col-md-1-><-col-md-1->
<------col-md-6------><-col-md-1-><-col-md-1-><-col-md-1-><-col-md-1-><-col-md-1->

But when the browser resizes horitontally (gets narrower). The pages becomes the following:

<------col-md-6------>
<-col-md-1->
<-col-md-1->
<-col-md-1->
<-col-md-1->
<-col-md-1->
<------col-md-6------>
<-col-md-1->
<-col-md-1->
<-col-md-1->
<-col-md-1->
<-col-md-1->

So how do I make it so that it does not stack? And have to be scrolled?

I have tried applying the following css but does not work.

.row {
    white-space: nowrap;
    min-width: 1250px;
    overflow: auto;
}

Body:
You would have to use the corresponding grid column classes for each screen size. For example, using .col-xs-* and .col-sm-* for extra small and small screens as described in the Boostrap documentation: http://getbootstrap.com/css/#grid-options

<div class="row">
    <div class="col-md-6 col-sm-6 col-xs-6">
        ...
    </div>
    <div class="col-md-1 col-sm-1 col-xs-1">
        ...
    </div>
    <div class="col-md-1 col-sm-1 col-xs-1">
        ...
    </div>
    <div class="col-md-1 col-sm-1 col-xs-1">
        ...
    </div>
    <div class="col-md-1 col-sm-1 col-xs-1">
        ...
    </div>
    <div class="col-md-1 col-sm-1 col-xs-1">
        ...
    </div>
</div>


问:
Calibrating Development Schedules
Are there any online repositories of completed real-world projects with their timescales that I can use to callibrate my own development time estimates?</p>

答:
I don't think relating your project to a set of generic other projects to determine a time est. would be hugely beneficial. You can compare to other projects for defect rates - here's a good starting point for that: http://www.scribd.com/doc/7758538/Capers-Jones-Software-Quality-in-2008

My suggestion would be to look at prior projects in your company with the same relative technology and resources and develop a table (via function points) and then a continual resync.  If there is no prior info and/or the technology is new and/or the resources are different - then it's best to use the team's prior experience from prior jobs.

Here's a good book: Software Estimation: Demystifying the Black Art

OwnerDisplayName: sasserstyl

ContentLicense: CC BY-SA 2.5

Title: Calibrating Development Schedules

OwnerDisplayName: meade


问:
What does Java do with my "equals" implementations here?
Today, I've stumbled over the following:

Consider two classes NewClass and NewClass1, which have the following "equals"-methods:

NewClass:

```<code>@Override
public boolean equals(Object obj) {
    return false;
}

public boolean equals(NewClass obj) {
    return value == obj.getValue();
}
</code>```

NewClass1:

```<code>@Override
public boolean equals(Object obj) {
    if(!(obj instanceof NewClass1)) {
        return false;
    }
    return equals((NewClass1) obj);
}

public boolean equals(NewClass1 obj) {
    return value == obj.getValue();
}
</code>```

What I find weird is that the equals in NewClass1 seems to be exponentially slower than the one in NewClass (for 10.000.000 calls 14ms against 3000ms). At first, I thought this was related to the "instanceof" check, but if I replace "return equals((NewClass1) obj);" with "return false;" in NewClass1, suddenly it runs more or less equally fast. I don't really understand what is happening here, because in my opinion, the return statement in equals(Object) should never actually be called. What am I getting wrong here?

The following is my "benchmarking code", in case I made some mistake there:

```<code>public static void main(String[] args) {
    // TODO code application logic here

    NewClass i1 = new NewClass(1);
    NewClass i2 = new NewClass(1);
    NewClass i3 = new NewClass(5);

    NewClass1 j1 = new NewClass1(1);
    NewClass1 j2 = new NewClass1(1);
    NewClass1 j3 = new NewClass1(5);

    Object o1 = new Object();
    Object o2 = new Object();

    assert(i1.equals(i1));
    assert(i1.equals(i2));
    assert(i1.equals(i3) == false);
    assert(i1.equals(o1) == false);

    assert(j1.equals(j1));
    assert(j1.equals(j2));
    assert(j1.equals(j3) == false);
    assert(j1.equals(o1) == false);

    long start = System.currentTimeMillis();

    for(int i=0; i<1000000000; i++) {
        i1.equals(i1);
        i1.equals(i2);
        i1.equals(o1);
        i1.equals(o2);
    }

    long end = System.currentTimeMillis();

    System.out.println("Execution time was "+(end-start)+" ms.");

    start = System.currentTimeMillis();

    for(int i=0; i<1000000000; i++) {
        j1.equals(j1);
        j1.equals(j2);
        j1.equals(o1);
        j1.equals(o2);
    }

    end = System.currentTimeMillis();

    System.out.println("Execution time was "+(end-start)+" ms.");
}
</code>```

答:
I would guess that it is the instanceof test that is consuming the time.  When you change the final return in that method to always return false, the compiler probably eliminates the conditional, since the result will be the same (return false) regardless of its evaluation.  This would also explain why changing the final return has any effect at all, since as you say it should never actually be reached in the code path.

To put it more generally, a code change can impact performance even if it is not on the executed code path, by changing how the compiler optimizes the code.

Body:
Today, I've stumbled over the following:

Consider two classes NewClass and NewClass1, which have the following "equals"-methods:

NewClass:

@Override
public boolean equals(Object obj) {
    return false;
}

public boolean equals(NewClass obj) {
    return value == obj.getValue();
}

NewClass1:

@Override
public boolean equals(Object obj) {
    if(!(obj instanceof NewClass1)) {
        return false;
    }
    return equals((NewClass1) obj);
}

public boolean equals(NewClass1 obj) {
    return value == obj.getValue();
}

What I find weird is that the equals in NewClass1 seems to be exponentially slower than the one in NewClass (for 10.000.000 calls 14ms against 3000ms). At first, I thought this was related to the "instanceof" check, but if I replace "return equals((NewClass1) obj);" with "return false;" in NewClass1, suddenly it runs more or less equally fast. I don't really understand what is happening here, because in my opinion, the return statement in equals(Object) should never actually be called. What am I getting wrong here?

The following is my "benchmarking code", in case I made some mistake there:

public static void main(String[] args) {
    // TODO code application logic here

    NewClass i1 = new NewClass(1);
    NewClass i2 = new NewClass(1);
    NewClass i3 = new NewClass(5);

    NewClass1 j1 = new NewClass1(1);
    NewClass1 j2 = new NewClass1(1);
    NewClass1 j3 = new NewClass1(5);

    Object o1 = new Object();
    Object o2 = new Object();

    assert(i1.equals(i1));
    assert(i1.equals(i2));
    assert(i1.equals(i3) == false);
    assert(i1.equals(o1) == false);

    assert(j1.equals(j1));
    assert(j1.equals(j2));
    assert(j1.equals(j3) == false);
    assert(j1.equals(o1) == false);

    long start = System.currentTimeMillis();

    for(int i=0; i<1000000000; i++) {
        i1.equals(i1);
        i1.equals(i2);
        i1.equals(o1);
        i1.equals(o2);
    }

    long end = System.currentTimeMillis();

    System.out.println("Execution time was "+(end-start)+" ms.");

    start = System.currentTimeMillis();

    for(int i=0; i<1000000000; i++) {
        j1.equals(j1);
        j1.equals(j2);
        j1.equals(o1);
        j1.equals(o2);
    }

    end = System.currentTimeMillis();

    System.out.println("Execution time was "+(end-start)+" ms.");
}


问:
Wix - How to install multiple windows services with one executable?
I'm trying to install multiple windows services with the same executable, but WiX doesn't like the same name attributes in the two file tags. I have tried changing the names of the two file tags. It works but I hope I don't have to install two of the same executable just for that purpose. Is there a better way to do this? Here's my code so far:

```<code><Component Id="Service1" Guid="{SOMEGUID1}">
  <File Id='Service1' Name='ConnDriver.exe' DiskId='1' Source='..\Service\obj\x86\$(var.BUILD)\ConnDriver.exe'  KeyPath='yes'/>
    <ServiceInstall
      Id="ServiceInstaller1"
      Type="ownProcess"
      Name="MyService1"
      DisplayName="MyService1"
      Description="Some Description"
      Start="auto"
      Account="[SERVICEACCOUNT]"
      Password="[SERVICEPASSWORD]"
      ErrorControl="normal"
      Arguments=' "Service1"'
      Vital="yes"
      Interactive="no" />
    <ServiceControl Id="ServiceControl1" Stop="uninstall" Remove="uninstall" Name="MyService1" Wait="yes" />
</Component>

<Component Id="Service2" Guid="{SOMEGUID2}">
  <File Id='Service2' Name='ConnDriver.exe' DiskId='1' Source='..\Service\obj\x86\$(var.BUILD)\ConnDriver.exe'  KeyPath='yes'/>
    <ServiceInstall
      Id="ServiceInstaller2"
      Type="ownProcess"
      Name="MyService2"
      DisplayName="MyService2"
      Description="Some Description"
      Start="auto"
      Account="[SERVICEACCOUNT]"
      Password="[SERVICEPASSWORD]"
      ErrorControl="normal"
      Arguments=' "Service2"'
      Vital="yes"
      Interactive="no" />
    <ServiceControl Id="ServiceControl2" Stop="uninstall" Remove="uninstall" Name="MyService2" Wait="yes" />
</Component>
</code>```

In features:

```<code><Feature Id="Feature1" Title="Feature 2" Level="1" Description="...">
  <ComponentRef Id="Service1_xml"/>
  <ComponentRef Id="Service1"/>
</Feature>
<Feature Id="Feature2" Title="Feature 2" Level="1" Description="...">
  <ComponentRef Id="Service2_xml"/>
  <ComponentRef Id="Service2"/>
</Feature>
</code>```

Any help is appreciated.

(PS. The reason I brake them up into 2 components is so that I can include an xml config file with the service in the features section. My windows service installer takes in a command line argument to know which xml file to read from and configure accordingly)

EDIT:

Error Output:

ICE30: The target file 'hlo8twix.exe|ConnDriver.exe' is installed in '[ProgramFilesFolder]\CompanyName\ProgramName\' by two different components on an LFN system: 'Service1' and 'Service2'. This breaks component reference counting.

答:
```<code><?xml version="1.0" encoding="UTF-8"?>
<!-- The name of the product -->
<?define Service1Name = "Test Service1" ?>
<?define Service2Name = "Test Service2" ?>
<!-- The description of the product -->
<?define Service1Description = "Test Service1 that logs dummy text on an interval to a text file." ?>
<?define Service2Description = "Test Service2 that logs dummy text on an interval to a text file." ?>
<!-- The manufacturer, for setup package publisher and folder info -->
<?define Manufacturer = "Your Company" ?>
<!-- The version number of this setup package-->
<?define Version = "1.0.1" ?>
<!-- UpgradeCode must be unique and not changed once the first version of the program is installed. -->
<?define UpgradeCode = "{1240E0CD-B3D2-44A7-B064-11B3C0709D69}" ?>

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Product Id="*" Name="$(var.Service1Name)" Manufacturer="$(var.Manufacturer)" UpgradeCode="$(var.UpgradeCode)" Version="$(var.Version)" Language="1033">
    <!-- Create a folder inside Your Company called Test Service -->
    <Package InstallerVersion="300" Compressed="yes"/>
    <!-- Create a folder inside Your Company called Test Service -->
    <Media Id="1" Cabinet="TestService.cab" EmbedCab="yes" />
    <!-- Allow upgrades and prevent downgrades -->
    <MajorUpgrade DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit." />
    <!-- Define the directory structure -->
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <!-- Create a folder inside program files called Your Company -->
        <Directory Id="ROOTDIRECTORY" Name="$(var.Manufacturer)">
          <!-- Create a folder inside Your Company called Test Service -->
          <Directory Id="INSTALLFOLDER" Name="$(var.Service1Name)" />
        </Directory>
      </Directory>
    </Directory>
    <!-- The files inside this DirectoryRef are linked to the Test Service directory via INSTALLFOLDER -->
    <DirectoryRef Id="INSTALLFOLDER">
      <!-- Create a single component which is the TestService.exe file -->
      <Component Id="$(var.TestService1.TargetFileName)">
        <!-- Copies the TestService.exe file using the project reference preprocessor variables -->
        <File Id="$(var.TestService1.TargetFileName)" Source="$(var.TestService1.TargetPath)" KeyPath="yes" />
        <!-- Remove all files from the INSTALLFOLDER on uninstall -->
        <RemoveFile Id="RemoveService1" Name="*.*" On="both" />
        <!-- Tell WiX to install the Service -->
        <ServiceInstall Id="Service1Installer"
        Type="ownProcess"
        Name="TestService1"
        DisplayName="$(var.Service1Name)"
        Description="$(var.Service1Description)"
        Start="auto"
        ErrorControl="normal" />
        <!-- Tell WiX to start the Service -->
        <ServiceControl Id="StartService1" Start="install" Stop="both" Remove="uninstall" Name="TestService1" Wait="yes" />
      </Component>
      <!-- Create a single component which is the TestService.exe file -->
      <Component Id="$(var.TestService2.TargetFileName)">
        <!-- Copies the TestService.exe file using the project reference preprocessor variables -->
        <File Id="$(var.TestService2.TargetFileName)" Source="$(var.TestService2.TargetPath)" KeyPath="yes" />
        <!-- Remove all files from the INSTALLFOLDER on uninstall -->
        <RemoveFile Id="RemoveService2" Name="*.*" On="both" />
        <!-- Tell WiX to install the Service -->
        <ServiceInstall Id="Service2Installer"
        Type="ownProcess"
        Name="TestService2"
        DisplayName="$(var.Service2Name)"
        Description="$(var.Service2Description)"
        Start="auto"
        ErrorControl="normal" />
        <!-- Tell WiX to start the Service -->
        <ServiceControl Id="StartService2" Start="install" Stop="both" Remove="uninstall" Name="TestService2" Wait="yes" />
      </Component>
    </DirectoryRef>
    <!-- Tell WiX to install the files -->
    <Feature Id="Feature1" Title="TestService1.Setup" Level="1">
      <ComponentRef Id="$(var.TestService1.TargetFileName)" />
    </Feature>
    <Feature Id="Feature2" Title="TestService2.Setup" Level="1">
      <ComponentRef Id="$(var.TestService2.TargetFileName)" />
    </Feature>
  </Product>
</Wix>
</code>```

Body:
I'm trying to install multiple windows services with the same executable, but WiX doesn't like the same name attributes in the two file tags. I have tried changing the names of the two file tags. It works but I hope I don't have to install two of the same executable just for that purpose. Is there a better way to do this? Here's my code so far:

<Component Id="Service1" Guid="{SOMEGUID1}">
  <File Id='Service1' Name='ConnDriver.exe' DiskId='1' Source='..\Service\obj\x86\$(var.BUILD)\ConnDriver.exe'  KeyPath='yes'/>
    <ServiceInstall
      Id="ServiceInstaller1"
      Type="ownProcess"
      Name="MyService1"
      DisplayName="MyService1"
      Description="Some Description"
      Start="auto"
      Account="[SERVICEACCOUNT]"
      Password="[SERVICEPASSWORD]"
      ErrorControl="normal"
      Arguments=' "Service1"'
      Vital="yes"
      Interactive="no" />
    <ServiceControl Id="ServiceControl1" Stop="uninstall" Remove="uninstall" Name="MyService1" Wait="yes" />
</Component>

<Component Id="Service2" Guid="{SOMEGUID2}">
  <File Id='Service2' Name='ConnDriver.exe' DiskId='1' Source='..\Service\obj\x86\$(var.BUILD)\ConnDriver.exe'  KeyPath='yes'/>
    <ServiceInstall
      Id="ServiceInstaller2"
      Type="ownProcess"
      Name="MyService2"
      DisplayName="MyService2"
      Description="Some Description"
      Start="auto"
      Account="[SERVICEACCOUNT]"
      Password="[SERVICEPASSWORD]"
      ErrorControl="normal"
      Arguments=' "Service2"'
      Vital="yes"
      Interactive="no" />
    <ServiceControl Id="ServiceControl2" Stop="uninstall" Remove="uninstall" Name="MyService2" Wait="yes" />
</Component>

In features:

<Feature Id="Feature1" Title="Feature 2" Level="1" Description="...">
  <ComponentRef Id="Service1_xml"/>
  <ComponentRef Id="Service1"/>
</Feature>
<Feature Id="Feature2" Title="Feature 2" Level="1" Description="...">
  <ComponentRef Id="Service2_xml"/>
  <ComponentRef Id="Service2"/>
</Feature>

Any help is appreciated.

(PS. The reason I brake them up into 2 components is so that I can include an xml config file with the service in the features section. My windows service installer takes in a command line argument to know which xml file to read from and configure accordingly)

EDIT:

Error Output:

ICE30: The target file 'hlo8twix.exe|ConnDriver.exe' is installed in '[ProgramFilesFolder]\CompanyName\ProgramName\' by two different components on an LFN system: 'Service1' and 'Service2'. This breaks component reference counting.


问:
MS Access: Saving data after displaying on a form
I have the following 3 tables:

Retailer:

RetailerID

RetailerName

Taxable(YES or NO)

Product:

Stake

AmountWithTax

AmountWithoutTax

Refund:

RetailerID (lookup values from Retailer as a dropdown list)

ProductName (lookup values from Product as a dropdown list)

I have a query, called RefundQuery, that takes from these 3 tables:

Refund - RetailerID, ProductName

Retailer - RetailerName, Taxable

Product - Stake, AmountWithTax, AmountWithoutTax

A form is then created based on RefundQuery. The idea is to have a user select the RetailerID from a dropdown list, which populates the fields RetailerName and Taxable automatically. The user will then select a ProductName from a dropdown list and key in a value for Stake, which then auto-populates the values for both AmountWithTax and AmountWithoutTax. However, I do not how to display just one of the values, depending on whether the Retailer is Taxable or not.

I have tried to create an additional Textbox in the form and added

=IIf([Taxable]="YES",[AmountWithTax],[AmountWithoutTax])

into the control source. While this displays the corresponding value, it does not save into my records. Is there any way to do this?

答:
Is Taxable a Yes/No (Boolean) type field? If it is then don't need the ="Yes", just:

=IIf([Taxable], [AmountWithTax], [AmountWithoutTax])

However, since you say your expression is working I guess it is a text type field.

Saving is not necessary unless these values are subject to change over time. If you must save then that requires code in some event. You also need a field in appropriate table (maybe Refund) to save into.

Me!Amount = Me.textboxname

The real trick is figuring out what event. Perhaps the AfterUpdate event of Stake textbox.

Stake combobox is where you select product name?


问:
Apache Spark how to append new column from list/array to Spark dataframe
I am using Apache Spark 2.0 Dataframe/Dataset API
I want to add a new column to my dataframe from List of values. My list has same number of values like given dataframe.

```<code>val list = List(4,5,10,7,2)
val df   = List("a","b","c","d","e").toDF("row1")
</code>```

I would like to do something like:

```<code>val appendedDF = df.withColumn("row2",somefunc(list))
df.show()
// +----+------+
// |row1 |row2 |
// +----+------+
// |a    |4    |
// |b    |5    |
// |c    |10   |
// |d    |7    |
// |e    |2    |
// +----+------+
</code>```

For any ideas I would be greatful, my dataframe in reality contains more columns.

答:
You could do it like this:</p>

```<code>import org.apache.spark.sql.Row
import org.apache.spark.sql.types._

// create rdd from the list
val rdd = sc.parallelize(List(4,5,10,7,2))
// rdd: org.apache.spark.rdd.RDD[Int] = ParallelCollectionRDD[31] at parallelize at <console>:28

// zip the data frame with rdd
val rdd_new = df.rdd.zip(rdd).map(r => Row.fromSeq(r._1.toSeq ++ Seq(r._2)))
// rdd_new: org.apache.spark.rdd.RDD[org.apache.spark.sql.Row] = MapPartitionsRDD[33] at map at <console>:32

// create a new data frame from the rdd_new with modified schema
spark.createDataFrame(rdd_new, df.schema.add("new_col", IntegerType)).show
+----+-------+
|row1|new_col|
+----+-------+
|   a|      4|
|   b|      5|
|   c|     10|
|   d|      7|
|   e|      2|
+----+-------+
</code>```

Body:
I am using Apache Spark 2.0 Dataframe/Dataset API
I want to add a new column to my dataframe from List of values. My list has same number of values like given dataframe.

val list = List(4,5,10,7,2)
val df   = List("a","b","c","d","e").toDF("row1")

I would like to do something like:

val appendedDF = df.withColumn("row2",somefunc(list))
df.show()
// +----+------+
// |row1 |row2 |
// +----+------+
// |a    |4    |
// |b    |5    |
// |c    |10   |
// |d    |7    |
// |e    |2    |
// +----+------+

For any ideas I would be greatful, my dataframe in reality contains more columns.

Body:
You could do it like this:

import org.apache.spark.sql.Row
import org.apache.spark.sql.types._

// create rdd from the list
val rdd = sc.parallelize(List(4,5,10,7,2))
// rdd: org.apache.spark.rdd.RDD[Int] = ParallelCollectionRDD[31] at parallelize at <console>:28

// zip the data frame with rdd
val rdd_new = df.rdd.zip(rdd).map(r => Row.fromSeq(r._1.toSeq ++ Seq(r._2)))
// rdd_new: org.apache.spark.rdd.RDD[org.apache.spark.sql.Row] = MapPartitionsRDD[33] at map at <console>:32

// create a new data frame from the rdd_new with modified schema
spark.createDataFrame(rdd_new, df.schema.add("new_col", IntegerType)).show
+----+-------+
|row1|new_col|
+----+-------+
|   a|      4|
|   b|      5|
|   c|     10|
|   d|      7|
|   e|      2|
+----+-------+


问:
JIRA Apache setup - error
I am tryin to setup reverse proxy on my JIRA instance using the following documentation from atlassian.

After all the settigs are established, I start the server application and get the following error in the Client Browser.

We've detected a potential problem with JIRA's Dashboard configuration that your administrator can correct. Hide
  Dashboard Diagnostics: Mismatched URL Port
  JIRA is reporting that it is running on the port '80', which does not match the hostname used to run these diagnostics, '8080'. This is known to cause JIRA to construct URLs using the incorrect port, which will result in errors in the dashboard, among other issues.
  The most common cause of this is the use of a reverse-proxy HTTP server (often Apache or IIS) in front of the application server running JIRA. While this configuration is supported, some additional setup might be necessary in order to ensure that JIRA detects the correct port.
  The following articles describe the issue and the steps you should take to ensure that your web server and app server are configured correctly:
  Gadgets do not display correctly after upgrade to JIRA 4.0
  Integrating JIRA with Apache
  Integrating JIRA with Apache using SSL
  If you believe this diagnosis is in error, or you have any other questions, please contact Atlassian Support.
  Detailed Error
  Hide
          com.atlassian.gadgets.dashboard.internal.diagnostics.UrlPortMismatchException: Detected URL port, '80', does not match expected port, '8080'
      at com.atlassian.gadgets.dashboard.internal.diagnostics.Diagnostics.checkExpectedPort(Diagnostics.java:87)
      at com.atlassian.gadgets.dashboard.internal.diagnostics.Diagnostics.check(Diagnostics.java:38)
      at com.atlassian.gadgets.dashboard.internal.diagnostics.DiagnosticsServlet.executeDiagnostics(DiagnosticsServlet.java:97)
      at com.atlassian.gadgets.dashboard.internal.diagnostics.DiagnosticsServlet.doPost(DiagnosticsServlet.java:65)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:644)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
      at com.atlassian.plugin.servlet.DelegatingPluginServlet.service(DelegatingPluginServlet.java:42)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
      at com.atlassian.plugin.servlet.ServletModuleContainerServlet.service(ServletModuleContainerServlet.java:52)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at com.atlassian.jira.web.filters.steps.ChainedFilterStepRunner.doFilter(ChainedFilterStepRunner.java:74)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at com.atlassian.jira.web.filters.XContentTypeOptionsNoSniffFilter.doFilter(XContentTypeOptionsNoSniffFilter.java:20)
      at com.atlassian.core.filters.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:32)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at com.atlassian.core.filters.HeaderSanitisingFilter.doFilter(HeaderSanitisingFilter.java:37)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:46)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:70)
      at com.atlassian.jira.tzdetect.IncludeResourcesFilter.doFilter(IncludeResourcesFilter.java:85)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:78)
      at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:70)
      at com.atlassian.jira.baseurl.IncludeResourcesFilter.doFilter(IncludeResourcesFilter.java:38)
      at com.atlassian.core.filters.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:32)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:78)
      at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:70)
      at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:26)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:78)
      at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:70)
      at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:26)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:78)
      at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:70)
      at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:26)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:78)
      at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:70)
      at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:26)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:78)
      at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:70)
      at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:26)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:78)
      at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:70)
      at com.atlassian.servicedesk.internal.web.RedirectExternalCustomerToPortalFilter.doFilter(RedirectExternalCustomerToPortalFilter.scala:18)
      at com.atlassian.core.filters.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:32)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:78)
      at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:70)
      at com.atlassian.mywork.client.filter.ServingRequestsFilter.doFilter(ServingRequestsFilter.java:37)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:78)
      at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:70)
      at com.atlassian.prettyurls.filter.PrettyUrlsSiteMeshFixupFilter.doFilter(PrettyUrlsSiteMeshFixupFilter.java:36)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:78)
      at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:70)
      at com.atlassian.prettyurls.filter.PrettyUrlsDispatcherFilter.doFilter(PrettyUrlsDispatcherFilter.java:60)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:78)
      at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:70)
      at com.atlassian.prettyurls.filter.PrettyUrlsSiteMeshFilter.doFilter(PrettyUrlsSiteMeshFilter.java:92)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:78)
      at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:70)
      at com.atlassian.prettyurls.filter.PrettyUrlsMatcherFilter.doFilter(PrettyUrlsMatcherFilter.java:56)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:78)
      at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:70)
      at com.atlassian.labs.botkiller.BotKillerFilter.doFilter(BotKillerFilter.java:36)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:78)
      at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)
      at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:77)
      at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:63)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at com.atlassian.jira.web.filters.accesslog.AccessLogFilter.executeRequest(AccessLogFilter.java:92)
      at com.atlassian.jira.web.filters.accesslog.AccessLogFilter.doFilter(AccessLogFilter.java:78)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at com.atlassian.jira.security.xsrf.XsrfTokenAdditionRequestFilter.doFilter(XsrfTokenAdditionRequestFilter.java:47)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:181)
      at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:85)
      at com.atlassian.jira.web.filters.SitemeshPageFilter.doFilter(SitemeshPageFilter.java:112)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at com.atlassian.jira.web.filters.pagebuilder.PageBuilderFilter.doFilter(PageBuilderFilter.java:79)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at com.atlassian.jira.web.filters.CommittedResponseHtmlErrorRecoveryFilter.doFilter(CommittedResponseHtmlErrorRecoveryFilter.java:55)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:46)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:70)
      at com.atlassian.prettyurls.filter.PrettyUrlsCombinedMatchDispatcherFilter.doFilter(PrettyUrlsCombinedMatchDispatcherFilter.java:61)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:78)
      at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)
      at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:77)
      at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:63)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at com.atlassian.jira.web.filters.MauEventFilter.doFilter(MauEventFilter.java:32)
      at com.atlassian.core.filters.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:32)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at com.atlassian.seraph.filter.SecurityFilter.doFilter(SecurityFilter.java:242)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at com.atlassian.security.auth.trustedapps.filter.TrustedApplicationsFilter.doFilter(TrustedApplicationsFilter.java:103)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at com.atlassian.seraph.filter.BaseLoginFilter.doFilter(BaseLoginFilter.java:148)
      at com.atlassian.jira.web.filters.JiraLoginFilter.doFilter(JiraLoginFilter.java:66)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:46)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:70)
      at com.atlassian.oauth.serviceprovider.internal.servlet.OAuthFilter.doFilter(OAuthFilter.java:79)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:78)
      at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:70)
      at com.atlassian.prettyurls.filter.PrettyUrlsCombinedMatchDispatcherFilter.doFilter(PrettyUrlsCombinedMatchDispatcherFilter.java:61)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:78)
      at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)
      at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:77)
      at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:63)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at com.atlassian.util.profiling.filters.ProfilingFilter.doFilter(ProfilingFilter.java:99)
      at com.atlassian.jira.web.filters.JIRAProfilingFilter.doFilter(JIRAProfilingFilter.java:16)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at com.atlassian.johnson.filters.AbstractJohnsonFilter.doFilter(AbstractJohnsonFilter.java:59)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)
      at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
      at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
      at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:394)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:46)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:70)
      at com.atlassian.prettyurls.filter.PrettyUrlsCombinedMatchDispatcherFilter.doFilter(PrettyUrlsCombinedMatchDispatcherFilter.java:61)
      at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:78)
      at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)
      at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:77)
      at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:63)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at com.atlassian.jira.web.filters.steps.ChainedFilterStepRunner.doFilter(ChainedFilterStepRunner.java:74)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at com.atlassian.core.filters.cache.AbstractCachingFilter.doFilter(AbstractCachingFilter.java:31)
      at com.atlassian.core.filters.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:32)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at com.atlassian.core.filters.encoding.AbstractEncodingFilter.doFilter(AbstractEncodingFilter.java:39)
      at com.atlassian.core.filters.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:32)
      at com.atlassian.jira.web.filters.PathMatchingEncodingFilter.doFilter(PathMatchingEncodingFilter.java:41)
      at com.atlassian.core.filters.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:32)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at com.atlassian.jira.startup.JiraStartupChecklistFilter.doFilter(JiraStartupChecklistFilter.java:65)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at com.atlassian.jira.web.filters.MultipartBoundaryCheckFilter.doFilter(MultipartBoundaryCheckFilter.java:36)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at com.atlassian.jira.web.filters.steps.ChainedFilterStepRunner.doFilter(ChainedFilterStepRunner.java:74)
      at com.atlassian.jira.web.filters.JiraFirstFilter.doFilter(JiraFirstFilter.java:57)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at com.atlassian.gzipfilter.GzipFilter.doFilterInternal(GzipFilter.java:115)
      at com.atlassian.gzipfilter.GzipFilter.doFilter(GzipFilter.java:92)
      at com.atlassian.jira.web.filters.gzip.JiraGzipFilter.doFilter(JiraGzipFilter.java:52)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
      at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:516)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1086)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:659)
      at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223)
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1558)
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1515)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      at java.lang.Thread.run(Thread.java:745)

What am I doing wrong in here? Please help, I have been stuck at this for a while.
Thanks!!

答:
You can fix this issue by setting correct port in server.xml file.
For more details please refer to this question.

Title: JIRA Apache setup - error


问:
Can anyone explain the difference between expression, ng-bind and ng-model?
I am very confuse between expression {{}}, ng-bind and ng-model. please explain with example if possible.</p>

答:
{{ data }} will be replaced by the value of data variable in the related scope. It updates automatically as data inside scope changes. So, we say,

{{ data }} is binded to the variable data. However, if data is html, angularjs will automatically escape the markup for security reasons.

ng-bind binds the 'content' of element. Like, in case of

 the div will be filled with value of data variable. In this case markup present in data will be rendered too.(using ng-bind-html)

ng-model simply binds the value of html element to some variable in the scope. Like: in case of <input ng-model="data" /> variable data inside scope will have the value of input.

Hope that helps !

Body:
{{ data }} will be replaced by the value of data variable in the related scope. It updates automatically as data inside scope changes. So, we say,

{{ data }} is binded to the variable data. However, if data is html, angularjs will automatically escape the markup for security reasons.

ng-bind binds the 'content' of element. Like, in case of <div ng-bind="data" ></div> the div will be filled with value of data variable. In this case markup present in data will be rendered too.(using ng-bind-html)

ng-model simply binds the value of html element to some variable in the scope. Like: in case of <input ng-model="data" /> variable data inside scope will have the value of input.

Hope that helps !


问:
Transform CSS { ul li:hover a } in JQUERY .hover
I want to now if there's a way to transform this css properties in a jquery .hover, or control this by javascript to change the colour dynamically.

CSS:

```<code>ul li:hover a {
    color: #FFF;
}
</code>```

Can anyone Help ?

EDIT:

My problem is:

I have a drop down menu and i want that when I hover the menu the text color change and when I hover the submenu the hover state stays for both.

JQuery:

```<code>$("ul li").hover(function () {
    $(this).stop().animate({ backgroundColor: "white"}, 500);
}, function () {
    $(this).stop().animate({ backgroundColor: "black"}, 400);
});
</code>```

To animate background color on hover in menu and submenu.

For example if the text are black I want to make the text white on hover. For this I use:(Submenu example, for menu change the selector of course)

```<code>$('ul.submenu li a').hover(function () {
    $(this).css({color:'#FFFFFF'});
}, function () {
    $(this).css({color:'#00FF00'});
});
</code>```

All This works fine, but when I hover the submenu the menu returns to the original state(because the mouseleave is activated on hover out). All I want is that when I hover submenu the hover state in menu stays active as well.

I've tried many things but all give me problems, only thing that works is css, but I need to control the text colours dynamically too.

HTML Structure:

```<code><ul class="menu">

      <li><a href="#">text</a></li>

      <li><a href="#">text</a>

        <ul class="submenu">
          <li><a href="#">text</a></li>
          <li><a href="#">text</a></li>
          <li><a href="#">text</a></li>
        </ul>

      </li>

      <li><a href="#">text</a></li>

</ul>
</code>```

答:
```<code>$("ul li a").hover(function() {
    $(this)
        .data("color", $(this).css("color"))
        .css("color", "#FFF");
}, function() {
    $(this).css("color", $(this).data("color"));
});

$("ul li").hover(function() {
    $(this).find("a")
        .data("color", $(this).css("color"))
        .css("color", "#FFF");
}, function() {
    $(this).find("a").css("color", $(this).data("color"));
});
</code>```

Update:

Assuming that the first selector (ul li a:hover) is superfluous, we can simplify the code considerably:

```<code>$("li").hover(function() {
    $(this).find("a").css("color", "#FFF");
}, function() {
    $(this).find("a").removeAttr("style");
});
</code>```

This updated code should work also (under the condition that you don't have additional CSS code inside the style attribute of the ANCHOR elements).

Update:

An alternative solution would be this:

```<code>$("li").hover(function() {
    $(this).toggleClass("hover", $(this).is(":hover"));
});
</code>```

with this CSS code:

```<code>ul li.hover a {
    color: #FFF;
}
</code>```

I highly recommend this alternative solution!

Body:
I want to now if there's a way to transform this css properties in a jquery .hover, or control this by javascript to change the colour dynamically.

CSS:

ul li:hover a {
    color: #FFF;
}

Can anyone Help ?

EDIT:

My problem is:

I have a drop down menu and i want that when I hover the menu the text color change and when I hover the submenu the hover state stays for both.

JQuery:

$("ul li").hover(function () {
    $(this).stop().animate({ backgroundColor: "white"}, 500);
}, function () {
    $(this).stop().animate({ backgroundColor: "black"}, 400);
});

To animate background color on hover in menu and submenu.

For example if the text are black I want to make the text white on hover. For this I use:(Submenu example, for menu change the selector of course)

$('ul.submenu li a').hover(function () {
    $(this).css({color:'#FFFFFF'});
}, function () {
    $(this).css({color:'#00FF00'});
});

All This works fine, but when I hover the submenu the menu returns to the original state(because the mouseleave is activated on hover out). All I want is that when I hover submenu the hover state in menu stays active as well.

I've tried many things but all give me problems, only thing that works is css, but I need to control the text colours dynamically too.

HTML Structure:

text

text

text

text

text

text

Body:
$("ul li a").hover(function() {
    $(this)
        .data("color", $(this).css("color"))
        .css("color", "#FFF");
}, function() {
    $(this).css("color", $(this).data("color"));
});

$("ul li").hover(function() {
    $(this).find("a")
        .data("color", $(this).css("color"))
        .css("color", "#FFF");
}, function() {
    $(this).find("a").css("color", $(this).data("color"));
});

Update:

Assuming that the first selector (ul li a:hover) is superfluous, we can simplify the code considerably:

$("li").hover(function() {
    $(this).find("a").css("color", "#FFF");
}, function() {
    $(this).find("a").removeAttr("style");
});

This updated code should work also (under the condition that you don't have additional CSS code inside the style attribute of the ANCHOR elements).

Update:

An alternative solution would be this:

$("li").hover(function() {
    $(this).toggleClass("hover", $(this).is(":hover"));
});

with this CSS code:

ul li.hover a {
    color: #FFF;
}

I highly recommend this alternative solution!


问:
n steps with 1, 2 or 3 steps taken. How many ways to get to the top?
If we have n steps and we can go up 1 or 2 steps at a time, there is a Fibonacci relation between the number of steps and the ways to climb them. IF and ONLY if we do not count 2+1 and 1+2 as different.

However, this no longer the case, as well as having to add we add a third option, taking 3 steps. How do I do this?

What I have:

```<code>1 step = 1 way
2 steps = 2 ways: 1+1, 2
3 steps = 4 ways: 1+1+1, 2+1, 1+2, 3
</code>```

I have no idea where to go from here to find out the number of ways for n stairs

I get 7 for n = 4 and 14 for n= 5 i get 14+7+4+2+1 by doing the sum of all the combinations before it. so ways for n steps = n-1 ways + n-2 ways + .... 1 ways  assuming i kept all the values.  DYNAMIC programming.
1 2 and 3 steps would be the base-case is that correct?

答:
Count ways to reach the nth stair using step 1, 2, 3.

We can count using simple Recursive Methods.

```<code>// Header File
#include<stdio.h>
// Function prototype for recursive Approch
int findStep(int);
int main(){
    int n;
    int ways=0;
    ways = findStep(4);
    printf("%d\n", ways);
return 0;
}
// Function Definition
int findStep(int n){
    int t1, t2, t3;
    if(n==1 || n==0){
        return 1;
    }else if(n==2){
        return 2;
    }
    else{
        t3 = findStep(n-3);
        t2 = findStep(n-2);
        t1 = findStep(n-1);
        return t1+t2+t3;
    }
}
</code>```

Body:
If we have n steps and we can go up 1 or 2 steps at a time, there is a Fibonacci relation between the number of steps and the ways to climb them. IF and ONLY if we do not count 2+1 and 1+2 as different.

However, this no longer the case, as well as having to add we add a third option, taking 3 steps. How do I do this?

What I have:

1 step = 1 way
2 steps = 2 ways: 1+1, 2
3 steps = 4 ways: 1+1+1, 2+1, 1+2, 3

I have no idea where to go from here to find out the number of ways for n stairs

I get 7 for n = 4 and 14 for n= 5 i get 14+7+4+2+1 by doing the sum of all the combinations before it. so ways for n steps = n-1 ways + n-2 ways + .... 1 ways  assuming i kept all the values.  DYNAMIC programming.
1 2 and 3 steps would be the base-case is that correct?

Body:
Count ways to reach the nth stair using step 1, 2, 3.

We can count using simple Recursive Methods.

// Header File
#include<stdio.h>
// Function prototype for recursive Approch
int findStep(int);
int main(){
    int n;
    int ways=0;
    ways = findStep(4);
    printf("%d\n", ways);
return 0;
}
// Function Definition
int findStep(int n){
    int t1, t2, t3;
    if(n==1 || n==0){
        return 1;
    }else if(n==2){
        return 2;
    }
    else{
        t3 = findStep(n-3);
        t2 = findStep(n-2);
        t1 = findStep(n-1);
        return t1+t2+t3;
    }
}


问:
Swift 3.1 error: cannot invoke 'stride' with an argument list of type

When I try the following code:

```<code>extension Int{

   func hello(to end: Int, by step: Int, task: (Int) -> Void ){

        for i in stride(from: 4, to: 8, by: 2) {

            task(i)
         }
     }
}
</code>```

And I get the error saying:

error: cannot invoke 'stride' with an argument list of type '(from: Int, to: Int, by: Int)' for i in stride(from: 4, to: 8, by: 2)

note: overloads for 'stride' exist with these partially matching parameter lists: (to: Self, by: Self.Stride), (through: Self, by: Self.Stride)
          for i in stride(from: 4, to: 8, by: 2)

I don't why this type of error happens

答:
This is kind of tricky! :)

Int apparently declares its own stride methods (that's why the compiler shows you that partially matching overloads exist), but somehow I can't access them (compiler says that they are marked unavailable). Since you are in an Int extension, calling stride in this context is equivalent to self.stride. And the stride methods that Int has does not have the arguments from:to:by:, so it does not compile.

You want to specifically refer to the stride method that's global. Just specify the module in which the method is defined, i.e. Swift:

```<code>extension Int{

   func hello(to end: Int, by step: Int, task: (Int) -> Void ){

        for i in Swift.stride(from: 4, to: 8, by: 2) {

            task(i)
         }
     }
}
</code>```

Body:
When I try the following code:

extension Int{

   func hello(to end: Int, by step: Int, task: (Int) -> Void ){

        for i in stride(from: 4, to: 8, by: 2) {

            task(i)
         }
     }
}

And I get the error saying:

error: cannot invoke 'stride' with an argument list of type '(from: Int, to: Int, by: Int)' for i in stride(from: 4, to: 8, by: 2)

note: overloads for 'stride' exist with these partially matching parameter lists: (to: Self, by: Self.Stride), (through: Self, by: Self.Stride)
          for i in stride(from: 4, to: 8, by: 2)

I don't why this type of error happens

Body:
This is kind of tricky! :)

Int apparently declares its own stride methods (that's why the compiler shows you that partially matching overloads exist), but somehow I can't access them (compiler says that they are marked unavailable). Since you are in an Int extension, calling stride in this context is equivalent to self.stride. And the stride methods that Int has does not have the arguments from:to:by:, so it does not compile.

You want to specifically refer to the stride method that's global. Just specify the module in which the method is defined, i.e. Swift:

extension Int{

   func hello(to end: Int, by step: Int, task: (Int) -> Void ){

        for i in Swift.stride(from: 4, to: 8, by: 2) {

            task(i)
         }
     }
}


问:
How to set OneNote API´s permissions
I Need to use OneNote API in order to get pages by searching specific words in their content with search attribute.

I have made a successful connection to Microsoft Graph, but it doesn´t have support to search words in pages´s content.

In order to get the access token I am using https://login.microsoftonline.com as endpoint url.

As I said I already did a successful connection to Microsoft Graph with the following request : https://login.microsoftonline.com/common/oauth2/v2.0/authorize?scope=Notes.ReadWrite.All+openid+email+profile+offline_access&client_id=4e3c319

with that I got the accesstoken and I was able to get pages using https://graph.microsoft.com/v1.0/me/onenote/pages, but I need to get pages by searching words in their content, so I am trying with onenote api that has search attribute.

If I try with https://www.onenote.com/api/v1.0/me/notes/pages I get Unauthorized error.

I have added onenote api´s scopes : office.onenote_update, office.onenote, etchttps://login.microsoftonline.com/common/oauth2/v2.0/authorize?scope=office.onenote_update+openid+email+profile

But : I got this issue

How can I set the correct scopes for onenote api but using https://login.microsoftonline.com as I did with Microsoft Graph because I need to use that oauth endpoint

答:
I addition to Jorge's answer above, get pages by searching words in their content is not supported for O365 Users.

In summary - (Get Pages with certain text in the content)

O365 account - Not supported, you will receive 503.

Microsoft account - Supported.

Title: How to set OneNote API´s permissions


问:
Does MtouchSdkVersion setting affect what version of iOS we can run on?
When deploying an existing Xamarin forms proj from Visual Studio I was getting errors like "Failed to load AOT module ‘System.Net.Http’ while running in aot-only mode".  This had worked in the past, it seemed Xcode had recently updated before I hit the problem.  I found I was able to get the project deploying by changing the csproj entry 10.0 to 10.3.  It looks like I could change this setting and everyone would be ok if they also had updated xcode.

My concern is:  Does this change what versions of iOS the application can support?  Would it have any other surprises when deployed to the apple store?

One thing I don't understand is I am the only person seeing this issue.  Another developer is able to deploy to an iOS device (iPad instead of an iPhone) that also has the latest version of iOS without problems.  Running “xcodebuild -version” shows we have the same version of xcode installed (8.3.1) and running “xcodebuild -showsdks” shows we have the same iOS sdk available (iOS 10.3).

答:
There is some good documentation on the iOS SDK version: https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/cross_development/Overview/overview.html#//apple_ref/doc/uid/20002001-BABEBGCF

You can build against a higher version of the SDK and run against lower versions of iOS.

Building against different versions of the iOS SDK can cause differences in behavior, these may show as regressions in your application.


问:
Unable to scroll image using scroll view in swift
I am facing this weird problem with scroll view in swift, The image does not scroll even after defining scroll view in the file, I have also added zooming and it worked fine. Please help me with this
https://pastebin.com/1uC3fqHG</p>

```<code>import UIKit

class ImageViewController: UIViewController
{
    var imageURL: URL? {
        didSet {
            image = nil
            if view.window != nil {
                fetchImage()
            }
        }
    }

    private func fetchImage() {
        if let url = imageURL {
            let urlContents = try? Data(contentsOf: url)
            if let imageData = urlContents {
                image = UIImage(data: imageData)
            }
        }
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        view.addSubview(imageView)
        imageURL = URL(string: "http://www.lamborghini.com/en-en/sites/en-en/files/DAM/lamborghini/share%20img/huracan-coupe-facebook-og.jpg")
    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        if image == nil {
            fetchImage()
        }

    }

    @IBOutlet weak var scrollView: UIScrollView! {
        didSet {

            scrollView.delegate = self
            scrollView.minimumZoomScale = 0.03
            scrollView.maximumZoomScale = 2.0
            scrollView.contentSize = imageView.frame.size
            scrollView.addSubview(imageView)
        }
    }

    fileprivate var imageView = UIImageView()

    private var image: UIImage? {
        get{
            return imageView.image
        }
        set{
            imageView.image = newValue
            imageView.sizeToFit()
            scrollView?.contentSize = imageView.frame.size
        }
    }
}

extension ImageViewController: UIScrollViewDelegate
{
    func viewForZooming(in scrollView: UIScrollView) -> UIView? {
        return imageView
    }
}
</code>```

答: You should be updating the content size and update the image view constraints Checkout this tutorial</p>

Body:
I am facing this weird problem with scroll view in swift, The image does not scroll even after defining scroll view in the file, I have also added zooming and it worked fine. Please help me with this
https://pastebin.com/1uC3fqHG

import UIKit

class ImageViewController: UIViewController
{
    var imageURL: URL? {
        didSet {
            image = nil
            if view.window != nil {
                fetchImage()
            }
        }
    }

    private func fetchImage() {
        if let url = imageURL {
            let urlContents = try? Data(contentsOf: url)
            if let imageData = urlContents {
                image = UIImage(data: imageData)
            }
        }
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        view.addSubview(imageView)
        imageURL = URL(string: "http://www.lamborghini.com/en-en/sites/en-en/files/DAM/lamborghini/share%20img/huracan-coupe-facebook-og.jpg")
    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        if image == nil {
            fetchImage()
        }

    }

    @IBOutlet weak var scrollView: UIScrollView! {
        didSet {

            scrollView.delegate = self
            scrollView.minimumZoomScale = 0.03
            scrollView.maximumZoomScale = 2.0
            scrollView.contentSize = imageView.frame.size
            scrollView.addSubview(imageView)
        }
    }

    fileprivate var imageView = UIImageView()

    private var image: UIImage? {
        get{
            return imageView.image
        }
        set{
            imageView.image = newValue
            imageView.sizeToFit()
            scrollView?.contentSize = imageView.frame.size
        }
    }
}

extension ImageViewController: UIScrollViewDelegate
{
    func viewForZooming(in scrollView: UIScrollView) -> UIView? {
        return imageView
    }
}