Takbeer and Rafa Yadain

Question: What is Takbeer and Rafa Yadain? Why we raise our hands till our ears to say Allahu Akbar. What this gesture symbolizes?
Comment: This question title suggests that rafa' al-yadain is a synonym of takbeer which is clearly misleading as except within prayer there's no connection between both. Further takbeer is a kind of dhikr and rafa' al-yadain is an act. Please learn your own religion before teaching others.
Comment: A.O.A
Brother if you read the answer carefully, I have explained Rafa yadain as an act or gesture and not as AllahuAkbar. Mistakenly in the title it is mentioned as "or" inspite of "and". However, both are necessary  in the completion of Rafa Yadain. Secondly, Dont become too harsh on others, because Islam always emphasis on constructive criticism. may be there is a proof reading mistake. Anyhow thanks for the correction.
Comment: I don't see any improvement here you still set an act equal to a dhikr! And Takbeer is not equal to rafa' al-Yadain. My understanding of constructive criticism is pointing at what is wrong and explaining why and I did so.
Comment: I think you have not read the whole answer. its not about Rafa Yadain is equal to Zikar. Its about the symbolical meaning of the gesture called Rafa Yadian. Anyhow. sometime, people make comment after reading the title only.
Comment: I've read your answer and question and still there's the issue that you don't really distinguish between rafa'a al-Yadayn as an act and saying Allahu akbar at the same time (which is a dhikr) or takbeer or as it is mostly known the takbeer at the beginning of the prayer act and dhikr which is also called takbirat al-Ihraam. And as long there's this ambiguity my position is clear.
Answer: Assalamualaikum,
The translation for the takbeer or takbir (AllahuAkbar) is Allah is the greatest. One form of takbeer is used when saying AllahuAkbar at the start of your salat. Another form of takbeer is said on eid day (AllahuAkbar, AllahuAkbar, La ilaha illalah, AllahuAkbar, AllahuAkbar, Wa lillah il Hamd)
Rafal yadain is something done in salat, before a person goes into ruku and after ruku. It's an act of sunnah performed by Prophet Muhammed PBUH. Some fiqh's deem it permissible whereas some do not, I cannot give information on this as I am not educated but I hope my answer has covered the question.
Answer: Our namaz starts with a Sunnah called Rafa Yadain, (Takbeer).
Have you ever thought consciously about this gesture called Rafa Yadain? that why we raise our hands almost to the ears by saying Allahu Akbar. (A confession about the magnification of Allah).
It can be understood through the example of a student in the class room, who raises his hand to show his presence or wants to answer or asks a question.
In the same way, Rafa yadain is a gesture towards Allah Subhan Tallah that I am standing empty handed in front of you with the confession that I am incapable of attaining anything without your help and support.  Now, I am fully attentive and ready for having conversation with you by putting all my love and soul into it.
Then we recite Allahu Akbar with the declaration of faith that we truly honored the greatness of Allah Subhan Tallah.
The words Allahu Akbar are a celebration of life, the first words, whisper in our ears when we born, we read in Azan, Prayers, Eid festivals, halal slaughtering of animas, in times of distress, joy, gratitude, battle and protest etc.
Anyhow, some Arab people make will that their hands must be kept outside their shroud (kafan) in the position of Rafah yadain in order to show their children that they are going to meet their Lord empty handed, irrespective of their wealth and bank balance, they have in their life. And this is way they make their children to understand the real meaning of Rafah yadain.
Now the point to think is that have you ever feel in this way while saying your prayer?

Takbeer and Rafa Yadain


What does the BFF item do?

Question: I've gotten the BFF item a couple of times, but so far I haven't noticed any effects that I could attribute to it specifically. The description just says "Your friends rule," which isn't very helpful. So, what does it do?
Answer: I know it makes your familiars bigger, which I assume also means they do more damage.  If you're curious for items in general, I would recommend looking the items up on this item database, as they have most of the items up there and will (hopefully) continue adding them.
Comment: The synergies section of that site at least is out of date for rebirth. For instance, it lists Spoon Bender as having no synergy with Brimstone, and my giant purple homing blood beams strongly disagree.
Comment: The synergies tab is for vanilla.  The rebirth tab is the one with info on rebirth items.

What does the BFF item do?


Covariant derivatives of the frame field, are they the same?

Question: There is a exterior covariant derivative
$$
D \alpha_a = d \alpha_a -\omega^b{}_a \wedge \alpha_b\;, \tag 1
$$
and another $D$ in the vierbein postulate
$$
D_\mu e_{I\alpha}=\partial_\mu e_{I\alpha}-\omega_\mu{}^J{}_Ie_{J\alpha}-\Gamma_\mu{}^{\lambda}{}_\alpha e_{I\lambda}=0\;.\tag 2
$$
The question is: Do they the same thing?
Comment: Would [math.se] be a better home for this question?
Comment: No. The clue is in the term "exterior differential" - which is a skew differential. Regarding the orthogonal moving frame, $e_{I\alpha}$ - which I presume is the frame basis vector and not a $2$-form - which typically should be written as $e_{a}(x)=e^{i}_{a}(x)\frac{\partial}{\partial x_{i}}$ where $a$ is the frame index and $i$ is the tangent space index.
Answer: You first statement looks like the definition of the torsion form
$$
D{\bf e}^{*a}\equiv  d{\bf e}^{*a}+ {\omega^a}_b \wedge {\bf e}^{*b}= T^a.
$$
The second is a confused aspect of the ordinary covariant derivative and has nothing to do torsion or metricity.
The $e_a^\mu$ and so on are just an array of numbers. Their covariant derivative is just the ordinary partial derivative. The expression you have is therefore not the covaraint derivative of $e^\mu_a$. It is the geometric basis vectors ${\bf e}_a$ or ${\boldsymbol \partial}_\mu$ for the tangent space, or ${\bf e}^{*a}$, or $dx^\mu$  for the cotangent space that need the connection forms ${\omega^b}_{a\mu}dx^\mu$ or ${\Gamma^\lambda}_{\nu\mu}dx^\mu$.
In particular the  "vierbein postulate" is not a postulate. It is an identy that always holds. It is in fact an  appallingly  bad and confusing name for the  formula for converting the  covariant derivative $\nabla_X\equiv X^\mu \nabla_\mu$  from its definition in terms of a  frame-field
$$
\nabla_X {\bf e}_a= {\bf e}_b{\omega^b}_{a\mu}X^\mu
$$
to its definition in terms of the coordinate basis
$$
\nabla_X {\boldsymbol \partial }_\nu= {\boldsymbol \partial }_\lambda {\Gamma^\lambda}_{\nu\mu} X^\mu.
$$
In each case $\nabla_X$ is the same object. So by expanding
$$
{\bf e}_a =  e^\nu_a {\boldsymbol \partial}_\nu
$$
and   using   the derivation property (Leibnitz rule) of $\nabla_X$, we   evaluate
$$
\nabla_X {\bf e}_a =  e_b^\nu {\omega^b}_{a\mu}X^\mu{\boldsymbol \partial}_\nu
$$
in the equivalent form
$$
\nabla_X {\bf e}_a  = X^\mu (\partial_ \mu  e^\nu_a){\boldsymbol \partial}_\nu +
X^\mu e^\nu_a (\nabla_\mu {\boldsymbol \partial}_\nu)\\
=X^\mu (\partial_\mu e_a^\nu+ e^\lambda_a {\Gamma^\nu}_{\lambda \mu}){\boldsymbol \partial}_\nu.
$$
By comparing coefficients of $X^\mu {\boldsymbol \partial}_\nu$, we read off that
$$
\partial_\mu e_a^\nu+ e^\lambda_a {\Gamma^\nu}_{\lambda \mu}- e_b^\lambda {\omega^b}_{a\mu}=0.
$$
Your equation (2) is just an example of this manipulation for the co-frames ${\bf e}^{*a}= e^{*a}_\mu dx^\mu$.
Answer: As far as I known the anti-symmetric part of (2) equals to (1).


Complex equation proof of existence of roots

Question: How can we try to prove that the equation
$$
\left(\bar z+\frac{i}{z} \right)^{16} +\left(\bar z-\frac{i}{z} \right)^{16} =0
$$
has any solution (where $\bar z$ is a conjugate of $z$).
Comment: I changed your notation to the standard $\bar z$ for conjugation.
Answer: $$\begin{aligned}\left(\bar z+\frac{i}{z} \right)^{16} +\left(\bar z-\frac{i}{z} \right)^{16} &= z^{-16}\left[\left(\bar z z+i \right)^{16}+\left(\bar z z-i \right)^{16}\right]\\&=z^{-16}\left[\left(|z|^2+i \right)^{16}+\left(|z|^2-i \right)^{16}\right]\\&=z^{-16}\left[\left(|z|^2+i \right)^{16}+\left(\overline{|z|^2+i }\right)^{16}\right]\end{aligned}$$
Set $w=|z|^2+i=re^{i\varphi}.$
Solve $$w^{16}+\overline{w}^{16}=0$$ or equivalently (because clearly $r\neq0$)$$e^{16i\varphi}+e^{-16i\varphi}=0$$ or $$\cos (16\varphi)=0,$$ which is easy to solve.
Answer: If $\left(\bar z+\frac{i}{z} \right)^{16} +\left(\bar z-\frac{i}{z} \right)^{16} =0$ then we can write for $z \neq 0$
$\left(z \bar z+i \right)^{16} +\left(z \bar z-i \right)^{16} =0$
If we write $z = \rho e^{i \phi}$ then $z \bar z = \rho^2$ so the previous equation can be written $(\rho^2 + i)^{16} + (\rho^2 - i)^{16} = 0$
On the complex plane these are two vectors symmetric with respect to the real axis.

Two complex numbers like this have a 0 sum only when they are aligned with the imaginary axis. Moreover the 16th power are vectors rotating clockwise and counterclockise 16 times.
So the geometric condition for the $\alpha$ angle will be $\rho^2 \tan \alpha = 1$ and moreover $16 \alpha = \frac{\pi}{2}$ hence $\alpha = \frac{\pi}{32}$
So the magnitude must be $\rho = \sqrt{\frac{1}{\tan{\frac{\pi}{32}}}}$
In these conditions, the solution to the equation will be the set of complex numbers having magnitude $\rho$ computed as seen before, i.e. a circle around the origin of the complex plane.


Use MariaDB instead of MySQL in my Rails project

Question: How can I use MariaDB instead of MySQL in my Rails project?
When I try to install mysql2 gem it returns error,because mysqlclient was not found.
Here some solution, but I didn't found any libmariadbd-dev package on my openSUSE 12.3.
Comment: You should put your solution as an answer, then select it as the accepted answer.  Right now, this question shows up in the stats as being not-answered.
Answer: It doesn't look like openSUSE has a MariaDB client development package.  You must install  the libmysqlclient-devel package package.  Since MariaDB is tagged as a drop in replacement for MySQL, it would have to support the MySQL clients, though you may lose tiny bits of MariaDB improvements.
It appears that the mysql2 gem should function with the MariaDB client libraries.  Other options are hoping the mariadb-client package is enough, find a 3rd party package for the libraries or installing them yourself.
Update
There is now an MariaDB repository for openSUSE.  It includes a development package, and very good instructions.  Place the following in a file under /etc/zypp/repos.d/
# MariaDB 10.1 openSUSE repository list - created 2015-10-20 16:37 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/opensuse13-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Now you can run zypper install MariaDB-client MariaDB-devel

Your question isn't about Ubuntu, but I'm sure a lot of people Googling Ubuntu (or its derivatives like Mint) will land on this page.  In Ubuntu, you have to install all the packages using the MariaDB Foundation's ppa, but they include all the development libraries and support the 5.5, 10.0 and 10.1 releases.  Then you can install packages such as mariadb-server, mariadb-client, libmariadbclient-dev, and libmariadbclient-dev:i386 (32-bit client).
The instructions are simple and detailed on the site.  For example, installing just the 10.1 dev libraries in Ubuntu 14.04
sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
sudo add-apt-repository 'deb http://mirrors.syringanetworks.net/mariadb/repo/10.1/ubuntu trusty main'
sudo apt-get update
sudo apt-get install libmariadbclient-dev

Answer: On linux mint, I was able to install:
sudo aptitude install libmariadbclient-dev:i386 libmariadbclient-dev
Answer: For recent ubuntu 15.04 vivid and Debian 8.0 Jessie:
No need to install from a ppa (mariadb-server is included), but you have to install libmariadb-client-lgpl-dev and libmariadb-client-lgpl-dev-compat and configure the gem to use mariadb_config:
apt-get install mariadb-server libmariadb-client-lgpl-dev libmariadb-client-lgpl-dev-compat

gem install mysql2 -- --with-mysql-config=/usr/bin/mariadb_config

# or for bundler
bundle config build.mysql2 --with-mysql-config=/usr/bin/mariadb_config
bundle install

Comment: Also valid for Debian 8.0 Jessie. libmariadb-client-lgpl-dev-compat should really have a symlink for mariadb_config.
Answer: Probably you are getting error related with mariadb_config. Something like
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /home/dev/.rbenv/versions/2.1.5/bin/ruby extconf.rb --with-mysql-config=/usr/bin/mariadb_config
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Cannot find mysql_config at /usr/bin/mariadb_config
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.

You just need to go to /usr/bin directory and run this command

sudo ln -nfs mysql_config mariadb_config

This will solve your problem.
Answer: In Ubuntu 14.04.3 LTS I am able to install with sudo apt-get install libmariadbd-dev
I followed https://mariadb.com/kb/en/mariadb/installing-mariadb-deb-files/ to install MariaDB which adds apt repository for maria db.
Answer: As of Rails 5 (currently still in beta), MariaDB is officially supported, which I think should ease the implementation. Although I haven't tried it myself.
You can read about it in the blogpost on the Rails weblog:
http://weblog.rubyonrails.org/2016/4/16/this-week-in-rails-mariadb-action-cable-and-more/
Answer: While installing libmariadbd-dev package is the easiest way, in some OS or package managers it is not available.
For example on a mac with homebrew this is not available.
I found a workaround though.
To install gem mysql2 on a mac you need mariadb-connector-c in homebrew.
This package conflicts with Mariadb symlinks so you need to do:
brew unlink mariadb

brew install mariadb-connector-c

cd into the rails project directory

bundle install (or gem install mysql2)

brew uninstall mariadb-connector-c

brew link mariadb


How the IIS7 handle a auth module? Memory scope?

Question: As those who have worked on such a project you probably know this site:

Developing a Module Using .NET

In this article Mike Volodarsky created a very good post on how to create your own security authentication extension for the IIS7.
I took this and modified to my own need. I am fetching the basic auth credentials and call an external web service to authenticate the user from a different active directory domain.
This in principal works fine so far.
Calling the web service takes some time and each request, site, resource (image, stylesheet, javascript file, etc.) causes IIS7 to call the module and authenticate again.
I am not aware how the IIS7 handles this module so I decided to create a sql-table based security token with a ten minutes lifetime. So now my code checks if this token is available and grants acccess or if not, call the web service to authenticate again.
I developed everything and it works well. In production I ran into worse timeouts and found out that my sql connection is the problem. The connection pool overloaded. I fixed this with a bad workaround to set the pool size to very large number.
Now here is my problem / question:
Does anyone know if this module will stay in memory in any way so I can store a token in memory - application pool scope? The idea is to store the tokens in memory while the application runs. But I can't find any information to help me to find out how the module is handled in IIS7 and if my idea is a solution for the problem.
Answer: You wouldn't keep the module itself in memory, but what's common would be to use an encrypted cookie or session to maintain the creds.  It sounds like you're conflating problems a bit, though.  Your module sounds like it can (and should) be handled by a custom Membership Provider, nto a custom authentication module.
Assuming (based on your post) that you're taking a person's username and password over the web (ostensibly from a web form), you should use the Forms Authentication provider in ASP.NET, and then implement a customMembership provider for doing the actual creds checking.  The Forms Atuh provider can then handle maintaining the auth token between your app and the user's browser.
Comment: Well I thought about it, too, but I really need basic auth at all for some application reasons. You wrote that I use a encrypted cookie or session, that is exact the point, it is possible to store information in a likely session/application scope?
Comment: yes, you can use session or app scope; I'd probably use session for this.
Comment: when i access the HttpApplication application = (HttpApplication)source;
            HttpContext context = application.Context; var test = (String)context.Session["LCID"];   I get a null reference, so it seems there is no session available?!
Comment: I have no idea where in the code you are.  You said you're in a module?  the module should have access to the app as a parameter, see here:  http://support.microsoft.com/kb/307996
Comment: I don't have a session because in my case (using old classic asp app after auth) I just had application_start event. So I decided to store encrypted data there, that works fine to me, so my problem is solved at all. Learned a lot about modules now at all, so thx a lot to all that helped me.
Comment: ah... I had no idea you were using classic ASP in the mix, that definitely changes things.  Glad you worked through it, though!


import bulk data into MySQL

Question: So I'm trying to import some sales data into my MySQL database. The data is originally in the form of a raw CSV file, which my PHP application needs to first process, then save the processed sales data to the database.
Initially I was doing individual INSERT queries, which I realized was incredibly inefficient (~6000 queries taking almost 2 minutes). I then generated a single large query and INSERTed the data all at once. That gave us a 3400% increase in efficiency, and reduced the query time to just over 3 seconds.
But as I understand it, LOAD DATA INFILE is supposed to be even quicker than any sort of INSERT query. So now I'm thinking about writing the processed data to a text file and using LOAD DATA INFILE to import it into the database. Is this the optimal way to insert large amounts of data to a database? Or am I going about this entirely the wrong way?
I know a few thousand rows of mostly numeric data isn't a lot in the grand scheme of things, but I'm trying to make this intranet application as quick/responsive as possible. And I also want to make sure that this process scales up in case we decide to license the program to other companies.
UPDATE:
So I did go ahead and test LOAD DATA INFILE out as suggested, thinking it might give me only marginal speed increases (since I was now writing the same data to disk twice), but I was surprised when it cut the query time from over 3300ms down to ~240ms. The page still takes about ~1500ms to execute total, but it's still noticeably better than before.
From here I guess I'll check to see if I have any superfluous indexes in the database, and, since all but two of my tables are InnoDB, I will look into optimizing the InnoDB buffer pool to optimize the overall performance.
Comment: I do know this question was posted ages ago, but i have to say that the difference between one bulk INSERT and LOAD DATA INFILE is the time saved. I went from 30 secs / more with INSERT to about 10 secs loading a ~11000 line with 30 columns CSV file.
Answer: LOAD DATA INFILE is very fast, and is the right way to import text files into MySQL.  It is one of the recommended methods for speeding up the insertion of data -up to 20 times faster, according to this:
https://dev.mysql.com/doc/refman/8.0/en/insert-optimization.html
Assuming that writing the processed data back to a text file is faster than inserting it into the database, then this is a good way to go.
Answer: LOAD DATA or multiple inserts are going to be much better than single inserts; LOAD DATA saves you a tiny little bit you probably don't care about that much.
In any case, do quite a lot but not too much in one transaction - 10,000 rows per transaction generally feels about right (NB: this is not relevant to non-transactional engines). If your transactions are too small then it will spend all its time syncing the log to disc.
Most of the time doing a big insert is going to come from building indexes, which is an expensive and memory-intensive operation.
If you need performance,

Have as few indexes as possible
Make sure the table and all its indexes fit in your innodb buffer pool (Assuming innodb here)
Just add more ram until your table fits in memory, unless that becomes prohibitively expensive (64G is not too expensive nowadays)

If you must use MyISAM, there are a few dirty tricks there to make it better which I won't discuss further.
Answer: Guys, i had the same question, my needs might have been a little more specific than general, but i have written a post about my findings here.
http://www.mediabandit.co.uk/blog/215_mysql-bulk-insert-vs-load-data
For my needs load data was fast, but the need to save to a flat file on the fly meant the average load times took longer than a bulk insert.  Moreover i wasnt required to do more than say 200 queries, where before i was doing this one at a time, i'm now bulking them up, the time savings are in the region of seconds.
Anyway, hopefully this will help you?
Comment: Lese: This is to do with standard deviation.  My understanding of standard deviation is it shows how much variance there is from the average. (Excel did the calculation for me).  My point was the standard deviation for bulk was less than that of load data.  This to me meant that BULK was most consistantly faster.  Which for me was the most important factor when deciding about this.  Mainly because this was working on a live site.

Hopefully this makes sense?  Have a look here for more information: http://en.wikipedia.org/wiki/Standard_deviation
Comment: Interesting. This is definitely good to know for many use cases, though I'm a little confused as to how you got the 0.0013sec figure. (I'm not good with statistics.)
Answer: You should be fine with your approach.  I'm not sure how much faster LOAD DATA INFILE is compared to bulk INSERT, but I've heard the same thing, that it's supposed to be faster.
Of course, you'll want to do some benchmarks to be sure, but I'd say it's worth writing some test code.

import bulk data into MySQL


Prove that $f(x)=-\exp(-g(x))$ is convex if $g(x)$ is convex...

Question: Show that the following function $f:\Re^{n}\rightarrow \Re$ is convex.
\begin{equation}
f(x)=-\exp(-g(x))
\end{equation}
where $g:\Re^{n}\rightarrow \Re$ is a twice differentiable function with convex domain and satisfies
\begin{eqnarray*}
\left(
\begin{array}{cc}
\nabla^{2} g & \nabla g  \\
\nabla^{T} g & 1 \\
\end{array}
\right)\geq 0 \;(semidefinite\; positive\; matrix)
\end{eqnarray*}
for $x\in Dom$ $g$.\
My idea to prove that is to show that the Hessian of $f$ is a semidefinite positive matrix. So, I computed the Hessian of $f$
\begin{eqnarray*}
\nabla^{2}f(x)&=&-\exp(-g(x))\left(
\begin{array}{cccc}
g_{x_{1}}^{2}-g_{x_{1}x_{1}} & g_{x_{2}}g_{x_{1}}-g_{x_{2}x_{1}} & \ldots & g_{x_{n}}g_{x_{1}}-g_{x_{n}x_{1}}  \\
g_{x_{2}}g_{x_{1}}-g_{x_{2}x_{1}} & g_{x_{2}}^{2}-g_{x_{2}x_{2}} & \ldots & g_{x_{n}}g_{x_{2}}-g_{x_{n}x_{2}}  \\
\vdots & \vdots & \ddots & \vdots \\
g_{x_{n}}g_{x_{1}}-g_{x_{n}x_{1}} & g_{x_{2}}g_{x_{n}}-g_{x_{2}x_{n}} & \ldots & g_{x_{n}}^{2}-g_{x_{n}x_{n}}
\end{array}
\right)\\
&=&\exp(-g(x))\left( \nabla^{2}g-\nabla g \nabla^{T}g\right) .
\end{eqnarray*}
Until now I havent been able to use the hipotesis to prove what I want, just that $\nabla^{2}g$ is a semidefinite positive matrix. Also, I know that $\nabla g \nabla^{T}g$ is a semidefinite positive matrix (but I dont know if this result is useful). Thanks for the help.
Comment: Your notation is strange.  $\nabla^2$ is the Laplacian, not the Hessian.
Comment: @RobertIsrael the notation $\nabla^{2}$ for the Hessian is quite common in optimization despite the conflict with it's use for the Laplacian operator.
Comment: If "$g$ convex" is part of your hypotheses, then you don't need all those derivatives (i.e you don't need to assume differentiability of $g$). The title of your question and it's body don't quite match. Please clarify.
Comment: @dohmatob  It is not literally part of the hipotesis. But, from the hipotesis I proved that $\nabla^{2}g$ is a semidefinite positive matrix which implies that $g$ is convex.
Comment: 'm lost. How do you go about proving that a hessian is p.s.d if you don't **assume** that the function in question is differentiable (in fact twice!), so that you can even form the hessian, to begin with ?
Comment: @dohmatob I am sorry, I did not write the complete hipotesis, but $g$ is twice differentiable
Answer: In the one-variable case, what you need for a function $-\exp(-g(x))$ (where $g$ is twice differentiable) to be convex is $g''(x) \ge g'(x)^2$.  Thus in the many-variable case, you need $$ \dfrac{d^2}{dt^2} g(x_t) \ge \left(\frac{d}{dt} g(x_t)\right)^2 $$
on every line $x_t = a + b t$ in the domain.  This translates to
$$ b^T H b \ge (b \cdot \nabla g)^2 = b^T (\nabla g) (\nabla g)^T b \ \text{for all } b$$
where $H$ is the Hessian of $g$, and that is equivalent to positive semidefiniteness of $H - (\nabla g) (\nabla g)^T$.
Answer: You don't need differentiability of $g$...
Lemma: If $g: \mathbb R^n \rightarrow (-\infty, +\infty]$ is convex and $h: \mathbb R \rightarrow \mathbb R$ is convex non-decreasing, then $h \circ g$ is convex.
Proof:
Let $x, y \in \mathbb R^n$ and $t \in [0, 1]$. Then
$$
\begin{split}
(h \circ g)(tx + (1-t)y) &:= h(g(tx + (1-t)y)) \\
&\le h(t g(x) + (1-t)g(y))\text{ ($g$ convex, $h$ non-decreasing)}\\
&\le t h(g(x)) + (1-t)h(g(y))\text{ ($h$ convex)} \\
&=: t(h \circ g)(x) + (1-t)(h \circ g)(y),
\end{split}
$$
showing that $h \circ g$ is convex.$\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad  \Box$

Now apply the lemma with $h(a) := -\exp(-a)$.
Comment: I never said you should use $h(a) \equiv \exp(-a)$. I said $h(a) = -\exp(-a)$. Mind the outermost **minus (-)** sign...
Comment: What do you mean by "$h(a) = -\exp(-a)h(a)$" ? $h(a):= -\exp(-a)$ defines a convex function, definitely. What's your critique about precisely ?
Comment: I realize that $h(a)=-exp(−a)h(a)=exp(−a)$ is concave, so I cannot applied the Lemma
Answer: Let $x\in \Re^{n}$ then by the hipotesis
\begin{eqnarray*}
(x^{T},-x^{T}\nabla g)
\left(
\begin{array}{cc}
\nabla^{2} g & \nabla g  \\
(\nabla g)^{T} & 1 \\
\end{array}
\right)
\left(
\begin{array}{c}
x \\
-(\nabla g)^{T} x \\
\end{array}
\right)=x^{T}\nabla^{2}gx-x\nabla g(\nabla g)^{T}x\geq 0
\end{eqnarray*}
since $x\in \Re^{n}$ is arbitrary, then the Hessian of $f$ is positive-semidefinite which implies that $f$ is convex.


Who were the witnesses at the marriage of Padmé Amidala and Anakin Skywalker?

Question: Who were the witnesses at the marriage of Padmé Amidala and Anakin Skywalker?
Comment: Does a marriage in the Star Wars universe require witnesses to be valid?
Comment: The presiding robot minister? Everyone who watched the movie? R2-D2 and C-3P0?
Comment: They really married.. I thought, they were in Live-in-Relationship...
Answer: If you are looking for who served as 'Witnesses' in the legal sense, no one, really, unless you are counting the droids, C3P0 and R2D2.
Per the old Starwars Databank, the ceremony was performed by Maxiron Agolerga, the Pontifex of the Brotherhood of Cognizance, but only the droids were in attendance, and Maxiron was advised that he had to keep the knowledge of the marriage to himself.
I'm not sure it counted as legal in most senses; they used false names:

Since Agolerga had agreed to the request, the two droids came to pick him up in a gondola speeder and brought him to Varykino across the Lake Country. The Pontifex, dressed in his holy purple garments, met the beautiful young couple that just wanted to be known as Veré and Set, two eternal lovers from an old Futhork legend.
The matrimony was short and by the power invested by the Pontifex, Set and Veré were pronounced husband and wife. When Agolerga was about to leave, the groom waved his hand and spoke kindly to him that nobody could ever be told about this marriage. And thus the only remaining evidence was an official scroll containing their "names" to be classified in the archives of the Brotherhood.

But lets be honest- I don't think they cared.   Witnesses and names are part of how the marriage is made legal; they didn't care about they legal status of the marriage, they were getting married 'for them.'
I don't know how 'canon' this is considered, but I believe it is consistent with what we saw in the movies.
I believe there may be more info in the Novelization of Attack of the Clones, but I don't have a copy to verify that with.
Comment: I've removed the incredibly tangential "What is marriage?" comments.  Y'all can take that to [the future weddings.SE](http://area51.stackexchange.com/proposals/35451/weddings).
Comment: For the record, the sources you've referenced (the old Databank, for example) are no longer canon. That being said, you're not wrong.
Comment: @Richard - Ugh; the whole change of canon is.. screwed up.  Someone needs to define something like PDC=Pre Disney Canon vs PMA (Post Mouse Abuse) or some such.  For that matter, is there a policy on Canon answers when the canon changes?
Comment: There's no "policy" but I tend to slap a comment on any answers that refer to non-canon sources.
Answer: According to the "Absolutely Everything you Need to Know" factbook, R2-D2 and C-3PO acted as witnesses to the wedding

This is confirmed in the official novelisation

On distant Naboo, in a rose-covered arbor overlooking the sparkling
  lake, Anakin and Padmé stood hand in hand, Anakin in his formal Jedi
  robes and Padmé in a beautiful white gown with flowered trim. Anakin's
  new mechanical arm hung at his side, the fingers clenching and opening
  in reflexive movements.
Before them stood a Naboo holy man, his hands raised above their heads
  as he recited the ancient texts of marriage.
And when the proclamation was made, R2-D2 and C-3PO, bearing witness
  to the union, whistled and clapped.
And Anakin Skywalker and Padmé Amidala shared their first kiss as
  husband and wife.

and in the official junior novelisation:

If Padmé had ever thought about her wedding, she had pictured a formal
  ceremony with her family and friends as witnesses. She had never, in
  her wildest dreams, expected to be married secretly on an isolated
  island with only a pair of droids to watch the Holy Man's blessing.
  But she was here, and she could imagine no more perfect place to marry
  Anakin than the balcony of this lake lodge where she had begun to
  discover her love for him. The roses in the garden below were past
  their prime, shedding petals at the slightest breeze. The fading
  flowers drenched the air with their perfume.


Software developers with $2$ years experience

Question: Statistics suggest that software developer with 2 years of experience in a town earn an average of 70,000 per year, with a standard deviation of 5,000. To verify this salary level, a random sample of 100 software developers with 2 years of experience was selected from a personnel database for all software developers in the town.
a) Describe the sampling distribution of the sample mean of the average salary of these 100 software developers.
b) Calculate the probability that the sample mean is greater than or equal to 71,200.
c) If the random sample actually produced a sample mean of 71,200, would you consider this rather unusual? What conclusion might you draw then?
My work:
a) the sampling distribution of the sample mean follows a normal distribution since n>30.
b) z = (71,200 - μ)/[σ / sqrt(n)] = 2.4, I then used this value for z in order to find the probability: P(x ≥ 71,200) = P(z ≥ 2.4) = 0.0082
c) I would consider this unusual since the probability that the sample mean is greater than or equal to 71,200 is 0.82%. I'm not too sure about the "What conclusion should you draw then" part..
I'm not sure if I am solving this correctly. Any help is greatly appreciated!!
Answer: In part b) you should divide $\sigma$ by $\sqrt n$, dont subtract it from $\sigma$.so, you need to recompute z-statistics and your conclusion on part c will depend on the new z-statistics.
Comment: That typo went completely unnoticed to me! Thank you for pointing that out!


Adding any email address under Recipient in Workflow Actions - Email Alerts

Question: Is it possible to add any email address for the workflow action email alert recipient that is nowhere related to the contact, or workflow that is being triggered. Like typing it out. Is it a good idea to add the email in a public group and select it here.
Answer: If you want any Email recipient that is not added in the contact then you can use Additional Emails section where you can add up to 5 additional recipient for testing purpose and you don't have to add them in contact.
Comment: That is if you want to cc someone. I don't want to cc anyone, or i just want to mail a custom contact A when another contact B does something on salesforce. But I don't want B to know that I mailed A regarding the change they did.
Answer: To add the email recipient to Email Alerts which are not the salesforce user or contact. You can Use the Additional Emails option.
One thing that you need to consider here is if you have already added any user or contact in the email alert and then you are adding a Additional Emails, then it will be added as CC email.
To add the emails directly to To, you can create another email alert where you have not added any user or contact and then add your emails in Additional Emails. It will be added as To.


GNUPG how to encrypt file without it's original extension in the name?

Question: I need to automatically encrypt file e.g. myfile.xls to myfile.gpg.
Now when I'm trying to encrypt it automatically or with GNU privacy assistent, the encrypted file is myfile.xls.gpg. When I delete that .xls, it has no extension after decrypting.
Thank you.
Comment: why do you need to remove the "extra" extension? It is logical that after you remove it, you can't automagically add it back when you decrypt your file, unless you bind the specific extension to the specific file name (myfile will be always a .xls) or invent a naming schema (e.g. all files beginning with "m" are .xls); maybe using "file" or similar utilities can fix it too... but I think it is not a good idea!
Comment: Hi Shin. Thank you. I think the same that it's stupid decision to rename it, but managers in our bank want it that way. The naming schema you mentioned is not possible, because file names are exacly specified. I wonder if it's possible to make it as I wrote. For example, when you zip files, they have extension .zip and after decompression it has original extension. I know this is little bit different, but...is it possible or not? Thanks!
Comment: Zip is an arhiver and it stores the filenames of course. The only chance you have is if gpg adds such an information in the final encrypted file; the ascii armor of gpg-ed file contains extra info like the version of the gpg used; so that maybe also other info could be added
Comment: What exactly are you asking? If you're asking how to remove the `.xls` extension, a simple shell script can do that. If you're asking how to recover the `.xls` extension when decrypting the file, well, removing the `.xls` loses information. Do you know *why* the managers in your bank want to discard this important piece of information?
Answer: That gpgencrypt.c option looks like far too much effort.
To encrypt do this:
gpg -er $recipient_id -o myfile.gpg myfile.xls

To decrypt and restore the original filename do this:
gpg --use-embedded-filename -d myfile.gpg

That name has been encrypted and is stored with the encrypted data.  That flag tells GPG to use the original filename instead of creating a new filename based on the name of the encrypted file.
Answer: This could be done easily with a simple C app that controls the output. The below file can do what you are looking for, you just need to compile it (linked against libgpgme) and then pass it the input file, the desired output file and the key-ids to use for encryption.
To compile using gcc, simply save the code below as gpgencrypt.c, and compile with gcc gpgencrypt.c -lgpgme -o gpgencrypt. (you need libgpgme installed)
The invocation syntax is gpgencrypt <input file> <output file> <encrypt to>. i.e. gpgencrypt myfile.xls myfile.gpg 01234567 12345678
file: gpgencrypt.c
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <stdlib.h>
#include <errno.h>
#include <locale.h>

#include <gpgme.h>

#define fail_if_err(err)                                    \
    do {                                                    \
        if (err) {                                          \
            fprintf (stderr, "%s:%d: %s: %s\n",             \
                __FILE__, __LINE__, gpgme_strsource (err),  \
                gpgme_strerror (err));                      \
            exit (1);                                       \
        }                                                   \
    }                                                       \
    while (0)

typedef char * string;

void gpgEncrypt(const char *fileToEncrypt, const char *outputFileName,
                char *encryptTo[],
                int encryptToLength) {
    gpgme_ctx_t ctx;
    gpgme_error_t err;
    gpgme_data_t in, out;
    gpgme_encrypt_result_t enc_result;
    FILE *outputFile;
    gpgme_key_t keys[encryptToLength];
    int nrecipients = 0;
    int BUF_SIZE = 512;
    char buf[BUF_SIZE + 1];
    int ret;

    /* Begin setup of GPGME */
    gpgme_check_version (NULL);
    setlocale (LC_ALL, "");
    gpgme_set_locale (NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL));
#ifndef HAVE_W32_SYSTEM
    gpgme_set_locale (NULL, LC_MESSAGES, setlocale (LC_MESSAGES, NULL));
#endif
    /* End setup of GPGME */

    // Create the GPGME Context
    err = gpgme_new (&ctx);
    // Error handling
    fail_if_err (err);

    // Set the context to textmode
    gpgme_set_textmode (ctx, 1);
    // Enable ASCII armor on the context
    gpgme_set_armor (ctx, 1);

    // Create a data object pointing to the input file
    err = gpgme_data_new_from_file (&in, fileToEncrypt, 1);
    // Error handling
    fail_if_err (err);

    // Create a data object pointing to the out buffer
    err = gpgme_data_new (&out);
    // Error handling
    fail_if_err (err);

    // Retrieve the keys used to encrypt to
    for (nrecipients=0; nrecipients < encryptToLength; nrecipients++) {
        printf("Retrieving key: %s, %i of %i\n", encryptTo[nrecipients], nrecipients, encryptToLength);
        err = gpgme_get_key (ctx, encryptTo[nrecipients], &keys[nrecipients], 0);

        if(err != GPG_ERR_NO_ERROR)
            printf("error");
    }

    // NULL terminate the key array
    keys[nrecipients] = NULL;

    // Encrypt the contents of "in" using the defined mode and place it into "out"
    err = gpgme_op_encrypt (ctx, keys, GPGME_ENCRYPT_ALWAYS_TRUST, in, out);
    // Error handling
    fail_if_err (err);

    // Retrieve the encrypt result from the context
    enc_result = gpgme_op_encrypt_result (ctx);

    // Check for invalid recipients
    if (enc_result->invalid_recipients) {
        fail_if_err (err);
    }

    // Open the output file
    outputFile = fopen (outputFileName, "w+");

    // Rewind the "out" data object
    ret = gpgme_data_seek (out, 0, SEEK_SET);
    // Error handling
    if (ret)
        fail_if_err (gpgme_err_code_from_errno (errno));

    // Read the contents of "out" and place it into buf
    while ((ret = gpgme_data_read (out, buf, BUF_SIZE)) > 0) {
        // Write the contents of "buf" to "outputFile"
        fwrite (buf, ret, 1, outputFile);
    }

    // Error handling
    if (ret < 0)
        fail_if_err (gpgme_err_code_from_errno (errno));

    // Close "outputFile"
    fclose(outputFile);

    // Unreference the key objects
    for (nrecipients=0; nrecipients < sizeof(&keys) / sizeof(int) + 1; nrecipients++) {
        if (keys[nrecipients]) {
            printf ("Releasing key: %s\n", keys[nrecipients]->subkeys->fpr);
            gpgme_key_unref (keys[nrecipients]);
        }
    }

    // Release the "in" data object
    gpgme_data_release (in);
    // Release the "out" data object
    gpgme_data_release (out);
    // Release the context
    gpgme_release (ctx);
}

int
main (int argc, char **argv) {
    if (argc < 4) {
        printf ("Usage: gpgencrypt <input file> <output file> <encrypt to>\n");
        exit (1);
    }
    int pos, n;
    string encryptToList[argc - 4];

    printf ("Encrypting %s and placing the result into %s\n",
                argv[1], argv[2]);

    for (pos=3; pos < argc; pos++) {
        encryptToList[n] = argv[pos];
        n++;
    }
    gpgEncrypt (argv[1], argv[2], encryptToList, argc - 3);
    return 0;
}


Real time digital filter with zero phase

Question: In matlab we can use filtfilt function to filter out data which implements forward and backward filtering techniques which results in zero-phase. But it's difficult to implement this filter in real time as it involves backward filtering.
I want to implement a 1st order high-pass or low pass filter with zero phase in real time. How can i achieve this?
I have search the web for days but unable to get any clue to start with it!
Thanks in advance!
Answer: It is not possible to perform a zero-phase filter in real-time because a zero-phase filter requires filter coefficients that are symmetric around zero.  That means that the filter is non-causal, or that current output depends on future input.  This of course is not possible in the real-time case and can be faked as in the case of filtfilt during post-processing.
What you probably are looking for is a linear phase filter.  Don't let the name confuse you; this does not mean that the filter produces any phase distortion.  It only means that a time shift is applied to the output.  A linear phase shift with respect to frequency results in a constant shift with respect to time.  So basically your output will be delayed some constant number of samples (group delay) from the input.
So the only difference between a zero-phase and linear-phase filter is that the linear-phase filter output is a delayed version of the zero-phase output.  This delay can be accounted for by keeping track of the group delay if you need to keep the output aligned in time with the input.
Response to comment:
FIR filters are guaranteed to be linear phase if their coefficients are symmetric about the center.  MATLAB can easily create these types of filters with functions such as fir1 or firpm.  The examples in the documentation of those functions should show you how to use them.
The group delay of a linear phase FIR filter is (L-1)/2 where L is the length of the filter.  Because of this and a few other things, I would usually choose an odd filter length so the delay is aligned to a sample and not in between samples.  This basically means that the output signal will be delayed from the input by (L-1)/2 samples.
Implementing the actual filtering process is basically discrete convolution of the input with the filter.  This involves reversing the filter coefficients, multiplying them by the most recent L input samples, and adding those results to produce a single output sample.  Then a new input sample is brought in and the whole process is done again to produce another sample (mutiplying and summing over a sliding window).  You should be able to find some sample code for convolution on the web.
This is the direct way to perform FIR filtering, but for longer filters, it may be more efficient to perform fast convolution with an FFT.  This will be a lot more difficult to get right, so unless you are talking about high sample rates and long filters, I would just go with the direct approach.
Comment: Thank you for the valuable explanation!! But how to implement it in real time? How to keep the track of group delay? Is there any references or previously completed examples of this kind of nature? And more importantly how can we use Matlab tool to generate the coefficients of a real time linear-phase low pass/high pass filter? Thank you!!
Answer: A "non-causal" zero-phase filter plus a sufficient amount of added delay can be approximated by a causal linear phase FIR filter.  This assumes that adding some delay fits your system requirements.
In your case, you could take the impulse response of your forward+backward asymmetric (or non-linear phase) filtering process, window that impulse response to make the response finite in length, delay the finite length kernel so that it doesn't require "future" samples, and use that as a FIR filter kernel.  You will have to check the results to see if your chosen window was appropriate in length and shape.  There may be a trade-off in choosing a delay versus quality of the filter due to the finite length windowing required for that delay.
Comment: Can i implement this type of filter to filter the data in real time using a high ended micro-controller? Do you have any references that follow a similar method as you mentioned above?


How do you know what number of page views per second is an acceptable amount for your server?

Question: Apache's AB tool allows us to test our server to see how many pages per second a server can handle. The results are obviously is going to vary based on the specs of the server hardware and software configuration. My question is: how do you know when your server's results are too low/can be improved? Or are acceptable/optimized?
Comment: Are you satisfied with you answers???
Comment: Thanks for the reminder. I am although they have raised more questions. :/
Answer: Benchmarking is such a complicated topic...
My points..
use a different amount of concurrency in your tests
1-2-8-16-64-256-512-1024-2048
And push lots of requests.. until
You start seeing errors.. returned by AB...
Then you starting to find your limits of your application + webserver..
Keep in mind also your RTT and Delay..
Remember to run your tests for a little while to get a good average..
I should also note that.
   You can easily use all the CPU on the server your testing with.. than the server your actually testing.. So keep an eye on cpu and memory on your testing machine..
Hope that Helps :D
Answer:
If your results are even near the general ballpark figure for your scenario (at least thousands of requests per second for small static files, at least hundreds of requests per second for simple dynamic PHP, perhaps less for heavy dynamic content with databases and stuff) should have and the server is still chugging along nicely, then you're OK.
It's also important that during the load test server still has room to breath. If it barely has any CPU time or extra memory left, then you're gonna be in big trouble during sudden traffic spikes and/or growth of your site.
Trust your instincts. If you have just a small database for the content and during the benchmark the database server seems to eat lots of CPU, go and double-check everything. Is the database server itself configured OK? Are all the expected indexes in place? Is the site performing some half-assed SQL queries which could be optimized and/or cached? Something else? Or if your web server seems to spend a lot of time even serving out static content, check the web server settings.

And if you happen to benchmark a completely slow-as-molasses site, you WILL know there's room for optimization. I once benchmarked a seemingly simple site running with an 8-core server, 16 GB RAM and all that jazz. ab, siege and JMeter all gave me five requests per sec! At that point I knew something was very, very badly wrong. Ironically enough, it was totally misconfigured cache-plugin accessing memcached that was wrong. After fixing that the site was around 100 times faster. :-)
Comment: You hit alot of points i missed..especially point 2.. +1 :D
Comment: @Arenstar: +1 to you, sir, too -- the concurrency and burn-the-server-down-with-insane-amount-of-requests testing is very important, indeed.
Answer: In my mind it's always about volume of users and their expected/anticipated experience. Your use case will vary but I'm sure if Google started responding at the speed of say Expedia people would be disappointed. So ultimately it's all about how does your system react when faced with a certain volume of traffic - and we can't tell you that data, you need to know yourself.


Gconf Dconf and Gsettings

Question: What is the difference between all of these programs? I read that some act as a back-end but I cannot find details.  How are they all related and used?
Answer: Gconf is the older Gnome configuration system, and dconf is newer. There is currently a transition from Gconf to dconf happening.  See  https://askubuntu.com/a/91409 for a good answer. I guess it's progress...
Comment: Thank you, How is gsettings related to both of them?
Comment: Gsettings is the higher level API that hides the actual backend implementation. It's what most devs should use.
Comment: so gsettings will know which you have installed and acts as an abstraction for dconf or gconf?

Gconf Dconf and Gsettings


How to convert a linked object into an individual object?

Question: Iam trying to use the subdivision modifier, I selected the linked image by Shortcut Key "L" and the I go to modifier tab and select sub.divide modifier and it sub divide the whole object so If anybody how to convert a linked object into an individual object please let me know?
Comment: if you're talking about several different meshes within the same object, if you give your object a Subdivision Surface modifier, the whole object will be subdivided
Answer: It's just vocabulary, but your question is ambiguous.

If you want to make an instanced object, (one which shares some aspect of its data (mesh, materials,etc., with other objects,) independent, that's now hidden in Header menu > Object > Relations > Make Single User.
A Subdivision Surface modifier always affects the entire object to which it is assigned. If you want to split part of the mesh off to another object, select that part of the mesh in Edit mode, and P Separate > Selection.
Answer: You have to select the loose part or linked part and separate it using "P" and separate selected. Then you can apply the subdivision.


Once saved, is there a way to change the subject line

Question: I get an automated reply from a program but the automated subject does not reflect the content of the email. I would like to change the subject line on the saved messages so I can easily tell what is in the email. Is there a way to do this without having to reply to myself and change the subject in the reply?
Answer: In a word, no. The only way you can achieve this is if you change it in the said program email template. Otherwise, you are stuck with either keeping it as it is or resending it to yourself and editing the subject.


What's the default value for the second parameter of eth_getBalance() if not supplied

Question: It's not clear in the documentation, but this function works if the 2nd parameter is not passed. What's the default if not passed?
Answer: At least for the EthereumJ (i.e. Java) implementation there are 2 versions of the function: one that takes the two arguments mentioned in the documentation, and one that takes only the first of the two arguments (i.e. the address string).
If you pass just the address string, the single-argument version is invoked.
The Java implementation is below. It shows the second argument is defaulted to "latest".
See JsonRpcImpl.java for the code.
   public String eth_getBalance(String address) throws Exception {
        String s = null;
        try {
            return s = eth_getBalance(address, "latest");
        } finally {
            if (logger.isDebugEnabled()) logger.debug("eth_getBalance(" + address + "): " + s);
        }
    }

Edit: See Eth's answer for advice on other clients.
Answer: Behavior that might not be supported across clients
The default is to use the latest block, which means that eth_getBalance will return the balance of the account according to the most recently mined block that the client/node has.  The latest block is equivalent to eth_blocknumber.
Behavior according to JSON-RPC spec
You are correct that per the JSON-RPC spec, the second parameter is required.  Technically all clients should implement the spec, but some clients are not 100% compliant to the spec (and bugs should be filed).  When using eth_getBalance it is advisable to call it according to the JSON-RPC spec, since there are no guarantees about all clients being able to handle the single parameter.  The single parameter request may work with EthereumJ, but might not work Geth or cpp-ethereum.
Contrast this with web3.eth.getBalance, where the second parameter is indeed optional.


Drupal error reporting by e-mail

Question: I'm looking for a solution that would mail me errors from <code>/admin/reports/dblog</code> site in Drupal 6.
The best would be a daily summary.
Is there any module or a trigger+action solution for that?
Answer: Try http://drupal.org/project/logging_alerts
It will enable to you to send watchdog (i.e. dblog) messages to any arbitrary email addresses meeting your severity criteria.
If you want to get summary mails (and not an individual email)... I don't know of a quick and easy method. However you could use http://drupal.org/project/filelog that will log all events to a file. Using a cron command that runs perhaps once a day you could mail this file to yourself
See http://www.shelldorado.com/articles/mailattachments.html to mail files via the command line (this command line command would be called via cron, of course).
Answer: Drupal's loggin layer is pluggable. By default Drupal ships with db_log, which is a logger that inserts entries into the watchdog table in Database.
The most used alternative is filelogging, which uses unix-alike logfiles to log into.
From there on you can use any monitoring tool to monitor those logs and pipe output into your usual reporting pipes (mail, pagers, screens etceteras).
I would advice this route above the logging_alerts NoParrots brings up for several reasons:

You will want to keep monitoring out of the tasks of your CMS. A CMS is a CMs and not a monitoring tool.
Most larger sites and environments have monitoring for the rest of the stack in place: from hardware to the apache and mySQL are already monitored, Drupal, part of that stack, should be monitored from there too, and probably not from some entirely different environment.

Reasons when to choose logging_alerts, or alike projects; monitoring from within Drupl, are when you do not monitor the rest of the stack, or do not have access to that monitoring. In such cases, setting up an entire monitoring environment, just to monitor the logs in Drupal is overkill.
Alternatively, you could create a very simple module which presents a plain-text, or XML report on an url endpoint (most probably permission based, with some token in the path).
Then have a tool like Nagios call that file every x minutes and parse it. I have done this in the past, it works fine, but the overhead of a fully bootstrapped Drupal serving a simple plain-text report at, say example.com/reports/nagios/1234qwe1234 can cause problem with the speed for the rest of the server.

Drupal error reporting by e-mail


Do I need US, UK transit visas travelling Dubai-London-Dallas-Calgary as an Indian citizen?

Question: Hi I'm Indian and planning to travel from Dubai, where I am a resident, to Calgary on British Airways (roundtrip) with two layovers: one at London Heathrow, and the other at Dallas. I have a Canadian visitor visa, but am confused with web search as some sites say that I will need transit visas for the UK and US, while others say that I don't. Do I need these visas also?
Comment: What site says you don't need a visa for the US?  Either that site is wrong or you are misinterpreting it.
Comment: For completeness, is the itinerary booked as one ticket (one PNR)? Entering the full details of your trip and travel documents in IATA https://www.iatatravelcentre.com/ will give you a reliable answer. Unlike many other countries, the United States does not allow sterile transit, which means that for any stop in the US, you have to pass through Customs and Immigration. For UK see https://www.gov.uk/check-uk-visa/y
Comment: You don't need a UK transit visa as you are exempt on the basis of your Canadian visa. You need a US visa as you need to clear passport control in the US amd enter the US. There is no airside transit in the US. There are links posted in the answer and other comments for you to confirm.
Comment: Be aware that in some consulates there can be a two-year wait to get a visa for the US.
Comment: If I transit through Frankfurt do I need transit visa? Dubai- Frankfurt -calgary
Answer: According to the UK government's Visa Check, you will not require a UK transit visa if you are on a connecting itinerary and can complete your transfer airside because you meet the first exception, "you have[...] a visa for Canada."
According to the US Visa Wizard, you will require a US visitor (B) or transit (C) visa for your connection in Dallas, as India is not part of the US Visa Waiver Program or any other visa-free arrangement with the US.
Answer: You won't need a transit visa if you can complete your transfer at Heathrow without passing through border control (known as airside transit), according to the UK Government's visa checking tool. This is because you already have a Canadian visitor visa.
You will need a visitor visa or a transit visa when you are transiting through the United States. See the U.S. Government's visa checking tool. You can apply at the nearest U.S. embassy or consulate. If you don't already have the visa, make the appointment ASAP. Wait times can be long.
Important: Airlines can deny you boarding if they believe you don't have the right documentation. Keeping your itinerary on a single ticket (as opposed to separate tickets requiring self-transfers) shows airline employees that you are transiting instead of visiting the UK and the USA. See the table in this article for more info about the differences between connecting flights and self-transfer flights. If you are on self-transfer flights, airlines might ask for documentation showing that you can enter the UK or USA as a visitor instead of as a visitor in transit because they can't verify onward flights that aren't booked through their systems.


In ArcGIS raster calculator can you access the individual cells surrounding a central cell like you can in GRASS r.mapcalc

Question: Is there a way to do the following in Raster Calculator in ArcGIS?
In GRASS r.mapcalc you can access the cells surrounding the current cell by writing  inputRaster[a,b] where a and b represent the number of cells away from the current cell. So you can write complex map algebra expressions using the surrounding and central cell, not just what is directly above or below it in the raster stack. For example if I wanted to estimate the 3d surface area of a DEM, I could add up the the area of each of the 8 triangles formed between the central cell and each pair of its 8 neighbors (each triangle of course would only go half way out to the surrounding cells).
Is there a way to do this in Raster Calculator in ArcGIS? Or some other tool, or in python maybe?
Comment: You'll need to script it and access cells using numpy arrays, e.g. http://gis.stackexchange.com/questions/184272/variable-window-kernel-size-for-raster-processing/184753#184753
Answer: You'll need the 3D Analyst license to do this.
You can use the ArcToolBox\3D Analyst Tools\Functional Surface\Surface Volume
Or if you prefer python scripting:
SurfaceVolume_3d (in_surface, {out_text_file}, {reference_plane}, {base_z},
                  {z_factor}, {pyramid_level_resolution})

Read more about it here:
http://desktop.arcgis.com/en/arcmap/latest/tools/3d-analyst-toolbox/surface-volume.htm
Comment: This answers the example application question but leaves the general question open. How do I access the surrounding cells is what I am really asking.
Comment: @thayer Okay, you'll want something like Raster Calculator in combination with something like Focal Statistics. You can define the "shape" very specifically by defining it in a text file. Read this and play around with it. Once you wrap your head around it, you can do some pretty powerful stuff on rasters: http://desktop.arcgis.com/en/arcmap/10.3/tools/spatial-analyst-toolbox/focal-statistics.htm
Comment: I guess I could apply a custom shape using focal statistics to one cell at a time to get what I want.


MOSS2007 to 2010 - What tricks have you learnt?

Question: The company I work for is currently in the planning stages of a MOSS to 2010 migration (we have a business critical environment with >500 users to port). With this in mind I was wondering what are some of the less known problems you have found or tricks you know for making this transition go easier?
Comment: I will allow this question, as it is relevant even though it is very broad. All answers will be community wiki
Answer: Had similar experience. My 5 cents:

Delegation. You need "SharePoint Champions" for each department (i.e. tax, legal). This should be a person who has communication skills, willing to learn and the most important willing to help others and answer their questions. This person must be from this department because he knows the business process inside it. He should be a Proxy between IT staff and end users. This approach will simplify the incoming threshold for business. Users usually don't like changes and don't like to learn especially if its complicated.  The Champs will help to solve this have more influence in this situation than IT staff.
You need to "sell" some features of SharePoint.  If the straightforward s solution doesn't work - be creative. In my situation people didn't like to use theirs photos in the User Profile. We figure out that some of the are fond of photography. We make a contest for the best personal photo and asked them to do this.
You need to train end users to fulfil the company's document management approach. Otherwise in 2 weeks your documents will be in very messy state.
Answer: Familiarity - make sure you have a plan to give users time to adjust to the new look, behaviour (eg. ribbon) and layout.
Plan training sessions to allow users to translate their existing skills from 2007 to 2010 (e.g. changing list views).
Use SharePoint 2010 functionality to keep the existing visual styles to help manage the changeover.
From a technical standpoint, review and test customisations before the deployment, and check for any content dependencies on customisations too.  Even if you don't plan to port a customisation over, how will that effect existing lists?
Comment: In your experience how have you found general user reception to 2010? We've had Office 2007 deployed to everybody for some time so I feel that they'll adopt the ribbon somewhat better then they would otherwise but I can't say for sure
Comment: At first users can be wary - it is new and different and they can't do their job as quickly at first. It has a significant change, especially UI-wise, which can make users uncomfortable. Emphasise the similarity with Office, and that it is trying to have a fimiliar feel across services.
Answer: What we've done in some cases is to put up a SharePoint 2010 site somewhere (separate from the actual new environment) and put up a survey or discussion board there.
Survey can be pretty much anything, but if you can figure a good survey that is related to MOSS or SP2010, maybe asking "what could be improved in the current environment", etc. Then you just sit and wait for the people to say certain unpleasant things of the current environment and try to turn those around how SP2010 will improve those. Another benefit of that is that people will use SP2010 to fill in that survey.
Regarding discussions, it can be again anything, but can be related to the survey, or some company event. Idea is just to get people into SP2010 and familiarize with it without even realizing it.
You can think of similar things with other SP2010 functionalities.


Change locale of Postgres server

Question: I have a big Postgres server with 2 Tb of data that has been created with the wrong locale.
How can I correct it, without recreating the whole server with pg_dump and pg_restore.  It would take a longtime to do so, and would need a lot of disk space.
Comment: There is no alternative.
Comment: yeah, LC_COLLATE and LC_CTYPE cannot be changed,
Comment: There is no reason this should not be doable somehow. Because locale and collation data can change on the OS for other reasons, and there are instructions for PostgreSQL to compensate for that https://wiki.postgresql.org/wiki/Locale_data_changes
Answer: This question is reasonable and it deserves an answer. Whether or not this is "supported" or whether you "should" (not) do it, it has an answer.
I do not have a full answer, as in I don't care about collations, but I have the beginning breakthrough of what nobody has thought possible.
One of the biggest issues I had was that while I used encoding UTF8, I used the locale and collation "C" hoping that it would just do whatever without being specific to any language. But that was a mistake. I should instead have used en_US.UTF-8 or for that matter turkish anatolia UTF-8. This is where I got it wrong. C doesn't care about any UNICODE character info, and that has effects in upper/lower case folding and also in the way regular expressions work. With the locale C, greek characters aren't considered \w word letters.
Test case is
select upper('árvore ação αβγ'), 'árvore ação αβγ' ~ '^[\s\w]+$';

      upper      | ?column?
-----------------+----------
 áRVORE AçãO αβγ | f
(1 row)

Bad.
And I found that it is quite easy to fix this by
update pg_database set datctype = 'en_US.UTF-8' where datname = 'test';

Then after that is done I connect again with \c and I can see the effect.
      upper      | ?column?
-----------------+----------
 ÁRVORE AÇÃO ΑΒΓ | t
(1 row)

Good!
And since I don't care about the collation at all right now anyway, I can just use only this change and have things work nicely for me.
So this is step one.
But there are more steps. Now I have indexes, some of them function based (case folding to upper or lower for case insensitive lookup.) Those I would have to rebuilt.
Let's do a test table with random strings:
create table test1 as
select id, array_to_string(array(
             select substr('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', trunc(random() * 62)::integer + 1, 1)
               from generate_series(1, len)), '') as name
  from (select (random() * 60 + 10)::integer as len, *
          from generate_series(1, 10000) as id) x;

update test1 set name = 'Árvore ação Αβγ' where id = 1234;

create index on test1(upper(name));

This was created while datctype was 'C' and doesn't work correctly:
select * from test1 where upper(name) = 'ÁRVORE AÇÃO ΑΒΓ';

nothing returned, bad. Now let's do my database "fix" above, then after connecting with \c I see that it is still not right. But now I reindex:
reindex table test1;

and now it works!
select * from test1 where upper(name) = 'ÁRVORE AÇÃO ΑΒΓ';
  id  |      name
------+-----------------
 1234 | Árvore ação Αβγ
(1 row)

Note I have not touched the collation, it could become more complicated with that, because the collation is stored in various other places in the system catalog pg_attribute for example, which might mean that we can anyway change the collation of individual columns, but again, that is really not such a big deal as long as the really deficient behavior of the locale C has been resolved.

Change locale of Postgres server


Cylinder Reconditioning

Question: When reconditioning of a pneumatic cylinder, which fit between piston and cylinder is required? and how much tolerance between mating parts is required?. Will surface finish inside of cylinder play a major role?.
Answer: It depends on the application. I think it's better described as play. Tolerance says something about the requirements regarding precision of the production, play says something about the space between piston and cylinder. I'll assume you are referring to the latter.
If it's a fast moving piston, like in a compressor, the play can be relatively much. The piston moves so fast, air doesn't get much chance or time to escape. Relatively, fast moving pistons create a lot of heat, so play is required to prevent them from getting too hot. Leaving more play will effectively give less resistance, giving less heat.
If it's a slow moving piston, like a hydraulic jack, a tight fit is required. If there's too much play, air (or oil in the case of a jack) will be able to escape, and you won't be efficient in moving or compressing the air.
Since these kind of pistons don't move fast, more resistance is allowed since there won't be any significant heat generated anyway.
Surface finish plays a big role in this situation, a rough surface is much harder to seal, and will also give more resistance. Generally speaking, the flatter the better. A practical example: try to mount the suction mount of your navigation or phone to a window. It will mount just fine since the glass is perfectly flat. If you try to mount it to a wall, it won't even hold; the wall is too rough to give a proper seal.
Most of the times, a piston will have one or more piston rings which are relied upon for a proper sealing. Both metal and rubber piston rings are used in resp. fast and slow moving pistons. This method is more efficient in sealing, and makes maintenance cheaper and easier; replacing a ring is cheaper and easier than replacing a whole piston.
Comment: Can I get these play details from any text book
Comment: @velu I didn't use any source in the form of literature. It's more of a qualitative explanation why play is a more important factor than tolerance, and how and where it matters. To give numbers, a detailed specific application must be included in the question. Otherwise not even a wild guess could be made. What do you need a refference to a text book, is it for homework for which it is required?
Answer: General comment, this is a direct answer to the question. Most pneumatic cylinder, especially bores of 2" or less are non repairable. Actually I have never seen a pneumatic cylinder repaired, but I think the procedure is to get a new seal kit. I suggest contacting the manufacture of the cylinder.

Cylinder Reconditioning


Salaht while being sick

Question: I missed fajr unintentionally while being very sick. I still pray the others as i am obliged to while being sick but missed fajr with no intention of it. Is it accounted as a sin on me? I will make up for it though.
Answer: First of all brother Masha' Allah; very proud of you for being steadfast and concerned about your salat even when sick! I ask Allah Subhanahu Wa Ta'la to give you rapid recovery and good health.
In Islam you are judged based on your sincere intention, despite what the outcomes might be due to unexpected circumstances, based on this Hadith.
Moreover, if an individual misses any prayer of his prayers, either due to a slip from the memory (forgetting), or due to sleep (not intentionally sleeping on salat), then he should pray it when he recalls it, as that's the the only expiation, based on these Hadiths: (1), (2), and (3)
Comment: Al7amdulillah thank you brother!

Salaht while being sick


Can plasma under ANY circumstances get attracted to a magnet?

Question: Can plasma under ANY circumstances get attracted to a magnet? y/n If so, then under what circumstances?
Comment: related  https://physics.stackexchange.com/q/238361/
Comment: Charged particles in a magnetic field obey the Lorentz force.  The Earth is basically a big dipole bar magnet and particles respond to its field just as you would expect from the Lorentz force.  It's not really that particles are "attracted" to a magnetic like iron filings.  They respond to it because it applies a force, but the force is orthogonal to both the field and the particle velocity.
Answer: The particles in a plasma can have a magnetic dipole moment (nuclear or electronic). A magnetic dipole experiences a force in a diverging magnetic field.
So the short answer appears to be "yes" - in a diverging field, a plasma will experience some attraction.
Whether that force is ever stronger than the other forces in the plasma is not something that can easily be answered - but then you didn't ask.


Logic design to circuit -- how is it generally done?

Question: So I've designed this CPU with purely logical components (basic logic gates), now how would I go about converting it into a circuit? I know that logical gates can be implemented using transistors, but it seems pretty cumbersome to do the equivalent conversion for every gate (there are a couple hundred). In addition to this, adding the required resistors and other passive components due to physical constraints seems a bit cumbersome. Is there a secret to how this is generally done?
Comment: the secret is that this is not generally done. you usually design your logic with a hardware description language, that already is a level of abstraction above logic gates, then some automatic tools (cost for enterprise > 10k$) translates the code in masks that are used to produce the chip. sometimes, for prototyping, an FPGA is used: that's a bunch of gates with programmable interconnections. The question is: what piece of sw did you use for your design?
Comment: Yes, it would be done in VHDL or Verilog. The layout to individual logic gates is then *mostly* automatic, with a bit of hand-tuning of timing critical parts. Placed logic gates -> production masks is one of the conceptually simpler parts of the process.
Comment: @VladimirCravero, is that really how it is done in industry? I knew FPGAs were used for prototyping a new device, but would someone like Intel or AMD program their new CPU design in VHDL, have software create some FPGA-like minimal design (with only the necessary used internconnections) and then send it to the fab?
Answer: For practical purposes of getting it working on your desk, you probably want an FPGA.
In order to make sure it works, you should simulate it first with a program like Modelsim. This enables you to iron out the bugs before buying any hardware.
Answer: Texas Instruments, et al. have almost unbelievably extensive stables of digital logic functions available which can be assembled into pretty much anything you want.
Go here and here , then check out HC (HCMOS) to get started.
Answer: While the above answers are correct, in the late 70's through the early 90's sometimes simple CPU's were constructed from TTL logic.  While you may or may not want to get into such a project, it is interesting concept.  Because the CPU is spread out and hand wired you can probe around and see it in its entirety rather than just as a small black box.
Here's one that I found that is along the lines of what I've seen in the past:
4-Bit TTL Scratchbuilt Computer
Here's another that I think would be a mess to debug but still fun to work on:
Instructables - How to Build an 8-Bit Computer
Good luck with whatever you choose.


REST API Random Authentication Failure on Sandbox

Question: I've encountered a problem where a sandbox completely stops allowing me to login.  Nothing changed in the sandbox configuration.  I'm still able to login via the web interface using the exact same credentials, and I can also still login to my other sandboxes.
My setup:

python
REST API
simple_salesforce

This has happened to me twice: once on a development sandbox and again on a full sandbox.  The only way I could recover was to completely delete and re-create the sandbox.
Anyone know what's going on?
Edit: More Info
I was trying to login to Salesforce from home this weekend when I couldn't connect.  Now that I'm back in the office, I can connect to the API without any trouble.  I checked, and there are no IP range restrictions on the sandbox; besides, I could still connect via the web interface.
Additionally, I tested the connection to the full sandbox and was successfully able to connect via the API.  This had previously stopped working, and I could not get in even while at work.
Comment: Do you need to add a security token when working from home? Perhaps your company's IP range is whitelisted as secure?
Comment: Anything interesting in the login history ?
Comment: techtrekker - Nothing stands out in the log history.  It just says "Invalid Password."
Comment: Mike Chale - I thought that when logging into a sandbox, the security token has to be an empty string.  I'll test it when I get home.  I'll also try to add my home IP to the whitelist and see if that works.
Answer: Looks a trusted IP setting to me.
When you access via API from within your organisation's trusted IP Range the security token is not required. That becomes necessary from outside the IP range.
Try checking Security Controls > Network Access under setup. More info here.
I hope it helps.


There is any way to run processes in the background in Windows? nohup equivalent for windows

Question: nohup runs a process in the background. There is any equivalent for Windows?
Answer: You can use the start command to run a process in the background of the command window.
command1
command2
start command3
command4

command2 waits until command1 finish but command4 don't wait that command3 finishes.
and if you need to run independently of the user logged on, you need to start the process as a service and you can use anysrv.exe
Comment: As far as I understand `START` command doesn't do a detach, i.e. it it still a child of the process that created it. In your example it will mean that 'command3' will die whenever the mother process exits. Unix circumvents this by doing was is known as a 'fork-twice' but I do not know of an equivalent in Windows.
Comment: at least on Windows 7 the command3 will NOT die,  for example u can get into a cmd prompt "start notepad" then exit and notepad will still be running
Comment: Yep, you are right. However I was testing from within another language where all I can is `exec()`. I can clearly see in [Process Explorer](http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx) the parent-child relationship and whatever I start from within `exec()` doesn't survive. Correct that it seems to work if I start a `cmd.exe` from Start Menu where the started process seems to be orphaned 'correctly' when `cmd.exe` exits. Clearly I need to understand this better. :-(
Answer: You might want to look at windows services.  There are some tools you can download to host any process as a windows service.  This causes the process to load in the background at windows startup, so provided it doesn't require user interaction you should be able to host it like this.
Windows Server 2003 Resource Kit
The tool you're after is called srvany.exe.
Answer: The only way, in Windows, that you can have a process started by a user continue running after logoff (i.e. what "nohup" does) is to start it either through a "scheduled task" or as a Windows service. When the user logs off all processes in their logon session will be killed.
If you're game to try the "Scheduled Tasks" method, you'll want to know how to create them programmatically. The Win32_ScheduledJob WMI class can do it. Documentation is provided in detail here: http://www.microsoft.com/technet/scriptcenter/guide/sas_man_rsxs.mspx?mfr=true  Basically, you're looking at doing (shamelessly stolen from Microsoft):
Set objService = GetObject("winmgmts:\\.")
Set objNewJob = objService.Get("Win32_ScheduledJob")
errJobCreated = objNewJob.Create("Program-to-execute.exe", "ugly-formatted-time-string-per-Microsoft-docs",True ,1 OR 4 OR 16, , ,JobID)
If Err.Number = 0 Then
 Wscript.Echo "New Job ID: " & JobID
Else
 Wscript.Echo "An error occurred: " & errJobCreated
End If

To grant "joe user" the ability to create scheduled tasks, you'll have to modify the permission on the %SystemRoot%\Tasks folder. See here for some info on that front: http://technet.microsoft.com/en-us/library/cc785125(WS.10).aspx
Comment: What's the advantage of doing this vs using schtasks.exe or the Task Scheduler GUI?
Comment: There's not much of a functional difference between this API and schtasks.exe. The advantage of the GUI is that you can do this programmatically.
Answer: This all depends on what your ultimate purpose is. You could run a scheduled task with the option to run only if the user is logged on set to DISABLED. You could possibly use psexec from a remote machine. Better yet might be to run the process as a service. Check out this Google search, this other Google search, this thread, and this other thread for some possible leads in your search for a solution. Ultimately it appears that there is no exact equivalent to nohup on a Windows machine.
Comment: My ultimate purpose is to hide the process from the user. Hide the windows that it spawns.


Tensorflow - How to translate models into other languages

Question: I'm using tensorflow to classify images in a dataset. It's python api is so easy and useful. It gives me some english tags for each image when I use inception v3 model. I want to how I can translate these words to another language (e.g Turkish, Persian, ...) in its model.
Comment: Isn't it just dictionary translation of tag (class name)? Your training data is in English so the model output English tags. You can "fix" this by manually translate the tags in your data then replace the English tags.
Comment: Are you trying to get image to text or only text to text translation. https://github.com/tensorflow/models/tree/master/research/im2txt have a look here
Comment: I'm trying to get image to text.
Answer: If you're using something like https://www.tensorflow.org/tutorials/image_recognition
then the model returns a numerical representation of the label which it then turns into a text string using a look up table. In that example, I think they provide the look up table as a text file with a number and an object or short list of objects. You just need to translate the look up table then tie the numerical label to that text string. Maybe google translate can do that. The labels are objects or lists of objects (so not sentences).
Answer: Try this link
https://www.tensorflow.org/versions/r0.10/tutorials/seq2seq/
Above link shows example for English to French or vice versa but you can train the model again for your requirements.
Comment: Welcome to Stackoverflow! To make your answer more useful, could you please provide the relevant sections from the link directly in your answer. Background is that content of links might change over time and your answer becomes useless then.


How to change Viewport background color

Question: I would like to draw on a dark gray or black background, but I do not yet know how to change the background color of the 3D viewport in Grease Pencil mode.
Answer: Go to Shading and change the color
Hope that helps.

Good Luck
Comment: Go to Render >> Film >> Transparent
Comment: Very helpful. Suppose you want a transparent background afterwards, before exporting to image sequence. What do you do?
Comment: Thank you very much. That helps.
Answer: You can control this also in the World Properties section.
Comment: @susu That might be true, but it's definitely moved from where the other clip showed it was located at and that is confusing. Which is why I think forums like these shouldn't necessarily post clips/videos/images about it - as they get outdated **really** quickly. It's my honest opinion that answers like these **should** reference to the manual page upstream when referencing a solution, so that users can follow the changes. Dead links is an issue, but that's more for blog posts etc. Product manuals should be alive during the lifetime of the product at least.
Comment: It hasn't really changed, in the shading you can control the background for the viewport as well as the world.  Additionally you can do this in the world settings.

How to change Viewport background color


Does a laptop need to be regularly shut down?

Question: I've recently bought a Lenovo Ideapad Slim 5 14ARE05. Till date, I've always been a PC User. When I was deciding which laptop to purchase, a friend who has a MacBook claimed that he hasn't had to shut it down for last 6 months. He just closes and opens the lid. Is this behaviour recommended and healthy for my new Windows laptop or does it harm the laptop in any way?
Comment: Windows users regularly have to restart because of updates. Not updating your Windows computer is a bad idea (in most cases for most people).
Answer: It causes no harm, in & of itself.
(Power savings & battery life are outside the premise of the question)
The length of time you can leave a machine without reboot really depends on how the apps you are using behave. A set of well-behaved apps will nicely hand back memory when they no longer need it & leave it then in the hands of the OS, which can release it if another app needs it.
So long as this & other potential 'clogs' such as networking ports behave themselves, there's no real need to reboot.
If anything seems 'not quite right' then a reboot is always first thing to try.
A quick check round some of the machines here, 3 different OSes, (Mac, Win, nix) gives 1 day, 10 days, 18 days & 85 days. Each will probably have last been rebooted for some update or another.
Windows will probably need rebooting the most frequently because it issues OS updates more frequently than the others. The 1 day is Windows, set to auto-update, so it reboots itself when it wants to. It rarely has a human at it, so that's fine. It never sleeps & usually updates overnight, when no-one needs it.
Half the machines here never sleep. The record holder - unfortunately now gone - ran 10 years uninterrupted, never sleeping, only ever rebooting for OS updates.
Comment: "It causes no harm, in & of itself.
(Power savings & battery life are outside the premise of the question)" Do you mean that long term health of battery isn't harmed?
Comment: I mean that battery health wasn't in the question. Everybody else seems to have latched onto that as some kind of be all & end all. It wasn't in the question. Batteries last until they die, no matter what you do. The computer itself doesn't need to be shut down.
Comment: If we take battery health into account, is no-shutdown a viable option?
Comment: Shutdown itself has absolutely no relevance to battery life. Hibernate uses the same amount of power, ie none. People seem to have got all hung up on batteries, as I mentioned in my answer. It literally has no connection to the question asked.
Answer: Most computers have three levels of low-power states when they're not in use: sleeping, hibernating, and shut down.
In sleep mode, your computer shuts down portions of itself but saves a snapshot of what you were doing so you can get right back to where you were.
Hibernate mode is similar but shuts more things off for deeper sleep and less power. The main difference you'd notice is the time it takes to boot back up.
Shutting down your laptop fully means your computer is totally powered off and uses almost no power.
You might have heard shutting down a computer completely actually uses more power in the long run because the system is more stressed than usual during the shutdown and boot up. That might have been true in older models, but it's not an issue with modern computers.
Even if you do keep your laptop in sleep mode most nights, it's recommanded to fully shut down your computer at least once a week. The more you use your computer, the more applications will be running, from cached copies of attachments to ad blockers in the background. A weekly shutdown can avoid buggy technology. You've probably had computer issues that a simple reset fixed, and making that reboot a habit can nip those problems in the bud.
Furthermore, you could refer to the following article:
Why shutting down your computer is important
Comment: Sleep must use some power to hold RAM stable. Hibernate doesn't necessarily, as the RAM state has been saved to disk. None of this has any relevance to the question, of course, which never mentioned power states.
Comment: From the energy consumption point of view, hibernate and shutdown are the same. After all a hibernated system just saves its state to the hard drive (instead of leaving it in RAM like sleep mode does) and resumes from there.
Answer:
He just closes and opens the lid. Is this behaviour recommended and
healthy for my new Windows laptop or does it harm the laptop in any
way?

This does not harm the laptop in any way. I have done this many times. No issue.
Alternative 1:  It is a Lenovo machine. Install Lenovo Vantage and set Battery Threshold to Max 80% Min 75% and then you can leave the machine ON and not suspended. Battery lifespan is not harmed doing this. (Nor is Battery lifespan extended)
Alternative 2:  Suspend at end of day, but do start up the next day. If you Suspend and ignore the computer for a very long time (week or so) the battery will wear down.
Alternative 3: Enable Hibernate and hibernate for long periods. Hibernate writes an image of the working system to disk (hiber file) so that it can save more power when hibernated.
I use Alternative 1 and usually shut down on a weekend evening.
Remember, you do have to update monthly at least and restart anyway at that time.
Comment: https://imgur.com/a/u4kzdqI Do I have to change something to see the threshold setting?
Answer: In my experience last year I owned 20 laptops from different brands, most Acer then Toshiba, Asus, and HP.
All these computers had one year of direct power cable connected to them.
After one year, The fan speed stopped working properly for most computers

notice that I occasionally opened my PC every 6 months for deep clean-up.

Toshiba first to fail, not good, the display presented deficiencies.

HP the fan was replaced once.

Asus the fan sustained.

Acer is the best but had fan speed replaced many times at least once per machine.

Everything was working as expected I saw no devalues in performance. I also tested the stress of CPU with programs.
The weather was highly influenced, and the summer presented a high peak of fans replaced.
I was using lots of fans in my house just to take into consideration, 24h/7.
Conclusion: it depends on the brand, model, material, and the quality of the fan speed.
Answer: By default, the lid close action on Windows is to sleep. MacBooks are set up exactly the same way. Keeping the system "powered on" (though suspended at times) is very convenient: Your open programs and documents stay open and you can continue working on them just by opening the lid (and maybe entering a password). This does not harm MacBooks and it does not harm Windows notebooks. From time to time, your system will receive updates and you will have to reboot—this again applies to both MacBooks and Windows notebooks.
However, keep reading!
When you close the lid the system goes to sleep. What that means exactly depends on the hardware and software configuration. Certain types of sleep must be handled with extra care! Microsoft is pushing notebook makers to support Connected Standby (S0 Low Power Idle). Previously, the prevalent sleep type was Suspend to RAM (S3). Connected Standby is not really a sleep type. The system will remain almost fully powered on and can still generate lots of heat. If you put it in a bag in this power state, it is highly likely the notebook will die. Do not put a system in Connected Standby in a bag/backpack. Of course, Connected Standby will also consume lots of power, quickly draining the battery.
It is generally safe to put notebooks in S3 sleep in a bag, because the CPU is powered down in this state.
You can find out which sleep states your system supports by running powercfg /a in Command Prompt.
Furthermore, you should make sure Hibernate (S4) is enabled. You may be tempted to disable it because hiberfil.sys requires quite a lot of space. If you disable it, the system cannot hibernate when the battery gets low. Instead, the battery will simply run out of juice. This could lead to data corruption.
I personally recommend explicitly hibernating notebooks that only support Connected Standby. All your programs and documents will remain open. The battery will not be drained. It is safe to put it in bags. The negative is that the resume process takes almost as long as a regular boot.


Why does friction does not depend upon area of contact?

Question: Why does friction does not depend upon area of contact ? Now we know that friction=(coefficient of friction)*Normal.So also is, why does friction arise.Is it because of the irregularities of a surface or because of the electrostatic forces in between the surfaces?
Comment: Or for a more detailed analysis see: [How is frictional force dependent on normal reaction?](http://physics.stackexchange.com/questions/260979/how-is-frictional-force-dependent-on-normal-reaction)
Answer: I will quote Klepnner here,
It may seem strange that friction is independent of the area of contact. The reason is that the actual area of contact on an atomic scale is a minute fraction of the total surface area. Friction occurs because of the interatomic forces at these minute regions of atomic contact. The fraction of the geometric area in atomic contact is proportional to the normal force divided by the geometric area. If the normal force is doubled, the area of atomic contact is doubled and the friction is twice as large. However, if the geometric area is doubled while the normal force remains the same, the fraction of area in atomic contact is halved and the actual area in atomic contact hence the friction force remains constant.
Comment: That's one interpretation that hinges on a linear model. But realistically frictional force is *very* complex and nonlinear to the point it cannot be accurately predicted except under very controlled conditions that force a more linear relationship. Friction also depends on other parameters such as temperature and other intervening materials such as lubricants. There are regimes of friction: static and dynamic equally difficult to model and almost impossible to model in the transition.
Comment: @docscience Regarding linearity, there is indeed a very accurate linearity between friction and normal force for small normal forces/pressures - which is the most usual situation. Few models are fitting in the entire range, and this is one of them - nothing wrong in stating linearity, because we assume everyday cases as long as nothing else is mentioned in the question.
Comment: @Steeven I agree linear models in general get you linearized answers over small displacements, forces, etc. But in the real world nothing polices scale of motion. I guess the point I failed to include in my last comment. If you consider the realistic nonlinear behavior of frictional forces, those forces *indeed do depend on contact area*.
Answer:
Why does friction does not depend upon area of contact ?

Because, even though surface gripping would scale with contact area, so does other parameters that are in the friction formula. Area therefore appears more times in the expression and turns out to cancel out completely, leaving the formula as $f=\mu n$.
For low normal forces, one would expect friction to be proportional to contact area $A$ and also to the pressure $q$ that presses the surfaces together (the normal pressure):
$$f \propto Aq$$
Normal pressure is normal force over area, $q=n/A$, so plugging this in causes $A$ to cancel out.

why does friction arise.Is it because of the irregularities of a surface or because of the electrostatic forces in between the surfaces?

Both. You can both have mechanical interlocking - as velcro - but also adhesion of one material onto the other - like glue - which tries to prevent sideways sliding. Friction is then the force needed to rip this adhesion free again.
I find it useful to think of the surfaces as very rough with "stickey" peaks and valleys. Peaks can grip into valleys and when pressed together like that they don't want to slide