Is the C++ std library platform independent?

Question: I would like to know if some code I write with 'fstream' in C++ will work on all platforms? Is the C++ standard library platform independent or has the headers been rewritten for each platform?
Answer: Both. You can compile a C++ program using fstream for any platform, but the headers are implementation-dependent. They will differ between compilers and operating systems, but they fulfill the purpose they've been designed and specified for.
Answer: The C++ standard library is platform independent. You will, of course, need to recompile your program for each platform on which you want it to run.
Between different platforms or different compiler vendors, the actual headers themselves may be different, but they should all provide exactly the same set of services.
Answer: The standard library is platform independent. How you use it may not be (endianess with files, etc).
The headers are rewritten for each implementation, but they must conform to the standard.
Answer: <fstream> is part of the Iso C++ standard, so any standard-compliant compiler/toolchain supports it.
Answer: I believe the base behaviour of stl is platform independent. However, the implementation is not platform indifferent. Hence some behaviour will be different.
For example, try to make a string initiates from a null char*, like s = f(), and f() returns a char* null. On Redhat, an exception will be thrown; but on Ubuntu, it will just segfault.
Answer: And file systems (and their file naming conventions) vary from one system to another. For instance, some (non Unix) file systems are case insensitive, but mot of them are.
And the conventions dictating the file names are widely different.
So while using the standard C++ library will help a lot on portability, there are differences which you should take account of.
Cheers.


Recs on getting started with Django on Heroku, with Pycharm

Question: I've been trying for a couple of days to get my first Django app up on Heroku, mainly following Heroku's instructions (https://devcenter.heroku.com/articles/getting-started-with-django —
(The background: for those interested, I'm a Django newbie who's created his first app and I thought I'd put it online to show it off as part of my portfolio. Not so easy!  My shared-hosting web host said: nothing doing.   So I looked through various things and came on Heroku, which is a bit pricey for me to use as a web host, but at least I could practice deployment.)
But I'm having a great deal of trouble. I deinstalled my regular pythons and installed homebrew and all that, finally got Pycharm to play nicely with my Homebrew python, but can't get gunicorn to work within Pycharm, can't get foreman to work as it can't find gunicorn (although gunicorn is installed into Pycharm's virtual env), etc.
I know both that I don't have a lot of idea what I'm doing (I'm still trying to grok Django) and that it would be difficult for anyone to troubleshoot my situation.  I'm curious to know if anyone can suggest a step-by-step — taking the Heroku link as a starting point up until where it says to run foreman — that I could follow to proceed.  A link would be super-helpful.  I'm a good programmer, but really haven't tackled all these setup intricacies before, or deal with WSGI issues or anything like that).
Thanks, I know it's a bit vague, but I'm a bit blinded by the light at the moment.
Answer: This may not be quite the answer you're looking for, but if you come over and give us a try at PythonAnyhwere.com, we specialise in Python hosting, we provide lots of instructions on how to get going with django, and are very happy to help you if you run into any problems....


Applications of Perfect Matching

Question: I'm exploring some applications of perfect matching and I would like some input. I have found many applications in chemistry (storing information, estimating bond lengths, estimating resonance energy, etc). However, I would like to learn more about its applications in other domains - specifically in the "real world" (by that I mean something relatively widely useful instead of confined to a very strict vertical like a branch of quantum mechanics or graph theory). Thank you in advance!
Comment: There has been a lot of work on kidney transplant matching. In the kidney donation system, if you need kidney, and, say, your sister is willing to donate you a kidney, but you turn out not to be a compatible match with her, there are very often situations where your sister's kidney could be a viable transplant for another patient, whose donor's kidney can be a viable transplant for you. Of course, the donation chain can be even longer. Moreover, there are many complicating factors like how urgently someone needs the transplant.
Comment: The TSP is used in the "real world" quite a bit, and still the best general approximation employs the min-weight perfect matching at a key step.
Comment: Pairing passengers in ridesharing systems like Lyft Line and UberPool can be treated as a maximum matching problem. I don't have any academic references, but it's alluded to here: https://eng.lyft.com/matchmaking-in-lyft-line-part-3-d8f9497c0e51
Comment: These are all great! Thank you very much!
Comment: @YoavKallus I've seen some work on kidney exchange, but I do not recall perfect matchings playing a role there.
Comment: Some answers can be found in this MO question http://mathoverflow.net/q/238995/31310
Answer: Perfect matching is used in combinatorial optimisation / constraint satisfaction for the AllDifferent constraint. Given a set of variables $x_1, \dots, x_n$ with domains $X_1, \dots, X_n \subset A$ finite sets, $AllDifferent(x_1, \dots, x_n)$ is true iff $x_i \neq x_j$ for all $i \neq j$. This turns into a matching problem between the variables $x_i$ and elements of $A$: we put an edge $(i,a)$ if $a \in X_i$, which results in a bipartite graph. Finding an assignment to the variables is equivalent to finding a matching. In reality we don't just want to find an assignment but we want to remove all items from the domains $X_i$ that can never lead to a valid assignment. For example if the domains are $X_1 = \{1,2\}, X_2 = \{1,2\}, X_3 = \{1,2,3\}$ then we can remove $1$ and $2$ from $X_3$ because they can never lead to a valid assignment. You can quickly find all these removeable elements with a variant of the bipartite matching algorithm.
See also Propagation Algorithms for the Alldifferent
Constraint.
Answer:
like to learn more about its applications in other domains - specifically in the "real world" (by that I mean something relatively widely useful instead of confined to a very strict vertical like a branch of quantum mechanics or graph theory)

Just to add an example fitting your request (no chemistry here, and there are more complicated game-theoretic examples, but this is pretty much the easiest non-trivial example): perfect matchings are a concept without which certain perfect-information games could not conveniently be analyzed. Easy example: for any finite simple undirected graph G (not necessarily connected, but the game will perforce unfold in one connected component only), consider the two-player game between player A and B with precisely the following rules: A moves first by choosing an arbitrary vertex v of G. Henceforth, the players must alternatingly choose a vertex-not-yet-chosen, each choice being arbitrary except that the vertex chosen must be adjacent in G to the vertex previously chosen by the other player. (In particular, the two players collaborate in choosing a graph-theoretic path in G.) The player which first cannot legally choose any vertex looses. It can be proved that

if G has a perfect matching, then there exists a winning strategy for B (for B to actually win against a strong player A if B does not know a perfect matching might not be easy for B though; for complicated G this is not a no-brainer)

if B knows (e.g. by having calculated one M beforehand, or by having been given one by an oracle) a perfect matching M of G, then B can use M to always win, no matter how intelligent A is

if G does not have a perfect matching, then there exists a winning strategy for A
(sort-of-symmetrially to above, for A to then actually win against a strong player B, if A does not know a maximum matching to use as a guide, might still not be easy though; for complicated G this is not a no-brainer).

if A knows (e.g. by having calculated one M beforehand, or by having been given one by an oracle) a maximum (then necessarily non-perfect) matching M of G, then A can use M to always win, no matter how intelligent B is.

Remark. In both cases above, if the player having the winning strategy has a perfect (resp. maximum) matching handy, they will win even if they announce to the opponent which matching it is that they use as their guide. This is another twist, and does not go without saying. (There are games where there exists such a "road-map to victory" but the winning player has to keep it secret for the road-map to work. Fancifullily put, the perfect (respectively maximum) matching makes it possible to win against an opponent which is not only infinitely-intelligent, but also clairvoyant.
Relevance to your question. It seems that without the abstract concept "(perfect) matching", analyzing this game would be more difficult, so this is an application of the concept of perfect matching.
Answer: Topological codes in a quantum computer are decoded by a miminum-weight perfect matching algorithm, as discussed for example in this article. We don't yet have an operational quantum computer, but this may well become a "real-world" application of perfect matching in the next decade.
Answer: You may want to check a paper about matching at arXiv:1805.00214.
Even though the general problems are NP-complete or
intractable in layman's terms, one may want to find
triples or quadruples in some special cases.
Such algorithms run in $\mathcal{O}(n \log n)$ time.
Answer: Designs of experiments may use matching. Imagine we have 100 female patients
and 100 male patients. We want to apply some treatment to both groups to see
if there is any difference between the response of male and female patients.
But there may be another variable such as age, as an example. Such a variable
is called a confounding variable and there are prety complicated ways to
define a confounding variable, such as propensity score, etc.
Now we want to pair male and female patients so that the sum of absolute
values of differences in male and female patients within each pair is the
smallest. That would lead to bipartite matching.
We may have 300 patients, age would be the confounding variable, and we may
want to partition them to pairs with ages as close as possible, we mean
the sum of absolute values of differences of ages in each pair. The first
patient in each pair may recieve treatment A, the second one may recieves
reatment B. That would lead to nonbipartite matching.
What if we want to form triples to be able to apply placebo (or perhaps
the usual treatment instead), treatment A, and treatment B. Even though the general problem is NP-complete or, in layman's terms, intractable.
Ask around.
The same would hold for quadruples: placebo, treatment A, treatment B,
interaction AB.
Sincerely,
Josef
Comment: -1 The example is about an application of the bipartite matching, but I don't see how it applies to the case of a perfect one in the edge-theoretic sense.

Applications of Perfect Matching


What are the parameters measure the performance of a rendering?

Question: Let's say I designed a housing model and rendered it using a rendering engine. how can I measure the performance of my rendering?
Comment: Can you narrow down what you want to know about the rendering performance? There can be many metrics and they too will depend on so many factors in the scene (e.g. complexity of shading models)
Answer: I assume you mean performance of the numerical algorithm responsible for generating the image?
Usually the performance of a rendering algorithm is assessed through a pixel-wise comparison with a ground truth, converged image. This image is typically rendered for a very long time using a standard and (ideally) unbiased technique like unidirectional path tracing. For a fixed time and sampling budget, you then run your custom algorithm and track a meaningful error (e.g. relative MSE) between your intermediate image and the ground truth image. Plotting the error over time on a logarithmic scale should give you a sense of how your algorithm is performing.
When comparing algorithms, you need to make sure that you are actually comparing images that were output by the same rendering engine. This is crucial if you want to report a faithful metric, otherwise the comparison is unfair and inherently depends on the implementation. For instance, if rendering engine $A$ takes twice as long as engine $B$ to fetch and load a texture, your reported error will be higher, even though the main algorithm you are testing is the same (assuming you are treating materials as blackboxes). The main downside is that rendering researchers are typically required to implement other algorithms in their engine to report the true performance of their new algorithm.


Lie groups reference which is gentle with differential geometry

Question: I would like to ask if somebody is aware of a textbook or internet lecture notes on Lie groups which are accessible for someone with solid background in (general) group theory and topology, but who is not so strong in differential geometry.
My main background is in functional analysis, but I believe I have a reasonable knowledge of group theory (including topological groups) and of (algebraic and general) topology, but quite limited knowledge of differential geometry. So I would prefere a book which introduces differential geometric concepts as needed during the course.
I am now studying (general infinite-dimensional) unitary representations of locally compact groups, but without reasonable understanding of Lie groups I feel half blind.
Answer: John Stillwell's Naive Lie theory is what you are after.


What are Portable latex facilities?

Question: I am looking for a minimalist Latex installation that can be installed on a USB key.
I also want to use this key on my workstation without interfering with my installation (MikTex).
What do you know?
Comment: Probably duplicate of one of [1](https://tex.stackexchange.com/q/75407)
[2](https://tex.stackexchange.com/q/267986)
[3](https://tex.stackexchange.com/q/81802)
[4](https://tex.stackexchange.com/q/3751)
[5](https://tex.stackexchange.com/q/410192)

. Although I haven't gone through them to see if they're applicable.
Comment: On Windows see here: [https://miktex.org/howto/portable-edition](https://miktex.org/howto/portable-edition)
Comment: Apart from the above link you could also check out https://portableapps.com . There is an older MikTeX installation available, which I used before, including a portable version of TeXStudio. Portableapps helped me a lot using my favorite programs on restricted access computers in class rooms … *don't tell anyone …*
Comment: Actually my question is mostly about a minimalist version of latex.
I will review both proposals.
thank you
Answer: Look at this description of making the TeXLive portable: https://tug.org/texlive/archive/portable-anchor.html
They propose:

Running from USB
You can run the normal TeX Live installation and make the output
directory be a USB stick. Then you do several things:
Use the tl-portable script to run completely from the stick, without
touching the host system at all. As described in the documentation,
tl-portable starts a new shell (command prompt) within which you do
your work.

On the page https://tug.org/texlive/doc/texlive-en/texlive-en.html#x1-420004.2 we can read

4.2 Portable (USB) installations
The -portable installer option (or V command in the text installer or
corresponding GUI option) creates a completely self-contained TeX Live
installation under a common root and forgoes system integration. You
can create such an installation directly on a USB stick, or copy it to
a USB stick afterwards.
Comment: As it's currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer).

What are Portable latex facilities?


Can I get an always-on-top button in windows' titlebar (alongside with minimize/maximize/close buttons)?

Question: I use to use always-on-top windows frequently and make them such by setting the option in windows' right click menu. Can I get this option closer, right in windows' titlebar alongside with minimize/maximize/close buttons?
Answer: You can add such a button to your titlebar, however there is a very strong limitation on it. The issue is that the theme you are using must have an image for it.
In gconf-editor (Alt+F2 and enter gconf-editor), go to /apps/metacity/general and add the value above where ever you like it. eg:
menu:above,minimize,maximize,close

Now you'll probably not see a whole lot of change, since according to this blog post from the metacity developers only a few themes support it. An example of such a theme would be Crux.
Adding that button to the theme yourself will, at first glance, require you to delve into your theme's settings; more precisely its metacity-1 folder. It looks like there you would be have to edit the xml file as well as dropping some image files in the folder.
Answer: You can map a key-binding for this. You can do that by hitting Alt+F2 (to get the run dialog) and running gconf-editor. In gconf-editor, browse to /apps/metacity/window_keybindings and set a key-binding for toggle_above.
I'd expect this key-binding to be changable from System -> Preferences -> Keyboard shorcuts too, but either I'm blind or it's not there for some reason.
Answer: To my knowledge this is not possible on metacity, but it is possible if you use compiz (with emerald), kwin, or icewm (AFAIK). If you don't mind running compiz, you could install emerald and emerald theme manager, and edit the theme (or install another) to use this button.
Another option would be to use ubuntu-tweak (NB: NOT SUPPORTED) and edit your metacity theme to have the menu button (saves a right click :P).
Comment: Unfortunately Compiz is unusable with my graphics card and Metacity is the most stable WM I used with it (even XFWM has issues). As for Ubuntu Tweak - I used it to move the window buttons to the right, but couldn't find an option to add always-on-top button there.
Comment: I said the "menu" button because there is no always on top button. The menu button just saves you a right click :)


Do phone manufacturers use AOSP as their base?

Question: Do phone manufacturers like Samsung use AOSP as their base and customize that, or does Google provide a special vanilla version of Android and they customize that?
Answer: I worked with a couple of OEMs and know for a fact that when the OEMs start off working on a new version of android the Software Configuration team picks the latest stable version of the AOSP and then various teams start work to put their customizations in place.
So say a Samsung will have the Touchwiz team start work to customize the UX. The Baseband team will route the Radio Interface layer to the proprietary RIL or vendor-Ril as it is sometimes called. It takes months of effort to roll out phones with the latest software. And contect with google minimal. Google does a compatibilty test suite (for new handset launches) upon failure of which Google proactively supports. Google also works very proactively with OEMs on the Nexus line of phones.
Answer: I worked at BlackBerry while they were developing the Priv, and we worked directly with AOSP plus some libraries provided by the chipset manufacturers.  IIRC we also got a little bit of advance access to new versions, but nothing from Google that was developed specially for us or manufacturers in general.
Please note that this is based on my personal opinions/knowledge and I do not represent BlackBerry in any way.
Answer: Other than a few exceptions, such as OnePlus with CyanogenOS, most manufacturers use AOSP code for their base and customize it.


How do I fix a broken floor tile (without replacing it)

Question: I need help in putting the pieces back together for the broken tile if that's still possible. What should I use? Anything I should look out for?
Comment: I believe it is better to buy a new tile than to try to fix it. Even if it looks slightly different shade of the same color it probably won't look quite as bad as a fixed tile. Additionally, if you walk there barefoot you are likely to hurt your feet - either because you misaligned these pieces a tiny bit, or when it inevitably starts chipping because of other stress induced micro cracks.
Comment: How are those 2 pieces supposed to fit that space?
Comment: I notice no grout around this tile or adjacent ones. Have you removed grout in attempt to repair, or did the breakage happen during installation (before the tiles were grouted)?
Comment: I think the grout has been removed prior, since the tiles at the top are still grouted in.
Comment: One thing to consider is why it cracked.  If it cracked because the floor is flexing below it. this kind of fix is unlikely to last for long.
Comment: "all the kings horses and all the kings men... couldn't put humpty together again".
Comment: @DavidPostill the piece sitting on top fits into the corner location when the bottom fragment is pushed all the way to the left.  The piece that would fit in the triangular space remaining isn't shown.  (Hopefully it's just off camera and not a pile of sand/gravel.)
Answer: Remove the loose pieces. remove the grout, dull the broken edges with a file.
scrape/abrade away the tile cement, place fresh tile cement   set the pieces in the cement and press down with a board to level them, one the thinset has set re-grout.
Taping the pieces together on the front side of the tile may make reinstalling it easier, you could also glue them together with cyanoacrylate ("superglue")
Comment: Dull the edges? Why? Supergluing the tile together as it is has the best chance of hiding the appearance of the cracks. They should fit together perfectly.
Comment: to prevent injury.
Comment: another option if impossible to match would be to remove a row of tiles and create a border pattern and hopefully be able to remove one fully intact that could be used to replace the broken one.  depends a bit on how much coverage the tile setter achieved when they were put down.
Answer: Get a complete tile from under or behind a cupboard or other out-of-the-way place and use that to fill that space then put the broken one - repaired in some fashion as explained in the other answers in the more hidden place.
It won't look so unsightly then.
Comment: Yeah, "get a tile" is comically oversimplified. I've done this job several times. It's much more difficult than it sounds. Also, "the other answers" is problematically vague, especially as new answers are posted. [needs improvement]
Comment: Good idea. +1. Could use some tips on how to remove a tile without breaking it.
Comment: Another option is to look in the garage, shed, laundry cupboards, or sometimes in wall or ceiling space for "spares"  because tiles are often bought in boxes of 5, 6, or 10 so there's a good chance some are left-over.
Answer: This answer assumes that all parts are free of the subfloor.
Ceramic is similar to glass in that broken pieces fit together with high precision. Use super glue (cyanoacrylate) to reassemble the tile carefully. The cracks will almost disappear if you have the right position. Be careful to not injure yourself on sharp edges.
Now clean all loose material out of the tile's space and reinstall it with a thin but thorough application of construction adhesive. You'll need to reapply matching grout once that's set hard.
Comment: "broken pieces fit together with high precision" unless, of course, small chips have disappeared over time. It's likely that this was broken by something being dropped on it, which may have also dislodged small chips which may have scattered. Still, an excellent option. +1 Any color difference could be hidden, possibly as simply as by using a colored marker, but that's fodder for a new question.
Comment: Yeah, it's not at all a great situation to not have spares. We're making the best of it.
Answer:
remove the loose pieces.
Use a grout saw to carefully cut the grout around the edges of the tile.
Remove any more loose pieces (esp that lower triangular one).
Try to figure out why it cracked in the first place.  Usually either because the subfloor isn't rigid or due to voids under the tiles.
You can either try to get the big piece up or not.  Best tools to use here are a mini chipper attached to a reciprocating tool, but a sawzall with a masonry saw might be able to get under the remaining tile.
Clean off the bottoms. Look hard for any markings and google aggressively.  If at all possible, buy a new tile, or go to a tile store and try to find a match.  Those look pretty generic, so an educated tile person may be able to find a match better than the internet can.
If you can't replace it, set out the pieces and tape the tops of them together. Now carefully flip the whole thing (pizza peel is helpful) and use some epoxy to glue them back together.  Some say crazy glue, but my experience is that epoxy provides more flexibility and a little more width, which helps.
re-install tile.
Re-grout.  Depending on how much tile you've lost or shattered, it may be quite noticeable.
Repeat the mantra "I will always save a few tiles from each project"
Comment: If OP can't buy a good match tile, then it might suit to buy the same size but completely different colour, and forgo any attempt to colour-match.   Something like a "feature wall" of a different appearance,
Comment: #5, get the big piece up *or not*. +1. If it sounds hollow when you tap on it, maybe try to pull it. If it's in there like swimwear, then leave it.
Answer: This tile appears to be rather thin for a floor tile. If you are using a wall tile, this kind of breakage is to be expected.
You don't say what kind of tile it is - ceramic, porcelain etc
It could be patched up by using grout, if its not in a prominent place, since the grout is quite a close match to the tile colour.
Comment: Getting matching grout may well depend on the original color still being made and/or this not having been a custom mixed color.


How to prevent scan by drupalxray

Question: A website called Drupal X-Ray can detect a Drupal site's Drupal version and modules in use. So if I don't want others to find that information, what can I do?
Answer: You can look at deploying a site and scrubbing it of files like CHANGELOG.txt/INSTALL.txt automatically. Other things, like removing the meta generator tag in the head also can hide that it is Drupal, but nothing is bulletproof. For example, typing 'Drupal' in the browser devtools window is another way to tell if a site is Drupal or not (in most cases). You could also try banning requests originating from that domain/service at the server level.

How to prevent scan by drupalxray


Why include frequency dividers in this PLL circuit?

Question: I found replicated in few sites this PLL diagram and I'm wondering why the authors included frequency dividers on the input and output signal, since the two signals to be compared have the same frequency magnitude? Why make the PLL working at 1:16 frequency?   Any benefit?
Answer: There are many subtleties to PLL design, in addition to whether things will work fast enough.
Obviously, the phase detector (PSD) has to work fast enough. The 3-state PSD in analog's answer requires a time delay in the feedback path. Its linearity improves as the delay increases, so there is a speed tradeoff.
The rest of my answer is going to concentrate on the often overlooked effects of PSD saturation.
A typical phase detector will saturate at a small phase offset. The 3-state saturates at +/- 1 cycle, though other types will often not go that far, and some can be built to go further. This saturation has some interesting consequences.
Let's say the PLL is designed to recover the carrier from an FM modulated signal. If the phase deviation of the signal exceeds the PSD saturation range, then the loop will go non-linear, which could cause problems depending on what the recovered average frequency signal was going to be used for. Putting a /16 divider in front of the PSD effectively moves its saturation level to +/- 16 cycles, so it can tolerate a much larger phase deviation before going non-linear.
Let's say the PLL is designed to rapidly acquire lock when presented with a new signal. Let's assume the PLL requires some particular bandwidth, for noise performance when locked, which means a particular gain round the loop. When far from lock, PSD saturation will limit how fast the loop can be driven towards lock. If, without changing the total gain round the loop, we divide the frequencies by 16 and multiply the analog gain after the PSD by 16, then the total loop gain and so loop dynamics when in lock remains unaltered (can remain essentially unaltered, see comment discussion below). However, the saturated PSD will now drive towards the lock point 16 times faster when out of lock.
As divided PSD like this will result in an increased contribution of PSD noise in the locked bandwidth. This may or may not be relevant in any particular situation. Different PLL applications will have different specifications, and so different tolerance of PSD noise. There is no one-size-fits-all answer.
Comment: @analogsystemsrf Division increases the latency of the loop, so *may* result in a need to reduce the bandwidth for stability. If latency is small, you get the same bandwidth loop if you keep compensate with gain to keep the loop gain constant. My answer was simplified to ignore latency. I sort of agree with you on 3 state linearity. I meant it gets worse as the time reduces, though I agree that the rate it gets better as the time increases becomes asymptotic. I've used 4 state PSDs where no amount of delay increase in 3 state made them linear enough (3 and higher accumulator all digital fracN)
Comment: Neil_UK I like the details of your answer. However, division drops the control bandwidth by (16:1? 4:1) and hurts the frequency response, losing modulation information; perhaps instantaneously changing from 16:1 to 1:1, once locked, will provide the benefit of both divisors. Also, I don't think the "linearity" will continue to improve, once the delay is long enough to let both the FlipFlops reach steady internal node voltages **and** let the Charge Pump switches reach steady internal currents.
Comment: Neil_UK Thanks for the details. Never needed to use the higher-state PFDs. My focus was on predicting the various jitter floors, so we could achieve high-slew-rates (by burning power) only where needed, and have the designs be first-pass-successes.
Answer: If the FlipFlops are working near max clock rate, the internal silicon nodes will not be in steady-state, and the deterministic jitter will be unpleasant to handle. [corrected math error Feb 8, 2019. 63uV should be 6.3uV]
Additionally, some small delay is used in the feedback (reset-the-Flops) path, to ensure the Q outputs have time to produce FULL AMPLITUDE output levels. Like this

simulate this circuit – Schematic created using CircuitLab
How much jitter will the RC delay insert? (assuming the VDD rail is quiet; typical logic has ZERO dB or perhaps 6dB Power Supply Rejection; a risk of slow edges from the RC delay is the increased vulnerability to Rail trash, contributing to deterministic 60/120/1MHz_switch_reg jitter).
The noise voltage of a capacitor is sqrt(K*T/C), and is 20 microVolts RMS for 10 pF(easy to remember). For 100pF, this increases 3.16x to 63 microVolts. <<<==== WRONG. This decreases, to 6.3 microVolts.
To compute the added jitter of this noisy node (which is the input to that NAND2 gate), we need the SlewRate of the RC signal at VDD/2, assuming the gates are biased for VDD/2 switching as linear amplifiers. The initial SlewRate will produce exactly RC=TAU delay; with 5 volt rails and with 100 nanoSec TAU, the edge rate will be 5 volts in 100 nanoseconds or 1v/20nS or 50 milliVolts/nanosecond. If we waited to trip (cross the threshold) to 63% (we expect 50% trip), our slewrate will be exactly 1/e (1/2.718) slower or 37% of initial; since we are (assumed) crossing the (linear-internal-gate amplifier) at 50%, lets avoid the math and simply assume a 2:1 lower slewrate instead of 2.718 slower; this makes the slewrate become 50 mV/nS times 50% or 25 millivolt / nanosecond.
Now we can compute the jitter added by this RC delay.
Tj = Vnoise / SlewRate
TimeJitter = Total Integrated Noise RMS Voltage/ SlewRate at Zero Crossing
Tj= 6.3 microVolts / (25 milliVolts / nanosecond)
Tj = 6.3 microVolts / (25,000 microVolts / nanosecond)
Tj = 6.3/25000 * microVolts/microVolts * 1/(1/nanosecond)
Tj = 1/4,000 nanosecond = 0.25 picoSeconds time jitter, total integrated
The delay bandwidth (100 nanosecond) is 1.6MHz; round up to 4MHz, because of the PI/2 factor (2.5MHz if brick-wall rolloff model) and to make the next math easy.
If we have 4MHz bandwidth, the noise density is 0.25pS/sqrt(4,000,000) or 0.25pS/2,000 = ~~ 0.1 femtosecond/rootHertz RMS additive random noise, up to about 1.6MHz and then rolling off. In other words, 100 attoSeconds/rtHz.
=======================================
Notice the SlewRate is key to setting how the thermal Noise is converted into edge jitter. With the RC delay, we have a predictable SlewEate. What is the SlewRate INSIDE those logic gates? Consider this

simulate this circuit
Comment: As long as the charge pump can completely switch in 9+13.5 = 22.5 nanoSeconds, you may not need any delay. But provide excellent VDD bypassing on the PFD rails and on the ChargePump rails. Avoid ripple. Learn to dampen the VDD.
Comment: If you are going for lower phase noise, I'd be careful using TTL logic. As the internal common-anode junction (where the 2 or 3 or 4 input emitters have their bases shared) rises, that node is SLOW and has high-value resistor pullup (LSTTL has 40Kohm pullup; I don't know about AS internal pullups). Pulldown may be less jitter; I dunno. But Tj = Vnoise/SlewRate still defines the jitter contribution, whether slow-pullup or fast-pulldown; here the jitter will be seriously DIFFERENT, depending upon the edge polarity. Regarding delays --- use 10 nanoSeconds, with a trimmer capacitor to experiment.
Comment: If I would use 74AS74 (9ns max) and 3x serie 74AS00 (4.5ns*3=13.5ns) to lock a frequency of  705KHz (11.2Mhz/16), how should be a "safe" RC delay to avoid dead zone?
Comment: In the circuit (which I'm going to replicate: http://members.chello.nl/~m.heijligers/DAChtml/dig_r2c.pdf ) I don't have any charge pump stage: I just have a LPF (U17) after the PFD. The original scheme doesn't have any delay network after the 74HC00 (U15) nor has any serie gates to delay the signal applied to the latches (74HC74 U14-U13) like you and most of the PLL designs suggest. Now I'm going to improve it by replacing with much faster 74AS logics. I'm wondering now if I need the delay network in that scheme in order to improve it and, if so, how many ns to delay I would need. Thanks
Answer:
Why make the PLL working at 1:16 frequency

quite possibly simply because the phase detector simply doesn't work reliably enough at the VCO frequency itself.
Comment: @GianlucaG, TI's 74HC74 has a propagation delay of 15 ns. If you use it at 10 MHz, the propagation delay is 15% of the period. That could cause a pretty big offset error in the control signal.
Comment: I thought the same. In fact I put in the graph the chips technology making phase detector: But 74HC74 should work at 25MHz, hence should be fast enough for the clock signal (11.2MHz)


Recommended books or articles as introduction to Cluster Analysis?

Question: I'm working on a small (200M) corpus of text, which I want to explore with some cluster analysis. What books or articles on that subject would you recommend?
Answer: It may be worth looking at M.W. Berry's books:

Survey of Text Mining I: Clustering, Classification, and Retrieval (2003)
Survey of Text Mining II: Clustering, Classification, and Retrieval (2008)

They consist of series of applied and review papers. The latest seems to be available as PDF at the following address: http://bit.ly/deNeiy.
Here are few links related to CA as applied to text mining:

Document Topic Generation in Text Mining by Using Cluster Analysis with EROCK
An Approach to Text Mining using Information Extraction

You can also look at Latent Semantic Analysis, but see my response there: Working through a clustering problem.
Answer: Finding Groups in Data. An Introduction to Cluster Analysis from professors Leonard Kaufman and Peter J. Rousseeuw.
I am reading the book and finding it very useful because:

As stated by the authors in the preface:

Our purpose was to write an applied book for the general user. We wanted to make cluster analysis available to people who do not necessarily have a strong mathematical or statistical background.

It provides theoretical content to understand the functions available in the R package Cluster.
Chapters can be read individually according to the cluster method of interest.
 exception is chapter 3, which is built on chapter 2

The book's chapters are:

Introduction
Partitioning Around Medoids (Program PAM).
Clustering Large Applications (Program CLARA).
Fuzzy Analysis (Program FUNNY).
Agglomerative Nesting (Program AGNES).
Divisive Analysis (Program DIANA).
Monothetic Analysis (Program MONA).

References:
Kaufman, L., & Rousseeuw, P. J. (2005). Finding Groups in Data. An Introduction to Cluster Analysis (p. 342). John Wiley & Sons Inc.
Maechler, M. (2013). Cluster Analysis Extended Rousseeuw et al. CRAN.
Comment: This book indeed provides a nice overview of the field. It focuses on a few algorithms/methods (e.g. the well-known silhouette, which happens to have been designed by one of the book's authors) and covers them extensively. It also comes with some code, but 1990 style. FYI: [full table of contents](https://www.quora.com/Data-Analysis/What-are-the-best-books-on-cluster-analysis/answer/Franck-Dernoncourt).
Answer: This chapter of Introduction to Data Mining is available online and gives a nice overview.
Comment: And [here](https://www-users.cs.umn.edu/~kumar001/dmbook/ch7_clustering.pdf) is the link to the 2nd edition (2018).
Answer: Cluster Analysis by Brian S. Everitt is a nice book length applied treatment of Cluster Analysis.
Answer: Another in-depth book worth looking at:
Handbook of Cluster Analysis by Hennig et al. (2015)
Answer: Not specifically about text-mining, but I quite liked "Exploratory Data Analysis with MATLAB" by Martinez and Martinez.
Answer: From an statistical viewpoint there is Model-Based Clustering and Classification for Data Science which uses R for the examples. The book is by  Charles Bouveyron et al (2019)
Answer: I am not sure what software you use, but this book is a good one if you are using R. It covers many common unsupervised learning algorithms with good examples!


Work with large number of features for machine learning with pandas and sklearn

Question: I'm relatively new to data science and I'm working with a large dataset. It has lots of rows and around 270 features after removing features with a lot of nan valuew and encoding categorical features. And when I run logistic regression using sklearn, my computer runs out of ram and crashes. How do I handle huge datasets like these?
Comment: Can you post the dimension of your dataset?
Answer: I'm assuming you already have made feature selection so all your ~200 features are the ones that describe your target
So particularly for models that use SGD you can train your model in batches i.e adding new observations each time
In your case if using python you can make usage of SGDClassfiier with loss = log to optimize logistic regression cost function, and use the method partial_fit.
You may need to do something like this:
chunksize = 5
clf = SGDClassifier(loss='log', penalty="l2", random_state = 42)

for train in pd.read_csv("train.csv", chunksize=chunksize, iterator=True):
    X = train[features_columns]
    Y = train["target"]
    clf.partial_fit(X, Y)

Answer: Running models on all your available variables may not be the deal, since you'd have too much variables not directly linked to your result, and you might lose performance (you flood your model with unnecessary info, so it's lost and can't find direct and necessary one). You should start trying to produce the model starting with only a few variables you think show the most interest in your problem. Then, you'll have to make feature selection (Select the variables you want to put in your model) so you know which set would bring the best models. There are a lot of feature selection algorithms, you'll easily find some more info about them elsewhere.
Answer: Run a PCA on or LDA your data set. Here is some sample code to start with.
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

from sklearn.datasets import load_breast_cancer
cancer = load_breast_cancer()
df = pd.DataFrame(data=cancer.data, columns=cancer.feature_names)
df.head()

X = df.values
X.shape

from sklearn.preprocessing import StandardScaler

# It is essential to perform feature scaling before running PCA if there is a significant difference in
# the scale between the features of the dataset; for example, one feature ranges in values between 0 and 1
# and another between 100 and 1,000. PCA is very sensitive to the relative ranges of the original features.
# We can apply z-score standardization to get all features into the same scale by using Scikit-learn
# StandardScaler() class which is in the preprocessing submodule in Scikit-learn.
scaler = StandardScaler()
scaler.fit(X)
X_scaled = scaler.transform(X)

from sklearn.decomposition import PCA
pca_30 = PCA(n_components=30, random_state=2020)
pca_30.fit(X_scaled)
X_pca_30 = pca_30.transform(X_scaled)

print('variance explained by all 30 components = ', sum(pca_30.explained_variance_ratio_ * 100))

# The first component alone captures about 44.27% of the variability in the dataset and the second component alone captures about 18.97% of the variability in the dataset and so on.
pca_30.explained_variance_ratio_ * 100

np.cumsum(pca_30.explained_variance_ratio_ * 100)

plt.plot(np.cumsum(pca_30.explained_variance_ratio_))
plt.xlabel('number of components')
plt.ylabel('explained variance')

print(np.cumsum(pca_30.explained_variance_ratio_ * 100)[0])
print(np.cumsum(pca_30.explained_variance_ratio_ * 100)[1])
print(np.cumsum(pca_30.explained_variance_ratio_ * 100)[2])

# You can see that the first 10 principal components keep about 95.1% of the variability in the
# dataset while reducing 20 (30–10) features in the dataset. That's great. The remaining 20 features
# only contain less than 5% of the variability in data.

# two principal components
pca_2 = PCA(n_components=2, random_state=2020)
pca_2.fit(X_scaled)
X_pca_2 = pca_2.transform(X_scaled)

plt.figure(figsize=(10,10))
sns.scatterplot(x=X_pca_2[:,0], y=X_pca_2[:,1], s=70, hue=cancer.target, palette=['blue','red'])
plt.title('2D Scatterplot of 63% of Variability Captured')
plt.xlabel('First Principal Component')
plt.ylabel('Second Principal Component')

# three principal components
pca_3 = PCA(n_components=3, random_state=2020)
pca_3.fit(X_scaled)
X_pca_3 = pca_3.transform(X_scaled)

from mpl_toolkits import mplot3d
fig = plt.figure(figsize= (12,9))
ax = plt.axes(projection='3d')
sctt = ax.scatter3D(X_pca_3[:,0], X_pca_3[:,1], X_pca_3[:,2], c=cancer.target, s=50, alpha=0.6)
plt.title('3D Scatterplot of 72% of Variability Captured')
plt.xlabel('First Principal Component')
plt.ylabel('Second Principal Component')

pca_95 = PCA(n_components=.95, random_state=2020)
pca_95.fit(X_scaled)
X_pca_95 = pca_95.transform(X_scaled)

# This means that the algorithm has found 10 principal components to preserve 95% of the variability in
# the data. The X_pca_95 array holds the values of all 10 principal components.
X_pca_95.shape

df_new = pd.DataFrame(X_pca_95, columns=['PC1','PC2','PC3','PC4','PC5','PC6','PC7','PC8','PC9','PC10'])
df_new['label'] = cancer.target
df_new

Relevant link.
https://towardsdatascience.com/principal-component-analysis-pca-with-scikit-learn-1e84a0c731b0


Problem with iMessage "Delivered" status

Question: For some recipients when I send an iMessage (blue blox) I get a "Delivered" message below it.  However, with other users the "Delivered" box never appears.  I know one option is that their phone may be off, but I know this is not the case because I get a response. Why does the "Delivered" status appear on some iMessages, but not on others when I know the message has been received?  Thank you for your help.
Comment: Do you try to re-activate iMessage in settings?
Answer: Basically, your message has been sent, from your end, to another iPhone or Apple apparatus (it appears in Blue and not Green) but has not been delivered to your recipient.
"Delivered" may not appear for several reasons. The most likely, and also the only I've confirmed, is that the recipient cannot receive the data. This happens when a phone is off or out of service range, obviously. It also happens frequently if they are talking on the phone. When someone is talking voice, and out of a WiFi area, they may not be able to receive text messages, because they may drop or lose some of the data, so it is conveniently held onto for them until they're freed up (i.e. off the phone). It can also happen when WiFi access is spotty, when other apps are running in the background, etc.
The reason you may be experiencing this but still receiving responses is that once a response is sent (in any exchange) that "Delivered" or "Read" message vanishes. Poof. So you're probably just not seeing it change to Delivered to Read before you see a response.
Another possibility that makes sense and could explain both, however unconfirmed by yours truly, is that the "Do Not Disturb" feature is toggled on the recipients phone. As far as I was aware, this simply prevents them from receiving notifications of the messages, but I haven't test it out.
It's one of the above anyway for sure.  Hope it helps.


How to convert a file of format tar.gz to tar.bz2?

Question: Like the title says, how do I do this conversion from the Linux console?
Answer: You can combine the two commands as following:
gunzip < file.gz | bzip2 > file.bz2

This will start two processes in parallel, gunzip reading the file.gz file and outputting the non-compressed stream to bizp2 to re-compress it into file.bz2.
This process does not create intermediate files, you'll need to remove the file.gz afterwards (rm file.gz).
Comment: Doesn't seem to work on Mac: `No such file or directory` for the new archive.


Reconnect to mobile via USB without rebooting

Question: I am a developer (using eclipse) and regularly have my Samsung Galaxy SII connected to my PC via a USB cable. A few times per day I will unplug the cable and plug it back in again in order to take phone calls, go to lunch etc. About 4 times out of 5 this is all fine. But one time in 5 the PC fails to properly re-communicate with my mobile and eclipse does not recognise the phone as being connected. Repeatedly unplugging and replugging in makes no difference, the connection is lost. The only way I know to fix it is to reboot my PC - which takes ages!... Is there something else I could try?
Comment: Shouldn't be an issue, certainly isn't here with my Galaxy Nexus, you could try an "adb usb" from the CLI? Unless it's the operating system just not detecting it and loading the drivers. Is this a work machine, does it have any software added to not allow unauthorized USB devices?
Comment: Its my own "work" machine. I don't have software that bars unauthorised USB devices. I'll try adb usb next time it happens.
Comment: I've seen that happen on my machine too. I've never been able to reconnect without a reboot.
Answer: Sometimes my computer does the same thing, though it doesn't come up too often. In those cases, I try plugging the device into a different usb port. Usually it fixes the problem (though the first port is still 'disabled' for that particular device until I reboot).


The Similarity of a Matrix with its Diagonal Matrix of Eigenvalues

Question: When is a matrix $A$ similar to its diagonal matrix $D$ of eigenvalues? Evidently the two matrices have the same eigenvalues, but this by itself is not enough to conclude similarity. If the eigenvalues are distinct, the matrices are similar. If $A$ is diagonalizable, then we have such similarity by definition. Can we say anything better?
Comment: See what you can do with $$  \left( \begin{array}{cc} 1 & 1 \\ 0 & 1  \end{array} \right) $$
Comment: You want to know a criterion of diagonalizability. Are you working in an algebraically closed field?
Answer: You need a basis for the vector space consisting of eigenvectors of the matrix.  Of course, if all eigenvalues are different then their corresponding eigenvectors are independent so form a basis.  But two or more eigenvalues can be the same as long as their corresponding eivenvectors are independent.
Comment: This is what I expected. This question is labeled as a challenge problem in Strang's text, so I thought I had missed something.
Answer: For Will Jagy's example, $\begin{bmatrix}1 & 1 \\ 0 & 1 \end{bmatrix}$ the eigenvalue equation is $\left|\begin{array}{cc} 1- \lambda & 0 \\ 0 & 1- \lambda \end{array}\right|= (1- \lambda)^2= 0$ which has the double root $\lambda= 1$.  What are its eigenvectors?  If $\begin{bmatrix}x \\ y\end{bmatrix}$ is an eigenvector corresponding to  eigenvalue 1 then we must have $\begin{bmatrix}1 & 1 \\  0 &
 1\end{bmatrix}\begin{bmatrix}x \\ y \end{bmatrix}= \begin{bmatrix} x+ y \\  y\end{bmatrix}= \begin{bmatrix}x \\ y\end{bmatrix}$.  We must have x+ y= x and y= y.  The first equation gives y= 0 while the second equation does not give a value for x.  Any vector of the form $\begin{bmatrix} x \\ 0 \end{bmatrix}$ is an eigenvector.  Clearly there is no basis for $R^2$ consisting of eigenvectors so this matrix cannot be diagonalized.
On the other hand, the matrix $\begin{bmatrix}1 & 0 \\ 0 & 1\end{bmatrix}$ already is* diagonal even though its only eigenvalue is 1. There are two independent eigenvectors coorespondng t that eigenvalue, $\begin{bmatrix} 1 \\ 0 \end{bmatrix}$ and $\begin{bmatrix}0 \\ 1 \end{bmatrix}$.


How can I see where the tab stops are in the SQL Server Management Studio editor?

Question: I dictate SQL using speech recognition, and lining things up is a pain. If I could see where the tab stops are it would save me a lot of time.
Comment: @DylanCorriveau, the tag that you edited is already a tag synonym of the tag that was on the question. Flooding the edit review queue with edits on five, six, seven year old questions thta do nothing but change tags adds no value to these posts and wastes reviwer's time - I highly encourage you to stop and to find more impactful editing opportunities if you're interested in helping the community.
Answer: Management Studio supports an undocumented feature that Visual Studio has as well. It adds vertical guide lines to the editor window at specific column locations.
Create a .reg file using the text below and open it to merge it with your registry. This will add a line every 8 characters (up to column 96) in SQL Server 2005. Modify as needed to suit your tab size. It does not appear to support more than 12 lines. The RGB portion of the string is supposed to set the color, but it always displays as black for me. You'll quickly notice why this is an undocumented feature - the lines appear in unwanted locations such as the Messages output window.
<code>Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Microsoft SQL Server\90\Tools\Shell\Text Editor]
"Guides"="RGB(128,0,0) 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96"
</code>
Comment: Thanks for this – and I wanted to remove the pesky vertical lines! I did have a little trouble finding the value in the registry (wasn't quite where the above said it was), but all I did was a registry search for my lines ("80, 100, 120") and eventually I was able to delete the offending entry. Incidentally I got the lines because I tried SSMSBoost, however the lines remained after the "uninstall".
Answer: Perhaps SQL Refactor by Red Gate. You can define the desired layout of the code, and then simply use command "Lay Out SQL".
When you install SQL Refactor it adds extra menu item to the Management Studio main menu. Each command has its keyboard shortcut (e.g. for Lay Out SQL it is Ctrl+B Ctrl+L) so I assume you should be able to assign that command to your speech recognition tool.
SQL Refactor comes with the price but you can be download 14-day full working trial to try it it serves your needs.
Comment: I think my company has this tool (it was included with a package of products). I'll have to take a look and see if it supports our formatting standards.


Why is safe navigation better than using try in Rails?

Question: I'm reading this. What's the benefit of using this:
user&.address&.state

over
user.try(:address).try(:state)

I still don't get it.
Answer: (1) &. is generally shorter than try(...)
Depending on the scenario, this can make your code more readable.
(2) &. is standard Ruby, as opposed to try
The method try is not defined in a Ruby core library but rather in a Rails library. When you are not developing a RoR web app but instead are writing e.g. little helper scripts, this will get relevant pretty fast.
(I prefer Ruby over Bash, for example.)
(3) &. makes debugging easier
The safe traversal operator will throw an error if a nonexistent method is being invoked.
>> "s"&.glubsch
NoMethodError: undefined method `glubsch' for "s":String

Only on nil it will behave leniently:
>> nil&.glubsch
=> nil

The try method will always return nil.
>> "s".try(:glubsch)
=> nil

Note that this is the case with most recent versions of Ruby and Rails.
Now imagine a scenario where a method named glubsch exists. Then you decide to rename that method but forget to rename it in one place. (Sadly, that can happen with ruby...) With the safe traversal operator, you will notice the mistake almost immediately (as soon as that line of code is executed for the first time). The try method however will happily provide you with a nil and you will get a nil related error somewhere downstream in program execution. Figuring out where such a nil came from can be hard at times.
Failing fast and hard with &. makes debugging easier than blithely returning nil with try.
EDIT: There is also the variant try! (with a bang) that behaves the same as &. in this regard. Use that if you don't like &..
(4) What if I don't care if a method is implemented or not?
That would be strange. Since that would be an unexpected way of programming, please make it explicit. For example by fleshing out the two cases (implemented or not) using respond_to? and branch off of that.
(5) What about try's block form?
Instead of a method name, a block can be passed to try. The block will be executed in the context of the receiver; and within the block there is no leniency applied. So with just a single method call, it will acutally behave the same as &..
>> "s".try{ glubsch }
NameError: undefined local variable or method `glubsch' for "s":String

For more complex computations, you might prefer this block form over introducing lots of local variables. E.g. a chain of
foo.try{ glubsch.blam }.try{ bar }.to_s

would allow foo to be nil but require foo.glubsch to return a non-nil value. Then again, you can do the same with the safe traversal operator in a more concise fashion:
foo&.glubsch.blam&.bar.to_s

Using try's block form for complex computations IMHO is a code smell, though, because it impedes readability. When you need to implement complex logic, introduce local variables with descriptive names and maybe use an if to branch off a nil case. Your code will be more maintainable.
HTH!
Comment: Here comes my non-constructive comment of the day: Thanks for not using `foo` as the default variable. `glubsch` is more fun.
Comment: Response is old but just a comment to mean, in the last point, the `try` version and the `&.` version doesn't behaves the same. Example when foo is `nil`: try version will result in `nil.to_s` whereas `&.` version will try to call `blam` on `nil` and raise a NoMethodError
Comment: Actually, the truely equal version with full ruby should be more like `foo&.yield_self { |foo| foo.glubsch.blam }&.bar.to_s` or more readable if it's ok to consider to react the same for false foo as for nil foor: `foo && foo.glubsch.blam&.bar.to_s`
Comment: The example is indeed wrong. Thank's for pointing that out, @firetonton. I'll leave it there as a reminder that complicated chains of method calls are a maintenance nightmare.
Answer: (6) Speed
Safe navigation is almost 4 times faster than using the try method from activesupport
require 'active_support/all'
require 'benchmark'

foo = nil

puts Benchmark.measure { 10_000_000.times { foo.try(:lala) } }
puts Benchmark.measure { 10_000_000.times { foo&.lala } }

Output
  1.310000   0.000000   1.310000 (  1.311835)
  0.360000   0.000000   0.360000 (  0.353127)

Comment: It seems to be 3 times faster on my machine, but you forgot to bench the case when `foo` is actually not nil. So I wrote the following benchmark: https://gist.github.com/alchimere/1cd424ee8b093867a88d82026734c78c and for non-nil objects, `&.` seems to be **8 times faster** than `try`
Answer: I don't think we should be comparing those two things, because they do something else.
Given this example Person class
class Person
  def name
    "John"
  end
end

try
try should be used if you're not sure whether the given method exists on the object or not.
person = Person.new
person.name        # => "John"
person.email       # => NoMethodError: undefined method `email' for #<Person>
person.try(:email) # => nil

&.
Safe nagivation should be used if you're not sure if the object you're calling your method on is nil or not
person = nil
person.name  # => NoMethodError: undefined method `name' for nil:NilClass
person&.name # => nil

You can't use them interchangeably
People often confuse those two methods, because you can use try instead of &.
person = nil
person.name       # => NoMethodError: undefined method `name' for nil:NilClass
person&.name      # => nil
person.try(:name) # => nil

But you cannot use &. instead of try
person = Person.new
person.name        # => "John"
person.email       # => NoMethodError: undefined method `email' for #<Person>
person.try(:email) # => nil
person&.email      # NoMethodError: undefined method `email' for #<Person>


Current, conductors and charge density

Question: Ok i read that the charge (current) entering the conductor is same   as that of charge leaving through the conductor
Means current is same at all the points in a conductor having varying cross section. My question is how?
If the conductor have varying cross section how the current should be same at every point and also at cross sections.  After this i want to ask what is the difference between current and current density. And i also study that that current is directly proportional to area. so the current should need to be high at large cross section?
Comment: A cross section is not a point but a plane
Answer: If a wire becomes thicker the current density goes down.
Current density is current per unit surface.
Current is only proportional to area at constant current density.
Answer: For a start, for a perfect conductor, the current flows on the surface, not in the bulk.
The conservation law is: in = out + accumulated. Any surface separating the source and sink will have a constant flux across it. This is calculated by integrating the dot product of the flux with the surface normal over the surface.
The net current is constant but the current density will vary with geometry.
So lets take a wire of radius r. The circumference (not area) is 2 pi r. Therefore the current density will be proportional to 1/r.
Current density if big enough causes a breakdown in insulation. That is why thicker wires can handle higher currents.
Answer:
If the conductor have varying cross section how the current should be same

Because current is not a per-area measure.
If I send 10 charges-per-second into a wire, then I don't care if they suddenly have more space if the wire widens somewhere. 10 charges must still enter and leave per second at every point. Otherwise charge would accumulate somewhere.
Think of it as a water pipe system. Send in 10 litres-per-second and you will see 10 liters-per second enter and leave every point along the pipe. If only, say, 8 litres-per-second left some point, then that point would accumulate 2 liters every second. That would soon be a lot of water. The pressure would soon be so large that the out-flowing water would increase to fit the 10 litres-per-second - otherwise you either would at some point not be able to press in any more water or the pipe would break.
Same idea goes for electric circuits and wires. Current is analogous to the water flow rate. It doesn't say anything about the shape or size of pipes / wires along the way, it just says "how much" that flows through per second.
This concept is in general called Kirchhoff's current law, by the way.

what is the difference between current and current density

Current density is the same concept, but with area taken into account. Current density is in fact what you originally thought current was. It is charges flowing per second **per area*.

current is directly proportional to area.

No, this is not true.
Current e.g. provided by a battery may be proportional to other parameters such as resistance in a resistor, and such resistance is proportional to area. But it is not a general rule for current.

Current, conductors and charge density


Why do Hindus worship rats and Monkeys?

Question: Why do Hindus Animal Worship ?
Comment: Simple answer hindus practically see god every where even in stone.. they see the inside this there is god here is god, where is not god.. this is highest form spirtual practice.. other religion may or may not accept the presence of God everywhere for those who accept also there is no pratical implementation of the concept.. those who dont accept the omnipresence of God then there god is limited may be not god at all..
Comment: @PrasannaR, "Hindus practically see god everywhere even in stone" - do we Hindus also see god in Shudras?
Comment: Does this answer your question? [What is the main reason behind praying to animals like mice, monkeys and cows?](https://hinduism.stackexchange.com/questions/26714/what-is-the-main-reason-behind-praying-to-animals-like-mice-monkeys-and-cows)
Comment: Yes @iruvar as antaryami, for pooja and other rites there is sanidhana and athistana.. name conscreted places. where you inovke universal prana into the diety and start worshiping the detail. For shudra to be worshipped.. he should have shown all the qualities that he believes in god and sing spontantaneusly about god there were several example in tamilnadu, thiumangzhai alzhwar.. thirupannazhwar and lot many in kannada also kanandasa..
Answer: Hanuman is possibly one of the most fascinating characters of the Ramayana….
He is represented as a monkey because that is a symbolism for the always agitated human mind. Ramayana shows how the agitated mind can be transformed to conquer our kingdom within !!!
The devotion of Hanuman towards Rama us second to none.
Hanuman is a Vanara (Monkey) and is said to be the son of Vayu (Wind). He was born to Anjana and Kesari,
Like most others characters in Ramayana, there is a deep symbolism associated with Lord hanuman as well. Let us look at the symbolism…
Analogical interpretation of Hanuman
Hanuman represents the human mind, seeking self knowledge (Ravana represents a mind driven and infested with multi headed desires for the mundane)
Nature of Mind
Hanuman is said to be the Son of Vayu… subtlest of all material elements (Space and Air)
Mind is born out of subtility is us and so like vayu is always in motion with gusts of thoughts and storms of passion
Hanuman is a Vanara.. always excited and unable to focus on his own
The Mind cannot focus by itself on one thing for too long
The Self Introspection Process
Hanuman first approached Rama in the form of a Brahmin.
The first approach of the mind to the divine starts with performance of rituals or mere recitation… this is the beginning of the process… not the goal
During their search for Sita, a group of Vanaras reaches the southern seashore. Upon encountering the vast ocean, every vanara begins to lament his inability to jump across the water. Hanuman too is saddened at the possible failure of his mission, until the other vanaras and the wise bear Jambavantha begin to extol his virtues. Hanuman then recollects his own powers, enlarges his body, and flies across the ocean.
Jambavan represents intellect which makes us aware of our true potential
The ocean of Ignorance can be crossed only when we become aware of our potential divinity
As we realise the divine nature, the mind grows big, encompassing and accepting all, and realises the power within to cross the ocean of ignorance
Hanuman reaches Lanka and explores the Island of Lanka
The island reveals the source of all desires (Lanka ruled by multi headed Ravana), It represents the deep subconscious which contains the wealth of Sanchita Karma, which may make us wealthy), but also deter us from knowing the true nature of the self. The mind cannot destroy the burden of millions of birth only the Divine Grace can
Hanuman Discovers Sita in Ashoka Vatika
A part of divinity can be discovered by the mind, but the mind alone cannot make the part whole…
Self Realisation - Realisation of our true Nature
Hanuman approaches Rama with the news of Sita in Lanka
The mind now knows that the divine alone can destroy the island of sanchita Karma
Rama crosses the ocean with an army of vanaras and destroys the demon king Ravana
The divine with the army of grace and devotion destroys the source of desires, freeing you from the bondage of desires.
Hanuman picked flew with the Dunagiri Mountains to lanka so that Lakshmana could be revived with the herb Sanjeevani
The Mind can move mountains, when inspired by the divine, There will be challenges in the self introspection process, but the mind will overcome all by the sanjeevani sheer devotion growing on the mountain of mumukshutva.
Hanuman always remains by Rama's side, and Rama residues in Hanuman;s heart
Once the Mind has discovered the divine… the divine graces us and the mnd focusses and is made of the divine only
From what i know, Hinduism is purely symbolic. to begin with, Rats are associated with Lord Ganesha, (Destroyer of Evil, The first to be worshipped amongst Hindu God Pantheon, The King of Good Times). As depicted, a rat is shown either sitting nearby Lord Ganesha (eating sweets) or Lord Ganesha is seen riding the Rat.
As i said, Hinduism is purely symbolic, the symbolism involved here is that a "Rat" signifies our senses. Rats, by nature are considered quite greedy, for everything. on the top of it, they have their incisors growing all the time if they are not nibbling onto something,
Our senses are here, compared to nature of Rat. (our senses rule our judgements and almost everything in our lives.) a natural tendency of senses, is to only get heightened (read incisors of Rat).
Hence, by riding the Rat, lord Ganesha symbolises a control over the senses, which in turn will reap better fruits (See Rat eating sweet)
Now, bringing you back to the original question, I have no idea as to why there is a need to worship Rats( read senses ). Maybe, because they are associated religiously to Lord Ganesha and vice versa. I throw the ball back to your court. :)
Comment: We [insist](https://hinduism.meta.stackexchange.com/q/803/277) on citing some authentic sources while answering questions. [Here](https://hinduism.stackexchange.com/a/15425/277) you can find link to useful resources to get scriptures (shastras).
Answer: Please ignore spelling, grammar and formatting mistakes.
This file is open-source,if you have an GitHub Account you can contribute in editing this file.
This is an  extract from Video of Dharma Speaks .
The many deities within hinduism can often appear strange to the western mind.This is particularly true of the various deities who have the form of animals.

Ganesha has an elephant head
Lord Narasimh is half lion
Haya Griva has the head of a horse
there is Aadi Shesh the snakebed of vishnu then
there is Garuda the bird
lord Varaha a boar there is
Matsya a fish
Kurma
and of course Hanuman a monkey

Why? someone may ask do you worship so many random animals ?
Is this not a sign of the primitive pagan roots of your religion?
symbolism
Ganesha has a big elephant head to represent the immense intelligence needed to discriminate and grow. He has large ears to show that he listens and is all-knowing.His trunk represents strength and flexibility in our temperament.
He has a rope which pulls us to the right place in life
He has a sweet modakam which is the blissful reward of our spiritual practice.
Ganesha rides the rat showing us how spiritual wisdom should be used to
conquer the erratic mind.
The symbolism of the various deities is
a very important feature of bharatiya samskriti.
There are innumerable life lessons and teachings embedded in these forms and indeed the
stories behind them.
But there is a danger that we can become overly obsessed with symbolism rather than truly connecting with him within we may end up superficially trying to interpret him.

learning the meanings behind the forms is very valuable
but it cannot be at the expense of
attempting to know them on a adhyatmic level

the same applies for ritual activity in the temple
it is important to understand why things are being done but the main point of ritual activity is
to connect and build a relationship with god these forms have been envisaged by rishis and sages

their nature has been revealed through the various narratives
and mantras have been ascribed to them that carry their vibration

The various personalities of the divine are portals that take us beyond the material and mental to the transcendent
But this only happens once we embrace and devotionally enjoy them as they are. The great bhakti saints of all the
different deities reached elevated states of consciousness not through obsessing about the symbolism of the forms they worshipped but through surrendering to them in devotion. ( this surrender is different from Islamic notions of surrender)
We commonly believe that such devotion
to these forms is for the ignorant and
naive,
more advanced seekers however should not
bother too much with these sentimental
practices,
and should instead focus on the inner
symbolic meaning.
But actually it is more the other way
for those who feel distant from god,
an intellectual understanding is
important to help build a connection.
It provides a base for the logical mind
and critically keeps us grounded in our
perspective.
But for those who are more evolved such
a connection flows easily
it is not based on interpreting symbols,
but on humility
and a sincerity to know who god is.
When a hindu is asked why ganesha has an
elephant head?,
Rather than immediately
pointing to his symbolic nature
perhaps the right response should be why
shouldn't a manifestation of the divine
have an elephant's head ?
Is there a limitation on how God can
reveal himself?

Animals are as much a part of nature as
humans. So why should he not choose their
characteristics in a divine form.

The paramatma does not have any restrictions on
how he ( using 'he' is wrong according to sanskrit) wishes to be known.
He does not have to conform to the judgments and conditions of our minds
and hinduism recognizes this he can manifest in any form.
This is why we have stones such as the shaligram and plants such as tulsidevi which are
viewed as divine personalities.
In chapter 10 of the Bhagavad-Gita Arjuna yearns to know the truth of how Krishna can be known in this world.
In response Krishna describes his vibhudis or glories Krishna goes on illustrating how he can
be recognized in this material world.
The overall point is his attributes and the breadth of who he is is truly infinite and he is  woven into
nature and at the same time he lies completely beyond it.
This is why Hindu deities carry all kinds of features, including animals.
There is no limit to the expression and beauty of God.
Comment: hey you and I are also animals and my dog worships me :-). Don't you worship a murderer turned sportsman ay? which animal is worshipped when makes a lot of sense ay aahnik ?

Why do Hindus worship rats and Monkeys?


Disposable ip addresses

Question: Is there an internet provider that assigns a random ip address when you connect to the internet and disposes of it when you disconnect?
Comment: What do you exactly mean by 'dispose'? IP addresses (well at least IPv4 addresses) are scarce, no provider would use an address only once and then never again.
Comment: Well if an internet provider had 1000 ip addresses then you would have to connect to the internet 1000 times before you would end up using an ip address you had used previously. For a major isp that has millions of subscribers it would be unlikely you would ever be assigned the same temporary ip address. Also I just heard about a program that takes advantage of comcasts 1 hour of free wifi trial, so every time you connect you use a different ip address piggy backing off Comcast subscribers wifi signals.
Comment: As I said, you need to be specific what you mean by 'dispose'. Any IP address is likely to be reused. Many ISP's do dynamic assignment so you don't necessarily get the same address every time you connect, but it all depends on the ISP's network and their policies. This sounds like an [X/Y question](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem) by the way, which problem are you trying to solve?
Comment: I was just wondering if any isp has a standard policy of providing a different ip address every time you connect.
Comment: Every isp has its own policies ranging from static to dynamic addressing schemes.
Answer: No not really.
You either get a static or dynamic IP.  Obviously static isn't want you want.  However, dynamic IP assign by dhcp are not random.  Each IP in has purchase 1 or more ranges of IP addresses.  Typically handed out by region.
There is a dhcp leases, and when the lease expires it tries to get a new IP, however 99% of the time it just gives you the same one back.
When you disconnect, and later reconnect you get an IP from the pool.  The range of IP is limited, and way to limited to be called random.  Plus some ISP may log these devices.
Disposes, as in never to be re-used by anyone, nope never there are just to few IPv4 left to ever allow an IP to go unused.
Disposed of, as in you never use it again, again IPv4 is too small to allow this.  Chances are in you will eventually get the same IP back again.
Now, IPv6 has 2^128 address vs 2^32.  You might be able to buy blocks of IPv6 and after you used them once resell them and get a different block.  This however, is a lot of work, and records are kept so it wouldn't get you any anonymity.
Also 90% of the internet is IPv4 so if you have an IPv6 nobody on IPv4 can easily communicate with you.  They could get a VPN, but your typically user isn't going to do that just to visit your site.
Answer: Yes, pretty much most of them.
IPV4 addresses are a dwindling resource.
But if you are looking for a way to hide your identity while you rob banks, then don't assume they don't keep records of who had what when.

Disposable ip addresses


Find the cartesian equation of: $r=2\cos\left(\frac {3\theta}{2}\right)$

Question: I've managed to use identities to simplify it down to:
$$r = 2\left(\cos^3\left({\theta\over2}\right)-3\sin\left({\theta\over2}\right)\cos\left({\theta\over2}\right)\right)$$
using trig identities, but I am stuck now. Does this have a Cartesian equivalent?
Answer: Hint.  The difficulty is the half angle.  So:
$$\eqalign{r^2
  &=4\cos^2\Bigl(\frac{3\theta}{2}\Bigr)\cr
  &=2\bigl(1+\cos(3\theta)\bigr)\ .\cr}$$
Now you should be able to write in various ways $\cos(3\theta)$ in terms of $\cos\theta$ or $\sin\theta$ or both, and the rest should not be too difficult.  Good luck!
Comment: Of course! Why didn't I think of squaring the regular half angle identity. Thank you! I'll return when I've finished or run into another issue.
Answer: I want to elaborate on David's answer but please give him the credit...
From David's result
$$
r^2 = 2 ( 4 \cos^3(\theta)- 3 \cos(\theta)+1)$$
Now $\cos(\theta) = x/r$ and hence
$$
r^2 =  {{8\,x^3}\over{r^3}}-{{6\,x}\over{r}}+2$$
cross multiplying we get
$$-8\,x^3+6\,r^2\,x+r^5-2\,r^3=0$$
Now substitute $r =\sqrt{y^2+x^2}$ to get
$$y^4\,\sqrt{y^2+x^2}+2\,x^2\,y^2\,\sqrt{y^2+x^2}-2\,y^2\,\sqrt{y^2+x
 ^2}+x^4\,\sqrt{y^2+x^2}-2\,x^2\,\sqrt{y^2+x^2}+6\,x\,y^2-2\,x^3=0$$
Here is the plot (remember to use $\theta = 0 \cdots 4 \pi$)

The above graph was produced using Octave (a free software similar to Matlab)
Here are the commands:
theta=0:0.001:4*pi;
r=2*cos(3*theta/2);
plot(r.*cos(theta), r.*sin(theta))
print -djpeg keanu.jpg

Added more info in response to OP's question:
You can isolate $\sqrt{y^2+x^2}$, square it to get
$$-y^{10}-5\,x^2\,y^8+4\,y^8-10\,x^4\,y^6+16\,x^2\,y^6-4\,y^6-10\,x^6
 \,y^4\\+24\,x^4\,y^4+24\,x^2\,y^4-5\,x^8\,y^2+16\,x^6\,y^2-36\,x^4\,y^
 2-x^{10}+4\,x^8=0$$
[I used maxima to do the work for me!]
You can sweep $x$ from $-2$ to $2$ and solve for $y$ using "roots" command and plot the result to get the pattern that you see.
This method is not very efficient but can be used for quick checks:
Here is octave script to check the plot. It has some extraneous solutions that have to be pruned (complex roots) but that is a lot more work!
h=@(x)sqrt(roots([-1,4-5*x^2,-10*x^4+16*x^2-4,...
 -10*x^6+24*x^4+24*x^2,...
 -5*x^8+16*x^6-36*x^4,4*x^8-x^10]));
hold on;
for x=-2:0.005:2 plot(x*ones(5,1), h(x), '.'); end
for x=-2:0.005:2 plot(x*ones(5,1), -h(x), '.'); end
hold off

Comment: Thank you for going through and solving this out. I came to the same result.
Comment: When I graph this relation, should it resemble the original polar equation?
Comment: yes, except you have an implicit function to graph.
Comment: When I graphed it using CountourPlot[] in Mathematica, it only appeared as one half of the original graph. However, replacing all the x's with (-x)'s reflected it across the y axis, therefore completing it. Is this just an issue with the square roots present?
Comment: Perhaps, you went for $\theta=0 \cdot \cdot 2 \pi$. You need to go to $4 \pi$ since you have half angles. See my output
Comment: Would you mind sending me your input for that graph?
Comment: Ah, that was a graph of the original $r = 2\cos\left(\frac {3\theta} {2} \right)$. I was referring to the graph of the new Cartesian relation that you concluded with.
Comment: See my updated answer.
Comment: Are the extraneous solutions found between about $y = -0.1$ and $y = 0.1$, as in this graph? http://i.imgur.com/87Iicn4.png


Is "series" Plural or Singular?

Question: Such expressions as

Drama series

and

TV series

are plural or singular?
E.g.

I like to watch drama/TV series or I like to watch a drama/TV series?
Comment: When someone says "There is a series of classes" it doesn't sound right to me but I don't have a formal basis to complain :|
Answer: "Series" can be singular or plural depending on context.  Both of your sentences are therefore correct but different.

I like to watch TV series.

uses series as a plural and means you like to watch a number of different TV shows.

I like to watch a TV series.

uses series as singular and means you like to watch one TV show.
Answer: Nice Question.
The word series is both singular and plural.
Good information from thefreedictionary quoting American Heritage Dictionary as its source:

Series is both a singular and a plural form. When it has the singular sense of "one set," it takes a singular verb, even when series is followed by of and a plural noun: A series of lectures is scheduled. When it has the plural sense of "two or more sets," it takes a plural verb: Two series of lectures are scheduled: one for experts and one for laypeople.

Our concern is series in broadcasting. So,

a set of radio or television programs that deal with the same subject or that have the same characters.* -OALD

Having this said, you watch a TV series. And yes, do consider Nigel's answer if you are specific about one particular program or series.
Answer: It's like the word "fish" — it's both. (Although "fishes" has been used frequently as a reluctantly accepted plural of fish. For example, the slang statement, "sleep with the fishes".)
Comment: Actually, 'fishes' is a proper plural and refers to multiple species of fish. When you say "there are so many fish in that aquarium," the reference is to the QUANTITY of ALL the fish in the tank. If you say "There are so many different fishes in the aquarium.", you are acknowledging species diversity and referring to the many different KINDS of fish in the tank. The same applies to fish as food in the grocery or at a sushi restaurant. e.g. "I have only eaten half of the fishes on this menu." In short, "fish" (pl.) refers to the number of creatures, and "fishes" refers to the number of species.

Is "series" Plural or Singular?


Vacuum energy extraction: What happens to the cosmological constant?

Question: If the vacuum energy is extracted, then what will happen to the cosmological constant? Will it remain the same? .
Comment: Was "our" meant to be "or?"
Comment: Why is this in the low-quality queue? It looks quite good.
Comment: @ben crowell someone edited the question..now is more clear
Comment: Related (not a duplicate/)():     http://physics.stackexchange.com/questions/11800/can-energy-be-taken-out-of-the-qft-vacuum
Answer:
If the vacuum energy is extracted, then what will happen to the cosmological constant? Will it remain the same?

A cosmological constant is one possible description of how dark energy behaves. We don't know the equation of state of dark energy for sure, but current data do seem to be consistent with the hypothesis that it behaves as a cosmological constant, which is also the simplest hypothesis mathematically.
A cosmological constant is constant, and therefore it can't be extracted in the sense of lowering the amount of dark energy in a given cubic meter of space and transforming it into some other, useful form of energy. There are various kooks who claim to have promising ideas about how to do this, the most prominent probably being Myron Evans. They are kooks.
Regardless of the equation of state, general relativity has local conservation of mass-energy (technically expressed by the fact that GR is not self-consistent unless the divergence of the stress-energy tensor is zero). This implies that you can't just locally increase some form of energy (e.g., by doing mechanical work) without decreasing some other form of energy (e.g., dark energy).
On a cosmological scale, it is certainly true in some sense that dark energy causes other forms of energy to appear. It drives the accelerating expansion of the universe, which can be thought of as involving large amounts of kinetic energy. The reason for the qualifiers like "in some sense" and "can be thought of as" is that general relativity doesn't have a global law of conservation of energy that applies to cosmological spacetimes. In fact, there is not even any satisfactory way of defining the total energy of a region of the universe that spans cosmological distances. (The technical statement is that we don't have a measure of mass-energy that is conserved and transforms as a tensor.)
Comment: Just to head it off at the pass: "There are various kooks who claim to have promising ideas about how to do this" These guys invariably bring up the Casimir effect, but a proper understanding of the Casimir effect shows that the force is due to currents in the conducting materials. The fact that the leading order term is independent of the material (a sort of universality) lets you loosely describe it as a vacuum effect, but insulators don't feel a Casimir force. So it is closely analogous to the dispersion forces, and no more mysterious.
Comment: @MichaelBrown : Are you reffering to this [paper](http://arxiv.org/abs/hep-th/0503158) ?
Comment: @Trimok Yes, that's a good one. Thanks. Another one that may interest the OP is [1205.3365](http://arxiv.org/abs/1205.3365), which discusses the cosmological constant problem pedagogically at great length, and explicitly shows that e.g. the Casimir stress energy is very different from the vacuum stress energy.
Comment: @MichaelBrown see this one http://www.google.com/patents/US7379286. It's almost certainly a sophisticated deliberate fraud and I make this comment grounded not on the paper's contents (which are more sophisticated than the wonted unlimited energy claims) but on a draught of the patent I saw several years ago that made me fall off my chair laughing some years ago. There was actually a photo (very seldom in patents) of "the device" and it showed a plain aluminium box with a power cord leading to a fluorescent light bulb. Needless to say, the latter was glowing brightly. The patent was ....
Comment: ... granted, but I suspect one of the examiners ordered the removal of the photo. The fact that one would try to include that bespeaks outright fraud. The company's name "Jovion" is I think a play on "Jovial" and has the same kind of spirit for the names of trusts and entities that Enron used to transfer their debts too: on the balance sheets the names looked reasonable, but on permuting the letters something else was revealed: for example, an "investor" named "M. Yass" in Yemen: swap the space and the "y" and you get "My Ass". This was one of the milder examples I recall.


Unable to connect on premise sql server from Sql Azure db

Question: I have two SQL Server databases:

On-Premise : See the image below.

We have a static IP associated with this server in order to access remotely from other development machines. Machine is deployed in Location A and is accessible from Location B or C which are geographically separated.
To connect using SSMS, from Location B or C we are using IP Address/UserName/Password. Neither instance name is required nor FQDN. Only IP.
On Azure : Another database is on Azure. Hosted as a Service there. No VM. Its migrated from one of our On-Premise database, which was earlier accessible from #1. We are planned to move our all database to azure , but as of now, we need a cross communication for few months, until we migrate completely.

Problem
We are using a linked server in our queries, and they are failing as Azure does not support linked servers. So in order to access on premise from Azure db we are using External/Table and data-sources but still its giving me connectivity issues.
Error

Msg 46823, Level 16, State 1, Line 1
  Error retrieving data from XXX.XXX.157.236.TableBackup.
  The underlying error message received was: 'A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.
  (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)'.

Kindly help me fixing this issue.
Comment: I don't think you mention that, but you can connect to that Azure db using SSMS?
Comment: It seems you are trying to connect using : `provider: Named Pipes Provider` instead of tcp connection.
Answer: My suggestion is to gradually migrate databases from SQL Server on-premises to SQL Azure but keeping the original databases on-premises and have them synchronize with Azure using SQL Data Sync as explained here. You then will be able to access your databases on premises if you need without the latency of linked server or you can access them on SQL Azure if you want.
Alternatively you can use replication as explained here.
Hope this helps.
Regards,
Alberto Morillo


Should a bug fixer know the overall structure what the program does?

Question: I heard that if you maintain a program, you have to study what the code does. Another engineer said it is not necessary. Just use test cases to find out the function that does not work well, modify the code so it handles the new case, as well as the previous ones, and release it. So when fixing bugs, do you have to focus on the bug or think about how the edited code affects the program overall?
Comment: The "other engineer"'s approach doesn't make sense because writing valid test cases involves understanding what the function is supposed to do. Otherwise, you can easily write bad tests that lie to you, telling you the code works when it doesn't. The goal of writing software isn't to pass tests, it's to implement a specification, business logic. Tests are just one tool to help enforce a specification. A "bug" means the program doesn't meet a specification in some capacity. You could fix it by guessing the intended specification, which is sometimes obvious and sometimes not.
Comment: Working "well" is not a well-defined concept (no pun intended) by itself. You have to know *exactly* what the callers of the function you work with expect to give and receive from it, and usually this means you *do* have to understand its larger purpose.
Answer: In order to fix a broken program you need to know both what the program actually does and also what it is supposed to do. The latter comes from some sort of specification, which might, itself, be either executable or prose.
Finding the function that "does not work well" requires knowledge of what it is supposed to do.
It is also a bit (or more) naive to think that an error involves only a single function (or other component). Many errors, including the more sophisticated ones come from faulty interactions between parts.
But generally, a component "works well" if it contributes correctly to the overall design, which implies knowledge of the specification.
In very large and well designed programs, it may be possible to isolate the effect of errors to some subset of components, in which case only the specification of that subset may be necessary to make a correction.
But, small changes without considering the overall effect is quite likely to introduce additional bugs due to unforeseen and unintended interaction effects. This leads to "thrashing" where the bug "fixes" make it worse and worse. A microscopic view is very seldom enough.
FWIW, I'm working on such a situation now. A seemingly small change is leading to a lot of analysis.
Answer: Complete understanding of a large piece of software may be impossible if it is very large. So you end up having to fix bugs on the assumption that your local knowledge of a particular subsystem is adequate.
A major challenge of software architecture is how to structure a system so that a change intended to be local will have no unexpected non-local effects. Since this is hard to do, you may find that locally testing the function isn't sufficient.
In summary: do the best you can with the information available.
Answer: There are two parts to fixing a bug: One, find out what goes wrong, and change some code so it doesn't go wrong. Two, make sure that your code change doesn't affect any other code in your application and makes it go wrong.
For that you don't need to know the complete structure of the program but you need some way to find all places affected. Sometimes a refactoring tool may help: You may be able to select "rename method" and a refactoring tool will show you all the places in your complete application where that method is used (and not an unrelated method that has the same name by coincidence). Doesn't work well if you change code in a library.
Answer: You can sometimes just focus on the test cases, but in reality the one and only thing you care about is "does the program perform correctly for the user."  Tests are only a proxy for this.  They make it easier to locate and isolate the bugs, but the end goal is never just to make the tests pass.
As a redactio ad absurdum, consider how successful you would be if you simply recoded the entire unit under test to do nothing except spit out the right answers to the unit tests, effectively making it one big mock.  Sure, it would pass the tests, but it would certainly not be an acceptable job.
We use tests to isolate the bugs as best as we can, and that makes your job easier.  If most of the behavior you need to worry about is well defined in requirements on the unit under test, then you don't need to worry much about the behavior.
Other bugs are more subtle.  What may pass in the tests may fail when you get to integration testing.  As an example, one of the people I work with has been working on a library that is steeped in mathematics.  All of the equations work flawlessly in math with real numbers, but we don't have real numbers in computing.  We have floating point numbers.  Many of the bugs he is working on are numeric stability issues.  These are delicate holistic beasts.  As he described it, he often is playing "whack a mole," where the resolution of one stability issue introduces another subtle one elsewhere in the pipeline.  For the problems he is solving, he must be aware of the functionality of the whole application.
Answer: The short answer here is that it depends on the bug. Some bugs are of a technical nature (e.g. an index going out of range), whereas other bugs are a misapplication of the intended behavior. The former is probably solvable by any competent developer even if they don't know the application requirements, the latter is probably going to require intimate knowledge of the application requirements to solve.
Additionally, developer seniority and expertise makes a difference. A more experienced developer is likely going to be better able to learn the codebase on the fly than a more junior profile.
The cleanliness of the codebase can further help a developer make sense of the intention of the code without already having prior knowledge.
Overall, many things go into the consideration whether (a) a particular developer is able to go into (b) a particular codebase in order to solve (c) a particular bug. There is no "one size fits all" answer here.

Another engineering said it is not necessary. Just use test cases to find out the function that does not work well, modify the code that it handles the new case as well as the previous ones and release it.

Depending on how far they take this advice, there's two possible answers here.
One interpretation is that they're describing the process of studying what the code does. They're just doing it by reading the tests instead of talking to another dev or reading some documentation, but in actual fact they are "studying what the code does" (which is what they claim you don't need to do).
Another interpretation is that they're not reading the tests to gain understanding, they're just shotgun debugging:

The making of relatively undirected changes to software in the hope that a bug will be perturbed out of existence.

There's a lot to be said about shotgun debugging. It's stupid, but sometimes it does work. When you're stuck and you don't know what to do, shotgun debugging is a great way to try and shake something loose. I'm a firm believer of "if it's stupid and it works, it ain't stupid", which is why I picked the phrasing that I did.
However, just because it might not be stupid does not mean that it is therefore an efficient approach. When the alternative is being stuck, going slowly is still better than standing still. However, if there are smarter ways to skin this proverbial cat, they will almost always be faster and more reliable than shotgun debugging will be.
So it's not that you should never do it, but it should literally be your last resort when all else has failed you.
Additionally, your coworker's assumption that they can divine the source of the bug based on playing around with the test almost entirely relies on the assumption that the test was well written to begin with. This refers back to my original point: in addition to (a), (b) and (c), it very much depends on (d) the particular test suite you find yourself working with (which may or may not be a subset of (b)).
Answer: If there is high coupling, then you have to understand it all.
If low coupling then you don't.
When you make a change, any change, reduce coupling a bit. Not usually a complete rewrite, but make the bit that you worked on better. You may introduce more bugs (5 or 6 compared to 1 or 2), but they will be easy to remove, and you probably won't introduce more bugs at this stage.