Discern "ongoing" notifciations in AccessibilityService?

Question: In the new JB-4.3 NotificationListenerService, each StatusBarNotification-object has a isOngoing() method to see if it's a persistent notification. Is the same also possible with the AccessibilityService? I've cast the event to Notification, but this is equivalent to sbn.getNotification() (and therefore doesn't have an ongoingproperty).
Also, is there a way to clear existing status bar notifications using the AccessibilityService?
Answer: As you can see in StatusBarNotification.java, isOngoing() just looks at the flags:
public boolean isOngoing() {
    return (notification.flags & Notification.FLAG_ONGOING_EVENT) != 0;
}

So you can do this too.
There's no way to clear notifications using an accessibility service—that's why the NotificationListenerService was created. :)
Comment: Awesome, thank you very much for your answer! I would have never thought to look at the `StatusBarNotification`-source as I was sure that it was doing some 4.3-only-magic :-)!


How to override registration form message

Question: I should override registration form message "Registration successful. You are now logged in." with String Overrides module it does not work, because new text is long and every line with other style, it is in Drupal 7
I try to do it in template.php , but no my code is working.
Can anyone help me?
Answer: You can check this message in hook_init it's working for me please try this code.
function custom_init() {
 if (!empty($_SESSION['messages']['status'])) {
  $message_text_to_remove = "Registration successful. You are now logged in.";
  $key = array_search($message_text_to_remove, $_SESSION['messages']['status']);
   if ($key !== FALSE) {
      $_SESSION['messages']['status'][$key] = t('Greta Now your message changed');
    }
  }
 }

Thankyou
Comment: Thank you very much. I used this code in template.php , but nothing have changed (
Comment: Try this in custom module.It's working if you need i will create video for you.
Comment: Pankaj Thank you very much. I do not want to waste your time , I understood about module )
Comment: Glad to help you.
Comment: Pankaj, I override it , everything is ok. Just want to know , how can I change message show time?
Comment: Unable to understand what do you want to change message or time .
Comment: I changed the message , Now I want to change message show time
Answer: Maybe someone will need this, I put it in template.php
function THEME_form_alter(&$form, &$form_state, $form_id) {
 if($form_id == 'user_register_form') {
   $form['account']['mail']['#attributes'] = array('placeholder'=> array(t('E-mail')));
      $form['account']['name']['#prefix'] = '
';
      $form['account']['name']['#prefix']  = '
'.t('Create account').'
';
      $form['actions']['submit']['#suffix'] = 'orCONTINUE WITH FACEBOOK'.'

Already have an account?
' .  'LOGIN';
      $form['actions']['submit']['#suffix'] .= '
';
       drupal_set_message(' Your message');
   }
}


How do I chose my first electrical guitar?

Question:
Possible Duplicate:
What to check when buying a new guitar?

I have a couple years experience on acoustic guitar (although I haven't played one for a very long time), and wanted to go back to playing but with an electrical one.
How do I chose a beginner's guitar and what questions should I ask when I walk into a store and buy one?
Comment: I searched for a dupe, and didn't find it. But you're right, that's a dupe. This should be closed.
Answer: Electric guitars are pretty simple things at their heart.
Aficionados worry about things like the tone characteristics of the body, but that's a really subtle effect, and budget guitars are unlikely to benefit from good enough materials for that to matter.
The absolute most important factor is action and intonation. Make sure that the neck is straight, the action is acceptable all the way down the fretboard, and that the intonation is good.
One basic check is to play a harmonic on the 12th fret, then an octave. They should have the same pitch.
It's good to have two pickups, so you can choose different tones. The pickups have a much bigger impact on the sound than the body. However, it's fine to start with cheap pickups, since they can be replaced with fancier ones at a later date very easily.
Cheap electric guitars can be very well made nowadays. Check for obvious cut corners, though. Reject anything with badly finished frets. See that the bridge looks nice and solid. Make sure nothing wobbles where it shouldn't.
Decide whether you want a tremolo arm. Many guitarists go their whole career without using one. Hank Marvin never stopped wobbling his. They have a reputation for making it harder to keep the instrument in tune, and that's more likely the cheaper you go -- but if you want the effect they provide, by all means go for it.
Don't buy a super-cheap practice amp. They sound awful. It's better to put an amp-modelling pedal through a hi-fi -- slightly more expensive practice amps such as the Roland Cube are fine too.
Comment: Also, if the fret ends stick out of the neck and cut your hand, that's a problem.
Comment: I didn't realise just how bad fret ends were on cheap guitars until I got my new Ibanez. I don't need to take care at all when sliding down the neck now. Made me consider taking the old ones to a luthier for a bit of fret sanding/trimming (don't think I'd like to risk it myself)
Comment: Regarding tremolo arm: I am a huge Hendrix fan, and have had several strat guitars, but I have NEVER used the tremolo. The back of strats usually have a plate which can be removed to access the tremolo. You can place a snug-fitting wedge of wood in there to immobilize the tremolo mechanism. So in this case the tremolo has no impact on the tuning.


How to wrap a custom content page with HTML tags?

Question: I have a mini-panel in which I add custom content panes. I would like to turn these content panes into buttons. I am able to apply some CSS to turn them into a block, by adding a css class via the "CSS properties" option in each pane's settings. But how can I make a link out of them?
There is no option to add HTML around a pane. And I really want the entire pane to be a link, not just the stuff in it. I could artificially insert HTML into the pane to create a link-block that would fill up all the space, but then I'd have to create other CSS properties to apply to this element, it would just be cumbersome.
I'm still on Drupal 6. Any help would be appreciated.
Comment: Mabye [this](https://www.drupal.org/sandbox/knobo/2376371) is what you want. You create a required context to your panel, then you choose the panel style to be "Linked". Then your panel will be rendered as PANELCONTENT
Answer: Could you put an  tag inside the pane, and then with CSS give it a width: 100% and height: 100%, effectively filling the mini-pane?
To be specific, your html inside the pane would look like:
This Is A Link

And your CSS would look like:
a.mini-pane-link {
    display:block;
    width: 100%;
    height: 100%;
}

(You might want/need to put a few extra selectors in front of the a.mini-pane-link)


cmake fixup_bundle doesn't say why it's failing

Question: I have a cmake project that uses Qt libraries and I need to build it on a few different systems.  I've configured the cmake project it to install library dependencies using fixup_bundle.  This works on some systems but fails on others and I can't tell why.
I'm including the locations of all the library dependencies in the 3rd param of fixup_bundle, and it doesn't seem to have any trouble finding libraries or copying them to the install directory.  And as stated above, on some systems it all works fine.
On the systems where it fails it lists the Qt libs as external prerequisites.  I don't know why though.  It copies all the Qt libs to the install dir.  It also copies the libs which the QT libs depend on to the install dir.  So I don't understand what the problem is.
make install
...
[100%] Built target my_project_executable
Install the project...
-- Install configuration: "Release"
-- Installing: /build/workspace/my_project/build/install_dir/./libgenerated-proto.so
-- Installing: /build/workspace/my_project/build/install_dir/./libicudata.so
-- Installing: /build/workspace/my_project/build/install_dir/./libicudata.so.64
-- Installing: /build/workspace/my_project/build/install_dir/./libicudata.so.64.1
-- Installing: /build/workspace/my_project/build/install_dir/./libicui18n.so
-- Installing: /build/workspace/my_project/build/install_dir/./libicui18n.so.64
-- Installing: /build/workspace/my_project/build/install_dir/./libicui18n.so.64.1
-- Installing: /build/workspace/my_project/build/install_dir/./libicuuc.so
-- Installing: /build/workspace/my_project/build/install_dir/./libicuuc.so.64
-- Installing: /build/workspace/my_project/build/install_dir/./libicuuc.so.64.1
-- Installing: /build/workspace/my_project/build/install_dir/./libicutu.so
-- Installing: /build/workspace/my_project/build/install_dir/./libicutu.so.64
-- Installing: /build/workspace/my_project/build/install_dir/./libicutu.so.64.1
-- Installing: /build/workspace/my_project/build/install_dir/./libssl.so
-- Installing: /build/workspace/my_project/build/install_dir/./libssl.so.1.1
-- Installing: /build/workspace/my_project/build/install_dir/./libcrypto.so
-- Installing: /build/workspace/my_project/build/install_dir/./libcrypto.so.1.1
-- Installing: /build/workspace/my_project/build/install_dir/./my_project_executable
-- fixup_bundle
--   app='/build/workspace/my_project/build/install_dir/my_project_executable'
--   libs=''
--   dirs='/build/workspace/my_project/build/install_dir;/build/workspace/my_project/build/lib;/opt/Qt5.6.1/5.6/gcc_64/lib'
--   ignoreItems=''
-- fixup_bundle: preparing...
-- fixup_bundle: copying...
-- 1/40: *NOT* copying '/build/workspace/my_project/build/install_dir/my_project_executable'
-- 2/40: copying '/home/build/gcc5/lib64/libgcc_s.so.1'
-- 3/40: linking '/build/workspace/my_project/build/install_dir/libstdc++.so.6.0.21' -> '/build/workspace/my_project/build/install_dir/libstdc++.so.6'
-- 4/40: linking '/build/workspace/my_project/build/install_dir/libQt5Core.so.5.6.1' -> '/build/workspace/my_project/build/install_dir/libQt5Core.so.5'
-- 5/40: linking '/build/workspace/my_project/build/install_dir/libQt5Network.so.5.6.1' -> '/build/workspace/my_project/build/install_dir/libQt5Network.so.5'
-- 6/40: linking '/build/workspace/my_project/build/install_dir/libQt5Sql.so.5.6.1' -> '/build/workspace/my_project/build/install_dir/libQt5Sql.so.5'
-- 7/40: linking '/build/workspace/my_project/build/install_dir/libQt5Xml.so.5.6.1' -> '/build/workspace/my_project/build/install_dir/libQt5Xml.so.5'
-- 8/40: linking '/build/workspace/my_project/build/install_dir/libQt5XmlPatterns.so.5.6.1' -> '/build/workspace/my_project/build/install_dir/libQt5XmlPatterns.so.5'
-- 9/40: linking '/build/workspace/my_project/build/install_dir/libicudata.so.56.1' -> '/build/workspace/my_project/build/install_dir/libicudata.so.56'
-- 10/40: linking '/build/workspace/my_project/build/install_dir/libicui18n.so.56.1' -> '/build/workspace/my_project/build/install_dir/libicui18n.so.56'
-- 11/40: linking '/build/workspace/my_project/build/install_dir/libicuuc.so.56.1' -> '/build/workspace/my_project/build/install_dir/libicuuc.so.56'
-- 12/40: copying '/home/build/gcc5/lib64/libstdc++.so.6.0.21'
-- 13/40: copying '/opt/Qt5.6.1/5.6/gcc_64/lib/libQt5Core.so.5.6.1'
-- Removed runtime path from "/build/workspace/my_project/build/install_dir/libQt5Core.so.5.6.1"
-- 14/40: copying '/opt/Qt5.6.1/5.6/gcc_64/lib/libQt5Network.so.5.6.1'
-- Removed runtime path from "/build/workspace/my_project/build/install_dir/libQt5Network.so.5.6.1"
-- 15/40: copying '/opt/Qt5.6.1/5.6/gcc_64/lib/libQt5Sql.so.5.6.1'
-- Removed runtime path from "/build/workspace/my_project/build/install_dir/libQt5Sql.so.5.6.1"
-- 16/40: copying '/opt/Qt5.6.1/5.6/gcc_64/lib/libQt5Xml.so.5.6.1'
-- Removed runtime path from "/build/workspace/my_project/build/install_dir/libQt5Xml.so.5.6.1"
-- 17/40: copying '/opt/Qt5.6.1/5.6/gcc_64/lib/libQt5XmlPatterns.so.5.6.1'
-- Removed runtime path from "/build/workspace/my_project/build/install_dir/libQt5XmlPatterns.so.5.6.1"
-- 18/40: copying '/opt/Qt5.6.1/5.6/gcc_64/lib/libicudata.so.56.1'
-- Removed runtime path from "/build/workspace/my_project/build/install_dir/libicudata.so.56.1"
-- 19/40: copying '/opt/Qt5.6.1/5.6/gcc_64/lib/libicui18n.so.56.1'
-- Removed runtime path from "/build/workspace/my_project/build/install_dir/libicui18n.so.56.1"
-- 20/40: copying '/opt/Qt5.6.1/5.6/gcc_64/lib/libicuuc.so.56.1'
-- Removed runtime path from "/build/workspace/my_project/build/install_dir/libicuuc.so.56.1"
-- fixup_bundle: fixing...
-- 21/40: fix-up not required on this platform '/build/workspace/my_project/build/install_dir/my_project_executable'
-- 22/40: fix-up not required on this platform '/build/workspace/my_project/build/install_dir/libgcc_s.so.1'
-- 23/40: fix-up not required on this platform '/build/workspace/my_project/build/install_dir/libstdc++.so.6'
-- 24/40: fix-up not required on this platform '/build/workspace/my_project/build/install_dir/libQt5Core.so.5'
-- 25/40: fix-up not required on this platform '/build/workspace/my_project/build/install_dir/libQt5Network.so.5'
-- 26/40: fix-up not required on this platform '/build/workspace/my_project/build/install_dir/libQt5Sql.so.5'
-- 27/40: fix-up not required on this platform '/build/workspace/my_project/build/install_dir/libQt5Xml.so.5'
-- 28/40: fix-up not required on this platform '/build/workspace/my_project/build/install_dir/libQt5XmlPatterns.so.5'
-- 29/40: fix-up not required on this platform '/build/workspace/my_project/build/install_dir/libicudata.so.56'
-- 30/40: fix-up not required on this platform '/build/workspace/my_project/build/install_dir/libicui18n.so.56'
-- 31/40: fix-up not required on this platform '/build/workspace/my_project/build/install_dir/libicuuc.so.56'
-- 32/40: fix-up not required on this platform '/build/workspace/my_project/build/install_dir/libstdc++.so.6.0.21'
-- 33/40: fix-up not required on this platform '/build/workspace/my_project/build/install_dir/libQt5Core.so.5.6.1'
-- 34/40: fix-up not required on this platform '/build/workspace/my_project/build/install_dir/libQt5Network.so.5.6.1'
-- 35/40: fix-up not required on this platform '/build/workspace/my_project/build/install_dir/libQt5Sql.so.5.6.1'
-- 36/40: fix-up not required on this platform '/build/workspace/my_project/build/install_dir/libQt5Xml.so.5.6.1'
-- 37/40: fix-up not required on this platform '/build/workspace/my_project/build/install_dir/libQt5XmlPatterns.so.5.6.1'
-- 38/40: fix-up not required on this platform '/build/workspace/my_project/build/install_dir/libicudata.so.56.1'
-- 39/40: fix-up not required on this platform '/build/workspace/my_project/build/install_dir/libicui18n.so.56.1'
-- 40/40: fix-up not required on this platform '/build/workspace/my_project/build/install_dir/libicuuc.so.56.1'
-- fixup_bundle: cleaning up...
-- fixup_bundle: verifying...
-- ===========================================================================
-- Analyzing app='/build/workspace/my_project/build/install_dir/my_project_executable'
-- bundle='/build/workspace/my_project/build/install_dir'
-- executable='/build/workspace/my_project/build/install_dir/my_project_executable'
-- valid='1'
-- executable file 1: /build/workspace/my_project/build/install_dir/libQt5Core.so.5.6.1
-- executable file 2: /build/workspace/my_project/build/install_dir/my_project_executable
-- verified='0'
-- info='external prerequisites found:
f='/build/workspace/my_project/build/install_dir/my_project_executable'
external_prereqs='/opt/Qt5.6.1/5.6/gcc_64/lib/libQt5Core.so.5;/opt/Qt5.6.1/5.6/gcc_64/lib/libQt5Network.so.5;/opt/Qt5.6.1/5.6/gcc_64/lib/libQt5Sql.so.5;/opt/Qt5.6.1/5.6/gcc_64/lib/libQt5Xml.so.5;/opt/Qt5.6.1/5.6/gcc_64/lib/libQt5XmlPatterns.so.5'
'
--
CMake Error at /home/build/cmake-3.17.1/share/cmake-3.17/Modules/BundleUtilities.cmake:1119 (message):
  error: verify_app failed
Call Stack (most recent call first):
  /home/build/cmake-3.17.1/share/cmake-3.17/Modules/BundleUtilities.cmake:986 (verify_app)
  src/server/cmake_install.cmake:47 (fixup_bundle)
  cmake_install.cmake:81 (include)

make: *** [install] Error 1

I know there are 2 different versions of ICU libraries here.  My project uses ICU and it's using version 64.  The Qt libs reference an older version of ICU libs.  The ICU lib files have the version in the file name so this shouldn't be a problem and it doesn't seem to be causing issues on the system where fixup_bundle is working.
Hopefully someone out there knows what fixup_bundle is choking on and can help.  I'm currently stumped.
Answer: The problem here seems to be OS specific.  The cmake project was configured to rename the executable from ${PROJECT_NAME} to ${PROJECT_NAME}.bin during the install, so it was using:
install(PROGRAMS ... RENAME ${PROJECT_NAME}.bin)

instead of:
install(TARGETS ...)

This results in the RPATH being left as-is in the installed binary.  Having the hard-coded RPATH in the installed binary only caused problems for fixup_bundle on our CentOS build machine.  My local development machine (which does not use CentOS) had no problem.
Anyway, I reconfigured the project so it no longer renamed the project executable and just used the standard install(TARGETS ...) paradigm and now fixup_bundle is able to bundle up the package without problems.


Opening port 587 on Debian running on Google Compute Engine

Question: I'm attempting to use port 587 for my server mailing purposes. However, I can't seem to be able to unblock the port even after trying the following :

Adding port 587 to the Google Cloud network firewall list
Adding a new rule to iptables in the operating system
Restart the server

Am I missing out anything?
EDIT:
<code> /etc/iptables.up.rules
 -A INPUT -p tcp -m tcp --dport 587 -j ACCEPT
</code>
AND:
<code> Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes  target     prot opt in     out       source             destination
   7   420   ACCEPT     tcp   --  *      *       0.0.0.0/0            0.0.0.0/0            tcp dpt:587
</code>
Comment: Would be glad if you could point out where the question required a downvote
Comment: *How* did you add the new rule to iptables? Unless you add it to a config file, restarting the server will throw away any changes you have just made. `iptables -L -nv` and `tcpdump -n port 587` are two good debugging tools to figure out where packets are getting to and why they're being dropped. `tcpdump` runs outside `iptables` so if it doesn't see packets, probably the "cloud network firewall" is dropping them instead.
Comment: @Ladadadada Thanks! I have updated the question with the iptables information. However the tcp dumps seems to have no respond capturing 0 packets. Does that mean that the last line of your comment applies?
Comment: That rule doesn't exist in your iptables output but it doesn't matter because your iptables rules are set to accept everything anyway.  It's very likely that the packets are being blocked *before* they get to iptables, so yes, I think it's the "cloud network firewall". Can you get any logging or debugging information from that?
Comment: @Ladadadada I don't seem to see any. Is there other ways I can verify the info?
Answer: From the documentation for Google Compute Engine, section "Networking and Firewalls":

Blocked traffic
Google Compute Engine blocks or restricts traffic through all of the
following ports/protocols between the Internet and virtual machines,
as well as between two virtual machines when traffic is addressed to
their public IP addresses (this also includes load-balanced
addresses).
Note: These restrictions do not apply for traffic between two virtual
machines through their private addresses.

All outgoing traffic to port 25 (SMTP) is blocked.
Most outgoing traffic to port 465 or 587 (SMTP over SSL) is blocked. except for known Google IP addresses
All traffic that uses a protocol other than TCP, UDP, and ICMP is blocked.

I also found "Sending Email from an Instance":

Google Compute Engine does not allow outbound connections on ports 25,
465, and 587 but you can still set up your instances to send mail
through ports 587 and 465 using servers provided through partner
services, such as SendGrid. This document discusses how to set up your
instances to send email using SendGrid.
Comment: I did came across this post too. May I clarify if my Google Cloud instance IP addressis a'known' Google IP address as described above?
Comment: What do you mean?
Comment: Apologies for the typo. I was asking if my server instance is created as a Google Compute Engine instance, will it be a 'known' Google IP address?
Comment: I don't think so. I think they're referring to servers run _completely_ by them which is not our case, but again, I'm not sure.
Comment: It's pretty obvious that they mean Gmail here.
Comment: @MichaelHampton Sorry! I am really new to all this server things and all!
Comment: Are you trying to send email or receive it? The iptables output in the question only covers receiving it.
Comment: The google cloud don't seem to allow us to use smtp port 25 to do handle our mails. Hence, I have used their partner's service Sendgrid to handle the mailing as stated above. Am I right to say that if I were to allow port 587 through my firewall, Sendgrid would handle both receiving and sending?


Find $\lim\limits_{x\to\infty} \frac{1}{x}\int_{0}^{x} \frac{1}{2+\cos t}dt$.

Question:
Find $$\lim_{x\rightarrow\infty}\frac{1}{x} \int_{0}^{x} \frac{1}{2+\cos t}dt$$

I thought that using the fundamental theorem of calculus and l'Hospital would provide me with ${\lim\limits_{x\to \infty}\frac{1}{2+\cos x}}$, but I don't know if this has a result when ${x\to \infty}$.
Answer: The function
$$ f(t)=\frac{1}{2+\cos t}  $$
is periodic with period $2\pi$. Thus, we have that
$$\int_0^x f(t)\,dt = N \int_0^{2\pi}f(t)\,dt + \int_0^{x- 2\pi N}f(t)\,dt   $$
with
$$ N = \left\lfloor \frac{x}{2\pi} \right\rfloor\,.$$
The second term is bounded by a constant,
$$\left|\int_0^{x- 2\pi N}f(t)\,dt \right| \leq \int_0^{2\pi}|f(t)|\,dt\,.$$
Thus, we have that
$$\lim_{x\to\infty}  \frac{1}{x} \int_0^x f(t)\,dt = \frac{1}{2\pi}\left(\lim_{x\to\infty} \frac{2\pi}{x} \left\lfloor \frac{x}{2\pi} \right\rfloor \right)\int_0^{2\pi}f(t)\,dt =\frac{1}{2\pi} \int_0^{2\pi}f(t)\,dt\,.$$
The last integral can be easily evaluated and we obtain
$$ \lim_{x\to\infty}  \frac{1}{x} \int_0^x f(t)\,dt = \frac{1}{2\pi} \int_0^{2\pi}f(t)\,dt = \frac{1}{\sqrt{3}}\,.$$
Answer: As $-1\le \cos(t)\le 1$ for any $t$,
$$\frac{1}{2+\cos(t)}\ge \frac{1}{3}$$
So
$$
\int_0^x \frac{1}{2+\cos(t)}  dt \ge \frac{x}{3}
$$
Comment: This may be useful, but does not provide me with an answer for the given limit.
Comment: @user651754 Wouldn't the integral in question tend to $\infty$?
Comment: I did a mistake by not adding everything given. Otherwise, the l'Hospital idea would have had no sense.
Comment: This only shows that the given limit is greater than or equal to $\frac{1}{3}$.


Convergence of the serie $\sum \dfrac{(\ln(n))^n}{n!}$

Question: How to prove the convergence of the series: $$\sum_n \dfrac{(\ln(n))^n}{n!}$$

I tried to use the d'Alembert's rule:
If we write $u_n = \dfrac{(\ln(n))^n}{n!}$ then we get
$$\dfrac{u_{n+1}}{u_n} = \dfrac{1}{n+1} \times \dfrac{(\ln(n+1))^{n+1}}{(\ln(n))^n}$$

Is that possible to show that $\dfrac{u_{n+1}}{u_n} \rightarrow l <1$ ?
Answer: Since $\log(n)\leq \sqrt{n}$ and $n!\geq \frac{n^n}{e^n}$ we have
$$ 0\leq \sum_{n\geq 1}\frac{\log(n)^n}{n!}\leq \sum_{n\geq 1}\frac{e^n}{n^{n/2}}=\sum_{n\geq 1}\frac{1}{\left(\frac{1}{e}\sqrt{n}\right)^n} $$
and convergence by asymptotic comparison with a geometric series.
Answer: Computations show $$\begin{aligned}
\ln(\dfrac{u_{n+1}}{u_n}) = (n+1)\ln\ln(n+1)-n\ln\ln n - \ln (n+1)\sim-\ln n
\end{aligned}$$
so $\dfrac{u_{n+1}}{u_n} \to 0$. This yields convergence of the series.

Another way of getting convergence could resort to Stirling's estimate: $$\dfrac{(\ln(n))^n}{n!}\sim \left(\frac{e\ln n}{n} \right)^n \frac{1}{\sqrt{2\pi n}}$$
For large $n$, $\displaystyle \frac{\ln n}n\leq \frac{1}{e^2} $, hence $\displaystyle \frac{e\ln n}{n}\leq \frac{1}{e}$.
Thus $$\dfrac{(\ln(n))^n}{n!} = O\left(\frac{1}{e^n} \right)$$
The series converges.
Answer: From
$$\frac{u_{n+1}}{u_n}=\frac{1}{n+1}\frac{(\ln{(n+1)})^{n+1}}{(\ln{n})^n}=\frac{\ln{(n+1)}}{n+1}\left(\frac{\ln{(n+1)}}{\ln{n}}\right)^n=\\
\frac{\ln{(n+1)}}{n+1}\left(1+\frac{\ln{\left(1+\frac{1}{n}\right)}}{\ln{n}}\right)^n=...$$
Note $a_n=\frac{\ln{\left(1+\frac{1}{n}\right)}}{\ln{n}} \rightarrow 0, n\rightarrow\infty$
$$...=\frac{\ln{(n+1)}}{n+1}\left(\left(1+a_n\right)^{\frac{1}{a_n}}\right)^{a_nn} \rightarrow 0, n\rightarrow\infty$$
because
$$\lim\limits_{n\rightarrow\infty}\frac{\ln{(n+1)}}{n+1}=0$$
$$\lim\limits_{n\rightarrow\infty}\left(1+a_n\right)^{\frac{1}{a_n}}=e \Rightarrow e-\varepsilon < \left(1+a_n\right)^{\frac{1}{a_n}} < e+\varepsilon \tag{1}$$
$$\lim\limits_{n\rightarrow\infty}a_nn=\lim\limits_{n\rightarrow\infty}n\frac{\ln{\left(1+\frac{1}{n}\right)}}{\ln{n}}=\lim\limits_{n\rightarrow\infty}\frac{\ln{\left(1+\frac{1}{n}\right)^n}}{\ln{n}}=\frac{1}{\lim\limits_{n\rightarrow\infty} \ln{n}}=0 \tag{2}$$
from $(1)$ and $(2)$
$$\left(e-\varepsilon\right)^{a_nn} < \left(\left(1+a_n\right)^{\frac{1}{a_n}}\right)^{a_nn} < \left(e+\varepsilon\right)^{a_nn} \Rightarrow \lim\limits_{n\rightarrow\infty}\left(\left(1+a_n\right)^{\frac{1}{a_n}}\right)^{a_nn}=1$$
Answer: Write
$$\frac{u_{n+1}}{u_n} = \frac{\ln(n+1)}{n+1}\times \left(\frac{\ln(n+1)}{\ln n}\right)^n$$
Since $\ln(n+1) = 2\ln \sqrt{n+1} < 2\sqrt{n+1}$, it follows from the squeeze theorem that
$$\lim_{n\to \infty} \frac{\ln(n+1)}{n+1} = 0$$
Now
$$\frac{\ln(n+1)}{\ln n} = 1 + \frac{\ln(n+1) - \ln n}{\ln n} = 1 + \frac{\ln(1 + \frac{1}{n})}{\ln n}$$
so by the binomial theorem,
$$\left(\frac{\ln(n+1)}{\ln n}\right)^n > 1 + n\frac{\ln(1 + \frac{1}{n})}{\ln n} = 1 + \frac{\ln(1 + \frac{1}{n})}{\frac{1}{n}}\frac{1}{\ln n}$$
The limit of $n\dfrac{\ln(1 + \frac{1}{n})}{\ln n}$ is $0$ since $\lim\limits_{n\to \infty} \dfrac{1}{\ln n} = 0$ and $\dfrac{\ln(1 + \frac{1}{n})}{\frac{1}{n}}$ is bounded by $1$. As
$$1 + n\frac{\ln(1 + \frac{1}{n})}{\ln n} < \left(\frac{\ln(n+1)}{\ln n}\right)^n < 1$$
the squeeze theorem yields $\lim\limits_{n\to \infty} \left(\dfrac{\ln(n+1)}{\ln n}\right)^n = 1$. Consequently, $\lim\limits_{n\to \infty} \dfrac{u_{n+1}}{u_n} = 0$.


Mysterious Debian 8 random reboots

Question: I have a Debian 8 server that restarts randomly. I tried to lookup journalctl logs from previous boots (logs are persistent) but found nothing:
<code>$ journalctl -b -1 -e
</code>
Tried to grep through all logs (reboot, shutting, shut, down, restart, panic) - nothing helpful:
<code>$ grep -rn "reboot" /var/log
</code>
I was able to reproduce it on a few GCP and OVH (VPS, dedicated) nodes. Although some of the nodes with the similar setup work just fine.
<code>$ last reboot
reboot   system boot  3.16.0-4-amd64   Mon May 29 13:20 - 14:21  (01:00)
reboot   system boot  3.16.0-4-amd64   Mon May 29 13:11 - 14:21  (01:10)
reboot   system boot  3.16.0-4-amd64   Mon May 29 13:06 - 14:21  (01:15)
reboot   system boot  3.16.0-4-amd64   Mon May 29 12:58 - 14:21  (01:23)
reboot   system boot  3.16.0-4-amd64   Mon May 29 10:53 - 14:21  (03:28)
reboot   system boot  3.16.0-4-amd64   Mon May 29 09:51 - 10:52  (01:01)
reboot   system boot  3.16.0-4-amd64   Sun May 28 20:29 - 10:52  (14:23)
reboot   system boot  3.16.0-4-amd64   Sun May 28 20:01 - 10:52  (14:51)
reboot   system boot  3.16.0-4-amd64   Sun May 28 18:45 - 10:52  (16:07)
reboot   system boot  3.16.0-4-amd64   Sun May 28 18:36 - 10:52  (16:16)
reboot   system boot  3.16.0-4-amd64   Sun May 28 18:19 - 10:52  (16:33)
reboot   system boot  3.16.0-4-amd64   Sun May 28 17:51 - 10:52  (17:01)
reboot   system boot  3.16.0-4-amd64   Sun May 28 10:20 - 10:52 (1+00:31)
reboot   system boot  3.16.0-4-amd64   Sun May 28 09:04 - 10:52 (1+01:48)
reboot   system boot  3.16.0-4-amd64   Sun May 28 08:54 - 10:52 (1+01:58)
reboot   system boot  3.16.0-4-amd64   Sun May 28 08:48 - 10:52 (1+02:03)
reboot   system boot  3.16.0-4-amd64   Sun May 28 08:42 - 10:52 (1+02:10)
reboot   system boot  3.16.0-4-amd64   Sun May 28 08:35 - 10:52 (1+02:17)
reboot   system boot  3.16.0-4-amd64   Sun May 28 08:18 - 10:52 (1+02:34)
reboot   system boot  3.16.0-4-amd64   Sun May 28 08:12 - 10:52 (1+02:40)
reboot   system boot  3.16.0-4-amd64   Sun May 28 05:34 - 10:52 (1+05:18)
reboot   system boot  3.16.0-4-amd64   Sun May 28 01:03 - 10:52 (1+09:49)
reboot   system boot  3.16.0-4-amd64   Sun May 28 01:00 - 10:52 (1+09:52)
reboot   system boot  3.16.0-4-amd64   Sat May 27 23:20 - 10:52 (1+11:32)
reboot   system boot  3.16.0-4-amd64   Sat May 27 21:22 - 10:52 (1+13:30)
reboot   system boot  3.16.0-4-amd64   Sat May 27 21:17 - 10:52 (1+13:35)
reboot   system boot  3.16.0-4-amd64   Sat May 27 20:52 - 10:52 (1+14:00)
reboot   system boot  3.16.0-4-amd64   Sat May 27 19:32 - 10:52 (1+15:20)
reboot   system boot  3.16.0-4-amd64   Sat May 27 18:07 - 10:52 (1+16:45)
reboot   system boot  3.16.0-4-amd64   Sat May 27 17:52 - 10:52 (1+17:00)
reboot   system boot  3.16.0-4-amd64   Sat May 27 16:32 - 10:52 (1+18:20)
reboot   system boot  3.16.0-4-amd64   Sat May 27 12:25 - 10:52 (1+22:27)
reboot   system boot  3.16.0-4-amd64   Sat May 27 12:16 - 10:52 (1+22:36)
reboot   system boot  3.16.0-4-amd64   Sat May 27 11:07 - 10:52 (1+23:45)
reboot   system boot  3.16.0-4-amd64   Sat May 27 09:53 - 10:52 (2+00:59)
reboot   system boot  3.16.0-4-amd64   Sat May 27 09:09 - 10:52 (2+01:43)
reboot   system boot  3.16.0-4-amd64   Sat May 27 06:39 - 10:52 (2+04:13)
reboot   system boot  3.16.0-4-amd64   Sat May 27 06:06 - 10:52 (2+04:46)
reboot   system boot  3.16.0-4-amd64   Sat May 27 05:00 - 10:52 (2+05:52)
reboot   system boot  3.16.0-4-amd64   Sat May 27 04:53 - 10:52 (2+05:58)
reboot   system boot  3.16.0-4-amd64   Sat May 27 03:40 - 10:52 (2+07:12)
reboot   system boot  3.16.0-4-amd64   Sat May 27 01:57 - 10:52 (2+08:55)
reboot   system boot  3.16.0-4-amd64   Sat May 27 01:13 - 10:52 (2+09:39)
reboot   system boot  3.16.0-4-amd64   Fri May 26 22:51 - 10:52 (2+12:01)
reboot   system boot  3.16.0-4-amd64   Fri May 26 20:54 - 10:52 (2+13:58)
reboot   system boot  3.16.0-4-amd64   Fri May 26 16:50 - 10:52 (2+18:02)
reboot   system boot  3.16.0-4-amd64   Fri May 26 15:58 - 10:52 (2+18:54)
reboot   system boot  3.16.0-4-amd64   Fri May 26 15:21 - 10:52 (2+19:31)
reboot   system boot  3.16.0-4-amd64   Fri May 26 14:41 - 10:52 (2+20:11)
reboot   system boot  3.16.0-4-amd64   Fri May 26 13:23 - 10:52 (2+21:29)
reboot   system boot  3.16.0-4-amd64   Fri May 26 11:44 - 10:52 (2+23:08)
reboot   system boot  3.16.0-4-amd64   Fri May 26 10:55 - 10:52 (2+23:57)
reboot   system boot  3.16.0-4-amd64   Fri May 26 10:36 - 10:52 (3+00:16)
reboot   system boot  3.16.0-4-amd64   Fri May 26 10:12 - 10:52 (3+00:40)
reboot   system boot  3.16.0-4-amd64   Fri May 26 08:27 - 10:52 (3+02:25)
reboot   system boot  3.16.0-4-amd64   Fri May 26 08:25 - 10:52 (3+02:27)
reboot   system boot  3.16.0-4-amd64   Fri May 26 08:17 - 10:52 (3+02:35)
reboot   system boot  3.16.0-4-amd64   Fri May 26 06:45 - 10:52 (3+04:07)
reboot   system boot  3.16.0-4-amd64   Fri May 26 04:53 - 10:52 (3+05:59)
reboot   system boot  3.16.0-4-amd64   Fri May 26 04:23 - 10:52 (3+06:29)
reboot   system boot  3.16.0-4-amd64   Thu May 25 16:25 - 10:52 (3+18:27)
reboot   system boot  3.16.0-4-amd64   Thu May 25 16:01 - 10:52 (3+18:51)
reboot   system boot  3.16.0-4-amd64   Thu May 25 15:41 - 10:52 (3+19:11)
reboot   system boot  3.16.0-4-amd64   Thu May 25 15:24 - 10:52 (3+19:28)
reboot   system boot  3.16.0-4-amd64   Thu May 25 15:10 - 10:52 (3+19:42)
reboot   system boot  3.16.0-4-amd64   Thu May 25 14:10 - 10:52 (3+20:42)
reboot   system boot  3.16.0-4-amd64   Thu May 25 13:54 - 10:52 (3+20:58)
reboot   system boot  3.16.0-4-amd64   Thu May 25 13:31 - 10:52 (3+21:21)
reboot   system boot  3.16.0-4-amd64   Thu May 25 13:20 - 10:52 (3+21:32)
reboot   system boot  3.16.0-4-amd64   Thu May 25 13:03 - 10:52 (3+21:49)
reboot   system boot  3.16.0-4-amd64   Thu May 25 12:42 - 10:52 (3+22:10)
reboot   system boot  3.16.0-4-amd64   Thu May 25 11:52 - 10:52 (3+23:00)
reboot   system boot  3.16.0-4-amd64   Thu May 25 11:44 - 10:52 (3+23:08)
reboot   system boot  3.16.0-4-amd64   Thu May 25 11:24 - 10:52 (3+23:28)
reboot   system boot  3.16.0-4-amd64   Thu May 25 07:17 - 10:52 (4+03:35)
reboot   system boot  3.16.0-4-amd64   Wed May 24 04:42 - 10:52 (5+06:10)
reboot   system boot  3.16.0-4-amd64   Wed May 24 04:37 - 04:42  (00:05)
</code>
It is super weird that there's nothing in logs suggesting who triggered the restart, no kernel panic.
I tried to replace <code>/sbin/shutdown</code> as suggested in Server mysteriously rebooting but it seems no one runs it.
Journalctl logs just after the reboot: https://pastebin.com/raw/AmkNVs66
Please suggest how can I debug it further.
Comment: Maybe some kind of watchdog involved? Could you check BIOS logs?
Comment: @rudimeier not sure how I can get BIOS logs, but here logs in journalctl after reboot: https://pastebin.com/raw/AmkNVs66
Comment: Seems the reboots caused by kernel oops
Answer: Random reboots were caused by kernel panic although there were no logs suggesting it. After installing and configuring kdump I got a stack trace that helped me to identify the problem. Not obvious.

Mysterious Debian 8 random reboots


How to Compute for the Transition Probability Matrix F

Question:
this is our homework. I don't understand how to compute for the F matrix...I'm having a hard time understanding this transition probability matrix. Thank you in advance!
Comment: please add 'self-study' tag
Answer: The (i,j)'th element of the probability transition matrix is defined as
P(in state j after one year | in state i now).
I.e. the (i,j) element of the probability transition matrix is the probability of a Markov chain being in state j after one period, given that it is in state i now.  In this example, the period is one year.  The states 0,1,2,3,4 are the values of i and j.  So the probability transition matrix in this case is a 5 by 5 matrix, and each row (i) and column (j) can be considered to be labeled by its corresponding state.
Comment: f sub 11 is the probability that one year from now, there'll be 1 kid in the household, given that there is 1 kid now. The assumption provided is that there are no deaths.  So f sub 11 is the probability that no kids are born during the year, or perhaps if allowance is made that a kid can become an adult or move out, number of kids born equals number of kids who become adults or move out. But it may be that they want you to not consider kids becoming adults or moving out, in which case f sub 11 would be the probability of a household with 1 kid not having any kids born during the coming year.
Comment: Hi I still don't quite get it...can you show me how to compute f sub 11? or any element in the matrix? Please.
Comment: You are showing only the continuation, not the original statement, so I presume sufficient information is provided there to enable computation of the required probabilities.


OpenOffice / LibreOffice Base SQL Group By

Question: I have a small LibreOffice database with customer data and invoices. Each invoice consists of n items.
Customers:
**********************
* ID * Name * Adress *
**********************
*  0 *   N1 *     A1 *
*  1 *   N2 *     A2 *
**********************

Invoices:
********************************
* ID * CustomerID *       Date *
********************************
*  0 *          0 * 01/01/1970 *
*  1 *          0 * 08/02/1971 *
********************************

Items:
***********************************
* ID * InvoiceID * Amount * Price *
***********************************
*  1 *         0 *     12 * 12.95 *
*  2 *         0 *      9 *  8.75 *
*  3 *         1 *     29 *  8.75 *
***********************************

I want to create a query with the value of an invoice:
SELECT "invoices"."ID", SUM( "items"."Amount" * "items"."Price" )
FROM "invoices", "items"
WHERE "invoices"."ID" = "items"."InvoiceID"
GROUP BY "invoice"."ID"

So far everything works. But if I want to include some more information to the query, e.g.
SELECT "invoices"."ID", "invoices"."Date", SUM( "items"."Amount" * "items"."Price" )
FROM "invoices", "items"
WHERE "invoices"."ID" = "items"."InvoiceID"
GROUP BY "invoice"."ID"

I get the error message Not in aggregate function or group by clause. I tried it in phpmyadmin and it worked, so I think, that the SQL Syntax should be ok. What is the problem with my SQL statement?
Comment: The general GROUP BY rule says: "If a GROUP BY clause is specified, each column reference in the SELECT list must either identify a grouping column or be the argument of a set function." I.e try `GROUP BY "invoices"."ID", "invoices"."Date"`.
Answer: You have to include "invoices"."Date" in the group by clause.


Is there anything like Haskell's 'maybe' function built into Scala?

Question: What I'm looking for is this function:
def maybe[A, B](a: Option[A])(f: A => B)(g: () => B): B = a match
{
    case Some(x) => f(x)
    case None => g()
}

It's in the Haskell prelude so I'm thinking it might be in the Scala standard library somewhere and I've just missed it. I hate having to recode it in projects so I'm wondering if anyone knows where it is, or if it's definitively not there. Or is there a better method for getting this functionality?
Answer: Other answers have given the map + getOrElse composition.  Just for the record, you can "add" a maybe function to Option in the following way:
implicit def optionWithMaybe[A](opt: Option[A]) = new {
  def maybe[B](f: A=>B)(g: =>B) = opt map f getOrElse g
}

It's worth noting that the syntax of higher-order functions in Scala is usually nicer when the function parameter comes last.  Thus, a better way to organize maybe would be as follows:
def maybe[B](g: =>B)(f: A=>B) = opt map f getOrElse g

This could be used as follows:
val opt: Option[String] = ...
opt.maybe("") { _.toUpperCase }

Answer: You could do
val opt:Option[A] = // ...
val result:B = opt.map(f).getOrElse(g());

getOrElse takes a by-name parameter, so g will only be evaluated if opt is None.
Comment: Why `a => f(a)` instead of just `f`?
Answer: You can use scalaz, and then you have an implicit conversion to OptionW which has fold, or you can use Scala 2.10.0-M3 and use the builtin Option.fold
scala> Some(1).fold(5)(_ * 2)
res5: Int = 2

scala> (None: Option[Int]).fold(5)(_ * 2)
res7: Int = 5

Note that the scalaz fold signature is fold[X](some: A => X, none: => X), while the builtin seems to be fold[X](none: => X)(some: A => X).
Comment: +1 for mentioning that the function is already in the standard library in the latest version
Answer: The method would be called fold if it were to adhere to convention (see Either.fold which is the catamorphism for Either).
Answer: I'd use Option.fold for this:
opt.fold(g)(f)

Note that g is by-name, just like getOrElse. Also note the inversion of the cases.
Answer: I don't think there is.  The best I could come up with is to chain Option's "map" and "getOrElse" together:
scala> var a: Option[String] = Some("hello")
a: Option[String] = Some(hello)

scala> a.map(_.toUpperCase).getOrElse("empty")
res19: java.lang.String = HELLO

scala> a = None
a: Option[String] = None

scala> a.map(_.toUpperCase).getOrElse("empty")
res21: java.lang.String = empty

Answer: I don't think there is. However, I'd write it to take g by name:
def maybe[A, B](a: Option[A])(f: A => B)(g: => B): B = a.map(f).getOrElse(g)

This is more Scala- and Haskell-like and a bit nicer to use.


Resolution of Recaptcha Error in Drupal 7 forms

Question: I am using Recaptcha module for filtering the spam on the form.
But the form contains some alax file upload field which stop recaptcha to work properly. Every time I upload the file in the form by AJAX it is giving me following message:
CAPTCHA session reuse attack detected.
This made me difficult to use the module. Please let me know if there is any work around to solve the problem.
I am just newbie in Drupal 7. If there is any better spam protection module than recaptcha then also suggest me.
Answer: I personally use the Are You a Human PlayThru Module:

PlayThru is designed to be more simple, more intuitive, and more fun than other CAPTCHA options. We use game mechanics to create an experience that's more enjoyable than figuring out what that awful squiggly text says.
PlayThru is also more secure. Because users interact directly with PlayThru, we can analyze that interaction and track the resulting data to generate a Human Confidence Score: our level of confidence that a user is an actual human.

You can also check out a video about it this module here:
Drupal 7 Are You a Human PlayThru Module - Daily Dose of Drupal episode 78

Update
The Are you a human PlayThru service has shutdown, I recommend you go with ReCaptcha

Uses the Google reCAPTCHA web service to improve the CAPTCHA system
and protect email addresses.
reCAPTCHA helps power massive-scale online collaboration.


Mudar de pagina em um tabela html com beautifulsoup

Question: Estou coletando os dados nesse site, utilizando requests e beautifulsoup. Consegui coletar todos os dados da pagina 1, porem não consigo mudar a pagina.

Codigo Python
   variaveis = []
   df_list = []
   for i in range(1,3):
       print('rodada')
       print(i)
       url = 'https://www.cartolafcbrasil.com.br/scouts/cartola-fc-2018/rodada-' + str(i)
       page = requests.get(url)
       soup = BeautifulSoup(page.text, 'html.parser')
       table = soup.find_all('table')[0]
       df = pd.read_html(str(table), encoding="UTF-8")
       df_list.append(df)
    print(df)

HTML

      1

      2

      3

Answer: Problema
A paginação usada na lista dos resultados depende da execução de uma função javascript e o BeautifulSoup não executa javascript, então você não vai conseguir o acesso a dados obtidos pelo javascript.
Solução
Você pode usar uma engine de renderização completa, no Python você pode usar o Selenium, assim você vai conseguir simular o clique na paginação e o javascript sera executado garantindo o acesso aos dados que precisa.
Comment: soup.find_element_by_xpath("(//a[contains(.,'2')])[2]").click()         'NoneType' object is not callable
Comment: @Pedro com o Soup você não ira conseguir executar o javascript.


If there is a branch of $\sqrt{z}$ on an open set $U$ with $0 \notin U,$ then there is also a branch of $arg$ $z.$

Question: Show that if there is a branch of $\sqrt{z}$ on an open set $U$ with $0 \notin U,$ then there is also a branch of $arg$ $z.$
I am unable to proceed any further in this and any help in this regard would be greatly appreciated.
Comment: Both are equivalent to: $0$ is connected to $\infty$ outside $U$.
Comment: I swear this is a duplicate
Answer: A natural way is proving the ``obvious'' fact that if an open set $U\subset\mathbb{C}$ contains a closed curve $\gamma$ with non-zero winding number around $0$ then $U$ contains a closed curve $\gamma_1$ with winding number $1$ around $0$. To do this, first we replace $\gamma$ by a closed polygon. After some perturbation the polygon has no multiple segments, just finitely many self-intersections. At the self-intersections the polygon can be split into finitely many simply closed polygons. From the sum of the winding numbers of the small polygons, at least one of them has non-zero winding number. But, due to Jordan's curve theorem, the winding number of a simply closed polygon can be only $0$ or $\pm 1$.

Another proof: Suppose that there is a continuous branch of $\sqrt{z}$ on $U$.
Let $V=\{\sqrt{z}:z\in U\}$. We will prove that $\log z$ has a holomorphic branch on $V$; this provides a branch of $2\log\sqrt{z}$ on $U$.
Notice that the sets $V$ and $-V$ are disjoint.
For the existence of $\log z$ on $V$ it suffices if every closed polygon in $V$ has zero winding number around $0$. Take an arbitrary closed polygon $\gamma\subset V$, and for every $z\in V\subset \gamma$, let
$n_\gamma(z) =\frac1{2\pi i}\int_{w\in\gamma}\frac{\mathrm{d}w}{w-z}$
be the winding number of $\gamma$ around the point $z$. We want to prove
$n_\gamma(0)=0$.
Consider the polygon $-\gamma$. As $\gamma\subset V$ and $-\gamma\subset (-V)$ and the sets $V$ and $-V$ are disjoint, the curves $\gamma$ and $-\gamma$ are disjoint, too. Let $z_1\in(-\gamma)$ and $z_2\in(-\gamma)$ be two points of $-\gamma$ with minimum and maximum distance from $0$. In the open set $\mathbb{C}\setminus(\{0\}\cup \gamma)$
the points $0$ and $z_1$ are connected by a line segment; the points $z_1$ and $z_2$ are connected by the curve $-\gamma$; finally $z_2$ and $\infty$ are connected by a ray. Therefore, the points $0,z_1,z_2,\infty$ are in the same component of $\overline{\mathbb{C}}\setminus(\{0\}\cup\gamma)$, so
$$
n_\gamma(0) = n_\gamma(z_1) = n_\gamma(z_2) = n_\gamma(\infty) = 0.
$$
Hence, every closed polygon $\gamma\subset V$ has winding number $0$ around $0$, so there is a holomorphic branch of $\log z$ on $V$.
Comment: In the  first answer "first we replace $\gamma$  by a closed polygon?" How to get the closed polygon?
Comment: The curve $\gamma$ lies in an open domain, so the distance between $\gamma$ and $\mathbb{C}\setminus{U}$ is positive. We can choose finitely many sampling points along the curve.


I need to convert a yearly data into a quarterly and monthly data?

Question: Can anybody please help me convert yearly data into monthly and quarterly data?
Comment: Why downvote and ask to close this? User41793 is asking a question others might ask. The answer (see my post or the comment by @Penguin_Knight) may be obvious to us, but it is not obvious to everyone.
Comment: Calm down, and go collect some quarterly and monthly data. Higher level of temporal scale cannot be decomposed into lower level, unless you are willing to make some assumptions which are often unrealistic.
Comment: Welcome to our site! This question needs more detail to be answerable. You can edit it to do so. Please consult our [help] for suggestions.
Comment: Thanks, @PeterFlom, I see your point and I have retracted mine.
Comment: What is the purpose? I've seen people doing this to prop up the statistics by increasing the sample size this way. I hope it's not what you're trying to do here
Answer: Welcome to the site.
Unless you are willing to make assumptions, there is no way to convert yearly data into monthly or quarterly data.
If you are willing to make the assumption that whatever it is you have data on happens at a uniform rate throughout the year then quarterly data would just be yearly data divided by 4.  Monthly data is a little trickier, but not much. You'd need to multiply the yearly data by (days in month)/365 to get close. If you want to account for leap years too, you can.
But that assumption is awfully dangerous; few things happen at the same rate all year.  There may be other assumptions that are more reasonable.
Comment: Yes, assumptions are needed--but you appear to have made some additional unstated assumptions that could confuse the unwary. One of them is that these data are cumulative totals. What, for example, would happen with annual mean temperatures?  Would you propose dividing them all by four?  Even in an area where temperatures never vary (a "uniform rate")? :-)
Answer: We need to make assumptions to convert a time series from quarterly to monthly. Sometimes, one must transform a series from quarterly to monthly since one must have the same frequency across all variables to run a regression. In Economics,  it is common to use the  cubic spline interpolation to convert quarterly data into monthly. Let's assume that we have n quarterly data points, which implies n - 1 spaces between them. Across each space, we draw a unique 3rd-degree polynomial connecting two points. If you are conducting your analysis in excel, you can do this: http://newtonexcelbach.wordpress.com/2009/07/02/cubic-splines/
There is a package in R that performs the cubic spline interpolation.
http://stat.ethz.ch/R-manual/R-patched/library/stats/html/splinefun.html
If you plan to use the data with cubic splines in a regression, be careful with autocorrelation in the residuals. In this case, it is recommend to use the Newey-West standard errors as they are robust against the autocorrelation caused by the cubic splines.


Python, sort dict based on external list

Question: I have to sort a dict like:
jobs = {'elem_05': {'id': 'fifth'},
        'elem_03': {'id': 'third'},
        'elem_01': {'id': 'first'},
        'elem_00': {'id': 'zeroth'},
        'elem_04': {'id': 'fourth'},
        'elem_02': {'id': 'second'}}

based on the "id" elements, whose order can be found in a list:
sorting_list = ['zeroth', 'first', 'second', 'third', 'fourth', 'fifth']

The trivial way to solve the problem is to use:
tmp = {}
for x in sorting_list:
    for k, v in jobs.items():
        if v["id"] == x:
            tmp.update({k: v})

but I was trying to figure out a more efficient and pythonic way.
I've been trying sorted and lambda functions as key, but I'm not familiar with that yet, so I was unsuccessful so far.
Comment: The key function should extract the "id" value from the "jobs" entry and find the index of it in the "sorting_list" and return it. What is the problem with this approach?
Comment: I mean, as I mentioned I'm not that familiar with sorted and lambda function. For instance, I didn't know that key is automatically called on all the elements of the iterable you'e calling sorted on. Hence, I didn't really understand what the argument of the lambda function would be, and so on...
Answer: There is a way to sort the dict using lambda as a sorting key:
jobs = {'elem_05': {'id': 'fifth'},
    'elem_03': {'id': 'third'},
    'elem_01': {'id': 'first'},
    'elem_00': {'id': 'zeroth'},
    'elem_04': {'id': 'fourth'},
    'elem_02': {'id': 'second'}}

sorting_list = ['zeroth', 'first', 'second', 'third', 'fourth', 'fifth']

sorted_jobs = dict(sorted(jobs.items(), key=lambda x: sorting_list.index(x[1]['id'])))

print(sorted_jobs)

This outputs
{'elem_00': {'id': 'zeroth'}, 'elem_01': {'id': 'first'}, 'elem_02': {'id': 'second'}, 'elem_03': {'id': 'third'}, 'elem_04': {'id': 'fourth'}, 'elem_05': {'id': 'fifth'}}

I have a feeling the sorted expression could be cleaner but I didn't get it to work any other way.
Comment: This issue with that approach is that `sorting_list.index` is expensive when repeated many times
Comment: @mozway Big O notation is meaningless for small N. Feel free to ```timeit``` for micro-optimizations but clear, simple and short solutions for tiny problems are entirely valid.
Comment: @Homer512 in OP's question "*I was trying to figure out a more efficient way*", this seems relevant (the example is likely minimal). NB. not the downvoter.
Comment: I really like this approach, thanks for the help! I accepted another answer because, as @mozway suggested, this is only a MWE, the actual dict I'm working with can easily have tens of thousands of elements.
Comment: @mozway it can't really be repeated many times since it is a handcrafted list of words. For small lists, this is an entirely sufficient approach.
Comment: @Homer512 it is repeated 6 times here, so you have to search in `sorting_list` 6 times, the behavior has a worst complexity of O(n**2)
Comment: I do agree there are a lot more efficient solutions if required. I wrote this answer in respect to OP trying to do it with sorted and lambda as he mentioned. It's simple so quite pythonic as well in a sense.
Answer: The sorted function costs O(n log n) in average time complexity. For a linear time complexity you can instead create a reverse mapping that maps each ID to the corresponding dict entry:
mapping = {d['id']: (k, d) for k, d in jobs.items()}

so that you can then construct a new dict by mapping sorting_list with the ID mapping above:
dict(map(mapping.get, sorting_list))

which, with your sample input, returns:
{'elem_00': {'id': 'zeroth'}, 'elem_01': {'id': 'first'}, 'elem_02': {'id': 'second'}, 'elem_03': {'id': 'third'}, 'elem_04': {'id': 'fourth'}, 'elem_05': {'id': 'fifth'}}

Demo: https://replit.com/@blhsing/WorseChartreuseFonts
Answer: You can use OrderedDict:
from collections import OrderedDict

sorted_jobs = OrderedDict([(el, jobs[key]['id']) for el, key in zip(sorting_list, jobs.keys())])

This creates an OrderedDict object which is pretty similar to dict, and can be converted to dict using dict(sorted_jobs).
Comment: You might want to add that ```OrderedDict``` is only required for compatibility with <Python-3.7. dicts are now always ordered by insertion order
Answer: Similar to what is already posted, but with error checking in case id doesn't appear in sorting_list
sorting_list = ['zeroth', 'first', 'second', 'third', 'fourth', 'fifth']

jobs = {'elem_05': {'id': 'fifth'},
        'elem_03': {'id': 'third'},
        'elem_01': {'id': 'first'},
        'elem_00': {'id': 'zeroth'},
        'elem_04': {'id': 'fourth'},
        'elem_02': {'id': 'second'}}

def custom_order(item):
    try:
        return sorting_list.index(item[1]["id"])
    except ValueError:
        return len(sorting_list)

jobs_sorted = {k: v for k, v in sorted(jobs.items(), key=custom_order)}
print(jobs_sorted)

Answer: I would use a dictionary as key for sorted:
order = {k:i for i,k in enumerate(sorting_list)}
# {'zeroth': 0, 'first': 1, 'second': 2, 'third': 3, 'fourth': 4, 'fifth': 5}

out = dict(sorted(jobs.items(), key=lambda x: order.get(x[1].get('id'))))

output:
{'elem_00': {'id': 'zeroth'},
 'elem_01': {'id': 'first'},
 'elem_02': {'id': 'second'},
 'elem_03': {'id': 'third'},
 'elem_04': {'id': 'fourth'},
 'elem_05': {'id': 'fifth'}}


Menu links at the corners of the screen

Question: Used omega theme and stumped at menu part.
Top right - Home
Top Left - Work
Bottom Left - Contact
Bottom Right - FAQ
Tried to set 2 menus: top and bottom in menu zone and then set id to each links so they can be positioned accordingly but it didn't work as expected. These menus sit next to the main menu in column 1, 3, 8
How do I put the menu links in menu block then set them at the corners of the screen?
Answer: For those that are not familiar with Omega theme, it will be hard to help you without more information like a link or your HTML and CSS code. However, you may look up the CSS float property to achieve what you want.
Answer: You could use the Menu attributes module to add classes to each module (such as top-left, bottom-right, etc) and style based on those.  This will be a lot more robust than using ids derived from the menu link's mid.
Next, to get the links to the corners of the screen, you will need to give them position: absolute or position: fixed.  Bear in mind that that will allow you to position them relative to their first positioned (not static) ancestor element.  This means that you'll have to make sure that none of the containers around the menu links have a css position of anything other than "static".
Finally you may need to add "min-height: 100%" to the html and body tags in order to make sure that the bottom-left/right links do get down to the bottom of the page.
These changes might break other styling on your page, which would probably mean that one of the containers around your menu links needs to have a position other than static.  If you can't work around this then you'll need to move your menu outside of that container by (for example) overriding the relevant templates such as page.tpl.php, or if all else fails, you could use javascript to move the menu to another part of the DOM where it's styling won't effect other elements on the page.  However, you should only do that if you're happy that non-javascript users will still get a sufficiently usable experience without the links being at the edge of the page.
Comment: thanks and I did that already but it doesn't go as expected. The menu zone has column-12 grid and the links stay in that zone. Not following position that I set.
Comment: This will most likely be because the menu zone has a position of "relative" or similar.  you would need to override this and give it "position: static", then repeat for any other containers until you get to the body

Menu links at the corners of the screen


What is the Azure equivalent of AWS Lambda?

Question: At the moment we are running our application on an AWS Beanstalk but are trying to determine the suitablilty of Azure.
Our biggest issue is the amount of wasted CPU time we are paying for but not using. We are running on t2.small instances as these have the min amount of RAM we need but we never use even the base amount of CPU time allotted. (20% for a t2.small ) We need lots of CPU power during short bursts of the day and bringing more instances on line in advance of this is the only way we can handle it.
AWS Lambda looks a good solution for us but we have dependencies on Windows components like SAPI so we have to run inside of Windows VMs.
Looking at Azure cloud services we thought using a Web role would be best fit for our app but it seems a Web role is nothing more than a Win 2012 VM with IIS enabled. So as the app scales it just brings on more of these VMs which is exactly what we have at the moment. Does Azure have a service similar to Lambda where you just pay for the CPU processing time you use?
The reason for our inefficient use of CPU resources is that our speech generation app uses lost of 3rd party voices but can only run single threaded when calling into SAPI because the voice engine is prone to crashing when multithreading.  We have no control over this voice engine. It must have access to a system registry and Windows SAPI so the ideal solution is to somehow wrap all dependencies is a package and deploy this onto Azure and then kick off multiple instances of this.  What "this" is I have no Idea
Answer: Microsoft just announced a new serverless compute service as an alternative to AWS Lambda, called Azure Functions:
https://azure.microsoft.com/en-us/services/functions/
http://www.zdnet.com/article/microsoft-releases-preview-of-new-azure-serverless-compute-service-to-take-on-aws-lambda/
With Azure Functions you only pay for what you use with compute metered to the nearest 100ms at Per/GB price based on the time your function runs and the memory size of the function space you choose. Function space size can range from 128mb to 1536mb. With the first 400k GB/Sec free.
Azure Function requests are charged per million requests, with the first 1 million requests free.
Comment: One should add that while AWS Lambda and Azure Functions are equivalent, Lambda is uses to implement services that are already available in Azure. Eg, Amazon doesn't offer any ETL dataflow tools so people use Lambda to implement the pipelines. Azure though offers both Data Factory and U-SQL. The same for Azure Stream Analytics - Kinesis Analytics is still in the "Fill this email form" phase so people use Lambdas to implement event analytics.
Answer: Based on the documentation on Azure website here: https://azure.microsoft.com/en-in/campaigns/azure-vs-aws/mapping/, the services equivalent to AWS Lambda are Web Jobs and Logic Apps.
Comment: I do find it very odd that they don't include Azure Automation as a direct equivalent to Lambda!
Comment: I'm surprised as well. Azure team must have done some diligence before putting out this mapping.
Comment: Or, it offers proof that they didn't! Since it is clearly a very similar product (I just opened [Lambda](http://docs.aws.amazon.com/lambda/latest/dg/welcome.html) and [Automation](https://azure.microsoft.com/en-in/documentation/services/automation/) front pages up, and they're almost identical in what they say they offer)
Answer: The most direct equivalent of Lambda on Azure is Azure Automation which does a lot of what Lambda does except it runs Powershell instead of Node etc. It isn't as tightly integrated into other services like Lambda is, but it has the same model. i.e. you write a script, and it is executed on demand.
I presume by SAPI you are refering to the speech API? If so you can create Powershell modules for Azure, and they can include dll files. In which case you could create a module to wrap around the SAPI dll, and that should do what you are looking for.
If you want a full compute environment, without the complexity of multiple machines when you run. You could use Azure Batch which would be the Azure recommended way of running what you are looking for.
The cost benefit you need to evaluate would be how much quicker your solution would run against a native .net stack (in batch), and if performance is significantly degraded when run from Powershell.
Personally I would give Automation a try, it is surprisingly powerful.
Comment: Azure Batch asks to create VMs to run Batch how is that comparable to AWS Lambda ?
Answer: There is something called "Cloud Service" in azure which allows you to run code on a pure VM. Scaling options on these include such things as CPU%, queue size, etc. If you can schedule your needs, Azure allows you to easily set up a scheduled scaler, i.e. 4 VM's from 8AM until 08:10AM, and of course, in Azure, you pay by the minute, so it could be a feasible solution.
I'd say more, but the documentation in Azure is really so great that I'd be offending them by offering my "translation" here. Checkout azure.com for more info :)
Comment: The OP has already stated that he's not looking to run a Vm, A cloud service is simply a container for a Vm / Web app, its not a replacement in its own right.
Comment: I know he stated that, but Azure is not AWS, there are two very important distinctions: 1) you pay by the minute, which in this case seems important, and 2) While true that a cloud service runs in a VM, you do not manage that VM at all, only the application. Anything related to uptime, failover, fault domains etc is handled by the cloud service, so it's a very viable solution to the problem. Not sure why this is downvoted when it is a clear match
Comment: Hey Pedro,  thanks for the answer but using Azure cloud service would be almost identical to what we have at the moment with AWS,  except cost would be 2x.  The most basic VM that a web/worker role would use costs 2.5x what an EC2 t2.small costs.


Comparison principle for heat equation

Question: Let $\Omega$ be a bounded open subset of $\mathbb{R}^n$ and $g:\bar \Omega \to \mathbb{R}$ be a continuous (non-constant) function.
Where can I find a proof of the fact that if $u$ solves
\begin{equation}
\begin{cases}
u_t + \Delta u = 0 &\quad \text{ on } (0,\infty) \times \Omega \\
u = 0  &\quad \text{ on } (0,\infty) \times \partial \Omega \\
u(0,\cdot) =g  &\quad \text{ on }   \bar \Omega
\end{cases}
\end{equation}
then
$$\min_{\bar \Omega} g < u(t,x) <\max_{\bar \Omega} g$$
for any $t>0$ and $x \in \bar \Omega$?
Answer: This is the maximum principle for the heat equation which says solutions to the heat equation attains its maximum and minimum on the boundary of $\Omega$ or at time $t=0$. Every PDE book worth its salt should cover this property in its discussion of the heat equation. Here is a proof in a single spatial variable.

Comparison principle for heat equation


Securing RDP access to Windows Server 2008 R2: is Network Level Authentication enough?

Question: I am a dev with little admin expertise, administering a single dedicated web server remotely.
A recent independent security audit of our site recommended that "RDP is not exposed to the Internet and that a robust management solution such as a VPN is considered for remote access.
When used, RDP should be configured for Server Authentication to ensure that clients cannot be subjected to man-in-the-middle attacks."
Having read around a bit, it seems like Network Level Authentication is a Good Thing so I have enabled the "Allow connections only from Remote Desktop with NLA" option on the server today.
Is this acion enough to mitigate the risk of a Man-in-the-Middle attack? Or are there other essential steps I should be taking? If VPN is essential, how do I go about it?
Answer: You really should not have RDP open to the world, even with NLA on. NLA does cut down on MITM attacks, but if you are using the default self-signed certificate for RDP access, you're not all too secure.
One of the main reasons that you don't want to leave RDP open to the world is to prevent automated password cracking attempts. If you remove RDP from Internet-facing interfaces, you completely mitigate random, automated brute-force attacks. Putting something like a VPN in place for remote access is both highly recommended and useful.
There are many ways that you can implement a VPN. Windows has a built-in IPSEC VPN, for example. OpenVPN Access Server is also free for up to two concurrent users if you want to go the SSL VPN route.
If you need very specific instructions on how to set up a VPN, then you need to research the options, pick a technology, read the documentation, and then open a new question with any concerns or issues that you have implementing it. Just asking "How do I implement a VPN" is much too broad for Server Fault.
Answer: In the same way that a user can click right through an SSL warning in their browser, the avoidance of man-in-the-middle attacks is still the responsibility of the user.
All that this change has accomplished is to prevent the connection of older clients that don't support NLA (and the server identity validation that that provides).
For RDP version 6 clients, they're no more and no less vulnerable to an attack as they were yesterday - a user clicking through a server identity dialog box is all that needs to happen for a man-in-the-middle attack to be successful.
Comment: You're really only preventing Windows 2000 clients anyway, by turning NLA on. Windows XP SP3 can be made to use CredSSP with a couple of minor (and supported) registry tweaks.
Comment: @MarkM Good point.
Answer: No, NLA is designed to minimize the attack surface of the Remote Desktop server.  The man-in-the-middle protection occurs when you configure your Remote Desktop server connection with a valid certificate.  However, if users dismiss the warning that appears if the server or certificate is not trusted or valid, they may still connect to an hostile Remote Desktop server, and that vulnerability has nothing to do with your Remote Desktop server.
From:
Configure Network Level Authentication for Remote Desktop Services Connections
http://technet.microsoft.com/en-us/library/cc732713.aspx
"Network Level Authentication completes user authentication before you establish a remote desktop connection and the logon screen appears. This is a more secure authentication method that can help protect the remote computer [remote desktop server] from malicious users and malicious software. The advantages of Network Level Authentication are:
"It requires fewer remote computer [remote desktop server] resources initially. The remote computer uses a limited number of resources before authenticating the user, rather than starting a full remote desktop connection as in previous versions.
"It can help provide better security by reducing the risk of denial-of-service attacks."


All links point to the old site after migration

Question: I migrated a Drupal 7 site from 1 server to another. Let's call the old site URL http://oldsite.com and the new site url http://newsite.com. I have copied over the code base and the database. The site displays correctly on http://newsite.com, however all the links point to http://oldsite.com. The only way to access the links are to type the URL in the browser (e.g. http://newsite.com/admin).
I have read lot of forums and done the following:

Set the $base_url in settings.php
Cleared cache in Config > Development > Performance
Cleared the cache table in DB
Ran update.php
Disabled clean urls

Nothing has worked. Someone suggested changing an entry in system table. Don't know which entry they were talking about.
Can anyone suggest the correct steps and perhaps an explanation of why I keep getting the redirects?
I have also referred to Moving a site, links/admin do not work.
Comment: Did you try this module https://drupal.org/project/pathologic
Answer: For sites being localized, you have to edit every language:
<code>/admin/config/regional/language</code>
It's because there's a "domain" field that is left with the wrong URL in the database.
That solved my case of moving from subdomain beta.mysite.com to www.mysite.com
Answer: If you are using domain access, be sure to check the table PREFIX_languages. I had the exact same problem and wasted 2 days before I found the problem. The old domain was hard coded in the PREFIX_languages table and once I changed it everything worked perfectly.
Comment: There is no indication that the OP is using Domain.


Git remove file from a range of commits

Question: I need to remove a folder from my repo in certain commits. It was added in commit a and removed in commit b and was added again in commit c as submodule.
Now I want to remove it from the commits between (including) a and b.
I have it as far as I have to do something like:
git filter-branch --index-filter 'git update-index --remove lib --ignore-submodules' 7a08959f87681decc15ad5a272bbada66c3272e8 goodbye_cmake

But I don't know how I can add the end (b). It deletes it from all the commits from a to the last commit of goodbye_cmake (i.e. HEAD)... So what do I have to change that I still have my submodule in the last few (~30) commits?
Thanks for all your time!
- Fodinabor
Answer: BFG is a nice alternative to filter-branch, and it's blessed by github. It only changes your history and won't remove any files currently in the project, so it should remove the old directory up to commit b like you want. The invocation will end up looking like:
java -jar bfg.jar --delete-folders directory_name your_repo.git

Answer: Unless I am misunderstanding the question, you already have the answer (almost):
$ git filter-branch --index-filter 'git update-index --remove tests/files/ceac_analysis_data_* --ignore-submodules'  10e8e892b49a4657a3b36ef4ca0a524b8a26a438..HEAD

So the syntax is
$ git filter-branch *options* a..b

Instead of
$ git filter-branch *options* a b`

Comment: `git filter-repo` https://github.com/newren/git-filter-repo/ is now recommended when you try to run `git filter-branch`

Git remove file from a range of commits


How I can force enable clean url d7

Question: Today i have transferred my d7 site to a new ubuntu vps, then in the Apache config files i made this change: AllowOverride None to AllowOverride All and now d7 site is working under clean url.
While transferring the website i have disabled the clean url option from the admin/config/search/clean-urls, but here is the difficulty. Now clean url works but in order to enable clean url when i click on the "Run the clean URL test" button then it shows "The clean URL test failed." though it is working :/
I have cleared all the cache data with no luck.
Now what are alternative ways to enable clean url manually in d7?
Answer: Clean URL state is managed through the Drupal variable clean_url.

clean url disabled: clean_url is 0
clean url enabled: clean_url is 1

You can force this value by:

Using drush
drush vset clean_url 1

Using a direct SQL query
UPDATE variable SET value=1 WHERE name='clean_url';

Force a value in settings.php
$conf['clean_url'] = 1;

Comment: Variables are cached, so the `UPDATE` won't take right away.  Assuming a SQL backend, you would need to `DELETE FROM cache_bootstrap WHERE cid = 'variables'`
Comment: The talbe name is 'variable', but if your using a database prefix it should be '_variable'... if you can just use drush, is the best way.
Comment: Thanks for your answer, is that the table name should be dr_variable ?
Answer: Here is a non Drush solution:
The trick,if the clean url test fails on drupal 7 (but you think it should be working) is to edit the url.
Your current url at the clean url page should be;
http://www.your-site.com/?q=admin/config/search/clean-urls
So edit it and change it to;
http://www.your-site.com/admin/config/search/clean-urls
You should now be able to see the box to enable clean URLs. Enable the clean urls and visit some of the sites inner pages to check that it is working. If you have any problems you can turn them off again here: http://www.your-site.com/?q=admin/config/search/clean-urls
Answer: Setting
$GLOBALS['conf']['clean_url'] = 1;

line 587 in settings.php always work for me.

How I can force enable clean url d7


Wait for Animation Inside of Form Submit Event

Question: Submitting Form After jQuery Execution
The way I have my form currently set up the user can select one of several options, each represented by a button with a unique value. What I'd like to do is process the form data and then execute an animation if everything checks out. My problem is that if I use .preventDefault() I can't get the form to submit with the chosen button value properly, without preventDefault() the animation doesn't occur always (I can get it to work sporadically but that isn't really an acceptable solution).
Just to be clear, the desired behavior is to detect a form submission with an event listener, execute an animation upon submission, and redirect the page while sending the value of the button that was selected via POST to the next page.
I tried

using $("input").click()
using $("form").submit()

Here is the HTML I was Using to Experiment
<!DOCTYPE html>

  <meta charset="utf-8">

  <meta name="viewport" content="width=device-width, initial-scale=1.0">

<?php
  if(isset($_POST['my_button'])){
    echo $_POST['my_button'];
  }
?>

<form id="ver_form" method="post" action="">
  <input type="submit" value = "Button No. 0" name = "my_button">
  <input type="submit" value = "Button No. 1" name = "my_button">
  <input type="submit" value = "Button No. 2" name = "my_button">
  <input type="submit" value = "Button No. 3" name = "my_button">
</form>

Answer: First a warning: If you're doing this on a form with target="_blank", this may well trigger the pop-up blocker of the user's browser, because it tries to open a window from code that isn't running in immediate response to a user event.
But assuming you're staying in the same window: A combination should do it:

Remove the name of your submit buttons entirely.
Add a type=hidden field with name=my_button
On a click of a submit button, set the form's my_button hidden field to the button's value.
Use your example submit handler but change how you submit the form after the end of the animation to:
form[0].submit();
//  ^^^---- note

form.submit() calls jQuery's submit method, which will re-trigger the submit event. form[0].submit() calls the DOM form element's submit function, which does not re-trigger the submit event.

So combining the click and submit handlers:
$(function(){
  var form = $("form");
  // On a click on a submit button, set the hidden field's value
  form.find("input[type=submit]").on("click", function() {
    form.find("[name=my_button]").val(this.value);
  });
  // On form submit...
  form.submit(function(e){
    // Prevent the submission
    e.preventDefault();
    // Start the animation
    $("#square").toggle(100,function(){
      // It's done, do the submission NOT with jQuery's `submit` function
      form[0].submit();
    });
  });
});

With this updated HTML:
<input type="submit" value = "Button No. 0">
<input type="submit" value = "Button No. 1">
<input type="submit" value = "Button No. 2">
<input type="submit" value = "Button No. 3">
<input type="hidden" name = "my_button">

Complete example, doing a GET to google.com using q instead of my_button so we see the result in their search page based on which button you press:
Live Copy on JSBin
<!DOCTYPE html>

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Example</title>

<form action="http://google.com/search" method="get">
<input type="submit" value = "Kittens">
<input type="submit" value = "Puppies">
<input type="submit" value = "Unicorns">
<input type="submit" value = "Bunnies">
<input type="hidden" name = "q">
</form>

I'm the square


AJAX Jquery url not working

Question: I have a strange problem with Jquery Ajax with the following code.
Situation 1:
function leuk(decrease_id, user_id) {
    $.ajax({
        type: "POST",
        url: 'http://schoolprove.nl/nieuw/index.php/leerlingen/checkvoortgang/',
        data: 'decrease_id=' + decrease_id + '&user_id=' + user_id,
        success: function (msg) {
            $('#output').html(msg);

        }
    });
}

Situation 2
function leuk(decrease_id, user_id) {
    $.ajax({
        type: "POST",
        url: '/nieuw/index.php/leerlingen/checkvoortgang/',
        data: 'decrease_id=' + decrease_id + '&user_id=' + user_id,
        success: function (msg) {
            $('#output').html(msg);

        }
    });
}

The AJAX url works sometimes whith http:// and sometimes without. I build and error catch when a error occured. This works very well at IE but Firefox doesn't give a error. So at some computers with Firefox this will not work. It is very strange and i don't know why it will not work.
Situation 1: Works sometimes
Situation 2: Works sometimes
Sometimes situation 1 works and ad a other computer situation 2 works, WHY?
Anybody know how to solve?
Thank you very much!!
Comment: Do you mean when you include the full url with `http://` it does not work? Because this will be cause by browser security. You can not perform AJAX cross domain therefor you have to use a relative path such as `/something`, `./something` or `../something`.
Answer: Redirect your domain like this tonerize.com to www.tonerize.com will solve this issue
please read this http://en.wikipedia.org/wiki/Same_origin_policy. for more information
Answer: Is your ajax file located on some other server?
If no then, you need not specify the the whole path for url.
Its enough if you use
url: 'ajaxfilename.php' //depending on the folder the file is located
Comment: Thanks for your your help! The file located on the same server.When i use http://website/filename it works, but on a other computer it doesn't work and then i have to use /filename. So when i use http:// It works, but on a other computer it will work without http://. i can not use one if them. I like t know why that changes on different computers.
Answer: You can not use a path such as this for AJAX.
http://something.com/file.php

It has to be relative to your file and located on your server like to.
/file.php

I am not quite sure what your problem is though, your question does not provide any error information.
Comment: Thanks for your your help! The file located on the same server.When i use website/filename it works, but on a other computer it doesn't work and then i have to use /filename. So when i use http:// It works, but on a other computer it will work without http://. i can not use one if them. I like t know why that changes on different computers.
Comment: Are the computers running different operating systems or browsers?
Answer: I found the solutions it is causing due to cache, try to disable the cache and add the random value in your query string.
function leuk(decrease_id,user_id)
              {
                $.ajax({
                    type: "POST",
                    cache:fale,
                    timeout:10000,
                    url: '/nieuw/index.php/leerlingen/checkvoortgang/?rnd='+Math.random(),

                    data: 'decrease_id='+decrease_id+'&user_id='+user_id,
                    success: function(msg){
                        $('#output').html(msg);

                }
                });
             }

AJAX Jquery url not working


Where should I go to learn about non-Western scales (particularly Turkish & Greek)

Question: Apart from Turkey and Greece, I mean.
I'm looking for fairly abstract musicological and comparative descriptions, not "how to play"-style information. Particularly interested in departures from the well-tempered 12-semitone "Western basic" system.
Are there for instance standard texts that a musicology student would be expected to read?
Comment: I'm aware this is pretty open-ended. Suggestions for narrowing it down (or edits) gratefully received.
Comment: One way is to restrict it to a specific kind of music.
Comment: Apart from or particularly Turkish and Greek scales? I'm not sure which you mean. Greek scales for one are very much Western - the Western scales today descend from the Ancient Greek modes (although many were dropped during the medaeval and Renaissance periods).
Comment: Noldorin, Turkish music often departs from 12-tone equal temperament. The lead instrument, the *oud*, is like a guitar with no frets, and people who play it don't stick to the Western modes and don't stick to 12 equal intervals in an octave either.
Comment: Noldorin, see my answer on the Holdrian Comma. Turkish scales need a certain note with an interval of a quarter-tone from its nearest neighbor. Those don't exist on the piano or guitar.
Comment: What do you mean with "where should I go"? I know of a few music institutions in Greece where you can learn Greek and Turkish music (and even some other world music). If you're asking for texts, or suggestions in finding a teacher (which I highly suggest), that's another thing.
Answer: John Coltrane famously studied Nicolas Slonimsky's Thesaurus of Scales and Melodic Patterns and using eastern and exotic scales in his solos.  I believe this text is supposed to contain such scales, but I don't have a copy and can't verify that definitely, or that it will specify which scales come from where.
Yusef Lateef's Repository of Scales and Melodic Patterns appears to be a competing volume of a similar nature. and if you're interested in scales and scale theory in general, Masaya Yamaguchi does something interesting here: The Complete Thesaurus of Musical Scales.  It is clearly written with jazz in mind but may yield some interesting fruit to you.
You are asking for texts that a musicology student my be expected to read.  So ask a professor of musicology (musicologist)! If you're looking for a book specifically devoted to non-western scales you'll need the help of someone who teaches (or has taken if you aren't lucky finding a teacher) a region specific musicology course.  I know there are Eastern European Music and Music in Asia courses so you should be able to find whatever you need if Encyclopedias and Thesauruses of scales are too general for you.  Otherwise, go big!  Check a few of those out from a library to see if they have what you need, then buy it if you need it to be in your library.  Good luck!
Answer: Here are two links that you might find useful: Turkish Music Wikipedia page and Turkish Music Portal.
Here are some books I found (some are in Turkish):

Turk musikisi nazariyati dersleri (in Turkish, translation of the title: Lectures on Turkish Music Theory)
The Garland Encyclopedia of World Music: The Middle East

There are quite a number different kinds of Turkish music. You have be more specific about the type of the music you are interested in to get more specific answers.
Comment: Well, they didn't directly help (lots of sociological context in the links, but not much technical information). But it seems what I was looking for is [makam](http://en.wikipedia.org/wiki/Makam) theory. If you update your answer to link it I'll accept it.
Comment: (Forgot: any equivalent for Greek? Wikipedia redirects δρόμοι to the makam page, which is an answer of a sort I suppose.)
Comment: I think makam is not specific to Turkish music (it is also used in Persian and Arabic traditional music), so I think yes.
Comment: I think it would be better if you post an answer in place of me updating mine, since you have find the answer for your question yourself. :)
Comment: Fair enough -- thought I'd give you the credit since you got me on the right track, but if you don't mind then I'll self-answer instead.
Answer: The Wikipedia page on makam theory seems to be a good beginning.
Comment: This is a self-answer and pretty limited. If anyone wants to fill it out with more detail I'll happily accept a different answer.
Comment: I know it has been quite some time, but if you can give me more details I might look it up for you. (As being turkish in TUDelft and having Greek friends all over ;).
Answer: I don't know if they sell abroad but you may read Turkish Music Makam Guide.
Answer: Holdrian Comma
This is the famous musical interval of 22.6 cents that crops up frequently in Turkish and Arabic music. The Makam references posted here will explain how the Holdrian Comma is used. But you need an instrument capable of playing notes based on factors of this interval, which is not used in Western music.
Extra frets for notes not found in Western music
I am told that many fretted instruments in this part of the world have an extra fret at certain positions to enable playing an interval of approximately a quarter-tone in certain keys.
I found a Web site that explains, in English, the frets, intervals and tunings used on the Turkish saz, a popular fretted string instrument. Here is a quote:

If you are used to a guitar or other western string instrument, first
  realize that the saz has extra frets for notes not found in western
  music. Most of these are "about halfway" between other notes that
  western music does use.
Answer: 'Where' to go to learn scale tunings? Two places named 'pure/just' and 'tempered' in the territory named 'practice' on a map named 'theory', where people map the territory and make territory from map.
Two major PRACTICAL approaches to musical scales are pure tuning and tuning by tempering. Both can involve acoustic/auditory beat: the first approach choose scale pitches to minimize it; the second makes a number of 'practically-the-same' scale steps out of some musical interval by adjusting or even maximizing it. Timbre is of importance to both because choice of timbre can change the sensation of beats too (yet, the need for lowering cognitive dissonance by pitch choices remains). Human voices and some instruments are capable of an 'adaptive' approach 'in-between'.
Two major THEORETICAL approaches to musical scales are Just Intonation (JI) and Equal Temperament (ET). The first approach chooses scale pitches with 'integer frequency ratio' and the second with (mathematical) 'equal division' of an interval (most usually an octave, but not necessarily). The first approach usually is supposed to involve 'small integer' ratios because of its practical roots in pure tuning; however, it is not unusual at all to see just intonation theorist to report their results in terms of ratios of 'really big numbers'. The second approach uses the syntax of enharmonics to create semantically synonyms of musical intervals, perhaps expressed in cents (sometimes millioctave).
In theory, ET intervals are approximations of pure intervals. In practice, JI intervals are interpretations of tempered intervals. In theory, practice follows theory. In practice, theory follows practice.
Into these 'two places to learn scale tuning', you may start exploring 'non-western' theory and practice of these people:

Ozan Yarman (on Rauf Yekta, etc.) for the tempered approach
Stefan Pohlit (on Julien Weiss) for the just/pure approach
Answer: There are electronic musical instruments specifically marketed for Greek, Turkish, and Arabic music, utilizing modes and scales from those cultures as well as specific microtonal tuning (rather than the 12 equally-spaced pitches in an octave that we refer to as equal temperament).
You might be able to find owners manuals or documentation on these instruments that would explain the scales and tunings programmed into them.
I'm fairly certain you could find an affordable virtual instrument for your computer that could reproduce these scales and microtonal tunings in a way that a piano or guitar cannot.
Here is one example from GeneralMusic, an Italian company.

Genesys Pro Oriental is the new GEM multimedia workstation explicitly
  developed for the music of Middle East and Mediterranean countries.
Featuring the exclusive and advanced technical characteristics that
  have made the Genesys one of the most popular keyboards in the world,
  the new Genesys Pro Oriental includes 128 new styles and over 200
  hi-quality oriental sounds and percussions originating from different
  cultures such as Arab, Greek, and Turkish designed in collaboration
  with the top musicians from this sector. Genesys Pro Oriental includes
  some important features that fulfil oriental music requirements, such
  as a joystick for pitch and modulation and programmable Arabic scales,
  assignable to the programmable pads. For the most demanding musicians,
  the external module AS-1 can be easily connected, allowing to create,
  save and recall Arabic scales and microtuned notes.
Main features: 128MB RAM memory (64MB internal sounds + 32MB new
  sounds + 32MB user samples) 256 Factory Presets (including 200
  hi-quality oriental sounds) and 256 User Presets; 64 notes polyphony
  256 Factory Styles (including 128 new oriental styles) and 64 User
  Styles Built-in CD player/burner Internal 20GB Hard disk; sampler and
  hard disk recording functions (mono/stereo) Vocal genius with separate
  EFX for the microphone Wide LCD graphic display (320 x 240)
  Pitch/modulation joystick new software functions: Edit Parts functions
  (L+R Mode, Portamento, Legato), MultiPedal Mode, new Play List
  function, and others...
By merging the exceptional performances of the Genesys series with the
  versatility of the AS-1 module, with Genesys Pro Oriental you will
  discover the fascinating world of oriental music.


O que é Null Byte Injection? Como evitá-lo?

Question:
O que seria esse Null Byte Injection?
Como evitá-lo?
Answer: É o envio de um byte nulo (0) como um texto que mais tarde será usado em alguma parte da aplicação que provavelmente dará acesso a algum recurso que não deveria ser acessado.
Como é comum strings serem tratadas com uma sequência de caracteres terminadas com um nulo, isto faria que operações de segurança que adicionam um texto protetor na string recebida pela aplicação externamente não considere este texto, já que as funções de comparação de textos param quando encontram um nulo.
Isto é comum nas funções padrões do C (existem algumas novas que não sofrem deste problema). Por isto verificações ou manipulações extras devem ser feitas antes da utilização de textos de origem externa. Como tudo de origem externa.
Linguagens que se valem destas funções sem fazer nenhuma verificação ou manipulação extra sofrem do mesmo problema. PHP sofria com isso no passado, mas hoje sabe como evitar isto em suas funções críticas.
A solução costuma ser simples, já que um nulo raramente é algo correto quando vem de fonte web, onde é mais comum o tipo de ataque.
No fundo, esta preocupação específica não é necessária. Se você valida ou limpa dados externos corretamente, como sempre deve fazer, não tem este problema. Este é só um dos caracteres que não devem ser aceitos.
Coloquei no GitHub para referência futura.
Comment: Apenas complementando: a referência que me fez fazer a pergunta foi no [Manual do PHP](http://php.net/manual/en/security.filesystem.nullbytes.php), que fala sobre Null Byte Injection, justamente por conta de o PHP usar internamente o C. Parece que o Bug foi corrigido nas versões superiores ao PHP 5.3.4, de acordo com [essa resposta](http://security.stackexchange.com/questions/48187/null-byte-injection-on-php).


Need help with finding length of sides and angles of a triangle in upper half plane model

Question: The given points are $i, 3i, 1 + 2i$
I know that the distance for points on a vertical line can be found by using the formula
$$\ln\left|\frac{y_2}{y_1}\right|$$
So the distance between points $ i$ and $3i$ would be $\ln 3$. How can I get the length between the other sides and the angles of the triangle?
Comment: @Kaster - If I'm not wrong, you're describing Euclidean space. I was looking for the length in upper half plane hyperbolic model.
Comment: @WillJagy I asked because in that wiki-article there's an expression for distance between two points.
Comment: That's some weird metric. Usually distance between points $z_1$ and $z_2$ is $d = |z_2-z_1| = \sqrt{\left(x_2-x_1\right)^2 + \left(y_2-y_1\right)^2}$, and for the points on vertical line it's $d =|y_2-y_1|$.
Comment: All the conformal(holomorphic) bijection of upper half plane to itself doesn't change the length,i.e., they're isometry. So you could after an isometry to take the circle passing through i and 1+2i with center at real axis to a vertical line.
Comment: @user74938 Oh, I overlooked that part. I'm indeed not familiar with that concept, but just in case, is [this](http://en.wikipedia.org/wiki/Poincar%C3%A9_half-plane_model) what you mean by upper half-plane model?
Comment: @Kaster, that's it. I show how to parametrize the geodesics in my answer.
Comment: @Kaster, yes, I've never memorized that. On the other hand, I went through the geodesic equations for that metric from start to finish, and I have memorized the unit speed parametrizations. Note that Mobius transformations, real coefficients and positive determinant, are isometries.
Answer: The two flavors of unit speed geodesics, in the upper half plane, are the one you know, $$ \alpha(t) = A + i e^t,    $$ for real constant $A$, and
$$ \beta(t) =  A + B \tanh t + i B \operatorname{sech} t  $$ for real constants $A,B$ with $B > 0.$
Since people do not appear to be familiar with the second type, I request that you ask your instructor about it.
My impression from MSE questions from the past week or two is that people are being taught that Möbius transformations (with positive matrix determinant and real entries) give isometries. If you apply the map $-1/z$ to the vertical line, $ \alpha(t) = A + i e^t,    $ you get one example of the second type, which travels along a semicircle with center on the real line. This can be moved about and $B$ changed with additional Möbius transformations.
You should be able to finish from here. You need to find the $A,B$ and two $t$ values along two circular arcs. The difference in $t$ values is the length of that arc in the model.
Or, you can use a Möbius transformation that maps two points to other points with the same real part, in which case you can use your little logarithm. Probably about the same amount of work.


Unity Prefab won't instantiate into the game scene

Question: Having a bit of trouble with unity. I have had two different builds for firing and movement systems, now I am porting them together although I encounter some issues when I do this. The 'bullet' prefab in the assets folder is asked to be spawned into the game scene but never is. But what is more intriguing is the other functions of the 'bullet' and script take place, so it is only the prefab not showing in the scene.
THe following is the code from the script which instaniates the prefab:
public bool isFiring; // Boolean to check if the player is firing
public bool isReloading = false; // Boolean to check if the player is reloading

public BulletController bullet; // Reference another script
public float bulletSpeed; // bullet speed - changed in bullet controller

public float timeBetweenShots; // time between shots can be fired
private float shotCounter; // Tempoary time holder - ensures no bullet spam

public Transform firePoint; // The fire point in the game attached to the gun

public static int ammoRemaining = 3; // Ammo left for the player to fire

public static int maxAmmo = 3;
public Text ammoText;

public Rigidbody cannonballInstance;
public BulletController projectile;

[Range(10f, 80f)]
public float angle = 45f;

// Use this for initialization
void Awake () {
    isReloading = false;
    timeBetweenShots = 0.3f;
    ammoRemaining = maxAmmo;
}

// Update is called once per frame
void Update () {

    if (ammoRemaining == 0 && isReloading == false)
    {
        StartCoroutine(Reload());

    }

    else if (isFiring == true && isReloading == false)
    {
        shotCounter -= Time.deltaTime;
        if(shotCounter <= 0 && ammoRemaining > 0 && isReloading == false)
        {
            shotCounter = timeBetweenShots;

            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            RaycastHit hitInfo;
            if (Physics.Raycast(ray, out hitInfo))
            {
                FireCannonAtPoint(hitInfo.point);
            }

            ammoRemaining -= 1;
            ammoText.text = "Ammo:" + ammoRemaining;

        }

    }
    else if (Input.GetKey(KeyCode.R))
    {
        StartCoroutine(Reload());
    }

    else
    {
        shotCounter = 0;

    }

}

private void FireCannonAtPoint(Vector3 point)
{
    Vector3 randomAccuracy;

    randomAccuracy = new Vector3(Random.Range(-2.0f, 2f), 0, Random.Range(-2f, 2f));

    var velocity = BallisticVelocity(point + randomAccuracy, angle);
    Debug.Log("Firing at " + (point + randomAccuracy) + " velocity " + velocity);

    Rigidbody rg = Instantiate(cannonballInstance, transform.position, transform.rotation);
    Debug.Log("Firing at" + transform.position);
    Debug.Log(rg.transform);
    BulletController newProjectile = rg.GetComponent<BulletController>();

    newProjectile.speed = velocity;
    Debug.Log(newProjectile.speed);

    // cannonballInstance.transform.position = transform.position ;
    // cannonballInstance.velocity = velocity;
}

private Vector3 BallisticVelocity(Vector3 destination, float angle)
{
    Vector3 direction = destination - transform.position; // get Target Direction
    float height = direction.y; // get height difference
    direction.y = 0; // retain only the horizontal difference
    float distance = direction.magnitude; // get horizontal direction
    float AngleRadians = angle * Mathf.Deg2Rad; // Convert angle to radians
    direction.y = distance * Mathf.Tan(AngleRadians); // set direction to the elevation angle.
    distance += height / Mathf.Tan(AngleRadians); // Correction for small height differences

    // Calculate the velocity magnitude
    float velocity = Mathf.Sqrt(distance * Physics.gravity.magnitude / Mathf.Sin(2 * AngleRadians));
    Debug.Log(velocity);
    return velocity * direction.normalized; // Return a normalized vector.

}

public IEnumerator Reload()
{
    isReloading = true;
    ammoText.text = "REL...";

    yield return new WaitForSeconds(2);
    ammoRemaining = maxAmmo;
    isReloading = false;
    ammoText.text = "Ammo:" + ammoRemaining;

}
}

Everything is the same in the two seperate version but it just the spawning in of the prefab which doesn't work.
Any ideas/suggestions are much appreciated.
Answer: From your code:
public Rigidbody cannonballInstance;

[...]

Rigidbody rg = Instantiate(cannonballInstance, transform.position, transform.rotation);

You are Instantiating a Rigidbody where I think you expect to instantiate a GameObject
try with:
Rigidbody rg = Instantiate(cannonballInstance.gameObject, transform.position, transform.rotation).GetComponent<Rigidbody>();

Comment: Even with the change the issues of not spawning still exists. I can a recoil as though it is being added by never added to the game hierarchy.