RestSharp "The operation has timed out"

Question: I use RestSharp to execute POST request: var response = client.Execute(request);
This request returns an error exception is inside response: {"The operation has timed out"}.
What is the reason for this? How to fix it?
Comment: Are you sure remote endpoint, where you send POST, is OK? Try to send the same post with Fiddler or Postman.
Answer: If you haven't found an answer yet, look at the Timeout property.  The HttpWebRequest default is 100 seconds and I haven't been able to find any data that suggests RestSharp changes the timeout default.
https://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.timeout(v=vs.110).aspx
In the following line of code, this would set the timeout to 5 minutes.
    request.Timeout = 300000;

RestSharp "The operation has timed out"


Using the jQuery Update module throws the "F is undefined" error

Question: I am using the jQuery validate module (which is mandatory for client side validation module).
If I use that module, my existing functionality is not working well. It is throwing, "F is undefined" while using minified version or, "$.ui is not a function" with the normal version of jQuery.
I understood that version plays the problem here. How do I avoid the error message?
Comment: Please mention your version numbers for Drupal, the jQuery library, jQuery update module and other components that might be relevant.
Comment: That's a strange combination of version numbers. According to the [jQuery Update module](http://drupal.org/project/jquery_update), you should have jQuery 1.3.2. Check if it installed correctly on the /admin/reports/status page. Also (even though it will probably not fix this problem) try to keep your Drupal core up-to-date for security reasons.
Comment: Drupal 6.2, Jquery is 18.104.22.168 and jquery_update is 6.x-2.0-alpha1.. Hope this satisfy the needs.
Answer: I use jQuery Update on every site we make.
One typical problem it has, is that it can cause problems on admin pages.  The issues for the module has a patch (http://drupal.org/node/775924#comment-3010750) that fixes the problem.  You can also edit this to use any version of jQuery you want, as long as you place the proper versions in the module folder.


Simple u-subsitution - Paradoxical Result

Question: If I were to try and take $$\int{\mathrm{sin}(t)\mathrm{cos}(t)dt} $$ I would either take $u=\mathrm{sin}(t) $, yeilding a result of $\frac{1}{2} \mathrm{sin}^2(t) + C$, or I would take $u=\mathrm{cos}(t) $, yeilding a result of $-\frac{1}{2} \mathrm{cos}^2(t)+ C$.
These two results are not equivalent.  What just happened?
Comment: $1/2 \sin^2 t=1/2-1/2\cos^2 t$. And don't forget that we need always to add a constant.
Comment: Does this answer your question? [A contradictory integral: $\int \sin x \cos x \, \mathrm dx$](https://math.stackexchange.com/questions/233971/a-contradictory-integral-int-sin-x-cos-x-mathrm-dx)
Answer: The answers are not equal, but they are equivalent. Remember, as Artem said, that the two answers differ by a constant. And antiderivatives are always defined up to a constant.
Answer: If you evaluate the definite integral of $$ \int_{a}^{b} \sin(t)\cos(t) dt$$, then you get:$$\frac{1}{2}\left(\sin^2(b)-\sin^2(a)\right)=\frac{1}{2}\left(1-\cos^2(b)-1+\cos^2(a)\right)$$ $$=-\frac{1}{2}\left(\cos^2(b)-\cos^2(a)\right).$$ So while the indefinite integral might seem off, the definite integral has the same values.
Comment: Wait I get it lol.
Comment: The fact that their graphs are only off by a constant implies that their derivatives should be equal.
Comment: Every time, despite the fact that their graphs are not equivalent?  Hot dog...
Comment: Im just showing that regardless of which antiderivative you use, either the $\frac{1}{2}\sin^2(t)$ or the $-\frac{1}{2}\cos^2(t)$, you will still get the same answer.


random logic to print numbers in following pattern

Question: Currently, I have an array r[1] to r[12].
Now, I need to print it like this:
r[10]    r[11]    r[12]
r[7]     r[8]     r[9]
r[4]     r[5]     r[6]
r[1]     r[2]     r[3]

Answer: for (int i = 0; i < 4; i++){
   for(int j = 0; j < 3; j++){
       print("%d", r[ 12 - (i * 3) + j]);
   }
}

If you need any other numbers than you could generalize the solution
for (int i = 0; i < count / interval; i++){
   for(int j = 0; j < interval; j++){
       print("%d", r[ count - (i * interval) + j]);
   }

Answer: supposing you've got an array with n elements and you want to show them in row of 3 elements, you could proceed in this way (in php):
// this is your array, it starts with 1 and could end with n (but it must be divisible by 3)
$array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);

// check if the number of the elements is ok for the script
if (count($array) % 3) {
    echo "The array must be divisible for the number of the element in a row!";
    exit;
}

// for each row, from 1 to number of the elements in array...
for ($row = 1; $row <= count($array) / 3; $row++){

   // ... and for each column (with a max of 3 columns)
   for($column = 0; $column < 3; $column++){

       // print out the last element, less current row multipled by 3 plus the number of the column (which was started with 1).
       echo $array[count($array) - ($row * 3) + $column] . " ";

   }

   // another row is finished, move the cursor to the next line
   echo "
";

}

Comment: actually array is not limited to 12.it can be infite
Comment: good news for me. my boss doesnt want that functionality now.anyways thanks to all of u guys
Comment: i modified it, check if the new script suits for you


Create query with JPA Criteria API for foreign key

Question: This is the query I want to rewrite using criteria query:
Query query = entityManager.createQuery( "Select a from UserDetails a where a.user.id = ?1")

How can I achieve this? I know how to do select with criteria query when I know some of the property of the entity I'm looking for but in this case I want to do select using foreign key. I got two entities:
@Entity
@Table(name = "user")
public class User {
    private String name;
    @OneToOne(cascade = {CascadeType.MERGE, CascadeType.PERSIST}, fetch = FetchType.LAZY)
    private UserDetails userdetails;
etc.
 }

@Entity
@Table( name = "userdetails")
public class UserDetails
{
   @OneToOne( cascade = { CascadeType.MERGE, CascadeType.PERSIST}, fetch = FetchType.LAZY)
   @JoinColumn( name = "fk_user_id")
   private User user;
etc.
    }

I only know the id of the user and now I want to do select in userdetails with this user id. How can I do it?
Answer: I have solved it this way:
CriteriaBuilder cb = entityManager.getCriteriaBuilder();
CriteriaQuery<UserDetails > cq = cb.createQuery( UserDetails .class);
Root<UserDetails > root = cq.from( UserDetails .class);
cq.select(root);
cq.where(cb.equal( root.get("user").get("id"), userID));
return entityManager.createQuery(cq).getSingleResult;


Using JSONPath to filter and get only specific properties as result?

Question: Is it possible to use JSONPath to both filter and "select" properties to keep for the result.
For instance if we have the following JSON:
{
    "firstName": "John",
    "lastName": "doe",
    "age": 26,
    "address": {
        "streetAddress": "naist street",
        "city": "Nara",
        "postalCode": "630-0192"
    },
    "phoneNumbers": [
        {
            "type": "iPhone",
            "number": "0123-4567-8888"
        },
        {
            "type": "home",
            "number": "0123-4567-8910"
        }
    ]
}

And we run a JSONPath like:
$.phoneNumbers[?(@.type=='iPhone')]

We would end up with the result:
[
  {
    "type": "iPhone",
    "number": "0123-4567-8888"
  }
]

Now lets say that what I actually want is the phonenumber.. so we could do this:
$.phoneNumbers[?(@.type=='iPhone')].number

Which would result in:
[
  "0123-4567-8888"
]

However.. the result that I would like to get would be:
[
  {
    "number": "0123-4567-8888"
  }
]

Notice how the actual JSON-object is returned and the property..
Is that possible to achive somehow using JSONPath?
Comment: Only with JSONPath? No! you need to do some kind of post-processing. `$.phoneNumbers[?(@.type=='iPhone')]` transforms to `$['phoneNumbers'][0]` and `$.phoneNumbers[?(@.type=='iPhone')].number` to `$['phoneNumbers'][0]['number']` . There is nothing in between.
Answer: Since you know what property you're looking for (i.e. number), what you can do is to construct a new Json object with the property name and the returned value.
The actual implementation depends on what programming language you're using, but the pseudocode should look somewhat like this:
returnedList = json.find("$.phoneNumbers[?(@.type=='iPhone')].number")

initialize newJsonArray

foreach(returnedValue in returnedList):
  newJsonArray.add(newJsonObject("number", returnedValue))

An alternative way to tackle the problem in OOP languages is to use lambda functions to filter your Json objects instead of using Jsonpath filters. An example on how to do it in C# using Newtonsoft.Json:
JArray jArray = new JArray(jObject.SelectToken("$.phoneNumbers").Where(x => x["type"].ToString() == "iPhone"));


Problem when I try to delete data and files

Question: I'm new in Laravel, and I'm doing a project for my university, and I've two problems when I try to delete:
First error: When I try to delete the records, only the first one (with ID 1) doesn't delete from the table, but the other if deleted from the table and I've already tried some things to fix the error, but I couldn't:
Controller.php:
public function destroy_int($inst_id)
    {
        $inst = InstitucionEntidadInt::where('id', $inst_id);
        $inst->delete();
        return redirect('/activities/cons_instituciones_int');
    }

Web.php:
Route::delete('/delete_inst_int/{inst_id}', [InstEntController::class, 'destroy_int'])
    ->name('institucion_int.destroy');

Second error: In some forms, it's necessary to upload and save files in a database (so I save just the name in the database and the files are saved in the public path). And some of this input files are multiple, so I save the names in the database like a JSON (using the json_encode method):
//This is the way that I save the files
$files = [];

if ($request->hasFile('inst_docsoporteNac')) {
    foreach ($request->file('inst_docsoporteNac') as $file) {
        $name = time() . "_" . $file->getClientOriginalName();
        $file->move(public_path('files/institucionesNac'), $name);
        $files[] = $name;
    }
}

$instentNact->docSoportes = json_encode($files);

So, I'm trying to implement the delete method and I need to delete the files from both places (from the DB and the public path), I don't know how I can do it and I've already tried some "solutions" that I read from some forums (like this).
Controller.php:
public function destroy_nac($inst_id)
    {

        $inst = InstEntNac::where('id', $inst_id);
        $files = InstEntNac::where('id', $inst_id)->get('docSoportes');
        foreach (json_decode($files) as $file) {
            Storage::delete(public_path('files/institucionesNac/' . $file));
        }
        $inst->delete();
        return redirect('/activities/cons_instituciones_nac');
    }

This is the way that I'm using, but I'm getting an error "Object of class stdClass could not be converted to string".
I'll appreciate your solutions for these errors.
Comment: Why json_decode $files before deleting?
Comment: 'Cause I need to access the name saved in the DB and using it to delete from the public path (and are multiples files/names), "I guess".
Answer: For the first error, you can add error handling using this code:
InstitucionEntidadInt::findOrFail($inst_id)->delete();

For the second error, json_decode returns by default stdClass object instead of array. You can tell the function to return array type with second boolean parameter setting it to true:
json_decode($files, true)

https://www.php.net/manual/en/function.json-decode.php
Comment: Thanks for the help, but the first solution didn't work, it's still not deleting the record with ID 1.

And the second solution I'm getting other error "Array to string conversion".
Comment: Actually, I don't know why are you using json_decode here.
Comment: You'd better do it like this: InstEntNac::where('id', $inst_id)->get('docSoportes')->each(function(InstEntNac $file) { Storage::delete(public_path('files/institucionesNac/' . $file->docSoportes));});
Comment: Regarding id 1, it should work. Make sure that id slug is passed correctly to the route. Do you get an error here or just nothing happens?
Comment: Trying your solution for the file didn't work, I don't get an error but nothing appends.
And nothing happens with the record ID 1, I try with dd() method and I get nothing, but it's curious because with the others I use that method and I get something (the ID). With that is like just refresh the page and nothing else.
Comment: I found the problem, when I get the files' name saved in the DB and I see its types, they are "string" and not an "array". So, when I wanna delete it, nothing happens for this reason. But it's strange because when I show each name in the view, I use a foreach, and it works, and I apply a download method for each file and I don't know why I can fix this.


What's the ratio of triangles made by diagonals of a trapezoid/trapezium?

Question:
In the above image, what will be the ratio of areas of triangle $A$ and $B$?
From Googling, I've found that:
$\operatorname{Ar}(A) = \dfrac{a^2h}{2(a+b)}$
and
$\operatorname{Ar}(B) = \dfrac{b^2h}{2(a+b)}$
but how do I get these formulas from the classic formula of $\dfrac{\rm base \times height}2$?!
Basically, how were the formulas in this image:
this image http://www.geometryexpressions.com/explorations/04-Examples/02-Example_Book/02-Quadrilaterals/Example%20036-Areas_Of_Triangles_In_A_Trapezoid_files/image004.gif
figured out?
Comment: Oh, and reference link: [Geometry Expressions](http://www.geometryexpressions.com/explore.php?p=04-Examples%2F02-Example_Book%2F02-Quadrilaterals&f=Example+036-Areas_Of_Triangles_In_A_Trapezoid.htm)
Answer: Well, what is the height of the triangle $\Delta a$? It is similar to the triangle $\Delta b$ (why?), so and the heights $h_a$ of $\Delta a$ and $h_b$ of $\Delta b$ are related in the following way:
First, we have $h = h_a + h_b$. This is obvious if you draw them on your figure. Secondly, from similarity, we have that
$$
\frac{h_b}{h_a} = \frac{b}{a}.
$$
By manipulating the last equation, and with a little help from the first to rid ourselves of $h_b$, we get
$$
\frac{h-h_a}{h_a} = \frac{b}{a} \\\\
\frac{h}{h_a} - 1 = \frac{b}{a} \\\\
\frac{h}{h_a} = 1 + \frac{b}{a} \\\\
h_a = \frac{h}{1 + \frac{b}{a}} = \frac{ha}{a + b}
$$
This means that the area of $\Delta a$ is equal to
$$
\frac{1}{2}\cdot a \cdot h_a = \frac{1}{2}\cdot a \cdot \frac{ha}{a + b} = \frac{a^2h}{2(a+b)}
$$
Comment: Thank you very much! Great explanation! :)
Comment: One thing, though, how is $1 + b/a$ = $a + b$?
Comment: It isn't. The $a$ in the denominator was 'thrown' up.
Comment: @ohad Now I feel dumb... Thanks for explaining this!


How many numbers exists that are smaller than $p$ and prime with $p$?

Question: I have a homework to hand in and they asked this question. I don't know if I'm supposed to count 1 as a prime to that number or not.
In my case $p=3947$, so I count 3945 numbers fitting that criteria since $p$ is prime.
Is this correct ?
Thanks.
Comment: There are not 3945 primes lower than $3947$.
Comment: $p=3947$ is prime. Therefore the answer is $\phi(p)=p-1=3946$.
Comment: I would definitely count 1, since the normal definition if "prime to ..." is that the greatest common factor should be 1.
Comment: I understand that he is not counting primes below $p$, but rather numbers below $p$ which are "prime to $p$", i.e. relatively prime to $p$.
Comment: @JonasKibelbek : I edited the question to be clearer. You're right that it's a different question.
Comment: It seems likely that your homework question is asking "How many numbers exist that are smaller than $p$ and prime with $p$?" In this case, you should definitely count 1.  But you ask "How many *prime* numbers...?", which is a very different question.  A number can be prime with 3947 without actually being a prime number.  For the sake of getting the right answer, be sure you understand the difference between these two questions and figure out which question your homework is asking.
Answer: The correct terminology is 'co-prime' with p. And there's a known formula for it. Euler's totient. look at http://en.wikipedia.org/wiki/Euler_totient_function.
Comment: Thanks, in short $3947$ is the answer I was looking for. Euler's totient function clarified my confusion.
Comment: If you take the average of your 2 answers then you are correct!


C# excel - extract only rows within a range of columns

Question: I have the following code:
Excel.Range range = workSheet.UsedRange;
for (rowCount = 2; rowCount <= range.Rows.Count; rowCount++)
  {
     //Do something here
  }

However, I encounter the following problem. If I have the following excel data:
cell1, cell2, cell3

cell4, cell5, cell6

..............cell7

range.Rows.Count will return 3. However, I don't care about column C - it has some data that is used for drop-down lists within say column 1. How can I get the range.Rows.Count only for columns A and B?
For example:
Comment: Can you post a screenshot and be clear about what you want to count and what you want to ignore?
Answer: Assuming there are no blanks in column A, just walk down rows until you hit a blank row using range.Offset(x,y): (sorry, I'm more fluent with Excel VBA, you'll have to translate to C#)
Dim myCell as Range
set myCell = workSheet.Range("A2");
Do Until myCell.Formula = ""
     'Do something here
     set myCell = myCell.Offset(1,0) 'Moves down a row
Loop

Or just loop through numerically using Worksheet.Cells(row,col):
Dim myRow as Integer
myRow = 2
Do Until cells(myrow,2).Formula = ""
     'Do something here
     myRow = myRow + 1
Loop

Edit: You could also use Range("A1").End(xlDown) to find the last populated cell of the first column. This should work with your current logic. Something like (I'll try it in C#):
Excel.Range range = workSheet.Range("A1", Range("A1").End(xlDown));
for (rowCount = 2; rowCount <= range.Rows.Count; rowCount++)
  {
     //Do something here
  }


Show that a space is $T_1$ if all subset is the intersection of all open sets containing it

Question: Following a question I asked yesterday Is this the correct definiton of $T_1$ space?
I was left with a claim:

$(X, \tau)$ is $T_1$ iff $\forall A \subseteq X, A = \bigcap\{U
 \subseteq X: U \in \tau, A \subseteq U\}$

I can borrow two additional results: singletons are closed, finite union of singletons is closed (by def), but I don't see that they are useful at all
I am not sure how to prove this but let's try:
$(\Rightarrow)$
Suppose $(X, \tau)$ is a $T_1$ space, then for all $x,y \in X$, $x \neq y$, there exists open sets $U, V \in \tau$ such that $x \in U,  y \not\in U$ and $y \in V, x \not\in V$
Let $A \subseteq X$, we wish to show that $A$ is the intersection of all open sets containing it.
Pick $x \in A$, then there exists $ U \in \tau$, $ x \in U$ such that $y \not\in U$ for all $x \neq y$. Then $x \in A$ and $x \in U$...what does this imply? Stuck! Help!
$(\Leftarrow)$ Let $x \in \bigcap\{U \subseteq X: U \in \tau, A \subseteq U\}$, I want to show that $x \in A$
Suppose $A$ is open, then trivially $x\in\bigcap\{U \subseteq X: U \in \tau, A \subseteq U\} \subset A$.
Otherwise suppose $A$ is closed. By contradiction assume that $x \not\in A$, then $x \in X \backslash A$ is open, but $A \cap X \backslash A = \varnothing$, then $x \not \in \bigcap\{U \subseteq X: U \in \tau, A \subseteq U\}$ a contradition.
This shows that all sets are intersection of open sets....Wrong!
(Not using $T_1$ properties at all..)
Can someone use his or her magic touch to revive this proof from the dead?
Comment: There are a few issues here...
Comment: A set that is not open doesn't need to be closed.
Answer: Suppose $X$ is T$_{1}$. Let $A\subseteq X$. Let $x\in X\setminus A$. For each $a\in A$ there is an open set $U_a$ with $a\in U_a$ and $x\notin U_a$. Then $U_x:=\bigcup_{a\in A} U_a$ is open containing $A$, missing $x$. Then $A=\bigcap _{x\in X\setminus A} U_x$, so that $A$ is the intersection of all open sets containing it.
Suppose $X$ is not T$_1$. There exist $x,y\in X$ such that every open set containing $x$ also contains $y$. Then $\{x\}$ is a subset of $X$ which is not the intersection of all open sets containing it.


Finding injection on natural numbers?

Question: I would like to find an injection $f:\mathbb{N} \to  \mathbb{N} \times \mathbb{N}$
I thought of it as a chess board. Each field of $\mathbb{N}$ correspond to the board axes  $\mathbb{N} \times \mathbb{N}$. However I cant image the corresponding function doing that. Could someone provide some assistance?
Comment: Maybe he wanted an injection $\Bbb N \times \Bbb N \to \Bbb N$
Comment: Or perhaps a bijection?
Answer: Your are so near to an answer, that I don't want to say too much. Think about going diagonal over the chess board.
Comment: Welcome to Math.SE ! As you may be aware of, this should be better suited as a comment rather than an answer, but you don't have enough reputation to do so. However, this is an answer so maybe you could elaborate a little bit more (without spoiling too much if you want, it is up to you), or shape your answer differently (Ex : "**Hint**: Try to..."). Upvoted because it is useful and so that you will be able to comment soon.
Comment: Offtopic: Thank you :). Yes, I know about the comment problem. Will be over it soon, I hope.
Answer: An injection in the desired direction is easy to obtain, for instance $n\mapsto (n,5)$ will work. It is more interesting to look for an injection $\mathbb N\times\mathbb N\to\mathbb N$.
Comment: Or are you actually looking for a bijection?
Comment: No for an injection. I mean $2^a \times 3^b$ maps from $\Bbb N  \times\Bbb N \to\Bbb  N$ the other way around was not clear somehow
Comment: Okay, then my answer will work. Notice that people think it's easy to inject $\mathbb N$ into $\mathbb N\times\mathbb N$ because the former is "smaller."
Comment: Nothing in particular. I just couldn think of a function. Im trying to get a better understanding of functions and struggle somehow...next project is to find the surjective for $\Bbb N  \times\Bbb N \to\Bbb  N$ :)
Answer: The classic bijection $\Bbb N\times\Bbb N\to\Bbb N$ is
$$(n,m)\longmapsto\frac{(n+m)(n+m+1)}2 + n.$$
Can you find the inverse?
Comment: That seems interesting...
Comment: This bijection is correct if $0 \in \mathbb{N}$. But it is easy to find a similar function in case $0 \notin \mathbb{N}$.
Comment: for example? I mean what is the general approach...just trying every function?
Comment: I'm not sure, but this is what I came up with: $N \triangleq \lfloor\frac{-1+\sqrt{1+8x}}{2}\rfloor$, then $n = x-\frac{N(N+1)}{2}$ and $m=N-n$.
Comment: @Ronald Actually, I think it doesn't work if $0 \notin \mathbb{N}$. Just try to think of the inverse of $1$. The definition should make an exception to that formula and include the case $n=m=0$ mapping to $0$.
Comment: @wood well, that's what I tried to say. The mapping in case $0 \notin \mathbb{N}$ should be something like $(n, m) \mapsto \frac{(n + m - 2)(n + m - 1)}{2} + n$

Finding injection on natural numbers?


Error - No Transport , while trying to create an entity using json

Question: //Prepare 'Account' object and call create function
function createAccount() {

var new_nit = new Object();

// Set text field

new_nit.Name = "Maddy";
createRecord(new_nit, "new_nitSet", createAccountCompleted, null);

}

// This callback method executes on succesful account creation
function createAccountCompleted(data, textStatus, XmlHttpRequest) {

var nit = data;

alert("Account created; Id: ");

}

// This function creates record by making OData call
function createRecord(entityObject, odataSetName, successCallback, errorCallback) {

//Parse the entity object into JSON

var jsonEntity = window.JSON.stringify(entityObject);

// Get Server URL

var serverUrl = Xrm.Page.context.getServerUrl();

//The OData end-point

var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";

//Asynchronous AJAX function to Create a CRM record using OData

$.ajax({

type: "POST",

contentType: "application/json; charset=utf-8",

datatype: "json",

url: serverUrl + ODATA_ENDPOINT + "/" + odataSetName,

data: jsonEntity,

beforeSend: function (XMLHttpRequest) {

//Specifying this header ensures that the results will be returned as JSON.

XMLHttpRequest.setRequestHeader("Accept", "application/json");

},

success: function (data, textStatus, XmlHttpRequest) {

if (successCallback) {

successCallback(data.d, textStatus, XmlHttpRequest);

}

},

error: function (XmlHttpRequest, textStatus, errorThrown) {

if (errorCallback)

errorCallback(XmlHttpRequest, textStatus, errorThrown);

else

alert("Error on the creation of record; Error – "+errorThrown);

}

});

}

I'm using above code to create a entity called nit. I have json2 and jQuery js files in web resource. When i run this code on button click, i'm getting error as No Transport. when i searched , i got to know that this error is because of cross site scripting. How to enable cross site scripting or how to get rid of this error.
Comment: Add in the top line of your above function; should work fine.
Comment: Here in this [link](http://stackoverflow.com/questions/5241088/jquery-call-to-webservice-returns-no-transport-error), they have given solution as adding `jQuery.support.cors = true;` code to enable cross site scripting. But 'm not getting where to add this line. If in jQuery.js then in which function i need to add.
Answer:   function createAccount() {
var gid = Xrm.Page.getAttribute("new_syllabus").getValue();
var stamail = new Object();
stamail.new_name = "Maddy";
stamail.new_gid = gid;
var myurl = "http://" + window.location.host + "/" + Xrm.Page.context.getOrgUniqueName();
//alert(gid);
// alert(Xrm.Page.data.entity.getId());

var jsoEntity = JSON.stringify(stamail);
var createRecordReq = new XMLHttpRequest();

var ODataPath = myurl + "/XRMServices/2011/OrganizationData.svc";

createRecordReq.open("POST", ODataPath + "/new_nitSet", false);
createRecordReq.setRequestHeader("Accept", "application/json");
createRecordReq.setRequestHeader("Content-Type", "application/json; charset=utf-8");

// createRecordReq.onreadystatechange = function () { requestCallBack(this); };
createRecordReq.send(jsoEntity);

var newRecord = JSON.parse(createRecordReq.responseText).d;

}

Instead of using ajax i used above code. Its working fine.


Will inverse DWT of approx. coefficients results in an approximate signal in original space?

Question: I have a signal $y$ in real-time space $V_0$. Hence assume $y = y^0$, the approximation coefficients of the signal at level $V^0$ (as per Mallat's pyramidal algorithm). I applied DWT and obtained approximation coeffcients $y_a^1 \in V^1$ and detail coefficients $y_d^1 \in W^1$. Now, I apply inverse DWT to $y_a^1$ by appending zero to all detail coefficients (i.e. $y_d^1 = 0$) and obtain $\hat{y}^0$. My question is whether $\hat{y}^0$ lies in $V^0$. As we neglected all the detail coefficients, does it result in different space? I am not a mathematician, but would like to know the answer to complete a proof in controllability.
Answer: The inverse DWT produces a linear combination of basis functions of $V_0$, thus of course results in an element of $V_0$, whatever the average and detail coefficients are.
Presumably your DWT is orthogonal, then the setting to zero of the detail coefficients is a projection, thus the norm of the reconstructed signal is smaller than the norm of the original signal.
You should care for terminology, $V_j,W_j$ are subspaces of $L^2(\Bbb R)$, as you also initially say. So if $y^0$ is a function of continuous time, so are $y^1_a,y^1_d$. The spaces of coefficient sequences are always the full $\ell^2(\Bbb Z)$, thus there are no questions of inclusion in subspaces.


Error while trying to print the pdf file

Question: I was trying to print a pdf document in the background using a console application. I used the process for doing it. The console application sends the pdf file to the printer, But the adobe reader that is opened in the background in minimized mode is throwing the following error "There was an error opening this document. This file cannot be found". As a result of this while printing multiple times, I was not able to kill the process. Is there any possibility of getting rid of this error?
My requirement is to print the pdf file using process and while doing that the pdf file must be opened in the minimized mode and once done printing the reader needs to be closed automatically. I have tried the following code, but still throws the error..
string file = "D:\\hat.pdf";
PrinterSettings ps = new PrinterSettings();
string printer = ps.PrinterName;
Process.Start(Registry.LocalMachine.OpenSubKe(@"SOFTWARE\Microsoft\Windows\CurrentVersion"+@"\App Paths\AcroRd32.exe").GetValue("").ToString(),string.Format("/h /t \"{0}\" \"{1}\"", file, printer));

Answer: since you want to have Acrobat reader open in the background when you want to print the document, you could use something like:
private static void RunExecutable(string executable, string arguments)
{
   ProcessStartInfo starter = new ProcessStartInfo(executable, arguments);
   starter.CreateNoWindow = true;
   starter.RedirectStandardOutput = true;
   starter.UseShellExecute = false;

   Process process = new Process();
   process.StartInfo = starter;
   process.Start();

  StringBuilder buffer = new StringBuilder();
  using (StreamReader reader = process.StandardOutput)
  {
    string line = reader.ReadLine();
    while (line != null)
    {
      buffer.Append(line);
      buffer.Append(Environment.NewLine);
      line = reader.ReadLine();
      Thread.Sleep(100);
    }
  }
  if (process.ExitCode != 0)
 {
    throw new Exception(string.Format(@"""{0}"" exited with ExitCode {1}. Output: {2}",
executable, process.ExitCode, buffer.ToString());
 }

}
You can print your PDF by incorporating the above code into your project and using it as follows:
string pathToExecutable = "c:\...\acrord32.exe";
RunExecutable(pathToExecutable, @"/t ""mytest.pdf"" ""My Windows PrinterName""");

this code was taken from http://aspalliance.com/514_CodeSnip_Printing_PDF_from_NET.all
If you do not need to have Acrobat Reader open in the background, and just print the pdf like any other document, you can have a look at the PrintDocument class:
http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.print.aspx


Who is credited with the conjecture that all odd squares are solitary?

Question: Let $\sigma(x)$ be the sum of the divisors of the positive integer $x$.  For example, $\sigma(6)=1+2+3+6=12$ and $\sigma(28)=1+2+4+7+14+28=56$.
Denote the abundancy index $I$ of $x$ by
$$I(x)=\frac{\sigma(x)}{x}.$$
If a positive integer $y$ is one of at least two solutions of
$$I(y)=\frac{a}{b}$$
for a given rational number $a/b$, then $y$ is called a friendly number.
Here is a formal definition:
DEFINITION. Let $x$ and $y$ be distinct positive integers.  If $x$ and $y$ satisfy the equation $I(x)=I(y)$ then $(x,y)$ is called a friendly pair.  Each member of the pair is called a friendly number.  (In other words, $x$ is a friend of $y$, and $y$ is also a friend of $x$.)  A number which is not friendly is called a solitary number.
Checking the first few odd squares $N$ gives us $\gcd(N,\sigma(N))=1$, which by Greening's Theorem means that such $N$ are solitary.  Since Greening's Theorem that

$\gcd(N,\sigma(N))=1$ implies that $N$ is solitary.

is sufficient (but not necessary), "it's easy to find odd squares for which $\gcd(n, \sigma(n))$ is not equal to $1$; e.g. if  $n = {21}^2 = 441$  then $\gcd(n, \sigma(n)) = 3$.  But $441$ is solitary." (Dean Hickerson, personal communication via e-mail, Mar. 12, 2011)
Here is my question:

Who is credited with the conjecture that all odd squares are solitary?
Comment: This was inspired by comments to your other question [Does $k=9018009$ have a friend?](http://math.stackexchange.com/questions/1922297/).
Comment: @JeppeStigNielsen, indeed!  Thanks for pointing that out.  Nonetheless, the question is interesting in its own right.
Answer: In an answer to a related MSE question (as hinted by Jeppe Stig Nielsen in the comments), it is conjectured that $9018009 = {3003}^2$ is not solitary.
It remains to find a friend of $9018009$, or to prove that none exists.


Is it possible to put a user control into a context menu

Question: I don't know if this is possible but does anyone know if there is a way to put a user control inside a context menu, I have a dialog for adding items to a list but I would like when I click the add button for the control to be displayed in the context menu instead. (dont like having a lot of dialog's in my app).
Here is what I tried but it doesn't work:
<code><Button  Grid.Column="2" Grid.Row="1" Content="Add Item" HorizontalAlignment="Right">
    <Button.ContextMenu>
        <ContextMenu>
            <MenuItem>
                <vm:MyControlView/>
            </MenuItem>
        </ContextMenu>
    </Button.ContextMenu>
</Button>
</code>
Is there a way to achieve this? (or something similar)
Comment: Can you define "doesn't work"?
Comment: What's the crash? What's the call stack?
Comment: crashes when button is loaded
Answer: You could try this link, it looks like you might be able to extend ContextMenu like John Dunn did to meet your needs.


How to understand a 32 bar progression

Question: I am learning some country progressions. There is a waltz time 32 bar progression in the style of some old Tex Ritter song, I think. It's not just two 16 bar progressions (the last two 16 bars are different from the first).
My two questions are:

Is there anything as a standard 32 bar progression?
In blues you often use standard progressions and jam around the chords. Does it work the same with this kind of music?
Comment: I feel like jamming around the chords is a possibility for any kind of music, assuming you either know the chords or have a chord chart in front of you.
Comment: There are a few common 32-bar progressions: AABA and ABAC are two.
Answer: It's a very common form for modern music and it can be seen in one of the most iconic standards I Got Rhythm and other rhythm changes songs. The changes for that song are depicted below.

The basic form breaks down to an AA'BA where each letter is an 8 bar phrase. The A sections are obviously the same. A' is mostly A, but with a slightly different ending to get you to the B section which is very different from the A section. If you are interested in the specific analysis of this piece, Wiki as a very nice article about it in depth.
Improvisation and jamming is the same as any other form and in general, unless the form you pick is too hard to "feel" you should have no problem jamming on it. There are plenty of changes to play over and you can trade fours although trading eights would better fit this specific form.

How to understand a 32 bar progression


If $D$ is an integral domain, show $M_n(D)$ is a prime ring

Question: So for $M_n(D)$ to be a prime ring it means that if $A$,$B$ are ideals of $M_n(D)$ and $AB=0$ then either $A=0$ or $B=0$.
The fact that $D$ is an integral domain seems quite crucial, because this means that if $a,b \in D$ and $ab=0$ then either $a=0$ or $b=0$.
Anyway, lets let $A,B$ be ideals of $D$ s.t. $AB=0$.
$AB = \{ab : a \in A, b \in B\}$
I have also deduced that if $A$ is an ideal of $M_n(D)$, then $A$ is of the form $M_n(I)$ where $I$ is an ideal of $D$.
I'm gonna need some advice from this point.. Thanks everyone!
Comment: It seems by "ideals of $M_n(D)$" you probably mean two-sided ideals?  (Otherwise, for example $\{ A \mid A e_1 = 0 \}$ would be a left ideal not equal to $M_n(I)$ for any $I$.)
Answer: Assume that $A,B \ne 0$.
Let $M = (a_{ij})\in A$ with $M \ne 0$. There exists an element $a_{rs} \ne 0$.
Denote $E_{ij}$ the matrix with $1$ as the position $(i,j)$ and $0$ elsewhere. We have
$$a_{rs}E_{11} = E_{1r}ME_{s1} \in A$$
Similarly, take $N = (b_{ij})\in B$ with $b_{kl} \ne 0$ so $b_{kl}E_{11} \in B$.
Therefore
$$0 \ne (a_{rs}b_{kl})E_{11} = (a_{rs}E_{11})(b_{kl}E_{11}) \in AB$$
Note that $a_{rs}b_{kl} \ne 0$ because $D$ is an integral domain.
Answer: Let's prove the contrapositive: if $A \ne 0$ and $B \ne 0$, then $AB \ne 0$.
Using your fact, let $A = M_n(I)$ and $B = M_n(J)$ for some ideals $I,J$ of $D$. If $A \ne 0$ and $B \ne 0$, then there are nonzero elements $x \in I$ and $y \in J$, so that $x\mathbf{1} \in A$ and $y\mathbf{1} \in B$, where $\mathbf{1}$ is the identity matrix (so $x\mathbf{1}$ is the matrix with $x$ on the diagonal and $0$ elsewhere). Then $xy\mathbf{1} = (x\mathbf{1})(y\mathbf{1}) \in AB$ is nonzero since $D$ is an integral domain.
Answer: Another way: with not much effort you can show that $M_n(I)M_n(J)=M_n(IJ)$.
Then $M_n(I)M_n(J)=M_n(IJ)=M_n(0)$ implies $I=0$ or $J=0$.
Superficially it looks like we're not using elements of $R$, but you would probably prove my initial claim with elements.


Oracle SQL merge tables without specifying columns

Question: I have a table people with less than 100,000 records and I have taken a backup of this table using the following:
create table people_backup as select * from people

I add some new records to my people table over time, but eventually I want to merge the records from my backup table into people. Unfortunately I cannot simply DROP my table as my new records will be lost!
So I want to update the records in my people table using the records from people_backup, based on their primary key id and I have found 2 ways to do this:

MERGE the tables together
use some sort of fancy correlated update

Great! However, both of these methods use SET and make me specify what columns I want to update. Unfortunately I am lazy and the structure of people may change over time and while my CTAS statement doesn't need to be updated, my update/merge script will need changes, which feels like unnecessary work for me.
Is there a way merge entire rows without having to specify columns? I see here that not specifying columns during an INSERT will direct SQL to insert values by order, can the same methodology be applied here, is this safe?
NB: The structure of the table will not change between backups
Comment: Given that your table is small, could you simply `delete` anything from the table that exists in the backup and then do an `insert` of everything in the backup?  That's slow and not particularly elegant but it meets your requirements.
Comment: You always need to specify which columns will be updated. That's just how it works. You could, however, write a script to write a script - eg. `select 'set tgt.'||column_name||' = src.'||colunn_name||',' from user_tab_columns where table_name = 'TABLE_NAME';` that would at least be able to generate the list of columns for you, so you can copy and paste into your statement
Comment: Do you want to replace new data with old?
Comment: @JustinCave if you could post as answer I'll accept
Answer: Given that your table is small, you could simply
DELETE FROM table t
 WHERE EXISTS( SELECT 1
                 FROM backup b
                WHERE t.key = b.key );

INSERT INTO table
  SELECT *
    FROM backup;

That is slow and not particularly elegant (particularly if most of the data from the backup hasn't changed) but assuming the columns in the two tables match, it does allow you to not list out the columns.  Personally, I'd much prefer writing out the column names (presumably those don't change all that often) so that I could do an update.


Enable Textbox if any selection is made in a combobox in Access

Question: Hey I am trying to get a textbox to enable based on if someone selects any value in a combobox it does not have to be a specific one just any value. This is the code I have so far and I am getting a Type Mismatch error, but my field type is short text.
Private Sub cmbOwner2_Click()
If Me.cmbOwner2.Value Then
Me.txtOwner2.Enabled = True
Else
Me.txtOwner2.Enabled = False
End If
End Sub

Thanks in advance! Also, I am using VBA if thats not obvious lol
Answer: try this
Private Sub cmbOwner2_Click()
If Me.cmbOwner2.Value <> "" Then
Me.txtOwner2.Enabled = True
Else
Me.txtOwner2.Enabled = False
End If
End Sub

Comment: You rock! Thanks so much :)
Comment: you're welcome, and if your question is answered please use the tick :)
Comment: I will it told me I had to wait 6 more minutes for some reason.
Comment: Ok, I guess in case of editing or similar reasons. If you need further help any time, don't hesitate to contact us. :)
Comment: I cant ask more than one question on one page right?
Comment: Of course you can ask more than one question. But use one paige for a single problem only. e.g. don't ask multiple questions to different macros, when they don't rely to each other.
Comment: Ok cool I asked another question on another page not getting what I need though :/ lol


$_POST data does not work with ../ 1 up folder action

Question: My form $_POST data works perfectly fine when I put the action.php file in the same directly as in my index.php on my hosting, when I move the php file up 1 folder and into the includes folder like so:

<form id="test" action="action.php"  method="POST" >

<form id="test" action="../includes/action.php"  method="POST" >

Folder Structure that DOES work
(ROOT DIR)Test form
-js
-img
-index.php
-action.php

Folder Structure that DOES NOT work
(ROOT DIR) includes
- action.php
(ROOT DIR) Test form
-js
-img
-index.php

even set the includes folder persmissions to chmod 777, no luck. put the file back in the same directly and got the data print results just fine.
Any reason why this might occur? nothing changes but the form action. and once I do that all data is lost when I try to test it.
It is really odd.
Comment: is `ROOT DIR` the web root or just the root folder of your application?
Comment: the web root is the (ROOT DIR)
Answer: The way you are doing it
<form id="test" action="../includes/action.php"  method="POST" >

Means "yoursite.com/../includes/action.php" and it won't work.
Try doing:
<form id="test" action="/includes/action.php"  method="POST" >


Resultado de pesquisa via web service

Question: Estou construindo uma aplicação de busca (input) e ele deve trazer o resultado de um webservice.
Exemplo:
xhttp.open("POST", "https://www.site.br/api/v1/busca/termo/_pesquisa", true);
xhttp.setRequestHeader("Content-type", "application/json");
var data = JSON.stringify({"order":"relevancia","pagina":1,"q":"*"});
xhttp.send(data);

O retorno deste código traz o JSON puro do web service e eu gostaria de organizar os dados de acordo com meu HTML, com título, nome e descrição (vindo, claro, do webservice).
Há algum exemplo prático que eu possa fazer?
Obrigado, desde já.
Comment: se pesquisar aqui no site tem vários exemplos, como esse: [acessar o valor de um objeto json](https://pt.stackoverflow.com/questions/391583/n%C3%A3o-consigo-acessar-valor-de-um-objeto-json-e-exibi-lo-na-div)
Comment: Obrigado, @Ricardo. Resolveu pra mim
Answer: Você pode pegar o Json puro e realizar o "parse"
let jsonData = jsonRetorno.parse();
E depois vc pode usar o objeto Json:
   console.log(jsonData.titulo);
   console.log(jsonData.nome);
   console.log(jsonData.descricao);

Comment: Isso foi bem útil, vou usar daqui pra frente.

Resultado de pesquisa via web service


Video orientation after launched from UIWebView

Question: I have an UIWebView that has an youtube's embed code (iframe). I'd like to enable both portrait and horizontal orientation for the video player, but portrait mode only for the UIWebView itself.
How can I achieve this?
Answer: The UIWebView displays its content by its orientation. There is no (easy) way to conditionally change which orientations the UIWebView allows based on its content. The only way I can imagine this working is by parsing the HTML of the web view and based on its content, allowing or disallowing certain orientations.
Regardless of all this, I would suggest either allowing both portrait and landscape for both, or only allowing portrait. This would be confusing to users if you only sometimes allowed landscape.


Como filtrar uma lista tipo IEnumerable<> através de outro IEnumerable<>?

Question: Como filtrar uma lista tipo IEnumerable<> passando um parâmetro do tipo IEnumerable<> de preferência via expressão lambda ou linq?
Baseando-se no filtro abaixo eu espero esse resultado:
{MundoId = 0, ContinenteId = "AMERICA DO SUL",   PaisId = "PERU",     UFId = "LIMA" },
{MundoId = 0, ContinenteId = "AMERICA DO SUL",   PaisId = "COLOMBIA", UFId = "BOGOTÁ" },
{MundoId = 0, ContinenteId = "AMERICA DO NORTE", PaisId = "EUA",      UFId = "NOVA IORQUE" }

Action:
 public ActionResult Index() {
     var mundo = new List < Mundo > {
      new Mundo {
       MundoId = 0, ContinenteId = 1, PaisId = 2, UFId = 4
      },
      new Mundo {
       MundoId = 0, ContinenteId = 1, PaisId = 3, UFId = 7
      },
      new Mundo {
       MundoId = 0, ContinenteId = 2, PaisId = 4, UFId = 10
      }
     };
     var _mundo = mundo.ToList();

     IEnumerable < Mundo > _mundoFiltrado = FiltrarMundo(_mundo);

     return View(_mundoFiltrado);
    }

Método Filtrar:
public IEnumerable < Mundo > FiltrarMundo(IEnumerable < Mundo > pMundo) {#
 region::lista Mundo::
  var mundo = new List < Mundo > {
   new Mundo {
    MundoId = 1, ContinenteId = 1, PaisId = 1, UFId = 1
   },
   new Mundo {
    MundoId = 2, ContinenteId = 1, PaisId = 1, UFId = 2
   },
   new Mundo {
    MundoId = 3, ContinenteId = 1, PaisId = 1, UFId = 3
   },
   new Mundo {
    MundoId = 4, ContinenteId = 1, PaisId = 2, UFId = 4
   },
   new Mundo {
    MundoId = 5, ContinenteId = 1, PaisId = 2, UFId = 5
   },
   new Mundo {
    MundoId = 6, ContinenteId = 1, PaisId = 2, UFId = 6
   },
   new Mundo {
    MundoId = 7, ContinenteId = 1, PaisId = 3, UFId = 7
   },
   new Mundo {
    MundoId = 8, ContinenteId = 1, PaisId = 3, UFId = 8
   },
   new Mundo {
    MundoId = 9, ContinenteId = 1, PaisId = 3, UFId = 9
   },
   new Mundo {
    MundoId = 10, ContinenteId = 2, PaisId = 4, UFId = 10
   },
   new Mundo {
    MundoId = 11, ContinenteId = 2, PaisId = 4, UFId = 11
   },
   new Mundo {
    MundoId = 12, ContinenteId = 2, PaisId = 4, UFId = 12
   },
   new Mundo {
    MundoId = 13, ContinenteId = 2, PaisId = 5, UFId = 13
   },
   new Mundo {
    MundoId = 14, ContinenteId = 2, PaisId = 5, UFId = 14
   },
   new Mundo {
    MundoId = 15, ContinenteId = 2, PaisId = 5, UFId = 15
   },
   new Mundo {
    MundoId = 16, ContinenteId = 2, PaisId = 6, UFId = 16
   },
   new Mundo {
    MundoId = 17, ContinenteId = 2, PaisId = 6, UFId = 17
   },
   new Mundo {
    MundoId = 18, ContinenteId = 2, PaisId = 6, UFId = 18
   },
   new Mundo {
    MundoId = 19, ContinenteId = 3, PaisId = 7, UFId = 19
   },
   new Mundo {
    MundoId = 20, ContinenteId = 3, PaisId = 7, UFId = 20
   },
   new Mundo {
    MundoId = 21, ContinenteId = 3, PaisId = 7, UFId = 21
   },
   new Mundo {
    MundoId = 22, ContinenteId = 3, PaisId = 8, UFId = 22
   },
   new Mundo {
    MundoId = 23, ContinenteId = 3, PaisId = 8, UFId = 23
   },
   new Mundo {
    MundoId = 24, ContinenteId = 3, PaisId = 8, UFId = 24
   },
   new Mundo {
    MundoId = 25, ContinenteId = 3, PaisId = 9, UFId = 25
   },
   new Mundo {
    MundoId = 26, ContinenteId = 3, PaisId = 9, UFId = 26
   },
   new Mundo {
    MundoId = 27, ContinenteId = 3, PaisId = 9, UFId = 27
   },
   new Mundo {
    MundoId = 28, ContinenteId = 4, PaisId = 10, UFId = 28
   },
   new Mundo {
    MundoId = 29, ContinenteId = 4, PaisId = 10, UFId = 29
   },
   new Mundo {
    MundoId = 30, ContinenteId = 4, PaisId = 10, UFId = 30
   },
   new Mundo {
    MundoId = 31, ContinenteId = 4, PaisId = 11, UFId = 31
   },
   new Mundo {
    MundoId = 32, ContinenteId = 4, PaisId = 11, UFId = 32
   },
   new Mundo {
    MundoId = 33, ContinenteId = 4, PaisId = 11, UFId = 33
   },
   new Mundo {
    MundoId = 34, ContinenteId = 4, PaisId = 12, UFId = 34
   },
   new Mundo {
    MundoId = 35, ContinenteId = 4, PaisId = 12, UFId = 35
   },
   new Mundo {
    MundoId = 36, ContinenteId = 4, PaisId = 12, UFId = 36
   }
  };#
 endregion

 # region::Lista Continente
 var continente = new List < Continente > {
  new Continente {
   ContinenteId = 1, Nome = "AMERICA DO SUL"
  },
  new Continente {
   ContinenteId = 2, Nome = "AMERICA DO NORTE"
  },
  new Continente {
   ContinenteId = 3, Nome = "EUROPA"
  }
 };#
 endregion

 # region::Lista Pais::
  var pais = new List < Pais > {
   new Pais {
    PaisId = 1, ContinenteId = 1, Nome = "BRASIL"
   },
   new Pais {
    PaisId = 2, ContinenteId = 1, Nome = "PERU"
   },
   new Pais {
    PaisId = 3, ContinenteId = 1, Nome = "COLOMBIA"
   },
   new Pais {
    PaisId = 4, ContinenteId = 2, Nome = "EUA"
   },
   new Pais {
    PaisId = 5, ContinenteId = 2, Nome = "CANADA"
   },
   new Pais {
    PaisId = 6, ContinenteId = 2, Nome = "MÉXICO"
   },
   new Pais {
    PaisId = 7, ContinenteId = 3, Nome = "FRANÇA"
   },
   new Pais {
    PaisId = 8, ContinenteId = 3, Nome = "INGLATERRA"
   },
   new Pais {
    PaisId = 9, ContinenteId = 3, Nome = "ITÁLIA"
   }
  };#
 endregion

 # region::Lista UF::
  var uf = new List < UF > {
   new UF {
    UFId = 1, PaisId = 1, Nome = "UF 1"
   },
   new UF {
    UFId = 2, PaisId = 1, Nome = "UF 2"
   },
   new UF {
    UFId = 3, PaisId = 1, Nome = "UF 3"
   },
   new UF {
    UFId = 4, PaisId = 2, Nome = "UF 4"
   },
   new UF {
    UFId = 5, PaisId = 2, Nome = "UF 5"
   },
   new UF {
    UFId = 6, PaisId = 2, Nome = "UF 6"
   },
   new UF {
    UFId = 7, PaisId = 3, Nome = "UF 7"
   },
   new UF {
    UFId = 8, PaisId = 3, Nome = "UF 8"
   },
   new UF {
    UFId = 9, PaisId = 3, Nome = "UF 9"
   },
   new UF {
    UFId = 10, PaisId = 4, Nome = "UF10"
   },
   new UF {
    UFId = 11, PaisId = 4, Nome = "UF11"
   },
   new UF {
    UFId = 12, PaisId = 4, Nome = "UF12"
   },
   new UF {
    UFId = 13, PaisId = 5, Nome = "UF13"
   },
   new UF {
    UFId = 14, PaisId = 5, Nome = "UF14"
   },
   new UF {
    UFId = 15, PaisId = 5, Nome = "UF15"
   },
   new UF {
    UFId = 16, PaisId = 6, Nome = "UF16"
   },
   new UF {
    UFId = 17, PaisId = 6, Nome = "UF17"
   },
   new UF {
    UFId = 18, PaisId = 6, Nome = "UF18"
   },
   new UF {
    UFId = 19, PaisId = 7, Nome = "UF19"
   },
   new UF {
    UFId = 20, PaisId = 7, Nome = "UF20"
   },
   new UF {
    UFId = 21, PaisId = 7, Nome = "UF21"
   },
   new UF {
    UFId = 22, PaisId = 8, Nome = "UF22"
   },
   new UF {
    UFId = 23, PaisId = 8, Nome = "UF23"
   },
   new UF {
    UFId = 24, PaisId = 8, Nome = "UF24"
   },
   new UF {
    UFId = 25, PaisId = 9, Nome = "UF25"
   },
   new UF {
    UFId = 26, PaisId = 9, Nome = "UF26"
   },
   new UF {
    UFId = 27, PaisId = 9, Nome = "UF27"
   }
  };#
 endregion

 var _continente = continente.ToList();
 var _pais = pais.ToList();
 var _uf = uf.ToList();

 //Preciso fazer o filtro aqui:
 var _mundo = mundo.ToList();

 return _mundo;
}

Entidades
    public class Mundo {
 public int MundoId {
  get;
  set;
 }
 public int ContinenteId {
  get;
  set;
 }
 public int PaisId {
  get;
  set;
 }
 public int UFId {
  get;
  set;
 }
}

public class Continente {
 public int ContinenteId {
  get;
  set;
 }
 public int PaisId {
  get;
  set;
 }
 public string Nome {
  get;
  set;
 }

}

public class Pais {
 public int PaisId {
  get;
  set;
 }
 public int ContinenteId {
  get;
  set;
 }
 public string Nome {
  get;
  set;
 }
 public ICollection < Continente > Continente {
  get;
  set;
 }

}

public class UF {
 public int UFId {
  get;
  set;
 }
 public int PaisId {
  get;
  set;
 }
 public string Nome {
  get;
  set;
 }
 public ICollection < Pais > Pais {
  get;
  set;
 }

}

Comment: Deculpe-me não sei exatamente o que quer dizer com comparar objetos rs... eu preciso retornar dados da Entidade Mundo baseado nos parâmetros que estou passando.
Comment: @AdrianoSUV Qual seria o resultado esperado dado o seu código acima?
Answer: Entendi que com base em um IEnumerable você quer filtrar em outro. Com o método Any você irá conseguir o que deseja, adicione ao método FiltraMundo:
 IEnumerable<Mundo> filtered = mundo
                   .Where(x => pMundo.Any(y => y.MundoId == x.MundoId)).ToList<Mundo>();

Comment: @AdrianoSUV é só ajustar pra outro que deseja.
Comment: realmente nem passou pela minha cabeça alterar as chaves, mas fica de lição e uma boa alternativa.
Comment: Exatamente, porém eu vou ajustar o Id do filtro porque fiz uma confusão e vou testar a implementação e darei um retorno.
Comment: @AdrianoSUV ok, no aguardo aqui. Tomara que ajude você!
Comment: nesse caso o atributo `MundoId` não pode fazer parte pois na passagem do filtro `MundoId` é igual a 0.
Answer: Você pode utilizar algo assim para obter um objeto mais completo :
var query = from r in pMundo
        join l in mundo on new { r.MundoId, r.ContinenteId, r.PaisId, r.UFId }
                equals new { l.MundoId, l.ContinenteId, l.PaisId, l.UFId } into mundos
        from m in mundos
        join c in continente on m.ContinenteId equals c.ContinenteId
        join p in pais on m.PaisId equals p.PaisId
        join u in uf on m.UFId equals u.UFId
        select new
        {
            m.ContinenteId,
            NomeContinente = c.Nome,
            m.PaisId,
            NomePais = p.Nome,
            m.UFId,
            NomeUF = u.Nome
        };

ou simplesmente fazer assim:
var query = from r in pMundo
        join l in mundo on new { r.MundoId, r.ContinenteId, r.PaisId, r.UFId }
                equals new { l.MundoId, l.ContinenteId, l.PaisId, l.UFId } into mundos
        from m in mundos
        join c in continente on m.ContinenteId equals c.ContinenteId
        join p in pais on m.PaisId equals p.PaisId
        join u in uf on m.UFId equals u.UFId
        select r;

Comment: funcionou ! eu só tirei o atributo MundoId da query pois na passa dos parâmetros ele é igual a 0.
Comment: Vou testar e darei um retorno, obrigado.
Answer: Você pode escrever o seu método de filtrar com dois parâmetros, um com a lista fonte a ser filtrada e outro com os filtros. Exemplo:
 static IEnumerable<Mundo> FiltrarMundo(IEnumerable<Mundo> mundos, IEnumerable<Mundo> filtros)
        {
            var mundoFiltrado = new List<Mundo>();

            foreach (var item in filtros)
            {
                mundoFiltrado.AddRange(mundos.Where(
                    m => m.ContinenteId == item.ContinenteId &&
                    m.MundoId == item.MundoId &&
                    m.PaisId == item.PaisId &&
                    m.UFId == item.UFId
                ));
            }

            return mundoFiltrado;
        }


The summation of independent random variables

Question: The random variables $N, X_1, X_2,...$ are independent, $N \in Po(\lambda) $, and $X_k \in Be(\frac{1}{2}),\ k \geq1$
$Y_1=\sum_{k=1}^{N}X_k \ and \ Y_2=N-Y_1$
I need to show that $Y_1 \ and \ Y_2$ are independent and find their distributions. This is from the conditional distributions chapter, so the solution can't really use the advanced tricks.
I am not sure where to begin, since I have solved the summation of only 2 variables before.
Please help.
Answer: To show they are independent, you need to show
$$P(Y_1=y_1, Y_2=y_2) = P(Y_1 = y_1) \cdot P(Y_2 = y_2)$$
for any $y_1$ and $y_2$ both integers in $\{0,1,2,\ldots\}$.

Hint to get you started:
\begin{align}
P(Y_1=y_1, Y_2=y_2)
&= P(Y_1=y_1, Y_2=y_2, N=y_1+y_2)
\\
&= P(Y_1=y_1, Y_2=y_2 \mid N=y_1+y_2) \cdot P(N=y_1+y_2)
\\
&= P\left(\sum_{k=1}^{y_1+y_2} X_k = y_1\right) \cdot P(N=y_1+y_2).
\end{align}


Doxygen - Variable documented but not defined when it really is?

Question: I have the following
    static uint8_t sreadBuf [SERIAL_BUF_SIZE]  __attribute__ ((section (".data.$SDRAM_B0_HEAP"))) = {0};

The top of the file has the appropriate doxygen stuff
 /**
 * \file blah.cpp
 * \brief blah implmentation
*/

Doxygen throws the following warning: warning: documented symbol 'static uint8_t sreadBuf' was not declared or defined.
Other static variables (and buffers) in the same file have no issues, doxygen doesn't complain and they are all declared the same way (they even have documentation strings).
Here is the output of doxygen -x Doxyfile:
# Difference with default Doxyfile 1.10.0 (ebc57c6dd303a980bd19dd74b8b61c8f3f5180ca)
PROJECT_NAME           = "redacted"
PROJECT_NUMBER         = 1234
PROJECT_BRIEF          = "redacted"
OUTPUT_DIRECTORY       = ./doxygen
OPTIMIZE_OUTPUT_FOR_C  = YES
BUILTIN_STL_SUPPORT    = YES
EXTRACT_STATIC         = YES
CASE_SENSE_NAMES       = YES
INPUT                  = ./source
FILE_PATTERNS          = *.c \
                         *.cc \
                         *.cxx \
                         *.cpp \
                         *.c++ \
                         *.java \
                         *.ii \
                         *.ixx \
                         *.ipp \
                         *.i++ \
                         *.inl \
                         *.idl \
                         *.ddl \
                         *.odl \
                         *.h \
                         *.hh \
                         *.hxx \
                         *.hpp \
                         *.h++ \
                         *.cs \
                         *.d \
                         *.php \
                         *.php4 \
                         *.php5 \
                         *.phtml \
                         *.inc \
                         *.m \
                         *.markdown \
                         *.md \
                         *.mm \
                         *.dox \
                         *.py \
                         *.pyw \
                         *.f90 \
                         *.f95 \
                         *.f03 \
                         *.f08 \
                         *.f18 \
                         *.f \
                         *.for \
                         *.vhd \
                         *.vhdl \
                         *.ucf \
                         *.qsf \
                         *.ice
RECURSIVE              = YES
EXCLUDE                = ./source/ArduinoJson-v7.0.0.hpp \
                         ./source/lwipopts.h \
                         ./source/FreeRTOSConfig.h \
                         ./source/LICENSES.h \
                         ./source/semihost_hardfault.c
EXCLUDE_PATTERNS       = *.bak
MATHJAX_RELPATH        = https://cdn.jsdelivr.net/npm/mathjax@2
HAVE_DOT               = YES

Why is doxygen saying the symbol is documented but not declared or defined? It very clearly is declared and defined, and gcc throws no fits. If anything it's not documented.
Comment: Which version of doxygen? Just post the result of `doxygen -x Doxyfile` which gives the settings different from the default settings. Post a, small, complete example showing the issue.
Comment: @albert updated, but in the process of building the complete example I got different results, which pointed me to the answer I actually posted. Thanks!
Answer: I managed to find the root cause:
__attribute__ ((section (".data.$SDRAM_B0_HEAP"))) was confusing doxygen. Even though it goes against from what I've seen in the standards, moving the __attribute__ section before the definition seems to make doxygen happy.
/**
 * \brief Upper layer serial read buffer
 */
static __attribute__ ((section (".data.$SDRAM_B0_HEAP"))) uint8_t sreadBuf
[SERIAL_BUF_SIZE] = {0};

Works
Comment: `__attribute__` is not a standard term, it is a GNU extension. See for this also the chapter in the doxygen manual about preprocessing (file:///D:/Program%20Files/doxygen/html/preprocessing.html) and search in this chapter for `__attribute__`.


How to create a data provider for use with Excel

Question: Excel (2010) has functionality to create pivot tables from an external data source like from Access, From Web and other data sources like SQL server and ODBC. Suppose I have created a new database system called X and I want to create the functionality that Excel can connect to this X using a data provider (not an Excel Add-in). What do I develop and where do I start?
Comment: Question is constructive. There are only few valid answers to it.
Answer: Excel can use any ADO.NET driver If I'm not mistaken. So all you need to do is to follow the following guide. Here is a more detailed description from MSDN Magazine.
You'll need to create an OleDb driver if Excel doesn't support ADO.NET drivers.


500 server error on clear cache

Question: I am facing a pretty strange problem. I have installed Drupal 7 on my site. Whenever I install a module and tries to access the module's configure page after enabling the module, it leads me to simply /admin/config page without showing the option for that particular module configuration.
sometimes when I do a clear cache the problem gets resolved and then I can access the module's config page. but sometime after installing a module, clear cache gives Internal Server Error 500 .. also I tried to flush the cache manually by making a php file into / directory with the following code:
<?php
include_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
drupal_flush_all_caches();
?>

but this also gives Error 500.
When I disable the installed module, clear cache works as usual...
please help me.
Comment: Try increasing it to 256M or 512M, and then check.
Comment: What are the permissions on the root folder ?
Comment: @aerozeppelin  I am using shared hosting so can not set permissions on root folder, btw `.php` files are working when placed in root folder
Comment: I am not sure about this, but you could try increasing your php memory limit and then check if the problem still persists.
Comment: @aerozeppelin I have also tried by setting `ini_set('memory_limit', '64M');` in `settings.php` but problem remains the same
Comment: @aerozeppelin no effect :( tried with `ini_set('memory_limit', '512M');`   just to give more information, the 500 error page also comes up whenever I enable or disable a module (on loading http:///admin/modules/list/confirm page)
Comment: Check your php error_logs, you may get some information there.
Comment: @aerozeppelin Can you please tell me where to find these logs.
Comment: It should be outside your drupal root folder. Probably inside a folder called logs. If you can't find it, check your php.ini file to know its path
Comment: Is this can be the cause as I am seeing this notice in the drupal logs after enabling the module `Notice: Undefined variable: errstr in drupal_http_request() (line 836 of /home//htdocs/includes/common.inc).`
Answer: As directed by aerozeppelin I got the following error:

Fatal error: Allowed memory size of 50331648 bytes exhausted (tried to allocate 4096 bytes) in /home/htdocs/includes/database/query.inc on line 1857

So increasing the PHP memory limit is the cure; this link is useful for that.
Answer: In a file type
<?php
phpinfo();
?>

to know your php configuration. Here you can know the path of php error_log or type
<?php
print_r(error_get_last());
?>

to get the last error that occurred.
Comment: Try setting the error log using the following link, http://www.php.net/manual/en/errorfunc.configuration.php#ini.error-log. Without the error logs it would be a challenge to pin point the error.
Comment: erro_log is set to `no value`
unfortunately my hosting provider does not seem to provide that feature
can I explicitly set it?
Comment: whats the output of
Comment: I am getting no output (blank)
Comment: So i guess increasing the php memory limit of your server fixed this problem. Right?
Comment: I am pretty Sure it would fix the problem... But my hosting provider doesnt allow me to increase its memory limit (currently set to 48 M and for soomth functioning it should be at least 64M ), so I am unable to fix this issue,uninstalling some modules may be the way.
Answer: May be this is a late answer.But it will help for new people.

Try to add this in .htaccess file.

php_value memory_limit 64M
I hope this will help you to solve the Internal Server Error in Drupal 7
Comment: It's rather improbable that a php.ini in the root directory would be used from PHP.
Comment: yes adding php.ini is not a good method.But i could find it in few projects!

500 server error on clear cache


Container goes out of jumbotron

Question: I have a problem with my website, when I'm creating new element based on jumbotron. Above a certain height, container (main view in my element), goes out from jumbotron, and I haven't got any idea, what I did bad. Excluding Bootstrap, I'm using nk-o/jarallax.
HTML:

Slogan

Title

                                <form>

                                        <input type="text" id="newsletterName" class="form-control rounded-0" placeholder="Twoje imię" required>
                                        <input type="email" id="newsletterEmail" class="form-control rounded-0" placeholder="Adres e-mail" required>

                                    <button type="submit" class="btn bg-red rounded-0">Send</button>
                                </form>

Some text

CSS for jumbotron:
.jumbotron {
    background-color: #db1a1a;
}

.jumbotron.footer--jumbotron,
.jumbotron .footer--jumbotron {
    height: 70vh;
    margin-bottom: 0;
}

@media (max-width: 1199.98px) {
    .jumbotron {
        padding: 0 !important;
    }
}

@media (min-width: 1200px) {
    .jumbotron {
        padding: 1rem 1rem;
    }
}

.jarallax {
    position: relative;
    z-index: 0;
}

.jarallax .jarallax-img {
    position: absolute;
    object-fit: cover;
    font-family: 'object-fit: cover;';
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.jumbotron.jarallax,
.jumbotron .jarallax {
    height: 100%;
}

.jumbotron.jarallax .container,
.jumbotron .jarallax .container {
    top: 50%;
    left: 50%;
    position: absolute;
    transform: translate(-50%, -50%);
}

@media (min-width: 1200px) {
    .jarallax .col-lg-6.col-left-align {
        text-align: left;
    }

    .jarallax .col-lg-6.col-right-align {
        text-align: right;
    }
}

@media (max-width: 1199.98px) {
    .jarallax .col-lg-6.col-left-align {
        text-align: center;
    }

    .jarallax .col-lg-6.col-right-align {
        text-align: center;
    }
}

@media (max-width: 991.98px) {
    .jarallax .col-lg-6 {
        margin-left: 2rem;
        margin-right: 2rem;
    }

    .jarallax .col-lg-6 + .col-lg-6 {
        padding-top: 2rem;
        padding-right: 2rem;
    }
}

@media (min-width: 992px) {
    .jarallax .col-lg-6 {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

Image:

Thanks a lot for any help. :)
Answer: I tried to replicate your problem here in codepen.
The jumbotron container is a fixed height (70vh) and the child elements, like the form are fixed too, so at some point things will overflow.
.jumbotron.footer--jumbotron,
.jumbotron .footer--jumbotron {
    height: 70vh;
    margin-bottom: 0;
}

Quick fix will be to turn the parent container into a display: flex; then give the jumbotron flex: 8 and the footer flex:2 (or even better using grid)

body {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.footer {
  flex: 2;
  widht: 100%;
}

.jumbotron {
  background-color: #db1a1a;

Container goes out of jumbotron


Is shuffle double tonguing feasible on a brass instrument?

Question: Drummers are used to the idea of performing 16th note patterns with varying amounts of shuffle.
Brass players spend loads of effort perfecting even double-tonguing for performing extended 16th note passages. Double tonguing is often used to play 16th notes when the quarter-note tick is 120 bpm or faster.
Is it possible to shuffle double-tonguing on a brass instrument, so the 't' and 'k' notes are different lengths? I've tried to do this and I found it next to impossible, which doesn't mean that someone really good couldn't do it with ease. But I've never come across a recorded performance that uses this technique, or been given sheet music that requires it.
Is this because the technique is too hard? Or is it not a musically useful technique?
Edit - I realised I used the wrong rhythmic description. Swing refers to pairs of 8th notes. No brass player would double-tongue 8th notes. But shuffle (which I was really asking about) refers to pairs of 16th notes. So I've just replaced the word swing in this question with shuffle.
Comment: I can't imagine any reason it wouldn't be possible. I just tried it on my trombone and it didn't seem significantly more difficult to me. Are you talking about a super fast tempo?
Comment: Try doing it backwards.  Might sound odd but give it a try and see if it helps
Comment: Two names to check out: James Morrison, Scott Tinkler
Comment: Areel Xocha - can you be more specific? How about some YouTube links? And Some_Guy - do you mean articulating k-t rather than t-k?
Answer: I went to an excellent seminar many years ago by Jiggs Whigham where he described his technique of "doodle tonguing" for fast, swung passages: the longer note is started with the tip of the tongue against the roof of the mouth near the teeth, slightly further back than normal tonguing, then the shorter one is started with the middle of the tongue against the roof of the mouth.  The tongue's motion was very much like saying the word "doodle" repeatedly, hence the name of the technique.  I don't do much fast, swung stuff, but I found it quite effective when I tried.
Any errors in the above description are my memory and/or poor trombone technique playing me false, and no reflection on that excellent musician's teaching!
Answer: It can be done.  Swing is normally applied to 8th notes, alternate hard and soft tonguing is routine.  We double-tongue faster notes, where cleaner tonguing becomes impossible, and this isn't usually swing territory! But they don't HAVE to be played evenly.


how to apply css to a link within a particular div only?

Question: Here is my situation. I have 3 divs on my website. There is a button in each of divs. Here is my codes :

May I know how to apply css style to 1 button only without effect on other 2 buttons Css or Jquery? Note that I cannot change the class and id of the buttons.
Answer: Use a descendant selector:
#gg1 a.btn {
    /* styles here affect only a.btn elements within #gg1 */
}


how to pass variable from callback function to function call?

Question: Here i am sending sensor data to database using simple javascript (johnny five)
using this code
var five = require("johnny-five");
var pg = require("pg");
var conString = "pg://admin:raja@localhost:5432/data";
var client = new pg.Client(conString);

function call(n)
{
  client.connect();
  client.query("INSERT INTO sensordata (event) VALUES (n);");
}

var board = new five.Board();
board.on("ready", function() {

  var sensor = new five.Sensor.Digital(2);

  sensor.on("change", function() {
    var n = this.value;
    call(n);
  });
});

My question is can i pass the streaming data variable n in the sensor call back function to call method.
Comment: I don't understand the question. What's a "streaming data variable"? Also, according to [the Johnny-Five docs](https://github.com/rwaldron/johnny-five/wiki/Sensor), `value` is not a function.
Comment: Sensor data to database
Answer: I think, what you're looking here is a simple query templating, supported by all sql clients:
client.query("INSERT INTO sensordata (event) VALUES ($1);", n);

This way you'll be able to pass the value of n variable to your SQL query.
Update: And you don't have to call client.connect() before every call to client.query. You should only call it once to establish DB connection, after that pg.Client will use it to send all subsequent requests.


Show that there is always a proposition between two propositions logic

Question: Suppose we define the following relationship of ordering between propositions in PROP:
$$
\phi < \psi := (\models \phi \rightarrow \psi \land \lnot(\models \psi \rightarrow \phi) )
$$
Show that if exists $\phi$ and $\psi$ such that:
$$
\phi < \psi
$$
Then there is a $\sigma$ such that:
$$
\phi < \sigma < \psi
$$
I have tried to use valuation to find what $\sigma$ could possibly be, so for all valuations v:

If $v(\phi)=0$ and $v(\psi)=0$ then, since $\models \sigma \rightarrow \psi$, $v(\sigma)=0$

If $v(\phi)=1$ and $v(\psi)=1$ then, since $\models \phi \rightarrow \sigma$, $v(\sigma)=1$

It is impossible that $v(\phi)=1$ and $v(\psi)=0$ since $\models \phi \rightarrow \psi$

If $v(\phi)=1$ and $v(\psi)=0$ then $v(\sigma)$ could be either 0 or 1, and it would satisfy the tautologies, but if:

$v(\sigma)=0$, then the valuation of $\sigma$ would be equal to valuation of $\psi$ for all valuations and thus $\models \psi \rightarrow \sigma$, which is a contraditcion;
$v(\sigma)=1$, then the valuation of $\sigma$ would be equal to valuation of $\phi$ for all valuations and thus $\models \sigma \rightarrow \phi$, which is a contraditcion.
Comment: What have you tried? Where did you get stuck?
Comment: Also, this needs more detail - when you say "proposition," what exactly is the first-order language you're using? (This matters: if you're restricting to propositions from a fixed finite language, the statement is in fact *false*.)
Comment: not that it matters, but did you get the definition of $<$ right? Seems backwards...
Comment: Maybe it is indeed backwards, it was defined this way when I saw it but I don't think this changes the solution (or maybe I wrote in the wrong way, it is defined as AB is a tautology and B->A is not)  @DavidC.Ullrich
Comment: Sorry, I forgot to add that to the question, I will edit it @NoahSchweber
Comment: @NoahSchweber Just edited
Answer: I assume that this is a question about classical propositional logic.
Given $\varphi < \psi$, pick a variable $q$ not occuring in $\varphi$ or $\psi$. Then
$$
\varphi < (\varphi\land q)\lor(\psi\land\lnot q) < \psi.
$$

Let's go through the things we have to check. If $v(\varphi)=1$ then also $v(\psi)=1$ because $\models \varphi\rightarrow\psi$ by assumption, and so either $v(\varphi\land q)=1$ (if $v(q)=1$) or $v(\psi\land\lnot q)=1$ (if $v(q)=0$). Hence $\models \varphi\rightarrow (\varphi\land q)\lor(\psi\land\lnot q)$. On the other hand, if it were the case that $\models (\varphi\land q)\lor(\psi\land\lnot q)\rightarrow \varphi$, then in particular it would follow that $\models(\psi\land\lnot q)\rightarrow \varphi$, which in turn implies $\models \psi\rightarrow \varphi$ as $q$ does not in $\varphi$ and $\psi$. But this is ruled out as we assumed $\varphi <\psi$. We have now established $\varphi < (\varphi\land q)\lor(\psi\land\lnot q)$. For the second part, $\models (\varphi\land q)\lor(\psi\land\lnot q) \rightarrow \psi$ follows from $\models \varphi\rightarrow\psi$. And if it were the case that $\models\psi\rightarrow (\varphi\land q)\lor(\psi\land\lnot q)$, then we'd again have $\models\psi\rightarrow \varphi$ because $q$ does not appear in $\varphi$ and $\psi$, but this was ruled out because $\varphi<\psi$. We therefore conclude $(\varphi\land q)\lor(\psi\land\lnot q) < \psi$.

[EDIT: I just saw the question is tagged "first-order logic". The argument above also works in the first-order setting, one only has to replace the propositional variable $q$ by the formula $\exists x Q(x)$ where $Q$ is a new relation symbol.]
Comment: Since the text of the question mentions valuations, I suspect it's really about propositional logic and the first-order tag was a mistake. But it doesn't matter since your construction works in both cases.


Curved windway of a recorder - what is the use for it?

Question: What is the use of curved windway of a recorder? After my first Yamaha YRS-23 I bought YRS-302B and I'm still puzzled about that difference.
It feels like the blowing into 302 gives slightly more resistance... But I could not find clear explanation of difference in tone quality or how properly use the curved windway. Though I found this related question which still left me confused. (I hope it is not a kind of thing which only could be taught personally by teacher in a music school?)
Comment: For the same diameter of the instrument, a curved windway and labium will give a "wider" wind stream (measured around the curve)  than a straight one, which will tend to make the instrument "play louder" for the same volume of air. I think more detailed explanation than that would need either a lot of experimenting with different designs, and/or some detailed l(and difficult) computer simulations. There isn't a universally agreed-on objective definition of the "best sound" for a musical instrument, or course.
Answer: I think this is an "all other things being equal" answer... and all those other things are never equal! The curved windway is a subtle influence that is easily dwarfed by other aspects of craftsmanship and design. My experience is that curved windways offer a bit more resistance and this gives something a bit more to "push against" with the air column. Very subtle, but it seems to be real.
Everyone says a curved windway gives a more complex sound, but I don't know this to be true. Acoustically, it's hard to understand how this would be an important influence, and we have many centuries of careful flue design in organ pipes... if curved windways were superior, I'd think we would see more of them in organ pipes. Perhaps the curved windway, if combined with a curved blade, would give more surface area for the blade (and the "wind reed") which could lead to more volume and presence... but I'm speculating.
I think this is a minor impact at best and probably shouldn't figure too strongly in your choice of instrument.
Answer: A curved windway helps keep a seal on the lead pipe where you breath into the instrument. With a perfect seal, your low notes will sound "brassy," which is most desirable, and you high notes, easily can get three octives, stable and soft. It's got most to do with the embouchure and verly little with the quality of instrument, although, a curved wind way facilitates this seal. When approaching the instrument for address, place the brim of the lover lip where it meets the skin and put your upper lip tucked into the lower so the lower is covering the upper while maintaining your position on the lead pipe of the instrument; the gently pull the cinders of your mouth down and back like when you might pucker after eating a tart lemon, all the while allowing your tucked upper lip to slowly and gently roll out from under the lower lip while gently blowing. Your upper lip should come to rest on the flat surface where the curved bore is. The outer rim of the upper and lower lips should make the shape of the frown like downward turn of the curve on the bore. Never fill your cheeks with air always breath through your nose and never let your upper and lower lips touch; if they do, take them off and try again, fishing is a bad habit, i.e. keeping your lips attached and jockeying for your position. Keep in mine not to drive yourself mad with this; if you keep slipping then go to the next step which is to bring the tip of your tongue up to the roof of your mouth, while keeping a steady breath through the instrument, and make the sound of Tah. Start with long taaahhh (s) on the lowest note and climb the scale with each sharp and natural note (12 steps to the chromatic scale from middle C to high C) untill you get to the High C and now go down the same way making all the flat and naturel notes on the way back down to middle C. Then go middle C repeating it twice and jump to high C (c=low and C= high cc CC cc CC) , this will help you establish your range so when your lips are wide for the low their embouchure will be able to play the high C in the open position of Low C and when narrow (remember never close your lips or otherwise let them touch) in the High C position to effect the brassy quality of the low note. Finally, as your breathing improves through your nose and your seal becomes more and more  firm, you may fill the jowls under the tongue, remembering to keep the corners of your mouth pulled down and back, and let it be a type of bag like the bag pipes hold air to keep a contestant flowing note between breaths through the nose. This may be achieved by using the back of the tongue to separate the wind in the mouth that is spending itself to keep the flow forward and note playing while the airway from the nose down the back of the throat fills up the lungs again, then bring the breath back through the mouth to fill up the air pocket under the tongue and keep the note playing. Remember, you won't have to puff your cheeks if you get this right and a way to help facilitate this reciprocation of air, by filling your lungs while the lips are on the instrument and breath out through your nose while at the same time blowing through the lips to make the note. It may seem counter productive like you're wasting your air however it's counter intuitive, for part of the difficulty is getting oxygen deprived with a lung full of air, then you might keep slipping off the lead pipe of the instrument; when therw time come that you lean controll of your breath, it will not be necessary to dump air out of the nostrils, you'll only breath in through them.
I hope this as was helpful. I started playing recorder in 1992 and moved to the trumpet in 1997 and whent to Allen Colin of Charles Colin music on 53rd st New York, New York (at the time of 1997) as well as having taken musical theory at New Jersey City University in 1993, 94 and 95.
Best Regards
Joseph Markenstein
Mountain View Cal.


Reorder a vector after changing every value in it(index should be same as before) in R

Question: I have two data frames I want order its value after a little change in the current value.
my data frames are like below
V1<-data.frame(name = c("APP_RTYD_A", "APP_GHYD_B", "APP_CHAS_D"))
V2<- data.frame(name = c("NewAPP_GHYD_B_1", "NewAPP_CHAS_D_1", "NewAPP_RTYD_A_2"))

I want my data frame V2 also should be in order of data frame V1 as the names in V2 derived from V1 names.
 Expected ouput:
V2 <- data.frame(name=c("NewAPP_RTYD_A_2", "NewAPP_GHYD_B_1", "NewAPP_CHAS_D_1"))

I have tried using match() but as values are not exactly same. it is not working. is there anyway I can match substring from V1 and get same index order of V1 for V2.
reorder_idx <- match(V1,V2)
reordered <- V2[reorder_idx]

Answer: Extract only the part which is relevant from V2 which can be matched with V1.
sub('New(.*_\\w+_\\w+)_.*', '\\1', V2)
#[1] "APP_GHYD_B" "APP_CHAS_D" "APP_RTYD_A"

and then use match and order.
V2[order(match(sub('New(.*_\\w+_\\w+)_.*', '\\1', V2), V1))]
#[1] "NewAPP_RTYD_A_2" "NewAPP_GHYD_B_1" "NewAPP_CHAS_D_1"

The opposite approach would be to remove additional text and then match.
V2[order(match(gsub('New|_\\d+$', '', V2), V1))]

For the updated dataset :
library(stringr)
vals <- str_extract(V2$name, str_c(V1$name, collapse = "|"))
V2[order(match(vals, V1$name)), , drop = FALSE]

Comment: I think you don't even need `order` if you switch the arguments in `match` : `V2[match(V1, sub('.*(APP_\\w+_\\w+)_.*', '\\1', V2))]`
Comment: That's correct. Provided `V2` and `V1` are always of same length.
Comment: I want to compare whole name from V1 with V2 name as the names in V2 contains whole string of V1 name except "New" and "_1 or _2" and in case if we are not sure name starts with "APP"
Comment: @Hmm I think that is what my answer is doing.Instead of removing "New", "_1" and "_2" I am keeping the part to match. The answer works for the data you have provided. Did you try it on real data? Did you face any issues? You can replace "APP" with `"\\w+"` as well.
Comment: instead of hard coded "APP" in regular expression can we directly keep name from V1 because we are not sure if name having "APP" will it work
Comment: See Updated answer where I removed hardcoded "APP" from the text. Also I added another approach to remove "New" and the number. @Hmm
Comment: I should not stick to "New" or "APP", I am not sure about the values but for sure names in V2 contains the whole name from V1. and also not sure about the length of the names


Induction Proof: $5^n + 5 < 5^{n+1}$

Question: I am trying to prove for all natural $n$ that:
$$5^n + 5 < 5^{n+1}$$
I did the basic step with $n=1$ and inequality holds, I am now at the induction step:
$$5^{k+1} + 5 < 5^{k+2}$$
and I have no idea how to proceed from here. Can someone give me a clue?
Comment: The second hint: for positive $x,y:$ if $x > y + 25$ then $x > x + 5.$
Answer: At the induction step, assuming the inequality is true for $n=k$, we have $$5^{k} + 5 < 5^{k+1}$$ Multiplying the above by $5$ and make use of the fact the $5^{k+1} + 5 < 5^{k+1} + 25$ to conclude what you want.
Answer: Hint $\rm\ 5\! +\! 5^n < 5^{n+1}\!\!\iff\! 5 < 5^{n+1}\!-\!5^n = 4\cdot 5^n =: f(n).\,$ $\rm\:f(n)\:$ is increasing $\rm\: f(n\!+\!1)\ge f(n)\:$ hence a simple induction shows $\rm\:f(n) \ge f(1) > 5.$
Remark $\ $ This is a prototypical example of inequality telescoping. The hinted inductive proof - that an increasing function stays greater than its initial value - can be vividly viewed as collapsing $\rm\:f(n)\ge f(n\!-\!1)\ge\,\cdots\,f(2)\ge f(1)\:$ down to $\rm\:f(n)\ge f(1),\:$ using the transitivity of $\,\ge,\,$ just like one collapses the sections of a telescope down to one section.
Note that proving said lemma on increasing functions is actually easier then proving the simple case in your problem, because the special-case details no longer obscure the innate telescopic structure. Further, this lemma  can be reused for many induction problems of similar type. Ditto for the higher-level conceptual understanding of how these types of induction work.
The above method of transforming an inductive proof into a much simpler telescopic proof is quite powerful, and very widely applicable, not only for inequalities but also for sums, products, etc. For many further examples see my prior posts on telescopy.
Comment: How did you develop and realise the application of this general telescopy procedure to such diverse problems? This is amazing. The telescopy you employ can be applied to inequality transitivity, modular arithmetic, sums, products...
Answer: For any $\,n\in\Bbb N=\{1,2,3,...\}\,$:
$$5+5^n<5^{n+1}\stackrel{\text{div. by}\,5}\Longleftrightarrow 1+5^{n-1}<5^n\Longleftrightarrow 1<4\cdot 5^{n-1}$$
And since $\,4\cdot 5^{n-1}\,$ is the product of two natural numbers, one of them greater than $\,1\,$, we're done.
Answer: Inequality holds for $n=1$.
For $n=k$
$$5^k + 5 < 5^{k+1}$$
We can write this as
$$5^{k+1} - (5^k + 5) = p$$
where $p$ is a positive integer.
$$5*5^k - 5^k - 5 = p$$
$$4*5^k - 5 = p$$
$$5^k=\frac{p+5}{4}$$
Now we have to prove it is true for $n = k+1$. So if $(5^{k+2} - (5^{k+1}+5))$ is positive then inequality holds true for $n=k+1$.
$$5^{k+2} - (5^{k+1}+5)$$
$$25*5^k - (5*5^{k}+5)$$
$$25*5^k - 5*5^{k}-5$$
$$20*5^k - 5$$
substitute value of $5^k$,
$$20*(\frac{p+5}{4}) - 5$$
$$5*(p+5)-5$$
$$5p+25-5$$
$$5p+20$$
$$5(p+4)$$
As $p$ is a positive integer, so $5(p+4)$ is also positive integer.
Thus, we can say that
$$5^{k+1}+5 < 5^{k+2}$$

Induction Proof: $5^n + 5 < 5^{n+1}$


Prove that the no of solutions of the equation $f(z)=w$, counted with Multiplicities for $w$ varying in $D_2$, is constant on $D_2$

Question:
Prove that the no of solutions of the equation $f(z)=w$, counted with Multiplicities for $w$ varying in $D_2$, is constant on $D_2$.

Def: A map $f\colon X \to Y$ is said to be proper if $f^{-1}(K)$ is compact for every compact set $K$ in $Y$.
Domain: Open connected Set.
Let $D_1$ and $D_2$ be domains in $ \mathbb C$. Suppose $f\colon D_1 \to D_2 $ is a proper holomorphic mapping. Prove that the number of solutions of the equation $f(z)=w$, counted with multiplicities, for $w$ varying in $D_2$ is constant on $D_2$.
Can someone please give some hints/ideas?
Comment: 1. For all $w\in D_2$, the set $f^{-1}(w)$ is finite. 2. For all $n\in \mathbb{N}$, the set $\{ w\in D_2 : w \text{ is attained } n \text{ times in }  D_1\}$, where we count according to multiplicity of course, is open. 3. Recall what connectedness means.
Answer: Step 0: A proper holomorphic map is not constant.
For if $f(z) \equiv w_0$, then $f^{-1}(\{w_0\}) = D_1$ is not compact, although the singleton set $\{w_0\}$ is compact.
Step 1: For each $w\in D_2$, the fibre $f^{-1}(\{w\})$ is finite.
Since $f$ is not constant, the fibre is discrete. A discrete compact space is finite.
Step 2: The function $N\colon D_2 \to \mathbb{N}$, where $N(w)$ is the number of times the value $w$ is attained by $f$, counting multiplicities, is continuous.
Let $w_0\in D_2$, and $r > 0$ so small that $\overline{D_r(w_0)} = \{ w\in \mathbb{C} : \lvert w-w_0\rvert \leqslant r\} \subset D_2$. Since $f$ is proper,
$$K := \{ z \in D_1 : \lvert f(z) - w_0\rvert \leqslant r\}$$
is compact. There is a piecewise smooth cycle $\Gamma$ in $D_1$ that is nullhomologous in $D_1$ and has $n(\Gamma,z) = 1$ for all $z\in K$. [$n(\Gamma,z)$ is the winding number of the cycle $\Gamma$ around $z$.] Then for $w\in D_r(w_0)$, we have
$$N(w) = \frac{1}{2\pi i} \int_{\Gamma} \frac{f'(\zeta)}{f(\zeta) - w}\,d\zeta,\tag{1}$$
which is continuous since the integrand depends continuously on $w$. Since $w_0$ was arbitrary, $N$ is continuous on $D_2$.
Step 3: A continuous function from a connected space to a discrete space is constant.

Equation $(1)$ is the application of the residue theorem known as the argument principle.
The existence of a cycle $\Gamma$ with the desired properties may not be immediately obvious. In case it is not known, below is an outline of a proof of the

Proposition: Let $U\subset \mathbb{C}$ be open, and $K\subset U$ compact. Then there is a cycle $\Gamma$ in $U$, consisting of straight line segments, such that $$n(\Gamma,z) = 0$$ for all $z \in \mathbb{C}\setminus U$ (that is, $\Gamma$ is nullhomologous in $U$), and $$n(\Gamma,z) = 1$$ for all $z\in K$.

Proof sketch: If $K = \varnothing$, the empty cycle has the desired properties. Henceforth, we therefore assume $K\neq \varnothing$. Let
$$d = \min \{ 1, \operatorname{dist}(K,\mathbb{C}\setminus U)\}.$$
Choose $k\in \mathbb{N}$ such that $2^{2-k} < d$. For $a+ib \in \mathbb{Z}[i]$, let
$$R_{a+ib} = 2^{-k}\cdot \{z \in \mathbb{C} : a \leqslant \operatorname{Re} z \leqslant a+1,\; b \leqslant \operatorname{Im} z \leqslant b+1\}.$$
Then consider $I(K) = \{\omega \in \mathbb{Z}[i] : R_\omega \cap K \neq \varnothing\}$. Since $K$ is bounded, $I(K)$ is compact. If $\omega \in I(K)$, and $z_0 \in K\cap R_\omega$, then
$$R_\omega \subset D_{2^{1/2-k}}(z_0) \subset U$$
and therefore
$$\int_{\partial R_\omega} \frac{d\zeta}{\zeta-z} = 0$$
for all $z\notin U$. Let
$$R := \bigcup_{\omega\in I(K)} R_\omega$$
and $\Gamma = \partial R$. The $\Gamma$ consists of boundary segments of some of the $R_\omega$, hence of straight line segments, and
$$\int_{\Gamma} \frac{d\zeta}{\zeta - z} = \sum_{\omega \in I(K)} \int_{\partial R_\omega} \frac{d\zeta}{\zeta - z} = 0,$$
since if a boundary segment of $R_{\omega}$ doesn't occur in $\Gamma$, it is traversed in the opposite direction as a boundary segment of one of the neighbouring squares - $R_{\omega + \alpha}$, where $\alpha \in \{ 1,i,-1,-i\}$, depending on whether it is the right, upper, left, or lower boundary segment of $R_\omega$ - and that part of the integral is cancelled in the sum. Thus $\Gamma$ is nullhomologous in $U$.
If $z_0 \in K$, then there is at least one $\omega\in I(K)$ with $z_0\in R_\omega$. If $z_0 \in \overset{\Large\circ}{R}_\omega$, then $z_0 \notin R_\alpha$ for $\alpha \in I(K)\setminus \{\omega\}$, and hence
$$n(\gamma, z_0) = \sum_{\alpha \in I(K)} n(\partial R_\alpha, z_0) = n(\partial R_\omega, z_0) = 1.$$
The cases where $z_0$ lies on the common boundary segment of two $R_\omega$ (but not on a corner) or on a corner shared by four $R_\omega$, the argument to show that $n(\gamma,z_0) = 1$ is similar.
Answer: This approach probably will over-kill the problem :p. Anyway, here how it goes: Assume $f$ is a non-constant proper holomorphic map.
First, note that since $f$ is a holomorphic, $f$ is an open map. In particular because $D_1$ is an open subset of $\mathbb{C}$, so is $f(D_1)$ an open subset of $D_2$. On the other hand, $f$ being proper forces its image to closed. To see this, let $y$ be a limit point $f(D_1)$. Then we can find a sequence of $\{y_n:=f(z_n)\}\subset f(D_1)$, where $\{z_n\}\subset D_1$ such that $y_n\rightarrow y$. Now consider $K:=\{y_n\}\cup\{y\}$. Note that $K$ is sequential compact subset of $D_2$, thus also compact. Thus, $f^{-1}(K)$ is also compact in $D_1$. $\{z_n\}$ now being a sequence in a compact subset of $D_1$ has a convergent sub-sequence, say $z_{n_k}\rightarrow z$ in $D_1$. So by continuity of $f$, $f(z_{n_k})\rightarrow f(z)$. This means that $f(z)=y$. Or equivalently, $y\in f(D_1)$.
The point is, $f(D_1)$ is both an open and closed subset of a connected set $D_2$. Therefore, it must be the case that $f(D_1)=D_2$. In other words, $f$ is surjective.
Now the fact that $D_1$ and $D_2$ are open connected subsets of $\mathbb{C}$ is important. Identify $\mathbb{C}=\mathbb{R^2}$ for a moment, $D_1$ and $D_2$ can be viewed as connected submanifolds (smooth and same dimension!) of $\mathbb{R^2}$. $f$ is holomorphic, so it is certainly a smooth map (in the usual sense) from $D_1$ onto $D_2$. Then for any $p\in D_1$, I claim that the differential $(f_*)_p:T_{p}(D_1)\longrightarrow T_{f(p)}(D_2)$ is surjective.
Indeed, let $f(x,y)=u(x,y)+iv(x,y):=(u(x,y),v(x,y))$. Recall the definition of the differential at $p:$ $$(f_*)_p(q)=\begin{pmatrix}
  u_x(p) & u_y(p)  \\
  v_x(p) & v_y(p)  \\
  \end{pmatrix}.q$$
But we can do better! The holomorphicity of $f$ implies that $u$ and $v$ satisfy the Cauchy-Riemann Equations. So we can rewrite the differential map as follow $$(f_*)_p(q)=\begin{pmatrix}
  u_x(p) & -v_x(p)  \\
  v_x(p) & u_x(p)  \\
  \end{pmatrix}.q$$
Since $f$ is non-constant, that means $u_x(p)$ and $v_x(p)$ can't be simultaneously zero. So the matrix of the differential map is full rank. Therefore, $(f_*)_p$ is surjective. And because $p$ is chosen arbitrarily, this means that every point in $f(D_1)=D_2$ is a regular value.
Now let $q$ be any point in $D_2$. Since $f$ is surjective, the inverse image of $q$ is non-empty. Furthermore note that the singleton $\{q\}$ is compact in $D_2$. So the inverse image $q$ is compact in $D_1$, and with $f$ being non-constant holomorphic map, $f^{-1}(q)$ is also discrete. Thus it is finite. Set this finite number $n(q)$ to be the multiplicity of $q$. And define an equivalent relation on $D_2$ as follow $$x\sim y \Leftrightarrow n(x)=n(y)$$
Think of $q$ also as a regular value of $f$. In our case, since the two Euclidean spaces have the same dimension, the differential $f_*$ is surjective if and only if it is an isomorphism. Then if $\{x_1,x_2,\cdots, x_{n(q)}\}$ is the set of points get mapped to $q$, the inverse function theorem tells us that around each point $x_i$, $f$ is a local diffeomorphism.That is, if $B$ is a open disk around $q$ that is also a subset of $D_2$ (such disk exists because $D_2$ is open), $f^{-1}(B)$ is a countable union of open disk $B_i$ around each $x_i$ such that $f|_{B_i}$ is a diffeomorphism. So now let $p$ be any point in $B$. No two distinct points in the inverse image of $p$ lies in the same open set $B_i$ (Or else it would violate the fact $f|_{B_i}$ is injective!). This shows that each point in the inverse image of $p$ lies in each distinct set $B_i$. And thus $n(p)=n(q)$. So $[q]$ is open. But under $\sim$, $D_2$ is partitioned into open disjoint equivalence classes and $D_2$ is connected. The only time this is possible is when $[q]=D_2$.
Therefore, the multiplicity of each point is constant as the point varies through $D_2$.
Comment: Sorry..Can you explain this: "Since $f$ is non-constant, that means $u_x(p)$ and $v_x(p)$ can't be simultaneously zero. So the matrix of the differential map is full rank".I think at all the critical points the derivative  will be zero.
Comment: Can you please clarify my doubt?
Comment: It seems like I have over looked something. I'm reviewing my argument like now. But if you can come up with the way how to fix the hole, feel free to scold me :p


Shared database during development?

Question: Sometimes I need to collaborate with a more frontend-centric developer to help implement a site. So typically they're only changing CSS and minor template changes.
The way we've handled this in the past is that I work locally. When I have everything in a good state, I clone my environment to a staging server. The frontend dev then uploads his changes via sftp.
We'd like to move toward a setup where we're both working locally. The problem of course is keeping the configuration changes all in sync. I have been using Features, but there is still a lot of global configuration that would need to be manually migrated between instances.
I'm not quite ready to make the jump to each of us having a local database. I have considered taking a "half step" by having a shared database that we both connect to over the network.
I've found a few blog posts here and there where people have suggested it, but I thought I'd ask here: have you tried this, and if not, is there's any reason this is a bad idea?
Comment: You should be able to use Features + Strongarm to handle 99% of the configuration in code. There are a few modules that don't work well with either of those two, but otherwise the combination should get you what you need.  What configuration are you not able to export?
Answer: We've been through the same scenario as you in our company, and currently we've ended up with a situation where we work on a remote development server and have our code locally via sshfs mounts. It works pretty well, you can read more about it in this blog post I wrote.
You can't use graphical clients (e.g. gitx or gitl) so we use git and drush on the commandline, but that actually made people more aware of how those tools works rather than just clicking the same buttons every time.
On a different note, you should also use memcached so your cache doesn't get shared via cache tables in the shared database. It's pretty simple to setup and after that just make sure every developer has a unique memcache prefix.

Shared database during development?