How to create a SOCKS proxy with ssh?

Question: I want to use my computer as a SOCKS proxy. Do you just have to do ssh -D port_number hostname? Do I have to put my Linux username as the hostname?
Answer: tl;dr -- seek the bold text below.

Note: I use $ prefix for strings you have to substitute with your desired values. This syntax is not meant to be fully compatible with variables in any shell.
Usage of ssh -D is indeed like this:
ssh -D $port_number $hostname

or
ssh -D $port_number $username@$hostname

Where $hostname identifies some machine; it can be IP address, address resolvable via DNS or via /etc/hosts file or via ssh_config file etc. The first command will use your current (local) username unless your ssh_config file tells otherwise (by default it doesn't). You need to provide credentials (like $username and password when asked) valid to the $hostname machine.
This will open the $port_number TCP port on your local computer and establish a SOCKS server on it. Note you may not be allowed to open some ports as regular user, especially lower than 1024, use higher number then.
In general the situation without SOCKS proxy provided by ssh is like this:
A -> D

where A is a client (e.g. web browser), D is a server (e.g. web server). But with proxy this is as follows:
A -> B -> C -> D

where:

A represents a single client that uses B:$port_number as SOCKS address; there may be many clients.
B is the machine where ssh -D $port_number C runs and where the TCP $port_number listens for incoming connections from any A.
C is the $hostname B connects to; communication that normally goes to D from A now reaches D from C.
D is any server, it sees communication from C and may not be aware that A and B are involved; there may be many servers.

Some of these letters may refer to same machine in some particular usage cases. Obviously any case where A=C gives no direct advantage over simple A -> D connection, but there are other useful cases.
Let's say you run the ssh command shown above and you tell your local browser to use SOCKS at localhost:$port_number. This is the case where A=B. Your browser's traffic will be forwarded and sites you visit (D) will see communication coming from the $hostname (C) as if your browser run there.
If you'd like other computers to connect to your open port (A≠B, they will use $your_IP:$port_number as SOCKS server address) you need to:

configure your firewall to allow incoming connections to TCP port $port_number;
use -g option with ssh -D;

or

tunnel each client e.g. via their own separate ssh connection so their connections appear local (as if A=B) to your already running ssh -D ... thus firewall doesn't interfere nor -g is necessary; this can be done by ssh -L $some_port:localhost:$port_number $your_IP invoked at their side or ssh -R $some_port:localhost:$port_number $their_IP invoked at your side; clients will use localhost:$some_port as SOCKS server address in their browsers.

There's no reason $hostname cannot be B's localhost; it can. In this case B=C. This is pointless when you use this SOCKS proxy with your local browser (A=B=C) but if you allow connections from the outside then it makes perfect sense. I guess this is what you want to do. The command may be:
ssh -g -f -N -D $port_number localhost

You may want to establish key-based authentication so this ssh connection from localhost to localhost doesn't ask for your password. The above remark regarding firewall stands. Anyone able to use $your_IP:$port_number as SOCKS server address will be seen by servers they visit as if they are at your computer.

Relevant fragments of man 1 ssh:

-D [bind_address:]port
Specifies a local "dynamic" application-level port forwarding. This works by allocating a socket to listen to port on the local side, optionally bound to the specified bind_address. Whenever a connection is made to this port, the connection is forwarded over the secure channel, and the application protocol is then used to determine where to connect to from the remote machine. Currently the SOCKS4 and SOCKS5 protocols are supported, and ssh will act as a SOCKS server. Only root can forward privileged ports. [...]
-f
Requests ssh to go to background just before command execution. [...]
-g
Allows remote hosts to connect to local forwarded ports.
-N
Do not execute a remote command. This is useful for just forwarding ports. [...]
Comment: thanks man :). So, for example, ssh -D 5050 myname@my_ip is the command that i will run on my notebook. Then, i open the port on the router and finally i set up proxy on my pc. Right?
Comment: @RaffaeleD'Arco I don't really know if it's right because I don't know what `my_ip` refers to nor where the router in your network is nor what it does. I think you're missing `-g` though. If you want your Linux notebook to act as a sole relay then `ssh -g -D 5050 $username@localhost` should be the first step. If the notebook is behind a router that implements NAT and if possible clients are not in the same LAN then you have to set up port forwarding there.
Comment: YES, I would like to configure my Linux notebook as a proxy server.
When I'm away from home, I want to use the proxy on my pc.
Comment: @R It looks like you need guidance to apply my generic answer to your specific case. A bit of [XY problem](https://meta.stackexchange.com/q/66377/355310). It may have been better to reveal these details in the beginning, my answer would address them. OK, you need SSH access from your "traveling" computer to your "home" one, most likely with port forwarding on the home router. From "travelling": `ssh -p $forwarded_port -D $port_number $username@$external_IP_of_home`. SOCKS proxy setup in "travelling" browser: `localhost:$port_number`. This is the case that starts with "Let's say" in my answer.
Comment: great answer.  I was struggling to understand where the server bit of socks lives and this has helped clear that up :)

How to create a SOCKS proxy with ssh?


Developing Themes on WordPress, Looking for Excellent Tutorials

Question: I am a beginner at WordPress. I know html, asp, a little PHP and I'm familiar with WordPress. I want to be an WordPress expert. So far I know WordPress involves designing themes, making plugins and customized websites. Please let me know of any other things I need to do.
Please provide links of some excellent tutorials( free to access, not want to buy) ..to get started with WordPress from beginner to expert.
Answer: The best place to learn wordpress is for me the site & the book from http://digwp.com/
To learn how to build your own themes you might want to look at http://www.sitepoint.com/books/wordpress1/
Hope this helps!
Answer: A lot of people start right in with modifying the twenty ten theme that comes with WordPress.... so let me start right out by pointing out that should never be done.
http://go.rvoodoo.com/WPchild
is my write-up about child themes. Child themes are used to modify existing themes. They are important for the twenty ten theme because twenty ten gets upgraded when WordPress does, so if you modify twenty ten without using a child theme, your changes will get lost. Other themes also frequently get upgraded, so same point, if the theme gets upgraded and you didn't use a child theme, you will lose your changes. So unless making your own new theme, always consider a child theme.
Other than that, maybe check out my site at
http://voodoopress.com
A lot of neat tips and tricks for themes there (especially child themes) to get you started
Answer: I would suggest some of the sites which i used. Hope you find it useful. These contains tutorials as simple as possible.

https://www.taniarascia.com/tutorials/#wordpress
https://premium.wpmudev.org/blog/theme-development/
https://code.tutsplus.com/series/developing-your-first-wordpress-theme--wp-33845


Principle of least action to prove that conservation of momentum results from translational symmetry

Question: In an article that I am reading http://go.owu.edu/~physics/StudentResearch/2005/LauraBecker/SymmetrytoConservation.html - the author proves, firstly, why translational symmetry in space results from the principle of least action and, secondly, why conservation of momentum results from translational symmetry, using the same principle of least action. In the first proof, the author defines the action as $$S=T_{\rm avg}(t_2-t_1)$$ rather than the conventional definition of action as $$\int_{t_1}^{t_2}(T-V)dt, $$ which has confused me. (I am very new to this topic and self-taught). I am also struggling the understand the logic for the second proof of the conservation of momentum, which can be found in the link above. I would appreciate an explanation of both of these misunderstandings and, perhaps, a walkthrough of the steps of the proof of conservation of momentum.
Answer: The author Laura Becker of OP's linked webpage is considering 2 types of actions:

The off-shell action functional
$$ I[q;t_i,t_f]~:=~ \int_{t_i}^{t_f}\! {\rm d}t \  L(q(t),\dot{q}(t),t), \tag{1} $$

The Dirichlet on-shell action function
$$ S(q_f,t_f;q_i,t_i)~:=~I[q_{\rm cl};t_i,t_f], \tag{2} $$
where $q_{\rm cl}:[t_i,t_f] \to \mathbb{R}$ is the extremal/classical path.

Noether's theorem is usually/originally formulated with (1). However e.g. Feynman sometimes uses (2), cf. this related Phys.SE post, which also provides the sought-for proofs.


Maximal tori of $SO(n)$ and $Sp(n)$

Question: I know that the maximal torus of the group $GL_n (\mathbb{C})$ is the set of all diagonal matrices
$$
\left(
\begin{matrix}
x_1 & 0 & \cdots & 0 \\
0 & x_2 & \cdots & 0 \\
0 & 0 & \ddots & 0 \\
0 & 0 & \cdots & x_n
\end{matrix}
\right)
$$
But what are the maximal tori of $SO(n)$ and $Sp(n)$? What about the maximal split tori?
Comment: See [wikipedia](https://en.wikipedia.org/wiki/Maximal_torus) under examples and references.
Comment: But can elements of these tori be explicitly stated? I'm not sure what the elements of the tori look like.
Comment: Wikipedia is very explicit: "all block-diagonal matrices with
$2\times 2$ diagonal blocks, where each diagonal block is a rotation matrix." Do you know, what a rotation matrix is?
Comment: Yes I do. So a matrix of the form $diag(a_1,\ldots,a_n,a_{1}^{-1},\ldots,a_{n}^{-1})$ would not be in either of those tori, yes?
Answer: What a maximal torus looks like depends on your choice of bilinear form.  For example, in the split group $G = \operatorname{SO}_{2n}(\mathbb C)$, we can choose the symmetric, nondegenerate bilinear form $B: \mathbb C^{2n} \times \mathbb C^{2n} \rightarrow \mathbb C$ given by
$$B(x_1, ... , x_{2n}, y_1, ... , y_{2n}) = x_1 y_{2n} + x_2y_{2n-1} + \cdots + x_{2n}y_1$$
By definition, $G$ is the group of invertible linear operators $T$ on $\mathbb C^{2n}$ satisfying $B(Tv,Tw) = B(v,w)$ for all $v, w \in \mathbb C^{2n}$.
In coordinates, if  $J_0$ is matrix with $1$s on the antidiagonal, and zeroes elsewhere, and
$$J = \begin{pmatrix} & J_0 \\ J_0 &  \end{pmatrix}$$
then
$$G = \{ g \in \operatorname{GL}_{2n}(\mathbb C) : \space ^tg Jg = J \}$$
Up to isomorphism, this does not depend on the choice of nondegenerate, symmetric bilinear form $B$ (equivalently, it does not depend on the choice of invertible symmetric matrix $J$).  If you prefer another matrix $J'$ in place of $J$, you will define another special orthogonal group $G'$, and there will exist a $g \in \operatorname{GL}_{2n}(\mathbb C)$ such that $gGg^{-1} = G'$.
To find a maximal torus of $G$, we let $D$ be the group of diagonal invertible matrices in $\operatorname{GL}_{2n}(\mathbb C)$.  It is easy to see that
$$T := D \cap G = \{ \begin{pmatrix} t_1 \\ & \ddots \\ & & t_n \\ & & & t_n^{-1} \\ & & & & \ddots \\ & & & & & & t_1^{-1} \end{pmatrix} \}$$
It is clear that $T$ is a torus in $G$.  I claim it is moreover a maximal torus in $G$.  If not, then the general theory of linear algebraic groups tells you that $T$ is contained in a maximal torus $T_1$ of $G$.  Every element of $T_1$ must commute with every element of $T$.  But there are no elements in $\operatorname{GL}_{2n}(\mathbb C)$ which commute with every element of $T$, except for diagonal matrices.  Thus $T_1$ must consist of diagonal matrices, which forces $T_1$ to equal $T$.
Comment: That bilinear form is not alternating, so you can't define $Sp(2n)$ that way.  An alternating form needs to satisfy $B(v,v) = 0$.
Comment: And for $Sp(2n)$, could one take $$B(x_1, \ldots, x_{2n}, y_1, \ldots, y_{2n}) = x_1 y_1 +  \cdots + x_{2n} y_{2n}$$ and then obtain $T=diag(t_1, \ldots, t_n, t_{1}^{-1}, \ldots, t_{n}^{-1})$?
Comment: Ah! Yes.. thank u!
Comment: @D_S Why must every element of $T_1$ commute with every element of $T$ ?
Comment: @rae306 because $T_1$ is a torus (and in particular, an abelian group), containing $T$ as a subgroup.

Maximal tori of $SO(n)$ and $Sp(n)$


MSSQL enterprise cluster - track of failovers

Question: In an MSSQL Enterprise cluster where can I find a log of past fail over events (when they happened and which instances were re-assigned?)
Answer: The following image might help you:

I expect exporting this Event Log from each cluster member and then combining the exported values (Perhaps using Excel) will show you what you want to know.
Answer: Powershell's Get-EventLog to the rescue....
Cluster failovers write to the event logs of the servers.  You can use Powershell to query the event logs for the specific events you want to retrieve.


Driving with a revoked license

Question: In the state on Tennessee am I required to have a valid driver's license to drive myself around?
Comment: Yes, you are.  Why would you think otherwise?
Comment: Driving for the military or driving an agricultural tractor between fields often get exceptions, but I doubt either would be called driving yourself around.
Answer: Tennessee Code 55-50-301 (a) (1):

No person, except those expressly exempted in this section, shall drive any motor vehicle upon a highway in this state unless the person has a valid driver license under this chapter for the type or class of vehicle being driven;

Moreover, under 55-50-504 (a) (1), it is a crime to drive with a revoked license:

A person who drives a motor vehicle within the entire width between the boundary lines of every way publicly maintained that is open to the use of the public for purposes of vehicular travel, or the premises of any shopping center, manufactured housing complex or apartment house complex or any other premises frequented by the public at large at a time when the person's privilege to do so is cancelled, suspended, or revoked commits a Class B misdemeanor.

Driving with a revoked license


Momentum of Light Question

Question: Since light beams carry momentum, why would a person holding a flashlight not feel a recoil similar to that of a rifle being fired?
Comment: Because they have extremely little momentum when compared to a bullet.
Comment: Thank you for your answer, but I am looking for one that is more in-depth. I believe I should talk about photons and such, I cannot formulate a strong answer, however.
Comment: To a significant extent, @JavierBadia's comment *is* the "more in-depth" version. That really is all there is to it.
Answer: One can do a simple calculation. Suppose you hold a $60\text{W}$ lightbulb and you turn it on. Each second it emits $60 \text{J}$ of energy. Using the energy-momentum relation for photons, $E=pc$, we get a momentum of $p = 60\text{J}/c = 2\cdot 10^{-6}\ \text{kg}\cdot\text{m}/\text{s}$, or a force $F = 2\cdot 10^{-6}\ \text{N}$. In contrast, a Wikipedia page about firearms says that each bullet of a .44 Remington Magnum comes out with a momentum of roughly $5\ \text{kg}\cdot\text{m}/\text{s}$. That's quite a bit more than the flashlight.
(I should make a disclaimer that I know nothing about guns, I just pulled the numbers from Wikipedia. When we have a difference of six orders of magnitude, you don't really care about these things.)
Comment: $(60\ \mathrm{J})/(3\times10^8\ \mathrm{m/s}) = 2\times10^{-7}\ \mathrm{m/s}$
Comment: @user10851 what is that quantity supposed to be?

Momentum of Light Question


Need to find the set these belong to

Question: Need to find the set these belong to.
Blue octagon, a shooter, mostly black.
And bananas!
Answer: This belongs to Gorzan's Gorilla Striker (70008)

Identified by combination of following elements:
Dark Azure Plate, Modified 10 x 10 Octagonal with 6 x 6 Open Center. Dark Azure is the only shade of blue this part exist in, event though on a picture it looked like to be blue.
Projectile Arrow, Liftarm Shaft with Hollow Yellow Rubber End

Need to find the set these belong to


Error while trying to create a detail page

Question: I've got two classes in my model, like thus:
from django.db import models

class nonprofit(models.Model):
    organization = models.CharField(max_length=200)
    city = models.CharField(max_length=200)
    website = models.URLField(max_length=120, blank=True)
    ........

    def __unicode__(self):
        return self.organization

class executive(models.Model):
    nonprofit = models.ForeignKey(nonprofit)
    name = models.CharField(max_length=200)
    title = models.CharField(max_length=200)
    salary = models.PositiveIntegerField()

    def __unicode__(self):
         return self.name

My view looks like this:
from django.shortcuts import render_to_response, get_object_or_404
from nonprofit.models import executive

def index(request):
    executives = executive.objects.all()
    return render_to_response('nonprofit/index.html', {'executives': executives})

def detail(request, id):
    e = get_object_or_404(executive, d=id)
    return render_to_response('nonprofit/detail.html', {'executives': e})

I keep getting a FieldError:
Cannot resolve keyword 'd' into field. Choices are: id, name, nonprofit, salary, title
I'm a giant noob and can't quite figure out how to fix this. I don't know why it can't resolve it into a field when d equals a field....
Answer: Typo:
e = get_object_or_404(executive, d=id)

should be:
e = get_object_or_404(executive, id=id)

Comment: Thanks! It looks like it really should have been 'executive' not 'executives'. As a noob, little typos are just KILLING me right now.


What IM clients for Mac or iOS support multiple points of presence for MSN/Windows Live Messenger?

Question: I usually use Adium on OSX and Trillian on my iPhone, but most of my friends use MSN/WLM. Neither of these programs support multiple points of presence, so I can only log in to WLM from one location at a time. Are there any IM clients for these platforms that support multiple points of presence like the official Windows version of WLM does?
Answer: IM+ or its paying counterpart IM+ Pro on iOS supports Multiple Points of Presence. Otherwise Trillian for Mac is supposed to support MMoP as well.
Answer: Have you tried Messenger:mac and WLM for iPhone? If you really need a particular feature of an IM protocol, your best bet is to use the native ("original") clients for those protocols.


Current date and time in Soy file

Question: Is there any way to get the current date and time in the Soy template itself?
Answer: I'm fairly confident you cannot do this. It's possible you could implement your own custom function, but it will probably be much easier to simply pass in the current date/time string as a parameter to your template.

Current date and time in Soy file


What do these special spaces do in Elefant Hunt?

Question: I recently dug up a very old Tom Wham board game that I cut out of a Dragon Magazine back in the 1980s (I want to say early 80s) called Elefant Hunt. I have all the pieces, and I remember the mechanics surprisingly well enough that I think I can play it without the rule book. I am just stuck on two spaces on the board: the Lost City and the Elefant Graveyard. I believe this is where you get relic and ivory counters, but I don't know how many or for how many points. Does anyone know the rules governing these two spaces on the board?
Comment: is it this game: https://boardgamegeek.com/boardgame/3925/elefant-hunt
Comment: That is the game and although you did not post an answer, your comment is helpful because it tells me what issue of Dragon the game was in. I can now search my boxes for that one, or try to find a copy on line to get the full rules. So thank you!
Comment: Can you add a picture of the board, highlight these two spaces?
Answer: They score 3d6 points when returned to port.
From the rules:

When a player lands on the Elefant Graveyard, he
takes an Ivory marker. When he lands in the Lost City,
he takes a Relic marker. Ivory and Relics are worth a
variable number of points upon their return to port, as
determined by a roll of three dice.

The value of each Relic and piece of Ivory is determined by totalling the roll of three dice.
Answer: I've located Dragon #88 online and have printed out the rules. I'm going to go ahead and post this answer because the answer I originally accepted was incomplete.
It was correct insofar as you gain one ivory when landing on the Elefant Graveyard and one relic when landing on the Lost City. It was also correct in that these items could be traded in at either port for 3d6 points, each.
What the answer failed to mention is that when landing on the Elefant Graveyard, you lose one captured elephant, if you have one. Likewise, when landing on the Lost City, you lose one of your hired hunters (chosen randomly), if you have one. It does not specify choosing the elephant randomly in the Graveyard, so presumably the player may choose to lose a normal elephant if he also has the higher-point value Mad Mom.
Presumably, you cannot take a relic or ivory if none are in the bank, but the game comes with so many that, given the limitations on movement and the incentive to cash these items in as soon as possible, this is extremely unlikely to ever occur.


Chrome save as PDF doesn't work

Question: For some reason whenever I try to save a webpage as a PDF Chrome generates a 0-byte size document. And when I try to open the PDF in my Downloads folder QuickPDF tells me "Error while opening file. It appears to be damamged."
My phone is a Moto G if it helps.
Answer: Alternatively visit http://www.web2pdfconvert.com/ and paste the url which you want as a PDF.
Or
If you want to download pdf via app, try free app named "UrlToPdf" from play store.

Chrome save as PDF doesn't work


How is the concept of data different for different disciplines?

Question: How is the concept of data different for different disciplines? Obviously, for physicists and sociologists, "data" is something different.
Comment: The variety of perspectives for this particular topic is not obvious for me. I'd say that: Data = symbols (of an alphabet). Information = data + syntax. Knowledge = information + semantics.
Answer: Data is, at it's most basic reduction, a raw element of something. Data is a raw "thing" that exists in any form from which we can analyze it and construct intelligence. When I was an Intelligence Analyst, we used to define data as "anything and everything that could be used to construct a hypothesis."
Thus, data for any discipline is interchangeable; as a sociologist, I have a vector of discrete variables indicating ethnicity, as an economist I have a vector with housing prices, and as an anthropologist I have a vector of tablet names used in some long-gone civilization.
Data is data.
Comment: I'm not sure data is a "thing". If it is a thing, it should exist somewhere. Data doesn't exist anywhere. Take your own examples: (1) ethnicity: belonging to a social group - this quality does not "exist", but is assigned to an individual and a group of individuals. What counts as an ethnicity is a social construction and may differ between individuals, societies, and eras; (2) housing prices do not have existence either, but are a manifestation of perceived property/material/social value. But anyway, the point is taken that data is a construction that is used to make meaningful inferences.
Comment: @mateuz I think you're saying the same thing that I am saying, just in a different way. Data is the approximation of some element which we have decided to measure in some way.


How did the Greeks label their axes?

Question: In the current era, we label the Cartesian plane in x and y as our basis vectors, but what did the Greeks use to label their axis? The Greeks were around long before Descartes, so did they even use the same axis system? Or how did they graph things?
Comment: Did they graph things?
Comment: Ancient Greeks had neither coordinate axes nor letters for variables to label them with. Some prototypes of axes appeared in geometric constructions of Apollonius's Conica, but they were not labeled, only segments on them were labeled (by capital Greek letters A, B, Γ, Δ...). The earliest symbol for variable appears in Diophantus's Arithmetica (c. 250 AD), it was ς, but he did not label anything with it.
Comment: The ancient Greeks named the axes after their favorite stallions, thus... putting the Horse befor  DesCartes.  //rim shot
Answer: The ancient Greeks did not use rectangular coordinate systems in their mathematics, so it is unclear what are you asking about. The method of coordinates was introduced to mathematics by Descartes.
However the Greeks used spherical coordinates in astronomy and geography, and they labeled the coordinate circles the same way as we do (or more precisely we do the same as they did). I mean equator, ecliptic, meridians etc. In practical astronomy and geography we use the same coordinates as Ptolemy did, with essentially the same names and labels.

How did the Greeks label their axes?


Show Don't Tell

Question: How would you use "Show Don't Tell" imagery to portray a person who is watching something (an encounter) that makes him 'freeze' in his spot? All I can think of is: He is frozen in his spot as he watches on in utter shock.
Comment: Is the scene from the frozen person's POV, someone else's, third-person limited, third-person omniscient? Depending on whose thoughts you have access to, you can describe (show) a lot of brain processes and emotions even if the person's body isn't moving.
Comment: The POV is from the person who is frozen to the spot (in shock/frightened)
Answer: Describe what is happening to his body and (since you said this is his POV) his thoughts and feelings about it. For example:

"He felt as if an invisible force was turning his body to stone. An ache in his lungs made him realize that he wasn't sure whether or not he was breathing. He willed his limbs to move but they stayed as still as stone. For a fleeting moment he thought he'd become a statue."

Alternatively, if you don't want to grant access to his mind, you can show he is frozen by showing it in his actions. For instance, he strikes a match and is about to light his cigarette when he sees whatever freezes him. He never quite lights it, but instead stares ahead until the match burns down to the fingers holding it.
Comment: I like to think of this as 'focusing on the emotions.' I find this is great for things like fight sequences, where describing every move can get boring. Instead, focus on the *character*.
Answer: I think the complete rule is "Show, don't tell. Except when it's better to tell, don't show."
There's nothing inherently wrong with telling. Sometimes you should just say what's going on and move on. How do you decide whether to show or tell? Pivotal moments might want to be shown, not told. Pay attention to pacing and the rhythms of your text and write accordingly. Read a lot, noticing where your favorite authors use exposition and action.
Answer: Also, try to tell with respect to the surroundings. A factual description comes to mind, just the happenings and the moments, and not the thoughts or feelings. The crowd rose to it's feet, the boy in the red cap still with his soda, and they all shouted in unison - " Go Team Go".

Show Don't Tell


Springer or CRC versus self-publishing

Question: I have an IT textbook that is about 120,000 words which was accepted for publishing at several very reputable publishers. My goal is to get the text out to as many people as possible. My secondary goal is to make some money but that is not all that likely as far as I have heard. The audience is university students, researchers, and professionals. It is a textbook but one of the publishers will not publish it as such but just a monograph. In the self-publishing world there are IngramSpark and Amazon that would be good routes to go. I am wondering what people think about which is preferable, self-publishing or traditional publishers. Traditional publishers will take the rights to the content and pay around 9 to 11 percent. Self-publishing is more like 60 to 70 percent. I would publish both paperback and digital.
Answer: In academia, traditional publishing is a signal to readers that a book may be trusted. When I'm studying science or technology (and reading textbooks), I am usually not yet able to judge whether a book presents the current consensus of the scientific or technical community or contains misleading falsehoods. Self-published academic works give the impression of being rejected by respectable publishers because they were written by quacks. I would therefore never buy self-published textbooks, unless the author was famous (and possibly not even then, because some famous tech writers self-published abominable trash).
Comment: Thanks for the feedback. Seems that you and S. Mitchell both agree that traditional publishing is preferable. The benefits of self-publishing are, among others, that one keeps the rights to the material and that you can control updates, versions, pricing and so on. I like that I can keep the price low so that I can reach more readers. I would sell the book for under  $10 or perhaps break it up into two and sell each for under $10.
Answer: If you were a university lecturer deciding on the course textbook, would you choose a self-published one, no matter how good you thought it was?
If you were a reader looking for a book about a particular IT subject, where would you look? If you found a self-published title, would you be likely to buy it?
What are the less ten books you have bought? How many of them were self-published?
For me it's a no-brainer: if a traditional publisher will take it on, go with them.
Comment: The traditional route would charge above $50 probably.There is a large distributor that you can use called IngramSpark and they reach 39,000 outlets including all the major ones (Barnes and Noble, Universities, etc). But as both of you pointed out, the reputation of traditionally published books is much greater. When I see a book on Amazon though, I don't usually worry about whether it comes from a traditional publisher or not. I just look at the TOC and maybe read a bit and then decide. Oh well, it is a hard decision.
Answer: Trad publishers are far better for this.   How would you market and sell it yourself?  How would you compete against vetted books by publishers if you are not a very famous name in the field already?
If your name is Einstein or Hawking then self publishing would make you more money.  Charging less while still making more because you get a bigger slice would also reach more people.   win win!
So how famous are you?  How hard do you want to market this book?

Springer or CRC versus self-publishing


Can ion Thrusters be used for Reaction Control System?

Question: As RCS (Reaction Control System) mainly required less thrust than regular rocket engine can ion Thrusters be used for attitude determination in spacecraft(Orion, Dragon), satellites or even during propulsive landing of booster/first stages ?
Comment: For stationkeeping and orientation of a satellite, sure. For active control of a capsule in space, no. Too weak by two orders of magnitude. For in-atmosphere orientation control of booster, no. Too weak by SEVEN orders of magnitude.
Answer: Reaction Control System Thrusters typically have a thrust on the order of Newtons to tens of Newtons – hundreds of Newtons for atmospheric control (e.g. the RCS thrusters on Falcon 9 have about 400 N). Ion Thrusters in current use have a thrust on the order tens to hundreds of Millinewtons. There are experimental thrusters that have achieved 5 N in lab settings.
So, even the most powerful Ion Thrusters that aren't even in use yet are barely able to keep up with the least powerful RCS thrusters. If we are talking about typical thrusters that are actually flying right now, Ion Thrusters are off by a factor of 100×–1000×.
And that's only talking about RCS thrusters for low-mass vehicles in space. For sensible control authority within an atmosphere, as needed for e.g. Falcon 9, you need another couple of orders of magnitude.
Comment: And remember that ion thrusters are weaker, to the point of almost not working at all, in atmosphere. Even 50km up atmosphere.
Comment: so an Ion thruster is too weak by a factor of 1000. A RCS maneuver would take too long time by a factor of 1000. From 0,5 seconds as an example to 8 mintues and 20 seconds.
Comment: Different but related: [Are the (relatively) new "all electric" satellite buses like the Boeing 702SP really all-electric? Are RCS and momentum unloading done with ions?](https://space.stackexchange.com/q/54201/12102)


How do you pronounce "Star Wars" in Hebrew?

Question: I saw a screening of "Star Wars, Part IV" last night, and they flashed a poster for the film in Hebrew. Sadly, I cannot pronounce Hebrew without vowels. I'm dying to be able to!
Answer: JBiggs' answer is almost correct, the translation is Milchemet Hakochavim which directly translates to 'War of stars' but has the same meaning as Star Wars is does in English, while his answer translates to 'War stars'.
Source: I am fluent in hebrew and this poster:
Comment: I stand corrected (missed the "Ha" before "kohavim"). I wonder if the title is known this way in Israel instead of the common modern "HEnglish" style of spelling out an English name with Hebrew letters (that you see all over Tel Aviv) because back in the 70s, there wasn't a whole generation of Israelis who had grown up on American TV?
Answer: You pronounce it exactly the same. Most Israelis watch films like Star Wars in English (with Hebrew subtitles). Lots of big companies and movie titles will have an English name spelled out in Hebrew letters, so it sounds literally the same.
In Hebrew, a star is a "Kochav" (that's a transliteration, I don't have a Hebrew keyboard or word processor on this PC, so I can't write it in Hebrew). War is "Milchama". If you wanted a direct google type translation I guess it might be "Milchemet Kochavim" ("War of the stars")?
There are actually lots of words Hebrew has borrowed from English, and pop-culture references are usually at the top of the list. For example, a silly joke in Hebrew is to ask how you pronounce "banana" in English, because the word is identical.


jQuery AJAX request in IE9 not sending Cookie header

Question: I'm using jQuery's ajax .get method to retrieve data from my server.  Works perfect in Chrome, but in IE9 it is not sending the Cookie header and that breaks the app.  Any idea why?  Here's the jQuery code:
$.get(this.server + 'rest/photo/' + this.profileId + '/count', function(data) {
    $('#imageCount').html(data);
});

Answer: I have the same problem here, I can't get the jQuery .ajax() function to work. The only workaround I found is this:
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />

You can add this meta tag to the top of the page to get it working. But it doesn't feel like a good solution. I think the problem is that the xmlhttprequest object in IE9 is different, so jQuery cannot find the respective object, therefore ajax is not triggering.
Answer: I ran into a similar issue to the OP many years later with IE9 which, sadly, is still hanging on.
Every browser I tried, including IE10+, seemed fine with passing cookies to my backend, but IE9 would just drop them.  It didn't seem to matter what attributes were on the cookies.  The main page and API were on the same domains and the cookies matched, the schemes were the same.  I wasn't doing anything with IFRAMES, so the P3P 'potato' hack didn't help.
So I started doing some research on what it was about IE9 that could be different. This Microsoft post was very enlightening, and outlines all the things the IE8 and IE9 did to help lock down CORS security holes:

Must use HTTP(S), and both endpoints must use the same scheme
Must use GET/POST
No custom headers allowed
Only text/plain content-type allowed
More sensitive to Security Zone settings
Cookies will be stripped from the request

That last item about the cookies got me thinking, what if IE9 thought I was making a cross-site request?  It certainly looked like it was getting shot down in fine fashion like that.  I had already checked some of the obvious things like the scheme and domain, but maybe I didn't check everything.
The solution? Specifically, I was using reqwest as my ajax library.  It has a cross-origin parameter, which I had left set to true for some reason.  Setting it (correctly) to false did the trick - all my cookies were picked up by the server.  So it was a dumb mistake, but I learned a thing or two.
Hope this helps someone!


Normality of two variables jointly

Question: Can someone explain me what the relation is between bivariate normal distribution and dependence and independence of two variables? When i search for this topic i get answer in dependence and independence of two variables :(
Answer: If you know that $X$ and $Y$ are jointly a bivariate normal distribution then $X$ and $Y$ are independent if and only if they are uncorrelated.
However, the above statement is contingent on $X$ and $Y$ having a bivariate normal distribution. If all we know are the following facts:

The marginal distributions of $X$ and $Y$ are normally distributed.
The variables are uncorrelated.

Then it is possible to construct examples where the variables are not independent of each other. (Also see https://en.wikipedia.org/wiki/Normally_distributed_and_uncorrelated_does_not_imply_independent for an example.)
Comment: +1  This was very well done and exactly what I would have said.
Comment: @whuber The link to cardinal's beautiful answer that you inserted via your edit might not be completely relevant here since, to the best of my belief, _none_ of the 6 examples in cardinal's answer has _uncorrelated but independent_ marginally normal random variables; they are all instances of marginally normal but not jointly normal random variables

Normality of two variables jointly


Combining post categories and link categories?

Question: So as to get a single index of both internal posts and external links on the same or related topic/subject matter, is it possible to combine post categories and link categories?  I would like to be able to drill down through a single hierarchy, and find all collected information on the topic, whether external or internal to the site.  Thanks.
Answer: You can register a custom taxonomy for more than one object type:
<code>register_taxonomy( 'topic', array( 'post', 'link' ), /* more arguments */ );
</code>
But be aware that the link manager will be removed in 3.5, so it might be better to use a custom post type for links. You can register a shared taxonomy for that too.


Openlayers Auto Pan when drawing

Question: Is there a way to auto pan the map in the direction of mouse location if it hits the extents of the window when drawing line or polygon? It seems inefficient to have to pan by clicking the pan arrow if the polygon goes outside the map window.
Hope this makes sense?
Answer: You shouldn't have to click the pan arrow, you should be able to drag the map the normal way even with the draw feature control active, as in this example. Just drag the map the way you usually would when the draw control is active and you'll see it won't draw any extra nodes. Other than this,I don't think there is a default OpenLayers way to do this, as it can't really know why your mouse has left the map viewport. Imagine if, whilst drawing your polygon, you received an email you wanted to read, you mouse would leave the viewport and OpenLayers would only be able to interpret this by panning the map. By the time you came back to your map it probably would've panned itself all the way to the Antarctic.
You can (apparently) do this for when you are modifying a feature, so that if you drag a node or the entire object to the edge of the window it will move. This option is available as a property of your modifyFeature object called 'documentDrag'. However, I have never got this to work myself (although I haven't really properly tried).
Comment: Thanks Rob, That is some really great information for me to utilise. Good point about the auto pan. I had not thought of that...either had the users requesting it ;-). Once again Thanks!
Comment: There might be a way round it, but I imagine it would require a lot of custom scripting and adding your own event listeners to the map for when you reach the edge and being able to handle the window losing focus etc. and I imagine it would be a fair chunk of work. Still, if you did and it was good enough you could merge it into the OpenLayers branch or submit it as an extension
Answer: See the example below
http://dev.openlayers.org/examples/draw-feature.html
I hope you help.

Openlayers Auto Pan when drawing


How to customize the add-to-cart form using hook_form_alter?

Question: How can add-to-cart form be customized using hook_form_alter.  Or better yet can layouts like display suite or panels be applied to the add to cart form using hook_form_alter?  I have custom line item types that I would like to show using some kind add_to_cart form regions in 2 or 3 stacked columns.
Comment: If you're wanting to change the presentation, then this is why you use product display nodes, to give you that flexibility.
Comment: product display nodes cannot fields in add to cart form, it can access the whole add to cart form.  This makes for a very messy UI as add to cart form can have multiple fields that are not organized in layouts
Answer: You can use this snippet to customize the add to cart form:
/**
 * Implements hook_form_alter()
 */
function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  if (strpos($form_id, 'commerce_cart_add_to_cart_form_') === 0) {
    // Your form modifications go here.
  }
}

The $form_id changes based on the product that is in it, so you have to check for the string at the beginning of the $form_id variable.
You can theme it and/or change markup in the form like you would a regular form.
Comment: Thank you for this,  I did find this, but beyond this is where I am having a tough time.  For example how do i get a 2 column stacked layout in this or how to integrate layouts from Display Suite or Panels?
Comment: This goes beyond the type of help you'll be able to get on Drupal SE. You'll need to use the classes and other elements your theme provides to you accomplish this.
Comment: @nvahalik Your snippet is great, but where/how do you implement this code? Is there a link to a site to explain how to implement Kickstart v2 hooks? For example, where do you put the hook to only fire when the add-to-cart form is used? Do you put the hook in another event hook? Then where do you put the code for the even hook?
Comment: @RobertAchmann You'd implement it in your module. Take a look at this: https://www.drupal.org/node/1419390
Answer: For future reference better solution is there:
function wallsociety_form_commerce_order_item_add_to_cart_form_alter(&$form, &$form_state, $form_id) {
 if ($form_state->getBuildInfo()['callback_object'] instanceof \Drupal\commerce_cart\Form\AddToCartFormInterface) {
   dsm($form);
 }
}

I chaged to hook commerce_order_item_add_to_cart as mentioned not working. People find this answear when searching for Drupal 9/10/11
Source: https://www.drupal.org/project/commerce/issues/2933154#comment-13885788


How can I add a dropbox folder option under my "Places" in Nautilus

Question: Like windows, when you download dropbox it places a folder in the library list.  I'm wondering if I'm able to similarly add dropbox under "Places".  Thank you in advance for your help.
Comment: I dont currently have my Ubuntu 14.04 laptop with me, However, I do know that I was able to do this... Not sure if its bc I backed up my settings with Deja Backup from 13 and restored them and it just did it for me, or if I made the changes myself (can't remember).  But I do know that I have it there on 14.04.
Comment: possible duplicate of [How to add custom links in the left pane of Nautilus?](http://askubuntu.com/questions/64010/how-to-add-custom-links-in-the-left-pane-of-nautilus)
Answer: There multiple alternative options:

Pressing Ctrl+D adds a bookmark to the folder you're in (tested under Ubuntu 12.04 & 13.04). For Ubuntu 14.04, use the Files application (a. k. a. Nautilus) to navigate to the folder you want bookmarked, then press Ctrl+D, the same with going to the top menu bar and selecting Bookmarks → Bookmark this location.
Select the folder that you want added to bookmarks, then go to the top menu bar and select Bookmarks → Add Bookmark.
You can add them editing by ~/.gtk-bookmarks. Say you want to add ~/Software and ~/Ebooks folder under Places. Just add the following line at the end of ~/.gtk-bookmarks:
file:///home/my_username/Software
file:///home/my_username/Ebooks

Try it out and let me know. Hope it helps.
Comment: Under Bookmarks is not under Places.
Comment: One can only make use of the **Bookmarks** menu both to add the current folder and also to manage the bookmarks.
Answer: To edit the actual "Places" group, edit the ~/.config/user-dirs.dirs file and add your directories in there.
The thing is, that file is automatically generated when you log-on by the xdg-user-dirs-update program. To prevent it from overriding your changes, run the following command:
$ echo "enabled=False" > ~/.config/user-dirs.conf

For a more detailed explanation, and support for other versions of Ubuntu, see this page: http://choorucode.com/2010/07/25/how-to-add-or-remove-places-entries-in-nautilus/
Comment: This file doesn't exist in 14.04 and the link is now broken.
Answer: I have Ubuntu 14.04 with latest nautilus/files 3.12.2. I have the same problem, some files only have bookmark with Ctrl+B, I try to add but it won't work.
The solution is press Ctrl+D.
Hope it helps other
Answer: I am using jammy 22.04.03 and I fixed this problem by navigating to the Dropbox folder and dragging the Dropbox folder icon over the 'Places" in the left panel. This added it to the Places list.


Image Compression Using the SVD in MATLAB

Question: I have to compress an image using SVD. I did a few things, but all of them produced a black & white image. However, the output must be RGB. How can I compress an image without changing its original format?
Comment: What sort of "few things" you did so far?
Comment: I assume that he has used SVD in a PCA fashion and RGB values as the features, applied a standard dimensionality reduction and obtained features in the reduced space (possibly a gray scale one - following a normalization step).
Comment: what do you mean by depends on image dimensions too much? Suppose m x n(the total number of pixels) is fixed, and also number of singular values are fixed. What dimensions should your image have to save the most space from compression?
Comment: Any chance you review my answer?
Answer: The typical thing to do is the low-rank approximation on separate channels. Assume that $C$ is a channel of the RGB image $I$:
rank = 10;
[U,S,V] = svd(C);
L = U(:,1:rank) * S(1:rank, 1:rank) * V(:, 1:rank)';

Now, L should be the compressed image. If you do this operation and compose the channels back, you should get a compressed RGB image.
However, such a method in my opinion is only good for mathematical understanding. It is not very practical due to the fact that it depends on image dimensions too much and cannot generate high SNR results. Or better stated, as you decrease rank, you drastically reduce the quality of the reconstruction. For this reason, one has to retain around ~50-100 components. Better methods doing this blockwise, or formulating the compression as an energy functional exist. Image denoising is a huge area of its own.
You might want to check some results with varying rank in this presentation.

Also, a similar question has already been asked; please follow the Stack Exchange discussion here.
Answer: Let's do that in a hands on approach.
We'll follow this steps:

Apply the SVD to the Image Blocks.
When you compress with SVD you should compress blocks of the image.
The reason is simple, images are objects with spatial correlation. This is exactly what we take advantage of for compression.
Pre Prcoessing - Remove the DC Level
Important step before doing SVD is to remove the DC Level (And remember bringing it back).
RGB Images
Work in a Loop on the image channels to support Gray Scale images. Though you can work with the SVD extension to apply it on tensors (See Apply Principal Component Analysis (PCA) for RGB Images). Yet the color correlation is not worth the trouble usually. Pay attention that usually it is good to convert to YCbCr or other channel which separates color from luminosity as we can compress the color more.

Let's have a look on the function:
function [ mO ] = CompressImageSvd( mI, energyThr, blockRadius )
% Release Notes:
%   -   1.0.000     01/09/2017  Royi Avital
%       *   First release version.
% ----------------------------------------------------------------------------------------------- %

FALSE   = 0;
TRUE    = 1;

OFF     = 0;
ON      = 1;

numRows = size(mI, 1);
numCols = size(mI, 2);
numChan = size(mI, 3); %<! Number of Channels

vImageDim = [numRows, numCols];

blockLength = (2 * blockRadius) + 1;
vBlockDim   = [blockLength, blockLength];

mO = zeros([numRows, numCols, numChan]);

for ii = 1:numChan

    mII     = mI(:, :, ii);
    dcLevel = mean(mII(:)); %<! Extracting DC Level
    mII     = mII - dcLevel;

    % Decomposing the image into blocks. Each block becomes a vector in the
    % Columns Images.
    mColImage   = im2col(mII, vBlockDim, 'distinct');

    % The SVD Step
    [mU, mS, mV] = svd(mColImage);

    vSingularValues = diag(mS);

    vSingularValueEnergy = cumsum(vSingularValues) / sum(vSingularValues);
    lastIdx = find(vSingularValueEnergy >= energyThr, 1, 'first');

    vSingularValues(lastIdx + 1:end) = 0;
    % mS isn't necessarily square matrix. Hence only work on its main
    % diagonal.
    mS(1:length(vSingularValues), 1:length(vSingularValues)) = diag(vSingularValues);

    % Reconstruction of the image using "Less Energy".
    mColImage = mU * mS * mV.';

    % Restoring the original structure and the DC Level
    mO(:, :, ii) = col2im(mColImage, vBlockDim, vImageDim, 'distinct') + dcLevel;

end

end

We iterate over the image's channels.
Per channel, we calculate the mean (dcLevel). We better do that per block of data. But for simplicity we did it for the whole channel.
We decompose the image into distinct blocks.
We apply the decomposition per block.
We keep only part of the decomposition according to the energy threshold.

The full code is available on my StackExchange Signal Processing Q18673 GitHub Repository (Look at the SignalProcessing\Q18673 folder).


What is chain decimal?

Question: I saw token decimal has different value like 12, 10, 6 in different substrate chain, What exactly it means and what is the use of it?
Answer: This is the number of decimals on your main token. Compare with fiat currencies a euro has a decimal value of 2 and a cup of coffee is 0.99 Euro, while in Japan a Japanese yen (for all practical use) has a decimal value of 0 and a cup of coffee is 120 yen.
On a chain all currencies are a huge integer number, but since that is confusing for humans, these integers are treated as a fix point decimal number system instead.
Calling the RPC system.properties will reveal this information for any chain. For instance polkadot as 10
system.properties: ChainProperties
{
  isEthereum: false
  ss58Format: 0
  tokenDecimals: [
    10
  ]
  tokenSymbol: [
    DOT
  ]
}

So 1 DOT is represented internally by 10^10
When encoding operations on the chain values are given in the internal u128 integer format, any tool communication with the chain should do this conversion for the user.
Comment: If you're asking how you define your fixed point (i.e., number of decimal digits) for your token - that depends on your use case moderated by the fact that the entire expected treasury amount must fit on the _left_ side of the implied point, and the smallest units you expect to use _plus some more digits for arithmetic precision when multiplying by a fraction, or dividing_ need to fit on the _right_ side.  Look around for existing examples, and make an educated guess as to what you need.
Comment: on what basics should we define fix point decimal number for chain? Is it random value or it has some meaning? @Simon
Comment: @Ganesh11 - there's an unfortunate terminology problem here where it pays to be precise.  The _fixed point_ number can mean two things.  First, when doing any kind of arithmetic, remember it is a _binary_ number - therefore you have the typical problems of representing fractions that you think of as _decimal_ fractions in binary - that is, all the problems that surface with multiples of `0.1`.  So when you _do_ use the bits to the right of the implied "binary point" separating whole from fractional: be careful.  The other use is that all numbers representing amounts of your token are ...
Comment: ... represented as a whole number of the _smallest_ unit of that token.  In the example in this answer, the precision is _ten decimal digits_ to the right of the decimal point, so an amount of 1 token is actually represented as `10_000_000_000`.  On a chain such as Ethereum, using Uniswap contracts for examples, fractions there - used for computing liquidity equations for example -  are represented as a `128.128` fixed point binary number - which would mean you take your 1 token = `10_000_000_000` "units" (whatever you call them) and multiply _that_ by `2¹²⁸`.

What is chain decimal?


Bitcoin wallet integration with website

Question: I'm trying to create a website that will allow me to accept payment in bitcoins. What I need is a way to integrate the wallet with the website so that I can generate a unique address to give each user to deposit the bitcoins. The reason to create a different address for each user to pay is to create a sense of anonymity. The site is purely for transactional purposes and not for mining. How do I generate a unique valid address for each user?
Answer: You can use bitcoinjs-lib, a nodejs package which easily generates addresses. Apart from that it manages transaction signing and other useful stuff too which would help in development. You can check out their site (where there is a list of organisations, including blockchain.info, who use their package)
Bitcoinjs
Comment: This I assume would work like a web wallet. I want to integrate my already existing bitcoin wallet (not web) to generate addresses in the browser. Would that be possible or would it have to be a web wallet only?
Comment: Your bitcoin wallet is nothing but a collection of your private keys (in WIF format) and the public keys(addresses). You can obviously add more keys to the wallet using the wallet software, or add another address not generated from the wallet too. The integration you speak of is just adding new key-pairs generated by bitcoin-js which all bwallet software support.
Comment: this library only works with btc I presume! Is there a package to accept more coins? such as BCH, DOGE, etc. In addition, is it safe to generate a public address for each user, or is it better to assign a new wallet to each user?

Bitcoin wallet integration with website


Bluetooth HCI Snoop Log not generated Pixel 2

Question: I would like to enable Bluetooth HCI Snoop logging, however, when I enable the option in Developer Settings, no file shows up in my internal storage directory. I took a look at the /etc/bluetooth/bt_stack.conf file as well, and there are no lines indicating that BtSnoop is enabled or the location where the Bt Snoop log file will be stored. I also tried manually enabling logging with adb shell settings put secure bluetooth_hci_log 1 but that doesn't fix the issue either. I'm running Android 8.1 on a Pixel 2. Any way to actually get the logging enabled or any workarounds?
Answer: It turns out that Google doesn't simply output the logs to the internal memory on Pixel devices. Instead, these are the steps to obtain the logs:

Enable Bluetooth
Enable Developer options
Enable Bluetooth HCI snoop log in Developer options
Disable & reenable Bluetooth
Reboot
Go back to Developer options and "take bug report"
Wait for the bug report to be created, and once finished, click on the notification, and share the zip file via email or however you want to view the logs
Find the log file in FS/data/misc/bluetooth/logs/btsnoop_hci.log
Comment: Isn't it the case that somewhere between "Reboot" and "Take bug report" there should be a "do whatever Bluetooth actions you want to log" step?
Comment: On Xiaomi Mi 9, even this didn't work to get the Bluetooth HCI snoop.
Comment: FYI: On a Nexus 5 with Android 6.0.1 the `btsnoop_hci.log` file is created directly in the internal storage (`/sdcard/btsnoop_hci.log`), even without the need of taking a bug report. So if you're doing some serious BT-debugging, avoid 8.0 (and possibly 7.0?)
Comment: I found that just disabling and reenable bluetooth step was enough to solve my issue - then the log file gets generated under /data/misc/bluetooth/logs/
Comment: I am trying to do the same on One Plus 10 pro which is Android 13, but not able to get the logs. Can we have a solution for One plus devices?


Find optimum number and location of rain gauges

Question: Is there any recommended method for finding the optimum number and location of rain gauges over a region based on the data from existing rain gauges. There is one Isohyetal method that does not give the exact location.
Comment: You might want to investigate the potential for using [geostatistics](https://en.wikipedia.org/wiki/Geostatistics) (the theory of regionalized variables). [See this](https://duckduckgo.com/?q=geostatistics+rainfall&t=ffab&ia=web)
Answer: The answer, as is often the case for questions about optimums, depends on objectives and constraints.

How accurately do you want to measure rainfall? The more gauges the more precision, but obviously at greater cost.

How important is the spatial element, which in turn might depend on the objectives of monitoring? Is it more important to get accurate total volumes, or to identify variability and extremes?

Imagine two cases in the same region, with a hilly area, a hydroelectric dam and an agricultural lowland. The dam operators would want to accurately characterize inflow to their dam, while the farmers might want to measure dry season rainfall to schedule irrigation. A third agency might be satisfied with a single gauge that most closely represented a regional average. Their definitions of optimum would be rather different.
With objectives determined the next question is where do you get data on existing rainfall and variability? Often it's the case that these questions of optimization are about rationalizing or refining existing networks. In this case you will have records from the existing network.
While the detailed approach may vary, the basic principal is to compare the contribution, in terms of information, of each rain gauge to your quantitative objective. You can then eliminate the gauge that contributes the least information. This process can be repeated until a minimum network that meets the project objective is arrived at. Computationally refining this method to look at all possible combinations of subsamples is  usual. I.e. for a 10 gauge network you would look at all combinations of 9 gauges, then of 8 etc. until the objectives were met.
A similar approach can be used to add gauges to a network, by looking at the correlations between adjacent rain gauges and siting gauges in areas of poor spatial correlation.
«A New Approach for Optimizing Rain Gauge Networks: A Case Study in the Jinjiang Basin» by Wu et al. is a good worked example of this process using geostatistics. Its reference list provides links to many other case studies.
Reference:
Wu, H.; Chen, Y.; Chen, X.; Liu, M.; Gao, L.; Deng, H. Water 2020, 12, 2252; (https://doi.org/10.3390/w12082252, open access).
Answer: For simple calculation, use this: https://www.calculatoratoz.com/en/optimum-number-of-rain-gauge-stations-calculator/Calc-5418
You need to know the CV and degree of error (example: 10%).
CV can be calculated from average and stdev of monthly rainfall in certain area. The equation is CV = 100*stdev/avg.
Then number of optimum rain gauge will be N = (CV/error)^2.
If you have more data (watershed, lands, or slope and elevation), you can also add this data and make different scenario (flat, mountain, forest
Answer: Rainfall varies according to a lot of different factors, which include the location of mountains and hills, bodies of water, and vegetation.
One approach is to collect data interactively with the environment. To do that keep placing rain gauges. If they are reading the same, separate them. So, by trial and error you determine a good distribution.


Question about Strange Attractors

Question: I'm reading the book Chaos by James Gleick and came upon a certain excerpt in the chapter 'Strange Attractors'. I'm having a hard time understanding it (the merging of two surfaces part, in particular). Could someone explain the contents of the second paragraph on the page in detail in an easy-to-understand way?
Answer: Fortunately the system is low dimension enough to allow direct visualization of the attractor:

With respect to the infinite number of surfaces instead of the apparent two, the author is simply trying to convey that the figure must actually be a fractal. A finite number of flat surfaces together would have integer dimension 2, the Lorenz attractor has a non-integer dimension of about $2.06$.
The reason that is so is because the attractor is not periodic and a spiral in 2D would be, since it must tend to either a point or a closed cycle (both periodic).

Question about Strange Attractors


From logged footage to clips

Question: I've got 40 hours of logged footage. I created a new project for each tape, captured the tape, logged it with pen and paper, wrote in some metadata for the file. Now I need to go back through and create clips from the good bits in the footage. How should I do this? Should I make  another new project, import all the avi files into it and mark clips from those (I don't know how to do this), creating new clips in the project library which I can then drag into the timeline and arrange? I've experimented a bit with this process but I'm not too sure.
Comment: any reason you created a new project for each tape, Normally when you log and capture a tape you will do this within a single project and have each tape as a video file.
Comment: yeah, there is no reason. I should import all the files into one project then?
Comment: yea, one project with folders and within the folders the timelines, video files, sound files etc, I would make a folder for each with appropriate names of course
Answer: More recently I had moved to individual clip logging at the logging level and doing batch captures that would capture the individual clips.  With direct to disk systems, it also uses distinct files, so it's been a while since I did this.
That said, what I did for going through long sets of bulk captured footage back in the day was to place the clips on V2 or V3 in my timeline approximately around where I expected to use them.  If I thought they were interesting but didn't know where they would be, I'd put them in another sequence as a set of B-roll shots to pull from.
I then arranged them in to a rough cut, pulling in clips from my B-roll shots where needed.  This works best if you have a pretty decent familiarity with all your footage and a decent idea of your end result, but can also work (I'll be it kind of painfully) if you have less of an idea.  It just takes more culling passes to get it worked down and more video tracks to place clips on.
I also always shifted everything down as I built the rough cut and removed clips I wasn't going to use once I determined they weren't needed.

From logged footage to clips


Tuning an approximate model with data?

Question: Given an approximate model (obtained by theoretical simplifications etc.), how can observations (data) be used to fine tune it?. Standard supervised learning techniques can used for constructing models between dependent and independent variables but it seems like that having some prior knowledge should help.
Comment: I would make an augmented model, where some learner predicts the difference between the pristine/theoretical/false simple model and the noisy/practical/real actual world.  This would allow you to move the work of the learner away from having to approximate the simple model first, and accelerate convergence and make sure that for the same complexity the combined answers have better accuracy (or other general performance depending on your error metric).
Answer: "it seems like having some prior knowledge should help"
Well, you can encode that into your description of the model, no? If you expect some variables to be squared, etc, you can make that a parameter of the model.
But if you mean, is there a way to start with a perfect (theoretical) model and build out from there, one way to do it would be to build a preliminary model using a perfect dataset (i.e. one built using the exact function that your model is based on). Then you can use some kind of update functionality to add new data to the model to "tune" it. The size of the theoretical dataset would determine how susceptible your model is to change under the new data. Hope this answers your question.

Tuning an approximate model with data?


Risk of dropping users in postgres

Question: Is there any risk in DROPPING users in postgres?
We have bunch of users in our database that no longer work at the company.
I was wondering what (if any) risk there was in dropping those users?
Answer: The only risk is that you might drop a user that you still need.
Other than that, PostgreSQL tracks dependencies between users and other objects and won't let you drop users that have permissions or own objects in the database.

Risk of dropping users in postgres


How to make a tree having multiple type of nodes and each node can have multiple child nodes in java

Question: Basically i am trying to implement something like this, where partner node is of say "type1", client node is of "type2" and user nodes is of "type3". And each of the nodes can have multiple number of child nodes. So Partner1 can have any number of client nodes under it, similarly client nodes can have any number of users under it.

I have started the implementation but i am stuck now.The code which i have written is as follows.

public class ClientProperty {
    public class Root{}         //NodeType1

    public class Partner{       //NodeType2
        public String partner_id;
        public String partner_name;
        public int partner_node_id;

        public Partner(String partner_id,String partner_name,int partner_node_id){
            this.partner_id = partner_id;
            this.partner_name = partner_name;
            this.partner_node_id = partner_node_id;
        }
    }

    public class Clients{       //NodeType3
        public String client_name;
        public String client_id;
        public int client_node_id;
        public Map<Enum,List<Enum>> clientproperty = new HashMap<Enum,List<Enum>>();

        public Clients(String client_name, String client_id, int client_node_id,Map<Enum,List<Enum>> clientproperty){
            this.client_name = client_name;
            this.client_id = client_id;
            this.client_node_id = client_node_id;
            this.clientproperty = clientproperty;
        }
    }
    public class Users{         //NodeType4
        public String user_name;
        public String user_id;
        public int user_node_id;

        public Users(String user_id,String user_name, int user_node_id){
            this.user_id = user_id;
            this.user_name = user_name;
            this.user_node_id = user_node_id;
        }
    }
    public class Node{
        Node next;
        Object nodes;

        public Node(){
            next = null;
        }

        public Node(Object nodes, Node next){
            this.nodes = nodes;
            this.next = next;
        }
    }
}

Let me know if some insights is required
Comment: @GhostCat Thanks for the heads up. We must acknowkedge efforts of our fellow developers.
Comment: I am stuck at the point as what should be the structure of my class Node. I don't know how to point a node to many other nodes in a tree type of hierarchy.
Answer: First some more unspecific things:
You want to read about data encapsulation. Putting all public fields on your classes is simply wrong. You actually want to hide such information as far as possible.
Then you want to read about java coding style conventions; as you are violating quite some of them (which simply doesn't help when you show your code to more experienced java coders).
Finally, most important: you want to read quite a bit about OO design in general (I recommend "Agile practices" by Robert Martin; there is a free PDF of the "C# version" of that book):
It starts wit the fact that
a) being a client/user is a "different responsibility" than
b) being some element in a graph
In other words: you are putting way too many "roles" into your classes.
Meaning: you want to introduce various kinds of abstractions. For example:
interface GraphNode<N, C extends GraphNode> {
    N getNodeContent();
    List<C> getChildrenNodes();
}

Now you can express: any "node" does have some content (which could be a User or Client or whatever object); and it has a list (or set) of children, that are also "nodes".
Answer: Here I am providing you a high-level design, you have to give the implementation of getNext() and getChildren() as per your requirement.
I hope It may help you, Let me know If you have any other thought.
// As all the entities are a kind of Node , so this interface should be implemented by all the entities . You can put some more methods in this interface, If required to be a Node type.

interface Node {
    Node getNext();
    List<? extends Node> getChildren();
}

class Root implements Node {
    private List<Partner> partners;

    @Override /*Implementation required*/
    public Root getNext() {
        return null;   // Return next node
    }

    @Override /*Implementation required*/
    public List<Partner> getChildren() {
        return partners;
    }
}

class Partner implements Node  {
    private List<Client> clients;
    @Override /*Implementation required*/
    public Partner getNext() {
        return null;  // Return next node
    }

    @Override /*Implementation required*/
    public List<Client> getChildren() {
        return clients;
    }
}

class Client implements Node {
    private List<User> users;

    @Override /*Implementation required*/
    public Client getNext() {
        return null;   // Return next node
    }

    @Override /*Implementation required*/
    public List<User> getChildren() {
        return users;
    }
}

//As per your requirement, User class is leaf node, so you can return null in getChildren() call;
class User implements Node  {
    private List<? extends Node> children;

    @Override /*Implementation required*/
    public User getNext() {
        return null;  // Return next node
    }

    @Override /*Implementation required*/
    public List<? extends Node> getChildren() {
        return children;
    }
}

Note: Its a high level design. With this design, you can introduce more types in your application, if required in future.


.ZIP from Windows to Mac: folder structure lost - how to avoid that?

Question: I am creating .zip-files on windows that I want to make available to Mac-Users (created with ZipFile.CreatefromDirectory from .NET Core). However, when I extract these files on my Mac (running Mojave, using the context-menu's "Extract File"), it re-creates the source-folder that I had zipped - and a flattened structure in side that folder: where I previously had root\foo\bar.txt, I now have a file "foo\bar.txt" in the root-folder. How I can get a "foo" folder with "bar.txt"? Did that problem arise when I build the .zip or do I need to extract differently in order to preserve directory-structure?
Answer: The default install of macOS does not have an "Extra File" context menu - it seems like that could be a third party program / plugin.
The default install of macOS comes with the Archive Utility for uncompressing for example ZIP files. It will preserve folder structure by default.
So in your case, either you're using a third party extractor, that does not by default preserve folder structure, or you have made a mistake when making the compressed file.
I would test by building a small test folder structure on the Mac, then select the top folder in Finder and choose "Compress" from the context menu. Now you'll have a ZIP-file that you can try uncompressing in a different folder. This should create the same folder structure that you initially compressed.
Comment: Thanks! Your first 5 words solved the problem - the filemanager that I was using made that mistake. And I'm too much of a newbie to realize that this wasn't a macOS-Option... "Open with>Archive utility" did it correctly :)


Equation of a Riemann surface?

Question: Intuitively in complex analysis I know what a Riemann surface is. It is a surface such that at every point on it the value of a function $f(z)$ is single-valued. However, how would I go about finding the equation for such a surface, i.e. if I was to plot one what one I plot?
Comment: [THIS](https://en.wikipedia.org/wiki/Riemann_surface) might be of some help in understanding the question and providing an answer.
Answer: When you are talking about the equation of a surface you have equations like $x^2+y^2+z^2=1$ for a sphere or $z=x^2+y^2$ for a paraboloid in ${\mathbb R}^3$ in mind. But this is not the appropriate way to think about a Riemann surface. A Riemann surface can be any orientable two-dimensional manifold, i.e.,  "surface" in the intuitive way. In fact the surfaces I mentioned can be the bottom carrier of various Riemann surface structures, whereby the latter will  then differ in their  local or global conformal structure. To put it bluntly: A Riemann surface is an orientable $2$-manifold on which an angle measurement is defined on all tangent planes.
The surfaces I mentioned inherit an  angle measurement in their tangent planes from their imbedding in ${\mathbb R}^3$, whereas the "Riemann surface of the function $z^2=w$" inherits its angle measurement from the angle measurement in the complex $z$-, or $w$-plane (the point $z=w=0$ is special).
To sum it up: A Riemann surface is an orientable $2$-manifold on which you have introduced local coordinates $z_\alpha$ $(\alpha\in I)$ such that in intersections of coordinate patches you have $z_\alpha=\phi_{\alpha\beta}(z_\beta)$ with analytic transition functions $\phi_{\alpha\beta}$.
Answer: $\newcommand{\Reals}{\mathbf{R}}\newcommand{\Cpx}{\mathbf{C}}\newcommand{\Proj}{\mathbf{P}}$As worded the question is a bit awkward to address.
Abstractly, a Riemann surface is a smooth real surface equipped with a holomorphic structure, i.e., a holomorphic curve. Examples include open subsets of $\Cpx$, the complex projective line $\Cpx\Proj^{1}$, tori $\Cpx/\Lambda$ with $\Lambda \subset \Cpx$ a rank-two lattice, and hyperbolic quotients (which tend to be difficult to describe explicitly).
Concretely, certain multi-valued complex functions defined on (open subsets of) the plane, such as logs and roots of entire functions, are associated with Riemann surfaces, and may be understood as subsets of $\Cpx\Proj^{1} \times \Cpx\Proj^{1}$, or as multiple copies of the complex line $\Cpx$ with suitable branch cuts and cross-gluings and added points at infinity. Examples include "the Riemann surface of the $n$th root", $w = \sqrt[n]{z}$ or $w^{n} = z$; "the Riemann surface of $\log$", $w = \log z$ or $\exp w = z$; and "the circle" $w = \sqrt{1 - z^{2}}$, or $z^{2} + w^{2} = 1$.
Alternatively, a homogeneous polynomial $f$ in three variables (whose gradient vanishes only at the origin of $\Cpx^{3}$) defines a Riemann surface embedded in the complex projective plane $\Cpx\Proj^{2}$.
All three classes are difficult to represent geometrically with complete fidelity: Abstract Riemann surfaces are not embedded in anything (and don't have an intrinsic "equation" in the sense you mean), while the concrete "plane curves" naturally sit inside a (real) four-dimensional ambient space, and inevitably undergo distortion (acquire singularities and/or self-intersections) when projected into real three-dimensional space.
That said, a particularly nice example is Costa's surface, a minimal surface in $\Reals^{3}$ of a torus with three punctures given by its Weierstrass embedding.
Answer: You shouldn't expect to be able to look at a surface and say, "oh! here it is: it's all the $z$ that satisfy this equation.
You may not even be able to find an $f(z)$ that globally works. We only know that locally, Riemann surfaces have such a description.
Answer: The standard example (and for me a major motivation for studying Riemann surfaces) is the complex logarithm. The formula usually given for it is really just the branch cut of the entire Riemann surface.

If $z = re^{iθ}$ with $r > 0$ (polar form), then $$w = \ln r + iθ$$ is
  one logarithm of $z$ [i.e. a branch cut of the Riemann surface];
  adding integer multiples of $2πi$ $$w=\ln r + i(\theta + 2n\pi),\ n \in \mathbb{Z}$$ gives all the others [i.e. the
  entire Riemann surface].

https://en.wikipedia.org/wiki/Complex_logarithm
http://mathworld.wolfram.com/BranchCut.html
The above page actually gives a lot of examples of functions which are not problematic as functions on the real line but which need to be represented either with branch cuts or as Riemann surfaces when considered as functions of complex numbers.
This page has some graphs of Riemann surfaces related to Lambert's W function:
http://mathworld.wolfram.com/RiemannSurface.html

Equation of a Riemann surface?


push into array while it is being looped

Question: Here's a snippet of my code. I understand that it is generally advised against to modify an array whilst it is being looped, however in this scenario I think it is the right thing to do and saves resources.
$levels = array($post);
foreach ($levels as $level) {
    $next_sibling = get_next_sibling_page($level);
    if ($next_sibling) {
        $next_page = $next_sibling;
        break 1;
    } else if ($level->post_parent) {
        array_push($levels, get_page($level->post_parent));
    }
}

The idea is that the foreach would reiterate with the pushed value if ($level->post_parent), I can see that the if statement is resolving to true and the array is being pushed to however the foreach does not reiterate and only runs the one time.
Does anyone know how I can recursively continue my foreach until $level->post_parent resolves to false?
Comment: "Does anyone know how I can recursively continue my foreach.." - with recursion
Comment: @KarolyHorvath Do you know something I don't?
Answer: To modify array which is being used in foreach pass array by referance.
foreach (&$levels as $level) {
   .....
}

Comment: `Parse error: syntax error, unexpected '&'`, I have seen passing the value as a reference but there are no examples of passing the array as reference,


How to determine direction of rotation in CSS3 transitions?

Question: I'd like to rotate an object from -180 degrees to 180 degrees via CSS3 transforms and transitions. This works fine, but I'd like to control the direction of rotation. How to determine if it will be going clockwise or counter clockwise?
Comment: I think you will need to set a mid-point in your animation. I haven't seen anything that lets you specify which way the rotation goes.
Comment: So that's via css3 animation properties you mean? Yes, that's what I also thought, but I'd like to do it just with simple css3 transition and transform properties, if at all possible.
Answer: 0 .. 180 is clockwise, 0 .. -180 is counterclockwise. So, positive number rotates clockwise, negative - other way around. You can also keep increasing/decreasing the number to continue rotation, the browser will remove additional 360s.
I created an example of how to rotate:

This div will do a spin when clicked!

First we display rotated div. When you click on it, it will rotate. Depending on the value - negative or positive it will rotate counter-clockwise or clockwise.
Comment: Thanks. In the end I came up with a solution, triggered by your example. Degrees are not limited by a minimum of 0 and a maximum of 360. You can also specify -720 for example. This way you can control clockwise and counter-clockwise movement.
Comment: But what if you want a transition between 30 and 40 degrees, only counter-clockwise?
Comment: But what if current rotation is -90, and you want it to rotate one turn clockwise ? I tried -90 then 270, but it seems to not be working in IE.
Comment: Well, if you rotate something 360 degrees it will stay in the same place. If you want to see the rotation you need to rotate by adding 1 degree (or any other degree number) until you reach 360. After that you'll complete the whole circle.
Answer: It seems that you also need to remember to put in the "from" initial concrete values, otherwise the +/- direction sign won't behave well.


Terms related to megasporogenesis

Question: Well, I am not able to understand the exact difference between megasporocyte and archesporium. Also I'm not quite able to get, how or precisely from where do these arise?
Please help.
Answer: In relation  to angiospermic megasporogenesis, archesporium cell is the precursor of Megasporocyte.

Archesporium is defined as   the cell or group of cells from which spore mother cells develops
The megasporocyte is the cell(or the tissue) which directly produces
   the megaspores.

In most angiosperm, the nucellar tissue within the ovule first differentiates into a single archesporial cell, the ancestor of the Megaspore Mother cell(MMC). In certain species, this archesporial cell may itself act as the MMC undergoing meiosis to produce the megaspores. in such cases, the archesporial cell and the megasporocyte (another name for MMC) is the same.
But in some species, the archesporial cell first undergoes a periclinic division producing two cells which further produce the parietal layer (covering of the megaspore) and a single sporogenous cell. This cell acts as the MMC, and is the megasporocyte.
Thus the archesporial cell may or may not be the same as the megasporocyte. It could be the ancestor of megasporocyte.
Comment: Thanks a lot. What I was wondering is that, as you said that archesporium can be a group of cells than would all those cells develop into a MMC or is there any type of differentiation among them so as to satisfy the requirements of any one cell which would develop into a MMC?
Comment: When archesporium is a group of cell, two things can happen. One is that most of them form the parietal layer, and a single cell matures into MMC. Or if the archesporial cell is in the male anther, most of them mature into PMC (pollen mother cell).

Terms related to megasporogenesis


Learning JavaScript for a total non-programmer

Question: I code CSS/XHTML like it should be my mother language, and I do write valid, semantic code following guidelines of accessibility and such.
But I want to learn Unobtrusive JavaScripting, but with a total non-programmer brain I need some motivation / tips / etc., like what's the best way to learn it, and how long does it take/did it take you before you could feel the power of knowledge? :)
PS: I do have an understanding on how JavaScript works and changes the DOM etc.. I think it's more about learning the syntax by head instead of having to look it up.
See also:

Suggestions for someone starting javascript programming.
Comment: Hmmm, after CSS/XHTML you might be too damaged to ever think logically again.  ;-)
Comment: JS is too complicated to start with? Hmm... Most of the confusion I see tends to come from programmers used to far more complex languages who approach JS expecting it to require the same sort of structure!
Comment: I wonder if Js is a good beginner language or not. I think it's possibly too complicated to start with, because it's a hodgepodge of different concepts wrapped around in loose syntax and typing. Perhaps learn another language and then move onto Js? But then there might not be a reason to learn that language because it's not practical to you. Just thinking out loud.
Comment: Good choice of a language. May I recommend Flash/ActionScript3? It has great documentation, is an extension or EMCAScript, like JavaScript, and Adobe releases a free, open-source, copy of their compiler under the name of "Flex SDK".AS2 was kind of dirty, but AS3 is clean, and MUCH faster than JavaScript (although JS is catching up with browsers like Chrome), because of it's compiled nature. The only trick is finding a nice (free) IDE. On Windows, I would recommend FlashDevelop, or on mac TextMate+AS3 Bundle (not free, but inexpensive), or XCode+Flex bindings (free, but not the best).
Comment: If I'll use JS for changing the DOM's CSS or XHTML, it shouldn't be too difficult. That way I guess I can take step by step away from the CSS/XHTML and learn more advanced code whenever my brain is ready for that, haha ;)
Comment: ^^^^^ Why can't I put line breaks in comments?
Answer: Just use it. Really, the more time you spend reading and writing the language, the more natural it becomes. Use Firebug or an equivalent console to test short ideas; take an existing web page and wire up events interactively from the command line, get used to the idea of writing behavioral code as a separate process from writing markup.
If you want a good book, i can recommend the excellent jQuery in Action - yes, it's targeted at jQuery users, but the concepts apply regardless of your choice in libraries.
Answer: Motivation, sorry can't help there.
Syntax is learned by rote. The rules are simple, and reasonably consistent, so in truth syntax isn't that hard.
What you conflate with syntax are likely the other aspects like what properties are available on what objects, what functions to call, what does your framework provide. That, again, is basically rote memorization.
Many frameworks add a little bit of syntax through clever use of the JavaScript syntax, and you'll need to learn those as well.
But when it all comes down to it, the only way to learn this stuff is to use it.
You can't read about it, you have to do it.
Find an issue that you want to work on, a feature for your site or whatever, and attack that.
If you find a tutorial or whatever on line that does what you want, TYPE IN THE CODE, don't cut and paste it. As you type it in, question every symbol or character, try to understand why you're typing what you are typing.
Make an effort to change things, even if it's just variable names, because then you get a better idea of what things are being used for, and how they're referenced. It also lets you focus on a small part of the larger program.
If you're changing the "window1" variable to "myWindow", then at least you can look at the code as "blah blah blah window1 blah blah window1" without having to understand all of it.
Start small, don't worry about "doing it right", etc. so much as just being successful. If the way it's done doesn't bother you, then you're good. If you look at it and go "That's not quite right" because you learned something later after you started, then go back and clean it up.
At this stage, function is greater than form. Much of the form simply comes from experience.
Answer: Depends on what you want to do. Are you a successful web designer who's considering getting into the development side? Forge ahead, but tread cautiously. JavaScript can be easy to start with, but it can get ugly very quickly. And it's very different from any server-side language (including Java). Some of your JavaScript skills will translate to other languages, (conditional and control-flow operators, for example). But some things are unique to JavaScript and will require some relearning if you move to another language.
Also, some things in JavaScript won't completely make sense unless you've done object-oriented development; even though JavaScript is "prototype-based" rather than strictly object-oriented, without the OO concepts to relate to, the prototyping system may be difficult to understand. The typing system also may not make much sense if you don't have a lot of experience with different typing systems (static vs. dynamic, explicit vs. implicit).
Use a good framework like jQuery or YUI, but be sure to understand what's going on behind the scenes. Shog9's suggestion to use FireBug is a good one, too. It will show you what's going on (without having to do a lot of alert() statements in your code).
Your HTML DOM and CSS experience will help some, but only in the sense of understanding what the JavaScript is trying to do. Having written HTML and CSS by hand won't help you learn to write JavaScript; HTML and CSS are document markup languages, not imperative programming languages.
So go for it, but don't expect it to be easy. You may make a lot of quick progress, only to find that you're not as far along as you think, and that things don't work the way the appear to. But with enough effort and research you'll probably get there.
Answer: I think learning Javascript is a great idea if you are all ready doing HTML and CSS. Javascript is a cool, but quirky language.  Most people that use don't really know how to write good JS code. I highly recommend watching Douglas Crockford video, see http://video.yahoo.com/watch/111593
They will give the real scoop on Javascript.
Comment: Yaaay! China blocked me from watching that video but I'll get me a VPN account soon. Thanks anyways :D
Answer: I've recommended JavaScript: The Good Parts before (and can't recommend it highly enough), but if you're new to programming I suggest starting with Head First JavaScript.

(source: oreilly.com)
Comment: Thanks, think I've downloaded all the books mentioned here :) I'll get these printed up on a chinese university around here, cost like 1-2 USD to print up a whole book xD
Comment: "Javascript: The Good Parts" is such a great book, ++
Comment: @Frank Not for a newbie programmer, it isn't.
Answer: I think you've got an abundance of great answers and resources already, but I'd like to chime in, too, since I've seen a couple of jQuery recommendations:
I love jQuery, too, and use it nearly daily. That said, for a beginner, I would recommend that you be comfortable with javascript proper first before diving into jQuery. Being comfortable with the syntax, variables, scope, and at least some DOM concepts will greatly improve your understanding of how to do what you want with jQuery. If you try to speed too quickly past the fundamentals, you'll definitely get stuck on some common misunderstanding that jQuery won't be able to help you with.
Answer: http://codeavengers.com level 1 JavaScript is great for the complete beginner. I created the courses and have had lots of great feedback from beginners who have found my course a fun and effective way to learn JavaScript.


Usage of stack and Queue?

Question: I am reading datastructures and see stack and queue but i do not get enough examples in computer systems or web development or specific problems where i should use a stack or queue or a tree etc.
Comment: ha ha -1 for being curious. Anways atleast i have some answer.
Comment: Was your assignment to give examples of the use of stack, queues or trees, perhaps?
Comment: there isnt a assignment i am just curious. Moreover i am not a college going student.
Answer: Queues are common whereever something needs to be handled on a first-come-first-serve principle. Network packets, I/O requests, etc.
You want a stack when you need to re-use the last item you put on it again. I can't find a nice example off the top of my hat, but it's used e.g. in converting normal mathematical expressions into RPN or for storing nodes when doing a depth-first search in a graph.
Answer: Stacks are used by most (all?) programming languages to keep track of the state of the program when sub-routines are called.
Explanation: The code of your program is stored in main memory. The CPU has an instruction pointer that always points to the next instruction that will be executed. When an instruction has been executed, this pointer is increased by one, to point to the next instruction.
When your program enters a sub-routine, the instruction pointer jumps to some other address. When that routine is finished, it has to know where it left of. So, the last address before the jump is pushed on the stack. When the function is finished, the topmost item on the stack will be that address.
This is also the reason why excessive recursion can lead to a stack-overflow. Too many nested calls lead to many return addresses being pushed on the stack, but none are removed.
Read more on Wikipedia.
Trees can be used for many things, for instance binary search trees.
Comment: Can u please describe "keep track of the state of the program when sub-routines are called"
Comment: @sushil: added an explanation and a link for call-stacks.
Answer: Queue - First In First Out, used for sequntial processing of data. Can be used for processing tasks in the order they were enqueued.
Stack is the opposite of the Queue - Last In First Out, most commonly used example - method call stack.
Comment: @sushil - How about a simpler example of LIFO? Think of the undo feature in your word processor. You need to store each thing you did so you can undo it later, and when you access it you want to start from the last item (top of the stack) and work backwards to the first item.
Comment: can you please elaborate method call stack?
Comment: @JohnFx - there are times when i feel i should have ability to keep clicking upvotes. Ur answer is one among them
Answer: In stack deletion and insertion are performed on the same end. So it is called Last In First Out. In stack only one pointer is used called TOP.No wastage of memory space
In queue deletion and insertion are performed on two ends. So, it is called First In First Out. In queue two pointer called as FRONT and REAR.Wastage of memory space.

Usage of stack and Queue?


Calculating $\int_{-\infty}^x\frac{1}{\sqrt{2\pi}} e^{-(\frac{x^2}{2}+2x+2)}\,dx$

Question: I want to solve this integral from $-\infty$ to $x$ .
$$f_X(x)=\frac{1}{\sqrt{2\pi}} e^{-(\frac{x^2}{2}+2x+2)}, -\infty<x<\infty$$
I have searched as much as I could and I found a solution in wikipedia
$$\int_{-\infty}^{\infty} x e^{-a(x-b)^2} dx=b \sqrt{\frac{\pi}{a}}$$
In that solution there is a $x$ before $e$ but in my problem there is not any $x$ before $e$ and it is the only deference also the answer in that solution is a number but I need a function which contains $x$ .
I really need this answer as soon as possible
Comment: What is your question? You didn't post anything of substance. Also, do you have any (valid) attempts at work? Saying you searched on the internet as much as you could is not a valid attempt at the problem
Comment: I don't understand what is actually inside the integral...
Comment: @mayam, lookup complementary error function. Pay attention to the limits of that definition.
Comment: @cool, to be quite fair, the integral is not something usually taught to children and non-specialists, so at least the mention of the OP that a search was done is alright. On that note: completing the square should be useful here.
Comment: @J.M before the edit, the question contained no integral. It simply read something to the extent of "I cannot solve this integral" but did not have an integral written. This is why I said what I did.
Answer: Complete the square in the exponential function, then let $y=\frac{x+2}{\sqrt{2}}$
\begin{align}
\frac{1}{\sqrt{2 \pi}} \int\limits_{-\infty}^{z} \mathrm{e}^{-(\frac{1}{2}x^{2}+2x+2)} dx &=
\frac{1}{\sqrt{2 \pi}} \int\limits_{-\infty}^{z} \mathrm{e}^{-\frac{1}{2}(x+2)^{2}} dx \\
&= \frac{1}{\sqrt{\pi}} \int\limits_{-\infty}^{(z+2)/\sqrt{2}} \mathrm{e}^{-y^{2}} dy \\
&= \frac{1}{\sqrt{\pi}} \frac{\sqrt{\pi}}{2} \mathrm{erf}(y) \Big|_{-\infty}^{(z+2)/\sqrt{2}} \\
&= \frac{1}{2} \mathrm{erf}\left(\frac{z+2}{\sqrt{2}} \right) + \frac{1}{2}
\end{align}
Where
$$\int \mathrm{e}^{-y^{2}} dy = \frac{\sqrt{\pi}}{2} \mathrm{erf}(y) + C$$
is the error function.


pdf to sharepoint

Question: My coworkers currently fill out a pdf file and then it is manually entered into an excel table. I am trying to automate the process by putting it in a SharePoint page. I know it is quick and easy to convert a pdf to excel. I also have found it is possible to go from excel to SharePoint. Does anyone know of a way to convert a pdf table to a SharePoint table? Or does it have to be a two part process?
Comment: How do you concert pdf table to excel in existing process? Using some 3rd party tool?
Comment: yes, and no. I haven't found one that will update an existing excel. I  manually concatenate them.
Answer: You can integrate PDF forms to SharePoint directly, using 3rd party tools like PDF Share Forms. You can find details on their homepage www.pdfshareforms.com. Our company has been using PDF Share Forms products for about a year and our HR department is really satisfied, because they are able to create forms by themselves. I am happy as well, since there is much less load on IT dept with all this form related questions....

pdf to sharepoint


How do I put an image onto the surface of a mesh?

Question: How do i get the .tga image on the right onto the mesh on the left?

thank you
Answer: If you just want to make an object use your image texture, try creating a new material under your "Material Properties" tab, then choosing your image.

As long as you have unwrapped your Object, your image should be applied to the object. If it looks stretched, choppy or just tiled in a way you don't like; this is a reference to a node structure I use for my meshes.
But if you are planning on using images as like a background or even a wall, there is one option for you that I use pretty consistently and is built right into blender!
First thing you will want to do is go to your User Preferences under File -> User Preferences. next, go to the Add-On Tab in the middle and search for an Add-On called Images as Planes. Once you find it, click the little check box and close the User Interface window. Now, you can press Shift - A to add a new mesh as you normally would and instead of choosing a mesh, go to the bottom and select "Images as Planes". This will bring up a new window where you can choose your image file, and once it has been imported it will show up in your world as a plane.