问:
Creating a generic function based on these three functions in a base class without adding parameters
I have multiple similar performing functions across many files in my project that all derive from a base class. Each of these files contains a function called IsAt() that returns a boolean based on whether I am on the correct page or not in my process. Below are some examples of the functions being used across these files..

Example 1.

```<code>public bool IsAt()
{
    try
    {
        DriverUtils.WaitTillElementVisible(_driver, ObjectRepository.H1);
    }
    catch (WebDriverTimeoutException)
    {
        return false;
    }
    if (ObjectRepository.PageHeaderLocator.Text != ObjectRepository.textOnPageIdentifier)
        return false;
    Console.WriteLine($"Login Page loaded successfully");
    return true;
}
</code>```

Example 2.

```<code>public bool IsAt()
{
    try
    {
        DriverUtils.WaitTillElementVisible(_driver, ObjectRepository.UseAuthCodeBy);
    }
    catch (WebDriverTimeoutException)
    {
        return false;
    }
    if (ObjectRepository.UseAuthCodeLocator.Text != ObjectRepository.textOnPageIdentifier)
        return false;
    Console.WriteLine("Select two factor provider page loaded successfully!");
    return true;
}
</code>```

Example 3.

```<code>public bool IsAt()
{
    try
    {
        DriverUtils.WaitTillElementVisible(_driver, ObjectRepository.H1);
    }
    catch (WebDriverTimeoutException)
    {
        return false;
    }
    if (ObjectRepository.PageHeaderLocator.Text != ObjectRepository.TextInPageIdentifier)
        return false;
    Console.WriteLine("Forgot password page loaded successfully");
    return true;
}
</code>```

The Structure:

Based on the functions here is the structure here's how I think it would be implemented..

```<code>public virtual bool IsAt()
{
    OpenQA.Selenium.By obj;
    var message = "My message!";

    try
    {
        DriverUtils.WaitTillElementVisible(_driver, obj);
    }
    catch (WebDriverTimeoutException)
    {
        return false;
    }

    if(obj.locator.text != obj.textOnPageIdentifier)
        return false;
    Console.WriteLine(message);
    return true;
}
</code>```

How can I implement these functions as a single generic function? Is it possible without introducing parameters to the function? eg. public bool IsAt(string message, obj myObject)

答:
Do you mean this?</p>

```<code>//example 1
public bool IsAt()
{
    return this.IsAt(ObjectRepository.H1, ObjectRepository.PageHeaderLocator.Text, $"Login Page loaded successfully");
}

//example 2
public bool IsAt()
{
    return this.IsAt(ObjectRepository.UseAuthCodeBy, ObjectRepository.UseAuthCodeLocator.Text, "Select two factor provider page loaded successfully!");
}

//example 3
public bool IsAt()
{
    return this.IsAt(ObjectRepository.H1, ObjectRepository.PageHeaderLocator.Text, "Forgot password page loaded successfully");
}

//base class
protected bool IsAt(object element, string match, string message)
{
    try
    {
        DriverUtils.WaitTillElementVisible(_driver, element);
    }
    catch (WebDriverTimeoutException)
    {
        return false;
    }

    if(match != ObjectRepository.TextInPageIdentifier)
        return false;
    Console.WriteLine(message);
    return true;
}
</code>```

Body:
I have multiple similar performing functions across many files in my project that all derive from a base class. Each of these files contains a function called IsAt() that returns a boolean based on whether I am on the correct page or not in my process. Below are some examples of the functions being used across these files..

Example 1.

public bool IsAt()
{
    try
    {
        DriverUtils.WaitTillElementVisible(_driver, ObjectRepository.H1);
    }
    catch (WebDriverTimeoutException)
    {
        return false;
    }
    if (ObjectRepository.PageHeaderLocator.Text != ObjectRepository.textOnPageIdentifier)
        return false;
    Console.WriteLine($"Login Page loaded successfully");
    return true;
}

Example 2.

public bool IsAt()
{
    try
    {
        DriverUtils.WaitTillElementVisible(_driver, ObjectRepository.UseAuthCodeBy);
    }
    catch (WebDriverTimeoutException)
    {
        return false;
    }
    if (ObjectRepository.UseAuthCodeLocator.Text != ObjectRepository.textOnPageIdentifier)
        return false;
    Console.WriteLine("Select two factor provider page loaded successfully!");
    return true;
}

Example 3.

public bool IsAt()
{
    try
    {
        DriverUtils.WaitTillElementVisible(_driver, ObjectRepository.H1);
    }
    catch (WebDriverTimeoutException)
    {
        return false;
    }
    if (ObjectRepository.PageHeaderLocator.Text != ObjectRepository.TextInPageIdentifier)
        return false;
    Console.WriteLine("Forgot password page loaded successfully");
    return true;
}

The Structure:

Based on the functions here is the structure here's how I think it would be implemented..

public virtual bool IsAt()
{
    OpenQA.Selenium.By obj;
    var message = "My message!";

    try
    {
        DriverUtils.WaitTillElementVisible(_driver, obj);
    }
    catch (WebDriverTimeoutException)
    {
        return false;
    }

    if(obj.locator.text != obj.textOnPageIdentifier)
        return false;
    Console.WriteLine(message);
    return true;
}

How can I implement these functions as a single generic function? Is it possible without introducing parameters to the function? eg. public bool IsAt(string message, obj myObject)

Body:
Do you mean this?

//example 1
public bool IsAt()
{
    return this.IsAt(ObjectRepository.H1, ObjectRepository.PageHeaderLocator.Text, $"Login Page loaded successfully");
}

//example 2
public bool IsAt()
{
    return this.IsAt(ObjectRepository.UseAuthCodeBy, ObjectRepository.UseAuthCodeLocator.Text, "Select two factor provider page loaded successfully!");
}

//example 3
public bool IsAt()
{
    return this.IsAt(ObjectRepository.H1, ObjectRepository.PageHeaderLocator.Text, "Forgot password page loaded successfully");
}

//base class
protected bool IsAt(object element, string match, string message)
{
    try
    {
        DriverUtils.WaitTillElementVisible(_driver, element);
    }
    catch (WebDriverTimeoutException)
    {
        return false;
    }

    if(match != ObjectRepository.TextInPageIdentifier)
        return false;
    Console.WriteLine(message);
    return true;
}


来源: stackexchange

问:
How to set radio button as hidden for the div
I am working on simple feedback form where I have 3 fields Name,rating(Poor, fair, good) and feedback comment.

In my form I want user to select a single rating at a time and submit the form with selected rating & feedback comments.

I have created the
 elements for each rating and make them as radio type.

I don't want to show the radio button on the form, but I want my Div to behave as radio button.

Also how to fix the border of Divs?

I am attaching the screenshots.

First one, how I want it to appear and second one is how my current code is appearing on UI.

Below is my form code & CSS

```<code><div id="modal_wrapper">
  <div id="modal_window">

    <div style="text-align: right;"><a id="modal_close" href="#">close   <b>X</b></a></div>

    <p><Strong>We'd love your feedback.</Strong><br></p>

    <p>Your feedback will help us improve your experience. To protect your privacy, please do not enter personal or account information.</p>

    <form id="modal_feedback" method="POST" action="#" accept-charset="UTF-8">
      Your Name :<br>
      <input type="text" name="name" value=""><span></span><br>
      <div class="feedbackCl" >
        <input id="overall_0" name="overall" type="radio" value="1" tabindex="0" aria-describedby="o1-l">
        <label for="overall_0" class="labelClass">— —</label>
        <span class="screen_reader" id="o1-l">Poor</span>
      </div>
      <div class="feedbackCl">
        <input id="overall_1" name="overall" type="radio" value="2" tabindex="0" aria-describedby="o2-l">
        <label for="overall_1" class="labelClass">—</label>
        <span class="screen_reader" id="o2-l">Fair</span>
      </div>
      <div class="feedbackCl">
        <input id="overall_2" name="overall" type="radio" value="3" tabindex="0" aria-describedby="o3-l">
        <label for="overall_2" class="labelClass">+ —</label>
        <span class="screen_reader" id="o3-l">Good</span>
      </div>
      <br>
      <span><br></span><br>
      <textarea style="overflow-x: hidden;" id="gBann" name="message" maxlength="1000" rows="4" cols="85" placeholder="How can we improve our site? Please share your suggestions." onKeyUp="toCount('gBann','uBann','{CHAR} characters left',1000);" >
      </textarea><br>
      <span id="uBann" class="minitext" style="text-align: right;">1000 characters left</span><br>
      <input type="submit" name="feedbackForm" value="Submit">
    </form>

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

CSS Code

```<code>.feedbackCl {
  float: left;
  box-sizing: border-box;
  padding-top: 5px;
  width: 9%;
  text-align: center;
  height: 40px;
}

input[type="radio" i] {
  -webkit-appearance: radio;
  box-sizing: border-box;
}

.labelClass{
  margin-right: 0 !important;
  height: 28px;
  background-color: #fff !important;
  color: #0511ac;
  box-sizing: border-box;
}
</code>```

答:
I think you wish to use the radio inputs, because you don't know another way to get only one form field to track on submit.

Here, I use a hidden input field to store which div (poor - fair - good) has been selected.

And divs are easy to style like you want.

;)

$(".feedbackCl").on("click",function(){
  $(".feedbackCl").removeClass("selected").css({"opacity":1});;
  $(this).addClass("selected");
  $(".feedbackCl").not(".selected").css({"opacity":0.6});

  console.log("Value stored in the hidden input of the form: "+$(this).attr("id"));
  $("#feedbackResult").val( $(this).index() );
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.feedbackCl {
  float: left;
  box-sizing: border-box;
  padding-top: 5px;
  width: 9%;
  text-align: center;
  height: 40px;
  border:1px solid grey;
  display:block;
}
.feedbackCl.selected{
  border:2px solid blue;

}

#poor{
  background-color:red;
}
#fair{
  background-color:yellow;
}
#good{
  background-color:green;
}</code>```

      close   X

We'd love your feedback.

Your feedback will help us improve your experience. To protect your privacy, please do not enter personal or account information.

    <form id="modal_feedback" method="POST" action="#" accept-charset="UTF-8">
      Your Name :

      <input type="text" name="name" value="">

        Poor

        Fair

        Good

      <input type="hidden" id="feedbackResult" name="feedbackResult">

      <textarea id="gBann" name="message" maxlength="1000" rows="4" cols="85" placeholder="How can we improve our site? Please share your suggestions." onKeyUp="toCount('gBann','uBann','{CHAR} characters left',1000);" ></textarea>

      1000 characters left

      <input type="submit" name="feedbackForm" value="Submit">
    </form>

```

ContentLicense: CC BY-SA 3.0

Body:
I am working on simple feedback form where I have 3 fields Name,rating(Poor, fair, good) and feedback comment.

In my form I want user to select a single rating at a time and submit the form with selected rating & feedback comments.

I have created the
 elements for each rating and make them as radio type.

I don't want to show the radio button on the form, but I want my Div to behave as radio button.

Also how to fix the border of Divs?

I am attaching the screenshots.

First one, how I want it to appear and second one is how my current code is appearing on UI.

Below is my form code & CSS

close   X

We'd love your feedback.

Your feedback will help us improve your experience. To protect your privacy, please do not enter personal or account information.

    <form id="modal_feedback" method="POST" action="#" accept-charset="UTF-8">
      Your Name :

      <input type="text" name="name" value="">

        <input id="overall_0" name="overall" type="radio" value="1" tabindex="0" aria-describedby="o1-l">
        — —
        Poor

        <input id="overall_1" name="overall" type="radio" value="2" tabindex="0" aria-describedby="o2-l">
        —
        Fair

        <input id="overall_2" name="overall" type="radio" value="3" tabindex="0" aria-describedby="o3-l">
        + —
        Good

      <textarea style="overflow-x: hidden;" id="gBann" name="message" maxlength="1000" rows="4" cols="85" placeholder="How can we improve our site? Please share your suggestions." onKeyUp="toCount('gBann','uBann','{CHAR} characters left',1000);" >
      </textarea>

      1000 characters left

      <input type="submit" name="feedbackForm" value="Submit">
    </form>

CSS Code

.feedbackCl {
  float: left;
  box-sizing: border-box;
  padding-top: 5px;
  width: 9%;
  text-align: center;
  height: 40px;
}

input[type="radio" i] {
  -webkit-appearance: radio;
  box-sizing: border-box;
}

.labelClass{
  margin-right: 0 !important;
  height: 28px;
  background-color: #fff !important;
  color: #0511ac;
  box-sizing: border-box;
}

Body:
I think you wish to use the radio inputs, because you don't know another way to get only one form field to track on submit.

Here, I use a hidden input field to store which div (poor - fair - good) has been selected.

And divs are easy to style like you want.

;)

$(".feedbackCl").on("click",function(){
  $(".feedbackCl").removeClass("selected").css({"opacity":1});;
  $(this).addClass("selected");
  $(".feedbackCl").not(".selected").css({"opacity":0.6});

  console.log("Value stored in the hidden input of the form: "+$(this).attr("id"));
  $("#feedbackResult").val( $(this).index() );
});

.feedbackCl {
  float: left;
  box-sizing: border-box;
  padding-top: 5px;
  width: 9%;
  text-align: center;
  height: 40px;
  border:1px solid grey;
  display:block;
}
.feedbackCl.selected{
  border:2px solid blue;

}

#poor{
  background-color:red;
}
#fair{
  background-color:yellow;
}
#good{
  background-color:green;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div id="modal_wrapper">
  <div id="modal_window">

    <div style="text-align: right;">
      <a id="modal_close" href="#">close   <b>X</b></a>
    </div>

    <p><Strong>We'd love your feedback.</Strong><br></p>

    <p>Your feedback will help us improve your experience. To protect your privacy, please do not enter personal or account information.</p>

    <form id="modal_feedback" method="POST" action="#" accept-charset="UTF-8">
      Your Name :<br>
      <input type="text" name="name" value=""><span></span><br>
      <br>
      <div class="feedbackCl" id="poor">
        Poor
      </div>
      <div class="feedbackCl" id="fair">
        Fair
      </div>
      <div class="feedbackCl" id="good">
        Good
      </div>
      <input type="hidden" id="feedbackResult" name="feedbackResult">
      <br>
      <br>
      <br>

      <textarea id="gBann" name="message" maxlength="1000" rows="4" cols="85" placeholder="How can we improve our site? Please share your suggestions." onKeyUp="toCount('gBann','uBann','{CHAR} characters left',1000);" ></textarea><br>
      <span id="uBann" class="minitext" style="text-align: right;">1000 characters left</span><br>
      <br>
      <input type="submit" name="feedbackForm" value="Submit">
    </form>
    <br>
  </div>
</div>


问:
Managing collision detection in games
So my question isn't about the how-to of collision detection, but is more of a broad 'what code should own collision detection'. I've written some game in the past(relatively simple 2D Flash games) and it got me thinking of which code should own collision detection?

Let me clarify - say in a game I have a group of enemies and a group of projectiles the player has fired. So in the past I've had say an EnemyManager class, that every frame updates the positions of the enemies and likewise for the player projectiles had a PlayerProjectilesManager class that moved around the bullets. That's cool - everything is fine and dandy. But then, I decide I want the bullets to affect the enemies(crazy I know!). So that means somewhere in the code I need to:

Figure out which bullets and enemies are colliding(I don't care how for this question)

Figure out the response to each collision

So basically what I've done in the past is just have the EnemyManager class take 'ownership' of the collisions, and during its update loop it finds the player bullets that collide with enemy bullets(i.e. Step 1) and also calls code for both objects to handle the collision (e.g. the enemy losses health, the bullet disappears) (i.e. Step 2). So I've given control of the collision detection and collision 'reaction' to the EnemyManager.

A couple comments about that:

It feels vary arbitrary to me that the EnemyManager is in 'control' instead of the PlayerProjectilesManager

Both collision detection and collision 'reaction' are handled by the same owner, this isn't a requirement from my point of view

What's forming in my mind is a 3rd party entity managing collision detection. For instance have a CollisionManager which has code that know's which other Managers need to have collisions detected. That leads to other questions like what interfaces do the 'Managers' need to expose for efficient collision detection without exposing too many innards to the CollisionManager. Then I suppose the CollisionManager what broadcast some sort of an event, containing which 2 objects collided etc... and perhaps the EnemyManager/PlayerProjectilesManager could separately listen for these events and react accordingly and separately. Starting to make sense in my mind. :)

Thoughts? Almost every game has collision detection, so I'm sure this has been discussed before. :)

答:
Questions specific to game development are best suited to https://gamedev.stackexchange.com/ by the way.

So in the past I've had say an EnemyManager class

I consider any SomethingManager class to be a sign that your code isn't organised accurately yet. For the most part, objects should manage themselves. If they can't, that implies there is some external information about them, and that information probably has a representation more specific than 'manager'. 3 game-specific examples might be GameWorld, GameRegion, or GameLevel. Enemies exist within a world, or a region of the world, or a current game level, so have such an object maintain its list of enemies.

and likewise for the player projectiles had a PlayerProjectilesManager class

Projectiles too would live in some sort of game space, a world, region, or level.

By now, you can probably guess that one of the above objects can (and probably should) be responsible for owning all the above objects (perhaps indirectly, via a container class, but not via a heavyweight manager of any sort) and responsible for detecting collisions and resolving them.

ContentLicense: CC BY-SA 2.5

Title: Managing collision detection in games


问:
Form validation regular expressions using javascript
Hello How can i add regular expressions in to my form validation i have done really basic form validation below and would just like to add regular expressions to increae security any ideas?? Noob at js</p>

```<code>    <head>
    <script>
    function validateForm() {
    var x = document.forms["login"]["username"].value;
    if (x == "") {
    alert("Name must be filled out");
    return false;
    }
    var x = document.forms["login"]["password"].value;
    if (x == "") {
    alert("Password must be filled out");
    return false;
    }
    }
    </script>
    </head>
</code>```

答:
Kerwin'answer is to test whether the input is empty. 'test' function will test the input string with a pattern to see if there is a match. /^w+$/ is the regex pattern you want to test against, it means:

the string starts with (by ^)

one or more than one alphanumeric and underscore characters (by \w+, \w means a character from character set [a-zA-Z0-9_], and +
means one or more than one)

then the string ends(by $, this ensure the user input ends with the character from above set, not sth like space or new line)


问:
PHP explode specific text beetwen different elements
I have result

```<code>{"success":true,"data":{"id":6583879,"listingId":"11745/3470/OMS"}}
</code>```

I need to explode it on two arrays:

```<code>$id = 6583879;
</code>```

and

```<code>$listid = 11745/3470/OMS
</code>```

I'd like to avoid counting characters, this response may be another in future. I was thinking about taking:

everything between "id": and comma

everything between "listingId":" and "

答:
```<code><?php
$json='{"success":true,"data":{"id":6583879,"listingId":"11745/3470/OMS"}}';
$decoded = json_decode($json);
$id = $decoded['data']['id'];
$listingId = $decoded['data']['listingId'];
</code>```

Body:
I have result

{"success":true,"data":{"id":6583879,"listingId":"11745/3470/OMS"}}

I need to explode it on two arrays:

$id = 6583879;

and

$listid = 11745/3470/OMS

I'd like to avoid counting characters, this response may be another in future. I was thinking about taking:

everything between "id": and comma

everything between "listingId":" and "


问:
C2084 - function already has a body
I'm running into an error "C2084 - function 'void Pet::display(void)' already has a body". Error occurs on Dog.cpp file. Slightly confused about the issue. Any help would be appreciated.

Pet.h

```<code>#ifndef _PET_H_
#define _PET_H_

#include <string>
using namespace std;

enum Type { dog = 0, cat };

class Pet {
private:
    string name, breed; // private local variables
    Type type;

public:
    Pet(string pet_name, string pet_breed, Type pet_type); // constructor

    // accessor methods
    string getName();
    string getBreed();
    Type getType();

    virtual void display() {};
};

#endif // _PET_H_
</code>```

Dog.h

```<code>#ifndef _DOG_H_
#define _DOG_H_

#include "Pet.h"
#include <string>

using namespace std;

class Dog : public Pet {
public:
    Dog(string pet_name, string pet_breed, Type pet_type) : Pet(pet_name, pet_breed, pet_type) {
    } // constructor

    virtual void display() = 0;

};

#endif
</code>```

Dog.cpp

```<code>#include "Dog.h"
#include "Pet.h"
#include <iostream>

void Pet::display() {
    cout << "Name: " << name << endl;
    cout << "Breed: " << breed << endl;
    cout << "Type: Dog" << endl;
}
</code>```

答:
In Pet.h you already have a body defined for display(), which does nothing.

In Pet.h:

```<code>class Pet {
    /* other class members */
    virtual void display() {}; // Here is your virtual function with an empty body.
};
</code>```

In Dog.h:

```<code>class Dog : public Pet {
    /* other class members */
    virtual void display() = 0; // This pure virtual function which is inheriting from Pet which is not purely virtual.

};
</code>```

Swap the two around.

Make Pet's virtual void display() = 0, i.e. a pure virtual function.

Make Pet's virtual void display(), i.e. a virtual function which you are already implementing in Dog.cpp.

Solution:

In Pet.h:

```<code>class Pet {
    /* other class members */
    virtual void display() = 0; // Make this a pure virtual function. It does not have an implementation.
};
</code>```

In Dog.h:

```<code>class Dog : public Pet {
    /* other class members */
    virtual void display(); // This virtual function is implemented in Dog.cpp.

};
</code>```

Title: C2084 - function already has a body

Body:
I'm running into an error "C2084 - function 'void Pet::display(void)' already has a body". Error occurs on Dog.cpp file. Slightly confused about the issue. Any help would be appreciated.

Pet.h

#ifndef _PET_H_
#define _PET_H_

#include <string>
using namespace std;

enum Type { dog = 0, cat };

class Pet {
private:
    string name, breed; // private local variables
    Type type;

public:
    Pet(string pet_name, string pet_breed, Type pet_type); // constructor

    // accessor methods
    string getName();
    string getBreed();
    Type getType();

    virtual void display() {};
};

#endif // _PET_H_

Dog.h

#ifndef _DOG_H_
#define _DOG_H_

#include "Pet.h"
#include <string>

using namespace std;

class Dog : public Pet {
public:
    Dog(string pet_name, string pet_breed, Type pet_type) : Pet(pet_name, pet_breed, pet_type) {
    } // constructor

    virtual void display() = 0;

};

#endif

Dog.cpp

#include "Dog.h"
#include "Pet.h"
#include <iostream>

void Pet::display() {
    cout << "Name: " << name << endl;
    cout << "Breed: " << breed << endl;
    cout << "Type: Dog" << endl;
}

Body:
In Pet.h you already have a body defined for display(), which does nothing.

In Pet.h:

class Pet {
    /* other class members */
    virtual void display() {}; // Here is your virtual function with an empty body.
};

In Dog.h:

class Dog : public Pet {
    /* other class members */
    virtual void display() = 0; // This pure virtual function which is inheriting from Pet which is not purely virtual.

};

Swap the two around.

Make Pet's virtual void display() = 0, i.e. a pure virtual function.

Make Pet's virtual void display(), i.e. a virtual function which you are already implementing in Dog.cpp.

Solution:

In Pet.h:

class Pet {
    /* other class members */
    virtual void display() = 0; // Make this a pure virtual function. It does not have an implementation.
};

In Dog.h:

class Dog : public Pet {
    /* other class members */
    virtual void display(); // This virtual function is implemented in Dog.cpp.

};


问:
Git commit -a "untracked files"?
When I do a git commit -a, I am seeing the following:

```<code>  # Please enter the commit message for your changes. Lines starting
  # with '#' will be ignored, and an empty message aborts the commit.
  # On branch better_tag_show
  # Changes to be committed:
  #   (use "git reset HEAD <file>..." to unstage)
  #
  # modified:   ../assets/stylesheets/application.css
  # modified:   ../views/pages/home.html.erb
  # modified:   ../views/tags/show.html.erb
  # modified:   ../../db/seeds.rb
  #
  # Untracked files:
  #   (use "git add <file>..." to include in what will be committed)
  #
  # ../assets/stylesheets/
  # ../views/pages/
</code>```

What does those untracked files mean? All the changes have been indeed tracked. I don't understand why git is warning me about untracked files here.

EDIT:

Ok I see a lot of confused replies. This is what happens after I git commit -a this.

```<code># On branch master
nothing to commit (working directory clean)
</code>```

As you can see, there is NOTHING other than those four files that had changes applied.

My question should be rephrased as follows: Why is git warning me about untracked files when all of the changes in this commit has been tracked?

In other words, is the untracked warning in the git commit message unnecessary?

答:
First you need to add all untracked files. Use this command line:

git add *

Then commit using this command line :

git commit -a

Title: Git commit -a "untracked files"?

Body:
When I do a git commit -a, I am seeing the following:

  # Please enter the commit message for your changes. Lines starting
  # with '#' will be ignored, and an empty message aborts the commit.
  # On branch better_tag_show
  # Changes to be committed:
  #   (use "git reset HEAD <file>..." to unstage)
  #
  # modified:   ../assets/stylesheets/application.css
  # modified:   ../views/pages/home.html.erb
  # modified:   ../views/tags/show.html.erb
  # modified:   ../../db/seeds.rb
  #
  # Untracked files:
  #   (use "git add <file>..." to include in what will be committed)
  #
  # ../assets/stylesheets/
  # ../views/pages/

What does those untracked files mean? All the changes have been indeed tracked. I don't understand why git is warning me about untracked files here.

EDIT:

Ok I see a lot of confused replies. This is what happens after I git commit -a this.

# On branch master
nothing to commit (working directory clean)

As you can see, there is NOTHING other than those four files that had changes applied.

My question should be rephrased as follows: Why is git warning me about untracked files when all of the changes in this commit has been tracked?

In other words, is the untracked warning in the git commit message unnecessary?

ContentLicense: CC BY-SA 4.0


问:
win batch regexp search and replace
I have a set of data like this

7859 10000:00        7859 10000:00 (xfer#1, to-check=1033/1035)

32768   000:17    22174479 10000:00 (xfer#2, to-check=1032/1035)

They are read from a file and passed line by line to a method inside my batch script
What I want to do in that method is to extract only

7859

22174479

from this lines, basically whatever is after "\d+:\d\d\s+", then what follows are the numbers that I need and then another "\d\d.*"

Is this possible using only batch script regular expression and search and replace?
I tried and read a bunch of articles but could not find a solution
In the and I want to add the numbers

Thank you

EDIT

Based on Andrei's comment to David Ruhmann's answer, Andrei wants the token that is 2 positions before (xfer#, not the 3rd token from the beginning.

答:
```<code>  :: Does %variable% =~ s/old/new/
  setlocal ENABLEDELAYEDEXPANSION
  for /f "delims=" %%a in ('echo !variable! ^|perl -pe "s/regexp/replace/" ') do set variable=%%a
</code>```

Title: win batch regexp search and replace


问:
How to test logging(log.Println) in Golang?
How to test below the code in Golang?</p>

```<code>package main

import "log"

func main() {
    log.Println("hello world")
}
</code>```

答: Your program writes to the log package standard logger which writes to standard error. Compile and run your program and see what appears on standard error.

Body:
How to test below the code in Golang?

package main

import "log"

func main() {
    log.Println("hello world")
}


答:
You can do something like the following:

$('.radio-group .feedbackCl').click(function(){
    $(this).parent().find('.feedbackCl').removeClass('selected');
    $(this).addClass('selected');
    var val = $(this).attr('data-value');
    $(this).parent().find('input').val(val);
    console.log('You have selected: '+val);
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.feedbackCl {
    display: inline-block;
    width: 70px;
    height: 30px;
    border: 2px solid lightblue;
    cursor: pointer;
    margin: 2px 0;
    text-align: center;
    line-height: 30px;
}

.radio-group{
    position: relative;
}

.feedbackCl.selected{
    border-color: blue;
    background-color: orange;
}
span{
    display: block;
}</code>```

close   X

We'd love your feedback.

Your feedback will help us improve your experience. To protect your privacy, please do not enter personal or account information.

  <form id="modal_feedback" method="POST" action="#" accept-charset="UTF-8">
  Your Name :

  <input type="text" name="name" value="">

— —
          Poor

-
          Fair

+ —
          Good

+
          Very good

   <textarea style="overflow-x: hidden;" id="gBann" name="message" maxlength="1000" rows="4" cols="85" placeholder="How can we improve our site? Please share your suggestions." onKeyUp="toCount('gBann','uBann','{CHAR} characters left',1000);" >
   </textarea>

   1000 characters left

   </form>

```

Title: How to set radio button as hidden for the div

Body:
You can do something like the following:

$('.radio-group .feedbackCl').click(function(){
    $(this).parent().find('.feedbackCl').removeClass('selected');
    $(this).addClass('selected');
    var val = $(this).attr('data-value');
    $(this).parent().find('input').val(val);
    console.log('You have selected: '+val);
});

.feedbackCl {
    display: inline-block;
    width: 70px;
    height: 30px;
    border: 2px solid lightblue;
    cursor: pointer;
    margin: 2px 0;
    text-align: center;
    line-height: 30px;
}

.radio-group{
    position: relative;
}

.feedbackCl.selected{
    border-color: blue;
    background-color: orange;
}
span{
    display: block;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="modal_wrapper">
  <div id="modal_window">

  <div style="text-align: right;"><a id="modal_close" href="#">close   <b>X</b></a></div>

  <p><Strong>We'd love your feedback.</Strong><br></p>

  <p>Your feedback will help us improve your experience. To protect your privacy, please do not enter personal or account information.</p>

  <form id="modal_feedback" method="POST" action="#" accept-charset="UTF-8">
  Your Name :<br>
  <input type="text" name="name" value=""><span></span><br>
   <div class="radio-group">
      <div class="feedbackCl" data-value="1">— —
          <span>Poor</span>
      </div>
      <div class="feedbackCl" data-value="2">-
          <span>Fair</span>
      </div>
      <div class="feedbackCl" data-value="3">+ —
          <span>Good</span>
      </div>
      <div class="feedbackCl" data-value="4">+
          <span>Very good</span>
      </div>
   </div>
   <br>
   <span><br></span><br>
   <textarea style="overflow-x: hidden;" id="gBann" name="message" maxlength="1000" rows="4" cols="85" placeholder="How can we improve our site? Please share your suggestions." onKeyUp="toCount('gBann','uBann','{CHAR} characters left',1000);" >
   </textarea><br>
   <span id="uBann" class="minitext" style="text-align: right;">1000 characters left</span><br>
   </form>

   </div>
</div>


问:
Is there an effective way to load a lot of text in a UITextView?
UITextView is causing my App to slow down because it holds a lot of text. I was wondering if there is some kind of third party library that can load more text effectively?
I am using attributedText to hold all of the text. If there is a better way please let me know. Any tips or suggestions are appreciated.</p>

```<code> textView.attributedText = attributeStr;
</code>```

答:
Really?  It worked fine on me. Please check this out on how I implemented my UITextView.The  HELP_STATIC_CONTENT there is a constant variable that holds static texts for my Help screen which contains lot of texts (about  500 lines).</p>

```<code>UITextView *lblHelp = [[UITextView alloc]initWithFrame:CGRectMake(10, 10, self.view.frame.size.width - 20, self.view.frame.size.height - 20)];
[lblHelp setBackgroundColor:[UIColor clearColor]];
[lblHelp setEditable:NO];
[lblHelp setSelectable:NO];
lblHelp.showsVerticalScrollIndicator=NO;
lblHelp.showsHorizontalScrollIndicator=NO;
[self.view addSubview:lblHelp];

NSString *string = HELP_STATIC_CONTENT;
NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:string];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy];
paragraphStyle.alignment=NSTextAlignmentJustified;
[paragraphStyle setLineSpacing:3];
[attrString beginEditing];
[attrString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:NSMakeRange(0, string.length)];
[attrString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, string.length)];

[attrString endEditing];
lblHelp.attributedText = attrString;
</code>```

Body:
UITextView is causing my App to slow down because it holds a lot of text. I was wondering if there is some kind of third party library that can load more text effectively?
I am using attributedText to hold all of the text. If there is a better way please let me know. Any tips or suggestions are appreciated.

 textView.attributedText = attributeStr;

Body:
Really?  It worked fine on me. Please check this out on how I implemented my UITextView.The  HELP_STATIC_CONTENT there is a constant variable that holds static texts for my Help screen which contains lot of texts (about  500 lines).

UITextView *lblHelp = [[UITextView alloc]initWithFrame:CGRectMake(10, 10, self.view.frame.size.width - 20, self.view.frame.size.height - 20)];
[lblHelp setBackgroundColor:[UIColor clearColor]];
[lblHelp setEditable:NO];
[lblHelp setSelectable:NO];
lblHelp.showsVerticalScrollIndicator=NO;
lblHelp.showsHorizontalScrollIndicator=NO;
[self.view addSubview:lblHelp];

NSString *string = HELP_STATIC_CONTENT;
NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:string];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy];
paragraphStyle.alignment=NSTextAlignmentJustified;
[paragraphStyle setLineSpacing:3];
[attrString beginEditing];
[attrString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:NSMakeRange(0, string.length)];
[attrString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, string.length)];

[attrString endEditing];
lblHelp.attributedText = attrString;


问:
Reading from a text file and changing the strings to int's to be entered in arrays is not working
Basically I am asking for the filename with a method called CS160Input (provided by my instructor) to ask for the filename. The text document has a bunch of entries each on their own lines, and I am trying to assign each number to a place in an array, but I am failing to actually write to the array. I know it is finding the file, because when i print out the counter, it tells me the correct amount of lines in the file. But when I try to print out a place in the array, I tried index 3 as you can see in my code, and it gives me 0 regardless of what I try. I tried creating an array of strings first and I ended up getting null for each index value as well.</p>

```<code>public static void caclulate() throws FileNotFoundException {
        String fileName = CS160Input.readString("Please enter the name of the file: ");
        Scanner sc = new Scanner (new File (fileName));
        int value, counter = 0;
        int array[] = null;
        while (sc.hasNextLine()) {
            sc.nextLine();
            counter++;
        }
        Scanner scanner = new Scanner(new File(fileName));
        int[] calcArray = new int [counter];
        int i = 0;
        while(scanner.hasNextInt()){
           calcArray[i++] = scanner.nextInt();
        }
        System.out.println(calcArray[3]);
        System.out.println(counter);
    }
</code>```

答: Thanks to @Gendarme pointing out that hasNextInt() could be spitting out false if there were values in between, it made me take a closer look and I realized that in a previous program the numbers being written to the text file were doubles with 2 decimal places. Once I changed to hasNextDouble(), the program worked as intended.</p>

Body:
Basically I am asking for the filename with a method called CS160Input (provided by my instructor) to ask for the filename. The text document has a bunch of entries each on their own lines, and I am trying to assign each number to a place in an array, but I am failing to actually write to the array. I know it is finding the file, because when i print out the counter, it tells me the correct amount of lines in the file. But when I try to print out a place in the array, I tried index 3 as you can see in my code, and it gives me 0 regardless of what I try. I tried creating an array of strings first and I ended up getting null for each index value as well.

public static void caclulate() throws FileNotFoundException {
        String fileName = CS160Input.readString("Please enter the name of the file: ");
        Scanner sc = new Scanner (new File (fileName));
        int value, counter = 0;
        int array[] = null;
        while (sc.hasNextLine()) {
            sc.nextLine();
            counter++;
        }
        Scanner scanner = new Scanner(new File(fileName));
        int[] calcArray = new int [counter];
        int i = 0;
        while(scanner.hasNextInt()){
           calcArray[i++] = scanner.nextInt();
        }
        System.out.println(calcArray[3]);
        System.out.println(counter);
    }


问:
Using Dot Leaders for a food menu with flex *follow-up
This is a follow-up from: Using dot leaders for a food menu with bootstrap grids

I'm creating a food menu using the grid column system with bootstrap 3, and I've created dot leaders between the menu item and the price. Thanks to user LGSon I'm using

```<code>display:flex;
</code>```

Which is doing the trick, however now the word margin seems to be cutting off the dot leaders differently depending on how many words there are. One word there is no cut off, after that there seems to be around 10px (These are approximated, and not exact). My goal is to make the dot leaders completely uniform and even. Here's what the image:

Here's my code. My apologies if it's too long, I tried to keep it brief. If anyone could help I would appreciate it.

```<code><link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />

<div class="container">
  <div class="row">
    <div class=" col-xs-6 ">
       <p class="item dots">Cheese</p>
       <p class="item dots">White</p>
       <p class="item dots">Special</p>
       <p class="item dots">Whole Wheat</p>
       <p class="item dots">Silician</p>
       <p class="item dots">Silician Special</p>
       <p class="item dots">Chicago Style</p>
     </div>
     <div class="col-xs-2">
       <p class="item">$8.99</p>
       <p class="item">$9.99</p>
       <p class="item">$13.50</p>
       <p class="item">$13.50</p>
       <p class="item">$13.50</p>
       <p class="item">$13.50</p>
       <p class="item">$13.50</p>
     </div>
     <div class="col-xs-2">
       <p class="item">$11.99</p>
       <p class="item">$12.99</p>
       <p class="item">$15.99</p>
       <p class="item">$12.99</p>
       <p class="item">$12.99</p>
       <p class="item">$12.99</p>
       <p class="item">$12.99</p>
     </div>
     <div class="col-xs-2">
       <p class="item">$12.99</p>
       <p class="item">$13.99</p>
       <p class="item">$17.99</p>
       <p class="item">$13.99</p>
       <p class="item">$15.99</p>
       <p class="item">$20.00</p>
       <p class="item">$14.99</p>
     </div>
  </div>
</div>

<style>
.dots {
  display: flex;
}

.dots::after {
  white-space: nowrap;
  overflow: hidden;
  direction: rtl;
  content: " . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .       . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ."
}
</style>

<!-- Matches Height in between divs--><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.matchHeight/0.7.0/jquery.matchHeight-min.js">

$(function() {
   $('.item').matchHeight(false);

   //Make links '.active' in Handlebars
   var url = window.location.href;
      $('nav li').find('.active').removeClass('active');
      $('nav li a').filter(function(){
         return this.href == url;
    }).parent().addClass('active');
});
</script>
</code>```

答:
One way would be to use a pseudo element to draw the dots instead, wrap your text in an element that gives it a background color that matches the page background, and position the dots underneath that element with the background color.

.dots {
  display: flex;
  position: relative;
}

.dots span {
  background: white;
  padding: 0 15px 0 0;
}

.dots::after {
  white-space: nowrap;
  overflow: hidden;
  direction: rtl;
  content: "";
  border-bottom: 1px dotted black;
  position: absolute;
  bottom: 5px;
  left: 0; right: 0;
  z-index: -1;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
  <div class="row">
    <div class=" col-xs-6 ">
      <p class="item dots"><span>Cheese</span></p>
      <p class="item dots"><span>White</span></p>
      <p class="item dots"><span>Special</span></p>
      <p class="item dots"><span>Whole Wheat</span></p>
      <p class="item dots"><span>Silician</span></p>
      <p class="item dots"><span>Silician Special</span></p>
      <p class="item dots"><span>Chicago Style</span></p>
    </div>
    <div class="col-xs-2">
      <p class="item">$8.99</p>
      <p class="item">$9.99</p>
      <p class="item">$13.50</p>
      <p class="item">$13.50</p>
      <p class="item">$13.50</p>
      <p class="item">$13.50</p>
      <p class="item">$13.50</p>
    </div>
    <div class="col-xs-2">
      <p class="item">$11.99</p>
      <p class="item">$12.99</p>
      <p class="item">$15.99</p>
      <p class="item">$12.99</p>
      <p class="item">$12.99</p>
      <p class="item">$12.99</p>
      <p class="item">$12.99</p>
    </div>
    <div class="col-xs-2">
      <p class="item">$12.99</p>
      <p class="item">$13.99</p>
      <p class="item">$17.99</p>
      <p class="item">$13.99</p>
      <p class="item">$15.99</p>
      <p class="item">$20.00</p>
      <p class="item">$14.99</p>
    </div>
  </div>
</div></code>```

Body:
This is a follow-up from: Using dot leaders for a food menu with bootstrap grids

I'm creating a food menu using the grid column system with bootstrap 3, and I've created dot leaders between the menu item and the price. Thanks to user LGSon I'm using

display:flex;

Which is doing the trick, however now the word margin seems to be cutting off the dot leaders differently depending on how many words there are. One word there is no cut off, after that there seems to be around 10px (These are approximated, and not exact). My goal is to make the dot leaders completely uniform and even. Here's what the image:

Here's my code. My apologies if it's too long, I tried to keep it brief. If anyone could help I would appreciate it.

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />

Cheese

White

Special

Whole Wheat

Silician

Silician Special

Chicago Style

$8.99

$9.99

$13.50

$13.50

$13.50

$13.50

$13.50

$11.99

$12.99

$15.99

$12.99

$12.99

$12.99

$12.99

$12.99

$13.99

$17.99

$13.99

$15.99

$20.00

$14.99

Body:
One way would be to use a pseudo element to draw the dots instead, wrap your text in an element that gives it a background color that matches the page background, and position the dots underneath that element with the background color.

.dots {
  display: flex;
  position: relative;
}

.dots span {
  background: white;
  padding: 0 15px 0 0;
}

.dots::after {
  white-space: nowrap;
  overflow: hidden;
  direction: rtl;
  content: "";
  border-bottom: 1px dotted black;
  position: absolute;
  bottom: 5px;
  left: 0; right: 0;
  z-index: -1;
}

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
  <div class="row">
    <div class=" col-xs-6 ">
      <p class="item dots"><span>Cheese</span></p>
      <p class="item dots"><span>White</span></p>
      <p class="item dots"><span>Special</span></p>
      <p class="item dots"><span>Whole Wheat</span></p>
      <p class="item dots"><span>Silician</span></p>
      <p class="item dots"><span>Silician Special</span></p>
      <p class="item dots"><span>Chicago Style</span></p>
    </div>
    <div class="col-xs-2">
      <p class="item">$8.99</p>
      <p class="item">$9.99</p>
      <p class="item">$13.50</p>
      <p class="item">$13.50</p>
      <p class="item">$13.50</p>
      <p class="item">$13.50</p>
      <p class="item">$13.50</p>
    </div>
    <div class="col-xs-2">
      <p class="item">$11.99</p>
      <p class="item">$12.99</p>
      <p class="item">$15.99</p>
      <p class="item">$12.99</p>
      <p class="item">$12.99</p>
      <p class="item">$12.99</p>
      <p class="item">$12.99</p>
    </div>
    <div class="col-xs-2">
      <p class="item">$12.99</p>
      <p class="item">$13.99</p>
      <p class="item">$17.99</p>
      <p class="item">$13.99</p>
      <p class="item">$15.99</p>
      <p class="item">$20.00</p>
      <p class="item">$14.99</p>
    </div>
  </div>
</div>


问:
How to identify existing user login Firebase?
How to identify the id (from push) of existing user?
I created a node using push when a user is registered, but when the user try to login again, I don't know how to identify it directly because its a different key.

Is it wrong to use push instead of the authentication id as my node? Because I want to retrieve the data I kept in my db for that user.

```<code>  // [START auth_state_listener]
    mAuthListener = new FirebaseAuth.AuthStateListener() {
        @Override
        public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
            FirebaseUser user = firebaseAuth.getCurrentUser();

            if (user != null) {   //I WANT TO RETRIEVE DB DATA HERE
</code>```

答:
You ask: Is it wrong to use push instead of the authentication id as my node? The answer is almost certainly, yes.  The documentation for FirebaseUser.getUid() states:

Returns a string used to uniquely identify your user in your Firebase
  project's user database. Use it when storing information in Firebase
  Database or Storage, or even in your own backend

The completion of the code in your post would be something like:

```<code>    if (user != null) {
        DatabaseReference ref = FirebaseDatabase.getInstance()
                .getReference("users").child(user.getUid());

        ref.addListenerForSingleValueEvent(...);
    }
</code>```

Body:
How to identify the id (from push) of existing user?
I created a node using push when a user is registered, but when the user try to login again, I don't know how to identify it directly because its a different key.

Is it wrong to use push instead of the authentication id as my node? Because I want to retrieve the data I kept in my db for that user.

  // [START auth_state_listener]
    mAuthListener = new FirebaseAuth.AuthStateListener() {
        @Override
        public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
            FirebaseUser user = firebaseAuth.getCurrentUser();

            if (user != null) {   //I WANT TO RETRIEVE DB DATA HERE

Body:
You ask: Is it wrong to use push instead of the authentication id as my node? The answer is almost certainly, yes.  The documentation for FirebaseUser.getUid() states:

Returns a string used to uniquely identify your user in your Firebase
  project's user database. Use it when storing information in Firebase
  Database or Storage, or even in your own backend

The completion of the code in your post would be something like:

    if (user != null) {
        DatabaseReference ref = FirebaseDatabase.getInstance()
                .getReference("users").child(user.getUid());

        ref.addListenerForSingleValueEvent(...);
    }


问:
404 error when trying to install Cordova plugin in Visual Studio
I'm building a Cordova web app using Visual Studio 2015.  I'm trying to add the Amazon Mobile Ads Cordova plugin to the project manually.  The following lists the steps I am following, and (at the end) the error I keep getting:

```<code> 1. I download Amazon Mobile Ads SDK from Amazon Developer site.
 2. I unzip the plugin contained within the SDK zip file into its own directory:
    C:\AmazonSDK
    (In other words, C:\AmazonSDK is where plugin.xml is located.)
 3. I create a new Cordova app project in Visual Studio called MyCordovaApp.
 4. I double-click on config.xml in Visual Studio to bring up the designer.
 5. I select "PlugIns", and then I select Custom.
 6. I choose "Local", and then browse to the plugin directory C:\AmazonSDK.
 7. I click on "Add".
</code>```

The process fails and I get this error in the output console:

```<code> Error: Registry returned 404 for GET on https://registry.npmjs.org/MyCordovaApp
</code>```

I've also tried manually adding the plugin from the command line by navigating to the Visual Studio project folder and executing:

```<code>cordova plugin add C:\AmazonSDK
</code>```

I get the same error as stated above.

Any ideas on how to resolve this?  I surmise that Cordova is looking at the project name in my config.xml file (i.e. "MyCordovaApp"), and then looking for a registry entry at registry.npmjs.org, but I'm not clear why it's doing this or how to add this plugin.

UPDATE: Here is the complete Visual Studio console output, along with the error (and as you can see, the actual directory location of my plugin is a little different from what I listed in the original question):

答:
I followed your steps and reproduced the issue, after checking of the plugin.xml file. I found there is an empty line ahead  of <?xml version="1.0" encoding="UTF-8"?>, which prevents VS from parsing the file.

Deleting this empty line will resolve the issue.

Body:
I'm building a Cordova web app using Visual Studio 2015.  I'm trying to add the Amazon Mobile Ads Cordova plugin to the project manually.  The following lists the steps I am following, and (at the end) the error I keep getting:

 1. I download Amazon Mobile Ads SDK from Amazon Developer site.
 2. I unzip the plugin contained within the SDK zip file into its own directory:
    C:\AmazonSDK
    (In other words, C:\AmazonSDK is where plugin.xml is located.)
 3. I create a new Cordova app project in Visual Studio called MyCordovaApp.
 4. I double-click on config.xml in Visual Studio to bring up the designer.
 5. I select "PlugIns", and then I select Custom.
 6. I choose "Local", and then browse to the plugin directory C:\AmazonSDK.
 7. I click on "Add".

The process fails and I get this error in the output console:

 Error: Registry returned 404 for GET on https://registry.npmjs.org/MyCordovaApp

I've also tried manually adding the plugin from the command line by navigating to the Visual Studio project folder and executing:

cordova plugin add C:\AmazonSDK

I get the same error as stated above.

Any ideas on how to resolve this?  I surmise that Cordova is looking at the project name in my config.xml file (i.e. "MyCordovaApp"), and then looking for a registry entry at registry.npmjs.org, but I'm not clear why it's doing this or how to add this plugin.

UPDATE: Here is the complete Visual Studio console output, along with the error (and as you can see, the actual directory location of my plugin is a little different from what I listed in the original question):


问:
Taking a line from a text file and putting them into a dictionary in python
I have a line in the following format:

```<code>Liam "!#123121" 32 "University of Southern California" "1312azasdas"
</code>```

I want to split this line in python such that for each line in a file, there is a name, age and university. In the above example, '32' is the age, 'Liam' is the name and 'University...' is the University name. What could be the best way to do this?

答: Use csv.reader, set empty space as delimiter and put in " for your quote character. This is fairly simple, just experiment and test a bit.

Body:
I have a line in the following format:

Liam "!#123121" 32 "University of Southern California" "1312azasdas"

I want to split this line in python such that for each line in a file, there is a name, age and university. In the above example, '32' is the age, 'Liam' is the name and 'University...' is the University name. What could be the best way to do this?


问:
MySQL using two databases in same query. Do not want to combine tables
New to MySQL, searched for answers, but multiple database questions seem to be all about combining tables, that's not what I'm after.

In new database, I duplicated a table from old database, with most columns but not all.

I need to get customer number from old database where customer name has 'Co.' in their name. This should return 14 or so customers with about 80 rows

I then need to delete all orders in the second database that has those customer numbers.

Is this possible with a subquery? that's where I am stuck right now.

Thanks so much.

答:
Say you have a table of SO threads (threads_table) from which you need to eliminate duplicates that you have already identified in the Problem field of another table (problem_log).

```<code>DELETE FROM `threads_table`
    WHERE `thread_ID` IN
        (SELECT `Thread_ID` from `problem_log_table`
        WHERE `Problem`='Duplicate');
</code>```

Edited to add:
Here's one way to do it, if I'm understanding your needs correctly.  (Btw, I've assumed away the added complexity of working with tables it two different databases.)

```<code>DELETE FROM tbl2
    WHERE tbl2.customer_num IN
        (SELECT tbl1.customer_num from `tbl1`
        WHERE tbl1.customer_name LIKE '%Co.%');
</code>```

Body:
Say you have a table of SO threads (threads_table) from which you need to eliminate duplicates that you have already identified in the Problem field of another table (problem_log).

DELETE FROM `threads_table`
    WHERE `thread_ID` IN
        (SELECT `Thread_ID` from `problem_log_table`
        WHERE `Problem`='Duplicate');

Edited to add:
Here's one way to do it, if I'm understanding your needs correctly.  (Btw, I've assumed away the added complexity of working with tables it two different databases.)

DELETE FROM tbl2
    WHERE tbl2.customer_num IN
        (SELECT tbl1.customer_num from `tbl1`
        WHERE tbl1.customer_name LIKE '%Co.%');


问:
Best XML Based Database
I had been assigned to develop a system on where we would get a XML from multiple sources (millions of xml) and put them in some database like and judging from the xml i would receive, there wont be any concrete structure even if they are from the same source. With this reason i think i cannot suggest RDMS and currently looking at NoSQL databases. We need a system that could do CRUD and is fast on Read.

I had been looking at MarkLogic and eXist, which are both XML based NoSQL databases, have anyone had experience with them? and any other suggestion? Thanks

答: You are right in saying that RDBMS would not serve the purpose even if it does support XML datatype these days. I have extensively worked in MarkLogic, and so far it is the best noSQL XMl DB you can have. I have also tried eXist, however it is not much scalable for production usage. MarkLogic gives agility in developement as well with integrated app servers and search engine. Currently it is serving terabytes of XML data in some huge publishing houses. </p>

Title: Best XML Based Database


问:
Spinning Image in Windows Forms (C#)
I'm working in a music player, where I want the album art of the current song to be spinning in a circular picture box, just a vynil turntable.

I already have the circular picturebox, I made one attempt to make it spin, but it is spinning roughly, it doesn't look smooth. So I don't know if I am using the wrong parameters or if something is wrong in my code.

Used code from here:
Rotating image around center C#

Hope you can help. Thanks in advance.

答:
This was really smooth for me with a PictureBox size of 150x150 and an image size of 200x200:

```<code>public partial class Form1 : Form
{

    public Form1()
    {
        InitializeComponent();
    }

    private int Angle;
    private Image Art; // you may need to resample larger images to a smaller image dynamically!
    private int AngleStep = 20;
    private System.Drawing.Drawing2D.GraphicsPath Vinyl = new System.Drawing.Drawing2D.GraphicsPath();

    private void Form1_Load(object sender, EventArgs e)
    {
        timer1.Interval = 50;
        Art = Properties.Resources.AlbumArt2; // image as embedded resource (or from somewhere else)

        // larger circle with the center cut out: (like a vinyl record)
        Vinyl.AddEllipse(pictureBox1.ClientRectangle);
        Rectangle rc = new Rectangle(pictureBox1.Width / 2, pictureBox1.Height / 2, 1, 1);
        rc.Inflate(10, 10);
        Vinyl.AddEllipse(rc);

        pictureBox1.Paint += PictureBox1_Paint;
    }

    private void PictureBox1_Paint(object sender, PaintEventArgs e)
    {
        Graphics G = e.Graphics;
        G.SetClip(Vinyl);
        G.TranslateTransform(pictureBox1.Width / 2, pictureBox1.Height / 2); // move to the center
        G.RotateTransform(Angle); // rotate to the current angle
        G.DrawImage(Art, new Point(-(Art.Width / 2), -(Art.Height / 2))); // draw the image centered
    }

    private void button1_Click(object sender, EventArgs e)
    {
        timer1.Enabled = !timer1.Enabled;
    }

    private void timer1_Tick(object sender, EventArgs e)
    {
        Angle = Angle + AngleStep;
        if (Angle >= 360)
        {
            Angle = Angle - 360;
        }
        pictureBox1.Refresh();
    }

}
</code>```

Play with it and see if it'll work for you.  You'll definitely need to make dynamic smaller images from those larger ones.  If you want performance graphics and animations, move to WPF as DigheadsFerke suggested.

Title: Spinning Image in Windows Forms (C#)

Body:
This was really smooth for me with a PictureBox size of 150x150 and an image size of 200x200:

public partial class Form1 : Form
{

    public Form1()
    {
        InitializeComponent();
    }

    private int Angle;
    private Image Art; // you may need to resample larger images to a smaller image dynamically!
    private int AngleStep = 20;
    private System.Drawing.Drawing2D.GraphicsPath Vinyl = new System.Drawing.Drawing2D.GraphicsPath();

    private void Form1_Load(object sender, EventArgs e)
    {
        timer1.Interval = 50;
        Art = Properties.Resources.AlbumArt2; // image as embedded resource (or from somewhere else)

        // larger circle with the center cut out: (like a vinyl record)
        Vinyl.AddEllipse(pictureBox1.ClientRectangle);
        Rectangle rc = new Rectangle(pictureBox1.Width / 2, pictureBox1.Height / 2, 1, 1);
        rc.Inflate(10, 10);
        Vinyl.AddEllipse(rc);

        pictureBox1.Paint += PictureBox1_Paint;
    }

    private void PictureBox1_Paint(object sender, PaintEventArgs e)
    {
        Graphics G = e.Graphics;
        G.SetClip(Vinyl);
        G.TranslateTransform(pictureBox1.Width / 2, pictureBox1.Height / 2); // move to the center
        G.RotateTransform(Angle); // rotate to the current angle
        G.DrawImage(Art, new Point(-(Art.Width / 2), -(Art.Height / 2))); // draw the image centered
    }

    private void button1_Click(object sender, EventArgs e)
    {
        timer1.Enabled = !timer1.Enabled;
    }

    private void timer1_Tick(object sender, EventArgs e)
    {
        Angle = Angle + AngleStep;
        if (Angle >= 360)
        {
            Angle = Angle - 360;
        }
        pictureBox1.Refresh();
    }

}

Play with it and see if it'll work for you.  You'll definitely need to make dynamic smaller images from those larger ones.  If you want performance graphics and animations, move to WPF as DigheadsFerke suggested.


问:
Error when making a socket chat
I am making a chat using the socket library in python, it works, only half way though, when you netcat onto what I am using as a channel I am able to send messages and the other terminal is able to receive them, but, when that terminal sends a message (typing text, then hit enter) I do not receive it through the python script. So I ran it raw in the following way:
python shell:

```<code>import socket
sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
sock.bind(("127.0.0.1",8000)
sock.listen(2)
(client, (ip,port))=sock.accept()
</code>```

Terminal:

```<code>nc 127.0.0.1 8000
</code>```

This worked and to send or receive in the python shell all I had to do was type: sock.send("message") or sock.recv(2012)
Here is My code:

```<code>#!/bin/python
import socket
import subprocess
from subprocess import Popen, PIPE
import time
class color:
    r = '\033[31m'
    g = '\033[32m'
    d = '\033[0m'
    b = '\033[94m'
    p = '\033[35m'

def clear():
    print('\n' * 100)

chat_clients = []

sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
clear()

def chatting_on_serverr():
        (client, (ip, port))=sock.accept()
    def chatting_on_server():
        message = raw_input("Send Message: ")
        client.send(message + '\n')
        client.recv(2012)
        chatting_on_server()
    chatting_on_server()

def make_channel():
    print color.b + '[+] '+color.d+'Welcome to the chat server'+color.b+' [+]'
    host = raw_input("Channel Name: ")
    port = input("Channel Access Key: ")
    clear()
    print color.p + "[info] "+color.b+"Making %s" % host
    time.sleep(1)
    sock.bind((host,port))
    sock.listen(3)
    print color.g + "[+] "+color.d+"Channel Made"+color.g+" [+]"+color.d
    print("[info]: Waiting for people to join your channel...")
    global chatting_on_serverr
    global chatting_on_server
    chatting_on_serverr()

clear()
make_channel()
</code>```

答:
All that was needed to be done is to print the output of the .recv function
    x = client.recv(2020)
    print(x)</p>

Title: Error when making a socket chat

Body:
I am making a chat using the socket library in python, it works, only half way though, when you netcat onto what I am using as a channel I am able to send messages and the other terminal is able to receive them, but, when that terminal sends a message (typing text, then hit enter) I do not receive it through the python script. So I ran it raw in the following way:
python shell:

import socket
sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
sock.bind(("127.0.0.1",8000)
sock.listen(2)
(client, (ip,port))=sock.accept()

Terminal:

nc 127.0.0.1 8000

This worked and to send or receive in the python shell all I had to do was type: sock.send("message") or sock.recv(2012)
Here is My code:

#!/bin/python
import socket
import subprocess
from subprocess import Popen, PIPE
import time
class color:
    r = '\033[31m'
    g = '\033[32m'
    d = '\033[0m'
    b = '\033[94m'
    p = '\033[35m'

def clear():
    print('\n' * 100)

chat_clients = []

sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
clear()

def chatting_on_serverr():
        (client, (ip, port))=sock.accept()
    def chatting_on_server():
        message = raw_input("Send Message: ")
        client.send(message + '\n')
        client.recv(2012)
        chatting_on_server()
    chatting_on_server()

def make_channel():
    print color.b + '[+] '+color.d+'Welcome to the chat server'+color.b+' [+]'
    host = raw_input("Channel Name: ")
    port = input("Channel Access Key: ")
    clear()
    print color.p + "[info] "+color.b+"Making %s" % host
    time.sleep(1)
    sock.bind((host,port))
    sock.listen(3)
    print color.g + "[+] "+color.d+"Channel Made"+color.g+" [+]"+color.d
    print("[info]: Waiting for people to join your channel...")
    global chatting_on_serverr
    global chatting_on_server
    chatting_on_serverr()

clear()
make_channel()


问:
Cool tricks and expressive snippets with ruby collections/enumerables
What are your favorite code snippets with ruby collections? Preferably they should be discovery for you, be expressive, readable and introduce some fun in your coding practice.

Pattern-matching in arrays (for local variables and parameters):

```<code>(a, b), c = [[:a, :b], :c]
[a,b,c]
=> [:a, :b, :c]

(a,), = [[:a]]
a
=> :a
</code>```

Assigning from non-arrays to multiple variables:

```<code>abc, a, b =* "abc".match(/(a)(b)./)
=> ["abc", "a", "b"]

nil1, =* "abc".match(/xyz/)
=> []
</code>```

Initialize array elements with the same expression:

```<code>5.times.map { 1 }
=> [1,1,1,1]

Array.new(5) { 1 }
=> [1,1,1,1,1]
</code>```

Initialize array with the same value:

```<code>[2]*5
=>[2,2,2,2,2]

Array.new 5, 2
=>[2,2,2,2,2]
</code>```

Sum elements of an array:

```<code>[1,2,3].reduce(0, &:+)

=> 6
</code>```

Find all indices that match condition:

```<code>a.each_with_index.find_all { |e, i| some_predicate(e) }.map(&:last)
</code>```

Alternate CSS classes:

```<code>(1..4).zip(%w[cls1 cls2].cycle)

=> [[1, "cls1"], [2, "cls2"], [3, "cls1"], [4, "cls2"]]
</code>```

Unzipping:

```<code>keys, values = {a: 1, b: 2}.to_a.transpose
keys
=> [:a, :b]
</code>```

Exploring boolean member methods of a string:

```<code>"".methods.sort.grep(/\?/)
</code>```

Exploring string-specific methods:

```<code>"".methods.sort - [].methods
</code>```

答:
My own are:

Initialize array elements with same expression:

```<code>5.times.map { some_expression }
</code>```

Initialize array with same value:

```<code>[value]*5
</code>```

Sum elements of an array:

```<code>[1,2,3].reduce(0, &:+)
</code>```

Find all indices that match condition:

```<code>a.each_with_index.find_all { |e, i| some_predicate(e) }.map(&:last)
</code>```

Body:
What are your favorite code snippets with ruby collections? Preferably they should be discovery for you, be expressive, readable and introduce some fun in your coding practice.

Pattern-matching in arrays (for local variables and parameters):

(a, b), c = [[:a, :b], :c]
[a,b,c]
=> [:a, :b, :c]

(a,), = [[:a]]
a
=> :a

Assigning from non-arrays to multiple variables:

abc, a, b =* "abc".match(/(a)(b)./)
=> ["abc", "a", "b"]

nil1, =* "abc".match(/xyz/)
=> []

Initialize array elements with the same expression:

5.times.map { 1 }
=> [1,1,1,1]

Array.new(5) { 1 }
=> [1,1,1,1,1]

Initialize array with the same value:

[2]*5
=>[2,2,2,2,2]

Array.new 5, 2
=>[2,2,2,2,2]

Sum elements of an array:

[1,2,3].reduce(0, &:+)

=> 6

Find all indices that match condition:

a.each_with_index.find_all { |e, i| some_predicate(e) }.map(&:last)

Alternate CSS classes:

(1..4).zip(%w[cls1 cls2].cycle)

=> [[1, "cls1"], [2, "cls2"], [3, "cls1"], [4, "cls2"]]

Unzipping:

keys, values = {a: 1, b: 2}.to_a.transpose
keys
=> [:a, :b]

Exploring boolean member methods of a string:

"".methods.sort.grep(/\?/)

Exploring string-specific methods:

"".methods.sort - [].methods

Body:
My own are:

Initialize array elements with same expression:

5.times.map { some_expression }

Initialize array with same value:

[value]*5

Sum elements of an array:

[1,2,3].reduce(0, &:+)

Find all indices that match condition:

a.each_with_index.find_all { |e, i| some_predicate(e) }.map(&:last)


问:
Is it possible to suppress fields from API results?
For example, I wish to get the like count for each post without getting name and Id details of each like.

The likes attribute returned for a call to me/posts?fields=likes.summary(true) would be:

```<code>      "likes": {
        "data": [
          {
            "id": "aaa",
            "name": "bbb"
          },
          {
            "id": "ccc",
            "name": "ddd"
          },
          ...
          ...
        ],
        "summary": {
          "total_count": 56,
          "can_like": true,
          "has_liked": false
        }
      }
</code>```

It's the "data" attribute I'd like to suppress coming back due to it (and the same for comments and other fields I'd like to turn off) substantially increasing the bandwidth of data received.

答:
If you enumerate the post id's, you can then get the summary of likes for each post by calling:

```<code>/<post-id>/likes?summary=true&fields=total_count
</code>```

This returns something like:

```<code>{
  "data": [
    {
      "id": "<id>"
    }
  ],
  "paging": {
    "cursors": {
      "before": "...",
      "after": "..."
    }
  },
  "summary": {
    "total_count": 3,
    "can_like": true,
    "has_liked": false
  }
}
</code>```

Body:
For example, I wish to get the like count for each post without getting name and Id details of each like.

The likes attribute returned for a call to me/posts?fields=likes.summary(true) would be:

      "likes": {
        "data": [
          {
            "id": "aaa",
            "name": "bbb"
          },
          {
            "id": "ccc",
            "name": "ddd"
          },
          ...
          ...
        ],
        "summary": {
          "total_count": 56,
          "can_like": true,
          "has_liked": false
        }
      }

It's the "data" attribute I'd like to suppress coming back due to it (and the same for comments and other fields I'd like to turn off) substantially increasing the bandwidth of data received.

Body:
If you enumerate the post id's, you can then get the summary of likes for each post by calling:

/<post-id>/likes?summary=true&fields=total_count

This returns something like:

{
  "data": [
    {
      "id": "<id>"
    }
  ],
  "paging": {
    "cursors": {
      "before": "...",
      "after": "..."
    }
  },
  "summary": {
    "total_count": 3,
    "can_like": true,
    "has_liked": false
  }
}


问:
loop through columns and generate rows for each record R
When I used to program in SAS, it was easy to loop across variables and generate rows after applying some sort of logic. I would like to do this in R. To illustrate, consider the following scenario.

```<code>Input
+----+----------------+-------------------+-------------+
| ID |      lvl1      |        lvl2       |     lvl3    |
+----+----------------+-------------------+-------------+
|  1 |  United States |  Ohio             |  Cincinnati |
|  2 |  Ohio          |  Cincinnati       |             |
|  3 |  Canada        |  British Columbia |  Vancouver  |
+----+----------------+-------------------+-------------+
</code>```

Let array _lvl contain lvl1, lvl2, and lvl3 and loop from i = 1 to 3 (the upper bound).

Loop 1: _lvl(1) Check whether lvl1 is null and output if not, supplying null values for the other values.

Loop 2: _lvl(2) Check whether lvl1 is null or lvl2 is null and output if not, supplying null for lvl3.

Loop 3: _lvl(3) Check whether lvl1 is null, lvl2 is null, or lvl3 is null and output if not.

This should produce the following for ID = 2.

```<code>Output
+----+-------+-------------+-------+
| ID |  lvl1 |     lvl2    |  lvl3 |
+----+-------+-------------+-------+
|  2 |  Ohio |             |       |
|  2 |  Ohio |  Cincinnati |       |
+----+-------+-------------+-------+
</code>```

Thank you in advance.

答:
I'm not too keen on your particular use case, but I'm sympathetic to the general struggle of adjusting to R after using the SAS data step in this way.

The way I emulate output statements in data step in R, is by applying functions along the rows (or in this case, columns) of a data frame.

Define your "array" of column names:

```<code>lvl <- c('lvl1','lvl2','lvl3')
</code>```

Then mimic the SAS output statements using a function (with i playing the same role as the index of your SAS array, data representing the input data frame, and names being the entire vector of columns names to iterate over):

```<code>outputcriteria <- function(i, data, names) {
  data <- data[!is.na(data[,names[i]]),] #exclude rows with NA in the current column
  data[,names[-(1:i)]] <- NA             #blank out columns after the current column
  return (data)
}
</code>```

Then apply this function to your data frame df with lapply() by setting the input vector to 1:length(lvl) (the index of your vector of column names), and also passing the data and name arguments into the function:

```<code>l <- lapply(1:length(lvl), outputcriteria, data = df, names = lvl)
</code>```

The result l is a list of three data frames (one for each iteration), which you can rbind into a single data frame:

```<code>do.call(rbind, l)
</code>```

The main difference is that you end up reading the data three times and outputting a data frame each time, as opposed to reading it once in SAS.

Body:
When I used to program in SAS, it was easy to loop across variables and generate rows after applying some sort of logic. I would like to do this in R. To illustrate, consider the following scenario.

Input
+----+----------------+-------------------+-------------+
| ID |      lvl1      |        lvl2       |     lvl3    |
+----+----------------+-------------------+-------------+
|  1 |  United States |  Ohio             |  Cincinnati |
|  2 |  Ohio          |  Cincinnati       |             |
|  3 |  Canada        |  British Columbia |  Vancouver  |
+----+----------------+-------------------+-------------+

Let array _lvl contain lvl1, lvl2, and lvl3 and loop from i = 1 to 3 (the upper bound).

Loop 1: _lvl(1) Check whether lvl1 is null and output if not, supplying null values for the other values.

Loop 2: _lvl(2) Check whether lvl1 is null or lvl2 is null and output if not, supplying null for lvl3.

Loop 3: _lvl(3) Check whether lvl1 is null, lvl2 is null, or lvl3 is null and output if not.

This should produce the following for ID = 2.

Output
+----+-------+-------------+-------+
| ID |  lvl1 |     lvl2    |  lvl3 |
+----+-------+-------------+-------+
|  2 |  Ohio |             |       |
|  2 |  Ohio |  Cincinnati |       |
+----+-------+-------------+-------+

Thank you in advance.

Body:
I'm not too keen on your particular use case, but I'm sympathetic to the general struggle of adjusting to R after using the SAS data step in this way.

The way I emulate output statements in data step in R, is by applying functions along the rows (or in this case, columns) of a data frame.

Define your "array" of column names:

lvl <- c('lvl1','lvl2','lvl3')

Then mimic the SAS output statements using a function (with i playing the same role as the index of your SAS array, data representing the input data frame, and names being the entire vector of columns names to iterate over):

outputcriteria <- function(i, data, names) {
  data <- data[!is.na(data[,names[i]]),] #exclude rows with NA in the current column
  data[,names[-(1:i)]] <- NA             #blank out columns after the current column
  return (data)
}

Then apply this function to your data frame df with lapply() by setting the input vector to 1:length(lvl) (the index of your vector of column names), and also passing the data and name arguments into the function:

l <- lapply(1:length(lvl), outputcriteria, data = df, names = lvl)

The result l is a list of three data frames (one for each iteration), which you can rbind into a single data frame:

do.call(rbind, l)

The main difference is that you end up reading the data three times and outputting a data frame each time, as opposed to reading it once in SAS.


问:
Wrapping issues when using Masonry with Bootstrap Columns
I have a news article page, where i can specify the width of the articles like this :

```<code><div class="<%# GetArticleSize(Item.ArticleSize) %>">
</code>```

Which renders the box elements in one of the following :

col-lg-3 col-md-3 col-sm-3 col-xs-6  (small size)

col-lg-6 col-md-6 col-sm-6 col-xs-6  (half size)

col-xs-12 (full size)

The masonry layout works perfectly if all the news-articles are col-sm-3 (look at this link HERE for the perfect result when using this)..

The issue comes when i set one of the news-articles as col-sm-6 (half page size)..
See this image :

It seems like it's not enough room for last col-sm-3 element, and it wraps underneath, and creating a weird look on all other news-articles.

Here is a JSFIDDLE to illustrate the code.. BUT.. this code works and wraps like it should..

I have no idea what's causing this.. Maybe one of you have any idea how to make this correct ?

UPDATED !!
When i changed the masonry target from the container to the grid items itself, it atleast spanned the whole width, but it is too wide..

```<code>$('.grid-item').masonry({
    columnWidth: 200
});

 <asp:ListView ID="lvArticles" runat="server" EnableViewState="False" ItemType="Servicelayer.Article" OnItemCommand="lvArticles_OnItemCommand" OnItemDataBound="lvArticles_OnItemDataBound">
        <ItemTemplate>
            <div class="grid-item <%# GetArticleSize(Item.ArticleSize) %>">
</code>```

Which... renders into :

                                A-lagsjentene på oppdrag for CC Gjøvik

                                    Mari Finstad Bergum og Emma Fauchald

Marthe Godtlund Bråthen

19.09.2016 11:46

                                NM-gull til ni Gjøvik HK-jenter!

                                    Region Innlandet med ni Gjøvik HK-jenter kunne juble for gull i region-NM.

Tags: Region-Nm 2016, Nm-Gull, Nm-Gullvm-Gull,  Nm-Gull,  Nm-Gullvm-Gull

Marthe Godtlund Bråthen

25.04.2016 17:45

                                Dokument nå da ?

                                    Hekk planter barlind bestilling.xlsx

Terje Nygård

31.03.2017 19:57

                                Dokument ?

Terje Nygård

31.03.2017 19:53

                                Test..

                                    Boss.

Terje Nygård

31.03.2017 19:51

                                Møtereferat ja

Terje Nygård

31.03.2017 18:44

```

I end up with a result which looks like this :

答:
Masonry FAQ: The first item breaks the grid!

You most likely need to set the columnWidth option. Without columnWidth set, Masonry will use the width of the first item for the size of its columns.

```<code>$('.grid').masonry({
  columnWidth: 200
});
</code>```

Body:
I have a news article page, where i can specify the width of the articles like this :

<div class="<%# GetArticleSize(Item.ArticleSize) %>">

Which renders the box elements in one of the following :

col-lg-3 col-md-3 col-sm-3 col-xs-6  (small size)

col-lg-6 col-md-6 col-sm-6 col-xs-6  (half size)

col-xs-12 (full size)

The masonry layout works perfectly if all the news-articles are col-sm-3 (look at this link HERE for the perfect result when using this)..

The issue comes when i set one of the news-articles as col-sm-6 (half page size)..
See this image :

It seems like it's not enough room for last col-sm-3 element, and it wraps underneath, and creating a weird look on all other news-articles.

Here is a JSFIDDLE to illustrate the code.. BUT.. this code works and wraps like it should..

I have no idea what's causing this.. Maybe one of you have any idea how to make this correct ?

UPDATED !!
When i changed the masonry target from the container to the grid items itself, it atleast spanned the whole width, but it is too wide..

$('.grid-item').masonry({
    columnWidth: 200
});

 <asp:ListView ID="lvArticles" runat="server" EnableViewState="False" ItemType="Servicelayer.Article" OnItemCommand="lvArticles_OnItemCommand" OnItemDataBound="lvArticles_OnItemDataBound">
        <ItemTemplate>
            <div class="grid-item <%# GetArticleSize(Item.ArticleSize) %>">

Which... renders into :

                                A-lagsjentene på oppdrag for CC Gjøvik

                                    Mari Finstad Bergum og Emma Fauchald

Marthe Godtlund Bråthen

19.09.2016 11:46

                                NM-gull til ni Gjøvik HK-jenter!

                                    Region Innlandet med ni Gjøvik HK-jenter kunne juble for gull i region-NM.

Tags: Region-Nm 2016, Nm-Gull, Nm-Gullvm-Gull,  Nm-Gull,  Nm-Gullvm-Gull

Marthe Godtlund Bråthen

25.04.2016 17:45

                                Dokument nå da ?

                                    Hekk planter barlind bestilling.xlsx

Terje Nygård

31.03.2017 19:57

                                Dokument ?

Terje Nygård

31.03.2017 19:53

                                Test..

                                    Boss.

Terje Nygård

31.03.2017 19:51

                                Møtereferat ja

Terje Nygård

31.03.2017 18:44

I end up with a result which looks like this :

Body:
Masonry FAQ: The first item breaks the grid!

You most likely need to set the columnWidth option. Without columnWidth set, Masonry will use the width of the first item for the size of its columns.

$('.grid').masonry({
  columnWidth: 200
});


问:
Custom login password check with Laravel 5.4
If a user tries to log into my Laravel application and the password won't match with the "password" column in the database, I want to check it against another password column ("old_system_password") too.

I'm using the default Laravel authentication system, and as far as I understand I should be able to create a new "AuthController" and override the built in authentication methods. But I don't find any methods dealing with password matching in the vendor folder, and neither do I know how to tell Laravel to use my method instead of the default.

I've searched the web for this, but any solutions I find seems to be only for older versions of Laravel.

Any ideas?

答:
Probably try using the Middleware of the authentication looking like this by default:

```<code><?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Support\Facades\Auth;

class RedirectIfAuthenticated
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @param  string|null  $guard
     * @return mixed
     */
    public function handle($request, Closure $next, $guard = null)
    {
        if (Auth::guard($guard)->check()) {
            return redirect('/home');
        }

        return $next($request);
    }
}
</code>```

Try to check if the user has been authenticated then if not call a function that will take your password and check in your database.

Body:
Probably try using the Middleware of the authentication looking like this by default:

<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Support\Facades\Auth;

class RedirectIfAuthenticated
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @param  string|null  $guard
     * @return mixed
     */
    public function handle($request, Closure $next, $guard = null)
    {
        if (Auth::guard($guard)->check()) {
            return redirect('/home');
        }

        return $next($request);
    }
}

Try to check if the user has been authenticated then if not call a function that will take your password and check in your database.


问:
execute javascript after focused on an element
I need to run execFunc(); not only when the user moves onto the next field, but also runs when the user remains focused on the same field for 5 seconds.

```<code>$('input[name="email"]').bind('blur', function () {
 execFunc();
});
</code>```

答:
How about...

```<code>$('input[name="email"]').bind('blur', execFunc).bind('focus', function() {
    setTimeout(execFunc, 5000);
});
</code>```

If the function isn't idempotent and you must execute it only once, you can do:

```<code>var execFuncHasExecuted = false;
function execFunc() {
    if (execFuncHasExecuted)
        return false;
    execFuncHasExecuted = true;

    // ... remainder of implementation
}
</code>```

Body:
I need to run execFunc(); not only when the user moves onto the next field, but also runs when the user remains focused on the same field for 5 seconds.

$('input[name="email"]').bind('blur', function () {
 execFunc();
});

Body:
How about...

$('input[name="email"]').bind('blur', execFunc).bind('focus', function() {
    setTimeout(execFunc, 5000);
});

If the function isn't idempotent and you must execute it only once, you can do:

var execFuncHasExecuted = false;
function execFunc() {
    if (execFuncHasExecuted)
        return false;
    execFuncHasExecuted = true;

    // ... remainder of implementation
}


问:
HTTP-Post binding with isPassive
My question is very similar to: How should I be implementing the HTTP POST Protocol Binding for SAML WebSSO Profile?

But I couldn't find a proper answer in it. Is it possible to send a request via an HTTP-Post binding with isPassive set to true. The Oasis specifications say that the IdP must not "visibly" take control of the user interface. Thus the IdP must be aware of the user somehow.

If the user is already active on a session on the SP side, how do I relay that information to the IdP and have them re-authenticate the user?

I want to verify the user, without hindering the user's flow...

答:
There are a few common ways to re-authenticate a user with IsPassive=true. For example, Integrated Windows Auth (Kerberos) and x509 Cert Based Auth can both be done w/out visibly working with the user's experience.

If you combine a ForceAuthn=true and IsPassive=true in your AuthnRequest, it should force the IDP to re-authenticate the user if both conditions can be met.

Title: HTTP-Post binding with isPassive


问:
How to set radio button as hidden for the div
I am working on simple feedback form where I have 3 fields Name,rating(Poor, fair, good) and feedback comment.

In my form I want user to select a single rating at a time and submit the form with selected rating & feedback comments.

I have created the
 elements for each rating and make them as radio type.

I don't want to show the radio button on the form, but I want my Div to behave as radio button.

Also how to fix the border of Divs?

I am attaching the screenshots.

First one, how I want it to appear and second one is how my current code is appearing on UI.

Below is my form code & CSS

```<code><div id="modal_wrapper">
  <div id="modal_window">

    <div style="text-align: right;"><a id="modal_close" href="#">close   <b>X</b></a></div>

    <p><Strong>We'd love your feedback.</Strong><br></p>

    <p>Your feedback will help us improve your experience. To protect your privacy, please do not enter personal or account information.</p>

    <form id="modal_feedback" method="POST" action="#" accept-charset="UTF-8">
      Your Name :<br>
      <input type="text" name="name" value=""><span></span><br>
      <div class="feedbackCl" >
        <input id="overall_0" name="overall" type="radio" value="1" tabindex="0" aria-describedby="o1-l">
        <label for="overall_0" class="labelClass">— —</label>
        <span class="screen_reader" id="o1-l">Poor</span>
      </div>
      <div class="feedbackCl">
        <input id="overall_1" name="overall" type="radio" value="2" tabindex="0" aria-describedby="o2-l">
        <label for="overall_1" class="labelClass">—</label>
        <span class="screen_reader" id="o2-l">Fair</span>
      </div>
      <div class="feedbackCl">
        <input id="overall_2" name="overall" type="radio" value="3" tabindex="0" aria-describedby="o3-l">
        <label for="overall_2" class="labelClass">+ —</label>
        <span class="screen_reader" id="o3-l">Good</span>
      </div>
      <br>
      <span><br></span><br>
      <textarea style="overflow-x: hidden;" id="gBann" name="message" maxlength="1000" rows="4" cols="85" placeholder="How can we improve our site? Please share your suggestions." onKeyUp="toCount('gBann','uBann','{CHAR} characters left',1000);" >
      </textarea><br>
      <span id="uBann" class="minitext" style="text-align: right;">1000 characters left</span><br>
      <input type="submit" name="feedbackForm" value="Submit">
    </form>

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

CSS Code

```<code>.feedbackCl {
  float: left;
  box-sizing: border-box;
  padding-top: 5px;
  width: 9%;
  text-align: center;
  height: 40px;
}

input[type="radio" i] {
  -webkit-appearance: radio;
  box-sizing: border-box;
}

.labelClass{
  margin-right: 0 !important;
  height: 28px;
  background-color: #fff !important;
  color: #0511ac;
  box-sizing: border-box;
}
</code>```

答:
Try my snippet! I dont use any js code, just html and css! hope this can help you!

.feedback{float:left;width:100%;margin-top:10px}
.feedbackCl{float:left;width:15%}
.feedbackCl>input[type="radio"]{display:none}
.feedbackCl>input[type="radio"]:checked+label>.sight{border:solid 2px #00f;background:orange}
.feedbackCl>label{width:100%;height:100%;display:inline-block;text-align:center}
.feedbackCl>label>.sight{width:100%;float:left;border:solid 1px #ccc;padding:10px 0;color:#00f;margin-left:1px}
.feedbackCl>label>.screen_reader{width:100%;float:left;padding-top:10px}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
<div id="modal_wrapper">
  <div id="modal_window">

    <div style="text-align: right;">close   <b>X</b></div>

    <p><Strong>We'd love your feedback.</Strong><br></p>

    <p>Your feedback will help us improve your experience. To protect your privacy, please do not enter personal or account information.</p>

    <form id="modal_feedback" method="POST" action="#" accept-charset="UTF-8">
      Your Name :<br>
      <input type="text" name="name" value=""><span></span><br>
      <div class="feedback">
        <div class="feedbackCl" >
        <input id="overall_0" name="overall" type="radio" value="1" tabindex="0" aria-describedby="o1-l">
        <label for="overall_0" class="labelClass">
          <span class="sight">— —</span>
          <span class="screen_reader" id="o1-l">Poor</span>
        </label>
      </div>
      <div class="feedbackCl">
        <input id="overall_1" name="overall" type="radio" value="2" tabindex="0" aria-describedby="o2-l">
        <label for="overall_1" class="labelClass">
          <span class="sight">—</span>
          <span class="screen_reader" id="o2-l">Fair</span>
        </label>

      </div>
      <div class="feedbackCl">
        <input id="overall_2" name="overall" type="radio" value="3" tabindex="0" aria-describedby="o3-l">
        <label for="overall_2" class="labelClass">
          <span class="sight">+—</span>
          <span class="screen_reader" id="o3-l">Good</span>
        </label>
      </div>
       <div class="feedbackCl">
        <input id="overall_3" name="overall" type="radio" value="3" tabindex="0" aria-describedby="o3-l">
        <label for="overall_3" class="labelClass">
          <span class="sight">+</span>
          <span class="screen_reader" id="o3-l">Very Good</span>
        </label>
      </div>
      </div>
      <br>
      <span><br></span><br>
      <textarea style="overflow-x: hidden;" id="gBann" name="message" maxlength="1000" rows="4" cols="85" placeholder="How can we improve our site? Please share your suggestions." onKeyUp="toCount('gBann','uBann','{CHAR} characters left',1000);" >
      </textarea><br>
      <span id="uBann" class="minitext" style="text-align: right;">1000 characters left</span><br>
      <input type="submit" name="feedbackForm" value="Submit">
    </form>

  </div>
</div>
</body>
</html></code>```

Body:
I am working on simple feedback form where I have 3 fields Name,rating(Poor, fair, good) and feedback comment.

In my form I want user to select a single rating at a time and submit the form with selected rating & feedback comments.

I have created the
 elements for each rating and make them as radio type.

I don't want to show the radio button on the form, but I want my Div to behave as radio button.

Also how to fix the border of Divs?

I am attaching the screenshots.

First one, how I want it to appear and second one is how my current code is appearing on UI.

Below is my form code & CSS

close   X

We'd love your feedback.

Your feedback will help us improve your experience. To protect your privacy, please do not enter personal or account information.

    <form id="modal_feedback" method="POST" action="#" accept-charset="UTF-8">
      Your Name :

      <input type="text" name="name" value="">

        <input id="overall_0" name="overall" type="radio" value="1" tabindex="0" aria-describedby="o1-l">
        — —
        Poor

        <input id="overall_1" name="overall" type="radio" value="2" tabindex="0" aria-describedby="o2-l">
        —
        Fair

        <input id="overall_2" name="overall" type="radio" value="3" tabindex="0" aria-describedby="o3-l">
        + —
        Good

      <textarea style="overflow-x: hidden;" id="gBann" name="message" maxlength="1000" rows="4" cols="85" placeholder="How can we improve our site? Please share your suggestions." onKeyUp="toCount('gBann','uBann','{CHAR} characters left',1000);" >
      </textarea>

      1000 characters left

      <input type="submit" name="feedbackForm" value="Submit">
    </form>

CSS Code

.feedbackCl {
  float: left;
  box-sizing: border-box;
  padding-top: 5px;
  width: 9%;
  text-align: center;
  height: 40px;
}

input[type="radio" i] {
  -webkit-appearance: radio;
  box-sizing: border-box;
}

.labelClass{
  margin-right: 0 !important;
  height: 28px;
  background-color: #fff !important;
  color: #0511ac;
  box-sizing: border-box;
}

Body:
Try my snippet! I dont use any js code, just html and css! hope this can help you!

.feedback{float:left;width:100%;margin-top:10px}
.feedbackCl{float:left;width:15%}
.feedbackCl>input[type="radio"]{display:none}
.feedbackCl>input[type="radio"]:checked+label>.sight{border:solid 2px #00f;background:orange}
.feedbackCl>label{width:100%;height:100%;display:inline-block;text-align:center}
.feedbackCl>label>.sight{width:100%;float:left;border:solid 1px #ccc;padding:10px 0;color:#00f;margin-left:1px}
.feedbackCl>label>.screen_reader{width:100%;float:left;padding-top:10px}

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
<div id="modal_wrapper">
  <div id="modal_window">

    <div style="text-align: right;"><a id="modal_close" href="#">close   <b>X</b></a></div>

    <p><Strong>We'd love your feedback.</Strong><br></p>

    <p>Your feedback will help us improve your experience. To protect your privacy, please do not enter personal or account information.</p>

    <form id="modal_feedback" method="POST" action="#" accept-charset="UTF-8">
      Your Name :<br>
      <input type="text" name="name" value=""><span></span><br>
      <div class="feedback">
        <div class="feedbackCl" >
        <input id="overall_0" name="overall" type="radio" value="1" tabindex="0" aria-describedby="o1-l">
        <label for="overall_0" class="labelClass">
          <span class="sight">— —</span>
          <span class="screen_reader" id="o1-l">Poor</span>
        </label>
      </div>
      <div class="feedbackCl">
        <input id="overall_1" name="overall" type="radio" value="2" tabindex="0" aria-describedby="o2-l">
        <label for="overall_1" class="labelClass">
          <span class="sight">—</span>
          <span class="screen_reader" id="o2-l">Fair</span>
        </label>

      </div>
      <div class="feedbackCl">
        <input id="overall_2" name="overall" type="radio" value="3" tabindex="0" aria-describedby="o3-l">
        <label for="overall_2" class="labelClass">
          <span class="sight">+—</span>
          <span class="screen_reader" id="o3-l">Good</span>
        </label>
      </div>
       <div class="feedbackCl">
        <input id="overall_3" name="overall" type="radio" value="3" tabindex="0" aria-describedby="o3-l">
        <label for="overall_3" class="labelClass">
          <span class="sight">+</span>
          <span class="screen_reader" id="o3-l">Very Good</span>
        </label>
      </div>
      </div>
      <br>
      <span><br></span><br>
      <textarea style="overflow-x: hidden;" id="gBann" name="message" maxlength="1000" rows="4" cols="85" placeholder="How can we improve our site? Please share your suggestions." onKeyUp="toCount('gBann','uBann','{CHAR} characters left',1000);" >
      </textarea><br>
      <span id="uBann" class="minitext" style="text-align: right;">1000 characters left</span><br>
      <input type="submit" name="feedbackForm" value="Submit">
    </form>

  </div>
</div>
</body>
</html>