Mysqli multi_query INSERT + insert_id multiplas tabelas autoincrement + Foreign key

Question: Possuo 2 tabelas por exemplo uma tabela "usuarios" contendo uma primary key ID usuário e outra tabela "detalhes" com uma foreign key do usuario.ID
A minha necessidade seria de através do php fazer por exemplo em uma única query o INSERT do usuário e os seus detalhes. Atualmente eu consegui fazer isso da seguinte forma:
$sql = "INSERT INTO usuario (usuario.nome,usuario.cpf) VALUES ('$nome','$cpf')";
$trans1 = $mysqli->query($sql);

$sql = "INSERT INTO detalhes (usuario.user_id,detalhes.civil,detalhes.idade) VALUES ($mysqli->insert_id,'$civil','$idade')";
$trans2 = $mysqli->query($sql);

if ($trans1 AND $trans2 == 1){
     echo "";
  } else {
     echo "";
  }

$conn->close();

Não sei se esta forma está correta, mas foi a que eu consegui por enquanto.
Passei horas tentando obter o mesmo resultado através do multi_query() mas não estou conseguindo de jeito nenhum.
Alguém tem alguma luz?
Valeu!
Comment: Dá pra fazer um pouco diferente usando transações.
Answer: Para obter resultados consistentes utilize transações, isso garante que somente será gravado os dados se ambos os insert funcionarem.
Caso o segundo insert falhe automaticamente o primeiro será cancelado(rollback). Para mais detalhes veja
$driver = new mysqli_driver();
$driver->report_mode = MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT;

$mysqli->autocommit(false);
try{
    $sql = "INSERT INTO usuario (usuario.nome,usuario.cpf) VALUES (?,?)";
    $stmt = $mysqli->prepare($sql);
    $stmt->bind_param('ss', $nome, $cpf);
    $insert1 = $stmt->execute();
    $id = $mysqli->insert_id;

    $sql = "INSERT INTO detalhes (usuario.user_id,detalhes.civil,detalhes.idade) VALUES (?,?,?')";
    $stmt = $mysqli->prepare($sql);
    $stmt->bind_param('isi', $id, $civil, $idade);
    $insert2 = $stmt->execute();

    $mysqli->commit();
}catch(mysqli_sql_exception $e){
    echo 'SQLState: '. $e->getCode() .'
Descrição: '. $e->getMessage();
}

if(isset($insert1, $insert2)){
    echo 'sucesso';
}

Answer: Um exemplo que você pode traduzir para o seu projeto:
Diagrama das duas tabelas (product e items)

Código Fonte
Código 1: (Indicaria esse código)
<?php

    $con = new mysqli('localhost', 'root', 'senha', 'dbase');

    $con->begin_transaction();

    try
    {

        $sts = $con->prepare("INSERT INTO product(description) VALUES(?)");

        $description = "Café";
        $sts->bind_param('s', $description);
        $sts->execute();
        $sts->close();

        $productid = $con->insert_id;
        $count = 100;

        $sts = $con->prepare("INSERT INTO items(productid, count) VALUES(?,?)");
        $sts->bind_param('ss', $productid, $count);
        $sts->execute();
        $sts->close();

        $con->commit();

    }
    catch (Exception $ex)
    {
        $con->rollback();
    }

Código 2:
<?php

    $con = new mysqli('localhost', 'root', 'senha', 'dbase');

    $con->begin_transaction();

    try
    {
        $description = "Feijão";
        $query1 = "INSERT INTO product(description) VALUES('".$description."');";

        $count = 200;
        $query2 = "INSERT INTO items(productid, count) VALUES(LAST_INSERT_ID(),".$count.");";

        $con->multi_query($query1.$query2);

        do {
            $con->store_result();
        }
        while($con->next_result());

        $con->commit();

    }
    catch (Exception $ex)
    {
        $con->rollback();
    }


How to delete a hacked score from Google Play Game Services leaderboard?

Question: I have a leaderboard with tamper protection ON since it's creation, but a player has added a hacked score of some millions of points (human reachable max of points is less than 1000)
How can I delete only that hacked score? It must be a way to do it... but can't find in documentation: https://developers.google.com/games/services/common/concepts/leaderboards
Answer: Check out the players.hide() call. This will hide a player and all of his/her scores from the public leaderboard so that nobody else can see them.
Note that this REST call is not built into the mobile libraries; you'll need to create your own mini web app (or make curl calls directly) to use this call, although there is a management tools sample app that you can use here which might make your life easier.
Oh, and if you know that the human reachable high score has to be 1000 max, specify a "Max score" of 1000 for that leaderboard in the Play Games Console.
Comment: The management-tools seems not working any more... Wish someone can have an update of it...
Answer: What I do is some kind of obfuscation.
I mean, I do replace numbers with an string like
0 = #$%@&*52$*@
1 = #$%@&*84$*$
2 = #$%@&*58$*#

separated for another unique string like: %$$90&*
and so on.
so when I go to post the score, first I do a find and replace
the string for each number, as I am posting the score locally the
data would look like;
122 = #$%@&*84$*$%$$90&*#$%@&*58$*#%$$90&*#$%@&*58$*#

so its a little bit difficult (not impossible) to post a hacked score
Answer: You can use Google Developers OAuth 2.0 Playground to do the players.hide() as mentioned by @todd-kerpelman, following the instruction in this article, but it is still a very tedious process.
I used the management-tools before too, but it seems to be not working any more.


Android HTTP requests

Question: I'm trying to use an HTTP GET request to accomplish the tasks of an HTTP POST request. I realize that this doesn't make sense and is poor practice, but is this possible? I want to be able to execute an HTTP GET that contains the URL along with a list of NameValuePairs. The NameValuePairs should not be included in the URL. On the server side (PHP), it should identify that the request is a GET and then proceed to perform the proper actions that correspond to the keys of the NameValuePairs.
My motivation for doing this is to be able to mask the type of HTTP request. In other words, if everything is a GET request, anyone monitoring network traffic wont be able to draw useful information from the request types.
I guess it's also worth noting that this is for research purposes.
Thanks.
Answer: Yes, it is possible. By violating the RFC in insane ways: Attach a message body to the GET request like you would do with a POST request.

My motivation for doing this is to be able to mask the type of HTTP request. In other words, if everything is a GET request, anyone monitoring network traffic wont be able to draw useful information from the request types.

That is a poor reason. Just use https.

I guess it's also worth noting that this is for research purposes.

Doesn't make it any better.
Comment: https isn't an option for this situation. We're trying to highlight flaws in academic research for network-level android malware detection systems in the realm of http.
Comment: Oh? Hm. Here's an idea: You could disguise your key/value pairs by placing them in prepared cookie headers. It shouldn't be too hard to obfuscate them in a way that they will look much like regular session cookies.

Android HTTP requests


Can access site from external network, but not from internal network

Question: I have registered a domain name (say leavemanager.somecompany.com), it points to a web based application (web app) hosted in a windows server machine running apache2. I have port forwarded http/s traffic of the server LAN address 192.168.0.x in the router to the external IP of the router.
When I try access the web app from an external network using the domain name, it works perfectly, but when I try access from a machine in the LAN using the same domain name, the web app does not load at all and browser says it cannot find the page. What could be the problem?
Comment: "browser says it cannot find the page.".  Obviously first things to do would be to test name resolution. You are not giving however enough important information in your question for anyone to help.
Comment: Hi @PatrickMevzek Kindly let me know what information I have left out so that I share.
Comment: Try to start with the real name involved maybe... Do proper troubleshooting using DNS and HTTP clients (`dig` and `wget` for example) and share actual traces of what works, what does not (without using images).
Comment: Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
Answer: You must set your Firewall to redirect the traffic from the internal IP range(s) to the internal IP of the Server 192.168.0.x, for the port and traffic type.


parity of function over general field

Question: we know over $\mathbb{R}$, the only function that is both even and odd is the zero function. My question is: what happens if the function is not over $\mathbb{R}$, but over some other field? Field of characteristic $0$ or $p$? How about a finite field?
Answer: Let's start by looking at the proof of what you say in $\Bbb R$.  If $f$ is both even and odd then for any $x$ we have
$$f(x)=-f(-x)=-f(x)\quad\Rightarrow\quad 2f(x)=0\quad\Rightarrow\quad f(x)=0\ .$$
This uses only the field axioms, the definitions of even and odd functions, and the assumption in the last step that we can divide by $2$: that is, the assumption that $2\ne0$.  Therefore the same is true if the codomain of $f$ is any field, finite or infinite, of characteristic ${}\ne2$.
If the codomain is a field of characteristic $2$ then
$$f(x)=-f(-x)\quad\Leftrightarrow\quad f(x)=f(-x)\ ,$$
so that even and odd mean the same thing.  There will be non-zero functions which are both even and odd, for example the identity function (as long as the domain of $f$ is the same as the codomain).
Comment: Thanks, David! This is such a through answer.

parity of function over general field


SSL Issue on EC2 Ubuntu Server

Question: I have an EC2 server with Ubuntu. Its running multiple websites and one of the websites uses a SSL certificate. The SSL is running fine but the issue is when you type in the url of one of the other domains with https and add an address of the one of the SSL domain's pages you can see the SSL domain page.
For instance https://domain.com/page/1 is the original page. If you type in https://domain2.com/page/1 you will see the original page of the SSL configured domain. If you remove the https from https://domain2.com/page/1 so its http://domain2.com/page/1 you see page not found which is what you should see.
Sorry but this is very hard to explain and Ive never came across this before. I must have something configured wrong with Apache but Im not sure what.
Comment: You have only configured SSL for the single domain, so on port 443 it becomes the default VirtualHost and catch-all for any hostname (and the ip-address) that points to your server, probably with a warning/error that there's a mismatch between the certificate and the hostname you entered in your webbrowsers URL bar.
Comment: This makes sense.  How do I fix it though?
Comment: How do you want the other sites to respond if accessed over HTTPS? Do you simply need them not to listen on port 443 and give a connection error?
Comment: You want Server Name Indication (SNI) available only after openssl-1.X, just compile that and be happy! Then your virtualhosts will work as expected.
Answer: The problem:
You only have one SSL vhost, so that one SSL vhost will match ALL SSL requests, regardless of the domain name.
Possible Solutions:
Enable SSL for every domain.
Obtain an SSL cert for each domain your server will host. Configure a vhost for each of those domains.
This will only help with browsers that support SNI. Browsers that do not support SNI will get the first SSL vhost regardless of which domain is used.
Create a 'default' SSL vhost with no content.
Create a default SSL vhost, with its own certificate. Something like webserver.example.com.
This will only work with browsers that support SNI. Browsers that do not support SNI will receive the default vhost even when they try to view the "real" SSL vhost.
Get a SAN certificate that covers all the domains.
Again, setup an SSL vhost for each domain, but have them all use the same SAN cert.
This will work even with browsers that do not support SNI, however, it becomes a pain if you want to add more domains later.
Answer: I have found one solution that is working but I do not think its the best solution.  I went ahead and created a generic self-signed certificate to use for the other domains that do not have SSL configured or SSL certificates to use.  I then created and enabled virtual host files for each of these domains.  If someone has a better solution please share.
Answer: If you install openssl-1.X and a webserver with support for it, you can make use of SNI, that stands for Server Name Indication and it's works like virtualhosts for SSL-virtualhosts.
Just compile openssl-1.X and your webserver linking to the newly compiled libraries and you can have virtualhosted ssl domains!
Cheers
Answer: the other answer should be correct.
Your problem: your domains that don't have an SSL are redirecting to the SSL domain when they have the https prefix.
Reason: the server sees you are accessing a domain over https, and redirects you to the domain the SSL certificate is issued for.
Solution: redirect each domain you have for which you do not have an SSL from https to http. Mod rewrite can do that for you by converting requests hitting your non SSL domains from trying to connect over https(causing the redirect) to connecting over http(not triggering the redirect.
Let me know if that solves it.
Comment: This does not work.  When the connection happens over https it immediately goes for the certificate on the server.  It never does the redirect.
Comment: did you try it? I would think that mod_rewrite intercepts the call before the resolution of the route happens.
Comment: Yes I did try it.  The mod_rewrite doesnt intercept before the route happens.
Answer: Your problem is that the server is redirecting to the domain pointed to by your SSL certificate. All the server knows is that your client is trying to access a site over https and that it has an SSL that points to your SSLed domain. You need to specifically tell it to redirect non-https domains to http to fix the problem.
You can use mod_rewrite for that purpose, by adding the following in the .htaccess file:
<code>RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</code>
Comment: This issue isnt about redirecting http to https.
Comment: No that does not work.  When you connect to my server on port 443 it goes to the site with the ssl configured.  I need to make sure that the other domains do not go to that site when connecting on port 443, ie https://domain2.com should not show the content of https://domain1.com like it does not since domain1.com has ssl configured.  I am guessing I need to configure a ssl virtual host for each domain but I'm not sure.
Comment: The SSL handshake happens before the mod_rewrite so it never gets a chance to redirect.
Comment: Your answer has no content. What happens when that link changes? Your answer becomes worthless. Please provide content **here** and if needed, link elsewhere for more details.
Comment: The answer has been revised. Let me know if this helps

SSL Issue on EC2 Ubuntu Server


Handling null objects in object setters

Question: I am trying to use a nice near object setter, but have null issues.
My code right now:
var Result = new RefundReplyObject
{
    AuthorisationNumber = reply.refundResponse.transactionDetails.authorisationNumber,
    ChargeValue = reply.refundResponse.transactionDetails.totalAmount.amount,
    Message = reply.refundResponse.transactionDetails.message,
    ReconciliationReference = reply.refundResponse.transactionDetails.reconciliationReference,
    SettlementDate = reply.refundResponse.transactionDetails.settlementDate,
    Status = TransactionStatusToLocalModel(reply.refundResponse.transactionDetails.status),
    TransactionReference = reply.refundResponse.transactionDetails.transactionReference
};

BUT ... 'totalAmount' might be null. So, I get errors.
Is there a neat way to handle this, so that if 'totalAmount' is null, then set chargevalue to zero?
Answer: How about a ternary operator, that checks to see if total amount is null. If it isn't, then use it's amount, otherwise 0.
ChargeValue = (reply.refundResponse.transactionDetails.totalAmount != null) ? reply.refundResponse.transactionDetails.totalAmount.amount : 0,

Answer: You could do, for example:
ChargeValue = reply.refundResponse.transactionDetails.totalAmount != null ? reply.refundResponse.transactionDetails.totalAmount.amount : 0

Answer: ternary operator to the rescue!
ChargeValue = totalAmount ? totalAmount.amount : 0;
Answer: Something like this?
ChargeValue = (null == reply.refundResponse.transactionDetails.totalAmount)
    ? 0
    : reply.refundResponse.transactionDetails.totalAmount.amount

Answer: You're not going to be able to do it on the setter side of things since the exception is occuring before you even get there. You can get what you're after (and clean up your code substantially in the process) by doing something like this:
var trans = reply.refundResponse.transactionDetails;

var Result = new RefundReplyObject
{
    AuthorisationNumber = trans.authorisationNumber,
    ChargeValue = trans.totalAmount == null ? 0 : trans.totalAmount.amount,
    Message = trans.message,
    ReconciliationReference = trans.reconciliationReference,
    SettlementDate = trans.settlementDate,
    Status = TransactionStatusToLocalModeltrans.status),
    TransactionReference = trans.transactionReference
};

Handling null objects in object setters


Access iOS Certificate in Keychain Programatically using PHP

Question: We have a web app that creates iOS apps from a CMS. It builds the Xcode project and we need to be able to archive and export it using PHP. We are able to do this fine from terminal, but using shell_exec in PHP it doesn't work.

Code Sign error: No code signing identities found: No valid signing identities (i.e. certificate and private key pair) matching the team ID "XXXXXXXXX"

We think this is because PHP isn't running as the correct user account to have permission to access the certificates in the keychain. We can set the _www user to run as in particular group, but does anybody know which user it should run as?
I understand opening up access to the _www user is a huge security flaw, but it's for an isolated system unconnected to the outside world.
Comment: Any luck with this? I'm doing something oddly similar.
Answer: And why not copy the certificate in the _www user ?


Firefox: view raw JSON on network tab

Question: I'm having a problem with Firefox's debugging panel, spcecifically on the Network tab; when a POST request sends some JSON, it shows the request body inside a tree-like viewer; while this viewer is cute and everything, I actually need to copy and paste the actual raw JSON text into another tool.
There doesn't seem to view the actual JSON request from this panel. Does someone know of some way of viewing the actual RAW JSON inside it?
Answer: After some fumbling around, I found out that if you right-click the request, the browser gives you the option to copy the post data (which would return the JSON, if it is a POST) or to "Edit and resend", which would open a dialog that, among other things, has the JSON itself.
Comment: Good answer, but totally crap that you have to do this just to copy the json.

Firefox: view raw JSON on network tab


How to pass Ruby on Rails 'form_for' elements to a Javascript function?

Question: I want to create a function that adds the value of a text field to another, the problem here is that I'm using forms from Ruby on Rails and I don't know if it is possible to get the ID from the field I want to process.
Here is my code:
This is a nested form.
<%= f.fields_for :invoices do |invoice_form| %>

    <%= invoice_form.label :in_number %>

    <%= invoice_form.text_field :in_number %>

    <%= invoice_form.label :in_amount %>

    <%= invoice_form.text_field(:in_amount,:onkeypress => "myFunction(document.getElementById('in_amount'))") %>

    <%= invoice_form.label :in_date %>

    <%= invoice_form.date_select :in_date %>

    <%= invoice_form.label :in_meshHr %>

    <%= invoice_form.text_field :in_meshHr %>
  <% end %>

And here is my javascript function:
function myFunction(text) {
    var amount = parseFloat($('#purchase_order_po_amount').val());
    var amount1 = document.getElementById(text).value;
    alert(amount1+amount);
}

Answer: You can pass this which will represent the field you want.
<%= invoice_form.text_field(:in_amount,:onkeypress => "myFunction(this)") %>

and then in your function you can do:
function myFunction(element) {
  var amount = parseFloat($('#purchase_order_po_amount').val());
  var amount1 = $(element).val();
  alert(amount1+amount);
}


Plotting lines, alphas and facet_grids

Question: I'd like to compare a number of curves which are very similar.  Plotting them on the same axis gets very confusing (because they are so close together) but plotting them on different axes is no better because they are almost indistinguishable.
I'd like to do a facet_wrap for each curve and have the curves which do not belong to that facet set to alpha = 0.25 while the faceted curve is alpha = 1.
For reference, my data looks like
tibble::tribble(
        ~METHOD,    ~mean,            ~lower,            ~upper,             ~width,   ~n,          ~p,
   "ASYMPTOTIC", 0.939365, 0.938319047477885, 0.940410952522115, 0.0445455136166802, 500L,  "p = 0.07",
      "CLOGLOG", 0.946005, 0.945005622467146, 0.946986730333604, 0.0445611267179592, 500L,  "p = 0.07",
        "EXACT", 0.964695, 0.963876926502612,  0.96549956881645, 0.0465924279807666, 500L,  "p = 0.07",
        "LOGIT",  0.95672, 0.955819372211766, 0.957603082736301, 0.0450897716879822, 500L,  "p = 0.07",
       "WILSON",  0.95672,  0.95581938978958, 0.957603065836674,  0.044862320426846, 500L,  "p = 0.07",
   "ASYMPTOTIC",  0.93936, 0.938314007137612, 0.940405992862388, 0.0445885063907574, 499L,  "p = 0.07"
  )

I'd like to facet METHOD and plot n vs width.
Is this at all possible?
Answer: Can't do much with your sample data (need more rows), so I cooked up an example using some generated data. Basically, if we add two grouping variables, we can add the lines to each facet and control the alpha, and then use the normal facetting.
Basically, I would add a second column METHOD2 (which equals METHOD), and use that to draw lines on each facet. In the call to geom_line using METHOD2, make sure to specify geom_line(data = select(dat, -METHOD), aes(group = METHOD2))
library(tidyverse)

set.seed(123)
dat <- data_frame(x = rnorm(50),
                  y = 2 * x + rnorm(50),
                  g = sample(letters[1:3], 50, T))
dat$g2 <- dat$g

ggplot(dat, aes(x = x, y = y))+
  geom_line(data = select(dat, -g),
            aes(group = g2), alpha = .25)+
  geom_line()+
  facet_wrap(~g)

Specific code for your case:
dat$METHOD2 <- dat$METHOD

ggplot(dat, aes(x = width, y = n))+
 geom_line(data = select(dat, -METHOD), aes(group = METHOD2), alpha = 0.25)+
 geom_line()

Comment: Amazing, just as I had envisioned it.  Thanks for all your help!

Plotting lines, alphas and facet_grids


Talking about percents of durations

Question: I'm translating an academic paper from German into English, and am having trouble finding a noun to describe a "portion of the total duration expressed as a percent." The objects investigated in this paper are all 6-part recordings. The paper compares e.g. part 3 of two different recordings by contrasting the absolute durations of the two part 3s with "the portions of the total duration they makes up, expressed as percentages."
13 words is not an acceptable solution, and my suggestion of "percentual duration" was rejected by the authors as too imprecise, because what's being described is actually a percent value and not a duration.
No one involved in this project is a real statistician, and we would be very grateful for suggestions re. how statisticians actually talk about things like this!
Comment: How about "share of total duration"?
Answer: One way of doing this
In your case, when you talk about percentages, you may simply use the following expression: "the proportion of total duration". Indeed, a basic google search for the definition of proportion is "a part, share, or number considered in comparative relation to a whole". For example, you could say: a large/small/...[insert any sensible adjective describing size here] proportion of total duration is ... [continue your sentence].
Answer: In your question, you use the term absolute duration to describe the actual time taken in minutes and seconds. You could contrast that with the term relative duration to describe the length of time with respect to the total time. You may want to explicitly define the term somewhere in the manuscript, with just one sentence stating that "Relative duration is calculated as the proportion of the total duration, expressed as a percentage." From then on, you can use the term relative duration as a concise yet precise way of expressing your intended idea.

Talking about percents of durations


Enabling Optional Features in IIS with PowerShell

Question: I just want to enable few  windows optional features in IIS like IIS-WebServerRole, IIS-WebServer, IIS-Metabaseand and few more using powershell. What will be the easiest way to do this?
Answer: Use :
<code>Enable-WindowsOptionalFeature -Online -FeatureName [Your_Feature_Name]
</code>
Comment: What if i want to enable them all at once so that i don't need to write Enable-windowsOptionalFeature -Online  -Feature_name every single time?
Comment: You can create a function and pass feature as parameter or you can create an array of features and loop inside it. Maybe the `-all` parameter can help you too, you may check this [link](https://learn.microsoft.com/en-us/powershell/module/dism/enable-windowsoptionalfeature?view=win10-ps#parameters)


Modulation by a tritone: nomenclature

Question: The chord progression in question follows:
C -> C#7 -> F#
in order to modulate from F to F# (C is the V of F etc.)
But is it F# or Gb? And if it's Gb, should the C#7 be a Db7 instead?
Does it matter??
Comment: it doesn't matter. You may have Eb-instruments that will play Eb major and Bb playing Ab, but the C-instruments play F#. Regularly the Dominant of F# is C#7 but even if you notate Db7 one who is able to read or play in F# major wouldn't mind if the V7 is written as Db7.
Answer: Either way, you'll end up with either 6 ♯ or 6 ♭.It will be more dependant on what key(s) any other instruments, which may be transposing,  may need to be written in.

Modulation by a tritone: nomenclature


Finding the max/min turning points of $y=\sin x$

Question:
Use differentiation to show that
$$y = \sin x$$ has a maximum turning point at $\left(\frac{\pi}2, 1\right)$ and a minimum turning point of $\left(\frac{3\pi}2, -1\right)$.

I know that the turning points occur when $\frac{dy}{dx} = 0$. So ...
$$\begin{align}\frac{dy}{dx} &= \cos x \\[6pt]
\implies\quad \cos x &= 0 \\[6pt]
\implies\quad \cos^{-1}(0) &= 90^\circ
\end{align}$$
$\cos x $ is positive in the 1st and 4th quadrants, so $x = 90^\circ$ or $x = 270^\circ$
I am not sure how to progress from here or if indeed this is the correct approach.
Comment: Stick to radians.  They are the only sensible unit for angle once you reach calculus.
Comment: ah right, I remember that actually.  Do the quadrants still apply when using derivatives?
Comment: The quadrants still apply, yes.
Answer: You're correct. Just change your measures from degrees to radians and you will get $$x=90^\circ = \frac{\pi}{2} \\ x=270^\circ = \frac{3 \pi}{2}$$ If you plug these back in the original equation you will get $$ \sin\left(\frac{\pi}{2}\right)=1 \\ \sin\left(\frac{3\pi}{2}\right)=-1$$ Which gives you your points $\left(\frac{\pi}{2},1\right),\left(\frac{3\pi}{2},-1\right)$ as extrema (maximum and minimum respectively) to the function.
Comment: How can I turn degrees into radians?  Is there a table or something I should learn so I know that $\frac{\pi}{2} = 90$
Comment: @dagda1 the relationship between degrees and radians is that $360^\circ = 2\pi$. So, for example, if you want to convert $30^\circ$ to radians, you take the ratio $\frac{360}{30} = 12$, and divide $2\pi$ to get $\frac{2 \pi}{12} = \frac{\pi}{6}$ as the measure in radians. From this you can see that $1^\circ = \frac{\pi}{180}$.
Answer: Let $f(x) = \sin x$, then $f'(x)=\cos x = 0 \iff x = 90^{\circ}$ or $x = 270^{\circ}$, and $f''(x) = - \sin x$ has $f''(90^{\circ}) = -1< 0$, and $f''(270^{\circ}) = 1 > 0$. Thus the max occurs at $x = 90^{\circ}$, and min happens at $x = 270^{\circ}$.
Comment: THe question asks for proof of a maximum turning point at $(\frac{\pi}2, 1)$ and a minimum turning point of $(\frac{3\pi}2, -1)$
Comment: @dagda1  The argument given here is based on the [Second Derivative Test](https://en.wikipedia.org/wiki/Derivative_test#Second_derivative_test).
Comment: yes but it did not answer the question


Find all solutions for a system of linear equations over a given field

Question: My Problem is: to find all Solutions for the following given System of linear equations over the Field $K = \mathbb{Z}_{/7}$
The System is given with:
$$\begin{equation}
    \begin{split}
        x_1\quad\quad\quad   + 3x_3 &= 5 \\
        5x_1 + 3x_2 + 6x_3 &= 3 \\
        6x_1 + 2x_2 + 5x_3 &= 6 \\
    \end{split}
\end{equation}$$
My Approach was: i can see this is inhomogenous System of linear Equations. The given Field is $$\mathbb{Z}_{/7}=\{ 0,1,2,3,4,5,6\}$$ so i have to calculate in Modulo 7, i think. My task seems to be to find the general solution of this System.
I tried the Cramer's rule.
$$(A\ \ b)=\left(\begin{array}{ccc|c}
1 & 0 & 3 & 5 \\
5 & 3 & 6 & 3  \\
6 & 2 & 5 & 6
\end{array}\right)$$
Since this is not Zero:
$$\det A = \left|\begin{array}{ccc}
1 & 0 & 3 \\
5 & 3 & 6 \\
6 & 2 & 5
\end{array}\right|=-8 \neq 0$$
there must be a solution. i think.
$$x_1 = \frac{\det A_1}{\det A}=\frac{ \left|\begin{array}{ccc}
5 & 0 & 3 \\
3 & 3 & 6 \\
6 & 2 & 5
\end{array}\right| }{ \left|\begin{array}{ccc}
1 & 0 & 3 \\
5 & 3 & 6 \\
6 & 2 & 5
\end{array}\right| } =\frac{0}{-8}=0$$
$$x_2 = \frac{\det A_2}{\det A}=\frac{ \left|\begin{array}{ccc}
1 & 5 & 3 \\
5 & 3 & 6 \\
6 & 6 & 5
\end{array}\right| }{ \left|\begin{array}{ccc}
1 & 0 & 3 \\
5 & 3 & 6 \\
6 & 2 & 5
\end{array}\right| }=\frac{0}{-8}=0$$
$$x_3 = \frac{\det A_3}{\det A}=\frac{ \left|\begin{array}{ccc}
1 & 0 & 5 \\
5 & 3 & 3 \\
6 & 2 & 6
\end{array}\right| }{ \left|\begin{array}{ccc}
1 & 0 & 3 \\
5 & 3 & 6 \\
6 & 2 & 5
\end{array}\right| }=\frac{-7}{-8}=\frac{7}{8}$$
Okay now i have a solution.
$$\left(\begin{array}{c}
x_1 \\
x_2 \\
x_3
\end{array}\right) = \left(\begin{array}{c}
0 \\
0 \\
\frac{7}{8}
\end{array}\right)$$That Looks cool. But my Task is to find ALL Solutions. But the given System has as many unknowns as equations. So i learned there should be only one solution.
My conclusion is: there is either just one solution (and this one is "all") or i made one (or more) mistakes.
My question is: am i right? And in case i am wrong, what are my mistakes? How can i solve such a Task?
Comment: I am definitly sure, my determinants are incorrect. :/
Answer: \begin{align}
(A\ \ b)=
\left(\begin{array}{ccc|c}
1 & 0 & 3 & 5 \\
5 & 3 & 6 & 3 \\
6 & 2 & 5 & 6
\end{array}\right)
&\to
\left(\begin{array}{ccc|c}
1 & 0 & 3 & 5 \\
0 & 3 & 5 & 6 \\
0 & 2 & 1 & 4
\end{array}\right)\quad R_2-5R1, R_3-6R_1
\\
&\to
\left(\begin{array}{ccc|c}
1 & 0 & 3 & 5 \\
0 & 1 & 4 & 2 \\
0 & 2 & 1 & 4
\end{array}\right)\quad 5R_2
\\
&\to
\left(\begin{array}{ccc|c}
1 & 0 & 3 & 5 \\
0 & 1 & 3 & 2 \\
0 & 0 & 0 & 0
\end{array}\right)\quad R_3-2R_2
\end{align}
So the solution set is
$$
\begin{pmatrix}5-3h\\2-3h\\h\end{pmatrix}\quad (h\in\mathbb{Z}/7\mathbb{Z})
$$
Let's look at the determinant, if you don't trust Gauss Elimination. I'll develop with respect to the first row:
\begin{align}
\det A&=(-1)^{1+1}\det\begin{pmatrix}3 & 6 \\ 2 & 5\end{pmatrix}
+0+(-1)^{1+3}\cdot 3\det\begin{pmatrix}5 & 3 \\ 6 & 2\end{pmatrix}\\
&=(15-12)+3(10-18)\\
&=3+3(-8)=3-24=-21=0
\end{align}
so you can't apply Cramer's rule.
Comment: @ToralfWestström Yes, any choice for $h$ is good. Since $\mathbb{Z}/7\mathbb{Z}$ is a field, the elimination method works the same as in the real numbers; just the arithmetic is different.
Comment: oh allright.. and so the solution set consits of seven different solutions/vectors like: $$\left(\begin{array}{c}
5-3\cdot 1 \\
2-3\cdot 1 \\
1
\end{array}\right) = \left(\begin{array}{c}
2 \\
6 \\
1
\end{array}\right)$$ right?


problem with spring ajax file upload

Question: I have a simple form with an option to upload image but to upload a file I am not using this method
<form:input path="logoData" id="image" type="file" />

instead I am using ajax upload jquery pulgin.
The problem is upload.parseRequest(request) is returning null in the below code :
@RequestMapping(value = "/upload.htm", method = RequestMethod.POST)
public @ResponseBody String upload(HttpServletRequest request) throws FileUploadException{

    // Create a factory for disk-based file items
    FileItemFactory factory = new DiskFileItemFactory();

    // Create a new file upload handler
    ServletFileUpload upload = new ServletFileUpload(factory);

    // Parse the request
    List<FileItem> items = upload.parseRequest(request);
     System.out.println("====ITEMS====" + items.size());

     System.out.println("----REQUEST---" +request.getParameter("uploadImg"));
        System.out.println("-----SIZE----" +request.getParameterMap().size());
        Map<String, String> map = request.getParameterMap();

        for(Map.Entry<String, String> entry : map.entrySet()){
            System.out.println("----KEY---" + entry.getKey() + "----value---" + entry.getValue());
        }

 // Check that we have a file upload request
    boolean isMultipart = ServletFileUpload.isMultipartContent(request);

    System.out.println("----IS MULTIPART---" +isMultipart);
    return "hello";
}

Output of log is :
====ITEMS====0
----REQUEST---null
-----SIZE----0
----IS MULTIPART---true
And my javascript code is :
new AjaxUpload('#upload', {
action : my_url+ 'methodName/upload.htm',
name : 'uploadImg',
autoSubmit : true,
responseType: 'html',
onChange: function(file, extension){   },
onSubmit: function(file, extension) {

},
onComplete: function(file, html) {
    alert(file);
    alert(html);

}

});
IS MULTIPART is showing true but how to get the file name and how to store it. I have tried an example without ajax and it works fine using datatype CommonsMultipartFile.
Also I have used ajaxupload in PHP and I get the filename as $_FILES['image']['name'] but no idea in java as I am new to java.
I have followed my similar question on this site but no success.
Thanks.
Answer: You can make this shorter. You need a multipart-resolver:
<bean id="multipartResolver"
    class="org.springframework.web.multipart.commons.CommonsMultipartResolver">

    <property name="maxUploadSize" value="100000"/>
</bean>

And then:
@Controller
public class FileUpoadController {

    @RequestMapping(value = "/form", method = RequestMethod.POST)
    public String handleFormUpload(@RequestParam("file") MultipartFile file) {

        if (!file.isEmpty()) {
            byte[] bytes = file.getBytes();
            // store the bytes somewhere
           return "redirect:uploadSuccess";
       } else {
           return "redirect:uploadFailure";
       }
    }

}

Comment: hey thanks for the help....actually i had used the same bean...but i thought @RequestParam works only with GET request..!!
Comment: would you please give the full working code as i am struggling for more than two weeks to get this done.
Comment: Hi Bozho! Can you please tell me how can I test this with RestTemplate ? Thanks a a lot.
Comment: I don't remember. You could probably ask a separate question about it
Answer: @RequestMapping(value = "/imageUpload", method = RequestMethod.POST)
public String handleFormUpload(@RequestParam("file") MultipartFile file) {

    if (!file.isEmpty()) {

            System.out.println("File name:"+ file.getOriginalFilename());
            //byte[] bytes = file.getBytes();
            System.out.println("Content type:"+ file.getContentType());
            String [] contentType = file.getContentType().split("/");
            String fileType = contentType[contentType.length-1];
            System.out.println("File type:"+ fileType);
            System.out.println("File size:"+ (file.getSize()/1024) + "KB");

            String path = context.getRealPath( "/resources/images/");
            System.out.println("Path: " + path);

            InputStream inputStream = null;
            OutputStream outputStream = null;
            try {
                inputStream = file.getInputStream();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            try {
                outputStream = new FileOutputStream(path + file.getOriginalFilename());
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            int readBytes = 0;
            byte[] buffer = new byte[8192];
            try {
                while ((readBytes = inputStream.read(buffer, 0, 8192)) != -1) {
                            outputStream.write(buffer, 0, readBytes);
                }
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            try {
                outputStream.close();
                inputStream.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            // store the bytes somewhere
            return "theme";
    }
    else
        return "uploadError";

}

problem with spring ajax file upload


Jquery submit not working to submit into the action servlet

Question: I'm having trouble to submit the form by clicking button in another form.When i hit the button,it is not redirected to the action servlet, but it redirects into the same page,with a url like this,

http://localhost:8080/OnlineDD/index.jsp/login.jsp?

with a '?' at the end.This method was working in my sample project.
HTML code
<form autocomplete="off">
    Email
    <input autocomplete="off" autofocus type="text" required="" id="emailIDForm1">

    Password
    <input autocomplete="off" type="password" min="6" required="" id="logPassId" />

        <button id="submitForm" class="btn btn-primary">LOGIN</button>

</form>
<form action="LoginServlet" method="post" id="SecFormLogin" style="display:none">
    <input type="text" name="emailId" id="emailIdForm2" />
    <input type="password" name="password" id="passForm2" />
</form>

and Jquery code

and Servlet code is,
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    System.out.println("Called post");}

Comment: This approach makes no sense. Check section "Ajaxifying an existing form" in the above linked duplicate
Comment: Iam not intented to use Ajax,it is just a part of my project(for encryption for password).My intention is as per the question and is different from the duplicated,it is to make the action of another form on button click from another form.Thankyou for noticing this question.
Comment: I made it correct.It was to use  `` instead of `LOGIN`
Answer: You need to have Deployment Descriptor (web.xml)
<servlet>
  <servlet-name>servletName</servlet-name>
  <servlet-class>packageName.servletName</servlet-class>
</servlet>

<servlet-mapping>
  <servlet-name>servletName</servlet-name>
  <url-pattern>/yourServletUrl</url-pattern>
</servlet-mapping>

Or you may use annotations in your Servlet since servlets 3.0.
import javax.servlet.annotation.WebServlet;

@WebServlet(name = "servletName", urlPatterns = { "/yourServletUrl" })
public class servletName extends HttpServlet {

Comment: This answer is wrong. If the URL mapping was indeed missing, OP would have faced a HTTP 404 error when hitting the servlet, but this is not the case.
Comment: I have already added the details in web.xml.Still not working.!
Comment: Sorry.By mistake, i voted up.
Comment: Yeah.Thank you for helping.


PyMC: how can I use a custom sampler for one specific variable in a model?

Question: Basically I have a function to efficiently sample one variable in my model that I would like PyMC to use, along with its normal samplers for everything else. Since I have this function I don't have a need to define a log likelihood for the variable either.
Can I do this using the Stochastic class and making a random function? Or do I need to make a custom step method?
Answer: I think you will need to make a custom step method.  This is what I did for a project on sampling random spanning trees with PyMC2, and you can see my spanning tree Metropolis step method here.
Here is a minimal PyMC2 version:
class StandardNormal(pm.Gibbs):
    def __init__(self, stochastic, verbose=None):
        pm.Gibbs.__init__(self, stochastic, verbose=verbose)

    def step(self):
        self.stochastic.value = np.random.normal()

A = pm.Uninformative('A', value=0)
B = pm.Normal('B', mu=20+A, tau=10)

mc = pm.MCMC([A,B])
mc.use_step_method(StandardNormal, A)
mc.sample(iter=5000, burn=100)

And here is a corresponding PyMC3 version:
class StandardNormal(object):
    def __init__(self, var):
        self.var = var.name

    def step(self, point):
        new = point.copy()
        new[self.var] = np.random.normal()

        return new

with pm.Model() as model:
    A = pm.Flat('A')
    B = pm.Normal('B', mu=20+A, sd=10)

    step_A = StandardNormal(var=A)
    step_B = pm.step_methods.Metropolis(vars=[B])

    trace = pm.sample(5000, [step_A, step_B])

You can see it all in action here.
Comment: Thanks, I also just came across [this](https://github.com/aflaxman/gbd/blob/birth-prev/fit_posterior.py#L92-99) (written by you I believe!) which seems relevant and fairly straightforward. Any idea if it is compatible with PyMC3? I'm still a bit surprised this isn't as simple as providing a `Stochastic` with just a `random` function and having PyMC recognize that automatically.
Comment: Followup question: if I used a custom step method for sampling one of my variables, then how do I even define the variable in PyMC given that I don't want to bother with a log likelihood function (since I'm defining my own sampler)?
Comment: It looks like you got the answer already [on github](https://github.com/pymc-devs/pymc/issues/542), but I will update here in case future searchers find this page.


get image title and append to end of current URL for link

Question: I'm using dynamic content in PHP and I need to get the image title and then append that to the end of the current URL.  When the user clicks the image they'll be sent to that destination.
For instance - www.foo.com/bar/ is the current url. The image title is dynamic "current-image-title".  I need the anchor with the class "item-link" to now use "www.foo.com/bar/current-image-title" when the user clicks the image

I can figure out how to either get and use the image title or how to append to the end of the URL but I can't seem to figure out how to do both.
Answer: You could try
$(".item-link").each(function () {
    var $this = $(this), $img = $this.find("img");
  $this.attr("href", $this.attr("href") + "/" + $img.attr("title"));
});

Try it on https://jsfiddle.net/gkk9ohca/


How to properly set Angular locale globally?

Question: I'm trying to set French as global locale in an Angular app.
Following the docs, that's what I did in my app.module.ts:
import { registerLocaleData } from '@angular/common'
import localeFr from '@angular/common/locales/fr'

registerLocaleData(localeFr, 'fr-FR')

In a custom pipe, I'd like to use @angular/common's formatDate but it requires a locale param. Is there any way to get the locale I registered?
I've also tried providing LOCALE_ID ({ provide: LOCALE_ID, useValue: 'fr-FR' }) but it seems like I can't use it without injecting it. I'm not sure using registerLocaleData() is relevant in that case? (if it is, I'd like to understand why)
By the way, I don't want to inject DatePipe in my constructor since I just need to use formatDate and it would make my unit tests more complicated.
Answer: Try to import localeFrExtra and use it with the register function:
import { registerLocaleData } from '@angular/common';
import localeFr from '@angular/common/locales/fr';
import localeFrExtra from '@angular/common/locales/extra/fr';

registerLocaleData(localeFr, 'fr-FR', localeFrExtra);

From Angular Documentation:

The files in @angular/common/locales contain most of the locale data that you need, but some advanced formatting options might only be available in the extra dataset that you can import from @angular/common/locales/extra. An error message informs you when this is the case.


enable viewing access to anonymous user

Question: I have the Content Access   7.x-1.2-beta1 module installed.  I would like to enable access to a few basic pages, not all of them, for everyone including unauthorized users.   I only see how to change the access for control for specific users or for all nodes of one type.  How would I fix this?  thanks!
Comment: I can't find any reference to a module called "access control"...is it possible you mean [Content Access](http://drupal.org/project/content_access)?
Comment: yes sorry! Content Access 7.x-1.2-beta1
Answer: Content Access has "Per content node access control settings" available for each content type.
If you navigate to the "Access control" tab for your content type (or navigate to admin/structure/types/manage/content_type/access) you should see the following fieldset:

As the description suggests, once you've enabled that setting each piece of content of that content type will have an 'Access Control' tab. From there you can decide which roles should be able to access that individual piece of content.
This is what the 'Access Control' tab looks like once you've enabled that setting:
Comment: Not sure what to say to be honest, I've looked at the code for the node access page (`content_access_page()`) and it only has settings for roles, not users, so I don't know how you're getting a list of users on that page. Are you sure you've got the beta1 version installed and not the dev version or an old version or something?
Comment: It's the fieldset at the top of the screenshot on the left where you select permissions by role. I wonder is it the fact that the fieldset looks identical to the one on the node type settings page that's causing the confusion? The one on the 'Node Access' page is specific to that node, it's not the same one as on the node type settings page
Comment: Yeah permissions are always a tricky one! You should un-check 'anonymous user' from 'view any public content' in the global (node type) settings, and then on an individual node basis go and enable/disable the same permission based on whether or not anonymous users should be able to access that specific node. So you're essentially implementing a `DENY FROM ALL` access control list that's overridden on a per-content basis. Does that help?
Comment: this just enables it per user, not per role
Comment: Nope, it lets you choose roles too. I'll put another screenshot in the answer
Comment: Yeah I did this already it didn't work.  Any ideas?
Comment: okay, i screencapped it to show what i'm looking at.  maybe that will help.  on the left is the node-specfic access setttings and on right are the node type, PUBLIC, settings.  http://img716.imageshack.us/img716/4539/access.png
Comment: Are you saying if I make these identical, it might work?  I will try.
Comment: never mind, sorry i am still confused!
Comment: fwiw i tried rebuilding permissions, still no luck
Comment: going to try this now, i will let you know if it works.  thanks for being so patient :)
Comment: darn, still doesn't work

enable viewing access to anonymous user


Type errors trying to configure graphqlExpress

Question: I'm trying GraphQL with Express for the first time. I have declared a schema:
import { makeExecutableSchema } from "graphql-tools";
import { interfaces } from "inversify";

const schema = `
    type Feature {
        id: Int!
        name: String
        description: String
        roles: [Feature]
    }

    type Role {
        id: Int!
        name: String
        description: String
        roles: [Feature]
    }

    type User {
        id: Int!
        fullname: String
        email: String
        profilePicUrl: String
        status: String
        roles: [Role]
    }

    type Query {
        users: [User]
        roles: [Role]
        features: [Feature]
        role(id: Int!): Author
    }

    schema {
        query: Query
    }
`;

const resolveFunctions = {
  Query: {
    users(obj: any, args: any, context: { container: interfaces.Container }) {
        return [];
    },
    roles(obj: any, args: any, context: { container: interfaces.Container }) {
        return [];
    },
    features(obj: any, args: any, context: { container: interfaces.Container }) {
        return [];
    }
  },
  User: {
    roles(userId: number) {
      return [];
    }
  },
  Feature: {
    roles(featureId: number) {
      return [];
    },
  },
  Role: {
    users(roleId: number) {
      return [];
    },
    features(roleId: number) {
      return [];
    }
  },
};

const executableSchema = makeExecutableSchema({
  typeDefs: schema,
  resolvers: resolveFunctions,
});

export { executableSchema };

I have imported the executableSchema and tried to create a graphqlExpress instance but I get a compilation error:
import { executableSchema } from "./schema";
import { graphqlExpress } from "graphql-server-express";

// ...

app.use("/graphql", graphqlExpress((req) => { // Error!
    return {
        schema: executableSchema,
        context: {
            container: container
        }
    };
}));

The error is the following:
'Argument of type '(req: Request | undefined) => { schema: GraphQLSchema; context: { container: Container; }; }'

is not assignable to parameter of type

'GraphQLServerOptions | ExpressGraphQLOptionsFunction'

I have examined the dts file:
import * as express from 'express';
import { GraphQLOptions } from 'graphql-server-core';
import * as GraphiQL from 'graphql-server-module-graphiql';
export interface ExpressGraphQLOptionsFunction {
    (req?: express.Request, res?: express.Response): GraphQLOptions | Promise<GraphQLOptions>;
}
export interface ExpressHandler {
    (req: express.Request, res: express.Response, next: any): void;
}
export declare function graphqlExpress(options: GraphQLOptions | ExpressGraphQLOptionsFunction): ExpressHandler;
export declare function graphiqlExpress(options: GraphiQL.GraphiQLData): (req: express.Request, res: express.Response) => void;

But I have not been able to figure out what is wrong. Any ideas? Thanks!
Comment: Can you share your `tsconfig.json`?
Comment: You may want to look into this GraphQL sample project:
https://github.com/kriasoft/nodejs-api-starter
Answer: It's not a solution answer... But if you try to define the schema using GraphQL js standard implementation and its types... Does it work?
Comment: And the signature of GraphQL express seems different from the one that you are using. ```
app.use('/graphql', graphqlHTTP({
  schema: MyGraphQLSchema,
  graphiql: true
}));
```
Answer: It looks like you need to use a Type Asserting to let the TypeScript compiler know that executableSchema is of type GraphQLSchema.  Try the following:
Try this:
import { executableSchema } from "./schema";
import { graphqlExpress } from "graphql-server-express";
import { GraphQLSchema } from "graphql-server-core/node_modules/@types/graphql";

// ...

app.use("/graphql", graphqlExpress((req) => { // Error!
    return {
        schema: executableSchema as GraphQLSchema,
        context: {
            container: container
        }
    };
}));

Answer: Another solution is to import the GraphQLServerOptions definition and typecast your object. Similar to the solution proposed by James, but with this approach you can use the ES6 object shorthand syntax.
import { GraphQLServerOptions } from 'apollo-server-core/src/graphqlOptions';
import { graphqlExpress } from 'apollo-server-express';
import { executableSchema as schema } from "./schema";

// ...

app.use('/graphql', graphqlExpress({
  schema,
  context: { container },
} as GraphQLServerOptions));


Why are the bails taken-off from the stumps?

Question: Why are the bails taken-off from the stumps at the break time & end of the day of a Test-match?
Answer: According to Law 16.2, 16.3:

The bowler's end umpire shall call Time when the ball is dead on the
  cessation of play before any interval or interruption and at the
  conclusion of the match. After the call of Time, the bails shall be
  removed from both wickets.

So, this is the official way to show that the match has been paused or finished.


CSS pesudo-selectors parecem não funcionar com o método querySelector

Question: Basicamente, eu preciso acessar o href da última tag anchor e mudar o seu valor.

const modHref = document.querySelector('.menu a:last-child');
modHref.setAttribute('href', 'ricardo.com');
console.log(modHref);

Animais

FAQ

Contato

Dev →

Mas, ao que parece, o método querySelector simplesmente ignora o pseudo-selector a seleciona direto a primeira anchor. Esse é um comportamento esperado ou eu estou ignorando alguma coisa?
Answer: Seu problema é que vc montou o seletor de forma errada.
Deveria ser ('.menu ul li:last-child a') pseudo-seletor na li
Repare que vc não tem  irmão de  então todos são first e last. Para corrigir vc tem que selecionar a última
 e ai sim o  dentro dela

const modHref = document.querySelector('.menu ul li:last-child a');
modHref.setAttribute('href', 'ricardo.com');
console.log(modHref);

Animais

FAQ

Contato

Dev →


Shift trill symbol horizontally in Lilypond

Question: I'm rewriting (with Lilypond) an old copy of Händel's Allemande HWV 437 and I can not recreate the orignial position of the trill symbol. In the original the ornament begins with the note 'b', yet Lilypond centres the trill symbol above the note, which I find less beatiful. The syntax I'm using is b'8.\prallprall.
Is there a way to either shift the ornament or at least fake this zigzag-line for example using \markup?
Answer: A good way to do it would be to simulate it using \markup, as you propose. Something like c^\markup{\left-align \musicglyph #"scripts.prallprall"} should do the trick.
Another way would be moving the prall by setting the extra-offset property. Pretty much any object that is drawn somewhere in the score has this property, and it works like this: after all the positions are calculated, the object is moved by the amount specified in this property.
So you could do it by putting \once\override Script.extra-offset = #'(1 . 0) just in front of the offending note.
There's a more convenient way, however, and that is the \tweak command. It essentially applies a change to the very next object specified in the source code, so in this instance, we can do something like c-\tweak extra-offset #'(1 . 0) \prallprall.

Out of those two ways, I like the markup more because it's not so "context-dependent". Hacking things with extra-offset is always possible but it's best done as a "finishing touch" on an already finished score. Otherwise, the things will move around and an offset that was good in one position will be awful in another. The positioning of the markup will be correctly calculated by Lilypond wherever it is.
Comment: Thank you very much. I tried the tweak option earlier, but missed the `-` and it failed. `extra-offset` failed as well, because I did put it in front of the \prallprall instead of the note. (Both my mistakes) Your markup-example unfortunately results in an error, but since the two other solutions work very well, I'm happy with the result.
Comment: @Peder: It's weird that the markup example results in an error; for me it is working correctly. What kind of error is it? For instance, in this lilybin: http://lilybin.com/pa1207/1 , it does what it should do.
Comment: I just tried it again, and now it works. I don't remember yesterday's error message, but I believe Lilypond complained about a lyrics context, which I didn't even use. Maybe once again I inserted the command on a slightly incorrect position.
Comment: I had the problem with staccato wedges in two-part music (using `<< {…} \\ {…} >>`). They were very close to the stem, so not noticeable as separate objects, and I wanted them centered over/under the note head, not the stem. `c-\tweak extra-offset #'(-0.6 . 0.4) \staccatissimo` did the trick (I didn't get the `\markup` solution to work in this case).


Why do my results regression results change when I change my contrasts?

Question: I have the following dataset
<code>df <- structure(list(RT = c(828L, 1430L, 963L, 2161L, 991L, 1353L,
1025L, 1593L, 1031L, 1233L, 1334L, 1573L, 1284L, 1907L, 734L,
1231L, 988L, 1695L, 1586L, 882L, 762L, 1201L, 1076L, 1024L, 638L,
909L, 1066L, 610L, 947L, 1293L, 774L, 1512L, 888L, 1721L, 1745L,
781L, 1084L, 1456L, 2687L, 1173L, 1854L, 1968L, 1305L, 1560L,
2461L, 807L, 3851L, 2442L, 2864L, 933L, 2765L, 2308L, 1905L,
1108L, 1204L, 1375L, 1087L, 821L, 1055L, 1068L, 1678L, 1039L,
2673L, 1622L, 993L, 1390L, 922L, 1080L, 2747L, 863L, 1187L, 790L,
805L, 666L, 810L, 1123L, 2171L, 790L, 769L, 557L, 952L, 955L,
592L, 1045L, 946L, 643L, 677L, 1119L, 1486L, 890L, 1013L, 924L,
1160L, 931L, 849L, 1663L, 1234L, 1398L, 1251L, 1275L, 1248L,
1428L, 843L, 2815L, 907L, 993L, 1337L, 1027L, 1161L, 828L, 994L,
764L, 1101L, 1012L, 951L, 906L, 786L, 724L, 910L, 1087L, 896L,
1024L, 1691L, 1431L, 1367L, 1061L, 1048L, 2689L, 1261L, 1274L,
1258L, 1192L, 937L, 1063L, 835L, 1074L, 1148L, 1702L, 1353L,
1703L, 995L, 769L, 783L, 727L, 713L, 904L, 803L, 1492L, 704L,
807L, 865L, 1092L, 928L, 1226L, 1108L, 734L, 745L, 917L, 818L,
1188L, 1545L, 987L, 1917L, 928L, 708L, 1168L, 906L, 1256L, 952L,
2363L, 985L, 1972L, 1423L, 1878L, 796L, 1694L, 1107L, 1982L,
1170L, 1007L, 1798L, 1575L, 1263L, 944L, 966L, 1164L, 1266L,
1138L, 1260L, 2664L, 1388L, 1530L, 1072L, 1137L, 1503L, 1325L,
1256L, 1738L, 1139L, 718L, 1008L, 1202L, 1825L, 932L, 895L, 1106L,
755L, 909L, 927L, 864L, 990L, 1964L, 976L, 751L, 1368L, 2593L,
1097L, 1222L, 1587L, 1578L, 1719L, 3006L, 1014L, 2535L, 1772L,
1172L, 1640L, 756L, 1245L, 908L, 962L, 1181L, 783L, 804L, 2069L,
820L, 867L, 926L, 939L, 807L, 1100L, 762L, 1418L, 1480L, 1554L,
942L, 2245L, 1523L, 1279L, 878L, 1166L, 1070L, 1041L, 645L, 753L,
809L, 856L, 796L, 676L, 896L, 845L, 885L, 866L, 650L, 754L, 849L,
786L, 1052L, 727L, 734L, 1586L, 820L, 874L, 1718L, 1281L, 996L,
1024L, 1037L, 777L, 890L, 1189L, 891L, 782L, 974L, 895L, 940L,
1126L, 1315L, 1747L, 1321L, 1326L, 1587L, 1326L, 3663L, 1219L,
1066L, 1170L, 957L, 2827L, 1319L, 1283L, 1845L, 1576L, 1410L,
1287L, 946L, 858L, 2158L, 1196L, 1029L, 1243L, 820L, 960L, 978L,
1095L, 1928L, 862L, 1278L, 806L, 963L, 937L, 799L, 1529L, 762L,
867L, 929L, 673L, 998L, 1091L, 1050L, 645L, 3445L, 1137L, 2342L,
1014L, 990L, 2092L, 771L, 1062L, 3649L, 777L, 2460L, 1670L, 925L,
1019L, 1713L, 922L, 1263L, 1005L, 1710L, 1367L, 812L, 935L, 746L,
959L, 787L, 748L, 877L, 1153L, 915L, 1170L, 930L, 924L, 988L,
842L, 2630L, 2646L, 2728L, 2743L, 2390L, 2652L, 701L, 782L, 1150L,
901L, 2047L, 2520L, 827L, 1262L, 1826L, 947L, 699L, 2372L, 1431L,
1789L, 1763L, 659L, 906L, 1393L, 784L, 1056L, 755L, 802L, 967L,
724L, 830L, 902L, 796L, 1105L, 1191L, 1242L, 1483L, 922L, 875L,
1285L, 1412L, 984L, 810L, 1838L, 1948L, 1753L, 1567L, 1081L,
1827L, 1301L, 1958L, 1334L, 1482L, 1633L, 1591L, 957L, 1328L,
1226L, 986L, 915L, 1342L, 1850L, 1422L, 1759L, 2504L, 1431L,
2099L, 3188L, 1314L, 1314L, 3242L, 2042L, 2677L, 1345L, 2976L,
1380L, 1268L, 699L, 1180L, 1022L, 1330L, 864L, 714L, 798L, 899L,
1018L, 830L, 878L, 1287L, 721L, 743L, 681L, 828L, 689L, 807L,
683L, 771L, 684L, 908L, 941L, 980L, 1233L, 1174L, 1005L, 1026L,
810L, 1048L, 935L, 962L, 972L, 1295L, 1098L, 868L, 1049L, 984L,
1413L, 1120L, 962L, 1215L, 1371L, 1715L, 1179L, 2814L, 1110L,
2090L, 2022L, 1126L, 2058L, 1853L, 1469L, 2029L, 1973L, 1392L,
1846L, 892L, 1253L, 1621L, 1487L, 1584L, 1706L, 1309L, 2392L,
1046L, 1074L, 2327L, 1182L, 1842L, 1062L, 1546L, 768L, 986L,
1813L, 2704L, 2328L, 1027L, 996L, 766L, 890L, 1864L, 861L, 1348L,
1085L, 1272L, 1300L, 1252L, 1776L, 1974L, 963L, 2171L, 1610L,
1194L, 1784L, 1268L, 1416L, 1484L, 1603L, 1092L, 1212L, 1248L,
2485L, 2661L, 2472L, 936L, 3860L, 3875L, 3145L, 1800L, 986L,
1428L, 703L, 1135L, 1178L, 1000L, 2497L, 1313L, 1179L, 1279L,
1441L, 1456L, 999L, 1557L, 1334L, 1053L, 861L, 1236L, 648L, 658L,
621L, 886L, 651L, 1386L, 601L, 549L, 732L, 573L, 935L, 707L,
587L, 1503L, 1207L, 1637L, 2014L, 1908L, 2566L, 2007L, 1350L,
1196L, 1382L, 1351L, 1347L, 2203L, 1693L, 3361L, 1485L, 2330L,
1375L, 1672L, 1102L, 2367L, 3219L, 1109L, 977L, 1421L, 1341L,
1082L, 2254L, 900L, 1450L, 1114L, 920L, 1414L, 1232L, 654L, 664L,
912L, 1932L, 1335L, 1231L, 652L, 1170L, 1114L, 1333L, 831L, 3877L,
939L, 1772L, 1584L, 1391L, 1111L, 776L, 1094L, 1811L, 1196L,
1057L, 1420L, 1129L, 847L, 2818L, 862L, 2708L, 1928L, 1734L,
1119L, 1757L, 928L, 1344L, 1012L, 2040L, 933L, 1406L, 1474L,
793L, 1022L, 758L, 876L, 1904L, 1994L, 680L, 978L, 1208L, 1015L,
840L, 1292L, 935L, 1064L, 3063L, 2166L, 1097L, 3711L, 1042L,
1030L, 1233L, 960L, 1403L, 1330L, 976L, 1745L, 922L, 989L, 953L,
787L, 1060L, 1024L, 1218L, 1159L, 1063L, 1130L, 1332L, 2422L,
1423L, 927L, 1002L, 933L, 727L, 1935L, 1373L, 751L, 2000L, 2010L,
845L, 934L, 1191L, 1462L, 705L, 703L, 911L, 1591L, 1319L, 833L,
2421L, 1456L, 812L, 1256L, 1706L, 1557L, 1100L, 2586L, 1195L,
1693L, 2377L, 2932L, 1331L, 948L, 911L, 1208L, 3297L, 3149L,
1485L, 1335L, 687L, 2084L, 1490L, 2774L, 2247L, 2258L, 1425L,
1221L, 1653L, 1326L, 935L, 1352L, 963L, 1157L, 1987L, 943L, 1111L,
779L, 1202L, 784L, 1525L, 1636L, 1174L, 1039L, 880L, 979L, 1305L,
1742L, 1285L, 1061L, 1007L, 2175L, 770L, 1061L, 1571L, 1648L,
792L, 1148L, 772L, 1139L, 885L, 1107L, 1585L, 1081L, 603L, 644L,
2780L, 1321L, 1951L, 1689L, 2102L, 2795L, 2591L, 2410L, 1504L,
1908L, 3877L, 1607L, 1209L, 1744L, 1209L, 1399L, 2928L, 1885L,
3645L, 2203L, 1533L, 1623L, 3010L, 2569L, 1641L, 1053L, 932L,
1276L, 1361L, 1380L, 1028L, 771L, 770L, 1270L, 1038L, 1154L,
1195L, 658L, 588L, 943L, 829L, 1470L, 772L, 832L, 907L, 1193L,
885L, 797L, 770L, 1294L, 945L, 735L, 1368L, 2600L, 2005L, 2384L,
2750L, 1265L, 1435L, 1144L, 1057L, 951L, 769L, 1525L, 727L, 809L,
617L, 697L, 695L, 1058L, 683L, 671L, 690L, 679L, 1123L, 1056L,
739L, 762L, 787L, 572L, 2902L, 2589L, 3710L, 3940L, 2483L, 3280L,
2415L, 1873L, 3149L, 1367L, 2735L, 3680L, 2451L, 1679L, 733L,
699L, 1043L, 663L, 960L, 817L, 1373L, 1332L, 1092L, 739L, 1608L,
860L, 1622L, 1531L, 924L, 1570L, 737L, 813L, 711L, 930L, 901L,
860L, 1169L, 764L, 629L, 717L, 1202L, 1071L, 1415L, 1112L, 1086L,
1140L, 1553L, 1172L, 874L, 1258L, 803L, 2554L, 1131L, 833L, 1271L,
1342L, 755L, 1369L, 1474L, 1215L, 917L, 1280L, 847L, 816L, 993L,
1916L, 904L, 1951L, 1546L, 1805L, 3134L, 1741L, 2998L, 2243L,
1324L, 1661L, 1866L, 1344L, 1323L, 802L, 813L, 1610L, 974L, 685L,
1421L, 1123L, 852L, 787L, 793L, 845L, 1834L, 914L, 718L, 1206L,
762L, 1038L, 851L, 823L, 802L, 866L, 818L, 726L, 767L, 1099L,
1164L, 1028L, 1188L, 842L, 1188L, 987L, 1093L, 989L, 1574L, 1938L,
1000L, 1353L, 1083L, 1316L, 1130L, 1154L, 1178L, 665L, 833L,
1223L, 2246L, 1493L, 1896L, 3150L, 1777L, 1054L, 1361L, 1504L,
1993L, 1428L, 2794L, 1240L, 1613L, 1125L, 1240L, 1930L, 1399L,
1170L, 2136L, 1419L, 1799L, 972L, 2032L, 1345L, 983L, 917L, 2747L,
709L, 2196L, 1022L, 1245L, 853L, 878L, 891L, 1121L, 2461L, 1176L,
819L, 752L, 1537L, 1429L, 1892L, 1422L, 2077L, 1430L, 1485L,
3147L, 1447L, 1133L, 1217L, 1376L, 2337L, 2438L, 1145L, 1410L,
1212L, 1886L, 3741L, 1732L, 2892L, 870L, 1789L, 2430L, 936L,
957L, 1480L, 1802L, 978L, 846L, 876L, 1883L, 1242L, 1221L, 978L,
1025L, 921L, 1074L, 801L, 717L, 970L, 913L, 782L, 686L, 719L,
1246L, 638L, 1261L, 1076L, 639L, 818L, 541L, 677L, 672L, 799L,
805L, 619L, 569L, 749L, 1002L, 1778L, 1256L, 2191L, 2524L, 1499L,
1483L, 1659L, 1936L, 2404L, 1320L, 1200L, 1216L, 1257L, 1234L,
1011L, 1930L, 1287L, 2922L, 1993L, 1431L, 2537L, 1004L, 2096L,
3900L, 1112L, 1424L, 1238L, 1176L, 852L, 1911L, 855L, 665L, 671L,
736L, 1021L, 1415L, 1139L, 1231L, 690L, 1006L, 1144L, 1064L,
775L, 729L, 627L, 899L, 608L, 734L, 570L, 1057L, 601L, 1215L,
430L, 572L, 1219L, 1189L, 677L, 1439L, 2591L, 1025L, 2357L, 3083L,
1210L, 819L, 928L, 854L, 1166L, 1047L, 1280L, 1325L, 982L, 1089L,
708L, 774L, 1959L, 1351L, 985L, 978L, 713L, 813L, 904L, 912L,
1328L, 896L, 2943L, 1635L, 1984L, 1418L, 1155L, 1764L, 1636L,
1946L, 1376L, 1526L, 1229L, 1227L, 1140L, 1870L, 973L, 664L,
779L, 677L, 1306L, 671L, 678L, 938L, 620L, 1459L, 883L, 991L,
810L, 705L, 985L, 1099L, 1061L, 2261L, 1628L, 3726L, 1486L, 1220L,
1367L, 1075L, 973L, 1625L, 829L, 1501L, 1031L, 806L, 831L, 1603L,
1181L, 1584L, 2327L, 1831L, 1370L, 951L, 812L, 1601L, 996L, 1721L,
1999L, 1253L, 1920L, 1279L, 1451L, 918L, 2574L, 1336L, 749L,
1262L, 1142L, 917L, 1398L, 1170L, 883L, 2158L, 1738L, 1177L,
1848L, 1483L, 1333L, 1482L, 1287L, 927L, 858L, 981L, 825L, 1944L,
1220L, 751L, 1787L, 1006L, 1047L, 842L, 850L, 1494L, 1026L, 1084L,
837L, 805L, 702L, 765L, 559L, 857L, 1055L, 855L, 1482L, 1613L,
1141L, 1589L, 1028L, 1329L, 1015L, 1103L, 919L, 823L, 935L, 891L,
1149L, 1123L, 958L, 924L, 1209L, 1807L, 1551L, 1976L, 1378L,
3033L, 1421L, 1508L, 3128L, 2204L, 1862L, 1355L, 2013L, 3008L,
1091L, 1245L, 2086L, 902L, 2955L, 1364L, 1902L, 1756L, 846L,
904L, 1011L, 2116L, 2054L, 1086L, 1955L, 1338L, 1505L, 1690L,
1314L, 1225L, 1234L, 730L, 1819L, 957L, 1078L, 678L, 763L, 751L,
1655L, 863L, 1129L, 1341L, 654L, 542L, 965L, 823L, 686L, 1167L,
929L, 1023L, 1204L, 3396L, 827L, 1035L, 1310L, 1228L, 1036L,
893L, 1082L, 1289L, 940L, 959L, 1062L, 958L, 1279L, 1105L, 627L,
1038L, 733L, 882L, 766L, 811L, 623L, 919L, 803L, 2573L, 3539L,
2340L, 2702L, 2278L, 1403L, 1644L, 1916L, 1722L, 3382L, 2704L,
1654L, 1491L, 1127L, 708L, 712L, 709L, 1220L, 635L, 977L, 928L,
806L, 766L, 1606L, 884L, 1072L, 1214L, 705L, 826L, 1315L, 746L,
644L, 858L, 1244L, 788L, 650L, 1139L, 731L, 2042L, 1500L, 1658L,
1370L, 1762L, 1207L, 1171L, 863L, 1048L, 847L, 1840L, 861L, 1188L,
1053L, 1559L, 1035L, 1427L, 1209L, 999L, 1042L, 2082L, 929L,
2476L, 1194L, 1686L, 795L, 1514L, 1496L, 1491L, 1743L, 2374L,
3245L, 2473L, 1469L, 1998L, 2736L, 1317L, 1148L, 3011L, 1296L,
1277L, 743L, 879L, 719L, 2158L, 898L, 1201L, 731L, 869L, 1054L,
1696L, 831L, 890L, 775L, 1011L, 1159L, 819L, 1183L, 694L, 953L,
1329L, 973L, 842L, 840L, 768L, 962L, 1013L, 792L, 750L, 1123L,
814L, 938L, 1829L, 843L, 1022L, 2177L, 1033L, 1626L, 610L, 743L,
1078L, 887L, 962L, 812L, 1576L, 1231L, 1246L, 1821L, 1479L, 1957L,
2171L, 1698L, 1624L, 1579L, 2830L, 896L, 1466L, 900L, 982L, 1901L,
875L, 1443L, 1418L, 1637L, 1627L, 1411L, 3675L, 1987L, 824L,
835L, 1243L, 1635L, 1180L, 2415L, 1156L, 1034L, 1794L, 985L,
2188L, 1722L, 1245L, 4410L, 2778L, 1425L, 2757L, 3464L, 2066L,
5178L, 1770L, 3148L, 3862L, 2190L, 2601L, 847L, 912L, 1196L,
751L, 1204L, 792L, 788L, 840L, 872L, 984L, 867L, 1003L, 704L,
1193L, 921L, 921L, 2703L, 2549L, 2670L, 4433L, 5575L, 2938L,
2849L, 3189L, 2439L, 3861L, 2668L, 2337L, 3521L, 4095L, 3214L,
3807L, 620L, 751L, 872L, 714L, 1032L, 770L, 692L, 662L, 1002L,
746L, 837L, 858L, 1319L, 1028L, 1214L, 678L, 1562L, 1257L, 1295L,
1110L, 1025L, 1641L, 933L, 1282L, 1144L, 974L, 916L, 1152L, 1154L,
1215L, 764L, 872L, 1961L, 888L, 1084L, 1496L, 1486L, 3219L, 849L,
1002L, 896L, 900L, 1304L, 1657L, 2398L, 1797L, 1669L, 943L, 718L,
1251L, 1183L, 766L, 944L, 924L, 731L, 939L, 891L, 850L, 1228L,
940L, 774L, 1089L, 888L, 732L, 747L, 732L, 895L, 762L, 727L,
808L, 747L, 695L, 1021L, 741L, 996L, 715L, 684L, 941L, 869L,
857L, 1210L, 928L, 778L, 832L, 2041L, 1270L, 813L, 867L, 812L,
964L, 1784L, 733L, 915L, 1088L, 867L, 699L, 734L, 832L, 969L,
779L, 938L, 1328L, 611L, 687L, 1088L, 871L, 1301L, 1131L, 779L,
1060L, 934L, 661L, 3351L, 963L, 4323L, 1974L, 3932L, 2279L, 1534L,
979L, 1078L, 1089L, 1521L, 2783L, 2099L, 2500L, 1040L, 1118L,
823L, 1667L, 3055L, 1242L, 2068L, 1129L, 1331L, 1657L, 1168L,
1470L, 1775L, 1554L, 2319L, 4628L, 1407L, 1441L, 1208L, 1533L,
1072L, 1175L, 821L, 895L, 1280L, 938L, 763L, 861L, 1674L, 1002L,
1319L, 1276L, 1109L, 926L, 845L, 922L, 1574L, 3261L, 4930L, 2349L,
4168L, 1562L, 669L, 1679L, 963L, 2081L, 1693L, 1487L, 634L, 4017L,
4736L, 4249L, 3758L, 5104L, 6543L, 6710L, 5141L, 3891L, 4368L,
5538L, 7274L, 3858L, 4582L, 5434L, 4055L, 5092L, 1056L, 1207L,
1961L, 1146L, 1203L, 1593L, 857L, 1133L, 1122L, 1314L, 980L,
1211L, 1034L, 1341L, 1934L, 3318L, 1163L, 819L, 1126L, 1013L,
2814L, 1302L, 985L, 1704L, 736L, 779L, 1058L, 809L, 776L, 1410L,
765L, 1341L, 1377L, 793L, 1214L, 1453L, 2450L, 1942L, 1054L,
991L, 1042L, 981L, 1030L, 878L, 1133L, 2204L, 841L, 1714L, 1140L,
983L, 777L, 802L, 1129L, 1410L, 759L, 868L, 852L, 670L, 1345L,
972L, 900L, 863L, 679L, 967L, 746L, 737L, 929L, 874L, 764L, 1619L,
761L, 747L, 705L, 847L, 1358L, 957L, 1344L, 1301L, 880L, 899L,
1915L, 864L, 1081L, 1307L, 783L, 897L, 1076L, 722L, 709L, 997L,
770L, 700L, 1391L, 954L, 725L, 685L, 1168L, 1278L, 3040L, 1136L,
1225L, 1674L, 1528L, 1082L, 1268L, 1803L, 1118L, 1048L, 1509L,
1115L, 864L, 1352L, 1040L, 3815L, 1127L, 1464L, 3160L, 3412L,
1221L, 1468L, 3196L, 1510L, 1992L, 1727L, 2488L, 2814L, 3158L,
1811L, 921L, 844L, 806L, 808L, 1440L, 1316L, 836L, 1598L, 968L,
968L, 1061L, 1068L, 952L, 2306L, 886L, 766L, 3891L, 3452L, 3095L,
3555L, 2143L, 1890L, 2886L, 5629L, 2895L, 4380L, 2583L, 2113L,
8157L, 2814L, 2908L, 6832L, 714L, 989L, 877L, 823L, 1032L, 878L,
1132L, 807L, 1383L, 1378L, 1971L, 936L, 1586L, 1072L, 1351L,
773L, 1017L, 1126L, 1239L, 883L, 794L, 1498L, 1284L, 874L, 734L,
817L, 1249L, 940L, 943L, 702L, 641L, 877L, 1786L, 807L, 1769L,
1079L, 1477L, 1239L, 1845L, 835L, 1235L, 889L, 969L, 1105L, 1155L,
765L, 980L, 1194L, 809L, 1137L, 865L, 847L, 898L, 1290L, 1110L,
881L, 1198L, 947L, 760L, 929L, 848L, 1054L, 908L, 971L, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1436L,
1206L, 1166L, 5552L, 3010L, 1617L, 1148L, 1117L, 1642L, 976L,
2586L, 1375L, 2983L, 1154L, 2185L, 922L, 1188L, 743L, 992L, 925L,
2946L, 1433L, 810L, 916L, 715L, 778L, 1204L, 843L, 1588L, 943L,
975L, 1314L, 2806L, 1029L, 3876L, 1689L, 5250L, 1119L, 1680L,
1060L, 897L, 711L, 1266L, 935L, 992L, 1146L, 674L, 998L, 1177L,
1414L, 1061L, 911L, 4131L, 1553L, 1990L, 1396L, 4544L, 1147L,
3629L, 1380L, 1893L, 2686L, 2348L, 1000L, 1373L, 1785L, 1356L,
1676L, 1650L, 1527L, 1091L, 1184L, 5865L, 807L, 1159L, 916L,
1359L, 1402L, 824L, 981L, 984L, 1730L, 1299L, 1087L, 1440L, 1199L,
3112L, 2332L, 1072L, 1059L, 1577L, 1243L, 1032L, 868L, 1093L,
970L, 2379L, 4909L, 6407L, 5135L, 11244L, 3931L, 4331L, 6399L,
5346L, 5452L, 6768L, 6934L, 1252L, 2864L, 6068L, 3996L, 908L,
740L, 1740L, 939L, 1892L, 1169L, 843L, 1255L, 1416L, 908L, 847L,
905L, 816L, 1165L, 1888L, 953L, 1048L, 646L, 1263L, 1074L, 2067L,
1828L, 1175L, 803L, 1354L, 749L, 1506L, 633L, 1008L, 1246L, 708L,
916L, 2795L, 934L, 3660L, 964L, 2519L, 2572L, 1412L, 937L, 1215L,
939L, 1320L, 937L, 921L, 1074L, 1208L, 1368L, 1179L, 675L, 1386L,
799L, 1072L, 1250L, 785L, 750L, 873L, 781L, 754L, 809L, 1057L,
925L, 933L, 836L, 558L, 523L, 802L, 577L, 664L, 1357L, 765L,
590L, 833L, 866L, 830L, 799L, 609L, 1067L, 684L, 652L, 1713L,
1042L, 1305L, 1134L, 577L, 712L, 903L, 631L, 782L, 754L, 734L,
825L, 894L, 974L, 793L, 824L, 1632L, 3015L, 3626L, 1442L, 804L,
2086L, 1108L, 1777L, 999L, 1099L, 1030L, 1386L, 2945L, 1341L,
730L, 1242L, 1161L, 826L, 1304L, 1580L, 2979L, 2258L, 1180L,
2051L, 6211L, 122L, 2947L, 1328L, 2335L, 1879L, 2104L, 2126L,
796L, 1082L, 799L, 805L, 1550L, 1010L, 1153L, 1089L, 1004L, 889L,
1043L, 1061L, 843L, 1414L, 883L, 727L, 3621L, 2941L, 3262L, 2608L,
3663L, 3444L, 4073L, 3057L, 2572L, 1988L, 2243L, 1974L, 3512L,
5119L, 1948L, 3885L, 1055L, 1014L, 1291L, 868L, 919L, 1056L,
1097L, 1092L, 1239L, 938L, 1915L, 942L, 1123L, 955L, 977L, 765L,
933L, 791L, 1627L, 1054L, 1005L, 1331L, 622L, 1127L, 736L, 937L,
1190L, 1345L, 995L, 1667L, 836L, 847L, 1528L, 1279L, 1414L, 1131L,
1178L, 1434L, 1227L, 1385L, 851L, 1030L, 708L, 823L, 1176L, 767L,
714L, 1322L, 984L, 1028L, 830L, 799L, 1188L, 1049L, 961L, 928L,
1052L, 644L, 873L, 631L, 779L, 755L, 1022L, 787L, 739L, 905L,
900L, 698L, 710L, 1084L, 1074L, 787L, 818L, 724L, 664L, 916L,
746L, 724L, 852L, 815L, 1064L, 890L, 1207L, 1454L, 1344L, 1105L,
911L, 812L, 700L, 712L, 863L, 769L, 675L, 679L, 622L, 807L, 1062L,
932L, 838L, 718L, 2526L, 1676L, 2115L, 1293L, 2430L, 1013L, 744L,
869L, 1262L, 1144L, 1283L, 1855L, 988L, 1306L, 1187L, 2189L,
1425L, 2255L, 1207L, 703L, 848L, 952L, 3522L, 933L, 954L, 2031L,
609L, 671L, 938L, 1689L, 1344L, 1156L, 1263L, 526L, 1452L, 867L,
961L, 1082L, 1571L, 1523L, 921L, 1885L, 1153L, 1910L, 1547L,
1231L, 1748L, 1717L, 2328L, 1427L, 2721L, 893L, 822L, 1364L,
922L, 858L, 1044L, 1285L, 961L, 776L, 986L, 1462L, 1078L, 2385L,
1845L, 1154L, 1713L, 1033L, 761L, 906L, 1172L, 1011L, 1084L,
678L, 631L, 908L, 5573L, 3652L, 3214L, 3195L, 5070L, 7386L, 1848L,
3624L, 6290L, 4809L, 4067L, 1651L, 1961L, 2212L, 6184L, 4887L,
987L, 1284L, 918L, 1479L, 1337L, 1461L, 1030L, 1029L, 1102L,
875L, 1068L, 890L, 1046L, 842L, 1195L, 1442L, 856L, 1150L, 1123L,
909L, 2076L, 2208L, 1146L, 836L, 947L, 752L, 1185L, 763L, 617L,
876L, 847L, 1000L, 1092L, 1386L, 2254L, 1096L, 2142L, 2617L,
1215L, 1208L, 756L, 895L, 1031L, 798L, 1288L, 1043L, 718L, 806L,
1476L, 659L, 1614L, 694L, 1500L, 1070L, 715L, 1865L, 544L, 991L,
619L, 656L, 611L, 683L, 725L, 943L, 779L, 691L, 829L, 813L, 1227L,
1099L, 895L, 634L, 593L, 595L, 779L, 743L, 806L, 1102L, 883L,
615L, 937L, 1057L, 881L, 1655L, 2067L, 1144L, 905L, 1008L, 748L,
1227L, 942L, 716L, 669L, 695L, 749L, 1409L), test.time = structure(c(3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L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, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("delayed",
"immediate", "pretest"), class = "factor")), class = "data.frame", row.names = c(NA,
-2559L))
</code>
These are my default contrasts for my factors
<code>contrasts(df$test.time)

         immediate pretest
delayed           0       0
immediate         1       0
pretest           0       1
</code>
I define a contrast matrix so that I compare pretest vs immediate and pretest vs delayed and perform a regression:
<code>contrastmatrix <- cbind(c(0, -1, 1), c(-1, 0, 1))

contrasts(df$test.time) <- contrastmatrix

contrasts(df$test.time)

          [,1] [,2]
delayed      0   -1
immediate   -1    0
pretest      1    1

summary(lm(RT ~ test.time, data = df))

Coefficients:
            Estimate Std. Error t value Pr(>|t|)
(Intercept)  1403.25      17.72  79.194  < 2e-16 ***
test.time1    -80.59      25.16  -3.203  0.00138 **
test.time2     63.63      24.97   2.548  0.01090 *

</code>
I am aware that those contrasts also provide information on the immediate versus delayed contrasts due to being orthogonal. However suppose I want to assess that contrast. If I specify this, leaving my other contrast the same (test.time1), why do the results for my first contrast change? Also, the results for my immediate versus delayed contrast are the exact same as my pre-test versus delayed - I assume this is not a coincidence.
<code>contrastmatrix <- cbind(c(0, -1, 1), c(-1, 1, 0))

contrasts(df$test.time) <- contrastmatrix

contrasts(df$test.time)

          [,1] [,2]
delayed      0   -1
immediate   -1    1
pretest      1    0

summary(lm(RT ~ test.time, data = df))

Coefficients:
            Estimate Std. Error t value Pr(>|t|)
(Intercept)  1403.25      17.72  79.194   <2e-16 ***
test.time1    -16.96      25.04  -0.677   0.4982
test.time2     63.63      24.97   2.548   0.0109 *
---

</code>
Any help is much appreciated!
Answer: As this answer puts it:

Testing contrasts of factorial variables is notoriously difficult in R. Most of the things that go on beneath the surface in friendlier programs like SPSS must be spelled out specifically in R. This is both a bad and a good thing. Bad because it takes you a long time to learn how, but good because your understanding is vastly improved as a result.

In particular when you write
<code>contrastmatrix <- cbind(c(0, -1, 1), c(-1, 0, 1))
</code>
you are not accomplishing what you intend, which is to

define a contrast matrix so that I compare pretest vs immediate and pretest vs delayed.

What you have done is to define two new variables (called <code>test.time1</code> and <code>test.time2</code> by R) that will be used to get around the problem that the 3 levels of your factor must be reduced to 2 linearly independent variables to get a unique solution. That "contrast matrix" is combined with a leading column of 1's (representing the intercept) to set the form of the design matrix for the regression.
This is easy to see with the default treatment contrasts matrix, with its prepended column of 1's:
<code>Treatment contrasts:
          Intercept test.time1 test.time2
delayed           1          0          0
immediate         1          1          0
pretest           1          0          1
</code>
As you can see from the extended discussion on this page, that matrix must be inverted to show how the coefficients for the Intercept, <code>test.time1</code>, and <code>test.time2</code> are estimated from the data. That inverse is:
<code>Inverse, treatment contrasts:
           delayed immediate pretest
Intercept        1         0       0
test.time1      -1         1       0
test.time2      -1         0       1
</code>
This provides the well-known result with treatment contrasts: the intercept is the reference level of the factor (in R the first level, "delayed") and the linearly independent constructed variables represent the differences of each other level from that reference.
Here are the inverses of the two contrast matrices (including the leading columns of 1's) that you proposed, called CM1 and CM2.
<code>Inverse with CM1:
              delayed  immediate   pretest
Intercept       1/3       1/3        1/3
test.time1      1/3      -2/3        1/3
test.time2     -2/3       1/3        1/3

Inverse with CM2:
              delayed  immediate   pretest
Intercept       1/3       1/3        1/3
test.time1     -1/3      -1/3        2/3
test.time2     -2/3       1/3        1/3
</code>
In both cases, the intercept is estimated as the mean over the 3 levels of the factor. In this respect, the intercept is what you get with deviation coding or <code>contr.sum</code> in R, in which 2 of the levels are expressed as differences from the mean, with the mean as the intercept. The estimation of the coefficient for <code>test.time2</code> is identical for both of your proposed contrast matrices, as you discovered. It represents the negative of the difference between "delayed" and the mean. For CM1, <code>test.time1</code> represents the negative of the difference between "immediate" and the mean; for CM2, it's the difference between "pretest" and the mean.
For comparison, here's what you would get with sum contrasts in R:
<code>Sum contrast matrix with intercept column
          Intercept test.time1 test.time2
delayed           1          1          0
immediate         1          0          1
pretest           1         -1         -1

Inverse with sum contrasts:
              delayed  immediate    pretest
Intercept       1/3       1/3        1/3
test.time1      2/3      -1/3       -1/3
test.time2     -1/3       2/3       -1/3
</code>
which estimates coefficients for <code>test.time1</code> and <code>test.time2</code> as differences of "delayed" and "immediate" from the mean (intercept), respectively.
There are two simple solutions if your interest is in an application instead of in figuring out how to code your own contrast matrices.
First, accept the default treatment contrast matrix and get the coefficients and the coefficient variance-covariance matrix returned by the regression. Together with the formula for the variance of a sum of correlated variables you can reconstruct any desired comparisons among factor levels. This can be combined with a judicious choice of reference level. For example, to compare "pretest vs immediate and pretest vs delayed" just set the reference level to "pretest" and you get those comparisons automatically.
Second, use a program that provides a more direct way to translate your intentions into the correct contrast matrix. The answer linked at the beginning of my answer recommended the <code>lsmeans</code> package in R, which I understand is now deprecated in favor of the <code>emmeans</code> package.


Como posso printar uma string digitada pelo usuário em Assembly 8086?

Question: Estou com dificuldades para conseguir printar uma string que foi posteriormente digitada pelo usuário através do INT 21h/AH 0Ah. Não tenho ideia de como posso fazer para printar a string que foi arquivada em AL.
mov ah, 0Ah
int 21h

Já tentei utilizar o INT 21h/AH 09h, porém acho que não soube utilizar de maneira correta.
Answer: Uma string pode ser lida do teclado por meio das funções / interrupões:

0Ah/21h   : entrada bufferizada
03Fh/21h  : leitura de arquivo ou dispositivo
08h/21h   : leitura caractere a caractere (loop manual)
4810h/2Fh : entrada bufferizada usando DOSKEY (demanda o DOSKEY TSR
instalado)

Dado o tipo do problema relatado, suponho que você esteja lendo a entrada por meio de buffer 0Ah/21h.
Para o buffer ser utilizado nessa leitura existem certos requisitos a serem seguidos:

O primeiro byte dirá qual o tamanho máximo de caracteres a serem
lidos.
O segundo byte retornará o número de bytes efetivamente lidos.
A partir do terceiro byte é que de fato inicia-se a string lida.

Um buffer declarado no seguinte formato não serve:
BUFFER db 255 DUP('$')

Um bom buffer para leitura de string terá a seguinte forma:
BUFFER db 255         ; Número máximo de elemementos a serem lidos.
       db ?           ; Número de elementos lidos retornado pela interrução sem incluir o enter.
STRING db 255 DUP(0)  ; Variável armazenando o texto lido.

Posteriormente, de posse da quantidade de caracteres lidos, será feita a substituição do enter chr(13) final do buffer pelo terminador de string.
O código abaixo realiza a leitura e impressão de uma string, comentando os procedimentos seguidos.
DOSSEG
.MODEL SMALL
.STACK

.DATA
    BUFFER db 255             ; Número máximo de elemementos a serem lidos.
           db ?               ; Número de elementos lidos retornado pela interrução sem incluir o enter.
    STRING db 255 DUP(0)      ; Variável armazenando o texto lido.
    TERMINADOR db 10D,13D,'$'

.CODE
inicio:
    ; Inicializa o segmento de dados.
    mov ax,SEG _DATA
    mov ds,ax

    ; Lê entrada no buffer.
    mov dx,OFFSET BUFFER
    mov ah,0ah
    int 21h

    ; Substitui enter chr(13) por término de string.
    mov si, offset BUFFER + 1 ; Carrega em si o número de elementos lidos.
    mov cl, [si]              ; Armazena em cl o número de elementos lidos.
    mov ch, 0                 ; Zera ch para poder usar cx.
    inc cx                    ; cx passa a armazenar a posição do enter chr(13) final do buffer
    add si, cx                ; si aponta para a posição
    mov al, '$'
    mov [si], al              ; substitui o enter chr(13) pelo terminadore de string '$'

    ; imprime terminador
    mov dx, OFFSET TERMINADOR
    mov ah,09h
    int 21h

    ; imprime string
    mov dx,OFFSET STRING
    mov ah,09h
    int 21h

    mov ah,4ch              ; funcao de termino
    int 21h                 ; interrupcao do DOS
END inicio

O código foi testado usando o compilador MASM 5.00 neste emulador com DOSBox


Blackberry Simulator cannot run

Question: I am building an blackberry app. When I run/debug Project it's giving an error:

Again and again. I have cleaned the project, restarted eclipse, but nothing changes. Project is working fine, but suddenly this happened!
Answer: In your simulator or the JDE installation directory you can find clean.bat you can run it from the command prompt. If you just double click it some times it might not run properly. So point to the path of the command.bat of the corresponding JDE simulator directory and run the clean.bat.
Hope this will solve your problem.

Blackberry Simulator cannot run


Why have so few women competed in F1?

Question: The list of women competing in Formula One is extremely short.
Since we are seeing women teams in a whole lot of sports nowadays, F1 remains an outlier. Unlike in other sports, there does not seem to be too much of a reason for women and men not to be racing together (as it has already been done). So the reasons for so few women competing in F1 has to be found elsewhere.
I am wondering if any kind of formal, scientific, or at least semi-professional study has been conducted that looks into the structural and cultural aspects of this question and tries to explore why women don't compete. I'm also interested in knowing if the FIA, Formula One Management, or individual teams are currently (or have tried in the past) to encourage more women to compete in the sport.
Comment: Not really appropriate for comments here, but that's a great argument for why women should be *dominant* in F1.  In high endurance required sports (which the G forces would qualify as), women outperform men.
Comment: @Joe I wouldn't say that. Formula One cars are extremely physically demanding, due to the sheer amount of G-force they're able to produce while accelerating and cornering. It takes 100kg of force *just to operate the brake pedal*.
Comment: Given F1 is not a sport where physical strength is relevant, this line of inquiry doesn't make any sense.  Take it up in [chat] if you want.
Answer: I don't know of any such studies, but I can point to one piece of action the FIA has taken to encourage more women to enter motorsport: the creation of the W Series.
Founded in 2019, the W Series is a women-only spec series using Formula 3 machinery. It is intended to act as a stepping stone for female drivers, allowing them to progress from the W Series up into feeder series such as Formula 2. Jamie Chadwick, the winner of the first two W Series championships, is currently a test driver for the Williams F1 team, but has yet to compete at a race weekend.
Comment: One thing about the W-Series is that it is free to enter - meaning drivers are there purely on talent - thus removing what would probably the main barrier to entry to getting into Formula 1 for most people (let alone women): Money

Why have so few women competed in F1?


Show $\varphi(x_1,...,x_{n+1})=\frac{1}{1-x_{n+1}}(x_1,...,x_n)$ is surjective.

Question: We consider in fact the stereographic projection. Let $$\mathbb S^{n}=\{x_1^2+...+x_{n+1}^2=1\mid (x_1,...,x_{n+1})\in\mathbb R^{n+1}\}$$
and $E=\text{span}(e_{n+1})^\perp$ where $e_{n+1}=(0,...,0,1)$. Let $$\varphi:\mathbb S^{n+1}\backslash \{e_{n+1}\}\longrightarrow E$$ defined by $$\varphi(x_1,...,x_{n+1})=\frac{1}{1-x_{n+1}}(x_1,...,x_n).$$
I have to show that $$\big\{(\mathbb S^{n+1}\backslash \{e_{n+1}\},\varphi)\big\}$$
is an atlas. In the solution, it's written that the fact that $\varphi$ is surjective is obvious. Is it really that obvious ? I mean, if $\varphi:\mathbb R^{n+1}\backslash \{e_{n+1}\}\longrightarrow E$, I would say that the surjectivity is obvious... but here, it doesn't look that obvious (in any case, not for me).
Answer: If it doesn't seem obvious, you can pick a point $x$ in $E$ and construct its preimage. Hint: parametrize the line that goes through $x$ and $e_{n+1}$. It's also useful to think about it in the low dimensional case, and then generalize.