How to use Clebsch-Gordan coefficients for 3 particles?

Question: I have a Hamiltonian for 3 particles of spin 1 that I boiled down to:
\begin{equation}
k(\textbf{S}^2+\cdots),
\end{equation}
where:
\begin{equation}
\textbf{S}=\textbf{S}_1+\textbf{S}_2+\textbf{S}_3.
\end{equation}
I read somewhere on the internet that the Clebsch-Gordan coefficients were the thing to use to figure out the value of $\textbf{S}^2$, but I'm not seeing it. Could someone explain to me how to use the Clebsch-Gordan coefficients for this case? - In particular, I understand (more or less) Clebsch-Gordan coefficients for adding two angular momenta, but here, I have 3 particles. Is there an equivalent of Clebsch-Gordan coefficients for three angular momenta $j_1,j_2,j_3$?
Comment: The Clebsch Gordan coefficients will help you relate the total |SM> basis to the direct product basis |s1m2>|s2m2>|s2m2>.
Comment: Due diligence: [Racah coeffs](https://en.wikipedia.org/wiki/Racah_W-coefficient) .
Comment: Related: [Adding 3 electron spins](http://physics.stackexchange.com/q/29443/8563).
Answer: Clebsch-Gordan coefficients let you treat n spins (or generaly - any n particles with arbitrary angular momentum) as a single composite system. The coefficients are simply the matrix element of basis transformation from seperated to composite system.
For 2 particles with total angular momentum eigenvalues  $ l_1,l_2 $, such that for example $ m_1=-l_1,-l_1+1,...,+l_1 $ the composite system is -
$$ (l_1) \otimes (l_2) \sim (l_1+l_2) \oplus ...\oplus(|l_1-l_2|) $$
2 spin half particles reduce to -
$$ (\frac{1}{2})\otimes(\frac{1}{2})\sim (1)\oplus(0) $$
the left size decribes 2 particles, each has spin 1/2 ,and you can decribe the sany system configuration by combination of those spins -
$$ |++\rangle , |+-\rangle, |-+\rangle, |--\rangle $$
the right side describes the system as composite system, which can be described by it's total angular momentum and it's total $z$ component -
$$ |S_{tot}=1,m_s=1\rangle ,|S_{tot}=1,m_s=0\rangle , |S_{tot}=1,m_s=-1\rangle , |S_{tot}=0,m_s=0\rangle ,$$
As I said, the Clebsch-Gordan coefficients are the basis transformation matrix elements, for example, one of them is -
$$ \langle++|S_{tot}=1,m_s=1\rangle $$
The way to add 3 spins is first to add 2 of the and then to add the third one to the composite system -
$$ [(\frac{1}{2})\otimes (\frac{1}{2})]\otimes (\frac{1}{2})\sim [(1)\oplus(0)]\otimes(\frac{1}{2})\sim [(1)\otimes(\frac{1}{2})]\oplus[(0)\otimes(\frac{1}{2})]\sim  (\frac{3}{2})\oplus (\frac{1}{2})\oplus(\frac{1}{2})$$
(notice the first addition. the later one is "conditional" - if S1+S2=1 then ... if S1+S2=0 then)
so the new basis, in order of $ |S_{tot},S_{1+2},m_{tot}\rangle $ is
$ |\frac{3}{2},1,-\frac{3}{2}\rangle,|\frac{3}{2},1,-\frac{1}{2}\rangle,|\frac{3}{2},1,\frac{1}{2}\rangle,|\frac{3}{2},1,\frac{3}{2}\rangle,|\frac{1}{2},1,\frac{1}{2}\rangle,|\frac{1}{2},1,-\frac{1}{2}\rangle,|\frac{1}{2},0,-\frac{1}{2}\rangle,|\frac{1}{2},0,\frac{1}{2}\rangle $
this is enough for most applications (finding energy spectrum and such)
Comment: Yes, this is the general method to add the spins/angular momentum of any number of particles. Notice that the coefficients are required only if you need an explicit representation of the new states in terms of the old ones. Many questions might be answered even without knowing the specific Clebsch-Gordan coefficients, but only with the final quantum numbers (that determine the configuration of the system) (questions that require to know the eigenvalues of the composite system, such as energy spectrum, but not the eigenvectors)
Comment: Thanks Alexander! So in the case of 3 spins, I need to use the CG coefficients twice, for adding 2 spins, then again to add them to the third spin?
Comment: Thanks - yes, I realized that, I can get energies and degeneracies just with the sum decomposition. Very neat!
Answer: Be aware that the order in which you do the couplings matters, in the sense that $(j_1\otimes j_2)\to j_{12}$ followed by $j_{12}\otimes j_3\to J$, usually written as $(j_1j_2)j_{12}j_3 J$, will not produce the same basis states as coupling $j_2\otimes j_3\to j_{23}$ first, and then coupling
$j_1\otimes j_{23}\to J$, or $j_1(j_2j_3)j_{23}J$.  The two sets of basis states are related by a unitary transformation that is used to define Racah coefficients as overlaps between the two bases.


Why does lightning strike lightning rods sometimes?

Question: I watched some videos and read a lot of posts mentioned that pointy shaped objects create denser electric field than other objects (especially spherical ones), that's why people use pointy and conductive metals to make lightning rods. As the clouds started to gather charges ( usually negative ions ) the lightning rods with high electric field will attract the charges so that the clouds cannot create high enough voltage to ionize the air between them and the ground. However, the lightning rods are still struck sometimes. And this is what I wonder: When the lightning rods are struck, does it mean that the clouds gather charges faster than the rods? And do the sparks only happen when there is a huge amount of ions in the air and when they recombine to form neutral particles, they emit energy in the form of light which makes the lightning glow?
Answer: A positive cloud overhead will attract electrons and cause a significant build up of negative charge in the ground (or water) below it. A high, sharp, well grounded rod can bleed this induced charge into the air, reducing the field between cloud and ground, and reducing the probability of a strike.  I'm not sure that this would work for a negative cloud.  I have endured several lightning storms while anchored in shallow (salt) water in my sailboat (some well offshore). My boat has a sharpened metal ribbon clamped to the top of the mast, and I drop grounding wires from the side stays into the water. The one strike that I am aware of sounded more like a sizzle than a boom.  At home, my outside TV antenna post has a similar ribbon at the top and it has been struck at least twice (I think because the ground was dry, and my grounding rod does not go deep). (In south Florida we get a lot of lightning.)


convert Excel to csv either using shell script or jython . if so how

Question: I am looking for a procedure where i can convert the excel to csv either if there some shell script , if so please guide me or if possbile how can i do in jython.
The main reason is that the excel is being received from other source and the header is always changing , which is unnecessary and we need to have some automatic way to remove that . If is it possible to do that easily using jython or shell script and remove only the first line of the excel
Thanks in advance.
Answer: To convert between various file formats I use: PyODConverter. There is Python and Java version.
It uses OpenOffice working as a service and can convert between various document formats including MS Office, PDF and text.
There is also pure Python library: xlrd Library for developers to extract data from Microsoft Excel (tm) spreadsheet files


Wifi: not configured

Question: I was removing a wifi network and after removing it, my wifi icon is blank, showing a cross over it, while i hover over it which says Not Configured, I googled the problem but didn't find any solution to the problem, I tried reinstalling mavericks, while everything (user, setting and everything remain same) the problem remain same too. What can be the problem? How can I fix it?
  and
Comment: Go to about my mac => more info => system report => Network => WiFi and post a print screen
Comment: @Thomas I edited the question and posted a screenshot, not on PC but from mobile
Comment: Thanks, could you also provide one with about my mac => more info => system report => Network ?
Comment: @Thomas  I updated it
Answer: Rather than removing a Wi-Fi network, it appears you've removed the Wi-Fi service. In OS X prior to 10.10, this means the AirPort shows Not Configured.
To allow configuration of AirPort, you need to add the Wi-Fi service back to the list of services:

Go to System Preferences → Network and click the + button to add a service.
Select Wi-Fi as the Interface and provide a service name.

This will allow configuration through the menu bar item.
Comment: @Georhe Garside it worked, thanks mate. Should I delete the screenshots from question as it MAC address?
Comment: @Nofel No problem! You can if you want; it'll still be in the question's revision history though. Flag for a moderator if you want an older revision deleting.
Comment: @grgarside It works well for macOS Sierra! Thanks a lot.
Answer: As even after installation, your hardware is not functioning, then it certainly HS. Do an Apple Hardware Test in advance mode (could take time)

Wifi: not configured


Temporary download folder for Steam on Mac

Question: I want to know this, because I deleted some ncf/gcf files for portal 2, because the updating was stuck. And now it wants to download it all (11GB) again, so it would be nice if I could copy the content to the download location, without Steam noticing.
Comment: Aren't you worried about file corruption that might cause Steam to choke again, resulting in all 11 GB having to be redownloaded anyway?
Comment: @The Annoying Pyro: Even if some files are corrupted, Steam won't have to download all of them. The new format (`NCF`) which is used for all newer games including Portal 2 is able to download indiviual files instead of whole packs (`GCF`).
Answer: Game files are stored in ~/Library/Application Support/Steam/SteamApps (NCFs and GCFs) and ~/Library/Application Support/Steam/SteamApps/common (for files extracted from GCFs or referenced by NCFs).
Copying and pasting files there might work as expected but - as "The Annoying Pyro" mentions above - is prone to (existing) file corruption. So I would recommend the following  procedure:

Copy the files in place
Let Steam download missing files
Let Steam check file consistency (and download corrupt ones again)

Please note that this might not work as well as I might look in the first place. Steam might want to download all files again when it thinks they are corrupt. But it's worth a try.
Answer: I would let Steam download whatever it wants to right now and reach a stable point.
(or you could rollback from your Time Machine backup).
When you have something that works, then consider asking Steam to back up your files to external media so you have working files next time you want to restore something.


How to build opencv in ios

Question: I have compiled openCV 3.1 with contrib modules using cmake gui following this link. The files have been generated but how do I use it in my ios project? Is there a way to create the opencv.framework file or do I just import the whole built folder into my XCode project.
Comment: Why do you need something like that? You already have opencv.framework compiled
Comment: I need the modules xfeatures2d and xphoto to follow along a textbook
Answer: Maybe it would be simplest to use command line instead of using CMakeGUI to build openCV with additional modules.
CMake must be installed, of course.
Create somewhere in a place suitable for you a new folder
>mkdir ~/your_open_cv_dir
>
>cd ~/your_open_cv_dir
>
>git clone https://github.com/opencv/opencv.git

If your need extra modules clone their sources too
>git clone https://github.com/opencv/opencv_contrib.git

Your your_open_cv_dir can have inside 2 folders,
opencv and opencv_contrib
Make a symbolic link for Xcode to let the OpenCV build scripts find the compiler, header files etc.
>cd /
>
>sudo ln -s /Applications/Xcode.app/Contents/Developer Developer

Build OpenCV framework:
>cd ~/your_open_cv_dir
>
>python opencv/platforms/ios/build_framework.py ios

In case you need extended version of OpenCV build it with extra modules
>python opencv/platforms/ios/build_framework.py ios --contrib opencv_contrib

Comment: To add onto @Dimitry 's answer, specifying which modules to load will reduce any errors you may encounter in xcode and reduce the time it takes to build. For example, you can exclude moduls using the --without _modulename_ argument. Last, the `opencv_contrib` argument is a relative path to the opencv_contrib
Answer:
Look for opencv2.framework in opencv/platforms/ios/ios/opencv2.framework (if you followed the cmake instructions correctly, the framework should have been built there). If you built opencv_contrib separately, the framework will be under opencv/platforms/ios/ios_contrib/opencv2.framework.
Drag opencv2.framework into your Xcode project. Make sure you check "copy items if needed".
In "Build Phases", under "Link Binary with Libraries", add opencv2.framework. This might do the trick. You can check by importing an OpenCV header in one of your Objective-C++ files and seeing if Xcode can find it. If not, follow the next steps to specify a header search path.
In your project's "Build Settings", add $(PROJECT_DIR) to "Framework Search Paths", "Header Search Paths", and "Library Search Paths".
Now you can import OpenCV header files (.hpp files) in your Objective-C++ code.

How to build opencv in ios


Is it sin to touch your sister with lust?

Question: In quran it is mentioned that you cannot marry or have intercourse with your sister but can we touch them with lust without ejaculating, can we touch their awrah what is between navel and knee over their clothes?
Comment: This is not important but can I ask how this question occurred to you
Answer: It is haram to look at or touch a mahram (such as your sister) with lust. A Mahram by definition is someone with whom sexual intercourse is haram. A mahram can not be made lawful, even by means such as marriage which make other women lawful. And the precursors of sex  (such as lustful touch) come under the same ruling as sex itself.

وقد اتفق الفقهاء على أن النظر إلى المرأة بشهوة حرام، سواء أكانت محرما أم أجنبية ... متى حرم النظر حرم المس بشهوة
The jurists are in agreement that it is haram for a man to look at a woman with lust , regardless of whether she be his mahram or a stranger ... and what is haram to look at is also haram to touch with lust
— Mawsoo'ah al-Fiqhiyyah

Consensus is evidence by itself. Further it is also evident by reasoning from the following texts:

والذين هم لفروجهم حافظون إلا على أزواجهم أو ما ملكت أيمانهم فإنهم غير ملومين فمن ابتغى وراء ذلك فأولئك هم العادون
And they who guard their private parts. Except from their wives or those their right hands possess, for indeed, they will not be blamed. But whoever seeks beyond that, then those are the transgressors.
— Quran 23:5-7

This verse forbids obtaining sexual pleasure by means of any person other than your wife or concubine. Touching with lust causes ones private part to experience pleasure, and is contrary to 'guarding' it. Hence it comes under "whoever seeks beyond that" and is haram.

ولا تقربوا الزنا
Do not even go close to fornication
— Quran 17:32

Touching with lust tempts one closer towards zina. Zina with a mahram is haram. Whatever invites one to Haram is itself Haram.

فالعينان زناهما النظر ، والأذنان زناهما الاستماع ، واللسان زناه الكلام ، واليد زناها البطش
The Zina of the eyes is looking, the Zina of the ears is listening, the Zina of the tongue is speaking, the Zina of the hands is touching
— Muslim

Looking and Touching are types of Zina. Hence they are haram and must be avoided. Zina with a mahram is more reprehensible than Zina with a non-mahram hence is more severely haram.

قل للمؤمنين يغضوا من أبصارهم
Tell the believing men to lower their gaze
— Quran 24:30

This is a general and unconditional command to lower one's gaze i.e. to not look. By default it includes looking at mahrams with lust - as there is no evidence which excludes it. And when looking is haram then touching is worse than that, so it is also haram.

وفرقوا بينهم في المضاجع
When your children become ten years old ... arrange their beds (to sleep) separately.
— Abu Dawud

This is to prevent any immoral act between the males and females. Touching with desire is more serious than sleeping together and hence is more deserving to be haram.
Answer:
Abu Huraira reported Allah's Messenger (ﷺ) as saying.
Allah fixed the very portion of adultery which a man will indulge in. There would be no escape from it. The adultery of the eye is the lustful look and the adultery of the ears is listening to voluptuous (song or talk) and the adultery of the tongue is licentious speech and the adultery of the hand is the lustful grip (embrace) and the adultery of the feet is to walk (to the place) where he intends to commit adultery and the heart yearns and desires which he may or may not put into effect.
 [Sahih Muslim 2658a]

As stated above, touching or grabbing someone with lust would be adultery of the hand. And we all know that adultery is haram (prohibited).  Hope that answers the question.


How does one get better at real analysis proofs?

Question: How does one proceed through a math proof in real analysis? My instructor always says make a diagram, but I am not a visual learner. It seems that whenever I write out the definition of an assumption, then I cannot make the next logical step. Also, when I go to try to verify that my proof is correct, I ask myself questions like, "why must this be true?" but the proof does not end up not being air tight. For those that have had real analysis, what did you do to master proofs and do the exercises?
Comment: This might not be the answer you are looking for, but honestly, it is practice. You start building up intuition for these results. A lot of people, including myself, start with the same problem you are starting with, but as you keep on doing these proofs, you will start developing an intuition. I wonder what other people have to say about this. The point is, don't get demoralized by the fact that you don't have the intuition right now.
Comment: Visit MSE everyday and look at the `real-analysis` tag.
Comment: @Luis. How do you practice?
Comment: The point is that there are plenty of resources out there. If your textbook is too difficult for you at the moment, get an easier one. Remember that there is nothing wrong with going back to the basics. Think about what you know from basic calculus. Do you understand the definition of a sequence converging? That's a great place to start. Especially for $\epsilon$ type proofs. If you are using baby Rudin, try getting a different textbooks to go along with it.
Comment: @Luis. I see what you are saying. Can you offer me a list of resources preferably online that contain solutions?
Answer: Most of the theorems in real-analysis (especially those in introductory chapters) are intuitive and based on the concept of inequalities. If one understands the concept of inequalities (not in the sense of memorizing AM greater than equal to GM or other famous inequalities) in terms of comparison of numbers most of the common proofs are trivial applications of the definitions.
I will provide two examples:
1) If $f$ is continuous at $x = a$ and $f(a)$ is positive then there is a neighborhood of $a$ in which $f$ is positive.
Now one has to know what is meant by continuity to prove this. Informally this means that values of $f(x)$ are arbitrarily near $f(a)$ if $x$ is sufficiently near $a$. The $\epsilon, \delta$ are used to quantify "arbitrarily" and "sufficiently" in a formal manner. Now if we see that $f(a)$ is positive then there is a range of values near $f(a)$ which are positive. Hence if $x$ is sufficiently close to $a$, $f(x)$ will take values in the range near $f(a)$ and these are all positive as mentioned in last sentence.
2) If $f(x) \leq g(x)$ in a neighborhood of $a$ and both $\lim_{x \to a}f(x), \lim_{x \to a}g(x)$ exist then $\lim_{x \to a}f(x) \leq \lim_{x \to a}g(x)$.
Clearly let $A = \lim_{x \to a}f(x), B = \lim_{x \to a}g(x)$. Suppose $A > B$. Now values of $f(x)$ are near $A$ when $x$ is near $a$. Similarly values of $g(x)$ are near $B$. Since $A > B$ we can obviously make values of $f$ much nearer to $A$ compared to $B$ and values of $g$ much nearer to $B$ compared to $A$. We will find that this leads to values of $f$ being greater than some values of $g$ and we get contradiction.
Thinking in terms of inequalities as a way of comparing magnitudes and numbers is the key to these kinds of proofs. However thinking in this fashion is not easy for a beginner as he is trained to think in terms of operations like $+, -, \times, /$ and not $< , >$. As a further example consider the two following facts:
a) There is no rational number whose square is equal to $2$ (i.e. $\sqrt{2}$ is an irrational number).
b) If $a$ is a positive rational such that $a^{2} < 2$ then there exists another rational $b$ such that $a < b$ and $b^{2} < 2$.
The proof of statement a) is mostly algebraical and can be figured out easily if we know simple facts about integers and their factorization. The proof of statement b) is not easy unless we know how to deal with inequalities (reader can convince himself by trying to prove this). I consider this to be the fundamental difference between algebraic and analytic approaches and a beginner in analysis must make a transition from understanding statements like a) to understanding statements like b).
Answer: I think the best thing to do is to learn and understand the proofs of the theorem you do in class. The key thing about analysis (as opposed to algebra) is that all the proofs have a pattern to them.
For example: The proof of sequence of continuous functions converges uniformly to a continuous function uses the idea called $\frac{\epsilon}{3}$ argument. By knowing this technique, you can do a number of other proof that involves convergence and continuity.
Comment: And then you reach the point at which you realize that proving that so-and-so is less than $3\epsilon$ is good enough, so you don't bother with $\frac{\epsilon}3$.
Comment: Triangle inequality for the win!
Comment: If you get parts of a sum so that each part is bounded by a constant times $\epsilon$, then the total is bounded by another constant times $\epsilon$. That is good enough for me. This manipulating proofs so that the final bound is exactly $\epsilon$ is, to me, an exercise in magic numbers that often obscures the true nature of the proof.
Comment: @user44322. I see. But if I want to solve more difficult problems that may not employ such a technique, then what do I do? I seem to be able to do epsilon-delta proofs, like proving that a function is continuous using the definition, but I just get stumbled when the exercises are not standard. How do I get beyond this?
Comment: Every question falls in some category. There will always be similar question in that category. Can you give us an example?


how do I get stable connection of WiFi on my Samsung tablet A

Question: My Samsung tablet A, gets disconnected immediately after connecting to router WiFi at my home. But at my office I do not face this problem with the router over there. Can you help me?
Answer: Do you know if your router is wireless n and if there is a switch to change it to wireless g. Try to change channel in router also.


Is it okay to have wildly varying chapter lengths in a fantasy novel?

Question: I'm currently writing a fantasy novel and it's my first piece of work. My chapters currently range from 500 to 3,350 words. Is this too much of a dramatic change? Should I go back and pad out some of the shorter chapters? Am I overthinking it, or is chapter length that important?
Comment: @MacCooper Ha! Shows what you know: I don't have an answer for this one. :P ;)
Comment: I'm sure What or Lauren Ipsum will make an answer shortly :D but I'd just comment, while mostly the answer is "however long" you do need to keep in mind your medium. Eg, if you're publishing in chapter incriments either free or paid, a 10 word chapter will leave people who are waiting for it dissatisfied. If you're writing for a specific medium (or even for a specific publisher), adding that into your question would give you a better answer :)
Comment: Relevant, possibly a duplicate: [What is a normal length for a chapter?](http://writers.stackexchange.com/questions/41/what-is-a-normal-length-for-a-chapter)
Comment: Thanks guys, think i'll probaly be alright with the length they are. I'll get someone to read it and give me their opinion on it.
Answer: Chapter length is important. Consistency of chapter length is not.
A few ways to use chapter length:

Think of chapters as a pacing tool. All other factors being equal--which, of course, they never are--longer chapters tend to slow the pace, shorter chapters to increase the pace.
The length of a chapter can suggest (perhaps subtly) the importance of the events in the chapter. A longer chapter can give more weight to the events, a shorter chapter less weight.

These two effects often fight with each other.
Comment: That's some good advice I had not thought of. It makes perfect sense, although I think chapter length will contribute to pacing WAY more than weight, IMO.
Comment: I disagree with your second point. Quite to the contrary, shorter chapters can be more focussed and the events they describe thus gain more impact. Think of "Chapter 10: Paul died. Chapter 11: bla bla" The death of Paul in the one-sentence chapter 10 will be the most significant event in the whole novel.
Comment: @what I think he meant that the length of a chapter can *suggest* importance. All bets are off once you start reading the chapter. Just by looking at the length though, a reader might think, 'hmm, a lot must happen in this one.'
Comment: I did try to hedge on that one with "can." Perhaps a more emphatic qualifier is in order.
Answer: Assuming there are no requirements for chapter length you are supposed to meet, I don't believe it matters. Some books maintain a steady chapter length of twenty or so pages (Harry Potter), but I've seen several with a page long chapter, followed by an extremely long one (Inheritance Cycle). Still yet others maintain short chapters throughout (Anne of Green Gables). In my experience, such ranges don't really mess with the pace/flow.
Answer: In my opinion, everything about a novel or other piece of writing must follow from its whole. If the lengths of your chapters follow narurally from the story.you are telling, then those are the lengths they must have. Word count is the wrong way to evaluate writing (unless you write specifically for a certain word count, as in academic or news writing). Let someone read what you wrote and tell you what might be too much or missing. Don't follow the advice of a word counter.
Comment: As an extreme example of this in Eric Flint's Forward the Mage (which is a satirical fantasy novel) there are several chapters consisting only of titles. In that book, not only does it work, it works very well.
Answer: Is this too much of a dramatic change? Unless your book is to be serialized by chapter, it doesn't look like an issue.
Should I go back and pad out some of the shorter chapters? Not necessarily. If a read-through demonstrates that the flow is not how you want it to be, chapter length may be changed, although usually indirectly: you may erase some slow parts, or tighten up some other parts, or put in some dialogs, descriptions or previously removed scenes. As a rule of thumb, what happens on a given chapter and how it is portrayed is the driving force for chapter length. Unless your book is to be serialized, as I said earlier.
Am I over thinking it, or is chapter length that important? You may as well use the chance to get some work done. You can make chapter length important if you give it meaning within your writing.
As stated by @Dale Emery in his answer, chapter length can be used to great effect. I like @what's take on it: "Chapter 10: Paul died." is a very powerful effect, especially if you take care to make all of the other chapters long by comparison.
Answer: Whatever you do, do not pad out chapters.  You want them to contain nothing superfluous.
Instead, look at their structure.  Are the chapters logical units?  Does it make sense to group these scenes together, rather than chop them in half, or group them with the next ones, or chop them in half and then group them with the ones before or after?
If you have chapters that have logical structure even though they are both short and long, go with it.
If you want more uniformity, I would look rather to split long chapters than pad short ones.  And if splitting didn't work, consider merging the short ones before padding them.
Answer: I am also writing a fantasy book and have found that chapter length doesn't matter too much. A lot of the time, chapter length only puts stress on you as a writer. If you're trying to reach consistent chapters of, let's say 3,000 words, but you can only make it to 2,000, so be it! Chapter length paces the book and helps to emphasize the action. If your chapters are too long, it tends to drag on too much information and the reader gets lost or bored. If it's too short, then the events seem anticlimactic.
Just read through it and give it your best judgement. If you plan on publishing this, it would be wise to run it by an editor.


How to perform SIA or Bezier line smoothing in PostGIS?

Question: Can anyone provide an example SQL for smoothing linestrings from postgis table using Bezier curves or Iterative Averaging (SIA) algorithm?
Answer: I created a small, naive script which converts input LineStrings to CompoundCurves based on some heuristics.
What it does:

Cuts down sharp corners to create a visually more appealing results than the original data.
Uses plpgsql. No additional extensions required.
Accepts an optional "smoothing factor" between 0 and 100 besides a geometry.

What it doesn't do:

Processes MultiLineStrings. For any other geometry type, it simply returns the input.
Uses Z and M values. It simply drops them. Use this only for 2D cartographic purposes.
Creates mathematically correct results. The results are far from correct, and might be even visually unaesthetic in some cases (e.g. sharp corners). I didn't test it thoroughly. Always review the results!
Runs fast. I'm sure it can be rewritten to a far more optimal form.
Does real smoothing. There are much better algorithms (e.g. Chaiken or the ones mentioned in the question) to use for real smoothing. This answer targets people like me searching for a pure PostGIS approach automatically creating some kind of curved lines from real data.

The script:
CREATE OR REPLACE FUNCTION CreateCurve(geom geometry, percent int DEFAULT 40)
    RETURNS geometry AS
$$
DECLARE
    result text;
    p0 geometry;
    p1 geometry;
    p2 geometry;
    intp geometry;
    tempp geometry;
    geomtype text := ST_GeometryType(geom);
    factor double precision := percent::double precision / 200;
    i integer;
BEGIN
    IF percent < 0 OR percent > 100 THEN
        RAISE EXCEPTION 'Smoothing factor must be between 0 and 100';
    END IF;
    IF geomtype != 'ST_LineString' OR factor = 0 THEN
        RETURN geom;
    END IF;
    result := 'COMPOUNDCURVE((';
    p0 := ST_PointN(geom, 1);
    IF ST_NPoints(geom) = 2 THEN
        p1:= ST_PointN(geom, 2);
        result := result || ST_X(p0) || ' ' || ST_Y(p0) || ',' || ST_X(p1) || ' ' || ST_Y(p1) || '))';
    ELSE
        FOR i IN 2..(ST_NPoints(geom) - 1) LOOP
            p1 := ST_PointN(geom, i);
            p2 := ST_PointN(geom, i + 1);
            result := result || ST_X(p0) || ' ' || ST_Y(p0) || ',';
            tempp := ST_Line_Interpolate_Point(ST_MakeLine(p1, p0), factor);
            p0 := ST_Line_Interpolate_Point(ST_MakeLine(p1, p2), factor);
            intp := ST_Line_Interpolate_Point(
                ST_MakeLine(
                    ST_Line_Interpolate_Point(ST_MakeLine(p0, p1), 0.5),
                    ST_Line_Interpolate_Point(ST_MakeLine(tempp, p1), 0.5)
                ), 0.5);
            result := result || ST_X(tempp) || ' ' || ST_Y(tempp) || '),CIRCULARSTRING(' || ST_X(tempp) || ' ' || ST_Y(tempp) || ',' || ST_X(intp) || ' ' ||
            ST_Y(intp) || ',' || ST_X(p0) || ' ' || ST_Y(p0) || '),(';
        END LOOP;
        result := result || ST_X(p0) || ' ' || ST_Y(p0) || ',' || ST_X(p2) || ' ' || ST_Y(p2) || '))';
    END IF;
    RETURN ST_SetSRID(result::geometry, ST_SRID(geom));
END;
$$
LANGUAGE 'plpgsql' IMMUTABLE;

As it returns curves in a geometry type, if you would like to use it in a GIS such as QGIS, you have to wrap it into PostGIS functions converting them around. The intended use syntax is:
SELECT ST_AsText(ST_CurveToLine(CreateCurve(geom))) AS geom FROM linestringtable;

Comment: This was a lifesaver! Thank you for the script. It seems like Chaikin smoothing will become available as a function from postgis 2.5 onwards, which I'm looking forward to.
Answer: This is still an open issue in PostGIS (and other GIS tools) as stated in the book "PostGIS in Action" in chapter 2.2.6 "Curved geometries".
Here are some references to algorithms and code:

http://www.codeproject.com/Articles/31859/Draw-a-Smooth-Curve-through-a-Set-of-2D-Points-wit
http://www.antigrain.com/research/bezier_interpolation/index.html (also used by LineSmoother function in JTS!)
http://www.java2v.com/Code/Java/2D-Graphics-GUI/Interpolatesgivenpointsbyabeziercurve.htm
http://www.ibiblio.org/e-notes/Splines/Bezier.java
Comment: I added the http://postgis.17.x6... links
Answer: You can try to convert your linestrings to curves with ST_LineToCurve and then back to linestrings with ST_CurveToLine.
You can set the number of segments per quarter circle you want in ST_CurveToLine.
Comment: LineToCurve is built to handing the outputs of CurveToLine, not to extract curves from arbitrary input.
Comment: @PaulRamsey would bezier smoothing be added in next Postgis versions? I've been thinking on something like this for instance: http://webhelp.esri.com/arcgisdesktop/9.2/index.cfm?TopicName=How%20Smooth%20Line%20(Data%20Management)%20works
Answer: My take on smoothing - Smoothing Iterative Averaging (SIA) + ST_SimplifyPreserveTopology using PostGIS:
Keep in mind for good results: ss < si, sl = 0 if ss > 1
sl is my addition to algorithm to not change longer segments as I use it for smoothing out GPS accuracy issues in line tracks. After SIA I also use St_SimplifyPreserveTopology to remove tiny nuances and downsize number of vertices. I don't care about 3D and have only Line Strings. Shouldn't be hard to adapt if you use multiline strings and 3D.
Usage:
update table_name set geom = ST_SimplifyPreserveTopology(ST_SIA(geom, 1, 3, 20), 1);

Function:
-- Smoothing Iterative Averaging (SIA)
-- Parameters:
-- Smoothing Sensitivity (ss) - positive integer
-- Smoothing Iteration (si) - positive integer
-- Smoothing Limit (sl) - 0+ numeric - maximum distance between neighbouring vertices, 0 = do not apply limit
create or replace function ST_SIA(geom geometry, ss int default 1, si int default 5, sl numeric default 0)
    returns geometry as $$
declare
    p_prev geometry;
    pi geometry;
    p_next geometry;
    new_line geometry;
    s integer;
    i integer;
    i_prev integer;
    i_next integer;
    p_count integer;
begin
    if ss < 1 or si < 1 or sl < 0 then
        raise exception 'Smoothing sensitivity and smoothing iteration must be positive integer! Smoothing Limit 0+!';
    end if;
    if ST_GeometryType(geom) != 'ST_LineString' or ST_NPoints(geom) <= ss*2+1 then
        return geom;
    end if;
    new_line := geom;
    p_count := st_npoints(geom);
    for s in 1..si loop
        for i in 2..p_count-1 loop
            i_prev := i-ss;
            i_next := i+ss;
            if i <= ss then
                i_prev := 1;
            end if;
            if i+ss > p_count then
                i_next := p_count;
            end if;
            p_prev := ST_PointN(geom, i_prev);
            pi := ST_PointN(geom, i);
            p_next := ST_PointN(geom, i_next);
            if sl = 0 or ST_Length(ST_MakeLine(p_prev, p_next)) < sl then
                new_line := ST_SetPoint(new_line, i-1, ST_Centroid(ST_MakeLine(array[p_prev,pi,p_next])));
            end if;
        end loop;
        geom := new_line;
    end loop;
    return geom;
end;
$$ language plpgsql;


$yy'=\sin(t),y(0)=1$ phase portrait

Question: I need to draw a phase portrait for the equation
$y(t)y'(t)=\sin(t)$ with the initial condition $y(0)=1$. So far i've found that $y(t)= \sqrt{3-2\cos(t)}$ and $y'(t)=\frac{sin(t)}{\sqrt{3-2\cos(t)}}=\frac{sin(t)}{y(t)}$. I am not sure how to draw this phase portrait though, and i don't want to rely on computer tools too much, if someone could walk me through on how to draw the phase portrait for this that would really help. Please show steps.
Comment: i thought you could only draw phase portraits of autonomous system of differential equations: the differential equations that don't depend on $t$ explicitly which yours does. trouble is the direction field is time dependent and this causes trouble like trajectories can go intersect in space variables at different times without violating the uniqueness  of solutions.
Comment: @abel You always can consider an extended phase space, substituting $t$ with $\theta$ and adding an equation $\dot{\theta}=1$.
Answer: Normally, the horizontal axis is $y$ and the vertical axis is $y'$.
The two points where $y'(t)=0$ are $t=0$ and $t=\pi$, which is when $y=1,\sqrt{5}$ respectively.  So you have two points $A=(1,0)$ and $B=(\sqrt{5},0)$.  You are almost done.  There is a curve above the $y'$ axis connecting $A$ to $B$, and a curve below the $y'$ axis connecting $B$ to $A$.  The result looks like an approximate ellipse.
The direction of this path is clockwise because $y'>0$ in the upper half plane, so $y$ is increasing in the upper half plane, and $y'<0$ in the lower half plane, so $y$ is decreasing in the lower half plane.
Answer: $$
y = \sqrt{3-2\cos t}\implies \cos t = \frac{3-y^2}{2}
$$
we can see that
$$
yy' = \sin t = \pm\sqrt{1-\cos^2 t} = \pm\sqrt{1- \left(\frac{3-y^2}{2}\right)^2}
$$
thus maybe you can use
$$
y' = \pm\frac{\sqrt{1- \left(\frac{3-y^2}{2}\right)^2}}{y}
$$
this crosses the $y'=0$ line at
$$
\left(\frac{3-y^2}{2}\right)^2 = 1 \\
\frac{3-y^2}{2} = \pm 1 \implies y^2 = 3\mp2 \implies y = \left\{\pm\sqrt{5},\pm 1\right\}
$$
since you can not cross $y=0$ unless you want a blow up solution then there is a symmetry about that axis.

$yy'=\sin(t),y(0)=1$ phase portrait


How to grow a tree on steroids?

Question: How can a tree be made to grow bigger and faster constantly over 100 years?
Could a full grown tree be given a constant trickle of water and a time-released nutrient pack, like huge miracle grow stick or tree steroids, would boost the tree into growing bigger?
Comment: If your only goal is improving the growth rate, then yes it's quite possible with all kinds of stuff. If you have other considerations like lumber quality, limb strength, etc, then it's pretty hard to do it and get what you want out of it.  Like with most things, speeding up growth comes at the cost of something else.
Answer: Interesting question. There are definitely ways to speed up growth, like fine-tuning soil for optimal growth. For example taking the time to test soil and amend it with any deficient macro- or micro-nutrients would improve forest/tree growth.
There will probably be trade-offs in environmental benefits trees that are "rushed". The tree quality itself may or may not be "better" for the tree use you're looking for, and the production, transport, and use of soil amendments may have more negative impact on the environment overall than the sped-up growth of the tree. Also note that slower growing trees and less "craddled" (carefully cared for) trees tend to be more resilient (if they survive into maturity that is!) Faster trees tend to be weaker and more susceptible to damage or shorter lifespans, as we see in pioneer species who's fast growth lets them fill in disturbed areas first but also with short lifespans.
Beware that rushing to fertilize is not the same as optimizing soil. Trees and other plants can be "burned" by too much of a good thing, so more is not necessarily better. Optimize growth by site selection in the first place and soil amendments based on tree needs and you'll get the best growth possible.

Anectodally, at school we once had a contest to grow climbing bean plants the fastest. Some teams fed their beans things that are stimulants for humans, like coffee or energy drinks. Surprisingly those beans did begin to grow faster than other plants, but then all those beans died off. Not a great "soil amendment" apparently! But those teams who had good site selection in terms of light and optimized soil nutrition (not too much, not too little; the right drainage; the right pH) grew the best bean plants the fastest.
Comment: To  your point, cr0 - in general, the faster a tree grows, the weaker the growth is. An oak may grow about one foot a year while an Autumn Blaze maple (a cross between silver and red maples) may reach five feet a year. After 10-15 years, it's a good bet that at least one major Autumn Blaze limb will be lost to wind damage while the oak may go decades (if not more than a century) before the same damage befalls it.
Comment: Good point @Jurp, I edited to add info about that. Thanks!
Comment: @Jurp the tree would need to be naturally dense and placed in a hospitable climate.
Answer: Your question implies an existing tree. But have you considered getting a new tree?
Paulownia tomentosa (Empress Tree) is one of the fastest-growing trees on the planet, rivalling Normandy Poplar. It will reach over a dozen feet after just a couple years, and may reach 40' in a dozen years or so. It has wonderful purple flowers that come out in the spring before the leaves. This east-Asia native tolerates -20° winter temperatures. The wood is high in tannins, and is as rot-proof as cedar, and it splits easily for fences and such. It is also a great mulching tree, with leaves as big as a yard across.

Legend is that when a Japanese farmer had a daughter born, he would plant a Paulownia seed, and on his daughter's 18th birthday, he would cut it down and make a set of furniture for her dowry.
In certain places, it is considered invasive, generally places like the US Southeast that lack hard winters. But if you mow or graze under it, the baby plants will be kept in check.
Comment: @Muze: the  answer is still no....unless GMO techniques are applied, though heaven only knows why anyone would think that was a good idea...
Comment: Good answer. GMO version of this tree if available will be a good candidate of a Miracle grown from a sprout tree. I still would like to know if there is any other then listed techniques taking a tree like the ones in the picture and make them grown faster?
Comment: That's one *nice* tree. Too bad I planted my swamp oak 10 year past. It's just now topping the second story.
Answer: No, you can't make a tree grow in a turbo charged fashion - each type of tree has its own genetic code that dictates how fast it will grow. The only thing you can do is ensure the tree you grow has absolutely optimum conditions to allow it to grow at its fastest rate, so things like making sure the tree you choose is suitable for your climate, soil and local conditions, keeping the soil in good condition with the application of composted materials as a  mulch, watering when necessary.  Unfortunately, permanently optimal conditions aren't something you can always guarantee for various reasons beyond your control, such as the weather and infestation/infection. Whatever you do though, something like a Eucalyptus gunnii will always grow much faster than, say, a Ginkgo biloba.
Answer: you can use a gene gun to insert growth speed genes & do lots (lots!) of experimenting until you get a viable product. then release your global warming reducing kudzu!
especially if you're going for maximum total tree biomass, rather than maximum individual tree biomass
i know a guy who's working on this
Comment: https://twitter.com/glimsd

sry for not being useful earlier
Comment: Could you get me some more info? This is very interesting and would like to know more.
Comment: i'm not actually sure he's going to succeed at it, but he's spent enough time working in bio labs that i bet he's right that it's possible
Comment: Any new info on this or a link to his page?
Comment: Don't forget Auxins and Gibberelins! The constant drip plan sounds like a way to encourage fungi to me.

How to grow a tree on steroids?


Subversion... practical with a PHP framework app or not?

Question: I am developing a website using CodeIgniter and PHP.  Some of my friends suggest I start using Subversion to take care of my organization.  Could someone give me a basic explanation of what SVN is without the jargon and also if it is practical for a framework where 5 files are needed to run a single page?
Answer: Subversion allows you to store your source in a central location, make changes from multiple places (ie. laptop, desktop), track changes and revert changes to your source tree if needed.
Have you ever made a big 'improvement' and then decided you were going in the wrong direction? With Subversion you can revert to the version of your source before you started heading off in the wrong direction.
Or how about this, you make some subtle changes to the codebase, but don't notice that you introduced a new bug until much later. You can use subversion to revert to previous code versions, helping you track down the change that introduced the bug.
It is more valuable when sharing the source with multiple developers, but even for my single developer projects I find it very handy to have all my source and changes in a Subversion repository.
If you combine it with Trac, you can then keep track of bugs/features, milestones, and use the Trac Wiki to document your project.
Answer: Every single project (even with only one developer) should be under source control, no matter what framework or language you are using.
Using simple words, Subversion will keep a history of your code files, should you like to revert them to a previous state or restore a copy in case of a disk crash (SVN must be on another computer in this case). It will also help you see easily the differences between two versions of a file.
For more information, just read TortoiseSVN user's guide, it has a pretty good overview of Subversion.
Here's some good info : Chapter 2. Basic Concepts
Answer: SVN is a version control system. It is used as a central repository for all of your code.
A significant strength of SVN is that it uses a Copy-Modify-Merge work flow model versus a Lock-Modify-Unlock model. The idea behind this is that each developer checks out or copies (copy) their own version of the code, works on it (modify), checks it back in and reconciles any changes (merge) that may conflict with other work another developer has done.
This is really handy as if you wanted to work on a piece of your code, you won't have to worry about the file being locked because someone else is working on it.
If anything, developers should use SVN to catalogue all revisions of their code and revert back if needed.
Answer: SVN is a version control system - which means that it stores various previous versions of a given file, and allows many people to work on the same file, and in the end put all the changes together. It also helps you go back to a previous version if necessary.
You should use that in your project if there are a lot of people working on the project. But even if you are the only one working, it will be easier to manage the project if it is on version control.
Comment: How do you actually run the scripts if they are in SVN's file system?
Comment: You will have a local copy in your favourite IDE which you can run like you would normally do.
Comment: Only thing is, you would 'check in'(upload) your updates to the SVN server so that it can keep track of the versions.
Answer: It's a way to keep control of versions. You could think of it as some kind of incremental backup. You send your code to the SVN server and it saves only the differences from the last version. This way, you can go back to an earlier version if you need it. It also allows you to work with more people and merge differences with ease. I say, you should use it. It's easy and useful.
Answer: Irrespective of what software you produce and even if you are on your own, SVN has to be used. I depend on it every day. Its the one software tool I could not live without. If you can install it off-site it gives you backup as well.
Simple things like being able to do a diff on the previous version of a file when you are making changes, can be a great help.
Use Toortoise under windows for the client side. It integrates into Windows and is just great to use.


Why is local copy writable by default in SVN, but readonly in Perforce/TFS?

Question: I have some experience with Perforce, SVN, and TFS. For SVN, The source files were by default writable after synchronization. However, they were readonly for Perforce, as well as TFS if memory served me.
Meanwhile, 'checkout' means source sync for SVN but its meaning is quite different for other popular tools.
I'm wondering which is more 'correct' behavior and why these tools behave differently.
Thanks.
Comment: Checkout Mercurial and Git, you're in for a big surprise... Also the concept is called "software configuration management", revision control is just a part of it, and you can't really expect different tools to have exactly the same approach in everything, what would be the purpose of having different tools then? There's rarely a "correct way" when implementing a software concept, that's a fallacy. It's a concept, not a formal standard (but implementations of those differ too)...
Comment: I think the concept for version control should keep consistent.
Comment: @ZaphodBeeblebrox: But SVN and Perforce are *just* revision control -- They're nowhere near a full SCM system. (TFS has other features, but is probably not a full SCM either.)
Comment: @SeanMcMillan Hmm, the (subtle?) point of my comment was that the question is unsuitable for Programmers, because OP doesn't seem to had (at least minimally) researched the basic concepts involved in it. The other point was that revision control is part of a larger concept, and several of the subtle differences between implementations are exactly because tools implement (or at least try to) some of the other concepts of SCM (even minimally).
Answer: There used to be two different ways or paradigms with source control.  These were:

Get latest/checkout (locking for other users)/edit/commit
Checkout (not locking for other users)/edit/merge/commit

The first was used by VSS, whereas svn uses the second by default.
(TFS has evolved from VSS and I believe Perforce used cvs as a starting point)
Using the first paradigm, when getting files from the repository, you haven't said that you want to edit them and the source control marks them as readonly to force you to explicitly 'checkout for edit' the file you want to alter.  VSS had commands to 'get latest' and checkout' - and it was checkout that marked the field as editable (and locked it in the repository by default so other couldn't edit the same file at the same time).
This leads to issues if one developer checks out and locks a particular file and then goes off on leave, etc.  His colleagues cannot edit the file without breaking the lock or hacking into his account.
Subversion uses the 2nd, edit/merge/commit paradigm.  There is no command to 'get latest' without the ability to edit the file - there is only the checkout command.  Several developers can modify a same file a the same time.
This leads to other issues at commit.  If you and I have both edited the same file, and you commit your changes first, I cannot commit my version without first merging in your changes.  There is a risk here that I don't understand the changes you've made and I alter the file so it does what I wanted and breaks the change you had made.
Both paradigms have potential issues, but in my opinion the checkout/edit/merge is better.  If multiple developers are editing the same files at the same time and have difficultly merging the changes, I believe you've got problems with the code structure and the inter-team communication that cannot be solved by source control tool alone.
In order to avoid the issue when one developer has a file locked and cannot be contacted to release the lock, some source control systems allowed locks to be broken or overridden.  Some also allow the repository to be set such that some files are not locked and then have to be merged prior to commit - i.e. using an amalgamated checkout/edit/merge/commit.  Because of their provenance, their 'get latest' command obtains a read-only copy and insists that you 'checkout for edit' in order to get a writable copy, but they then follow the same flow as subversion with the editing and merging before commit.  This is how Perforce works.
In order to mitigate the cannot merge changes issue, Subversion does allow the repository to be setup to require locking for some or all files.  (I've used this is the past to ensure MSWord documentation that was a pain to merge could only be updated by one user at a time, and similarly with picture/icons.)
Comment: CVS was the first tool that used the edit/merge/commit cycle by default, though it does support locking (so please remove "and I believe cvs"). Subversion does support locking, so you should say "by default uses the second", not "always uses the second" (only distributed systems always use the second, since they don't have a central authority to arbiter any locks).
Comment: @JanHudec Thanks, my memory is obviously not what it used to be.  Updated accordingly.
Comment: @Grhm, first I agreed that checkout/edit/merge style is better. Secondly, like what you said, explicit 'lock' command should be better than 'checkout' and 'lock' by default, and it's the way I think how tools evolved. Thanks.
Comment: Also, there's another cool advantage of the checkout/edit/commit approach: You can query the VCS to find out who is currently working on which file(s).
Comment: I'm not disputing your answer, but TFS probably has more in common with perforce than VSS. MS use(d) a customised version of perforce internally. Also the next version of TFS will add local workspaces which will behave in a similar way to SVN


Staying in the EU past my 90-day work agreement

Question: I'm a non-EU citizen with a 90-day work agreement for Germany as a sort of student program. After these 90 days, I want to stay for no more than a week to go on a vacation with my girlfriend. But the vacation is also in the EU, so do I have 90 days as a tourist in the EU because of my work agreement or will overstaying for a week cause no harm?
Comment: For clarity what is your nationality (ie can you enter visa free)?
Comment: Do you have a visa to cover your stay in Germany? If so, is it a type C or type D visa?
Comment: If you have no visa, or it is a type C visa, then you will need a type D visa for your subsequent visit (unless you wait for 90 days).  It is probably impossible to obtain a type D visa for a 1-week vacation.
Answer: I would assume that you have to leave the EU and apply for a visitor visa again. From a report on Euro-Dollar-Currency.com:

Overstaying Schengen visa can be very expensive. One traveler is known
  to have been fined 700 EUR by the Greece embassy after 20 days of
  overstaying Schengen visa. He had two options, either to pay a 700 EUR
  fine to the embassy or not to pay the 700 EUR fine but then not be
  allowed to get back to Greece and the whole Schengen zone for 5 years.

I really wouldn't risk it, more so, if you plan on going back to Germany or other Schengen states in the near future.
EDIT:
Found this answer on a similar question:

I had the same situation as you. I decided to leave the Schengen area
  when my work visa expired (hopped over to London for the weekend) and
  came back through Paris. I had no trouble at border control with
  getting an entry stamp, and the border agent hardly looked at my
  expired visa.

seems like you will be fine if you just leave the Schengen area and go right back in. On the other hand, other answers on the question mentioned seem to suggest, that you get the 90 day tourist visa automatically after your work agreement expires, but I find that hard to believe.
The French Consulate in Sydney specifically says you should leave Schengen and reenter it:

If you want to stay in the Schengen space (for up to 90 days) at the
  expiry of your working holiday visa, you will have to leave France and
  the Schengen space and re-enter the Schengen area the following day as
  a tourist for 90 days within a 6 months period. You may leave the
  Schengen area (passport stamped at the border) by going to the UK for
  example.
Comment: @jwenting by saying "enter as a tourist," the French consulate assumes that the person is entitled to visa-free short stays by reason of nationality or has a type-C visa. An expired national visa, work permit, or residence permit does not serve as an implicit tourist visa in any event.  Furthermore, we do not know whether the poster here has a national visa or residence permit. Some countries separate work authorization from residence authorization. If the residence authorization was under the short stay rules, it will be difficult indeed to return as a tourist within three months.
Comment: iow, what the French consulate says pretty much confirms the other example you came across. Seems that an expired work permit serves as an implicit tourist visa for the period immediately following its expiration.
Comment: @jwenting Quite the opposite I believe, the French Consulate states that you have to leave the Schengen area and come back to get your tourist visa there is no implicit visa granted.
Comment: it's implicit in that it will count as such when returning within the 6 month period. And apparently it becomes such when an exit stamp is placed on it before the work permit's expiry date (so overstaying your work permit will not grant you an automatic 90 day extension, which is probably why that rule applies).


WordPress permissions error with admin account

Question: I have been assigned to manage a website that uses WordPress and hence have an admin account. It is hosted on a Linux machine. WordPress is not installed in the /srv/http directory. Instead, it is installed in a sub-directory (say /srv/http/foo). However, there is a catch - the person who manages the Linux machine (I'll refer to them as X) does not let me ssh into the machine (as it has 'confidential information'). As a result, I am forced to do everything using the WordPress menu and additional plugins. To manage files and directories without ssh, I have installed a plugin called WP File Manager.
I never had any troubles with the website. However, recently X and X's team have decided to 'revamp' their site (the /srv/http directory). Now, when I try to do anything on the site (say create an empty directory via WP File Manager) I get permission errors - but WP File Manager shows that I have Read and Write permissions.
I need to urgently update the website. But, obviously, I cannot do anything due to the permission errors. How can I get around this?
Answer:
How can I get around this?

Talk to the administrator.
If you're supposed to have access to complete updates and you can't do your job, he's doing something incorrectly - don't compound the problem by trying to find a backdoor into the file system when you should be welcome at the front door.


Filtering a dataframe

Question: Still learning basic functions in R,
The subset function seems to only filter based a condition based on single column with or without multiple conditions?
How can I easily filter data from a dataframe?

when you are provided with multiple conditions
When the condition needs to be applied across the available columns.

Example:
Given a data frame containing
name    D1      D2     D3      D4
julius  "A"     "A"    "B"     "B"
cate    "D"     "E"     "A"     "C"
karo    "A"     "D"     "C"     "E"

say I want to filter this dataframe so that only names where any of the D1 to D4 is an 'E'
then I should have,
name    D1      D2     D3      D4
cate    "D"     "E"     "A"     "C"
karo    "A"     "D"     "C"     "E"

Say that the D1 can be a big list of columns, how or what is the recommended approach to perform this filter?
Thank you
Answer: If you want to combine several filters in subset function use logical operators:
 subset(data, D1 == "E" | D2 == "E")

will select those rows for which either column D1 or column D2 has value "E". Look at the help pages for available logical operators:
 > ?"|"

For your second question what you need is to filter the rows. This can be achieved in the following way
 collist <- c("D1","D2","D3","D4")
 sel <- apply(data[,collist],1,function(row) "E" %in% row)
 data[sel,]

The first argument to apply suplies the columns on which we need to filter. The second argument is 1, meaning that we are looping through rows of the data. The third argument is unnamed one-line function which returns TRUE if "E" is present in the row and FALSE if the "E" is not present.
The result of the apply function will be logical vector sel, which has the length the same as number of rows in data. We then use this vector to select the necessary rows.
Update
The same can be achieved with grep:
sel <- apply(data[,collist],1,function(row) length(grep("E",row))>0)

in R grep with default arguments returns the numbers of elements in the supplied vector which have the matching pattern.
Comment: another useful function is `any`. For instance if you want to check that at least one element of a vector is `= 10` you could write (`any(v==10)`).
Comment: @nico yeah, but **10 %in% v** has 9 characters and variant with **any** 10 :). Although for numeric vectors it is better to use equality, since R is smart and if your data is integers mixed with real numbers it will correctly recognize that you have 10 in your data set.
Comment: what about the case for regular expression? assuming that you do not want to work with an exact match? Do they have something close to ~= as in other languages? what is most close  to that expression in R
Comment: @Biorelated See `grep` and `agrep`, and related documentation on POSIX 1003.2 or Perl-compatible regex.
Comment: @Biorelated, I've update the answer with the example of grep.
Comment: Thanks a tonne on this!!!! the explanation and the references! awesome.

Filtering a dataframe


Should I reword the Factor if it shows all negative loadings?

Question: I've seen very similar questions but none really address my issue. I ran a PCA on 29 items to identify different factors of stress and worry. All items were on a scale from 1 to 3 and none of these were reversed coded (Higher scores mean higher stress and worry). When I run the PCA the factors I obtain make sense in the grouping of the items; I've called these Depressive stress, Impulsive and Physiological. The fourth one incorporates items that reflect "Low energy" and they all have negative loadings. I have created factor scores for all 4 and run a cluster analysis. The cluster analysis only seems to make sense if I refer to the last factor as "High energy" rather than low, and I'm guessing this is because of the negative factor loadings. What should I do? I would like to use the name "Low Energy" so that it similarly indicates high stress as the other factors. Can I some how reverse the factor score?
Comment: No you don't have to. You may simply change the sign in all loadings (and factor scores) of the factor.
Answer: Your "factors" are the eigen vectors of the covariance matrix. They are only defined up to length (usually normalized to one or to the sqaure root of the corresponding eigenvalue) and sign: the eigen value equation
$$A\vec{v} = \lambda \vec{v}$$
still holds if $\vec{v}$ is replaced with $-\vec{v}$. You can thus simply multiply your "energy factor" with minus one.


Bitcoin qt 4.8.3

Question: Hi I recently tried to make a transaction to a coinbase btc wallet from my bitcoin qt 4.8.3 node/wallet.  In a hurry I didn't add a transaction fee.  So the fee is zero.  I see on my end the transaction is unconfirmed.  Blockchain Explorer does not recognize the transaction ID either. I assume the block is waiting in the mempool and no miner wants to touch it.  I've contacted coinbase's customer support and don't have too much faith they even understand what is going on (sry for the negativity, just keeping it real).  It has been 6 days so far.  Any suggestions?  I would still like the transaction to go through.  Maybe a "pay for parent protocol".  But if it doesn't could someone walk me through the process of retrieving my transaction/block back.  There is a lot of support out their on the internet but not that much for a bitcoin qt 4.8.3 node/wallet.  Any help would be appreciated.  Thanks.
Answer: When you add a very small fee or no fee at all, as in your case, you'll need to ask for a special favor from a mining pool in order to get your TX in.
It is possible to request, on exceptional basis, for a mining pool to include your transaction into one of their less busy blocks.
They call this service "transaction accelerators".
For instance, ViaBTC offers an accelerator.
If you search Google you'll find several similar services from other pools. Some of them are paid: you send someone a small reward and they'll get the TX into a mining pool queue for you.
This service has worked for me in the past, especially during the November 2017 mempool explosion when low fee transactions weren't going through.
Keep in mind, though, that this is a courtesy service and there are no guarantees. I recall that, in 2017, you'd need to submit during late night or less busy hours to succeed.

Bitcoin qt 4.8.3


Do European folklore creatures, like ogres, brownies, fairies,goblins etc. have characteristics attributed to anti-semitism?

Question: These creatures mentioned in the title have characteristics (any, such as traits, costumes, behavior, etc.) attributed to anti-semitism by antisemitic people (or have their origins rooted in this)?
Comment: Who are these people you are talking about? who is giving false information? what are they saying?
Comment: Hi there! I am talking about Anti Semitic people attributing characteristics of **folkloric creatures** to Jewish people. Not the **aspects**. I will edit my post
Comment: Can you elaborate on these characteristics..?
Comment: Any characteristics, such as behavior, costumes, actions, appearance, etc.
Comment: In folklore, probably not.  In modern fantasy depictions, probably.  The pictures we associate with goblins, for instance, with the long hooked nose, probably arose as part of a general tendency to give creatures that were supposed to be evil or deceptive a stereotypical "jewish look". You see similar things with the traditional depiction of witches, with hooked noses and a version of the Judenhat that Jews were required to wear.  There was no one way that goblins or ogres or the like were depicted in the folklore, but standardized depictions that developed later often used antisemitic tropes.
Answer: Antisemitism is almost as old as Christianity itself, and because the churches dominated every aspect of life and death, the folkloric and the religious aspects are so intertwined they are almost indistinguishable. An example of this would be the Passion Plays:

Over the course of time, Christians began to accept... that the Jewish people as a whole were responsible for killing Jesus. According to this interpretation, both the Jews present at Jesus' death and the Jewish people collectively and for all time, have committed the sin of deicide, or God-killing. For 1900 years of Christian-Jewish history, the charge of deicide (Which was originally attributed by Melito of Sardis) has led to hatred, violence against and murder of Jews in Europe and America --Boston College Guide to Passion Plays

Another "folkloric" work that was used from the Middle Ages onward is the "Judensau" (German for "Jews' sow"), an image of Jews in obscene contact with a large sow (female pig), which in Judaism is an unclean animal, that appeared during the 13th century in Germany and some other European countries; its popularity lasted for over 600 years. In Nazi Germany, classes of German schoolchildren were sent to see the Judensau on German churches and the term remains extant as a neo-Nazi insult.
As for "costumes", the Fourth Lateran Council in 1215 was the first to proclaim the requirement for Jews to wear something that distinguished them as Jews. It could be a colored piece of cloth in the shape of a star or circle or square, a Jewish hat (already a distinctive style), or a robe.
For an extensive reading on the stereotypical depiction of Jews in Medieval art, see Sara Lipton, Dark Mirror: The Medieval Origins of Anti-Jewish Iconography
Comment: PS. I edited my post to prevent deletion, and i am asking about Mythological creatures such as the widely known brownies, fairies, ogres, elves, etc. that have their characteristics attibuted to jewish people, by antisemitic people.
Answer: Possible
You don't mention any specific characteristics, specific dates or specific references so it's impossible to determine any real connexion between folkloristic iconography and some real instance(s) of antisemitism.
That said, one can speculate. From the 21st century perspective, we could say: "Well, Dwarves love gold and the Jews run the banking system, so naturally, Dwarves are a caricature of Jews." The premise falls apart once we realise that mythological Dwarves, while they do seem to be into gold and gems, come to us from prechristian times out of the far north. Unlikely, it seems to me, that pagan Norsemen would be so perturbed by Jews that they would invent a whole race for the simple purpose of denigration.
Does that mean later antisemites couldn't take those characteristics of Dwarves and turn them to evil? Of course it's possible! Tolkien fell afoul of this accusation. I think at best the answer to your query is both yes and no.
Comment: @TechnicGoblin5R -- I don't know. I guess you could ask one?  Unless I'm misunderstanding your point, I think I addressed your question in my response: we can certainly speculate that antisemites might (or might not) make such a connexion.
Comment: @elemtilas I like the way you think. The enormous bold "Possible" made me wary at first, but your answer is a good one.  I hope people understand the nuance of "anyone can interpret anything the way they want to" without taking your answer to be a definitive affirmative.
Comment: Hi there, does creatures that carry gold are attibuted to Jewish people by antisemitic people?
Comment: I searched on Reddit and found something interesting: https://np.reddit.com/r/askhistorians/search?q=anti-semitism subreddit:askhistorians The thread that i am asking is on the first page of this search
Answer: These characters were created, like all mythological creatures, as a metaphor for somebody.  Long after those people disappeared, Jews appeared and like most immigrants became the subject of negative imagery.  The long story is complicated.
Comment: Could you please expand on your answer? We always love hearing long answers!
Answer: I think the answer to your question is no. Folklore is created primarily for the ears of children and would consist of imagery relevant to the culture of the area. By culture I mean natural aspects, type of landscape, textiles created from available materials, manners of speaking and daily rituals.
First of all I don't see any close connection between the loric creatures you mention. Ogres, brownies and fairies are very different from each other.
In Norway ogres turn to stone in sunlight and come alive in the dark.
In Scotland Brownies sometimes do housework while the people are sleeping but will leave if you show any generosity to them.
In Ireland different fairies have different roles but are generally  benevolent towards humans unless natural surroundings are subject to devastation in which case they may cause harm as punishment.


Install Dimmer Switch in Old House

Question: My house is circa 1910 and I dont really know how old the wiring is in it.  I am trying to swap a 3 way light switch with a 3 way dimmer (Lutron CL Dimmer). I killed the power and pulled the switch out. I expected 4 wires and I only saw 3.  One was green and it looked like the other two were black.  Does anyone know how to connect my 4 wire dimmer to the 3 wires?  I expect the green is the ground, are the other two the travelers?
Comment: You're sure this is a 3-way? Two separate switches control the same light?
Comment: How was the original switch connected? Can you provide some photos?
Answer: So it sounds like you have the wrong number of wires for your switch to have ever worked properly by your description, from the way that I read it.
SO I will try to understand. When you took off your three way switch was there three screws with three wires going to it? Plus perhaps your box is metal and has a bare ground screw at the back, or a bare ground somewhere as well as the other three wires?
Your house is really old but should have had an electrical upgrade. So I am assuming your cable has a separate, bare ground screw?
I am trying to see if perhaps the insulated(?) green wire you see is actually just a traveller for some sort of reason. And maybe there is another wire for the ground in the box.
Not knowing when your house was re wired last (since I am sure you do not have knob and tube) is making me wonder what the cables have inside them.
Could you please state what was on the original three way switch? Because those should be the wires you use for your new switch. I just want to make sure your bonded (grounded for simpler terms) properly.
Comment: Well, I think I do have some knob and tube wiring left in the house.  From what I am reading online a dimmer switch is not recommended.
Comment: if you answer our previous questions it still might be possible.

Install Dimmer Switch in Old House


Should I be worried about radon while I live on the 9th floor?

Question: I've recently heard of this threat to our health and I'm trying to educate myself on how to best protect myself and my family from it. I've been living for the past few years in a rented apartment in an old 16 story building (50-60 years old) and I'm not planing on moving anytime soon, so I'd like to find out how pressing it is for me to spend money on radon testing. Any information on this matter is welcome, thank you for your time!
Comment: Oh oh I hope you don't have any granite countertops or tile. For that case have you ever drank out of a hose? If so just hang it up you are a guaranteed goner in 60-80 years on average. Sound silly?
If you are worried get a test kit and send it in after following the instructions. If you live in California prop 69 says everything will cause cancer.
Comment: This isn't a clarifying comment, but I must add that I think you (Ed Beal) and I would get along quite well. The California warnings are so stupid and silly. It's like crying wolf every minute of the day. But what's worse is they lose their effectiveness when there might be an actual risk.
Answer: Threats to health can be scary.  But in this case, you'll want to keep on learning about radon.  Learn what it is, exactly; learn where it's found in terms of what part of the building, and how it's mitigated.
The upshot is I've never heard of a radon mitigation system on the second floor, least of all the 9th!  You have more to fear from wildfire.
Comment: Radon can be emitted by building materials, especially concrete which may have uranium-containing aggregates.  So it's entirely possible that even a 9th floor can be affected.
Comment: I would be more concerned about granite I think pink is the type that really emits a lot of radon , but you are correct abatement systems are usually at the basement or ground floor levels.+
Answer: Radon is emitted only from rocks in the ground or from masonry.  Unless your apartment is composed entirely of raw concrete and has no ventilation, radon is an unlikely concern.  You can buy small testing kits that will tell you how much radon is present.
On another note, it also debatable what concentration of radon is linked to an increase in cancer.  Small doses appear to have a beneficial affect, as they stimulate the body's defenses to damaged cells.  See https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3315166/
Comment: I found a 400$ detector on amazon. Where would I be able to find a cheaper testing kit? I'm not a USA citizen, I live in Europe.
Comment: Ah.  In the USA these kits normally go for about $20USD.  This could be due to many districts in the USA requiring a radon test before selling your home.  Your local real estate agents or government might have a source.   Radon tests normally have to be returned for analysis quickly after measurement, so a local supplier will probably be cheapest.  The European Radon Association (http://radoneurope.org/) might be able to help you locate a cheaper kit.  $400 seems extremely excessive, unless it includes two-day shipping to and from the USA.
Answer: Do not cast this off as unlikely.
Radon is a gas that infiltrates buildings and can cause breathing problems. We dispose of radon by installing tubes in the ground and extend the tubes up through the roof.
Often, because there isn't enough ground pressure to move the radon up and away, we install exhaust fans and exhaust the tubes up through the roof.
While I've never extended tubes up 9 stories, I've extended them 3 stories.
I'd check with building maintenance to verify that if there is an exhaust system, that it's been certified to be solid and in tact (no cracks that could leak into your unit, other's unit, corridors, etc.)
There are maps that show likely radon hot-spots. I'd Google "radon map USA".
Comment: Radon dose not "cause breathing problems". It is odorless and cause no immediate problem... but *possibly*, could lead to cancer. If you're concerned, check with the building owner or local authority for the findings of the last radon tests. As @LeeSam states, though, check a map to see if you even need to be concerned. Radon is found mostly emanating from granite or other igneous rocks.
Comment: @DrMoishePippik I'd say lung cancer is a breathing problem. Here's an article that explains it ... https://www.ac-heatingconnect.com/homeowners/infographic-everything-need-know-radon-gas-home/?gclid=Cj0KCQiAs67yBRC7ARIsAF49CdVHPRWhugAaAhaiaCa17xC4Lt1UbT9SE1IC_Mgd2ZqnHdcZq04hqO8aAoi9EALw_wcB


What construction or classification is "Come what may"

Question: Is this an example of inversion, an idiom, archaic usage, or just incorrect?
Comment: Related: [Number disagreement between subject and verb in Shakespeare?](https://english.stackexchange.com/questions/239613), [God save the Queen](https://english.stackexchange.com/questions/66020/god-save-the-queen)
Comment: I don't think it's Subjunctive, God save the Queen is a wish and save is not conjugated with S.  Come what may I feel is different.
Comment: When I try and work out structure and grammar I try and change the words around and see if they obey the rule with other examples.  The examples in the other thread of "Let God save the Queen" would mean "Let us prey" or "let's eat" are subjunctive and I don't think they are therefore "God save the Queen" and "let God save the Queen" do not have the same meaning / structure.
Comment: Many uses of the subjunctive are archaic/obsolete, and so their grammar doesn't necessarily work the same way in modern English as it did when these idioms or constructions first came into use. I think the "Let's eat" construction in particular represents a specialized development that would no longer be considered "subjunctive" in synchronic analyses of English grammar.
Comment: Your probably right, Let + verb in romance languages is subjunctive so it stands to reason it is in English as well.  So "come what may" is an example of the subjunctive?
Answer: There seems to be consensus in the sources that I have looked at that "Come what may" originated as a subjunctive construction. (Many uses of the subjunctive are archaic/obsolete, and so their grammar doesn't necessarily work the same way in modern English as it did when these idioms or constructions first came into use. I think in modern English, it would be considered a frozen idiom, not an example of a modern English subjunctive construction.)
I haven't found so much information about what type of subjunctive it is, or about why the verb is placed first, but here is a brief discussion from
"A Historical Outline of the Subjunctive Mood in English, With Special Reference to the Mandative Subjunctive", a thesis by Aristeidis Skevis (2014):

Another interesting case is the front-positioning of the main verb in conditional-concessive constructions. This case could very well be interpreted as optative subjunctive:
(175) Come what may… ('Whatever may happen…')
Present subjunctive come is also used in a temporal clause without a subordinator. It is
  generally initial:
(176) Come Sunday he will have to face the music. ('When Sunday comes…')
  (177) The supposition is that come tomorrow the inspectors will be allowed to have
  access to the site. ('When tomorrow comes…')
  (178) Be that as it may…('However that may be…')

(p. 58)
Comment: That's a great source.  The example immediately after the above citations gives a clear precedent. *be that as it may* seems very close in structure.
Answer: This is the so called formulaic subjunctive (CoGEL p. 157 § 3.60)

The formulaic subjunctive
Like the mandative subjunctive, the FORMULAIC SUBJUNCTIVE consists of the
base form of the verb. It is used in certain set expressions chiefly in
independent clauses:
♦ Come what may, we will go ahead with our plan.
♦ God save the Queen! ['May God save the Queen']
♦ Suffice it to say that we won. ['Let it suffice . . .']
♦ Heaven forbid that I should let my own parents suffer.
♦ Be it noted that this offer was made in good faith. (formal, rather
archaic)
♦ Be that as it may, we have nothing to lose.
The force which the subjunctive conveys here, that of an expression of will,
may also be conveyed by let or may. The formulaic subjunctive tends
to be formal and rather old-fashioned in style.


How do you use OSGeo-Live with Windows and Mac Installers?

Question: I'm familiar with installing from bootable USB, and have done so with Ubuntu, Linux Mint, and OSGeo-Live. But there's a version of OSGeo-Live which includes Windows and Mac installers. I would guess that this uses Wubi, but I don't see that explicitly spelled out anywhere, and Wubi is an EXE whereas the download is an ISO. So, what do the Windows and Mac installers actually do, and how do I use them?
Answer: The image is a bootable Linux distribution. If you want to use the programs on a windows box or Mac then you just copy the installer on to the box and install as usual. You may find the osgeo4w installer a better option.
Answer: The standard installation image does come with mint4win, which used to be based on Wubi, the "Windows-based Ubuntu Installer", which provided a way to install an Ubuntu-based OS in a dual-boot configuration without having to muck around with disk partitioning. It also gave you an easy way to uninstall using Windows' Add/Remove Programs feature. However, Wubi is no longer maintained. So if you run mint4win on a Windows machine (which I tested), all that will happen is it will ask you to reboot, and after that you have the usual choice to boot to OSGeoLive and install from there.
Thus, the Windows and Mac installers that come optionally with OSGeo-Live are not installers for OSGeo-Live, they are installers for Windows and Mac versions of many of the packages (QGIS, uGig, etc.) that are included with OSGeo-Live. As pointed out by @iant, using OSGeo4W is a better approach (for Windows, but not Mac).


How to open a stack of loot bags in one go?

Question: Simple question really but it annoys me every time. Sometimes I buy 250 of the same bags, for example 'Heavy Moldy Bag' from the TP. When I have them all in my inventory I end up clicking 500 times on the icon to open all 250. Surely there must be a better way to do this?
Comment: I have a similar problem sometimes. I've considered suggesting a "use all" right-click function for containers and consumables, but I felt like it was such a niche problem that it wasn't worthwhile.
Comment: @Brian where did you make this suggestion? I'd like to upvote it, perhaps get it out of the niche.
Comment: It's totally not a niche problem, however, bag space is though! Would it be possible to implement a "open until bag full" option?
Comment: I hadn't actually suggested it, but I did just now. It's at https://forum-en.guildwars2.com/forum/game/suggestions/Use-All-function
Answer: At the time of writing there is no way known to me that let's you open a stack of those bags in one go.
The only way to automate this would be scripts or keyboard macros (if your keyboard supports those), but they are not allowed as per EULA.
Comment: How does triple-click help exactly?
Comment: For what it's worth, my mouse has triple-click (razer inferno) and it really helps with all the double-clicking in GW2.
Answer: It's not just loot bags mind you, but also using salvage kits and consuming Essences of Luck :)
A simple Autohotkey script can save a lot of doubleclicking. For example, the following sends a double click when typing alt-d:
<code>#IfWinActive ahk_class ArenaNet_Dx_Window_Class
$!d::Click 2
</code>
While it's true that the use of scripts is not officially sanctioned, it's very unlikely a player will be banned for using a script that essentially redirects or remaps some input; not to mention that it would be very hard for the game to detect such scripts and prove a script was indeed used when you also have many keyboards and mouses with custom software that does essentially the same.
There is a popular script for example, called Immersive Combat Mode which many players use for Guild Wars 2. The version 1.0 of this mod summarizes the situation as:

ArenaNet are ok with mods that don't give an advantage over other players and don't impact others negatively
Comment: Technically they're okay with mods that give advantages too - like Eyefinity and arrow carts.


Subclassing NSOutlineView

Question: How would you Subclass an NSOutlineView?
Comment: The short answer is: the same way you subclass any object. You should try and be more specific with your questions. Apple's documentation covers subclassing and so we must assume you've read that and tried something and then got stuck. Where have you got stuck?
Comment: Sorry I hadn't read all the Apple Docs on Sub-Classing.
Answer: Firstly, before you subclass an object, you should ask yourself "do I need to do this?". Subclassing is a more complex way of interacting and extending the functionality of other classes, so you should make sure that what you are trying to achieve cannot easily be achieved through another, simpler method, such as delegation, notifications etc. Obviously if you are trying to change the way the control looks this is going to be more easily accomplished through subclassing, but make sure you check all the other available options. Remember that NSOutlineView has a fairly long object tree - it inherits from NSTableView, which inherits from NSControl, which inherits from NSView, which inherits from NSResponder which inherits from NSObject, and there are various helper methods that exist in each of these classes which can often help you achieve what you want.
However, if you check all of these options and decide to subclass NSOutlineView, it depends what you want to do with your subclass. The easiest way to create the shell of your subclass would be to select File > New File then choosing Objective-C class, as you would with any other class, which will create a new class, with header and implementation files, that inherits from NSObject. Then you can simply change the line in your header file:
@interface MyClass : NSObject { // Where MyClass is the name of your class

to
@interface MyClass : NSOutlineView {

which will cause your class to inherit from NSOutlineView. Since it is a subclass of NSOutlineView, this gives you lots of opportunities to change the default behaviour of the control.
Since you are creating a subclass, you can change the default implementation of any method up the object tree - that is, you can override methods declared in NSOutlineView, NSTableView, NSControl, NSView, NSResponder and NSObject (although you should rarely override methods declared in NSObject). You do not need to redefine the method signature in your header file, you can simply override the function by implementing it in your subclass's implementation. For example, if you wanted to override NSView's drawRect: method, you would do the following in your subclass's implementation:
- (void)drawRect:(NSRect)rect //Method signature from the docs
{
    //Code here
}

When drawRect: is called upon your class, your code will be executed instead of the code in NSView.
You can also pass method calls up the tree for methods that you do not want to handle. This is done by default, so you do not need to create empty methods that simply call the method on super, however, if you override a method and want to allow one of your superclasses to handle it first, you could do the following:
- (void)expandItem:(id)item
{
    [super expandItem:item];

    //Your code here
}

This would be beneficial if you wanted to change a variable in your class, for example, but provide the default implementation of the method by first passing the method call up the tree.
Subclassing can be a rather complex process, especially for such a complex object as a control, although it can be very useful and powerful.
Comment: Wow! Thanks very much for this great answer! I have put the code in that I want to use but, I get an error with the code I used, I was wondering if you could help me solve the problem. Here is the code.
http://fwdr.org/w3cr  .The Problem I have is that i get an error saying 'rowIndex' is un-declared but I don't know what to declare as (I mean whether it is an NSArray etc.). I wondered if you could help, seeing as though it is why I had to subclass NSOutlineView in the first place. Thanks Again for the Great Answer. And sorry about this long comment.
Comment: That was what I was trying to say at the beginning of my post - if you look in the docs, outlineView:willDisplayCell:forTableColumn:item: is a delegate method; therefore if you only want to override this method then you do not need to subclass NSOutlineView; you can simply make your controller class a delegate of your NSOutlineView, and then implement that method there. As for your sample, you want to call rowForItem: on the outline view, passing anItem as the argument to retrieve the row index.
Comment: The reason I am trying to sub-class NSOutlineView to do this is because it said to do so where I got the code from (http://www.cocoadev.com/index.pl?AlternatingRowColors)
Comment: If you're only implementing the outlineView:willDisplayCell:forTableColumn:item: method, you don't need to subclass NSOutlineView. If you are looking at the Apple code example further down the page where you have to do actual drawing then you need to subclass NSOutlineView.
Comment: The code I was using was the code at the top of the page. If i did not sub-class NSOutlineView for that how would I need to change the code?
Comment: Thanks, I didn't notice that code near the bottom of the page, So I had a go at using the Apple Code with the Sub-Class and it just about worked but I get a warning saying ''MyOutlineView' may not respond to '-drawStripesInRect:''. Do you know how I might fix this problem?
Comment: Did you declare the drawStripesInRect: method in your NSOutlineView subclass? Check the method declaration and make sure to declare it in your class header file.
Comment: What would I put in the header file to declare it?
Comment: You would simply declare it in the class implementation like any other class method.
Comment: How would you declare it? Would it be a bit like this …  NSArray *objectArray; but saying drawStripesInRect and NS Something?
Comment: You'd declare it as - (void) drawStripesInRect:(NSRect)clipRect after the curly braces but before the @end.
Comment: Ahh I See, That Now gets rid of the error but now I get another error on the line #import "MyOutlineView.h" saying 'syntax error before 'AT_NAME' Token'.
Comment: Sorry, I missed out the semicolon at the end of the declaration. It should be - (void) drawStripesInRect:(NSRect)clipRect;
Comment: No Problem, All the code works now but It has not affected the Outline View, is there something i need to do to connect the two so they will work?
Comment: Perhaps you should start a new question? It will attract a larger audience and you can get a specific answer to what you want.
Comment: Perhaps So, what do you think would be the best title to attract a larger audience?
Comment: That's up to you - I was just saying that your question has deviated from your original question, and is more specific so perhaps it would be better placed as a new question.
Comment: The New Question Is Here, http://stackoverflow.com/questions/993465/nsoutlineview-not-doing-what-it-has-should-do-in-its-subclass .
Answer: @interface MyOutlineView : NSOutlineView
{
...
}
...
@end
Comment: Oh I see, What would I put where the dots are?
Comment: Oh i put my code there. Would I need to put anything in the header file?
Comment: That is what goes in the header file; the first `...` is for instance variables, the second for method signatures. The .m contains the `@implementation MyOutlineView
...
@end`
with your actual method... implementations.
Comment: I see, would this class file have to be the Outline View's data source?

Subclassing NSOutlineView


unable to run gtk apps compiled with gcc 4.4 (mingw)

Question: I have downloaded the gtk all-in-one package for windows. I am compiling my file with -mms-bitfields but still i get the error,
<code>Gtk-ERROR **: Incompatible build!
The code using GTK+ thinks GtkBox is of different
size than it actually is in this build of GTK+.
On Windows, this probably means that you have compiled
your code with gcc without the -mms-bitfields switch,
or that you are using an unsupported compiler.
aborting...
</code>
Any ideas?
Adeel.
Answer: You should enable -mms-bitfields in your project's properties.
Depending on what IDE you use, it might be a bit different.
In NetBeans, right click on your project. Then go to
Project Properties -> C++ Compiler. Expand Compilation Line and in Additional Options enter -mms-bitfields. Make sure that Configuration is set to All Configuration. Rebuild your project.
In Code::Blocks I think you should do, as follows:
Right click on your project -> Build Options. Go to Compiler Settings -> Other Options and write -mms-bitfields. Make sure that you apply this change to the whole project (not just the debug or release). Rebuild your project.


How do I model a simple robot arm as a plant?

Question: How do I model a simple robot arm as a plant?. I know how to model motors but, I think, controlling individual motors may not be enough; and in order to control the the arm as a plant I need to model it as a plant. In the block diagram below my trouble is in finding the hardware model of the robot arm.
Answer: Each joint of your robot is one motor. They are coupled though kinematic relations and dynamic physics.
One straight forward way is to derive these so called 'equations of motion' using the euler-lagrange formalism. Once you obtained your equations you can create for example a Matlab function to solve them dynamically.
But back to the modelling part, check out the slides in Dynamic model of robots: Lagrangian approach, by Prof. Alessandro De Luca .
Comment: So the robot's mechanical model(in the block diagram) could be represented by the dynamic model you suggested? That's to say, will the dynamic model relate input voltages to the robot to output joint angles? I will check the slides of course, just want to be sure that's what I'll get at the end. Thanks for the help!
Comment: You are missing a few steps in between. It's not as easy as a fixed relation
_voltage_ --> _angle_
An advice from my side: think about what's really going on inside of your robot if you apply some voltage to a motor.
The voltage will generate a torque, the torque will _accelerate_ the link of your robot. This whole process can be described as a dynamical system where the voltage is the input and the angle is the output. But as mentioned, first you need to think about the phyiscs, then do the modeling, then the implementation ;)
Comment: Whether fixed relation or not, my concern was how to relate the input voltage to output angles. And I suppose your answer is that the dynamic model of the robot will solve that. Thanks for the help again, I will try to develop a dynamic model for the robot.
Comment: Welcome to *Robotics* madn, that's a nice first answer. On stack exchange, it is better to edit your question to add information requested in comments, rather than adding more comments. Comments are for helping to improve questions and answers, and are distracting, so we try to keep them to a minimum. If all of the information needed to answer the question is contained within it, the comments can be tidied up (deleted).