Open connected subsets of path connected spaces

Question: Does every open and connected subset of path connected topological space has to be path connected? Statement should be false as there is a similar theorem but for Euclidean spaces, however I can't think of a counterexample. What about the same statement, but for path connected metric spaces?
Comment: https://math.stackexchange.com/questions/766422/when-does-open-and-connected-imply-path-connected
Comment: An open and connected subset of a *locally* path-connected space is path-connected. This is the theorem I think you are confused with.
Answer: The classical example of a connected (metric) space that is not path-connected is the topologist's sine curve. I will give an example based on this.
Consider the graph of the $\sin(\frac{1}{x})$ function on $(0,1]$.

Let $X$ be the space which consists of this graph together with the vertical line segment connecting $(0,-1)$ and $(0,1)$, and the curve in red:
$X$ is a metric space that is path connected. You can also clearly see this as an open subset of $X$:

This is an open connected subspace of the $X$ that is not path connected.
This counter example is a metric space. It applies as well for the general case of topological spaces.
Answer: Consider the space $$X=\left\{(x,y)\in\Bbb R^2\,:\, (x=0\land y\le 2)\lor \left(x\ne 0\land y=\sin\frac1{\lvert x\rvert}\right) \lor (y\ge 0\land x^2+y^2=4)\right\}$$
I.e. a topologist sine, plus an appropriate vertical half-line, plus a half circle "path-connecting" the curve to the tip of the half-line. Then, $X\setminus \{(0,2)\}$ is connected, but not path-connected.


Why does my drivtrain skip under hard torque?

Question: I recently purchased a new bike, a Specialized hardtail mountain model.  It is on the cheaper side, but with the brand I expected a good ride.  Less than a month of riding it, the drivtrain has started skipping.  Under a hard torque load, the rear drivtrain will "chink", and the crank will slip forward just a little.  It only does this in a few gears, specifically 7 and 8 on the back with the middle chainring. Shifting down to 6 usually stops it.  As it is good quality, brand new bike I did not expect this.  I looked at the rear derailer, and it appears to be ever so slightly bent, but i dont think this is the problem.  It is hard to look back while pedaling hard, but it doesnt look like the chain is trying to go up or down a gear.  Since I got it, I have given it a good wash and lubed everything back up, but the problem remains.  It is a less expensive bike, so I expect to replace some components eventually, but I would like to get my money's worth from the old ones first.   Also, I live over two hours from the nearest bike shop, so any help here would be appreciated.
Comment: A month riding is not enough to wear out a component.  More likely your gear cables have "settled" (ie, stretched a tiny bit) and the gear adjust is out.  Most bike shops offer a 4-8 week tune up for these types of things.  2 hours each way sounds like a loverly bike ride!   Or give it a go yourself, the site has plenty of good answers, like https://bicycles.stackexchange.com/questions/457/how-do-i-adjust-my-rear-derailleur-shimano-sis-when-it-is-only-slightly-out
Comment: http://www.parktool.com/blog/repair-help/rear-derailleur-adjustment
Answer: Skipping like that is usually worn cassette, chain or chainring(or all 3).  Considering it's only doing it in the highest gears, my first guess would have been the cassette.  But since it's only a month old, it's much more likely to be the derailleur is mis-aligned just a little bit.  You say the derailleur is "ever so slightly bent", that little bit can make a big difference if it's out of alignment with the gears.  Also, as Criggie says in the comments, the cables "settle in" a little after about a month or 2 of riding, that's very common, and the reason most shops offer a free tuneup in the first year you own a new bike.  May be worth checking to see if the shop you got it from offers one.


Using multiple Git repositories instead of a single one containing many apps from different teams?

Question: I am migrating a 10-years-old big CVS repository to Git. It seemed obvious to split this multiple-projects repository into several Git ones. But the decision-makers are used to CVS, therefore their point of view is influenced by CVS philosophy.
To convince them to migrate from one CVS repo to different Git repositories I need to give them some arguments.
When I speak with mates working on Git repo for years, they say that using multiple Git repo is the way to use Git. I do not know really why (they give me some ideas). I am a newbie in this field so I ask here my question.
What are the arguments to use multiple Git repositories instead of a single one containing different applications and libraries from different teams?
I have already listed:

branches/tags impact the whole Git repository files => pollutes other team projects
4GB limit Git repo size but this is wrong
git annotate may be slower on bloat Git repo...

Eamon Nerbonne has noticed the related question:
Choosing between Single or multiple projects in a git repository?
The reason the team managers finally have accepted the split: the single Git repo (550 MB) was requiring 13 minutes to be cloned on Windows (one minute on Linux).
The bloat CVS repo split in 100 Git repositories:

each dead apps in one repo
each stabilized library in one repo (source code almost never changed any longer)
related apps/libs kept together in one repo
moved large files not used for compilation (config...) to other repos (Git does not like large files)
skipped other unrelevant files (*.jar, *.pcb, *.dll, *.so, *.backup ...)

Successfully installed the repo tool used by Android Open Source Project in order to handle all these Git repos:

easy installation on Linux
more difficult on Windows because of Cygwin and NTFS native symlinks requirements
Comment: see: http://programmers.stackexchange.com/questions/161293/choosing-between-single-or-multiple-projects-in-a-git-repository?rq=1
Comment: Where is the question actually?
Comment: @JimMartens: **What are the reasons Git users usually use several Git repositories while CVS users use a single one?** (one Git repo per deliverable module?) Thanks for your comment, I may change the question explanation... Finally I changed the title ;-)
Comment: Do they? We used to have different SVN repositories for different projects.
Comment: Who says that git users, use multiple smaller repositories?
Comment: @LeonardoHerrera: On the unique CVS repo, there are main directories for each *group of applications*, then sub-directories for each team project, each team developing/maintaining different libs and apps. Actually, there are also historic-reason-garbage directories and common directories... Some *group of applications* have already moved from CVS to SVN (one SVN repo per group). I am migrating one of the other *groups of applications* that was thinking to migrate to a unique Git repository.
Comment: @LeonardoHerrera It's not just a CVS/SVN difference, either - we use one massive SVN repo with thousands of directories at the root level, including a lot of dead projects.  It's just an IT/business decision what layout to use.
Comment: @olibre: I'd avoid multiple repos unless you actually need it.  When you do, it's not hard to split repos.
Comment: Thanks for the link :) To manage multiple Git repos I successfully installed the [`repo` tool used by Android Open Source Project](http://code.google.com/p/git-repo/) on Linux (easy) and Windows (more difficult because of Cygwin and NTFS native symlinks requirements). But you are right, to make the developer life pleasant I have kept together some related projects. Cheers ;)
Answer: There doesn't seem to be an argument in favor of the big repo in this thread, so here's one:
The advantage of a big repo with all your code in it, is that you have a reliable source of truth. All the state in your overarching project is represented in that repo's history. You don't have to worry about questions like "What version of libA do I need to build libB from 3 months ago?" or "Did the integration tests start failing because of Susan's change in libC or Bob's change in libD?" or "Are there any callers left for evilMethod()?" It's all in the history.
When related projects are split into separate repos, git isn't keeping track of their relationships for you. Your build system needs to know where to find the code for all its dependencies, and more importantly what version of the code to build. You can "just build everything from master", but that makes it hard to reproduce past builds, hard to make changes (or rollbacks) that need to be synced across repos, and hard to keep branches in a stable state.
So the question isn't "One big repo or many small repos?" It's actually "One big repo or many small repos with tooling." What tool are you going to use? Repo (Android) and gclient (Chromium) from Google are two examples. Git submodules is another. All of those have major downsides that you have to weigh against the downsides of a big repo.
Edit: Here are some more answers Choosing between Single or multiple projects in a git repository?
PS: All that said, I'm working on a tool to hopefully make things better, for when you have to split repos or use other people's code: https://github.com/buildinspace/peru
Comment: Totally agree that arbitrarily splitting a repo into multiple repos is not necessarily good. Version control ambiguity: there is no 1 source of truth from which you could build the total project - Maintainability: You'd have to write documentation specifically to tell people how the projects relate to one another and how to compile and merge them together - Workflow: if you regularly make changes in one repo that you then deploy from another repo you are continually having to copy builds from one project to another which seems completely unnecessary compared to them being in the same repo.
Comment: One repository plus a Dockerfile providing a shared development environment that just works out of the box for the whole project saves A LOT OF TIME AND FRUSTRATION. Plus the setup is extremely easy for a new developer and he/she doesn't need to know many details about how everything works compared with n repositories where you need to know what version of x works with what version of y plus you need to put this folder here with these file permissions edit 10 configuration files to have the login page after one day of work because ah this library is not available on Debian Wheezy.
Comment: I have started to feel the pain in multiple repos when it comes to code sharing. Since there are many different solutions with public code, you can never be 100% sure that some piece of code is not being used anymore. This creates severe maintainability issues. This goes along with what you mentioned with the `evilMethod()` there.
Answer: Git tends to experience performance problems when used with large repositories.
To quote Linus:

And git obviously doesn't have that kind of model at all. Git
  fundamnetally never really looks at less than the whole repo. Even if
  you   limit things a bit (ie check out just a portion, or have the
  history go   back just a bit), git ends up still always caring about
  the whole thing,   and carrying the knowledge around.
So git scales really badly if you force it to look at everything as
  one   huge repository. I don't think that part is really fixable,
  although we   can probably improve on it.

Emphasis mine.  That's not to say your company's version control repository is "large," but this is one reason people tend to avoid large repositories within Git.
Comment: So basically using multiple repos is just a perf optimization?
Comment: It's a performance optimization, but I'm not sure if it's *only* a performance optimization.  Per [AProgrammer's answer](http://programmers.stackexchange.com/a/206801/15162) it's also a way to represent the notion of a "module" in git.
Comment: Thanks for the link ;) This is the reason why Google limits the code.google.com Git repositories to [4 GB](http://code.google.com/p/support/wiki/GitFAQ). Cheers
Comment: Here we need to make it clear: few quite big solutions are implemented using Git as the source code repository (Android, Linux). That is solid confirmation Git could be used with large repositories. Though that DOES require additional technics
Comment: Git also does not support a lot of things that improve the ability to have huge repositories. That works nicely in SVN but not in git where the main supported way of working is to checkout an entire repository, not only all folders but all history. It's harder in git to accomplish as much such as sharing only one folder or using externals (which allow internal references to the same repo).
Comment: If you're doing development on Windows, Microsoft made an effort to resolve these problems as part of https://gvfs.io .
Answer: You're dealing with multiple teams and multiple projects. Likely decades of work went into the codebase.
The short answer is that your teams and projects have varying needs and varying dependencies.
The monolithic repository approach reduces commits to "Everything is stable in this configuration!!!" (i.e. unrealistic, huge commits sourced from many teams). That, or many intermediate points of incompatibilities for many projects. Either way, there's a lot of wasted energy invested in supporting configurations which were simply never meant to be.
Your repositories should be structured independently instead, and should have multiple repositories which represent their dependencies. The dependencies should be configured, updated, and tested by the project maintainers at appropriate points in development.

ProjectA saw its last major release 3 years ago. It is in maintenance mode and has "older" system requirements. It should refer to an appropriate set of dependencies. It has 20 dependencies.
ProjectB was just released. It has more modern System Requirements, and was developed and tested by another team. It has 15 dependent libraries (=repos), 10 of which are shared with ProjectA. These projects generally refer to different commits of their dependent libraries. Dependencies are updated at appropriate points in development.
ProjectC is yet to be released. It's very similar to ProjectB, but includes significant changes and improvements to its dependencies. Developers of ProjectB are only interested in taking the stable releases of the dependencies they share with ProjectC. ProjectB's team makes some commits to the shared dependencies, although they are mostly bugfixes and optimizations at this time. A monolithic repository would either hold development of ProjectC back in order to maintain support for ProjectA, or ProjectC's changes would break A and B, or developers would just end up not sharing/reusing code.

With multiple (distributed) repositories, each team can work independently and minimize impacting the other projects while reusing and constantly improving the codebases. This also keeps teams from shifting focus/speed when changes come in from other teams. The centralized monolithic repository makes each team dependent on every team's move, and that would have to be synchronized.
Comment: What you describe here is [exactly the opposite of what Google does](https://cacm.acm.org/magazines/2016/7/204032-why-google-stores-billions-of-lines-of-code-in-a-single-repository/fulltext). (That paper describes why they feel that, even with two billion lines of code, the monolithic approach works far better.)
Comment: @CurtJ.Sampson Well… Google has built an in-house revision control system, several supporting utilities, build systems, has a compiler team, etc. all of which support their workflow. My shop doesn't have those tools or teams. Unless you work for Google, you don't have those tools either. Google's Android codebase uses Git; they use over 800 Git repositories. This question is specific to Git, right? FWIW I typically structure my repos by A) a large-ish repo with several shared libraries B) various Application/Project repos which depend on A and C) separate repos with various media assets.
Comment: Have no fear, @justin, answers on StackExchange sites are not written just for you, and I won't try to come after you to read mine.
Comment: I brought up Google as an example of a company that clearly has a very high level of technical skill and found having a single repo so compelling that they were willing to spend literally millions of dollars to create the unique system they needed to do that. If someone doesn't understand at all why they would put in that kind of effort, I hope it's obvious that they should be thinking not "Google's wrong" but "there's something I'm missing here." But ask I think about this more, I think I need to add an answer to argue my opinion at appropriate length.
Comment: I am reviewing our number of repositories.  A compelling advantage of monorepo is that truly global files like system configuration are versioned along with all other projects.  Thus a monorepo would contain the old configuration to support Project A.
Comment: @CurtJ.Sampson Find somebody else to argue with. Not interested.
Answer:
They want [something that can] show their changes across all projects instead of trying to remember what project they made a change [to].

Sourcetree (a free-as-in-beer GUI Git frontend) allows you to register multiple repositories, organise them into logical groups, and then view status across all of them at once:

I am not affiliated with them in any way.
Comment: I like it. SourceTree went off the rails in recent times. I paid for Smartgit & use it for Hg too. I like the diff tool in it.  They are pretty similar but I think Smartgit made more progress lately.
Comment: Smartgit does this too ... but better.
Comment: @CADbloke how is the interface for SmartGit nowadays?  I remember a year or two back I was deciding between the two, and SourceTree was clearly easier to use than SmartGit, which was rather spartan and problematic.  I couldn't even get my diff tool to work well
Comment: Have you used Beyond Compare, I find this diff tool better than the others?  How does it compare?
Comment: I recognize this is pretty old but either Sourcetree has gone backwards or I just can't find that left hand overview pane.  I have the mid-left one (File status, Branches, etc.) that is per repo, just not the one for multiple repos.  Any ideas how I get it (or is it no longer or?)
Comment: @JoelAZ They've since changed to a tabbed interface.  If you click the '+' button in the tab bar, you'll get to what used to be the overview pane.  I'm not convinced it's an improvement.
Comment: @RonMacNeil OH geez. Is THAT the equivalent of that pane?  ffs. No not an improvement at all.  Better to have left that pane, made it pinnable and/or slide/hideable imo if some ppl wanted the real estate back but burying it on another separate screen does not seem well thought out.  Thx for replying.
Answer: TL;DR; the equivalent of a git repository is a CVS module, not a CVS repository.
CVS is designed with a notion of modules being a subdivision of a repository, and it is common to use CVS repositories with several modules having a quite independent life.  As an example, it is easy to have branches specific to one module and not present in another.
git has not be designed with a notion of module, each git repository is limited to one module in CVS term.  When you create a branch, it is valid for the whole repository.
Thus, if you want to import a CVS repository with several modules in git, you better create a repository per module, especially if the modules have a more or less independent life and don't shares things like branch and labels.  (Due to different usage patterns of branches in CVS and git, you may even investigate the usefulness to have one repository per CVS branch; but for a migration from CVS to git, it is probable that your workflow will at the start be similar enough to a CVS workflow that it doesn't worth the pain).
Answer: If you're willing to play ball with them in order to appease, you could set it up this way. Or this method. Other than that, I think they're just expecting a single point of entry into the system to access assets.
Depending on access needs, the separated GIT repos might still be the better way to go, as "John Smith" may need access to certain data, but not other data. While "Suzy Que" may be a sys admin needing access to everything.
If you go with a single repo, you might run into issues with your internal access requirements. If it's an "everybody gets full access" type of thing, then I could possibly see their point of view.
Comment: Would be a much better answer if you summarize the methods in the links.
Comment: At present, each developer has access to any source code within the unique CVS repository. So they do not care about developers having access to any source code within a unique Git repo. But this is a good advantage to switch to multiple Git repositories, thanks ;-) However I did not understand what you mean about your branching models as each application has its own branches/tags. Cheers
Comment: Hi Will. After reading again your answer I understand better what you mean (I mean the last two paragraphs). This is a good point to underlying +1 Please could you give more explanation on your first paragraph instead of putting *this* links? Or you may remove your first paragraph... ;) Cheers
Answer: Git migration help page from Eclipse suggests to reorganize the CVS/SVN directory tree into multiple Git repositories:

Now is a great time to refactor your code structure.
  Map the current CVS/SVN directories, modules, plugins, etc. to their new home in Git.
  Typically, one Git repository (.git) is created for each logical
  grouping of code -- a project, a component, and so on.

The arguments:

The trade-off here is that each additional Git repository
  adds extra overhead to your development process -
  all Git commands and operations happen at the level of a single Git repository.
  On the flip side, each repository user will have an entire copy
  of the repository history, making very large repositories cumbersome
  to work with for casual contributors.
Answer: Git operates on a whole tree at once, not on just the subdirectory you're on.
Let's say you have your project at
C:\MyCode\ProjectABC

And let's say these two files have changed:
C:\MyCode\ProjectABC\stuff.txt
C:\MyCode\ProjectABC\Stuff\MoreStuff\morestuff.txt

When you're in the project root and you do a git status, you'll see these files as having changed:
stuff.txt
Stuff\MoreStuff\morestuff.txt

If you cd to the MoreStuff directory, though, will you see only the morestuff.txt file?  No.  You'll still see both files, relative to your position:
..\..\stuff.txt
morestuff.txt

As a result, if you lump all your projects together in one big ol' Git repository, then every time you go to check in, you'll have to pick from among changes in every project.
Now there could be ways to mitigate that; for instance, you can try to make sure you at least temporarily commit your changes before switching to work on a different project.  But that's a lot of overhead that each person on your team would have to deal with, compared to simply doing it the right way: one Git repository per project.
Comment: Thanks for this argument, I agree ;) But most of the developers used to CVS do not agree, they want this behavior: They want that WinCVS show their changes across all projects instead of trying to remember what project they made a change (if you change several files on many directories about the same fix, you risk to forget to commit one of these files). The [`repo` tool from AOSP](http://code.google.com/p/git-repo/) allow to mix multiple Git repositories and the `repo status` showing changes across all the projects ;) Cheers
Comment: Commands like `git diff` and `git add` take directory arguments that can help with this, if it's a problem for you. Usually though, I find myself with the opposite problem, where I get confused because something has changed that I can't see.


Play Framework website session does not remember form input from previous page

Question: I have a Play framework project that asks for information to be submitted on four pages (i.e., enter information on page 1, click "go to page 2" and continue) and on my local Macbook Pro when I run this application (play run) everything runs perfectly. All the information is saved step by step (I save it using session), so when I go to page 2 and look at HTML like the following:
<input type="hidden" name="myFirstField" value="WhatIwroteOnPage1">
As you can see the value from page 1 is saved on page 2 in the source.
Here is my problem ...
I took this project and scp -r'd it onto a server running CentOS with OpenJDK and the same version of Play (2.1.1) (note my Mac has Java (SE)). However now, for some reason the session isn't saved and in the same situation as before I see the following:
<input type="hidden" name="myFirstField" value="">
So for some reason, none of my information is saved! The only changes I made were:

Changed the database password (the db name and username are the same)

That's it. Other than that the only differences are that I:

Use play -DapplyEvolutions.default=true start instead of play run (but the behaviour is the same with play -DapplyEvolutions.default=true run)
The different Java versions

Does anyone have any idea why this may be happening? Any help is greatly appreciated, this project is quite important and I'm completely lost. Thanks
Answer: Fixed this. Put my Play project (the folder I'm in when I run play start) into my downloaded Play directory (/.../play-2.1.1/)


How to interpret Berlekamp-Massey algorithm?

Question:
I'm trying to find a way to understand the process of the Berlekamp-Massey Algorithm. But I'm struggling in understanding the fourth step of the process, which is $B^{(r+1)}(x) = A^{(r)}/\delta^{(r)}$. I found this algorithm from this paper, "VLSI Architectures for Reed-Solomon Codes: Classic, Nested, Coupled, and Beyond". However, I don't know what this step is doing. Can anyone explain to me the purpose of having this step?
Answer: Too long for a comment.
The Berlekamp Massey algorithm is a tour de force. It has the names of two Shannon award (top information/coding theory award for lifetime contributions) recipients attached and it is quite subtle.
The step you point to is a way of correcting the discrepancy between the sequence the current polynomial would generate and the actual sequence by modifying the polynomial.
Dilip Sarwate has a nice answer on this with somewhat different notation.
Berlekamp-Massey to construct minimal LFSR
The textbooks by Richard Blahut also explain the BM algorithm. The one called "Fast algorithms.." may be the most detailed.
Comment: The explanation is based on the wikepedia derivation. That part i understand. However, this algorithm seems to correct the discrepancy in the future iteration. This part I'm confused.


If photons evolve over time, how can they not have mass?

Question: I was reading about the reason why we think neutrinos have mass, and it said that because they evolve over time, they must have mass because they feel the flow of time.
But don't photons also evolve over time? They get red shifted, isn't that evolution over time?
Comment: The closest thing I can find is: we know neutrinos have mass because they can oscillate between flavors in flight. But that is a _very_ different statement.
Comment: Where did you read this?
Comment: On a lot of different sites like: https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwiRiZu1l_vpAhVq63MBHSMaBDkQFjAEegQIDBAF&url=https%3A%2F%2Fneutrinos.fnal.gov%2Fmysteries%2Fmass%2F&usg=AOvVaw0wVN_io__oiW7smXiUpeZY
Comment: Can you quote the specific part of that site that says that neutrinos must have mass because they feel the flow of time?
Comment: Does this express what you are thinking? (There are problems with it.) If you see someone traveling near the speed of light, there clock runs slowly. If they were traveling at the speed of light, their clock would stop Since light evolves, its clock must not have stopped. It must not travel at the speed of light. Things that don't travel at the speed of light have mass.
Comment: There's an answer to why evolution over time implies mass here: https://physics.stackexchange.com/a/15329/264915
Answer:
they must have mass because they feel the flow of time

This is a badly designed sentence to describe a specific mathematically explained behavior of neutrinos.
Neutrinos with a specific energy and momentum vector ( whose length gives the invariant mass of the particle) as they travel change type of neutrino in an observation called neutrino oscillation.. This observation is dependent on time. There are three kinds of neutrinos whereas there is only one type of photon, so this effect cannot happen to photons.
Comment: Really nice answer.
Answer: If you are talking about photons from galaxies and other distant sources, they are red shifted relative to the rest frame of their source because we are moving away from the source rapidly. The photons have nothing to do with it.


In computer science in the US, is there a bias towards hiring junior faculty straight from PhD programs?

Question: In computer science in the US, is it harder to get employed as a professor if you've had to do post-docs, or if you decided to work in an industrial research lab for several years?
Answer: In many fields these days, it is exactly the opposite: it is hard to get a faculty position until you have spent time as a postdoc.  Graduate students are often considered to be simply too inexperienced to become professors.  It is also the case that in some fields (e.g., biomedical research) postdocs are a source of cheap labor and professor positions are scarce, so there is a "market" that pushes people toward more and more postdoc.
Industrial labs are a different matter: they may effectively count either for or against you, depending on the situation.  In essence: if you are in a postdoc-like position, doing a lot of publications, it's probably in your favor.  If you are mostly doing proprietary research that cannot be published, then it's likely to count against you instead.
Specifically in US computer science, the field is currently in transition: historically, there were few postdocs and much hiring directly from graduate school (my own advisor did not even apply for his post).  Now, however, the field is moving toward more postdocs before professorship.
Comment: In Europe some institutions even formalize this. I have seen junior prof. job announcements that required "between 2 and 8 years after PhD graduation". I have heard that many institutions claim to have been burned by hiring seemingly great people directly out of grad school, which then turned out to be incapable of working on their own agenda.
Comment: @xLeitix Most postings I have seen just require that one has demonstrated the ability to do independent research (with the underlying assumption that this is impossible to demonstrate while working as closely with a supervisor as one does during a PhD). I suppose this might be a difference in fields.


In Order Successor in Binary Search Tree

Question: Given a node in a BST, how does one find the next higher key?
Comment: `if (node->right) return min_tree(node->right);` What if the node has no right sub-tree?
Answer: The general way depends on whether you have a parent link in your nodes or not.
If you store the parent link
Then you pick:

The leftmost child of the right child, if your current node has a right child. If the right child has no left child, the right child is your inorder successor.
Navigate up the parent ancestor nodes, and when you find a parent whose left child is the node you're currently at, the parent is the inorder successor of your original node.

If you have right child, do this approach (case 1 above):

If you don't have a right child, do this approach (case 2 above):

If you don't store the parent link
Then you need to run a complete scan of the tree, keeping track of the nodes, usually with a stack, so that you have the information necessary to basically do the same as the first method that relied on the parent link.
Comment: @Lasse V. Karlsen If you don't have parent pointers, you can still find the in-order successor in O(h) time, where h is the height of the tree.  As you find the node, keep track of last node from which you stepped to a left child.  This node is the in-order successor when a node has no right child.  If a node has a right child, the in-order successor is the minimum node in the right subtree.
Comment: great answer! can you please explain the first way once more...in a bit more detail would be great. thank you so much.
Comment: Agree with @JohnKurlak Here's a gist in Java implementing without parent pointers. https://gist.github.com/rcaloras/36f9e5f94f4334e0827c5b52ec0d8115
Comment: Just wanted to add... 1. Basically, the right goes up until the parent's left is the child. However, if there is a right. It will go all the way to the down to the left most in the right side!
Comment: @RCCola This solution is not quite the same as JohnKurlak's because it begins searching from root when the right subtree is null. Here is a jsfiddle example with keeping track of the node last stepped left from: https://jsfiddle.net/e3d8Lvu5/4/
Comment: How does this answer use the fact that the tree is a binary _search_ tree?
Comment: This drawing shows exactly what an in-order successor is. Most of the texts out there does not explain what exactly is an "in-order" node, since the "order" can be left to right also, depending on how you think.
Thank you!
Answer: Python code to the Lasse's answer:
def findNext(node):
  # Case 1
  if node.right != None:
    node = node.right:
    while node.left:
      node = node.left
    return node

  # Case 2
  parent = node.parent
  while parent != None:
    if parent.left == node:
      break
    node = parent
    parent = node.parent
  return parent

Answer: Here's an implementation without the need for parent links or intermediate structures (like a stack). This in-order successor function is a bit different to what most might be looking for since it operates on the key as opposed to the node. Also, it will find a successor of a key even if it is not present in the tree. Not too hard to change if you needed to, however.
public class Node<T extends Comparable<T>> {

private T data;
private Node<T> left;
private Node<T> right;

public Node(T data, Node<T> left, Node<T> right) {
    this.data = data;
    this.left = left;
    this.right = right;
}

/*
 * Returns the left-most node of the current node. If there is no left child, the current node is the left-most.
 */
private Node<T> getLeftMost() {
    Node<T> curr = this;
    while(curr.left != null) curr = curr.left;
    return curr;
}

/*
 * Returns the right-most node of the current node. If there is no right child, the current node is the right-most.
 */
private Node<T> getRightMost() {
    Node<T> curr = this;
    while(curr.right != null) curr = curr.right;
    return curr;
}

/**
 * Returns the in-order successor of the specified key.
 * @param key The key.
 * @return
 */
public T getSuccessor(T key) {
    Node<T> curr = this;
    T successor = null;
    while(curr != null) {
        // If this.data < key, search to the right.
        if(curr.data.compareTo(key) < 0 && curr.right != null) {
            curr = curr.right;
        }
        // If this.data > key, search to the left.
        else if(curr.data.compareTo(key) > 0) {
            // If the right-most on the left side has bigger than the key, search left.
            if(curr.left != null && curr.left.getRightMost().data.compareTo(key) > 0) {
                curr = curr.left;
            }
            // If there's no left, or the right-most on the left branch is smaller than the key, we're at the successor.
            else {
                successor = curr.data;
                curr = null;
            }
        }
        // this.data == key...
        else {
            // so get the right-most data.
            if(curr.right != null) {
                successor = curr.right.getLeftMost().data;
            }
            // there is no successor.
            else {
                successor = null;
            }
            curr = null;
        }
    }
    return successor;
}

public static void main(String[] args) {
    Node<Integer> one, three, five, seven, two, six, four;
    one = new Node<Integer>(Integer.valueOf(1), null, null);
    three = new Node<Integer>(Integer.valueOf(3), null, null);
    five = new Node<Integer>(Integer.valueOf(5), null, null);
    seven = new Node<Integer>(Integer.valueOf(7), null, null);
    two = new Node<Integer>(Integer.valueOf(2), one, three);
    six = new Node<Integer>(Integer.valueOf(6), five, seven);
    four = new Node<Integer>(Integer.valueOf(4), two, six);
    Node<Integer> head = four;
    for(int i = 0; i <= 7; i++) {
        System.out.println(head.getSuccessor(i));
    }
}
}

Answer: Check out here : InOrder Successor in a Binary Search Tree

In Binary Tree, Inorder successor of a
  node is the next node in Inorder
  traversal of the Binary Tree. Inorder
  Successor is NULL for the last node in
  Inoorder traversal. In Binary Search
  Tree, Inorder Successor of an input
  node can also be defined as the node
  with the smallest key greater than the
  key of input node.
Comment: This algorithm depends on the parent link, the implementation if you don't have that is quite different.
Answer: With Binary Search Tree, the algorithm to find the next highest node of a given node is basically finding the lowest node of the right sub-tree of that node.
The algorithm can just be simply:

Start with the right child of the given node (make it the temporary current node)
If the current node has no left child, it is the next highest node.
If the current node has a left child, make it the current node.

Repeat 2 and 3 until we find next highest node.
Comment: In a tree with three nodes, a parent and two children, this algorithm would fail on the left child. It ignores walking back up the tree.
Answer: we dont need parent link or stack to find the in order successor in O(log n) (assuming balanced tree).
Keep a temporary variable with the most recent value encountered in the inorder traversal that is larger than the key. if inorder traversal finds that the node does not have a right child, then this would be the inorder successor. else, the leftmost descendant of the right child.
Answer: C++ solution assuming Nodes have left, right, and parent pointers:
This illustrates the function Node* getNextNodeInOrder(Node) which returns the next key of the binary search tree in-order.
#include <cstdlib>
#include <iostream>
using namespace std;

struct Node{
    int data;
    Node *parent;
    Node *left, *right;
};

Node *createNode(int data){
    Node *node =  new Node();
    node->data = data;
    node->left = node->right = NULL;
    return node;
}

Node* getFirstRightParent(Node *node){
    if (node->parent == NULL)
        return NULL;

    while (node->parent != NULL && node->parent->left != node){
        node = node->parent;
    }
    return node->parent;
}
Node* getLeftMostRightChild(Node *node){
    node = node->right;
    while (node->left != NULL){
        node = node->left;
    }
    return node;
}
Node *getNextNodeInOrder(Node *node){
    //if you pass in the last Node this will return NULL
    if (node->right != NULL)
        return getLeftMostRightChild(node);
    else
        return getFirstRightParent(node);
}
void inOrderPrint(Node *root)
{
    if (root->left != NULL) inOrderPrint(root->left);
    cout << root->data << " ";
    if (root->right != NULL) inOrderPrint(root->right);
}

int main(int argc, char** argv) {
    //Purpose of this program is to demonstrate the function getNextNodeInOrder
    //of a binary tree in-order.  Below the tree is listed with the order
    //of the items in-order.  1 is the beginning, 11 is the end.  If you
    //pass in the node 4, getNextNode returns the node for 5, the next in the
    //sequence.

    //test tree:
    //
    //        4
    //      /    \
    //     2      11
    //    / \     /
    //   1  3    10
    //          /
    //         5
    //          \
    //           6
    //            \
    //             8
    //            / \
    //           7  9

    Node *root = createNode(4);
    root->parent = NULL;

    root->left = createNode(2);
    root->left->parent = root;

    root->right = createNode(11);
    root->right->parent = root;

    root->left->left = createNode(1);
    root->left->left->parent = root->left;

    root->right->left = createNode(10);
    root->right->left->parent = root->right;

    root->left->right = createNode(3);
    root->left->right->parent = root->left;

    root->right->left->left = createNode(5);
    root->right->left->left->parent = root->right->left;

    root->right->left->left->right = createNode(6);
    root->right->left->left->right->parent = root->right->left->left;

    root->right->left->left->right->right = createNode(8);
    root->right->left->left->right->right->parent =
            root->right->left->left->right;

    root->right->left->left->right->right->left = createNode(7);
    root->right->left->left->right->right->left->parent =
            root->right->left->left->right->right;

    root->right->left->left->right->right->right = createNode(9);
    root->right->left->left->right->right->right->parent =
            root->right->left->left->right->right;

    inOrderPrint(root);

    //UNIT TESTING FOLLOWS

    cout << endl << "unit tests: " << endl;

    if (getNextNodeInOrder(root)->data != 5)
        cout << "failed01" << endl;
    else
        cout << "passed01" << endl;

    if (getNextNodeInOrder(root->right) != NULL)
        cout << "failed02" << endl;
    else
        cout << "passed02" << endl;

    if (getNextNodeInOrder(root->right->left)->data != 11)
        cout << "failed03" << endl;
    else
        cout << "passed03" << endl;

    if (getNextNodeInOrder(root->left)->data != 3)
        cout << "failed04" << endl;
    else
        cout << "passed04" << endl;

    if (getNextNodeInOrder(root->left->left)->data != 2)
        cout << "failed05" << endl;
    else
        cout << "passed05" << endl;

    if (getNextNodeInOrder(root->left->right)->data != 4)
        cout << "failed06" << endl;
    else
        cout << "passed06" << endl;

    if (getNextNodeInOrder(root->right->left->left)->data != 6)
        cout << "failed07" << endl;
    else
        cout << "passed07" << endl;

    if (getNextNodeInOrder(root->right->left->left->right)->data != 7)
        cout << "failed08 it came up with: " <<
          getNextNodeInOrder(root->right->left->left->right)->data << endl;
    else
        cout << "passed08" << endl;

    if (getNextNodeInOrder(root->right->left->left->right->right)->data != 9)
        cout << "failed09 it came up with: "
          << getNextNodeInOrder(root->right->left->left->right->right)->data
          << endl;
    else
        cout << "passed09" << endl;

    return 0;
}

Which prints:
1 2 3 4 5 6 7 8 9 10 11

unit tests:
passed01
passed02
passed03
passed04
passed05
passed06
passed07
passed08
passed09

Answer: You can read additional info here(Rus lung)
Node next(Node x)
   if x.right != null
      return minimum(x.right)
   y = x.parent
   while y != null and x == y.right
      x = y
      y = y.parent
   return y

Node prev(Node x)
   if x.left != null
      return maximum(x.left)
   y = x.parent
   while y != null and x == y.left
      x = y
      y = y.parent
   return y

Answer: If we perform a in order traversal then we visit the left subtree, then root node and finally the right subtree for each node in the tree.
Performing a in order traversal will give us the keys of a binary search tree in ascending order, so when we refer to retrieving the in order successor of a node belonging to a binary search tree we mean what would be the next node in the sequence from the given node.
Lets say we have a node R and we want its in order successor we would have the following cases.
[1] The root R has a right node, so all we need to do is to traverse to the left most node of R->right.
[2] The root R has no right node, in this case we traverse back up the tree following the parent links until the node R is a left child of its parent, when this occurs we have the parent node P as the in order successor.
[3] We are at the extreme right node of the tree, in this case there is no in order successor.
The implementation is based on the following node definition
class node
{
private:
node* left;
node* right;
node* parent
int data;

public:
//public interface not shown, these are just setters and getters
.......
};

//go up the tree until we have our root node a left child of its parent
node* getParent(node* root)
{
    if(root->parent == NULL)
        return NULL;

    if(root->parent->left == root)
        return root->parent;
    else
        return getParent(root->parent);
}

node* getLeftMostNode(node* root)
{
    if(root == NULL)
        return NULL;

    node* left = getLeftMostNode(root->left);
    if(left)
        return left;
    return root;
}

//return the in order successor if there is one.
//parameters - root, the node whose in order successor we are 'searching' for
node* getInOrderSucc(node* root)
{
    //no tree, therefore no successor
    if(root == NULL)
        return NULL;

    //if we have a right tree, get its left most node
    if(root->right)
        return getLeftMostNode(root->right);
    else
        //bubble up so the root node becomes the left child of its
        //parent, the parent will be the inorder successor.
        return getParent(root);
}

Answer: We can find the successor in O(log n) without using parent pointers (for a balanced tree).
The idea is very similar to when you have parent pointers.
We can define a recursive function that achieves this as follows:

If the current node is the target, return the left-most / smallest node of its right subtree, if it exists.
Recurse left if the target is smaller than the current node, and right if it's greater.
If the target is to the left and we haven't found a successor yet, return the current node.

Pseudo-code:
Key successor(Node current, Key target):
   if current == null
      return null
   if target == current.key
      if current.right != null
         return leftMost(current.right).key
      else
         return specialKey
   else
      if target < current.key
         s = successor(current.left, target)
         if s == specialKey
            return current.key
         else
            return s
      else
         return successor(current.right, target)

Node leftMost(Node current):
    while current.left != null
       current = current.left
    return current

Live Java demo.
Answer: These answers all seem overly complicated to me.  We really don't need parent pointers or any auxiliary data structures like a stack.  All we need to do is traverse the tree from the root in-order, set a flag as soon as we find the target node, and the next node in the tree that we visit will be the in order successor node.  Here is a quick and dirty routine I wrote up.
Node* FindNextInorderSuccessor(Node* root, int target, bool& done)
{
    if (!root)
        return NULL;

    // go left
    Node* result = FindNextInorderSuccessor(root->left, target, done);
    if (result)
        return result;

    // visit
    if (done)
    {
        // flag is set, this must be our in-order successor node
        return root;
    }
    else
    {
        if (root->value == target)
        {
            // found target node, set flag so that we stop at next node
            done = true;
        }
    }

    // go right
    return FindNextInorderSuccessor(root->right, target, done);
}

Comment: The big O would be O(n), let's do better. See @Lasse V. Karlsen's answer.
Answer: JavaScript solution
- If the given node has a right node, then return the smallest node in the right subtree
- If not, then there are 2 possibilities:
- The given node is a left child of the parent node. If so, return the parent node. Otherwise, the given node is a right child of the parent node. If so, return the right child of the parent node
function nextNode(node) {
  var nextLargest = null;
  if (node.right != null) {
    // Return the smallest item in the right subtree

    nextLargest = node.right;
    while (nextLargest.left !== null) {
      nextLargest = nextLargest.left;
    }

    return nextLargest;
  } else {
    // Node is the left child of the parent
    if (node === node.parent.left) return node.parent;

    // Node is the right child of the parent
    nextLargest = node.parent;
    while (nextLargest.parent !== null && nextLargest !== nextLargest.parent.left) {
      nextLargest = nextLargest.parent
    }
    return nextLargest.parent;
  }
}

Answer: Doing this in Java
TreeNode getSuccessor(TreeNode treeNode) {
    if (treeNode.right != null) {
         return getLeftMostChild(treeNode.right);
    } else {
        TreeNode p = treeNode.parent;
        while (p != null && treeNode == p.right) { // traverse upwards until there is no parent (at the last node of BST and when current treeNode is still the parent's right child
            treeNode = p;
            p = p.parent; // traverse upwards
        }
        return p; // returns the parent node
    }
}

TreeNode getLeftMostChild(TreeNode treeNode) {
    if (treeNode.left == null) {
        return treeNode;
    } else {
        return getLeftMostChild(treeNode.left);
    }
}

Answer: We can divide this in 3 cases:

If the node is a parent: In this case we find if it has a right node and traverse to the leftmost child of the right node. In case the right node has no children then the right node is its inorder successor. If there is no right node we need to move up the tree to find the inorder successor.
If the node is a left child: In this case the parent is the inorder successor.
If the node (call it x) is a right child (of its immediate parent): We traverse up the tree until we find a node whose left subtree has x.

Extreme case: If the node is the rightmost corner node, there is no inorder successor.
Answer: Every "tutorial" that I checked on google and all answers in this thread uses the following logic: "If node doesn't have a right child then its in-order successor will be one of its ancestors. Using parent link keep traveling up until you get the node which is the left child of its parent. Then this parent node will be the in-order successor."
This is the same as thinking "if my parent is bigger than me, then I am the left child" (property of a binary search tree). This means that you can simply walk up the parent chain until the above property is true. Which in my opinion results in a more elegant code.
I guess the reason why everyone is checking "am I the left child" by looking at branches instead of values in the code path that utilizes parent links comes from "borrowing" logic from the no-link-to-parent algorithm.
Also from the included code below we can see there is no need for stack data structure as suggested by other answers.
Following is a simple C++ function that works for both use-cases (with and without utilizing the link to parent).
Node* nextInOrder(const Node *node, bool useParentLink) const
{
    if (!node)
        return nullptr;

    // when has a right sub-tree
    if (node->right) {
        // get left-most node from the right sub-tree
        node = node->right;
        while (node->left)
            node = node->left;
        return node;
    }

    // when does not have a right sub-tree
    if (useParentLink) {
        Node *parent = node->parent;
        while (parent) {
            if (parent->value > node->value)
                return parent;
            parent = parent->parent;
        }
        return nullptr;
    } else {
        Node *nextInOrder = nullptr;
        // 'root' is a class member pointing to the root of the tree
        Node *current = root;
        while (current != node) {
            if (node->value < current->value) {
                nextInOrder = current;
                current = current->left;
            } else {
                current = current->right;
            }
        }
        return nextInOrder;
    }
}

Node* previousInOrder(const Node *node, bool useParentLink) const
{
    if (!node)
        return nullptr;

    // when has a left sub-tree
    if (node->left) {
        // get right-most node from the left sub-tree
        node = node->left;
        while (node->right)
            node = node->right;
        return node;
    }

    // when does not have a left sub-tree
    if (useParentLink) {
        Node *parent = node->parent;
        while (parent) {
            if (parent->value < node->value)
                return parent;
            parent = parent->parent;
        }
        return nullptr;
    } else {
        Node *prevInOrder = nullptr;
        // 'root' is a class member pointing to the root of the tree
        Node *current = root;
        while (current != node) {
            if (node->value < current->value) {
                current = current->left;
            } else {
                prevInOrder = current;
                current = current->right;
            }
        }
        return prevInOrder;
    }
}

Answer: C# implementation (Non recursive!) to find the 'next' node of a given node in a binary search tree where each node has a link to its parent.
    public static Node WhoIsNextInOrder(Node root, Node node)
    {
        if (node.Right != null)
        {
            return GetLeftMost(node.Right);
        }
        else
        {
            Node p = new Node(null,null,-1);
            Node Next = new Node(null, null, -1);
            bool found = false;
            p = FindParent(root, node);
            while (found == false)
                {
                    if (p.Left == node) { Next = p; return Next; }
                    node = p;
                    p = FindParent(root, node);
                }
            return Next;
        }
    }

    public static Node FindParent(Node root, Node node)
    {
        if (root == null || node == null)
        {
            return null;
        }
        else if ( (root.Right != null && root.Right.Value == node.Value) || (root.Left != null && root.Left.Value == node.Value))
        {
            return root;
        }
        else
        {
            Node found = FindParent(root.Right, node);

            if (found == null)
            {
                found = FindParent(root.Left, node);
            }

            return found;
        }
    }

    public static Node GetLeftMost (Node node)
    {
        if (node.Left == null)
        {
            return node;
        }
        return GetLeftMost(node.Left);
    }

Answer: Node successor(int data) {
  return successor(root, data);
}

// look for the successor to data in the tree rooted at curr
private Node successor(Node curr, int data) {
  if (curr == null) {
    return null;
  } else if (data < curr.data) {
    Node suc = successor(curr.left, data);
    // if a successor is found use it otherwise we know this node
    // is the successor since the target node was in this nodes left subtree
    return suc == null ? curr : suc;
  } else if (data > curr.data) {
    return successor(curr.right, data);
  } else {
    // we found the node so the successor might be the min of the right subtree
    return findMin(curr.right);
  }
}

private Node findMin(Node curr) {
  if (curr == null) {
    return null;
  }

  while (curr.left != null) {
    curr = curr.left;
  }

  return curr;
}

Answer: All right I will take a shot since everyone is posting their implementations. This technique is from Introduction To Algorithms book. Basically, you need a way to backtrack to parent nodes from child nodes.
First up, you need a class to represent nodes:
public class TreeNode<V extends Comparable<V>> {
    TreeNode<V> parent;
    TreeNode<V> left;
    TreeNode<V> right;
    V data;

    public TreeNode(TreeNode<V> parent, V data) {
        this.parent = parent;
        this.data = data;
    }

    public void insert(TreeNode<V> parent, V data) {
        if (data.compareTo(this.data) < 0) {
            if (left == null) {
                left = new TreeNode<>(parent, data);
            } else {
                left.insert(left, data);
            }
        } else if (data.compareTo(this.data) > 0) {
            if (right == null) {
                right = new TreeNode<>(parent, data);
            } else {
                right.insert(right, data);
            }
        }
        // ignore duplicates
    }

    @Override
    public String toString() {
        return data + " -> [parent: " + (parent != null ? parent.data : null) + "]";
    }
}

You can have another class to run the operations:
public class BinarySearchTree<E extends Comparable<E>> {

    private TreeNode<E> root;

    public void insert(E data) {
        if (root == null) {
            root = new TreeNode<>(null, data);
        } else {
            root.insert(root, data);
        }
    }

    public TreeNode<E> successor(TreeNode<E> x) {
        if (x != null && x.right != null) {
            return min(x.right);
        }
        TreeNode<E> y = x.parent;
        while (y != null && x == y.right) {
            x = y;
            y = y.parent;
        }
        return y;
    }

    public TreeNode<E> min() {
        return min(root);
    }

    private TreeNode<E> min(TreeNode<E> node) {
        if (node.left != null) {
            return min(node.left);
        }
        return node;
    }

    public TreeNode<E> predecessor(TreeNode<E> x) {
        if(x != null && x.left != null) {
            return max(x.left);
        }

        TreeNode<E> y = x.parent;
        while(y != null && x == y.left) {
            x = y;
            y = y.parent;
        }
        return y;
    }

    public TreeNode<E> max() {
        return max(root);
    }

    private TreeNode<E> max(TreeNode<E> node) {
        if (node.right != null) {
            return max(node.right);
        }
        return node;
    }

}

The idea of finding an accessor is:

if right-subtree is not null, find the minimum value in right-subtree.
else, keep going up the tree till you get to a node that's a left child of its parent.

And for finding a predecessor, it's vice versa.
You can find a complete working example on my GitHub in this package.
Answer: In general, queries about n-th smallest (order statistic) element in a tree can be achieved in O(log n) time using an order statistic tree. One implementation is in GNU's C++ extensions: Policy-Based Data Structures. See this CodeForces blog for usage.
The way this is achieved is simply by storing an additional value at each node of a self-balancing tree that is the size of the subtree rooted at that node. Then operations Select(i) which finds the i-th smallest element and Rank(x) which finds the index such that x is the i-th smallest element can be implemented in logarithmic time complexity; see CLRS or the Wikipedia page. Then the query is simply Select(Rank(x)+1).


11 month old Kitty won't eat

Question: I know y'all probably get this alot. I'm a new cat owner. Ive had him for about 13 hours now. He's so good and loving already. He's definitely not used to the environment he's in. He's got his tail through his legs when he walks about. When I or my spouse come in though, he's very loving and sweet. He literally won't leave us alone. I've tried feeding him by hand. I've tried treats. The person we adopted from says his stomach is sensitive and he only eats food with chicken flavor. We have like 9 different wet foods, two dry, and some chicken flavored dental treats. He sniffs at it, looks like he's about to bite, then he turns around and flops over for belly rubs (sometimes) or just lays down as close as he can to my side. Is this normal? Like do I just wait a few hours? I don't want lil Shiloh to go without food for a day..
Comment: Welcome to pets.SE! Have a look into thid answer and please let us know, if it answers your question too: [Is this normal kitten behavior for the first day in a new home](https://pets.stackexchange.com/questions/23224/is-this-normal-first-day-home-behavior-for-my-kitten-or-should-i-be-concerned/23270?r=SearchResults#23270)
Answer: According to Blog.Feliway.com,

They don't have a routine
Kittens need to eat regularly to support their growth and energy needs! And while some owners may want to leave food out for their cats all the time, having food to graze on won't help your pet develop a clear routine - or could cause your kitten to under or over eat.
To ensure your kitty is only hungry at the right times, create a feeding schedule and keep to this routine. Kittens of around 8 weeks old should be fed three to four times a day, reducing this at 12 weeks to three times a day - in the morning, middle of the day, and again at night just before bed time.
Keep in mind that kittens will often want to use the litter tray straight after eating so this is a great time to reinforce some litter tray training!

They're not used to the food
You can feed your kitten either dried food, canned food or a combination. However as we've mentioned, feeding your kitten the same food that they are already used to will help to limit their stress as they adjust to life with you. If you do want to change their food, make sure any adjustments are gradual - slowly mix the new food with the old and transition over a few days so that your pet doesn't have a sudden change, feel stressed, or go off eating altogether. Making occasional changes to your pet's diet, up to 4 times a year, can also add some variety, help you discover their favourites and prevent any dietary issues or allergies. If your kitty still seems reluctant, try warming their food for a few seconds in the microwave - heat will release the scent of the food and entice your kitty to eat up! Always make sure that the food isn't too hot before serving it to your kitty - don't make the food piping hot, just warm!

And more helpful items on this website.
Comment: Just copying and pasting a random chunk of a website that was found by googling the question title doesn't necessarily help.
Comment: from the website The User is not authorized to:
- copy, distribute (including copies), modify or falsify in any way all or part of the elements of this Website / Application

11 month old Kitty won't eat


What information is significant in a company's 10Q?

Question: From a quantitative point of view which information is significant, what can be ignored?
Answer: From the following 10-Q information, the bold highlighted rows are most significant:

Net sales
Cost of sales
Gross margin
Operating expenses:

Research and development
Selling, general and administrative
Total operating expenses

Operating income
Other income/(expense), net
Income before provision for income taxes
Provision for income taxes
Net income
Earnings per Share

Basic
Diluted

Shares used in computing earnings per share:

Basic
Diluted

Cash dividends declared per share

But keep in mind: this selection is not frozen in time. Some would argue that Net Income is also necessary.
Comment: Not really. By "significant" I mean "relevant" or the key financial figures that most participants look at. If you are looking for a figure for a significant stock price reaction, then EPS (diluted) would be the most relevant number. Comparing the Analyst expectations with the recent published numbers causes is often a stock price reaction. Net sales is also a relevant figure, especially when Company is generating no significant earnings. Amazon for instance, has high Revenue Growth, but they are directly investing their cash into new segments, therefore, their EPS is comparatively small.
Comment: By "significant" I assume you mean in terms of market impact. That these figures will cause a significant stock price reaction of they differ from expectations, i.e a "miss" or a "beat".


Identifying $\int_{-\infty}^\infty e^{i k x} dx$ as Dirac delta distribution

Question: The expression $\int_{-\infty}^\infty e^{i k x} dx$ is sometimes identified as the Dirac delta function. This identification is said "formal" or "symbolic", and some physics texts say that the theory of distribution makes this identification rigorous. So I read some texts on distributions and I think now I understand what delta function is as a distribution. However, I still cannot give any meaninig on the expression as a distribution. Is it possible to give a well defined meaning as a mathematical object to the expression?
Comment: @CalvinKhor So you introduce two ways. i) The actually "intended" by the expression may be the distributional Fourier transform of 1. ii) Intepreting the improper integral as a special kind of limit introduced in the Wikipedia page makes the expression rigorous. Am I right?
Comment: I'm not sure but I believe: its the inverse Fourier transform of 1, but of course writing it formally as this integral doesn't make sense, so you define as a limit of an approximating sequence in $\mathcal D'$. Check https://en.wikipedia.org/wiki/Oscillatory_integral
Comment: That's my impression but I'm not certain as I've only read about this in passing.
Answer: The way to give meaning to an expression as a distribution is to see its effect on a test function.  If $\phi(x)$ is a test function (a member of the Schwartz space $\mathscr S(\mathbb R)$), then the action of the formal expression $T = \int_{-\infty}^\infty e^{ikx}\; dx$ on $\phi$ is obtained by integration (and switching the order of the integrals):
$$ T(\phi) = \int_{-\infty}^\infty dx \int_{-\infty}^\infty dk \; \phi(k) e^{ikx}
= \int_{-\infty}^\infty dx \; \hat{\phi}(-x/(2\pi)) = 2 \pi \phi(0)$$
Comment: Isn't it still "formal"? There is a distribtion $T$ defined as $\left< T, \phi \right> = \int_{-\infty}^\infty dx \int_{-\infty}^\infty dk \phi(k) e^{ikx}$. Do you mean I have to identify any occurrence of $\int_{-\infty}^\infty e^{ikx} dx$ in an integral with the action of $T$ even if the integral itself is not well defined? For example, $\int_{-\infty}^\infty dk \int_{-\infty}^\infty dx \phi(k) e^{ikx}$ is sometimes found in physics texts but it is meaningless if interpreted as it is.
Answer: $$
   \langle \int_{-R}^{R}e^{ikx}dk,\varphi\rangle=\int_{-\infty}^{\infty}\varphi(x)\int_{-R}^{R}e^{ikx}dkdx \\
            = \int_{-R}^{R}\int_{-\infty}^{\infty}\varphi(x)e^{ikx}dx dk
$$
As $R\rightarrow\infty$ the above tends to $2\pi\varphi(0)$. So the truncated integral converges in the distribution sense to a scalar times the Delta function at $0$:
$$
      \int_{-R}^{R}e^{ikx}dk \rightarrow 2\pi\delta_{0}.
$$
The improper integral converges in the dual. It's an element of $\mathscr{S}^*$.


Wordpress or Drupal Users Report Module

Question: I have to build a site that receives some custom report from my users and store them in a database. The users are able to view their reports and the department administrator comments on it. I was creating this myself using PHP although it was good but it's full of security holes and I get lost after a while when my code grows bigger.
I think if there is a module for drupal or wordpess that can benefit from grouping my users into separate groups that would be much easier.
Does anyone know if there is such plugin or would you recommend me some keywords to search with.
Thanx in advance
Answer: Sounds like Drupal would be a good fit for this. There would be (at least) two roles (one for regular users and one for administrators), and there would be a 'report' content type. Regular users would be able to upload reports and view their own reports and administrators would be able to comment on reports.
Drupal + CCK (and possibly the FileField module if users are uploading document files) would be able to handle all of this pretty easily.
Answer: Drupal with the CCK & FileField modules would work great (as Mike mentioned). Two roles would suffice (admin & regular user).
As for security, make sure to use the latest versions in Drupal 6 & stay on top of when those 2 modules get updated although Drupal makes it super easy for you through site notification. Along the lines of security, you'd want to 'hide' the login box from the homepage & use www.sitename.com/user for your users to login.

Wordpress or Drupal Users Report Module


How to count the number of NEW ids in hive SQL table by date?

Question: I have a table with a bunch of months and ids. I want to count how many NEW ids I've gotten in each month. For example, say I have the following table:
Month | ID
------------
Jan   | 123
Jan   | 456
Jan   | 789
Feb   | 123
Feb   | 101112
Mar   | 456
Mar   | 12345
Mar   | 6789

I want the output to be:
Month | # New IDS
------------------
Jan   | 3
Feb   | 1
Mar   | 2

I'm truly lost on the best way to do this and haven't been able to find anything that's similar to this problem.
Answer: One option uses two levels of aggregation. Assuming that month is of a date datatype (or at least something that can be consistently sorted as a date):
select month, count(*) new_ids
from (select min(month) month from mytable group by id) t
group by month

You can also use window functions:
select month, count(*) new_ids
from (
    select month, row_number() over(partition by id order by month) rn
    from mytable
) t
where rn = 1


Import or open transparent PNG in Illustrator results with black edges

Question: Whenever I open or import a PNG with transparency to Illustrator I get these black pixels along the edges. The only way I've found to get rid of the black pixels is to rasterise it with a white background, if I try rasterise it with transparency preserved the black blocks remain. I do not want to have to replace all of these transparent PNGs with PSDs. It is crucial to my current workflow that I use PNGs because I am using Photoshop Extract Assets; so if I go to Photoshop and make changes to the PNG it automatically extracts the asset and then in turn automatically updates the linked PNG in Illustrator. Another alternative workaround I can think of is to extract to TIFF instead, however, I'm pretty sure you should be able to import transparent PNGs to Illsutrator without problems... so any idea what's causing my problem?
Answer: Possible problem one
This is caused by a pretty central concept that does sometimes crop up. It more commonly a problem in video production but its also good to know when isolating objects form background.
There is no such thing as a transparent pixel. There is only a color and how transparent that pixel is. When you cut color out to form the alpha its contaminated by the matte fringe. So if you have a pixel with 50% black and 50% white and cut it out so its 50% transparent it is still 50% black. This is not visible in all conditions but it is a problem.
So in addition to masking you need to remove the contaminant color from the layer. Now there are tools that do this in the in Layer → Matting sub menu. The different tools use different methods. Whichever is better is up to you and the situation at hand. It is also possible to do this calculation manually for an example why you'd do this see this post.
Possible problem two
If you extract assets with PNG-8 option then your PNG does not have a full alpha channel. Thus the fringe has to be put in as there is only indexed colors but only one level of transparency. While the PNG standard as understood by browsers does indeed make it possible to have 8 bit PNG files with multi level alpha, Adobe does not support this. So youy still need to crunch the images with a external tool.
Comment: Hi, thanks very much for your answer. I guess there is something I don't understand because I'm still having problems. First I checked that I am extracting the assets as PNG-32. Then I tried the same file but this time used the Save For Web and saved it as PNG-24 with transparency (PNG-32). The one that went through the Safe For Web process seems to be working fine, but the Extract Assets method is giving me the same problem.
Comment: Hi, sorry I just thought I should full you in, I'm not trying to extract (deep etch) an object from a background. This is an image that was created from scratch in Photoshop with a transparent background. I think my problem is more related to "Possible problem two" in your answer.
Comment: Please excuse all these comments, I'm sort of figuring things out as I go along. I'm very confused now because I tried the same test I did earlier, but with a different image. This time both the "Save For Web" and "Extract Assets" methods gave me the same problem.
Comment: @IOIIOOIO  is not impossible your problem over exceeds the scope of this answer. But in that case you may need to add some more info.


git pre-commit hook bypass email

Question: I have a pre-commit hook that runs PHP Codesniffer on all files in the staging area. However, sometimes developers bypass this hook by adding --no-verify option to the git commit command. Is there a way I can send an email each time a developer bypasses the hook?
Answer: Too long for a comment, but probably not a complete answer.
Whooph... In the DVCS world everything that happens in a private repo is a private business. You as a team repository administrator can propose them some facilities to enhance and simplify their job, but you shouldn't overcarry.
You, however, can and actually should put some automatic sanity checks on receiving their commits on the team repository side. Likely pre-receive hook is a better place for obligatory checks.
Alternatively, and indeed it's recommended for any "valuable" project, you could set up a more complex system for code review (our team uses gerrit but there're plenty of them including those written in PHP). Thus, your team members will familiarize themselves with other members works, suggest improvements and so on, while robots will perform routine tasks, like checking code-style, running unit- and integration tests and so on.

git pre-commit hook bypass email


How to save label scales?

Question: When I open a QGIS file, QGIS 1.8 resets the scale factors for all labels.  Is there a way to save the file so that it knows to also save the label scales?
Comment: I have a polygon shapefile which represents parcels.  I am labeling the polygons with an attribute containing the parcel ID and I only want the label to show up at scales less than 1:5000 so I set the max scale factor to be 5000.  I zoom in and out to check my settings are correct.  I save and exit.  I open the file again and the scale factors are not set and the labels show up at all scales.
Comment: Which version are you using?  I can't confirm on current development build.
Answer: Label scale works on my stable version of QGIS 1.8. Presumbably it is saved between sessions. Are you familiar with the save icon for the layer vs the save icon for the project file?
Answer: It is strange that, when you save a project, it does not keep the style of the labels as well.
I think aynthing will be better once the (now development) 1.9 version of QGIS will released with the new labelling system. (You can of course install the dev version from the OSGEO installer, I use it daily and I have no stability problem at all)
I would anyway suggest you that, when you are finished with the style editing of a shapefile, to save the style of the shapefile as the "deafult style":
in the style tab of the shapefile "style properties", at the bottom "save as default"
This creates a style file (.qml) assosiated to your shapefile which stores also the label formatting.
In this way anytime you import that shapefile in a project it keeps the style format and the labelling.
hope it helps

How to save label scales?


Taxonomy term missing as type of data to store in new field for content type

Question: I have Drupal 6.2. I added a taxonomy term and I am trying to to add it as a new field to a content type. However, I don't see "taxonomy term" as a "type of data to store" when I try to select a field type.
Answer: Use the Content taxonomy module. It provides a CCK field type for referencing taxonomy terms.
Answer: Visit the Taxonomy administrative page (admin/content/taxonomy), and click on the "edit vocabulary" link for the vocabulary you want to associate with a content type.

On that page, you find the "Content types" field set that allows you to associate the content type for which a vocabulary should be used.


To put/take/place your finger in/into/inside your nose

Question: Which word do you think is appropriate for the following context?
"Jim is very rude. He always puts/takes his finger in/into/inside his nose."
Or, should I say, "He always places his finger inside his nose."?
Edit: I also know the word "nostril". Maybe I should use this word instead of "nose".
Comment: Note that extracting mucus from one's nose is called *nose-picking*. ("He always picks his nose.")
Comment: @userr2684291 Thank you. Can I also say to take out snot from the nose instead of to pick the nose? But I would think it's more impolite.
Comment: You can definitely describe everything in multiple ways, but there's a difference between what you *can* say and what's idiomatic (= natural). *Picking one's nose* is an expression denoting the whole act of a person inserting their finger into the nose and then pulling boogers out of it. *Taking snot out of one's nose* emphasizes the pulling out of boogers. I think a more common verb to use there would be *get* (*get nucus/boogers out of **someone**'s nose*), indicating possible difficulty in doing so. I put *someone* in bold since you don't idiomatically *pick* someone's nose (just your own).
Comment: You're right in saying that *snot* is an impolite way of saying ***nasal** mucus*. (*Booger* just sounds informal, and usually denotes a piece of dried nasal mucus.) I put *nasal* in bold because *mucus* doesn't necessarily mean *nasal mucus*, but it can be clear from the context (*get the mucus out of your nose*) which type you're referring to. Other acceptable, natural ways of saying *getting mucus out of someone's nose* include *getting rid of nasal mucus*, *clearing out mucus in the nose*, *clearing mucus from the nose*, etc.
Comment: Thank you a lot. In addition to getting my answer, I learned some words and phrases like "booger", "clear out mucus in the nose".etc
Answer: Here is a typical sentence describing this activity:

He decided he would have to make do with flicking bogeys again, however when he put his finger up his nose to get some snot his finger got stuck. The Giant's revenge

stick and poke can be used instead of put, and in can be used instead of up, but it is less common. You can also use have or with if the person spends some time with a finger up his nose.
According to this NGRAM, into is rare, and inside does not occur at all.
This is not a polite activity, and the words place and nostril are far too formal.
take is the wrong direction: it would be appropriate for removing a finger from a nose, but not for inserting it.


Simple redundant LAN

Question: I have two switches (Netgear Prosafe FS104's) and want to use these to create a LAN with cheap redundancy. So, if one switch fails, the other can still route traffic between our PCs and maintain communications with the outside world. Each switch has its own internet connection to the outside world. Each PC has only one NIC. I was thinking of splitting the 2 pairs of TxRx lines available on each NIC and sending one pair to each switch. The question is what else would I need to get this to work? All PCs run Linux (Ubuntu).
Answer: End-user computers, generally, do not require this level of redundancy.  You would see this level of fault tolerance in a stacked/chassis setup for something like a server farm. You would have two routing engines, two power supplies, multiple cards and multiple links to that node with 802.1ax (i.e. LACP/PAgP) to help protect you in every instance from an outage.
If you want redundancy, split the network into two. Have half your connections going to one switch, and the other half going to the former.

I was thinking of splitting the 2 pairs of TxRx lines available on
  each NIC and sending one pair to each switch.

This is a very bad idea; not to mention it will not work how your anticipating it will. If you did split the pairs like this, you would only get use out of one set of them. Auto negotiation will allow a single pair to function by autoing down to 100Mb; remember, 100BASE-TX only functions on pairs 1,2,3 and 6.
Comment: "cheap" and "simple" are not generally used in the same sentence as redundancy... considering the redundancy you seem to want really requires more hardware (refuting the cheap) and network failover typically employs properly tuned protocols (refuting the simple). You need to analyze business requirements, either a system is critical enough to shell out the cash to make it awesomely redundant... or it isn't.
Comment: The "PC"s are dataloggers and low-power post-processing boards. The problem with a split network is that a datalogger could fail on one network while the post-processor could fail on another.
Answer: I did some research, and one solution to my problem is to use Parallel Redundant Protocol (see http://wiki.wireshark.org/PRP). This requires a dual-NIC node to participate in the network, but single-NIC can too by using a Redundancy Box or "RedBox", which duplicates an incoming packet and sends it to the two parallel networks. There are commercial RedBox products (eg: http://www.ruggedcom.com/pdfs/datasheets/rs950g_datasheet.pdf), but they are unlikely to be "cheap". I'd need RedBoxes for each participating single-NIC node.
The split-network solution suggested by Fizzle is also not as bad as I thought -- it handles all single-point failure modes. Also, if the FS104's are more reliable than the datalogger & processing nodes, the split network would also handle the 2-point failure mode in my last comment. All I have to do is to write the L3 apps to handle this type of failure.
Answer: if dual nics are possible, then the best solution might be to use an active/passive redundant NIC configuration on your nodes. In this configuraton, nodes use only the primary NIC but can perform tests to determine network availability on each and switch to the secondary if a failure is detected.

Simple redundant LAN


Name of a fantasy book where male character finds a magic absorbing artifact

Question: The basic beginning premise is that a young man, who I think was trained in swordsmanship, finds a magical artifact capable of absorbing energy/magic at the cost of his life/vitality. He's able to extend this ability to his weapons. The setting is high fantasy, and the big bad is someone trying to collect all the artifacts,  which I believe were all based after the main elements. I think the cover had a medallion on it.
Comment: Hi, welcome to SF&F!  When did you read this?  Do you remember what the cover looked like?
Comment: Honorable mention for Elric.
Answer: This is potentially Brent Week's Night Angel Trilogy. Significant  spoilers ahead.
The main character is known by various names, but for the majority of the books is called Azoth or Kyler Stern. By the end of book one he is in control of a magical artifact known as a Ka'kari.
There are a number of these Ka'kari floating around the story. Each is known by its colour and its effect. Many of these effects are elemental in nature. The red Ka'kari is linked to fire and the blue to water.
Azoth is trained as a Wetboy. Very much a magical assassin, but they don't like being called that. Given the medieval setting this requires some significant sword fighting skills.
The Ka'kari Kyler controls spends a lot of type wrapped around his sword. And the Ka'kari is capable of absorbing magic and bringing Kyler back to life... for a price.
There are several big bads within the series, but the Ka'kari are of interest to all of them.
Comment: That's it!!! Thank you so much, read it back in like 2010 and could barely remember anything! Glad you could figure it out from my vague description!


How do I transfer reputation points from one Stack Exchange site to another?

Question: I have earned points on Stack Exchange for Database related. How do I transfer those points to dba.stackexchange?
Answer: You can't.
Your reputation for each site is earned for that site respectively.
Answer:
Reputation is a rough measurement of how much the community trusts
  you; it is earned by convincing your peers that you know what you're
  talking about. The more reputation you earn, the more privileges you
  gain and the more tools you'll have access to on the site - at the
  highest privilege levels, you'll have access to many of the same tools
  available to the site moderators.

If you know programming, does it mean you will be able to talk about bicycles?
Comment: OP specifically asked about transferring reputation from the same domain. The bicycle analogy is a bit of a strawman.
Comment: "If you know programming, does it mean you will be able to talk about bicycles?" ⇒ Why would this be a basis for *preventing* me of fixing a 1-character typo in a bicycle post when I'm more than trusted on stackoverflow?
Comment: Then why does it ask new users to make more edits to get to the required 6 characters? This sounds like reverse logic. If you don't know the subject you may make contextual edits but not typo edits.
Comment: @bruglesco - The communities are separate for a reason, if they were similar enough to warrant reputation transfer between them, they should be a single community.  Doesn't matter if we are talking about Serverfault and SuperUser, or Workplace and Law.
Comment: @Ramhound I am not arguing that it should be an added feature. But the OP specifically wants the reputation they earned under the `database` tag to transfer to dba. Bicycles are a strawman.
Comment: @MarkJeronimus There is a certain community on each Stack Exchange site, and you should leave all edits and corrections to their users.
Answer: The short answer is, you can't. Reputation is specific to each individual site and marks how thorough your knowledge is on the site's subject. While you do earn the association bonus to get past the basic new user restrictions, you have to gain reputation on each specific site to gain the privileges that heavily affect the site's content.
Answer: You simply can't:
My reputation on X site is on X site,
My reputation on Y site is on Y site,
There is no way to change it.
Answer: Just to be different...
You can "effectively" transfer reputation by applying your database expertise to questions on dba.SE.
OTOH, you already have higher rep there than SO, so I don't think it's something you should spend any time worrying about.


Run OpenGL shader on part of a texture

Question: How do I run an OpenGL shader on just a portion of an off screen texture and leave the rest of the texture unmodified? Are there any calls that restrict the sampled pixels to just a rectangle or do I have to filter out the rectangle in the shader code?
Comment: What are you actually trying to achieve? This sounds a bit like a problem you might be creating by using the wrong strategy when rendering to (or using the) render texture.
Answer: Yes, you can restrict rendering to just a rectangle by using either the viewport rect or the scissor rect.  These can be set by the glViewport and glScissor calls, respectively.
The distinction is that setting the viewport will pretend that the viewport is the entire render target.  Any geometry you render will be scaled down to the viewport; the viewport will always extend from -1 to 1 in NDC (post-projective) coordinates.  The scissor rect, on the other hand, doesn't rescale any geometry or alter any coordinates - it simply suppresses rendering to any pixels outside the rect.

Run OpenGL shader on part of a texture


Zero and inverse element in abelian group of extensions of modules

Question: Let $A,B$ be modules. An extension of $A$ by $B$ is a short exact sequence $$B\to E\to A$$. Let $Ext(A,B)$ be a set of equivalence classes of such modules $E$. The book said that this admit an abelian group structure. I would like to confirm is it true that the zero object is the split short exact sequence
$B\to A\oplus B\to A$? I wanna prove this, but I am stuck at making an isomorphism between $E$ and $E\oplus A\oplus B$. And I have no clue about the inverse element of $B\to E\to A$: that is $B\to X\to A$ such that $E\oplus X$ is isomorphic to $A\oplus B$. Any help is appreciated.
Comment: You can't get an isomorphism between $E$ and $E\oplus A\oplus B$ since these will rarely be isomorphic. You need to look at what the actual sum is on the extensions (it is not just direct sum).
Comment: My thesis contains just this and all the proofs :-)
Comment: @TobiasKildetoft, yes. I think that does not work
Answer: For two extensions
$$A\to E \to B$$
and
$$A\to F \to B$$
we define the sum of them to be be the quotient of the pullback $X$ on the morphisms
$$\pi_e: E\to B$$
$$\pi_f: F\to B$$
with the module
$$N=\{\imath_e(a)\oplus-\imath_f(a):a\in A\}$$
Then the baer sum is $X/N$. Let $A\oplus B$ be given and $E$ an extension, then we have.
$$X=\{(a\oplus b)\oplus e:\pi(a\oplus b)=\pi_e(e)\}$$
$$=\{a\oplus b\oplus e:b=\pi_e(e)\}$$
$$=\{(a\oplus b)\oplus e:b=\pi_e(e)\}$$
$$\cong\{a \oplus e\}$$
$$=A\oplus E$$
and for the submodule we have through a similar reasoning that $N\cong A\cong A\oplus 0$
and taking their quotient you get the rest. I recommend you look into MacLanes book on it.
Comment: The inverse is just the same chain but the negative epimorphism. What is wrong is that you cannot establish them being equivalent through commutative diagrams, like this we can.
Comment: I do not get what is wrong with my definition and why it does not work. I think something should have been missing. But the way you define the zero element works. Thanks.
Comment: I see. Thanks for your explanation :)
Comment: @ChenMLing welcome, it all really boils down to generalizations and commutative diagrams, as i mentioned i did an entire thesis on this :-)


How to select hard to see faces in edit mode?

Question: This model has lots of faces htat are hard to see. Is there any way to select all connected faces of a selected face? Ctrl+L doesn't work.
Comment: maybe the faces are not connected? or there's a problem with your shortcut?
Comment: If they are not connected and they should be, you can try to merge by distance, if they are connected than ctrl and "+" should select all faces that are connected, you just need to hold it long enough
Answer: Normally, in edit-mode you can select connected faces via Ctrl+Num +. This is called growing selection and works for vertices and edges as well. With Ctrl+Num - you can shrink your selection accordingly.
Since Ctrl+L does not work, growing selection will not work either, since your faces clearly are not connected. Maybe you ripped them accidentally. Try selecting all vertices, hit M for Merge, and click By Distance. This should meld all faces together again.


Interpreting mediation, significant beta

Question: I am testing mediation in SPSS, and all Baron Kenny steps are satisfied, but I have problem in last step. When I include mediator, F becomes non significant, but beta is significant and effect is smaller after including moderator. Can I interpret this like mediation?
Sample size is 126. Dependent variable is disease severity (psoriasis), predictor is Cloninger`s temperament dimension (reward dependence), and mediator is avoidant coping with stress.
Comment: Welcome to CrossValidated. It would help those with expertise in this area if you would provide more detail regarding your analysis. If possible, consider posting the relevant output and providing information regarding the model, sample size, and the covariates and outcome of interest.
Comment: I believe the @Lily is referencing: http://web.pdx.edu/~newsomj/da2/ho_mediation.pdf
Comment: @Lily, were you able to satisfy the 1-3 steps listed out in the link I referenced?

"Assuming there are significant relationships from Steps 1 through 3, one proceeds to Step 4. In the
Step 4 model, some form of mediation is supported if the effect of M (path b) remains significant after
controlling for X. If X is no longer significant when M is controlled, the finding supports full mediation.
If X is still significant (i.e., both X and M both significantly predict Y), the finding supports partial
mediation."
Comment: Also, have you considered another model? Your R-squared is super low, meaning your model doesn't have an impact effect in explaining the variance of your dependent variable. A significant F-stat is meaningless if your R-squared is near zero.
Comment: yes, steps 1-3 are satisfied. Does that mean that F can be non significant, and I can interpret this like mediation? I am a bit confused because my mentor tells me that F should be significant, and to me it seemed that does not have.
Answer: I am not an SPSS expert, but from what I am reading from your output you have two models, Model 1 (top) and Model 2 (bottom). Model 2 has an added predictor with a lower F statistic (5.765 --> 2.651). Additionally Model 2 has an R square of 0.067 which is very low. Indicating the model does not have a good impact.
Also, note that for Model 2, your t-statistics are 2.004 (p-val: 0.47) and 1.628 (p-val: 0.106). Both parameters are not significant at the 0.95 confidence level, hence you cannot report
From the reference I've read (http://web.pdx.edu/~newsomj/da2/ho_mediation.pdf)

If X is no longer significant when M is controlled, the finding supports full mediation.
  If X is still significant (i.e., both X and M both significantly predict Y), the finding supports partial
  mediation.

Your mediation factor (the added predictor) is not significant in Model 2. That said, I would not conclude there is a significant mediation factor. In order for you to conclude mediation, both factors have to be significant. Hence, you have two choices.

Rule out the effect of mediation
Lower your confidence level to 0.90, and then you can conclude mediation.

I'd be very cautious with option 2, as your are now modeling your analysis around trying to obtain significant results, vs trying to be as truthful to the data (and null hypothesis) as possible.
If I've misinterpreted something in the output, let me know and I'll adjust my answer.
Thanks
Comment: Thank you for the explanation :) Obviously I will have to interpret this as non significant results.. Option 1 is my other hypothesis :) Although in this case is a similar situation, F is not significant, and the beta is significant :D


SR/LR transceivers Multi-mode/Single-mode

Question: Generally, we have: SR transceivers with multi-mode fiber and LR with single-mode fiber.
Is it possible to use single mode fiber with 10G-SFP-SR transceivers ?
And same question for LR: is it possible to use multimode fiber with 10G-SFP-LR transceivers ?
Answer: No i would not recommend using multimode with singlemode cabling and vice versa. MM to singlemode cabling is probably the worst and might not even work, but SM to multimode cabling might give you a short range because it lets out a lot of light at the edges.
Instead i would use 10GBASE-LRM, (long reach multi-mode) originally specified in IEEE 802.3aq is a port type for multi-mode fiber and uses 1310 nm lasers. It allows distances up to 220 metres (720 ft) on FDDI-grade multi-mode fiber and the same 220m maximum reach on OM1, OM2 and OM3 fiber types.
Most 10GBASE-LRM transceivers also allow distances up to 300 metres (980 ft) on standard single-mode fiber (SMF, G.652), however this is not part of the IEEE or MSA specification.
Answer: You should always use the correct fiber type for the connection required. If you need to run new fiber you need to think ahead of what might be coming. Generally, it doesn't pay to save on fiber as a redeployment a few years later is expensive.
If you have to put up with old fiber and need to squeeze out more performance please add the appropriate details to your question.
Answer: No, you cannot use SR optics with single-mode fiber. You'd be firing a 50/62.5 micron beam at a 9 micron hole; at best 18% of the light will enter the fiber.
Yes, you can use LR optics with short, high quality multi-mode fiber with the use of a "mode conditioning cable". That special section of cable is the Magic(tm) that makes it possible by precisely aligning the 9 micron laser with the 50/62.5 micron fiber. [This procedure is not recommended.]
Comment: 18% wouldn't be so bad. 9^2/50^2 = 3% = -15 dB.
Comment: Assuming the MM laser was properly focused. (hint: it isn't, which is why it's *multi*mode.) Don't believe me? Try it yourself.
Comment: Agreed - SMF optics usually overfill generously, so 18% seems reasonable. But connecting from SMF into MMF you should expect an actual -15 dB power loss.
Answer: I think using a MM fiber with a LR transceiver or a SM fiber with a SR transceiver would adversely affect performance, regardless of the form factor (SFP, QSFP, CFP, etc). The technician/engineer running the fiber for you should be able to confirm that. Normally, I would use a LC duplex or LC-SC fiber for LR-type optic and MPO/MTP fiber connectors for SR-type optic. The number of fiber strands you need for the SR-type optic would depend on the number of optical lanes configured on your transceiver. For SR4 (4x10G or 4x25G), you would need a 12-strand MPO/MTP fiber whereas for a SR10 (10x4G or 10x10G) optic, you would need a 24-strand MPO/MTP fiber. The most widely used operating frequencies are 2.0MHz (OM3) and 4.7MHz (OM4). Another spec to look out for is key-up/key-down or key-up/key-up.