text:
Q: Genus of a topological surface I am not understanding the geometry of the actual definition of Topological genus of a surface.
In Wikipedia I have found the following definition:

The genus of a connected, orientable surface is an integer representing the maximum number of cuttings along non-intersecting closed simple curves without rendering the resultant manifold disconnected.It is equal to the number of handles on it.

I am unable to understand the geometry. Can someone please describe this?

A: This is probably best done with a sequence of examples.
On a sphere, any closed curve (read: loop) we cut along will disconnect the sphere:

I've shown this for one particular loop, but it's not hard to convince yourself it's true of any loop. So we can cut along $0$ loops without disconnected the sphere, making it genus $0$.
Next consider a torus. It's easy to find a loop which we can cut along so that the resulting surface is still connected, see here:

Of course, if we try to cut along any second loop, we will necessarily be left with a shape in two pieces.
Since we can cut along $1$ loop without disconnecting the shape, we say it has genus $1$.
Finally, let's consider a genus $2$ surface:

Again, you should convince yourself that any three cuts will result in multiple pieces, while here we were able to make $2$ cuts without disconnecting the surface. So this surface has genus $2$.
The case of higher genera (the plural of "genus") is similar.

Edit: Oh, and what does this have to do with handles? It turns out every (connected, oriented, compact) surface can be deformed into a sphere with handles. See this photo of a genus $3$ surface from wikipedia:

Notice we can make a cut in the middle of every handle while leaving the figure connected, but we can't cut anywhere else. This is some informal proof that the genus is equal to the number of handles your surface has.

I hope this helps ^_^

A: The genus of a connected, orientable surface is intuitively the number of "holes" in that surface. For instance: the sphere has genus 0, the standard torus has genus 1, etc. The Wikipedia page on Genus g surfaces has some nice visualisations.
In terms of the definition you've given, it's useful to consider that a "cutting" (under the conditions specified) would reduce a genus-n surface to a genus-(n-1) surface, either by cutting between two holes and joining them into one, or by cutting between a hole and the outside of the surface, eliminating that hole. Notice that any cutting on the sphere (the genus 0 surface) splits it into two connected components, rendering it disconnected.
We can then see that, for a genus g surface, it will take g cuttings to reduce it to the sphere, at which point any further cuttings will render it disconnected. This is effectively what your definition is trying to elucidate.


text:
Q: why i can't use projects of netbeans without netbeans? I've cloned a NetBeans made project from git to my IntelliJ and not the IntelliJ throws this error and doesn't run the programme.
Error:(126, 59) java: package org.netbeans.lib.awtextra does not exist

I've also searched for maven dependency of that as well, but IntelliJ says that the dependency isn't valid too.
to make the story short, I was basically wondering for an easy way to use NetBeans project on IntelliJ
thank you in advance :)

redpajama_set_name: RedPajamaStackExchange


text:
Q: Flexbox with multiline text ellipsis I've been using the white-space: no-wrap, text-overflow: ellipsis, and overflow: hidden CSS properties to create ellipsis truncation for multiline text. However, this doesn't work when using flexbox.
When using flex, text-overflow: ellipsis seems to truncate the height of the flex-item to a single line always.
Is it possible to use some combination of flex and css ellipsis truncation for multiline text?

long multiline text that i would like to truncate

I can get it working with single line truncation. Setting the height manually in conjunction with flex + white-space: nowrap doesn't work.

A: You can use this code for multiline truncation for ellipsis
.text-block-div {
  display: block;
  display: -webkit-box;
  max-width: 100%;
  height: 43px;
  margin: 0 auto;
  font-size: 14px;
  line-height: 1;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

You can use your text inside this div having class .text-block-div for ellipsis effect.
Note: The ellipsis effect requires webkit, which means if someone views it using a browser that does not support webkit then they will not see the ... but the text will still be cut off at the correct point, so this effect still works on all major browsers.


text:
Q: Why stage duration and amount report comes with multiple zeros when export it I am facing a very unusual problem. When I creates any report and add any number or currency field like stage duration, Age, Amount and export it in excel so all numbers fields come with additional unwanted zeros.
like if stage duration is 20 days so it's come as 20,000,000.
Kindly help how can I solve the issue.

A: Yes, Issue is solved just to change locale setting. by clicking on
Setup > Manage Users > Users > Edit Next to the Users Full name > Changed the locale > Save and exported the report and it was showing correctly.


text:
Q: Matching a variable with AWK this is my code:
awk -v header=$header '{if($0~/header/){if(i>0){printf "\n"$0}else{printf $0}}else{printf "\t"$0};i++}END{printf "\n"}' $1 > $basename1"_tab.tab"

However, it maches exactly 'header'' instead of the content of the variable. For example, if I set header='hola', I want the script to match hola instead of header.
Do you have any idea?
Thanks in advance.

A: You can use double quotes to use shell variable
Example 1#:
rahul@test-srv:~$ u=root
rahul@test-srv:~$ awk "/$u/" /etc/passwd
root:x:0:0:root:/root:/bin/bash

Example 2#
rahul@test-srv:~$ r=rahul
rahul@test-srv:~$ awk  '/'"$r"'/' /etc/passwd
rahul:x:1000:1000:rahul,,,:/home/rahul:/bin/bash

A: try this:
awk -v head="$header" '{if($0~head){if(i>0){printf "\n"$0.....

A: That is weird. If you change header to h it works!
header=hola; echo hola | awk -v h=$header '/h/{print "Matched"}'
Matched

header=hola; echo hola | awk -v header=$header '/header/{print "Matched"}'

And Kent's doesn't seem to work - which is definitely not what I would expect!!!
header=hola; echo hola | awk -v header="$header" '/header/{print "Matched"}'


text:
Q: How do you ensure accuracy of your query I am have a table with about 100,000 rows.
Lets suppose the primary key is some sequence of numbers like a barcode for example.
I am doing checks like
SELECT count(*) FROM TABLE WHERE LEFT(Barcode, 1)  is 0

I have about a 100 more rules to implement. They should ALL return 0 rows. But how do I ensure that they are returning 0 rows because the data is in fact correct OR that it is returning 0 rows because of a poorly written query.
I know that all my queries should return 0 since there are constraints that prevent bad data from getting in the first place but this is still needed by the company.

A: You can do this pretty easily using SUM and CASE:
SELECT
    COUNT(*) as 'Total Rowcount',
    SUM(CASE WHEN LEFT(BARCODE, 1) = 0 THEN 1 ELSE 0 END) as 'Leading Zero Barcode',
    SUM(CASE WHEN LEFT(Foo, 1) = 'X' THEN 1 ELSE 0 END) as 'Leading X in Foo'
....

Then you get a number for the WHOLE table/query, and a breakdown of each category, all on the same line.  It'll be easy to see if you have a bad query since you'll get a low/high rowcount or something else.
This has the added advantage or processing more efficiently than a bunch of separate queries, since you just evaluate the whole table once.

A: Take care with nulls and never forget that SQL's three-valued logic is treats constraints differently i.e.
P(row)  | WHERE P(row) | CHECK(P(row))
--------+--------------+-------------------------
TRUE    | Row accepted | Row satisfies constraint
FALSE   | Row rejected | Row violates constraint
UNKNOWN | Row rejected | Row satisfies constraint   <-- careful here!

My personal approach is the write a SELECT * FROM query and add columns returning a ternary value for each constraint:
SELECT T.*,
       CASE
          WHEN     ( LEFT(Barcode, 1) <> 0 ) THEN 'TRUE'
          WHEN NOT ( LEFT(Barcode, 1) <> 0 ) THEN 'FALSE'
          ELSE 'UNKNOWN'
       END AS result__Barcode__first_char_cannot_be_0,
       CASE
          WHEN     ( LEFT(Foo, 1) <> 'X' ) THEN 'TRUE'
          WHEN NOT ( LEFT(Foo, 1) <> 'X' ) THEN 'FALSE'
          ELSE 'UNKNOWN'
       END AS result__Foo__first_char_cannot_be_X
 FROM YourTable AS T;

Alternatively:
SELECT T.*,
       CASE
          WHEN NOT ( LEFT(Barcode, 1) <> 0 ) THEN '{{violates constraint}}'
          ELSE '{{satisfies constraint}}'
       END AS result__Barcode__first_char_cannot_be_0,
       CASE
          WHEN NOT ( LEFT(Foo, 1) <> 'X' ) THEN '{{violates constraint}}'
          ELSE '{{satisfies constraint}}'
       END AS result__Foo__first_char_cannot_be_X
 FROM YourTable AS T;

These results can be used for further analysis e.g. tally failure modes, tally failures per failure mode, (tally of) rows that satisify all constraints, (tally of) rows that fail at least one constraint, etc.
Consider using a unit test framework such as tSQLt to add data that would otherwise violate constraints that are actually in force (FakeTable command in tSQLt): if your query doesn't highlight this data then you need to rewrite your query!
p.s. ensure you do not waste time testing the DBMS itself. If the constraint is declared and in force (not deferred, not in NO CHECK mode, etc) then you should trust the DBMS. By all means query the INFORMATION SCHEMA to ensure an expected key exists on the required columns but there is simply no point in testing that the values comprising the key are actually unique: if they weren't then the DBMS would have a serious bug and we'd all know about it!

A: Your question is a little vague, but would two queries per rule get you there?  For your example, perhaps make sure the count returned without the WHERE criteria is greater than 0?
Also, the code you have provided is incorrect.  Not sure if you meant = instead of is or quotes around the 0 or what...


text:
Q: Django ORM, filter data from 3 different table there are 3 models, how to form a request to retrieve all LocationCompany with a specific city or sector, + DomainService domain + Service service_type, name
    name = models.CharField(max_length=20, blank=True, null=True)
    service_type = models.ForeignKey(Service_type, on_delete=models.CASCADE)
    price = models.DecimalField(max_digits=10, decimal_places=0)
    slug = models.SlugField(max_length=30)

class DomainService(models.Model):
        domain = models.CharField(max_length=30)
    sercices = models.ManyToManyField(Service, blank=True)
    title = models.CharField(max_length=200, blank=True)
    short_description = models.CharField(max_length=500, blank=True)
    long_description = models.CharField(max_length=1000, blank=True)
    specialization = models.ForeignKey(SpecializationService, on_delete=models.SET_NULL, blank=True, null=True)
    slug = models.SlugField(max_length=30)

class LocationCompany(models.Model):
    company = models.ForeignKey(MyUser, on_delete=models.CASCADE, blank=True, null=True)
    doctors = models.ManyToManyField(MyUser, blank=True, related_name='company_doctors')
    domain = models.ManyToManyField(DomainService, blank=True)
    city = models.CharField(max_length=30)
    sector = models.CharField(max_length=30, blank=True, null=True)
    street = models.CharField(max_length=30, blank=True, null=True)
    google_maps_link = models.CharField(max_length=500, blank=True, null=True)
    slug = models.SlugField(max_length=30)
    slug_sector = models.SlugField(max_length=30)```

A: Something like:
from django.db.models import Q

location_companies = LocationCompany.objects.filter(
    Q(city='some city') | Q(sector='some sector'), # or query for city or sector
    domain__domain = 'some domain',
    sercices__name = 'some service',
    sercices__service_type = 'some service type',
).distinct() # add this to ensure uniqueness

Note, best practice is to give your model relations more intuitive names, for example:
class LocationCompany(models.Model):
    domain_services = models.ManyToManyField(
        DomainService,
        ...,
        related_name = 'location_companies'
    )

This then changes the above query to something like:
location_companies = LocationCompany.objects.filter(
    domain_services__domain = 'some domain',
    ...
)


text:
Q: How do I check a table to see if a string is already in use? I am using this code to check my username column (username is primary) in my userdb table to see whether or not the string is already there. If it isn't there then it adds the string entered from a previous form into the username column in my table. But if it is there then it says "(Username) is already in use!".
This works when I put an entry in the username column such as "Sam" and then when I enter Sam into the previous form. But if I have "Sam" in the username column and then enter sam with all lowercase into the previous form, it displays Duplicate entry 'sam' for key 1.
I just want it to say that the string is already in use no matter what kind of casing I enter into the previous form.
$result = mysql_query("SELECT username FROM userdb") or die(mysql_error());
$row = mysql_fetch_array( $result );
$checkuser = $row['username'];

if ( $checkuser == $username ) {
    echo "" .$username. " is already in use!";
    die(mysql_error());
} else {
    mysql_query("INSERT INTO userdb (username, password) VALUES('$username', '$password' ) ") or die(mysql_error());;
    echo "Data Inserted!";
}

A: You shouldn't do it this way, because it can lead to race conditions. That's what happens if, between your check and your insert, somebody else inserts that username into the table.
The correct way to do it is to have a primary key on the username and insert the record, catching an exception or error code returned from the DBMS.
If the username is already in there, it won't be inserted again and you'll catch the error.
If it's not there, it will be inserted and you'll get no error.
In terms of your casing problem, I'd either convert all user names to lowercase before insertion or checking, or insert the mixed-case version and lower-case both the DB copy and local copy in all checks.

A: Change the code to:
strtolower($checkuser) == strtolower($username)

A: $result = mysql_query("SELECT count(*) FROM userdb where UCASE(username)=UCASE($checkuser);"

Check the number of rows in the result.
Pseudocode:
If num_rows>0
    Username exists;

A: The short answer is:
If you want the usernames to be case-insensitive, you need to store them in the database in a case-insensitive manner. Convert the given username to all lower-case (or all upper-case) first.
$lcusername = strtolower($username);

Then use $lcusername wherever you use $username in the code you supplied.
The long answer is:
You don't need to check for the pre-existence of a key in a table. Assuming you have a PRIMARY KEY attribute on the username field, simply try to your data into the table (after converting it to lower-case). If the database returns a "duplicate key" error, you know the username already existed and you can display the error message. If the database returns that it successfully inserted the row (perhaps by using the mysql_affected_rows function). This saves you from having to do a SELECT before doing the INSERT, greatly simplifying your code.
You should also escape all the strings that you'll be inserting into the table to help avert potential security holes.
$lcusername = strtolower($username);

// Escape strings
$esclcusername = mysql_real_escape_string($lcusername);
$escpassword = mysql_real_escape_string($password);

mysql_query("INSERT INTO userdb (username, password) VALUES('$esclcusername', '$escpassword') ");
if (mysql_affected_rows() == -1) {
    // Display error message
} elseif (mysql_affected_rows() == 1) {
    // Yay! Insert successful
} else {
    // Affected rows is 0. Something went wrong
}

A: The only way to do this correctly and avoid race conditions* is attempt to insert the user's data and examine any errors to see if the error is a duplicate key error. If you were using PDO (you should be) it would throw an exception which you could catch and examine. I think you can still trap and examine errors using PHP's standard error handling, I'm just not sure how.
*The race condition here is this:

*

*Check user name is unique, it is.

*Another user creates an account with that username

*You now attempt to create an account with that username for the original user, which causes an error.


text:
Q: How to replace the values of columns with conditions in python DataFrame? I have a DataFrame. How can I replace the values of Returns according to values of other columns?
the conditions are below:
if:Returns > Very_bullish, then Returns=2;
if:Returns > Very_bullish, then Returns=2;
if:Very_bullish > Returns > bullish, then Returns=1;
if:bullish >Returns >bearish,then Returns=0;
if:bearish > Returns > Very_bearish, then Returns=-1;
if:Very_bearish > Returns,then Returns=-2;

A: I think you need this =)
pandas.DataFrame.apply
Some examples of apply

A: There are many ways to do this, I find np.select easier to understand.
Simply we can specify multiple conditions in a list format.
import numpy as np

conditions  = [df['Returns'] > df['Very_bullish'],
               df['Very_bullish'] > df['Returns'] > df['bullish'],
               df['bullish'] > df['Returns'] > df['bearish'],
               df['bearish'] > df['Returns'] > df['Very_bearish'],
               df['Very_bearish'] > df['Returns']
               ]
choices     = [2, 1, 0,-1, -2]

df["Returns"] = np.select(conditions, choices, default=np.nan)

Here, anything that doesn't match any of the conditions will be replaced by np.nan.


text:
Q: Let $F$ be the set of infinite vectors $(a_0, a_1, ...)$ satisfying $a_i + a_{i+1} = a_{i+2}$ for all $i \geq 0$. Show that $F$ is a vector space. Here is my thinking. To show it's a vector space, we need to show that $(F, +)$ is an abelian group, and the other general axioms that make something a vector space. However, the way the operation is defined doesn't make much sense to me. It's obviously closed under addition, and addition is obiviously commutative, but how can I show
$\begin{align*}
(a_i + a_{i+1}) + a_{i +2} = a_i + (a_{i+1} + a_{i+2})\\
a_{i+2} + a_{i +2} = ?
\end{align*}$
I guess the notation is really screwing with me here.
Also, it has several follow up questions:
(a) What is a basis for F?
*Here I know that I need to find a set of vectors so that any element in the set can be expressed as a linear combination of these vectors.
(b) Find 2 linearly independent geometric series $v_i = ( 1, \lambda_i , \lambda_i^2,...)_{i\in \{1,2\}}$ in F.
*I have no clue how to approach this.
(c) Find the coordinates of the vector $(1,1,2,3,...)$ w.r.t. the basis $(v_1, v_2)$.
*This looks strangely reminiscent of the Fibonacci Sequence.
I apologize for the length of the question, but any help would be great.

A: For the first part, you'll want to carefully distinguish between the addition in your underlying field and the addition in your vector space. While it is not entirely clear from your question, I presume that your vector space addition is defined pointwise.
So you have:
$(a_0, a_1, a_2, \ldots) + (b_0, b_1, b_2, \ldots) = (a_0 + b_0, a_1 + b_1, \ldots)$
Now you assume that both the $a_i$ and the $b_i$ satsify the criterion, and proceed to show that it applies to $(a_i + b_i)$ - which, as you've written boils down to $+$ being associative and commutative.
(Edited) For the second part, start with solving $1 + x = x^2$, and see where your solutions get you. To figure out how large the basis ought to be, think about how many degrees of freedom you have in principle to built an element of this vector space.
For the third part, yes, that is the Fibonacci sequence.


text:
Q: Associated values from two different file I have a vector of vector. I'd like to read its first components and delete it from the vector if it is less than a specific value or if it is bigger than another value. How can I do this?
My code is:
int d = sum_et.size();
vector <float>sum_et
vector <float>sum_ieta_iphi;
vector <vector<float> >v;
sum_et.push_back(energySum);
sum_ieta_iphi[0]=energySum;
sum_ieta_iphi[1]=ieta;
sum_ieta_iphi[2]=iphi;
v.push_back(sum_ieta_iphi);
float max,min;
max=sum_et[(int)(19/20*d)];
min=sum_et[(int)(d/20)];

for (int i=0;i<v.size();i++){
/* line 312 */  if (v[i[0][0][0]]<min || v[i[0][0][0]]>max){
/* line 313 */      v.erase(v[i]);
  }
}

I get these errors:
Analysis.cc:312:16: error: invalid types 'int[int]' for array subscript
Analysis.cc:312:37: error: invalid types 'int[int]' for array subscript
Analysis.cc:313:14: error: no matching function for call to 'std::vector<std::vector<float> >::erase(std::vector<float>&)'

A: The problem is that you're indexing something (the integer variable i) that is not a vector.

There are also better ways to do this. Remember that C++ has many nice algorithms in the standard library, for example std::copy_if which copies from one collection to another if a predicate is true.
This can be used to copy the vector over itself:
std::copy_if(std::begin(v), std::end(v), std::begin(v),
             [v, min, max](const vector<float>& value)
             { return v[value[0]] >= min && v[value[0]] <= max; });

A: You are doing something strange here:
v[i[0][0][0]]

In particular i is a plain int, which gives the error for line 312 of "invalid types for array subscrit".
Beyond that, you have far to many [0] for this to work right, I think.

A: There are two problems in your code : i is an integer, so i[0][0][0] is a nonsense.
Plus, the function erase requires an iterator on the vector, not a value. (cf the reference)
If I'm not mistaking, you want to check the first element of each sub-vector, and if it matches the criteria, delete the sub-vectors.
As alexisdm pointed out in the comments, the for loop I suggested first misses out elements. It should be :

// We get an iterator on the first vector
vector<vector<float> >::iterator it = v.begin();
while(it != v.end())
{
    // We check the first element of the subvector pointed by the iterator
    if ( (*it).at(0) < min || (*it).at(0) > max)
    {
        // We erase the subvector of v and erase returns
        // an iterator to the next element
        it = v.erase(it);
    }
    else
    {
        // We go to next element
        it++;
    }
}

The first not working loop was :
// We get an iterator on the first vector
for(vector<vector<float> >::iterator it = v.begin(); it != v.end(); ++it)
{
    // We check the first element of the subvector pointed by the iterator
    if ( (*it).at(0) < min || (*it).at(0) > max)
    {
        // We erase the subvector of v
        it = v.erase(it);
    }
}


text:
Q: php: Keep select option after submit I have a type of grocery list where I want to able to add items from different stores.
Currently I have a form where I post the article number and quantity and then press submit to add the item to the grocery list (the table below).
<form action="<?php echo $current_file.$id; ?>" method="POST">

    Store:  <select>
                    <option value="gross1">Store 1</option>
                    <option value="gross2">Store 2</option>
                    <option value="gross3">Store 3</option>
            </select>

    Art no: <input type="text" size="15" name="number"  />

    Quantity: <input type="text" size="3" name="q" />

    <input type="submit" value="Add item" />

</form>

            Art no

            Article name

            Price

            Quantity

            Total

The stores item lists are stored in mysql tables so I want to choose the store (or the table if you so will) via a drop down select list. But the problem is, if the store I'm choosing items from isn't store 1, its going to pretty frustrating to select the store over and over again after every time I press submit.
I don't think I can use a script that uses some kind of GET variable to specify the selected store, because I already use GET to specify the selected grocery list. Is there another way to get the site to remember the selected store after a page refresh?
Thanks in advance!

A: In your php you would normally set SELECTED against the option based on the POSTed value. But you need to set a name on the select tag.
Have you tried searching google for any of this?

A: I had a similar problem and needed a quick solution.After selecting a value from the dropdown list and submitting, the page reloads which resets the dropdown list as was - without keeping the selected value (even though the selected value was sent ($_GET). For me the issue was purely aesthetic since I wanted the user to see the value they selected. Here is what I did:
// Change the parent dropdown selected value to the currently selected value
    $(window).load(function() {

        // Get url attributes which should contain the $_POST or $_GET value and split it. You have to refine this in case you have multiple attributes

        var str=window.location.href; var n=str.split("=");

         // This should be the selected value attribute
         var myAttrVal= n[1];

       // check all options and grab the value (or whatever other unique identifier you're using). Check this value against your url value and when they match, add the selected attribute to that option.
        $('#selectID option').each(function() {

            var selectedOptVal = $(this).attr('value');

            if ( myAttrVal  == selectedOptVal) {

                $(this).attr('selected', 'selected');
            }
        });

    });

I'm sure there are much better ways of doing this but I hope it gives you ideas on how to solve your problem.


text:
Q: C++: implicit conversions At first I saw a program on MSDN.
For example:
#include <iostream>

class Money
{
public:
    Money() : amount{ 0.0 } {};
    Money(double _amount) : amount{ _amount } {};

    double amount;
};

void display_balance(const Money balance)
{
    std::cout << "The balance is: " << balance.amount << std::endl;
}

int main(int argc, char* argv[])
{
    Money payable{ 79.99 };

    display_balance(payable);
    display_balance(49.95);
    display_balance(9.99f);

    return 0;
}

The explanation for it is:

On the second call to display_balance, the type of the argument, a double with a value of 49.95, is not the function expects, so a conversion is needed.

There is a conversion from the type of argument— double to Money, and what I don't know about it is why the implicit conversion happened.
Think about it more deeply, we assume that a function needs a type of object as a parameter, and the constructor of the object needs one parameter, when call to the function, whether can provide this parameter.

A:
[C++14: 5.2.2/4]: When a function is called, each parameter (8.3.5) shall be initialized (8.5, 12.8, 12.1) with its corresponding argument. [..]

Money can obviously be initialized from double because you wrote a constructor to do exactly that.
It is, however, possible to prohibit such implicit conversions by adding the explicit keyword to that constructor:
explicit Money(double _amount) : amount{ _amount } {};

Now you'd have to explicitly convert (or "cast") the double to a Money in the function call expression:
display_balance(static_cast<Money>(49.95));

A: i think this example will help:
int number;
double rate;
number =2;
rate=1.0345;
number=rate;
cout<<number<<endl; //implicit conversion //narrowing conersion //gives 1 //tried to store floating point number in integer data type variable
rate=2 // implicit conversion //widening conversion // value actually assigned is 2.0 //we are not ordering compiler to convert double data type to integer. it is automatically understood by compiler.

number=(int)rate; //explicit conversion //we are ordering compiler here to take value from rate and convert it to integer and assign it to number. //we are specific here.


text:
Q: UIImagePickerControllerDelegate has no member 'delegate' I'm trying to do a picker controller for the camera/photo library. The correct option come up but I can't get the details back from the picker.
I have it declared as
class Add: UITableViewController, UIImagePickerControllerDelegate {

    var imagePickerController : UIImagePickerController!

and in my view did load
override func viewDidLoad() {
    imagePickerController = UIImagePickerController()
    imagePickerController.delegate = self
}

I'm getting an when trying to set the delegate

Value of type '(UIImagePickerController,
  [UIImagePickerController.InfoKey : Any]) -> ()' has no member
  'delegate'

If I comment out the delegate line, the code compiles but function afterwards doesn't run
@objc func imagePickerController(_ picker: UIImagePickerController,
                           didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
    // Code
}

A: Add UINavigationControllerDelegate conformance to your Add ViewController:
class Add: UITableViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {


text:
Q: AngularJS Jasmine Unit Tests Select - getting option at index x On the angular site the have the following example of a unit test:
http://docs.angularjs.org/api/ng/directive/select
(note that you need to click the protractor.js button; there is no direct link to show the unit test code)
here is the snippet of interest:
element.all(by.select('color')).first().click();
element.all(by.css('select[ng-model="color"] option')).first().click();

Is there a way to get an element other than the "first()" when using "element.all()"?
I can't seem to find proper documentation on what can be done.

A: From the comments:
Judging by this part of the source exactly that code (get(x)) should work. Did you try it? The documentation of the method also has an example which is exactly what I said above.


text:
Q: Multiple rotation directions using CSS rotateX() I've got a simple display that flips over on click. I want to add a little bounce to the movement by rotating a few degrees in the opposite direction before rotating the full 180 degrees to reveal the opposite side.
RotateX() will accept more than one instance inline, but it calculates the end result and does not show both directions. ie:
transform: rotateX(-10deg) rotateX(190deg)
this results in the object rotating 180deg.
I've tried comma separating them, as well as just putting two sets of degress in the parens, with similar results.
I've tried putting both steps into @keyframes, but animation doesn't seem to work with my on-click event in javascript.
I've also tried having each direction of rotation in a separate class that are both activated via classlist.toggle, but still do not see both directions of rotation.
here's a codepen with the above mocked up:
https://codepen.io/Boreetos22/pen/WNrJEvR
I'd appreciate any insight. Thanks!

A: Transitions probably won't get what you want since you can't fake the bounce with multiple steps. @keyframes will work but you can't simply toggle the class. You need to add one and then add another to reset it.
Also, you'll need multiple animations (forward and back) that you change on over/out and click.

let sides = document.querySelector('.sides');
sides.addEventListener( 'click', function(e) {
  if(sides.classList.contains('flip-forward')){
    sides.classList.remove('flip-forward');
    sides.classList.add('flip-backward');
  }else{
    sides.classList.add('flip-forward');
    sides.classList.remove('flip-backward');
  }
});
* {
  padding: 0;
  margin: 0;
}

h2 {
  margin-top: 12px;
  font-size: 30px;
}

body {
  height: 100vh;
  width: 100vw;
  display: flex;
  justify-content: center;
  align-items: center;
}

.container {
  display: flex;
  justify-content: center;
  height: 60px;
  width: 400px;
  perspective: 1000px;
}

@keyframes myAnimationFwrd {
  /* has bounce */

    24% {
        transform: rotateX( -40deg)
    }

    36% {
        transform: rotateX( 0)
    }

    100% {
        transform: rotateX( 190deg)
    }

}
@keyframes myAnimationBkwrd {

 /* no bounce add more steps to enable */
    0% {
        transform: rotateX( 190deg)
    }

    100% {
        transform: rotateX( 0deg)
    }

}
.flip-forward {
  animation: myAnimationFwrd 1s forwards;
}
.flip-backward {
  animation: myAnimationBkwrd 1s forwards;
}

.sides {
  height: 100%;
  width: 100%;
  display: flex;
  justify-content: center;
  position: relative;
  transform-style: preserve-3d;
  cursor: pointer;
}

.red, .black {
  text-align: center;
  color: white;
  height: 100%;
  width: 100%;
  border-radius: 30px;
  box-shadow: 2px 2px 4px black;
  position: absolute;
  backface-visibility: hidden;
}

.red {
  background-color: darkred;
  z-index: 2;
}

.black {
  background-color: black;
  z-index: 1;
  transform: rotateX(180deg);
}

PLAYER ONE'S TURN

PLAYER TWO'S TURN


text:
Q: Can dataloader.io export files (not attachments)? As far as I can see in the documentation, dataloader.io only supports exporting Attachments rather than Files.
https://dataloader.zendesk.com/hc/en-us/articles/218984278
Based on this (What is the object that stores "files") it seems like ContentVersion.VersionData is the equivalent to Attachment.Body for downloading Files.
It looks to me like since ContentVersion is in the list for Dataloader.io. I can't test this myself as the user that I am accessing for this has limited access, so can't simply create a file.
Can anyone confirm that they have successfully exported Files from a Salesforce Org using the ContentVersion object?

A:
Hi @frackham, you can export the files using contentversion object but
  only problem is versiondata you will get is in blob datatype. But in
  attachment you are getting it as zip file. That's the difference. That
  you may be not wanting.


text:
Q: eclipse maven - Run on server - ClassNotFound I maven-build my application (has a single servlet) with 'clean install' and it creates war in target folder. If I copy it to webapps in tomcat and it works fine. But if I do Run on server it fails with ClassNotFoundException on the servlet.
Deployment assembly includes maven dependencies.


text:
Q: Spivak's proof of $a\cdot 0 = 0$ I picked up Spivak's Calculus (3rd Edition) today and it seemed like a good idea to go through the section Basic Properties of Numbers. In this chapter, Spivak proves that
$$a \cdot 0 = 0$$
The proof looks simple:
$$a \cdot 0 + a \centerdot 0 = a \centerdot (0+0) = a \centerdot 0$$
My question is just as simple: How do I get from $a \centerdot 0 = 0$ to $a \centerdot 0 + a \centerdot 0 = a \centerdot (0+0)$?

A: $$a \centerdot 0 + a \centerdot 0 = a \centerdot (0+0) = a \centerdot 0$$ by distributivity.
Then we have that $$2(a\cdot 0) = a\cdot 0$$
which implies that $$a\cdot 0 =0$$

A: I am reading pp 7 of Spivak's Calculus (3rd Edition) right now.
What he's trying to do is to prove: $$ a\cdot 0 = 0$$ using $$  a\cdot(b+c) = a\cdot b + a\cdot c \tag{P9}$$
Let $b,c = 0$. We have: $$ a\cdot 0 = a\cdot (0+0) = a\cdot 0 + a\cdot 0. $$ By adding $(-a\cdot 0)$ to both sides of $ a\cdot 0 = a\cdot 0 + a\cdot 0 $ we get $$ a\cdot 0 + (-a\cdot 0) = a\cdot 0 + a\cdot 0 + (-a\cdot 0) $$ i.e. $$ 0 =  a\cdot 0.$$

A: Since $0=0+0$, then $a\cdot 0 = a\cdot (0+0)$.
Since $\cdot$ distributes over $+$, whenever we have $x\cdot (b+c)$, this is equal to $x\cdot b + x\cdot c$. Applying this to $a\cdot(0+0)$, we get
$a\cdot (0+0) = a\cdot 0 + a\cdot 0$.
So:
$$\begin{align*}
a\cdot 0 + 0 &=a\cdot 0 &\text{(because }x+0=x\text{ for all }x\text{)}\\
&= a\cdot (0+0) &\text{(because }0=0+0\text{)}\\
&= a\cdot 0 + a\cdot 0 &\text{(because }\cdot\text{ distributes over }+\text{)}
\end{align*}$$
So we have $a\cdot 0 + 0 = a\cdot 0 + a\cdot 0$. Cancelling one $a\cdot 0$ (or adding $-(a\cdot 0)$ to both sides) we conclude that $0=a\cdot 0$.

A: That $a\cdot 0 + a\cdot 0 = a\cdot (0+0)$ is just using the distributive law. (From here you get $a\cdot (0+0) = a\cdot 0$ and then you just subtract $a\cdot 0$ on both sides.

A: You don't.  He's not assuming $a \cdot 0 = 0$.  He's proving that.  So, you don't get from that to $a \cdot 0 + a \cdot 0 = a \cdot (0 + 0)$.  How you do get that last statement is the distributive property.  He then uses the property that 0 plus anything is that anything.  In particular, $0 + 0 = 0$.  Once you have that, we have $a \cdot 0 + a \cdot 0 = a \cdot 0$.  Now, we use the fact that every number has an additive inverse, so we can add that to both sides, which is the same as subtracting $a \cdot 0$ from both sides.  This leaves us with $a \cdot 0 = 0$.


text:
Q: How to open toc automatically when open a .ipynb file in jupyterlab? When I open a file in jupyterlab. The left sidebar will disappear the file browser.
file browser
But I want to open the toc.
I try to write a javascript to simulate click the toc button in sidebar, but it doesn't work.
There are any configuration or script can open toc?

A: JupyterLab 4.0 will include toc:show-panel command, and in earlier versions you can activate ToC using activateById() method from JupyterFrontEnd.IShell interface using table-of-contents identifier.
You can try it out on jupyterlab-plugin-playground with the following code:
import { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application';
import { NotebookPanel, INotebookTracker } from '@jupyterlab/notebook';

const plugin: JupyterFrontEndPlugin<void> = {
  id: 'toc-show:plugin',
  autoStart: true,
  requires: [INotebookTracker],
  activate: (app: JupyterFrontEnd, notebookTracker: INotebookTracker) => {
    alert('TOC-show extension activated!'); // you can remove this
    notebookTracker.currentChanged.connect((_: any, notebookPanel: NotebookPanel | null) => {
      if (notebookPanel) {
        // JupyterLab 3.x:
        app.shell.activateById('table-of-contents');
        // JupyterLab 4.0+:
        // app.commands.execute('toc:show-panel');
      }
    });
  },
};

export default plugin;

For packaging/installing it as a permanent extension you can follow the JupyterLab extension tutorial.
In future it might be possible to recreate this functionality from ipylab but currently it does not implement signal handlind.


text:
Q: Program with SPI_SETDESKWALLPAPER Function Only Changes the Desktop Background to the Color Black when Trying to Change it to an Image using C++ I am trying to change the desktop background/wallpaper to a different image with a .png file. Although when I run the program, the background turns to solid black instead.
I am certain that I typed the file name, "ksa.png", correctly in my code to be the image I want to be on my background. I used an if condition to write out the last error on a file when the error occurred and used an else condition to write out "Success" if no errors occurred; but when I run the program, it writes "Success" to the file. I have thought about using a .jpg file instead, thinking that maybe .png files just don't work. I'll give an update when I tried using that.
#include <windows.h>
#include <fstream>

int main () {
    const wchar_t *filenm = L"ksa.png";
    std::ofstream log;
    if (SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, (void*)filenm, SPIF_UPDATEINIFILE) == FALSE) {
        log.open("log.txt");
        log << "Error: " << GetLastError();
        log.close();
    }
    else {
        log.open("log.txt");
        log << "Success";
        log.close();
    }
    return 0;
}

When I run this program, the desktop background is suppose to be set as the image "ksa.png". Instead it's solid black. Any help is appreciated for making this work, thank you.
UPDATE
Okay so I updated the code to where it would run a .jpg file and I'm still getting the same result. Also I moved the line log.open("log.txt") command before the SystemParametersInfo() function like Remy Lebeau suggested and it still writes out "Success" to the file. I'm still having the same problem.
Here is my updated code:
#include <windows.h>
#include <fstream>

int main () {
    const wchar_t *filenm = L"3.jpg";
    std::ofstream log;
    log.open("log.txt");
    if (SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, (void*)filenm, SPIF_UPDATEINIFILE) == FALSE) {
        log << "Error: " << GetLastError();
        log.close();
    }
    else {
        log.open("log.txt");
        log << "Success";
        log.close();
    }
    return 0;
}

A: Emmmm,there is a problem with your picture path. I've tried your code. You can't get pictures under relative paths unless you use absolute paths.
Like Cody Gray♦'s judgment .
const wchar_t *filenm = L"C:\\Users\\strives\\Desktop\\timg.bmp";


text:
Q: Spring Session not setting X-Auth-Token, JSESSIONID still present I'm trying to figure out why Spring Session isn't setting the session header and is still setting the JSESSIONID. Also, I'm trying to determine why my test doesn't get the JSESSIONID that the browser does. I'm not trying to use redis, just the in memory store.
@RestController
@SpringBootApplication
public class Application {

    @RequestMapping( "/" )
    public String greeting() {
        return "hello";
    }

    @Configuration
    @Order( SecurityProperties.ACCESS_OVERRIDE_ORDER )
    protected static class SecurityConfiguration extends WebSecurityConfigurerAdapter {

        @Bean
        static SessionRepository<? extends ExpiringSession> repository() {
            return new MapSessionRepository( );
        }

        @Bean
        static HttpSessionStrategy httpSessionStrategy() {
            return new HeaderHttpSessionStrategy();
        }

        @Autowired
        void globalUserDetails( final AuthenticationManagerBuilder auth ) throws Exception {
            auth.inMemoryAuthentication().withUser( "admin" ).password( "admin" ).roles( "USER", "ADMIN" );
        }

        @Override
        protected void configure(HttpSecurity http) throws Exception {
            http.httpBasic()
                    .and()
                    .authorizeRequests()
                    .anyRequest().authenticated();
        }
    }

    public static void main( final String[] args ) {
        SpringApplication app = new SpringApplication( Application.class );
        app.setShowBanner( false );
        app.run( args );
    }
}

and a test class
@RunWith( SpringJUnit4ClassRunner.class )
@WebAppConfiguration
@SpringApplicationConfiguration( classes = { MockServletContext.class, Application.class } )
public class ApplicationTest {

    private MockMvc mockMvc = null;
    private MockHttpServletRequestBuilder requestBuilder;
    @Autowired private WebApplicationContext context;
    @Autowired private FilterChainProxy springSecurityFilterChain;

    @Before
    public void setup() {
        mockMvc = MockMvcBuilders.webAppContextSetup( context )
                .addFilter( springSecurityFilterChain )
                .build();

        requestBuilder = get( "/" )
                .header( "Authorization", "Basic " + Base64.getEncoder().encodeToString( "admin:admin".getBytes() ) );
    }

    @Test
    public void getSessionToken() throws Exception {
        this.mockMvc.perform( requestBuilder )
                .andExpect( status().is2xxSuccessful() )
                .andExpect( header().string( "X-Auth-Token", notNullValue() ) );
    }

    @Test
    public void getJessionId() throws Exception {
     // response does not agree with an actual browser request which has a JSESSIONID
        this.mockMvc.perform( requestBuilder )
                .andExpect( status().is2xxSuccessful() )
                .andExpect( cookie().doesNotExist( "JSESSIONID" ) );
    }
}

these are the response headers chrome has when I login at  /
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Set-Cookie: JSESSIONID=6D7E2CB0AAFDD3B5DB53BA77C0725750; Path=/; HttpOnly
Content-Type: text/html;charset=UTF-8
Content-Length: 5
Date: Fri, 29 May 2015 01:16:33 GMT

and lastly here's my pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.xenoterracide</groupId>
    <artifactId>spring-session-test-case</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <!-- use UTF-8 for everything -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <parent>
        <groupId>io.spring.platform</groupId>
        <artifactId>platform-bom</artifactId>
        <version>1.1.2.RELEASE</version>
    </parent>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.session</groupId>
            <artifactId>spring-session</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>

why am I not getting the X-Auth-Token header instead of the JESSIONID Cookie? and why doesn't my test say that I'm getting the JSESSIONID cookie?

A: You need to add configuration class doing three things:

*

*Enabling SessionRepositoryFilter (this is done by @EnableSpringHttpSession annotation)

*Providing bean implementing HttpSessionIdResolver interface - in your case HeaderHttpSessionIdResolver

*Because @EnableSpringHttpSession requires providing SessionRepository - it needs to provide a bean implementing this interface as well (MapSessionRepository used in example below)

Sample configuration:
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.session.MapSessionRepository;
import org.springframework.session.config.annotation.web.http.EnableSpringHttpSession;
import org.springframework.session.web.http.HeaderHttpSessionIdResolver;
import org.springframework.session.web.http.HttpSessionIdResolver;

import java.util.concurrent.ConcurrentHashMap;

@Configuration
@EnableSpringHttpSession
public class HttpSessionConfig {

    @Bean
    MapSessionRepository sessionRepository() {
        return new MapSessionRepository(new ConcurrentHashMap<>());
    }

    @Bean
    public HttpSessionIdResolver httpSessionIdResolver() {
        return HeaderHttpSessionIdResolver.xAuthToken();
    }
}

A: All you need is to define proper HttpSessionIdResolver implementation. By default spring-session uses CookieHttpSessionIdResolver.
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.session.web.http.HeaderHttpSessionIdResolver;
import org.springframework.session.web.http.HttpSessionIdResolver;

@Configuration
public class SessionConfig {

    @Bean
    public HttpSessionIdResolver httpSessionIdResolver() {
        return HeaderHttpSessionIdResolver.xAuthToken();
    }
}

At least it works for Spring Boot 2.2.5.RELEASE.


text:
Q: Basic sp-gist indexing? Please forgive a very, very elementary question.
I am using a PostgreSQL 9.3.5 database, and one of the tables stores longitude and latitude.  (These are two separate columns.)  I would like to do efficient searches of the form "find all rows with (latitude,longitude) within 20 km of a given point".
I understand that this version of PostgreSQL has an "sp-gist" indexing method for addressing exactly this sort of situation.  However, I can't seem to find an example or tutorial of how I go about actually building the index.  In particular, are (latitude,longitude) distance handled natively, or am I somehow supposed to provide my own C code to implement the haversine formula?  Do I need to convert the (latitude,longitude) into some sort of joint spatial variable?

A: AFAIK you want to use a regular GIST index (PostGIS has a special R-Tree index on top of GIST).
Usually it's easier to have one column represent your lat/longs. See http://postgis.net/docs/manual-1.5/ch04.html#PostGIS_Geography
For indexed radius search see ST_DWithin


text:
Q: Why does import a.b.c run __init.py__ while from a.b.c import does not? Consider this simple Python package structure (where each __init__.py just prints the containing directory name and test.py prints 'test'):
a
├── __init__.py
└── b
    ├── __init__.py
    └── c
        ├── __init__.py
        └── test.py

Now if I import test two different ways I get completely different results:
>>> import a.b.c.test
a
b
c
test
>>> from a.b.c import test
>>>

Why are __init__.py files not run in the second case? Where is this documented?


text:
Q: Conversion from Standard Ellipse Function to General Ellipse Function I wonder if anyone can assist/show me how to complete this task...
I have the following equation which models a dual axis magnetic field:
$$\begin{equation} B_{H}^2 = B_x^2 + B_y^2 \tag{1}\end{equation}$$
Where $ B_{H}^2 $ is the 'ideal' earths magnetic field, $ {B}_{x}, {B}_{y} $ are the 'ideal' x and y axis mag. field values.
Now, the 'actual' measured fields can be given by:
$$\begin{equation} \hat{B}_x = aB_x + x_0   \tag{2}\end{equation}$$
$$\begin{equation} \hat{B}_y = b\left(B_y\cos{(p)} + B_x\sin{(p)}\right) + y_0\tag{3} \end{equation}$$
Where, $ a, b $ are scaling factors for each axis, $ p $ is an angular offset and $ x_0, y_0 $ are bias offset values.
Now, solving for $ B_x $ in $ (2) $ gives:
$$ B_x = \left(\frac{\hat{B}_{x} - x_{0}}{a}\right) $$
Plugging into $ (3) $ and solving for $ B_y $ gives:
$$ B_y = \frac{\left(\frac{\hat{B}_y - y_0}{b} - \frac{\left(\hat{B}_x - x_0\right) * \sin{(p)}}{a}\right)}{\cos{(p)}} $$
Which simplified gives:
$$ B_y = \frac{\left(a\hat{B}_y + ay_0 + \hat{B}_x\sin{(p)}b - \sin{(p)}b^2\right)}{ab\cos{(p)}} $$
Plugging $ B_x, B_y $ into $ (1) $ gives:
$$ B_{H}^2 = \left(\frac{\hat{B}_{x} - x_{0}}{a}\right)^2 + \left(\frac{\left(a\hat{B}_y + ay_0 + \hat{B}_x\sin{(p)}b - \sin{(p)}b^2\right)}{ab\cos{(p)}}\right)^2 $$
Now this is the bit I can't seem to figure out...  Apparently this can written in the form of a shifted, distorted ellipse with the general ellipse form:
$$ A\hat{B}_x^2 + B\hat{B}_x\hat{B}_y + C\hat{B}_y^2 + D\hat{B}_x + E\hat{B}_y + F = 0 $$
Can anyone point me in the right direction as to how to do this?  I've been trying all day with zero success, I could put my attempts here but I would be here all day!  I think it's the reversal of Completing the Squares but I'm not 100% sure.
Any help appreciated,
Thankyou.
Carrying on from the above and based upon Grahams observation.
Subtract $ B_H^2 $ from both sides gives:
$$ \left(\frac{\hat{B}_{x} - x_{0}}{a}\right)^2 + \left(\frac{\left(a\hat{B}_y + ay_0 + \hat{B}_x\sin{(p)}b - \sin{(p)}b^2\right)}{ab\cos{(p)}}\right)^2 - B_H^2 = 0 $$
Removing the denominators gives:
$$ \left(\hat{B}_x-x_0\right)^2\left(ab\cos(p)\right)^2 + a^2\left(a\hat{B}_y+ay_0+\hat{B}_x\sin(p)b-\sin(p)b^2\right)^2-B_H^2a^2\left(ab\cos(p)\right)^2 = 0 $$
Expanding the first term $ \left(\hat{B}_x-x_0\right)^2\left(ab\cos(p)\right)^2 $ gives:
$$  \left(\hat{B}_x^2-2\hat{B}_xx_0+x_0^2\right)\left(ab\cos(p)\right)^2 = \hat{B}_x^2\left(ab\cos(p)\right)^2-2\hat{B}_xx_0\left(ab\cos(p)\right)^2+x_0^2\left(ab\cos(p)\right)^2 \qquad\qquad\mathbf{(4)}$$
Expanding the second term gives:
$$ a^2\left(\left(a\hat{B}_y+ay_0+\hat{B}_x\sin(p)b-\sin(p)b^2\right)\left(a\hat{B}_y+ay_0+\hat{B}_x\sin(p)b-\sin(p)b^2\right)\right) \\
= a^2\left(a^2\hat{B}_y^2+a^2y_0\hat{B}_y+\hat{B}_y\hat{B}_xab\sin(p)-\hat{B}_yab^2\sin(p)+\hat{B}_ya^2y_0+a^2y_0^2+\hat{B}_x^2aby_0\sin(p)-ab^2y_0\sin(p)+\hat{B}_x\hat{B}_yab\sin(p)+\hat{B}_xaby_0\sin(p)+\hat{B}_x^2\sin^2(p)b^2-\hat{B}_xb^3\sin^2(p)-\hat{B}_yab^2\sin(p)-ab^2y_0\sin(p)-\hat{B}_xb^3\sin^2(p)+\sin^2(p)b^4\right) $$
Collecting the terms and multiplying by $ a^2 $ gives:
$$ \hat{B}_x^2\left(a^2b^2\sin^2(p)\right)+\hat{B}_x\hat{B}_y\left(2a^3b\sin(p)\right)+\hat{B}_y^2\left(a^4\right)+\hat{B}_x\left(2a^3by_0\sin(p)-2a^2b^3\sin^2(p)\right)+\hat{B}_y\left(2a^2y_0-2a^2b^2\sin(p)\right)+a^4y_0^2-2a^3b^2y_0\sin(p)+a^2b^4\sin^2(p)\qquad\qquad \mathbf{(5)}$$
Combining $ \mathbf{(4)}, \mathbf{(5)},  $ and $ -B_H^2a^2\left(ab\cos(p)\right)^2 $ gives:
$$ \hat{B}_x^2\left(a^2b^2\right)+\hat{B}_x\hat{B}_y\left(2a^3b\sin(p)\right)+\hat{B}_y^2\left(a^4\right)+\hat{B}_x\left(2a^3by_0\sin(p)-2a^2b^3\sin^2(p)-2a^2b^2x_0\cos^2(p)\right)+\hat{B}_y\left(2a^2y_0-2a^2b^2\sin(p)\right)+a^4y_0^2-2a^3b^2y_0\sin(p)+a^2b^4\sin^2(p)+x_0^2\left(ab\cos(p)\right)^2-B_H^2a^4b^2\cos^2(p) $$
So finally, we have:
$$ A=a^2b^2 \\
B=2a^3b\sin(p) \\
C=a^4 \\
D=2a^3by_0\sin(p)-2a^2b^3\sin^2(p)-2a^2b^2x_0\cos^2(p) \\
E=2a^2y_0-2a^2b^2\sin(p) \\
F=a^4y_0^2-2a^3b^2y_0\sin(p)+a^2b^4\sin(p)+x_0^2\left(ab\cos(p)\right)^2-B_H^2a^4b^2\cos^2(p) $$
After tidying up a little gives:
$$ A=b^2 \\
B=a\left(2b\sin(p)\right) \\
C=a^2 \\
D=\left(2aby_0\sin(p)-2b^3\sin^2(p)-2b^2x_0\cos^2(p)\right) \\
E=\left(2y_0-2b^2\sin(p)\right) \\
F=\left(a^2y_0^2-2ab^2y_0\sin(p)+b^4\sin(p)+x_0^2b^2\cos^2(p)-B_H^2b^2\cos^2(p)\right) $$
Does this look ok?


text:
Q: Inverse Z Transform with $2-z^{-2}$ How do I find the inverse z transform for:
$$Y[z]=\frac{2-z^{-2}}{(1-.5z^{-1})(1-.2z^{-1})}$$
I believe I need to use partial fractions but everytime I try it I get stuck.
Thanks for help.

A: Hint:
Setting $z^{-1}=x,$
we can write
$$Y[z]=a+\dfrac b{1-.5z^{-1}}+\dfrac c{1-.2z^{-1}}$$
Now $Z\{b^n\}=?$

A: $$Y(z) = \frac{10(2z^2 - 1)}{(2z-1)(5z-1)}$$
Here you have to see that Degree of Numerator and Denominator are same hence during partial fraction you will have to consider a constant term A
$$Y(z) = A + \frac{B}{2z-1} + \frac{C}{5z-1}$$
Now find the A,B and C
$$A = 2 ; B = -\frac{10}{3} ; C = \frac{46}{3}$$
$$Y(z) = 2 - \frac{5}{(3)(z-\frac{1}{2})} + \frac{46}{(15)(z - \frac{1}{5})}$$
$$y(n) = 2\delta(n) - [ \frac{5(.5^n-1)}{3} - \frac{46(.2^n-1)}{15}] u(n-1)$$


text:
Q: Should i use public/private key encryption in this case? I have an iPhone app and a backend php web app.
The php site stores some information and i have to use the iPhone app to retrieve that data and show it in it.
So, suppose the iphone app has to show a list of houses for a given user, it would call the folllowing php script
http://example/process.php?user=300
That script makes the sql query and returns an xml with the houses' data.
Should i at any point encrypt anything to prevent spoofing?
Another case, for example admob for each app generates a "publisher id" that is used in the iphone app to "connect" the app with the web app, is that "publisher id" used as a private key to encrypt/decrypt the data sent/received?
Thanks

A: Does the user have to authenticate? If so, it would be better to generate a token on the server after the authentication step, and use that token in subsequent webservice calls.
e.g.:
http://example/login.php?login=xxx&pw=yyyy
=> returns token 80a8b97c0c8941e1b290bdf33f3124de  if successful
Then instead of passing a user id, pass the token:
http://example/process.php?token=80a8b97c0c8941e1b290bdf33f3124de


text:
Q: how do one determine the number of concurrent users that a web application can handle? As far as what I know , I think apache web server handles multiple requests through a combination of multi-processing and multi-threading. Want to know for a php application running a webserver is it just the apache which decides the concurrent users it can handle or it also depends on the php application. If yes, then to what extent?

A: There's only one way to know, by testing under real load.
Basically you setup multiple client 'bashers' that are scripted to behave like real users but can run lots of sessions concurrently. Do this for a long enough period, measure load (cpu, mem, network, storage), look for where things break - there's usually a quite clear load point over which you start getting truncated sessions, timeouts etc. - that's your server's limit.
You can guess and get close but it'll only ever be a guess until you've tested.
Oh and by the way, there are lots of external companies out there who specialise in testing for you.

A: http_load, siege, jmeter, ab are all tools that can allow you to do some simulation of load.  However, without writing some complicated scripting, you aren't really testing things well.  While Ian Bicking mentioned this more for wsgi testing, the same issues come up when dealing with webapps.
When you benchmark, are you using a local connection where every test is considered a fast client?  Are they doing posts, slow uploads, hitting pages you didn't anticipate, testing your authentication mechanism, losing cookies, etc?
Your webserver plays a pretty big part of the bottleneck, but, your application code, how it is written, how it interacts with the database, how the database reacts to the queries, updates, etc all come into play.  Things that you expect to work while benchmarking will break in odd and mysterious ways when traffic hits certain levels.  Moving some of the load off the application server to static content servers buys you more time.
Your choice of apache's processing model also has a lot to do with things.  Apache2-prefork is what most people use for mod_php, but, apache2-mpm-worker/fcgid php can be faster.  Offloading static content to Varnish or Nginx can also ease some of the load on your application server which buys time.
Everything has an impact somewhere.  Most of the webapp performance issues I've seen come from poor use of the SQL backend or configuration errors in Apache.


text:
Q: The derivative of the action functional and Lie derivative When computing the "formal" derivative of the action functional
$$\mathcal{A}\colon C^{\infty}(S^1,M) \to \mathbb{R}$$
$$x \mapsto \int_{S^1}x^* \alpha $$
on a contact manifold $M$ with contact form $\alpha$, we pick a variation $x_s$ of $x$ with variational vector field $Y$ and aim to compute
$$\frac{d}{ds}\mathcal{A}(x_s).$$
In the computations I see, the first steps are
\begin{align*}
\left(\frac{d}{ds}\mathcal{A}(x_s)\right)_{|_{s=0}}&=\left(\frac{d}{ds}\int_{S^1}x_s^* \alpha\right)_{|_{s=0}} \\
&= \int_{S^1} \left(\frac{\partial}{\partial s}x_s^* \alpha\right)_{|_{s=0}} \\
&\stackrel{!}{=} \int_{S^1} x^* \mathcal{L}_Y \alpha  \\
&=\cdots
\end{align*}
 and from then on I can follow. However, I don't see why the Lie derivative appears here. The $x_s^*$ are pull-backs by maps of the circle. I don't see the derivative of the pull-back of a flow on $M$, only the derivative of the pull-back of the maps $S^1 \to M$. In fact, I don't see the flow of $Y$ appearing.
My question is: How do I see why the equation $(!)$ holds?

A: After pondering for a while, I can't make sense of the expression $x^*(\mathcal{L}_Y \alpha)$ in general. The way I managed to circumvent this was to look at the cylinder $S^1 \times (-\epsilon, \epsilon)$ itself.
Let $H: S^1 \times (\epsilon, \epsilon) \to M$ be the variation under question (i.e., $H(\cdot,s)=x_s$) and let $j_s:S^1 \to S^1 \times (-\epsilon,\epsilon)$ be the inclusion $j_s(t)=(t,s)$. Then
$$x_s=H\circ j_s =H \circ \Phi_s\circ j_0,$$
where $\Phi_s$ is the flow of the vector field $(0,\partial/\partial s$).
Thus,
\begin{align*}
\left.\frac{\partial }{\partial s}\right|_{s=0}x_s^*\alpha&=\left.\frac{\partial }{\partial s}\right|_{s=0}j_0^*\Phi_s^*H^*\alpha \\
&=j_0^*\mathcal{L}_{\partial/\partial s}H^*\alpha.
\end{align*}
I think the above is the correct computation. The objective of the computation on OP is to get at the fact that
$$\left.\frac{d}{ds}\right|_{s=0}\mathcal{A}(x_s)=\int_0^1d\alpha(Y,\dot{x}). $$
We now see that we arrive at this final result with the above computation. Indeed,
\begin{align*}
\left.\frac{d}{ds}\right|_{s=0}\mathcal{A}(x_s)&=\int_{S^1}j_0^*\mathcal{L}_{\partial/\partial s}H^*\alpha \\
&=\int_{S^1}j_0^*(d\iota_{\partial/\partial_s}H^*\alpha+\iota_{\partial/\partial_s}dH^*\alpha) \\
&=\int_{S^1}j_0^*\iota_{\partial/\partial_s}H^*d\alpha \\
&=\int_{S^1}j_0^*\iota_{\partial/\partial_s}d\alpha(H_*(\cdot),H_*(\cdot)) \\
&=\int_{S^1}j_0^*d\alpha\left(\frac{\partial}{\partial s}H,H_*(\cdot)\right) \\
&=\int_{S^1}d\alpha\left(Y,H_*(\cdot)\right) \\
&=\int_0^1 d\alpha\left(Y,\dot{x}\right).
\end{align*}

A: You need to use the fact that $x_s$ is $\Phi_s \circ x$, where $\Phi_s : M\to M$ is the flow of the vector field $Y$. Then
$$\frac{\partial}{\partial s} x_s^* \alpha \bigg|_{s=0} =  \frac{\partial}{\partial s}(\Phi_s \circ x)^* \alpha \bigg|_{s=0}= \frac{\partial}{\partial s} x^* (\Phi_s^* \alpha) \bigg|_{s=0}= x^* \left(\frac{\partial}{\partial s} \Phi_s^* \alpha\bigg|_{s=0} \right)= x^* (L_Y \alpha). $$

A: It is not immediately clear to me how to interpret the Lie derivative $\mathcal{L}_{Y} \alpha$, since $Y$ is only a vector field along $x$. One way to deal with this is to pull everything back to the domain of the variation. We see the variation $x_s$ as a map $\xi: S^1 \times (-\epsilon, \epsilon) \to M$, with $\xi( \cdot, s) = x_s$. On the cylinder $S^1 \times (-\epsilon, \epsilon)$ there is the vector field $\frac{\partial}{\partial s}$ which points along the $(-\epsilon, \epsilon)$ direction. Denote by $\Phi_t$ its flow. Let $i_s: S^1 \to S^1\times (-\epsilon, \epsilon)$ be the inclusion at level $s$. Then of course $i_s = \Phi_s \circ i_0$, and $x_s = \xi \circ i_s = \xi \circ \Phi_s \circ i_0$.
Now we can compute:
\begin{align}
\frac{d}{ds}\bigg|_{s=0} \, x_s^* \alpha
&= \frac{d}{ds}\bigg|_{s=0} \, i_0^* \; \Phi_s^* \;\xi^* \alpha \\
&= i_0^* \;\frac{d}{ds}\bigg|_{s=0} \, \Phi_s^* \;\xi^* \alpha \\
&= i_0^* \;\mathcal{L}_{\frac{\partial}{\partial s}} \xi^*\alpha.
\end{align}
So here instead of the (a priori) ill-defined $\mathcal{L}_Y \alpha$ we have the derivative of $\xi^* \alpha$ in the direction of $\frac{\partial}{\partial s}$, which pretty much means "differentiate $\alpha$ in the direction transverse to the variation", as we would want intuitively. From there, the next step is to use Cartan's formula, but I think you had this part figured out.


text:
Q: How to print lines between two patterns with optional end pattern I have gone through stack over flow and found these questions
How to print lines between two patterns, inclusive or exclusive (in sed, AWK or Perl)?
Combine multiple lines between flags in one line in AWK
The problem with my question is that there can be another TAG1 without the matching TAG2 like this
file.txt:
aa

TAG1
some right text
TAG2

some text2

TAG1
some text3

TAG1
some text4

TAG1
some right text 2
TAG2

some text4

TAG1
some text5
some text6

expected output:
TAG1
some right text
TAG2

TAG1
some right text 2
TAG2

A: One way is to reverse the input, get TAG2 to TAG1 and then reverse again:
$ tac ip.txt | sed -n '/TAG2/,/TAG1/p' | tac
TAG1
some right text
TAG2
TAG1
some right text 2
TAG2

Another way is to reset and start collecting lines once the first one is found and print only when the second one is found:
$ awk '/TAG1/{f=1; buf=$0; next}
       f{buf=buf ORS $0}
       /TAG2/{if(f) print buf; f=0}' ip.txt
TAG1
some right text
TAG2
TAG1
some right text 2
TAG2

A: Here is an example with GNU sed. Collect the data into pattern space and only print when matching TAG1/TAG2 found:
sed -nE ':a; /TAG1$/ s/.*(TAG1)/\1/; N; /TAG2$/ { /^TAG1/ { G; p; }; z; }; ba'

Or as a stand-alone script with explanation:
parse.sed
:a                            # main-loop
/TAG1$/ s/.*(TAG1)/\1/        # Ensure only one TAG1
N                             # Read next line
/TAG2$/ {                     # When TAG2 encountered
  /^TAG1/ { G; p; }           # Which started with a TAG1, print
  z                           # Clear out pattern space
}
ba                            # Repeat main-loop

Run it like this:
sed -nEf parse.sed infile


text:
Q: Linkedin official "search people" API My company needs to develop an app where we need to make use of the searching the profile BY EMAIL ADDRESS.
there are several questions and/or other resources regarding the "search api" on the linkedin API. Lots of them contain broken links or outdated information.
E.g.
Linkedin rest api to search people with name
Search people with Linkedin API
What are the steps to use linkedin people search api?
http://www.programmableweb.com/api/linkedin-people-search
Of course, I started here: https://developer.linkedin.com/docs/rest-api
To my understanding, there was a change in the API in 2015, which left basic profile for the public to use, the availabiliy of the rest went under the Partnership Programs.
Is the search API available under all of the listed profiles? Does anyone of you use it these days? (mid-2016)?


text:
Q: How to edit an array which stores time values in it? I have an application in which I am storing time values in an array. The time is getting stored in the array through a key name called @"time" when a particular date is selected from datepicker. This date I am using to schedule notification for a particular date.
I am using sqlite database where I am saving my notification time values. My problem is I want to edit my already scheduled notification through the key value that I am used store in my array i.e if I change a particular time that particular time should get changed in my array of time through the index path at that index, where it should get edited?

A: fetch all scheduled notifications array via scheduledLocalNotifications
check for fireDate in a loop on array for which you want to reschedule (old date/time)
when you find the notification's object you want to reschedule, cancel that notification via cancelLocalNotification.
when old notification is cancelled, schedule a new local notification with your updated time.


text:
Q: Solving a third-order recurrence relation How can I solve a recurrence relation as the following: $x_{n+3} = x_{n+2} + x_{n+1} + x_{n} +n$ with $x_0=0$ and $x_1 = x_2 =1$?

A: Hint: as with any non-homogeneous linear equation, the general solution is a particular solution + the general solution of the homogeneous equation.  So

*

*Find a particular solution (try $x_n = a n + b$).

*Find the general solution of the homogeneous equation.

*Adjust the constants to match the initial conditions.

Note that (2) will involve the roots of the irreducible cubic $z^3 - z^2 - z - 1$, which are not very pleasant.  So you won't get a "nice" closed-form solution.


text:
Q: Append Model to VXYModelMapper I use "VXYModelMapper" and "QStandardItemModel" in plot chart. I use blow codes but append model to VXYModelMapper is very slow.
VXYModelMapper {
        model: myChartClass.newMyChartModel
        series: lineSeries
        xColumn: 0
        yColumn: 1
}
void MyChartClass::setMyChartModel(QStandardItemModel *model)
{
  newMyChartModel= model;
  emit myChartModelChanged(model);
}

QStandardItemModel* lineModel=new QStandardItemModel(npcArray.size(), 2);
foreach(const QJsonValue & val, npcArray){
    double xVal=val.toObject().value("x").toDouble();
    double yVal=val.toObject().value("y").toDouble();

    QStandardItem *item1 = new QStandardItem(QString::number(xVal));
    lineModel->setItem(i, 0, item1);

    QStandardItem *item2 = new QStandardItem(QString::number(yVal));
    lineModel->setItem(i, 1, item2);
     i+=1;
}

 //To this line everything is very good and fast

QElapsedTimer timer;
timer.start();
myChartClass->setMyChartModel(lineModel);
qDebug() << "The slow operation took" << timer.elapsed() << "millisecond";

Output: The slow operation took 123045 millisecond. Total point
  count: 5188

It is very slow :(
Update:
I use QTimer but not benefit. :(
lineModel=new QStandardItemModel(0, 2);
myChartClass->setMyChartModel(lineModel);
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
timer->start(30);

void MyChartClass::update(){

int toIndex=fromIndex+100;
if(toIndex>=npcArray.size()){
    toIndex=npcArray.size()-1;
}

for(int i=fromIndex;i<toIndex;i++){
    double xVal=npcArray[i].toObject().value("x").toDouble();
    double yVal=npcArray[i].toObject().value("y").toDouble();

    QStandardItem *item1 = new QStandardItem(QString::number(xVal));
    lineModel->setItem(i, 0, item1);

    QStandardItem *item2 = new QStandardItem(QString::number(yVal));
    lineModel->setItem(i, 1, item2);
}
fromIndex=toIndex;
}


text:
Q: How can I delete specific appearances of elements from an array in Prolog? I want to delete only second appearance of each element in given array and return the result in a new array. The given array can have have atomic elements but also can have list like element within it.

the predicate should be called like this: delete_second(L1,L2).
L1=[1,2,4,1,[1,2,3,[4]],2,1]
L2=[1,2,4,[1,3,[]],2,1].

A: You might use two accumulator lists. In one accumulator you would have the items that appeared just once, and on the other accumulator you would have the items that appeared more than once.
So you would have to go through all the items of the input list updating those accumulators and selecting and discarding the item from the output list if required.
Something like:
delete_second(In, Out):-
delete_second(In, [], [], _, _, Out).

delete_second([], Once, Twice, Once, Twice, []):- !.
delete_second([X|Tail], Once, Twice, NOnce, NTwice, [Y|Out]):-
  delete_second(X, Once, Twice, MOnce, MTwice, Y),
  !,
  delete_second(Tail, MOnce, MTwice, NOnce, NTwice, Out).
delete_second([X|Tail], Once, Twice, NOnce, NTwice, [X|Out]):-
  member(X, Twice),
  !,
  delete_second(Tail, Once, Twice, NOnce, NTwice, Out).
delete_second([X|Tail], Once, Twice, NOnce, NTwice, Out):-
  append(OnceP, [X|OnceT], Once),
  append(OnceP, OnceT, MOnce),
  !,
  delete_second(Tail, MOnce, [X|Twice], NOnce, NTwice, Out).
delete_second([X|Tail], Once, Twice, NOnce, NTwice, [X|Out]):-
  !,
  delete_second(Tail, [X|Once], Twice, NOnce, NTwice, Out).


text:
Q: H14 error upon Django app deployment on Heroku I tried today to deploy my Django app on Heroku.
I first had success and got the message that it is deployed. However upon Heroku open I had a screen informing me that an error occurred and that I should check the logs which look as follows:
2020-05-17T21:01:16.000000+00:00 app[api]: Build succeeded
2020-05-17T21:01:23.528711+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=wsb-project.herokuapp.com request_id=4ea57e57-b230-4d49-99d6-f5f17856b589 fwd="85.221.138.216" dyno= connect= service= status=503 bytes= protocol=https
2020-05-17T21:01:23.897006+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=wsb-project.herokuapp.com request_id=59fc1c4d-330c-4084-8e9e-1a3d7d8ed292 fwd="85.221.138.216" dyno= connect= service= status=503 bytes= protocol=https
2020-05-17T21:09:45.484945+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=wsb-project.herokuapp.com request_id=f1cd7d3d-8781-49b8-80e0-278ca06139ce fwd="85.221.138.216" dyno= connect= service= status=503 bytes= protocol=https
2020-05-17T21:09:45.885362+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=wsb-project.herokuapp.com request_id=64c1d78c-8e75-47d0-b748-9ffbf239c545 fwd="85.221.138.216" dyno= connect= service= status=503 bytes= protocol=https

Heroku ps tells me that no dynos are on my app.
I tried this tutorial:
and when scaling dynos I was informed that "couldn't find that process type(web)"
So I tried to clear and add the buildpacks again using this link
And still nothing works.
Thanks in advance in any of you know where I could find a solution as I am slowly running out of options here :)
Cheers.
Adding directory:
drwxr-xr-x 1 bapti 197609      0 May 17 14:18 ./
drwxr-xr-x 1 bapti 197609      0 May 16 14:22 ../
drwxr-xr-x 1 bapti 197609      0 May 18 19:09 .git/
-rw-r--r-- 1 bapti 197609     72 May 13 20:29 .gitignore
drwxr-xr-x 1 bapti 197609      0 May 16 14:44 .idea/
-rw-r--r-- 1 bapti 197609 155648 May 17 14:18 db.sqlite3
-rwxr-xr-x 1 bapti 197609    652 Apr  1 14:16 manage.py*
-rw-r--r-- 1 bapti 197609     43 May 15 19:01 Procfile.txt
drwxr-xr-x 1 bapti 197609      0 May 14 22:25 python-getting-started/
drwxr-xr-x 1 bapti 197609      0 May 15 17:46 register/
-rw-r--r-- 1 bapti 197609    301 May 16 11:11 requirements.txt
drwxr-xr-x 1 bapti 197609      0 May 16 13:31 restaurants/
-rw-r--r-- 1 bapti 197609     12 May 15 19:03 runtime.txt
drwxr-xr-x 1 bapti 197609      0 Apr 14 11:45 sent_emails/
drwxr-xr-x 1 bapti 197609      0 May 17 23:33 WSB_website/

A:
This is most likely the result of scaling your web dynos down to 0 dynos. To fix it, scale your web dynos to 1 or more dynos:

heroku ps:scale web=1 or if it asks for an app, heroku ps:scale web=1 -a wsb-project

The Procfile is always a simple text file that is named Procfile without a file extension. For example, Procfile.txt is not valid.

The Procfile must live in your app's root (main) directory. It does not function if placed anywhere else.
The content of Procfiles can be set up as following,
web: gunicorn blog.wsgi --log-file -


text:
Q: jQuery: load() loads the page but doesn't focus the textbox I have a fiddle : http://jsfiddle.net/SDr3F/10/
Currently:
onclick, it alerts
alert('hi')

Required:
onclick, it loads a search.html with a search text box and focus in textbox
search.html
<input id="search-input" type="text" class="input-medium search-query span4">

How I set focus?
$(function(){
  $("#search").click(function(){
      $('#feature').load('templates/search.html');
      $('#search-input').focus();
      alert("hi");
  });
});

Problem

*

*It loads the page BUT doesn't focuses inside textbox, how do I fix this?

A: In your example you focus element right after the Ajax request is made but not when the request is successfully completed. Hence, you try to focus the element that is not yet loaded.
You should add the complete handler. The following should work:
$("#search").click(function() {
    $("#feature").load("templates/search.html", function() {
        $("#search-input").focus();
    });
});

A: You need a callback so that it knows that the content of the page is fully loaded before it tries to set the focus.


text:
Q: What windows C IDE can I use that will use gcc to compile and let me insert breakpoints just like Visual Studio would for C#? What windows C IDE can I use that will use gcc to compile and let me insert breakpoints just like Visual Studio would for C#?
I have searched Google and cannot find anything more recent that 2005.
I'm just getting back into C since graduating and would like a non MS IDE that uses GCC, but that's a versatile as Visual Studio.
The thought of having to use GDB command line is not too appealing right now.

A: I successfully used Eclipse with C/C++ plugin. Matter of fact I prefer it to VS. You can download it from here it's a real beaut. If you do JNI it's simply indispensable since you can setup your project to do both C/C++ and Java

A: Dev-C++ http://www.bloodshed.net/devcpp.html
GPL license
Uses GCC

A: Netbeans http://www.netbeans.org/features/cpp/index.html

A: Code::Blocks is another free C++ IDE for Windows/Linux/MacOSX. GPL3 license.

A: I highly recommend Insight Debugger that is a lightweight Tk frontend to GDB by RedHat.
It adds a convenient GUI to call stack display, breakpoints, watches and memory display (non exhaustive list).
As it is in Tk, it both supports GNU/Linux and Windows (and probably MacOS X). For MinGW users, there is even a MinGW package to install it.
Once installed, you just add the -w setting to the command line to start the GUI: gdb -w

A: ddd
you could found it on the "development" menu.


text:
Q: Merging 2 dataframes on Pandas Sorry I have a very simple question. So I have two dataframes that look like
Dataframe 1:
columns: a b c d e f g h
Dataframe 2:
columns: e ef
I'm trying to join Dataframe 2 on Dataframe 1 at column e, which should yield
columns: a b c d e ef g h
or
columns: a b c d e f g h ef
However:
df1.merge(df2, how = 'inner', on = 'e') yields a blank dataframe when I print it out.
'outer' merge only extends the dataframe vertically (like using an append function).
Would appreciate some help thank you!

A: You need same dtypes of columns for join, so need converting:
#convert string column to int
df1['e'] = df1['e'].astype(int)
#inner is default value, so can be omit
df1.merge(df2, on = 'e')

Sample:
df1 = pd.DataFrame({'a':list('abcdef'),
                   'b':[4,5,4,5,5,4],
                   'c':[7,8,9,4,2,3],
                   'd':[1,3,5,7,1,0],
                   'e':['5','3','6','9','2','4'],
                   'f':list('aaabbb'),
                   'g':[1,3,5,7,1,0]})

print (df1)
   a  b  c  d  e  f  g
0  a  4  7  1  5  a  1
1  b  5  8  3  3  a  3
2  c  4  9  5  6  a  5
3  d  5  4  7  9  b  7
4  e  5  2  1  2  b  1
5  f  4  3  0  4  b  0

df2 = pd.DataFrame({'ef':[10,30,50,70,10,100],
                   'e':[5,3,6,9,0,7]})
print (df2)
   e   ef
0  5   10
1  3   30
2  6   50
3  9   70
4  0   10
5  7  100

df1['e'] = df1['e'].astype(int)
df = df1.merge(df2, on = 'e')
print (df)
   a  b  c  d  e  f  g  ef
0  a  4  7  1  5  a  1  10
1  b  5  8  3  3  a  3  30
2  c  4  9  5  6  a  5  50
3  d  5  4  7  9  b  7  70

A: Instead of
df1.merge(...)
try:
pd.merge(left=df1, right=df2, on ='e', how='inner')

A: You can do it like this:
def mergeDfs(df1,df2):
    newDf = dict()
    dfList = []
    for i in df1:
        l = len(i)
        row = []
        for j in range(l):
            row.append(df1[i][j])
        newDf[i] = row
        dfList.append(i)
    for i in df2:
        l = len(i)
        row = []
        if i not in dfList:
            for j in range(l):
                row.append(df2[i][j])
            newDf[i] = row
    df = pd.DataFrame(newDf)
    return df


text:
Q: Should I use a GraphServiceClient per set of client credentials or can I reuse the same GraphServiceClient with different credentials? I know you generally want to reuse GraphServiceClient like HttpClient, but what should I do if I need to use two or more different Azure AD Client ID/Client Secret combinations in the same daemon application?
Should I create a singleton GraphServiceClient for each set of credentials? If so, would I need to register some sort of factory class for dependency injection of the correct GraphServiceClient?
Or is there a way to use different client credentials with the same GraphServiceClient instance?