text:
Q: SVG circle element in Leaflet Legend I am wondering the simplest way to add an SVG circle in a leaflet legend.  I don't need it to update size, I just want a circle with some specified radius (doesn't really matter the size) and a specified color.  I have three different map layers, with different colored points being displayed in each.
I have three checkboxes where I can toggle these layers, and I want each checkbox to display a different colored circle below it to indicate which layer is being turned on/off.  Below is my script for the checkboxes, and I'm able to get a circle to show up as an SVG element.  However, I don't want it to attach to the 'panel', but rather, I want to attach three separate SVG's under each of the checkboxes (or next to).  Here's my code:
$('#panel').append('<input type="checkbox" id="checkboxCity3" class="Cities3" id="showResidents" value="true" checked="checked" style="-moz-box-shadow: 0px 10px 14px -7px #383838; -webkit-box-shadow: 0px 10px 14px -7px #383838; box-shadow: 0px 10px 14px -7px #383838; background-color:#FFF; -moz-border-radius:8px; -webkit-border-radius:8px; border-radius:8px; display:inline-block; cursor:pointer; color:#000000; font-family:avenir; font-size:10px; font-weight:bold; padding:8px 14px; text-decoration:none;">Show Residents</button>');
    $('#panel').append('<input type="checkbox" id="checkboxCity" class="Cities" id="showFellows" value="true" checked="checked" style="-moz-box-shadow: 0px 10px 14px -7px #383838; -webkit-box-shadow: 0px 10px 14px -7px #383838; box-shadow: 0px 10px 14px -7px #383838; background-color:#FFF; -moz-border-radius:8px; -webkit-border-radius:8px; border-radius:8px; display:inline-block; cursor:pointer; color:#000000; font-family:avenir; font-size:1px; font-weight:bold; padding:8px 14px; text-decoration:none;">Show Fellows</button>');
    $('#panel').append('<input type="checkbox" id="checkboxCity2" class="Cities2" id="showResidentFellows" value="true" checked="checked" style="-moz-box-shadow: 0px 10px 14px -7px #383838; -webkit-box-shadow: 0px 10px 14px -7px #383838; box-shadow: 0px 10px 14px -7px #383838; background-color:#FFF; -moz-border-radius:8px; -webkit-border-radius:8px; border-radius:8px; display:inline-block; cursor:pointer; color:#000000; font-family:avenir; font-size:1px; font-weight:bold; padding:8px 14px; text-decoration:none;">Show Residents/<br>Fellows</button>');
    d3.select('#panel').append("svg").attr("width", 60).attr("height", 60).append("circle").attr("cx", 25).attr("cy", 25).attr("r", 25).style("fill", "purple");

However, if I attempt to append circle to actual checkboxes, it doesn't work:
      d3.select('#checkboxCity3').append("svg").attr("width", 60).attr("height", 60).append("circle").attr("cx", 25).attr("cy", 25).attr("r", 25).style("fill", "purple");

Thanks in advance!

A: That happens because HTML input elements are not allowed to have content. See reference:

Permitted content: None, it is an empty element.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input


text:
Q: Why Class is Serialized Even Without NSCoding Protocol I am using the following class:
import
@interface Person : NSObject
{

}

@property (nonatomic,copy) NSString *firstName;
@property (nonatomic,copy) NSString *lastName;

@end

@implementation Person

- (instancetype)initWithCoder:(NSCoder *)coder
{
    self = [super init];

    self.firstName = [coder decodeObjectForKey:@"firstName"];
    self.lastName = [coder decodeObjectForKey:@"lastName"];

    return self;

}

- (void)encodeWithCoder:(NSCoder *)coder
{
    [coder encodeObject:self.firstName forKey:@"firstName"];
    [coder encodeObject:self.lastName forKey:@"lastName"];
}

@end

I can still serialize this class without conforming the NSCoding protocol. The following code works. My question is why?
 // create a person
    Person *person = [[Person alloc] init];
    person.firstName = @"John";
    person.lastName = @"Doe";

    NSData *personData = [NSKeyedArchiver archivedDataWithRootObject:person];

A: The declaration of NSCoding is
@protocol NSCoding

- (void)encodeWithCoder:(NSCoder *)aCoder;
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder; // NS_DESIGNATED_INITIALIZER

@end

Which means you class conforms it - you have implemented those methods. The only thing you haven't done is to declare that you implemented the protocol, which could lead to some warnings (or compile errors, just to prevent you from crashes), but generally you are good to go. Additionally you can do an experiment if +conformsToProtocol: returns YES, even thou you haven't declared it.
Edit: Objective-C is not a strongly typed language so you have the freedom to do things like that and it will work. One example is what you have done: implemented the protocol, but haven't declared so - and it works or you can declare that you are implementing the protocol, but don't actually implement those methods - then except for the warning you will get during compilation, your code will crash. In Swift, which is a strongly typed, you can't get into situation like that.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Where does my CRUD LINQ Code Go? ASP.NET MVC I am currently using the ASP.NET MVC framework on a project (pretty much my first time)
I am using Linq2SQL as my data model..
Where should i have this kind of code:
var entries = from e in db.sometable select e;

I currently have this kinda code in the controller and pass the data i get into the view..
is this ok?
if not how do i entend my linq2sql datamodel to include this kindof code?
Thanks
Daniel

A: To add what @Poco said, here's an example:
In Foo.Common.Repositories (inside the Foo.Common Project):
public interface IRepository<T>
{
    IEnumerable<T> GetAll();
    void Update(T entity);
    void Add(T entity);
    void Delete(T entity);
    void Save();
}

public interface IUserRepository : IRepository<User>
{
    void GetByCredentials(string username, string password);
}

The inside Foo.Data.Repositories (inside Foo.Data project):
public class UserRepository
{
    // ... other methods/properties snipped.

    public IEnumerable<User> GetAll()
    {
        // Where this.Users would be L2Sql or Code-First... or some other ORM.
        return from u in this.Users orderby u.Name select u;
    }
}

Then inside your actual Foo.Web:
public class UserController : Controller
{
    private readonly IUserRepository userRepository;

    public UserController(IUserRepository userRepository)
    {
         this.userRepository = userRepository;
    }

    [AcceptVerbs(HttpVerbs.Get)]
    public ViewResult List()
    {
        var users = this.userRepository.GetAll();
        return this.View(users);
    }
}

And inside your Global.asax you'd have Ninject or some other IoC container to resolve IUserRepository:
public static void RegisterServices(IKernel kernel)
{
    kernel.Bind<IUserRepository>().To<UserRepository>();
}

protected void Application_Start()
{
    var kernel = new StandardKernel();

    AreaRegistration.RegisterAllAreas();

    MvcApplication.RegisterGlobalFilters(GlobalFilters.Filters);
    MvcApplication.RegisterRoutes(RouteTable.Routes);
    MvcApplication.RegisterServices(kernel);

    // I'm using MVC3 here:
    DependencyResolver.SetResolver(new NinjectResolver(kernel));
}

A: It's common to use the Repository pattern for MVC.
Typically, you define an interface, for instance, IProducts, and then, you implement this interface, calling you linq2sql code. Your controller will accept this interface as a parameter for the constructor, so that it depends on this interface, and not on a concrete class. Using a dependency injector, such as Ninject, will allow you to supply a concrete interface implementation to the constructor. This enables Unit Testing on you web app, and also adds flexibility.
There's a really nice book, Pro ASP.NET MVC 2 Framework, that explains all that. I'm currently reading it, and I just love it.

A: It's fine to have Linq queries in controller methods.
If we're talking about separation of concerns, the idea is that your data layer (in this case, the repository(?) code that supplies you with db.sometable) decouples your logic code (controller methods in this case) from the datastore.
You query the data layer rather than the database, so you can change the underlying datastore and your controller code will still work.
Some would argue that it's better again to move as much logic code as you can out of the controllers and into your model code (see the first answer here), but it depends how far you want to go.

A: Here's an example of how to implement the repository pattern
In addition to this I would implement an additional layer to handle your applications business logic and keep your controllers lightweight


text:
Q: Formal Mathematical Terminology For Tree Diagrams I currently have a tree diagram that shows the probabilities for certain paths in a game. The tree diagram first branches into four possibilities and then another four possibilities for each of the beginning four, making a total of sixteen possibilities (numbered outcome 1 - 16). I would like to know the proper mathematical notation or term to address the "root" of the branches that lead down to outcome 4 - 8. I have called the starting point of the whole tree diagram the "root" so I feel like it is confusing to term the branches of outcomes 4 - 8 that merge as another "root". Currently I am referring to its probability as "P(Outcome 4|8)" but is that an acceptable way to refer to it?
Edit: Now that I learned the definitions, my problem is that I do not know how to call the node on the 2nd level that branches out into leafs (outcomes which are on the third level) 4 to 8.

A: Trees are actually mathematically well-defined objects and have various pleasant properties and definitions associated with them. What you're talking about is probably better called a Directed Acyclic Graph, which is slightly different from a tree, but not in any important respect for this problem. A sketch of your tree would help me out quite a lot, but here's a picture of one that we can talk about to fix some definitions.

The circles are each referred to as nodes or vertices. The lines between them are edges, and the edge between nodes 10 and 5 is labelled or weighted with $x$. Each of the nodes at the bottom - 5, 18, 36, 39, 49 - is called a leaf. The node at the top - 33 - is called the root. Each stratum of nodes in the tree is called a level, though conventions for numbering levels differ. The level containing only 33 is either the $1^{st}$ or the $0^th$ level. You say that the branches of outcomes 4-8 "merge", presumably into a single node. This kind of node doesn't really have a name, but you can name nodes as you like.
For clarifying your problem, I'd advise naming each level of your tree with a random variable - $X_0$ at the root, then $X_1$, then $X_2$ at the leaves. The leaves could then have labels like $O_1, O_2, ...$, and we could talk about $\mathbb{P}(X_2 = O_4 | X_1 = 8)$, for example.
A sketch of your graph and a better statement of your problem would let me edit this into a better answer, but this will probably get you started on the terminology.


text:
Q: How to wait until all ajax is done in a $.each loop before running another function in jQuery I need to run a function after a series of ajax has been resolved. The problem is that the series of ajax calls are in a $.each loop. I have tried using $.when around the $.each loop and then running the .done() function on it, but everything in the .done() is still running before the ajax is finished in the $.each loop. Here is my code -
$.when(
    $.each(images, function(key, value){
        var getFile = $(value).attr('src');
        $.ajax({
            type: 'HEAD',
            url: getFile,
            success: function() {
                var index = images.index(key);

                if (index > -1) {
                    images.splice(index, 1);
                }
            },
            error: function() {

            }
        });
        x++;
    });
).done(function(){
    // code to be executed after ajax done.
});

I had this working by using async: false, but I learned that is now deprecated and provides a terrible user experience for various reasons. Does anyone have any ideas? This is stumping me...


text:
Q: inner join in nested way on MySQL this is my scheme:
board(name, catId)
cat(id, catName)
userBoard(boardName, username)
msg(boardName, username, title, text)

assume the username is "foo". i am trying to achieve the following but have no clue how to do it. i am interested in natural join of
userBoard.username = "foo" AND userBoard.boardName = board.name AND board.catId = cat.id AND msg.username = "foo" AND msg.boardName = board.name
what shall be the query for MySQL?
UPDATE:
i forgot to mention that i am interested in the following returned values
`board.name, cat.catName, msg.title, msg.text`

A: Try this:
Select b.name, c.catName, m.title, m.text
from board b
   inner join Cat c on b.catId = c.id
   inner join userBoard ub on b.name = ub.boardName
   inner join msg on m b.name = m.boardName
where ub.username = "foo" and m.username = "foo"

You will need to choose the type of join based on what do you want to select from your tables.

A: select b.name, c.catName, m.title, m.text
from board b
  inner join cat c on b.catId = c.id
  inner join userBoard ub on b.name = ub.boardName
  inner join msg m on b.name = m.boardName
where ub.username = "foo" and m.username = "foo"


text:
Q: C# -> How to read and print values form Textbox in realtime how do I get the values from the TextBox and to immediately display the calculated results in the other TextBoxes?
enter image description here
I want to load values and according to formulas to change in other TextBoxes.
This code does not work like that, or the only thing that is calculated is the average ap, but the result will be displayed only after typing any character into the textbox. All other textboxes are non-rewritable 0 or NaN.
using System;
using System.Drawing;
using System.Windows.Forms;

namespace sustruzenie_frezovanie
{
    /// <summary>
    /// Description of sustruzenie.
    /// </summary>
    public partial class sustruzenie : Form
    {
        double d = 0;
        double dm = 0;
        double vc = 0;
        double f = 0;
        double n = 0;
        double ap = 0;
        double vf = 0;
        public const double PI = 3.1415926535897931;
        public sustruzenie()
        {
            InitializeComponent();
        }
        void Label1Click(object sender, EventArgs e)
        {

        }
        void TextBox1TextChanged(object sender, EventArgs e)
        {
            double.TryParse(textBox1.Text, out d);
            d = double.Parse(textBox1.Text);
        }
        void TextBox2TextChanged(object sender, EventArgs e)
        {
            double.TryParse(textBox2.Text, out dm);
            dm = double.Parse(textBox2.Text);
        }
        void TextBox3TextChanged(object sender, EventArgs e)
        {
            double.TryParse(textBox3.Text, out vc);
            vc = double.Parse(textBox3.Text);
            if(d >=0 && n >= 0)
            {
                VypocetVc();
            }
        }
        void TextBox4TextChanged(object sender, EventArgs e)
        {
            double.TryParse(textBox4.Text, out vf);
            vf = double.Parse(textBox4.Text);
            if(f >=0 && n >= 0)
            {
                VypocetVf();
            }
        }
        void TextBox5TextChanged(object sender, EventArgs e)
        {
            double.TryParse(textBox5.Text, out n);
            n = double.Parse(textBox5.Text);
            if(vc >=0 && d >= 0)
            {
                VypocetN();
            }
        }
        void TextBox6TextChanged(object sender, EventArgs e)
        {
            double.TryParse(textBox6.Text, out f);
            f = double.Parse(textBox6.Text);
            if(vf >=0 && n >= 0)
            {
                VypocetF();
            }
        }
        void TextBox7TextChanged(object sender, EventArgs e)
        {
            double.TryParse(textBox7.Text, out ap);
            ap = double.Parse(textBox7.Text);
            if(d >=0 && dm >= 0)
            {
                VypocetAp();
            }
        }
        void SustruzenieTextChanged(object sender, EventArgs e)
        {

        }
        private void VypocetVc()
        {
            textBox3.Text = ((PI * d * n)/100).ToString();
        }
        private void VypocetVf()
        {
            textBox4.Text = (f * n).ToString();
        }
        private void VypocetN()
        {
            textBox5.Text = ((vc * 1000)/(PI * d)).ToString();
        }
        private void VypocetF()
        {
            textBox6.Text = (vf/n).ToString();
        }
        private void VypocetAp()
        {
            textBox7.Text = ((d - dm)/2).ToString();
        }
    }
}

A: Ok, if you wanna do it in realtime then you need TextChanged event associated to your textBoxes.
Let suppose if you want to add up the values from two textBoxes and immediately display the result in the third one. You can do it like,
public partial class Form1 : Form
    {
        double value1 = 0; // variables
        double value2 = 0; // variables

        public Form1()

        {
            InitializeComponent();
        }
// TextChanged associated with textBox1
 private void textBox1_TextChanged(object sender, EventArgs e)
  {
// Use TryParse instead of Prase. TryParse will not read if textBox is empty
      double.TryParse(textBox1.Text, out value1);

     if(value1 >=0 && value2 >= 0)
        {
            AddUp();// calling the metod with addition formula
        }
 }
// TextChanged associated with textBox2
 private void textBox2_TextChanged(object sender, EventArgs e)
   {
// Use TryParse instead of Prase. TryParse will not read if textBox is empty
    double.TryParse(textBox2.Text, out value2);

    if (value1 >= 0 && value2 >= 0)
      {
        AddUp();// calling the metod with addition formula
      }
}

   private void AddUp()
        {
            textBox3.Text = (value1+value2).ToString();
        }

I hope this answer addresses your question. Otherwirse write in the comment section.

A: you can use text change event for each textbox


text:
Q: How would I call a combination of specific data and procedure used to analyze the data? So I have a number of different sets of data, let's call them A, B, C, D etc. I also have a number of analysis methods for the data. Let's call them 1, 2, 3 etc.
I'm looking for a word or a phrase, if no single word exists, that can be used to explain the combination of the data and analysis method. So I'd have let's say α=(A,1), β=(A,2), γ=(B,3). What name would I use for the α, β or γ?
I was initially thinking of just using "dataset", but with that word, people tend to confuse A, B, C and α, β, γ.
Edit
OK, I see that people are taking interest, but I'm nor 100% sure if I explained clearly what I'm trying to do. So here's a couple of examples:

Here's another example:

After comparison of results, WHAT α has shown more accurate results than β, while WHAT γ has shown marginally worse results than α, but had 30% faster processing time...

A: I would think the most applicable term is, as you have already said, "combination", since that is what you are doing with your methods 1, 2, 3 and datasets A, B, C.  You are combining them in different ways to get different results, and (I assume) prove the relative effectiveness of different analytical methods.
So alpha is the combination of dataset A and method 1, beta is the combination of dataset B and method 1, gamma the combination of B and method 3, and so on.

A: When you have data, and you run it through a method, what you get is a result.
If the result is another dataset, you should label them Input Dataset, Method, Result or Output Dataset.


text:
Q: How do I know that jQuery validation rule is imposed on a particular element or not I need to update jquery validation for different scenarios. I have tried $("#elementId").rules("remove", "ruleName") for a few elements, but it is giving an Uncaught TypeError: Cannot read property 'settings' of undefined for elements which don't have validation rules.

A:
I need to update jquery validation on for different scenarios.

What scenarios?

I have tried $("#elementId").rules("remove", "ruleName") for a few elements, but it is giving an Uncaught TypeError: Cannot read property 'settings' of undefined for elements which don't have validation rules.

.rules("remove") is only used to remove validation rules that have already been assigned to a particular field.  It seems pretty pointless to "remove" something from a field that is not being validated.  If this field has no validation rules, then what are you removing?  Regardless, what you describe would not give the error message, or any other JavaScript errors.
See:  jsfiddle.net/m5vys55g/

How do I know that jQuery validation rule is imposed on a particular element or not

As you can see in my demo above, I am attaching .rules("remove") to a field that has no rules and no JavaScript errors are generated, so you wouldn't normally need to know in advance which elements have validation rules... just use .rules() in either case.


text:
Q: Load images onchange of select list I have two select list:
<select id="boy" class="list">
    <option value="">Boy picture...</option>
    <option value="1" >Picture 1</option>
    <option value="2" >Picture 2</option>
    <option value="3" >Picture 3</option>
    <option value="4" >Picture 4</option>
</select>
<select id="girl" class="list">
    <option value="">Girl picture.... </option>
    <option value="a">Picture 1</option>
    <option value="b">Picture 2</option>
    <option value="c">Picture 3</option>
    <option value="d">Picture 4</option>
</select>

and would like to load picture with both select list in separate div tag.
When I click on Picture 1 in boy list I want to load boy picture, and when clik on Picture 1 in girl list I want to load girl picture...
And, when Picture 1 is loaded and when press Next button Picture 2 to load..and so on.
I do not know how to do that.
My CODE

A: If I understand correctly you want to attach an image to every option of the select and than show the image when the option is selected.
To do so I set a custom attribute on the options myImg with the value of the image of boys and girls, I use random images (it takes a while to get them).
<select id="boy" class="list">
    <option value="">Boy picture...</option>
    <option value="1" myImg="http://randomimage.setgetgo.com/get.php?height=50&width=50">Picture 1</option>
    <option value="2"  myImg="http://randomimage.setgetgo.com/get.php?height=50&width=50">Picture 2</option>
    <option value="3"  myImg="http://randomimage.setgetgo.com/get.php?height=50&width=50">Picture 3</option>
    <option value="4"  myImg="http://randomimage.setgetgo.com/get.php?height=50&width=50">Picture 4</option>
</select>

In the change event I get the attribute with $('option:selected', this).attr('myImg') and set the css background-image of the picture div:
$('#boy').on('change', function () {
    $('select').removeClass('activeList');
    $(this).addClass('activeList');
    $(".picture").css('background-image', 'url(' + $('option:selected', this).attr('myImg') + ')');
});
$('#girl').on('change', function () {
    $('select').removeClass('activeList');
    $(this).addClass('activeList');
    $(".picture").css('background-image', 'url(' + $('option:selected', this).attr('myImg') + ')');
});

Here is a working fiddle: http://jsfiddle.net/IrvinDominin/LT8zc/
If I don't understand the question I enjoyed to develop this :-)
EDIT
If you want so set no-repeat on image set it like:
$(".picture").css({
    'background-image': 'url(' + $('option:selected', this).attr('myImg') + ')',
    'background-repeat': 'no-repeat'
});

or define it as regular css rule (not set via jQuery)
Fiddle: http://jsfiddle.net/IrvinDominin/LT8zc/1/


text:
Q: Is it possible to pass variadic template parameters to va_list? A mirroring question of Is it possible to pass va list to variadic template
In my project for testing, there is a function:
void Func(LPCSTR format, ...) {
    va_list args;
    va_start(args, format);
    char buffer[256];
    vsprintf_s(buffer, 256, format, args);
    printf("%s\n", buffer);
    va_end(args);
}

And I write a template function:
template<typename... Args>
void FuncTemp(LPCSTR format, Args... args) {
    Func(format, args...);    //#1
}

Is the call for Func in line #1 right?  I have tested my program, and it seemed to produce the correct results. Are there problems or pitfalls writing like this way?

The logic behind this:
I want to realize a log writing class which can decide to write logs to local positions or submitte to servers:
Class LogWriting{
public:
...
    LogTypes mLogType;
    void WriteLogs(...){
        switch (mlogType) {
            case(LogTypes::local): {
                // need to call <void LogLocal(LPCSTR format, ...)> here
                // which CANNOT be changed.
                break;
            }
            case(LogTypes::online): {
                // need to call
                /* template<typename... Args>
                   void LogOnline(LPCSTR format, Args... args)
                   {
                       std::string strFormat = std::string(format);
                       std::string logMessage = fmt::sprintf(strFormat, args...);
                       reportLog(logMessage);
                   }
                 */
                 // which CANNOT be changed.
                break;
            }
            ...
         }
};

Because I cannot change the parameters' types of LogLocal() and LogOnline()(one is va_list and another is variadic template), I decided to set WriteLogs() as a variadic function template to suit these two functions:
template<typename... Args>
void WriteLogs(LPCSTR format, Args... args)


text:
Q: Relationship between invertible matrices and polynomials Assume we have a matrix $B$ with dimensions $n \times n$ over the field $K$.
Prove if matrix $B$ is invertible, then $B^{-1} = f(B)$ for some polynomial $f \in K[X]$.
I understand I have to express $f(B)$ in form of matrix product or whatsoever.
Something like $f(A) = C +  D \cdot F$, where $C, D, F$ are some matrices, but I don't know what are these matrices.

A: The space of $n \times n$ linear operators  is finite dimensional, so there must be a smallest $k$ such that the monomials $I_n, B, B^2, \ldots, B^k$ are linearly dependent ($n^2$ is a very crude upper bound, but in the derivation of the minimal polynomial you actually prove the bound is $n$).
The existence of such a nontrivial linear dependence relation gives you a polynomial relation $$g(B) = a_0I_n + \sum_{j=1}^{k} a_jB^j = 0$$ with $a_j \in K$.
Now can you use the fact that $B$ is invertible to play with the polynomial $g$ a little bit and get a relation $f(B) = B^{-1}$ as desired?
(Note it's especially simple if $a_0$ is nonzero, but not a problem if it's not.)
Hint if you want

 There must be more than one nonzero coefficient in the relation.  If $a_i$ was the only nonzero term, then applying $B^{-i}$ to both sides would yield immediately the contradiction $a_i = 0$.


text:
Q: I don't know whats wrong with the below cod, thrrows an error "UnboundLocalError: local variable 'r' referenced before assignment" I don't know whats wrong with the below code, throws an error,
UnboundLocalError: local variable 'r' referenced before assignment
can some body help me, please
Code:
if i != 0:
    agentAttributes = etree.SubElement(root, "agentAttributes")
    agentAttribute = etree.SubElement(agentAttributes, "agentAttribute")
    attribute = etree.SubElement(agentAttribute, "attribute")
    refURL = etree.SubElement(attribute, "refURL")
    refURL.text = "/unifiedconfig/config/attribute/5007"
    name = etree.SubElement(attribute, "name")
    name.text = "CustomerService"
    attributeValue = etree.SubElement(agentAttribute, "attributeValue")
    attributeValue.text = "5"
    datatype = etree.SubElement(attribute, "datatype")
    datatype.text = "4"

    # print("After adding"+(str(etree.tostring(root))))

    r = requests.put(wsurl, verify=False, data=(etree.tostring(root)),
                     headers={"Content-Type": "application/xml"}, auth=('tsup01', 'Sp33chs0ft'))
    #       print("after put"+(r.text))
conn.close()
conn1.close()

#print("Adding one Attribute to all agents duration in hh:mm:ss  = " + str(datetime.now() - startTime))
#returnString = "Adding one Attribute to all agents duration in hh:mm:ss  = " + str(datetime.now() - startTime)
return HttpResponse(r.text)

A: Your problem is coming from r being defined within the if i != 0: statement. Since you haven't provided the full function, I am assuming that you are not assigning the variable r before the if statement, meaning that when you do the return HttpResponse(r.text), r is indeed unassigned!
To fix your problem, assign r outside of the if i != 0: statement.
Hope this helps!


text:
Q: Why are my X server configurations not taken into account? I know questions like that have been asked many times but I can't find a way to solve my problem even after reading them and trying the answers.
I have two screens on my desktop. Whatever I set to the /etc/X11/xorg.conf or to the /usr/share/X11/xorg.conf.d/xorg.conf files, this is how my desktop looks like when I log in (which is wrong because the wallpaper should cover the whole background on the right side):

Then I start nvidia-settings and when I change from this:

to this:

and apply it, my desktop looks like this:

which makes absolutely no sense at all to me, because I haven't touched the main screen's resolution.
I can't find a way to make X11 remember to put the small screen on the right of the big neither, nor keep the big screen as the main screen.
I have tried multiple configuration files including this:
Section "Screen"

    # Removed Option "nvidiaXineramaInfoOrder" "DFP-0"
    # Removed Option "metamodes" "DVI-I-2: nvidia-auto-select @1920x1080 +1280+0, DVI-I-1: nvidia-auto-select @1280x1024 +0+0"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "Stereo" "0"
    Option         "nvidiaXineramaInfoOrder" "DFP-2"
    Option         "metamodes" "CRT-0:nvidia-auto-select@1280x1024+1920+0,DFP-2:nvidia-auto-select@1920x1080+0+0"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

This issue appeared when I switched to 13.10. I have just switched to 14.04 but it hasn't improved anything.
My GPU is an nvidia GTS 450.
Anyone has a clue on how to solve this please ?
Edit: Output of xrandr:
Screen 0: minimum 8 x 8, current 3200 x 1080, maximum 16384 x 16384
DVI-I-0 disconnected (normal left inverted right x axis y axis)
DVI-I-1 connected primary 1280x1024+0+0 (normal left inverted right x axis y axis) 338mm x 270mm
   1280x1024      60.0*+   75.0
   1280x960       75.0     70.0     60.0
   1152x864       75.0     70.0     60.0
   1024x768       75.0     70.1     60.0
   800x600        75.0     72.2     60.3     56.2
   640x480        75.0     72.8     59.9
DVI-I-2 connected 1920x1080+1280+0 (normal left inverted right x axis y axis) 510mm x 290mm
   1920x1080      59.9*+   60.0
   1680x1050      60.0
   1280x1024      75.0     60.0
   1152x864       75.0
   1024x768       75.0     60.0
   800x600        75.0     60.3     56.2
   640x480        75.0     59.9
HDMI-0 disconnected (normal left inverted right x axis y axis)
DVI-I-3 disconnected (normal left inverted right x axis y axis)

DVI-I-1 should be on the right, DVI-I-2 on the left. I have tried
Option         "metamodes" "DVI-I-1: 1280x1024+1920+56, DVI-I-2: 1920x1080+0+0" in both /etc/X11/xorg.conf and /usr/share/X11/xorg.conf.d/xorg.conf but the result is still the same at startup.

A: I think the issue is actually much simpler. Try opening the "Appearance" settings (right click on the Dekstop => Change Background) and set the background to "Fill":

If that doesn't work, try editing your /etc/X11/xorg.conf file. Leave the Screen section as is but make sure you have the following sections:
Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0" 0 0
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
    Option         "Xinerama" "0"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "Quadro FX 880M"
    Option     "TwinView"
    ## Screen names are laptop's: DP-3, Philips: VGA-0 and Dell:DP-2
    Option         "metamodes" "DVI-I-2:  1920x1080, DVI-I-1: 1280x1024"
    Option         "TwinViewOrientation" "RightOf"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "Stereo" "0"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

I am not an expert on xorg.conf, the above is based on my own setup which I have finally gotten to work as I wanted. You can have a look at mine here, in case it gives you any ideas. It sets up two screens with either VGA-0 or DP-2 on the right (depending on which one is connected) and SP-3 (my laptop's) on the left.
I am pretty sure the Screen      0  "Screen0" 0 0 line in the "Server" section was very important but I did this about a year ago so I don't remember the details any more. Finally, the official nvidia documentation for xorg.conf is really very good and actually explains what the various options do. That and the Arch wiki page on NVIDIA are what helped me solve it.


text:
Q: Equal height columns that resize with the window I thought this markup should work, but it I must be doing something wrong. I have two divs that I want to be the same height and dynamically resize when the window is resized. One of the boxes becomes taller when the text inside the box wraps.
Edit: The two divs are side by side and I want the shorter one to resize to be the same height as the taller one. If the user has a device with a smaller screen or resizes the window to be smaller it causes the text in the  to wrap in one box before the other. I want them both to remain the same height regardless of how the user changes the size of the window.
JS
$(document).ready(function () {
    $('div.subFeaturedContainer > section').each(function() {

        var $sameHeightChildren = $(this).find('.subFeatured');
        var maxHeight = 0;

        $sameHeightChildren.each(function() {
            maxHeight = Math.max(maxHeight, $(this).outerHeight());
        });

        $sameHeightChildren.css({ height: maxHeight + 'px' });

    });
});

HTML

Header

        Nam vel risus mauris, id lacinia nulla

Header

        Donec tincidunt tellus ac dolor tristique blandit. Nam vel iaculis lorem.

CSS
.subFeatured {
width: 43.5%;
float: left;
background: rgba(0, 0, 0, 0.7);
border-top: 1px solid #b1bdbe;
padding: 2% 3% 2% 3%;
}

.subFeatured:nth-child(even) {
float: right;
}

A: Simply remove  > section : you're not finding the englobing element with the first selector.
See http://jsfiddle.net/dystroy/Pzm8k/
Additionally, maybe you'd like to call your function with the jquery $(window).resize binding function too, so that the sections remain equal when you resize the window.

A: this will do it easily
   $(document).ready(function () {

        maxHeight = 0;
        $('.subFeatured').each(function() {
            maxHeight = Math.max(maxHeight, $(this).outerHeight());
        });

        $('.subFeatured').css({ height: maxHeight + 'px' });
});

A: It's not perfect but I ended up using a script that I found here:
http://www.tutrino.com/2011/12/08/equal-height-columns-with-jquery-jxcol-plugin/

A: Late addition, but for future reference, on newer browsers you can use flexbox to achieve this.
Here's an example with 2 divs with the same height (FIDDLE HERE)
HTML

I'm column one

Here's my bottom text

I'm just a small div

CSS
.container {
  display: -webkit-flex;
  display: -ms-flex;
  display: flex;
}

References

*

*Comprehensive list of flexbox options

*Browser support (caniuse flexbox)


text:
Q: Unable to get controller to post comments - AngularJS app I'm trying to get PostsCtrl controller to display comments I have in the addPost function that is in the MainCtrl.  My goal is to be able to post the comments (in the right pane) associated with a post (in the left pane).  Did I not initialize something, or is there something missing in my addComment function?
---
name: home
url: /
---

                {{post.title}}

                {{post.title}}
               | upvotes: {{post.upvotes}}

                  Comments

        <form ng-submit="addPost(post)">
          <input type="text" ng-model="post.title" placeholder="Add post..."></input>

          <input type="text" ng-model="post.link" placeholder="Add link..."></input>

          <button type="submit" class="large button">Post</button>
        </form>

                  {{post.title}}

                  {{post.title}}

              +
              {{comment.upvotes}} - by {{comment.author}}
              {{comment.body}}

            <form ng-submit="addComment()">

Add a new comment

                <input type="text" class="form-control" placeholder="Comment" ng-model="body"></input>

              <button type="submit" class="btn btn-primary">Post</button>
            </form>

app.js
    (function() {
  'use strict';

  angular.module('chatter', [
    'ui.router',
    'ngAnimate',

    //foundation
    'foundation',
    'foundation.dynamicRouting',
    'foundation.dynamicRouting.animations'
  ])
    .factory('posts', [function(){
      var o = {
        posts: []
      };
      return o;
    }])
    .config(config)
    .run(run)

    // inject posts service into main controller
    .controller('MainCtrl', [
      '$scope', 'posts',
      function($scope, posts){
        // bind $scope.posts to posts array in factory
        $scope.posts = posts.posts;
        $scope.body = posts.body;
        $scope.test = 'Comments';

        $scope.addPost = function(post){
          if(!post.title || post.title === '') { return; }
          if(!post.upvotes) { post.upvotes = 0 }
          $scope.posts.push({
            title: post.title,
            link: post.link,
            upvotes: post.upvotes,
            comments: post.comments,
            comments: [
              {author: 'Joe', body: 'Cool post!', upvotes: 0},
              {author: 'Todd', body: 'This is a crappy post!', upvotes: 2}
            ]
          });
          post.title = '';
          post.link = '';
        };
        $scope.incrementUpvotes = function(post) {
          post.upvotes += 1;
        };
    }])
    // Posts controller
    .controller('PostsCtrl', [
      '$scope',
      '$stateParams',
      'posts',
      function($scope, $stateParams, posts){
        $scope.post = posts.posts[$stateParams.id];
        $scope.posts.comments = posts.posts.comments;

        $scope.addComment = function(comment){
          if(!comment.body === '') { return; }
          $scope.comments.push({
            body: comment.body,
            author: 'user',
            upvotes: 0
          });
          comment.body = '';
        };
    }])

  config.$inject = ['$urlRouterProvider', '$locationProvider'];

  function config($urlProvider, $locationProvider) {
    $urlProvider.otherwise('/');

    $locationProvider.html5Mode({
      enabled:false,
      requireBase: false
    });

    $locationProvider.hashPrefix('!');
  }

  function run() {
    FastClick.attach(document.body);
  }

})();

A: You are calling addComment without passing in a variable as the first parameter here:
<form ng-submit="addComment()">

But the addComment function expects a parameter:
$scope.addComment = function(comment){
    if(!comment.body === '') { return; }
            // ^^^^^ undefined because you didn't pass it in.

Instead, you should change addComment to look at the data that is on the scope that is being modified by the inputs.
Update the template input to look something like this:
<input type="text" class="form-control" placeholder="Comment" ng-model="comment.body"></input>

Then just look on the scope:
$scope.comment = {};
$scope.addComment = function(){
    if(!this.comment.body === '') { return; }


text:
Q: Resources not visible (Xamarin.Android) I have Xamarin. Android app and after I open project, I don't see any resources

I have no idea why so.
I make Clean and Rebuild
Maybe someone faced this problem? How I can solve it?

A: This is bug of last Visual Studio 2017 build. On previous all okay


text:
Q: How can I print only certain fields in a space separated file? I have a file containing the following content 1000 line in the following format:
abc def ghi gkl
How can I write a Perl script to print only the first and the third fields?
abc ghi

A: while ( <> ) {
    my @fields = split;
    print "@fields[0,2]\n";
}

and just for variety, on Windows:
C:\Temp> perl -pale "$_=qq{@F[0,2]}"

and on Unix
$ perl -pale '$_="@F[0,2]"'

A: As perl one-liner:
perl -ane 'print "@F[0,2]\n"' file
Or as executable script:
#!/usr/bin/perl

use strict;
use warnings;

open my $fh, '<', 'file' or die "Can't open file: $!\n";

while (<$fh>) {
    my @fields = split;
    print "@fields[0,2]\n";
}

Execute the script like this:
perl script.pl

or
chmod 755 script.pl
./script.pl

A: I'm sure I shouldn't get the bounty since the question asks for the result to be given in perl, but anyway:
In bash/ksh/ash/etc:
cut -d " " -f 1,3 "file"

In Windows/DOS:
for /f "tokens=1-4 delims= " %i in (file) do (echo %i %k)

Advantages: like others said, no need to learn Pearl, Awk, nothing, just knowing some tools. The result of both calls can be saved to the disk by using the ">" and the ">>" operator.

A: perl -lane 'print "@F[0,2]"' file

A: If no answer is good for you yet, I'll try to get the bounty ;-)
#!/usr/bin/perl
# Lines beginning with a hash (#) denote optional comments,
# except the first line, which is required,
# see http://en.wikipedia.org/wiki/Shebang_(Unix)

use strict;   # http://perldoc.perl.org/strict.html
use warnings; # http://perldoc.perl.org/warnings.html

# http://perldoc.perl.org/perlsyn.html#Compound-Statements
# http://perldoc.perl.org/functions/defined.html
# http://perldoc.perl.org/functions/my.html
# http://perldoc.perl.org/perldata.html
# http://perldoc.perl.org/perlop.html#I%2fO-Operators
while (defined(my $line = <>)) {
    # http://perldoc.perl.org/functions/split.html
    my @chunks = split ' ', $line;
    # http://perldoc.perl.org/functions/print.html
    # http://perldoc.perl.org/perlop.html#Quote-Like-Operators
    print "$chunks[0] $chunks[2]\n";
}

To run this script, given that its name is script.pl, invoke it as
perl script.pl FILE

where FILE is the file that you want to parse. See also http://perldoc.perl.org/perlrun.html. Good luck! ;-)

A: That's really kind of a waste for something as powerful as perl, since you can do the same thing in one trivial line of awk.
awk '{ print $1 $3 }'

A: while(<>){
  chomp;
  @s = split ;
  print "$s[0] $s[2]\n";
}

please start to go through the documentation as well

A: #!/usr/bin/env perl
open my$F, "<", "file" or die;
print join(" ",(split)[0,2])."\n" while(<$F>);
close $F

A: One easy way is:
(split)[0,2]

Example:
$_ = 'abc def ghi gkl';
print( (split)[0,2] , "\n");
print( join(" ", (split)[0,2]  ),"\n");

Command line:
perl -e '$_="abc def ghi gkl";print(join(" ",(split)[0,2]),"\n")'


text:
Q: How to know the right amp to power a 12V actuator? I have an Arduino Uno. I need to use an electric linear actuator to control the movement of a joint in which I have installed a rotary encoder to know in what angles it's moving.
The actuator is a 12 Volt DC and has only two wires to control it, no libraries or anything. I have a 'double relay' which I think is useful to make the actuator run in both directions, but I'm not sure if I'm going to fry it or not. I also need to connect the arduino and the actuator to batteries or an outlet and I really don't know how NOT to fry them and this is my real problem right now since I don't know what kind of power source to use.
The encoder is to prevent the actuator to move between some angles and to measure the rotation speed, and the movement of the actuator is supposed to be controlled by two buttons, one to go forward while is being pressed, and the other to move backwards.
To picture the design a little better, imagine a leg in which the actuator is in the thigh and it pushes the calf in order to move the leg. The encoder is located inside the knee joint.

A: Without details like what actuator you bought or a datasheet it is a little difficult to give you exact information and guarantee its correctness.  However we can do a bit of educated guessing.
If there are only 2 wires going to the actuator, note not 2 control wires but 2 wires total then we have to assume thats for power and ground.  Power them one direction and the actuator moves power them another and it moves the opposite direction.  We can determine the maximum current the actuator can consume by measuring the resistance between these 2 leads.  12volts/resisitance(in ohms) will give you the maximum current draw.  So if you measure 1 ohm then the current draw is 1 amp for 12 volts.
This is way to much for the arduino to handle.   If I were setting this circuit up I would use whats called an H bridge.  However using relays might be a bit easier as a beginner.  You will need 4 relays that way you can turn either wire positive or negative.  Depending on the relay you probably will not be able to trigger it with the arduino directly... Hook one side of the coil to your 12 volt power supply and wire a logic  level n channel mosfet up to the the other. Put a resistor between the gate of the mosfet and your microcontroller pin.  That will allow you to turn the relay on and off with your arduino

A: If you know for sure that the actuator is intended to be operated from 12 volts DC, simply apply 12 volts DC and measure the resulting current.
The actuator will attempt to draw its rated current - if this happens to be more than your power supply can produce, the supply may reduce the voltage, blow a fuse or otherwise attempt to protect itself.


text:
Q: Adding padding to Angular UI modal In this plunk I have an Angular UI modal containing a table. I want to add a margin between the table borders and the modal borders, but declaring in the css a padding element does not work. How to achieve this?
Also, I need the modal width to expand automatically depending on the content width. Is this possible?
HTML

Javascript:
var app = angular.module('app', ['ui.bootstrap']);
app.controller('ctl', function ($scope,$uibModal) {

          $scope.modalInstance = $uibModal.open({
              templateUrl: 'myModalContent.html',
              windowClass: 'app-modal',
            });

});

A: Add padding to the class .modal-content instead
.app-modal .modal-content{
   padding: 10px;
}


text:
Q: Creating a multi-column search box in Google Sheets I'm trying to create a multi-column search box using the FILTER and SEARCH function on Google Sheets.
I currently have one sheet called 'Master Client Sheet' with column A through column O and a "Search Tab" sheet where I have the following function:
=filter('Master Client Sheet'!A3:N,search(A2,'Master Client Sheet'!A3:A),search(B2,'Master Client Sheet'!B3:B),search(C2,'Master Client Sheet'!C3:C),search(D2,'Master Client Sheet'!D3:D),search(E2,'Master Client Sheet'!E3:E))

This makes it so that when I type a certain keyword into the search box, it pulls applicable clients from the master sheet.
When it's just 5 "searches," the function works perfectly fine. But when I try to add more, the function cuts my 180 entries down to half of that.
I don't know how to fix it. Any help would be greatly appreciated, thanks!

A: The reason you are getting the error is because search() will always return a #VALUE error if you search a blank cell to resolve this using your existing code you can wrap an array formula and make anything "" equal to " " so that it will not return an error.
=arrayformula(filter('Master Client Sheet'!A2:N,search(A2,'Master Client Sheet'!A2:A),search(B2,'Master Client Sheet'!B2:B),search(C2,'Master Client Sheet'!C2:C),search(D2,'Master Client Sheet'!D2:D),search(E2,if('Master Client Sheet'!E2:E=""," ",'Master Client Sheet'!E2:E))))

The key addition here is the ArrayFormula and
if('Master Client Sheet'!E2:E=""," ",'Master Client Sheet'!E2:E)

which is saying if something is blank make it a blank space so that the search function can return a non error result. You will have to wrap this if statement for any column that possibly could contain blank information.

A: try like this:
=ARRAYFORMULA(IFNA(QUERY(TO_TEXT('Master Client Sheet'!A2:J), "where "&TEXTJOIN(" and ", 1,
 IF(A2:J2<>"", "lower(Col"&COLUMN(A2:J2)&") contains '"&LOWER(A2:J2)&"'", )), 0),
 "no such data"))


text:
Q: PHP - codeigniter URL not working without index.php - object not found I am using codeigniter v3 for my website and I'm having problems redirecting from one page to another.
If I click the tab, the link shows localhost:8080/IDS/view/decisiontree and shows Object not found! The requested URL was not found on this server...
If I edit the URL and make it localhost:8080/IDS/index.php/view/decisiontree, the site perfectly loads.
Here are my routes:
$route['view/decisiontree'] = 'data_controller/goto_decisiontree';

Here are the codes of the tab related:

<a href="<?php echo base_url();?>view/decisiontree">Decision Tree

Here is my data_controller:
public function goto_decisiontree(){
    $data['page'] = "2";

    $this->load->view('decisiontree_page', $data);
}

And here is my config.php:
$config['base_url'] = 'http://localhost:8080/IDS';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

Here's my .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

And note, I'm using Codeigniter V3.
Thanks a lot for the help!

A: Try the following
Open config.php and do following replaces
$config['index_page'] = "index.php"

to
$config['index_page'] = ""

In some cases the default setting for uri_protocol does not work properly. Just replace
$config['uri_protocol'] ="AUTO"

by
$config['uri_protocol'] = "REQUEST_URI"

HTACCESS
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

Hope it helps .

A: Try this htaccess in main directory of your codeIgniter project. It seems to work fine in xampp and wamp.
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

config.php
$config['base_url'] = 'http://localhost:8080/IDS/';
$config['index_page'] = "";
$config['uri_protocol'] = 'REQUEST_URI';

All ways remember that you should have first letter of file name and class as upper case the rest lower case. refer
More htaccess examples here

A: Note: I'm on Ubuntu, so the paths here may change if you are on another distro.
I tried all .htaccess suggestions and none seemed to work, so I started thinking that was not the problem. And then it hit me, the apache.conf file. Doesn't matter the .htaccess you have, if that file is restricting the override, there's nothing you can do.
So i went to /etc/apache2/ and edited the apache2.conf file adding this:
<Directory /var/www/html/your-project-folder>
    AllowOverride All
    Require all granted
</Directory>

Also change $config['index_page'] = index; to $config['index_page'] = ''; in application/config/config.php as said above.
Btw, my .htaccess looks like this:
RewriteEngine On
RewriteRule ^(application) - [F,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

And don't forget to restart apache.

A: Please try to set the index_page blank in config.php file
$config['index_page']= "";
Also please change the .htaccess file:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

A: Try below in your .htaccess file
<IfModule mod_rewrite.c>
# Turn on URL rewriting
RewriteEngine On

# If your website begins from a folder e.g localhost/my_project then
# you have to change it to: RewriteBase /my_project/
# If your site begins from the root e.g. example.local/ then
# let it as it is
RewriteBase /

# Protect application and system files from being viewed when the index.php is missing
RewriteCond $1 ^(application|system|private|logs)

# Rewrite to index.php/access_denied/URL
RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]

# Allow these directories and files to be displayed directly:
RewriteCond $1 ^(index\.php|robots\.txt|favicon\.ico|public|assets|css|js|images)

# No rewriting
RewriteRule ^(.*)$ - [PT,L]

# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]
</IfModule>

For more detail, you can visit here


text:
Q: Change view controllers how can I change ViewController to another VC?
Example:
I have LogVC and UserDetailVC.
When user write username and pass on logVC need change to userDetailVC.
-When user not login, he can't see userDetailVC
-And when user login,, he can't see logVC until go out
Now I made
let userController = self.storyboard?.instantiateViewController(withIdentifier: "userDetailVC") as! userDetailVC
self.present(userController, animated: true, completion: nil)

Window change to userDetailVC, but I haven't got a TabBarController

A: You could add a segue in your storyboard and call the performSegue(withIdentifier: "identifier", sender: self)
If you have your view controllers in a a navigation controller, set the segue style as push otherwise set is as modalto present it on top of your current view controller

A: If you are in same a storyBoard then you can simply do this -
Take a button in your LogVC and ctrl+ drag a segue upto your UserDetailVC. Then click on the segue. (the round thing on between two view controller). -

And set a identifier for that (here about is the identifier, you can give any name for this)-

Here is the code -
@IBAction func UserDetailVC(sender: AnyObject) {
        self.performSegue(withIdentifier: "segueIdentifierName", sender: sender)
    }

Or if you want to navigate to Controller on StoryBoard with Identifier "userDetailVC", then do this(this will applicable when you are trying to show one storyboard's ViewController to another storyboard ViewController):
   let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
   let nextViewController = storyBoard.instantiateViewController(withIdentifier: "userDetailVC") as! userDetailVC
   self.present(nextViewController, animated:true, completion:nil)


text:
Q: Echo canceler using auto correlation I am implementing an echo canceler by first finding the parameters for the echoed signal using auto correlation. I have multiple delays in my signal.
After using s=xcorr(x,x), how do I extract the values of the peaks of s? The max function gives the value at the center of s, and findpeaks() gives values of peaks that lie just next to the maximum peak, but higher than the real delay peaks.

A: In short
Use findpeaks with SORTSTR applied on a smoothed version of your autocorrelation.
In more words
It really depends how noisy your signal is but a quick solution to your problem is to first smooth your autocorrelation to limit the effect of noise, which may introduce multiple local maxima around the peaks of interest.  Then you can take the peaks sorted in decreasing order.
Other options to play with and possibly combine:

*

*'MINPEAKHEIGHT' to find peaks that are above a threshold (say above 10% of the max of your autocorrelation)

*'MINPEAKDISTANCE' to avoid local maxima too close to each other

Or just write you own code, which is what you may need to do ultimately to get the code to do exactly what you want.
In code:
% Create right portion of autocorrelation of a sinusoid with some noise
% This should lead to peaks of decreasing amplitude around positions 1, 26, 51, 76
% Note: This is a quick example.  A more realistic signal would show better peaks.
x=.4*sin(2*pi*(1:N)/N*4)+rand(1,N);
autocorr=xcorr(x);
autocorr=autocorr(N:(2*N-1));

% Smooth out the autocorrelation
autocorrFiltered=filter([1 1 1 1 1],[1],autocorr);
subplot(2,1,1);
plot(autocorr);
xlabel('Autocorrelation')
subplot(2,1,2);
plot(autocorrFiltered);
xlabel('Smoothed autocorrelation')
[peaks,locations]=findpeaks(autocorrFiltered,'SORTSTR','descend');

% Display locations, correcting for the filter offset
locations-3
ans =

      2    23    49    73    92

In image:
Here is the comparison of filter and unfiltered autocorr side by side illustrating why the smoothing helps with finding the peaks.


text:
Q: how to count specifc values, even if there are no results? I'm trying to create an array with 10 elements that is filled with the count of all 10 possible options.
number_count = np.array([0,1,2,3,4,5,6,0,0,0])

unique, count = np.unique(number_count, return_counts=True)
dict(zip(unique,count))
count_array = count /10

(the number_count array has been changed as the values are coming from a txt file instead of it being hard coded).
The way I have counted the elements I am returning all 7 unique occurrences of the values, but I am trying to include options for (0,1,2,3,4,5,6,7,8,9) even if there are 0 occurrences of a specific value.
I'm wondering if there is a way to use numpy.unique to count specific unique values instead of just the unique occurrences, or am I better of using some other form of counting?

A: You can create an array of zeros of the length you want and just add your counts indexed by the return value of np.unique
import numpy as np

number_count = np.array([0,1,2,3,4,5,9,0,0,0,1])

counts = np.zeros(10, dtype=int)

unique, count = np.unique(number_count, return_counts=True)
counts[unique] += count

counts
# array([4, 2, 1, 1, 1, 1, 0, 0, 0, 1])

This avoids the temporary dictionary. If you actually want the dict you can create it from the list with :
dict(enumerate(counts))
# {0: 4, 1: 2, 2: 1, 3: 1, 4: 1, 5: 1, 6: 0, 7: 0, 8: 0, 9: 1}


text:
Q: Can Squid3 access PHP Helpers Can Squid3 use PHP helper programs other than for ACL and redirect?
I need Squid to use a PHP program (with mysql access) to set the parent proxy that should be used for a particular connection, so the program should be able to set values for cache_peer etc for that connection.
I may have the entire approach wrong, please correct me if that's so


text:
Q: Delete some files in folder I have a cronjob that removes every day all unused files, but I will wish to go further. My files are this structure name_number.jpg, but some files have this structure name_.jpg.
Currently my script does not make a difference and removes all. I wish the script to remove the name_number.jpg without erasing the files without number.
$days = 1;
$path = './result/';

// Open the directory
if ($handle = opendir($path))
{
    // Loop through the directory
    while (false !== ($file = readdir($handle)))
    {
        // Check the file we're doing is actually a file
        if (is_file($path.$file))
        {
            // Check if the file is older than X days old
            if (filemtime($path.$file) < ( time() - ( $days * 24 * 60 * 60 ) ) )
            {
                // Do the deletion
                unlink($path.$file);
            }
        }
    }
}

Thank you in advance for your response.

A: With Iterators:
$days = 1;

$fsi = new RegexIterator(
    new FilesystemIterator('/path/to/your/files'),
    '(.+_\d+\.jpg$)'
);
/** @var SplFileObject $file */
foreach ($fsi as $file) {
    if ($file->isFile() && $file->getMTime() < strtotime("-$days day")) {
        unlink($file);
    }
}

Functional approach:
$days = 1;

array_map(
    function($file) use ($days) {
        if (!is_dir($file) && filemtime($file) < strtotime("-$days day")) {
            unlink($file);
        }
    },
    glob('/path/to/your/files/*_[1-9].jpg')
);

Good old imperative:
$days = 1;

foreach (glob('/path/to/your/files/*_[1-9].jpg') as $file) {
    if (!is_dir($file) && filemtime($file) < strtotime("-$days day")) {
        unlink($file);
    }
};


text:
Q: WooCommerce: How to display fields from the "Product Add-ons" extension? I'm using the [Product Add-ons][1] extension for WooCommerce, which allows custom fields for products. This automatically displays on the single product template.
By some trial and error with the single product template, it appears to hook in somewhere in woocommerce_single_product_summary (single_meta?).
I need to get this same set of form fields to display on the archive-product template (the list of products). In my case, this is a field for a card request and one for delivery date. Both are needed before the product can be added to the cart from the product archive. I'm not sure if there is a function I can call for this, if it involves some more advanced coding.

Per Pelmered's answer, I was able to get the add-on fields to show up with adding this to functions.php:
add_action( 'woocommerce_after_shop_loop_item_title', array($GLOBALS['Product_Addon_Display'], 'display'), 10);
1ST ATTEMPT
Then, the problem was that the product archive was not creating a form element, only an anchor link for the add to cart button. So I've tried manually putting in a form. Code from content-product.php:
<?php do_action( 'woocommerce_before_shop_loop_item' ); ?>

<?php the_title(); ?>

<?php // MANUALLY PUT IN FORM, BECAUSE HOOKS ONLY PUT IN A BUTTON AND NO FORM. NEEDED FOR ADD-ON FIELDS ?>
<form class="cart" method="post" enctype='multipart/form-data'>
    <?php
        /**
         * woocommerce_after_shop_loop_item_title hook
         *
         * @hooked woocommerce_template_loop_rating - 5
         * @hooked woocommerce_template_loop_price - 10
         */
        do_action( 'woocommerce_after_shop_loop_item_title' );
    ?>

        <?php the_content(); ?>

    <input type="hidden" name="add-to-cart" value="<?php echo esc_attr( $product->id ); ?>" />
    <button type="submit" class="single_add_to_cart_button button alt"><?php echo $product->single_add_to_cart_text(); ?></button>
</form>

<?php //do_action( 'woocommerce_after_shop_loop_item' ); ?>

This worked, but kind of messes up the AJAX submission and flash messages. After clicking the add to cart button, the page appears to refresh, and then it looks like nothing happened. But when you go to another page, it displays the messages (and multiple can stack).
2ND ATTEMPT
So I saw that the original AJAX cart button (not within a form) was using a query string to send the product ID. So I am now attempting to tack on additional parameters by modifying the add to cart JS. This worked. What I did added as the accepted answer.

A: I've found a solution that works, using jQuery to add the form field values to the AJAX request. This requires overriding add-to-cart.js with your own version, so future updates to that file may need to be merged.
In functions.php
// display add-on fields in woocommerce_after_shop_loop_item_title
add_action( 'woocommerce_after_shop_loop_item_title', array($GLOBALS['Product_Addon_Display'], 'display'), 10);

// Our custom cart JS to allow for product add-on fields on product archive
add_action( 'wp_enqueue_scripts', 'load_woo_scripts', 9 );
function load_woo_scripts() {
    wp_enqueue_script( 'wc-add-to-cart', get_template_directory_uri() . '/js/add-to-cart.js', array( 'jquery' ), WC_VERSION, true );
}

Duplicate /assets/add-to-cart.js from the woocommerce plugin folder, and add to the folder referenced in load_woo_scripts. Then add the following after the var date = { statement (line 21).
// =========================================================================
// ADD PRODUCT ADD-ON FIELDS TO SUBMISSION (to allow from product archive)
// Store name and value of fields in object.
var addonfields = {};
$(this).parent().find(".after-shop-loop-item-title :input").each(function() {
    addonfields[this.name] = $(this).val();
});

// Merge new fields and existing data
data = $.extend(data, addonfields);

// Testing: final value of data
console.log( data );
// =========================================================================

This adds the names and values of all input fields within the .after-shop-loop-item-title div. I've added this div/class to my theme's woocommerce/content-product.php template:
<?php do_action( 'woocommerce_before_shop_loop_item' ); ?>

<?php the_title(); ?>

    <?php the_content(); ?>

    <?php
        /**
         * woocommerce_after_shop_loop_item_title hook
         *
         * @hooked woocommerce_template_loop_rating - 5
         * @hooked woocommerce_template_loop_price - 10
         */
        do_action( 'woocommerce_after_shop_loop_item_title' );
    ?>

<?php do_action( 'woocommerce_after_shop_loop_item' ); ?>

Note that in my case, I am only using a textarea and a text input. Neither of which changes the price. More advanced usage of the extension may require more work.
I really hope that WooCommerce makes this easier in the future...

A: It's impossible to give you an exact copy-paste solution without access to the code, but it should be possible to attach the same function that is being hooked.
The hook that adds this to the single product page probably looks like this:
add_action( 'woocommerce_single_product_summary', array($this, 'woocommerce_product_add_ons_something'));

To attach this action to the achive template as well you should probably be able to do something like this:
add_action( 'woocommerce_after_shop_loop_item_title', array('WC_Product_Add_On', 'woocommerce_product_add_ons_something'));

WC_Product_Add_On is the class name of the plguin and needs to be changed to match the class that has the function/method in the action. Put this code in the functions.php file in your theme.
See if it works. If not, give me more information and I can expand my answer.

A: If anyone want to display woocommerce product addons fields everywhere, you can do this:
$custom_field = get_post_meta( $product_id, '_product_addons', false );

foreach( $custom_field as $field => $value) {
    foreach( $value as $val => $v) {
        echo $v["name"]; // or other field that you want!
    }
}

Enjoy!


text:
Q: Having issues implemented a macro which changes rows to other sheets and an automatic date vba I have two pieces of code that I am trying to run. I have this macro that I have been running which checks a column for a word, copies that entire row, and paste into the next available row in a sheet that corresponds to the word found, here is the code:
Sub MoveRows()
    Dim ws As Worksheet
    Dim destination As Worksheet
    Dim rng As Range
    Dim r As Long

    For Each ws In ThisWorkbook.Worksheets

        'Set the range to search
        Set rng = ws.Range("D:D")

       'Find the rows to move
        For r = rng.Rows.Count To 1 Step -1
            'Check the cell value
            Select Case rng.Cells(r).Value
                Case "Complete"
                    'Set destination worksheet
                    Set destination = ThisWorkbook.Sheets("Completed")
                    If rng.Cells(r).Value = "Complete" And destination.Name <> ws.Name Then
                        'Cut and paste the row
                        rng.Cells(r).EntireRow.Copy destination.Cells(destination.Rows.Count, 1).End(xlUp).Offset(1)

                        'Delete the row
                        rng.Cells(r).EntireRow.Delete
                    End If
                Case "In-Process"
                    'Set destination worksheet
                    Set destination = ThisWorkbook.Sheets("In-Process")
                    If rng.Cells(r).Value = "In-Process" And destination.Name <> ws.Name Then
                        'Cut and paste the row
                        rng.Cells(r).EntireRow.Copy destination.Cells(destination.Rows.Count, 1).End(xlUp).Offset(1)

                        'Delete the row
                        rng.Cells(r).EntireRow.Delete
                    End If
                Case "Waiting on Response"
                    'Set destination worksheet
                    Set destination = ThisWorkbook.Sheets("Waiting on Response")
                    If rng.Cells(r).Value = "Waiting on Response" And destination.Name <> ws.Name Then
                        'Cut and paste the row
                        rng.Cells(r).EntireRow.Copy destination.Cells(destination.Rows.Count, 1).End(xlUp).Offset(1)

                        'Delete the row
                        rng.Cells(r).EntireRow.Delete
                    End If
                  Case "Rerouted"
                    'Set destination worksheet
                    Set destination = ThisWorkbook.Sheets("Rerouted")
                    If rng.Cells(r).Value = "Rerouted" And destination.Name <> ws.Name Then
                        'Cut and paste the row
                        rng.Cells(r).EntireRow.Copy destination.Cells(destination.Rows.Count, 1).End(xlUp).Offset(1)

                        'Delete the row
                        rng.Cells(r).EntireRow.Delete
                    End If

                Case "Draft Complete"
                    'Set the destination worksheet
                    Set destination = ThisWorkbook.Sheets("Draft Complete")
                    If rng.Cells(r).Value = "Draft Complete" And destination.Name <> ws.Name Then
                        'Cut and paste the row
                        rng.Cells(r).EntireRow.Copy destination.Cells(destination.Rows.Count, 1).End(xlUp).Offset(1)

                        'Delete the row
                        rng.Cells(r).EntireRow.Delete
                    End If
                Case "Routed for Approval"
                    'Set the destination worksheet
                    Set destination = ThisWorkbook.Sheets("Routed for Approval")
                    If rng.Cells(r).Value = "Routed for Approval" And destination.Name <> ws.Name Then
                        'Cut and paste the row
                        rng.Cells(r).EntireRow.Copy destination.Cells(destination.Rows.Count, 1).End(xlUp).Offset(1)

                        'Delete the row
                        rng.Cells(r).EntireRow.Delete
                    End If
                Case "Rejected"
                    'Set the destination worksheet
                    Set destination = ThisWorkbook.Sheets("Rejected")
                    If rng.Cells(r).Value = "Rejected" And destination.Name <> ws.Name Then
                        'Cut and paste the row
                        rng.Cells(r).EntireRow.Copy destination.Cells(destination.Rows.Count, 1).End(xlUp).Offset(1)

                        'Delete the row
                        rng.Cells(r).EntireRow.Delete

                    End If
            End Select
        Next
    Next
End Sub
here

This runs fine until I have this VBA code implemented. Where the idea was to have a time stamp next to the words I typed in a cell. This also works fine by itself. Here is the code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Application.EnableEvents = False
    Dim cell As Range
    Dim rng As Range
    Dim time_stamp As String

    Set rng = Range("I2:I100")
    time_stamp = Format(Now, "mm/dd/yyyy hh:mm")

    For Each cell In rng

        If Not Intersect(Target, cell) Is Nothing Then
            If Len(cell.Value) > 0 Then
                Target.Value = cell.Value & " " & time_stamp
                If Target.Cells.Count = 1 Then 'Check if Target is a single-cell range
                    Target.Characters(Target.Characters.Count - 15, 20).Font.Color = vbRed
                End If
            End If
        End If

    Next cell
    Application.EnableEvents = True
End Sub

Here is what happens when I have both implemented:

Also, when I comment out the "Target.Value = cell.Value & " " & time_stamp " line, the macro runs fine.
I tried using variations of If Len(cell.Value), thinking maybe that was the issue. I have also tried to google my issue, but I could never find an answer that was made within the last few years.

A: A Worksheet Change: Time Stamp With Font Color
Private Sub Worksheet_Change(ByVal Target As Range)
    On Error GoTo ClearError

    Dim rg As Range: Set rg = Target.Worksheet.Range("I2:I100")
    Dim trg As Range: Set trg = Intersect(rg, Target)
    If trg Is Nothing Then Exit Sub

    Dim TimeStamp As String: TimeStamp = Format(Now, "mm/dd/yyyy hh:mm")
    Dim tsLen As Long: tsLen = Len(TimeStamp)

    Application.EnableEvents = False

    Dim tCell As Range, tString As String

    For Each tCell In trg.Cells
        tString = CStr(tCell.Value)
        If Len(tString) > 0 Then
            tString = tString & " " & TimeStamp
            tCell.Value = tString
            tCell.Font.ColorIndex = xlAutomatic
            tCell.Characters(Len(tString) - tsLen + 1, tsLen).Font.Color = vbRed
        End If
    Next tCell

ProcExit:
    On Error Resume Next
        If Not Application.EnableEvents Then Application.EnableEvents = True
    On Error GoTo 0
    Exit Sub
ClearError:
    Debug.Print "Run-time error'" & Err.Number & "':" & vbLf & Err.Description
    Resume ProcExit
End Sub

A: You're triggering your event handler from MoveRows - you can disable events to prevent that:
Sub MoveRows()
    Dim ws As Worksheet, destination As Worksheet, rng As Range, r As Long, c As Range
    Dim destName As String, v
    For Each ws In ThisWorkbook.Worksheets

        'Set the range to search
        Set rng = ws.Range("D1:D" & ws.Cells(Rows.Count, "D").End(xlUp))

        On Error GoTo haveError
        Application.EnableEvents = False '<<<<   disable events

        'Find the rows to move
        For r = rng.Rows.Count To 1 Step -1
            Set c = rng.Cells(r)
            v = c.Value

            Select Case v
                Case "Complete": destName = "Completed" 'different sheet name from cell value
                Case "In-Process", "Waiting on Response", "Rerouted", _
                      "Draft Complete", "Routed for Approval", "Rejected"
                    destName = v  'same sheet name as cell value
                Case Else: destName = ""
            End Select

            If Len(destName) > 0 Then         'got a destination sheet?
                If destName <> ws.Name Then   'not the same sheet?
                    c.EntireRow.Copy _
                      ThisWorkbook.Sheets(destName).Cells(Rows.Count, 1).End(xlUp).Offset(1)
                    c.EntireRow.Delete
                End If
            End If
        Next r
    Next ws

haveError:
    If Err.Number > 0 Then MsgBox Err.Description
    'ensure events are re-enabled
    Application.EnableEvents = True
End Sub


text:
Q: Present a view controller from top to bottom direction How can I present a view controller from top to down direction in Swift?
I have a view controller with a notification(bell) icon at the top. When I click this icon, I want to show a view controller that originates from top.
Thanks.

A: There is no default transition style that will give you this effect. But you can use custom animations applied on view controller to acheive this effect. These are some links you can follow.
http://www.raywenderlich.com/113845/ios-animation-tutorial-custom-view-controller-presentation-transitions
How do you present a UIViewController from the top of the screen instead of the bottom?

A: There is an control available to presenting a uiviewcontroller as a popup with different type of animations.
MJPopupViewController try it may be it help you.

A: There are two ways to do it:

*

*Making a custom transition as suggested above

*Add view controller as child view controller and animate it from top.


text:
Q: Userform Combobox plays song in media player based on its value Need help on this. I have combobox which links to sheet that will show default value based on Column A value. Example,
A| Twinkle Star | BY Ali
B| ABC Song     | By Kim
C| 123 Song     | By Els
If i choose A, in userform will shows the twinkle star and by ali in text box.
I would like to set if A is chosen, it will play Twinkle Star song, when B is chosen, it wil play ABC Song. Need your opinion please.
    Private Sub UserForm_Initialize()
    Set xRg = Worksheets("Sheet4").Range("A2:C7")
    Me.ComboBox1.List = xRg.Columns(1).Value
End Sub
Private Sub ComboBox1_Change()
    Me.TextBox1.Text = Application.WorksheetFunction.VLookup(Me.ComboBox1.Value, xRg, 2, False)
    Me.TextBox2.Text = Application.WorksheetFunction.VLookup(Me.ComboBox1.Value, xRg, 3, False)

    Select Case ComboBox1.Value
       Case "A"
            WindowsMediaPlayer1.Controls.Play= FollowHyperlink "#Sheet4!A2"
       Case "B"
            WindowsMediaPlayer1.Controls.Play= FollowHyperlink "#Sheet4!A3"
    End Select

End Sub

i tried using case a, b and links to hyperlink but not works..
appreciate your help guys.

A: You need to create a playlist, add a song to it and then play the song. Here is an exmaple
Option Explicit

Private Sub CommandButton1_Click()
    Dim myPlayList As Object, myMedia As Object

    Dim wmP As WindowsMediaPlayer
    Set wmP = WindowsMediaPlayer2

    Dim MySong As String
    MySong = "C:\WhoLetTheDogsOut.mp3"

    With wmP
        Set myPlayList = .playlistCollection.newPlaylist("PersonalPlayList")

        .currentPlaylist = myPlayList

        Set myMedia = .mediaCollection.Add(MySong)

        .currentPlaylist.insertItem (.currentPlaylist.Count), myMedia
        .Controls.Play
    End With
End Sub

thanks for your advice Siddarth.i tried your method but it will play the listed song But if i put a list there, when i change combobox value, the song will not change accordingly. – SES0204 16 mins ago

You need to stop the song, clear the playlist and recreate it to play. See the below example. I am using 2 different buttons to play the song. You can pass the value from the combobox to Sub PlaySong(sng As String)
Option Explicit

Dim myPlayList As Object, myMedia As Object
Dim wmP As WindowsMediaPlayer
Dim MySong As String

Private Sub UserForm_Initialize()
    Set wmP = WindowsMediaPlayer2
End Sub

'~~> Play 1st Song
Private Sub CommandButton1_Click()
    MySong = "C:\WhoLetTheDogsOut.mp3"
    PlaySong MySong
End Sub

'~~> Play 2nd Song
Private Sub CommandButton2_Click()
    MySong = "C:\Game Of Thrones.mp3"
    PlaySong MySong
End Sub

Private Sub PlaySong(sng As String)
    With wmP
        .Controls.stop
        .currentPlaylist.Clear
        Set myPlayList = .playlistCollection.newPlaylist("PersonalPlayList")
        .currentPlaylist = myPlayList
        Set myMedia = .mediaCollection.Add(sng)
        .currentPlaylist.insertItem (.currentPlaylist.Count), myMedia
        .Controls.Play
    End With
End Sub


text:
Q: Echart.js library for graphs (javascript) does not show data on page using xaxis type is time I try to show temperature on a webapge (using Echarts.js) within 24 hours based on whole hours.
I have added a sample html.doc which i try.
Somehow it does not show the data.
Here is my example code:
The staqck-overflow editor keeps complaining that i had to add more details, please view the code.
That is full code.
<!DOCTYPE html>
    <meta charset="utf-8">
    <title>ECharts</title>

This is my output:
output of html file
All help is welcome.
Thanks in advance.
Anand


text:
Q: UIScrollViewDelegate not scrolling animated I have created a subclass of UIScrollView that uses the UIScrollViewDelegate. I created it to work with OpenGL ES objects. I have the following code:
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
    for(InputEntity * iEnt in [sceneInstance inputObjects]){
        iEnt.display.translation = GLKVector2Make(0, self.contentOffset.y);
    }
}

It eventually puts all the content in the correct spot, but it does not update the locations until after the scroll view has stopped moving. Is there a way to fix this so it looks animated like UIScrollViews do?

A: do you have render method like setNeedDisplay:
if you have,you can:
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
for(InputEntity * iEnt in [sceneInstance inputObjects]){
    iEnt.display.translation = GLKVector2Make(0, self.contentOffset.y);
    //render here
}
}


text:
Q: MSBuild target failing on server, yet succeeding locally For our web project, I require the assembly version of the project to version our static content.
I have declared a target in the web project file to get the assembly identity and retrieve the version number from it, like:
<PropertyGroup>
    <IvanhoWebVersion>
    </IvanhoWebVersion>
  </PropertyGroup>
  <Target Name="SetIvanhoWebVersion" AfterTargets="AfterBuild">
    <Message Text="-----------------">
    </Message>
    <Message Text="Entering target SetIvanhoWebVersion">
    </Message>
    <Message Text="-----------------">
    </Message>
    <GetAssemblyIdentity AssemblyFiles="$(OutputPath)$(AssemblyName).dll">
      <Output TaskParameter="Assemblies" ItemName="AssemblyIdentities" />
    </GetAssemblyIdentity>
    <CreateProperty value="%(AssemblyIdentities.Version)">
      <Output TaskParameter="Value" PropertyName="IvanhoWebVersion" />
    </CreateProperty>
    <Message Text="Assembly version = v$(IvanhoWebVersion)">
    </Message>
    <Exec Command=" "$(SolutionDir)Ivanho.Lib\TranslationGenerator\TranslationGenerator.exe" "$(ProjectDir)Areas\UI\Static\locales\translationsrc\Translations-EN-NL-AR.xlsx" "$(ProjectDir)Areas\UI\Static\locales\v.$(IvanhoWebVersion)"" />
  </Target>

This works like a charm when building locally, however when trying to check this in to our TFS build server it fails with the following error:

Cannot get assembly name for "bin\Ivanho.Web.dll". Could not load file
  or assembly 'Ivanho.Web.dll' or one of its dependencies. The system
  cannot find the path specified.

This error is thrown at the same line of the GetAssemblyIdentity call.
I can't figure out why this isn't working on the build server, I'm pretty new to MSBuild, can someone point me in the right direction? Many thanks in advance!

A: Either the file is not there or the path to it is wrong.
Have a look on the build server to see if the file's there. You can use the converttoabsolutepath task to be certain of the paths see:http://msdn.microsoft.com/en-us/library/bb882668(v=vs.100).aspx. You could put in an error statement to check for the file e.g.
<Error Condition="!Exists('$(OutputPath)$(AssemblyName).dll')" Text="FileNotFound"/>


text:
Q: exisitance of inf Let $f:[0, \infty] \rightarrow [0, \infty]$ be a strictly increasing (therefore one-to-one) but not onto function, with $f(0)=0$. For some $c >0$, I want to prove that $\inf\{ x \mid f(x) \ge c\}$ always exists. How do I prove this? We know that 0 is not in the set $\{ x \mid f(x) \ge c\}$ but how can we show that 0 is lower bound of the set? Thanks very much!

A: Let $c = f(1).$ Then it's easy to see that $c > 0, \;$ since $\; 0 \leq f(0) < f(1).$
Since $\{x : \; f(x) \geq c\} \; \neq \; \emptyset \;$ (the number $1$ belongs to this set), it follows that $\{x : \; f(x) \geq c\} \;$ is a nonempty set that is bounded below (by $0),$ and hence by the least upper bound property of the real numbers we have that $\;\inf \{x : \; f(x) \geq c\}$ exists.

A: If $\{ x \mid f(x) \ge c\} \neq \emptyset$ then its infimum exists, since it is a bounded-below subset of $R$.
Note that $x=0$ is a lower bound for the set.

A: As you note, $0$ is not in the set $\{x | f(x) \geq c\}$. This means that $0$ as a lower bound (not necessarily the greatest lower bound, but that's not a problem.
An important property of the real numbers is the "completeness" property. This means that if a set is bounded below (or above), then there exists an inf (or sup) for the set. Since your set is bounded below, an inf will always exist.
Edit: To show that $0$ is not in the set, we note that $f$ strictly increasing implies that $f(x) > 0$ for any $x > 0$. But because the domain of $f$ is $[0,\infty)$, $f(0) \geq 0$. This means that $f(c) > 0$ for any $c>0$.

A: The domain of the set is $[0, \infty)$ Thus $0 \le x$ for all $x \in [0,\infty)$.  There is nothing lower.  So $0$ is a lower bound of all subsets of $[0, \infty)$ and every subset of $[0, \infty)$ is bounded below.
Showing that $K \subset [0, \infty)$ is bounded below, is simply not an issue.  The only thing we have to show prove $\inf K$ existis is that $K$ is non-empty.  That is all.
To show that the must exist some $c > 0$ so that $\inf  \{x| f(x) \ge c\}$ we must simply prove there is some $c > 0$ so that $ \{x| f(x) \ge c\}$ is not empty.  Simply pick any $c= f(a) > 0$. As $f$ is strictly increasing then for $a > 0$ we know $f(a) > f(0) \ge 0$.  And for all $b \ge a; f(b) \ge f(a) = c$.  So $\{x|f(x) \ge c\} = [a, \infty)$ and $\inf  \{x| f(x) \ge c\} = a$.
======= oops; you wrote for some $c$; not for all $c$.  Nevermind the rest of this post =====
Which... I don't think we can.  Let $f(x)$ be assymptotic to $d < c$ and $\{x| f(x) \ge c\}$ is empty and $\inf \{x| f(x) \ge c\}$ does not exist.[$*$]
....
Also you claim that $0 \not \in \{x| f(x) \ge c\}$.  There is no reason to assume that at all.  It is perfectly possible for $f(0) \ge c$.[$**$]
[$*$] Example $f(x) = 1 - \frac 1{x+1}; c= 2$ then $ \{x| f(x) \ge c\}= \{x| \frac 1{x+1} \ge 2; x \ge 0\} = \{x| 1 \ge 2x + 2; x\ge 0\}=\{x| x \le -\frac 12 and x \ge 0\}= \emptyset$.
[$**$] Example $f(x) = 256 + x; c = 59$ then $f(x) = 256 > 59$ so $0 \in \{x| f(x) \ge c\}=\{x| 256 + x \ge 59; x \ge 0\} = \{x|x \ge - 197 and x \ge 0\} = \{x| x \ge 0\} = [0 , \infty)$.


text:
Q: dealing low memory in hadoop 3.1.3 in vmware virtual machine ubuntu 19.10 I installed Hadoop on a Ubuntu virtual machine.
I downloaded the source file that means among the releases available on this page https://hadoop.apache.org/releases.html  I downloaded 3.1.3 file
https://www.apache.org/dyn/closer.cgi/hadoop/common/hadoop-3.1.3/hadoop-3.1.3-src.tar.gz
the installation was successful. I got following message

It appears that I have low memory. I have allotted 2 GB of memory for this virtual machine of Ubuntu. If you can see in above screenshot there are many more virtual machines which I intend to use.

I need other virtual machines for various development works. I want to know how should or rather in what range I should increase the memory so that I can work with Hadoop ecosystem on ubuntu 19.10. I plan to do some development work which can be done with single nodes later on I want to work with multiple nodes. I am doing all this on my laptop which has 12 GB RAM.
and I have following virtual machines
1)Ubuntu 19.10 VM
2)Debian 10 VM
3)Windows 10 VM
4)Cloudera Hadoop VM
5)Ubuntu 19.10 (I have installed Hadoop in this VM)
I have given 2 GB to all VMs.
I also want to know as seen in above I get a Hadoop command prompt.
How can I again get it I mean if I power off the machine.
I notice the shell in above images as
debian@4d943db32085:~/hadoop$
debian is my username configured in Ubuntu 19.10
I want to know what is this kind of shell that I got above and why is this number debian@4d943db32085 coming

A: increasing size of RAM in VM from 2GB to 4GB solved the problem.


text:
Q: Push notification is getting received and taking user to inside the application automatically ? When user click on push notification app takes user to the respective screen depending upon the push notification information, but in case if so many pushes are coming and user frequently put the app in foreground and background , it automatically takes user to the respective screen, I am not able to determine if user clicked on push notification. Current I am using the following code to determine if user clicked on push notification. normally this check works fine but gets failed in the mentioned scenario.
if application.applicationState == UIApplicationState.Inactive {
        NSLog("App is Inactive......")
        NSLog(" PROCESS PUSH ")
        self.parsePushNotificationInfo(userInfo)
    }


text:
Q: What's a good way to output matplotlib graphs on a PHP website? I have a python script that can output a plot using matplotlib and command line inputs.
What i'm doing right now is making the script print the location/filename of the generated plot image and then when PHP sees it, it outputs an img tag to display it.
The python script deletes images that are older than 20 minutes when it runs. It seems like too much of a workaround, and i'm wondering if there's a better solution.

A: You could modify your python script so it outputs an image (image/jpeg) instead of saving it to a file. Then use the  tag as normal, but pointing directly to the python script. Your php wouldn't call the python script at all, It would just include it as the src of the image.


text:
Q: Django - Join two Table without Foreign key I have two tables and want to join them..
but I can't do that without rawQueryset and raw SQL.
how can i join two models without foreign key? The columns for JOIN is not unique so it can't be PK and Foreign Key.
I want to get the SQL LIKE THIS
'SELECT * FROM genome AS A JOIN metadata AS B ON A.query_id = B.sample_id',

and this the models I used.

class Genome(models.Model):
    query_id = models.CharField(max_length=100)
    ref_id = models.CharField(max_length=30)
    matching_hashes = models.CharField(max_length=30)

class Metadata(models.Model):
    project_id = models.CharField(max_length=50) # Metagenome의 query id와 JOIN함
    sample_id = models.CharField(max_length=50)

A: You can try this:
Firstly, construct a SQL query as desired
sql_query = "SELECT * FROM genome AS A JOIN metadata AS B ON A.query_id = B.sample_id"

User that SQL query in django DB connection like following:
from django.db import connection

def my_custom_sql(self):
    cursor = connection.cursor()
    cursor.execute(sql_query)
    row = cursor.fetchall()
    return row

Or you can try to execute raw() as following
Genome.objects.raw(sql_query) # in some cases it may not work

A: You can try this:
sample_ids = Metadata.objects.values('sample_id')
Genome.objects.filter(query_id__in=sample_ids)


text:
Q: How can I allow ajaxterm to connect to foreign hosts? I have installed ajaxterm from the repo and put it behind nginx. It works fine. However, it only allows to log in to the server it's running on.
How do I allow users to connect to an arbitrary host of their choice? Preferably, I'd like to limit that choice to a list of pre-approved hosts but just allowing any host would be good enough. I'd also like to avoid giving everyone shell access to the gateway server that ajaxterm is running on.
Possible? ServerDo seems to have it running like that.

A: There's a patched copy of AjaxTerm for this exact use-case.


text:
Q: why jquery load() method doesn't require a webserver to work properly? why jquery load() method doesn't require a webserver to work properly , although ajax requires a web server .!!? isn't load a wrapper to simplify ajax activities?
thanks :)
edit: it's now clear  , thank you

A: jQuery is a JavaScript library and thus a completely client side code. It runs entirely in the browser. While it does make AJAX easier it is not only for that. Even so, AJAX does not require a webserver either.

A: Since you are loading content from "somewhere" on the web, it doesn't matter if you have a web server or not, since you might be loading from Google, or Digg, or StackOverflow, etc.
AJAX doesn't require that you provide the web server... just that a web server somewhere exists to load up the content.


text:
Q: RSA encryption using public key without source needing to be shorter than modulus We need to RSA encrypt XML data before sending to a third party web service.
The encryption has to happen in Salesforce using public key provided by the service provider.
I have looked at code here by Mats Roshauw https://gist.github.com/karmats/4270441be5a34fff7062. The code seems to work but has a limitation where the length of XML data cannot be more than length of modulus part of public key.
Can someone please help with RSA encrypting XML data without such length restrictions?
Thank you for your time.

A: That length restriction is by design (see this Crypto SE answer). You don't directly encrypt the XML data. Instead you generate a hash of the XML (typically a SHA1 hash) using the Apex Crypto.generateDigest() method and then encrypt that hash. The generated hash will be unique to the original XML but it will be relatively very short. This allows you to use the Crypto.encrypt() methods taking the Hash as the input string.


text:
Q: C++ Error: expected primary-expression before 'double' I need to write a class program that calculates the distance between two points - Point.cpp, and another class program that calls my Point.cpp program to calculate the length(basically distance from Point.cpp) and slope between two points - LineSegment.cpp. I tested my Point.cpp separately and it runs fine. But when I run everything together (in conjunction with the LineSegment.cpp), I get the following error message:
LineSegment.cpp: In member function 'void LineSegment::setEnd1(Point)':
LineSegment.cpp:31: error: expected primary-expression before 'double'
LineSegment.cpp:32: error: expected primary-expression before 'double'
LineSegment.cpp: In member function 'void LineSegment::setEnd2(Point)':
LineSegment.cpp:37: error: expected primary-expression before 'double'
LineSegment.cpp:38: error: expected primary-expression before 'double'

My codes are below.  I have marked the 4 lines that the error message refers to with a comment (everytime I posted my code with line numbers I received a suggested edit to take the line numbers out, so I did not include line numbers this time).
My guess is that I am calling the functions from Point.cpp incorrectly, but my textbook does not tell me how to call functions from a nested class.  Any guidance would be appreciated.  Thank you all for your time!
LineSegment.hpp
#ifndef LINESEGMENT_HPP
#define LINESEGMENT_HPP
#include "Point.hpp"

class LineSegment {
private:
   Point p1;
   Point p2;

public:
   LineSegment(Point, Point);
   void setEnd1(Point p1);
   void setEnd2(Point p2);
   Point getEnd1();
   Point getEnd2();
   double length();
   double slope();
};
#endif

LineSegment.cpp
#include <iostream>
#include <cmath>
#include "LineSegment.hpp"

//constructor
LineSegment::LineSegment(Point p1, Point p2) {
   setEnd1(p1);
   setEnd2(p2);
}

//set and get points
void LineSegment::setEnd1(Point p1) {
   p1.setXCoord(double);       // <-- error
   p1.setYCoord(double);       // <-- error
   setEnd1(p1);
}

void LineSegment::setEnd2(Point p2) {
   p2.setXCoord(double);       // <-- error
   p2.setYCoord(double);       // <-- error
   setEnd2(p2);
}

Point LineSegment::getEnd1() {
   return p1;
}

Point LineSegment::getEnd2() {
   return p2;
}

//calculations
double LineSegment::length() {
   return p1.distanceTo(p2);
}

double LineSegment::slope() {
   return(p2.getYCoord()-p1.getYCoord())/p2.getXCoord()-p1.getXCoord();
}

Point.hpp
#ifndef POINT_HPP
#define POINT_HPP
class Point {
private:
   double xCoord;
   double yCoord;

public:
   Point();
   Point(double x1, double y1);
   void setXCoord(double x1);
   void setYCoord(double y1);
   double getXCoord();
   double getYCoord();
   double distanceTo(const Point&);
};
#endif

Point.cpp
#include <cmath>
#include <iostream>
#include "Point.hpp"

//default constructor
Point::Point() {
   xCoord = 0.0;
   yCoord = 0.0;
}

//constructor
Point::Point(double x, double y) {
   xCoord = x;
   yCoord = y;
}

//get and set functions
void Point::setXCoord(double x) {
   xCoord = x;
}

void Point::setYCoord(double y) {
  yCoord = y;
}

double Point::getXCoord() {
   return xCoord;
}

double Point::getYCoord() {
   return yCoord;
}

// calculate distance
double Point::distanceTo(const Point& p2) {
  double dx = p2.xCoord - xCoord;
  double dy = p2.yCoord - yCoord;
  return sqrt(dx * dx + dy * dy);
}

A:
p2.setXCoord(double);       // <-- error
p2.setYCoord(double);       // <-- error

double is a type, not a valid actual parameter name.
Call those functions with a value or a variable that is double or at least convertible to double.

A: double is a reserved keyword for the double type, it can't be passed to a function as an argument, you need to forward the actual values from the Point type.
void LineSegment::setEnd1(Point p1) {
   p1.setXCoord(p1.getXCoord());
   p1.setYCoord(p1.getYCoord());
}

A: double is a type specifier not an object. And why does for example setEnd1 call itself?
It seems you mean the following
//set and get points
void LineSegment::setEnd1(Point p1) {
   this->p1.setXCoord(p1.getXCoord());       // <-- error
   this->p1.setYCoord(pq.getYCoord());       // <-- error
}

void LineSegment::setEnd2(Point p2) {
   this->p2.setXCoord(p2.getXCoord());       // <-- error
   this->p2.setYCoord(p2.getXCoord());       // <-- error
}

You could write even simpler
//set and get points
void LineSegment::setEnd1(Point p1) {
   this->p1 = p1;
}

void LineSegment::setEnd2(Point p2) {
   this->p2 = p2;
}

And at least in the class Point all these member functions should be declared with qualifier const
double getXCoord() const;
double getYCoord() const;
double distanceTo(const Point&) const;

A: void LineSegment::setEnd1(Point p1) {
   p1.setXCoord(double);       // <-- error
   p1.setYCoord(double);       // <-- error
   setEnd1(p1);
}

LineSegment's set functions each take one argument of class Point. So when you give it a variable of type Point, you must save it as point.
void Point::setXCoord(double x) {
   xCoord = x;
}

This bit of your code is the template for what you want to do. Instead of type double, you want type Point for p1 and whatever the destination is called.