Why isn't my webm file playing in firefox?

Question: I'm using video.js, I've tried using ogv and now webm. Neither will play in Firefox 25. Site is http://www.hybi.info
<video id="intro" class="video-js vjs-default-skin" width="498" height="365"
data-setup= '{"controls":true, "autoplay": true, "preload":"auto"}'>
<source src="/images/intro.mp4" type="video/mp4">
<source src="/images/intro.webm" type="video/webm">
<source src="/images/intro.ogv" type="video/ogg">
</video>

Prior to using video.js I got
Video format or MIME type is not supported.

Works fine in Chrome. What's the deal?
Answer: SOLVED:
The issue here was actually the hosting account - godaddy.
Godaddy does not by default serve .webm or .ogv/ogg and using .httaccess doesn't do anything. You instead need to create a web.config file and add in this code:
<configuration>
   <system.webServer>
   <staticContent>
     <mimeMap fileExtension=".EXTENSION" mimeType="TYPE/SUBTYPE" />
   </staticContent>
 </system.webServer>
</configuration>

for example I added:
<configuration>
 <system.webServer>
   <staticContent>
     <mimeMap fileExtension=".ogv" mimeType="video/ogg" />
     <mimeMap fileExtension=".webm" mimeType="video/webm" />
   </staticContent>
 </system.webServer>
</configuration>

source: http://support.godaddy.com/help/article/6286/modifying-or-adding-custom-mime-types-to-windows-hosting-accounts
Answer: According to the HTML of your page, once the page loads on Firefox, the video element has src="/images/intro.webm".  However, once I tried to visit that page, it returned a 404 error.  I believe that the video is simply missing, and that you need to put it up in the images directory.  This is also the case with the intro.ogv video - it is simply missing.
Comment: files are definitely there. just checked the file manager. what this about file permissions?


os.path.join() on windows?

Question: I would like to write this code on windows :
os.path.join(folder1 + "/" + folder2)
it works fine in MAC but in windows it gives me an error:  OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: 'C:\Users\Khalaf\Desktop\test\dataset-images\x.jpg' -> 'C:\Users\Khalaf\Desktop\test\dataset-images\C:\Users\Khalaf\Desktop\test\dataset-images-1.jpg'
Comment: You have to use `os.path.join()` properly: `os.path.join(folder1, folder2)`. The divider is added by the function.
Comment: Does this answer your question? [Python os.path.join on Windows](https://stackoverflow.com/questions/2422798/python-os-path-join-on-windows)
Comment: I need the "/" between paths
Comment: You can use `os.pathsep` instead of `/` as well.
Comment: On Windows you do *not* "need / between paths" because / is an illegal character in a Windows filename. `os.path.join()`  knows that, even if you don't.
Answer: os.path.join(folder1 + "\\" + folder2)

MAC and Linux work with singe /
but in Windows we have to pass \\
Try these it will work
Comment: i solved it using : os.path.basename, thank you very much for your tips
Comment: i did, it gives me :

OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: 'C:\\Users\\Khalaf\\Desktop\\test\\dataset-images\\x.jpg' -> 'C:\\Users\\Khalaf\\Desktop\\test\\dataset-images\\C:\\Users\\Khalaf\\Desktop\\test\\dataset-images-1.jpg'
Comment: Please share folder1 and folder2 path
Answer: seperate the two folders with commas
os.path.join(folder1, folder2)

The function creates the equivalent for windows which i think is \
Answer: I am trying to learn python and am making a program that will output a script. I want to use os.path.join, but am pretty confused.
os.path.join('c:', 'sourcedir')
when I use the copytree command, Python will output it the desired way, for example:
import shutil
src = os.path.join('c:', 'src')
dst = os.path.join('c:', 'dst')
shutil.copytree(src, dst)
Windows has a concept of current directory for each drive. Because of that, "c:sourcedir" means "sourcedir" inside the current C: directory, and you'll need to specify an absolute directory.
Any of these should work and give the same result, but I don't have a Windows VM fired up at the moment to double check:
"c:/sourcedir"
os.path.join("/", "c:", "sourcedir")
os.path.join("c:/", "sourcedir")
Answer: Tried below on windows:
user= os.getlogin()
os.path.join("C:\\Users",user,"TestAutomationDownloads")

Result - A directory got created in windows at path c:Users\USERNAME\TestAutomationDownloads
where username gets its value from variable user =os.getlogin()
os.path.join adds "\" itself before and after variable.

os.path.join() on windows?


Drupal Commerce Line Item Revisions

Question: Has anyone seen a module capable of providing line item revisions? I am calculating the cost of a custom line item type via rules. It is essentially a booking and may need to be altered in the future.
I am therefore looking for some information from anyone who may have had a similar issue? This is what I need.

Every time I recalculate the price of a line item on an order to create a new revision.
Always display the latest revision to the user.
Provide a view showing other revisions in the admin panel.
Answer: The line item entity doesn't have revisions, so you would need to add this for all line items. Which means, you need to alter some of the very core of Drupal Commerce. It's possible, but maybe it would be better to store bookings in a custom table and save a reference on the line item instead.
Comment: @ben Creating a View would probably be the easiest solution. I don't believe there is any functionality for doing this yet.
Comment: Hi Thanks for your help. Do you know any module or way to view order revision data? Or would I have to create a view for that.

Drupal Commerce Line Item Revisions


Spurious note in "Für Elise" (D in measure 76)?

Question: Back in the olden days, when I walked to school barefoot in the snow uphill both ways, I learned "Für Elise" out of Suzuki Piano School Volume 5. In m. 76 (third measure in the below image), there is a lovely E7 chord.

Imagine my horror and dismay when today I heard the piece performed without the D, simply an E major chord. Yet, a brief perusal of IMSLP confirmed that, indeed, the chord is a humble E major, not a lovely E7. For example, here is the first edition (other editions agree):

What is the origin of the E7 chord in the Suzuki edition? Will Beethoven forgive me? Does the world still have meaning? Is there a Santa Claus?
Note: The St. Petersburg edition on IMSLP also contains the note in question.
Comment: Maybe you should ask Santa to give you that E7 :p ?
Comment: @Tom Touché. Well done.
Comment: …and you tell that to the kids of today, they don't believe a word of it [A. N. Other Yorkshireman]
Answer: Yes, it looks as if someone 'improved' it along the way!
Arguments for a plain E chord - It's perfectly sufficient and 'correct'.  It maintains the 4-note texture rather than slipping into 5-note for just one chord.  It seems to be what Beethoven wrote.
Arguments for E7 - Someone thought it sounded better.
Do we have a winner?   Perhaps.  But even first editions may be questioned.   The same note in the same harmony (but in a different  part of the work) is also questioned.
Welcome to the fascinating world of musical authenticity!
https://www.henle.de/blog/en/2011/11/30/beethoven-fur-elise-woo-59-%E2%80%93-do-you-strike-the-right-note/
Comment: I certainly also prefer to play a clean E major chord. A clean E major combined with the dynamics and note values sounds really great to me. The music becomes very soft at this point, with a soft E major chord which it is only an eight note. The softness and atmosphere is disturbed if you add a D. Thus just an E chord.
Comment: Regarding your remark:  "Arguments for E7 - Someone thought it sounded better." Well, others could make the argument that E sounds better. Beauty is in the eye of the beholder.
Comment: Yes, of course.  I think maintaining the 4-note texture sounds better.  But I don't get to decide!
Answer: 4-part harmony doesn't like to have 5 notes "just 'cuz".
That being said, the modern ear and sensibilities are so far past classical theory that if I were you, I would totally go ahead and add the 7th "just 'cuz."
What's the point of playing a timeless classic if you can't make Beethoven roll over in his grave? :D
Comment: The question is on the origin of the note, which appears in multiple editions, rather than on whether or not to play it. Perhaps you could add some information on when or by which editor it was added?


Payment method to cart page

Question: I need to move the payment method from the checkout page in drupal commerce and embed it into the cart page. is that even possible? I have been finding some resources and it does not lead me anywhere.
I believe I will need a custom module for this and which hook should I used for presenting a payment option in the cart page and when hitting 'checkout' button it will just go and review everything. so payment is processed in the cart page also.
thank you
Answer: It's actually very straight forward! If you want to not completely override the /cart url (basically, leaving the /cart in tact, but simply link key user interface elements directly to checkout) then you can skip to step 2...
Step 1: Overriding the cart view

You will want to do three things:

First, you'll want to "alias" the "/cart" to "/checkout" (see screenshot above) ... this will ensure all system links that go to cart actually just link to "/checkout"
Second, you'll want to override the system path "/cart" and have it redirect to an appropriate location. (code below)
Finally, you'll need to disable the view "Shopping cart form" (otherwise our hook_menu_alter may not work).

See verified code below (as in I checked to make sure this works).
<?php
function mymodule_menu_alter(&$items) {
  $items['cart']['page callback'] = '_mymodule_redirectcart';
}
function _mymodule_redirectcart() {
  global $user;
  $account = $user;
  $cart = commerce_cart_order_load($account->uid);

  // if user doesn't have a cart, go to <front>
  // else if user's cart is empty
  if ($cart == false || count($cart->commerce_line_items) == 0) {
    drupal_goto('<front>');
  }

  // go to checkout
  drupal_goto('checkout/'.$cart->order_id);
}
?>

Don't forget to disable the shopping cart form

Step 2: Making a one page checkout
I borrowed the step-by-step from an excellent "Express Checkout" blog.

From http://www.example.com/admin, click on the Store link, then Configuration, then Checkout settings
Drag the Review item out of the Review order section and into the disabled section
Drag the Payment item out of the Review order section and up into the Checkout section
Click Save Configuration

Step 3: Modify the title and button
This step is optional, but useful. Basically, we just use hook_form_alter to change the "Continue" button to indicate that payment will be taken and we modify the page title to "Cart" to further our ruse that this is the cart page and not checkout.
<?php
function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'commerce_checkout_form_checkout') {
    drupal_set_title("Cart");
    $form['buttons']['continue']['#value'] = t('Proceed with purchase');
  }
}
?>

Step 4: Your new cart checkout
This is not really a step, but it is the result of your effort. Now your new "cart" has a checkout/payment pane. Only thing you would be missing from the original cart is the ability to modify your cart (remove products) and that is where this process would fail you.

Other Thoughts
If your customers will need to be able to modify the cart (most likely the case), then you will need to link to a clone of the commerce_cart_view at a unique url (perhaps /cart-edit?) and then add a link called "Edit Cart Contents" in the footer of your cart contents view to indicate that they can remove items, but they have to click a link to do it.

The view you want to clone is called "Shopping cart form" and the clone option can be found at /admin/structure/views
Make sure you edit the path in your cloned view to "cart-edit" or some variation.
Edit the footer of the "Shopping Cart Summary" view found at /admin/structure/views/view/commerce_cart_summary/edit to look like the below:

The reason you can't modify cart items in checkout is that "forms within forms" is not a straightforward thing to implement, but linking to a view to edit your order is pretty simple and everyone wins with a 10 minute change.
Comment: this is great solutions! yeah, I build it like you told me and all are working well, thank you once again!

Payment method to cart page


Remove staircase in this example

Question: Is it possible to remove the staircase effect in this example ? I have one div floating right and a few divs with fixed height and fixed width floating left. If the divs meet somewhere I get a rather strange staircase effect.
I know why this happens and I get it but im looking for a solution to avoid this. Please help me

just some contents floating right

a div

        this one is the problem.
        Is it possible to have this div start at position B

Position B

a div

and the css
div{
    margin:10px;
    padding:10px;

.container{
    width:460px;
    float:left;
}

.fright{
    float:right;
    border:1px solid green;
}

.fleft{
    float:left;
    height:180px;
    width:180px;
    border:1px solid orange;
}

http://jsfiddle.net/FusWd/1/
Comment: Can you make an example of how you want it to turn out?
Answer: Instead of using floats, you may want to try using inline-block to do your layout.
I've updated your example here : http://jsfiddle.net/FusWd/4/
There are some caveats with this technique:

IE 6-7 doesn't support inline-block, you'll have to use the 'hasLayout' trick.
inline-block elements are influenced by whitespace in your markup, which may or may not break your layout. There are a couple of solutions to this.

You can remove the whitespace between the inline block elements in your markup
set the parent element's font-size and line-height to 0, and the letter-spacing and word-spacing properties to -1px, then reset font-size and line-height to their desired values, and reset letter-spacing and word-spacing properties to the normal values.
Comment: No problem. If an answer is useful to you, you should mark it as an accepted answer. Read more about the conventions of stackoverflow here: http://stackoverflow.com/faq#howtoask

Remove staircase in this example


Creating a ticketing system in Drupal 8. How to change a node's field value without going to the edit page?

Question: I'm creating a simple ticketing system in Drupal 8 to log my daily tasks. The content type contains title, body, and ticket status. The status field can be new, in progress, or completed. When I create a new ticket, the status is set as new by default. I also have commenting enabled on this content type.
The issue I'm having now is the UX of this setup. I can comment on the ticket fine, but if I were to change the status of the ticket to in progress or completed, I'd have to goto the edit page of the node and make this change. How can I change the status value without going to the edit page? Is there a ajax field update feature?
I wan't to be able to make my comment and also change the status of the ticket all at once vs making a comment, then click edit to change the status.
Answer: You could build an ajax form that would update the node's "Ticket Status" field, embed that in a custom block and place that block on the page for that node or embed it in the node.  Instead of in a block, you could also create a field formatter plugin that embeds the ajax form into the display for that field.
Comment: any example code I can follow to get this done? thanks.
Answer: There a thousands of ways you can place a minified node edit form, see your last question Creating a ticket system with core only. How to modify fields on full_content view without reloading? or the great answer from @oknate Creating a ticketing system in Drupal 8. How to change a node's field value without going to the edit page?
But what is new in this question is, that you want to do this together with the comment form. The comment form has already a submit that posts data to drupal. Then you don't need a second form. You could extend the comment form in a form alter hook with two submit buttons, which each execute not only the default submit from the comment form, but also a custom submit which changes the status of the parent node either to progress or completed.


Shower Head Jet Separation

Question:
The jets on a shower head are arranged in circles that are concentric with the rim. The jets are equally spaced out on each circle and there is at least one radius that intersects every circle at a jet.
The angular separation of two jets on a circle is the size of the angle formed by the two radii of the circle that pass through the jets. All angular separations are integers. For example, on a shower head, there are 10 jets on the inner circle. Hence the angular separation of adjacent jets is 360 / 10 = 36 degrees.
Another shower head has four circles with 10, 20, 30 and 45 jets respectively. Explain why no diameter of the shower head passes through 8 jets.

I know that it has to do with same angular separations for all 4 circles and a 180 degree angle doesn't go through 8 jets but how do I go about this?

Also, if a shower head has an inner circle of 12 jets, a middle circle of 18, and an outer circle of 36, how many radii pass through two jets?

I worked out the angular separations for all of the jets, and saw which ones were common to 2 circles, and I got an answer of $0$. Was I correct in my reasoning? There was also another question asking about how many radii passes through 3 jet holes, and I got 10. Was I correct?
P.S. A few of my questions have been deleted because they have been accused of cheating in the Australian Junior Competition however we are allowed to ask for help and/or answers from anyone or anything except for my teacher and classmates
Answer: If a diameter of the shower head passed through eight jets, it would have to pass through four antipodal pairs of jets, one pair per ring. It is easy to find such a pair for the rings with 10, 20 and 30 jets, but there is no such pair for the ring with 45 jets: the angular separation between adjacent jets is 8° here, and 8° does not divide 180°. Therefore no diameter passes through eight jets.
For the second question (12/18/36 jets), the number of radii passing through three jets is $\gcd(12,18,36)=6$. The number of radii passing through exactly two jets may be computed as follows:

$\gcd(12,18)=6$ (radius through jets in inner/middle rings)
$\gcd(12,36)=12$ (inner/outer rings)
$\gcd(18,36)=18$ (middle/outer rings)

From each of the above values, the six radii passing through three jets need to be subtracted. The final answer for the number of two-jet radii is $6+12+18-18=18$.
Comment: Can you please look at  the new question and try to answer it please?
Comment: @bio Your answer of zero for the second question is correct. For the third, the answer would be 18 - the GCD of 18, 18 and 36.
Comment: it says '12,18 and 36'
Comment: @bio Done.${}{}$
Comment: plus, why do we need to work out the greatest common denominator
Comment: @bio The $\gcd$ of two numbers, in this case representing the number of jets per ring, gives the number of radii passing through jets in both rings.
Comment: how was my way wrong(just trying to learn from my mistakes)
Comment: @bio You just counted incorrectly. It's perfectly possible to do this the manual way but it's tedious and error-prone.

Shower Head Jet Separation


What is the probability that EA > EC?

Question: I found this question in one of my books:

Square $ABCD$ has a length of $1$. Point $E$ is selected inside the square. Segment $EA$ represents the distance between point $E$ and one of the vertices of the square, $A$, and segment $EC$ represents the distance between point $E$ one of the vertices of the square, $C$. What is the probability that $EA > EC$?

Since $E$ can be anywhere on the square, the first thing to focus on is point $E$ being on the perpendicular bisector of $AC, BD$.

If it is on $BD$, then it's equidistant from $A$ and $C$. In this case, neither $EA$ nor $EC$ are greater than each other, but it still adds a possibility to where $E$ can be.
If $E$ is anywhere away from $BD$ and closer to $A$, then $EC > EA.$
If $E$ is anywhere away from $BD$ and closer to $C$, then $EA > EC.$
To me, it seems like there are $3$ total possibilities and there's only one where $EA > EC,$ making it $1/3$ for the answer to the question. In my book, it says the possibility $EA > EC$ is $1/2$, which I don't understand because it indicates that there are $2$ total possibilities, but $E$ being on the perpendicular bisector is still a possibility.
Any help is appreciated!
Comment: I buy a lottery ticket. There are two possibilities, either I win \$1 million or I get nothing. Does that mean that the probability of winning \$1 million must be 1/2?
Comment: Too many links for potential answerers to chase.
Comment: First, just because there are $n$ possibilities, doesn't mean that each has a probability of $\frac{1}{n}$. They can all have different probabilities. Second there are things that are "possible" but have probability zero. E.g., if I randomly pick a number between $0$ and $1$, the probability that I pick $1/7$ (or any specific number) is $0$. (To see this, note that the probability that I pick an number between $a$ and $b$ is $b-a$). In this case, there are indeed three possibilities, but the probability that the point $E$ is equidistant from $A$ and $C$ is zero.
Comment: I understand your confusion. But how likely is it for $E$ to be on that perp bisector which is a line in a square? In mathematics that probability is zero.
Comment: Your post indicates a naive understanding of probability. Perhaps by telling Readers what book you found this exercise in, you will help them to understand what level of studies the solution should be expected.
Answer: You can assume that $A=(0,0), C=(1,1), E=(x,y), 0\le x,y\le 1$. Then your condition means $x^2+y^2>(x-1)^2+(y-1)^2$ or $2x+2y>2$ or $y>1-x$. So the probability is the area of the region of the square above the line $y=1-x$ which (the line) is the diagonal $BD$. That area is $1/2$, so the probability is $1/2$.
One can argue also that the probability that $AE>EC$ must be the same as the probability that $EC>AE$ because of the symmetry of the square and the sum of these probabilities is $1$ (because the probability that $EC=AE$ is $0$; it is the area of the diagonal $BD$). If you want to know more about geometric probability, look here.

What is the probability that EA > EC?


Salvar arquivo com data e hora no nome com Python

Question: Amigos, sou novo em python e estou tentando salvar um arquivo que contenha a data e a hora como nome do arquivo.
Esse é o meu código, mas não está dando certo.
Onde estou errando?
from datetime import date, datetime

data = datetime.today()
hoje = data.strftime('%d/%m/%Y')
nome = 'Consolidado.xlsx'

...

df.to_excel(f'{hoje}-{nome}', index = False)

Answer: Você está usando a barra ("/") no nome do arquivo e se estiver usando Linux, macOS ou algum derivado de UNIX a tua data será considerada como parte do caminho do arquivo e não o seu nome. E no NTFS do Windows a barra é um caractere inválido para compor nomes de arquivo.
Answer: Substitua / por outro caractere, por exemplo -.
Isso é necessário porque o uma barra significa o caminho relativo ou absoluto do arquivo.
Comment: Muito bom Giovanni. Uma coisa tão simples. Muito obrigado.


How do I find "where-used" / many-to-one related entities?

Question: A field in my Content Type A references a Content Type B.
I'd like to find, in each instance of Content Type B, a list of all the As that reference it at a particular point in time.
[Update]:
I made the question less ambiguous in the light of the answer I found with help from others here.
Comment: http://drupal.stackexchange.com/questions/184397/how-to-check-if-an-article-is-referenced-from-a-collection#comment223326_184397
Comment: Thanks Ivan. Can't see how to embed the query in the display / newsletter.
Answer: If you want a quick solution in code, you can use the same way as in drupal 7:
Add a field (configurable in view modes):
hook_entity_extra_field_info
Put the code for the field in here:
hook_ENTITY_TYPE_view
Use this code:
How to check if an article is referenced from a collection?
Comment: V useful. Will experiment with this.
Comment: I used the code you referred to (item 3) in my answer.
Answer: In D7, Entity Views Attachment was the most popular solution for this. It has no D8 port yet however.
D8 modules which offer this functionality include:

Display Suite. It enables you to add a view as a dynamic field; that view could use a contextual filter to focus its content on the current node URL.
Viewfield, as you suggested. You use a token to specify a default view, and choose to "force the default" to prevent content editors from changing the selected view.
Display fields, an interesting new D8 module. It allows you to place views as fields on a node, and is meant to allow contextual arguments, but I've not been able to set this up properly (see the issue)
Comment: V useful. Will experiment with *Display fields* too. The *Embed a view* variant sounds ideal.
Comment: I've just tried Display fields views embedding and been unsuccessful, I've edited my answer to mention. Please accept if you're happy with the answer.
Answer: This code is in my agenda.module. The where-used relation is used as follows in the form validation handler that is called when the user clicks the Delete button on  the  delete  confirmation form:
The Agenda Node cannot be deleted if there are any Meeting Nodes that refer to it.
use Drupal\Core\Form\FormStateInterface;

function agenda_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  switch ($form_id) {
    // ...
    case "node_agenda_delete_form":
      $form['#validate'][] = '_agenda_delete_validation';
      break;
    // ...
  }
}

function _agenda_delete_validation(&$form, FormStateInterface $form_state) {
  $agenda_node = $form_state->getFormObject()->getEntity();
  $agenda_name = $agenda_node->getTitle();
  $agenda_node_id = $agenda_node->id();
  $query = \Drupal::entityQuery('node')
    ->condition('type', 'meeting')
    ->condition('field_agenda', $agenda_node_id);
  $nids = $query->execute();
  $count_nids = count($nids);
  if ($count_nids > 0) {
    $msg_stem = ($count_nids == 1) ? 'There is one Meeting that references "' : 'There are '.$count_nids.' Meetings that reference "';
    $form_state->setError($form, $msg_stem.$agenda_name.'". It cannot be deleted yet.' );
  }
}


Shape of tensorflow model input

Question: I'm reading Masking and padding with Keras, in the beginning, an input example is:
[
  ["Hello", "world", "!"],
  ["How", "are", "you", "doing", "today"],
  ["The", "weather", "will", "be", "nice", "tomorrow"],
]

The article states:

The data is a nested list where individual samples have length 3, 5,
and 6, respectively. Since the input data for a deep learning model
must be a single tensor (of shape e.g. (batch_size, 6, vocab_size) in
this case)

What is this tensor's shape (batch_size, 6, vocab_size)?

Is batch_size 3 since there're 3 sentences?
What is 6 here? Is it the longest sentence's length?
What is vocab_size?

The shape is strange to me because tf.keras.layers.Embedding's input is a "2D tensor with shape: (batch_size, input_length)." This is not the same with the above shape.
Answer: vocab_size is the size of the vocabulary, the number of unique tokens. They are one-hot encoded, hence the number of columns reflect their count. batch_size is the number of samples you pass to a training step at a time. So the tensor is batch size by the length of the longest sentence (shorter ones are padded) by the number of unique words.
Comment: So the input tensor is of shape `(batch_size, input_length, vocab_size)`. The `vocab_size` dimension corresponds to one-hot encoding and it has the same purpose as `tf.keras.layers.Embedding`. Is this correct?

Also, is there any particular scenario where we should use one-hot encoding like this instead of embedding (subspace embedding)? Because it seems to me once we have padded sequence of tokens, we can just input the sequence directly to embedding layer and obtain their embeddings.
Comment: @CyberPlayerOne sure, the data could be embeddings, hash-encodings, etc just the example uses raw data here.

Shape of tensorflow model input


Android error: annotation value not of an allowable type

Question: I am following a tutorial to generate a notification, but I am getting an error an annotation value not of an allowable type. I have seen the answer to similar questions but unable to solve mine. So, any Help?
public interface APIServices {

@Header(
        value = { // error is on this lin
                "Authorization: key=AAAAaTlmErw:APA91bH8nQxh3Hxn-SIA9u0nzlAIn96Ks1prH950uXVOUKQiDj8Bxdt2mR98qE7xqQaxbbKVcxwgromyYGwbw4xRYJ_47hu5_jmyQ5Yun1_KgTokpAEPNDIekGzldTAKp4IVnKvU8HVk",
                "Content-Type: application/json"
        }
)

@POST("fcm/send")
Call<MyResponse> sendNotification(@Body Sender body);

}
Answer: try replace
@Header(
        value = { // error is on this lin
                "Authorization: key=AAAAaTlmErw:APA91bH8nQxh3Hxn-SIA9u0nzlAIn96Ks1prH950uXVOUKQiDj8Bxdt2mR98qE7xqQaxbbKVcxwgromyYGwbw4xRYJ_47hu5_jmyQ5Yun1_KgTokpAEPNDIekGzldTAKp4IVnKvU8HVk",
                "Content-Type: application/json"
        }
)

to
@Headers({
                "Authorization: key=AAAAaTlmErw:APA91bH8nQxh3Hxn-SIA9u0nzlAIn96Ks1prH950uXVOUKQiDj8Bxdt2mR98qE7xqQaxbbKVcxwgromyYGwbw4xRYJ_47hu5_jmyQ5Yun1_KgTokpAEPNDIekGzldTAKp4IVnKvU8HVk",
                "Content-Type: application/json"
        }
)

Answer: I'd suggest starting with checking your imports at the top of the file and making sure you're importing the @Header and @POST annotations from where you intended.


Como inserir Entidades, relacionadas á outras ja existentes, no EntityFramework?

Question: No caso supondo uma entidade "EntidadeA" que referencia uma entidade "EntidadeB", desejo salvar a mesma, porém  referenciando uma entidade B ja existente ex:
EntidadeA a = new EntidadeA();
EntidadeB b = new EntidadeB();
b.Id = 5;// id de entidade existente no banco
a.EntidadeB = b;
context.EntidadesA.Add(a);
context.SaveChanges();
//porém neste caso o framework cria uma nova entidade para b,
//o real objetivo é referenciar uma entidade ja persistida com o id 5

Answer: Faça deste MODO
EntidadeA a = new EntidadeA();
EntidadeB b = new EntidadeB();
b.Id = 5;// id de entidade existente no banco
a.EntidadeB = b;

context.EntidadeB.Attach(a.EntidadeB);

context.EntidadesA.Add(a);
context.SaveChanges();

Comment: Se tiver várias você terá que fazer um foreach(EntidadeB oEntidadeB in a.EntidadeB) { }
Comment: e se tiverem várias entidades relacionadas  B, C, D,... tem alguma maneira de buscar dotas sem ser atacando uma por uma, por exemplo atcando a A direto ?
Answer: Alternativamente, você pode selecionar todas as entidades desejadas através de um contexto e fazer a associação. Por exemplo:
var minhasEntidades = contexto.EntidadesB.Where(e => e.Tipo == algumTipo).ToList();
var a = new EntidadeA {
    EntidadesB = minhasEntidades
};

contexto.EntidadesA.Add(a);
contexto.SaveChanges();

Há poucas situações em que Attach é recomendado, como por exemplo se o registro certamente não estar mapeado pelo contexto naquele momento.
Comment: `Attach` você está dizendo ao contexto que o registro já existe e ele que ele, contexto, deve aceitar esse objeto como válido. Particularmente acho essa abordagem muito perigosa. No caso do `Where`, você está fazendo de fato uma seleção em banco e pedindo ao contexto para monitorar os objetos pra você, por isso é uma abordagem muito mais segura.
Comment: e se no caso eu tiver n relações em EntidadeA, como EntidadeB, C, D, E, ... e quiser carrega-las sem precisar conhece-las
Comment: Qual é a diferença de Where e Attach ?, porque simplesmente setar a identidade não funciona ?
Comment: Agora, quanto a "não precisar conhecer as entidades", não entendi o motivo pelo qual você precisa disso.


Input boxes of Bootstrap are not responsive and cannot change their width

Question: I am a newbie to bootstrap and am currently working on a simple page. So far, I completed following code, but I have a few problems. First issue is the width of input boxes, I need them to be a bit wider but could not make it. They are also not responsive. Another issue is with the logo, it is always on the left of the banner but when the window width is too small it goes to the right of the window rather than left of the banner.
Code
<!DOCTYPE html>

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet"
    href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">

                <fieldset>
                    <form class="form-inline" role="form" method="post"
                        action="employee/search.htm" name="employeeForm" id="employeeForm">

                                <input class="form-control input-sm" type="text"
                                    name="firstName" id="fistName" placeholder="First Name">

                                <input class="form-control input-sm" type="text" name="lastName"
                                    id="lastName" placeholder="Last Name">

                            <button type="submit" class="btn btn-success">Search</button>
                            Click1 Click2
                    </form>
                </fieldset>

...

Answer: Input fields: On the bootstrap page there's a big warning box, that inline fields may require custom widths. So you have to handle the width by yourself.
Logo: The logo is always on the right sight of the related container because of the float: right; you've applied. On desktop mode it looks like it's on the left because it's in a floating column. On mobile mode there's no column floating anymore. You could set the logo floating via CSS using a media query so you can handle the right/non-floating behavior.


Dados da API não estão sendo mostrados no console (Angular)

Question: Eu tenho um endpoint que me retorna um array :
 consultExams(registerNumber: string): Promise<Exam[]> {
    return this.http
      .get<Exam[]>(`${environment.ecpApiUrl}/subscriptions/exams`, {
        params: { registerNumber },
        headers: this.auth.buildHeaders(),
      })
      .toPromise();
  }

Eu preciso pegar um dado de um exame, mas não estou conseguindo. Esse me endpoint está vindo de uma classe ActivitiesSubscriptionsService
Preciso criar uma função, pois vou usar ela em outro lugar. Estou tentando buscar da seguinte maneira:
async validateExam(registerNumber) {
    const result = await this.activitiesSubscriptionsService.consultExams(
      registerNumber
    );
    console.log(result);
}

No console não me retorna nenhum, só retorna os erros
Answer: Falta fazer um then() para caso seja success e um catch() para caso venha erro.

async validateExam(registerNumber) {
  await this.activitiesSubscriptionsService.consultExams(
    registerNumber
  ).then((res) => {
    console.log(res)
  }).catch((err) => {
    console.log(err)
  });
}


Prolog looping though variable results

Question: I have a small program wrote in Prolog. At the moment I can print the first result with
test(X, 1, 4, 5).
write(X).

But if there is more than one result for X, How do I print the next ones?
Thanks.
Answer: Use a failure-driven loop:
test(X, 1, 4, 5), writeln(X), fail ; true.

or the same in a more readable way, using forall/2:
forall(test(X, 1, 4, 5), writeln(X)).

There is no need to construct a list of all the solutions (this is what findall/3 is for),
unless you need this list for something else than just printing it out.
If your Prolog doesn't have forall/2 then implement it yourself in the following way:
forall(A, B) :-
    \+ (call(A), \+ call(B)).

Comment: forall doesn't seem to exist in GNU-Prolog, but the failure-driven loop works fine. Thanks.
Comment: @Kutzi: I've added the implementation of forall/2
Answer: If you want to get every solution for a variable in a call without having to continuously press ';' for the next solution, you can use the findall predicate like this:
findall(X,test(X,1,4,5),L).

The first argument specifies which variable you would want to collect all the values of, the second argument is the predicate along with its arguments that you want to find all the solutions for, and the third argument will be a list of all the values of X from all of the solutions.
So from here, you can can just print the values of L if you're happy with the result being formatted as a list. Otherwise you will need need to write a recursive predicate to print the contents of L in the way you want, as Vincent Ramdhanie points out.
Answer: Do you mean automatically? You can issue a backtrack command with ; and it backtracks and gets the next value. But if you want to print multiple results within the program then you use recursion. Give some more details of what you are trying to do.
UPDATE: You cannot issue ;. You have to write a procedure to "loop" through the results, so you may want the results in a list.
   printList([]) :- write("").
   printList([H|T]) :- write(H), printList(T).

Comment: I want the application to issue to ; command to loop though the results.
Comment: The example contains a syntax error: replace ';' with '.'. But even after fixing this error, the program does not work correctly, e.g. "?- printList([a, b, c])." outputs "abc[]" where the trailing "[]" is probably not wanted.

Prolog looping though variable results


Domain Definition in the complex plane

Question: Consider a bounded complex-valued function $f(z)$ of a complex variable $z = x + iy$, where  $a < x < b$ ( $0 < a < b$) and $y \ge 1$.
Question: is the following a bounded domain:
$a < x < b$ and $y = c$ ($c = \text{constant} > 1$)
Some references define a bounded domain as an open connected finite set. Others add that a domain cannot be a line segment.
Comment: It will depend on your text's precise definition of "domain". In my experience, a domain in $\mathbb C$ is *usually* (at least) a set open in $\mathbb C$.
Comment: Also, you probably don't mean a "finite" set. There are no open connected finite sets in $\mathbb C$ (except for $\varnothing$).
Comment: Thanks for your answer. You mean it's not open because y = c = constant?
Comment: Then a line segment cannot be a domain although the end values ("a" and "b" are not included).
Comment: What to change to "open" a domain around  "a" an "b" ?
Comment: So a line segment cannot be a domain, and the only domains are 2-dimensional shapes, or half strips?
Answer: Usually a domain in the context of complex analysis means an open, connected set. Not necessarily bounded (and certainly not finite).
Your set is not open, thus not a domain.
Comment: Then a <= x <= b and y = c  is a bounded domain

Domain Definition in the complex plane


Unequal integrals and proving the validity of a sum involving the Riemann Zeta function

Question: I was working with the family of integrals given by:
$$ S(a) = \int_0^{\infty} \frac{\sin(ax)}{e^x-1} dx$$
It is relatively easy to establish an expression for $S(a)$. As usual, we define its cosine variant and use Euler's formula.
$$ C(a) + iS(a) = \int_0^{\infty} \frac{e^{iax}}{e^x-1}dx = \int_0^{\infty} \frac{e^{iax}\cdot e^{-x}}{1-e^{-x}}dx = \int_0^{\infty} {e^{-(1-ia)x}} \cdot \sum_{n=0}^{\infty} e^{-nx} dx $$
$$ = \sum_{n=0}^{\infty} \int_0^{\infty} e^{-((n+1)-ia)x} dx = \sum_{n=0}^{\infty} \frac{(n+1) + ia}{(n+1)^2+a^2}$$
Thus,
$$ S(a) = \sum_{n=0}^{\infty} \frac{a}{a^2+(n+1)^2} = \frac{\pi a \coth(\pi a) - 1}{2a}$$
Then
$$\int_0^1 S(a)da = \int_0^1 \frac{\pi a \coth(\pi a) - 1}{2a} da$$
Which is
$$\int_0^1 S(a)da = \frac{1}{2}\cdot \ln(\frac{\sinh(\pi)}{\pi}) = 0.650923....$$
But if I compute the integral over the summation formula, I get:
$$ \int_0^1 S(a)da = \int_0^1 \sum_{n=0}^{\infty} \frac{a}{a^2+(n+1)^2} da$$
$$ = \sum_{n=0}^{\infty} \int_0^1 \frac{a da}{a^2+(n+1)^2} = \sum_{n=0}^{\infty} \frac{1}{2} \cdot \ln \big(1+\frac{1}{(n+1)^2}\big) $$
Which, according to WolframAlpha, is equal to $0.648442....$
Which is weird, because if you apply the Taylor Series expansion for $\ln(1+x)$ in the expression obtained and rewrite the sum, we get an interesting sum:
$$ S = \frac{1}{2} \cdot \sum_{n=1}^{\infty} \frac{(-1)^{n-1}}{n}\cdot \zeta(2n)$$
Which WolframAlpha calculates to be $0.650923$....
Can someone explain why the values obtained are different?
Also, is it correct to assert the equality
$$\sum_{n=1}^{\infty} \frac{(-1)^{n-1}}{n}\cdot \zeta(2n) = \ln(\frac{\sinh(\pi)}{\pi})$$
I am very much interested if there are any other methods to compute the sum in the LHS, so as to verify the veracity of the proposed equality independently.
Any help is appreciated. Thanks for reading!
Answer: Your analytical method is correct, and all of your calculations are correct.  The only issue is Wolfram Alpha's evaluation of the sum, which is incorrect.  Using Mathematica (version 13.3):
<code>NSum[Log[1 + 1/(n + 1)^2]/2, {n, 0, Infinity}]
</code>
returns $0.650923$.  Since this is an issue with computer evaluation, there is nothing else to say, except to stress that computers can be wrong, and that it is important to verify the results they provide.
Comment: @ScipioAemilianus Yes, your identity $$\sum_{n=1}^\infty \frac{(-1)^{n-1}}{n} \zeta(2n) = \log \frac{\sinh \pi}{\pi}$$ is true.
Comment: @ScipioAemilianus I used my very old version of Mathematica (version still in the single digits!) and even it gave the correct answer of $0.650923$. You'd assume Wolfram employs the same algorithms as Mathematica. So it might be a good idea to post a question to Mathematica StackExchange so they will be aware of the bug in Wolfram.
Comment: Thanks for the clarification! Can you also confirm the sum that arises from the equality, added in the recent edit?


How to intuivitely see that $e^{i \pi}+1=0$ is true?

Question: Gauss is reported to have said that if Euler's formula $e^{i \pi} + 1 = 0\,\!$ "was not immediately apparent to a student upon being told it, that student would never be a first-class mathematician."
How is someone supposed to see that this is true?
Comment: We're not... And that's why most of us (speaking in generalities here so don't get offended) are not 1st class mathematicians...  :)
Comment: @Eleven-Eleven Hey I saw you graduated at FAU, I am also from Broward county. Which school do you teachat?
Comment: I'm up in NJ now... A high school.  I'm hopefully going back to school to tackle a masters in a year or two, but I live up north now.
Comment: @Eleven-Eleven Oh alright
Comment: @user2943324 But why is $e^{i \theta}$ a circle? Once you know this fact, the Euler formula is embedded into it, and it doesn't take a first class mathematician to deduce it from here...
Comment: That is circular reasoning, @user2943324. Why is that true?
Comment: My favorite view is to define $e^z=\lim_{n\to\infty} (1+z/n)^n$. Then when $z=ix$ we see that $1+ix/n$ is "close enough" to $\cos(x/n) + i\sin(x/n)$ when $n$ is large so that $e^{ix}=\lim_{n\to\infty} (cos(x/n)+i\sin(x/n))^n$.
Comment: @ThomasAndrews "Circular reasoning" when talking about $e^{i\theta}$?  Was that a pun?
Comment: [Relevant MO thread](http://mathoverflow.net/questions/27126/interpreting-the-famous-five-equation)
Answer: $e^{i \theta} = \cos \theta + i \sin \theta$
Thus, on the complex plane, it makes the equation of a circle, with $\theta$ mapping to a point on the circle with angle $\theta$.
With $\theta = \pi$, that maps to the point of the circle on the negative real axis, namely the point $-1$.
Comment: But why is $e^{i \theta}=\cos(\theta)+i \sin(\theta)$? I highly doubt that the Gauss comment was about students figuring that one can simply plug $\pi$ into this....
Comment: @N.S. Since $i$ is orthogonal to $1$, it generates length-preserving transformations, *i.e.* rotations.
Comment: @Chris Culter: That seems like it might be fine for multiplication, but not exponentiation: $iz$ rotates $z$ by $\pi/2$ radians, but knowing that $e^{it}$ for $t$ real *also* has to do with rotation seems less obvious. It seems you need a really special kind of intuitive grasp of *what the exponential function means*.
Comment: Well I Don't believe there exists any explanation for it that is anything significantly simpler. This is already quite easy to understand with a basic knowledge of complex numbers.
Comment: @mike4ty4 Right, I didn't mean that multiplication by $i$ preserves length. That happens to be true, but it isn't true of, say $2i$, which also generates rotations. I agree that the critical ingredient is the meaning of exponentiation.
Comment: @N.S. The identity $e^{i\theta} = \cos \theta + i \sin \theta$ is clear if you know the Taylor series of those 3 functions.
Comment: @SpamIAm His point is that what would be the intuitive explanation of that fact, since OP is asking for an intuitive explanation which would fit what Gauss said.
Comment: @user92774 In that case, the answers in [this thread](http://mathoverflow.net/questions/27126/interpreting-the-famous-five-equation) (particularly that of gowers) provide some intuition.
Comment: That is indeed a very nice explanation. I never heard that explanation before.
Answer: Another approach is like this. Supposing that $f(x) = \cos x + i\sin x$ for all real $x$ we get $f'(x) = -\sin x + i\cos x = if(x)$. We treat $i$ as just a constant with property $i^{2} = 1$. Now put $g(x) = e^{-ix}f(x)$ so that $g'(x) = e^{-ix}if(x) -ie^{-ix}f(x) = 0$ so that $g(x)$ is a constant and hence $g(x) = g(0) = f(0) = 1$ and therefore $f(x) = e^{ix}$. putting $x = \pi$ we get $e^{i\pi} = f(\pi) = -1$.
The above derivation rests on the assumption that the symbol $e^{-ix}$ can be treated in a manner like $e^{kx}$ where $k$ is real and follows same rules of differentiation. This is something which needs a proper justification.

Update: After the comments user92774 I think I should put the above argument into a more intuitive manner. So let's start with $f(x) = \cos x + i\sin x$. This is a very common expression if one knows about polar form of a complex number. By differentiating it we get $f'(x) = if(x)$ so that the derivative is a constant multiple of the original function. From the existing knowledge of exponential/logarithm function we know that the function $e^{kx}$ possesses this property that $\{e^{kx}\}' = ke^{kx}$ for real constant $k$. It is now easy to compare this with $f(x)$ and extend our imagination and put $k = i$ and set $f(x) = e^{ix}$. This leads to a natural definition of $e^{ix}$ as $f(x)$ and $e^{x + iy} = e^{x}f(y)$ thereby extending the domain of exponential functions to entire complex plane.
Comment: This isn't very "intuitive" (as defined by the OP), this is just another way to derive it.
Comment: @user92774: Well the intuition is to treat the symbol $e^{ix}$ just like $e^{kx}$ without defining $e^{ix}$ precisely and see what happens. Well what happens is that we get $\{e^{ix}\}' = ie^{ix}$ and next we try to figure out which function has the same property. By the way obviously just by looking at symbols $e, i, \pi, 0, 1$ you can't figure out a connection between them unless you have some theory of exponential/logarithmic and trigonometric functions.
Comment: @user92774: The expression $\cos x + i\sin x$ naturally comes to mind if one knows anything about polar form of a complex number and it is a simple matter to differentiate $f(x)$ to get $if(x)$. But considering the above it is now easy to figure out the relation that $e^{ix} = f(x)$.
Comment: I'm afraid that, after two paragraphs and and additional update, you lose the argument that "this is intuitive". Heh. :)
Answer: As I mentioned in the comments to another answer here, you need a "special kind of intuition about the exponential function". I believe I might have thought of one. It uses physical reasoning.
The exponential function, $e^x$, is a fixed point of the derivative. That is,
$$\frac{d}{dx} e^x = e^x$$.
Assume it's also true for $x = it$, $t$ rael. By the chain rule, $\frac{d}{dt} e^{it} = ie^{it}$. You can think of this as "position/time", i.e. velocity in the plane. Differentiating it again gives acceleration. The acceleration is $-e^{it}$. This is $i$ times the velocity, therefore it lies at right angles to it. So at every point in time, the acceleration is always at right angles to the velocity, from which you might be able to intuit that it moves on a circular path.
You can show that $|e^{it}| = 1$ by taking the conjugate $\overline{e^{it}} = e^{-it}$ (which follows from the derivative equation by $\frac{d}{dt} \overline{e^{it}} = \overline{\frac{d}{dt} e^{it}} = \overline{ie^{it}} = \overline{i} \overline{e^{it}} = -i \overline{e^{it}}$, so $\overline{e^{it}}$ satisfies $f'(t) = -i f(t)$, which is the same equation as $e^{-it}$ satisfies. Noting that this differential equation is first-order linear and $e^0 = 1$, the equality $\overline{e^{it}} = e^{-it}$ is obtained.) and multiplying to get the square of the absolute value, $e^{it} e^{-it} = e^{it + -it} = e^0 = 1$. This alone shows the motion is on a circle, but the constant magnitude of velocity and acceleration show that it is circular orbital motion about the origin, and not, say, chaotically bouncing back and forth along the circle or some other weirdness like that.
Then it's not unreasonable to imagine that $t$ is an angle, and $e^{i \pi} = -1$, from which the formula follows. Actually, from the knowledge of the constant and equal magnitude of the velocity and acceleration and the fact the acceleration is always at right angles to the velocity, you can use physical reasoning to arrive at Euler's formula directly, i.e. $e^{it} = \cos(t) + i \sin(t)$.
Answer: We have that $\lim_{n \to \infty} (1 + \frac{i \pi}{n})^n = -1$. As $n \to \infty$, $\sqrt{1 + (\frac{\pi}{n})^2} \to 1$, so the first $(1 + \frac{i \pi}{n})$ has magnitude $1$ and further multiplications of it by itself won't change its magnitude.
Furthermore, we have that $\lim_{x \to 0} \tan x = x$, so the argument of $(1 + \frac{i \pi}{n})$ is $\frac{\pi}{n}$ as $n \to \infty$. Since we multiply $n$ times, the argument is $\pi$.
So $e^{i \pi}$ is a complex number with magnitude $1$ and argument $\pi$, namely $-1$.
Personally I find this to be very intuitive, but it won't be something you can figure out without some rudimentary knowledge of complex numbers.
Comment: There's a lot of things in this that are confusing. "We have that..." usually implies something is already known. "... so the first..." is just not true - the first number of that form is $1+i\pi$, which is not magnitude $1$.
Comment: Finally, it is wrong to say $\lim_{x\to 0} \tan x = x$. There cannot be any $x$ as the result of that limit. You can say that $\lim_{x\to 0}\frac{\tan x}{x} = 1$. But as written, it is wrong.
Answer: You can easily show geometrically, that if rotation+scaling is a multiplication, if the y axis is mapped onto $i$.  So scaling rotation of r,a * R,A gives Rr, a+A.  One can easily suppose a is an exponent, but the jump to radians and e needs series analysis.  It is possible to show that $i^2=-1$.

In the diagram, we wish to multiply R cis(A) by r cis(a), demonstrating that rotation and scaling comes out as complex multiplication.
We start with the triangle OAB being r cis(a), scaled by C, so  OA is Cc, OB is Cs, and OB is Cr.   Extend AB to C, so that BCD is a copy of OAB, scaled by S: ie BD=Sc, CD=Ss, and BD is Sr.  The triangle OBD is a copy of C:S:R, scaled by a factor of r.  The side OB is rC, the side BD is rS, and OD is rR.
We have now shown that OD is the point at rR cis(a+A).
One can calculate the point D as $Cc-Ss + i(Cs + sS)$.  But the product of C+iS and c+is is $Cc+Ssi^2 + i(Cs+sC)$.  Since these are equal, we get $i^2=-1$.
This is a geometric proof of the argand diagram.
While we have shown that complex multiplication corresponds to dialation and rotation, it is not immediately obvious that this is $e^{i\theta}$.  One has to resort to the expansion of series of cosine and sine, and exponential, to see this is the case.


Proper text wrapping for right sided widget in a row

Question: I have a layout as follows:

Widget1 is aligned to the left, Widget2 and the text widget - to the right.
How can I wrap the text with an ellipsis for example in case it doesn't fit into the row, as follows?
Answer: you can wrap 'Text with property...' inside ExpandedWidget.
Row(
      children: [
        WidgetA(),
        WidgetB(),
        Expanded(
          child: Text("...."),
        )
      ],
    )

Comment: Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer).
Comment: This will align WidgetB to the left.
Answer: add your Text widget inside Expanded
Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: [
        Expanded(
          child: Text('Atras'),
        ),
        Expanded(
          child: Text('Filtros offertos'),
        ),
        Expanded(
          child: Text('title'),
        ),
        Expanded(
          child: Text('titleasdas'),
        ),
        Expanded(
          child: Text('title'),
        ),
        Expanded(
          child: Text('titlesfsfsdf'),
        ),
      ],
    ),

Your result screen->
Comment: Firstly, you don't need to specify MainAxisAlignment.spaceBetween if you wrap every widget in the row with the same flex value. Secondly, your answer doesn't solve my question and is about something else. Please, read carefully


Why does `typeof false || undefined` returns "boolean"

Question: I've just executed the following in console:
typeof false || undefined // "boolean"

While I expected it to return "undefined", since
typeof undefined // "undefined"

Why did it return "boolean"? Isn't the OR operator supposed to return the last argument if previous evaluated to falsey values? So that false || undefined returns undefined and typeof is executed against undefined?
Comment: `typeof false` returns string `boolean` which is true
Comment: `typeof (false || undefined)` is your solution
Comment: @Maxx, I know that, my question is in the last paragraph
Comment: The problem is; first evaluated is not "falsey", it's a string. For more information about typeof https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/typeof
Answer: You're not observing operator precedence!
> typeof false || boolean  // (typeof false) || boolean
"boolean"
> typeof (false || boolean)
"undefined"

Answer: The OR operator returns the left argument as long as it isn't falsy.
In your example, we've got this:
(typeof false) || undefined
typeof false returns "boolean", which isn't falsy, so it is returned rather than undefined.
Answer: Consider the code :
typeof false || undefined

typeof false will return "boolean" , so it will become
"boolean" || undefined
The final output will be
"boolean"


Integral $\int_0^1 \frac{(x^2+1)\ln(1+x)}{x^4-x^2+1}dx$

Question: A while ago I encountered this integral $$I=\int_0^1 \frac{(x^2+1)\ln(1+x)}{x^4-x^2+1}dx$$ To be fair I spent some time with it and solved it in a  heuristic way, I want to avoid that way so I won't show that approach, but the result I got is $\frac{\pi}{6} \ln(2+\sqrt 3)$  so I bet it can be shown in a nice way.
Solving other integrals I also encountered this one: $$J=\int_0^\infty \frac{\ln(1+x^2+x^4)}{1+x^2}dx=\pi \ln(2+\sqrt 3)$$ Which is pretty easy to compute, so most of my time I tried to show that $J=6I$, however without explictly evaluating them I had no luck.
Also I tried to use partial fractions: $$I=\frac12 \left(\int_0^1 \frac{\ln(1+x)}{x^2+\sqrt 3x +1}dx - \int_0^1 \frac{\ln(1+x)}{x^2-\sqrt 3 x+1}dx\right) $$
Considering: $$K(t) =\int_0^1 \frac{\ln(1+x)}{x^2-2\cos(t)x+1}dx$$
We have that $I=\frac12 \left(K\left(\frac{5\pi}{6}\right)-K\left(\frac{\pi}{6}\right)\right) $ and since: $$\frac{\sin t}{x^2-2x\cos t+1}=\frac{1}{2i}\left(\frac{e^{it}}{1-xe^{it}}-\frac{e^{-it}}{1-xe^{-it}}\right)=\Im \left(\frac{e^{it}}{1-xe^{it}}\right)=$$
$$=\sum_{n=0}^{\infty} \Im\left(x^n e^{i(n+1)t}\right)=\sum_{n=0}^\infty x^n\sin((n+1)t)$$
$$\small \Rightarrow K(t)=\frac12 \left(\frac{1}{\sin \left(\frac{5\pi}{6}\right)}\sum_{n=0}^\infty  \sin\left(\frac{5\pi}{6} (n+1)t \right) + \frac{1}{\sin \left(\frac{\pi}{6}\right)}\sum_{n=0}^\infty  \sin\left(\frac{\pi}{6} (n+1)t \right)\right)\int_0^1 x^n \ln(1+x)dx$$
$$=2\sum_{n=0}^\infty  \sin\left(\frac{\pi}{6} (n+1)t \right)\int_0^1 x^n \ln(1+x)dx$$
Now I don't know how to deal with the integral and the sum combined.
Comment: A weight $3$ extension with a relatively simple result: $$\int_0^1 \frac{\left(x^2+1\right) \log (x+1) \log (1-x)}{x^4-x^2+1}dx $$ equals $$-\frac{4}{3} G \log (2)-\frac{8}{3} \Im\left(\text{Li}_3\left(\frac{1}{2}+\frac{i}{2}\right)\right)+\frac{17 \pi ^3}{288}+\frac{1}{12} \pi  \log ^2(2)-\frac{1}{8} \pi  \log ^2\left(\sqrt{3}+2\right)$$ $\int_0^1 \frac{\left(x^2+1\right) \log \left(x^2+1\right) \tan ^{-1}(x)}{x^4-x^2+1} dx$ has also a simple result.
Comment: This would be a good opportunity to apply an integration formula I derived here: https://math.stackexchange.com/questions/188732/methods-to-evaluate-int-a-b-frac-ln-left-tx-u-right-mx/3333638#3333638
Answer: \begin{align}J&=\int_0^1 \frac{(x^2+1)\ln(1+x)}{x^4-x^2+1}dx\\
&=\int_0^1\int_0^1 \frac{x(x^2+1)}{(x^4-x^2+1)(1+xt)}\,dt\,dx\\
&=-\int_0^1\int_0^1 \frac{t(t^2+1)}{(t^4-t^2+1)(1+xt)}\,dt\,dx+\int_0^1\int_0^1 \frac{t^3+t^2x-\sqrt{3}t^2-\sqrt{3}tx+t+x}{2(t^4-t^2+1)(x^2-\sqrt{3}x+1)}\,dt\,dx+\\
&\int_0^1\int_0^1 \frac{t^3+t^2x+\sqrt{3}t^2+\sqrt{3}tx+t+x}{2(t^4-t^2+1)(x^2+\sqrt{3}x+1)}\,dt\,dx\\
&=-J+\int_0^1\int_0^1 \frac{t^3+t^2x-\sqrt{3}t^2-\sqrt{3}tx+t+x}{2(t^4-t^2+1)(x^2-\sqrt{3}x+1)}\,dt\,dx+\\
&\int_0^1\int_0^1 \frac{t^3+t^2x+\sqrt{3}t^2+\sqrt{3}tx+t+x}{2(t^4-t^2+1)(x^2+\sqrt{3}x+1)}\,dt\,dx\\
\end{align}
Since,
\begin{align}A_1&=\int_0^1 \frac{t}{t^4-t^2+1}\,dt\\
&=\frac{1}{\sqrt{3}}\left[\arctan\left(\frac{2t^2-1}{\sqrt{3}}\right)\right]_0^1\\
&=\frac{\pi}{3\sqrt{3}}\\
A_3&=\int_0^1 \frac{t^3}{t^4-t^2+1}\,dt\\
&=\frac{1}{12}\left[2\sqrt{3}\arctan\left(\frac{2t^2-1}{\sqrt{3}}\right)+3\ln(t^4-t^2+1)\right]_0^1\\
&=\frac{\pi}{6\sqrt{3}}\\
B_1&=\int_0^1 \frac{1}{x^2-\sqrt{3}x+1}\,dx\\
&=2\Big[\arctan\left(2x-\sqrt{3}\right)\Big]_0^1\\
&=\frac{5\pi}{6}\\
B_2&=\int_0^1 \frac{1}{x^2+\sqrt{3}x+1}\,dx\\
&=2\Big[\arctan\left(2x+\sqrt{3}\right)\Big]_0^1\\
&=\frac{\pi}{6}\\
C_1&=\int_0^1 \frac{x}{x^2-\sqrt{3}x+1}\,dx\\
&=\Big[\frac{1}{2}\ln\left(x^2-\sqrt{3}x+1\right)+\sqrt{3}\arctan\left(2x-\sqrt{3}\right)\Big]_0^1\\
&=\frac{1}{2}\ln\left(2-\sqrt{3}\right)+\frac{5}{4\sqrt{3}}\pi\\
C_2&=\int_0^1 \frac{x}{x^2+\sqrt{3}x+1}\,dx\\
&=\Big[\frac{1}{2}\ln\left(x^2+\sqrt{3}x+1\right)-\sqrt{3}\arctan\left(2x+\sqrt{3}\right)\Big]_0^1\\
&=\frac{1}{2}\ln\left(2+\sqrt{3}\right)-\frac{1}{4\sqrt{3}}\pi\\
A_2&=\int_0^1 \frac{t^2}{t^4-t^2+1}\,dt\\
&=\int_0^1 \frac{t^2+1}{t^4-t^2+1}\,dt-\int_0^1 \frac{1}{t^4-t^2+1}\,dt\\
&=\left[\arctan\left(\frac{x}{1-x^2}\right)\right]_0^1-\frac{1}{2\sqrt{3}}\int_0^1 \frac{x}{x^2+\sqrt{3}x+1}\,dx+\frac{1}{2\sqrt{3}}\int_0^1 \frac{x}{x^2-\sqrt{3}x+1}\,dx-\\
&\frac{1}{2}\int_0^1 \frac{1}{x^2+\sqrt{3}x+1}\,dx-\frac{1}{2}\int_0^1 \frac{1}{x^2-\sqrt{3}x+1}\,dx\\
&=\frac{\pi}{2}-\frac{1}{2\sqrt{3}}C_2+\frac{1}{2\sqrt{3}}C_1-\frac{1}{2}B_2-\frac{1}{2}B_1\\
&=\frac{\pi}{4}-\frac{1}{2\sqrt{3}}\ln\left(2+\sqrt{3}\right)\\
A_0&=\int_0^1 \frac{1}{t^4-t^2+1}\,dt\\
&=\int_0^1 \frac{1+t^2}{t^4-t^2+1}\,dt-\int_0^1 \frac{t^2}{t^4-t^2+1}\,dt\\
&=\left[\arctan\left(\frac{x}{1-x^2}\right)\right]_0^1-A_2\\
&=\frac{\pi}{4}+\frac{1}{2\sqrt{3}}\ln\left(2+\sqrt{3}\right)\\
\end{align}
then,
\begin{align}
2J&=\left(\frac{1}{2}A_3B_1+\frac{1}{2}A_2C_1-\frac{\sqrt{3}}{2}A_2B_1-\frac{\sqrt{3}}{2}A_1C_1+\frac{1}{2}A_1B_1+\frac{1}{2}A_0C_1\right)+\\
&\left(\frac{1}{2}A_3B_2+\frac{1}{2}A_2C_2+\frac{\sqrt{3}}{2}A_2B_2+\frac{\sqrt{3}}{2}A_1C_2+\frac{1}{2}A_1B_2+\frac{1}{2}A_0C_2\right)\\
\end{align}
Since,
\begin{align}\frac{1}{2}A_3B_1&=\frac{5\pi^2}{72\sqrt{3}}\\
\frac{1}{2}A_2C_1&=\frac{5\pi^2}{32\sqrt{3}}+\frac{\pi}{16}\ln\left(2-\sqrt{3}\right)-\frac{1}{8\sqrt{3}}\ln\left(2-\sqrt{3}\right)\ln\left(2+\sqrt{3}\right)-\frac{5\pi}{48}\ln\left(2+\sqrt{3}\right)\\
-\frac{\sqrt{3}}{2}A_2B_1&=\frac{5\pi}{24}\ln\left(2+\sqrt{3}\right)-\frac{5\pi^2}{16\sqrt{3}}\\
-\frac{\sqrt{3}}{2}A_1C_1&=-\frac{\pi}{12}\ln\left(2-\sqrt{3}\right)-\frac{5\pi^2}{24\sqrt{3}}\\
\frac{1}{2}A_1B_1&=\frac{5\pi^2}{36\sqrt{3}}\\
\frac{1}{2}A_0C_1&=\frac{\pi}{16}\ln\left(2-\sqrt{3}\right)+\frac{5\pi^2}{32\sqrt{3}}+\frac{1}{8\sqrt{3}}\ln\left(2-\sqrt{3}\right)\ln\left(2+\sqrt{3}\right)+\frac{5\pi}{48}\ln\left(2+\sqrt{3}\right)\\
\frac{1}{2}A_3B_2&=\frac{\pi^2}{72\sqrt{3}}\\
\frac{1}{2}A_2C_2&=\frac{\pi}{12}\ln\left(2+\sqrt{3}\right)-\frac{\pi^2}{32\sqrt{3}}-\frac{1}{8\sqrt{3}}\ln^2\left(2+\sqrt{3}\right)\\
\frac{\sqrt{3}}{2}A_2B_2&=\frac{\pi^2}{16\sqrt{3}}-\frac{\pi}{24}\ln\left(2+\sqrt{3}\right)\\
\frac{\sqrt{3}}{2}A_1C_2&=\frac{\pi}{12}\ln\left(2+\sqrt{3}\right)-\frac{\pi^2}{24\sqrt{3}}\\
\frac{1}{2}A_1B_2&=\frac{\pi^2}{36\sqrt{3}}\\
\frac{1}{2}A_0C_2&=\frac{1}{8\sqrt{3}}\ln^2\left(2+\sqrt{3}\right)+\frac{\pi}{24}\ln\left(2+\sqrt{3}\right)-\frac{\pi^2}{32\sqrt{3}}\\
\end{align}
Therefore,
\begin{align}2J&=\frac{\pi}{24}\ln\left(2-\sqrt{3}\right)+\frac{3\pi}{8}\ln\left(2+\sqrt{3}\right)\end{align}
Since,
\begin{align}\left(2-\sqrt{3}\right)\left(2+\sqrt{3}\right)=1\end{align}
Therefore,
\begin{align}2J&=-\frac{\pi}{24}\ln\left(2+\sqrt{3}\right)+\frac{3\pi}{8}\ln\left(2+\sqrt{3}\right)\\
&=\frac{\pi}{3}\ln\left(2+\sqrt{3}\right)
\end{align}
Thus,
\begin{align}\boxed{J=\frac{\pi}{6}\ln\left(2+\sqrt{3}\right)}
\end{align}
Answer: Let $J(a) =\int_0^1 \frac{1}{1+x} \cot^{-1}\frac {2x\sin a}{1-x^2}\ dx$, along with $J(0)=\frac\pi2\ln2$
\begin{align}
J'(a) &= \int_0^1 \frac{2\cos a \ (x^2-x)}{(x^2+1)^2-(2x\cos a)^2}dx
=\frac12\left( a \ln\tan\frac a2\right)'
  - \frac\pi4\tan\frac a2
\end{align}
Then
\begin{align}
 &\int_0^1 \frac{(x^2+1)\ln(1+x)}{x^4-x^2+1}dx\\
\overset{ibp}= &\int_0^1 \frac{1}{1+x} \cot^{-1}\frac x{1-x^2}dx
=J\left(\frac\pi6\right)= J(0)+\int_0^{\frac\pi6}J'(a)da \\
= &\ \frac\pi2 \ln2-\frac\pi4 \int_0^{\frac\pi6}\tan\frac a2 da+\frac12\int_0^{\frac\pi6} d\left( a\ln\tan\frac a2\right)\\
=&\ \frac\pi2\ln2+\frac\pi2\ln\cos\frac\pi{12}+\frac\pi{12}\ln\tan\frac\pi{12}
= \frac\pi6\ln(2+\sqrt3)
\end{align}
Answer: $$I=\int_0^1 \frac{(x^2+1)\ln(1+x)}{x^4-x^2+1}dx\overset{\large{x=\frac{1-t}{1+t}}}=4\int_0^1 \frac{(t^2+1)\left(\ln 2 - \ln(1+t)\right)}{t^4+14t^2+1}dt$$
$$\overset{IBP}=\frac{\pi}{2}\ln 2- (2+\sqrt 3)\left( \int_0^1 \frac{\ln(1+t)}{t^2+(2+\sqrt 3)^2}dt +\int_0^1 \frac{\ln(1+t)}{(2+\sqrt 3)^2 t^2+1}dt\right)$$
$$\int_0^1 \frac{\ln(1+t)}{t^2+(2+\sqrt 3)^2}dt=\int_0^\infty \frac{\ln(1+t)}{t^2+(2+\sqrt 3)^2}dt-\int_0^1 \frac{\ln(1+t)-\ln t}{(2+\sqrt 3)^2t^2+1}dt$$
$$\Rightarrow I=\frac{\pi}{2}\ln 2 -(2+\sqrt 3)\left(\int_0^\infty \frac{\ln(1+t)}{t^2+(2+\sqrt 3)^2}dt+\int_0^1 \frac{\ln t}{(2+\sqrt 3)^2t^2+1}dt\right) $$
By substituting $t=(2+\sqrt 3) x$ respectively $(2+\sqrt 3)t =x$ we get:
$$I=\frac{\pi}{2}\ln 2 -\left(\int_0^\infty \frac{\ln\left(1+(2+\sqrt 3)x\right)}{1+x^2}dx+\int_0^{2+\sqrt 3} \frac{\ln\left(\frac{x}{2+\sqrt 3}\right)}{1+x^2}dx\right)$$
$$=\frac{\pi}{2}\ln 2 + \ln(2+\sqrt 3) \arctan( x)\bigg|_0^{2+\sqrt 3}-\int_0^\infty \frac{\ln\left(1+(2+\sqrt 3)x\right)}{1+x^2}dx-\int_0^{2+\sqrt 3} \frac{\ln\left(x\right)}{1+x^2}dx$$
$$=\frac{\pi}{2}\ln 2 + \frac{5\pi}{12}\ln(2+\sqrt 3)-(J_1(2+\sqrt  3)+J_2(2+\sqrt 3))$$
$$J_1(a)=\int_0^\infty \frac{\ln(1+ax)}{1+x^2}dx\Rightarrow J_1'(a)=\int_0^\infty \frac{x}{(1+x^2)(1+ax)}dx=$$
$$=\frac{a}{1+a^2} \int_0^\infty \frac{1}{1+x^2}dx+\frac{1}{1+a^2}\int_0^\infty \left(\frac{x}{1+x^2}-\frac{a}{1+ax}\right)dx=$$
$$=\frac{\pi}{2}\frac{a}{1+a^2} +\frac{1}{1+a^2}\ln\left(\frac{\sqrt{1+x^2}}{1+ax}\right)\bigg|_0^\infty=\frac{\pi}{2}\frac{a}{1+a^2}-\frac{\ln a}{1+a^2}$$
$$J_1(0)=0 \Rightarrow J_1(2+\sqrt 3) =\int_0^{2+\sqrt 3}\left(\frac{\pi}{2}\frac{a}{1+a^2}-\frac{\ln a}{1+a^2}\right)da$$
$$J_1(2+\sqrt  3)+J_2(2+\sqrt 3) =\int_0^{2+\sqrt 3}\frac{a}{1+a^2}da-\int_0^{2+\sqrt 3}\frac{\ln a}{1+a^2}da+\int_0^{2+\sqrt 3}\frac{\ln a}{1+a^2}da$$
$$\Rightarrow I=\frac{\pi}{2}\ln 2 + \frac{5\pi}{12}\ln(2+\sqrt 3)+\frac{\pi}{2}\int_0^{2+\sqrt 3}\frac{a}{1+a^2}da=$$
$$= \frac{\pi}{2}\ln 2 + \frac{5\pi}{12}\ln(2+\sqrt 3) +\frac{\pi}{4}\ln(4(2+\sqrt 3))$$
$$\Rightarrow I=\int_0^1 \frac{(x^2+1)\ln(1+x)}{x^4-x^2+1}dx= \frac{\pi}{6}\ln(2+ \sqrt 3)$$
Comment: (+1) Very nice and unexpected $\frac{1-t}{1+t}$ substitution!
Answer: I thought about the comment you left the other day, and it has led me to this alternative approach, which is more direct than my other answer. Thanks a lot, I have learned so much from you!
Let $\omega=\sqrt[3]{-1}$, and let Ti2 denote the inverse tangent integral function:
\begin{align*}
I&=\int_0^1\frac{\left(1+x^2\right)\log(1+x)}{x^4-x^2+1}dx\\
&=\int_0^1\left(\frac{\omega}{1+\omega^2 x^2}+\frac{\bar{\omega}}{1+\bar{\omega}^2 x^2}\right)\log\left(1+x\right)dx\\
&=\left.\left(\arctan(\omega x)+\arctan(\bar{\omega}x)\right)\log(1+x)\right|_0^1-\int_0^1\frac{\arctan(\omega x)+\arctan(\bar{\omega} x)}{1+x}dx\\
&=\frac{\pi}{2}\log 2-\operatorname{Ti_2}(\omega,\omega)-\operatorname{Ti_2}(\bar{\omega},\bar{\omega})
\end{align*}
A result (3.27) from Polylogarithms and Associated Functions reads:
$$\operatorname{Ti_2}(a,a)+\operatorname{Ti_2}(a^{-1},a^{-1})=\frac{\pi}{2}\log\left(\frac{2}{\sqrt{1+a^2}}\right)+\arctan(a)\log(a)
$$
Thus letting $a=\omega$, we get:
$$I=\frac{\pi}{2}\log\left(\sqrt{1+\omega^2}\right)-\arctan(\omega)\log(\omega)=\frac{\pi}{6}\log\left(2+\sqrt{3}\right)
$$

This approach also produces a general result, for when $-\frac{\pi}{2}<\varphi<\frac{\pi}{2}$:
$$\int_0^1\frac{\left(1+x^2\right)\log(1+x)}{x^4+2\cos(2\varphi)x^2+1}dx=\frac{\pi}{8\cos\varphi}\log(2\cos\varphi)+\frac{\varphi}{4\cos\varphi}\log\tan\left(\frac{\varphi}{2}+\frac{\pi}{4}\right)
$$
Answer: Here is a hint:
For some constants $p$,$q$ consider the integral
$$L_{p,q} = \int_0^1 \frac{\ln(1+px)}{1+qx} dx$$
and do an integration by parts (Focus on Integration of $\frac{1}{1+qx}$, while the other factor will only be differentiated). Thus:
$$L_{p,q} = [\ln(1+px)\ln(1+qx)/q]_0^1 - \frac{p}{q} \int_0^1 \frac{\ln(1+qx)}{1+px} dx $$$$= [\ln(1+px)\ln(1+qx)/q]_0^1 - \frac{p}{q} L_{q,p} = \ln(1+p)\ln(1+q)/q - \frac{p}{q} L_{q,p}$$
This is only a System of linear algebraic equations for the $L_{q,p}$. Identify the parameters and solve the system of two algebraic equations (one for the integral of desire and the other one with $p$, $q$ reversed).
Comment: Unfortunately, if you reverse $p$ and $q$, then you get the same equation: $$p\,L_{p,q}+q\,L_{q,p}=\ln\big((1+p)(1+q)\big)\,.$$  So, you cannot solve for $L_{p,q}$.  But this looks very nice.
Comment: I can also give you a hint for the integral $Q_n:=\int x^nln(1+x)dx$. If you integrate the function $ln(1+x)$, you obtain $(1+x)ln(1+x)-(1+x)$. After Differentiation of the $x^n$ you have $Q_n = ((1+x)ln(1+x)-(1+x))x^n - n\int x^nln(1+x)dx - n \int x^{n-1}ln(1+x)dx + n \int x^{n-1}(1+x)dx = nQ_n - nQ_{n-1} + n \int x^{n-1}(1+x)dx + ((1+x)ln(1+x)-(1+x))x^n $
Comment: Feyman's trick works fine. (it's a bit lenghty)


JQuery onclick and focusout

Question: Eu tenho minha navbar com um botão de busca que chama um slideToogle() e exibe um formulário com um input texto dentro abaixo da minha navbar.
Eu quero que meu formulário seja escondido ao perder o foco ou o botão de busca seja clicado de novo.
Então meu problema é esse, quando clico no botão de busca com o form aberto, ele executa a mesma coisa duas vezes.
http://codepen.io/anchietajunior/pen/amxmYX
Comment: Traduza sua pergunta por gentileza, este é o Stack em Português.
Comment: Já foi traduzida.
Answer: Tente algo parecido com isso companheiro.

try something like this.
<code>var i = 0;
$('#search_button').on('click', function(e){
    if(i == 0){
      i++;
      e.preventDefault();
      $searchbar.slideToggle(300);
      $('#search_form_input').focus();
   } else {
      i = 0;
      $searchbar.trigger('focusout');
   }
});
</code>
Comment: Traduza sua resposta por gentileza, este é o Stack em Português.
Comment: Certo @diegofm, irei alterar minha resposta.
Comment: Não funcionou, infelizmente.

JQuery onclick and focusout


topology of dual $k-$ linear space

Question: The problem arises when I was reading the book Hopf Algebra written by Eiichi Abe. I asked a qustion related to this question on this site Topology of vector spaces.
In the book, a subspace is referred to a topological subspace and a $k$-linear subspace is just a linear subspace.
On page 70, there is an exercise :
Let $u:V\rightarrow W$ be a $k$-linear map and let $u^*:W^*\rightarrow V^*$ be its dual $k$-linear map. Then $u^*$ is a continuous function and the image of a closed subspace of $W^*$ is a closed subspace of $V^*$. Moreover, if we let $S$, $T$ be $k$- linear subspaces of $V$, $W$ respectively, then $$u^{*-1}(S^{\perp})=(u(S))^{\perp}, u^{*}(T^{\perp})=(u^{-1}(T))^{\perp}$$
My question is how to prove $u^{*}(T^{\perp})=(u^{-1}(T))^{\perp}$ and the image of a closed subspace of $W^*$ is a closed subspace of $V^*$.
Comment: I assume $V, W$ are finite dimensional, right? Is $k$ arbitrary? What is the topology on $V^*$ then?
Comment: @freakish No, in general. $k$ is an arbitrary field.
Comment: The topology is called the finite topology. See Hopf Algebra An Introduction written by Sorin, page 10.
Comment: I don't have access to the book. Can you add the definition to your question?
Comment: As long as it is readable then I think yes.
Comment: My question is  in the last photo, exercise 1.2.18. Sorry to make it so long to read.
Answer: I've figured out the problem. I think it's not that trivial, so I post the answer. First, note that $V\subset V^{**}$ is a dense subset. Denote by $ X^{\perp(V^{**})}$ the orthogonal of $X$ in $V^{**}$. Then $V\cap X^{\perp(V^{**})}=X^{\perp}$. Denote by $(u^*(T^{\perp}))^{\perp(V^{**})}=R$, $(u^{-1}(T))^{\perp\perp(V^{**})}=S$ . By exercise 1.2.18(ii) (which is easy to prove), we have $V\cap R=V\cap S$ since $T^{\perp\perp}=T$ and $V\cap S=u^{-1}(T)$ by corollary. 1.2.8.  If we prove that $R=S$,then we are done since $R^{\perp}=u^*(T^\perp)$ and $S^{\perp}= (u^{-1}(T))^{\perp}$. Note that both $R$ and $S$ are closed in $V^{**}$ and $V$ is a dense subset. Then the closure of $V\cap R$ in $R$ is $R$. But $V\cap R=V\cap S\subset S$ is closed in $ R$. Thus we have $R=S$.

topology of dual $k-$ linear space


Active Directory replication failing with Access is Denied

Question: I recently discovered that Active Directory replication started failing about a month ago.  If I attempt to Replicate Now from the failing domain controller, I receive The following error occurred during the attempt to synchronize the domain controllers: Access is denied.
Directory Service log tells basically the same story; repeating two events

1061: Internal error: The directory replication agent (DRA) call returned error 5.
1085: Replication warning: The directory replication agent (DRA) couldn't synchronize partition DC=OUR_DOMAIN with partition on directory server big-long-guid._msdcs.OUR_DOMAIN. The error was: Access is denied

It is between two servers at a remote site.  One is Windows 2003 and the other is Windows 2000; the Windows 2000 machines is experiencing the errors.  The domain is older OUR_DOMAIN style.
Attempts so far:

I disabled Kerberos service on the Windows 2000 server and restarted
RPC and RPC locater services have expected settings
HKEY_Local_Machine\Software\Microsoft\Rpc\ClientProtocols missing ncacn_nb_tcp on Windows 20003 server (added)
Portqry reports okay
Firewall disabled
netdom resetpwd (and reboot) on Windows 2000 server.
ENTERPRISE DOMAIN ADMINS has read access to site on both servers
dcdiag /c on 2003: Pass all except DNS Forward; several errors related to root hint servers, which don't seem relevent
dcdiag /c on 2000: says replication failed (duh) (3 reports) and then passes the test(?)  Reports IISADMIN and SMTPSVC missing (don't see why they would be needed)  Lists some error events for kccevent (where are those in event viewer?) and some printer errors from systemlog.
Comment: Does DCDIAg show any issues on either server?
Answer: Are there any relevant errors in the System, Authentication or Directory Service Event logs to accompany this? Do dcdiag and/or netdiag on the servers give any clues? Does ENTERPRISE DOMAIN CONTROLLERS have read access to the sites in AD Sites and Services? Just same basic things to check and ask because this could be cause by any number of things. At the very least, I would expect some sort of error or authentication failure to be logged when you force the replication. You may want to increase your auditing for the purposes of troubleshooting.
Comment: There some messages in the Directory Service log, (added to main question text) but they tell the same story (Access is denied)
Comment: dcdiag on 2003 said it skipped `CheckSecurityErrors` because it needed a server name.  (this option is sadly missing on 2000 dcdiag)  Running it said there was 340 sec. time skew, enough to break the kerberos 5-minute window.  **Changing the clocks did it** (Now off to find out to keep them in sync.)
Comment: The servers should really sync themselves assuming the PDC Emulator has a valid time source. Good reference for setting this up: http://support.microsoft.com/kb/816042
Answer: I would also like to share my experience, I will immediately say that resetting the secure channel on the failed domain controller helped me, and I also rebooted the PDC. I did all the actions according to the detailed instructions, by the way, in parallel, I still need to solve problems with the DNS so that all the records are relevant in it in the servers.


How to add content inbetween node fields on node creation?

Question: I have a node called survey. Inbetween fields I want arbitrary text. The text is not associated with a field. I tried adding a "group", but could not find a way to add html. Then I looked at adding some kind of plain text field, but also no luck.
I'm sure I've done this using groups in the past, but I just can't seem to find out where to do it. Any ideas?
And just to be clear:
 - I have a node called survey
 - It has fields on it like "name" and "email" address
 - Inbetween name and email, I want, for example, to show an image and some text. I want to be able to enter the html to do this, but not sure how to add it?
In code, I would just add a type "#markup", but how do you do this via the interface?
Answer: I guess this inbetween content is static or else you would have it as a field as well. So, I think you should just edit the template file of this node and add the fields and whatever other info you want between them directly on the file.
It would look sth like:
<?php print render($content['field_firstfield']);?> // first custom field

whatever you want inbetween

<?php print render($content['field_firstfield']); ?> // second custom field
<?php print render($content['body']);?> // all the rest content

Answer: Field help helper

The Field help helper module adds a link to entity configurable fields so that users with the appropriate permissions may easily edit the help text and label for a field in context of where the field displays.

Better field descriptions

Better field descriptions makes it possible to
  add themeable descriptions to fields in
  forms.

Field Help

This module is a container for functions that extend Drupal's core Field API. It could be installed as a library and it would work just as well.

I hope the above modules will give you what you are asking for.
Another Workaround:
If i understand your question, you may use a long text field (same as the body field), make it read-only (disable it), change its settings to full html, and put inside whatever html code (image, text...) you like.
Note: if you have the ckeditor (wysiwyg editor bar) installed, it will be a better way for you to just you know lets say decorate your text.
Answer: Markup is undeniably the module for the job.


Are the discrete hexachords of a tone row always either the same set class or z-related?

Question: In a traditional 12-note tone row, it seems to me that the first six notes will always either be in the same set class as the last six notes, or will be z-related, but I'm having trouble confirming this. For example:
Schoenberg's Fourth String Quartet:
2 1 9 T 5 3 | 4 0 8 7 6 E
Both discrete hexachords are (014568)
Berg's Violin Concerto:
7 T 2 6 9 0 | 4 8 E 1 3 5
The first hexachord is (013468) and the last is (012469), both have interval vector <233331> and are thus z-related.
Are there exceptions to this? Alternatively, is there a proof of this fact without having to try all 12!=479,001,600 possibilities?
Comment: I've got Allen Forte's book on my desk at the moment, as it happens; but I must confess I haven't read all of it! I presume, by your question, you're familiar with this book… (+1 BTW…)
Comment: @BobBroadley Yes, although my primary set-class/serial study involved the Straus Post-Tonal Theory textbook. I read both long ago, although I frequently still refer to the Straus. It's possible that one or both answer the question, but I'm having difficulty locating an answer specifically. Seems like the kind of thing more likely to be an offhand reference than a specific topic of discussion...
Comment: This question would be great to look into - I'm unfortunately away from my library :(.  Are you looking for specific examples of pieces / textbooks that refute the claim?  Have you read any Babbitt?
Comment: @jjmusicnotes I'm looking either for a specific example or textbook that refutes the claim, or a paper or *a priori* proof that proves the claim.
Comment: Or, I suppose, a list of all 479 million possible rows showing that it's true. :) But seriously, I'm all but certain that it must be the case, just looking for some kind of confirmation.
Answer: For the sake of future readers, I'd like to synthesize a full answer to the question so that it isn't only buried in a link inside a comment.

1.
As Robert Fink's answer suggests, the TL;DR answer to the question is yes, the final hexachord of any tone row will either be the same as the first hexachord, or will be its z-partner.

2.
A slightly longer answer suggested by a non-SE friend is as follows:
The complement of any set-class of any size (that is, the set class of the notes remaining out of all 12 possibilities in the traditional Western system once you've removed the notes of the original set) will always be the same regardless of the specific notes. For example, the notes D, D#, F#, G#—a member of the all-interval tetrachord (0146)—has the complement C, C#, E, F, G, A, A#, B, a member of (01234689). A completely different member of (0146) would be G, A, C, C#; but its complement—D, D#, E, F, F#, G#, A#, B—is still of member of (01234689).
Obviously, this will still hold true for hexachords. Once you have the first hexachord of a traditional 12-tone series, the remaining hexachord is, by definition, the complement of the first. All that remains to prove the original hypothesis is the fact that the complement of any hexachord is either itself or its z-partner, as can be verified by looking at any hexachord list like the one in the Appendix of Straus' Introduction to Post-Tonal Theory.

3.
A somewhat more formal proof by Steven K. Blau was provided in a link by Micah, the full paper is here: http://www.maa.org/sites/default/files/269122711809.pdf
I'll provide a brief summary. If we pick an arbitrary hexachord, let's call it A, then it implies a complementary hexachord (B) that marks its completion in a tone row. We can envision these two hexachords in a clockface diagram like so:

     B   A   A
    B              B
   A                A
    B              A
        B       B
            A

Now we imagine switching one of the A notes with one of the B notes, I'll do a switch of the 2 o'clock and 3 o'clock positions.

     B   A   A
    B              A
   A              ⤹B⤣
    B              A
        B       B
            A

The only intervallic changes in A will be matched by identical intervallic changes in B. For example, the A note that used to be at 3 o'clock was 3 semitones away from the A note at 12 o'clock, but it is now only 2 away. This changes the A hexachord's constituent interval content but we've simultaneously changed the B hexachord in that the B note that used to be at 2 o'clock was also 3 semitones away from the B note at 5 o'clock and is now only 2 away. In other words, at the same time that we changed one of the intervals in A from IC3 to IC2, we also changed one of the intervals in B in precisely the same way. The article at that link covers all possibilities (although I think the author accidentally reverses n+1 and n at one point)
Therefore, the interval content of the two hexachords will always be the same no matter what, which is just another way of saying that the discrete hexachords of any row will either be the same set class or z-related. QED
Comment: Thanks @Pat, this explains a fundamental idea in an easily understandable way. I must confess I followed Micah's link, but didn't read the whole paper - now that you've given me this information, I'm likely to return to that paper.
Answer: Yes, this is true. We refer to it, in the business, as The Hexachordal Combinatoriality Theorem. It can be mathematically proven, but I can't (without reliving some traumatic graduate school experiences) do it for you here. :)
Comment: This looks like a proof: http://www.maa.org/sites/default/files/269122711809.pdf
Comment: Fair enough! Any references as to where I could find this discussed though? A google search for Hexachordal Combinatoriality Theorem in quotes yields no results. As a general rule, the texts I've read use Combinatoriality to refer to the combination of two different row forms such that the first hexachord of each form and the last hexachord of each form complete the aggregate, not to the two discrete hexachords of a single row.
Comment: Yep, looks like that covers it, thank you! Apparently it's just called the Hexachordal Theorem.
Answer: As the author of some horribly complicated proofs of the hexachordal theorem, I am happy to provide the simplest (I think it was first published around 2004, not sure who found it first). It uses two mathematical tools, but fairly simple ones.

the characteristic function of a pc-set X is simply a list of 0's and 1's, depending whether the index is  or not an element of X. Thze characteristic function of, say, C E G B or 0 4 7 11 is thus 1_X = (1 0 0 0 1 0 0 1 0 0 0 1).
the interval vector, complete, or rather IFunc(X, X) for a pc-set X can be expressed as something called a convolution product of characteristic functions.
The convolution product of two functions f and g is defined by
f*g (x) = sum f(t) g(x-t) —the sum runs for all t's, if a value exits the range 0-11 then add or remove 12 as needed.
The iv satisfies iv(x) = sum 1_X(t).1_X(x+t) since the running term is 1 only when both characteristic functions give a 1, id est when both t and x+t are elements of X.
Summing up, iv = 1_X * 1_(-X) where -X is the inverse of X.

Now the hexachordal thm is a one-liner: just compute the iv for the complement of X. Let us call it Y for clarity: 1_Y = 1 - 1_X (exchanges 0 for 1 and conversely !), hence
iv(Y) = (1 - 1_X)*(1 - 1_(-X))= 1*1 - 1*1_X - 1*1_(-X)+ 1_X * 1_(-X)= 12-6-6 + 1_X * 1_(-X) = iv(X)
(take care, 1 denotes here not a constant but the vector of values all equal to 1). Qed.
Comment: Uh, the combination of large amount of non-standard names and symbols with the lack of math support on this site makes it really hard to follow.
Comment: How is 1*1 = 12? Do you first use * to denote convolution, and then in other place a dot product?


Directly obtaining marginal cdf directly from joint cdf

Question: I know how to obtain marginal PDF $f(x)$ from $f(x,y)$. Just integrate over $y$.
But is there a way to directly obtain marginal CDF $F(x)$ from $F(x,y)$? Do I need to calculate marginal PDF $f(x)$ before obtaining $F(x)$? Is that the only way to go?
I need to do this because I need to show that x and y are independent. So I decided to show that:
$$F(x,y)=F(x)F(y)$$
Comment: I believe that if you were to write a careful definition of $F(x,y)$ and another definition of $F(x)$, then the answer might be immediately obvious.
Comment: @gung This question was motivated by what a textbook says, but this is not the same question that the textbook asks. It's just my own question. Should I still add self-study tag?
Comment: Is this a question from a course or textbook? If so, please add the `[self-study]`
tag & read its [wiki](http://stats.stackexchange.com/tags/self-study/info).
Comment: It's probably best, @user42459.
Answer: There's an easier way to approach your problem if you already know the joint density.  Just use the fact that if two random variables have joint density $f_{XY}(x, y)$ then they're independent if and only if that density factors, i.e., $f_{XY}(x, y) = g(x) h(y)$ for functions $g$ and $h$.  If instead you're determined to find $F_X$, then no, I don't believe you can calculate it from $f_{XY}(x, y)$ without implicitly calculating the marginal density along the way.
Comment: $F_X(x) = P(X \leq x) = \lim_{y \to \infty} P(X \leq x, Y \leq y) = \lim_{y \to \infty} F_{XY} (x, y)$.
Comment: How do I obtain the marginal CDF $F(x)$ from joint CDF $F(x,y)$ at least indirectly through calculating density?
Answer: It is rare for a joint CDF $F_{X,Y}(x,y)$ to known explicitly or to be stated in a homework problem that asks whether $X$ and $Y$ are independent random variables because of the length of the description of the CDF. For example, if jointly continuous $(X,Y)$ takes on values in the unit square, there will different expressions specifying the value of the CDF in the regions
$$\{(x,y)\colon x < 0 ~\text{or}~ y < 0\},\\\{(x,y)\colon 0 \leq x < 1, 0 \leq y < 1\}\\
\{(x,y)\colon 0 \leq x < 1, y \geq 1\}\\\{(x,y)\colon x \geq 1, 0 \leq y < 1\}\\
\{(x,y)\colon x \geq 1, y  \geq 1\}$$
with the middle three being further subdivided into more regions depending on the joint density.  But, if the joint CDF is indeed specified in this elaborate detail, then you can determine $F_X(x)$ and $F_Y(y)$ by finding the limiting values of $F_{X,Y}(x,y)$  (cf. dsaxton's comment following his answer)
and then check whether $F_{X,Y}(x,y) = F_X(x)F_Y(y)$ holds for all $(x,y)$.
More simply, check if for each $(x,y)$, it is possible to write $F_{X,Y}(x,y)$ as $G(x)H(y)$, that is, as the product of a function of $x$ and a
function of $y$.  This is analogous to the method mentioned in dsaxton's answer re checking whether $f_{X,Y}(x,y)$ factors into $g(x)h(y)$. Note,
however that neither of us is claiming that these factors themselves are valid pdfs or CDFs. For example, it could be that
$$F_{X,Y}(x,y) = \left(G(x)\right)\left(H(x)\right) =
\left(2F_X(x)\left)\left(\frac 12 F_Y(y)\right)\right.\right.$$


Creating a custom action in Wix for use in silent installation

Question: We use Wix to create our MSI installer. We have a few custom actions that work great when using the installer normally with a GUI, but when using silent install (with "msiexec /qb /i" ), the custom actions won't run.
What can I do to make them work through Wix?
Answer: I suggest you read (several times if needed... it took me awhile at first):
Installation Phases and In-Script Execution Options for Custom Actions in Windows Installer
There are a great many things to consider when authoring questions and the details are in that well written article.   Basically it sounds like you only put the custom action in the UI sequence and not the Execute Sequence but there are other things beyond that you should make sure you are doing correctly.
Answer: Do they simply not run or fail? It might be the case they are conditioned not to run in quiet mode (see UILevel property). If they fail, they might lack some input information (properties) which comes from user in full UI mode.
Anyway, the verbose log should give you more information.
Comment: Thank you, but how can I set the UILevel property in Wix?
Comment: It is set by the installer depending on e.g. the parameter you run msiexec with (/q). What you probably want to do is to check this property and either run custom action or not. Is it right?
Answer: You can set "[UILevel]" in ExeCommand and access it trough arguments.
<code> <CustomAction Id="customActionId" BinaryKey="InstallerProgram" ExeCommand="[UILevel]" Execute="deferred" Return="check" />

    static void Main(string[] args)
    {
     var uiLevel = args[0]; //==> [Here is the UILevel][1]
    }
</code>


Changing the default imagefield formatter for a node field

Question: I am trying to change the default formatter for an imagefield node form field so that it will default to the thumbnail image and not the icon. I have already tried a form alter and that isn't doing a damn bit of good. I have already flushed all the cache. So I was wondering if anyone else knew how to do this.
I am running Drupal 6 by the way. The field in question is using imagecache presets.
Answer: Go into the admin for the content type in question and look at the display fields, eg, admin/content/node-type/THISCONTENTTYPE/display and change up the field you want.  You can select any imagecache preset you have defined on your system along with a number of other options.
Comment: Unfortunately there are no options for neither positioning nor a default option to be selected. I dug around for this in both the interface and the code for a very long time.
Comment: on what type of page are you trying to change this then? meaning, are you trying to change it when the node is being displayed or edited or?
Comment: The formatters are appearing in a modal window after clicking on a button in the wysiwyg and it is done this way through wysiwyg_fields module. Actually more specifically the appear in the module window after an image is uploaded in it, which comes after that button is pressed in the wysiwyg. I ended up fixing this with a jQuery call that waits until after each ajax call is completed (called ajaxComplete()) and then tries to find the field and select one automatically.
Comment: By the way, I voted your answer up for your help.
Answer: Unfortunately none of the GUI tools allowed me to change the default. So I ended up writing a little JavaScript to select the option I wanted on form load.


How do I resolve the error messages for my flutter app

Question: I am building app which is done by famous youtube channel-Codepur. I was trying to build music player app, I used 'flute_music_player:' in dependency. But issues are comming in the way. The console message is:
*
The plugin flute_music_player uses a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding. Otherwise, consider removing it since a future release of Flutter will remove these deprecated APIs.
If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.
Launching lib\main.dart on Chrome in debug mode...
Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:

package:flute_music_player

For solutions, see https://dart.dev/go/unsound-null-safety
Unhandled exception:
Bad state: Unsupported Null Safety mode NonNullableByDefaultCompiledMode.Invalid, in null.
#0      ProgramCompiler.emitModule (package:dev_compiler/src/kernel/compiler.dart:511:9)
#1      IncrementalJavaScriptBundler.compile (package:frontend_server/src/javascript_bundle.dart:214:33)
#2      FrontendCompiler.writeJavascriptBundle (package:frontend_server/frontend_server.dart:721:46)

#3      FrontendCompiler.compile (package:frontend_server/frontend_server.dart:614:9)

#4      listenAndCompile. (package:frontend_server/frontend_server.dart:1222:11)

the Dart compiler exited unexpectedly.
Failed to compile application.
Exited (sigterm)
*
If needed more info, head to app's source code and plugins : https://github.com/iampawan/Flutter-Music-Player or his yt video: https://www.youtube.com/watch?v=eWicXD5vkyg&list=PLR2qQy0Zxs_UdqAcaipPR3CG1Ly57UlhV&index=25
I am new to stackoverflow, so you can point out mistakes while asking question.
I tried to do things mentioned on ChatGPT but it's quite hard to understand those.
Answer: That package hasn't been updated in five years, and is not compatible with current versions of Dart and Flutter.
You will need to either find a different package to use that is being maintained, or fork that package and update it yourself (adding null safety on the Dart side, updating the plugin APIs in the native Android code, and potentially other changes as well).


What should be the 'Root folder' name in Flas builder 4.5 if java web application is deployed in the war file?

Question: I am trying to develop one simple application using Java, Flex and Blazeds. I am using Flash builder 4.5, blazeds 4 and JBoss 6.
I have created 'Dynamic Web' application in Eclipse, added blazeds related file in WEB-INF/lib and in WEB-INF/flex folder. I have deployed this web application in JBoss using Eclipse, so this application is getting deployed in war file.
Then I tried to create new 'Flex Project' using flash builder 4.5 and I am stuck in 2nd step where we have to configure Root Folder, Root URL and Context Root.
As my java web application is deployed in war, there's no folder to which I can set Root Folder.
Does anyone knows what shall we do in this case? Is there any other option?
Please help!
Answer: One thing I like to do is actually place my Flex project inside the Java project, usually with the same name as the Java project but with something like "Client" appended.  But this might be a bit more advanced/complex than you'd like. I tend to rely on Ant somewhat, and I don't check the Blaze/LCDS box when setting up the project.  There are a few other options too - try looking at this site:
http://blogs.infosupport.com/flash-builder-4-the-easiest-way-to-create-a-combined-flex-java-project/


Find limits for functions of natural numbers

Question: So I am dealing with some problems about random graphs where we find limits of functions of natural numbers. A simple example can be the limit of $\ln(n)$ as $n \rightarrow \infty$, where $n$ is the number of vertices of a graph. My concern is how do we intepret this type of limit? Can we view it as a special type of limits in the calculus setting, where we have the variable $x \in \mathbb{R}$? In particular, can we still apply tools from calculus (say the l'Hospital's rule) to find limits of $f(n)$, where $n \in \mathbb{N}$?
Answer: Well, if we know that $f(x)$ converges as $x \to \infty$, then it doesn't matter how we get there (we can take $ x_n = n$). But if we aren't sure there can be problems. For example $\lim_{n \to \infty} \sin{n\pi x} = 0$, so if we know convergence "in $\mathbb{N}$" it doesn't necessarily buy us anything in the real sense. You aren't sampling all the possible sequences, in a sense.
So yes, if we know a limit exists, we can apply calculus tools. But if we aren't sure, we might get gobbledygook.


Receber e Enviar JSON C#

Question: Em uma aplicação local "WindowsForm" em C#, preciso enviar e receber dados via JSON para uma página PHP , existe alguma função pré-definida  para isso ?
Comment: Jovem, explique melhor o que deseja fazer. Aliás, o que tag PHP faz nessa pergunta?
Comment: Pra onde eu preciso enviar e receber JSON é uma página em PHP
Comment: Tá, e o que você está fazendo em C#? É uma página web? Um app console? Você precisa [edit] sua pergunta e adicionar mais detalhes, senão sua publicação pode ser fechada por estar pouco clara...
Comment: Você sabe o básico sobre isso? Dá uma lida nos primeiros resultados para você ter uma noção do que está fazendo: https://goo.gl/sq9Az8
Answer: Praticamente você precisa de algumas declarações para que seu WebServices funcione.

[ScriptMethod(ResponseFormat = ResponseFormat.Json)]

Especifica o verbo HTTP é usado para chamar um método e o formato da resposta. Essa classe não pode ser herdada. Detalhes

JavaScriptSerializer

Json.NET deve ser usado de serialização e desserialização. Fornece a funcionalidade de serialização e desserialização para aplicativos que usam AJAX. Detalhes

writeJsonData

E um método que monte seu JSON (response), como exemplo: writeJsonData
Vejas detalhes de um Serviços Web XML a partir do Windows Forms
e  Vincular a um Web Service usando o BindingSource do Windows Forms
<code>[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
[WebMethod()]
public void DadosUsuario(String IdUsuario, String Chave)
{
    using (var DBCtx = new WdbContext())
    {
        try
        {
            var Usuario = DBCtx.tb_Usuarios.FirstOrDefault();
            if (Usuario != null)
                RetornarJson(DBCtx, Usuario);
        }
        catch (Exception exc)
        {
        }
    }
}

private void RetornarJson(WdbContext DBCtx, tb_Usuarios Usu)
{
    string RespJson = String.Empty;

    JavaScriptSerializer js = new JavaScriptSerializer();
    RespJson = js.Serialize(Usu);
    writeJsonData(RespJson);
}

protected void writeJsonData(string s)
{
    HttpContext context = this.Context;
    HttpResponse response = context.Response;
    context.Response.ContentType = "application/json";
    byte[] b = response.ContentEncoding.GetBytes(s);
    response.AddHeader("Content-Length", b.Length.ToString());
    response.BinaryWrite(b);
    try
    {
        this.Context.Response.Flush();
        this.Context.Response.Close();
    }
    catch (Exception) { }
}
</code>

Receber e Enviar JSON C#